summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/diveplanner.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-11-02 22:52:27 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-12-05 10:14:25 -0800
commitb3253304a59b85c76f8a70f20ada4139e715a5b3 (patch)
tree8e21ae9d46d9d6ed1f651b7b6008512ae1fd622d /desktop-widgets/diveplanner.cpp
parent147a36647ce6148ef2eccbe393faa658d0fe6834 (diff)
downloadsubsurface-b3253304a59b85c76f8a70f20ada4139e715a5b3.tar.gz
Desktop: don't connect to remove() slot of model from TableModel
When connecting a model to the TableModel class, it would connect clicking on an item to the remove() slot of the model. This breaks the program flow implied by the undo code: Ui --> Undo-Command --> Model --> UI Moreover, the naming of the remove() slot is illogical, because clicks can also have different effects, as for example in the cylinder-table. Therefore, move the connect() call from TableModel to the callers. In the case of TabDiveSite, move the remove() function from the model to the TabWidget, where it makes more sense. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/diveplanner.cpp')
-rw-r--r--desktop-widgets/diveplanner.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp
index 663bb03fb..aac81c81e 100644
--- a/desktop-widgets/diveplanner.cpp
+++ b/desktop-widgets/diveplanner.cpp
@@ -114,12 +114,14 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg
ui.dateEdit->setDisplayFormat(prefs.date_format);
ui.tableWidget->setTitle(tr("Dive planner points"));
ui.tableWidget->setModel(plannerModel);
+ connect(ui.tableWidget, &TableView::itemClicked, plannerModel, &DivePlannerPointsModel::remove);
plannerModel->setRecalc(true);
ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::GAS, new AirTypesDelegate(this));
ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DIVEMODE, new DiveTypesDelegate(this));
ui.cylinderTableWidget->setTitle(tr("Available gases"));
ui.cylinderTableWidget->setBtnToolTip(tr("Add cylinder"));
ui.cylinderTableWidget->setModel(CylindersModel::instance());
+ connect(ui.cylinderTableWidget, &TableView::itemClicked, CylindersModel::instance(), &CylindersModel::remove);
ui.waterType->setItemData(0, FRESHWATER_SALINITY);
ui.waterType->setItemData(1, SEAWATER_SALINITY);
ui.waterType->setItemData(2, EN13319_SALINITY);