1 // Copyright (c) 2011-2017 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
11 #include <QAbstractTableModel>
12 #include <QStringList>
21 struct CNodeCombinedStats
{
23 CNodeStateStats nodeStateStats
;
24 bool fNodeStateStatsAvailable
;
30 NodeLessThan(int nColumn
, Qt::SortOrder fOrder
) :
31 column(nColumn
), order(fOrder
) {}
32 bool operator()(const CNodeCombinedStats
&left
, const CNodeCombinedStats
&right
) const;
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
48 explicit PeerTableModel(ClientModel
*parent
= 0);
50 const CNodeCombinedStats
*getNodeStats(int idx
);
51 int getRowByNodeId(NodeId nodeid
);
52 void startAutoRefresh();
53 void stopAutoRefresh();
64 /** @name Methods overridden from QAbstractTableModel
66 int rowCount(const QModelIndex
&parent
) const;
67 int columnCount(const QModelIndex
&parent
) const;
68 QVariant
data(const QModelIndex
&index
, int role
) const;
69 QVariant
headerData(int section
, Qt::Orientation orientation
, int role
) const;
70 QModelIndex
index(int row
, int column
, const QModelIndex
&parent
) const;
71 Qt::ItemFlags
flags(const QModelIndex
&index
) const;
72 void sort(int column
, Qt::SortOrder order
);
79 ClientModel
*clientModel
;
81 std::unique_ptr
<PeerTablePriv
> priv
;
85 #endif // BITCOIN_QT_PEERTABLEMODEL_H