Skip to content

Commit b981f3a

Browse files
author
jef
committedAug 24, 2008
update indentation and fix a warning
git-svn-id: http://svn.osgeo.org/qgis/trunk@9158 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 54ac40c commit b981f3a

File tree

5 files changed

+164
-166
lines changed

5 files changed

+164
-166
lines changed
 

‎src/app/composer/qgscomposer.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ QgsComposer::QgsComposer( QgisApp *qgis ): QMainWindow()
7676

7777
toolBar->addAction( QIcon( QPixmap( myIconPath + "mActionGroupItems.png" ) ), tr( "&Group Items" ), this, SLOT( groupItems() ) );
7878
toolBar->addAction( QIcon( QPixmap( myIconPath + "mActionUngroupItems.png" ) ), tr( "&Ungroup Items" ), this, SLOT( ungroupItems() ) );
79-
toolBar->addAction( QIcon( QPixmap( myIconPath + "mActionRaiseItems.png")), tr("Raise selected items"), this, SLOT(raiseSelectedItems()));
80-
toolBar->addAction( QIcon( QPixmap( myIconPath + "mActionLowerItems.png")), tr("Lower selected items"), this, SLOT(lowerSelectedItems()));
81-
toolBar->addAction( QIcon( QPixmap( myIconPath + "mActionMoveItemsToTop.png")), tr("Move selected items to top"), this, SLOT(moveSelectedItemsToTop()));
82-
toolBar->addAction( QIcon( QPixmap( myIconPath + "mActionMoveItemsToBottom.png")), tr("Move selected items to bottom"), this, SLOT(moveSelectedItemsToBottom()));
79+
toolBar->addAction( QIcon( QPixmap( myIconPath + "mActionRaiseItems.png" ) ), tr( "Raise selected items" ), this, SLOT( raiseSelectedItems() ) );
80+
toolBar->addAction( QIcon( QPixmap( myIconPath + "mActionLowerItems.png" ) ), tr( "Lower selected items" ), this, SLOT( lowerSelectedItems() ) );
81+
toolBar->addAction( QIcon( QPixmap( myIconPath + "mActionMoveItemsToTop.png" ) ), tr( "Move selected items to top" ), this, SLOT( moveSelectedItemsToTop() ) );
82+
toolBar->addAction( QIcon( QPixmap( myIconPath + "mActionMoveItemsToBottom.png" ) ), tr( "Move selected items to bottom" ), this, SLOT( moveSelectedItemsToBottom() ) );
8383

8484
QActionGroup* toggleActionGroup = new QActionGroup( this );
8585
toggleActionGroup->addAction( moveItemContentAction );
@@ -1034,34 +1034,34 @@ void QgsComposer::ungroupItems( void )
10341034

10351035
void QgsComposer::raiseSelectedItems()
10361036
{
1037-
if(mComposition)
1038-
{
1039-
mComposition->raiseSelectedItems();
1040-
}
1037+
if ( mComposition )
1038+
{
1039+
mComposition->raiseSelectedItems();
1040+
}
10411041
}
10421042

10431043
void QgsComposer::lowerSelectedItems()
10441044
{
1045-
if(mComposition)
1046-
{
1047-
mComposition->lowerSelectedItems();
1048-
}
1045+
if ( mComposition )
1046+
{
1047+
mComposition->lowerSelectedItems();
1048+
}
10491049
}
10501050

10511051
void QgsComposer::moveSelectedItemsToTop()
10521052
{
1053-
if(mComposition)
1054-
{
1055-
mComposition->moveSelectedItemsToTop();
1056-
}
1053+
if ( mComposition )
1054+
{
1055+
mComposition->moveSelectedItemsToTop();
1056+
}
10571057
}
10581058

10591059
void QgsComposer::moveSelectedItemsToBottom()
10601060
{
1061-
if(mComposition)
1062-
{
1063-
mComposition->moveSelectedItemsToBottom();
1064-
}
1061+
if ( mComposition )
1062+
{
1063+
mComposition->moveSelectedItemsToBottom();
1064+
}
10651065
}
10661066

10671067
void QgsComposer::moveEvent( QMoveEvent *e ) { saveWindowState(); }

‎src/app/qgisapp.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4658,14 +4658,12 @@ bool QgisApp::saveDirty()
46584658

