29 #include <QPushButton> 32 #include <QFileDialog> 37 dialog.
setCrs( defaultCrs );
38 if ( dialog.exec() == QDialog::Rejected )
44 QString name = dialog.
layerName().isEmpty() ? tr(
"New scratch layer" ) : dialog.
layerName();
50 : QDialog( parent, fl )
63 mGeometryWithZCheckBox->setEnabled(
false );
64 mGeometryWithMCheckBox->setEnabled(
false );
66 mNameLineEdit->setText( tr(
"New scratch layer" ) );
68 connect( mGeometryTypeBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsNewMemoryLayerDialog::geometryTypeChanged );
69 connect( mButtonBox, &QDialogButtonBox::helpRequested,
this, &QgsNewMemoryLayerDialog::showHelp );
70 geometryTypeChanged( mGeometryTypeBox->currentIndex() );
77 ( mGeometryTypeBox->currentData( Qt::UserRole ).toInt() );
81 if ( mGeometryWithZCheckBox->isChecked() )
83 if ( mGeometryWithMCheckBox->isChecked() )
90 void QgsNewMemoryLayerDialog::geometryTypeChanged(
int )
93 ( mGeometryTypeBox->currentData( Qt::UserRole ).toInt() );
96 mGeometryWithZCheckBox->setEnabled( isSpatial );
97 mGeometryWithMCheckBox->setEnabled( isSpatial );
98 mCrsSelector->setEnabled( isSpatial );
103 mCrsSelector->setCrs( crs );
108 return mCrsSelector->crs();
113 return mNameLineEdit->text();
116 void QgsNewMemoryLayerDialog::showHelp()
118 QgsHelp::openHelp( QStringLiteral(
"managing_data_source/create_layers.html#creating-a-new-temporary-scratch-layer" ) );
QgsCoordinateReferenceSystem crs() const
Returns the selected CRS for the new layer.
QgsWkbTypes::Type selectedType() const
Returns the selected geometry type.
Container of fields for a vector layer.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
QgsNewMemoryLayerDialog(QWidget *parent SIP_TRANSFERTHIS=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
New dialog constructor.
Type
The WKB type describes the number of dimensions a geometry has.
static Type addM(Type type)
Adds the m dimension to a WKB type and returns the new type.
static Type addZ(Type type)
Adds the z dimension to a WKB type and returns the new type.
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the crs value for the new layer in the dialog.
static QgsVectorLayer * runAndCreateLayer(QWidget *parent=nullptr, const QgsCoordinateReferenceSystem &defaultCrs=QgsCoordinateReferenceSystem())
Runs the dialog and creates a new memory layer.
This class represents a coordinate reference system (CRS).
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
static QgsVectorLayer * createMemoryLayer(const QString &name, const QgsFields &fields, QgsWkbTypes::Type geometryType=QgsWkbTypes::NoGeometry, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Creates a new memory layer using the specified parameters.
Represents a vector layer which manages a vector based data sets.
QString layerName() const
Returns the layer name.