mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
Merge bitcoin-core/gui#18: Add peertablesortproxy module
5a4a15d2b4qt, refactor: Drop no longer used PeerTableModel::getRowByNodeId func (Hennadii Stepanov)9a9f180df0qt, refactor: Drop no longer used PeerTableModel::sort function (Hennadii Stepanov)778a64af20qt: Use PeerTableSortProxy for sorting peer table (Hennadii Stepanov)df2d165ba9qt: Add peertablesortproxy module (Hennadii Stepanov) Pull request description: The "Peers" table in the "Node" window does not hold multiple selection after sorting. This PR introduces a `QSortFilterProxyModel` subclass, that is a standard Qt [practice](https://doc.qt.io/qt-5/model-view-programming.html#custom-sorting-models) for such cases. Now the sorting code is encapsulated into the dedicated Qt class, and we do not need to maintain it. Fixes #283 (additionally). --- On **master** (7ae86b3c68): - rows are sorted by "Ping", and a selection is made  - rows are sorted by "NodeId", and the previous selection is _lost_  With **this PR**: - rows are sorted by "Ping", and a selection is made  - rows are sorted by "NodeId", and the row are still selected  ACKs for top commit: jarolrod: re-ACK5a4a15d2b4, tested on macOS 11.2 Qt 5.15.2 after rebase promag: Tested ACK5a4a15d2b4. Tree-SHA512: f81c1385892fbf1a46ffb98b42094ca1cc97da52114bbbc94fedb553899b1f18c26a349e186bba6e27922a89426bd61e8bc88b1f7832512dbe211b5f834e076e
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <qt/guiconstants.h>
|
||||
#include <qt/guiutil.h>
|
||||
#include <qt/peertablemodel.h>
|
||||
#include <qt/peertablesortproxy.h>
|
||||
|
||||
#include <clientversion.h>
|
||||
#include <interfaces/handler.h>
|
||||
@@ -38,7 +39,11 @@ ClientModel::ClientModel(interfaces::Node& node, OptionsModel *_optionsModel, QO
|
||||
{
|
||||
cachedBestHeaderHeight = -1;
|
||||
cachedBestHeaderTime = -1;
|
||||
|
||||
peerTableModel = new PeerTableModel(m_node, this);
|
||||
m_peer_table_sort_proxy = new PeerTableSortProxy(this);
|
||||
m_peer_table_sort_proxy->setSourceModel(peerTableModel);
|
||||
|
||||
banTableModel = new BanTableModel(m_node, this);
|
||||
|
||||
QTimer* timer = new QTimer;
|
||||
@@ -184,6 +189,11 @@ PeerTableModel *ClientModel::getPeerTableModel()
|
||||
return peerTableModel;
|
||||
}
|
||||
|
||||
PeerTableSortProxy* ClientModel::peerTableSortProxy()
|
||||
{
|
||||
return m_peer_table_sort_proxy;
|
||||
}
|
||||
|
||||
BanTableModel *ClientModel::getBanTableModel()
|
||||
{
|
||||
return banTableModel;
|
||||
|
||||
Reference in New Issue
Block a user