Skip to content
Permalink
Browse files

Performance optimizations

- avoid container detachments
- use QStringLiteral
  • Loading branch information
nyalldawson committed Sep 5, 2017
1 parent b1745b0 commit 5b092aeb8d654dd75bce5415b43560e8543afec6
@@ -36,7 +36,7 @@ Destructor
%End
void setConnName( const QString &connName );

QgsDataSourceUri uri();
QgsDataSourceUri uri() const;
%Docstring
:rtype: QgsDataSourceUri
%End
@@ -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
@@ -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

@@ -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 );
@@ -58,7 +56,7 @@ QgsGeoNodeConnection::~QgsGeoNodeConnection()

}

QgsDataSourceUri QgsGeoNodeConnection::uri()
QgsDataSourceUri QgsGeoNodeConnection::uri() const
{
return mUri;
}
@@ -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()
@@ -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

0 comments on commit 5b092ae

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