|
|
|
@ -59,22 +59,28 @@ QVariant SubaddressAccountModel::data(const QModelIndex &index, int role) const
|
|
|
|
|
if (!index.isValid() || index.row() < 0 || (unsigned)index.row() >= m_subaddressAccount->count())
|
|
|
|
|
return {};
|
|
|
|
|
|
|
|
|
|
Monero::SubaddressAccountRow * sr = m_subaddressAccount->getRow(index.row());
|
|
|
|
|
QVariant result;
|
|
|
|
|
|
|
|
|
|
QVariant result = "";
|
|
|
|
|
switch (role) {
|
|
|
|
|
case SubaddressAccountAddressRole:
|
|
|
|
|
result = QString::fromStdString(sr->getAddress());
|
|
|
|
|
break;
|
|
|
|
|
case SubaddressAccountLabelRole:
|
|
|
|
|
result = QString::fromStdString(sr->getLabel());
|
|
|
|
|
break;
|
|
|
|
|
case SubaddressAccountBalanceRole:
|
|
|
|
|
result = QString::fromStdString(sr->getBalance());
|
|
|
|
|
break;
|
|
|
|
|
case SubaddressAccountUnlockedBalanceRole:
|
|
|
|
|
result = QString::fromStdString(sr->getUnlockedBalance());
|
|
|
|
|
break;
|
|
|
|
|
bool found = m_subaddressAccount->getRow(index.row(), [&result, &role](const Monero::SubaddressAccountRow &row) {
|
|
|
|
|
switch (role) {
|
|
|
|
|
case SubaddressAccountAddressRole:
|
|
|
|
|
result = QString::fromStdString(row.getAddress());
|
|
|
|
|
break;
|
|
|
|
|
case SubaddressAccountLabelRole:
|
|
|
|
|
result = QString::fromStdString(row.getLabel());
|
|
|
|
|
break;
|
|
|
|
|
case SubaddressAccountBalanceRole:
|
|
|
|
|
result = QString::fromStdString(row.getBalance());
|
|
|
|
|
break;
|
|
|
|
|
case SubaddressAccountUnlockedBalanceRole:
|
|
|
|
|
result = QString::fromStdString(row.getUnlockedBalance());
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
qCritical() << "Unimplemented role" << role;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (!found) {
|
|
|
|
|
qCritical("%s: internal error: invalid index %d", __FUNCTION__, index.row());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|