46594659
void QgisApp::changeEvent( QEvent* event )
46604660
{
4661-
switch ( event->type() )
4662-
{
4663-
case QEvent::WindowTitleChange:
46644661
#ifdef Q_WS_MAC
4665-
mWindowAction->setText( windowTitle() );
4666-
#endif
4667-
break;
4662+
if ( event->type() == QEvent::WindowTitleChange )
4663+
{
4664+
mWindowAction->setText( windowTitle() );
46684665
}
4666+
#endif
46694667
QWidget::changeEvent( event );
46704668
}
46714669

‎src/core/composer/qgscomposeritem.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ QgsComposerItem::QgsComposerItem( QgsComposition* composition ): QGraphicsRectIt
3939
setPen( defaultPen );
4040

4141
//let z-Value be managed by composition
42-
if(mComposition)
43-
{
44-
mComposition->addItemToZList(this);
45-
}
42+
if ( mComposition )
43+
{
44+
mComposition->addItemToZList( this );
45+
}
4646
}
4747

4848
QgsComposerItem::QgsComposerItem( qreal x, qreal y, qreal width, qreal height, QgsComposition* composition ): QGraphicsRectItem( 0, 0, width, height, 0 ), mComposition( composition ), mBoundingResizeRectangle( 0 ), mFrame( true )
@@ -60,19 +60,19 @@ QgsComposerItem::QgsComposerItem( qreal x, qreal y, qreal width, qreal height, Q
6060
defaultPen.setWidth( 1 );
6161
setPen( defaultPen );
6262

63-
//let z-Value be managed by composition
64-
if(mComposition)
65-
{
66-
mComposition->addItemToZList(this);
67-
}
63+
//let z-Value be managed by composition
64+
if ( mComposition )
65+
{
66+
mComposition->addItemToZList( this );
67+
}
6868
}
6969

7070
QgsComposerItem::~QgsComposerItem()
7171
{
72-
if(mComposition)
73-
{
74-
mComposition->removeItemFromZList(this);
75-
}
72+
if ( mComposition )
73+
{
74+
mComposition->removeItemFromZList( this );
75+
}
7676
}
7777

7878
void QgsComposerItem::setSelected( bool s )

‎src/core/composer/qgscomposition.cpp

Lines changed: 119 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -190,133 +190,133 @@ bool QgsComposition::readXML( const QDomElement& compositionElem, const QDomDocu
190190
return true;
191191
}
192192

193-
void QgsComposition::addItemToZList(QgsComposerItem* item)
193+
void QgsComposition::addItemToZList( QgsComposerItem* item )
194194
{
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() );
202202
}
203203

204-
void QgsComposition::removeItemFromZList(QgsComposerItem* item)
204+
void QgsComposition::removeItemFromZList( QgsComposerItem* item )
205205
{
206-
if(!item)
207-
{
208-
return;
209-
}
210-
mItemZList.removeAll(item);
206+
if ( !item )
207+
{
208+
return;
209+
}
210+
mItemZList.removeAll( item );
211211
}
212212

213213
void QgsComposition::raiseSelectedItems()
214214
{
215215
QList<QgsComposerItem*> selectedItems = selectedComposerItems();
216216
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+
}
221221

222222
//update all positions
223223
updateZValues();
224224
update();
225225
}
226226

227-
void QgsComposition::raiseItem(QgsComposerItem* item)
227+
void QgsComposition::raiseItem( QgsComposerItem* item )
228228
{
229229
//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() )
232234
{
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 );
239238
}
239+
}
240240
}
241241

242242
void QgsComposition::lowerSelectedItems()
243243
{
244244
QList<QgsComposerItem*> selectedItems = selectedComposerItems();
245245
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+
}
250250

251251
//update all positions
252252
updateZValues();
253253
update();
254254
}
255255

256-
void QgsComposition::lowerItem(QgsComposerItem* item)
256+
void QgsComposition::lowerItem( QgsComposerItem* item )
257257
{
258258
//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() )
261264
{
265+
it.remove();
262266
it.previous();
263-
if(it.hasPrevious())
264-
{
265-
it.remove();
266-
it.previous();
267-
it.insert(item);
268-
}
267+
it.insert( item );
269268
}
269+
}
270270
}
271271

