Bitcoin Core 32.99.0
P2P Digital Currency
Loading...
Searching...
No Matches
peertablemodel.h
Go to the documentation of this file.
1// Copyright (c) 2011-present 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>
9#include <net.h>
10
11#include <QAbstractTableModel>
12#include <QList>
13#include <QModelIndex>
14#include <QStringList>
15#include <QVariant>
16
17namespace interfaces {
18class Node;
19}
20
22class QTimer;
24
31
32
36class PeerTableModel : public QAbstractTableModel
37{
39
40public:
41 explicit PeerTableModel(interfaces::Node& node, QObject* parent);
43 void startAutoRefresh();
44 void stopAutoRefresh();
45
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;
73public Q_SLOTS:
74 void refresh();
75
76private:
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 indicates the duration (length of time)
85 since the peer connection started. */
86 tr("Age"),
87 /*: Title of Peers Table column which contains the
88 IP/Onion/I2P address of the connected peer. */
89 tr("Address"),
90 /*: Title of Peers Table column which indicates the direction
91 the peer connection was initiated from. */
92 tr("Direction"),
93 /*: Title of Peers Table column which describes the type of
94 peer connection. The "type" describes why the connection exists. */
95 tr("Type"),
96 /*: Title of Peers Table column which states the network the peer
97 connected through. */
98 tr("Network"),
99 /*: Title of Peers Table column which indicates the current latency
100 of the connection with the peer. */
101 tr("Ping"),
102 /*: Title of Peers Table column which indicates the total amount of
103 network information we have sent to the peer. */
104 tr("Sent"),
105 /*: Title of Peers Table column which indicates the total amount of
106 network information we have received from the peer. */
107 tr("Received"),
108 /*: Title of Peers Table column which contains the peer's
109 User Agent string. */
110 tr("User Agent")};
111 QTimer* timer{nullptr};
112};
113
114#endif // BITCOIN_QT_PEERTABLEMODEL_H
int flags
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:66
static const PrecomputedData data
Precomputed COutPoint and CCoins values.
CNodeStateStats nodeStateStats
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition time.h:82