diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-02-24 11:14:55 +0100 |
---|---|---|
committer | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-04-07 00:13:35 +0200 |
commit | 1f8a45db44d12ced038d72c84d663885043e8663 (patch) | |
tree | ae433b5f54774b9a50c7e21fe8f3b7422f94ca5f /desktop-widgets/tab-widgets/TabDiveEquipment.cpp | |
parent | c4bf1ce8916c3549e51b455548f87508f3b5e23b (diff) | |
download | subsurface-1f8a45db44d12ced038d72c84d663885043e8663.tar.gz |
undo: call removeCylinder undo command in equipment tab
Instead of connecting to the remove() function of the model,
call the removeCylinder undo command. Take care to translate
the index into the source index, should cylinders be hidden!
Apart from the map-to-source call, this copies the weightsystem
code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/tab-widgets/TabDiveEquipment.cpp')
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveEquipment.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/desktop-widgets/tab-widgets/TabDiveEquipment.cpp b/desktop-widgets/tab-widgets/TabDiveEquipment.cpp index d34b44c74..ea2d910ef 100644 --- a/desktop-widgets/tab-widgets/TabDiveEquipment.cpp +++ b/desktop-widgets/tab-widgets/TabDiveEquipment.cpp @@ -33,7 +33,6 @@ TabDiveEquipment::TabDiveEquipment(QWidget *parent) : TabBase(parent), ui.weights->setModel(weightModel); connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &TabDiveEquipment::divesChanged); - connect(ui.cylinders, &TableView::itemClicked, cylindersModel, &CylindersModelFiltered::remove); connect(ui.cylinders, &TableView::itemClicked, this, &TabDiveEquipment::editCylinderWidget); connect(ui.weights, &TableView::itemClicked, this, &TabDiveEquipment::editWeightWidget); @@ -164,14 +163,13 @@ void TabDiveEquipment::addWeight_clicked() void TabDiveEquipment::editCylinderWidget(const QModelIndex &index) { - if (cylindersModel->model()->changed && !MainWindow::instance()->mainTab->isEditing()) { - MainWindow::instance()->mainTab->enableEdition(); + if (!index.isValid()) return; - } - if (index.isValid() && index.column() != CylindersModel::REMOVE) { - MainWindow::instance()->mainTab->enableEdition(); + + if (index.column() == CylindersModel::REMOVE) + divesEdited(Command::removeCylinder(cylindersModel->mapToSource(index).row(), false)); + else ui.cylinders->edit(index); - } } void TabDiveEquipment::editWeightWidget(const QModelIndex &index) |