Skip to content
Permalink
Browse files

Add QgsLayerItem::iconForWkbType() and QgsWkbTypes::translatedDisplay…

…String()

and use them to avoid a lot of copy&paste in "New layer XXXX" dialogs and
providers.
  • Loading branch information
rouault authored and nyalldawson committed Nov 12, 2020
1 parent 40569f4 commit af9da65c236a07acfbc960c6fbce791c133ea0e7
Showing with 254 additions and 228 deletions.
  1. +8 −1 python/core/auto_generated/geometry/qgswkbtypes.sip.in
  2. +8 −0 python/core/auto_generated/qgsdataitem.sip.in
  3. +13 −7 src/app/qgsnewspatialitelayerdialog.cpp
  4. +68 −0 src/core/geometry/qgswkbtypes.cpp
  5. +8 −1 src/core/geometry/qgswkbtypes.h
  6. +20 −0 src/core/qgsdataitem.cpp
  7. +7 −0 src/core/qgsdataitem.h
  8. +11 −5 src/gui/ogr/qgsvectorlayersaveasdialog.cpp
  9. +2 −15 src/gui/qgsidentifymenu.cpp
  10. +19 −12 src/gui/qgsnewgeopackagelayerdialog.cpp
  11. +18 −11 src/gui/qgsnewmemorylayerdialog.cpp
  12. +12 −5 src/gui/qgsnewvectorlayerdialog.cpp
  13. +17 −10 src/gui/qgsnewvectortabledialog.cpp
  14. +4 −3 src/gui/qgstextformatwidget.cpp
  15. +4 −3 src/gui/symbology/qgsstylemanagerdialog.cpp
  16. +4 −3 src/gui/symbology/qgssymbollayerwidget.cpp
  17. +4 −3 src/plugins/geometry_checker/qgsgeometrycheckersetuptab.cpp
  18. +4 −3 src/providers/db2/qgsdb2sourceselect.cpp
  19. +4 −23 src/providers/db2/qgsdb2tablemodel.cpp
  20. +0 −2 src/providers/db2/qgsdb2tablemodel.h
  21. +4 −3 src/providers/mssql/qgsmssqlsourceselect.cpp
  22. +3 −21 src/providers/mssql/qgsmssqltablemodel.cpp
  23. +0 −2 src/providers/mssql/qgsmssqltablemodel.h
  24. +0 −42 src/providers/oracle/qgsoracleconn.cpp
  25. +0 −1 src/providers/oracle/qgsoracleconn.h
  26. +1 −1 src/providers/oracle/qgsoracledataitems.cpp
  27. +4 −3 src/providers/oracle/qgsoraclesourceselect.cpp
  28. +3 −24 src/providers/oracle/qgsoracletablemodel.cpp
  29. +0 −2 src/providers/oracle/qgsoracletablemodel.h
  30. +3 −2 src/providers/postgres/qgspgsourceselect.cpp
  31. +1 −18 src/providers/postgres/qgspgtablemodel.cpp
  32. +0 −2 src/providers/postgres/qgspgtablemodel.h
@@ -251,7 +251,14 @@ GeometryCollections are reported as QgsWkbTypes.UnknownGeometry.

static QString displayString( Type type ) /HoldGIL/;
%Docstring
Returns a display string type for a WKB type, e.g., the geometry name used in WKT geometry representations.
Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geometry representations.
%End

static QString translatedDisplayString( Type type ) /HoldGIL/;
%Docstring
Returns a translated display string type for a WKB type, e.g., the geometry name used in WKT geometry representations.

.. versionadded:: 3.18
%End

static QString geometryDisplayString( GeometryType type ) /HoldGIL/;
@@ -576,6 +576,14 @@ Use QgsDataItemGuiProvider.deleteLayer instead
protected:

public:

static QIcon iconForWkbType( QgsWkbTypes::Type type );
%Docstring
Returns the icon for a vector layer whose geometry type is provided.

.. versionadded:: 3.18
%End

