qt: Add PeerTableModel::StatsRole

This change allows access to CNodeCombinedStats instance directly from
any view object.
This commit is contained in:
Hennadii Stepanov committed 2020-12-30 20:54:47 +02:00
1 parent f1f26b8d5b
commit 35007edf9c
2 files changed
+10

No files matched your search

+5
View File
@@ -181,6 +181,11 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
default: default:
return QVariant(); return QVariant();
} }
} else if (role == StatsRole) {
switch (index.column()) {
case NetNodeId: return QVariant::fromValue(rec);
default: return QVariant();
}
} }
return QVariant(); return QVariant();
+5
View File
@@ -28,6 +28,7 @@ struct CNodeCombinedStats {
CNodeStateStats nodeStateStats; CNodeStateStats nodeStateStats;
bool fNodeStateStatsAvailable; bool fNodeStateStatsAvailable;
}; };
Q_DECLARE_METATYPE(CNodeCombinedStats*)
class NodeLessThan class NodeLessThan
{ {
@@ -67,6 +68,10 @@ public:
Subversion = 6 Subversion = 6
}; };
enum {
StatsRole = Qt::UserRole,
};
/** @name Methods overridden from QAbstractTableModel /** @name Methods overridden from QAbstractTableModel
@{*/ @{*/
int rowCount(const QModelIndex &parent) const override; int rowCount(const QModelIndex &parent) const override;