Skip to content
Permalink
Browse files

create scope based enum for QgsMapLayer::LayerType >> QgsMapLayerType

the enum is moved out of the class
this will allow forward declaration more easily since the enum is not nested in the class
  • Loading branch information
3nids committed Mar 8, 2019
1 parent 837607c commit 375a0aa253d95360c2892ad7345da4be647d19c8
Showing with 323 additions and 312 deletions.
  1. +7 −0 python/core/auto_additions/qgsmaplayer.py
  2. +2 −2 python/core/auto_generated/qgsbrowserproxymodel.sip.in
  3. +2 −2 python/core/auto_generated/qgsdataitem.sip.in
  4. +16 −15 python/core/auto_generated/qgsmaplayer.sip.in
  5. +0 −3 python/gui/auto_additions/qgsadvanceddigitizingdockwidget.py
  6. +1 −1 python/gui/auto_generated/qgisinterface.sip.in
  7. +2 −2 python/gui/auto_generated/qgsdatasourceselectdialog.sip.in
  8. +1 −1 python/gui/auto_generated/qgsmaplayeractionregistry.sip.in
  9. +5 −5 src/3d/qgs3dmapscene.cpp
  10. +1 −1 src/analysis/processing/qgsalgorithmmergevector.cpp
  11. +4 −4 src/analysis/processing/qgsalgorithmpackage.cpp
  12. +6 −6 src/app/browser/qgsinbuiltdataitemproviders.cpp
  13. +1 −1 src/app/decorations/qgsdecorationgrid.cpp
  14. +21 −21 src/app/qgisapp.cpp
  15. +1 −1 src/app/qgisappinterface.cpp
  16. +1 −1 src/app/qgisappinterface.h
  17. +1 −1 src/app/qgsalignrasterdialog.cpp
  18. +10 −10 src/app/qgsapplayertreeviewmenuprovider.cpp
  19. +3 −3 src/app/qgsapplayertreeviewmenuprovider.h
  20. +1 −1 src/app/qgsdxfexportdialog.cpp
  21. +4 −4 src/app/qgsidentifyresultsdialog.cpp
  22. +1 −1 src/app/qgslabelingwidget.cpp
  23. +7 −7 src/app/qgslayercapabilitiesmodel.cpp
  24. +12 −12 src/app/qgslayerstylingwidget.cpp
  25. +1 −1 src/app/qgsmaptoolfeatureaction.cpp
  26. +2 −2 src/app/qgsmaptoolidentifyaction.cpp
  27. +1 −1 src/app/qgsmaptoolselectionhandler.cpp
  28. +4 −4 src/app/qgsprojectproperties.cpp
  29. +1 −1 src/app/qgssnappingwidget.cpp
  30. +4 −4 src/core/expression/qgsexpressionfunction.cpp
  31. +6 −6 src/core/layertree/qgslayertreemodel.cpp
  32. +1 −1 src/core/mesh/qgsmeshlayer.cpp
  33. +7 −7 src/core/processing/qgsprocessingutils.cpp
  34. +6 −1 src/core/qgis_sip.h
  35. +2 −2 src/core/qgsbrowserproxymodel.cpp
  36. +3 −3 src/core/qgsbrowserproxymodel.h
  37. +14 −14 src/core/qgsdataitem.cpp
  38. +2 −2 src/core/qgsdataitem.h
  39. +4 −4 src/core/qgsmaplayer.cpp
  40. +19 −18 src/core/qgsmaplayer.h
  41. +3 −3 src/core/qgsmaplayermodel.cpp
  42. +5 −5 src/core/qgsmaplayerproxymodel.cpp
  43. +4 −4 src/core/qgsmaprenderercustompainterjob.cpp
  44. +2 −2 src/core/qgsmaprendererjob.cpp
  45. +4 −4 src/core/qgsmimedatautils.cpp
  46. +1 −1 src/core/qgspluginlayer.cpp
  47. +1 −1 src/core/qgspluginlayerregistry.cpp
  48. +3 −3 src/core/qgsproject.cpp
  49. +2 −2 src/core/qgsrelation.cpp
  50. +1 −1 src/core/qgssnappingconfig.cpp
  51. +1 −1 src/core/qgsvectorlayer.cpp
  52. +2 −2 src/core/raster/qgsrasterlayer.cpp
  53. +12 −12 src/gui/layertree/qgslayertreeembeddedwidgetsimpl.cpp
  54. +1 −1 src/gui/processing/qgsprocessingwidgetwrapper.cpp
  55. +1 −1 src/gui/processing/qgsprocessingwidgetwrapperimpl.cpp
  56. +1 −1 src/gui/qgisinterface.h
  57. +7 −7 src/gui/qgsbrowserdockwidget_p.cpp
  58. +2 −2 src/gui/qgsdatasourceselectdialog.cpp
  59. +2 −2 src/gui/qgsdatasourceselectdialog.h
  60. +4 −4 src/gui/qgsidentifymenu.cpp
  61. +2 −2 src/gui/qgsmaplayeractionregistry.cpp
  62. +2 −2 src/gui/qgsmaplayeractionregistry.h
  63. +3 −3 src/gui/qgsmaptoolidentify.cpp
  64. +2 −2 src/plugins/evis/eventbrowser/evisgenericeventbrowsergui.cpp
  65. +1 −1 src/plugins/evis/idtool/eviseventidtool.cpp
  66. +1 −1 src/plugins/globe/qgsglobevectorlayerproperties.cpp
  67. +1 −1 src/plugins/gps_importer/qgsgpsplugin.cpp
  68. +2 −2 src/plugins/grass/qgsgrassmoduleoptions.cpp
  69. +2 −2 src/plugins/grass/qgsgrassmoduleparam.cpp
  70. +2 −2 src/plugins/grass/qgsgrassplugin.cpp
  71. +2 −2 src/plugins/topology/rulesDialog.cpp
  72. +1 −1 src/providers/virtual/qgsembeddedlayerselectdialog.cpp
  73. +2 −2 src/providers/virtual/qgsvirtuallayerprovider.cpp
  74. +2 −2 src/providers/virtual/qgsvirtuallayersourceselect.cpp
  75. +1 −1 src/providers/virtual/qgsvirtuallayersqlitemodule.cpp
  76. +1 −1 src/server/qgsaccesscontrol.cpp
  77. +1 −1 src/server/services/wcs/qgswcsdescribecoverage.cpp
  78. +1 −1 src/server/services/wcs/qgswcsgetcapabilities.cpp
  79. +1 −1 src/server/services/wcs/qgswcsgetcoverage.cpp
  80. +1 −1 src/server/services/wfs/qgswfsdescribefeaturetype.cpp
  81. +1 −1 src/server/services/wfs/qgswfsgetcapabilities.cpp
  82. +1 −1 src/server/services/wfs/qgswfsgetcapabilities_1_0_0.cpp
  83. +1 −1 src/server/services/wfs/qgswfsgetfeature.cpp
  84. +1 −1 src/server/services/wfs/qgswfstransaction.cpp
  85. +1 −1 src/server/services/wfs/qgswfstransaction_1_0_0.cpp
  86. +1 −1 src/server/services/wfs/qgswfsutils.cpp
  87. +8 −8 src/server/services/wms/qgslayerrestorer.cpp
  88. +4 −4 src/server/services/wms/qgswmsdescribelayer.cpp
  89. +7 −7 src/server/services/wms/qgswmsgetcapabilities.cpp
  90. +1 −1 src/server/services/wms/qgswmsgetstyles.cpp
  91. +10 −10 src/server/services/wms/qgswmsrenderer.cpp
  92. +4 −4 tests/src/analysis/testqgsprocessing.cpp
  93. +2 −2 tests/src/core/testqgsbrowserproxymodel.cpp
  94. +1 −1 tests/src/core/testqgsproject.cpp
  95. +1 −1 tests/src/core/testziplayer.cpp
  96. +2 −2 tests/src/gui/testrenderergui.cpp
@@ -1,4 +1,11 @@
# The following has been generated automatically from src/core/qgsmaplayer.h
# monkey patching scoped based enum
.QgsMapLayerType.VectorLayer.__doc__ = ""
.QgsMapLayerType.RasterLayer.__doc__ = ""
.QgsMapLayerType.PluginLayer.__doc__ = ""
.QgsMapLayerType.MeshLayer.__doc__ = "Added in 3.2"
.QgsMapLayerType.__doc__ = 'Types of layers that can be added to a map\n\n' + '* VectorLayer: ' + .QgsMapLayerType.VectorLayer.__doc__ + '\n' + '* RasterLayer: ' + .QgsMapLayerType.RasterLayer.__doc__ + '\n' + '* PluginLayer: ' + .QgsMapLayerType.PluginLayer.__doc__ + '\n' + '* MeshLayer: ' + .QgsMapLayerType.MeshLayer.__doc__
# --
QgsMapLayer.LayerFlag.baseClass = QgsMapLayer
QgsMapLayer.LayerFlags.baseClass = QgsMapLayer
LayerFlags = QgsMapLayer # dirty hack since SIP seems to introduce the flags in module
@@ -113,7 +113,7 @@ Sets whether the model is filtered by map layer type.
.. seealso:: :py:func:`setLayerType`
%End

