diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2020-12-25 22:26:05 +0200 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2021-02-22 09:34:27 +0200 |
commit | a35223f1cdaf6918501faccac1ff94ebfd38c6f6 (patch) | |
tree | 68afc149bb49359b345a02aa8492f59d0a1a16ed /src/qt/bantablemodel.cpp | |
parent | ab8a747d1ced9f20ca32f9898418be70670da71a (diff) |
qt, refactor: Use enum type as switch argument in BanTableModel
Diffstat (limited to 'src/qt/bantablemodel.cpp')
-rw-r--r-- | src/qt/bantablemodel.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/qt/bantablemodel.cpp b/src/qt/bantablemodel.cpp index a01a7bc386..6cb4a4c546 100644 --- a/src/qt/bantablemodel.cpp +++ b/src/qt/bantablemodel.cpp @@ -23,15 +23,13 @@ bool BannedNodeLessThan::operator()(const CCombinedBan& left, const CCombinedBan if (order == Qt::DescendingOrder) std::swap(pLeft, pRight); - switch(column) - { + switch (static_cast<BanTableModel::ColumnIndex>(column)) { case BanTableModel::Address: return pLeft->subnet.ToString().compare(pRight->subnet.ToString()) < 0; case BanTableModel::Bantime: return pLeft->banEntry.nBanUntil < pRight->banEntry.nBanUntil; - } - - return false; + } // no default case, so the compiler can warn about missing cases + assert(false); } // private implementation @@ -119,16 +117,17 @@ QVariant BanTableModel::data(const QModelIndex &index, int role) const CCombinedBan *rec = static_cast<CCombinedBan*>(index.internalPointer()); + const auto column = static_cast<ColumnIndex>(index.column()); if (role == Qt::DisplayRole) { - switch(index.column()) - { + switch (column) { case Address: return QString::fromStdString(rec->subnet.ToString()); case Bantime: QDateTime date = QDateTime::fromMSecsSinceEpoch(0); date = date.addSecs(rec->banEntry.nBanUntil); return QLocale::system().toString(date, QLocale::LongFormat); - } + } // no default case, so the compiler can warn about missing cases + assert(false); } return QVariant(); |