mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-01 06:30:26 +00:00
Add UndoCommand class
Add a class to handle all undo/redo events. Whenever a user action affects a dive, an undo command will be created. A list of these commands will be stored in the UndoBuffer, to allow for moving forwards/backwards in the list. Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
c5138b2090
commit
8d1e4557a9
2 changed files with 31 additions and 0 deletions
|
@ -39,3 +39,21 @@ void UndoBuffer::recordAfter(dive *affectedDive)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
UndoCommand::UndoCommand(QString commandName, dive *affectedDive)
|
||||||
|
{
|
||||||
|
name = commandName;
|
||||||
|
stateBefore = affectedDive;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoCommand::undo()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoCommand::redo()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,19 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "dive.h"
|
#include "dive.h"
|
||||||
|
|
||||||
|
class UndoCommand {
|
||||||
|
private:
|
||||||
|
dive* stateBefore;
|
||||||
|
dive* stateAfter;
|
||||||
|
QString name;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit UndoCommand(QString commandName, dive* affectedDive);
|
||||||
|
void setStateAfter(dive* affectedDive);
|
||||||
|
void undo();
|
||||||
|
void redo();
|
||||||
|
};
|
||||||
|
|
||||||
class UndoBuffer : public QObject
|
class UndoBuffer : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
Loading…
Reference in a new issue