QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
layout
qgslayoutundocommand.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgslayoutundocommand.h
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
#ifndef QGSLAYOUTUNDOCOMMAND_H
19
#define QGSLAYOUTUNDOCOMMAND_H
20
21
#include "qgis_core.h"
22
#include "
qgis_sip.h
"
23
24
#include <QDomDocument>
25
#include <QUndoCommand>
26
27
class
QgsLayout
;
28
33
class
CORE_EXPORT
QgsAbstractLayoutUndoCommand
:
public
QUndoCommand
34
{
35
public
:
41
QgsAbstractLayoutUndoCommand
(
const
QString &text,
int
id
= 0, QUndoCommand *parent
SIP_TRANSFERTHIS
=
nullptr
);
42
43
void
undo
()
override
;
44
void
redo
()
override
;
45
int
id
()
const override
{
return
mId; }
46
52
void
saveBeforeState();
53
59
void
saveAfterState();
60
66
QDomDocument
beforeState
()
const
{
return
mBeforeState.cloneNode().toDocument(); }
67
73
QDomDocument
afterState
()
const
{
return
mAfterState.cloneNode().toDocument(); }
74
78
virtual
bool
containsChange()
const
;
79
80
protected
:
88
virtual
void
saveState
( QDomDocument &stateDoc )
const
= 0;
89
97
virtual
void
restoreState
( QDomDocument &stateDoc ) = 0;
98
102
void
setAfterState
(
const
QDomDocument &stateDoc );
103
105
bool
mFirstRun
=
true
;
106
107
private
:
109
QDomDocument mBeforeState;
110
112
QDomDocument mAfterState;
113
115
int
mId = 0;
116
};
117
122
class
CORE_EXPORT
QgsLayoutUndoObjectInterface
123
{
124
public
:
125
virtual
~QgsLayoutUndoObjectInterface
() =
default
;
126
133
virtual
QgsAbstractLayoutUndoCommand
*
createCommand
(
const
QString &text,
int
id
= 0, QUndoCommand *parent =
nullptr
) = 0
SIP_FACTORY
;
134
};
135
136
137
#endif
// QGSLAYOUTUNDOCOMMAND_H
QgsAbstractLayoutUndoCommand
Base class for commands to undo/redo layout and layout object changes.
Definition
qgslayoutundocommand.h:34
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::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::beforeState
QDomDocument beforeState() const
Returns the before state for the layout.
Definition
qgslayoutundocommand.h:66
QgsAbstractLayoutUndoCommand::restoreState
virtual void restoreState(QDomDocument &stateDoc)=0
Restores the state of the object from the specified stateDoc.
QgsAbstractLayoutUndoCommand::QgsAbstractLayoutUndoCommand
QgsAbstractLayoutUndoCommand(const QString &text, int id=0, QUndoCommand *parent=nullptr)
Constructor for QgsLayoutUndoCommand.
Definition
qgslayoutundocommand.cpp:20
QgsAbstractLayoutUndoCommand::afterState
QDomDocument afterState() const
Returns the after state for the layout.
Definition
qgslayoutundocommand.h:73
QgsAbstractLayoutUndoCommand::undo
void undo() override
Definition
qgslayoutundocommand.cpp:25
QgsAbstractLayoutUndoCommand::redo
void redo() override
Definition
qgslayoutundocommand.cpp:31
QgsLayoutUndoObjectInterface
Interface for layout objects which support undo/redo commands.
Definition
qgslayoutundocommand.h:123
QgsLayoutUndoObjectInterface::createCommand
virtual QgsAbstractLayoutUndoCommand * createCommand(const QString &text, int id=0, QUndoCommand *parent=nullptr)=0
Creates a new layout undo command with the specified text and parent.
QgsLayoutUndoObjectInterface::~QgsLayoutUndoObjectInterface
virtual ~QgsLayoutUndoObjectInterface()=default
QgsLayout
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition
qgslayout.h:51
qgis_sip.h
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition
qgis_sip.h:52
SIP_FACTORY
#define SIP_FACTORY
Definition
qgis_sip.h:83
Generated on
for QGIS API Documentation by
1.17.0