23 if (
order == Qt::DescendingOrder) {
24 std::swap(pLeft, pRight);
65 node.getNodesStats(nodes_stats);
67 for (
const auto &node_stats : nodes_stats) {
69 stats.
nodeStats = std::get<0>(node_stats);
88 std::pair<NodeId, int>(stats.nodeStats.nodeid, row++));
104 : QAbstractTableModel(parent),
m_node(
node), timer(nullptr) {
108 timer =
new QTimer(
this);
139 if (!
index.isValid()) {
146 if (role == Qt::DisplayRole) {
147 switch (
index.column()) {
166 }
else if (role == Qt::TextAlignmentRole) {
167 switch (
index.column()) {
169 return QVariant(Qt::AlignCenter);
173 return QVariant(Qt::AlignRight | Qt::AlignVCenter);
184 if (orientation == Qt::Horizontal) {
185 if (role == Qt::DisplayRole && section <
columns.size()) {
193 if (!
index.isValid()) {
194 return Qt::NoItemFlags;
197 Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
202 const QModelIndex &parent)
const {
207 return createIndex(row, column,
data);
209 return QModelIndex();
213 return priv->index(idx);
217 Q_EMIT layoutAboutToBeChanged();
219 Q_EMIT layoutChanged();
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.
CNodeStateStats nodeStateStats
bool fNodeStateStatsAvailable
POD that contains various stats about a node.
std::chrono::microseconds m_min_ping_time