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>
This commit is contained in:
Gaetan Bisson 2014-07-03 13:12:47 -10:00 committed by Dirk Hohndel
parent bb176e822a
commit 6a57ce5c6b

View file

@ -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