Skip to content

Commit

Permalink
Pass strings by const ref
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 12, 2017
1 parent a46cc54 commit b1745b0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
18 changes: 8 additions & 10 deletions src/core/geonode/qgsgeonoderequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ QgsGeoNodeRequest::QgsGeoNodeRequest( bool forceRefresh, QObject *parent )
QgsGeoNodeRequest::QgsGeoNodeRequest( const QString &baseUrl, /*const QgsWmsAuthorization &auth,*/ bool forceRefresh, QObject *parent )
: QObject( parent )
, mBaseUrl( baseUrl )
, mGeoNodeReply( nullptr )
, mIsAborted( false )
, mForceRefresh( forceRefresh )
{

Expand Down Expand Up @@ -70,7 +68,7 @@ QList<QgsServiceLayerDetail> QgsGeoNodeRequest::getLayers()
return parseLayers( this->response() );
}

QgsGeoNodeStyle QgsGeoNodeRequest::getDefaultStyle( QString layerName )
QgsGeoNodeStyle QgsGeoNodeRequest::getDefaultStyle( const QString &layerName )
{
QgsGeoNodeStyle defaultStyle;
bool success = request( QStringLiteral( "/api/layers?name=" ) + layerName );
Expand All @@ -94,7 +92,7 @@ QgsGeoNodeStyle QgsGeoNodeRequest::getDefaultStyle( QString layerName )

}

QList<QgsGeoNodeStyle> QgsGeoNodeRequest::getStyles( QString layerName )
QList<QgsGeoNodeStyle> QgsGeoNodeRequest::getStyles( const QString &layerName )
{
QList<QgsGeoNodeStyle> geoNodeStyles;
bool success = request( QStringLiteral( "/api/styles?layer__name=" ) + layerName );
Expand Down Expand Up @@ -122,7 +120,7 @@ QList<QgsGeoNodeStyle> QgsGeoNodeRequest::getStyles( QString layerName )

}

QgsGeoNodeStyle QgsGeoNodeRequest::getStyle( QString styleID )
QgsGeoNodeStyle QgsGeoNodeRequest::getStyle( const QString &styleID )
{
QString endPoint = QStringLiteral( "/api/styles/" ) + styleID;

Expand Down Expand Up @@ -243,7 +241,7 @@ void QgsGeoNodeRequest::replyFinished()

}

QList<QgsServiceLayerDetail> QgsGeoNodeRequest::parseLayers( QByteArray layerResponse )
QList<QgsServiceLayerDetail> QgsGeoNodeRequest::parseLayers( const QByteArray &layerResponse )
{
QList<QgsServiceLayerDetail> layers;
if ( layerResponse.isEmpty() )
Expand Down Expand Up @@ -356,7 +354,7 @@ QList<QgsServiceLayerDetail> QgsGeoNodeRequest::parseLayers( QByteArray layerRes
return layers;
}

QgsGeoNodeStyle QgsGeoNodeRequest::retrieveStyle( QString styleUrl )
QgsGeoNodeStyle QgsGeoNodeRequest::retrieveStyle( const QString &styleUrl )
{
QgsGeoNodeStyle geoNodeStyle;

Expand Down Expand Up @@ -388,7 +386,7 @@ QgsGeoNodeStyle QgsGeoNodeRequest::retrieveStyle( QString styleUrl )
return geoNodeStyle;
}

QStringList QgsGeoNodeRequest::serviceUrls( QString serviceType )
QStringList QgsGeoNodeRequest::serviceUrls( const QString &serviceType )
{
QStringList urls;

Expand Down Expand Up @@ -432,7 +430,7 @@ QStringList QgsGeoNodeRequest::serviceUrls( QString serviceType )
return urls;
}

QgsStringMap QgsGeoNodeRequest::serviceUrlData( QString serviceType )
QgsStringMap QgsGeoNodeRequest::serviceUrlData( const QString &serviceType )
{
QgsStringMap urls;

Expand Down Expand Up @@ -478,7 +476,7 @@ QgsStringMap QgsGeoNodeRequest::serviceUrlData( QString serviceType )
return urls;
}

bool QgsGeoNodeRequest::request( QString endPoint )
bool QgsGeoNodeRequest::request( const QString &endPoint )
{
abort();
mIsAborted = false;
Expand Down
20 changes: 10 additions & 10 deletions src/core/geonode/qgsgeonoderequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ class CORE_EXPORT QgsGeoNodeRequest : public QObject
QgsGeoNodeRequest( const QString &baseUrl, /*const QgsWmsAuthorization &auth,*/ bool forceRefresh, QObject *parent = nullptr );
virtual ~QgsGeoNodeRequest();

bool request( QString endPoint );
bool request( const QString &endPoint );

QList<QgsServiceLayerDetail> getLayers();

QList<QgsGeoNodeStyle> getStyles( QString layerName );
QList<QgsGeoNodeStyle> getStyles( const QString &layerName );

QgsGeoNodeStyle getDefaultStyle( QString layerName );
QgsGeoNodeStyle getDefaultStyle( const QString &layerName );

QgsGeoNodeStyle getStyle( QString styleID );
QgsGeoNodeStyle getStyle( const QString &styleID );

// Obtain list of unique URL in the geonode
QStringList serviceUrls( QString serviceType );
QStringList serviceUrls( const QString &serviceType );

// Obtain map of layer name and url for a service type
QgsStringMap serviceUrlData( QString serviceType );
QgsStringMap serviceUrlData( const QString &serviceType );

QString lastError() const { return mError; }

Expand All @@ -91,8 +91,8 @@ class CORE_EXPORT QgsGeoNodeRequest : public QObject
void setProtocol( const QString &protocol );

private:
QList<QgsServiceLayerDetail> parseLayers( QByteArray layerResponse );
QgsGeoNodeStyle retrieveStyle( QString styleUrl );
QList<QgsServiceLayerDetail> parseLayers( const QByteArray &layerResponse );
QgsGeoNodeStyle retrieveStyle( const QString &styleUrl );

signals:
//! \brief emit a signal to be caught by qgisapp and display a statusQString on status bar
Expand Down Expand Up @@ -127,8 +127,8 @@ class CORE_EXPORT QgsGeoNodeRequest : public QObject
//! Response
QByteArray mHttpGeoNodeResponse;

bool mIsAborted;
bool mForceRefresh;
bool mIsAborted = false;
bool mForceRefresh = false;

};

Expand Down

0 comments on commit b1745b0

Please sign in to comment.