diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-11-04 17:54:38 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-11-05 07:55:53 -0800 |
commit | f2f18b4e16656f0eb0d6b41981baa991ade3d33c (patch) | |
tree | c833d718a3f0c34e4dfb3fa38a9d6e0e7a94e74b /desktop-widgets/mainwindow.cpp | |
parent | 236373b6ba92b9a3935958a367e88b05d4f54854 (diff) | |
download | subsurface-f2f18b4e16656f0eb0d6b41981baa991ade3d33c.tar.gz |
Dive list: split reload() in reload() and setSortOrder()
The DiveListView code had a very fundamental problem with its
header: Each had its own idea of who is responsible for sorting.
Since we can't easily change QHeaderView, accept QHeaderView
as the authority on sort-column and order.
To make this possible, split the reload() function in two
distinct functions:
- reload() reloads the model and sorts according to the
current sort criterion.
- setSortOrder() tells the header to display a certain
sort criterion. If this is a new criterion, it will then
emit a signal. In this signal, resort according to that
criterion.
Thus, the actual sorting code has to be moved from the
headerClicked() to a new sortIndicatorChanged() slot.
Morover, the sorting of the QHeaderView has to be used.
Reported-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/mainwindow.cpp')
-rw-r--r-- | desktop-widgets/mainwindow.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index ee38bda28..33d954f8d 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -245,7 +245,7 @@ MainWindow::MainWindow() : QMainWindow(), graphics->setEmptyState(); initialUiSetup(); readSettings(); - diveList->reload(DiveTripModel::TREE); + diveList->reload(); diveList->reloadHeaderActions(); diveList->setFocus(); MapWidget::instance()->reload(); @@ -494,7 +494,7 @@ void MainWindow::refreshDisplay(bool doRecreateDiveList) void MainWindow::recreateDiveList() { - diveList->reload(DiveTripModel::CURRENT); + diveList->reload(); TagFilterModel::instance()->repopulate(); BuddyFilterModel::instance()->repopulate(); LocationFilterModel::instance()->repopulate(); @@ -704,7 +704,8 @@ void MainWindow::cleanUpEmpty() mainTab->clearTabs(); mainTab->updateDiveInfo(true); graphics->setEmptyState(); - diveList->reload(DiveTripModel::TREE); + diveList->reload(); + diveList->setSortOrder(DiveTripModel::NR, Qt::AscendingOrder); MapWidget::instance()->reload(); if (!existing_filename) setTitle(); |