Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

peertablemodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2015 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 QT_BEGIN_NAMESPACE
20 class QTimer;
21 QT_END_NAMESPACE
22 
27 };
28 
30 {
31 public:
32  NodeLessThan(int nColumn, Qt::SortOrder fOrder) :
33  column(nColumn), order(fOrder) {}
34  bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const;
35 
36 private:
37  int column;
38  Qt::SortOrder order;
39 };
40 
45 class PeerTableModel : public QAbstractTableModel
46 {
47  Q_OBJECT
48 
49 public:
50  explicit PeerTableModel(ClientModel *parent = 0);
52  const CNodeCombinedStats *getNodeStats(int idx);
53  int getRowByNodeId(NodeId nodeid);
54  void startAutoRefresh();
55  void stopAutoRefresh();
56 
57  enum ColumnIndex {
58  NetNodeId = 0,
59  Address = 1,
60  Ping = 2,
61  Sent = 3,
62  Received = 4,
64  };
65 
68  int rowCount(const QModelIndex &parent) const;
69  int columnCount(const QModelIndex &parent) const;
70  QVariant data(const QModelIndex &index, int role) const;
71  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
72  QModelIndex index(int row, int column, const QModelIndex &parent) const;
73  Qt::ItemFlags flags(const QModelIndex &index) const;
74  void sort(int column, Qt::SortOrder order);
77 public Q_SLOTS:
78  void refresh();
79 
80 private:
82  QStringList columns;
83  std::unique_ptr<PeerTablePriv> priv;
84  QTimer *timer;
85 };
86 
87 #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
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call...
std::unique_ptr< PeerTablePriv > priv
int64_t NodeId
Definition: net.h:109
const CNodeCombinedStats * getNodeStats(int idx)
QModelIndex index(int row, int column, const QModelIndex &parent) const
Model for Dash network client.
Definition: clientmodel.h:42
ClientModel * clientModel
void sort(int column, Qt::SortOrder order)
PeerTableModel(ClientModel *parent=0)
int rowCount(const QModelIndex &parent) const
QVariant headerData(int section, Qt::Orientation orientation, int role) const
Released under the MIT license