mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Undo: make weight-deletion an undoable action
This one is a bit more complicated than weight adding, because the multiple-dive case is not well defined. If multiple dives are selected, this implementation will search for weights that are identical to the weight deleted in the currently shown dive. The position of the weight in the list is ignored. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
b3253304a5
commit
b3f530bfb9
9 changed files with 111 additions and 18 deletions
|
@ -35,7 +35,6 @@ TabDiveEquipment::TabDiveEquipment(QWidget *parent) : TabBase(parent),
|
|||
connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &TabDiveEquipment::divesChanged);
|
||||
connect(ui.cylinders, &TableView::itemClicked, cylindersModel, &CylindersModel::remove);
|
||||
connect(ui.cylinders, &TableView::itemClicked, this, &TabDiveEquipment::editCylinderWidget);
|
||||
connect(ui.weights, &TableView::itemClicked, weightModel, &WeightModel::remove);
|
||||
connect(ui.weights, &TableView::itemClicked, this, &TabDiveEquipment::editWeightWidget);
|
||||
|
||||
// Current display of things on Gnome3 looks like shit, so
|
||||
|
@ -177,10 +176,15 @@ void TabDiveEquipment::editCylinderWidget(const QModelIndex &index)
|
|||
|
||||
void TabDiveEquipment::editWeightWidget(const QModelIndex &index)
|
||||
{
|
||||
MainWindow::instance()->mainTab->enableEdition();
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
if (index.isValid() && index.column() != WeightModel::REMOVE)
|
||||
if (index.column() == WeightModel::REMOVE) {
|
||||
divesEdited(Command::removeWeight(index.row(), false));
|
||||
} else {
|
||||
MainWindow::instance()->mainTab->enableEdition();
|
||||
ui.weights->edit(index);
|
||||
}
|
||||
}
|
||||
|
||||
// tricky little macro to edit all the selected dives
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue