diff --git a/python/gui/qgsmaptoolidentify.sip b/python/gui/qgsmaptoolidentify.sip index 9c08c225003..6251fccc83c 100644 --- a/python/gui/qgsmaptoolidentify.sip +++ b/python/gui/qgsmaptoolidentify.sip @@ -15,12 +15,13 @@ class QgsMapToolIdentify : QgsMapTool LayerSelection }; - enum LayerType + enum Type { - AllLayers, VectorLayer, - RasterLayer + RasterLayer, + AllLayers }; + typedef QFlags LayerType; struct IdentifyResult { diff --git a/src/gui/qgsmaptoolidentify.cpp b/src/gui/qgsmaptoolidentify.cpp index c1a86854fd8..dbdd5b88731 100644 --- a/src/gui/qgsmaptoolidentify.cpp +++ b/src/gui/qgsmaptoolidentify.cpp @@ -252,11 +252,11 @@ void QgsMapToolIdentify::deactivate() bool QgsMapToolIdentify::identifyLayer( QList *results, QgsMapLayer *layer, QgsPoint point, QgsRectangle viewExtent, double mapUnitsPerPixel, LayerType layerType ) { - if ( layer->type() == QgsMapLayer::RasterLayer && ( layerType == AllLayers || layerType == RasterLayer ) ) + if ( layer->type() == QgsMapLayer::RasterLayer && layerType.testFlag( RasterLayer ) ) { return identifyRasterLayer( results, qobject_cast( layer ), point, viewExtent, mapUnitsPerPixel ); } - else if ( layer->type() == QgsMapLayer::VectorLayer && ( layerType == AllLayers || layerType == VectorLayer ) ) + else if ( layer->type() == QgsMapLayer::VectorLayer && layerType.testFlag( VectorLayer ) ) { return identifyVectorLayer( results, qobject_cast( layer ), point ); } diff --git a/src/gui/qgsmaptoolidentify.h b/src/gui/qgsmaptoolidentify.h index 0a62da06145..c400cf91f31 100644 --- a/src/gui/qgsmaptoolidentify.h +++ b/src/gui/qgsmaptoolidentify.h @@ -44,6 +44,7 @@ class QgsHighlight; class GUI_EXPORT QgsMapToolIdentify : public QgsMapTool { Q_OBJECT + Q_FLAGS( LayerType ) public: @@ -56,12 +57,13 @@ class GUI_EXPORT QgsMapToolIdentify : public QgsMapTool LayerSelection }; - enum LayerType + enum Type { - AllLayers = -1, - VectorLayer, - RasterLayer + VectorLayer = 1, + RasterLayer = 2, + AllLayers = VectorLayer | RasterLayer }; + Q_DECLARE_FLAGS( LayerType, Type ) struct IdentifyResult { @@ -178,4 +180,6 @@ class GUI_EXPORT QgsMapToolIdentify : public QgsMapTool void handleMenuHover(); }; +Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapToolIdentify::LayerType ) + #endif