00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _QGSVECTORLAYERIMPORT_H_
00020 #define _QGSVECTORLAYERIMPORT_H_
00021
00022 #include "qgsvectordataprovider.h"
00023 #include "qgsvectorlayer.h"
00024
00034 class CORE_EXPORT QgsVectorLayerImport
00035 {
00036 public:
00037
00038 enum ImportError
00039 {
00040 NoError = 0,
00041 ErrDriverNotFound,
00042 ErrCreateDataSource,
00043 ErrCreateLayer,
00044 ErrAttributeTypeUnsupported,
00045 ErrAttributeCreationFailed,
00046 ErrProjection,
00047 ErrFeatureWriteFailed,
00048 ErrInvalidLayer,
00049 ErrInvalidProvider,
00050 ErrProviderUnsupportedFeature,
00051 ErrConnectionFailed
00052 };
00053
00054
00056 static ImportError importLayer( QgsVectorLayer* layer,
00057 const QString& uri,
00058 const QString& providerKey,
00059 const QgsCoordinateReferenceSystem *destCRS,
00060 bool onlySelected = false,
00061 QString *errorMessage = 0,
00062 bool skipAttributeCreation = false,
00063 QMap<QString, QVariant> *options = 0
00064 );
00065
00067 QgsVectorLayerImport( const QString &uri,
00068 const QString &provider,
00069 const QgsFieldMap& fields,
00070 QGis::WkbType geometryType,
00071 const QgsCoordinateReferenceSystem* crs,
00072 bool overwrite = false,
00073 const QMap<QString, QVariant> *options = 0
00074 );
00075
00077 ImportError hasError();
00078
00080 QString errorMessage();
00081
00082 int errorCount() const { return mErrorCount; }
00083
00085 bool addFeature( QgsFeature& feature );
00086
00088 ~QgsVectorLayerImport();
00089
00090 protected:
00092 bool flushBuffer();
00093
00095 ImportError mError;
00096 QString mErrorMessage;
00097
00098 int mErrorCount;
00099
00100 QgsVectorDataProvider *mProvider;
00101
00103 QMap<int, int> mOldToNewAttrIdx;
00104
00105 QgsFeatureList mFeatureBuffer;
00106 };
00107
00108 #endif