QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
layout
qgslayoutundocommand.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgslayoutundocommand.cpp
3
------------------------
4
begin : July 2017
5
copyright : (C) 2017 by Nyall Dawson
6
email : nyall dot dawson at gmail dot com
7
***************************************************************************/
8
9
/***************************************************************************
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
***************************************************************************/
17
18
#include "
qgslayoutundocommand.h
"
19
20
QgsAbstractLayoutUndoCommand::QgsAbstractLayoutUndoCommand
(
const
QString &text,
int
id
, QUndoCommand *parent )
21
: QUndoCommand( text, parent )
22
, mId(
id
)
23
{}
24
25
void
QgsAbstractLayoutUndoCommand::undo
()
26
{
27
QUndoCommand::undo();
28
restoreState
( mBeforeState );
29
}
30
31
void
QgsAbstractLayoutUndoCommand::redo
()
32
{
33
if
(
mFirstRun
)
34
{
35
mFirstRun
=
false
;
36
return
;
37
}
38
QUndoCommand::redo();
39
restoreState
( mAfterState );
40
}
41
42
void
QgsAbstractLayoutUndoCommand::saveBeforeState
()
43
{
44
saveState
( mBeforeState );
45
}
46
47
void
QgsAbstractLayoutUndoCommand::saveAfterState
()
48
{
49
saveState
( mAfterState );
50
}
51
52
bool
QgsAbstractLayoutUndoCommand::containsChange
()
const
53
{
54
return
!( mBeforeState.isNull() || mAfterState.isNull() || mBeforeState.toString() == mAfterState.toString() );
55
}
56
57
void
QgsAbstractLayoutUndoCommand::setAfterState
(
const
QDomDocument &stateDoc )
58
{
59
mAfterState = stateDoc;
60
}
QgsAbstractLayoutUndoCommand::id
int id() const override
Definition
qgslayoutundocommand.h:45
QgsAbstractLayoutUndoCommand::mFirstRun
bool mFirstRun
Flag to prevent the first redo() if the command is pushed to the undo stack.
Definition
qgslayoutundocommand.h:105
QgsAbstractLayoutUndoCommand::containsChange
virtual bool containsChange() const
Returns true if both the before and after states are valid and different.
Definition
qgslayoutundocommand.cpp:52
QgsAbstractLayoutUndoCommand::saveState
virtual void saveState(QDomDocument &stateDoc) const =0
Saves the state of the object to the specified stateDoc.
QgsAbstractLayoutUndoCommand::setAfterState
void setAfterState(const QDomDocument &stateDoc)
Manually sets the after state for the command.
Definition
qgslayoutundocommand.cpp:57
QgsAbstractLayoutUndoCommand::restoreState
virtual void restoreState(QDomDocument &stateDoc)=0
Restores the state of the object from the specified stateDoc.
QgsAbstractLayoutUndoCommand::saveAfterState
void saveAfterState()
Saves current layout state as after state.
Definition
qgslayoutundocommand.cpp:47
QgsAbstractLayoutUndoCommand::QgsAbstractLayoutUndoCommand
QgsAbstractLayoutUndoCommand(const QString &text, int id=0, QUndoCommand *parent=nullptr)
Constructor for QgsLayoutUndoCommand.
Definition
qgslayoutundocommand.cpp:20
QgsAbstractLayoutUndoCommand::saveBeforeState
void saveBeforeState()
Saves current layout state as before state.
Definition
qgslayoutundocommand.cpp:42
QgsAbstractLayoutUndoCommand::undo
void undo() override
Definition
qgslayoutundocommand.cpp:25
QgsAbstractLayoutUndoCommand::redo
void redo() override
Definition
qgslayoutundocommand.cpp:31
qgslayoutundocommand.h
Generated on
for QGIS API Documentation by
1.17.0