QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgslayoutundostack.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutundostack.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 QGSLAYOUTUNDOSTACK_H
19#define QGSLAYOUTUNDOSTACK_H
20
21#include <memory>
22
23#include "qgis_core.h"
24#include "qgis_sip.h"
25#include "qgslayoutitem.h"
27
28class QgsLayout;
29class QUndoStack;
30
35class CORE_EXPORT QgsLayoutUndoStack : public QObject
36{
37 Q_OBJECT
38
39 public:
40
45
56 void beginMacro( const QString &commandText );
57
69 void endMacro();
70
83 void beginCommand( QgsLayoutUndoObjectInterface *object, const QString &commandText, int id = 0 );
84
90 void endCommand();
91
97 void cancelCommand();
98
102 QUndoStack *stack();
103
108
120 void blockCommands( bool blocked );
121
126 bool isBlocked() const;
127
131 void push( QUndoCommand *command SIP_TRANSFER );
132
133 signals:
134
139 void undoRedoOccurredForItems( QSet< QString > itemUuids );
140
141 private slots:
142
143 void indexChanged();
144
145 private:
146
147 QgsLayout *mLayout = nullptr;
148
149 std::unique_ptr< QUndoStack > mUndoStack;
150
151 std::vector< std::unique_ptr< QgsAbstractLayoutUndoCommand > > mActiveCommands;
152
153 QSet< QString > mUndoRedoOccurredItemUuids;
154
155 int mBlockedCommands = 0;
156
157#ifdef SIP_RUN
159#endif
160};
161
162#endif // QGSLAYOUTUNDOCOMMAND_H
Base class for graphical items within a QgsLayout.
Interface for layout objects which support undo/redo commands.
void endCommand()
Saves final state of an object and pushes the active command to the undo history.
void cancelCommand()
Cancels the active command, discarding it without pushing to the undo history.
void beginMacro(const QString &commandText)
Starts a macro command, with the given descriptive commandText.
void beginCommand(QgsLayoutUndoObjectInterface *object, const QString &commandText, int id=0)
Begins a new undo command for the specified object.
void notifyUndoRedoOccurred(QgsLayoutItem *item)
Notifies the stack that an undo or redo action occurred for a specified item.
void push(QUndoCommand *command)
Manually pushes a command to the stack, and takes ownership of the command.
void endMacro()
Ends a macro command.
bool isBlocked() const
Returns true if undo commands are currently blocked.
void undoRedoOccurredForItems(QSet< QString > itemUuids)
Emitted when an undo or redo action has occurred, which affected a set of layout itemUuids.
QUndoStack * stack()
Returns a pointer to the internal QUndoStack.
void blockCommands(bool blocked)
Sets whether undo commands for the layout should be temporarily blocked.
QgsLayoutUndoStack(QgsLayout *layout)
Constructor for QgsLayoutUndoStack, for the specified parent layout.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition qgslayout.h:50
#define SIP_TRANSFER
Definition qgis_sip.h:36