mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
Fix ignoring empty selections on the globe and code cleanup.
If the 'mouseClicked' didn't get any dives at the click-geolocation, ignore it and do not try to select an empty selection. this was causing a lot of issues when map-navigation. Also, good deal of code cleanup. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
49cb75ee09
commit
80265e4b3f
2 changed files with 5 additions and 18 deletions
|
@ -228,7 +228,6 @@ void DiveListView::selectDives(const QList< int >& newDiveSelection)
|
||||||
|
|
||||||
QItemSelection newDeselected = selectionModel()->selection();
|
QItemSelection newDeselected = selectionModel()->selection();
|
||||||
QModelIndexList diveList;
|
QModelIndexList diveList;
|
||||||
QModelIndexList tripList;
|
|
||||||
|
|
||||||
int firstSelectedDive = -1;
|
int firstSelectedDive = -1;
|
||||||
/* context for temp. variables. */{
|
/* context for temp. variables. */{
|
||||||
|
@ -246,29 +245,18 @@ void DiveListView::selectDives(const QList< int >& newDiveSelection)
|
||||||
diveList.append(m->match(m->index(0,0), DiveTripModel::DIVE_IDX,
|
diveList.append(m->match(m->index(0,0), DiveTripModel::DIVE_IDX,
|
||||||
i, 2, Qt::MatchRecursive).first());
|
i, 2, Qt::MatchRecursive).first());
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_FOREACH(const QModelIndex& idx, diveList){
|
Q_FOREACH(const QModelIndex& idx, diveList){
|
||||||
selectionModel()->select(idx, flags);
|
selectionModel()->select(idx, flags);
|
||||||
if(idx.parent().isValid()){
|
if(idx.parent().isValid() && !isExpanded(idx.parent())){
|
||||||
if(tripList.contains(idx.parent()))
|
expand(idx.parent());
|
||||||
continue;
|
|
||||||
tripList.append(idx.parent());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_FOREACH(const QModelIndex& idx, tripList){
|
|
||||||
if(!isExpanded(idx)){
|
|
||||||
expand(idx);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setAnimated(true);
|
setAnimated(true);
|
||||||
|
|
||||||
QTreeView::selectionChanged(selectionModel()->selection(), newDeselected);
|
QTreeView::selectionChanged(selectionModel()->selection(), newDeselected);
|
||||||
connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
|
||||||
this, SLOT(selectionChanged(QItemSelection,QItemSelection)));
|
this, SLOT(selectionChanged(QItemSelection,QItemSelection)));
|
||||||
connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
|
connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
|
||||||
this, SLOT(currentChanged(QModelIndex,QModelIndex)));
|
this, SLOT(currentChanged(QModelIndex,QModelIndex)));
|
||||||
|
|
||||||
Q_EMIT currentDiveChanged(selected_dive);
|
Q_EMIT currentDiveChanged(selected_dive);
|
||||||
const QModelIndex& idx = m->match(m->index(0,0), DiveTripModel::DIVE_IDX,selected_dive, 2, Qt::MatchRecursive).first();
|
const QModelIndex& idx = m->match(m->index(0,0), DiveTripModel::DIVE_IDX,selected_dive, 2, Qt::MatchRecursive).first();
|
||||||
scrollTo(idx);
|
scrollTo(idx);
|
||||||
|
|
|
@ -132,9 +132,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;
|
|
||||||
QList<int> selectedDiveIds;
|
QList<int> selectedDiveIds;
|
||||||
for_each_dive(idx, dive) {
|
for_each_dive(idx, dive) {
|
||||||
long lat_diff, lon_diff;
|
long lat_diff, lon_diff;
|
||||||
|
@ -150,8 +148,9 @@ void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
selectedDiveIds.push_back(idx);
|
selectedDiveIds.push_back(idx);
|
||||||
first = false;
|
|
||||||
}
|
}
|
||||||
|
if(selectedDiveIds.empty())
|
||||||
|
return;
|
||||||
if (clear) {
|
if (clear) {
|
||||||
mainWindow()->dive_list()->unselectDives();
|
mainWindow()->dive_list()->unselectDives();
|
||||||
clear = false;
|
clear = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue