QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgslayoutitemundocommand.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutitemundocommand.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 QGSLAYOUTITEMUNDOCOMMAND_H
19#define QGSLAYOUTITEMUNDOCOMMAND_H
20
22#include "qgis_core.h"
23
24class QgsLayout;
25class QgsLayoutItem;
26
28
30
41class CORE_EXPORT QgsLayoutItemUndoCommand: public QgsAbstractLayoutUndoCommand
42{
43 public:
44
52 QgsLayoutItemUndoCommand( QgsLayoutItem *item, const QString &text, int id = 0, QUndoCommand *parent SIP_TRANSFERTHIS = nullptr );
53
54 bool mergeWith( const QUndoCommand *command ) override;
55
59 QgsLayout *layout() const;
60
65 QString itemUuid() const;
66
67 protected:
68
69 void saveState( QDomDocument &stateDoc ) const override;
70 void restoreState( QDomDocument &stateDoc ) override;
71
72 virtual QgsLayoutItem *recreateItem( int itemType, QgsLayout *layout );
73
74 private:
75
76 QString mItemUuid;
77 QgsLayout *mLayout = nullptr;
78 int mItemType = 0;
79
80};
81
91class CORE_EXPORT QgsLayoutItemDeleteUndoCommand: public QgsLayoutItemUndoCommand
92{
93 public:
94
102 QgsLayoutItemDeleteUndoCommand( QgsLayoutItem *item, const QString &text, int id = 0, QUndoCommand *parent SIP_TRANSFERTHIS = nullptr );
103 bool mergeWith( const QUndoCommand *command ) override;
104 void redo() override;
105
106};
107
108
118class CORE_EXPORT QgsLayoutItemAddItemCommand: public QgsLayoutItemUndoCommand
119{
120 public:
121
129 QgsLayoutItemAddItemCommand( QgsLayoutItem *item, const QString &text, int id = 0, QUndoCommand *parent SIP_TRANSFERTHIS = nullptr );
130 bool containsChange() const override;
131 bool mergeWith( const QUndoCommand *command ) override;
132 void undo() override;
133
134};
135
137
138#endif
Base class for commands to undo/redo layout and layout object changes.
virtual bool containsChange() const
Returns true if both the before and after states are valid and different.
virtual void saveState(QDomDocument &stateDoc) const =0
Saves the state of the object to the specified stateDoc.
virtual void restoreState(QDomDocument &stateDoc)=0
Restores the state of the object from the specified stateDoc.
Base class for graphical items within a QgsLayout.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition qgslayout.h:49
#define SIP_NO_FILE
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53