aboutsummaryrefslogtreecommitdiff
path: root/src/qt/peertablemodel.h
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-06-07 22:10:17 +0300
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-06-07 22:13:05 +0300
commite638acf6970394f8eb1957366ad2d39512f33b31 (patch)
tree355cf50ea72f45b97599d1a6e4a6e79dcbfc3635 /src/qt/peertablemodel.h
parent359f72105ba0184fbf998dfd84217c4229dc54ad (diff)
parentecbd91153875c8cdd5b92b840afc116f65e457fb (diff)
downloadbitcoin-e638acf6970394f8eb1957366ad2d39512f33b31.tar.xz
Merge bitcoin-core/gui#164: Handle peer addition/removal in a right way
ecbd91153875c8cdd5b92b840afc116f65e457fb qt: Handle peer addition/removal in a right way (Hennadii Stepanov) 1b66f6e556631a1a2d89aefba70a79894bd14fcd qt: Drop PeerTablePriv class (Hennadii Stepanov) efb7e5aa962d4a4047061996bbb50b6da4592cbc qt, refactor: Use default arguments for overridden functions (Hennadii Stepanov) Pull request description: This PR makes `PeerTableModel` handle a peer addition/removal in a right way. See: - https://doc.qt.io/qt-5/model-view-programming.html#inserting-and-removing-rows - https://doc.qt.io/qt-5/model-view-programming.html#resizable-models Fixes #160. Fixes #191. ACKs for top commit: jarolrod: re-ACK ecbd911 promag: reACK ecbd91153875c8cdd5b92b840afc116f65e457fb just improvements to the comment since last review. Tree-SHA512: 074935d67f78561724218e8b33822e2de16749f873c29054926b720ffcd642f08249a222b563983cf65a9b716290aa14e2372c47fc04e5f401f759db25ca710f
Diffstat (limited to 'src/qt/peertablemodel.h')
-rw-r--r--src/qt/peertablemodel.h21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/qt/peertablemodel.h b/src/qt/peertablemodel.h
index 3d195342f1..0ff1b5dba7 100644
--- a/src/qt/peertablemodel.h
+++ b/src/qt/peertablemodel.h
@@ -8,10 +8,11 @@
#include <net_processing.h> // For CNodeStateStats
#include <net.h>
-#include <memory>
-
#include <QAbstractTableModel>
+#include <QList>
+#include <QModelIndex>
#include <QStringList>
+#include <QVariant>
class PeerTablePriv;
@@ -61,18 +62,23 @@ public:
/** @name Methods overridden from QAbstractTableModel
@{*/
- int rowCount(const QModelIndex &parent) const override;
- int columnCount(const QModelIndex &parent) const override;
- QVariant data(const QModelIndex &index, int role) const override;
- QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
- QModelIndex index(int row, int column, const QModelIndex &parent) const override;
+ 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();
+Q_SIGNALS:
+ void changed();
+
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
@@ -99,7 +105,6 @@ private:
/*: Title of Peers Table column which contains the peer's
User Agent string. */
tr("User Agent")};
- std::unique_ptr<PeerTablePriv> priv;
QTimer *timer;
};