Skip to content
Permalink
Browse files

Fix some clazy issues (detach/iterating temporary, QString multi arg)

  • Loading branch information
nyalldawson committed Jan 13, 2016
1 parent 4181ef8 commit a30a73515008f7a170f1298dc47ad2e896509c58
@@ -363,8 +363,8 @@ void QgsFieldsProperties::loadRelations()
nmCombo->addItem( tr( "Many to one relation" ) );
Q_FOREACH ( const QgsRelation& nmrel, QgsProject::instance()->relationManager()->referencingRelations( relation.referencingLayer() ) )
{
if ( nmrel.fieldPairs().first().referencingField() != relation.fieldPairs().first().referencingField() )
nmCombo->addItem( QString( "%1 (%2)" ).arg( nmrel.referencedLayer()->name() ).arg( nmrel.fieldPairs().first().referencedField() ), nmrel.id() );
if ( nmrel.fieldPairs().at( 0 ).referencingField() != relation.fieldPairs().at( 0 ).referencingField() )
nmCombo->addItem( QString( "%1 (%2)" ).arg( nmrel.referencedLayer()->name(), nmrel.fieldPairs().at( 0 ).referencedField() ), nmrel.id() );

QgsEditorWidgetConfig cfg = mLayer->editFormConfig()->widgetConfig( relation.id() );

@@ -311,9 +311,9 @@ void QgsFeatureRequest::OrderByClause::setNullsFirst( bool nullsFirst )
QString QgsFeatureRequest::OrderByClause::dump() const
{
return QString( "%1 %2 %3" )
.arg( mExpression.expression() )
.arg( mAscending ? "ASC" : "DESC" )
.arg( mNullsFirst ? "NULLS FIRST" : "NULLS LAST" );
.arg( mExpression.expression(),
mAscending ? "ASC" : "DESC",
mNullsFirst ? "NULLS FIRST" : "NULLS LAST" );
}

QgsExpression QgsFeatureRequest::OrderByClause::expression() const
@@ -285,8 +285,8 @@ void QgsRelationEditorWidget::addFeature()
{
QgsFeature flink( mRelation.referencingLayer()->fields() ); // Linking feature

flink.setAttribute( mRelation.fieldPairs().first().first, mFeature.attribute( mRelation.fieldPairs().first().second ) );
flink.setAttribute( mNmRelation.referencingFields().first(), f.attribute( mNmRelation.referencedFields().first() ) );
flink.setAttribute( mRelation.fieldPairs().at( 0 ).first, mFeature.attribute( mRelation.fieldPairs().at( 0 ).second ) );
flink.setAttribute( mNmRelation.referencingFields().at( 0 ), f.attribute( mNmRelation.referencedFields().at( 0 ) ) );

mRelation.referencingLayer()->addFeature( flink );

@@ -716,7 +716,7 @@ void QgsGrassVectorMapLayer::addColumn( const QgsField &field, QString &error )
QVariant value = mAttributes.value( cat ).value( index );
QString valueString = quotedValue( value );
QString query = QString( "UPDATE %1 SET %2 = %3 WHERE %4 = %5" )
.arg( mFieldInfo->table ).arg( field.name() ).arg( valueString ).arg( keyColumnName() ).arg( cat );
.arg( mFieldInfo->table, field.name(), valueString, keyColumnName() ).arg( cat );
QString err;
executeSql( query, err );
if ( !err.isEmpty() )
@@ -50,9 +50,9 @@ QgsVirtualLayerFeatureIterator::QgsVirtualLayerFeatureIterator( QgsVirtualLayerF
QString mbr = QString( "%1,%2,%3,%4" ).arg( rect.xMinimum() ).arg( rect.yMinimum() ).arg( rect.xMaximum() ).arg( rect.yMaximum() );
wheres << quotedColumn( mDefinition.geometryField() ) + " is not null";
wheres << QString( "%1Intersects(%2,BuildMbr(%3))" )
.arg( do_exact ? "" : "Mbr" )
.arg( quotedColumn( mDefinition.geometryField() ) )
.arg( mbr );
.arg( do_exact ? "" : "Mbr",
quotedColumn( mDefinition.geometryField() ),
mbr );
}
else if ( !mDefinition.uid().isNull() && request.filterType() == QgsFeatureRequest::FilterFid )
{
@@ -292,7 +292,7 @@ bool QgsVirtualLayerProvider::createIt()
QString vname = mLayers.at( i ).name;
if ( vlayer )
{
QString createStr = QString( "DROP TABLE IF EXISTS \"%1\"; CREATE VIRTUAL TABLE \"%1\" USING QgsVLayer(%2);" ).arg( vname ).arg( vlayer->id() );
QString createStr = QString( "DROP TABLE IF EXISTS \"%1\"; CREATE VIRTUAL TABLE \"%1\" USING QgsVLayer(%2);" ).arg( vname, vlayer->id() );
Sqlite::Query::exec( mSqlite.get(), createStr );
}
else
@@ -304,10 +304,10 @@ bool QgsVirtualLayerProvider::createIt()
source.replace( "'", "''" );
QString encoding = mLayers.at( i ).encoding;
QString createStr = QString( "DROP TABLE IF EXISTS \"%1\"; CREATE VIRTUAL TABLE \"%1\" USING QgsVLayer('%2','%4',%3)" )
.arg( vname )
.arg( provider )
.arg( encoding )
.arg( source ); // source must be the last argument here, since it can contains '%x' strings that would be replaced
.arg( vname,
provider,
encoding,
source ); // source must be the last argument here, since it can contains '%x' strings that would be replaced
Sqlite::Query::exec( mSqlite.get(), createStr );
}
}
@@ -410,8 +410,8 @@ bool QgsVirtualLayerProvider::createIt()

// create a view
QString viewStr = QString( "DROP VIEW IF EXISTS %1; CREATE VIEW %1 AS %2" )
.arg( VIRTUAL_LAYER_QUERY_VIEW )
.arg( mDefinition.query() );
.arg( VIRTUAL_LAYER_QUERY_VIEW,
mDefinition.query() );
Sqlite::Query::exec( mSqlite.get(), viewStr );
}
else
@@ -528,9 +528,9 @@ void QgsVirtualLayerProvider::updateStatistics() const
bool hasGeometry = mDefinition.geometryWkbType() != QgsWKBTypes::NoGeometry;
QString subset = mSubset.isEmpty() ? "" : " WHERE " + mSubset;
QString sql = QString( "SELECT Count(*)%1 FROM %2%3" )
.arg( hasGeometry ? QString( ",Min(MbrMinX(%1)),Min(MbrMinY(%1)),Max(MbrMaxX(%1)),Max(MbrMaxY(%1))" ).arg( quotedColumn( mDefinition.geometryField() ) ) : "" )
.arg( mTableName )
.arg( subset );
.arg( hasGeometry ? QString( ",Min(MbrMinX(%1)),Min(MbrMinY(%1)),Max(MbrMaxX(%1)),Max(MbrMaxY(%1))" ).arg( quotedColumn( mDefinition.geometryField() ) ) : "",
mTableName,
subset );
Sqlite::Query q( mSqlite.get(), sql );
if ( q.step() == SQLITE_ROW )
{
@@ -234,9 +234,10 @@ struct VTable
sql_fields << QString( "geometry geometry(%1,%2)" ).arg( provider->geometryType() ).arg( provider->crs().postgisSrid() );
}

