[go: up one dir, main page]

Menu

[10cb05]: / undocommand.cpp  Maximize  Restore  History

Download this file

27 lines (21 with data), 549 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
#include "undocommand.h"
#include "dessin.h"
Undo_Command::Undo_Command(QWidget *dessin, QImage *image,
std::unique_ptr <Shape>&&s) :
dessin(dessin), image(image),
undoImage(image->copy(s->rect())), shape(std::move(s))
{
}
void Undo_Command::undo()
{
const QRect rect = shape->rect();
QPainter painter(image);
painter.drawImage(rect, undoImage);
dessin->update(rect);
}
void Undo_Command::redo()
{
QPainter painter(image);
shape->draw(painter);
dessin->update(shape->rect());
}