diff options
-rw-r--r-- | qt-ui/globe.cpp | 17 | ||||
-rw-r--r-- | qt-ui/globe.h | 1 | ||||
-rw-r--r-- | qt-ui/maintab.cpp | 8 | ||||
-rw-r--r-- | qt-ui/maintab.h | 1 |
4 files changed, 26 insertions, 1 deletions
diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp index 149f738e3..3ea01f0d8 100644 --- a/qt-ui/globe.cpp +++ b/qt-ui/globe.cpp @@ -212,6 +212,16 @@ void GlobeGPS::prepareForGetDiveCoordinates(dive* dive) editingDiveCoords = dive; } +void GlobeGPS::diveEditMode() +{ + if (messageWidget->isVisible()) + messageWidget->animatedHide(); + messageWidget->setMessageType(KMessageWidget::Warning); + messageWidget->setText(QObject::tr("Editing dive - move the map and double-click to set the dive location")); + messageWidget->setWordWrap(true); + messageWidget->animatedShow(); +} + void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::Unit unit) { // convert to degrees if in radian. @@ -241,7 +251,12 @@ void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::U void GlobeGPS::mousePressEvent(QMouseEvent* event) { qreal lat, lon; - if (editingDiveCoords && geoCoordinates(event->pos().x(), event->pos().y(), lon, lat, GeoDataCoordinates::Degree)) { + // there could be two scenarios that got us here; let's check if we are editing a dive + if (mainWindow()->information()->isEditing() && + geoCoordinates(event->pos().x(), event->pos().y(), lon, lat, GeoDataCoordinates::Degree)) { + mainWindow()->information()->updateCoordinatesText(lat, lon); + } else if (editingDiveCoords && + geoCoordinates(event->pos().x(), event->pos().y(), lon, lat, GeoDataCoordinates::Degree)) { changeDiveGeoPosition(lon, lat, GeoDataCoordinates::Degree); } } diff --git a/qt-ui/globe.h b/qt-ui/globe.h index cab42cefc..b04ff9266 100644 --- a/qt-ui/globe.h +++ b/qt-ui/globe.h @@ -18,6 +18,7 @@ public: GlobeGPS(QWidget *parent); void reload(); void centerOn(struct dive* dive); + void diveEditMode(); protected: /* reimp */ void resizeEvent(QResizeEvent *event); diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 7c94ab4c8..a1acfb52d 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -123,6 +123,7 @@ void MainTab::enableEdition(EditMode newEditMode) return; mainWindow()->dive_list()->setEnabled(false); + mainWindow()->globe()->diveEditMode(); // We may be editing one or more dives here. backup everything. notesBackup.clear(); ui.notesButtonBox->show(); @@ -835,6 +836,13 @@ QString MainTab::printGPSCoords(int lat, int lon) return result; } +void MainTab::updateCoordinatesText(qreal lat, qreal lon) +{ + int ulat = rint(lat * 1000000); + int ulon = rint(lon * 1000000); + ui.coordinates->setText(printGPSCoords(ulat, ulon)); +} + void MainTab::updateGpsCoordinates(const struct dive *dive) { if (dive) { diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index d2c96a972..6aee9fbfe 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -59,6 +59,7 @@ public: void initialUiSetup(); void equipmentPlusUpdate(); bool isEditing(); + void updateCoordinatesText(qreal lat, qreal lon); public slots: void addCylinder_clicked(); void addWeight_clicked(); |