Skip to content

Commit

Permalink
Merge 8c21562 into merged_master (Bitcoin PR bitcoin-core/gui#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
apoelstra committed Jun 26, 2021
2 parents a480f23 + 8c21562 commit 2a4f512
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 65 deletions.
44 changes: 20 additions & 24 deletions src/qt/addresstablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,42 +198,38 @@ QVariant AddressTableModel::data(const QModelIndex &index, int role) const

AddressTableEntry *rec = static_cast<AddressTableEntry*>(index.internalPointer());

if(role == Qt::DisplayRole || role == Qt::EditRole)
{
switch(index.column())
{
const auto column = static_cast<ColumnIndex>(index.column());
if (role == Qt::DisplayRole || role == Qt::EditRole) {
switch (column) {
case Label:
if(rec->label.isEmpty() && role == Qt::DisplayRole)
{
if (rec->label.isEmpty() && role == Qt::DisplayRole) {
return tr("(no label)");
}
else
{
} else {
return rec->label;
}
case Address:
return rec->address;
}
}
else if (role == Qt::FontRole)
{
QFont font;
if(index.column() == Address)
{
font = GUIUtil::fixedPitchFont();
}
return font;
}
else if (role == TypeRole)
{
} // no default case, so the compiler can warn about missing cases
assert(false);
} else if (role == Qt::FontRole) {
switch (column) {
case Label:
return QFont();
case Address:
return GUIUtil::fixedPitchFont();
} // no default case, so the compiler can warn about missing cases
assert(false);
} else if (role == TypeRole) {
switch(rec->type)
{
case AddressTableEntry::Sending:
return Send;
case AddressTableEntry::Receiving:
return Receive;
default: break;
}
case AddressTableEntry::Hidden:
return {};
} // no default case, so the compiler can warn about missing cases
assert(false);
}
return QVariant();
}
Expand Down
15 changes: 7 additions & 8 deletions src/qt/bantablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
41 changes: 22 additions & 19 deletions src/qt/peertablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombine
if (order == Qt::DescendingOrder)
std::swap(pLeft, pRight);

switch(column)
{
switch (static_cast<PeerTableModel::ColumnIndex>(column)) {
case PeerTableModel::NetNodeId:
return pLeft->nodeid < pRight->nodeid;
case PeerTableModel::Address:
Expand All @@ -41,9 +40,8 @@ bool NodeLessThan::operator()(const CNodeCombinedStats &left, const CNodeCombine
return pLeft->nRecvBytes < pRight->nRecvBytes;
case PeerTableModel::Subversion:
return pLeft->cleanSubVer.compare(pRight->cleanSubVer) < 0;
}

return false;
} // no default case, so the compiler can warn about missing cases
assert(false);
}

// private implementation
Expand Down Expand Up @@ -157,9 +155,9 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const

CNodeCombinedStats *rec = static_cast<CNodeCombinedStats*>(index.internalPointer());

const auto column = static_cast<ColumnIndex>(index.column());
if (role == Qt::DisplayRole) {
switch(index.column())
{
switch (column) {
case NetNodeId:
return (qint64)rec->nodeStats.nodeid;
case Address:
Expand All @@ -177,19 +175,24 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
return GUIUtil::formatBytes(rec->nodeStats.nRecvBytes);
case Subversion:
return QString::fromStdString(rec->nodeStats.cleanSubVer);
}
} // no default case, so the compiler can warn about missing cases
assert(false);
} else if (role == Qt::TextAlignmentRole) {
switch (index.column()) {
case ConnectionType:
case Network:
return QVariant(Qt::AlignCenter);
case Ping:
case Sent:
case Received:
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
default:
return QVariant();
}
switch (column) {
case NetNodeId:
case Address:
return {};
case ConnectionType:
case Network:
return QVariant(Qt::AlignCenter);
case Ping:
case Sent:
case Received:
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
case Subversion:
return {};
} // no default case, so the compiler can warn about missing cases
assert(false);
} else if (role == StatsRole) {
switch (index.column()) {
case NetNodeId: return QVariant::fromValue(rec);
Expand Down
30 changes: 16 additions & 14 deletions src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,27 +531,30 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
return QVariant();
TransactionRecord *rec = static_cast<TransactionRecord*>(index.internalPointer());

switch(role)
{
const auto column = static_cast<ColumnIndex>(index.column());
switch (role) {
case RawDecorationRole:
switch(index.column())
{
switch (column) {
case Status:
return txStatusDecoration(rec);
case Watchonly:
return txWatchonlyDecoration(rec);
case Date: return {};
case Type: return {};
case ToAddress:
return txAddressDecoration(rec);
}
break;
case Amount: return {};
} // no default case, so the compiler can warn about missing cases
assert(false);
case Qt::DecorationRole:
{
QIcon icon = qvariant_cast<QIcon>(index.data(RawDecorationRole));
return platformStyle->TextColorIcon(icon);
}
case Qt::DisplayRole:
switch(index.column())
{
switch (column) {
case Status: return {};
case Watchonly: return {};
case Date:
return formatTxDate(rec);
case Type:
Expand All @@ -560,12 +563,11 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
return formatTxToAddress(rec, false);
case Amount:
return formatTxAmount(rec, true, BitcoinUnits::SeparatorStyle::ALWAYS);
}
break;
} // no default case, so the compiler can warn about missing cases
assert(false);
case Qt::EditRole:
// Edit role is used for sorting, so return the unformatted values
switch(index.column())
{
switch (column) {
case Status:
return QString::fromStdString(rec->status.sortKey);
case Date:
Expand All @@ -578,8 +580,8 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
return formatTxToAddress(rec, true);
case Amount:
return qint64(rec->amount);
}
break;
} // no default case, so the compiler can warn about missing cases
assert(false);
case Qt::ToolTipRole:
return formatTooltip(rec);
case Qt::TextAlignmentRole:
Expand Down

0 comments on commit 2a4f512

Please sign in to comment.