File tree Expand file tree Collapse file tree 3 files changed +80
-0
lines changed Expand file tree Collapse file tree 3 files changed +80
-0
lines changed Original file line number Diff line number Diff line change @@ -106,13 +106,25 @@ class QgsComposition : QGraphicsScene
106
106
const QgsComposerHtml* getComposerHtmlByItem( QgsComposerItem *item ) const;
107
107
108
108
/**Returns a composer item given its text identifier.
109
+ Ids are not necessarely unique, but this function returns only one element.
109
110
@note added in 2.0
110
111
@param theId - A QString representing the identifier of the item to
111
112
retrieve.
112
113
@return QgsComposerItem pointer or 0 pointer if no such item exists.
113
114
**/
114
115
const QgsComposerItem* getComposerItemById( QString theId ) const;
115
116
117
+
118
+ /**Returns a composer item given its unique identifier.
119
+ Warning : ids are not necessarely unique, but this function returns only one element.
120
+ @note added in 2.0
121
+ @param theId - A QString representing the UUID of the item to retrieve.
122
+ @param inAllComposers - Whether the search should be done in all composers of the project
123
+ @return QgsComposerItem pointer or 0 pointer if no such item exists.
124
+ **/
125
+ //const QgsComposerItem* getComposerItemByUuid( QString theUuid, bool inAllComposers = false ) const;
126
+ const QgsComposerItem* getComposerItemByUuid( QString theUuid ) const;
127
+
116
128
int printResolution() const;
117
129
void setPrintResolution( int dpi );
118
130
Original file line number Diff line number Diff line change @@ -261,6 +261,61 @@ const QgsComposerItem* QgsComposition::getComposerItemById( QString theId ) cons
261
261
}
262
262
return 0 ;
263
263
}
264
+ /*
265
+ const QgsComposerItem* QgsComposition::getComposerItemByUuid( QString theUuid, bool inAllComposers ) const
266
+ {
267
+ //This does not work since it seems impossible to get the QgisApp::instance() from here... Is there a workaround ?
268
+ QSet<QgsComposer*> composers = QSet<QgsComposer*>();
269
+
270
+ if( inAllComposers )
271
+ {
272
+ composers = QgisApp::instance()->printComposers();
273
+ }
274
+ else
275
+ {
276
+ composers.insert( this )
277
+ }
278
+
279
+ QSet<QgsComposer*>::const_iterator it = composers.constBegin();
280
+ for ( ; it != composers.constEnd(); ++it )
281
+ {
282
+ QList<QGraphicsItem *> itemList = ( *it )->items();
283
+ QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
284
+ for ( ; itemIt != itemList.end(); ++itemIt )
285
+ {
286
+ const QgsComposerItem* mypItem = dynamic_cast<const QgsComposerItem *>( *itemIt );
287
+ if ( mypItem )
288
+ {
289
+ if ( mypItem->uuid() == theUuid )
290
+ {
291
+ return mypItem;
292
+ }
293
+ }
294
+ }
295
+ }
296
+
297
+ return 0;
298
+ }
299
+ */
300
+
301
+ const QgsComposerItem* QgsComposition::getComposerItemByUuid ( QString theUuid ) const
302
+ {
303
+ QList<QGraphicsItem *> itemList = items ();
304
+ QList<QGraphicsItem *>::iterator itemIt = itemList.begin ();
305
+ for ( ; itemIt != itemList.end (); ++itemIt )
306
+ {
307
+ const QgsComposerItem* mypItem = dynamic_cast <const QgsComposerItem *>( *itemIt );
308
+ if ( mypItem )
309
+ {
310
+ if ( mypItem->uuid () == theUuid )
311
+ {
312
+ return mypItem;
313
+ }
314
+ }
315
+ }
316
+
317
+ return 0 ;
318
+ }
264
319
265
320
int QgsComposition::pixelFontSize ( double pointSize ) const
266
321
{
Original file line number Diff line number Diff line change 30
30
#include " qgscomposeritemcommand.h"
31
31
#include " qgsatlascomposition.h"
32
32
33
+ class QgisApp ;
33
34
class QgsComposerFrame ;
34
35
class QgsComposerItem ;
35
36
class QgsComposerMap ;
@@ -50,6 +51,7 @@ class QgsComposerAttributeTable;
50
51
class QgsComposerMultiFrame ;
51
52
class QgsComposerMultiFrameCommand ;
52
53
class QgsVectorLayer ;
54
+ class QgsComposer ;
53
55
54
56
/* * \ingroup MapComposer
55
57
* Graphics scene for map printing. The class manages the paper item which always
@@ -158,13 +160,24 @@ class CORE_EXPORT QgsComposition: public QGraphicsScene
158
160
const QgsComposerHtml* getComposerHtmlByItem ( QgsComposerItem *item ) const ;
159
161
160
162
/* *Returns a composer item given its text identifier.
163
+ Ids are not necessarely unique, but this function returns only one element.
161
164
@note added in 2.0
162
165
@param theId - A QString representing the identifier of the item to
163
166
retrieve.
164
167
@return QgsComposerItem pointer or 0 pointer if no such item exists.
165
168
**/
166
169
const QgsComposerItem* getComposerItemById ( QString theId ) const ;
167
170
171
+ /* *Returns a composer item given its unique identifier.
172
+ @note added in 2.0
173
+ @param theId - A QString representing the UUID of the item to
174
+ @param inAllComposers - Whether the search should be done in all composers of the project
175
+ retrieve.
176
+ @return QgsComposerItem pointer or 0 pointer if no such item exists.
177
+ **/
178
+ // const QgsComposerItem* getComposerItemByUuid( QString theUuid, bool inAllComposers = false ) const;//does not work since it's impossible to get QGisApp::instance()
179
+ const QgsComposerItem* getComposerItemByUuid ( QString theUuid ) const ;
180
+
168
181
int printResolution () const {return mPrintResolution ;}
169
182
void setPrintResolution ( int dpi ) {mPrintResolution = dpi;}
170
183
You can’t perform that action at this time.
0 commit comments