QGIS API Documentation 4.1.0-Master (60fea48833c)
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:
44
55 void beginMacro( const QString &commandText );
56
68 void endMacro();
69
82 void beginCommand( QgsLayoutUndoObjectInterface *object, const QString &commandText, int id = 0 );
83
89 void endCommand();
90
96 void cancelCommand();
97
101 QUndoStack *stack();
102
107
119 void blockCommands( bool blocked );
120
125 bool isBlocked() const;
126
130 void push( QUndoCommand *command SIP_TRANSFER );
131
132 signals:
133
138 void undoRedoOccurredForItems( QSet< QString > itemUuids );
139
140 private slots:
141
142 void indexChanged();
143
144 private:
145 QgsLayout *mLayout = nullptr;
146
147 std::unique_ptr< QUndoStack > mUndoStack;
148
149 std::vector< std::unique_ptr< QgsAbstractLayoutUndoCommand > > mActiveCommands;
150
151 QSet< QString > mUndoRedoOccurredItemUuids;
152
153 int mBlockedCommands = 0;
154
155#ifdef SIP_RUN
157#endif
158};
159
160#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:35