static QIcon iconPoint();
static QIcon iconLine();
static QIcon iconPolygon();
@@ -24,6 +24,7 @@
#include "qgsapplication.h"
#include "qgsabstractdatabaseproviderconnection.h"
#include "qgisapp.h" // <- for theme icons
#include "qgsdataitem.h"
#include "qgsvectorlayer.h"
#include "qgsproject.h"
#include "qgscoordinatereferencesystem.h"
@@ -50,13 +51,18 @@ QgsNewSpatialiteLayerDialog::QgsNewSpatialiteLayerDialog( QWidget *parent, Qt::W
setupUi( this );
QgsGui::enableAutoGeometryRestore( this );

mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconTableLayer.svg" ) ), tr( "No Geometry" ), QString() );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPointLayer.svg" ) ), tr( "Point" ), QStringLiteral( "POINT" ) );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ), tr( "Line" ), QStringLiteral( "LINESTRING" ) );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPolygonLayer.svg" ) ), tr( "Polygon" ), QStringLiteral( "POLYGON" ) );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPointLayer.svg" ) ), tr( "MultiPoint" ), QStringLiteral( "MULTIPOINT" ) );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ), tr( "MultiLine" ), QStringLiteral( "MULTILINESTRING" ) );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPolygonLayer.svg" ) ), tr( "MultiPolygon" ), QStringLiteral( "MULTIPOLYGON" ) );
const auto addGeomItem = [this]( QgsWkbTypes::Type type, const QString & sqlType )
{
mGeometryTypeBox->addItem( QgsLayerItem::iconForWkbType( type ), QgsWkbTypes::translatedDisplayString( type ), sqlType );
};

addGeomItem( QgsWkbTypes::NoGeometry, QString() );
addGeomItem( QgsWkbTypes::Point, QStringLiteral( "POINT" ) );
addGeomItem( QgsWkbTypes::LineString, QStringLiteral( "LINESTRING" ) );
addGeomItem( QgsWkbTypes::Polygon, QStringLiteral( "POLYGON" ) );
addGeomItem( QgsWkbTypes::MultiPoint, QStringLiteral( "MULTIPOINT" ) );
addGeomItem( QgsWkbTypes::MultiLineString, QStringLiteral( "MULTILINESTRING" ) );
addGeomItem( QgsWkbTypes::MultiPolygon, QStringLiteral( "MULTIPOLYGON" ) );
mGeometryTypeBox->setCurrentIndex( -1 );

pbnFindSRID->setEnabled( false );
@@ -152,6 +152,74 @@ QString QgsWkbTypes::displayString( Type type )
return it->mName;
}

QString QgsWkbTypes::translatedDisplayString( Type type )
{
switch ( type )
{
case Unknown: return QObject::tr( "Unknown" );
case Point: return QObject::tr( "Point" );
case LineString: return QObject::tr( "LineString" );
case Polygon: return QObject::tr( "Polygon" );
case Triangle: return QObject::tr( "Triangle" );
case MultiPoint: return QObject::tr( "MultiPoint" );
case MultiLineString: return QObject::tr( "MultiLine" );
case MultiPolygon: return QObject::tr( "MultiPolygon" );
case GeometryCollection: return QObject::tr( "GeometryCollection" );
case CircularString: return QObject::tr( "CircularString" );
case CompoundCurve: return QObject::tr( "CompoundCurve" );
case CurvePolygon: return QObject::tr( "CurvePolygon" );
case MultiCurve: return QObject::tr( "MultiCurve" );
case MultiSurface: return QObject::tr( "MultiSurface" );
case NoGeometry: return QObject::tr( "No Geometry" );
case PointZ: return QObject::tr( "PointZ" );
case LineStringZ: return QObject::tr( "LineStringZ" );
case PolygonZ: return QObject::tr( "PolygonZ" );
case TriangleZ: return QObject::tr( "TriangleZ" );
case MultiPointZ: return QObject::tr( "MultiPointZ" );
case MultiLineStringZ: return QObject::tr( "MultiLineZ" );
case MultiPolygonZ: return QObject::tr( "MultiPolygonZ" );
case GeometryCollectionZ: return QObject::tr( "GeometryCollectionZ" );
case CircularStringZ: return QObject::tr( "CircularStringZ" );
case CompoundCurveZ: return QObject::tr( "CompoundCurveZ" );
case CurvePolygonZ: return QObject::tr( "CurvePolygonZ" );
case MultiCurveZ: return QObject::tr( "MultiCurveZ" );
case MultiSurfaceZ: return QObject::tr( "MultiSurfaceZ" );
case PointM: return QObject::tr( "PointM" );
case LineStringM: return QObject::tr( "LineStringM" );
case PolygonM: return QObject::tr( "PolygonM" );
case TriangleM: return QObject::tr( "TriangleM" );
case MultiPointM: return QObject::tr( "MultiPointM" );
case MultiLineStringM: return QObject::tr( "MultiLineStringM" );
case MultiPolygonM: return QObject::tr( "MultiPolygonM" );
case GeometryCollectionM: return QObject::tr( "GeometryCollectionM" );
case CircularStringM: return QObject::tr( "CircularStringM" );
case CompoundCurveM: return QObject::tr( "CompoundCurveM" );
case CurvePolygonM: return QObject::tr( "CurvePolygonM" );
case MultiCurveM: return QObject::tr( "MultiCurveM" );
case MultiSurfaceM: return QObject::tr( "MultiSurfaceM" );
case PointZM: return QObject::tr( "PointZM" );
case LineStringZM: return QObject::tr( "LineStringZM" );
case PolygonZM: return QObject::tr( "PolygonZM" );
case MultiPointZM: return QObject::tr( "MultiPointZM" );
case MultiLineStringZM: return QObject::tr( "MultiLineZM" );
case MultiPolygonZM: return QObject::tr( "MultiPolygonZM" );
case GeometryCollectionZM: return QObject::tr( "GeometryCollectionZM" );
case CircularStringZM: return QObject::tr( "CircularStringZM" );
case CompoundCurveZM: return QObject::tr( "CompoundCurveZM" );
case CurvePolygonZM: return QObject::tr( "CurvePolygonZM" );
case MultiCurveZM: return QObject::tr( "MultiCurveZM" );
case MultiSurfaceZM: return QObject::tr( "MultiSurfaceZM" );
case TriangleZM: return QObject::tr( "TriangleZM" );
case Point25D: return QObject::tr( "Point25D" );
case LineString25D: return QObject::tr( "LineString25D" );
case Polygon25D: return QObject::tr( "Polygon25D" );
case MultiPoint25D: return QObject::tr( "MultiPoint25D" );
case MultiLineString25D: return QObject::tr( "MultiLineString25D" );
case MultiPolygon25D: return QObject::tr( "MultiPolygon25D" );
}
return QString();
}

QString QgsWkbTypes::geometryDisplayString( QgsWkbTypes::GeometryType type )
{

@@ -1014,10 +1014,17 @@ class CORE_EXPORT QgsWkbTypes
}

/**
* Returns a display string type for a WKB type, e.g., the geometry name used in WKT geometry representations.
* Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geometry representations.
*/
static QString displayString( Type type ) SIP_HOLDGIL;

/**
* Returns a translated display string type for a WKB type, e.g., the geometry name used in WKT geometry representations.
*
* \since QGIS 3.18
*/
static QString translatedDisplayString( Type type ) SIP_HOLDGIL;

/**
* Returns a display string for a geometry type.
*
@@ -51,6 +51,26 @@
#include "cpl_string.h"

// shared icons

QIcon QgsLayerItem::iconForWkbType( QgsWkbTypes::Type type )
{
QgsWkbTypes::GeometryType geomType = QgsWkbTypes::geometryType( QgsWkbTypes::Type( type ) );
switch ( geomType )
{
case QgsWkbTypes::NullGeometry:
return iconTable();
case QgsWkbTypes::PointGeometry:
return iconPoint();
case QgsWkbTypes::LineGeometry:
return iconLine();
case QgsWkbTypes::PolygonGeometry:
return iconPolygon();
default:
break;
}
return iconDefault();
}

QIcon QgsLayerItem::iconPoint()
{
return QgsApplication::getThemeIcon( QStringLiteral( "/mIconPointLayer.svg" ) );
@@ -603,6 +603,13 @@ class CORE_EXPORT QgsLayerItem : public QgsDataItem
QStringList mSupportFormats;

public:

/**
* Returns the icon for a vector layer whose geometry type is provided.
* \since QGIS 3.18
*/
static QIcon iconForWkbType( QgsWkbTypes::Type type );

static QIcon iconPoint();
static QIcon iconLine();
static QIcon iconPolygon();
@@ -16,6 +16,7 @@
* *
***************************************************************************/
#include "qgslogger.h"
#include "qgsdataitem.h"
#include "qgsvectorlayersaveasdialog.h"
#include "qgsprojectionselectiondialog.h"
#include "qgsvectordataprovider.h"
@@ -130,13 +131,18 @@ void QgsVectorLayerSaveAsDialog::setup()
mFormatComboBox->setCurrentIndex( mFormatComboBox->findData( format ) );
mFormatComboBox->blockSignals( false );

const auto addGeomItem = [this]( QgsWkbTypes::Type type )
{
mGeometryTypeComboBox->addItem( QgsLayerItem::iconForWkbType( type ), QgsWkbTypes::translatedDisplayString( type ), type );
};

