Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Pass by const ref where possible
  • Loading branch information
nyalldawson committed Sep 11, 2017
1 parent c9fa976 commit 2a33844
Show file tree
Hide file tree
Showing 52 changed files with 106 additions and 106 deletions.
2 changes: 1 addition & 1 deletion python/core/qgsjsonutils.sip
Expand Up @@ -248,7 +248,7 @@ class QgsJsonUtils
%End

static QString exportAttributes( const QgsFeature &feature, QgsVectorLayer *layer = 0,
QVector<QVariant> attributeWidgetCaches = QVector<QVariant>() );
const QVector<QVariant> &attributeWidgetCaches = QVector<QVariant>() );
%Docstring
Exports all attributes from a QgsFeature as a JSON map type.
\param feature feature to export
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgsmaprenderertask.sip
Expand Up @@ -48,7 +48,7 @@ class QgsMapRendererTask : QgsTask
Adds ``annotations`` to be rendered on the map.
%End

void addDecorations( QList< QgsMapDecoration * > decorations );
void addDecorations( const QList<QgsMapDecoration *> &decorations );
%Docstring
Adds ``decorations`` to be rendered on the map.
%End
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgssettings.sip
Expand Up @@ -166,7 +166,7 @@ Returns a list of all key top-level groups (same as childGroups) but only for gr
Return the path to the Global Settings QSettings storage file
:rtype: str
%End
static bool setGlobalSettingsPath( QString path );
static bool setGlobalSettingsPath( const QString &path );
%Docstring
Set the Global Settings QSettings storage file
:rtype: bool
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsfiledownloader.sip
Expand Up @@ -32,7 +32,7 @@ class QgsFileDownloader : QObject
%End
public:

QgsFileDownloader( const QUrl &url, const QString &outputFileName, bool guiNotificationsEnabled = true, QString authcfg = QString() );
QgsFileDownloader( const QUrl &url, const QString &outputFileName, bool guiNotificationsEnabled = true, const QString &authcfg = QString() );
%Docstring
QgsFileDownloader
\param url the download url
Expand Down
4 changes: 2 additions & 2 deletions src/app/dwg/qgsdwgimportdialog.cpp
Expand Up @@ -267,7 +267,7 @@ void QgsDwgImportDialog::on_pbImportDrawing_clicked()
on_pbLoadDatabase_clicked();
}

QgsVectorLayer *QgsDwgImportDialog::layer( QgsLayerTreeGroup *layerGroup, QString layerFilter, QString table )
QgsVectorLayer *QgsDwgImportDialog::layer( QgsLayerTreeGroup *layerGroup, const QString &layerFilter, const QString &table )
{
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 ) );
Expand All @@ -283,7 +283,7 @@ QgsVectorLayer *QgsDwgImportDialog::layer( QgsLayerTreeGroup *layerGroup, QStrin
return l;
}

