File tree 3 files changed +45
-5
lines changed
python/core/auto_generated
3 files changed +45
-5
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ The QgsDefaultValue class provides a container for managing client
17
17
side default values for fields.
18
18
19
19
A QgsDefaultValue consists of an expression string that will be evaluated
20
- on the client when a defeault field value needs to be generated.
20
+ on the client when a default field value needs to be generated.
21
21
22
22
Usual values for such an expression are
23
23
Original file line number Diff line number Diff line change 18
18
#include " qgis.h"
19
19
20
20
#include < QFileInfo>
21
+ #include < QUrl>
21
22
22
23
23
24
QgsPathResolver::QgsPathResolver ( const QString &baseFileName )
@@ -163,9 +164,20 @@ QString QgsPathResolver::writePath( const QString &src ) const
163
164
return src;
164
165
}
165
166
166
- // Strip "file://"
167
- QFileInfo srcFileInfo ( src.startsWith ( QStringLiteral ( " file://" ) ) ? src.mid ( 7 ) : src );
168
- QString srcPath = srcFileInfo.exists () ? srcFileInfo.canonicalFilePath () : src;
167
+ // Check if it is a plublicSource uri and clean it
168
+ QUrl url { src };
169
+ QString srcPath { src };
170
+ QString urlQuery;
171
+
172
+ if ( url.isLocalFile ( ) )
173
+ {
174
+ srcPath = url.path ();
175
+ urlQuery = url.query ();
176
+ }
177
+
178
+ QFileInfo srcFileInfo ( srcPath );
179
+ if ( srcFileInfo.exists () )
180
+ srcPath = srcFileInfo.canonicalFilePath ();
169
181
170
182
// if this is a VSIFILE, remove the VSI prefix and append to final result
171
183
QString vsiPrefix = qgsVsiPrefix ( src );
@@ -233,5 +245,12 @@ QString QgsPathResolver::writePath( const QString &src ) const
233
245
srcElems.insert ( 0 , QStringLiteral ( " ." ) );
234
246
}
235
247
236
- return vsiPrefix + srcElems.join ( QStringLiteral ( " /" ) );
248
+ // Append url query if any
249
+ QString returnPath { vsiPrefix + srcElems.join ( QStringLiteral ( " /" ) ) };
250
+ if ( ! urlQuery.isEmpty () )
251
+ {
252
+ returnPath.append ( ' ?' );
253
+ returnPath.append ( urlQuery );
254
+ }
255
+ return returnPath;
237
256
}
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ class TestQgsProject : public QObject
42
42
void variablesChanged ();
43
43
void testLayerFlags ();
44
44
void testLocalFiles ();
45
+ void testLocalUrlFiles ();
45
46
};
46
47
47
48
void TestQgsProject::init ()
@@ -406,6 +407,26 @@ void TestQgsProject::testLocalFiles()
406
407
407
408
}
408
409
410
+ void TestQgsProject::testLocalUrlFiles ()
411
+ {
412
+ QTemporaryFile f;
413
+ QVERIFY ( f.open () );
414
+ f.close ();
415
+ QgsProject prj;
416
+ QFileInfo info ( f.fileName () );
417
+ prj.setFileName ( f.fileName () );
418
+ prj.write ();
419
+ QString shpPath = info.dir ().path () + ' /' + info.baseName () + " .shp" ;
420
+ QString extraStuff {" ?someVar=someValue&someOtherVar=someOtherValue" };
421
+ QString layerPath = " file://" + shpPath + extraStuff;
422
+ QFile f2 ( shpPath );
423
+ QVERIFY ( f2.open ( QFile::ReadWrite ) );
424
+ f2.close ();
425
+ QgsPathResolver resolver ( f.fileName ( ) );
426
+ QCOMPARE ( resolver.writePath ( layerPath ), QString ( " ./" + info.baseName () + " .shp" + extraStuff ) ) ;
427
+
428
+ }
429
+
409
430
410
431
QGSTEST_MAIN ( TestQgsProject )
411
432
#include " testqgsproject.moc"
You can’t perform that action at this time.
0 commit comments