Undo: make editing of dive number undoable

When pressing F2 in the dive list, the number can be edited.
Make this action undoable by implementing a EditNumber command.

This command is differs from the other undo commands, as not the
currently selected dives are changed. This means that the EditCommand
needs an alternative constructor taking a single dive. This constructor
was implemented in the base class so that all edit commands can now
be called with a single dive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-07-17 15:49:45 +02:00 committed by Dirk Hohndel
parent 658ac2bb78
commit 726d08c2f7
5 changed files with 55 additions and 2 deletions

View file

@ -7,6 +7,7 @@
#include "core/qthelper.h"
#include "core/subsurface-string.h"
#include "core/tag.h"
#include "desktop-widgets/command.h"
#include <QIcon>
#include <QDebug>
#include <memory>
@ -412,8 +413,7 @@ bool DiveTripModelBase::setData(const QModelIndex &index, const QVariant &value,
if (dive->number == v)
return false;
}
d->number = v;
mark_divelist_changed(true);
Command::editNumber(v, d);
return true;
}