27
27
#include " qgsgeometrychecker.h"
28
28
#include " qgsgeometrycheck.h"
29
29
#include " qgsfeaturepool.h"
30
+ #include " qgsfileutils.h"
30
31
31
32
#include " qgsgeometry.h"
32
33
#include " qgisinterface.h"
@@ -226,14 +227,17 @@ void QgsGeometryCheckerResultTab::exportErrors()
226
227
initialdir = dir.absolutePath ();
227
228
}
228
229
229
- QString file = QFileDialog::getSaveFileName ( this , tr ( " Select Output File" ), initialdir, tr ( " GeoPackage (*.gpkg);;" ) );
230
+ QString selectedFilter;
231
+ QString file = QFileDialog::getSaveFileName ( this , tr ( " Select Output File" ), initialdir, QgsVectorFileWriter::fileFilterString (), &selectedFilter );
230
232
if ( file.isEmpty () )
231
233
{
232
234
return ;
233
235
}
236
+
237
+ file = QgsFileUtils::addExtensionFromFilter ( file, selectedFilter );
234
238
if ( !exportErrorsDo ( file ) )
235
239
{
236
- QMessageBox::critical ( this , tr ( " Error " ), tr ( " Failed to export errors to shapefile. " ) );
240
+ QMessageBox::critical ( this , tr ( " Export Errors " ), tr ( " Failed to export errors to %1. " ). arg ( QDir::toNativeSeparators ( file ) ) );
237
241
}
238
242
}
239
243
@@ -244,6 +248,10 @@ bool QgsGeometryCheckerResultTab::exportErrorsDo( const QString &file )
244
248
attributes.append ( qMakePair ( QStringLiteral ( " FeatureID" ), QStringLiteral ( " String;10;" ) ) );
245
249
attributes.append ( qMakePair ( QStringLiteral ( " ErrorDesc" ), QStringLiteral ( " String;80;" ) ) );
246
250
251
+ QFileInfo fi ( file );
252
+ QString ext = fi.suffix ();
253
+ QString driver = QgsVectorFileWriter::driverForExtension ( ext );
254
+
247
255
QLibrary ogrLib ( QgsProviderRegistry::instance ()->library ( QStringLiteral ( " ogr" ) ) );
248
256
if ( !ogrLib.load () )
249
257
{
@@ -255,7 +263,7 @@ bool QgsGeometryCheckerResultTab::exportErrorsDo( const QString &file )
255
263
{
256
264
return false ;
257
265
}
258
- if ( !createEmptyDataSource ( file, QStringLiteral ( " ESRI Shapefile " ) , " UTF-8" , QgsWkbTypes::Point, attributes, QgsProject::instance ()->crs () ) )
266
+ if ( !createEmptyDataSource ( file, driver , " UTF-8" , QgsWkbTypes::Point, attributes, QgsProject::instance ()->crs () ) )
259
267
{
260
268
return false ;
261
269
}
0 commit comments