BSHA3  0.17.99
P2P Blockchain, based on Bitcoin
peertablemodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2018 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 <memory>
12 
13 #include <QAbstractTableModel>
14 #include <QStringList>
15 
16 class ClientModel;
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 
34 {
35 public:
36  NodeLessThan(int nColumn, Qt::SortOrder fOrder) :
37  column(nColumn), order(fOrder) {}
38  bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const;
39 
40 private:
41  int column;
42  Qt::SortOrder order;
43 };
44 
49 class PeerTableModel : public QAbstractTableModel
50 {
51  Q_OBJECT
52 
53 public:
54  explicit PeerTableModel(interfaces::Node& node, ClientModel *parent = 0);
56  const CNodeCombinedStats *getNodeStats(int idx);
57  int getRowByNodeId(NodeId nodeid);
58  void startAutoRefresh();
59  void stopAutoRefresh();
60 
61  enum ColumnIndex {
62  NetNodeId = 0,
63  Address = 1,
64  Ping = 2,
65  Sent = 3,
66  Received = 4,
68  };
69 
72  int rowCount(const QModelIndex &parent) const;
73  int columnCount(const QModelIndex &parent) const;
74  QVariant data(const QModelIndex &index, int role) const;
75  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
76  QModelIndex index(int row, int column, const QModelIndex &parent) const;
77  Qt::ItemFlags flags(const QModelIndex &index) const;
78  void sort(int column, Qt::SortOrder order);
81 public Q_SLOTS:
82  void refresh();
83 
84 private:
87  QStringList columns;
88  std::unique_ptr<PeerTablePriv> priv;
89  QTimer *timer;
90 };
91 
92 #endif // BITCOIN_QT_PEERTABLEMODEL_H
QVariant data(const QModelIndex &index, int role) const
int getRowByNodeId(NodeId nodeid)
bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const
CNodeStateStats nodeStateStats
QStringList columns
NodeLessThan(int nColumn, Qt::SortOrder fOrder)
Qt::SortOrder order
Qt::ItemFlags flags(const QModelIndex &index) const
CNodeStats nodeStats
int columnCount(const QModelIndex &parent) const
interfaces::Node & m_node
PeerTableModel(interfaces::Node &node, ClientModel *parent=0)
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call...
std::unique_ptr< PeerTablePriv > priv
int64_t NodeId
Definition: net.h:88
const CNodeCombinedStats * getNodeStats(int idx)
QModelIndex index(int row, int column, const QModelIndex &parent) const
Model for Bitcoin network client.
Definition: clientmodel.h:44
ClientModel * clientModel
void sort(int column, Qt::SortOrder order)
Top-level interface for a bitcoin node (bsha3d process).
Definition: node.h:35
int rowCount(const QModelIndex &parent) const
QVariant headerData(int section, Qt::Orientation orientation, int role) const