28 #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 )
55 restoreGeometry( settings.
value( QStringLiteral(
"Windows/NewMemoryLayer/geometry" ) ).toByteArray() );
65 mGeometryWithZCheckBox->setEnabled(
false );
66 mGeometryWithMCheckBox->setEnabled(
false );
68 mNameLineEdit->setText( tr(
"New scratch layer" ) );
70 connect( mGeometryTypeBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsNewMemoryLayerDialog::geometryTypeChanged );
71 connect( mButtonBox, &QDialogButtonBox::helpRequested,
this, &QgsNewMemoryLayerDialog::showHelp );
72 geometryTypeChanged( mGeometryTypeBox->currentIndex() );
85 ( mGeometryTypeBox->currentData( Qt::UserRole ).toInt() );
89 if ( mGeometryWithZCheckBox->isChecked() )
91 if ( mGeometryWithMCheckBox->isChecked() )
98 void QgsNewMemoryLayerDialog::geometryTypeChanged(
int )
101 ( mGeometryTypeBox->currentData( Qt::UserRole ).toInt() );
104 mGeometryWithZCheckBox->setEnabled( isSpatial );
105 mGeometryWithMCheckBox->setEnabled( isSpatial );
106 mCrsSelector->setEnabled( isSpatial );
111 mCrsSelector->setCrs( crs );
116 return mCrsSelector->crs();
121 return mNameLineEdit->text();
124 void QgsNewMemoryLayerDialog::showHelp()
126 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.
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
Container of fields for a vector layer.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
void saveGeometry(QWidget *widget, const QString &keyName)
Save the wigget geometry into settings.
bool restoreGeometry(QWidget *widget, const QString &keyName)
Restore the wigget geometry from settings.
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.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
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 openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
~QgsNewMemoryLayerDialog() override
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.
QgsNewMemoryLayerDialog(QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
QString layerName() const
Returns the layer name.