QGIS API Documentation  3.23.0-Master (eb871beae0)
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 #include <QDialog>
23 #include "qgshelp.h"
24 #include "qgsfields.h"
25 #include "qgsvectorfilewriter.h"
26 #include "qgis_gui.h"
27 
28 #define SIP_NO_FILE
29 
30 class QgsVectorLayer;
31 
38 class GUI_EXPORT QgsVectorLayerSaveAsDialog : public QDialog, private Ui::QgsVectorLayerSaveAsDialogBase
39 {
40  Q_OBJECT
41 
42  public:
43 
45  enum Option
46  {
47  Symbology = 1,
48  DestinationCrs = 1 << 2,
49  Fields = 1 << 3,
50  AddToCanvas = 1 << 4,
51  SelectedOnly = 1 << 5,
52  GeometryType = 1 << 6,
53  Extent = 1 << 7,
54  Metadata = 1 << 8,
55  AllOptions = ~0
56  };
57  Q_DECLARE_FLAGS( Options, Option )
58 
59 
64  Q_DECL_DEPRECATED QgsVectorLayerSaveAsDialog( long srsid, QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags() );
65 
69  QgsVectorLayerSaveAsDialog( QgsVectorLayer *layer, Options options = AllOptions, QWidget *parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags() );
70 
75  QString format() const;
76 
80  QString encoding() const;
81 
85  QString filename() const;
86 
90  QString layername() const;
91 
96  QStringList datasourceOptions() const;
97 
102  QStringList layerOptions() const;
103 
109  Q_DECL_DEPRECATED long crs() const;
110 
115  QgsCoordinateReferenceSystem crsObject() const;
116 
120  QgsAttributeList selectedAttributes() const;
122  QgsAttributeList attributesAsDisplayedValues() const;
123 
129  bool addToCanvas() const;
130 
137  void setAddToCanvas( bool checked );
138 
145  int symbologyExport() const;
146 
151  double scale() const;
152 
156  void setMapCanvas( QgsMapCanvas *canvas );
157 
162  bool hasFilterExtent() const;
163 
168  QgsRectangle filterExtent() const;
169 
173  void setOnlySelected( bool onlySelected );
174 
178  bool onlySelected() const;
179 
185  bool persistMetadata() const;
186 
193  QgsWkbTypes::Type geometryType() const;
194 
199  bool automaticGeometryType() const;
200 
205  bool forceMulti() const;
206 
210  void setForceMulti( bool checked );
211 
216  bool includeZ() const;
217 
221  void setIncludeZ( bool checked );
222 
224  QgsVectorFileWriter::ActionOnExistingFile creationActionOnExistingFile() const;
225 
226  private slots:
227 
228  void mFormatComboBox_currentIndexChanged( int idx );
229  void mCrsSelector_crsChanged( const QgsCoordinateReferenceSystem &crs );
230  void showHelp();
231  void mSymbologyExportComboBox_currentIndexChanged( const QString &text );
232  void mGeometryTypeComboBox_currentIndexChanged( int index );
233  void accept() override;
234  void mSelectAllAttributes_clicked();
235  void mDeselectAllAttributes_clicked();
236  void mReplaceRawFieldValues_stateChanged( int state );
237  void mAttributeTable_itemChanged( QTableWidgetItem *item );
238 
239  private:
240  void setup();
241  QList< QPair< QLabel *, QWidget * > > createControls( const QMap<QString, QgsVectorFileWriter::Option *> &options );
242 
243  QgsCoordinateReferenceSystem mSelectedCrs;
244 
245  QgsRectangle mLayerExtent;
247  QgsVectorLayer *mLayer = nullptr;
248  QgsMapCanvas *mMapCanvas = nullptr;
249  bool mAttributeTableItemChangedSlotEnabled;
250  bool mReplaceRawFieldValuesStateChangedSlotEnabled;
251  QgsVectorFileWriter::ActionOnExistingFile mActionOnExistingFile;
252  Options mOptions = AllOptions;
253 };
254 
255 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsVectorLayerSaveAsDialog::Options )
256 
257 
258 #endif // QGSVECTORLAYERSAVEASDIALOG_H
This class represents a coordinate reference system (CRS).
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:89
A rectangle specified with double values.
Definition: qgsrectangle.h:42
ActionOnExistingFile
Combination of CanAddNewLayer, CanAppendToExistingLayer, CanAddNewFieldsToExistingLayer or CanDeleteL...
Class to select destination file, type and CRS for ogr layers.
Option
Bitmask of options to be shown.
Represents a vector layer which manages a vector based data sets.
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:70
QList< int > QgsAttributeList
Definition: qgsfield.h:26
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
const QgsCoordinateReferenceSystem & crs