Skip to content

Commit

Permalink
Merge bitcoin-core/gui#375: Emit dataChanged signal to dynamically re…
Browse files Browse the repository at this point in the history
…-sort Peers table

986bf78 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 (8cdf917) as in ecbd911 (dashpay#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 dashpay#367.

  An alternative to dashpay#374.

ACKs for top commit:
  jarolrod:
    ACK 986bf78

Tree-SHA512: dcb92c2f9a2c632880429e9528007db426d2ad938c64dfa1f1538c03e4b62620df52ad7daf33b582976c67b472ff76bc0dae707049f4bbbd4941232cee9ce3d4
  • Loading branch information
hebasto authored and knst committed Oct 24, 2024
1 parent 7aeb0ad commit f358f2b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/qt/peertablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,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);
}
3 changes: 0 additions & 3 deletions src/qt/peertablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ class PeerTableModel : public QAbstractTableModel
public Q_SLOTS:
void refresh();

Q_SIGNALS:
void changed();

private:
//! Internal peer data structure.
QList<CNodeCombinedStats> m_peers_data{};
Expand Down
3 changes: 2 additions & 1 deletion src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#endif

#include <QAbstractButton>
#include <QAbstractItemModel>
#include <QButtonGroup>
#include <QDir>
#include <QFont>
Expand Down Expand Up @@ -743,7 +744,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());
Expand Down

0 comments on commit f358f2b

Please sign in to comment.