Skip to content
Permalink
Browse files

Add globs to information returned by QgsVectorFileWriter.supportedFil…

…tersAndFormats
  • Loading branch information
nyalldawson committed Jun 21, 2018
1 parent 352f3f3 commit 2ed547219a63bde1364bdca0d63a66425eb50215
@@ -418,6 +418,8 @@ Create a new vector file writer
QString driverName;

QString filterString;

QStringList globs;
};

static QList< QgsVectorFileWriter::FilterFormatDetails > supportedFiltersAndFormats( VectorFormatOptions options = SortRecommended );
@@ -2839,9 +2839,17 @@ QList< QgsVectorFileWriter::FilterFormatDetails > QgsVectorFileWriter::supported
if ( filterString.isEmpty() )
continue;

MetaData metadata;
QStringList globs;
if ( driverMetadata( drvName, metadata ) && !metadata.glob.isEmpty() )
{
globs << metadata.glob.toLower();
}

FilterFormatDetails details;
details.driverName = drvName;
details.filterString = filterString;
details.globs = globs;

results << details;
}
@@ -517,6 +517,12 @@ class CORE_EXPORT QgsVectorFileWriter : public QgsFeatureSink

//! Filter string for file picker dialogs
QString filterString;

/**
* Matching glob patterns for format, e.g. *.shp.
* \since QGIS 3.2
*/
QStringList globs;
};

/**
@@ -769,8 +769,10 @@ def testSupportedFiltersAndFormat(self):
formats = QgsVectorFileWriter.supportedFiltersAndFormats(QgsVectorFileWriter.SortRecommended)
self.assertEqual(formats[0].filterString, 'GeoPackage (*.gpkg *.GPKG)')
self.assertEqual(formats[0].driverName, 'GPKG')
self.assertEqual(formats[0].globs, ['*.gpkg'])
self.assertEqual(formats[1].filterString, 'ESRI Shapefile (*.shp *.SHP)')
self.assertEqual(formats[1].driverName, 'ESRI Shapefile')
self.assertEqual(formats[1].globs, ['*.shp'])
self.assertTrue('ODS' in [f.driverName for f in formats])

# alphabetical sorting

0 comments on commit 2ed5472

Please sign in to comment.
You can’t perform that action at this time.