qt, refactor: Use enum type as switch argument in AddressTableModel

pull/826/head
Hennadii Stepanov 4 years ago
parent 08eec6907a
commit ab8a747d1c
No known key found for this signature in database
GPG Key ID: 410108112E7EA81F

@ -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…
Cancel
Save