29 #include <QPushButton> 33 #include <QFileDialog> 38 dialog.
setCrs( defaultCrs );
39 if ( dialog.exec() == QDialog::Rejected )
45 QString name = dialog.
layerName().isEmpty() ? tr(
"New scratch layer" ) : dialog.
layerName();
51 : QDialog( parent, fl )
64 mGeometryWithZCheckBox->setEnabled(
false );
65 mGeometryWithMCheckBox->setEnabled(
false );
67 mNameLineEdit->setText( tr(
"New scratch layer" ) );
69 connect( mGeometryTypeBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsNewMemoryLayerDialog::geometryTypeChanged );
70 connect( mButtonBox, &QDialogButtonBox::helpRequested,
this, &QgsNewMemoryLayerDialog::showHelp );
71 geometryTypeChanged( mGeometryTypeBox->currentIndex() );
78 ( mGeometryTypeBox->currentData( Qt::UserRole ).toInt() );
82 if ( mGeometryWithZCheckBox->isChecked() )
84 if ( mGeometryWithMCheckBox->isChecked() )
91 void QgsNewMemoryLayerDialog::geometryTypeChanged(
int )
94 ( mGeometryTypeBox->currentData( Qt::UserRole ).toInt() );
97 mGeometryWithZCheckBox->setEnabled( isSpatial );
98 mGeometryWithMCheckBox->setEnabled( isSpatial );
99 mCrsSelector->setEnabled( isSpatial );
104 mCrsSelector->setCrs( crs );
109 return mCrsSelector->crs();
114 return mNameLineEdit->text();
117 void QgsNewMemoryLayerDialog::showHelp()
119 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.