Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bantablemodel.h
// Copyright (c) 2011-2016 The Bitcoin Core developers | // Copyright (c) 2011-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_QT_BANTABLEMODEL_H | #ifndef BITCOIN_QT_BANTABLEMODEL_H | ||||
#define BITCOIN_QT_BANTABLEMODEL_H | #define BITCOIN_QT_BANTABLEMODEL_H | ||||
#include "net.h" | #include "net.h" | ||||
#include <QAbstractTableModel> | #include <QAbstractTableModel> | ||||
#include <QStringList> | #include <QStringList> | ||||
class ClientModel; | class ClientModel; | ||||
class BanTablePriv; | class BanTablePriv; | ||||
namespace interface { | |||||
class Node; | |||||
} | |||||
struct CCombinedBan { | struct CCombinedBan { | ||||
CSubNet subnet; | CSubNet subnet; | ||||
CBanEntry banEntry; | CBanEntry banEntry; | ||||
}; | }; | ||||
class BannedNodeLessThan { | class BannedNodeLessThan { | ||||
public: | public: | ||||
BannedNodeLessThan(int nColumn, Qt::SortOrder fOrder) | BannedNodeLessThan(int nColumn, Qt::SortOrder fOrder) | ||||
: column(nColumn), order(fOrder) {} | : column(nColumn), order(fOrder) {} | ||||
bool operator()(const CCombinedBan &left, const CCombinedBan &right) const; | bool operator()(const CCombinedBan &left, const CCombinedBan &right) const; | ||||
private: | private: | ||||
int column; | int column; | ||||
Qt::SortOrder order; | Qt::SortOrder order; | ||||
}; | }; | ||||
/** | /** | ||||
Qt model providing information about connected peers, similar to the | Qt model providing information about connected peers, similar to the | ||||
"getpeerinfo" RPC call. Used by the rpc console UI. | "getpeerinfo" RPC call. Used by the rpc console UI. | ||||
*/ | */ | ||||
class BanTableModel : public QAbstractTableModel { | class BanTableModel : public QAbstractTableModel { | ||||
Q_OBJECT | Q_OBJECT | ||||
public: | public: | ||||
explicit BanTableModel(ClientModel *parent = 0); | explicit BanTableModel(interface::Node &node, ClientModel *parent = 0); | ||||
~BanTableModel(); | ~BanTableModel(); | ||||
void startAutoRefresh(); | void startAutoRefresh(); | ||||
void stopAutoRefresh(); | void stopAutoRefresh(); | ||||
enum ColumnIndex { Address = 0, Bantime = 1 }; | enum ColumnIndex { Address = 0, Bantime = 1 }; | ||||
/** @name Methods overridden from QAbstractTableModel | /** @name Methods overridden from QAbstractTableModel | ||||
@{*/ | @{*/ | ||||
int rowCount(const QModelIndex &parent) const override; | int rowCount(const QModelIndex &parent) const override; | ||||
int columnCount(const QModelIndex &parent) const override; | int columnCount(const QModelIndex &parent) const override; | ||||
QVariant data(const QModelIndex &index, int role) const override; | QVariant data(const QModelIndex &index, int role) const override; | ||||
QVariant headerData(int section, Qt::Orientation orientation, | QVariant headerData(int section, Qt::Orientation orientation, | ||||
int role) const override; | int role) const override; | ||||
QModelIndex index(int row, int column, | QModelIndex index(int row, int column, | ||||
const QModelIndex &parent) const override; | const QModelIndex &parent) const override; | ||||
Qt::ItemFlags flags(const QModelIndex &index) const override; | Qt::ItemFlags flags(const QModelIndex &index) const override; | ||||
void sort(int column, Qt::SortOrder order) override; | void sort(int column, Qt::SortOrder order) override; | ||||
bool shouldShow(); | bool shouldShow(); | ||||
/*@}*/ | /*@}*/ | ||||
public Q_SLOTS: | public Q_SLOTS: | ||||
void refresh(); | void refresh(); | ||||
private: | private: | ||||
interface::Node &m_node; | |||||
ClientModel *clientModel; | ClientModel *clientModel; | ||||
QStringList columns; | QStringList columns; | ||||
std::unique_ptr<BanTablePriv> priv; | std::unique_ptr<BanTablePriv> priv; | ||||
}; | }; | ||||
#endif // BITCOIN_QT_BANTABLEMODEL_H | #endif // BITCOIN_QT_BANTABLEMODEL_H |