mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 20:32:35 -03:00
qt, refactor: Use enum type as switch argument in BanTableModel
This commit is contained in:
parent
ab8a747d1c
commit
a35223f1cd
1 changed files with 7 additions and 8 deletions
|
@ -23,15 +23,13 @@ bool BannedNodeLessThan::operator()(const CCombinedBan& left, const CCombinedBan
|
||||||
if (order == Qt::DescendingOrder)
|
if (order == Qt::DescendingOrder)
|
||||||
std::swap(pLeft, pRight);
|
std::swap(pLeft, pRight);
|
||||||
|
|
||||||
switch(column)
|
switch (static_cast<BanTableModel::ColumnIndex>(column)) {
|
||||||
{
|
|
||||||
case BanTableModel::Address:
|
case BanTableModel::Address:
|
||||||
return pLeft->subnet.ToString().compare(pRight->subnet.ToString()) < 0;
|
return pLeft->subnet.ToString().compare(pRight->subnet.ToString()) < 0;
|
||||||
case BanTableModel::Bantime:
|
case BanTableModel::Bantime:
|
||||||
return pLeft->banEntry.nBanUntil < pRight->banEntry.nBanUntil;
|
return pLeft->banEntry.nBanUntil < pRight->banEntry.nBanUntil;
|
||||||
}
|
} // no default case, so the compiler can warn about missing cases
|
||||||
|
assert(false);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private implementation
|
// private implementation
|
||||||
|
@ -119,16 +117,17 @@ QVariant BanTableModel::data(const QModelIndex &index, int role) const
|
||||||
|
|
||||||
CCombinedBan *rec = static_cast<CCombinedBan*>(index.internalPointer());
|
CCombinedBan *rec = static_cast<CCombinedBan*>(index.internalPointer());
|
||||||
|
|
||||||
|
const auto column = static_cast<ColumnIndex>(index.column());
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
switch(index.column())
|
switch (column) {
|
||||||
{
|
|
||||||
case Address:
|
case Address:
|
||||||
return QString::fromStdString(rec->subnet.ToString());
|
return QString::fromStdString(rec->subnet.ToString());
|
||||||
case Bantime:
|
case Bantime:
|
||||||
QDateTime date = QDateTime::fromMSecsSinceEpoch(0);
|
QDateTime date = QDateTime::fromMSecsSinceEpoch(0);
|
||||||
date = date.addSecs(rec->banEntry.nBanUntil);
|
date = date.addSecs(rec->banEntry.nBanUntil);
|
||||||
return QLocale::system().toString(date, QLocale::LongFormat);
|
return QLocale::system().toString(date, QLocale::LongFormat);
|
||||||
}
|
} // no default case, so the compiler can warn about missing cases
|
||||||
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
Loading…
Reference in a new issue