subsurface/desktop-widgets/profilewidget.h
Berthold Stoeger 4c46a11ed1 profile: update profile in edit mode on undo
When the user undos/redos the profile should update even
when in edit mode. This is a bit more complicated than
anticipated:

1) We should not do the update when emitting an undo command
from the profile. But we *should* update if it is an undo
command from the maintab (change depth/time).

2) The divepointsplannermodel has to be reset. Side note:
the code is truly abysmal as it sends numerous changed-signals.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-03-12 18:32:22 +01:00

56 lines
1.3 KiB
C++

// SPDX-License-Identifier: GPL-2.0
// The profile and its toolbars.
#ifndef PROFILEWIDGET_H
#define PROFILEWIDGET_H
#include "ui_profilewidget.h"
#include "core/subsurface-qt/divelistnotifier.h"
#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:
ProfileWidget();
~ProfileWidget();
std::unique_ptr<ProfileWidget2> view;
void plotCurrentDive();
void setPlanState(const struct dive *d, int dc);
void setEnabledToolbar(bool enabled);
private
slots:
void divesChanged(const QVector<dive *> &dives, DiveField field);
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;
bool placingCommand;
};
#endif // PROFILEWIDGET_H