Skip to content
Permalink
Browse files

Merge pull request #5819 from nyalldawson/dialogs

New layer dialog improvements
  • Loading branch information
nyalldawson committed Dec 9, 2017
2 parents fb28adf + a603a3d commit 010cb1567b388a7b6be25b11ef5d6e80785ae430
@@ -68,18 +68,18 @@ QgsNewGeoPackageLayerDialog::QgsNewGeoPackageLayerDialog( QWidget *parent, Qt::W
mGeometryTypeBox->addItem( tr( "Point" ), wkbPoint );
mGeometryTypeBox->addItem( tr( "Line" ), wkbLineString );
mGeometryTypeBox->addItem( tr( "Polygon" ), wkbPolygon );
mGeometryTypeBox->addItem( tr( "Multi point" ), wkbMultiPoint );
mGeometryTypeBox->addItem( tr( "Multi line" ), wkbMultiLineString );
mGeometryTypeBox->addItem( tr( "Multi polygon" ), wkbMultiPolygon );
mGeometryTypeBox->addItem( tr( "MultiPoint" ), wkbMultiPoint );
mGeometryTypeBox->addItem( tr( "MultiLine" ), wkbMultiLineString );
mGeometryTypeBox->addItem( tr( "MultiPolygon" ), wkbMultiPolygon );

#if 0
// QGIS always create CompoundCurve and there's no real interest of having just CircularString. CompoundCurve are more useful
mGeometryTypeBox->addItem( tr( "Circular string" ), wkbCircularString );
mGeometryTypeBox->addItem( tr( "CircularString" ), wkbCircularString );
#endif
mGeometryTypeBox->addItem( tr( "Compound curve" ), wkbCompoundCurve );
mGeometryTypeBox->addItem( tr( "Curve polygon" ), wkbCurvePolygon );
mGeometryTypeBox->addItem( tr( "Multi curve" ), wkbMultiCurve );
mGeometryTypeBox->addItem( tr( "Multi surface" ), wkbMultiSurface );
mGeometryTypeBox->addItem( tr( "CompoundCurve" ), wkbCompoundCurve );
mGeometryTypeBox->addItem( tr( "CurvePolygon" ), wkbCurvePolygon );
mGeometryTypeBox->addItem( tr( "MultiCurve" ), wkbMultiCurve );
mGeometryTypeBox->addItem( tr( "MultiSurface" ), wkbMultiSurface );

mGeometryWithZCheckBox->setEnabled( false );
mGeometryWithMCheckBox->setEnabled( false );
@@ -58,9 +58,9 @@ QgsNewMemoryLayerDialog::QgsNewMemoryLayerDialog( QWidget *parent, Qt::WindowFla
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 );
mGeometryTypeBox->addItem( tr( "MultiPoint" ), QgsWkbTypes::MultiPoint );
mGeometryTypeBox->addItem( tr( "MultiLine" ), QgsWkbTypes::MultiLineString );
mGeometryTypeBox->addItem( tr( "MultiPolygon" ), QgsWkbTypes::MultiPolygon );

mGeometryWithZCheckBox->setEnabled( false );
mGeometryWithMCheckBox->setEnabled( false );
@@ -69,6 +69,7 @@ QgsNewMemoryLayerDialog::QgsNewMemoryLayerDialog( QWidget *parent, Qt::WindowFla

connect( mGeometryTypeBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsNewMemoryLayerDialog::geometryTypeChanged );
connect( mButtonBox, &QDialogButtonBox::helpRequested, this, &QgsNewMemoryLayerDialog::showHelp );
geometryTypeChanged( mGeometryTypeBox->currentIndex() );
}

QgsNewMemoryLayerDialog::~QgsNewMemoryLayerDialog()
@@ -167,8 +167,11 @@ QgsWkbTypes::Type QgsNewVectorLayerDialog::selectedType() const
wkbType = static_cast<QgsWkbTypes::Type>
( mGeometryTypeBox->currentData( Qt::UserRole ).toInt() );

if ( mGeometryWithZCheckBox->isChecked() && wkbType != QgsWkbTypes::Unknown )
wkbType = QgsWkbTypes::to25D( wkbType );
if ( mGeometryWithZCheckBox->isChecked() )
wkbType = QgsWkbTypes::addZ( wkbType );

if ( mGeometryWithMCheckBox->isChecked() )
wkbType = QgsWkbTypes::addM( wkbType );

return wkbType;
}
@@ -361,34 +361,23 @@ static QgsOgrLayerItem *dataItemForLayer( QgsDataItem *parentItem, QString name,

QgsLayerItem::LayerType layerType = QgsLayerItem::Vector;
OGRwkbGeometryType ogrType = QgsOgrProvider::getOgrGeomType( hLayer );
switch ( ogrType )
QgsWkbTypes::Type wkbType = QgsOgrProviderUtils::qgisTypeFromOgrType( ogrType );
switch ( QgsWkbTypes::geometryType( wkbType ) )
{
case wkbUnknown:
case wkbGeometryCollection:
case QgsWkbTypes::UnknownGeometry:
break;
case wkbNone:
case QgsWkbTypes::NullGeometry:
layerType = QgsLayerItem::TableLayer;
break;
case wkbPoint:
case wkbMultiPoint:
case wkbPoint25D:
case wkbMultiPoint25D:
case QgsWkbTypes::PointGeometry:
layerType = QgsLayerItem::Point;
break;
case wkbLineString:
case wkbMultiLineString:
case wkbLineString25D:
case wkbMultiLineString25D:
case QgsWkbTypes::LineGeometry:
layerType = QgsLayerItem::Line;
break;
case wkbPolygon:
case wkbMultiPolygon:
case wkbPolygon25D:
case wkbMultiPolygon25D:
case QgsWkbTypes::PolygonGeometry:
layerType = QgsLayerItem::Polygon;
break;
default:
break;
}

QgsDebugMsgLevel( QString( "ogrType = %1 layertype = %2" ).arg( ogrType ).arg( layerType ), 2 );

0 comments on commit 010cb15

Please sign in to comment.
You can’t perform that action at this time.