summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/command_divesite.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'desktop-widgets/command_divesite.cpp')
-rw-r--r--desktop-widgets/command_divesite.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/desktop-widgets/command_divesite.cpp b/desktop-widgets/command_divesite.cpp
index 5d32a902d..5534bc5bb 100644
--- a/desktop-widgets/command_divesite.cpp
+++ b/desktop-widgets/command_divesite.cpp
@@ -4,6 +4,7 @@
#include "core/divesite.h"
#include "core/subsurface-qt/DiveListNotifier.h"
#include "core/qthelper.h"
+#include "core/subsurface-string.h"
#include "qt-models/divelocationmodel.h"
namespace Command {
@@ -182,4 +183,29 @@ void EditDiveSiteNotes::undo()
redo();
}
+EditDiveSiteCountry::EditDiveSiteCountry(dive_site *dsIn, const QString &country) : ds(dsIn),
+ value(country)
+{
+ setText(tr("Edit dive site country"));
+}
+
+bool EditDiveSiteCountry::workToBeDone()
+{
+ return !same_string(qPrintable(value), taxonomy_get_country(&ds->taxonomy));
+}
+
+void EditDiveSiteCountry::redo()
+{
+ QString old = taxonomy_get_country(&ds->taxonomy);
+ taxonomy_set_country(&ds->taxonomy, copy_qstring(value), taxonomy_origin::GEOMANUAL);
+ value = old;
+ emit diveListNotifier.diveSiteChanged(ds, LocationInformationModel::TAXONOMY); // Inform frontend of changed dive site.
+}
+
+void EditDiveSiteCountry::undo()
+{
+ // Undo and redo do the same
+ redo();
+}
+
} // namespace Command