12 #include <validation.h> 24 if (
order == Qt::DescendingOrder)
25 std::swap(pLeft, pRight);
68 for (
const auto& node_stats : nodes_stats)
71 stats.
nodeStats = std::get<0>(node_stats);
86 mapNodeRows.insert(std::pair<NodeId, int>(stats.nodeStats.nodeid, row++));
104 QAbstractTableModel(parent),
109 columns << tr(
"NodeId") << tr(
"Node/Service") << tr(
"Ping") << tr(
"Sent") << tr(
"Received") << tr(
"User Agent");
112 priv->sortColumn = -1;
115 timer =
new QTimer(
this);
117 timer->setInterval(MODEL_UPDATE_DELAY);
157 if (role == Qt::DisplayRole) {
158 switch(
index.column())
174 }
else if (role == Qt::TextAlignmentRole) {
175 switch (
index.column()) {
179 return QVariant(Qt::AlignRight | Qt::AlignVCenter);
190 if(orientation == Qt::Horizontal)
192 if(role == Qt::DisplayRole && section <
columns.size())
205 Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
215 return createIndex(row, column,
data);
216 return QModelIndex();
221 return priv->index(idx);
226 Q_EMIT layoutAboutToBeChanged();
228 Q_EMIT layoutChanged();
233 std::map<NodeId, int>::iterator it =
priv->mapNodeRows.find(nodeid);
234 if (it ==
priv->mapNodeRows.end())
242 priv->sortColumn = column;
243 priv->sortOrder = order;
void refreshPeers(interfaces::Node &node)
Pull a full list of peers from vNodes into our cache.
QVariant data(const QModelIndex &index, int role) const
std::vector< std::tuple< CNodeStats, bool, CNodeStateStats > > NodesStats
Get stats for connected nodes.
int getRowByNodeId(NodeId nodeid)
bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const
CNodeStateStats nodeStateStats
int sortColumn
Column to sort nodes by.
QString formatBytes(uint64_t bytes)
CNodeCombinedStats * index(int idx)
Qt::ItemFlags flags(const QModelIndex &index) const
Qt::SortOrder sortOrder
Order (ascending or descending) to sort nodes by.
int columnCount(const QModelIndex &parent) const
bool fNodeStateStatsAvailable
interfaces::Node & m_node
PeerTableModel(interfaces::Node &node, ClientModel *parent=0)
QList< CNodeCombinedStats > cachedNodeStats
Local cache of peer information.
std::unique_ptr< PeerTablePriv > priv
const CNodeCombinedStats * getNodeStats(int idx)
QModelIndex index(int row, int column, const QModelIndex &parent) const
Model for Bitcoin network client.
QString formatPingTime(double dPingTime)
std::map< NodeId, int > mapNodeRows
Index of rows by node ID.
virtual bool getNodesStats(NodesStats &stats)=0
void sort(int column, Qt::SortOrder order)
Top-level interface for a bitcoin node (bsha3d process).
int rowCount(const QModelIndex &parent) const
QVariant headerData(int section, Qt::Orientation orientation, int role) const