summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Michael Andreen <harv@ruin.nu>2013-11-12 00:21:45 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-12 16:46:17 +0900
commitc7ea7426f7a17e7712a55c154ce2615893215d55 (patch)
tree722c691b8cf3e58c22f7d2945af260eecb6064e9
parent3c8155880aec5ccba3a25f03e37eb5a4ca00946a (diff)
downloadsubsurface-c7ea7426f7a17e7712a55c154ce2615893215d55.tar.gz
Only auto-complete gps information when empty.
Previously gps information was always overwritten, unless the user had modified it in the current editing session. This causes problem with some use cases, like when coordinates are provided before the location name by the companion app. Now gps information is only overwritten when it is: - Empty - Auto-completed in the current editing session. (When the user hits accept it is considered hand-edited.) Signed-off-by: Michael Andreen <harv@ruin.nu> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/maintab.cpp14
-rw-r--r--qt-ui/maintab.h1
2 files changed, 12 insertions, 3 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 003f0319a..30659c5c5 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -290,7 +290,7 @@ void MainTab::updateDiveInfo(int dive)
UPDATE_TEMP(d, airtemp);
UPDATE_TEMP(d, watertemp);
if (d) {
- ui.coordinates->setText(printGPSCoords(d->latitude.udeg, d->longitude.udeg));
+ updateGpsCoordinates(d);
ui.dateTimeEdit->setDateTime(QDateTime::fromTime_t(d->when - gettimezoneoffset()));
if (mainWindow() && mainWindow()->dive_list()->selectedTrips.count() == 1) {
// only use trip relevant fields
@@ -453,7 +453,7 @@ void MainTab::acceptChanges()
} else {
struct dive *curr = current_dive;
//Reset coordinates field, in case it contains garbage.
- ui.coordinates->setText(printGPSCoords(current_dive->latitude.udeg, current_dive->longitude.udeg));
+ updateGpsCoordinates(curr);
if (notesBackup[curr].buddy != ui.buddy->text() ||
notesBackup[curr].suit != ui.suit->text() ||
notesBackup[curr].notes != ui.notes->toPlainText() ||
@@ -566,7 +566,6 @@ void MainTab::rejectChanges()
struct dive *curr = current_dive;
ui.notes->setText(notesBackup[curr].notes );
ui.location->setText(notesBackup[curr].location);
- ui.coordinates->setText(notesBackup[curr].coordinates);
ui.buddy->setText(notesBackup[curr].buddy);
ui.suit->setText(notesBackup[curr].suit);
ui.divemaster->setText(notesBackup[curr].divemaster);
@@ -604,6 +603,7 @@ void MainTab::rejectChanges()
mydive->weightsystem[i] = notesBackup[mydive].weightsystem[i];
}
}
+ updateGpsCoordinates(curr);
if (selected_dive >= 0) {
multiEditEquipmentPlaceholder = *get_dive(selected_dive);
cylindersModel->setDive(&multiEditEquipmentPlaceholder);
@@ -717,6 +717,7 @@ void MainTab::on_location_textChanged(const QString& text)
(dive->latitude.udeg || dive->longitude.udeg)) {
EDIT_SELECTED_DIVES( mydive->latitude = dive->latitude );
EDIT_SELECTED_DIVES( mydive->longitude = dive->longitude );
+ //Don't use updateGpsCoordinates() since we don't want to set modified state yet
ui.coordinates->setText(printGPSCoords(dive->latitude.udeg, dive->longitude.udeg));
markChangedWidget(ui.coordinates);
break;
@@ -814,3 +815,10 @@ QString MainTab::printGPSCoords(int lat, int lon)
lonh.toLocal8Bit().data(), londeg, UTF8_DEGREE, ilonmin / 1000000, (ilonmin % 1000000) / 10);
return result;
}
+
+void MainTab::updateGpsCoordinates(const struct dive *dive)
+{
+ ui.coordinates->setText(printGPSCoords(dive->latitude.udeg, dive->longitude.udeg));
+ ui.coordinates->setModified(dive->latitude.udeg || dive->longitude.udeg);
+
+}
diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h
index 341a282e8..5a9e2efac 100644
--- a/qt-ui/maintab.h
+++ b/qt-ui/maintab.h
@@ -99,6 +99,7 @@ private:
void resetPallete();
void saveTags();
QString printGPSCoords(int lat, int lon);
+ void updateGpsCoordinates(const struct dive *dive);
};
#endif