Skip to content
Permalink
Browse files
Cleanup and add docs for QgsGeoNodeConnection
  • Loading branch information
nyalldawson committed Sep 12, 2017
1 parent e1562df commit e254368
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 54 deletions.
@@ -284,6 +284,7 @@
%Include fieldformatter/qgsrelationreferencefieldformatter.sip
%Include fieldformatter/qgsvaluemapfieldformatter.sip
%Include fieldformatter/qgsvaluerelationfieldformatter.sip
%Include geocms/geonode/qgsgeonodeconnection.sip
%Include gps/qgsqtlocationconnection.sip
%Include gps/qgsgpsconnectionregistry.sip
%Include qgsapplication.sip
@@ -0,0 +1,101 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/geocms/geonode/qgsgeonodeconnection.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/



class QgsGeoNodeConnection
{
%Docstring
Encapsulates settings related to a single GeoNode connection.
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgsgeonodeconnection.h"
%End
public:

explicit QgsGeoNodeConnection( const QString &name );
%Docstring
Constructor for a QgsGeoNodeConnection with the specified ``name``.
%End

QString connectionName() const;
%Docstring
Returns the name of the connection.
.. seealso:: setConnectionName()
:rtype: str
%End

void setConnectionName( const QString &connectionName );
%Docstring
Sets the ``name`` of the connection.
.. seealso:: connectionName()
%End

QgsDataSourceUri uri() const;
%Docstring
Returns the URI for the GeoNode connection.
.. seealso:: setUri()
:rtype: QgsDataSourceUri
%End

void setUri( const QgsDataSourceUri &uri );
%Docstring
Sets the ``uri`` for the GeoNode connection.
.. seealso:: uri()
%End

};

class QgsGeoNodeConnectionUtils
{
%Docstring
Contains various utilities for managing the known collection of
GeoNode servers associated with a QGIS install.
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgsgeonodeconnection.h"
%End
public:

static QStringList connectionList();
%Docstring
Returns a list of all known GeoNode connection names.
:rtype: list of str
%End

static void deleteConnection( const QString &name );
%Docstring
Deletes the GeoNode connection with matcing ``name``.
%End

static QString pathGeoNodeConnection();
%Docstring
Returns the base path for settings related to GeoNode connections.
:rtype: str
%End

static QString pathGeoNodeConnectionDetails();
%Docstring
Returns the base path for settings related to GeoNode connection details.
:rtype: str
%End

};


