summaryrefslogtreecommitdiffstats
path: root/qt-ui/locationinformation.cpp
diff options
context:
space:
mode:
authorGravatar Sander Kleijwegt <sander@myowndomain.nl>2015-08-30 01:00:22 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-29 20:10:32 -0700
commitd22a135343361a8243beb335ea89d5a9934a9347 (patch)
tree36856beca2b34ecd1be018097882561884c27985 /qt-ui/locationinformation.cpp
parent954c30c4cfea934b77ccf2035310f157238cb299 (diff)
downloadsubsurface-d22a135343361a8243beb335ea89d5a9934a9347.tar.gz
Fix edit & show of divesites for new and existing dives.
The UI detects when it should refresh the loction after the user finished editting a divesite. Creating and editting divesites is now working even when the current dive is not saved yet. Signed-off-by: Sander Kleijwegt <sander@myowndomain.nl> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/locationinformation.cpp')
-rw-r--r--qt-ui/locationinformation.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/qt-ui/locationinformation.cpp b/qt-ui/locationinformation.cpp
index 8cd9e20be..6006b18e5 100644
--- a/qt-ui/locationinformation.cpp
+++ b/qt-ui/locationinformation.cpp
@@ -78,10 +78,16 @@ void LocationInformationWidget::acceptChanges()
{
emit stopFilterDiveSite();
char *uiString;
- struct dive_site *currentDs = get_dive_site_by_uuid(displayed_dive_site.uuid);
+ struct dive_site *currentDs;
+ uiString = ui.diveSiteName->text().toUtf8().data();
+
+ if (get_dive_site_by_uuid(displayed_dive_site.uuid) != NULL)
+ currentDs = get_dive_site_by_uuid(displayed_dive_site.uuid);
+ else
+ currentDs = get_dive_site_by_uuid(create_dive_site_from_current_dive(uiString));
+
currentDs->latitude = displayed_dive_site.latitude;
currentDs->longitude = displayed_dive_site.longitude;
- uiString = ui.diveSiteName->text().toUtf8().data();
if (!same_string(uiString, currentDs->name)) {
free(currentDs->name);
currentDs->name = copy_string(uiString);
@@ -106,6 +112,7 @@ void LocationInformationWidget::acceptChanges()
LocationInformationModel::instance()->removeRow(get_divesite_idx(currentDs));
displayed_dive.dive_site_uuid = 0;
}
+ copy_dive_site(currentDs, &displayed_dive_site);
mark_divelist_changed(true);
resetState();
emit endRequestCoordinates();
@@ -238,14 +245,7 @@ void LocationManagementEditHelper::handleActivation(const QModelIndex& activated
/* if we are in 'recently added divesite mode, create a new divesite,
* and go to dive site edit edit mode. */
if (last_uuid == RECENTLY_ADDED_DIVESITE) {
- timestamp_t when;
- if (current_dive != NULL) {
- when = current_dive->when;
- } else {
- time_t now = time(0);
- when = utc_mktime(localtime(&now));
- }
- uint32_t ds_uuid = create_dive_site(qPrintable(activated.data().toString()), when);
+ uint32_t ds_uuid = create_dive_site_from_current_dive(qPrintable(activated.data().toString()));
qDebug() << "ds_uuid" << ds_uuid;
struct dive_site *ds = get_dive_site_by_uuid(ds_uuid);
copy_dive_site(ds, &displayed_dive_site);