Skip to content

Commit

Permalink
qt: Add PeerTableModel::StatsRole
Browse files Browse the repository at this point in the history
This change allows access to CNodeCombinedStats instance directly from
any view object.
  • Loading branch information
hebasto committed Dec 30, 2020
1 parent f1f26b8 commit 35007ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/qt/peertablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
default:
return QVariant();
}
} else if (role == StatsRole) {
switch (index.column()) {
case NetNodeId: return QVariant::fromValue(rec);
default: return QVariant();
}
}

return QVariant();
Expand Down
5 changes: 5 additions & 0 deletions src/qt/peertablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct CNodeCombinedStats {
CNodeStateStats nodeStateStats;
bool fNodeStateStatsAvailable;
};
Q_DECLARE_METATYPE(CNodeCombinedStats*)

class NodeLessThan
{
Expand Down Expand Up @@ -67,6 +68,10 @@ class PeerTableModel : public QAbstractTableModel
Subversion = 6
};

enum {
StatsRole = Qt::UserRole,
};

/** @name Methods overridden from QAbstractTableModel
@{*/
int rowCount(const QModelIndex &parent) const override;
Expand Down

0 comments on commit 35007ed

Please sign in to comment.