Skip to content
Permalink
Browse files

use flag instead of enum

  • Loading branch information
3nids committed Aug 14, 2014
1 parent faa3304 commit 71d7445c83cfcfad24694b72fc4505c29168c311
Showing with 14 additions and 9 deletions.
  1. +4 −3 python/gui/qgsmaptoolidentify.sip
  2. +2 −2 src/gui/qgsmaptoolidentify.cpp
  3. +8 −4 src/gui/qgsmaptoolidentify.h
@@ -15,12 +15,13 @@ class QgsMapToolIdentify : QgsMapTool
LayerSelection
};

enum LayerType
enum Type
{
AllLayers,
VectorLayer,
RasterLayer
RasterLayer,
AllLayers
};
typedef QFlags<QgsMapToolIdentify::Type> LayerType;

struct IdentifyResult
{
@@ -252,11 +252,11 @@ void QgsMapToolIdentify::deactivate()

bool QgsMapToolIdentify::identifyLayer( QList<IdentifyResult> *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<QgsRasterLayer *>( 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<QgsVectorLayer *>( layer ), point );
}
@@ -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

0 comments on commit 71d7445

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