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,
57  Subversion
58  };
59 
60  enum {
61  StatsRole = Qt::UserRole,
62  };
63 
66  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
67  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
68  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
69  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
70  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
71  Qt::ItemFlags flags(const QModelIndex &index) const override;
74 public Q_SLOTS:
75  void refresh();
76 
77 private:
79  QList<CNodeCombinedStats> m_peers_data{};
81  const QStringList columns{
82  /*: Title of Peers Table column which contains a
83  unique number used to identify a connection. */
84  tr("Peer"),
85  /*: Title of Peers Table column which contains the
86  IP/Onion/I2P address of the connected peer. */
87  tr("Address"),
88  /*: Title of Peers Table column which indicates the direction
89  the peer connection was initiated from. */
90  tr("Direction"),
91  /*: Title of Peers Table column which describes the type of
92  peer connection. The "type" describes why the connection exists. */
93  tr("Type"),
94  /*: Title of Peers Table column which states the network the peer
95  connected through. */
96  tr("Network"),
97  /*: Title of Peers Table column which indicates the current latency
98  of the connection with the peer. */
99  tr("Ping"),
100  /*: Title of Peers Table column which indicates the total amount of
101  network information we have sent to the peer. */
102  tr("Sent"),
103  /*: Title of Peers Table column which indicates the total amount of
104  network information we have received from the peer. */
105  tr("Received"),
106  /*: Title of Peers Table column which contains the peer's
107  User Agent string. */
108  tr("User Agent")};
109  QTimer *timer;
110 };
111 
112 #endif // BITCOIN_QT_PEERTABLEMODEL_H
PeerTableModel::Received
@ Received
Definition: peertablemodel.h:56
interfaces
Definition: dummywallet.cpp:11
CNodeCombinedStats::nodeStats
CNodeStats nodeStats
Definition: peertablemodel.h:28
flags
int flags
Definition: bitcoin-tx.cpp:525
PeerTableModel::Address
@ Address
Definition: peertablemodel.h:50
PeerTableModel::Direction
@ Direction
Definition: peertablemodel.h:51
PeerTableModel::m_node
interfaces::Node & m_node
Definition: peertablemodel.h:80
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:54
PeerTableModel::Sent
@ Sent
Definition: peertablemodel.h:55
node
Definition: interfaces.cpp:68
PeerTableModel::Network
@ Network
Definition: peertablemodel.h:53
CNodeStateStats
Definition: net_processing.h:26
CNodeStats
Definition: net.h:238
PeerTableModel::timer
QTimer * timer
Definition: peertablemodel.h:109
PeerTableModel::ConnectionType
@ ConnectionType
Definition: peertablemodel.h:52
PeerTableModel::ColumnIndex
ColumnIndex
Definition: peertablemodel.h:48
CNodeCombinedStats::nodeStateStats
CNodeStateStats nodeStateStats
Definition: peertablemodel.h:29