Skip to content

Commit 378a9e9

Browse files
committed
Split QgsGeoNodeConnection into two classes
Move utility functions to QgsGeoNodeConnectionUtils
1 parent b7683f2 commit 378a9e9

12 files changed

+72
-142
lines changed

python/core/core_auto.sip

+1-2
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,6 @@
284284
%Include fieldformatter/qgsrelationreferencefieldformatter.sip
285285
%Include fieldformatter/qgsvaluemapfieldformatter.sip
286286
%Include fieldformatter/qgsvaluerelationfieldformatter.sip
287-
%Include geonode/qgsgeonodeconnection.sip
288-
%Include geonode/qgsgeonoderequest.sip
289287
%Include gps/qgsqtlocationconnection.sip
290288
%Include gps/qgsgpsconnectionregistry.sip
291289
%Include qgsapplication.sip
@@ -384,6 +382,7 @@
384382
%Include raster/qgsrasterdataprovider.sip
385383
%Include raster/qgsrasterinterface.sip
386384
%Include geometry/qgspoint.sip
385+
%Include geonode/qgsgeonoderequest.sip
387386
%Include gps/qgsgpsconnection.sip
388387
%Include gps/qgsgpsdetector.sip
389388
%Include gps/qgsnmeaconnection.sip
Original file line numberDiff line numberDiff line change
@@ -1,86 +0,0 @@
1-
/************************************************************************
2-
* This file has been generated automatically from *
3-
* *
4-
* src/core/geonode/qgsgeonodeconnection.h *
5-
* *
6-
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7-
************************************************************************/
8-
9-
10-
11-
12-
class QgsGeoNodeConnection
13-
{
14-
%Docstring
15-
!
16-
GeoNode Connections management
17-
%End
18-
19-
%TypeHeaderCode
20-
#include "qgsgeonodeconnection.h"
21-
%End
22-
public:
23-
explicit QgsGeoNodeConnection( const QString &connName );
24-
%Docstring
25-
Constructor
26-
%End
27-
28-
~QgsGeoNodeConnection();
29-
%Docstring
30-
Destructor
31-
%End
32-
33-
QString connName() const;
34-
%Docstring
35-
:rtype: str
36-
%End
37-
void setConnName( const QString &connName );
38-
39-
QgsDataSourceUri uri() const;
40-
%Docstring
41-
:rtype: QgsDataSourceUri
42-
%End
43-
void setUri( const QgsDataSourceUri &uri );
44-
45-
static QStringList connectionList();
46-
%Docstring
47-
Retrieve all geonode connection
48-
:rtype: list of str
49-
%End
50-
51-
static void deleteConnection( const QString &name );
52-
%Docstring
53-
Delete connection with name, name
54-
%End
55-
56-
static QString selectedConnection();
57-
%Docstring
58-
Get selected connection
59-
:rtype: str
60-
%End
61-
62-
static void setSelectedConnection( const QString &name );
63-
%Docstring
64-
Set selected connection
65-
%End
66-
67-
static QString pathGeoNodeConnection();
68-
%Docstring
69-
:rtype: str
70-
%End
71-
72-
static QString pathGeoNodeConnectionDetails();
73-
%Docstring
74-
:rtype: str
75-
%End
76-
77-
};
78-
79-
80-
/************************************************************************
81-
* This file has been generated automatically from *
82-
* *
83-
* src/core/geonode/qgsgeonodeconnection.h *
84-
* *
85-
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
86-
************************************************************************/

python/core/qgsdataitem.sip

+2
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ Create path component replacing path separators
257257
:rtype: str
258258
%End
259259

260+
void setActions( QList<QAction *> actions );
261+
260262
static void deleteLater( QVector<QgsDataItem *> &items );
261263

262264
void moveToThread( QThread *targetThread );

src/core/geonode/qgsgeonodeconnection.cpp

+31-26
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,17 @@
1818
#include "qgslogger.h"
1919
#include "qgsdatasourceuri.h"
2020

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

