mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Undo: make "delete dive computer" undoable
Simply reuse the code for "move dive computer" by creating a DiveComputerBase base class. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
eba6e76b96
commit
0bc96905bf
7 changed files with 60 additions and 25 deletions
|
|
@ -236,23 +236,36 @@ public:
|
|||
SplitDiveComputer(dive *d, int dc_num);
|
||||
};
|
||||
|
||||
// When moving the dive computer to the front, we go the ineffective,
|
||||
// but easy way: We keep two full copies of the dive (before and after).
|
||||
// When manipulating dive computers (moving, deleting) we go the ineffective,
|
||||
// but simple and robust way: We keep two full copies of the dive (before and after).
|
||||
// Removing and readding assures that the dive stays at the correct
|
||||
// position in the list (the dive computer list is used for sorting dives).
|
||||
class MoveDiveComputerToFront : public DiveListBase {
|
||||
public:
|
||||
MoveDiveComputerToFront(dive *d, int dc_num);
|
||||
class DiveComputerBase : public DiveListBase {
|
||||
protected:
|
||||
// old_dive must be a dive known to the core.
|
||||
// new_dive must be new dive whose ownership is taken.
|
||||
DiveComputerBase(dive *old_dive, dive *new_dive);
|
||||
private:
|
||||
void undoit() override;
|
||||
void redoit() override;
|
||||
bool workToBeDone() override;
|
||||
|
||||
protected:
|
||||
// For redo and undo
|
||||
DivesAndTripsToAdd diveToAdd;
|
||||
DivesAndSitesToRemove diveToRemove;
|
||||
};
|
||||
|
||||
class MoveDiveComputerToFront : public DiveComputerBase {
|
||||
public:
|
||||
MoveDiveComputerToFront(dive *d, int dc_num);
|
||||
};
|
||||
|
||||
class DeleteDiveComputer : public DiveComputerBase {
|
||||
public:
|
||||
DeleteDiveComputer(dive *d, int dc_num);
|
||||
};
|
||||
|
||||
class MergeDives : public DiveListBase {
|
||||
public:
|
||||
MergeDives(const QVector<dive *> &dives);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue