mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Split QgsGeoNodeConnection into two classes
Move utility functions to QgsGeoNodeConnectionUtils
This commit is contained in:
parent
b7683f209e
commit
378a9e90dd
@ -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,44 +60,6 @@ QgsDataSourceUri QgsGeoNodeConnection::uri() const
|
||||
return mUri;
|
||||
}
|
||||
|
||||
QStringList QgsGeoNodeConnection::connectionList()
|
||||
{
|
||||
QgsSettings settings;
|
||||
// Add Section manually
|
||||
settings.beginGroup( QStringLiteral( "providers/qgis/connections-geonode" ) );
|
||||
return settings.childGroups();
|
||||
}
|
||||
|
||||
void QgsGeoNodeConnection::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()
|
||||
{
|
||||
QgsSettings settings;
|
||||
return settings.value( QStringLiteral( "qgis/connections-geonode/selected" ), QString(), QgsSettings::Providers ).toString();
|
||||
}
|
||||
|
||||
void QgsGeoNodeConnection::setSelectedConnection( const QString &name )
|
||||
{
|
||||
QgsSettings settings;
|
||||
settings.setValue( QStringLiteral( "qgis/connections-geonode/selected" ), name, QgsSettings::Providers );
|
||||
}
|
||||
|
||||
QString QgsGeoNodeConnection::pathGeoNodeConnection()
|
||||
{
|
||||
return sPathGeoNodeConnection;
|
||||
}
|
||||
|
||||
QString QgsGeoNodeConnection::pathGeoNodeConnectionDetails()
|
||||
{
|
||||
return sPathGeoNodeConnectionDetails;
|
||||
}
|
||||
|
||||
QString QgsGeoNodeConnection::connName() const
|
||||
{
|
||||
return mConnName;
|
||||
@ -113,3 +74,47 @@ 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 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 QgsGeoNodeConnectionUtils::selectedConnection()
|
||||
{
|
||||
QgsSettings settings;
|
||||
return settings.value( QStringLiteral( "qgis/connections-geonode/selected" ), QString(), QgsSettings::Providers ).toString();
|
||||
}
|
||||
|
||||
void QgsGeoNodeConnectionUtils::setSelectedConnection( const QString &name )
|
||||
{
|
||||
QgsSettings settings;
|
||||
settings.setValue( QStringLiteral( "qgis/connections-geonode/selected" ), name, QgsSettings::Providers );
|
||||
}
|
||||
|
||||
QString QgsGeoNodeConnectionUtils::pathGeoNodeConnection()
|
||||
{
|
||||
return sPathGeoNodeConnection;
|
||||
}
|
||||
|
||||
QString QgsGeoNodeConnectionUtils::pathGeoNodeConnectionDetails()
|
||||
{
|
||||
return sPathGeoNodeConnectionDetails;
|
||||
}
|
||||
|
@ -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 );
|
||||
|
||||
|
@ -35,9 +35,9 @@ class TestQgsGeoNodeConnection: public QObject
|
||||
// will be called after the last testfunction was executed.
|
||||
void cleanupTestCase()
|
||||
{
|
||||
QgsGeoNodeConnection::deleteConnection( mGeoNodeConnectionName );
|
||||
QgsGeoNodeConnection::deleteConnection( mDemoGeoNodeName );
|
||||
QgsGeoNodeConnection::deleteConnection( mKartozaGeoNodeQGISServerName );
|
||||
QgsGeoNodeConnectionUtils::deleteConnection( mGeoNodeConnectionName );
|
||||
QgsGeoNodeConnectionUtils::deleteConnection( mDemoGeoNodeName );
|
||||
QgsGeoNodeConnectionUtils::deleteConnection( mKartozaGeoNodeQGISServerName );
|
||||
}
|
||||
// will be called before each testfunction is executed.
|
||||
void init() {}
|
||||
@ -89,11 +89,11 @@ void TestQgsGeoNodeConnection::initTestCase()
|
||||
QgsSettings settings;
|
||||
|
||||
// Testing real server, demo.geonode.org. Need to be changed later.
|
||||
settings.setValue( QgsGeoNodeConnection::pathGeoNodeConnection() + QStringLiteral( "/%1/url" ).arg( mDemoGeoNodeName ), mDemoGeoNodeURL, QgsSettings::Providers );
|
||||
settings.setValue( QgsGeoNodeConnectionUtils::pathGeoNodeConnection() + QStringLiteral( "/%1/url" ).arg( mDemoGeoNodeName ), mDemoGeoNodeURL, QgsSettings::Providers );
|
||||
// Testing real server, staging.geonode.kartoza.com. Need to be changed later.
|
||||
settings.setValue( QgsGeoNodeConnection::pathGeoNodeConnection() + QStringLiteral( "/%1/url" ).arg( mKartozaGeoNodeQGISServerName ), mKartozaGeoNodeQGISServerURL, QgsSettings::Providers );
|
||||
settings.setValue( QgsGeoNodeConnectionUtils::pathGeoNodeConnection() + QStringLiteral( "/%1/url" ).arg( mKartozaGeoNodeQGISServerName ), mKartozaGeoNodeQGISServerURL, QgsSettings::Providers );
|
||||
// Testing real server, staginggs.geonode.kartoza.com. Need to be changed later.
|
||||
settings.setValue( QgsGeoNodeConnection::pathGeoNodeConnection() + QStringLiteral( "/%1/url" ).arg( mKartozaGeoNodeGeoServerName ), mKartozaGeoNodeGeoServerURL, QgsSettings::Providers );
|
||||
settings.setValue( QgsGeoNodeConnectionUtils::pathGeoNodeConnection() + QStringLiteral( "/%1/url" ).arg( mKartozaGeoNodeGeoServerName ), mKartozaGeoNodeGeoServerURL, QgsSettings::Providers );
|
||||
}
|
||||
|
||||
// Test the creation of geonode connection
|
||||
@ -104,7 +104,7 @@ void TestQgsGeoNodeConnection::testCreation()
|
||||
QSKIP( "Skip remote test for faster testing" );
|
||||
}
|
||||
|
||||
QStringList connectionList = QgsGeoNodeConnection::connectionList();
|
||||
QStringList connectionList = QgsGeoNodeConnectionUtils::connectionList();
|
||||
int numberOfConnection = connectionList.count();
|
||||
// Verify if the demo.geonode.org is created properly
|
||||
QVERIFY( connectionList.contains( mDemoGeoNodeName ) );
|
||||
@ -113,9 +113,9 @@ void TestQgsGeoNodeConnection::testCreation()
|
||||
// Add new GeoNode Connection
|
||||
QgsSettings settings;
|
||||
|
||||
settings.setValue( QgsGeoNodeConnection::pathGeoNodeConnection() + QStringLiteral( "/%1/url" ).arg( mGeoNodeConnectionName ), mGeoNodeConnectionURL, QgsSettings::Providers );
|
||||
settings.setValue( QgsGeoNodeConnectionUtils::pathGeoNodeConnection() + QStringLiteral( "/%1/url" ).arg( mGeoNodeConnectionName ), mGeoNodeConnectionURL, QgsSettings::Providers );
|
||||
|
||||
QStringList newConnectionList = QgsGeoNodeConnection::connectionList();
|
||||
QStringList newConnectionList = QgsGeoNodeConnectionUtils::connectionList();
|
||||
int newNumberOfConnection = newConnectionList.count();
|
||||
|
||||
// Check the number is increased by 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user