QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 "qgis.h"
22 #include "qgis_core.h"
23 #include "qgslayoutundocommand.h"
24 #include "qgslayoutitem.h"
25 
26 #include <memory>
27 
28 class QgsLayout;
29 class QUndoStack;
30 
36 class CORE_EXPORT QgsLayoutUndoStack : public QObject
37 {
38  Q_OBJECT
39 
40  public:
41 
45  QgsLayoutUndoStack( QgsLayout *layout );
46 
57  void beginMacro( const QString &commandText );
58 
70  void endMacro();
71 
84  void beginCommand( QgsLayoutUndoObjectInterface *object, const QString &commandText, int id = 0 );
85 
91  void endCommand();
92 
98  void cancelCommand();
99 
103  QUndoStack *stack();
104 
108  void notifyUndoRedoOccurred( QgsLayoutItem *item );
109 
121  void blockCommands( bool blocked );
122 
127  bool isBlocked() const;
128 
132  void push( QUndoCommand *command SIP_TRANSFER );
133 
134  signals:
135 
140  void undoRedoOccurredForItems( QSet< QString > itemUuids );
141 
142  private slots:
143 
144  void indexChanged();
145 
146  private:
147 
148  QgsLayout *mLayout = nullptr;
149 
150  std::unique_ptr< QUndoStack > mUndoStack;
151 
152  std::vector< std::unique_ptr< QgsAbstractLayoutUndoCommand > > mActiveCommands;
153 
154  QSet< QString > mUndoRedoOccurredItemUuids;
155 
156  int mBlockedCommands = 0;
157 
158 #ifdef SIP_RUN
159  QgsLayoutUndoStack( const QgsLayoutUndoStack &other );
160 #endif
161 };
162 
163 #endif // QGSLAYOUTUNDOCOMMAND_H
Base class for graphical items within a QgsLayout.
An undo stack for QgsLayouts.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:49
Interface for layout objects which support undo/redo commands.