QGIS API Documentation  2.17.0-Master (06698cd)
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 "qgsvectordataprovider.h"
23 #include "qgsvectorlayer.h"
24 
25 class QProgressDialog;
26 
33 class CORE_EXPORT QgsVectorLayerImport
34 {
35  public:
36 
38  {
39  NoError = 0,
52  };
53 
55  static ImportError importLayer( QgsVectorLayer* layer,
56  const QString& uri,
57  const QString& providerKey,
58  const QgsCoordinateReferenceSystem *destCRS,
59  bool onlySelected = false,
60  QString *errorMessage = nullptr,
61  bool skipAttributeCreation = false,
62  QMap<QString, QVariant> *options = nullptr,
63  QProgressDialog *progress = nullptr
64  );
65 
67  QgsVectorLayerImport( const QString &uri,
68  const QString &provider,
69  const QgsFields &fields,
70  QGis::WkbType geometryType,
72  bool overwrite = false,
73  const QMap<QString, QVariant> *options = nullptr,
74  QProgressDialog *progress = nullptr
75  );
76 
78  ImportError hasError();
79 
81  QString errorMessage();
82 
83  int errorCount() const { return mErrorCount; }
84 
86  bool addFeature( QgsFeature& feature );
87 
90 
91  protected:
93  bool flushBuffer();
94 
96  bool createSpatialIndex();
97 
101 
103 
105 
109 
112 
113  private:
114 
116  QgsVectorLayerImport& operator=( const QgsVectorLayerImport& rh );
117 };
118 
119 #endif
QMap< int, int > mOldToNewAttrIdx
Map attribute indexes to new field indexes.
QgsVectorDataProvider * mProvider
Container of fields for a vector layer.
Definition: qgsfield.h:209
WkbType
Used for symbology operations.
Definition: qgis.h:61
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
A convenience class for writing vector files to disk.
ImportError mError
Contains error value.
Class for storing 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