Anoncoin  0.9.4
P2P Digital Currency
peertablemodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2013 The Bitcoin developers
2 // Copyright (c) 2013-2015 The Anoncoin 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 ANONCOIN_QT_PEERTABLEMODEL_H
7 #define ANONCOIN_QT_PEERTABLEMODEL_H
8 
9 // Many builder specific things set in the config file. Included here in the header, we may need ENABLE_I2PSAM some...
10 // That is if you want I2P support enabled and declared as a new type of available service for peers.
11 #if defined(HAVE_CONFIG_H)
12 #include "config/anoncoin-config.h"
13 #endif
14 
15 #include "main.h"
16 #include "net.h"
17 
18 #include <QAbstractTableModel>
19 #include <QStringList>
20 
21 class ClientModel;
22 class PeerTablePriv;
23 
24 QT_BEGIN_NAMESPACE
25 class QTimer;
26 QT_END_NAMESPACE
27 
32 };
33 
35 {
36 public:
37  NodeLessThan(int nColumn, Qt::SortOrder fOrder) :
38  column(nColumn), order(fOrder) {}
39  bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const;
40 
41 private:
42  int column;
43  Qt::SortOrder order;
44 };
45 
50 class PeerTableModel : public QAbstractTableModel
51 {
52  Q_OBJECT
53 
54 public:
55  explicit PeerTableModel(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  Address = 0,
64  Ping = 2
65  };
66 
69  int rowCount(const QModelIndex &parent) const;
70  int columnCount(const QModelIndex &parent) const;
71  QVariant data(const QModelIndex &index, int role) const;
72  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
73  QModelIndex index(int row, int column, const QModelIndex &parent) const;
74  Qt::ItemFlags flags(const QModelIndex &index) const;
75  void sort(int column, Qt::SortOrder order);
78 public slots:
79  void refresh();
80 
81 private:
83  QStringList columns;
85  QTimer *timer;
86 };
87 
88 #endif // ANONCOIN_QT_PEERTABLEMODEL_H
int getRowByNodeId(NodeId nodeid)
int rowCount(const QModelIndex &parent) const
CNodeStateStats nodeStateStats
int columnCount(const QModelIndex &parent) const
QStringList columns
NodeLessThan(int nColumn, Qt::SortOrder fOrder)
Qt::SortOrder order
CNodeStats nodeStats
PeerTablePriv * priv
QVariant headerData(int section, Qt::Orientation orientation, int role) const
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call...
Qt::ItemFlags flags(const QModelIndex &index) const
const CNodeCombinedStats * getNodeStats(int idx)
bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const
Model for Anoncoin network client.
Definition: clientmodel.h:45
QVariant data(const QModelIndex &index, int role) const
ClientModel * clientModel
QModelIndex index(int row, int column, const QModelIndex &parent) const
int NodeId
Definition: net.h:75
void sort(int column, Qt::SortOrder order)
PeerTableModel(ClientModel *parent=0)