23 if (
order == Qt::DescendingOrder)
24 std::swap(pLeft, pRight);
64 cachedNodeStats.clear();
68 cachedNodeStats.reserve(nodes_stats.size());
69 for (
const auto& node_stats : nodes_stats)
72 stats.
nodeStats = std::get<0>(node_stats);
75 cachedNodeStats.append(stats);
81 std::stable_sort(cachedNodeStats.begin(), cachedNodeStats.end(),
NodeLessThan(sortColumn, sortOrder));
87 mapNodeRows.insert(std::pair<NodeId, int>(stats.nodeStats.nodeid, row++));
92 return cachedNodeStats.size();
97 if (idx >= 0 && idx < cachedNodeStats.size())
98 return &cachedNodeStats[idx];
105 QAbstractTableModel(parent),
112 timer =
new QTimer(
this);
137 if (parent.isValid()) {
145 if (parent.isValid()) {
158 if (role == Qt::DisplayRole) {
159 switch(index.column())
177 }
else if (role == Qt::TextAlignmentRole) {
178 switch (index.column()) {
180 return QVariant(Qt::AlignCenter);
184 return QVariant(Qt::AlignRight | Qt::AlignVCenter);
189 switch (index.column()) {
190 case NetNodeId:
return QVariant::fromValue(rec);
191 default:
return QVariant();
200 if(orientation == Qt::Horizontal)
202 if(role == Qt::DisplayRole && section <
columns.size())
212 if (!index.isValid())
return Qt::NoItemFlags;
214 Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
224 return createIndex(row, column, data);
225 return QModelIndex();
230 Q_EMIT layoutAboutToBeChanged();
232 Q_EMIT layoutChanged();
237 std::map<NodeId, int>::iterator
it =
priv->mapNodeRows.find(nodeid);
238 if (it ==
priv->mapNodeRows.end())
246 priv->sortColumn = column;
247 priv->sortOrder = order;
void refreshPeers(interfaces::Node &node)
Pull a full list of peers from vNodes into our cache.
std::vector< std::tuple< CNodeStats, bool, CNodeStateStats > > NodesStats
Get stats for connected nodes.
int getRowByNodeId(NodeId nodeid)
std::deque< CInv >::iterator it
bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const
CNodeStateStats nodeStateStats
QVariant data(const QModelIndex &index, int role) const override
int rowCount(const QModelIndex &parent) const override
QString formatBytes(uint64_t bytes)
CNodeCombinedStats * index(int idx)
QModelIndex index(int row, int column, const QModelIndex &parent) const override
NodeLessThan(int nColumn, Qt::SortOrder fOrder)
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
Qt::SortOrder sortOrder
Order (ascending or descending) to sort nodes by.
QString NetworkToQString(Network net)
Convert enum Network to QString.
bool fNodeStateStatsAvailable
interfaces::Node & m_node
QString formatPingTime(int64_t ping_usec)
Format a CNodeStats.m_ping_usec into a user-readable string or display N/A, if 0. ...
QList< CNodeCombinedStats > cachedNodeStats
Local cache of peer information.
std::unique_ptr< PeerTablePriv > priv
const QStringList columns
static const int MODEL_UPDATE_DELAY
void sort(int column, Qt::SortOrder order) override
std::map< NodeId, int > mapNodeRows
Index of rows by node ID.
virtual bool getNodesStats(NodesStats &stats)=0
PeerTableModel(interfaces::Node &node, QObject *parent)
int columnCount(const QModelIndex &parent) const override
Top-level interface for a bitcoin node (bitcoind process).