summaryrefslogtreecommitdiff
path: root/src/gui/models
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-06-06 23:34:34 +0300
committerAndrei Karas <akaras@inbox.ru>2017-06-07 19:23:40 +0300
commit36ba43d6ea38062b17f7e63ef659962bfc51c64d (patch)
tree190156cb88b13a38a6d13c69ee0742cc078065a1 /src/gui/models
parentf1518dd8476c968a43fa57cfb06198e290a4f77a (diff)
downloadmv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.gz
mv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.bz2
mv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.tar.xz
mv-36ba43d6ea38062b17f7e63ef659962bfc51c64d.zip
Fix clang-tidy check readability-implicit-bool-cast.
Diffstat (limited to 'src/gui/models')
-rw-r--r--src/gui/models/colormodel.cpp2
-rw-r--r--src/gui/models/extendednamesmodel.cpp2
-rw-r--r--src/gui/models/langlistmodel.h2
-rw-r--r--src/gui/models/modelistmodel.cpp4
-rw-r--r--src/gui/models/namesmodel.cpp2
-rw-r--r--src/gui/models/playertablemodel.cpp6
-rw-r--r--src/gui/models/serverslistmodel.h4
-rw-r--r--src/gui/models/shopitems.cpp8
-rw-r--r--src/gui/models/skillmodel.cpp4
-rw-r--r--src/gui/models/tablemodel.cpp8
-rw-r--r--src/gui/models/touchactionmodel.cpp2
-rw-r--r--src/gui/models/worldlistmodel.h2
12 files changed, 23 insertions, 23 deletions
diff --git a/src/gui/models/colormodel.cpp b/src/gui/models/colormodel.cpp
index 76a7da8fa..3bbded2e2 100644
--- a/src/gui/models/colormodel.cpp
+++ b/src/gui/models/colormodel.cpp
@@ -71,7 +71,7 @@ void ColorModel::add(const std::string &name, const Color *const color1,
ColorModel *ColorModel::createDefault(const Widget2 *const widget)
{
ColorModel *const model = new ColorModel;
- if (!widget)
+ if (widget == nullptr)
return model;
// TRANSLATORS: color name
addColor(_("black"), BLACK);
diff --git a/src/gui/models/extendednamesmodel.cpp b/src/gui/models/extendednamesmodel.cpp
index 2b185d9b3..2c8d7167a 100644
--- a/src/gui/models/extendednamesmodel.cpp
+++ b/src/gui/models/extendednamesmodel.cpp
@@ -58,7 +58,7 @@ void ExtendedNamesModel::clear()
mNames.clear();
FOR_EACH (std::vector<Image*>::iterator, it, mImages)
{
- if (*it)
+ if (*it != nullptr)
(*it)->decRef();
}
mImages.clear();
diff --git a/src/gui/models/langlistmodel.h b/src/gui/models/langlistmodel.h
index 839a836e7..f8c67ad30 100644
--- a/src/gui/models/langlistmodel.h
+++ b/src/gui/models/langlistmodel.h
@@ -116,7 +116,7 @@ class LangListModel final : public ExtendedListModel
for (int f = 0; f < langs_count; f ++)
{
Image *const img = mIcons[f];
- if (img)
+ if (img != nullptr)
img->decRef();
}
}
diff --git a/src/gui/models/modelistmodel.cpp b/src/gui/models/modelistmodel.cpp
index 60974bb7e..3c39921ad 100644
--- a/src/gui/models/modelistmodel.cpp
+++ b/src/gui/models/modelistmodel.cpp
@@ -36,12 +36,12 @@ static bool modeSorter(const std::string &mode1, const std::string &mode2)
{
const int width1 = atoi(mode1.substr(0, mode1.find('x')).c_str());
const int height1 = atoi(mode1.substr(mode1.find('x') + 1).c_str());
- if (!width1 || !height1)
+ if ((width1 == 0) || (height1 == 0))
return false;
const int width2 = atoi(mode2.substr(0, mode2.find('x')).c_str());
const int height2 = atoi(mode2.substr(mode2.find('x') + 1).c_str());
- if (!width2 || !height2)
+ if ((width2 == 0) || (height2 == 0))
return false;
if (width1 != width2)
return width1 < width2;
diff --git a/src/gui/models/namesmodel.cpp b/src/gui/models/namesmodel.cpp
index 9c90ff4c0..5a351f471 100644
--- a/src/gui/models/namesmodel.cpp
+++ b/src/gui/models/namesmodel.cpp
@@ -49,7 +49,7 @@ std::string NamesModel::getElementAt(int i)
void NamesModel::fillFromArray(const char *const *const arr,
const std::size_t sz)
{
- if (!arr)
+ if (arr == nullptr)
return;
for (size_t f = 0; f < sz; f ++)
mNames.push_back(gettext(arr[f]));
diff --git a/src/gui/models/playertablemodel.cpp b/src/gui/models/playertablemodel.cpp
index 29e08578d..9c8526e0d 100644
--- a/src/gui/models/playertablemodel.cpp
+++ b/src/gui/models/playertablemodel.cpp
@@ -66,7 +66,7 @@ PlayerTableModel::~PlayerTableModel()
int PlayerTableModel::getRows() const
{
- if (mPlayers)
+ if (mPlayers != nullptr)
return CAST_S32(mPlayers->size());
else
return 0;
@@ -120,7 +120,7 @@ void PlayerTableModel::updateModelInRow(const int row) const
{
const DropDown *const choicebox = static_cast<DropDown *>(
getElementAt(row, RELATION_CHOICE_COLUMN));
- if (!choicebox)
+ if (choicebox == nullptr)
return;
player_relations.setRelation(getPlayerAt(row),
static_cast<RelationT>(
@@ -141,7 +141,7 @@ void PlayerTableModel::freeWidgets()
std::string PlayerTableModel::getPlayerAt(const int index) const
{
- if (!mPlayers || index < 0
+ if ((mPlayers == nullptr) || index < 0
|| index >= CAST_S32(mPlayers->size()))
{
return std::string();
diff --git a/src/gui/models/serverslistmodel.h b/src/gui/models/serverslistmodel.h
index 453c1fa09..935fd3422 100644
--- a/src/gui/models/serverslistmodel.h
+++ b/src/gui/models/serverslistmodel.h
@@ -42,7 +42,7 @@ class ServersListModel final : public ListModel
ServersListModel(ServerInfos *const servers,
ServerDialog *const parent) :
mServers(servers),
- mVersionStrings(servers ? servers->size() : 0,
+ mVersionStrings(servers != nullptr ? servers->size() : 0,
VersionString(0, "")),
mParent(parent)
{
@@ -83,7 +83,7 @@ class ServersListModel final : public ListModel
if (index < 0 || index >= CAST_S32(mVersionStrings.size()))
return;
- if (version.empty() || !gui)
+ if (version.empty() || (gui == nullptr))
{
mVersionStrings[index] = VersionString(0, "");
}
diff --git a/src/gui/models/shopitems.cpp b/src/gui/models/shopitems.cpp
index 94bba3be4..a5c05388b 100644
--- a/src/gui/models/shopitems.cpp
+++ b/src/gui/models/shopitems.cpp
@@ -46,7 +46,7 @@ ShopItems::~ShopItems()
std::string ShopItems::getElementAt(int i)
{
if (i < 0 || CAST_U32(i)
- >= CAST_U32(mShopItems.size()) || !mShopItems.at(i))
+ >= CAST_U32(mShopItems.size()) || (mShopItems.at(i) == nullptr))
{
return "";
}
@@ -79,7 +79,7 @@ ShopItem *ShopItems::addItemNoDup(const int id,
const int price)
{
ShopItem *item = findItem(id, color);
- if (!item)
+ if (item == nullptr)
{
item = new ShopItem(-1,
id,
@@ -105,7 +105,7 @@ ShopItem *ShopItems::addItem2(const int inventoryIndex,
if (mMergeDuplicates)
item = findItem(id, color);
- if (item)
+ if (item != nullptr)
{
item->addDuplicate(inventoryIndex, quantity);
}
@@ -199,7 +199,7 @@ void ShopItems::updateList()
FOR_EACH (std::vector<ShopItem*>::iterator, it, mAllShopItems)
{
ShopItem *const item = *it;
- if (item && item->isVisible())
+ if ((item != nullptr) && item->isVisible())
mShopItems.push_back(item);
}
}
diff --git a/src/gui/models/skillmodel.cpp b/src/gui/models/skillmodel.cpp
index 13d2bb547..102956897 100644
--- a/src/gui/models/skillmodel.cpp
+++ b/src/gui/models/skillmodel.cpp
@@ -43,7 +43,7 @@ SkillInfo *SkillModel::getSkillAt(const int i) const
std::string SkillModel::getElementAt(int i)
{
const SkillInfo *const info = getSkillAt(i);
- if (info)
+ if (info != nullptr)
return info->data->name;
else
return std::string();
@@ -55,7 +55,7 @@ void SkillModel::updateVisibilities()
FOR_EACH (SkillList::const_iterator, it, mSkills)
{
- if ((*it) && (*it)->visible == Visible_true)
+ if (((*it) != nullptr) && (*it)->visible == Visible_true)
mVisibleSkills.push_back((*it));
}
}
diff --git a/src/gui/models/tablemodel.cpp b/src/gui/models/tablemodel.cpp
index fe60ccc95..08cfb6d83 100644
--- a/src/gui/models/tablemodel.cpp
+++ b/src/gui/models/tablemodel.cpp
@@ -32,13 +32,13 @@
void TableModel::installListener(TableModelListener *const listener)
{
- if (listener)
+ if (listener != nullptr)
listeners.insert(listener);
}
void TableModel::removeListener(TableModelListener *const listener)
{
- if (listener)
+ if (listener != nullptr)
listeners.erase(listener);
}
@@ -56,7 +56,7 @@ void TableModel::signalAfterUpdate()
for (std::set<TableModelListener *>::const_iterator it = listeners.begin();
it != listeners.end(); ++it)
{
- if (*it)
+ if (*it != nullptr)
(*it)->modelUpdated(true);
}
}
@@ -93,7 +93,7 @@ void StaticTableModel::resize()
void StaticTableModel::set(const int row, const int column,
Widget *const widget)
{
- if (!widget || row >= mRows || row < 0
+ if ((widget == nullptr) || row >= mRows || row < 0
|| column >= mColumns || column < 0)
{
// raise exn?
diff --git a/src/gui/models/touchactionmodel.cpp b/src/gui/models/touchactionmodel.cpp
index 6238797e6..983fc7065 100644
--- a/src/gui/models/touchactionmodel.cpp
+++ b/src/gui/models/touchactionmodel.cpp
@@ -37,7 +37,7 @@ static class SortTouchActionFunctor final
bool operator() (const SetupActionData *const data1,
const SetupActionData *const data2) const
{
- if (!data1 || !data2)
+ if ((data1 == nullptr) || (data2 == nullptr))
return false;
return data1->name < data2->name;
}
diff --git a/src/gui/models/worldlistmodel.h b/src/gui/models/worldlistmodel.h
index 4fe0a812e..4436f848c 100644
--- a/src/gui/models/worldlistmodel.h
+++ b/src/gui/models/worldlistmodel.h
@@ -53,7 +53,7 @@ class WorldListModel final : public ListModel
std::string getElementAt(int i) override final
{
const WorldInfo *const si = mWorlds[i];
- if (si)
+ if (si != nullptr)
{
return std::string(si->name).append(" (").append(
toString(si->online_users)).append(")");