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>
This commit is contained in:
Berthold Stoeger 2019-11-02 22:52:27 +01:00 committed by Dirk Hohndel
parent 147a36647c
commit b3253304a5
9 changed files with 34 additions and 35 deletions

View file

@ -33,8 +33,10 @@ TabDiveEquipment::TabDiveEquipment(QWidget *parent) : TabBase(parent),
ui.weights->setModel(weightModel);
connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &TabDiveEquipment::divesChanged);
connect(ui.cylinders->view(), &QTableView::clicked, this, &TabDiveEquipment::editCylinderWidget);
connect(ui.weights->view(), &QTableView::clicked, this, &TabDiveEquipment::editWeightWidget);
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
// let's fix that.