Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
peertablemodel.h
Go to the documentation of this file.
1// Copyright (c) 2011-2016 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_QT_PEERTABLEMODEL_H
6#define BITCOIN_QT_PEERTABLEMODEL_H
7
8#include <net.h>
9#include <net_processing.h> // For CNodeStateStats
10
11#include <QAbstractTableModel>
12#include <QStringList>
13
14#include <memory>
15
16class PeerTablePriv;
17
18namespace interfaces {
19class Node;
20}
21
23class QTimer;
25
31
33public:
34 NodeLessThan(int nColumn, Qt::SortOrder fOrder)
36 bool operator()(const CNodeCombinedStats &left,
37 const CNodeCombinedStats &right) const;
38
39private:
40 int column;
41 Qt::SortOrder order;
42};
43
48class PeerTableModel : public QAbstractTableModel {
50
51public:
52 explicit PeerTableModel(interfaces::Node &node, QObject *parent);
54 const CNodeCombinedStats *getNodeStats(int idx);
55 int getRowByNodeId(NodeId nodeid);
56 void startAutoRefresh();
57 void stopAutoRefresh();
58
63 Ping = 3,
64 Sent = 4,
67 };
68
71 int rowCount(const QModelIndex &parent) const override;
72 int columnCount(const QModelIndex &parent) const override;
73 QVariant data(const QModelIndex &index, int role) const override;
74 QVariant headerData(int section, Qt::Orientation orientation,
75 int role) const override;
76 QModelIndex index(int row, int column,
77 const QModelIndex &parent) const override;
78 Qt::ItemFlags flags(const QModelIndex &index) const override;
79 void sort(int column, Qt::SortOrder order) override;
82public Q_SLOTS:
83 void refresh();
84
85private:
87 const QStringList columns{tr("Peer Id"), tr("Address"), tr("Network"),
88 tr("Ping"), tr("Sent"), tr("Received"),
89 tr("User Agent")};
90 std::unique_ptr<PeerTablePriv> priv;
92};
93
94#endif // BITCOIN_QT_PEERTABLEMODEL_H
int flags
bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const
NodeLessThan(int nColumn, Qt::SortOrder fOrder)
Qt::SortOrder order
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call.
QVariant data(const QModelIndex &index, int role) const override
int columnCount(const QModelIndex &parent) 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
int getRowByNodeId(NodeId nodeid)
int rowCount(const QModelIndex &parent) const override
std::unique_ptr< PeerTablePriv > priv
Top-level interface for a bitcoin node (bitcoind process).
Definition node.h:59
Definition init.h:28
Network
A network type.
Definition netaddress.h:44
int64_t NodeId
Definition nodeid.h:10
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...
Definition random.h:85
CNodeStateStats nodeStateStats
POD that contains various stats about a node.
Definition net.h:287