QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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
73 QgsVectorLayer *layer, QgsVectorLayerSaveAsDialog::Options options = QgsVectorLayerSaveAsDialog::Option::AllOptions, QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags()
74 );
75
81 QString format() const;
82
86 QString encoding() const;
87
93 QString fileName() const;
94
100 QString layerName() const;
101
108 QStringList datasourceOptions() const;
109
116 QStringList layerOptions() const;
117
124
129
135
139 QStringList attributesExportNames() const;
140
146 bool addToCanvas() const;
147
154 void setAddToCanvas( bool checked );
155
159 Qgis::FeatureSymbologyExport symbologyExport() const;
160
165 double scale() const;
166
170 void setMapCanvas( QgsMapCanvas *canvas );
171
176 bool hasFilterExtent() const;
177
183
189 void setOnlySelected( bool onlySelected );
190
196 bool onlySelected() const;
197
203 bool persistMetadata() const;
204
211 Qgis::WkbType geometryType() const;
212
217 bool automaticGeometryType() const;
218
225 bool forceMulti() const;
226
232 void setForceMulti( bool checked );
233
240 bool includeZ() const;
241
247 void setIncludeZ( bool checked );
248
252 QgsVectorFileWriter::ActionOnExistingFile creationActionOnExistingFile() const;
253
254 void accept() override;
255
256 private slots:
257
258 void mFormatComboBox_currentIndexChanged( int idx );
259 void mCrsSelector_crsChanged( const QgsCoordinateReferenceSystem &crs );
260 void showHelp();
261 void mSymbologyExportComboBox_currentIndexChanged( const QString &text );
262 void mGeometryTypeComboBox_currentIndexChanged( int index );
263 void mSelectAllAttributes_clicked();
264 void mDeselectAllAttributes_clicked();
265 void mUseAliasesForExportedName_stateChanged( int state );
266 void mReplaceRawFieldValues_stateChanged( int state );
267 void mAttributeTable_itemChanged( QTableWidgetItem *item );
268
269 private:
270 enum class ColumnIndex : int
271 {
272 Name = 0,
273 ExportName = 1,
274 Type = 2,
275 ExportAsDisplayedValue = 3
276 };
277
278 void setup();
279 QList<QPair<QLabel *, QWidget *>> createControls( const QMap<QString, QgsVectorFileWriter::Option *> &options );
280
281 QgsCoordinateReferenceSystem mSelectedCrs;
282
283 QgsRectangle mLayerExtent;
285 QgsVectorLayer *mLayer = nullptr;
286 QgsMapCanvas *mMapCanvas = nullptr;
287 QgsVectorFileWriter::ActionOnExistingFile mActionOnExistingFile;
288 Options mOptions = Option::AllOptions;
289 QString mDefaultOutputLayerNameFromInputLayerName;
290 bool mAddToCanvasStateOnOpenCompatibleDriver = true;
291 QHash<QString, QPair<bool, std::optional<bool>>> mFieldsState;
292 QString mPreviousFormat;
293};
294
296
297
298#endif // QGSVECTORLAYERSAVEASDIALOG_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:62
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:274
#define SIP_SKIP
Definition qgis_sip.h:133
QList< int > QgsAttributeList
Definition qgsfield.h:30
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsProjectionSelectionWidget::CrsOptions)