Bitcoin Core  27.99.0
P2P Digital Currency
peertablemodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2022 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);
45  void startAutoRefresh();
46  void stopAutoRefresh();
47 
48  enum ColumnIndex {
49  NetNodeId = 0,
50  Age,
58  Subversion
59  };
60 
61  enum {
62  StatsRole = Qt::UserRole,
63  };
64 
67  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
68  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
69  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
70  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
71  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
72  Qt::ItemFlags flags(const QModelIndex &index) const override;
75 public Q_SLOTS:
76  void refresh();
77 
78 private:
80  QList<CNodeCombinedStats> m_peers_data{};
82  const QStringList columns{
83  /*: Title of Peers Table column which contains a
84  unique number used to identify a connection. */
85  tr("Peer"),
86  /*: Title of Peers Table column which indicates the duration (length of time)
87  since the peer connection started. */
88  tr("Age"),
89  /*: Title of Peers Table column which contains the
90  IP/Onion/I2P address of the connected peer. */
91  tr("Address"),
92  /*: Title of Peers Table column which indicates the direction
93  the peer connection was initiated from. */
94  tr("Direction"),
95  /*: Title of Peers Table column which describes the type of
96  peer connection. The "type" describes why the connection exists. */
97  tr("Type"),
98  /*: Title of Peers Table column which states the network the peer
99  connected through. */
100  tr("Network"),
101  /*: Title of Peers Table column which indicates the current latency
102  of the connection with the peer. */
103  tr("Ping"),
104  /*: Title of Peers Table column which indicates the total amount of
105  network information we have sent to the peer. */
106  tr("Sent"),
107  /*: Title of Peers Table column which indicates the total amount of
108  network information we have received from the peer. */
109  tr("Received"),
110  /*: Title of Peers Table column which contains the peer's
111  User Agent string. */
112  tr("User Agent")};
113  QTimer* timer{nullptr};
114 };
115 
116 #endif // BITCOIN_QT_PEERTABLEMODEL_H
int flags
Definition: bitcoin-tx.cpp:533
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call.
interfaces::Node & m_node
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:70
Definition: messages.h:20
CNodeStateStats nodeStateStats
CNodeStats nodeStats