Skip to content

Commit

Permalink
use flag instead of enum
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Aug 14, 2014
1 parent faa3304 commit 71d7445
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
7 changes: 4 additions & 3 deletions python/gui/qgsmaptoolidentify.sip
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ class QgsMapToolIdentify : QgsMapTool
LayerSelection
};

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

struct IdentifyResult
{
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsmaptoolidentify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down
12 changes: 8 additions & 4 deletions src/gui/qgsmaptoolidentify.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class QgsHighlight;
class GUI_EXPORT QgsMapToolIdentify : public QgsMapTool
{
Q_OBJECT
Q_FLAGS( LayerType )

public:

Expand All @@ -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
{
Expand Down Expand Up @@ -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.