QgsMapLayer::LayerType layerType() const;
QgsMapLayerType layerType() const;
%Docstring
Returns the layer type to filter the model by. This is only used if
filterByLayerType() is ``True``.
@@ -123,7 +123,7 @@ filterByLayerType() is ``True``.
.. seealso:: :py:func:`filterByLayerType`
%End

void setLayerType( QgsMapLayer::LayerType type );
void setLayerType( QgsMapLayerType type );
%Docstring
Sets the layer ``type`` to filter the model by. This is only used if
filterByLayerType() is ``True``.
@@ -433,9 +433,9 @@ Item that represents a layer that can be opened with one of the providers



QgsMapLayer::LayerType mapLayerType() const;
QgsMapLayerType mapLayerType() const;
%Docstring
Returns QgsMapLayer.LayerType
Returns :py:class:`QgsMapLayerType`
%End

static LayerType typeFromMapLayer( QgsMapLayer *layer );
@@ -13,6 +13,15 @@




enum class QgsMapLayerType
{
VectorLayer,
RasterLayer,
PluginLayer,
MeshLayer
};

class QgsMapLayer : QObject
{
%Docstring
@@ -24,24 +33,24 @@ This is the base class for all map layer types (vector, raster).
#include "qgsmaplayer.h"
%End
%ConvertToSubClassCode
QgsMapLayer *layer = qobject_cast<QgsMapLayer *>( sipCpp );
QgsMapLayer * layer = qobject_cast<QgsMapLayer *>( sipCpp );

sipType = 0;

if ( layer )
{
switch ( layer->type() )
{
case QgsMapLayer::VectorLayer:
case QgsMapLayerType::VectorLayer:
sipType = sipType_QgsVectorLayer;
break;
case QgsMapLayer::RasterLayer:
case QgsMapLayerType::RasterLayer:
sipType = sipType_QgsRasterLayer;
break;
case QgsMapLayer::PluginLayer:
case QgsMapLayerType::PluginLayer:
sipType = sipType_QgsPluginLayer;
break;
case QgsMapLayer::MeshLayer:
case QgsMapLayerType::MeshLayer:
sipType = sipType_QgsMeshLayer;
break;
default:
@@ -52,14 +61,6 @@ This is the base class for all map layer types (vector, raster).
%End
public:

enum LayerType
{
VectorLayer,
RasterLayer,
PluginLayer,
MeshLayer
};

enum PropertyType
{
Style,
@@ -95,7 +96,7 @@ This is the base class for all map layer types (vector, raster).
typedef QFlags<QgsMapLayer::StyleCategory> StyleCategories;


QgsMapLayer( QgsMapLayer::LayerType type = VectorLayer, const QString &name = QString(), const QString &source = QString() );
QgsMapLayer( QgsMapLayerType type = QgsMapLayerType::VectorLayer, const QString &name = QString(), const QString &source = QString() );
%Docstring
Constructor for QgsMapLayer

@@ -117,7 +118,7 @@ is still unique.
.. versionadded:: 3.0
%End

QgsMapLayer::LayerType type() const;
QgsMapLayerType type() const;
%Docstring
Returns the type of the layer.
%End
@@ -3,10 +3,7 @@
CadCapacities = QgsAdvancedDigitizingDockWidget # dirty hack since SIP seems to introduce the flags in module
# monkey patching scoped based enum
QgsAdvancedDigitizingDockWidget.AdditionalConstraint.NoConstraint.__doc__ = "No additional constraint"
QgsAdvancedDigitizingDockWidget.NoConstraint = QgsAdvancedDigitizingDockWidget.AdditionalConstraint.NoConstraint
QgsAdvancedDigitizingDockWidget.AdditionalConstraint.Perpendicular.__doc__ = "Perpendicular"
QgsAdvancedDigitizingDockWidget.Perpendicular = QgsAdvancedDigitizingDockWidget.AdditionalConstraint.Perpendicular
QgsAdvancedDigitizingDockWidget.AdditionalConstraint.Parallel.__doc__ = "Parallel"
QgsAdvancedDigitizingDockWidget.Parallel = QgsAdvancedDigitizingDockWidget.AdditionalConstraint.Parallel
QgsAdvancedDigitizingDockWidget.AdditionalConstraint.__doc__ = 'Additional constraints which can be enabled\n\n' + '* NoConstraint: ' + QgsAdvancedDigitizingDockWidget.AdditionalConstraint.NoConstraint.__doc__ + '\n' + '* Perpendicular: ' + QgsAdvancedDigitizingDockWidget.AdditionalConstraint.Perpendicular.__doc__ + '\n' + '* Parallel: ' + QgsAdvancedDigitizingDockWidget.AdditionalConstraint.Parallel.__doc__
# --
@@ -42,7 +42,7 @@ Constructor
virtual QgsLayerTreeView *layerTreeView() = 0;

virtual void addCustomActionForLayerType( QAction *action, QString menu,
QgsMapLayer::LayerType type, bool allLayers ) = 0;
QgsMapLayerType type, bool allLayers ) = 0;
%Docstring
Add action to context menu for layers in the layer tree.
If allLayers is ``True``, then the action will be available for all layers of given type,
@@ -33,7 +33,7 @@ will return a (possibly invalid) QgsMimeDataUtils.Uri.

QgsDataSourceSelectDialog( QgsBrowserModel *browserModel = 0,
bool setFilterByLayerType = false,
const QgsMapLayer::LayerType &layerType = QgsMapLayer::LayerType::VectorLayer,
const QgsMapLayerType &layerType = QgsMapLayerType::VectorLayer,
QWidget *parent = 0 );
%Docstring
Constructs a QgsDataSourceSelectDialog, optionally filtering by layer type
@@ -47,7 +47,7 @@ Constructs a QgsDataSourceSelectDialog, optionally filtering by layer type

~QgsDataSourceSelectDialog();

void setLayerTypeFilter( QgsMapLayer::LayerType layerType );
void setLayerTypeFilter( QgsMapLayerType layerType );
%Docstring
Sets layer type filter to ``layerType`` and activates the filtering
%End
@@ -52,7 +52,7 @@ Creates a map layer action which can run on any layer
Creates a map layer action which can run only on a specific layer
%End

QgsMapLayerAction( const QString &name, QObject *parent /TransferThis/, QgsMapLayer::LayerType layerType, Targets targets = AllActions, const QIcon &icon = QIcon(), QgsMapLayerAction::Flags flags = 0 );
QgsMapLayerAction( const QString &name, QObject *parent /TransferThis/, QgsMapLayerType layerType, Targets targets = AllActions, const QIcon &icon = QIcon(), QgsMapLayerAction::Flags flags = 0 );
%Docstring
Creates a map layer action which can run on a specific type of layer
%End
@@ -545,15 +545,15 @@ void Qgs3DMapScene::addLayerEntity( QgsMapLayer *layer )
// This is a bit of a hack and it should be handled in QgsMapLayer::setRenderer3D() but in qgis_core
// the vector layer 3D renderer class is not available. Maybe we need an intermediate map layer 3D renderer
// class in qgis_core that can be used to handle this case nicely.
if ( layer->type() == QgsMapLayer::VectorLayer && renderer->type() == QLatin1String( "vector" ) )
if ( layer->type() == QgsMapLayerType::VectorLayer && renderer->type() == QLatin1String( "vector" ) )
{
static_cast<QgsVectorLayer3DRenderer *>( renderer )->setLayer( static_cast<QgsVectorLayer *>( layer ) );
}
else if ( layer->type() == QgsMapLayer::VectorLayer && renderer->type() == QLatin1String( "rulebased" ) )
else if ( layer->type() == QgsMapLayerType::VectorLayer && renderer->type() == QLatin1String( "rulebased" ) )
{
static_cast<QgsRuleBased3DRenderer *>( renderer )->setLayer( static_cast<QgsVectorLayer *>( layer ) );
}
else if ( layer->type() == QgsMapLayer::MeshLayer && renderer->type() == QLatin1String( "mesh" ) )
else if ( layer->type() == QgsMapLayerType::MeshLayer && renderer->type() == QLatin1String( "mesh" ) )
{
static_cast<QgsMeshLayer3DRenderer *>( renderer )->setLayer( static_cast<QgsMeshLayer *>( layer ) );
}
@@ -575,7 +575,7 @@ void Qgs3DMapScene::addLayerEntity( QgsMapLayer *layer )

connect( layer, &QgsMapLayer::renderer3DChanged, this, &Qgs3DMapScene::onLayerRenderer3DChanged );

if ( layer->type() == QgsMapLayer::VectorLayer )
if ( layer->type() == QgsMapLayerType::VectorLayer )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
connect( vlayer, &QgsVectorLayer::selectionChanged, this, &Qgs3DMapScene::onLayerRenderer3DChanged );
@@ -590,7 +590,7 @@ void Qgs3DMapScene::removeLayerEntity( QgsMapLayer *layer )

disconnect( layer, &QgsMapLayer::renderer3DChanged, this, &Qgs3DMapScene::onLayerRenderer3DChanged );

if ( layer->type() == QgsMapLayer::VectorLayer )
if ( layer->type() == QgsMapLayerType::VectorLayer )
{
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
disconnect( vlayer, &QgsVectorLayer::selectionChanged, this, &Qgs3DMapScene::onLayerRenderer3DChanged );
@@ -98,7 +98,7 @@ QVariantMap QgsMergeVectorAlgorithm::processAlgorithm( const QVariantMap &parame
continue;
}

if ( layer->type() != QgsMapLayer::VectorLayer )
if ( layer->type() != QgsMapLayerType::VectorLayer )
throw QgsProcessingException( QObject::tr( "All layers must be vector layers!" ) );

QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( layer );
@@ -120,7 +120,7 @@ QVariantMap QgsPackageAlgorithm::processAlgorithm( const QVariantMap &parameters

switch ( layer->type() )
{
case QgsMapLayer::VectorLayer:
case QgsMapLayerType::VectorLayer:
{
if ( !packageVectorLayer( qobject_cast< QgsVectorLayer * >( layer ), packagePath,
context, &multiStepFeedback ) )
@@ -130,21 +130,21 @@ QVariantMap QgsPackageAlgorithm::processAlgorithm( const QVariantMap &parameters
break;
}

case QgsMapLayer::RasterLayer:
case QgsMapLayerType::RasterLayer:
{
//not supported
feedback->pushDebugInfo( QObject::tr( "Raster layers are not currently supported." ) );
errored = true;
break;
}

case QgsMapLayer::PluginLayer:
case QgsMapLayerType::PluginLayer:
//not supported
feedback->pushDebugInfo( QObject::tr( "Packaging plugin layers is not supported." ) );
errored = true;
break;

case QgsMapLayer::MeshLayer:
case QgsMapLayerType::MeshLayer:
//not supported
feedback->pushDebugInfo( QObject::tr( "Packaging mesh layers is not supported." ) );
errored = true;
@@ -350,8 +350,8 @@ void QgsLayerItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men
return;

QgsLayerItem *layerItem = qobject_cast<QgsLayerItem *>( item );
if ( layerItem && ( layerItem->mapLayerType() == QgsMapLayer::VectorLayer ||
layerItem->mapLayerType() == QgsMapLayer::RasterLayer ) )
if ( layerItem && ( layerItem->mapLayerType() == QgsMapLayerType::VectorLayer ||
layerItem->mapLayerType() == QgsMapLayerType::RasterLayer ) )
{
QMenu *exportMenu = new QMenu( tr( "Export Layer" ), menu );
menu->addMenu( exportMenu );
@@ -361,7 +361,7 @@ void QgsLayerItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men
{
switch ( layerItem->mapLayerType() )
{
case QgsMapLayer::VectorLayer:
case QgsMapLayerType::VectorLayer:
{
std::unique_ptr<QgsVectorLayer> layer( new QgsVectorLayer( layerItem->uri(), layerItem->name(), layerItem->providerKey() ) );
if ( layer && layer->isValid() )
@@ -371,7 +371,7 @@ void QgsLayerItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men
break;
}

case QgsMapLayer::RasterLayer:
case QgsMapLayerType::RasterLayer:
{
std::unique_ptr<QgsRasterLayer> layer( new QgsRasterLayer( layerItem->uri(), layerItem->name(), layerItem->providerKey() ) );
if ( layer && layer->isValid() )
@@ -381,8 +381,8 @@ void QgsLayerItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men
break;
}

case QgsMapLayer::PluginLayer:
case QgsMapLayer::MeshLayer:
case QgsMapLayerType::PluginLayer:
case QgsMapLayerType::MeshLayer:
break;
}
} );
@@ -804,7 +804,7 @@ bool QgsDecorationGrid::getIntervalFromCurrentLayer( double *values )
QMessageBox::warning( nullptr, tr( "Get Interval from Layer" ), tr( "No active layer" ) );
return false;
}
if ( layer->type() != QgsMapLayer::RasterLayer )
if ( layer->type() != QgsMapLayerType::RasterLayer )
{
QMessageBox::warning( nullptr, tr( "Get Interval from Layer" ), tr( "Please select a raster layer." ) );
return false;

0 comments on commit 375a0aa

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