QGIS API Documentation  2.99.0-Master (6a61179)
qgsvectorlayerimport.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorlayerimport.cpp
3  vector layer importer
4  -------------------
5  begin : Thu Aug 25 2011
6  copyright : (C) 2011 by Giuseppe Sucameli
7  email : brush.tyler at gmail.com
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #ifndef QGSVECTORLAYERIMPORT_H
20 #define QGSVECTORLAYERIMPORT_H
21 
22 #include "qgsfeature.h"
23 
24 class QProgressDialog;
26 class QgsVectorLayer;
27 class QgsFields;
28 
35 class CORE_EXPORT QgsVectorLayerImport
36 {
37  public:
38 
40  {
41  NoError = 0,
54  };
55 
70  static ImportError importLayer( QgsVectorLayer* layer,
71  const QString& uri,
72  const QString& providerKey,
73  const QgsCoordinateReferenceSystem& destCRS,
74  bool onlySelected = false,
75  QString *errorMessage = nullptr,
76  bool skipAttributeCreation = false,
77  QMap<QString, QVariant> *options = nullptr,
78  QProgressDialog *progress = nullptr
79  );
80 
92  QgsVectorLayerImport( const QString &uri,
93  const QString &provider,
94  const QgsFields &fields,
95  QgsWkbTypes::Type geometryType,
97  bool overwrite = false,
98  const QMap<QString, QVariant> *options = nullptr,
99  QProgressDialog *progress = nullptr
100  );
101 
103  ImportError hasError();
104 
106  QString errorMessage();
107 
108  int errorCount() const { return mErrorCount; }
109 
111  bool addFeature( QgsFeature& feature );
112 
115 
116  protected:
118  bool flushBuffer();
119 
121  bool createSpatialIndex();
122 
125  QString mErrorMessage;
126 
128 
130 
132  QMap<int, int> mOldToNewAttrIdx;
134 
136  QProgressDialog *mProgress;
137 
138  private:
139 
141  QgsVectorLayerImport& operator=( const QgsVectorLayerImport& rh );
142 };
143 
144 #endif
QMap< int, int > mOldToNewAttrIdx
Map attribute indexes to new field indexes.
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:360
QgsVectorDataProvider * mProvider
Container of fields for a vector layer.
Definition: qgsfields.h:36
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:135
A convenience class for writing vector files to disk.
ImportError mError
Contains error value.
This class represents a coordinate reference system (CRS).
This is the base class for vector data providers.
Represents a vector layer which manages a vector based data sets.
QProgressDialog * mProgress