29 #include <QProgressDialog>
31 #define FEATURE_BUFFER_SIZE 200
39 QMap<int, int> *oldToNewAttrIdx,
40 QString *errorMessage,
41 const QMap<QString, QVariant> *options
46 const QString &providerKey,
51 const QMap<QString, QVariant> *options,
52 QProgressDialog *progress )
54 , mProgress( progress )
106 if ( vectorProvider )
107 delete vectorProvider;
144 for (
int i = 0; i < attrs.count(); ++i )
152 QgsDebugMsgLevel( QString(
"moving field from pos %1 to %2" ).arg( i ).arg( dstIdx ), 3 );
179 .arg( errors.join(
"\n" ) );
208 const QString& providerKey,
211 QString *errorMessage,
212 bool skipAttributeCreation,
213 QMap<QString, QVariant> *options,
214 QProgressDialog *progress )
218 int shallTransform =
false;
225 if ( destCRS && destCRS->
isValid() )
229 shallTransform =
true;
234 outputCRS = &layer->
crs();
238 bool overwrite =
false;
239 bool forceSinglePartGeom =
false;
242 overwrite = options->take(
"overwrite" ).toBool();
243 forceSinglePartGeom = options->take(
"forceSinglePartGeometryType" ).toBool();
253 for (
int fldIdx = 0; fldIdx < fields.
count(); ++fldIdx )
255 fields[fldIdx].setName( fields[fldIdx].name().toLower() );
258 if ( !forceSinglePartGeom )
288 new QgsVectorLayerImport( uri, providerKey, fields, wkbType, outputCRS, overwrite, options, progress );
302 errorMessage->clear();
311 if ( skipAttributeCreation )
327 shallTransform =
false;
334 *errorMessage =
QObject::tr(
"Feature write errors:" );
345 if ( progress && progress->wasCanceled() )
349 *errorMessage +=
"\n" +
QObject::tr(
"Import was canceled at %1 of %2" ).arg( progress->value() ).arg( progress->maximum() );
363 if ( onlySelected && !ids.contains( fet.
id() ) )
366 if ( shallTransform )
380 QString msg =
QObject::tr(
"Failed to transform a point while drawing a feature with ID '%1'. Writing stopped. (Exception: %2)" )
381 .arg( fet.
id() ).arg( e.
what() );
384 *errorMessage +=
"\n" + msg;
389 if ( skipAttributeCreation )
404 progress->setValue( n );
428 if ( shallTransform )
437 *errorMessage +=
"\n" +
QObject::tr(
"Only %1 of %2 features written." ).arg( n - errors ).arg( n );
441 errorMessage->clear();