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:
Tomaz Canabrava 2013-12-03 15:29:40 -02:00 committed by Dirk Hohndel
parent 49cb75ee09
commit 80265e4b3f
2 changed files with 5 additions and 18 deletions

View file

@ -132,9 +132,7 @@ void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
int idx;
struct dive *dive;
bool clear = !(QApplication::keyboardModifiers() && Qt::ControlModifier);
bool toggle = !clear;
bool first = true;
bool clear = !(QApplication::keyboardModifiers() & Qt::ControlModifier);
QList<int> selectedDiveIds;
for_each_dive(idx, dive) {
long lat_diff, lon_diff;
@ -150,8 +148,9 @@ void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
continue;
selectedDiveIds.push_back(idx);
first = false;
}
if(selectedDiveIds.empty())
return;
if (clear) {
mainWindow()->dive_list()->unselectDives();
clear = false;