PIVX Core  5.6.99
P2P Digital Currency
peertablemodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2013 The Bitcoin developers
2 // Copyright (c) 2017-2020 The PIVX Core developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef PIVX_QT_PEERTABLEMODEL_H
7 #define PIVX_QT_PEERTABLEMODEL_H
8 
9 #include "net.h"
10 #include "net_processing.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) : column(nColumn), order(fOrder) {}
32  bool operator()(const CNodeCombinedStats& left, const CNodeCombinedStats& right) const;
33 
34 private:
35  int column;
36  Qt::SortOrder order;
37 };
38 
43 class PeerTableModel : public QAbstractTableModel
44 {
45  Q_OBJECT
46 
47 public:
48  explicit PeerTableModel(ClientModel* parent = 0);
49  const CNodeCombinedStats* getNodeStats(int idx);
50  int getRowByNodeId(NodeId nodeid);
51  void startAutoRefresh();
52  void stopAutoRefresh();
53 
54  enum ColumnIndex {
55  NetNodeId = 0,
56  Address = 1,
58  Ping = 3
59  };
60 
63  int rowCount(const QModelIndex& parent) const;
64  int columnCount(const QModelIndex& parent) const;
65  QVariant data(const QModelIndex& index, int role) const;
66  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
67  QModelIndex index(int row, int column, const QModelIndex& parent) const;
68  Qt::ItemFlags flags(const QModelIndex& index) const;
69  void sort(int column, Qt::SortOrder order);
72 public Q_SLOTS:
73  void refresh();
74 
75 private:
77  QStringList columns;
79  QTimer* timer;
80 };
81 
82 #endif // PIVX_QT_PEERTABLEMODEL_H
Model for PIVX network client.
Definition: clientmodel.h:50
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.
QModelIndex index(int row, int column, const QModelIndex &parent) const
ClientModel * clientModel
QVariant data(const QModelIndex &index, int role) const
int rowCount(const QModelIndex &parent) const
QStringList columns
PeerTableModel(ClientModel *parent=0)
const CNodeCombinedStats * getNodeStats(int idx)
int getRowByNodeId(NodeId nodeid)
PeerTablePriv * priv
QVariant headerData(int section, Qt::Orientation orientation, int role) const
void sort(int column, Qt::SortOrder order)
Qt::ItemFlags flags(const QModelIndex &index) const
int columnCount(const QModelIndex &parent) const
int NodeId
Definition: net.h:109
CNodeStateStats nodeStateStats
CNodeStats nodeStats