void QgsDwgImportDialog::createGroup( QgsLayerTreeGroup *group, QString name, QStringList layers, bool visible )
void QgsDwgImportDialog::createGroup( QgsLayerTreeGroup *group, const QString &name, const QStringList &layers, bool visible )
{
QgsLayerTreeGroup *layerGroup = group->addGroup( name );
QgsDebugMsg( QString( " %1" ).arg( name ) ) ;
Expand Down
4 changes: 2 additions & 2 deletions src/app/dwg/qgsdwgimportdialog.h
Expand Up @@ -44,8 +44,8 @@ class QgsDwgImportDialog : public QDialog, private Ui::QgsDwgImportBase
void showHelp();

private:
QgsVectorLayer *layer( QgsLayerTreeGroup *layerGroup, QString layer, QString table );
void createGroup( QgsLayerTreeGroup *group, QString name, QStringList layers, bool visible );
QgsVectorLayer *layer( QgsLayerTreeGroup *layerGroup, const QString &layer, const QString &table );
void createGroup( QgsLayerTreeGroup *group, const QString &name, const QStringList &layers, bool visible );
void updateUI();
void expandInserts();
void updateCheckState( Qt::CheckState state );
Expand Down
16 changes: 8 additions & 8 deletions src/app/dwg/qgsdwgimporter.cpp
Expand Up @@ -75,7 +75,7 @@ QgsDwgImporter::QgsDwgImporter( const QString &database, const QgsCoordinateRefe
QgsDebugMsg( QString( "CRS %1[%2]: %3" ).arg( mCrs ).arg( ( qint64 ) mCrsH, 0, 16 ).arg( crswkt ) );
}

bool QgsDwgImporter::exec( QString sql, bool logError )
bool QgsDwgImporter::exec( const QString &sql, bool logError )
{
if ( !mDs )
{
Expand Down Expand Up @@ -104,7 +104,7 @@ bool QgsDwgImporter::exec( QString sql, bool logError )
return false;
}

OGRLayerH QgsDwgImporter::query( QString sql )
OGRLayerH QgsDwgImporter::query( const QString &sql )
{
if ( !mDs )
{
Expand Down Expand Up @@ -259,7 +259,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa

struct field
{
field( QString name, OGRFieldType ogrType, int width = -1, int precision = -1 )
field( const QString &name, OGRFieldType ogrType, int width = -1, int precision = -1 )
: mName( name ), mOgrType( ogrType ), mWidth( width ), mPrecision( precision )
{}

Expand All @@ -271,7 +271,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa

struct table
{
table( QString name, QString desc, OGRwkbGeometryType wkbType, QList<field> fields )
table( const QString &name, const QString &desc, OGRwkbGeometryType wkbType, const QList<field> &fields )
: mName( name ), mDescription( desc ), mWkbType( wkbType ), mFields( fields )
{}

Expand Down Expand Up @@ -931,7 +931,7 @@ void QgsDwgImporter::addLayer( const DRW_Layer &data )
OGR_F_Destroy( f );
}

void QgsDwgImporter::setString( OGRFeatureDefnH dfn, OGRFeatureH f, QString field, const std::string &value ) const
void QgsDwgImporter::setString( OGRFeatureDefnH dfn, OGRFeatureH f, const QString &field, const std::string &value ) const
{
int idx = OGR_FD_GetFieldIndex( dfn, field.toLower().toUtf8().constData() );
if ( idx < 0 )
Expand All @@ -942,7 +942,7 @@ void QgsDwgImporter::setString( OGRFeatureDefnH dfn, OGRFeatureH f, QString fiel
OGR_F_SetFieldString( f, idx, value.c_str() );
}

void QgsDwgImporter::setDouble( OGRFeatureDefnH dfn, OGRFeatureH f, QString field, double value ) const
void QgsDwgImporter::setDouble( OGRFeatureDefnH dfn, OGRFeatureH f, const QString &field, double value ) const
{
int idx = OGR_FD_GetFieldIndex( dfn, field.toLower().toUtf8().constData() );
if ( idx < 0 )
Expand All @@ -953,7 +953,7 @@ void QgsDwgImporter::setDouble( OGRFeatureDefnH dfn, OGRFeatureH f, QString fiel
OGR_F_SetFieldDouble( f, idx, value );
}

void QgsDwgImporter::setInteger( OGRFeatureDefnH dfn, OGRFeatureH f, QString field, int value ) const
void QgsDwgImporter::setInteger( OGRFeatureDefnH dfn, OGRFeatureH f, const QString &field, int value ) const
{
int idx = OGR_FD_GetFieldIndex( dfn, field.toLower().toUtf8().constData() );
if ( idx < 0 )
Expand All @@ -964,7 +964,7 @@ void QgsDwgImporter::setInteger( OGRFeatureDefnH dfn, OGRFeatureH f, QString fie
OGR_F_SetFieldInteger( f, idx, value );
}

void QgsDwgImporter::setPoint( OGRFeatureDefnH dfn, OGRFeatureH f, QString field, const DRW_Coord &p ) const
void QgsDwgImporter::setPoint( OGRFeatureDefnH dfn, OGRFeatureH f, const QString &field, const DRW_Coord &p ) const
{
QVector<double> ext( 3 );
ext[0] = p.x;
Expand Down
12 changes: 6 additions & 6 deletions src/app/dwg/qgsdwgimporter.h
Expand Up @@ -168,17 +168,17 @@ class QgsDwgImporter : public DRW_Interface
private:
void startTransaction();
void commitTransaction();
bool exec( QString sql, bool logError = true );
OGRLayerH query( QString sql );
bool exec( const QString &sql, bool logError = true );
OGRLayerH query( const QString &sql );

void addEntity( OGRFeatureDefnH dfn, OGRFeatureH f, const DRW_Entity &data );
QString colorString( int color, int color24, int transparency, const std::string &layer ) const;
double lineWidth( int lWeight, const std::string &layer ) const;
QString linetypeString( const std::string &linetype, const std::string &layer ) const;
void setString( OGRFeatureDefnH dfn, OGRFeatureH f, QString field, const std::string &value ) const;
void setDouble( OGRFeatureDefnH dfn, OGRFeatureH f, QString field, double value ) const;
void setInteger( OGRFeatureDefnH dfn, OGRFeatureH f, QString field, int value ) const;
void setPoint( OGRFeatureDefnH dfn, OGRFeatureH f, QString field, const DRW_Coord &value ) const;
void setString( OGRFeatureDefnH dfn, OGRFeatureH f, const QString &field, const std::string &value ) const;
void setDouble( OGRFeatureDefnH dfn, OGRFeatureH f, const QString &field, double value ) const;
void setInteger( OGRFeatureDefnH dfn, OGRFeatureH f, const QString &field, int value ) const;
void setPoint( OGRFeatureDefnH dfn, OGRFeatureH f, const QString &field, const DRW_Coord &value ) const;

bool curveFromLWPolyline( const DRW_LWPolyline &data, QgsCompoundCurve &cc );

Expand Down
2 changes: 1 addition & 1 deletion src/app/nodetool/qgsnodetool.cpp
Expand Up @@ -1784,7 +1784,7 @@ void QgsNodeTool::CircularBand::updateRubberBand( const QgsPointXY &mapPoint )
}


void QgsNodeTool::validationErrorFound( QgsGeometry::Error e )
void QgsNodeTool::validationErrorFound( const QgsGeometry::Error &e )
{
QgsGeometryValidator *validator = qobject_cast<QgsGeometryValidator *>( sender() );
if ( !validator )
Expand Down
2 changes: 1 addition & 1 deletion src/app/nodetool/qgsnodetool.h
Expand Up @@ -90,7 +90,7 @@ class APP_EXPORT QgsNodeTool : public QgsMapToolAdvancedDigitizing

void deleteNodeEditorSelection();

void validationErrorFound( QgsGeometry::Error e );
void validationErrorFound( const QgsGeometry::Error &e );

void validationFinished();

Expand Down
8 changes: 4 additions & 4 deletions src/app/qgisapp.cpp
Expand Up @@ -603,7 +603,7 @@ static bool cmpByText_( QAction *a, QAction *b )
QgisApp *QgisApp::sInstance = nullptr;

// constructor starts here
QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCheck, const QString rootProfileLocation, const QString activeProfile, QWidget *parent, Qt::WindowFlags fl )
QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCheck, const QString &rootProfileLocation, const QString &activeProfile, QWidget *parent, Qt::WindowFlags fl )
: QMainWindow( parent, fl )
, mSplash( splash )
, mShowProjectionTab( false )
Expand Down Expand Up @@ -1505,7 +1505,7 @@ bool QgisApp::event( QEvent *event )
return done;
}

void QgisApp::dataSourceManager( QString pageName )
void QgisApp::dataSourceManager( const QString &pageName )
{
if ( ! mDataSourceManagerDialog )
{
Expand Down Expand Up @@ -11768,7 +11768,7 @@ void QgisApp::endProfile()
QgsApplication::profiler()->end();
}

void QgisApp::functionProfile( void ( QgisApp::*fnc )(), QgisApp *instance, QString name )
void QgisApp::functionProfile( void ( QgisApp::*fnc )(), QgisApp *instance, const QString &name )
{
startProfile( name );
( instance->*fnc )();
Expand Down Expand Up @@ -12484,7 +12484,7 @@ QMenu *QgisApp::createPopupMenu()
}


void QgisApp::showSystemNotification( const QString title, const QString message )
void QgisApp::showSystemNotification( const QString &title, const QString &message )
{
// Menubar icon is hidden by default. Show to enable notification bubbles
mTray->show();
Expand Down
10 changes: 5 additions & 5 deletions src/app/qgisapp.h
Expand Up @@ -165,8 +165,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
public:
//! Constructor
QgisApp( QSplashScreen *splash, bool restorePlugins = true,
bool skipVersionCheck = false, const QString rootProfileLocation = QString(),
const QString activeProfile = QString(),
bool skipVersionCheck = false, const QString &rootProfileLocation = QString(),
const QString &activeProfile = QString(),
QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::Window );
//! Constructor for unit tests
QgisApp();
Expand Down Expand Up @@ -377,7 +377,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
* \param title
* \param message
*/
void showSystemNotification( const QString title, const QString message );
void showSystemNotification( const QString &title, const QString &message );


//! Actions to be inserted in menus and toolbars
Expand Down Expand Up @@ -793,7 +793,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
* \param pageName the page name, usually the provider name or "browser" (for the browser panel)
* or "ogr" (vector layers) or "raster" (raster layers)
*/
void dataSourceManager( QString pageName = QString() );
void dataSourceManager( const QString &pageName = QString() );

/** Add a raster layer directly without prompting user for location
The caller must provide information compatible with the provider plugin
Expand Down Expand Up @@ -1599,7 +1599,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
private:
void startProfile( const QString &name );
void endProfile();
void functionProfile( void ( QgisApp::*fnc )(), QgisApp *instance, QString name );
void functionProfile( void ( QgisApp::*fnc )(), QgisApp *instance, const QString &name );

/** This method will open a dialog so the user can select GDAL sublayers to load
* \returns true if any items were loaded
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsattributeactionpropertiesdialog.cpp
Expand Up @@ -31,7 +31,7 @@
#include <QFileDialog>
#include <QImageWriter>

QgsAttributeActionPropertiesDialog::QgsAttributeActionPropertiesDialog( QgsAction::ActionType type, const QString &description, const QString &shortTitle, const QString &iconPath, const QString &actionText, bool capture, QSet<QString> actionScopes, QgsVectorLayer *layer, QWidget *parent )
QgsAttributeActionPropertiesDialog::QgsAttributeActionPropertiesDialog( QgsAction::ActionType type, const QString &description, const QString &shortTitle, const QString &iconPath, const QString &actionText, bool capture, const QSet<QString> &actionScopes, QgsVectorLayer *layer, QWidget *parent )
: QDialog( parent )
, mLayer( layer )
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsattributeactionpropertiesdialog.h
Expand Up @@ -28,7 +28,7 @@ class QgsAttributeActionPropertiesDialog: public QDialog, private Ui::QgsAttribu
Q_OBJECT

public:
QgsAttributeActionPropertiesDialog( QgsAction::ActionType type, const QString &description, const QString &shortTitle, const QString &iconPath, const QString &actionText, bool capture, QSet<QString> actionScopes, QgsVectorLayer *layer, QWidget *parent = nullptr );
QgsAttributeActionPropertiesDialog( QgsAction::ActionType type, const QString &description, const QString &shortTitle, const QString &iconPath, const QString &actionText, bool capture, const QSet<QString> &actionScopes, QgsVectorLayer *layer, QWidget *parent = nullptr );

QgsAttributeActionPropertiesDialog( QgsVectorLayer *layer, QWidget *parent = nullptr );

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmapsavedialog.cpp
Expand Up @@ -40,7 +40,7 @@

Q_GUI_EXPORT extern int qt_defaultDpiX();

QgsMapSaveDialog::QgsMapSaveDialog( QWidget *parent, QgsMapCanvas *mapCanvas, QList< QgsDecorationItem * > decorations, QList< QgsAnnotation *> annotations, DialogType type )
QgsMapSaveDialog::QgsMapSaveDialog( QWidget *parent, QgsMapCanvas *mapCanvas, const QList<QgsDecorationItem *> &decorations, const QList< QgsAnnotation *> &annotations, DialogType type )
: QDialog( parent )
, mDialogType( type )
, mMapCanvas( mapCanvas )
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmapsavedialog.h
Expand Up @@ -48,8 +48,8 @@ class APP_EXPORT QgsMapSaveDialog: public QDialog, private Ui::QgsMapSaveDialog
/** Constructor for QgsMapSaveDialog
*/
QgsMapSaveDialog( QWidget *parent = nullptr, QgsMapCanvas *mapCanvas = nullptr,
QList< QgsDecorationItem * > decorations = QList< QgsDecorationItem * >(),
QList< QgsAnnotation *> annotations = QList< QgsAnnotation * >(),
const QList< QgsDecorationItem * > &decorations = QList< QgsDecorationItem * >(),
const QList<QgsAnnotation *> &annotations = QList< QgsAnnotation * >(),
DialogType type = Image );

//! returns extent rectangle
Expand Down
8 changes: 4 additions & 4 deletions src/core/expression/qgsexpressionfunction.cpp
Expand Up @@ -131,8 +131,8 @@ QgsStaticExpressionFunction::QgsStaticExpressionFunction( const QString &fnname,
FcnEval fcn,
const QString &group,
const QString &helpText,
std::function < bool ( const QgsExpressionNodeFunction *node ) > usesGeometry,
std::function < QSet<QString>( const QgsExpressionNodeFunction *node ) > referencedColumns,
const std::function < bool ( const QgsExpressionNodeFunction *node ) > &usesGeometry,
const std::function < QSet<QString>( const QgsExpressionNodeFunction *node ) > &referencedColumns,
bool lazyEval,
const QStringList &aliases,
bool handlesNull )
Expand Down Expand Up @@ -182,7 +182,7 @@ bool QgsStaticExpressionFunction::prepare( const QgsExpressionNodeFunction *node
return true;
}

void QgsStaticExpressionFunction::setIsStaticFunction( std::function<bool ( const QgsExpressionNodeFunction *, QgsExpression *, const QgsExpressionContext * )> isStatic )
void QgsStaticExpressionFunction::setIsStaticFunction( const std::function<bool ( const QgsExpressionNodeFunction *, QgsExpression *, const QgsExpressionContext * )> &isStatic )
{
mIsStaticFunc = isStatic;
}
Expand All @@ -193,7 +193,7 @@ void QgsStaticExpressionFunction::setIsStatic( bool isStatic )
mIsStatic = isStatic;
}

void QgsStaticExpressionFunction::setPrepareFunction( std::function<bool ( const QgsExpressionNodeFunction *, QgsExpression *, const QgsExpressionContext * )> prepareFunc )
void QgsStaticExpressionFunction::setPrepareFunction( const std::function<bool ( const QgsExpressionNodeFunction *, QgsExpression *, const QgsExpressionContext * )> &prepareFunc )
{
mPrepareFunc = prepareFunc;
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/expression/qgsexpressionfunction.h
Expand Up @@ -369,8 +369,8 @@ class QgsStaticExpressionFunction : public QgsExpressionFunction
FcnEval fcn,
const QString &group,
const QString &helpText,
std::function < bool ( const QgsExpressionNodeFunction *node ) > usesGeometry,
std::function < QSet<QString>( const QgsExpressionNodeFunction *node ) > referencedColumns,
const std::function< bool( const QgsExpressionNodeFunction * )> &usesGeometry,
const std::function< QSet<QString>( const QgsExpressionNodeFunction * )> &referencedColumns,
bool lazyEval = false,
const QStringList &aliases = QStringList(),
bool handlesNull = false );
Expand Down Expand Up @@ -423,7 +423,7 @@ class QgsStaticExpressionFunction : public QgsExpressionFunction
* By default this is set to a function that checks all arguments that have been passed to the variable
* and if all of them are static, it will be assumed that the function is static as well.
*/
void setIsStaticFunction( std::function < bool( const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context ) > isStatic );
void setIsStaticFunction( const std::function< bool ( const QgsExpressionNodeFunction *, QgsExpression *, const QgsExpressionContext * ) > &isStatic );

/**
* Tag this function as either static or not static.
Expand All @@ -440,7 +440,7 @@ class QgsStaticExpressionFunction : public QgsExpressionFunction
* By default this is set to a function that checks all arguments that have been passed to the variable
* and if all of them are static, it will be assumed that the function is static as well.
*/
void setPrepareFunction( std::function < bool( const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context ) > prepareFunc );
void setPrepareFunction( const std::function< bool( const QgsExpressionNodeFunction *, QgsExpression *, const QgsExpressionContext * )> &prepareFunc );

static const QList<QgsExpressionFunction *> &functions();

Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsgeometryeditutils.cpp
Expand Up @@ -223,7 +223,7 @@ bool QgsGeometryEditUtils::deletePart( QgsAbstractGeometry *geom, int partNum )

std::unique_ptr<QgsAbstractGeometry> QgsGeometryEditUtils::avoidIntersections( const QgsAbstractGeometry &geom,
const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
QHash<QgsVectorLayer *, QSet<QgsFeatureId> > ignoreFeatures )
const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures )
{
std::unique_ptr<QgsGeometryEngine> geomEngine( QgsGeometry::createGeometryEngine( &geom ) );
if ( !geomEngine )
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsgeometryeditutils.h
Expand Up @@ -72,7 +72,7 @@ class QgsGeometryEditUtils
*/
static std::unique_ptr< QgsAbstractGeometry > avoidIntersections( const QgsAbstractGeometry &geom,
const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
QHash<QgsVectorLayer *, QSet<QgsFeatureId> > ignoreFeatures = ( QHash<QgsVectorLayer *, QSet<QgsFeatureId> >() ) );
const QHash<QgsVectorLayer *, QSet<QgsFeatureId> > &ignoreFeatures = ( QHash<QgsVectorLayer *, QSet<QgsFeatureId> >() ) );
};

#endif // QGSGEOMETRYEDITUTILS_H

0 comments on commit 2a33844

Please sign in to comment.