Skip to content

Commit

Permalink
qt, refactor: Use enum type as switch argument in TransactionTableModel
Browse files Browse the repository at this point in the history
  • Loading branch information
barton2526 committed Apr 21, 2022
1 parent f9f4b9a commit 63062a5
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,20 +605,18 @@ 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 Qt::DecorationRole:
switch(index.column())
{
switch (column) {
case Status:
return txStatusDecoration(rec);
case ToAddress:
return txAddressDecoration(rec);
}
break;
} // no default case, so the compiler can warn about missing cases
assert(false);
case Qt::DisplayRole:
switch(index.column())
{
switch (column) {
case Date:
return formatTxDate(rec);
case Type:
Expand All @@ -627,12 +625,11 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
return formatTxToAddress(rec, false);
case Amount:
return formatTxAmount(rec);
}
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 @@ -643,8 +640,8 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
return formatTxToAddress(rec, true);
case Amount:
return rec->credit + rec->debit;
}
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 63062a5

Please sign in to comment.