mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 23:23:23 +00:00
Dive list: remember/restore selection only on view change
The selection was remembered/restored anytime the sort-order changed. Yet, this is only necessary if the view (tree, list) changes. Therefore, handle the selection only if this is the case. This automatically fixes the problem of the trip-selection not being remembered if the view doesn't change. If the view does change, trip selection is lost. But since the list view doesn't have trips to start with, losing trip-selection seems like an understandable behavior. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
139c749c90
commit
323a71941d
1 changed files with 5 additions and 11 deletions
|
@ -462,15 +462,9 @@ bool DiveListView::eventFilter(QObject *, QEvent *event)
|
|||
return true;
|
||||
}
|
||||
|
||||
// NOTE! This loses trip selection, because while we remember the
|
||||
// dives, we don't remember the trips (see the "currentSelectedDives"
|
||||
// list). I haven't figured out how to look up the trip from the
|
||||
// index. TRIP_ROLE vs DIVE_ROLE?
|
||||
void DiveListView::headerClicked(int i)
|
||||
{
|
||||
DiveTripModel::Layout newLayout = i == (int)DiveTripModel::NR ? DiveTripModel::TREE : DiveTripModel::LIST;
|
||||
rememberSelection();
|
||||
unselectDives();
|
||||
/* 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
|
||||
|
@ -484,17 +478,17 @@ void DiveListView::headerClicked(int i)
|
|||
sortByColumn(i, currentOrder);
|
||||
} else {
|
||||
// clear the model, repopulate with new indexes.
|
||||
if (currentLayout == DiveTripModel::TREE) {
|
||||
rememberSelection();
|
||||
unselectDives();
|
||||
if (currentLayout == DiveTripModel::TREE)
|
||||
backupExpandedRows();
|
||||
}
|
||||
reload(newLayout, false);
|
||||
currentOrder = Qt::DescendingOrder;
|
||||
sortByColumn(i, currentOrder);
|
||||
if (newLayout == DiveTripModel::TREE) {
|
||||
if (newLayout == DiveTripModel::TREE)
|
||||
restoreExpandedRows();
|
||||
}
|
||||
restoreSelection();
|
||||
}
|
||||
restoreSelection();
|
||||
// remember the new sort column
|
||||
sortColumn = i;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue