mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Undo: unify selection behavior in dive-list commands
Some commands tried to retain the current selection on undo/redo, others set the selection to the modified dives. The latter was introduced because it was easier in some cases, but it is probably more user-friendly because the user gets feedback on the change. Therefore, unify to always select the affected dives on undo()/redo(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
27944a52b1
commit
e1abf9485c
7 changed files with 48 additions and 56 deletions
|
@ -192,13 +192,11 @@ void DiveListView::reset()
|
|||
}
|
||||
|
||||
// If items were selected, inform the selection model
|
||||
void DiveListView::diveSelectionChanged(const QVector<QModelIndex> &indexes, bool select)
|
||||
void DiveListView::diveSelectionChanged(const QVector<QModelIndex> &indexes)
|
||||
{
|
||||
clearSelection();
|
||||
MultiFilterSortModel *m = MultiFilterSortModel::instance();
|
||||
QItemSelectionModel *s = selectionModel();
|
||||
auto flags = select ?
|
||||
QItemSelectionModel::Rows | QItemSelectionModel::Select :
|
||||
QItemSelectionModel::Rows | QItemSelectionModel::Deselect;
|
||||
for (const QModelIndex &index: indexes) {
|
||||
// We have to transform the indices into local indices, since
|
||||
// there might be sorting or filtering in effect.
|
||||
|
@ -210,10 +208,10 @@ void DiveListView::diveSelectionChanged(const QVector<QModelIndex> &indexes, boo
|
|||
if (!localIndex.isValid())
|
||||
continue;
|
||||
|
||||
s->select(localIndex, flags);
|
||||
s->select(localIndex, QItemSelectionModel::Rows | QItemSelectionModel::Select);
|
||||
|
||||
// If an item of a not-yet expanded trip is selected, expand the trip.
|
||||
if (select && localIndex.parent().isValid() && !isExpanded(localIndex.parent())) {
|
||||
if (localIndex.parent().isValid() && !isExpanded(localIndex.parent())) {
|
||||
setAnimated(false);
|
||||
expand(localIndex.parent());
|
||||
setAnimated(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue