Bitcoin Core  22.99.0
P2P Digital Currency
peertablemodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2020 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_processing.h> // For CNodeStateStats
9 #include <net.h>
10 
11 #include <QAbstractTableModel>
12 #include <QList>
13 #include <QModelIndex>
14 #include <QStringList>
15 #include <QVariant>
16 
17 class PeerTablePriv;
18 
19 namespace interfaces {
20 class Node;
21 }
22 
23 QT_BEGIN_NAMESPACE
24 class QTimer;
25 QT_END_NAMESPACE
26 
31 };
32 Q_DECLARE_METATYPE(CNodeCombinedStats*)
33 
34 
38 class PeerTableModel : public QAbstractTableModel
39 {
40  Q_OBJECT
41 
42 public:
43  explicit PeerTableModel(interfaces::Node& node, QObject* parent);
44  ~PeerTableModel();
45  void startAutoRefresh();
46  void stopAutoRefresh();
47 
48  enum ColumnIndex {
49  NetNodeId = 0,
56  Subversion
57  };
58 
59  enum {
60  StatsRole = Qt::UserRole,
61  };
62 
65  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
66  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
67  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
68  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
69  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
70  Qt::ItemFlags flags(const QModelIndex &index) const override;
73 public Q_SLOTS:
74  void refresh();
75 
76 private:
78  QList<CNodeCombinedStats> m_peers_data{};
80  const QStringList columns{
81  /*: Title of Peers Table column which contains a
82  unique number used to identify a connection. */
83  tr("Peer"),
84  /*: Title of Peers Table column which contains the
85  IP/Onion/I2P address of the connected peer. */
86  tr("Address"),
87  /*: Title of Peers Table column which describes the type of
88  peer connection. The "type" describes why the connection exists. */
89  tr("Type"),
90  /*: Title of Peers Table column which states the network the peer
91  connected through. */
92  tr("Network"),
93  /*: Title of Peers Table column which indicates the current latency
94  of the connection with the peer. */
95  tr("Ping"),
96  /*: Title of Peers Table column which indicates the total amount of
97  network information we have sent to the peer. */
98  tr("Sent"),
99  /*: Title of Peers Table column which indicates the total amount of
100  network information we have received from the peer. */
101  tr("Received"),
102  /*: Title of Peers Table column which contains the peer's
103  User Agent string. */
104  tr("User Agent")};
105  QTimer *timer;
106 };
107 
108 #endif // BITCOIN_QT_PEERTABLEMODEL_H
PeerTableModel::Received
@ Received
Definition: peertablemodel.h:55
interfaces
Definition: dummywallet.cpp:10
CNodeCombinedStats::nodeStats
CNodeStats nodeStats
Definition: peertablemodel.h:28
flags
int flags
Definition: bitcoin-tx.cpp:512
PeerTableModel::Address
@ Address
Definition: peertablemodel.h:50
PeerTableModel::m_node
interfaces::Node & m_node
Definition: peertablemodel.h:79
CNodeCombinedStats::fNodeStateStatsAvailable
bool fNodeStateStatsAvailable
Definition: peertablemodel.h:30
CNodeCombinedStats
Definition: peertablemodel.h:27
PeerTableModel
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call.
Definition: peertablemodel.h:38
net_processing.h
interfaces::Node
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:54
PeerTableModel::Ping
@ Ping
Definition: peertablemodel.h:53
PeerTableModel::Sent
@ Sent
Definition: peertablemodel.h:54
node
Definition: interfaces.cpp:68
PeerTableModel::Network
@ Network
Definition: peertablemodel.h:52
CNodeStateStats
Definition: net_processing.h:26
CNodeStats
Definition: net.h:239
PeerTableModel::timer
QTimer * timer
Definition: peertablemodel.h:105
PeerTableModel::ConnectionType
@ ConnectionType
Definition: peertablemodel.h:51
PeerTableModel::ColumnIndex
ColumnIndex
Definition: peertablemodel.h:48
CNodeCombinedStats::nodeStateStats
CNodeStateStats nodeStateStats
Definition: peertablemodel.h:29