Line data Source code
1 : // Copyright (c) 2011-2013 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_BANTABLEMODEL_H
6 : #define BITCOIN_QT_BANTABLEMODEL_H
7 :
8 : #include "net.h"
9 :
10 : #include <QAbstractTableModel>
11 : #include <QStringList>
12 :
13 : class ClientModel;
14 : class BanTablePriv;
15 :
16 0 : struct CCombinedBan {
17 : CSubNet subnet;
18 : CBanEntry banEntry;
19 : };
20 :
21 : class BannedNodeLessThan
22 : {
23 : public:
24 0 : BannedNodeLessThan(int nColumn, Qt::SortOrder fOrder) :
25 0 : column(nColumn), order(fOrder) {}
26 : bool operator()(const CCombinedBan& left, const CCombinedBan& right) const;
27 :
28 : private:
29 : int column;
30 : Qt::SortOrder order;
31 : };
32 :
33 : /**
34 : Qt model providing information about connected peers, similar to the
35 : "getpeerinfo" RPC call. Used by the rpc console UI.
36 : */
37 0 : class BanTableModel : public QAbstractTableModel
38 : {
39 0 : Q_OBJECT
40 :
41 : public:
42 : explicit BanTableModel(ClientModel *parent = 0);
43 : void startAutoRefresh();
44 : void stopAutoRefresh();
45 :
46 : enum ColumnIndex {
47 : Address = 0,
48 : Bantime = 1
49 : };
50 :
51 : /** @name Methods overridden from QAbstractTableModel
52 : @{*/
53 : int rowCount(const QModelIndex &parent) const;
54 : int columnCount(const QModelIndex &parent) const;
55 : QVariant data(const QModelIndex &index, int role) const;
56 : QVariant headerData(int section, Qt::Orientation orientation, int role) const;
57 : QModelIndex index(int row, int column, const QModelIndex &parent) const;
58 : Qt::ItemFlags flags(const QModelIndex &index) const;
59 : void sort(int column, Qt::SortOrder order);
60 : bool shouldShow();
61 : /*@}*/
62 :
63 : public Q_SLOTS:
64 : void refresh();
65 :
66 : private:
67 : ClientModel *clientModel;
68 : QStringList columns;
69 : BanTablePriv *priv;
70 : };
71 :
72 : #endif // BITCOIN_QT_BANTABLEMODEL_H
|