undo: show multiple dive warning when editing equipment

When editing cylinders or weights directly in the table widgets,
no warning was shown if multiple dives were affected. To solve this,
emit signals from the respective models and catch them in dive
equipment tab. Not very nice, but it works for now.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-03-27 21:49:19 +01:00
parent 2eeb5f4fc2
commit 63414fc823
6 changed files with 22 additions and 8 deletions

View file

@ -112,8 +112,10 @@ void WeightModel::commitTempWS()
return;
// Only submit a command if the type changed
weightsystem_t ws = d->weightsystems.weightsystems[tempRow];
if (!same_string(ws.description, tempWS.description) || gettextFromC::tr(ws.description) != QString(tempWS.description))
Command::editWeight(tempRow, tempWS, false);
if (!same_string(ws.description, tempWS.description) || gettextFromC::tr(ws.description) != QString(tempWS.description)) {
int count = Command::editWeight(tempRow, tempWS, false);
emit divesEdited(count);
}
tempRow = -1;
#endif
}
@ -126,7 +128,8 @@ bool WeightModel::setData(const QModelIndex &index, const QVariant &value, int r
switch (index.column()) {
case WEIGHT:
ws.weight = string_to_weight(qPrintable(vString));
Command::editWeight(index.row(), ws, false);
int count = Command::editWeight(index.row(), ws, false);
emit divesEdited(count);
return true;
}
return false;