Bitcoin Core  22.99.0
P2P Digital Currency
bantablemodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2020 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 <memory>
11 
12 #include <QAbstractTableModel>
13 #include <QStringList>
14 
15 class BanTablePriv;
16 
17 namespace interfaces {
18  class Node;
19 }
20 
21 struct CCombinedBan {
24 };
25 
27 {
28 public:
29  BannedNodeLessThan(int nColumn, Qt::SortOrder fOrder) :
30  column(nColumn), order(fOrder) {}
31  bool operator()(const CCombinedBan& left, const CCombinedBan& right) const;
32 
33 private:
34  int column;
35  Qt::SortOrder order;
36 };
37 
42 class BanTableModel : public QAbstractTableModel
43 {
44  Q_OBJECT
45 
46 public:
47  explicit BanTableModel(interfaces::Node& node, QObject* parent);
49  void startAutoRefresh();
50  void stopAutoRefresh();
51 
52  enum ColumnIndex {
53  Address = 0,
54  Bantime = 1
55  };
56 
59  int rowCount(const QModelIndex &parent) const override;
60  int columnCount(const QModelIndex &parent) const override;
61  QVariant data(const QModelIndex &index, int role) const override;
62  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
63  QModelIndex index(int row, int column, const QModelIndex &parent) const override;
64  Qt::ItemFlags flags(const QModelIndex &index) const override;
65  void sort(int column, Qt::SortOrder order) override;
68  bool shouldShow();
69 
70 public Q_SLOTS:
71  void refresh();
72 
73 private:
75  QStringList columns;
76  std::unique_ptr<BanTablePriv> priv;
77 };
78 
79 #endif // BITCOIN_QT_BANTABLEMODEL_H
interfaces
Definition: dummywallet.cpp:10
CCombinedBan
Definition: bantablemodel.h:21
BanTableModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Definition: bantablemodel.cpp:136
CCombinedBan::banEntry
CBanEntry banEntry
Definition: bantablemodel.h:23
BannedNodeLessThan::operator()
bool operator()(const CCombinedBan &left, const CCombinedBan &right) const
Definition: bantablemodel.cpp:18
BanTableModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: bantablemodel.cpp:148
BannedNodeLessThan::order
Qt::SortOrder order
Definition: bantablemodel.h:35
BanTableModel
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call.
Definition: bantablemodel.h:42
BanTableModel::Bantime
@ Bantime
Definition: bantablemodel.h:54
BanTableModel::BanTableModel
BanTableModel(interfaces::Node &node, QObject *parent)
Definition: bantablemodel.cpp:81
CCombinedBan::subnet
CSubNet subnet
Definition: bantablemodel.h:22
BanTableModel::startAutoRefresh
void startAutoRefresh()
BanTableModel::sort
void sort(int column, Qt::SortOrder order) override
Definition: bantablemodel.cpp:173
BanTableModel::stopAutoRefresh
void stopAutoRefresh()
BanTableModel::~BanTableModel
~BanTableModel()
Definition: bantablemodel.cpp:92
CSubNet
Definition: netaddress.h:489
BanTableModel::ColumnIndex
ColumnIndex
Definition: bantablemodel.h:52
interfaces::Node
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:54
BanTableModel::shouldShow
bool shouldShow()
Definition: bantablemodel.cpp:180
BanTableModel::index
QModelIndex index(int row, int column, const QModelIndex &parent) const override
Definition: bantablemodel.cpp:156
BannedNodeLessThan
Definition: bantablemodel.h:26
BanTableModel::priv
std::unique_ptr< BanTablePriv > priv
Definition: bantablemodel.h:76
BannedNodeLessThan::BannedNodeLessThan
BannedNodeLessThan(int nColumn, Qt::SortOrder fOrder)
Definition: bantablemodel.h:29
BanTableModel::columnCount
int columnCount(const QModelIndex &parent) const override
Definition: bantablemodel.cpp:105
CBanEntry
Definition: addrdb.h:21
node
Definition: interfaces.cpp:68
BanTableModel::rowCount
int rowCount(const QModelIndex &parent) const override
Definition: bantablemodel.cpp:97
BanTableModel::m_node
interfaces::Node & m_node
Definition: bantablemodel.h:74
BanTableModel::data
QVariant data(const QModelIndex &index, int role) const override
Definition: bantablemodel.cpp:113
BanTableModel::refresh
void refresh()
Definition: bantablemodel.cpp:166
BannedNodeLessThan::column
int column
Definition: bantablemodel.h:34
BanTableModel::columns
QStringList columns
Definition: bantablemodel.h:75
BanTablePriv
Definition: bantablemodel.cpp:36
BanTableModel::Address
@ Address
Definition: bantablemodel.h:53