From 76f38ff33b918d4880614ff277b4b611c0ce2998 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 2 Nov 2018 08:09:00 +0100 Subject: [PATCH] Dive list: invert default sort order for sort by date / number Commit 6dc1d239f81f16133d5954bd2b21ffa0c2dcc755 introduced a well-defined sort order in the case of equal contents. It changed the code for sorting by date to simply use the order of the source model. BUT: The source-model was already sorted in descending order on date. Thus setting the default order on descening by date, the data was then presented as *ascending* by date. Change this back to descending by always using default-ascending in the filter model. Ultimately, the source model should simply reflect the ordering of the core-data (ascending on date), but such a change is too invasive shortly before release. Reported-by: Jan Mulder Signed-off-by: Berthold Stoeger --- desktop-widgets/divelistview.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index b669eb077..a31813697 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -27,7 +27,7 @@ #include "core/subsurface-qt/DiveListNotifier.h" DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false), sortColumn(DiveTripModel::NR), - currentOrder(Qt::DescendingOrder), dontEmitDiveChangedSignal(false), selectionSaved(false), + currentOrder(Qt::AscendingOrder), dontEmitDiveChangedSignal(false), selectionSaved(false), initialColumnWidths(DiveTripModel::COLUMNS, 50) // Set up with default length 50 { setItemDelegate(new DiveListDelegate(this)); @@ -465,11 +465,9 @@ void DiveListView::headerClicked(int i) /* No layout change? Just re-sort, and scroll to first selection, making sure all selections are expanded */ if (currentLayout == newLayout) { // If this is the same column as before, change sort order. Otherwise, choose a default - // sort order (descending for NR and DATE, ascending elsewise). + // sort order (ascending). if (sortColumn == i) currentOrder = (currentOrder == Qt::DescendingOrder) ? Qt::AscendingOrder : Qt::DescendingOrder; - else if (i == DiveTripModel::NR || i == DiveTripModel::DATE) - currentOrder = Qt::DescendingOrder; else currentOrder = Qt::AscendingOrder; sortByColumn(i, currentOrder); @@ -480,7 +478,7 @@ void DiveListView::headerClicked(int i) if (currentLayout == DiveTripModel::TREE) backupExpandedRows(); currentLayout = newLayout; - currentOrder = Qt::DescendingOrder; + currentOrder = Qt::AscendingOrder; MultiFilterSortModel::instance()->setLayout(newLayout); sortByColumn(i, currentOrder); if (newLayout == DiveTripModel::TREE)