Skip to content
Permalink
Browse files

Split QgsGeoNodeConnection into two classes

Move utility functions to QgsGeoNodeConnectionUtils
  • Loading branch information
nyalldawson committed Sep 5, 2017
1 parent b7683f2 commit 378a9e90dd3a521e2c0451f30876468790cf557d
@@ -284,8 +284,6 @@
%Include fieldformatter/qgsrelationreferencefieldformatter.sip
%Include fieldformatter/qgsvaluemapfieldformatter.sip
%Include fieldformatter/qgsvaluerelationfieldformatter.sip
%Include geonode/qgsgeonodeconnection.sip
%Include geonode/qgsgeonoderequest.sip
%Include gps/qgsqtlocationconnection.sip
%Include gps/qgsgpsconnectionregistry.sip
%Include qgsapplication.sip
@@ -384,6 +382,7 @@
%Include raster/qgsrasterdataprovider.sip
%Include raster/qgsrasterinterface.sip
%Include geometry/qgspoint.sip
%Include geonode/qgsgeonoderequest.sip
%Include gps/qgsgpsconnection.sip
%Include gps/qgsgpsdetector.sip
%Include gps/qgsnmeaconnection.sip
@@ -1,86 +0,0 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/geonode/qgsgeonodeconnection.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsGeoNodeConnection
{
%Docstring
!
GeoNode Connections management
%End

%TypeHeaderCode
#include "qgsgeonodeconnection.h"
%End
public:
explicit QgsGeoNodeConnection( const QString &connName );
%Docstring
Constructor
%End

~QgsGeoNodeConnection();
%Docstring
Destructor
%End

QString connName() const;
%Docstring
:rtype: str
%End
void setConnName( const QString &connName );

QgsDataSourceUri uri() const;
%Docstring
:rtype: QgsDataSourceUri
%End
void setUri( const QgsDataSourceUri &uri );

static QStringList connectionList();
%Docstring
Retrieve all geonode connection
:rtype: list of str
%End

static void deleteConnection( const QString &name );
%Docstring
Delete connection with name, name
%End

static QString selectedConnection();
%Docstring
Get selected connection
:rtype: str
%End

static void setSelectedConnection( const QString &name );
%Docstring
Set selected connection
%End

static QString pathGeoNodeConnection();
%Docstring
:rtype: str
%End

static QString pathGeoNodeConnectionDetails();
%Docstring
:rtype: str
%End

};


