From 22df98c0fe9106642ec983141141c093a275821b Mon Sep 17 00:00:00 2001 From: twanvl Date: Fri, 6 Jul 2007 13:53:13 +0000 Subject: [PATCH] Sorting of card list distributed to all card lists that share the same game. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@504 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/gui/control/card_list.cpp | 9 +++++++++ src/gui/control/card_list.hpp | 2 ++ src/gui/control/item_list.hpp | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gui/control/card_list.cpp b/src/gui/control/card_list.cpp index 3e60a304..a977fb2a 100644 --- a/src/gui/control/card_list.cpp +++ b/src/gui/control/card_list.cpp @@ -224,6 +224,15 @@ void CardListBase::rebuild() { refreshList(); } +void CardListBase::sortBy(long column, bool ascending) { + // sort all card lists for this game + FOR_EACH(card_list, card_lists) { + if (card_list->set && card_list->set->game == set->game) { + card_list->ItemList::sortBy(column, ascending); + } + } +} + // ----------------------------------------------------------------------------- : CardListBase : Columns void CardListBase::storeColumns() { diff --git a/src/gui/control/card_list.hpp b/src/gui/control/card_list.hpp index d45c0bb9..a658c66e 100644 --- a/src/gui/control/card_list.hpp +++ b/src/gui/control/card_list.hpp @@ -84,6 +84,8 @@ class CardListBase : public ItemList, public SetView { virtual void onRebuild() {} /// Can the card list be modified? virtual bool allowModify() const { return false; } + /// Sort all card lists + virtual void sortBy(long column, bool ascending); /// Send an 'item selected' event for the currently selected item (selected_item) virtual void sendEvent(); diff --git a/src/gui/control/item_list.hpp b/src/gui/control/item_list.hpp index 50946d96..89032159 100644 --- a/src/gui/control/item_list.hpp +++ b/src/gui/control/item_list.hpp @@ -66,7 +66,7 @@ class ItemList : public wxListView { /// Return the card at the given position in the sorted list inline const VoidP& getItem(long pos) const { return sorted_list[pos]; } /// Sort by the given column - void sortBy(long column, bool ascending); + virtual void sortBy(long column, bool ascending); /// Refresh the card list (resort, refresh and reselect current item) void refreshList(); /// Set the image of a column header (fixes wx bug)