mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Maintain the selection when aborting "dive add"
We remember what was selected before and restore it. Maybe there's a more "Qt way" of doing this, but my implementation appears to work :-) Also remove unconditional debug output that snuck into an earlier commit. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
179615f3a9
commit
dfd17c7a7f
5 changed files with 40 additions and 9 deletions
|
|
@ -112,6 +112,30 @@ void DiveListView::fixMessyQtModelBehaviour()
|
|||
}
|
||||
}
|
||||
|
||||
// this only remembers dives that were selected, not trips
|
||||
void DiveListView::rememberSelection()
|
||||
{
|
||||
selectedDives.clear();
|
||||
QItemSelection selection = selectionModel()->selection();
|
||||
Q_FOREACH(const QModelIndex& index , selection.indexes()) {
|
||||
if (index.column() != 0) // We only care about the dives, so, let's stick to rows and discard columns.
|
||||
continue;
|
||||
struct dive *d = (struct dive *) index.data(DiveTripModel::DIVE_ROLE).value<void*>();
|
||||
if (d)
|
||||
selectedDives.push_front(get_divenr(d));
|
||||
}
|
||||
}
|
||||
|
||||
void DiveListView::restoreSelection()
|
||||
{
|
||||
unselectDives();
|
||||
Q_FOREACH(int i, selectedDives) {
|
||||
struct dive *d = get_dive(i);
|
||||
if (d)
|
||||
selectDive(d);
|
||||
}
|
||||
}
|
||||
|
||||
void DiveListView::unselectDives()
|
||||
{
|
||||
selectionModel()->clearSelection();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue