mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-04 10:07:27 -05:00
77e23ca945
6971e790c3
gui: add Direction column to peers tab (Jon Atack) Pull request description: Picking up #289 This adds a `Direction column`, making the peers tab the same as the `Direction/Type` row in the peer details and the direction and type columns in our other user-facing peer connections table in `-netinfo`. Users can now sort the peers table by direction. The default sort is set to inbound, then outbound. | Master | PR | | ----------- | ----------- | | ![Screen Shot 2021-05-05 at 3 51 09 AM](https://user-images.githubusercontent.com/23396902/117111864-38ff9a00-ad56-11eb-889d-f1c838c845e6.png) | ![Screen Shot 2021-05-05 at 3 35 40 AM](https://user-images.githubusercontent.com/23396902/117111892-4157d500-ad56-11eb-82b1-5bd3e88a4cff.png) | ACKs for top commit: jonatack: Tested ACK6971e790c3
ShaMan239: tACK6971e790c3
hebasto: ACK6971e790c3
, tested on Linux Mint 20.2 (Qt 5.12.8). Tree-SHA512: 9716cdedd435f88245a097fed6d4b2b486104d0dd09df739bdb4f2bfad709cbd9c9a231168cc3326e94fa5fddc77dd68f992f20417d04d94930db9fccdbb7de1
112 lines
3.4 KiB
C++
112 lines
3.4 KiB
C++
// Copyright (c) 2011-2020 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifndef BITCOIN_QT_PEERTABLEMODEL_H
|
|
#define BITCOIN_QT_PEERTABLEMODEL_H
|
|
|
|
#include <net_processing.h> // For CNodeStateStats
|
|
#include <net.h>
|
|
|
|
#include <QAbstractTableModel>
|
|
#include <QList>
|
|
#include <QModelIndex>
|
|
#include <QStringList>
|
|
#include <QVariant>
|
|
|
|
class PeerTablePriv;
|
|
|
|
namespace interfaces {
|
|
class Node;
|
|
}
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
class QTimer;
|
|
QT_END_NAMESPACE
|
|
|
|
struct CNodeCombinedStats {
|
|
CNodeStats nodeStats;
|
|
CNodeStateStats nodeStateStats;
|
|
bool fNodeStateStatsAvailable;
|
|
};
|
|
Q_DECLARE_METATYPE(CNodeCombinedStats*)
|
|
|
|
/**
|
|
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(interfaces::Node& node, QObject* parent);
|
|
~PeerTableModel();
|
|
void startAutoRefresh();
|
|
void stopAutoRefresh();
|
|
|
|
enum ColumnIndex {
|
|
NetNodeId = 0,
|
|
Address,
|
|
Direction,
|
|
ConnectionType,
|
|
Network,
|
|
Ping,
|
|
Sent,
|
|
Received,
|
|
Subversion
|
|
};
|
|
|
|
enum {
|
|
StatsRole = Qt::UserRole,
|
|
};
|
|
|
|
/** @name Methods overridden from QAbstractTableModel
|
|
@{*/
|
|
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
|
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
|
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
|
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
|
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
|
/*@}*/
|
|
|
|
public Q_SLOTS:
|
|
void refresh();
|
|
|
|
private:
|
|
//! Internal peer data structure.
|
|
QList<CNodeCombinedStats> m_peers_data{};
|
|
interfaces::Node& m_node;
|
|
const QStringList columns{
|
|
/*: Title of Peers Table column which contains a
|
|
unique number used to identify a connection. */
|
|
tr("Peer"),
|
|
/*: Title of Peers Table column which contains the
|
|
IP/Onion/I2P address of the connected peer. */
|
|
tr("Address"),
|
|
/*: Title of Peers Table column which indicates the direction
|
|
the peer connection was initiated from. */
|
|
tr("Direction"),
|
|
/*: Title of Peers Table column which describes the type of
|
|
peer connection. The "type" describes why the connection exists. */
|
|
tr("Type"),
|
|
/*: Title of Peers Table column which states the network the peer
|
|
connected through. */
|
|
tr("Network"),
|
|
/*: Title of Peers Table column which indicates the current latency
|
|
of the connection with the peer. */
|
|
tr("Ping"),
|
|
/*: Title of Peers Table column which indicates the total amount of
|
|
network information we have sent to the peer. */
|
|
tr("Sent"),
|
|
/*: Title of Peers Table column which indicates the total amount of
|
|
network information we have received from the peer. */
|
|
tr("Received"),
|
|
/*: Title of Peers Table column which contains the peer's
|
|
User Agent string. */
|
|
tr("User Agent")};
|
|
QTimer *timer;
|
|
};
|
|
|
|
#endif // BITCOIN_QT_PEERTABLEMODEL_H
|