Files
thehub/hub-qt/peertablemodel.h
T

96 lines
2.5 KiB
C++
Raw Permalink Normal View History

2017-11-09 19:34:51 +01:00
/*
* This file is part of the Flowee project
* Copyright (C) 2011-2015 The Bitcoin Core developers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2014-05-23 12:09:59 -05:00
2018-01-16 10:47:52 +00:00
#ifndef FLOWEE_QT_PEERTABLEMODEL_H
#define FLOWEE_QT_PEERTABLEMODEL_H
2014-05-23 12:09:59 -05:00
#include "main.h" // For CNodeStateStats
2014-05-23 12:09:59 -05:00
#include "net.h"
#include <QAbstractTableModel>
#include <QStringList>
class ClientModel;
class PeerTablePriv;
2014-05-23 12:09:59 -05:00
QT_BEGIN_NAMESPACE
2014-05-23 12:09:59 -05:00
class QTimer;
QT_END_NAMESPACE
2014-05-23 12:09:59 -05:00
struct CNodeCombinedStats {
2014-06-04 12:06:18 +02:00
CNodeStats nodeStats;
CNodeStateStats nodeStateStats;
bool fNodeStateStatsAvailable;
2014-05-23 12:09:59 -05:00
};
class NodeLessThan
{
public:
NodeLessThan(int nColumn, Qt::SortOrder fOrder) :
2014-05-23 12:09:59 -05:00
column(nColumn), order(fOrder) {}
bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const;
private:
int column;
Qt::SortOrder order;
};
/**
Qt model providing information about connected peers, similar to the
"getpeerinfo" RPC call. Used by the rpc console UI.
*/
class PeerTableModel : public QAbstractTableModel
{
Q_OBJECT
public:
explicit PeerTableModel(ClientModel *parent = 0);
const CNodeCombinedStats *getNodeStats(int idx);
int getRowByNodeId(NodeId nodeid);
2014-06-04 12:06:18 +02:00
void startAutoRefresh();
2014-05-23 12:09:59 -05:00
void stopAutoRefresh();
enum ColumnIndex {
Address = 0,
Subversion = 1,
2014-06-04 12:06:18 +02:00
Ping = 2
2014-05-23 12:09:59 -05:00
};
/** @name Methods overridden from QAbstractTableModel
@{*/
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QModelIndex index(int row, int column, const QModelIndex &parent) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
void sort(int column, Qt::SortOrder order);
/*@}*/
2015-07-14 13:59:05 +02:00
public Q_SLOTS:
2014-05-23 12:09:59 -05:00
void refresh();
private:
ClientModel *clientModel;
QStringList columns;
PeerTablePriv *priv;
QTimer *timer;
};
2018-01-16 10:47:52 +00:00
#endif