Skip to content

Commit

Permalink
Merge pull request #5083 from nyalldawson/clazy
Browse files Browse the repository at this point in the history
Clazy optimisations
  • Loading branch information
nyalldawson committed Aug 29, 2017
2 parents 51170ae + e4c1e1b commit f99a7a9
Show file tree
Hide file tree
Showing 156 changed files with 771 additions and 664 deletions.
2 changes: 1 addition & 1 deletion python/core/core_auto.sip
Expand Up @@ -198,7 +198,6 @@
%Include raster/qgsrasterfilewriter.sip
%Include raster/qgsrasterhistogram.sip
%Include raster/qgsrasteridentifyresult.sip
%Include raster/qgsrasterinterface.sip
%Include raster/qgsrasteriterator.sip
%Include raster/qgsrasterminmaxorigin.sip
%Include raster/qgsrasternuller.sip
Expand Down Expand Up @@ -377,6 +376,7 @@
%Include raster/qgsrasterfilewritertask.sip
%Include raster/qgsrasterlayer.sip
%Include raster/qgsrasterdataprovider.sip
%Include raster/qgsrasterinterface.sip
%Include geometry/qgspoint.sip
%Include gps/qgsgpsconnection.sip
%Include gps/qgsgpsdetector.sip
Expand Down
2 changes: 2 additions & 0 deletions python/core/layertree/qgslayertreemodel.sip
Expand Up @@ -385,6 +385,8 @@ Filter nodes from QgsMapLayerLegend according to the current filtering rules
QFlags<QgsLayerTreeModel::Flag> operator|(QgsLayerTreeModel::Flag f1, QFlags<QgsLayerTreeModel::Flag> f2);




