From bac80aa93a650a5254333ebddd8f337563674800 Mon Sep 17 00:00:00 2001 From: Harrissou Sant-anna Date: Thu, 7 Dec 2017 03:41:43 +0100 Subject: [PATCH] [need-docs] Reorganize the new memory layer (#5804) --- src/gui/qgsnewmemorylayerdialog.cpp | 64 ++++++------ src/gui/qgsnewmemorylayerdialog.h | 1 + src/ui/qgsnewmemorylayerdialogbase.ui | 140 +++++++++----------------- 3 files changed, 76 insertions(+), 129 deletions(-) diff --git a/src/gui/qgsnewmemorylayerdialog.cpp b/src/gui/qgsnewmemorylayerdialog.cpp index 821b431d4f8..ba7acfec68a 100644 --- a/src/gui/qgsnewmemorylayerdialog.cpp +++ b/src/gui/qgsnewmemorylayerdialog.cpp @@ -54,9 +54,20 @@ QgsNewMemoryLayerDialog::QgsNewMemoryLayerDialog( QWidget *parent, Qt::WindowFla QgsSettings settings; restoreGeometry( settings.value( QStringLiteral( "Windows/NewMemoryLayer/geometry" ) ).toByteArray() ); - mPointRadioButton->setChecked( true ); + mGeometryTypeBox->addItem( tr( "Non spatial" ), QgsWkbTypes::NoGeometry ); + mGeometryTypeBox->addItem( tr( "Point" ), QgsWkbTypes::Point ); + mGeometryTypeBox->addItem( tr( "Line" ), QgsWkbTypes::LineString ); + mGeometryTypeBox->addItem( tr( "Polygon" ), QgsWkbTypes::Polygon ); + mGeometryTypeBox->addItem( tr( "Multi point" ), QgsWkbTypes::MultiPoint ); + mGeometryTypeBox->addItem( tr( "Multi line" ), QgsWkbTypes::MultiLineString ); + mGeometryTypeBox->addItem( tr( "Multi polygon" ), QgsWkbTypes::MultiPolygon ); + + mGeometryWithZCheckBox->setEnabled( false ); + mGeometryWithMCheckBox->setEnabled( false ); + mNameLineEdit->setText( tr( "New scratch layer" ) ); + connect( mGeometryTypeBox, static_cast( &QComboBox::currentIndexChanged ), this, &QgsNewMemoryLayerDialog::geometryTypeChanged ); connect( mButtonBox, &QDialogButtonBox::helpRequested, this, &QgsNewMemoryLayerDialog::showHelp ); } @@ -68,45 +79,30 @@ QgsNewMemoryLayerDialog::~QgsNewMemoryLayerDialog() QgsWkbTypes::Type QgsNewMemoryLayerDialog::selectedType() const { - QgsWkbTypes::Type wkbType = QgsWkbTypes::Unknown; - if ( !buttonGroupGeometry->isChecked() ) - { - wkbType = QgsWkbTypes::NoGeometry; - } - else if ( mPointRadioButton->isChecked() ) - { - wkbType = QgsWkbTypes::Point; - } - else if ( mLineRadioButton->isChecked() ) - { - wkbType = QgsWkbTypes::LineString; - } - else if ( mPolygonRadioButton->isChecked() ) - { - wkbType = QgsWkbTypes::Polygon; - } - else if ( mMultiPointRadioButton->isChecked() ) - { - wkbType = QgsWkbTypes::MultiPoint; - } - else if ( mMultiLineRadioButton->isChecked() ) - { - wkbType = QgsWkbTypes::MultiLineString; - } - else if ( mMultiPolygonRadioButton->isChecked() ) - { - wkbType = QgsWkbTypes::MultiPolygon; - } + QgsWkbTypes::Type geomType = QgsWkbTypes::Unknown; + geomType = static_cast + ( mGeometryTypeBox->currentData( Qt::UserRole ).toInt() ); - if ( wkbType != QgsWkbTypes::Unknown && wkbType != QgsWkbTypes::NoGeometry ) + if ( geomType != QgsWkbTypes::Unknown && geomType != QgsWkbTypes::NoGeometry ) { if ( mGeometryWithZCheckBox->isChecked() ) - wkbType = QgsWkbTypes::addZ( wkbType ); + geomType = QgsWkbTypes::addZ( geomType ); if ( mGeometryWithMCheckBox->isChecked() ) - wkbType = QgsWkbTypes::addM( wkbType ); + geomType = QgsWkbTypes::addM( geomType ); } - return wkbType; + return geomType; +} + +void QgsNewMemoryLayerDialog::geometryTypeChanged( int ) +{ + QgsWkbTypes::Type geomType = static_cast + ( mGeometryTypeBox->currentData( Qt::UserRole ).toInt() ); + + bool isSpatial = geomType != QgsWkbTypes::NoGeometry; + mGeometryWithZCheckBox->setEnabled( isSpatial ); + mGeometryWithMCheckBox->setEnabled( isSpatial ); + mCrsSelector->setEnabled( isSpatial ); } void QgsNewMemoryLayerDialog::setCrs( const QgsCoordinateReferenceSystem &crs ) diff --git a/src/gui/qgsnewmemorylayerdialog.h b/src/gui/qgsnewmemorylayerdialog.h index 8b032ec56e3..7e6dade3981 100644 --- a/src/gui/qgsnewmemorylayerdialog.h +++ b/src/gui/qgsnewmemorylayerdialog.h @@ -71,6 +71,7 @@ class GUI_EXPORT QgsNewMemoryLayerDialog: public QDialog, private Ui::QgsNewMemo private slots: + void geometryTypeChanged( int index ); void showHelp(); }; diff --git a/src/ui/qgsnewmemorylayerdialogbase.ui b/src/ui/qgsnewmemorylayerdialogbase.ui index dc514f1ba7e..0252c86e178 100644 --- a/src/ui/qgsnewmemorylayerdialogbase.ui +++ b/src/ui/qgsnewmemorylayerdialogbase.ui @@ -7,7 +7,7 @@ 0 0 444 - 304 + 233 @@ -24,100 +24,54 @@ - - - Geometry type and CRS - - - true - - - - - - - - Multipoint - - - - - - - Multipolygon - - - - - - - Polygon - - - - - - - Point - - - - - - - Line - - - - - - - Multiline - - - - - - - - - - - Include Z dimension - - - - - - - Include M values - - - - - - - - - Qt::StrongFocus - - - - - - - - - + + + + + Include M values + + + + + + + Geometry type + + + + Layer name - + + + + Include Z dimension + + + + + + + + + + + + 0 + 0 + + + + Qt::StrongFocus + + + @@ -168,15 +122,11 @@ - buttonGroupGeometry - mPointRadioButton - mLineRadioButton - mPolygonRadioButton - mMultiPointRadioButton - mMultiLineRadioButton - mMultiPolygonRadioButton - mCrsSelector mNameLineEdit + mGeometryTypeBox + mGeometryWithZCheckBox + mGeometryWithMCheckBox + mCrsSelector