summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-05 14:09:08 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-05 14:23:37 +0900
commit01d515b5d8c2988518f8a4a016fb6493c4639e7b (patch)
tree07b5ac9012064865805ecde80f9c006850bb5324 /qt-ui
parenteaa0d647b7ed4f37bdab35cac8177a8e132e47da (diff)
downloadsubsurface-01d515b5d8c2988518f8a4a016fb6493c4639e7b.tar.gz
Remember the column we are sorting by
A call to DiveListView::reload always reset our sortcolumn to be 0. Instead we are tracking the correct sort column and sort direction. This also removes an obsolete private member that was unused. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/divelistview.cpp11
-rw-r--r--qt-ui/divelistview.h3
2 files changed, 9 insertions, 5 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index e64ad217b..a78e48777 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -22,7 +22,7 @@
#include <QFileDialog>
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false),
- currentHeaderClicked(-1), searchBox(new QLineEdit(this))
+ sortColumn(0), currentOrder(Qt::DescendingOrder), searchBox(new QLineEdit(this))
{
setUniformRowHeights(true);
setItemDelegateForColumn(DiveTripModel::RATING, new StarWidgetsDelegate());
@@ -107,6 +107,7 @@ bool DiveListView::eventFilter(QObject* , QEvent* event)
// index. TRIP_ROLE vs DIVE_ROLE?
void DiveListView::headerClicked(int i)
{
+ sortColumn = i;
QItemSelection oldSelection = selectionModel()->selection();
QList<struct dive*> currentSelectedDives;
DiveTripModel::Layout newLayout;
@@ -127,11 +128,13 @@ 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) {
- sortByColumn(i);
+ currentOrder = (currentOrder == Qt::DescendingOrder) ? Qt::AscendingOrder : Qt::DescendingOrder;
+ sortByColumn(i, currentOrder);
} else {
// clear the model, repopulate with new indexes.
reload(newLayout, false);
- sortByColumn(i, Qt::DescendingOrder);
+ currentOrder = Qt::DescendingOrder;
+ sortByColumn(i, currentOrder);
}
// repopulate the selections.
@@ -163,7 +166,7 @@ void DiveListView::reload(DiveTripModel::Layout layout, bool forceSort)
if(!forceSort)
return;
- sortByColumn(0, Qt::DescendingOrder);
+ sortByColumn(sortColumn, currentOrder);
if (amount_selected && selected_dive >= 0) {
selectDive(current_dive, true);
} else {
diff --git a/qt-ui/divelistview.h b/qt-ui/divelistview.h
index c1222abdf..384ece9a3 100644
--- a/qt-ui/divelistview.h
+++ b/qt-ui/divelistview.h
@@ -48,7 +48,8 @@ signals:
private:
bool mouseClickSelection;
- int currentHeaderClicked;
+ int sortColumn;
+ Qt::SortOrder currentOrder;
DiveTripModel::Layout currentLayout;
QLineEdit *searchBox;
QModelIndex contextMenuIndex;