@@ -190,133 +190,133 @@ bool QgsComposition::readXML( const QDomElement& compositionElem, const QDomDocu
190
190
return true ;
191
191
}
192
192
193
- void QgsComposition::addItemToZList (QgsComposerItem* item)
193
+ void QgsComposition::addItemToZList ( QgsComposerItem* item )
194
194
{
195
- if ( !item)
196
- {
197
- return ;
198
- }
199
- mItemZList .push_back (item);
200
- qWarning (QString::number (mItemZList .size ()).toLocal8Bit ().data ());
201
- item->setZValue (mItemZList .size ());
195
+ if ( !item )
196
+ {
197
+ return ;
198
+ }
199
+ mItemZList .push_back ( item );
200
+ qWarning ( QString::number ( mItemZList .size () ).toLocal8Bit ().data () );
201
+ item->setZValue ( mItemZList .size () );
202
202
}
203
203
204
- void QgsComposition::removeItemFromZList (QgsComposerItem* item)
204
+ void QgsComposition::removeItemFromZList ( QgsComposerItem* item )
205
205
{
206
- if ( !item)
207
- {
208
- return ;
209
- }
210
- mItemZList .removeAll (item);
206
+ if ( !item )
207
+ {
208
+ return ;
209
+ }
210
+ mItemZList .removeAll ( item );
211
211
}
212
212
213
213
void QgsComposition::raiseSelectedItems ()
214
214
{
215
215
QList<QgsComposerItem*> selectedItems = selectedComposerItems ();
216
216
QList<QgsComposerItem*>::iterator it = selectedItems.begin ();
217
- for ( ; it != selectedItems.end (); ++it)
218
- {
219
- raiseItem (*it);
220
- }
217
+ for ( ; it != selectedItems.end (); ++it )
218
+ {
219
+ raiseItem ( *it );
220
+ }
221
221
222
222
// update all positions
223
223
updateZValues ();
224
224
update ();
225
225
}
226
226
227
- void QgsComposition::raiseItem (QgsComposerItem* item)
227
+ void QgsComposition::raiseItem ( QgsComposerItem* item )
228
228
{
229
229
// search item
230
- QMutableLinkedListIterator<QgsComposerItem*> it (mItemZList );
231
- if (it.findNext (item))
230
+ QMutableLinkedListIterator<QgsComposerItem*> it ( mItemZList );
231
+ if ( it.findNext ( item ) )
232
+ {
233
+ if ( it.hasNext () )
232
234
{
233
- if (it.hasNext ())
234
- {
235
- it.remove ();
236
- it.next ();
237
- it.insert (item);
238
- }
235
+ it.remove ();
236
+ it.next ();
237
+ it.insert ( item );
239
238
}
239
+ }
240
240
}
241
241
242
242
void QgsComposition::lowerSelectedItems ()
243
243
{
244
244
QList<QgsComposerItem*> selectedItems = selectedComposerItems ();
245
245
QList<QgsComposerItem*>::iterator it = selectedItems.begin ();
246
- for ( ; it != selectedItems.end (); ++it)
247
- {
248
- lowerItem (*it);
249
- }
246
+ for ( ; it != selectedItems.end (); ++it )
247
+ {
248
+ lowerItem ( *it );
249
+ }
250
250
251
251
// update all positions
252
252
updateZValues ();
253
253
update ();
254
254
}
255
255
256
- void QgsComposition::lowerItem (QgsComposerItem* item)
256
+ void QgsComposition::lowerItem ( QgsComposerItem* item )
257
257
{
258
258
// search item
259
- QMutableLinkedListIterator<QgsComposerItem*> it (mItemZList );
260
- if (it.findNext (item))
259
+ QMutableLinkedListIterator<QgsComposerItem*> it ( mItemZList );
260
+ if ( it.findNext ( item ) )
261
+ {
262
+ it.previous ();
263
+ if ( it.hasPrevious () )
261
264
{
265
+ it.remove ();
262
266
it.previous ();
263
- if (it.hasPrevious ())
264
- {
265
- it.remove ();
266
- it.previous ();
267
- it.insert (item);
268
- }
267
+ it.insert ( item );
269
268
}
269
+ }
270
270
}
271
271
272
272
void QgsComposition::moveSelectedItemsToTop ()
273
273
{
274
274
QList<QgsComposerItem*> selectedItems = selectedComposerItems ();
275
275
QList<QgsComposerItem*>::iterator it = selectedItems.begin ();
276
- for ( ; it != selectedItems.end (); ++it)
277
- {
278
- moveItemToTop (*it);
279
- }
276
+ for ( ; it != selectedItems.end (); ++it )
277
+ {
278
+ moveItemToTop ( *it );
279
+ }
280
280
281
281
// update all positions
282
282
updateZValues ();
283
283
update ();
284
284
}
285
285
286
- void QgsComposition::moveItemToTop (QgsComposerItem* item)
286
+ void QgsComposition::moveItemToTop ( QgsComposerItem* item )
287
287
{
288
288
// search item
289
- QMutableLinkedListIterator<QgsComposerItem*> it (mItemZList );
290
- if ( it.findNext (item) )
291
- {
292
- it.remove ();
293
- }
294
- mItemZList .push_back (item);
289
+ QMutableLinkedListIterator<QgsComposerItem*> it ( mItemZList );
290
+ if ( it.findNext ( item ) )
291
+ {
292
+ it.remove ();
293
+ }
294
+ mItemZList .push_back ( item );
295
295
}
296
-
296
+
297
297
void QgsComposition::moveSelectedItemsToBottom ()
298
298
{
299
299
QList<QgsComposerItem*> selectedItems = selectedComposerItems ();
300
300
QList<QgsComposerItem*>::iterator it = selectedItems.begin ();
301
- for ( ; it != selectedItems.end (); ++it)
302
- {
303
- moveItemToBottom (*it);
304
- }
301
+ for ( ; it != selectedItems.end (); ++it )
302
+ {
303
+ moveItemToBottom ( *it );
304
+ }
305
305
306
306
// update all positions
307
307
updateZValues ();
308
308
update ();
309
309
}
310
310
311
- void QgsComposition::moveItemToBottom (QgsComposerItem* item)
311
+ void QgsComposition::moveItemToBottom ( QgsComposerItem* item )
312
312
{
313
313
// search item
314
- QMutableLinkedListIterator<QgsComposerItem*> it (mItemZList );
315
- if ( it.findNext (item) )
316
- {
317
- it.remove ();
318
- }
319
- mItemZList .push_front (item);
314
+ QMutableLinkedListIterator<QgsComposerItem*> it ( mItemZList );
315
+ if ( it.findNext ( item ) )
316
+ {
317
+ it.remove ();
318
+ }
319
+ mItemZList .push_front ( item );
320
320
}
321
321
322
322
void QgsComposition::updateZValues ()
@@ -325,79 +325,79 @@ void QgsComposition::updateZValues()
325
325
QLinkedList<QgsComposerItem*>::iterator it = mItemZList .begin ();
326
326
QgsComposerItem* currentItem = 0 ;
327
327
328
- for (; it != mItemZList .end (); ++it)
328
+ for ( ; it != mItemZList .end (); ++it )
329
+ {
330
+ currentItem = *it;
331
+ if ( currentItem )
329
332
{
330
- currentItem = *it;
331
- if (currentItem)
332
- {
333
- qWarning (QString::number (counter).toLocal8Bit ().data ());
334
- currentItem->setZValue (counter);
335
- }
336
- ++counter;
333
+ qWarning ( QString::number ( counter ).toLocal8Bit ().data () );
334
+ currentItem->setZValue ( counter );
337
335
}
336
+ ++counter;
337
+ }
338
338
}
339
339
340
340
void QgsComposition::sortZList ()
341
341
{
342
342
// debug: list before sorting
343
- qWarning (" before sorting" );
343
+ qWarning ( " before sorting" );
344
344
QLinkedList<QgsComposerItem*>::iterator before_it = mItemZList .begin ();
345
- for ( ; before_it != mItemZList .end (); ++before_it)
346
- {
347
- qWarning (QString::number ((*before_it)->zValue ()).toLocal8Bit ().data ());
348
- }
345
+ for ( ; before_it != mItemZList .end (); ++before_it )
346
+ {
347
+ qWarning ( QString::number (( *before_it )->zValue () ).toLocal8Bit ().data () );
348
+ }
349
349
350
- QMutableLinkedListIterator<QgsComposerItem*> it (mItemZList );
350
+ QMutableLinkedListIterator<QgsComposerItem*> it ( mItemZList );
351
351
int previousZ, afterZ; // z values of items before and after
352
352
QgsComposerItem* previousItem;
353
353
QgsComposerItem* afterItem;
354
354
355
- while (it.hasNext ())
355
+ while ( it.hasNext () )
356
+ {
357
+ previousItem = it.next ();
358
+ if ( previousItem )
359
+ {
360
+ previousZ = previousItem->zValue ();
361
+ }
362
+ else
363
+ {
364
+ previousZ = -1 ;
365
+ }
366
+
367
+ if ( !it.hasNext () )
356
368
{
357
- previousItem = it.next ();
358
- if (previousItem)
359
- {
360
- previousZ = previousItem->zValue ();
361
- }
362
- else
363
- {
364
- previousZ = -1 ;
365
- }
366
-
367
- if (!it.hasNext ())
368
- {
369
- break ; // this is the end...
370
- }
371
- afterItem = it.peekNext ();
372
-
373
- if (afterItem)
374
- {
375
- afterZ = afterItem->zValue ();
376
- }
377
- else
378
- {
379
- afterZ = -1 ;
380
- }
381
-
382
- if (previousZ > afterZ)
383
- {
384
- // swap items
385
- if (previousItem && afterItem)
386
- {
387
- it.remove ();
388
- it.next ();
389
- it.insert (previousItem);
390
- it.previous ();
391
- }
392
- }
369
+ break ; // this is the end...
393
370
}
371
+ afterItem = it.peekNext ();
372
+
373
+ if ( afterItem )
374
+ {
375
+ afterZ = afterItem->zValue ();
376
+ }
377
+ else
378
+ {
379
+ afterZ = -1 ;
380
+ }
381
+
382
+ if ( previousZ > afterZ )
383
+ {
384
+ // swap items
385
+ if ( previousItem && afterItem )
386
+ {
387
+ it.remove ();
388
+ it.next ();
389
+ it.insert ( previousItem );
390
+ it.previous ();
391
+ }
392
+ }
393
+ }
394
394
395
395
// debug: list after sorting
396
396
// debug: list before sorting
397
- qWarning (" after sorting" );
397
+ qWarning ( " after sorting" );
398
398
QLinkedList<QgsComposerItem*>::iterator after_it = mItemZList .begin ();
399
- for ( ; after_it != mItemZList .end (); ++after_it)
400
- {
401
- qWarning (QString::number ((*after_it)->zValue ()).toLocal8Bit ().data ());
402
- }
399
+ for ( ; after_it != mItemZList .end (); ++after_it )
400
+ {
401
+ qWarning ( QString::number (( *after_it )->zValue () ).toLocal8Bit ().data () );
402
+ }
403
403
}
0 commit comments