/************************************************************************
* This file has been generated automatically from *
* *
* src/core/geonode/qgsgeonodeconnection.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -257,6 +257,8 @@ Create path component replacing path separators
:rtype: str
%End

void setActions( QList<QAction *> actions );

static void deleteLater( QVector<QgsDataItem *> &items );

void moveToThread( QThread *targetThread );
@@ -18,18 +18,17 @@
#include "qgslogger.h"
#include "qgsdatasourceuri.h"

const QString QgsGeoNodeConnection::sPathGeoNodeConnection = "qgis/connections-geonode";
const QString QgsGeoNodeConnection::sPathGeoNodeConnectionDetails = "qgis/GeoNode";
const QString QgsGeoNodeConnectionUtils::sPathGeoNodeConnection = "qgis/connections-geonode";
const QString QgsGeoNodeConnectionUtils::sPathGeoNodeConnectionDetails = "qgis/GeoNode";

QgsGeoNodeConnection::QgsGeoNodeConnection( const QString &connName )
: mConnName( connName )
{
QgsSettings settings;


// settings.Section
QString key = sPathGeoNodeConnection + QStringLiteral( "/" ) + mConnName;
QString credentialsKey = sPathGeoNodeConnectionDetails + QStringLiteral( "/" ) + mConnName;
QString key = QgsGeoNodeConnectionUtils::pathGeoNodeConnection() + QStringLiteral( "/" ) + mConnName;
QString credentialsKey = QgsGeoNodeConnectionUtils::pathGeoNodeConnectionDetails() + QStringLiteral( "/" ) + mConnName;

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

@@ -61,55 +60,61 @@ QgsDataSourceUri QgsGeoNodeConnection::uri() const
return mUri;
}

QStringList QgsGeoNodeConnection::connectionList()
QString QgsGeoNodeConnection::connName() const
{
return mConnName;
}

void QgsGeoNodeConnection::setConnName( const QString &connName )
{
mConnName = connName;
}

void QgsGeoNodeConnection::setUri( const QgsDataSourceUri &uri )
{
mUri = uri;
}


//
// QgsGeoNodeConnectionUtils
//


QStringList QgsGeoNodeConnectionUtils::connectionList()
{
QgsSettings settings;
// Add Section manually
settings.beginGroup( QStringLiteral( "providers/qgis/connections-geonode" ) );
return settings.childGroups();
}

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

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

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

QString QgsGeoNodeConnection::pathGeoNodeConnection()
QString QgsGeoNodeConnectionUtils::pathGeoNodeConnection()
{
return sPathGeoNodeConnection;
}

QString QgsGeoNodeConnection::pathGeoNodeConnectionDetails()
QString QgsGeoNodeConnectionUtils::pathGeoNodeConnectionDetails()
{
return sPathGeoNodeConnectionDetails;
}

QString QgsGeoNodeConnection::connName() const
{
return mConnName;
}

void QgsGeoNodeConnection::setConnName( const QString &connName )
{
mConnName = connName;
}

void QgsGeoNodeConnection::setUri( const QgsDataSourceUri &uri )
{
mUri = uri;
}
@@ -19,9 +19,10 @@
#include "qgis_core.h"
#include "qgsdatasourceuri.h"

SIP_NO_FILE

/*!
* \brief GeoNode Connections management
* \brief GeoNode Connections management
*/
class CORE_EXPORT QgsGeoNodeConnection
{
@@ -39,6 +40,19 @@ class CORE_EXPORT QgsGeoNodeConnection
QgsDataSourceUri uri() const;
void setUri( const QgsDataSourceUri &uri );

private:

//! The connection name
QString mConnName;

//! Property of mUri
QgsDataSourceUri mUri;
};

class CORE_EXPORT QgsGeoNodeConnectionUtils
{
public:

//! Retrieve all geonode connection
static QStringList connectionList();

@@ -56,15 +70,11 @@ class CORE_EXPORT QgsGeoNodeConnection
static QString pathGeoNodeConnectionDetails();

private:

// Path in QSetting
static const QString sPathGeoNodeConnection;
static const QString sPathGeoNodeConnectionDetails;

//! The connection name
QString mConnName;

//! Property of mUri
QgsDataSourceUri mUri;
};


