Skip to content

Commit

Permalink
don't pre-select any geometry type
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed May 9, 2020
1 parent 65dfb22 commit 95463e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/gui/qgsnewmemorylayerdialog.cpp
Expand Up @@ -64,9 +64,11 @@ QgsNewMemoryLayerDialog::QgsNewMemoryLayerDialog( QWidget *parent, Qt::WindowFla
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPointLayer.svg" ) ), tr( "MultiPoint" ), QgsWkbTypes::MultiPoint );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ), tr( "MultiLineString / MultiCurve" ), QgsWkbTypes::MultiLineString );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPolygonLayer.svg" ) ), tr( "MultiPolygon / MultiSurface" ), QgsWkbTypes::MultiPolygon );
mGeometryTypeBox->setCurrentIndex( -1 );

mGeometryWithZCheckBox->setEnabled( false );
mGeometryWithMCheckBox->setEnabled( false );
mCrsSelector->setEnabled( false );

mTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldText.svg" ) ), tr( "Text" ), "string" );
mTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldInteger.svg" ) ), tr( "Whole number" ), "integer" );
Expand All @@ -79,13 +81,16 @@ QgsNewMemoryLayerDialog::QgsNewMemoryLayerDialog( QWidget *parent, Qt::WindowFla
mWidth->setValidator( new QIntValidator( 1, 255, this ) );
mPrecision->setValidator( new QIntValidator( 0, 15, this ) );

mOkButton = mButtonBox->button( QDialogButtonBox::Ok );
mOkButton->setEnabled( false );

connect( mGeometryTypeBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsNewMemoryLayerDialog::geometryTypeChanged );
connect( mFieldNameEdit, &QLineEdit::textChanged, this, &QgsNewMemoryLayerDialog::fieldNameChanged );
connect( mAttributeView, &QTreeWidget::itemSelectionChanged, this, &QgsNewMemoryLayerDialog::selectionChanged );
connect( mAddAttributeButton, &QToolButton::clicked, this, &QgsNewMemoryLayerDialog::mAddAttributeButton_clicked );
connect( mRemoveAttributeButton, &QToolButton::clicked, this, &QgsNewMemoryLayerDialog::mRemoveAttributeButton_clicked );
connect( mButtonBox, &QDialogButtonBox::helpRequested, this, &QgsNewMemoryLayerDialog::showHelp );
geometryTypeChanged( mGeometryTypeBox->currentIndex() );
//geometryTypeChanged( mGeometryTypeBox->currentIndex() );
}

QgsWkbTypes::Type QgsNewMemoryLayerDialog::selectedType() const
Expand Down Expand Up @@ -114,6 +119,9 @@ void QgsNewMemoryLayerDialog::geometryTypeChanged( int )
mGeometryWithZCheckBox->setEnabled( isSpatial );
mGeometryWithMCheckBox->setEnabled( isSpatial );
mCrsSelector->setEnabled( isSpatial );

bool ok = ( !mNameLineEdit->text().isEmpty() && mGeometryTypeBox->currentIndex() != -1 );
mOkButton->setEnabled( ok );
}

void QgsNewMemoryLayerDialog::setCrs( const QgsCoordinateReferenceSystem &crs )
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsnewmemorylayerdialog.h
Expand Up @@ -77,6 +77,7 @@ class GUI_EXPORT QgsNewMemoryLayerDialog: public QDialog, private Ui::QgsNewMemo
private:

QString mCrsId;
QPushButton *mOkButton = nullptr;

private slots:

Expand Down

0 comments on commit 95463e6

Please sign in to comment.