2424
QgsGeoNodeConnection::QgsGeoNodeConnection( const QString &connName )
2525
: mConnName( connName )
2626
{
2727
QgsSettings settings;
2828

29-
3029
// settings.Section
31-
QString key = sPathGeoNodeConnection + QStringLiteral( "/" ) + mConnName;
32-
QString credentialsKey = sPathGeoNodeConnectionDetails + QStringLiteral( "/" ) + mConnName;
30+
QString key = QgsGeoNodeConnectionUtils::pathGeoNodeConnection() + QStringLiteral( "/" ) + mConnName;
31+
QString credentialsKey = QgsGeoNodeConnectionUtils::pathGeoNodeConnectionDetails() + QStringLiteral( "/" ) + mConnName;
3332

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

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

64-
QStringList QgsGeoNodeConnection::connectionList()
63+
QString QgsGeoNodeConnection::connName() const
64+
{
65+
return mConnName;
66+
}
67+
68+
void QgsGeoNodeConnection::setConnName( const QString &connName )
69+
{
70+
mConnName = connName;
71+
}
72+
73+
void QgsGeoNodeConnection::setUri( const QgsDataSourceUri &uri )
74+
{
75+
mUri = uri;
76+
}
77+
78+
79+
//
80+
// QgsGeoNodeConnectionUtils
81+
//
82+
83+
84+
QStringList QgsGeoNodeConnectionUtils::connectionList()
6585
{
6686
QgsSettings settings;
6787
// Add Section manually
6888
settings.beginGroup( QStringLiteral( "providers/qgis/connections-geonode" ) );
6989
return settings.childGroups();
7090
}
7191

72-
void QgsGeoNodeConnection::deleteConnection( const QString &name )
92+
void QgsGeoNodeConnectionUtils::deleteConnection( const QString &name )
7393
{
7494
QgsSettings settings;
7595
// Add Section manually
7696
settings.remove( QStringLiteral( "providers/qgis/connections-geonode/" ) + name );
7797
settings.remove( QStringLiteral( "providers/qgis/geonode/" ) + name );
7898
}
7999

80-
QString QgsGeoNodeConnection::selectedConnection()
100+
QString QgsGeoNodeConnectionUtils::selectedConnection()
81101
{
82102
QgsSettings settings;
83103
return settings.value( QStringLiteral( "qgis/connections-geonode/selected" ), QString(), QgsSettings::Providers ).toString();
84104
}
85105

86-
void QgsGeoNodeConnection::setSelectedConnection( const QString &name )
106+
void QgsGeoNodeConnectionUtils::setSelectedConnection( const QString &name )
87107
{
88108
QgsSettings settings;
89109
settings.setValue( QStringLiteral( "qgis/connections-geonode/selected" ), name, QgsSettings::Providers );
90110
}
91111

92-
QString QgsGeoNodeConnection::pathGeoNodeConnection()
112+
QString QgsGeoNodeConnectionUtils::pathGeoNodeConnection()
93113
{
94114
return sPathGeoNodeConnection;
95115
}
96116

97-
QString QgsGeoNodeConnection::pathGeoNodeConnectionDetails()
117+
QString QgsGeoNodeConnectionUtils::pathGeoNodeConnectionDetails()
98118
{
99119
return sPathGeoNodeConnectionDetails;
100120
}
101-
102-
QString QgsGeoNodeConnection::connName() const
103-
{
104-
return mConnName;
105-
}
106-
107-
void QgsGeoNodeConnection::setConnName( const QString &connName )
108-
{
109-
mConnName = connName;
110-
}
111-
112-
void QgsGeoNodeConnection::setUri( const QgsDataSourceUri &uri )
113-
{
114-
mUri = uri;
115-
}

src/core/geonode/qgsgeonodeconnection.h

+16-6
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
#include "qgis_core.h"
2020
#include "qgsdatasourceuri.h"
2121

22+
SIP_NO_FILE
2223

2324
/*!
24-
* \brief GeoNode Connections management
25+
* \brief GeoNode Connections management
2526
*/
2627
class CORE_EXPORT QgsGeoNodeConnection
2728
{
@@ -39,6 +40,19 @@ class CORE_EXPORT QgsGeoNodeConnection
3940
QgsDataSourceUri uri() const;
4041
void setUri( const QgsDataSourceUri &uri );
4142

43+
private:
44+
45+
//! The connection name
46+
QString mConnName;
47+
48+
//! Property of mUri
49+
QgsDataSourceUri mUri;
50+
};
51+
52+
class CORE_EXPORT QgsGeoNodeConnectionUtils
53+
{
54+
public:
55+
4256
//! Retrieve all geonode connection
4357
static QStringList connectionList();
4458

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

5872
private:
73+
5974
// Path in QSetting
6075
static const QString sPathGeoNodeConnection;
6176
static const QString sPathGeoNodeConnectionDetails;
6277

63-
//! The connection name
64-
QString mConnName;
65-
66-
//! Property of mUri
67-
QgsDataSourceUri mUri;
6878
};
6979

7080

src/gui/geonode/qgsgeonodenewconnection.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ QgsGeoNodeNewConnection::QgsGeoNodeNewConnection( QWidget *parent, const QString
3333
{
3434
setupUi( this );
3535

36-
mBaseKey = QgsGeoNodeConnection::pathGeoNodeConnection();
37-
mCredentialsBaseKey = QgsGeoNodeConnection::pathGeoNodeConnection();
36+
mBaseKey = QgsGeoNodeConnectionUtils::pathGeoNodeConnection();
37+
mCredentialsBaseKey = QgsGeoNodeConnectionUtils::pathGeoNodeConnection();
3838

3939
mAuthConfigSelect = new QgsAuthConfigSelect( this );
4040
tabAuth->insertTab( 1, mAuthConfigSelect, tr( "Configurations" ) );

src/gui/geonode/qgsgeonodesourceselect.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void QgsGeoNodeSourceSelect::deleteConnectionsEntryList()
118118
QMessageBox::StandardButton result = QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
119119
if ( result == QMessageBox::Ok )
120120
{
121-
QgsGeoNodeConnection::deleteConnection( cmbConnections->currentText() );
121+
QgsGeoNodeConnectionUtils::deleteConnection( cmbConnections->currentText() );
122122
cmbConnections->removeItem( cmbConnections->currentIndex() );
123123
if ( mModel )
124124
{
@@ -148,14 +148,14 @@ void QgsGeoNodeSourceSelect::deleteConnectionsEntryList()
148148
void QgsGeoNodeSourceSelect::populateConnectionList()
149149
{
150150
cmbConnections->clear();
151-
cmbConnections->addItems( QgsGeoNodeConnection::connectionList() );
151+
cmbConnections->addItems( QgsGeoNodeConnectionUtils::connectionList() );
152152

153153
setConnectionListPosition();
154154
}
155155

156156
void QgsGeoNodeSourceSelect::setConnectionListPosition()
157157
{
158-
QString toSelect = QgsGeoNodeConnection::selectedConnection();
158+
QString toSelect = QgsGeoNodeConnectionUtils::selectedConnection();
159159

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

src/providers/ows/qgsgeonodedataitems.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ QVector<QgsDataItem *> QgsGeoNodeRootItem::createChildren()
229229
{
230230
QVector<QgsDataItem *> connections;
231231

232-
Q_FOREACH ( const QString &connName, QgsGeoNodeConnection::connectionList() )
232+
Q_FOREACH ( const QString &connName, QgsGeoNodeConnectionUtils::connectionList() )
233233
{
234234
QgsGeoNodeConnection *connection = nullptr;
235235
connection = new QgsGeoNodeConnection( connName );
@@ -270,7 +270,7 @@ QgsDataItem *QgsGeoNodeDataItemProvider::createDataItem( const QString &path, Qg
270270
if ( path.startsWith( QLatin1String( "geonode:/" ) ) )
271271
{
272272
QString connectionName = path.split( '/' ).last();
273-
if ( QgsGeoNodeConnection::connectionList().contains( connectionName ) )
273+
if ( QgsGeoNodeConnectionUtils::connectionList().contains( connectionName ) )
274274
{
275275
QgsGeoNodeConnection *connection = new QgsGeoNodeConnection( connectionName );
276276
return new QgsGeoNodeConnectionItem( parentItem, QStringLiteral( "GeoNode" ), path, connection );

src/providers/ows/qgsgeonodedataitems.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class QgsGeoNodeConnectionItem : public QgsDataCollectionItem
3636
void editConnection();
3737
void deleteConnection()
3838
{
39-
QgsGeoNodeConnection::deleteConnection( name() );
39+
QgsGeoNodeConnectionUtils::deleteConnection( name() );
4040
mParent->refresh();
4141
};
4242

src/providers/wfs/qgswfsdataitems.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ QgsDataItem *QgsWfsDataItemProvider::createDataItem( const QString &path, QgsDat
220220
else if ( path.startsWith( QLatin1String( "geonode:/" ) ) )
221221
{
222222
QString connectionName = path.split( '/' ).last();
223-
if ( QgsGeoNodeConnection::connectionList().contains( connectionName ) )
223+
if ( QgsGeoNodeConnectionUtils::connectionList().contains( connectionName ) )
224224
{
225225
QgsGeoNodeConnection connection( connectionName );
226226

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

src/providers/wms/qgswmsdataitems.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ QVector<QgsDataItem *> QgsWmsDataItemProvider::createDataItems( const QString &p
559559
if ( path.startsWith( QLatin1String( "geonode:/" ) ) )
560560
{
561561
QString connectionName = path.split( '/' ).last();
562-
if ( QgsGeoNodeConnection::connectionList().contains( connectionName ) )
562+
if ( QgsGeoNodeConnectionUtils::connectionList().contains( connectionName ) )
563563
{
564564
QgsGeoNodeConnection connection( connectionName );
565565

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

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

0 commit comments

Comments
 (0)