@@ -33,8 +33,8 @@ QgsGeoNodeNewConnection::QgsGeoNodeNewConnection( QWidget *parent, const QString
{
setupUi( this );

mBaseKey = QgsGeoNodeConnection::pathGeoNodeConnection();
mCredentialsBaseKey = QgsGeoNodeConnection::pathGeoNodeConnection();
mBaseKey = QgsGeoNodeConnectionUtils::pathGeoNodeConnection();
mCredentialsBaseKey = QgsGeoNodeConnectionUtils::pathGeoNodeConnection();

mAuthConfigSelect = new QgsAuthConfigSelect( this );
tabAuth->insertTab( 1, mAuthConfigSelect, tr( "Configurations" ) );
@@ -118,7 +118,7 @@ void QgsGeoNodeSourceSelect::deleteConnectionsEntryList()
QMessageBox::StandardButton result = QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
if ( result == QMessageBox::Ok )
{
QgsGeoNodeConnection::deleteConnection( cmbConnections->currentText() );
QgsGeoNodeConnectionUtils::deleteConnection( cmbConnections->currentText() );
cmbConnections->removeItem( cmbConnections->currentIndex() );
if ( mModel )
{
@@ -148,14 +148,14 @@ void QgsGeoNodeSourceSelect::deleteConnectionsEntryList()
void QgsGeoNodeSourceSelect::populateConnectionList()
{
cmbConnections->clear();
cmbConnections->addItems( QgsGeoNodeConnection::connectionList() );
cmbConnections->addItems( QgsGeoNodeConnectionUtils::connectionList() );

setConnectionListPosition();
}

void QgsGeoNodeSourceSelect::setConnectionListPosition()
{
QString toSelect = QgsGeoNodeConnection::selectedConnection();
QString toSelect = QgsGeoNodeConnectionUtils::selectedConnection();

cmbConnections->setCurrentIndex( cmbConnections->findText( toSelect ) );

@@ -229,7 +229,7 @@ QVector<QgsDataItem *> QgsGeoNodeRootItem::createChildren()
{
QVector<QgsDataItem *> connections;

Q_FOREACH ( const QString &connName, QgsGeoNodeConnection::connectionList() )
Q_FOREACH ( const QString &connName, QgsGeoNodeConnectionUtils::connectionList() )
{
QgsGeoNodeConnection *connection = nullptr;
connection = new QgsGeoNodeConnection( connName );
@@ -270,7 +270,7 @@ QgsDataItem *QgsGeoNodeDataItemProvider::createDataItem( const QString &path, Qg
if ( path.startsWith( QLatin1String( "geonode:/" ) ) )
{
QString connectionName = path.split( '/' ).last();
if ( QgsGeoNodeConnection::connectionList().contains( connectionName ) )
if ( QgsGeoNodeConnectionUtils::connectionList().contains( connectionName ) )
{
QgsGeoNodeConnection *connection = new QgsGeoNodeConnection( connectionName );
return new QgsGeoNodeConnectionItem( parentItem, QStringLiteral( "GeoNode" ), path, connection );
@@ -36,7 +36,7 @@ class QgsGeoNodeConnectionItem : public QgsDataCollectionItem
void editConnection();
void deleteConnection()
{
QgsGeoNodeConnection::deleteConnection( name() );
QgsGeoNodeConnectionUtils::deleteConnection( name() );
mParent->refresh();
};

@@ -220,7 +220,7 @@ QgsDataItem *QgsWfsDataItemProvider::createDataItem( const QString &path, QgsDat
else if ( path.startsWith( QLatin1String( "geonode:/" ) ) )
{
QString connectionName = path.split( '/' ).last();
if ( QgsGeoNodeConnection::connectionList().contains( connectionName ) )
if ( QgsGeoNodeConnectionUtils::connectionList().contains( connectionName ) )
{
QgsGeoNodeConnection connection( connectionName );

@@ -244,7 +244,7 @@ QVector<QgsDataItem *> QgsWfsDataItemProvider::createDataItems( const QString &p
if ( path.startsWith( QLatin1String( "geonode:/" ) ) )
{
QString connectionName = path.split( '/' ).last();
if ( QgsGeoNodeConnection::connectionList().contains( connectionName ) )
if ( QgsGeoNodeConnectionUtils::connectionList().contains( connectionName ) )
{
QgsGeoNodeConnection connection( connectionName );

@@ -559,7 +559,7 @@ QVector<QgsDataItem *> QgsWmsDataItemProvider::createDataItems( const QString &p
if ( path.startsWith( QLatin1String( "geonode:/" ) ) )
{
QString connectionName = path.split( '/' ).last();
if ( QgsGeoNodeConnection::connectionList().contains( connectionName ) )
if ( QgsGeoNodeConnectionUtils::connectionList().contains( connectionName ) )
{
QgsGeoNodeConnection connection( connectionName );

@@ -575,7 +575,7 @@ QVector<QgsDataItem *> QgsWmsDataItemProvider::createDataItems( const QString &p
QgsDebugMsg( encodedUri );
QgsDataSourceUri uri;
QgsSettings settings;
QString key( connection.pathGeoNodeConnection() + "/" + connectionName );
QString key( QgsGeoNodeConnectionUtils::pathGeoNodeConnection() + "/" + connectionName );

QString dpiMode = settings.value( key + "/wms/dpiMode", "all", QgsSettings::Providers ).toString();
uri.setParam( QStringLiteral( "url" ), encodedUri );
@@ -605,7 +605,7 @@ QVector<QgsDataItem *> QgsXyzTileDataItemProvider::createDataItems( const QStrin
if ( path.startsWith( QLatin1String( "geonode:/" ) ) )
{
QString connectionName = path.split( '/' ).last();
if ( QgsGeoNodeConnection::connectionList().contains( connectionName ) )
if ( QgsGeoNodeConnectionUtils::connectionList().contains( connectionName ) )
{
QgsGeoNodeConnection connection( connectionName );

0 comments on commit 378a9e9

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