summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/tab-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-03-13 20:58:25 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 18:19:07 +0300
commit56dcbd9588fa3b7d70a4b639b71cb18e1c462067 (patch)
tree7a82e3bcc5e56d8c755f1e0244b5ef296bebaa39 /desktop-widgets/tab-widgets
parent2dcc0a7d1ebf6435060168f343df2adb5f0abb3c (diff)
downloadsubsurface-56dcbd9588fa3b7d70a4b639b71cb18e1c462067.tar.gz
Undo: implement undo of dive site addition
Implement a dive site addition undo command and connect it to the add dive site button. The added dive site has a default name ("new dive site"). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/tab-widgets')
-rw-r--r--desktop-widgets/tab-widgets/TabDiveSite.cpp8
-rw-r--r--desktop-widgets/tab-widgets/TabDiveSite.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/desktop-widgets/tab-widgets/TabDiveSite.cpp b/desktop-widgets/tab-widgets/TabDiveSite.cpp
index 5e2831c93..648df6395 100644
--- a/desktop-widgets/tab-widgets/TabDiveSite.cpp
+++ b/desktop-widgets/tab-widgets/TabDiveSite.cpp
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include "TabDiveSite.h"
#include "qt-models/divelocationmodel.h"
+#include "desktop-widgets/command.h"
#include <qt-models/divecomputerextradatamodel.h>
@@ -16,6 +17,8 @@ TabDiveSite::TabDiveSite(QWidget *parent) : TabBase(parent)
// Show only the first few columns
for (int i = LocationInformationModel::COORDS; i < LocationInformationModel::COLUMNS; ++i)
ui.diveSites->view()->setColumnHidden(i, true);
+
+ connect(ui.diveSites, &TableView::addButtonClicked, this, &TabDiveSite::add);
}
void TabDiveSite::updateData()
@@ -25,3 +28,8 @@ void TabDiveSite::updateData()
void TabDiveSite::clear()
{
}
+
+void TabDiveSite::add()
+{
+ Command::addDiveSite(tr("New dive site"));
+}
diff --git a/desktop-widgets/tab-widgets/TabDiveSite.h b/desktop-widgets/tab-widgets/TabDiveSite.h
index f0bf2d5d5..2538166b4 100644
--- a/desktop-widgets/tab-widgets/TabDiveSite.h
+++ b/desktop-widgets/tab-widgets/TabDiveSite.h
@@ -12,6 +12,8 @@ public:
TabDiveSite(QWidget *parent = 0);
void updateData() override;
void clear() override;
+private slots:
+ void add();
private:
Ui::TabDiveSite ui;
DiveSiteSortedModel model;