diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2021-07-06 00:00:33 +0300 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2021-07-06 00:02:49 +0300 |
commit | a62fc35a150da584d39d7cd01ade14bbb5002fb9 (patch) | |
tree | 1067ca830ee185c9a2f921d0630d5712088eb8f1 /src/qt | |
parent | 484d4ee226e2bbb2ab175cb1abe4e13b98489ead (diff) | |
parent | 986bf78d7e8fd9b69841ecb0decaff840efe9cff (diff) |
Merge bitcoin-core/gui#375: Emit dataChanged signal to dynamically re-sort Peers table
986bf78d7e8fd9b69841ecb0decaff840efe9cff qt: Emit dataChanged signal to dynamically re-sort Peers table (Hennadii Stepanov)
Pull request description:
[By default](https://doc.qt.io/qt-5/qsortfilterproxymodel.html#details), the `PeerTableSortProxy`
> dynamically re-sorts ... data whenever the original model changes.
That is not the case on master (8cdf91735f2bdc55577d84a9915f5920ce23b00a) as in ecbd91153875c8cdd5b92b840afc116f65e457fb (#164) no signals are emitted to notify about model changes.
This PR uses a dedicated [`dataChanged`](https://doc.qt.io/qt-5/qabstractitemmodel.html#dataChanged) signal.
Fixes #367.
An alternative to #374.
ACKs for top commit:
jarolrod:
ACK 986bf78d7e8fd9b69841ecb0decaff840efe9cff
Tree-SHA512: dcb92c2f9a2c632880429e9528007db426d2ad938c64dfa1f1538c03e4b62620df52ad7daf33b582976c67b472ff76bc0dae707049f4bbbd4941232cee9ce3d4
Diffstat (limited to 'src/qt')
-rw-r--r-- | src/qt/peertablemodel.cpp | 4 | ||||
-rw-r--r-- | src/qt/peertablemodel.h | 3 | ||||
-rw-r--r-- | src/qt/rpcconsole.cpp | 3 |
3 files changed, 5 insertions, 5 deletions
diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp index b324693692..1b7fda6e77 100644 --- a/src/qt/peertablemodel.cpp +++ b/src/qt/peertablemodel.cpp @@ -179,5 +179,7 @@ void PeerTableModel::refresh() m_peers_data.swap(new_peers_data); } - Q_EMIT changed(); + const auto top_left = index(0, 0); + const auto bottom_right = index(rowCount() - 1, columnCount() - 1); + Q_EMIT dataChanged(top_left, bottom_right); } diff --git a/src/qt/peertablemodel.h b/src/qt/peertablemodel.h index 0ff1b5dba7..0d841ebf28 100644 --- a/src/qt/peertablemodel.h +++ b/src/qt/peertablemodel.h @@ -73,9 +73,6 @@ public: public Q_SLOTS: void refresh(); -Q_SIGNALS: - void changed(); - private: //! Internal peer data structure. QList<CNodeCombinedStats> m_peers_data{}; diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index c973fdbe78..9c57816f91 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -35,6 +35,7 @@ #endif #include <QAbstractButton> +#include <QAbstractItemModel> #include <QDateTime> #include <QFont> #include <QKeyEvent> @@ -686,7 +687,7 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_ // peer table signal handling - update peer details when selecting new node connect(ui->peerWidget->selectionModel(), &QItemSelectionModel::selectionChanged, this, &RPCConsole::updateDetailWidget); - connect(model->getPeerTableModel(), &PeerTableModel::changed, this, &RPCConsole::updateDetailWidget); + connect(model->getPeerTableModel(), &QAbstractItemModel::dataChanged, [this] { updateDetailWidget(); }); // set up ban table ui->banlistWidget->setModel(model->getBanTableModel()); |