Bitcoin ABC 0.30.7
P2P Digital Currency
peertablemodel.h
Go to the documentation of this file.
1// Copyright (c) 2011-2016 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.h>
9#include <net_processing.h> // For CNodeStateStats
10
11#include <QAbstractTableModel>
12#include <QStringList>
13
14#include <memory>
15
16class PeerTablePriv;
17
18namespace interfaces {
19class Node;
20}
21
22QT_BEGIN_NAMESPACE
23class QTimer;
24QT_END_NAMESPACE
25
30};
31
33public:
34 NodeLessThan(int nColumn, Qt::SortOrder fOrder)
35 : column(nColumn), order(fOrder) {}
36 bool operator()(const CNodeCombinedStats &left,
37 const CNodeCombinedStats &right) const;
38
39private:
40 int column;
41 Qt::SortOrder order;
42};
43
48class PeerTableModel : public QAbstractTableModel {
49 Q_OBJECT
50
51public:
52 explicit PeerTableModel(interfaces::Node &node, QObject *parent);
54 const CNodeCombinedStats *getNodeStats(int idx);
55 int getRowByNodeId(NodeId nodeid);
56 void startAutoRefresh();
57 void stopAutoRefresh();
58
63 Ping = 3,
64 Sent = 4,
67 };
68
71 int rowCount(const QModelIndex &parent) const override;
72 int columnCount(const QModelIndex &parent) const override;
73 QVariant data(const QModelIndex &index, int role) const override;
74 QVariant headerData(int section, Qt::Orientation orientation,
75 int role) const override;
76 QModelIndex index(int row, int column,
77 const QModelIndex &parent) const override;
78 Qt::ItemFlags flags(const QModelIndex &index) const override;
79 void sort(int column, Qt::SortOrder order) override;
82public Q_SLOTS:
83 void refresh();
84
85private:
87 const QStringList columns{tr("Peer Id"), tr("Address"), tr("Network"),
88 tr("Ping"), tr("Sent"), tr("Received"),
89 tr("User Agent")};
90 std::unique_ptr<PeerTablePriv> priv;
91 QTimer *timer;
92};
93
94#endif // BITCOIN_QT_PEERTABLEMODEL_H
bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const
NodeLessThan(int nColumn, Qt::SortOrder fOrder)
Qt::SortOrder order
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call.
QVariant data(const QModelIndex &index, int role) const override
int columnCount(const QModelIndex &parent) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
interfaces::Node & m_node
QModelIndex index(int row, int column, const QModelIndex &parent) const override
void sort(int column, Qt::SortOrder order) override
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
const CNodeCombinedStats * getNodeStats(int idx)
const QStringList columns
PeerTableModel(interfaces::Node &node, QObject *parent)
int getRowByNodeId(NodeId nodeid)
int rowCount(const QModelIndex &parent) const override
std::unique_ptr< PeerTablePriv > priv
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:59
Definition: init.h:28
Network
A network type.
Definition: netaddress.h:44
int64_t NodeId
Definition: nodeid.h:10
CNodeStateStats nodeStateStats
CNodeStats nodeStats
POD that contains various stats about a node.
Definition: net.h:287