Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Performance optimizations
- avoid container detachments
- use QStringLiteral
  • Loading branch information
nyalldawson committed Sep 12, 2017
1 parent b1745b0 commit 5b092ae
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 117 deletions.
2 changes: 1 addition & 1 deletion python/core/geonode/qgsgeonodeconnection.sip
Expand Up @@ -36,7 +36,7 @@ Destructor
%End
void setConnName( const QString &connName );

QgsDataSourceUri uri();
QgsDataSourceUri uri() const;
%Docstring
:rtype: QgsDataSourceUri
%End
Expand Down
22 changes: 15 additions & 7 deletions python/core/geonode/qgsgeonoderequest.sip
Expand Up @@ -42,11 +42,17 @@ class QgsGeoNodeRequest : QObject
#include "qgsgeonoderequest.h"
%End
public:

explicit QgsGeoNodeRequest( bool forceRefresh, QObject *parent = 0 );
QgsGeoNodeRequest( const QString &baseUrl, /*const QgsWmsAuthorization &auth,*/ bool forceRefresh, QObject *parent = 0 );
%Docstring
Constructor for QgsGeoNodeRequest.

If ``forceRefresh`` is false, then cached copies of the request may be reused.
%End
QgsGeoNodeRequest( const QString &baseUrl, bool forceRefresh, QObject *parent = 0 );
virtual ~QgsGeoNodeRequest();

bool request( QString endPoint );
bool request( const QString &endPoint );
%Docstring
:rtype: bool
%End
Expand All @@ -56,28 +62,30 @@ class QgsGeoNodeRequest : QObject
:rtype: list of QgsServiceLayerDetail
%End

QList<QgsGeoNodeStyle> getStyles( QString layerName );
QList<QgsGeoNodeStyle> getStyles( const QString &layerName );
%Docstring
:rtype: list of QgsGeoNodeStyle
%End

QgsGeoNodeStyle getDefaultStyle( QString layerName );
QgsGeoNodeStyle getDefaultStyle( const QString &layerName );
%Docstring
:rtype: QgsGeoNodeStyle
%End

QgsGeoNodeStyle getStyle( QString styleID );
QgsGeoNodeStyle getStyle( const QString &styleID );
%Docstring
:rtype: QgsGeoNodeStyle
%End

QStringList serviceUrls( QString serviceType );
QStringList serviceUrls( const QString &serviceType );
%Docstring
Obtain list of unique URLs in the geonode
:rtype: list of str
%End

QgsStringMap serviceUrlData( QString serviceType );
QgsStringMap serviceUrlData( const QString &serviceType );
%Docstring
Obtain map of layer name and url for a service type
:rtype: QgsStringMap
%End

Expand Down
26 changes: 12 additions & 14 deletions src/core/geonode/qgsgeonodeconnection.cpp
Expand Up @@ -28,23 +28,21 @@ QgsGeoNodeConnection::QgsGeoNodeConnection( const QString &connName )


// settings.Section
QString key = "qgis/connections-geonode/" + mConnName;
QString credentialsKey = "qgis/geonode/" + mConnName;
QString key = sPathGeoNodeConnection + QStringLiteral( "/" ) + mConnName;
QString credentialsKey = sPathGeoNodeConnectionDetails + QStringLiteral( "/" ) + mConnName;

QStringList connStringParts;

mUri.setParam( QStringLiteral( "url" ), settings.value( key + "/url", "", QgsSettings::Providers ).toString() );
mUri.setParam( QStringLiteral( "url" ), settings.value( key + QStringLiteral( "/url" ), QString(), QgsSettings::Providers ).toString() );

// Check for credentials and prepend to the connection info
QString username = settings.value( credentialsKey + "/username", "", QgsSettings::Providers ).toString();
QString password = settings.value( credentialsKey + "/password", "", QgsSettings::Providers ).toString();
QString username = settings.value( credentialsKey + QStringLiteral( "/username" ), QString(), QgsSettings::Providers ).toString();
QString password = settings.value( credentialsKey + QStringLiteral( "/password" ), QString(), QgsSettings::Providers ).toString();
if ( !username.isEmpty() )
{
mUri.setParam( QStringLiteral( "username" ), username );
mUri.setParam( QStringLiteral( "password" ), password );
}

QString authcfg = settings.value( credentialsKey + "/authcfg", "", QgsSettings::Providers ).toString();
QString authcfg = settings.value( credentialsKey + QStringLiteral( "/authcfg" ), QString(), QgsSettings::Providers ).toString();
if ( !authcfg.isEmpty() )
{
mUri.setParam( QStringLiteral( "authcfg" ), authcfg );
Expand All @@ -58,7 +56,7 @@ QgsGeoNodeConnection::~QgsGeoNodeConnection()

}

QgsDataSourceUri QgsGeoNodeConnection::uri()
QgsDataSourceUri QgsGeoNodeConnection::uri() const
{
return mUri;
}
Expand All @@ -67,28 +65,28 @@ QStringList QgsGeoNodeConnection::connectionList()
{
QgsSettings settings;
// Add Section manually
settings.beginGroup( "providers/qgis/connections-geonode" );
settings.beginGroup( QStringLiteral( "providers/qgis/connections-geonode" ) );
return settings.childGroups();
}

void QgsGeoNodeConnection::deleteConnection( const QString &name )
{
QgsSettings settings;
// Add Section manually
settings.remove( "providers/qgis/connections-geonode/" + name );
settings.remove( "providers/qgis/geonode/" + name );
settings.remove( QStringLiteral( "providers/qgis/connections-geonode/" ) + name );
settings.remove( QStringLiteral( "providers/qgis/geonode/" ) + name );
}

QString QgsGeoNodeConnection::selectedConnection()
{
QgsSettings settings;
return settings.value( "qgis/connections-geonode/selected", "", QgsSettings::Providers ).toString();
return settings.value( QStringLiteral( "qgis/connections-geonode/selected" ), QString(), QgsSettings::Providers ).toString();
}

void QgsGeoNodeConnection::setSelectedConnection( const QString &name )
{
QgsSettings settings;
settings.setValue( "qgis/connections-geonode/selected", name, QgsSettings::Providers );
settings.setValue( QStringLiteral( "qgis/connections-geonode/selected" ), name, QgsSettings::Providers );
}

QString QgsGeoNodeConnection::pathGeoNodeConnection()
Expand Down
2 changes: 1 addition & 1 deletion src/core/geonode/qgsgeonodeconnection.h
Expand Up @@ -37,7 +37,7 @@ class CORE_EXPORT QgsGeoNodeConnection : public QObject
QString connName() const;
void setConnName( const QString &connName );

QgsDataSourceUri uri();
QgsDataSourceUri uri() const;
void setUri( const QgsDataSourceUri &uri );

//! Retrieve all geonode connection
Expand Down

0 comments on commit 5b092ae

Please sign in to comment.