Changeset View
Changeset View
Standalone View
Standalone View
src/qt/peertablemodel.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_PEERTABLEMODEL_H | #ifndef BITCOIN_QT_PEERTABLEMODEL_H | ||||
#define BITCOIN_QT_PEERTABLEMODEL_H | #define BITCOIN_QT_PEERTABLEMODEL_H | ||||
#include "net.h" | #include <net.h> | ||||
#include "net_processing.h" // For CNodeStateStats | #include <net_processing.h> // For CNodeStateStats | ||||
#include <QAbstractTableModel> | #include <QAbstractTableModel> | ||||
#include <QStringList> | #include <QStringList> | ||||
class ClientModel; | class ClientModel; | ||||
class PeerTablePriv; | class PeerTablePriv; | ||||
namespace interfaces { | |||||
class Node; | |||||
} | |||||
QT_BEGIN_NAMESPACE | QT_BEGIN_NAMESPACE | ||||
class QTimer; | class QTimer; | ||||
QT_END_NAMESPACE | QT_END_NAMESPACE | ||||
struct CNodeCombinedStats { | struct CNodeCombinedStats { | ||||
CNodeStats nodeStats; | CNodeStats nodeStats; | ||||
CNodeStateStats nodeStateStats; | CNodeStateStats nodeStateStats; | ||||
bool fNodeStateStatsAvailable; | bool fNodeStateStatsAvailable; | ||||
Show All 14 Lines | |||||
/** | /** | ||||
* 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 PeerTableModel : public QAbstractTableModel { | class PeerTableModel : public QAbstractTableModel { | ||||
Q_OBJECT | Q_OBJECT | ||||
public: | public: | ||||
explicit PeerTableModel(ClientModel *parent = 0); | explicit PeerTableModel(interfaces::Node &node, ClientModel *parent = 0); | ||||
~PeerTableModel(); | ~PeerTableModel(); | ||||
const CNodeCombinedStats *getNodeStats(int idx); | const CNodeCombinedStats *getNodeStats(int idx); | ||||
int getRowByNodeId(NodeId nodeid); | int getRowByNodeId(NodeId nodeid); | ||||
void startAutoRefresh(); | void startAutoRefresh(); | ||||
void stopAutoRefresh(); | void stopAutoRefresh(); | ||||
enum ColumnIndex { | enum ColumnIndex { | ||||
NetNodeId = 0, | NetNodeId = 0, | ||||
Show All 16 Lines | public: | ||||
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; | ||||
/*@}*/ | /*@}*/ | ||||
public Q_SLOTS: | public Q_SLOTS: | ||||
void refresh(); | void refresh(); | ||||
private: | private: | ||||
interfaces::Node &m_node; | |||||
ClientModel *clientModel; | ClientModel *clientModel; | ||||
QStringList columns; | QStringList columns; | ||||
std::unique_ptr<PeerTablePriv> priv; | std::unique_ptr<PeerTablePriv> priv; | ||||
QTimer *timer; | QTimer *timer; | ||||
}; | }; | ||||
#endif // BITCOIN_QT_PEERTABLEMODEL_H | #endif // BITCOIN_QT_PEERTABLEMODEL_H |