diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-03-13 22:49:34 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-04-12 18:19:07 +0300 |
commit | 0882ca64b0867e962b2231aed4fc097e8e5754de (patch) | |
tree | 94940a1fbf7d4c5814b943eba2858b671a438582 /desktop-widgets | |
parent | 08d789b933a449f1356275348b8aacdb02942fd5 (diff) | |
download | subsurface-0882ca64b0867e962b2231aed4fc097e8e5754de.tar.gz |
Undo: use undo commands for name and description editing in widget
In the dive site widget, use the undo commands instead of editing
only on accept. This introduces an inconsistency betwee the
name and description and the other fields. This will be fixed
in follow-up commits.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/locationinformation.cpp | 27 | ||||
-rw-r--r-- | desktop-widgets/locationinformation.h | 4 |
2 files changed, 9 insertions, 22 deletions
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp index f2b9fbcaa..28f3fa619 100644 --- a/desktop-widgets/locationinformation.cpp +++ b/desktop-widgets/locationinformation.cpp @@ -9,6 +9,7 @@ #include "core/divesitehelpers.h" #include "desktop-widgets/modeldelegates.h" #include "core/subsurface-qt/DiveListNotifier.h" +#include "command.h" #include <QDebug> #include <QShowEvent> @@ -180,20 +181,6 @@ void LocationInformationWidget::acceptChanges() } char *uiString; - uiString = copy_qstring(ui.diveSiteName->text()); - if (!same_string(uiString, diveSite->name)) { - free(diveSite->name); - diveSite->name = uiString; - } else { - free(uiString); - } - uiString = copy_qstring(ui.diveSiteDescription->text()); - if (!same_string(uiString, diveSite->description)) { - free(diveSite->description); - diveSite->description = uiString; - } else { - free(uiString); - } uiString = copy_qstring(ui.diveSiteCountry->text()); // if the user entered a different country, first update the local taxonomy // this below will get copied into the diveSite @@ -301,16 +288,16 @@ void LocationInformationWidget::on_diveSiteCountry_textChanged(const QString& te markChangedWidget(ui.diveSiteCountry); } -void LocationInformationWidget::on_diveSiteDescription_textChanged(const QString &text) +void LocationInformationWidget::on_diveSiteDescription_editingFinished() { - if (diveSite && !same_string(qPrintable(text), diveSite->description)) - markChangedWidget(ui.diveSiteDescription); + if (diveSite) + Command::editDiveSiteDescription(diveSite, ui.diveSiteDescription->text()); } -void LocationInformationWidget::on_diveSiteName_textChanged(const QString &text) +void LocationInformationWidget::on_diveSiteName_editingFinished() { - if (diveSite && !same_string(qPrintable(text), diveSite->name)) - markChangedWidget(ui.diveSiteName); + if (diveSite) + Command::editDiveSiteName(diveSite, ui.diveSiteName->text()); } void LocationInformationWidget::on_diveSiteNotes_textChanged() diff --git a/desktop-widgets/locationinformation.h b/desktop-widgets/locationinformation.h index 9697b4986..b97ceca18 100644 --- a/desktop-widgets/locationinformation.h +++ b/desktop-widgets/locationinformation.h @@ -31,8 +31,8 @@ public slots: void resetPallete(); void on_diveSiteCountry_textChanged(const QString& text); void on_diveSiteCoordinates_textChanged(const QString& text); - void on_diveSiteDescription_textChanged(const QString& text); - void on_diveSiteName_textChanged(const QString& text); + void on_diveSiteDescription_editingFinished(); + void on_diveSiteName_editingFinished(); void on_diveSiteNotes_textChanged(); void reverseGeocode(); void mergeSelectedDiveSites(); |