Bitcoin Core  0.20.99
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);
48  ~BanTableModel();
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
CSubNet subnet
Definition: bantablemodel.h:22
QStringList columns
Definition: bantablemodel.h:75
std::unique_ptr< BanTablePriv > priv
Definition: bantablemodel.h:76
interfaces::Node & m_node
Definition: bantablemodel.h:74
int flags
Definition: bitcoin-tx.cpp:506
BannedNodeLessThan(int nColumn, Qt::SortOrder fOrder)
Definition: bantablemodel.h:29
Qt model providing information about connected peers, similar to the "getpeerinfo" RPC call...
Definition: bantablemodel.h:42
CBanEntry banEntry
Definition: bantablemodel.h:23
Definition: addrdb.h:20
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:52
Qt::SortOrder order
Definition: bantablemodel.h:35