Skip to content

Commit 5603cc0

Browse files
committedSep 6, 2012
indentation update
1 parent 30c7ec4 commit 5603cc0

18 files changed

+399
-393
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,9 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
511511

512512
// create the notification widget for macros
513513
mMacrosWarn = QgsMessageBar::createMessage( tr( "Security warning:" ),
514-
tr( "macros have been disabled." ),
515-
QgsApplication::getThemeIcon( "/mIconWarn.png" ),
516-
mInfoBar );
514+
tr( "macros have been disabled." ),
515+
QgsApplication::getThemeIcon( "/mIconWarn.png" ),
516+
mInfoBar );
517517

518518
QToolButton *btnEnableMacros = new QToolButton( mMacrosWarn );
519519
btnEnableMacros->setText( tr( "Enable" ) );

‎src/app/qgsattributetypedialog.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ void QgsAttributeTypeDialog::accept()
607607
mValueRelationData.mAllowNull = valueRelationAllowNull->isChecked();
608608
mValueRelationData.mOrderByValue = valueRelationOrderByValue->isChecked();
609609
mValueRelationData.mAllowMulti = valueRelationAllowMulti->isChecked();
610-
if( valueRelationFilterColumn->currentIndex() == 0 )
610+
if ( valueRelationFilterColumn->currentIndex() == 0 )
611611
{
612612
mValueRelationData.mFilterAttributeColumn = QString::null;
613613
mValueRelationData.mFilterAttributeValue = QString::null;
@@ -655,7 +655,7 @@ void QgsAttributeTypeDialog::updateLayerColumns( int idx )
655655
valueRelationKeyColumn->setCurrentIndex( valueRelationKeyColumn->findText( mValueRelationData.mKey ) );
656656
valueRelationValueColumn->setCurrentIndex( valueRelationValueColumn->findText( mValueRelationData.mValue ) );
657657

658-
if( mValueRelationData.mFilterAttributeColumn.isNull() )
658+
if ( mValueRelationData.mFilterAttributeColumn.isNull() )
659659
{
660660
valueRelationFilterColumn->setCurrentIndex( 0 );
661661
}
@@ -683,7 +683,7 @@ void QgsAttributeTypeDialog::updateFilterColumn( int idx )
683683
QList<QVariant> uniqueValues;
684684
vl->uniqueValues( fidx, uniqueValues );
685685

686-
foreach( const QVariant &v, uniqueValues )
686+
foreach ( const QVariant &v, uniqueValues )
687687
{
688688
valueRelationFilterValue->addItem( v.toString(), v );
689689
}

‎src/app/qgsdiagramproperties.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ void QgsDiagramProperties::on_mAddCategoryPushButton_clicked()
376376

377377
void QgsDiagramProperties::on_mAttributesTreeWidget_itemDoubleClicked( QTreeWidgetItem * item, int column )
378378
{
379+
Q_UNUSED( column );
379380
addAttribute( item );
380381
}
381382

‎src/app/qgsmeasuretool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class QgsMeasureTool : public QgsMapTool
4040
//! returns whether measuring distance or area
4141
bool measureArea() { return mMeasureArea; }
4242

43-
//! When we hvae added our last point, and not following
43+
//! When we have added our last point, and not following
4444
// Added in 2.0
4545
bool done() { return mDone; }
4646

‎src/core/composer/qgscomposerscalebar.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,15 @@ void QgsComposerScaleBar::applyDefaultSize()
242242
int nUnitsPerSegment = widthMeter / 10.0; //default scalebar width equals half the map width
243243
setNumUnitsPerSegment( nUnitsPerSegment );
244244

245-
if( nUnitsPerSegment > 1000 )
245+
if ( nUnitsPerSegment > 1000 )
246246
{
247-
setNumUnitsPerSegment( (int)( numUnitsPerSegment() / 1000.0 + 0.5 ) * 1000 );
248-
setUnitLabeling( tr("km") );
249-
setNumMapUnitsPerScaleBarUnit( 1000 );
247+
setNumUnitsPerSegment(( int )( numUnitsPerSegment() / 1000.0 + 0.5 ) * 1000 );
248+
setUnitLabeling( tr( "km" ) );
249+
setNumMapUnitsPerScaleBarUnit( 1000 );
250250
}
251251
else
252252
{
253-
setUnitLabeling( tr("m") );
253+
setUnitLabeling( tr( "m" ) );
254254
}
255255

256256
setNumSegments( 4 );

‎src/core/composer/qgscomposition.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ class CORE_EXPORT QgsComposition: public QGraphicsScene
158158

159159
/**Load a template document
160160
@param doc template document
161-
@param substitutionMap map with text to replace. Text needs to be enclosed by brackets (e.g. '[text]' )*/
161+
@param substitutionMap map with text to replace. Text needs to be enclosed by brackets (e.g. '[text]' )
162+
@param addUndoCommands whether or not to add undo commands
163+
*/
162164
bool loadFromTemplate( const QDomDocument& doc, QMap<QString, QString>* substitutionMap = 0, bool addUndoCommands = false );
163165

164166
/**Add items from XML representation to the graphics scene (for project file reading, pasting items from clipboard)

‎src/core/diagram/qgstextdiagram.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ QSizeF QgsTextDiagram::diagramSize( const QgsAttributeMap& attributes, const Qgs
4040
{
4141
return QSizeF(); //zero size if attribute is missing
4242
}
43-
43+
4444
double scaledValue = attIt.value().toDouble();
4545
double scaledLowerValue = is.lowerValue;
4646
double scaledUpperValue = is.upperValue;
@@ -77,11 +77,11 @@ QSizeF QgsTextDiagram::diagramSize( const QgsAttributeMap& attributes, const Qgs
7777
}
7878

7979
QSizeF QgsTextDiagram::diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s )
80-
{
80+
{
8181
Q_UNUSED( c );
82-
Q_UNUSED( attributes );
82+
Q_UNUSED( attributes );
8383

84-
return s.size;
84+
return s.size;
8585
}
8686

8787
void QgsTextDiagram::renderDiagram( const QgsAttributeMap& att, QgsRenderContext& c, const QgsDiagramSettings& s, const QPointF& position )
@@ -218,11 +218,11 @@ void QgsTextDiagram::renderDiagram( const QgsAttributeMap& att, QgsRenderContext
218218
mPen.setColor( s.categoryColors.at( i ) );
219219
p->setPen( mPen );
220220
QPointF position = textPositions.at( i );
221-
221+
222222
// Calculate vertical placement
223223
double xOffset = 0;
224224

225-
switch( s.labelPlacementMethod )
225+
switch ( s.labelPlacementMethod )
226226
{
227227
case QgsDiagramSettings::Height:
228228
xOffset = textHeight / 2.0;

‎src/core/qgsapplication.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ void QgsApplication::init( QString customConfigPath )
9191

9292
// check if QGIS is run from build directory (not the install directory)
9393
QFile f;
94-
foreach( QString path, QStringList() << "" << "/.." << "/bin" )
94+
foreach ( QString path, QStringList() << "" << "/.." << "/bin" )
9595
{
9696
f.setFileName( prefixPath + path + "/path.txt" );
97-
if( f.exists() )
97+
if ( f.exists() )
9898
break;
9999
}
100100
if ( f.exists() && f.open( QIODevice::ReadOnly ) )

‎src/core/qgsdiagramrendererv2.h

Lines changed: 275 additions & 275 deletions
Large diffs are not rendered by default.

‎src/core/qgsexpression.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -789,14 +789,14 @@ static QVariant fcnRound( const QVariantList& values , QgsFeature *f, QgsExpress
789789

790790
static QVariant fcnScale( const QVariantList&, QgsFeature*, QgsExpression* parent )
791791
{
792-
return QVariant( parent->scale() );
792+
return QVariant( parent->scale() );
793793
}
794794

795795
static QVariant fcnFormatNumber( const QVariantList& values, QgsFeature*, QgsExpression* parent )
796796
{
797-
double value = getDoubleValue( values.at(0), parent );
798-
int places = getIntValue( values.at(1), parent );
799-
return QString( "%L1" ).arg( value, 0, 'f', places );
797+
double value = getDoubleValue( values.at( 0 ), parent );
798+
int places = getIntValue( values.at( 1 ), parent );
799+
return QString( "%L1" ).arg( value, 0, 'f', places );
800800
}
801801

802802
QList<QgsExpression::FunctionDef> QgsExpression::gmBuiltinFunctions;

‎src/core/qgsvectorlayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3160,7 +3160,7 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
31603160
bool allowNull = editTypeElement.attribute( "allowNull" ) == "true";
31613161
bool orderByValue = editTypeElement.attribute( "orderByValue" ) == "true";
31623162
bool allowMulti = editTypeElement.attribute( "allowMulti", "false" ) == "true";
3163-
QString filterAttributeColumn= editTypeElement.attribute( "filterAttributeColumn", QString::null );
3163+
QString filterAttributeColumn = editTypeElement.attribute( "filterAttributeColumn", QString::null );
31643164
QString filterAttributeValue = editTypeElement.attribute( "filterAttributeValue", QString::null );
31653165
mValueRelations[ name ] = ValueRelationData( id, key, value, allowNull, orderByValue, allowMulti, filterAttributeColumn, filterAttributeValue );
31663166
}

‎src/core/raster/qgsrasterchecker.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ QgsRasterChecker::QgsRasterChecker( ) :
3737
mErrMsgStyle = "color: #ff0000;";
3838
}
3939

40-
bool QgsRasterChecker::runTest( QString theVerifiedKey, QString theVerifiedUri,
40+
bool QgsRasterChecker::runTest( QString theVerifiedKey, QString theVerifiedUri,
4141
QString theExpectedKey, QString theExpectedUri )
4242
{
4343
bool ok = true;
@@ -46,14 +46,14 @@ bool QgsRasterChecker::runTest( QString theVerifiedKey, QString theVerifiedUri,
4646
QgsRasterDataProvider* verifiedProvider = QgsRasterLayer::loadProvider( theVerifiedKey, theVerifiedUri );
4747
if ( !verifiedProvider || !verifiedProvider->isValid() )
4848
{
49-
error( QString( "Cannot load provider %1 with URI: %2" ).arg( theVerifiedKey).arg( theVerifiedUri), mReport );
49+
error( QString( "Cannot load provider %1 with URI: %2" ).arg( theVerifiedKey ).arg( theVerifiedUri ), mReport );
5050
ok = false;
5151
}
5252

5353
QgsRasterDataProvider* expectedProvider = QgsRasterLayer::loadProvider( theExpectedKey, theExpectedUri );
5454
if ( !expectedProvider || !expectedProvider->isValid() )
5555
{
56-
error( QString( "Cannot load provider %1 with URI: %2" ).arg( theExpectedKey).arg( theExpectedUri ), mReport );
56+
error( QString( "Cannot load provider %1 with URI: %2" ).arg( theExpectedKey ).arg( theExpectedUri ), mReport );
5757
ok = false;
5858
}
5959

@@ -63,7 +63,7 @@ bool QgsRasterChecker::runTest( QString theVerifiedKey, QString theVerifiedUri,
6363
mReport += QString( "Expected URI: %1<br>" ).arg( theExpectedUri.replace( "&", "&amp;" ) );
6464

6565
mReport += "<br>";
66-
mReport += QString("<table style='%1'>\n").arg( mTabStyle );
66+
mReport += QString( "<table style='%1'>\n" ).arg( mTabStyle );
6767
mReport += compareHead();
6868

6969
compare( "Band count", verifiedProvider->bandCount(), expectedProvider->bandCount(), mReport, ok );
@@ -86,7 +86,7 @@ bool QgsRasterChecker::runTest( QString theVerifiedKey, QString theVerifiedUri,
8686
{
8787
bool bandOk = true;
8888
mReport += QString( "<h3>Band %1</h3>\n" ).arg( band );
89-
mReport += QString("<table style='%1'>\n").arg( mTabStyle );
89+
mReport += QString( "<table style='%1'>\n" ).arg( mTabStyle );
9090
mReport += compareHead();
9191

9292
// Data types may differ (?)
@@ -132,9 +132,9 @@ bool QgsRasterChecker::runTest( QString theVerifiedKey, QString theVerifiedUri,
132132

133133
mReport += "<table><tr>";
134134
mReport += "<td>Data comparison</td>";
135-
mReport += QString( "<td style='%1 %2 border: 1px solid'>correct&nbsp;value</td>" ).arg( mCellStyle).arg( mOkStyle );
135+
mReport += QString( "<td style='%1 %2 border: 1px solid'>correct&nbsp;value</td>" ).arg( mCellStyle ).arg( mOkStyle );
136136
mReport += "<td></td>";
137-
mReport += QString( "<td style='%1 %2 border: 1px solid'>wrong&nbsp;value<br>expected value</td></tr>").arg( mCellStyle).arg( mErrStyle );
137+
mReport += QString( "<td style='%1 %2 border: 1px solid'>wrong&nbsp;value<br>expected value</td></tr>" ).arg( mCellStyle ).arg( mErrStyle );
138138
mReport += "</tr></table>";
139139
mReport += "<br>";
140140

@@ -148,7 +148,7 @@ bool QgsRasterChecker::runTest( QString theVerifiedKey, QString theVerifiedUri,
148148
verifiedProvider->readBlock( band, expectedProvider->extent(), width, height, verifiedData );
149149

150150
// compare data values
151-
QString htmlTable = QString("<table style='%1'>").arg( mTabStyle );
151+
QString htmlTable = QString( "<table style='%1'>" ).arg( mTabStyle );
152152
for ( int row = 0; row < height; row ++ )
153153
{
154154
htmlTable += "<tr>";
@@ -169,7 +169,7 @@ bool QgsRasterChecker::runTest( QString theVerifiedKey, QString theVerifiedUri,
169169
allOk = false;
170170
valStr = QString( "%1<br>%2" ).arg( verifiedVal ).arg( expectedVal );
171171
}
172-
htmlTable += QString( "<td style='%1 %2'>%3</td>" ).arg( mCellStyle).arg( cellOk ? mOkStyle : mErrStyle ).arg( valStr );
172+
htmlTable += QString( "<td style='%1 %2'>%3</td>" ).arg( mCellStyle ).arg( cellOk ? mOkStyle : mErrStyle ).arg( valStr );
173173
}
174174
htmlTable += "</tr>";
175175
}
@@ -187,7 +187,7 @@ bool QgsRasterChecker::runTest( QString theVerifiedKey, QString theVerifiedUri,
187187

188188
void QgsRasterChecker::error( QString theMessage, QString &theReport )
189189
{
190-
theReport += QString( "<font style='%1'>Error: ").arg(mErrMsgStyle);
190+
theReport += QString( "<font style='%1'>Error: " ).arg( mErrMsgStyle );
191191
theReport += theMessage;
192192
theReport += "</font>";
193193
}
@@ -202,7 +202,7 @@ double QgsRasterChecker::tolerance( double val, int places )
202202
QString QgsRasterChecker::compareHead()
203203
{
204204
QString html;
205-
html += QString( "<tr><th style='%1'>Param name</th><th style='%1'>Verified value</th><th style='%1'>Eexpected value</th><th style='%1'>Difference</th><th style='%1'>Tolerance</th></tr>").arg( mCellStyle );
205+
html += QString( "<tr><th style='%1'>Param name</th><th style='%1'>Verified value</th><th style='%1'>Eexpected value</th><th style='%1'>Difference</th><th style='%1'>Tolerance</th></tr>" ).arg( mCellStyle );
206206
return html;
207207
}
208208

@@ -229,8 +229,8 @@ void QgsRasterChecker::compare( QString theParamName, double verifiedVal, double
229229
void QgsRasterChecker::compareRow( QString theParamName, QString verifiedVal, QString expectedVal, QString &theReport, bool theOk, QString theDifference, QString theTolerance )
230230
{
231231
theReport += "<tr>\n";
232-
theReport += QString( "<td style='%1'>%2</td><td style='%1 %3'>%4</td><td style='%1'>%5</td>\n" ).arg(mCellStyle).arg( theParamName ).arg( theOk ? mOkStyle : mErrStyle ).arg( verifiedVal ).arg( expectedVal );
233-
theReport += QString( "<td style='%1'>%2</td>\n" ).arg(mCellStyle).arg( theDifference );
234-
theReport += QString( "<td style='%1'>%2</td>\n" ).arg(mCellStyle).arg( theTolerance );
232+
theReport += QString( "<td style='%1'>%2</td><td style='%1 %3'>%4</td><td style='%1'>%5</td>\n" ).arg( mCellStyle ).arg( theParamName ).arg( theOk ? mOkStyle : mErrStyle ).arg( verifiedVal ).arg( expectedVal );
233+
theReport += QString( "<td style='%1'>%2</td>\n" ).arg( mCellStyle ).arg( theDifference );
234+
theReport += QString( "<td style='%1'>%2</td>\n" ).arg( mCellStyle ).arg( theTolerance );
235235
theReport += "</tr>";
236236
}

‎src/core/symbology-ng/qgsmarkersymbollayerv2.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ void QgsSimpleMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV
412412
case QgsSymbolV2::ScaleArea:
413413
scaledSize = sqrt( scaledSize );
414414
break;
415+
case QgsSymbolV2::ScaleDiameter:
416+
break;
415417
}
416418

417419
double half = scaledSize / 2.0;

‎src/gui/qgsmapcanvas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
336336
void renderComplete( QPainter * );
337337

338338
/** Emitted when canvas finished a refresh request.
339-
\note Added in 2.0 */
339+
\note Added in 2.0 */
340340
void mapCanvasRefreshed();
341341

342342
/** Emitted when the canvas is about to be rendered.

‎src/gui/qgsmessagebar.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828

2929
QgsMessageBar::QgsMessageBar( QWidget *parent )
30-
: QFrame( parent ), mCurrentItem ( NULL )
30+
: QFrame( parent ), mCurrentItem( NULL )
3131
{
3232
QPalette pal = palette();
3333
pal.setBrush( backgroundRole(), pal.window() );
@@ -66,22 +66,22 @@ void QgsMessageBar::popItem( QgsMessageBarItem *item )
6666
return;
6767

6868
if ( item == mCurrentItem )
69-
{
70-
if ( mCurrentItem )
71-
{
72-
mLayout->removeWidget( mCurrentItem->widget() );
73-
mCurrentItem->widget()->hide();
74-
mCurrentItem = 0;
75-
}
76-
77-
if ( !mList.isEmpty() )
78-
{
79-
pushItem( mList.first() );
80-
}
81-
else
82-
{
83-
hide();
84-
}
69+
{
70+
if ( mCurrentItem )
71+
{
72+
mLayout->removeWidget( mCurrentItem->widget() );
73+
mCurrentItem->widget()->hide();
74+
mCurrentItem = 0;
75+
}
76+
77+
if ( !mList.isEmpty() )
78+
{
79+
pushItem( mList.first() );
80+
}
81+
else
82+
{
83+
hide();
84+
}
8585
}
8686
else
8787
{
@@ -102,7 +102,7 @@ bool QgsMessageBar::popWidget( QWidget *widget )
102102
return true;
103103
}
104104

105-
foreach( QgsMessageBarItem *item, mList )
105+
foreach ( QgsMessageBarItem *item, mList )
106106
{
107107
if ( item->widget() == widget )
108108
{

‎src/gui/symbology-ng/qgscptcitycolorrampv2dialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ void QgsCptCityColorRampV2Dialog::showEvent( QShowEvent * e )
422422
tabBar->setCurrentIndex( 1 );
423423
mModel = mAuthorsModel;
424424
mBrowserView->setModel( mModel );
425-
}
425+
}
426426
}
427427
if ( modelIndex != QModelIndex() )
428428
{

‎src/gui/symbology-ng/qgsrendererv2widget.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ QgsRendererV2DataDefinedMenus::~QgsRendererV2DataDefinedMenus()
220220

221221
void QgsRendererV2DataDefinedMenus::populateMenu( QMenu* menu, const char* slot, QString fieldName, QActionGroup *actionGroup )
222222
{
223+
Q_UNUSED( slot );
223224
QAction* aNo = new QAction( tr( "- no field -" ), actionGroup );
224225
aNo->setCheckable( true );
225226
menu->addAction( aNo );
@@ -305,4 +306,4 @@ void QgsRendererV2DataDefinedMenus::updateMenu( QActionGroup* actionGroup, QStri
305306
a->setChecked( a->text() == fieldName );
306307
}
307308
}
308-
#endif
309+
#endif

‎tests/src/core/testqgscomposerscalebar.cpp

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -50,51 +50,51 @@ class TestQgsComposerScaleBar: public QObject
5050

5151
void TestQgsComposerScaleBar::initTestCase()
5252
{
53-
QgsApplication::init();
54-
QgsApplication::initQgis();
55-
56-
//create maplayers from testdata and add to layer registry
57-
QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "landsat.tif" );
58-
mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(),
59-
rasterFileInfo.completeBaseName() );
60-
QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 2, 3, 4 );
61-
mRasterLayer->setRenderer( rasterRenderer );
62-
63-
QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << mRasterLayer );
64-
65-
//create composition with composer map
66-
mMapRenderer = new QgsMapRenderer();
67-
mMapRenderer->setLayerSet( QStringList() << mRasterLayer->id() );
68-
69-
//reproject to WGS84
70-
QgsCoordinateReferenceSystem destCRS;
71-
destCRS.createFromId( 4326, QgsCoordinateReferenceSystem::EpsgCrsId );
72-
mMapRenderer->setDestinationCrs( destCRS );
73-
mMapRenderer->setProjectionsEnabled( true );
74-
75-
mComposition = new QgsComposition( mMapRenderer );
76-
mComposition->setPaperSize( 297, 210 ); //A4 landscape
77-
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 150, 150 );
78-
mComposerMap->setFrameEnabled( true );
79-
mComposition->addComposerMap( mComposerMap );
80-
mComposerMap->setNewExtent( QgsRectangle( 17.923, 30.160, 18.023, 30.260 ) );
81-
82-
mComposerScaleBar = new QgsComposerScaleBar( mComposition );
83-
mComposerScaleBar->setSceneRect( QRectF( 20, 180, 20, 20 ) );
84-
mComposition->addComposerScaleBar( mComposerScaleBar );
85-
mComposerScaleBar->setComposerMap( mComposerMap );
86-
mComposerScaleBar->setUnits( QgsComposerScaleBar::Meters );
87-
mComposerScaleBar->setNumUnitsPerSegment( 2000 );
88-
mComposerScaleBar->setNumSegmentsLeft( 0 );
89-
mComposerScaleBar->setNumSegments( 2 );
90-
mComposerScaleBar->setHeight( 5 );
53+
QgsApplication::init();
54+
QgsApplication::initQgis();
55+
56+
//create maplayers from testdata and add to layer registry
57+
QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "landsat.tif" );
58+
mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(),
59+
rasterFileInfo.completeBaseName() );
60+
QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 2, 3, 4 );
61+
mRasterLayer->setRenderer( rasterRenderer );
62+
63+
QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << mRasterLayer );
64+
65+
//create composition with composer map
66+
mMapRenderer = new QgsMapRenderer();
67+
mMapRenderer->setLayerSet( QStringList() << mRasterLayer->id() );
68+
69+
//reproject to WGS84
70+
QgsCoordinateReferenceSystem destCRS;
71+
destCRS.createFromId( 4326, QgsCoordinateReferenceSystem::EpsgCrsId );
72+
mMapRenderer->setDestinationCrs( destCRS );
73+
mMapRenderer->setProjectionsEnabled( true );
74+
75+
mComposition = new QgsComposition( mMapRenderer );
76+
mComposition->setPaperSize( 297, 210 ); //A4 landscape
77+
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 150, 150 );
78+
mComposerMap->setFrameEnabled( true );
79+
mComposition->addComposerMap( mComposerMap );
80+
mComposerMap->setNewExtent( QgsRectangle( 17.923, 30.160, 18.023, 30.260 ) );
81+
82+
mComposerScaleBar = new QgsComposerScaleBar( mComposition );
83+
mComposerScaleBar->setSceneRect( QRectF( 20, 180, 20, 20 ) );
84+
mComposition->addComposerScaleBar( mComposerScaleBar );
85+
mComposerScaleBar->setComposerMap( mComposerMap );
86+
mComposerScaleBar->setUnits( QgsComposerScaleBar::Meters );
87+
mComposerScaleBar->setNumUnitsPerSegment( 2000 );
88+
mComposerScaleBar->setNumSegmentsLeft( 0 );
89+
mComposerScaleBar->setNumSegments( 2 );
90+
mComposerScaleBar->setHeight( 5 );
9191
};
9292

9393
void TestQgsComposerScaleBar::cleanupTestCase()
9494
{
95-
delete mComposition;
96-
delete mMapRenderer;
97-
delete mRasterLayer;
95+
delete mComposition;
96+
delete mMapRenderer;
97+
delete mRasterLayer;
9898
};
9999

100100
void TestQgsComposerScaleBar::init()
@@ -109,34 +109,34 @@ void TestQgsComposerScaleBar::cleanup()
109109

110110
void TestQgsComposerScaleBar::singleBox()
111111
{
112-
mComposerScaleBar->setStyle( "Single Box" );
113-
QgsCompositionChecker checker( "Composer scalebar singleBox", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
114-
"control_images" + QDir::separator() + "expected_composerscalebar" + QDir::separator() + "composerscalebar_singlebox.png" ) );
115-
QVERIFY( checker.testComposition() );
112+
mComposerScaleBar->setStyle( "Single Box" );
113+
QgsCompositionChecker checker( "Composer scalebar singleBox", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
114+
"control_images" + QDir::separator() + "expected_composerscalebar" + QDir::separator() + "composerscalebar_singlebox.png" ) );
115+
QVERIFY( checker.testComposition() );
116116
};
117117

118118
void TestQgsComposerScaleBar::doubleBox()
119119
{
120-
mComposerScaleBar->setStyle( "Double Box" );
121-
QgsCompositionChecker checker( "Composer scalebar doubleBox", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
122-
"control_images" + QDir::separator() + "expected_composerscalebar" + QDir::separator() + "composerscalebar_doublebox.png" ) );
123-
QVERIFY( checker.testComposition() );
120+
mComposerScaleBar->setStyle( "Double Box" );
121+
QgsCompositionChecker checker( "Composer scalebar doubleBox", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
122+
"control_images" + QDir::separator() + "expected_composerscalebar" + QDir::separator() + "composerscalebar_doublebox.png" ) );
123+
QVERIFY( checker.testComposition() );
124124
};
125125

126126
void TestQgsComposerScaleBar::numeric()
127127
{
128-
mComposerScaleBar->setStyle( "Numeric" );
129-
QgsCompositionChecker checker( "Composer scalebar numeric", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
130-
"control_images" + QDir::separator() + "expected_composerscalebar" + QDir::separator() + "composerscalebar_numeric.png" ) );
131-
QVERIFY( checker.testComposition() );
128+
mComposerScaleBar->setStyle( "Numeric" );
129+
QgsCompositionChecker checker( "Composer scalebar numeric", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
130+
"control_images" + QDir::separator() + "expected_composerscalebar" + QDir::separator() + "composerscalebar_numeric.png" ) );
131+
QVERIFY( checker.testComposition() );
132132
};
133133

134134
void TestQgsComposerScaleBar::tick()
135135
{
136-
mComposerScaleBar->setStyle( "Line Ticks Up" );
137-
QgsCompositionChecker checker( "Composer scalebar numeric", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
138-
"control_images" + QDir::separator() + "expected_composerscalebar" + QDir::separator() + "composerscalebar_numeric.png" ) );
139-
QVERIFY( checker.testComposition() );
136+
mComposerScaleBar->setStyle( "Line Ticks Up" );
137+
QgsCompositionChecker checker( "Composer scalebar numeric", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
138+
"control_images" + QDir::separator() + "expected_composerscalebar" + QDir::separator() + "composerscalebar_numeric.png" ) );
139+
QVERIFY( checker.testComposition() );
140140
};
141141

142142
QTEST_MAIN( TestQgsComposerScaleBar )

0 commit comments

Comments
 (0)
Please sign in to comment.