QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsgeonodeconnection.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsgeonodeconnection.cpp
3 ---------------------
4 begin : Feb 2017
5 copyright : (C) 2017 by Muhammad Yarjuna Rohmat, Ismail Sunni
6 email : rohmat at kartoza dot com, ismail at kartoza dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include "qgssettings.h"
18#include "qgslogger.h"
19#include "qgsdatasourceuri.h"
20#include "qgsowsconnection.h"
21
22const QString QgsGeoNodeConnectionUtils::sGeoNodeConnection = QStringLiteral( "GEONODE" );
23
25 : mConnName( name )
26{
27 mUri.setParam( QStringLiteral( "url" ), QgsOwsConnection::settingsConnectionUrl.value( {QgsGeoNodeConnectionUtils::sGeoNodeConnection.toLower(), mConnName} ) );
28
29 // Check for credentials and prepend to the connection info
32 if ( !username.isEmpty() )
33 {
34 mUri.setUsername( username );
35 mUri.setPassword( password );
36 }
37
39 if ( !authcfg.isEmpty() )
40 {
41 mUri.setAuthConfigId( authcfg );
42 }
43
44 QgsDebugMsgLevel( QStringLiteral( "encodedUri: '%1'." ).arg( QString( mUri.encodedUri() ) ), 4 );
45}
46
48{
49 return mUri;
50}
51
53{
54 return mConnName;
55}
56
57void QgsGeoNodeConnection::setConnectionName( const QString &connName )
58{
59 mConnName = connName;
60}
61
63{
64 mUri = uri;
65}
66
68{
69 QString detailedConnectionName = QStringLiteral( "%1/wms" ).arg( mConnName );
71}
72
74{
75 QString detailedConnectionName = QStringLiteral( "%1/wfs" ).arg( mConnName );
77}
78
80{
81 QString detailedConnectionName = QStringLiteral( "%1/wcs" ).arg( mConnName );
83}
84
85//
86// QgsGeoNodeConnectionUtils
87//
88
89
91{
92 QgsSettings settings;
93 // Add Section manually
94 settings.beginGroup( QStringLiteral( "qgis/connections-geonode" ) );
95 return settings.childGroups();
96}
97
99{
101}
102
104{
105 return QStringLiteral( "qgis/connections-%1" ).arg( sGeoNodeConnection.toLower() );
106}
107
109{
110 return QStringLiteral( "qgis/%1" ).arg( sGeoNodeConnection );
111}
Class for storing the component parts of a RDBMS data source URI (e.g.
QByteArray encodedUri() const
Returns the complete encoded URI as a byte array.
void setAuthConfigId(const QString &authcfg)
Sets the authentication configuration ID for the URI.
void setUsername(const QString &username)
Sets the username for the URI.
void setParam(const QString &key, const QString &value)
Sets a generic parameter value on the URI.
void setPassword(const QString &password)
Sets the password for the URI.
static Q_DECL_DEPRECATED QString pathGeoNodeConnectionDetails()
Returns the base path for settings related to GeoNode connection details.
static void deleteConnection(const QString &name)
Deletes the GeoNode connection with matching name.
static const QString sGeoNodeConnection
static QString pathGeoNodeConnection()
Returns the base path for settings related to GeoNode connections.
static QStringList connectionList()
Returns a list of all known GeoNode connection names.
void setUri(const QgsDataSourceUri &uri)
Sets the uri for the GeoNode connection.
QgsDataSourceUri & addWmsConnectionSettings(QgsDataSourceUri &uri) const
Adds uri parameters relating to the settings for a WMS layer on the connection to a QgsDataSourceUri ...
void setConnectionName(const QString &connectionName)
Sets the name of the connection.
QgsDataSourceUri & addWcsConnectionSettings(QgsDataSourceUri &uri) const
Adds uri parameters relating to the settings for a WCS layer on the connection to a QgsDataSourceUri ...
QString connectionName() const
Returns the name of the connection.
QgsDataSourceUri & addWfsConnectionSettings(QgsDataSourceUri &uri) const
Adds uri parameters relating to the settings for a WFS layer on the connection to a QgsDataSourceUri ...
QgsDataSourceUri uri() const
Returns the URI for the GeoNode connection.
QgsGeoNodeConnection(const QString &name)
Constructor for a QgsGeoNodeConnection with the specified name.
static Q_DECL_DEPRECATED QgsDataSourceUri & addWmsWcsConnectionSettings(QgsDataSourceUri &uri, const QString &settingsKey)
Adds uri parameters relating to the settings for a WMS or WCS connection to a QgsDataSourceUri uri.
static const QgsSettingsEntryString settingsConnectionUrl
static const QgsSettingsEntryString settingsConnectionPassword
static const QgsSettingsEntryString settingsConnectionUsername
static void deleteConnection(const QString &service, const QString &name)
Deletes the connection for the specified service with the specified name.
static Q_DECL_DEPRECATED QgsDataSourceUri & addWfsConnectionSettings(QgsDataSourceUri &uri, const QString &settingsKey)
Adds uri parameters relating to the settings for a WFS connection to a QgsDataSourceUri uri.
static const QgsSettingsEntryString settingsConnectionAuthCfg
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
This class is a composition of two QSettings instances:
Definition: qgssettings.h:62
QStringList childGroups() const
Returns a list of all key top-level groups that contain keys that can be read using the QSettings obj...
void beginGroup(const QString &prefix, QgsSettings::Section section=QgsSettings::NoSection)
Appends prefix to the current group.
Definition: qgssettings.cpp:90
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39