Skip to content

Commit

Permalink
Remove unused skipAttributeCreation option in QgsVectorLayerExporter:…
Browse files Browse the repository at this point in the history
…:exportLayer
  • Loading branch information
nyalldawson committed May 11, 2017
1 parent 64b612f commit 75a5d5d
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 20 deletions.
1 change: 1 addition & 0 deletions doc/api_break.dox
Original file line number Diff line number Diff line change
Expand Up @@ -2189,6 +2189,7 @@ QgsCoordinateReferenceSystem is now implicitly shared, using references to QgsCo
pointers makes for more robust, safer code. Use an invalid (default constructed) QgsCoordinateReferenceSystem
in code which previously passed a null pointer to QgsVectorLayerImport.
- importLayer was renamed to exportLayer
- The unused skipAttributeCreation in exportLayer() was removed
- The unused QProgressBar argument in the QgsVectorLayerImport was removed
- ImportError was renamed to ExportError
- The unused enum value ErrDriverNotFound was removed
Expand Down
2 changes: 0 additions & 2 deletions python/core/qgsvectorlayerexporter.sip
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class QgsVectorLayerExporter : QgsFeatureSink
const QgsCoordinateReferenceSystem &destCRS,
bool onlySelected = false,
QString *errorMessage /Out/ = 0,
bool skipAttributeCreation = false,
QMap<QString, QVariant> *options = 0,
QProgressDialog *progress = 0
);
Expand All @@ -65,7 +64,6 @@ class QgsVectorLayerExporter : QgsFeatureSink
not available
\param onlySelected set to true to export only selected features
\param errorMessage if non-null, will be set to any error messages
\param skipAttributeCreation set to true to skip exporting feature attributes
\param options optional provider dataset options
\param progress optional progress dialog to show progress of export
:return: NoError for a successful export, or encountered error
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/db_manager/dlg_export_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def accept(self):
self.inLayer.setCrs(inCrs)

