Fix gcc build errors

Originally committed to SVN as r4610.
This commit is contained in:
Thomas Goyne 2010-06-27 03:24:03 +00:00
parent c5c306f90c
commit 5598b787c7
2 changed files with 24 additions and 17 deletions

View file

@ -41,6 +41,7 @@
#ifndef AGI_PRE #ifndef AGI_PRE
#include <algorithm> #include <algorithm>
#include <iterator>
#include <wx/sizer.h> #include <wx/sizer.h>
#endif #endif
@ -1273,31 +1274,33 @@ void BaseGrid::AnnounceActiveLineChanged(AssDialogue *new_line) {
if (batch_level > 0) if (batch_level > 0)
batch_active_line_changed = true; batch_active_line_changed = true;
else else
BaseSelectionController::AnnounceActiveLineChanged(new_line); BaseSelectionController<AssDialogue>::AnnounceActiveLineChanged(new_line);
} }
void BaseGrid::AnnounceSelectedSetChanged(const Selection &lines_added, const Selection &lines_removed) { void BaseGrid::AnnounceSelectedSetChanged(const Selection &lines_added, const Selection &lines_removed) {
if (batch_level > 0) { if (batch_level > 0) {
// Remove all previously added lines that are now removed // Remove all previously added lines that are now removed
for (Selection::iterator it = batch_selection_added.begin(); it != batch_selection_added.end();) { Selection temp;
if (lines_removed.find(*it) != lines_removed.end()) std::set_difference(
it = batch_selection_added.erase(it); batch_selection_added.begin(), batch_selection_added.end(),
else lines_removed.begin(), lines_removed.end(),
++it; std::inserter(temp, temp.begin()));
} std::swap(temp, batch_selection_added);
temp.clear();
// Remove all previously removed lines that are now added // Remove all previously removed lines that are now added
for (Selection::iterator it = batch_selection_removed.begin(); it != batch_selection_removed.end();) { std::set_difference(
if (lines_added.find(*it) != lines_added.end()) batch_selection_removed.begin(), batch_selection_removed.end(),
it = batch_selection_removed.erase(it); lines_added.begin(), lines_added.end(),
else std::inserter(temp, temp.begin()));
++it; std::swap(temp, batch_selection_removed);
}
// Add new stuff to batch sets // Add new stuff to batch sets
batch_selection_added.insert(lines_added.begin(), lines_added.end()); batch_selection_added.insert(lines_added.begin(), lines_added.end());
batch_selection_removed.insert(lines_removed.begin(), lines_removed.end()); batch_selection_removed.insert(lines_removed.begin(), lines_removed.end());
} }
else { else {
BaseSelectionController::AnnounceSelectedSetChanged(lines_added, lines_removed); BaseSelectionController<AssDialogue>::AnnounceSelectedSetChanged(lines_added, lines_removed);
} }
} }

View file

@ -165,14 +165,17 @@ public:
/// be desirable in some special cases such as test drivers. /// be desirable in some special cases such as test drivers.
template <typename ItemDataType> template <typename ItemDataType>
class BaseSelectionController : public SelectionController<ItemDataType> { class BaseSelectionController : public SelectionController<ItemDataType> {
public:
typedef typename SelectionController<ItemDataType>::Selection Selection;
private:
typedef std::set<SelectionListener<ItemDataType> *> SelectionListenerSet; typedef std::set<SelectionListener<ItemDataType> *> SelectionListenerSet;
std::set<SelectionListener<ItemDataType> *> listeners; SelectionListenerSet listeners;
protected: protected:
/// Call OnActiveLineChanged on all listeners /// Call OnActiveLineChanged on all listeners
void AnnounceActiveLineChanged(ItemDataType *new_line) void AnnounceActiveLineChanged(ItemDataType *new_line)
{ {
for (SelectionListenerSet::iterator listener = listeners.begin(); listener != listeners.end(); ++listener) for (typename SelectionListenerSet::iterator listener = listeners.begin(); listener != listeners.end(); ++listener)
{ {
(*listener)->OnActiveLineChanged(new_line); (*listener)->OnActiveLineChanged(new_line);
} }
@ -181,7 +184,7 @@ protected:
/// Call OnSelectedSetChangedon all listeners /// Call OnSelectedSetChangedon all listeners
void AnnounceSelectedSetChanged(const Selection &lines_added, const Selection &lines_removed) void AnnounceSelectedSetChanged(const Selection &lines_added, const Selection &lines_removed)
{ {
for (SelectionListenerSet::iterator listener = listeners.begin(); listener != listeners.end(); ++listener) for (typename SelectionListenerSet::iterator listener = listeners.begin(); listener != listeners.end(); ++listener)
{ {
(*listener)->OnSelectedSetChanged(lines_added, lines_removed); (*listener)->OnSelectedSetChanged(lines_added, lines_removed);
} }
@ -207,6 +210,7 @@ public:
template <typename ItemDataType> template <typename ItemDataType>
class DummySelectionController : public SelectionController<ItemDataType> { class DummySelectionController : public SelectionController<ItemDataType> {
public: public:
typedef typename SelectionController<ItemDataType>::Selection Selection;
virtual ~DummySelectionController() { } virtual ~DummySelectionController() { }
virtual void SetActiveLine(ItemDataType *new_line) { } virtual void SetActiveLine(ItemDataType *new_line) { }
virtual ItemDataType * GetActiveLine() const { return 0; } virtual ItemDataType * GetActiveLine() const { return 0; }