diff options
Diffstat (limited to 'desktop-widgets/command_divesite.cpp')
-rw-r--r-- | desktop-widgets/command_divesite.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/desktop-widgets/command_divesite.cpp b/desktop-widgets/command_divesite.cpp index d4c5d87b8..eafa18a76 100644 --- a/desktop-widgets/command_divesite.cpp +++ b/desktop-widgets/command_divesite.cpp @@ -3,6 +3,8 @@ #include "command_divesite.h" #include "core/divesite.h" #include "core/subsurface-qt/DiveListNotifier.h" +#include "core/qthelper.h" +#include "qt-models/divelocationmodel.h" namespace Command { @@ -80,4 +82,29 @@ void DeleteDiveSites::undo() sitesToRemove = std::move(addDiveSites(sitesToAdd)); } +EditDiveSiteName::EditDiveSiteName(dive_site *dsIn, const QString &name) : ds(dsIn), + value(name) +{ +} + +bool EditDiveSiteName::workToBeDone() +{ + return value != QString(ds->name); +} + +void EditDiveSiteName::redo() +{ + QString s = ds->name; + free(ds->name); + ds->name = copy_qstring(value); + value = s; + emit diveListNotifier.diveSiteChanged(ds, LocationInformationModel::NAME); // Inform frontend of changed dive site. +} + +void EditDiveSiteName::undo() +{ + // Undo and redo do the same + redo(); +} + } // namespace Command |