QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
36 class CORE_EXPORT QgsVectorLayerImport
37 {
38  public:
39 
41  {
42  NoError = 0,
53  ErrConnectionFailed
54  };
55 
57  static ImportError importLayer( QgsVectorLayer* layer,
58  const QString& uri,
59  const QString& providerKey,
60  const QgsCoordinateReferenceSystem *destCRS,
61  bool onlySelected = false,
62  QString *errorMessage = 0,
63  bool skipAttributeCreation = false,
64  QMap<QString, QVariant> *options = 0,
65  QProgressDialog *progress = 0
66  );
67 
69  QgsVectorLayerImport( const QString &uri,
70  const QString &provider,
71  const QgsFields &fields,
72  QGis::WkbType geometryType,
74  bool overwrite = false,
75  const QMap<QString, QVariant> *options = 0,
76  QProgressDialog *progress = 0
77  );
78 
80  ImportError hasError();
81 
83  QString errorMessage();
84 
85  int errorCount() const { return mErrorCount; }
86 
88  bool addFeature( QgsFeature& feature );
89 
92 
93  protected:
95  bool flushBuffer();
96 
98  bool createSpatialIndex();
99 
102  QString mErrorMessage;
103 
105 
107 
109  QMap<int, int> mOldToNewAttrIdx;
111 
113  QProgressDialog *mProgress;
114 };
115 
116 #endif