//add geometry types to combobox
mGeometryTypeComboBox->addItem( tr( "Automatic" ), -1 );
mGeometryTypeComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPointLayer.svg" ) ), QgsWkbTypes::displayString( QgsWkbTypes::Point ), QgsWkbTypes::Point );
mGeometryTypeComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ), QgsWkbTypes::displayString( QgsWkbTypes::LineString ), QgsWkbTypes::LineString );
mGeometryTypeComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPolygonLayer.svg" ) ), QgsWkbTypes::displayString( QgsWkbTypes::Polygon ), QgsWkbTypes::Polygon );
mGeometryTypeComboBox->addItem( QgsWkbTypes::displayString( QgsWkbTypes::GeometryCollection ), QgsWkbTypes::GeometryCollection );
mGeometryTypeComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconTableLayer.svg" ) ), tr( "No geometry" ), QgsWkbTypes::NoGeometry );
addGeomItem( QgsWkbTypes::Point );
addGeomItem( QgsWkbTypes::LineString );
addGeomItem( QgsWkbTypes::Polygon );
mGeometryTypeComboBox->addItem( QgsWkbTypes::translatedDisplayString( QgsWkbTypes::GeometryCollection ), QgsWkbTypes::GeometryCollection );
addGeomItem( QgsWkbTypes::NoGeometry );
mGeometryTypeComboBox->setCurrentIndex( mGeometryTypeComboBox->findData( -1 ) );

mEncodingComboBox->addItems( QgsVectorDataProvider::availableEncodings() );
@@ -18,6 +18,7 @@
#include "qgsidentifymenu.h"
#include "qgsapplication.h"
#include "qgsactionmanager.h"
#include "qgsdataitem.h"
#include "qgshighlight.h"
#include "qgsmapcanvas.h"
#include "qgsactionmenu.h"
@@ -327,21 +328,7 @@ void QgsIdentifyMenu::addVectorLayer( QgsVectorLayer *layer, const QList<QgsMapT
// case 1 or 2
if ( layerAction )
{
// icons
switch ( layer->geometryType() )
{
case QgsWkbTypes::PointGeometry:
layerAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPointLayer.svg" ) ) );
break;
case QgsWkbTypes::LineGeometry:
layerAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ) );
break;
case QgsWkbTypes::PolygonGeometry:
layerAction->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPolygonLayer.svg" ) ) );
break;
default:
break;
}
layerAction->setIcon( QgsLayerItem::iconForWkbType( layer->wkbType() ) );

// add layer action to the top menu
layerAction->setData( QVariant::fromValue<ActionData>( ActionData( layer ) ) );
@@ -21,6 +21,7 @@

#include "qgis.h"
#include "qgsapplication.h"
#include "qgsdataitem.h"
#include "qgsproviderregistry.h"
#include "qgsvectorlayer.h"
#include "qgsproject.h"
@@ -68,22 +69,28 @@ QgsNewGeoPackageLayerDialog::QgsNewGeoPackageLayerDialog( QWidget *parent, Qt::W
mAddAttributeButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionNewAttribute.svg" ) ) );
mRemoveAttributeButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionDeleteAttribute.svg" ) ) );

mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconTableLayer.svg" ) ), tr( "No Geometry" ), wkbNone );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPointLayer.svg" ) ), tr( "Point" ), wkbPoint );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ), tr( "Line" ), wkbLineString );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPolygonLayer.svg" ) ), tr( "Polygon" ), wkbPolygon );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPointLayer.svg" ) ), tr( "MultiPoint" ), wkbMultiPoint );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ), tr( "MultiLine" ), wkbMultiLineString );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPolygonLayer.svg" ) ), tr( "MultiPolygon" ), wkbMultiPolygon );
const auto addGeomItem = [this]( OGRwkbGeometryType ogrGeomType )
{
QgsWkbTypes::Type qgsType = QgsOgrUtils::ogrGeometryTypeToQgsWkbType( ogrGeomType );
mGeometryTypeBox->addItem( QgsLayerItem::iconForWkbType( qgsType ), QgsWkbTypes::translatedDisplayString( qgsType ), ogrGeomType );
};

addGeomItem( wkbNone );
addGeomItem( wkbPoint );
addGeomItem( wkbLineString );
addGeomItem( wkbPolygon );
addGeomItem( wkbMultiPoint );
addGeomItem( wkbMultiLineString );
addGeomItem( wkbMultiPolygon );

