mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 12:22:39 -03:00
qt, refactor: Use enum type as switch argument in AddressTableModel
This commit is contained in:
parent
08eec6907a
commit
ab8a747d1c
1 changed files with 20 additions and 24 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue