19
19
#include " qgis_core.h"
20
20
#include " qgis.h"
21
21
#include " qgscomposition.h"
22
+ #include " qgslayout.h"
22
23
#include < QObject>
23
24
24
25
class QgsProject ;
@@ -28,13 +29,13 @@ class QgsProject;
28
29
* \class QgsLayoutManager
29
30
* \since QGIS 3.0
30
31
*
31
- * \brief Manages storage of a set of compositions .
32
+ * \brief Manages storage of a set of layouts .
32
33
*
33
34
* QgsLayoutManager handles the storage, serializing and deserializing
34
- * of QgsCompositions . Usually this class is not constructed directly, but
35
+ * of QgsLayouts . Usually this class is not constructed directly, but
35
36
* rather accessed through a QgsProject via QgsProject::layoutManager().
36
37
*
37
- * QgsLayoutManager retains ownership of all the compositions contained
38
+ * QgsLayoutManager retains ownership of all the layouts contained
38
39
* in the manager.
39
40
*/
40
41
@@ -61,6 +62,15 @@ class CORE_EXPORT QgsLayoutManager : public QObject
61
62
*/
62
63
bool addComposition ( QgsComposition *composition SIP_TRANSFER );
63
64
65
+ /* *
66
+ * Adds a \a layout to the manager. Ownership of the layout is transferred to the manager.
67
+ * Returns true if the addition was successful, or false if the layout could not be added (eg
68
+ * as a result of a duplicate layout name).
69
+ * \see removeLayout()
70
+ * \see layoutAdded()
71
+ */
72
+ bool addLayout ( QgsLayout *layout SIP_TRANSFER );
73
+
64
74
/* *
65
75
* Removes a composition from the manager. The composition is deleted.
66
76
* Returns true if the removal was successful, or false if the removal failed (eg as a result
@@ -73,8 +83,19 @@ class CORE_EXPORT QgsLayoutManager : public QObject
73
83
bool removeComposition ( QgsComposition *composition );
74
84
75
85
/* *
76
- * Removes and deletes all compositions from the manager.
77
- * \see removeComposition()
86
+ * Removes a \a layout from the manager. The layout is deleted.
87
+ * Returns true if the removal was successful, or false if the removal failed (eg as a result
88
+ * of removing a layout which is not contained in the manager).
89
+ * \see addLayout()
90
+ * \see layoutRemoved()
91
+ * \see layoutAboutToBeRemoved()
92
+ * \see clear()
93
+ */
94
+ bool removeLayout ( QgsLayout *layout );
95
+
96
+ /* *
97
+ * Removes and deletes all layouts from the manager.
98
+ * \see removeLayout()
78
99
*/
79
100
void clear ();
80
101
@@ -83,14 +104,25 @@ class CORE_EXPORT QgsLayoutManager : public QObject
83
104
*/
84
105
QList< QgsComposition * > compositions () const ;
85
106
107
+ /* *
108
+ * Returns a list of all layouts contained in the manager.
109
+ */
110
+ QList< QgsLayout * > layouts () const ;
111
+
86
112
/* *
87
113
* Returns the composition with a matching name, or nullptr if no matching compositions
88
114
* were found.
89
115
*/
90
116
QgsComposition *compositionByName ( const QString &name ) const ;
91
117
92
118
/* *
93
- * Reads the manager's state from a DOM element, restoring all compositions
119
+ * Returns the layout with a matching name, or nullptr if no matching layouts
120
+ * were found.
121
+ */
122
+ QgsLayout *layoutByName ( const QString &name ) const ;
123
+
124
+ /* *
125
+ * Reads the manager's state from a DOM element, restoring all layouts
94
126
* present in the XML document.
95
127
* \see writeXml()
96
128
*/
@@ -126,30 +158,52 @@ class CORE_EXPORT QgsLayoutManager : public QObject
126
158
* Generates a unique title for a new composition, which does not
127
159
* clash with any already contained by the manager.
128
160
*/
161
+ QString generateUniqueComposerTitle () const ;
162
+
163
+ /* *
164
+ * Generates a unique title for a new layout, which does not
165
+ * clash with any already contained by the manager.
166
+ */
129
167
QString generateUniqueTitle () const ;
130
168
131
169
signals:
132
170
133
171
// ! Emitted when a composition is about to be added to the manager
134
172
void compositionAboutToBeAdded ( const QString &name );
135
173
174
+ // ! Emitted when a layout is about to be added to the manager
175
+ void layoutAboutToBeAdded ( const QString &name );
176
+
136
177
// ! Emitted when a composition has been added to the manager
137
178
void compositionAdded ( const QString &name );
138
179
180
+ // ! Emitted when a layout has been added to the manager
181
+ void layoutAdded ( const QString &name );
182
+
139
183
// ! Emitted when a composition was removed from the manager
140
184
void compositionRemoved ( const QString &name );
141
185
186
+ // ! Emitted when a layout was removed from the manager
187
+ void layoutRemoved ( const QString &name );
188
+
142
189
// ! Emitted when a composition is about to be removed from the manager
143
190
void compositionAboutToBeRemoved ( const QString &name );
144
191
192
+ // ! Emitted when a layout is about to be removed from the manager
193
+ void layoutAboutToBeRemoved ( const QString &name );
194
+
145
195
// ! Emitted when a composition is renamed
146
196
void compositionRenamed ( QgsComposition *composition, const QString &newName );
147
197
198
+ // ! Emitted when a layout is renamed
199
+ void layoutRenamed ( QgsLayout *layout, const QString &newName );
200
+
148
201
private:
149
202
150
203
QgsProject *mProject = nullptr ;
151
204
152
205
QList< QgsComposition * > mCompositions ;
206
+ QList< QgsLayout * > mLayouts ;
153
207
154
208
QgsComposition *createCompositionFromXml ( const QDomElement &element, const QDomDocument &doc ) const ;
155
209
0 commit comments