From 602fd127d09c995bc5470218c862b2cebfc558d5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 3 May 2015 20:09:53 +0300 Subject: Add filter into buy dialogs. --- src/gui/models/shopitems.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/gui/models/shopitems.cpp') diff --git a/src/gui/models/shopitems.cpp b/src/gui/models/shopitems.cpp index 1a9b89994..2fd399cb0 100644 --- a/src/gui/models/shopitems.cpp +++ b/src/gui/models/shopitems.cpp @@ -29,6 +29,7 @@ #include "debug.h" ShopItems::ShopItems(const bool mergeDuplicates) : + mAllShopItems(), mShopItems(), mMergeDuplicates(mergeDuplicates) { @@ -58,6 +59,7 @@ ShopItem *ShopItems::addItem(const int id, { ShopItem *const item = new ShopItem(-1, id, type, color, amount, price); mShopItems.push_back(item); + mAllShopItems.push_back(item); return item; } @@ -72,6 +74,7 @@ ShopItem *ShopItems::addItemNoDup(const int id, { item = new ShopItem(-1, id, type, color, amount, price); mShopItems.push_back(item); + mAllShopItems.push_back(item); } return item; } @@ -95,6 +98,7 @@ ShopItem *ShopItems::addItem2(const int inventoryIndex, { item = new ShopItem(inventoryIndex, id, type, color, quantity, price); mShopItems.push_back(item); + mAllShopItems.push_back(item); } return item; } @@ -127,7 +131,8 @@ void ShopItems::del(const unsigned int i) void ShopItems::clear() { - delete_all(mShopItems); + delete_all(mAllShopItems); + mAllShopItems.clear(); mShopItems.clear(); } @@ -146,3 +151,14 @@ ShopItem *ShopItems::findItem(const int id, const unsigned char color) const return nullptr; } + +void ShopItems::updateList() +{ + mShopItems.clear(); + FOR_EACH (std::vector::iterator, it, mAllShopItems) + { + ShopItem *const item = *it; + if (item && item->isVisible()) + mShopItems.push_back(item); + } +} -- cgit v1.2.3-60-g2f50