#if 0
// QGIS always create CompoundCurve and there's no real interest of having just CircularString. CompoundCurve are more useful
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ), tr( "CircularString" ), wkbCircularString );
addGeomItem( wkbCircularString );
#endif
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ), tr( "CompoundCurve" ), wkbCompoundCurve );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPolygonLayer.svg" ) ), tr( "CurvePolygon" ), wkbCurvePolygon );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ), tr( "MultiCurve" ), wkbMultiCurve );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPolygonLayer.svg" ) ), tr( "MultiSurface" ), wkbMultiSurface );
addGeomItem( wkbCompoundCurve );
addGeomItem( wkbCurvePolygon );
addGeomItem( wkbMultiCurve );
addGeomItem( wkbMultiSurface );
mGeometryTypeBox->setCurrentIndex( -1 );

mGeometryWithZCheckBox->setEnabled( false );
@@ -18,6 +18,7 @@
#include "qgsnewmemorylayerdialog.h"
#include "qgsapplication.h"
#include "qgis.h"
#include "qgsdataitem.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsproviderregistry.h"
#include "qgsvectordataprovider.h"
@@ -57,17 +58,23 @@ QgsNewMemoryLayerDialog::QgsNewMemoryLayerDialog( QWidget *parent, Qt::WindowFla

mNameLineEdit->setText( tr( "New scratch layer" ) );

mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconTableLayer.svg" ) ), tr( "No Geometry" ), QgsWkbTypes::NoGeometry );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPointLayer.svg" ) ), tr( "Point" ), QgsWkbTypes::Point );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ), tr( "LineString" ), QgsWkbTypes::LineString );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ), tr( "CompoundCurve" ), QgsWkbTypes::CompoundCurve );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPolygonLayer.svg" ) ), tr( "Polygon" ), QgsWkbTypes::Polygon );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPolygonLayer.svg" ) ), tr( "CurvePolygon" ), QgsWkbTypes::CurvePolygon );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPointLayer.svg" ) ), tr( "MultiPoint" ), QgsWkbTypes::MultiPoint );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ), tr( "MultiLineString" ), QgsWkbTypes::MultiLineString );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ), tr( "MultiCurve" ), QgsWkbTypes::MultiCurve );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPolygonLayer.svg" ) ), tr( "MultiPolygon" ), QgsWkbTypes::MultiPolygon );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPolygonLayer.svg" ) ), tr( "MultiSurface" ), QgsWkbTypes::MultiSurface );
const QgsWkbTypes::Type geomTypes[] =
{
QgsWkbTypes::NoGeometry,
QgsWkbTypes::Point,
QgsWkbTypes::LineString,
QgsWkbTypes::CompoundCurve,
QgsWkbTypes::Polygon,
QgsWkbTypes::CurvePolygon,
QgsWkbTypes::MultiPoint,
QgsWkbTypes::MultiLineString,
QgsWkbTypes::MultiCurve,
QgsWkbTypes::MultiPolygon,
QgsWkbTypes::MultiSurface,
};

for ( const auto type : geomTypes )
mGeometryTypeBox->addItem( QgsLayerItem::iconForWkbType( type ), QgsWkbTypes::translatedDisplayString( type ), type );
mGeometryTypeBox->setCurrentIndex( -1 );

mGeometryWithZCheckBox->setEnabled( false );
@@ -15,6 +15,7 @@
* *
***************************************************************************/

#include "qgsdataitem.h"
#include "qgsnewvectorlayerdialog.h"
#include "qgsapplication.h"
#include "qgsfilewidget.h"
@@ -56,11 +57,17 @@ QgsNewVectorLayerDialog::QgsNewVectorLayerDialog( QWidget *parent, Qt::WindowFla
mWidth->setValidator( new QIntValidator( 1, 255, this ) );
mPrecision->setValidator( new QIntValidator( 0, 15, this ) );

mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconTableLayer.svg" ) ), tr( "No Geometry" ), QgsWkbTypes::NoGeometry );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPointLayer.svg" ) ), tr( "Point" ), QgsWkbTypes::Point );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPointLayer.svg" ) ), tr( "MultiPoint" ), QgsWkbTypes::MultiPoint );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ), tr( "Line" ), QgsWkbTypes::LineString );
mGeometryTypeBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPolygonLayer.svg" ) ), tr( "Polygon" ), QgsWkbTypes::Polygon );
const QgsWkbTypes::Type geomTypes[] =
{
QgsWkbTypes::NoGeometry,
QgsWkbTypes::Point,
QgsWkbTypes::MultiPoint,
QgsWkbTypes::LineString,
QgsWkbTypes::Polygon,
};

for ( const auto type : geomTypes )
mGeometryTypeBox->addItem( QgsLayerItem::iconForWkbType( type ), QgsWkbTypes::translatedDisplayString( type ), type );
mGeometryTypeBox->setCurrentIndex( -1 );

mOkButton = buttonBox->button( QDialogButtonBox::Ok );

0 comments on commit af9da65

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