23 if (
order == Qt::DescendingOrder) {
31 return pLeft->m_addr_name.compare(
pRight->m_addr_name) < 0;
35 return pLeft->m_min_ping_time <
pRight->m_min_ping_time;
41 return pLeft->cleanSubVer.compare(
pRight->cleanSubVer) < 0;
88 std::pair<NodeId, int>(stats.nodeStats.nodeid,
row++));
139 if (!
index.isValid()) {
146 if (role == Qt::DisplayRole) {
147 switch (
index.column()) {
153 return QString(
rec->nodeStats.fInbound ?
"↓ " :
"↑ ") +
154 QString::fromStdString(
rec->nodeStats.m_addr_name);
164 return QString::fromStdString(
rec->nodeStats.cleanSubVer);
166 }
else if (role == Qt::TextAlignmentRole) {
167 switch (
index.column()) {
173 return QVariant(Qt::AlignRight | Qt::AlignVCenter);
193 if (!
index.isValid()) {
194 return Qt::NoItemFlags;
197 Qt::ItemFlags
retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
213 return priv->index(idx);
223 std::map<NodeId, int>::iterator it =
priv->mapNodeRows.find(nodeid);
224 if (it ==
priv->mapNodeRows.end()) {
232 priv->sortColumn = column;
233 priv->sortOrder = order;
bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const
QVariant data(const QModelIndex &index, int role) const override
int columnCount(const QModelIndex &parent) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
interfaces::Node & m_node
QModelIndex index(int row, int column, const QModelIndex &parent) const override
void sort(int column, Qt::SortOrder order) override
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
const CNodeCombinedStats * getNodeStats(int idx)
const QStringList columns
PeerTableModel(interfaces::Node &node, QObject *parent)
int getRowByNodeId(NodeId nodeid)
int rowCount(const QModelIndex &parent) const override
std::unique_ptr< PeerTablePriv > priv
int sortColumn
Column to sort nodes by (default to unsorted)
void refreshPeers(interfaces::Node &node)
Pull a full list of peers from vNodes into our cache.
QList< CNodeCombinedStats > cachedNodeStats
Local cache of peer information.
CNodeCombinedStats * index(int idx)
Qt::SortOrder sortOrder
Order (ascending or descending) to sort nodes by.
std::map< NodeId, int > mapNodeRows
Index of rows by node ID.
Top-level interface for a bitcoin node (bitcoind process).
std::vector< std::tuple< CNodeStats, bool, CNodeStateStats > > NodesStats
Get stats for connected nodes.
static const int MODEL_UPDATE_DELAY
QString NetworkToQString(Network net)
Convert enum Network to QString.
QString formatBytes(uint64_t bytes)
QString formatPingTime(std::chrono::microseconds ping_time)
Format a CNodeStats.m_last_ping_time into a user-readable string or display N/A, if 0.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
CNodeStateStats nodeStateStats
bool fNodeStateStatsAvailable
POD that contains various stats about a node.