/************************************************************************
* This file has been generated automatically from *
* *
* src/core/geocms/geonode/qgsgeonodeconnection.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -77,7 +77,7 @@ QList<QAction *> QgsGeoNodeConnectionItem::actions()

void QgsGeoNodeConnectionItem::editConnection()
{
QgsGeoNodeNewConnection nc( nullptr, mConnection->connName() );
QgsGeoNodeNewConnection nc( nullptr, mConnection->connectionName() );
nc.setWindowTitle( tr( "Modify GeoNode connection" ) );

if ( nc.exec() )
@@ -89,7 +89,7 @@ void QgsGeoNodeConnectionItem::editConnection()

QgsGeoNodeServiceItem::QgsGeoNodeServiceItem( QgsDataItem *parent, QgsGeoNodeConnection *conn, QString serviceName, QString path )
: QgsDataCollectionItem( parent, serviceName, path )
, mName( conn->connName() )
, mName( conn->connectionName() )
, mServiceName( serviceName )
, mConnection( conn )
{
@@ -127,6 +127,11 @@ QgsGeoNodeNewConnection::QgsGeoNodeNewConnection( QWidget *parent, const QString
connect( btnConnect, &QPushButton::clicked, this, &QgsGeoNodeNewConnection::testConnection );
}

QString QgsGeoNodeNewConnection::name() const
{
return txtName->text();
}

void QgsGeoNodeNewConnection::accept()
{
QgsSettings settings;
@@ -30,6 +30,9 @@ class QgsGeoNodeNewConnection : public QDialog, private Ui::QgsNewGeoNodeConnect
//! Constructor
QgsGeoNodeNewConnection( QWidget *parent = nullptr, const QString &connName = QString::null, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );

//! Returns the new connection name
QString name() const;

public slots:
void accept() override;
void okButtonBehavior( const QString & );
@@ -83,7 +83,7 @@ void QgsGeoNodeSourceSelect::addConnectionsEntryList()

if ( nc.exec() )
{
populateConnectionList();
populateConnectionList( nc.name() );
emit connectionsChanged();
}
}
@@ -95,7 +95,7 @@ void QgsGeoNodeSourceSelect::modifyConnectionsEntryList()

if ( nc.exec() )
{
populateConnectionList();
populateConnectionList( nc.name() );
emit connectionsChanged();
}
}
@@ -119,23 +119,21 @@ void QgsGeoNodeSourceSelect::deleteConnectionsEntryList()
}
}

void QgsGeoNodeSourceSelect::populateConnectionList()
void QgsGeoNodeSourceSelect::populateConnectionList( const QString &selectedConnectionName )
{
cmbConnections->clear();
cmbConnections->addItems( QgsGeoNodeConnectionUtils::connectionList() );

setConnectionListPosition();
setConnectionListPosition( selectedConnectionName );
}

void QgsGeoNodeSourceSelect::setConnectionListPosition()
void QgsGeoNodeSourceSelect::setConnectionListPosition( const QString &selectedConnectionName )
{
QString toSelect = QgsGeoNodeConnectionUtils::selectedConnection();

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

if ( cmbConnections->currentIndex() < 0 )
{
if ( toSelect.isNull() )
if ( selectedConnectionName.isEmpty() )
cmbConnections->setCurrentIndex( 0 );
else
cmbConnections->setCurrentIndex( cmbConnections->count() - 1 );
@@ -76,8 +76,8 @@ class QgsGeoNodeSourceSelect: public QgsAbstractDataSourceWidget, private Ui::Qg
void loadGeonodeConnection();
void filterChanged( const QString &text );
void treeViewSelectionChanged();
void populateConnectionList();
void setConnectionListPosition();
void populateConnectionList( const QString &selectedConnectionName = QString() );
void setConnectionListPosition( const QString &selectedConnectionName = QString() );
void showHelp();

};
@@ -21,8 +21,8 @@
const QString QgsGeoNodeConnectionUtils::sPathGeoNodeConnection = "qgis/connections-geonode";
const QString QgsGeoNodeConnectionUtils::sPathGeoNodeConnectionDetails = "qgis/GeoNode";

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

@@ -50,22 +50,17 @@ QgsGeoNodeConnection::QgsGeoNodeConnection( const QString &connName )
QgsDebugMsg( QString( "encodedUri: '%1'." ).arg( QString( mUri.encodedUri() ) ) );
}

QgsGeoNodeConnection::~QgsGeoNodeConnection()
{

}

QgsDataSourceUri QgsGeoNodeConnection::uri() const
{
return mUri;
}

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

void QgsGeoNodeConnection::setConnName( const QString &connName )
void QgsGeoNodeConnection::setConnectionName( const QString &connName )
{
mConnName = connName;
}
@@ -97,18 +92,6 @@ void QgsGeoNodeConnectionUtils::deleteConnection( const QString &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;
@@ -19,25 +19,44 @@
#include "qgis_core.h"
#include "qgsdatasourceuri.h"

SIP_NO_FILE

/*!
* \brief GeoNode Connections management
/**
* \ingroup core
* \class QgsGeoNodeConnection
* \brief Encapsulates settings related to a single GeoNode connection.
* \since QGIS 3.0
*/
class CORE_EXPORT QgsGeoNodeConnection
{

public:
//! Constructor
explicit QgsGeoNodeConnection( const QString &connName );

//! Destructor
~QgsGeoNodeConnection();

QString connName() const;
void setConnName( const QString &connName );

/**
* Constructor for a QgsGeoNodeConnection with the specified \a name.
*/
explicit QgsGeoNodeConnection( const QString &name );

/**
* Returns the name of the connection.
* \see setConnectionName()
*/
QString connectionName() const;

/**
* Sets the \a name of the connection.
* \see connectionName()
*/
void setConnectionName( const QString &connectionName );

/**
* Returns the URI for the GeoNode connection.
* \see setUri()
*/
QgsDataSourceUri uri() const;

/**
* Sets the \a uri for the GeoNode connection.
* \see uri()
*/
void setUri( const QgsDataSourceUri &uri );

private:
@@ -49,24 +68,35 @@ class CORE_EXPORT QgsGeoNodeConnection
QgsDataSourceUri mUri;
};

/**
* \ingroup core
* \class QgsGeoNodeConnectionUtils
* \brief Contains various utilities for managing the known collection of
* GeoNode servers associated with a QGIS install.
* \since QGIS 3.0
*/
class CORE_EXPORT QgsGeoNodeConnectionUtils
{
public:

//! Retrieve all geonode connection
/**
* Returns a list of all known GeoNode connection names.
*/
static QStringList connectionList();

//! Delete connection with name, name
/**
* Deletes the GeoNode connection with matcing \a name.
*/
static void deleteConnection( const QString &name );

//! Get selected connection
static QString selectedConnection();

//! Set selected connection
static void setSelectedConnection( const QString &name );

/**
* Returns the base path for settings related to GeoNode connections.
*/
static QString pathGeoNodeConnection();

/**
* Returns the base path for settings related to GeoNode connection details.
*/
static QString pathGeoNodeConnectionDetails();

private:

0 comments on commit e254368

Please sign in to comment.