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 <addrdb.h>
9 #include <net.h>
10 
11 #include <memory>
12 
13 #include <QAbstractTableModel>
14 #include <QStringList>
15 
16 class BanTablePriv;
17 
18 namespace interfaces {
19  class Node;
20 }
21 
22 struct CCombinedBan {
25 };
26 
28 {
29 public:
30  BannedNodeLessThan(int nColumn, Qt::SortOrder fOrder) :
31  column(nColumn), order(fOrder) {}
32  bool operator()(const CCombinedBan& left, const CCombinedBan& right) const;
33 
34 private:
35  int column;
36  Qt::SortOrder order;
37 };
38 
43 class BanTableModel : public QAbstractTableModel
44 {
45  Q_OBJECT
46 
47 public:
48  explicit BanTableModel(interfaces::Node& node, QObject* parent);
50  void startAutoRefresh();
51  void stopAutoRefresh();
52 
53  enum ColumnIndex {
54  Address = 0,
55  Bantime = 1
56  };
57 
60  int rowCount(const QModelIndex &parent) const override;
61  int columnCount(const QModelIndex &parent) const override;
62  QVariant data(const QModelIndex &index, int role) const override;
63  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
64  QModelIndex index(int row, int column, const QModelIndex &parent) const override;
65  Qt::ItemFlags flags(const QModelIndex &index) const override;
66  void sort(int column, Qt::SortOrder order) override;
69  bool shouldShow();
70 
71 public Q_SLOTS:
72  void refresh();
73 
74 private:
76  QStringList columns;
77  std::unique_ptr<BanTablePriv> priv;
78 };
79 
80 #endif // BITCOIN_QT_BANTABLEMODEL_H
interfaces
Definition: dummywallet.cpp:11
CCombinedBan
Definition: bantablemodel.h:22
BanTableModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Definition: bantablemodel.cpp:136
CCombinedBan::banEntry
CBanEntry banEntry
Definition: bantablemodel.h:24
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:36
BanTableModel
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call.
Definition: bantablemodel.h:43
BanTableModel::Bantime
@ Bantime
Definition: bantablemodel.h:55
BanTableModel::BanTableModel
BanTableModel(interfaces::Node &node, QObject *parent)
Definition: bantablemodel.cpp:81
addrdb.h
CCombinedBan::subnet
CSubNet subnet
Definition: bantablemodel.h:23
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:486
BanTableModel::ColumnIndex
ColumnIndex
Definition: bantablemodel.h:53
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:27
BanTableModel::priv
std::unique_ptr< BanTablePriv > priv
Definition: bantablemodel.h:77
BannedNodeLessThan::BannedNodeLessThan
BannedNodeLessThan(int nColumn, Qt::SortOrder fOrder)
Definition: bantablemodel.h:30
BanTableModel::columnCount
int columnCount(const QModelIndex &parent) const override
Definition: bantablemodel.cpp:105
CBanEntry
Definition: net_types.h:14
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:75
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:35
BanTableModel::columns
QStringList columns
Definition: bantablemodel.h:76
BanTablePriv
Definition: bantablemodel.cpp:36
BanTableModel::Address
@ Address
Definition: bantablemodel.h:54