|
| 1 | +/************************************************************************ |
| 2 | + * This file has been generated automatically from * |
| 3 | + * * |
| 4 | + * src/core/qgsvectorlayerexporter.h * |
| 5 | + * * |
| 6 | + * Do not edit manually ! Edit header and run scripts/sipify.pl again * |
| 7 | + ************************************************************************/ |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +class QgsVectorLayerExporter : QgsFeatureSink |
| 14 | +{ |
| 15 | +%Docstring |
| 16 | + A convenience class for exporting vector layers to a destination data provider. |
| 17 | + |
| 18 | + QgsVectorLayerExporter can be used in two ways: |
| 19 | + |
| 20 | + 1. Using a static call to QgsVectorLayerExporter.exportLayer(...) which exports the |
| 21 | + entire layer to the destination provider. |
| 22 | + |
| 23 | + 2. Create an instance of the class and issue calls to addFeature(...) |
| 24 | + |
| 25 | +.. versionadded:: 3.0 |
| 26 | +%End |
| 27 | + |
| 28 | +%TypeHeaderCode |
| 29 | +#include "qgsvectorlayerexporter.h" |
| 30 | +%End |
| 31 | + public: |
| 32 | + |
| 33 | + enum ExportError |
| 34 | + { |
| 35 | + NoError, |
| 36 | + ErrCreateDataSource, |
| 37 | + ErrCreateLayer, |
| 38 | + ErrAttributeTypeUnsupported, |
| 39 | + ErrAttributeCreationFailed, |
| 40 | + ErrProjection, |
| 41 | + ErrFeatureWriteFailed, |
| 42 | + ErrInvalidLayer, |
| 43 | + ErrInvalidProvider, |
| 44 | + ErrProviderUnsupportedFeature, |
| 45 | + ErrConnectionFailed, |
| 46 | + ErrUserCanceled, |
| 47 | + }; |
| 48 | + |
| 49 | + static ExportError exportLayer( QgsVectorLayer *layer, |
| 50 | + const QString &uri, |
| 51 | + const QString &providerKey, |
| 52 | + const QgsCoordinateReferenceSystem &destCRS, |
| 53 | + bool onlySelected = false, |
| 54 | + QString *errorMessage /Out/ = 0, |
| 55 | + QMap<QString, QVariant> *options = 0, |
| 56 | + QgsFeedback *feedback = 0 |
| 57 | + ); |
| 58 | +%Docstring |
| 59 | + Writes the contents of vector layer to a different datasource. |
| 60 | + \param layer source layer |
| 61 | + \param uri URI for destination data source |
| 62 | + \param providerKey string key for destination data provider |
| 63 | + \param destCRS destination CRS, or an invalid (default constructed) CRS if |
| 64 | + not available |
| 65 | + \param onlySelected set to true to export only selected features |
| 66 | + \param errorMessage if non-null, will be set to any error messages |
| 67 | + \param options optional provider dataset options |
| 68 | + \param feedback optional feedback object to show progress and cancelation of export |
| 69 | + :return: NoError for a successful export, or encountered error |
| 70 | + :rtype: ExportError |
| 71 | +%End |
| 72 | + |
| 73 | + QgsVectorLayerExporter( const QString &uri, |
| 74 | + const QString &provider, |
| 75 | + const QgsFields &fields, |
| 76 | + QgsWkbTypes::Type geometryType, |
| 77 | + const QgsCoordinateReferenceSystem &crs, |
| 78 | + bool overwrite = false, |
| 79 | + const QMap<QString, QVariant> *options = 0 ); |
| 80 | +%Docstring |
| 81 | + Constructor for QgsVectorLayerExporter. |
| 82 | + \param uri URI for destination data source |
| 83 | + \param provider string key for destination data provider |
| 84 | + \param fields fields to include in created layer |
| 85 | + \param geometryType destination geometry type |
| 86 | + \param crs desired CRS, or an invalid (default constructed) CRS if |
| 87 | + not available |
| 88 | + \param overwrite set to true to overwrite any existing data source |
| 89 | + \param options optional provider dataset options |
| 90 | +%End |
| 91 | + |
| 92 | + |
| 93 | + ExportError errorCode() const; |
| 94 | +%Docstring |
| 95 | + Returns any encountered error code, or false if no error was encountered. |
| 96 | +.. seealso:: errorMessage() |
| 97 | +.. seealso:: errorCount() |
| 98 | + :rtype: ExportError |
| 99 | +%End |
| 100 | + |
| 101 | + QString errorMessage() const; |
| 102 | +%Docstring |
| 103 | + Returns any error message encountered during the export. |
| 104 | +.. seealso:: errorCount() |
| 105 | +.. seealso:: errorCode() |
| 106 | + :rtype: str |
| 107 | +%End |
| 108 | + |
| 109 | + int errorCount() const; |
| 110 | +%Docstring |
| 111 | + Returns the number of error messages encountered during the export. |
| 112 | +.. seealso:: errorMessage() |
| 113 | +.. seealso:: errorCode() |
| 114 | + :rtype: int |
| 115 | +%End |
| 116 | + |
| 117 | + virtual bool addFeatures( QgsFeatureList &features ); |
| 118 | + |
| 119 | + virtual bool addFeature( QgsFeature &feature ); |
| 120 | + |
| 121 | + |
| 122 | + ~QgsVectorLayerExporter(); |
| 123 | +%Docstring |
| 124 | + Finalizes the export and closes the new created layer. |
| 125 | +%End |
| 126 | + |
| 127 | + private: |
| 128 | + QgsVectorLayerExporter( const QgsVectorLayerExporter &rh ); |
| 129 | +}; |
| 130 | + |
| 131 | + |
| 132 | +class QgsVectorLayerExporterTask : QgsTask |
| 133 | +{ |
| 134 | +%Docstring |
| 135 | + QgsTask task which performs a QgsVectorLayerExporter layer export operation as a background |
| 136 | + task. This can be used to export a vector layer out to a provider without blocking the |
| 137 | + QGIS interface. |
| 138 | +.. versionadded:: 3.0 |
| 139 | +.. seealso:: QgsVectorFileWriterTask |
| 140 | +.. seealso:: QgsRasterFileWriterTask |
| 141 | +%End |
| 142 | + |
| 143 | +%TypeHeaderCode |
| 144 | +#include "qgsvectorlayerexporter.h" |
| 145 | +%End |
| 146 | + public: |
| 147 | + |
| 148 | + QgsVectorLayerExporterTask( QgsVectorLayer *layer, |
| 149 | + const QString &uri, |
| 150 | + const QString &providerKey, |
| 151 | + const QgsCoordinateReferenceSystem &destinationCrs, |
| 152 | + QMap<QString, QVariant> *options = 0 ); |
| 153 | +%Docstring |
| 154 | + Constructor for QgsVectorLayerExporterTask. Takes a source ``layer``, destination ``uri`` |
| 155 | + and ``providerKey``, and various export related parameters such as destination CRS |
| 156 | + and export ``options``. |
| 157 | +%End |
| 158 | + |
| 159 | + static QgsVectorLayerExporterTask *withLayerOwnership( QgsVectorLayer *layer /Transfer/, |
| 160 | + const QString &uri, |
| 161 | + const QString &providerKey, |
| 162 | + const QgsCoordinateReferenceSystem &destinationCrs, |
| 163 | + QMap<QString, QVariant> *options = 0 ) /Factory/; |
| 164 | +%Docstring |
| 165 | + Creates a new QgsVectorLayerExporterTask which has ownership over a source ``layer``. |
| 166 | + When the export task has completed (successfully or otherwise) ``layer`` will be |
| 167 | + deleted. The destination ``uri`` and ``providerKey``, and various export related parameters such as destination CRS |
| 168 | + and export ``options`` must be specified. |
| 169 | + :rtype: QgsVectorLayerExporterTask |
| 170 | +%End |
| 171 | + |
| 172 | + virtual void cancel(); |
| 173 | + |
| 174 | + signals: |
| 175 | + |
| 176 | + void exportComplete(); |
| 177 | +%Docstring |
| 178 | + Emitted when exporting the layer is successfully completed. |
| 179 | +%End |
| 180 | + |
| 181 | + void errorOccurred( int error, const QString &errorMessage ); |
| 182 | +%Docstring |
| 183 | + Emitted when an error occurs which prevented the layer being exported (or if |
| 184 | + the task is canceled). The export ``error`` and ``errorMessage`` will be reported. |
| 185 | +%End |
| 186 | + |
| 187 | + protected: |
| 188 | + |
| 189 | + virtual bool run(); |
| 190 | + virtual void finished( bool result ); |
| 191 | + |
| 192 | +}; |
| 193 | + |
| 194 | +/************************************************************************ |
| 195 | + * This file has been generated automatically from * |
| 196 | + * * |
| 197 | + * src/core/qgsvectorlayerexporter.h * |
| 198 | + * * |
| 199 | + * Do not edit manually ! Edit header and run scripts/sipify.pl again * |
| 200 | + ************************************************************************/ |
0 commit comments