aboutsummaryrefslogtreecommitdiff
path: root/src/qt/clientmodel.cpp
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-04-28 20:51:58 +0300
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-04-28 20:57:52 +0300
commit328da3355787e76184d6bb16e6cf04eca760cbc6 (patch)
treeaf3aafac1bfa4b5005d65bdde931409b12edbbff /src/qt/clientmodel.cpp
parent549d20a31beaf71c722970af32d0076b70b5ffcb (diff)
parent5a4a15d2b4456272fd8aa080195f40a09576ae01 (diff)
downloadbitcoin-328da3355787e76184d6bb16e6cf04eca760cbc6.tar.xz
Merge bitcoin-core/gui#18: Add peertablesortproxy module
5a4a15d2b4456272fd8aa080195f40a09576ae01 qt, refactor: Drop no longer used PeerTableModel::getRowByNodeId func (Hennadii Stepanov) 9a9f180df0d51396fee2468681df6dd935b0248e qt, refactor: Drop no longer used PeerTableModel::sort function (Hennadii Stepanov) 778a64af209e4fa692a3aca8376ba1bd5e1af881 qt: Use PeerTableSortProxy for sorting peer table (Hennadii Stepanov) df2d165ba9e0acc53f36a326f68f57ad9c297872 qt: 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** (7ae86b3c6845873ca96650fc69beb4ae5285c801): - rows are sorted by "Ping", and a selection is made ![Screenshot from 2020-11-28 22-53-11](https://user-images.githubusercontent.com/32963518/100525900-96eaed00-31cc-11eb-86e7-72ede3b8b33c.png) - rows are sorted by "NodeId", and the previous selection is _lost_ ![Screenshot from 2020-11-28 22-53-21](https://user-images.githubusercontent.com/32963518/100525904-9c483780-31cc-11eb-957c-06f53d7d31ab.png) With **this PR**: - rows are sorted by "Ping", and a selection is made ![Screenshot from 2020-11-28 22-39-41](https://user-images.githubusercontent.com/32963518/100525776-06aca800-31cc-11eb-8c4e-9c6566fe80fe.png) - rows are sorted by "NodeId", and the row are still selected ![Screenshot from 2020-11-28 22-39-53](https://user-images.githubusercontent.com/32963518/100525791-2348e000-31cc-11eb-8b78-716a5551d7ec.png) ACKs for top commit: jarolrod: re-ACK 5a4a15d2b4456272fd8aa080195f40a09576ae01, tested on macOS 11.2 Qt 5.15.2 after rebase promag: Tested ACK 5a4a15d2b4456272fd8aa080195f40a09576ae01. Tree-SHA512: f81c1385892fbf1a46ffb98b42094ca1cc97da52114bbbc94fedb553899b1f18c26a349e186bba6e27922a89426bd61e8bc88b1f7832512dbe211b5f834e076e
Diffstat (limited to 'src/qt/clientmodel.cpp')
-rw-r--r--src/qt/clientmodel.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index f2c555de52..04161020b2 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -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;