272272
void QgsComposition::moveSelectedItemsToTop()
273273
{
274274
QList<QgsComposerItem*> selectedItems = selectedComposerItems();
275275
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+
}
280280

281281
//update all positions
282282
updateZValues();
283283
update();
284284
}
285285

286-
void QgsComposition::moveItemToTop(QgsComposerItem* item)
286+
void QgsComposition::moveItemToTop( QgsComposerItem* item )
287287
{
288288
//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 );
295295
}
296-
296+
297297
void QgsComposition::moveSelectedItemsToBottom()
298298
{
299299
QList<QgsComposerItem*> selectedItems = selectedComposerItems();
300300
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+
}
305305

306306
//update all positions
307307
updateZValues();
308308
update();
309309
}
310310

311-
void QgsComposition::moveItemToBottom(QgsComposerItem* item)
311+
void QgsComposition::moveItemToBottom( QgsComposerItem* item )
312312
{
313313
//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 );
320320
}
321321

322322
void QgsComposition::updateZValues()
@@ -325,79 +325,79 @@ void QgsComposition::updateZValues()
325325
QLinkedList<QgsComposerItem*>::iterator it = mItemZList.begin();
326326
QgsComposerItem* currentItem = 0;
327327

328-
for(; it != mItemZList.end(); ++it)
328+
for ( ; it != mItemZList.end(); ++it )
329+
{
330+
currentItem = *it;
331+
if ( currentItem )
329332
{
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 );
337335
}
336+
++counter;
337+
}
338338
}
339339

340340
void QgsComposition::sortZList()
341341
{
342342
//debug: list before sorting
343-
qWarning("before sorting");
343+
qWarning( "before sorting" );
344344
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+
}
349349

350-
QMutableLinkedListIterator<QgsComposerItem*> it(mItemZList);
350+
QMutableLinkedListIterator<QgsComposerItem*> it( mItemZList );
351351
int previousZ, afterZ; //z values of items before and after
352352
QgsComposerItem* previousItem;
353353
QgsComposerItem* afterItem;
354354

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() )
356368
{
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...
393370
}
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+
}
394394

395395
//debug: list after sorting
396396
//debug: list before sorting
397-
qWarning("after sorting");
397+
qWarning( "after sorting" );
398398
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+
}
403403
}

‎src/core/composer/qgscomposition.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class QDomElement;
3030
/** \ingroup MapComposer
3131
* Graphics scene for map printing. The class manages the paper item which always
3232
* is the item in the back (z-value 0). It maintains the z-Values of the items and stores
33-
* them in a list in ascending z-Order. This list can be changed to lower/raise items one position
33+
* them in a list in ascending z-Order. This list can be changed to lower/raise items one position
3434
* or to bring them to front/back.
3535
* */
3636
class CORE_EXPORT QgsComposition: public QGraphicsScene
@@ -93,23 +93,23 @@ class CORE_EXPORT QgsComposition: public QGraphicsScene
9393
bool readXML( const QDomElement& compositionElem, const QDomDocument& doc );
9494

9595
/**Adds item to z list. Usually called from constructor of QgsComposerItem*/
96-
void addItemToZList(QgsComposerItem* item);
96+
void addItemToZList( QgsComposerItem* item );
9797
/**Removes item from z list. Usually called from destructor of QgsComposerItem*/
98-
void removeItemFromZList(QgsComposerItem* item);
98+
void removeItemFromZList( QgsComposerItem* item );
9999

100100
void raiseSelectedItems();
101-
void raiseItem(QgsComposerItem* item);
101+
void raiseItem( QgsComposerItem* item );
102102
void lowerSelectedItems();
103-
void lowerItem(QgsComposerItem* item);
103+
void lowerItem( QgsComposerItem* item );
104104
void moveSelectedItemsToTop();
105-
void moveItemToTop(QgsComposerItem* item);
105+
void moveItemToTop( QgsComposerItem* item );
106106
void moveSelectedItemsToBottom();
107-
void moveItemToBottom(QgsComposerItem* item);
107+
void moveItemToBottom( QgsComposerItem* item );
108108

109109
/**Sorts the zList. The only time where this function needs to be called is from QgsComposer
110110
after reading all the items from xml file*/
111111
void sortZList();
112-
112+
113113

114114
private:
115115
/**Pointer to map renderer of QGIS main map*/

0 commit comments

Comments
 (0)
Please sign in to comment.