-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcommands.cpp
More file actions
32 lines (28 loc) · 740 Bytes
/
commands.cpp
File metadata and controls
32 lines (28 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "commands.h"
#include "qrect.h"
/**
* @brief DrawCommand::DrawCommand - A command that keeps a copy of the image
* before and after something is drawn
*/
DrawCommand::DrawCommand(const QPixmap &oldImage, QPixmap *image,
QUndoCommand *parent)
: QUndoCommand(parent)
{
this->image = image;
this->oldImage = oldImage;
newImage = image->copy(QRect());
}
/**
* @brief DrawCommand::undo - Undo a draw command, restoring the old image
*/
void DrawCommand::undo()
{
*image = oldImage.copy(QRect());
}
/**
* @brief DrawCommand::redo - 'Undo' an undo, restoring the new image
*/
void DrawCommand::redo()
{
*image = newImage.copy(QRect());
}