Add const to methods that do not modify the object for which it is called
[bitcoinplatinum.git] / src / qt / peertablemodel.h
blobcc47b67ec9b07f47f1e7518ad77aeef4a35a2088
1 // Copyright (c) 2011-2016 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.
5 #ifndef BITCOIN_QT_PEERTABLEMODEL_H
6 #define BITCOIN_QT_PEERTABLEMODEL_H
8 #include "net_processing.h" // For CNodeStateStats
9 #include "net.h"
11 #include <QAbstractTableModel>
12 #include <QStringList>
14 class ClientModel;
15 class PeerTablePriv;
17 QT_BEGIN_NAMESPACE
18 class QTimer;
19 QT_END_NAMESPACE
21 struct CNodeCombinedStats {
22 CNodeStats nodeStats;
23 CNodeStateStats nodeStateStats;
24 bool fNodeStateStatsAvailable;
27 class NodeLessThan
29 public:
30 NodeLessThan(int nColumn, Qt::SortOrder fOrder) :
31 column(nColumn), order(fOrder) {}
32 bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const;
34 private:
35 int column;
36 Qt::SortOrder order;
39 /**
40 Qt model providing information about connected peers, similar to the
41 "getpeerinfo" RPC call. Used by the rpc console UI.
43 class PeerTableModel : public QAbstractTableModel
45 Q_OBJECT
47 public:
48 explicit PeerTableModel(ClientModel *parent = 0);
49 ~PeerTableModel();
50 const CNodeCombinedStats *getNodeStats(int idx);
51 int getRowByNodeId(NodeId nodeid);
52 void startAutoRefresh();
53 void stopAutoRefresh();
55 enum ColumnIndex {
56 NetNodeId = 0,
57 Address = 1,
58 Subversion = 2,
59 Ping = 3
62 /** @name Methods overridden from QAbstractTableModel
63 @{*/
64 int rowCount(const QModelIndex &parent) const;
65 int columnCount(const QModelIndex &parent) const;
66 QVariant data(const QModelIndex &index, int role) const;
67 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
68 QModelIndex index(int row, int column, const QModelIndex &parent) const;
69 Qt::ItemFlags flags(const QModelIndex &index) const;
70 void sort(int column, Qt::SortOrder order);
71 /*@}*/
73 public Q_SLOTS:
74 void refresh();
76 private:
77 ClientModel *clientModel;
78 QStringList columns;
79 std::unique_ptr<PeerTablePriv> priv;
80 QTimer *timer;
83 #endif // BITCOIN_QT_PEERTABLEMODEL_H