QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsvectorlayersaveasdialog.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectorlayersaveasdialog.h
3 Dialog to select destination, type and crs to save as ogr layers
4 -------------------
5 begin : Mon Mar 22 2010
6 copyright : (C) 2010 by Juergen E. Fischer
7 email : jef at norbit dot de
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#ifndef QGSVECTORLAYERSAVEASDIALOG_H
19#define QGSVECTORLAYERSAVEASDIALOG_H
20
21#include "ui_qgsvectorlayersaveasdialogbase.h"
22
23#include "qgis_gui.h"
24#include "qgsvectorfilewriter.h"
25
26#include <QDialog>
27
28class QgsVectorLayer;
29
34class GUI_EXPORT QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVectorLayerSaveAsDialogBase
35{
36 Q_OBJECT
37
38 public:
42 enum class Option : int SIP_ENUM_BASETYPE( IntFlag )
43 {
44 Symbology = 1,
45 DestinationCrs = 1 << 2,
46 Fields = 1 << 3,
47 AddToCanvas = 1 << 4,
48 SelectedOnly = 1 << 5,
49 GeometryType = 1 << 6,
50 Extent = 1 << 7,
51 Metadata = 1 << 8,
52 AllOptions = ~0
53 };
54 Q_ENUM( Option )
55
56
59 Q_DECLARE_FLAGS( Options, Option )
60 Q_FLAG( Options )
61
67 Q_DECL_DEPRECATED QgsVectorLayerSaveAsDialog( long srsid, QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags() ) SIP_SKIP;
68
72 QgsVectorLayerSaveAsDialog( QgsVectorLayer *layer, QgsVectorLayerSaveAsDialog::Options options = QgsVectorLayerSaveAsDialog::Option::AllOptions, QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags() );
73
79 QString format() const;
80
84 QString encoding() const;
85
91 QString fileName() const;
92
98 QString layerName() const;
99
106 QStringList datasourceOptions() const;
107
114 QStringList layerOptions() const;
115
122
127
133
137 QStringList attributesExportNames() const;
138
144 bool addToCanvas() const;
145
152 void setAddToCanvas( bool checked );
153
157 Qgis::FeatureSymbologyExport symbologyExport() const;
158
163 double scale() const;
164
168 void setMapCanvas( QgsMapCanvas *canvas );
169
174 bool hasFilterExtent() const;
175
181
187 void setOnlySelected( bool onlySelected );
188
194 bool onlySelected() const;
195
201 bool persistMetadata() const;
202
209 Qgis::WkbType geometryType() const;
210
215 bool automaticGeometryType() const;
216
223 bool forceMulti() const;
224
230 void setForceMulti( bool checked );
231
238 bool includeZ() const;
239
245 void setIncludeZ( bool checked );
246
250 QgsVectorFileWriter::ActionOnExistingFile creationActionOnExistingFile() const;
251
252 void accept() override;
253
254 private slots:
255
256 void mFormatComboBox_currentIndexChanged( int idx );
257 void mCrsSelector_crsChanged( const QgsCoordinateReferenceSystem &crs );
258 void showHelp();
259 void mSymbologyExportComboBox_currentIndexChanged( const QString &text );
260 void mGeometryTypeComboBox_currentIndexChanged( int index );
261 void mSelectAllAttributes_clicked();
262 void mDeselectAllAttributes_clicked();
263 void mUseAliasesForExportedName_stateChanged( int state );
264 void mReplaceRawFieldValues_stateChanged( int state );
265 void mAttributeTable_itemChanged( QTableWidgetItem *item );
266
267 private:
268 enum class ColumnIndex : int
269 {
270 Name = 0,
271 ExportName = 1,
272 Type = 2,
273 ExportAsDisplayedValue = 3
274 };
275
276 void setup();
277 QList<QPair<QLabel *, QWidget *>> createControls( const QMap<QString, QgsVectorFileWriter::Option *> &options );
278
279 QgsCoordinateReferenceSystem mSelectedCrs;
280
281 QgsRectangle mLayerExtent;
283 QgsVectorLayer *mLayer = nullptr;
284 QgsMapCanvas *mMapCanvas = nullptr;
285 QgsVectorFileWriter::ActionOnExistingFile mActionOnExistingFile;
286 Options mOptions = Option::AllOptions;
287 QString mDefaultOutputLayerNameFromInputLayerName;
288 bool mAddToCanvasStateOnOpenCompatibleDriver = true;
289};
290
292
293
294#endif // QGSVECTORLAYERSAVEASDIALOG_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:56
Represents a coordinate reference system (CRS).
Map canvas is a class for displaying all GIS data types on a canvas.
A rectangle specified with double values.
A convenience class for writing vector layers to disk based formats (e.g.
ActionOnExistingFile
Enumeration to describe how to handle existing files.
bool onlySelected() const
Returns whether only selected features will be saved.
bool forceMulti() const
Returns true if force multi geometry type is checked.
QgsAttributeList selectedAttributes() const
Returns a list of attributes which are selected for saving.
QgsRectangle filterExtent() const
Determines the extent to be exported.
QString format() const
Returns the selected format in which the export should be written.
QStringList datasourceOptions() const
Returns a list of additional data source options which are passed to OGR.
bool persistMetadata() const
Returns true if the persist metadata (copy source metadata to destination layer) option is checked.
QString encoding() const
Returns the selected encoding for the target file.
void setIncludeZ(bool checked)
Sets whether the include z dimension checkbox should be checked.
QStringList attributesExportNames() const
Returns a list of export names for attributes.
QString fileName() const
Returns the target filename.
void setOnlySelected(bool onlySelected)
Sets whether only selected features will be saved.
QString layerName() const
Returns the target layer name.
bool automaticGeometryType() const
Returns true if geometry type is set to automatic.
Q_DECL_DEPRECATED QgsVectorLayerSaveAsDialog(long srsid, QWidget *parent=nullptr, Qt::WindowFlags fl=Qt::WindowFlags())
Construct a new QgsVectorLayerSaveAsDialog.
bool includeZ() const
Returns true if include z dimension is checked.
QgsCoordinateReferenceSystem crs() const
Returns the CRS chosen for export.
QStringList layerOptions() const
Returns a list of additional layer options which are passed to OGR.
void setForceMulti(bool checked)
Sets whether the force multi geometry checkbox should be checked.
QFlags< Option > Options
Available dialog options.
bool addToCanvas() const
Returns true if the "add to canvas" checkbox is checked.
void setMapCanvas(QgsMapCanvas *canvas)
Sets a map canvas to associate with the dialog.
Qgis::WkbType geometryType() const
Returns the selected flat geometry type for the export.
QgsVectorFileWriter::ActionOnExistingFile creationActionOnExistingFile() const
Returns the creation action.
QgsAttributeList attributesAsDisplayedValues() const
Returns selected attributes that must be exported with their displayed values instead of their raw va...
double scale() const
Returns the specified map scale.
bool hasFilterExtent() const
Determines if filtering the export by an extent is activated.
Qgis::FeatureSymbologyExport symbologyExport() const
Returns type of symbology export.
void setAddToCanvas(bool checked)
Sets whether the "add to canvas" checkbox should be checked.
Represents a vector layer which manages a vector based dataset.
#define SIP_ENUM_BASETYPE(type)
Definition qgis_sip.h:275
#define SIP_SKIP
Definition qgis_sip.h:134
QList< int > QgsAttributeList
Definition qgsfield.h:28
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsProjectionSelectionWidget::CrsOptions)