undo: more fine-grained undo of profile editing

Place undo commands for every change of the profile, not
only on "saving". Move the edit-mode from the mainwindow
and the maintab to the profile widget.

This is still very rough. For example, the only way to exit
the edit mode is changing the current dive.

The undo-commands are placed by the desktop-profile widget.
We might think about moving that down to the profile-view so
that this will be useable on mobile.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-02-19 11:58:36 +01:00
parent c5c8bfec65
commit fce48367cd
12 changed files with 162 additions and 100 deletions

View file

@ -9,10 +9,13 @@
#include <vector>
#include <memory>
struct dive;
class ProfileWidget2;
class EmptyView;
class QStackedWidget;
extern "C" void free_dive(struct dive *);
class ProfileWidget : public QWidget {
Q_OBJECT
public:
@ -21,18 +24,30 @@ public:
std::unique_ptr<ProfileWidget2> view;
void plotCurrentDive();
void setPlanState(const struct dive *d, int dc);
void setEditState(const struct dive *d, int dc);
void setEnabledToolbar(bool enabled);
private
slots:
void unsetProfHR();
void unsetProfTissues();
void stopAdded();
void stopRemoved(int count);
void stopMoved(int count);
private:
// The same code is in command/command_base.h. Should we make that a global feature?
struct DiveDeleter {
void operator()(dive *d) { free_dive(d); }
};
std::unique_ptr<EmptyView> emptyView;
std::vector<QAction *> toolbarActions;
Ui::ProfileWidget ui;
QStackedWidget *stack;
void setDive(const struct dive *d);
void editDive();
void exitEditMode();
std::unique_ptr<dive, DiveDeleter> editedDive;
int editedDc;
dive *originalDive;
};
#endif // PROFILEWIDGET_H