diff options
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/shopitems.cpp | 10 | ||||
-rw-r--r-- | src/gui/widgets/shopitems.h | 7 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/gui/widgets/shopitems.cpp b/src/gui/widgets/shopitems.cpp index 85ee0a181..c5bcd88c4 100644 --- a/src/gui/widgets/shopitems.cpp +++ b/src/gui/widgets/shopitems.cpp @@ -101,6 +101,16 @@ void ShopItems::erase(unsigned int i) mShopItems.erase(mShopItems.begin() + i); } +void ShopItems::del(unsigned int i) +{ + if (i >= mShopItems.size()) + return; + + ShopItem *item = *(mShopItems.begin() + i); + mShopItems.erase(mShopItems.begin() + i); + delete item; +} + void ShopItems::clear() { delete_all(mShopItems); diff --git a/src/gui/widgets/shopitems.h b/src/gui/widgets/shopitems.h index cc444fe85..abfcffb71 100644 --- a/src/gui/widgets/shopitems.h +++ b/src/gui/widgets/shopitems.h @@ -96,6 +96,13 @@ class ShopItems : public gcn::ListModel void erase(unsigned int i); /** + * Removes an element from the shop and destroy it. + * + * @param i index to remove + */ + void del(unsigned int i); + + /** * Clears the list of items in the shop. */ void clear(); |