summaryrefslogtreecommitdiff
path: root/src/gui/widgets/shopitems.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-08-30 22:53:27 +0300
committerAndrei Karas <akaras@inbox.ru>2012-08-30 22:53:27 +0300
commit5cbd0d2cb7086fda592c00dbc3b07d06af95f080 (patch)
treed36b4ac344f31f34311c7cb7a9a637ed48356e3e /src/gui/widgets/shopitems.cpp
parent4210163dae7d6266923ab11f78b631173c9533e3 (diff)
downloadplus-5cbd0d2cb7086fda592c00dbc3b07d06af95f080.tar.gz
plus-5cbd0d2cb7086fda592c00dbc3b07d06af95f080.tar.bz2
plus-5cbd0d2cb7086fda592c00dbc3b07d06af95f080.tar.xz
plus-5cbd0d2cb7086fda592c00dbc3b07d06af95f080.zip
Add const to more classes.
Diffstat (limited to 'src/gui/widgets/shopitems.cpp')
-rw-r--r--src/gui/widgets/shopitems.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/gui/widgets/shopitems.cpp b/src/gui/widgets/shopitems.cpp
index 5f13e5f71..d91e25304 100644
--- a/src/gui/widgets/shopitems.cpp
+++ b/src/gui/widgets/shopitems.cpp
@@ -28,7 +28,7 @@
#include "debug.h"
-ShopItems::ShopItems(bool mergeDuplicates) :
+ShopItems::ShopItems(const bool mergeDuplicates) :
mMergeDuplicates(mergeDuplicates)
{
}
@@ -43,7 +43,7 @@ int ShopItems::getNumberOfElements()
return static_cast<int>(mShopItems.size());
}
-bool ShopItems::empty()
+bool ShopItems::empty() const
{
return mShopItems.empty();
}
@@ -59,21 +59,23 @@ std::string ShopItems::getElementAt(int i)
return mShopItems.at(i)->getDisplayName();
}
-void ShopItems::addItem(int id, unsigned char color, int amount, int price)
+void ShopItems::addItem(const int id, const unsigned char color,
+ const int amount, const int price)
{
mShopItems.push_back(new ShopItem(-1, id, color, amount, price));
}
-void ShopItems::addItemNoDup(int id, unsigned char color,
- int amount, int price)
+void ShopItems::addItemNoDup(const int id, const unsigned char color,
+ const int amount, const int price)
{
- ShopItem *item = findItem(id, color);
+ const ShopItem *const item = findItem(id, color);
if (!item)
mShopItems.push_back(new ShopItem(-1, id, color, amount, price));
}
-void ShopItems::addItem2(int inventoryIndex, int id, unsigned char color,
- int quantity, int price)
+void ShopItems::addItem2(const int inventoryIndex, const int id,
+ const unsigned char color,
+ const int quantity, const int price)
{
ShopItem *item = nullptr;
if (mMergeDuplicates)
@@ -98,7 +100,7 @@ ShopItem *ShopItems::at(unsigned int i) const
return mShopItems.at(i);
}
-void ShopItems::erase(unsigned int i)
+void ShopItems::erase(const unsigned int i)
{
if (i >= mShopItems.size())
return;
@@ -106,7 +108,7 @@ void ShopItems::erase(unsigned int i)
mShopItems.erase(mShopItems.begin() + i);
}
-void ShopItems::del(unsigned int i)
+void ShopItems::del(const unsigned int i)
{
if (i >= mShopItems.size())
return;
@@ -122,12 +124,12 @@ void ShopItems::clear()
mShopItems.clear();
}
-ShopItem *ShopItems::findItem(int id, unsigned char color) const
+ShopItem *ShopItems::findItem(const int id, const unsigned char color) const
{
ShopItem *item;
std::vector<ShopItem*>::const_iterator it = mShopItems.begin();
- std::vector<ShopItem*>::const_iterator e = mShopItems.end();
+ const std::vector<ShopItem*>::const_iterator e = mShopItems.end();
while (it != e)
{
item = *(it);