Raven Core  3.0.0
P2P Digital Currency
peertablemodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2016 The Bitcoin Core developers
2 // Copyright (c) 2017-2019 The Raven Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef RAVEN_QT_PEERTABLEMODEL_H
7 #define RAVEN_QT_PEERTABLEMODEL_H
8 
9 #include "net_processing.h" // For CNodeStateStats
10 #include "net.h"
11 
12 #include <QAbstractTableModel>
13 #include <QStringList>
14 
15 class ClientModel;
16 class PeerTablePriv;
17 
18 QT_BEGIN_NAMESPACE
19 class QTimer;
20 QT_END_NAMESPACE
21 
26 };
27 
29 {
30 public:
31  NodeLessThan(int nColumn, Qt::SortOrder fOrder) :
32  column(nColumn), order(fOrder) {}
33  bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const;
34 
35 private:
36  int column;
37  Qt::SortOrder order;
38 };
39 
44 class PeerTableModel : public QAbstractTableModel
45 {
46  Q_OBJECT
47 
48 public:
49  explicit PeerTableModel(ClientModel *parent = 0);
50  ~PeerTableModel();
51  const CNodeCombinedStats *getNodeStats(int idx);
52  int getRowByNodeId(NodeId nodeid);
53  void startAutoRefresh();
54  void stopAutoRefresh();
55 
56  enum ColumnIndex {
57  NetNodeId = 0,
58  Address = 1,
59  Ping = 2,
60  Sent = 3,
61  Received = 4,
62  Subversion = 5
63  };
64 
67  int rowCount(const QModelIndex &parent) const;
68  int columnCount(const QModelIndex &parent) const;
69  QVariant data(const QModelIndex &index, int role) const;
70  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
71  QModelIndex index(int row, int column, const QModelIndex &parent) const;
72  Qt::ItemFlags flags(const QModelIndex &index) const;
73  void sort(int column, Qt::SortOrder order);
76 public Q_SLOTS:
77  void refresh();
78 
79 private:
81  QStringList columns;
82  std::unique_ptr<PeerTablePriv> priv;
83  QTimer *timer;
84 };
85 
86 #endif // RAVEN_QT_PEERTABLEMODEL_H
CNodeStateStats nodeStateStats
int flags
Definition: raven-tx.cpp:500
QStringList columns
NodeLessThan(int nColumn, Qt::SortOrder fOrder)
Qt::SortOrder order
CNodeStats nodeStats
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call...
std::unique_ptr< PeerTablePriv > priv
int64_t NodeId
Definition: net.h:93
Model for Raven network client.
Definition: clientmodel.h:39
ClientModel * clientModel