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.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/desktop-widgets/command_divesite.cpp b/desktop-widgets/command_divesite.cpp
index a5dce00d1..3b35ddcc2 100644
--- a/desktop-widgets/command_divesite.cpp
+++ b/desktop-widgets/command_divesite.cpp
@@ -105,6 +105,31 @@ void DeleteDiveSites::undo()
sitesToRemove = std::move(addDiveSites(sitesToAdd));
}
+PurgeUnusedDiveSites::PurgeUnusedDiveSites()
+{
+ setText(tr("purge unused dive sites"));
+ for (int i = 0; i < dive_site_table.nr; ++i) {
+ dive_site *ds = dive_site_table.dive_sites[i];
+ if (ds->dives.nr == 0)
+ sitesToRemove.push_back(ds);
+ }
+}
+
+bool PurgeUnusedDiveSites::workToBeDone()
+{
+ return !sitesToRemove.empty();
+}
+
+void PurgeUnusedDiveSites::redo()
+{
+ sitesToAdd = std::move(removeDiveSites(sitesToRemove));
+}
+
+void PurgeUnusedDiveSites::undo()
+{
+ sitesToRemove = std::move(addDiveSites(sitesToAdd));
+}
+
// Helper function: swap C and Qt string
static void swap(char *&c, QString &q)
{