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
17class PeerTablePriv;
18
19namespace interfaces {
20class Node;
21}
22
23QT_BEGIN_NAMESPACE
24class QTimer;
25QT_END_NAMESPACE
26
31};
32Q_DECLARE_METATYPE(CNodeCombinedStats*)
33
34
38class PeerTableModel : public QAbstractTableModel
39{
40 Q_OBJECT
41
42public:
43 explicit PeerTableModel(interfaces::Node& node, QObject* parent);
45 void startAutoRefresh();
46 void stopAutoRefresh();
47
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;
74public Q_SLOTS:
75 void refresh();
76
77private:
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
int flags
Definition: bitcoin-tx.cpp:525
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:55
CNodeStateStats nodeStateStats
CNodeStats nodeStats