mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-01 06:30:26 +00:00
Make a map ctrl-click toggle the selection state
This way the map selection works like normal selections do. Except we don't do "ranged" selections (shift-click) for fairly obvious reasons. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
ef873b4082
commit
00d5ab1bdc
3 changed files with 8 additions and 4 deletions
|
@ -47,16 +47,19 @@ void DiveListView::unselectDives()
|
||||||
selectionModel()->clearSelection();
|
selectionModel()->clearSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveListView::selectDive(struct dive *dive, bool scrollto)
|
void DiveListView::selectDive(struct dive *dive, bool scrollto, bool toggle)
|
||||||
{
|
{
|
||||||
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model());
|
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model());
|
||||||
QModelIndexList match = m->match(m->index(0,0), TreeItemDT::NR, dive->number, 1, Qt::MatchRecursive);
|
QModelIndexList match = m->match(m->index(0,0), TreeItemDT::NR, dive->number, 1, Qt::MatchRecursive);
|
||||||
|
QFlags<QItemSelectionModel::SelectionFlag> flags;
|
||||||
QModelIndex idx = match.first();
|
QModelIndex idx = match.first();
|
||||||
|
|
||||||
QModelIndex parent = idx.parent();
|
QModelIndex parent = idx.parent();
|
||||||
if (parent.isValid())
|
if (parent.isValid())
|
||||||
expand(parent);
|
expand(parent);
|
||||||
selectionModel()->select( idx, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
flags = toggle ? QItemSelectionModel::Toggle : QItemSelectionModel::Select;
|
||||||
|
flags |= QItemSelectionModel::Rows;
|
||||||
|
selectionModel()->select( idx, flags);
|
||||||
if (scrollto)
|
if (scrollto)
|
||||||
scrollTo(idx, PositionAtCenter);
|
scrollTo(idx, PositionAtCenter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
void reload(DiveTripModel::Layout layout, bool forceSort = true);
|
void reload(DiveTripModel::Layout layout, bool forceSort = true);
|
||||||
bool eventFilter(QObject* , QEvent* );
|
bool eventFilter(QObject* , QEvent* );
|
||||||
void unselectDives();
|
void unselectDives();
|
||||||
void selectDive(struct dive *, bool scrollto = false);
|
void selectDive(struct dive *, bool scrollto = false, bool toggle = false);
|
||||||
void contextMenuEvent(QContextMenuEvent *event);
|
void contextMenuEvent(QContextMenuEvent *event);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -82,6 +82,7 @@ void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
|
||||||
int idx;
|
int idx;
|
||||||
struct dive *dive;
|
struct dive *dive;
|
||||||
bool clear = !(QApplication::keyboardModifiers() && Qt::ControlModifier);
|
bool clear = !(QApplication::keyboardModifiers() && Qt::ControlModifier);
|
||||||
|
bool toggle = !clear;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for_each_dive(idx, dive) {
|
for_each_dive(idx, dive) {
|
||||||
long lat_diff, lon_diff;
|
long lat_diff, lon_diff;
|
||||||
|
@ -100,7 +101,7 @@ void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
|
||||||
mainWindow()->dive_list()->unselectDives();
|
mainWindow()->dive_list()->unselectDives();
|
||||||
clear = false;
|
clear = false;
|
||||||
}
|
}
|
||||||
mainWindow()->dive_list()->selectDive(dive, first);
|
mainWindow()->dive_list()->selectDive(dive, first, toggle);
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue