13
13
* *
14
14
***************************************************************************/
15
15
16
+ #include " QtGlobal"
17
+
16
18
#include " qgswfsconstants.h"
17
19
#include " qgswfsdatasourceuri.h"
18
20
#include " qgsmessagelog.h"
@@ -25,11 +27,26 @@ QgsWFSDataSourceURI::QgsWFSDataSourceURI( const QString& uri )
25
27
if ( !mURI .hasParam ( QgsWFSConstants::URI_PARAM_URL ) )
26
28
{
27
29
QUrl url ( uri );
28
- QString srsname = url.queryItemValue ( " SRSNAME" );
29
- QString bbox = url.queryItemValue ( " BBOX" );
30
- QString typeName = url.queryItemValue ( " TYPENAME" );
31
- QString filter = url.queryItemValue ( " FILTER" );
30
+ // Transform all param keys to lowercase
31
+ typedef QPair<QString, QString> queryItem;
32
+ QList<queryItem> items ( url.queryItems () );
33
+ foreach ( queryItem item, items )
34
+ {
35
+ url.removeQueryItem ( item.first );
36
+ url.addQueryItem ( item.first .toLower (), item.second );
37
+ }
38
+
39
+ QString srsname = url.queryItemValue ( QgsWFSConstants::URI_PARAM_SRSNAME );
40
+ QString bbox = url.queryItemValue ( QgsWFSConstants::URI_PARAM_BBOX );
41
+ QString typeName = url.queryItemValue ( QgsWFSConstants::URI_PARAM_TYPENAME );
42
+ QString version = url.queryItemValue ( QgsWFSConstants::URI_PARAM_VERSION );
43
+ QString filter = url.queryItemValue ( QgsWFSConstants::URI_PARAM_FILTER );
32
44
mAuth .mUserName = url.queryItemValue ( QgsWFSConstants::URI_PARAM_USERNAME );
45
+ // In QgsDataSourceURI, the "username" param is named "user", check it
46
+ if ( mAuth .mUserName .isEmpty () )
47
+ {
48
+ mAuth .mUserName = url.queryItemValue ( QgsWFSConstants::URI_PARAM_USER );
49
+ }
33
50
mAuth .mPassword = url.queryItemValue ( QgsWFSConstants::URI_PARAM_PASSWORD );
34
51
mAuth .mAuthCfg = url.queryItemValue ( QgsWFSConstants::URI_PARAM_AUTHCFG );
35
52
@@ -49,6 +66,7 @@ QgsWFSDataSourceURI::QgsWFSDataSourceURI( const QString& uri )
49
66
mURI .setParam ( QgsWFSConstants::URI_PARAM_URL, url.toEncoded () );
50
67
setTypeName ( typeName );
51
68
setSRSName ( srsname );
69
+ setVersion ( version );
52
70
53
71
// if the xml comes from the dialog, it needs to be a string to pass the validity test
54
72
if ( filter.startsWith ( ' \' ' ) && filter.endsWith ( ' \' ' ) && filter.size () > 1 )
@@ -63,17 +81,32 @@ QgsWFSDataSourceURI::QgsWFSDataSourceURI( const QString& uri )
63
81
}
64
82
else
65
83
{
66
- mAuth .mUserName = mURI .param ( QgsWFSConstants::URI_PARAM_USERNAME );
67
- mAuth .mPassword = mURI .param ( QgsWFSConstants::URI_PARAM_PASSWORD );
68
- mAuth .mAuthCfg = mURI .param ( QgsWFSConstants::URI_PARAM_AUTHCFG );
84
+ mAuth .mUserName = mURI .username ( );
85
+ mAuth .mPassword = mURI .password ( );
86
+ mAuth .mAuthCfg = mURI .authConfigId ( );
69
87
}
70
88
}
71
89
72
- QString QgsWFSDataSourceURI::uri ()
90
+ const QString QgsWFSDataSourceURI::uri ( bool expandAuthConfig ) const
73
91
{
74
- return mURI .uri ();
92
+ QgsDataSourceURI theURI ( mURI );
93
+ // Add auth params back into the uri
94
+ if ( ! mAuth .mAuthCfg .isEmpty () )
95
+ {
96
+ theURI.setAuthConfigId ( mAuth .mAuthCfg );
97
+ }
98
+ if ( ! mAuth .mUserName .isEmpty () )
99
+ {
100
+ theURI.setUsername ( mAuth .mUserName );
101
+ }
102
+ if ( ! mAuth .mPassword .isEmpty () )
103
+ {
104
+ theURI.setPassword ( mAuth .mPassword );
105
+ }
106
+ return theURI.uri ( expandAuthConfig );
75
107
}
76
108
109
+
77
110
QUrl QgsWFSDataSourceURI::baseURL ( bool bIncludeServiceWFS ) const
78
111
{
79
112
QUrl url ( mURI .param ( QgsWFSConstants::URI_PARAM_URL ) );
@@ -122,6 +155,13 @@ void QgsWFSDataSourceURI::setSRSName( const QString& crsString )
122
155
mURI .setParam ( QgsWFSConstants::URI_PARAM_SRSNAME, crsString );
123
156
}
124
157
158
+ void QgsWFSDataSourceURI::setVersion ( const QString& versionString )
159
+ {
160
+ mURI .removeParam ( QgsWFSConstants::URI_PARAM_VERSION );
161
+ if ( !versionString.isEmpty () )
162
+ mURI .setParam ( QgsWFSConstants::URI_PARAM_VERSION, versionString );
163
+ }
164
+
125
165
QString QgsWFSDataSourceURI::SRSName () const
126
166
{
127
167
return mURI .param ( QgsWFSConstants::URI_PARAM_SRSNAME );
0 commit comments