if ( provider->pkAttributeIndexes().size() == 1 )
QgsAttributeList pkAttributeIndexes = provider->pkAttributeIndexes();
if ( pkAttributeIndexes.size() == 1 )
{
mPkColumn = provider->pkAttributeIndexes()[0] + 1;
mPkColumn = pkAttributeIndexes.at( 0 ) + 1;
}

mCreationStr = "CREATE TABLE vtable (" + sql_fields.join( "," ) + ")";
@@ -479,7 +479,8 @@ QPair<QByteArray, QByteArray> QgsServer::handleRequest( const QString& queryStri
mServerInterface->setRequestHandler( theRequestHandler.data() );
// Iterate filters and call their requestReady() method
QgsServerFiltersMap::const_iterator filtersIterator;
for ( filtersIterator = mServerInterface->filters().constBegin(); filtersIterator != mServerInterface->filters().constEnd(); ++filtersIterator )
QgsServerFiltersMap filters = mServerInterface->filters();
for ( filtersIterator = filters.constBegin(); filtersIterator != filters.constEnd(); ++filtersIterator )
{
filtersIterator.value()->requestReady();
}
@@ -616,7 +617,8 @@ QPair<QByteArray, QByteArray> QgsServer::handleRequest( const QString& queryStri

#ifdef HAVE_SERVER_PYTHON_PLUGINS
// Iterate filters and call their responseComplete() method
for ( filtersIterator = mServerInterface->filters().constBegin(); filtersIterator != mServerInterface->filters().constEnd(); ++filtersIterator )
filters = mServerInterface->filters();
for ( filtersIterator = filters.constBegin(); filtersIterator != filters.constEnd(); ++filtersIterator )
{
filtersIterator.value()->responseComplete();
}
@@ -47,7 +47,7 @@ bool QgsServerPlugins::initPlugins( QgsServerInterface *interface )
pythonlibName.prepend( "lib" );
#endif
QString version = QString( "%1.%2.%3" ).arg( QGis::QGIS_VERSION_INT / 10000 ).arg( QGis::QGIS_VERSION_INT / 100 % 100 ).arg( QGis::QGIS_VERSION_INT % 100 );
QgsMessageLog::logMessage( QString( "load library %1 (%2)" ).arg( pythonlibName ).arg( version ), __FILE__, QgsMessageLog::INFO );
QgsMessageLog::logMessage( QString( "load library %1 (%2)" ).arg( pythonlibName, version ), __FILE__, QgsMessageLog::INFO );
QLibrary pythonlib( pythonlibName, version );
// It's necessary to set these two load hints, otherwise Python library won't work correctly
// see http://lists.kde.org/?l=pykde&m=117190116820758&w=2
@@ -1696,8 +1696,8 @@ void QgsSLDConfigParser::setCrsForLayer( const QDomElement& layerElem, QgsMapLay
if ( srs.srsid() == 0 )
{
QString myName = QString( " * %1 (%2)" )
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ) )
.arg( srs.toProj4() );
.arg( QObject::tr( "Generated CRS", "A CRS automatically generated from layer info get this prefix for description" ),
srs.toProj4() );
srs.saveAsUserCRS( myName );
}

@@ -764,7 +764,7 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
QString errorMsg;
if ( !filter.setContent( filterIt.value(), true, &errorMsg ) )
{
throw QgsMapServiceException( "RequestNotWellFormed", QString( "error message: %1. The XML string was: %2" ).arg( errorMsg ).arg( filterIt.value() ) );
throw QgsMapServiceException( "RequestNotWellFormed", QString( "error message: %1. The XML string was: %2" ).arg( errorMsg, filterIt.value() ) );
}
else
{
@@ -162,7 +162,7 @@ QList<QgsMapLayer*> QgsWMSProjectParser::mapLayerFromStyle( const QString& lName
{
// try to apply the specified style
if ( !ml->styleManager()->setCurrentStyle( styleName != EMPTY_STYLE_NAME ? styleName : QString() ) )
throw QgsMapServiceException( "StyleNotDefined", QString( "Style \"%1\" does not exist for layer \"%2\"" ).arg( styleName ).arg( lName ) );
throw QgsMapServiceException( "StyleNotDefined", QString( "Style \"%1\" does not exist for layer \"%2\"" ).arg( styleName, lName ) );
}
return QList<QgsMapLayer*>() << ml;
}
@@ -1517,7 +1517,7 @@ int QgsWMSServer::getFeatureInfo( QDomDocument& result, const QString& version )

for ( QMap<QString, QString>::const_iterator it = mParameters.constBegin(); it != mParameters.constEnd(); ++it )
{
QgsMessageLog::logMessage( QString( "%1 // %2" ).arg( it.key() ).arg( it.value() ) );
QgsMessageLog::logMessage( QString( "%1 // %2" ).arg( it.key(), it.value() ) );
}

if ( readLayersAndStyles( layersList, stylesList ) != 0 )
@@ -2178,7 +2178,7 @@ int QgsWMSServer::featureInfoFromVectorLayer( QgsVectorLayer* layer,
if ( fReq.filterExpression() )
{
fReq.setFilterExpression( QString( "intersects( $geometry , geomFromWKT( '%1' ) ) AND ( %2 )" ).
arg( searchRect.asWktPolygon() ).arg( fReq.filterExpression()->expression() ) );
arg( searchRect.asWktPolygon(), fReq.filterExpression()->expression() ) );
}
else
{

0 comments on commit a30a735

Please sign in to comment.
You can’t perform that action at this time.