mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-01 06:30:26 +00:00
d60a620193
Before the dive is deleted, a copy is made and passed to the undo buffer. When edit->undo is clicked, this dive is restored to the dive list. Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
39 lines
767 B
C++
39 lines
767 B
C++
#ifndef UNDOBUFFER_H
|
|
#define UNDOBUFFER_H
|
|
|
|
#include <QObject>
|
|
#include "dive.h"
|
|
|
|
class UndoCommand {
|
|
private:
|
|
dive* stateBefore;
|
|
dive* stateAfter;
|
|
QString name;
|
|
|
|
public:
|
|
explicit UndoCommand(QString commandName, dive* affectedDive);
|
|
void setStateAfter(dive* affectedDive) { stateAfter = affectedDive; }
|
|
void undo();
|
|
void redo();
|
|
};
|
|
|
|
class UndoBuffer : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit UndoBuffer(QObject *parent = 0);
|
|
~UndoBuffer();
|
|
bool canUndo();
|
|
bool canRedo();
|
|
UndoCommand *current() const { return list.at(curIdx - 1); }
|
|
private:
|
|
QList<UndoCommand*> list;
|
|
int curIdx;
|
|
public slots:
|
|
void redo();
|
|
void undo();
|
|
void recordbefore(QString commandName, dive *affectedDive);
|
|
void recordAfter(dive *affectedDive);
|
|
};
|
|
|
|
#endif // UNDOBUFFER_H
|