diff options
author | Gaetan Bisson <bisson@archlinux.org> | 2014-07-03 13:12:47 -1000 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-07-03 17:59:09 -0700 |
commit | 6a57ce5c6bfcd1787a4e57dc0b4e4ceea0743ec1 (patch) | |
tree | 31b30c9e43ebe4bbba3688639954dbb467744dd9 | |
parent | bb176e822a86d6bd4753faa625b9fa97ce7462ea (diff) | |
download | subsurface-6a57ce5c6bfcd1787a4e57dc0b4e4ceea0743ec1.tar.gz |
Autofill GPS coordinates for added dives.
Prior to commit 95cb4e, when a new dive was added with the same location
name as a previous dive, the GPS coordinates for that new dive would be
automatically set to that of the matching previous dive.
This restores this feature, by duplicating code further down
qt-ui/maintab.cpp that handles the case where multiple dives are
modified at once.
Signed-off-by: Gaetan Bisson <bisson@archlinux.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/maintab.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 4495731be..68918e7ed 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -613,9 +613,27 @@ void MainTab::acceptChanges() hideMessage(); ui.equipmentTab->setEnabled(true); if (editMode == ADD) { - // we need to add the dive we just created to the dive list and select it. + // We need to add the dive we just created to the dive list and select it. + // And if we happen to have GPS data for the location entered, let's add those. // Easy, right? struct dive *added_dive = clone_dive(&displayed_dive); + if (!same_string(added_dive->location, "") && + ui.coordinates->text().trimmed().isEmpty()) { + struct dive *dive; + int i = 0; + for_each_dive (i, dive) { + QString location(dive->location); + if (location == ui.location->text() && + (dive->latitude.udeg || dive->longitude.udeg)) { + if (same_string(added_dive->location, dive->location)) { + added_dive->latitude = dive->latitude; + added_dive->longitude = dive->longitude; + } + MainWindow::instance()->globe()->reload(); + break; + } + } + } record_dive(added_dive); addedId = added_dive->id; // unselect everything as far as the UI is concerned - we'll fix that below |