LCOV - code coverage report
Current view: top level - src/qt - peertablemodel.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 0 4 0.0 %
Date: 2020-09-26 01:30:44 Functions: 0 12 0.0 %

          Line data    Source code
       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_PEERTABLEMODEL_H
       6             : #define BITCOIN_QT_PEERTABLEMODEL_H
       7             : 
       8             : #include <net_processing.h> // For CNodeStateStats
       9             : #include <net.h>
      10             : 
      11             : #include <memory>
      12             : 
      13             : #include <QAbstractTableModel>
      14             : #include <QStringList>
      15             : 
      16             : class PeerTablePriv;
      17             : 
      18             : namespace interfaces {
      19             : class Node;
      20             : }
      21             : 
      22             : QT_BEGIN_NAMESPACE
      23             : class QTimer;
      24             : QT_END_NAMESPACE
      25             : 
      26           0 : struct CNodeCombinedStats {
      27             :     CNodeStats nodeStats;
      28             :     CNodeStateStats nodeStateStats;
      29             :     bool fNodeStateStatsAvailable;
      30             : };
      31             : 
      32             : class NodeLessThan
      33             : {
      34             : public:
      35           0 :     NodeLessThan(int nColumn, Qt::SortOrder fOrder) :
      36           0 :         column(nColumn), order(fOrder) {}
      37             :     bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const;
      38             : 
      39             : private:
      40             :     int column;
      41             :     Qt::SortOrder order;
      42             : };
      43             : 
      44             : /**
      45             :    Qt model providing information about connected peers, similar to the
      46             :    "getpeerinfo" RPC call. Used by the rpc console UI.
      47             :  */
      48             : class PeerTableModel : public QAbstractTableModel
      49             : {
      50           0 :     Q_OBJECT
      51             : 
      52             : public:
      53             :     explicit PeerTableModel(interfaces::Node& node, QObject* parent);
      54             :     ~PeerTableModel();
      55             :     const CNodeCombinedStats *getNodeStats(int idx);
      56             :     int getRowByNodeId(NodeId nodeid);
      57             :     void startAutoRefresh();
      58             :     void stopAutoRefresh();
      59             : 
      60             :     enum ColumnIndex {
      61             :         NetNodeId = 0,
      62             :         Address = 1,
      63             :         Ping = 2,
      64             :         Sent = 3,
      65             :         Received = 4,
      66             :         Subversion = 5
      67             :     };
      68             : 
      69             :     /** @name Methods overridden from QAbstractTableModel
      70             :         @{*/
      71             :     int rowCount(const QModelIndex &parent) const override;
      72             :     int columnCount(const QModelIndex &parent) const override;
      73             :     QVariant data(const QModelIndex &index, int role) const override;
      74             :     QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
      75             :     QModelIndex index(int row, int column, const QModelIndex &parent) const override;
      76             :     Qt::ItemFlags flags(const QModelIndex &index) const override;
      77             :     void sort(int column, Qt::SortOrder order) override;
      78             :     /*@}*/
      79             : 
      80             : public Q_SLOTS:
      81             :     void refresh();
      82             : 
      83             : private:
      84             :     interfaces::Node& m_node;
      85             :     QStringList columns;
      86             :     std::unique_ptr<PeerTablePriv> priv;
      87             :     QTimer *timer;
      88             : };
      89             : 
      90             : #endif // BITCOIN_QT_PEERTABLEMODEL_H

Generated by: LCOV version 1.15