Skip to content

Commit 63314b8

Browse files
author
MarcoFalke
committed
Merge #229: Fix regression with initial sorting after pr205
c524dc5 qt: Fix regression with initial sorting after pr205 (Hennadii Stepanov) Pull request description: Unfortunately, #205 introduced a regression. After opening the "Receive" or "Transaction" tab at first time despite of the "Date" header is marked as sorted, table rows are not sorted actually: ![Screenshot from 2021-02-27 17-49-54](https://user-images.githubusercontent.com/32963518/109392491-f7e9a480-7924-11eb-96cc-98b6f932e18e.png) It appears that sorting the table must be triggered _after_ the `QTableView::setModel` call. With this PR (and pre-#205): ![Screenshot from 2021-02-27 17-48-40](https://user-images.githubusercontent.com/32963518/109392505-08018400-7925-11eb-8107-8f8685744b83.png) ACKs for top commit: Talkless: tACK c524dc5, tested on Debian Sid with Qt 5.15.2. I can confirm @leonardojobim observations. leonardojobim: Tested ACK c524dc5 on Ubuntu 20.04.2 Qt 5.12.8 jonatack: ACK c524dc5 jarolrod: ACK c524dc5, tested on macOS 11.1 Qt 5.15.2 Tree-SHA512: e370229979a70d63a0b64dbc11c4eca338695a070881d4d8f015644617f180e6accc24d6bdf98a75e7c9ba9be2a0ace9a2b7eb9c783ebb2992c3b2c3b3deb408
2 parents 7cdadf9 + c524dc5 commit 63314b8

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/qt/receivecoinsdialog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *_platformStyle, QWid
8181
tableView->horizontalHeader()->setMinimumSectionSize(MINIMUM_COLUMN_WIDTH);
8282
tableView->horizontalHeader()->setStretchLastSection(true);
8383
}
84-
tableView->horizontalHeader()->setSortIndicator(RecentRequestsTableModel::Date, Qt::DescendingOrder);
8584
}
8685

8786
void ReceiveCoinsDialog::setModel(WalletModel *_model)
@@ -96,6 +95,8 @@ void ReceiveCoinsDialog::setModel(WalletModel *_model)
9695

9796
QTableView* tableView = ui->recentRequestsView;
9897
tableView->setModel(_model->getRecentRequestsTableModel());
98+
tableView->sortByColumn(RecentRequestsTableModel::Date, Qt::DescendingOrder);
99+
99100
connect(tableView->selectionModel(),
100101
&QItemSelectionModel::selectionChanged, this,
101102
&ReceiveCoinsDialog::recentRequestsView_selectionChanged);

src/qt/transactionview.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
160160
transactionView->horizontalHeader()->setMinimumSectionSize(MINIMUM_COLUMN_WIDTH);
161161
transactionView->horizontalHeader()->setStretchLastSection(true);
162162
}
163-
transactionView->horizontalHeader()->setSortIndicator(TransactionTableModel::Date, Qt::DescendingOrder);
164163

165164
// Actions
166165
abandonAction = new QAction(tr("Abandon transaction"), this);
@@ -236,6 +235,7 @@ void TransactionView::setModel(WalletModel *_model)
236235
transactionProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
237236
transactionProxyModel->setSortRole(Qt::EditRole);
238237
transactionView->setModel(transactionProxyModel);
238+
transactionView->sortByColumn(TransactionTableModel::Date, Qt::DescendingOrder);
239239

240240
if (_model->getOptionsModel())
241241
{

0 commit comments

Comments
 (0)