# do the export!
ret, errMsg = QgsVectorLayerExporter.exportLayer(self.inLayer, uri, providerName, outCrs, False,
ret, errMsg = QgsVectorLayerExporter.exportLayer(self.inLayer, uri, providerName, outCrs,
False, options)
except Exception as e:
ret = -1
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/db_manager/dlg_import_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def accept(self):
onlySelected = self.chkSelectedFeatures.isChecked()

# do the import!
ret, errMsg = QgsVectorLayerExporter.exportLayer(self.inLayer, uri, providerName, outCrs, onlySelected, False, options)
ret, errMsg = QgsVectorLayerExporter.exportLayer(self.inLayer, uri, providerName, outCrs, onlySelected, options)
except Exception as e:
ret = -1
errMsg = str(e)
Expand Down
1 change: 0 additions & 1 deletion python/plugins/processing/algs/qgis/ImportIntoPostGIS.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ def processAlgorithm(self, context, feedback):
providerName,
self.crs,
False,
False,
options,
)
if ret != 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ def processAlgorithm(self, context, feedback):
providerName,
self.crs,
False,
False,
options,
)
if ret != 0:
Expand Down
11 changes: 2 additions & 9 deletions src/core/qgsvectorlayerexporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ QgsVectorLayerExporter::exportLayer( QgsVectorLayer *layer,
const QgsCoordinateReferenceSystem &destCRS,
bool onlySelected,
QString *errorMessage,
bool skipAttributeCreation,
QMap<QString, QVariant> *options,
QProgressDialog *progress )
{
Expand Down Expand Up @@ -263,7 +262,7 @@ QgsVectorLayerExporter::exportLayer( QgsVectorLayer *layer,
forceSinglePartGeom = options->take( QStringLiteral( "forceSinglePartGeometryType" ) ).toBool();
}

QgsFields fields = skipAttributeCreation ? QgsFields() : layer->fields();
QgsFields fields = layer->fields();
QgsWkbTypes::Type wkbType = layer->wkbType();

// Special handling for Shapefiles
Expand Down Expand Up @@ -327,8 +326,6 @@ QgsVectorLayerExporter::exportLayer( QgsVectorLayer *layer,
QgsFeatureRequest req;
if ( wkbType == QgsWkbTypes::NoGeometry )
req.setFlags( QgsFeatureRequest::NoGeometry );
if ( skipAttributeCreation )
req.setSubsetOfAttributes( QgsAttributeList() );

QgsFeatureIterator fit = layer->getFeatures( req );

Expand Down Expand Up @@ -405,10 +402,6 @@ QgsVectorLayerExporter::exportLayer( QgsVectorLayer *layer,
return ErrProjection;
}
}
if ( skipAttributeCreation )
{
fet.initAttributes( 0 );
}
if ( !writer->addFeature( fet ) )
{
if ( writer->errorCode() && errorMessage )
Expand Down Expand Up @@ -504,7 +497,7 @@ bool QgsVectorLayerExporterTask::run()


mError = QgsVectorLayerExporter::exportLayer(
mLayer.data(), mDestUri, mDestProviderKey, mDestCrs, false, &mErrorMessage, false,
mLayer.data(), mDestUri, mDestProviderKey, mDestCrs, false, &mErrorMessage,
&mOptions );

if ( mOwnsLayer )
Expand Down
2 changes: 0 additions & 2 deletions src/core/qgsvectorlayerexporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class CORE_EXPORT QgsVectorLayerExporter : public QgsFeatureSink
* not available
* \param onlySelected set to true to export only selected features
* \param errorMessage if non-null, will be set to any error messages
* \param skipAttributeCreation set to true to skip exporting feature attributes
* \param options optional provider dataset options
* \param progress optional progress dialog to show progress of export
* \returns NoError for a successful export, or encountered error
Expand All @@ -85,7 +84,6 @@ class CORE_EXPORT QgsVectorLayerExporter : public QgsFeatureSink
const QgsCoordinateReferenceSystem &destCRS,
bool onlySelected = false,
QString *errorMessage SIP_OUT = 0,
bool skipAttributeCreation = false,
QMap<QString, QVariant> *options = nullptr,
QProgressDialog *progress = nullptr
);
Expand Down
6 changes: 3 additions & 3 deletions tests/src/python/test_provider_ogr_gpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def testSimulatedDBManagerImport(self):
options['update'] = True
options['driverName'] = 'GPKG'
options['layerName'] = 'my_out_table'
err = QgsVectorLayerExporter.exportLayer(lyr, tmpfile, "ogr", lyr.crs(), False, False, options)
err = QgsVectorLayerExporter.exportLayer(lyr, tmpfile, "ogr", lyr.crs(), False, options)
self.assertEqual(err[0], QgsVectorLayerExporter.NoError,
'unexpected import error {0}'.format(err))
lyr = QgsVectorLayer(tmpfile + "|layername=my_out_table", "y", "ogr")
Expand All @@ -431,7 +431,7 @@ def testSimulatedDBManagerImport(self):
features = None

# Test overwriting without overwrite option
err = QgsVectorLayerExporter.exportLayer(lyr, tmpfile, "ogr", lyr.crs(), False, False, options)
err = QgsVectorLayerExporter.exportLayer(lyr, tmpfile, "ogr", lyr.crs(), False, options)
self.assertEqual(err[0], QgsVectorLayerExporter.ErrCreateDataSource)

# Test overwriting
Expand All @@ -441,7 +441,7 @@ def testSimulatedDBManagerImport(self):
f['f1'] = 3
lyr.dataProvider().addFeatures([f])
options['overwrite'] = True
err = QgsVectorLayerExporter.exportLayer(lyr, tmpfile, "ogr", lyr.crs(), False, False, options)
err = QgsVectorLayerExporter.exportLayer(lyr, tmpfile, "ogr", lyr.crs(), False, options)
self.assertEqual(err[0], QgsVectorLayerExporter.NoError,
'unexpected import error {0}'.format(err))
lyr = QgsVectorLayer(tmpfile + "|layername=my_out_table", "y", "ogr")
Expand Down

0 comments on commit 75a5d5d

Please sign in to comment.