/************************************************************************
* This file has been generated automatically from *
* *
Expand Down
1 change: 1 addition & 0 deletions python/core/qgsdataitem.sip
Expand Up @@ -52,6 +52,7 @@ class QgsDataItem : QObject
Project
};


QgsDataItem( QgsDataItem::Type type, QgsDataItem *parent /TransferThis/, const QString &name, const QString &path );
%Docstring
Create new data item.
Expand Down
1 change: 0 additions & 1 deletion python/core/qgsdataprovider.sip
Expand Up @@ -46,7 +46,6 @@ class QgsDataProvider : QObject
%End
public:


enum DataCapability
{
NoDataCapabilities,
Expand Down
1 change: 1 addition & 0 deletions python/gui/attributetable/qgsdualview.sip
Expand Up @@ -34,6 +34,7 @@ class QgsDualView : QStackedWidget
AttributeEditor
};


explicit QgsDualView( QWidget *parent /TransferThis/ = 0 );
%Docstring
Constructor
Expand Down
1 change: 1 addition & 0 deletions python/gui/qgscodeeditorsql.sip
Expand Up @@ -28,6 +28,7 @@ class QgsCodeEditorSQL : QgsCodeEditor

};


/************************************************************************
* This file has been generated automatically from *
* *
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsfontbutton.sip
Expand Up @@ -31,13 +31,13 @@ class QgsFontButton : QToolButton
%End
public:


enum Mode
{
ModeTextRenderer,
ModeQFont,
};


QgsFontButton( QWidget *parent /TransferThis/ = 0, const QString &dialogTitle = QString() );
%Docstring
Construct a new font button.
Expand Down
1 change: 1 addition & 0 deletions python/gui/symbology/qgsdatadefinedsizelegendwidget.sip
Expand Up @@ -40,6 +40,7 @@ Returns configuration as set up in the dialog (may be null). Ownership is passed

};


/************************************************************************
* This file has been generated automatically from *
* *
Expand Down
2 changes: 1 addition & 1 deletion scripts/sipify.pl
Expand Up @@ -464,7 +464,7 @@ sub detect_comment_block{
next;
}
# Skip Q_OBJECT, Q_PROPERTY, Q_ENUM, Q_GADGET etc.
if ($LINE =~ m/^\s*Q_(OBJECT|ENUMS|PROPERTY|GADGET|DECLARE_METATYPE|DECLARE_TYPEINFO|DECL_DEPRECATED|NOWARN_DEPRECATED_(PUSH|POP)).*?$/){
if ($LINE =~ m/^\s*Q_(OBJECT|ENUMS|ENUM|PROPERTY|GADGET|DECLARE_METATYPE|DECLARE_TYPEINFO|DECL_DEPRECATED|NOWARN_DEPRECATED_(PUSH|POP)).*?$/){
next;
}

Expand Down
6 changes: 3 additions & 3 deletions src/analysis/interpolation/DualEdgeTriangulation.cc
Expand Up @@ -1545,18 +1545,18 @@ int DualEdgeTriangulation::insertForcedSegment( int p1, int p2, bool breakline )


//setNext and setPoint for the forced edge because this would disturb the building of 'leftpoly' and 'rightpoly' otherwise
mHalfEdge[leftPolygon.first()]->setNext( ( *( ++( leftiter = leftPolygon.begin() ) ) ) );
mHalfEdge[leftPolygon.first()]->setNext( ( *( ++( leftiter = leftPolygon.constBegin() ) ) ) );
mHalfEdge[leftPolygon.first()]->setPoint( p2 );
mHalfEdge[leftPolygon.last()]->setNext( firstedge );
mHalfEdge[rightPolygon.first()]->setNext( ( *( ++( rightiter = rightPolygon.begin() ) ) ) );
mHalfEdge[rightPolygon.first()]->setNext( ( *( ++( rightiter = rightPolygon.constBegin() ) ) ) );
mHalfEdge[rightPolygon.first()]->setPoint( p1 );
mHalfEdge[rightPolygon.last()]->setNext( dualfirstedge );

triangulatePolygon( &leftPolygon, &freelist, firstedge );
triangulatePolygon( &rightPolygon, &freelist, dualfirstedge );

//optimisation of the new edges
for ( iter = crossedEdges.begin(); iter != crossedEdges.end(); ++iter )
for ( iter = crossedEdges.constBegin(); iter != crossedEdges.constEnd(); ++iter )
{
checkSwap( ( *( iter ) ), 0 );
}
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/interpolation/qgsgridfilewriter.cpp
Expand Up @@ -98,7 +98,7 @@ int QgsGridFileWriter::writeFile( QgsFeedback *feedback )

// create prj file
QgsInterpolator::LayerData ld;
ld = mInterpolator->layerData().first();
ld = mInterpolator->layerData().at( 0 );
QgsVectorLayer *vl = ld.vectorLayer;
QString crs = vl->crs().toWkt();
QFileInfo fi( mOutputFilePath );
Expand Down
6 changes: 3 additions & 3 deletions src/analysis/network/qgsvectorlayerdirector.cpp
Expand Up @@ -255,18 +255,18 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
QList< QgsNetworkStrategy * >::const_iterator it;
QgsAttributeList::const_iterator it2;

for ( it = mStrategies.begin(); it != mStrategies.end(); ++it )
for ( it = mStrategies.constBegin(); it != mStrategies.constEnd(); ++it )
{
QgsAttributeList tmp = ( *it )->requiredAttributes();
for ( it2 = tmp.begin(); it2 != tmp.end(); ++it2 )
for ( it2 = tmp.constBegin(); it2 != tmp.constEnd(); ++it2 )
{
tmpAttr.push_back( *it2 );
}
}
std::sort( tmpAttr.begin(), tmpAttr.end() );

int lastAttrId = -1;
for ( it2 = tmpAttr.begin(); it2 != tmpAttr.end(); ++it2 )
for ( it2 = tmpAttr.constBegin(); it2 != tmpAttr.constEnd(); ++it2 )
{
if ( *it2 == lastAttrId )
{
Expand Down
7 changes: 3 additions & 4 deletions src/app/composer/qgscomposer.cpp
Expand Up @@ -2125,7 +2125,6 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )

QgsSettings myQSettings;
QString lastUsedDir = myQSettings.value( QStringLiteral( "UI/lastSaveAtlasAsImagesDir" ), QDir::homePath() ).toString();
QString lastUsedFormat = myQSettings.value( QStringLiteral( "UI/lastSaveAtlasAsImagesFormat" ), "jpg" ).toString();

QFileDialog dlg( this, tr( "Export atlas to directory" ) );
dlg.setFileMode( QFileDialog::Directory );
Expand Down Expand Up @@ -2696,8 +2695,8 @@ void QgsComposer::exportCompositionAsSVG( QgsComposer::OutputMode mode )
&& !mComposition->gridVisible() ) items.pop_back();
QgsItemTempHider itemsHider( items );
int composerItemLayerIdx = 0;
QList<QGraphicsItem *>::const_iterator it = items.begin();
for ( unsigned svgLayerId = 1; it != items.end(); ++svgLayerId )
QList<QGraphicsItem *>::const_iterator it = items.constBegin();
for ( unsigned svgLayerId = 1; it != items.constEnd(); ++svgLayerId )
{
itemsHider.hideAll();
QgsComposerItem *composerItem = dynamic_cast<QgsComposerItem *>( *it );
Expand All @@ -2711,7 +2710,7 @@ void QgsComposer::exportCompositionAsSVG( QgsComposer::OutputMode mode )
else
{
// show all items until the next item that renders on a separate layer
for ( ; it != items.end(); ++it )
for ( ; it != items.constEnd(); ++it )
{
composerItem = dynamic_cast<QgsComposerMap *>( *it );
if ( composerItem && composerItem->numberExportLayers() )
Expand Down
2 changes: 1 addition & 1 deletion src/app/composer/qgscompositionwidget.cpp
Expand Up @@ -269,7 +269,7 @@ void QgsCompositionWidget::createPaperEntries()
;
mPaperSizeComboBox->addItem( tr( "Custom" ) );

for ( QList<QgsCompositionPaper>::const_iterator it = formats.begin(); it != formats.end(); ++it )
for ( QList<QgsCompositionPaper>::const_iterator it = formats.constBegin(); it != formats.constEnd(); ++it )
{
mPaperSizeComboBox->addItem( it->mName );
mPaperMap.insert( it->mName, *it );
Expand Down
7 changes: 0 additions & 7 deletions src/app/dwg/libdxfrw/drw_base.h
Expand Up @@ -158,13 +158,6 @@ class DRW_Coord
DRW_Coord(): x( 0 ), y( 0 ), z( 0 ) {}
DRW_Coord( double ix, double iy, double iz ): x( ix ), y( iy ), z( iz ) {}

DRW_Coord &operator = ( const DRW_Coord &data )
{
x = data.x;
y = data.y;
z = data.z;
return *this;
}
//! < convert to unitary vector
void unitize()
{
Expand Down
6 changes: 3 additions & 3 deletions src/app/dwg/qgsdwgimportdialog.cpp
Expand Up @@ -151,7 +151,7 @@ void QgsDwgImportDialog::on_leLayerGroup_textChanged( const QString &text )

void QgsDwgImportDialog::on_pbLoadDatabase_clicked()
{
if ( !QFileInfo( leDatabase->text() ).exists() )
if ( !QFileInfo::exists( leDatabase->text() ) )
return;

CursorOverride waitCursor;
Expand Down Expand Up @@ -269,7 +269,7 @@ void QgsDwgImportDialog::on_pbImportDrawing_clicked()

QgsVectorLayer *QgsDwgImportDialog::layer( QgsLayerTreeGroup *layerGroup, QString layerFilter, QString table )
{
QgsVectorLayer *l = new QgsVectorLayer( QString( "%1|layername=%2" ).arg( leDatabase->text() ).arg( table ), table, "ogr", false );
QgsVectorLayer *l = new QgsVectorLayer( QString( "%1|layername=%2" ).arg( leDatabase->text(), table ), table, "ogr", false );
l->setSubsetString( QString( "%1space=0 AND block=-1" ).arg( layerFilter ) );

if ( l->featureCount() == 0 )
Expand Down Expand Up @@ -471,7 +471,7 @@ void QgsDwgImportDialog::on_buttonBox_accepted()
QgsLayerTreeGroup *dwgGroup = QgisApp::instance()->layerTreeView()->layerTreeModel()->rootGroup()->addGroup( leLayerGroup->text() );
Q_ASSERT( dwgGroup );

Q_FOREACH ( QString layer, layers.keys() )
Q_FOREACH ( const QString &layer, layers.keys() )
{
createGroup( dwgGroup, layer, QStringList( layer ), layers[layer] );
}
Expand Down
39 changes: 16 additions & 23 deletions src/app/dwg/qgsdwgimporter.cpp
Expand Up @@ -99,9 +99,7 @@ bool QgsDwgImporter::exec( QString sql, bool logError )
if ( logError )
{
LOG( QObject::tr( "SQL statement failed\nDatabase:%1\nSQL:%2\nError:%3" )
.arg( mDatabase )
.arg( sql )
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
.arg( mDatabase, sql, QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
}
return false;
}
Expand All @@ -127,9 +125,7 @@ OGRLayerH QgsDwgImporter::query( QString sql )
return layer;

LOG( QObject::tr( "SQL statement failed\nDatabase:%1\nSQL:%2\nError:%3" )
.arg( mDatabase )
.arg( sql )
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
.arg( mDatabase, sql, QString::fromUtf8( CPLGetLastErrorMsg() ) ) );

OGR_DS_ReleaseResultSet( mDs, layer );

Expand All @@ -145,8 +141,7 @@ void QgsDwgImporter::startTransaction()
if ( !mInTransaction )
{
LOG( QObject::tr( "Could not start transaction\nDatabase:%1\nError:%2" )
.arg( mDatabase )
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
.arg( mDatabase, QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
}
}

Expand All @@ -157,8 +152,7 @@ void QgsDwgImporter::commitTransaction()
if ( mInTransaction && GDALDatasetCommitTransaction( mDs ) != OGRERR_NONE )
{
LOG( QObject::tr( "Could not commit transaction\nDatabase:%1\nError:%2" )
.arg( mDatabase )
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
.arg( mDatabase, QString::fromUtf8( CPLGetLastErrorMsg() ) ) );
}
mInTransaction = false;
}
Expand Down Expand Up @@ -201,7 +195,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
return false;
}

if ( QFileInfo( mDatabase ).exists() )
if ( QFileInfo::exists( mDatabase ) )
{
mDs = OGROpen( mDatabase.toUtf8().constData(), true, nullptr );
if ( !mDs )
Expand All @@ -221,7 +215,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
}

OGRFeatureDefnH dfn = OGR_L_GetLayerDefn( layer );
int pathIdx = OGR_FD_GetFieldIndex( dfn, "path" );
//int pathIdx = OGR_FD_GetFieldIndex( dfn, "path" );
int lastmodifiedIdx = OGR_FD_GetFieldIndex( dfn, "lastmodified" );

OGR_L_ResetReading( layer );
Expand All @@ -235,8 +229,6 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
return false;
}

QString path = QString::fromUtf8( OGR_F_GetFieldAsString( f, pathIdx ) );

int year, month, day, hour, minute, second, tzf;
if ( !OGR_F_GetFieldAsDateTime( f, lastmodifiedIdx, &year, &month, &day, &hour, &minute, &second, &tzf ) )
{
Expand All @@ -247,9 +239,10 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
return false;
}

QDateTime lastModified( QDate( year, month, day ), QTime( hour, minute, second ) );

#if 0
QDateTime lastModified( QDate( year, month, day ), QTime( hour, minute, second ) );
QString path = QString::fromUtf8( OGR_F_GetFieldAsString( f, pathIdx ) );
if ( path == fi.canonicalPath() && fi.lastModified() <= lastModified )
{
LOG( QObject::tr( "Drawing already uptodate in database." ) );
Expand Down Expand Up @@ -608,7 +601,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa

OGR_F_Destroy( f );

LOG( QObject::tr( "Updating database from %1 [%2]." ).arg( drawing ).arg( fi.lastModified().toString() ) );
LOG( QObject::tr( "Updating database from %1 [%2]." ).arg( drawing, fi.lastModified().toString() ) );

DRW::error result( DRW::BAD_NONE );

Expand Down Expand Up @@ -752,9 +745,9 @@ void QgsDwgImporter::addHeader( const DRW_Header *data )

case DRW_Variant::COORD:
v = QString( "%1,%2,%3" )
.arg( qgsDoubleToString( it->second->content.v->x ) )
.arg( qgsDoubleToString( it->second->content.v->y ) )
.arg( qgsDoubleToString( it->second->content.v->z ) );
.arg( qgsDoubleToString( it->second->content.v->x ),
qgsDoubleToString( it->second->content.v->y ),
qgsDoubleToString( it->second->content.v->z ) );
break;

case DRW_Variant::INVALID:
Expand All @@ -767,9 +760,9 @@ void QgsDwgImporter::addHeader( const DRW_Header *data )
if ( OGR_L_CreateFeature( layer, f ) != OGRERR_NONE )
{
LOG( QObject::tr( "Could not add %3 %1 [%2]" )
.arg( k )
.arg( QString::fromUtf8( CPLGetLastErrorMsg() ) )
.arg( QObject::tr( "header record" ) )
.arg( k,
QString::fromUtf8( CPLGetLastErrorMsg() ),
QObject::tr( "header record" ) )
);
}

Expand Down Expand Up @@ -2612,7 +2605,7 @@ bool QgsDwgImporter::expandInserts( QString &error )
QTransform t;
t.translate( p.x(), p.y() ).scale( xscale, yscale ).rotateRadians( angle );

Q_FOREACH ( QString name, QStringList() << "hatches" << "lines" << "polylines" << "texts" << "points" )
Q_FOREACH ( const QString &name, QStringList() << "hatches" << "lines" << "polylines" << "texts" << "points" )
{
OGRLayerH src = OGR_DS_ExecuteSQL( mDs, QString( "SELECT * FROM %1 WHERE block=%2" ).arg( name ).arg( handle ).toUtf8().constData(), nullptr, nullptr );
if ( !src )
Expand Down
3 changes: 1 addition & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -3354,8 +3354,7 @@ QgsMapCanvasDockWidget *QgisApp::createNewMapCanvasDock( const QString &name, bo
{
if ( canvas->objectName() == name )
{
QString errorMessage = tr( "A map canvas with name '%1' already exists!" ).arg( name );
QgsDebugMsg( errorMessage );
QgsDebugMsg( tr( "A map canvas with name '%1' already exists!" ).arg( name ) );
return nullptr;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsabout.cpp
Expand Up @@ -255,8 +255,8 @@ void QgsAbout::setPluginInfo()
myString += QApplication::libraryPaths().join( QStringLiteral( "<br>" ) );
myString += QLatin1String( "<ol>\n<li>\n" );
QList<QByteArray> myImageFormats = QImageReader::supportedImageFormats();
QList<QByteArray>::const_iterator myIterator = myImageFormats.begin();
while ( myIterator != myImageFormats.end() )
QList<QByteArray>::const_iterator myIterator = myImageFormats.constBegin();
while ( myIterator != myImageFormats.constEnd() )
{
QString myFormat = ( *myIterator ).data();
myString += myFormat + "</li>\n<li>";
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsbookmarks.cpp
Expand Up @@ -445,10 +445,10 @@ bool QgsProjectBookmarksTableModel::setData( const QModelIndex &index, const QVa
switch ( index.column() )
{
case 1:
QgsProject::instance()->writeEntry( QStringLiteral( "Bookmarks" ), QStringLiteral( "/Row-%1/Name" ).arg( index.row() ), value.value<QString>() );
QgsProject::instance()->writeEntry( QStringLiteral( "Bookmarks" ), QStringLiteral( "/Row-%1/Name" ).arg( index.row() ), value.toString() );
return true;
case 2:
QgsProject::instance()->writeEntry( QStringLiteral( "Bookmarks" ), QStringLiteral( "/Row-%1/Project" ).arg( index.row() ), value.value<QString>() );
QgsProject::instance()->writeEntry( QStringLiteral( "Bookmarks" ), QStringLiteral( "/Row-%1/Project" ).arg( index.row() ), value.toString() );
return true;
case 3:
QgsProject::instance()->writeEntry( QStringLiteral( "Bookmarks" ), QStringLiteral( "/Row-%1/MinX" ).arg( index.row() ), value.toDouble() );
Expand Down
4 changes: 3 additions & 1 deletion src/app/qgscrashreport.cpp
Expand Up @@ -108,7 +108,7 @@ const QString QgsCrashReport::toHtml() const
}

QString report;
Q_FOREACH ( QString line, reportData )
Q_FOREACH ( const QString &line, reportData )
{
report += line + "<br>";
}
Expand All @@ -125,8 +125,10 @@ const QString QgsCrashReport::crashID() const
// Hashes the full stack.
Q_FOREACH ( const QgsStackTrace::StackLine &line, mStackTrace )
{
#if 0
QFileInfo fileInfo( line.fileName );
QString filename( fileInfo.fileName() );
#endif
data += line.symbolName;
}

Expand Down

0 comments on commit f99a7a9

Please sign in to comment.