diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-12-03 15:29:40 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-12-03 11:07:59 -0800 |
commit | 80265e4b3f213e0b9e69514ea68049e6bd964062 (patch) | |
tree | b0ca660232e31c36196bba86211a82375b353d08 /qt-ui | |
parent | 49cb75ee0947414b92b6268ee5db8ae312df7cc0 (diff) | |
download | subsurface-80265e4b3f213e0b9e69514ea68049e6bd964062.tar.gz |
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>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/divelistview.cpp | 16 | ||||
-rw-r--r-- | qt-ui/globe.cpp | 7 |
2 files changed, 5 insertions, 18 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index af2ff12b8..b0b14fb9c 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -228,7 +228,6 @@ void DiveListView::selectDives(const QList< int >& newDiveSelection) QItemSelection newDeselected = selectionModel()->selection(); QModelIndexList diveList; - QModelIndexList tripList; int firstSelectedDive = -1; /* 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, i, 2, Qt::MatchRecursive).first()); } - Q_FOREACH(const QModelIndex& idx, diveList){ selectionModel()->select(idx, flags); - if(idx.parent().isValid()){ - if(tripList.contains(idx.parent())) - continue; - tripList.append(idx.parent()); - } - } - - Q_FOREACH(const QModelIndex& idx, tripList){ - if(!isExpanded(idx)){ - expand(idx); + if(idx.parent().isValid() && !isExpanded(idx.parent())){ + expand(idx.parent()); } } setAnimated(true); - QTreeView::selectionChanged(selectionModel()->selection(), newDeselected); connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionChanged(QItemSelection,QItemSelection))); connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(currentChanged(QModelIndex,QModelIndex))); - Q_EMIT currentDiveChanged(selected_dive); const QModelIndex& idx = m->match(m->index(0,0), DiveTripModel::DIVE_IDX,selected_dive, 2, Qt::MatchRecursive).first(); scrollTo(idx); diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp index d1c23ed33..10ce7058b 100644 --- a/qt-ui/globe.cpp +++ b/qt-ui/globe.cpp @@ -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; |