diff options
author | Sander Kleijwegt <sander@myowndomain.nl> | 2015-08-30 01:00:22 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-08-29 20:10:32 -0700 |
commit | d22a135343361a8243beb335ea89d5a9934a9347 (patch) | |
tree | 36856beca2b34ecd1be018097882561884c27985 /qt-ui/maintab.cpp | |
parent | 954c30c4cfea934b77ccf2035310f157238cb299 (diff) | |
download | subsurface-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/maintab.cpp')
-rw-r--r-- | qt-ui/maintab.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 5f7e7da47..06bfca91c 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -76,6 +76,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), locationManagementEditHelper, &LocationManagementEditHelper::handleActivation); ui.location->setCompleter(completer); + ui.editDiveSiteButton->setEnabled(true); connect(ui.editDiveSiteButton, SIGNAL(clicked()), MainWindow::instance(), SIGNAL(startDiveSiteEdit())); QAction *action = new QAction(tr("Apply changes"), this); @@ -546,7 +547,7 @@ void MainTab::updateDiveInfo(bool clear) if (ds) copy_dive_site(ds, &displayed_dive_site); } - ui.editDiveSiteButton->setEnabled(ds); + if (ds) { // construct the location tags QString locationTag; @@ -861,6 +862,14 @@ MainTab::EditMode MainTab::getEditMode() const mydive->what = displayed_dive.what; \ } +void MainTab::refreshDisplayedDiveSite() +{ + if (displayed_dive_site.uuid) { + copy_dive_site(get_dive_site_by_uuid(displayed_dive_site.uuid), &displayed_dive_site); + ui.location->setText(displayed_dive_site.name); + } +} + void MainTab::updateDisplayedDiveSite() { const QString new_name = ui.location->text(); @@ -926,8 +935,11 @@ void MainTab::updateDiveSite(int divenr) if (pickedUuid) { qDebug() << "assign dive_site" << pickedUuid << "to current dive"; cd->dive_site_uuid = pickedUuid; + } else if (newUuid) { + // user created a new divesite + cd->dive_site_uuid = newUuid; } else if (!newName.isEmpty()) { - // user entered a name but didn't pick a dive site, so copy that data + // user entered a name but didn't pick or create a dive site, so create a divesite uint32_t createdUuid = create_dive_site(displayed_dive_site.name, cd->when); struct dive_site *newDs = get_dive_site_by_uuid(createdUuid); copy_dive_site(&displayed_dive_site, newDs); @@ -935,7 +947,7 @@ void MainTab::updateDiveSite(int divenr) cd->dive_site_uuid = createdUuid; qDebug() << "create a new dive site with name" << newName << "which is now named" << newDs->name << "and assign it as uuid" << createdUuid; } else { - qDebug() << "neither uuid nor name found"; + qDebug() << "neither uuid picked, uuid created nor new name found"; } } else { qDebug() << "current dive had dive site with uuid" << origUuid; |