diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2014-05-01 14:47:52 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-01 15:23:33 -0700 |
commit | 4243fcb9156218f54b3103ce7c8de6ea222f3cfb (patch) | |
tree | 7b09846deb68cde5e4d60ede981fff9c8a17c20c /qt-ui | |
parent | 7f3b487c77c71cc7e3f62bfd2ebde4559a0a6e56 (diff) | |
download | subsurface-4.0.97.tar.gz |
Dont set coordinates when two or more dives are selectedv4.0.97
If a trip is selected (or for other reasons more than one dive), this
would change the GPS coordinates of the whole selection which almost
certainly isn't what the user wanted.
Instead, only allow changes of the coordinates on the globe if exactly one
dive is selected.
[Dirk Hohndel: massively rewritten and extended - but I didn't want to
simply "steal" the commit from Tomaz...
This now maintains the "zoom out mode" for dives without
GPS coordinates and deals with edits of multiple dives that
are initiated the "normal way" by starting to edit other
data as well.]
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/globe.cpp | 52 | ||||
-rw-r--r-- | qt-ui/globe.h | 3 | ||||
-rw-r--r-- | qt-ui/maintab.cpp | 3 |
3 files changed, 37 insertions, 21 deletions
diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp index 03dccfe14..1fcbdea1d 100644 --- a/qt-ui/globe.cpp +++ b/qt-ui/globe.cpp @@ -3,9 +3,10 @@ #include "kmessagewidget.h" #include "mainwindow.h" #include "ui_mainwindow.h" -#include "../dive.h" -#include "../divelist.h" -#include "../helpers.h" +#include "dive.h" +#include "divelist.h" +#include "helpers.h" +#include "display.h" #include <QDebug> #include <QTimer> @@ -203,15 +204,24 @@ void GlobeGPS::reload() void GlobeGPS::centerOn(dive *dive) { // dive has changed, if we had the 'editingDive', hide it. - if (messageWidget->isVisible() && (!dive || dive_has_gps_location(dive))) + if (messageWidget->isVisible() + && (!dive || dive_has_gps_location(dive) || amount_selected != 1 )) messageWidget->hide(); + + editingDiveLocation = false; if (!dive) return; + qreal longitude = dive->longitude.udeg / 1000000.0; qreal latitude = dive->latitude.udeg / 1000000.0; - if (!longitude || !latitude || MainWindow::instance()->information()->isEditing()) { - prepareForGetDiveCoordinates(); + if ((!dive_has_gps_location(dive) || MainWindow::instance()->information()->isEditing()) + && amount_selected == 1) { + prepareForGetDiveCoordinates(dive); + return; + } + if (!dive_has_gps_location(dive)) { + zoomOutForNoGPS(); return; } @@ -239,7 +249,21 @@ void GlobeGPS::fixZoom() setZoom(currentZoomLevel, Marble::Linear); } -void GlobeGPS::prepareForGetDiveCoordinates() +void GlobeGPS::zoomOutForNoGPS() +{ + // this is called if the dive has no GPS location. + // zoom out quite a bit to show the globe and remember that the next time + // we show a dive with GPS location we need to zoom in again + if(fixZoomTimer->isActive()) + fixZoomTimer->stop(); + setZoom(1200, Marble::Automatic); + if (!needResetZoom) { + needResetZoom = true; + currentZoomLevel = zoom(); + } +} + +void GlobeGPS::prepareForGetDiveCoordinates(struct dive *dive) { if (!messageWidget->isVisible()) { messageWidget->setMessageType(KMessageWidget::Warning); @@ -247,18 +271,8 @@ void GlobeGPS::prepareForGetDiveCoordinates() messageWidget->setWordWrap(true); messageWidget->animatedShow(); editingDiveLocation = true; - // if the dive has no GPS location, zoom out quite a bit to show the globe - // and remember that the next time we show a dive with GPS location we need - // to zoom in again - if (!dive_has_gps_location(current_dive)) { - if(fixZoomTimer->isActive()) - fixZoomTimer->stop(); - setZoom(1200, Marble::Automatic); - if (!needResetZoom) { - needResetZoom = true; - currentZoomLevel = zoom(); - } - } + if (!dive_has_gps_location(dive)) + zoomOutForNoGPS(); } } diff --git a/qt-ui/globe.h b/qt-ui/globe.h index 51bda4878..91ea46c02 100644 --- a/qt-ui/globe.h +++ b/qt-ui/globe.h @@ -40,7 +40,8 @@ slots: void changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::Unit); void mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit); void fixZoom(); - void prepareForGetDiveCoordinates(); + void zoomOutForNoGPS(); + void prepareForGetDiveCoordinates(struct dive *dive); }; #else // NO_MARBLE diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index d85d3bcdb..b4b711445 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -251,7 +251,8 @@ void MainTab::enableEdition(EditMode newEditMode) return; } MainWindow::instance()->dive_list()->setEnabled(false); - MainWindow::instance()->globe()->prepareForGetDiveCoordinates(); + if (amount_selected == 1) + MainWindow::instance()->globe()->prepareForGetDiveCoordinates(current_dive); // We may be editing one or more dives here. backup everything. notesBackup.clear(); if (MainWindow::instance() && MainWindow::instance()->dive_list()->selectedTrips().count() == 1) { |