Undo: implement invalidate-dive command

Connect command to context menu.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-12-12 23:07:17 +01:00 committed by Dirk Hohndel
parent 329641fdcd
commit 4e47cdfa2c
8 changed files with 43 additions and 21 deletions

View file

@ -168,6 +168,11 @@ int editMode(int index, int newValue, bool currentDiveOnly)
return execute_edit(new EditMode(index, newValue, currentDiveOnly));
}
int editInvalid(int newValue, bool currentDiveOnly)
{
return execute_edit(new EditInvalid(newValue, currentDiveOnly));
}
int editSuit(const QString &newValue, bool currentDiveOnly)
{
return execute_edit(new EditSuit(newValue, currentDiveOnly));

View file

@ -66,6 +66,7 @@ void purgeUnusedDiveSites();
int editNotes(const QString &newValue, bool currentDiveOnly);
int editSuit(const QString &newValue, bool currentDiveOnly);
int editMode(int index, int newValue, bool currentDiveOnly);
int editInvalid(int newValue, bool currentDiveOnly);
int editRating(int newValue, bool currentDiveOnly);
int editVisibility(int newValue, bool currentDiveOnly);
int editWaveSize(int newValue, bool currentDiveOnly);

View file

@ -574,6 +574,27 @@ DiveField EditMode::fieldId() const
return DiveField::MODE;
}
// ***** Invalid *****
void EditInvalid::set(struct dive *d, int invalid) const
{
d->invalid = invalid;
}
int EditInvalid::data(struct dive *d) const
{
return d->invalid;
}
QString EditInvalid::fieldName() const
{
return tr("invalid");
}
DiveField EditInvalid::fieldId() const
{
return DiveField::INVALID;
}
// ***** Tag based commands *****
EditTagsBase::EditTagsBase(const QStringList &newListIn, bool currentDiveOnly) :
EditDivesBase(currentDiveOnly),

View file

@ -222,6 +222,15 @@ public:
DiveField fieldId() const override;
};
class EditInvalid : public EditBase<int> {
public:
using EditBase<int>::EditBase; // Use constructor of base class.
void set(struct dive *d, int number) const override;
int data(struct dive *d) const override;
QString fieldName() const override;
DiveField fieldId() const override;
};
// Fields that work with tag-lists (tags, buddies, divemasters) work differently and therefore
// have their own base class. In this case, it's not a template, as all these lists are base
// on strings.