mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-17 20:36:15 +00:00
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>
This commit is contained in:
parent
c4bf1ce891
commit
1f8a45db44
1 changed files with 5 additions and 7 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue