Skip to content

Commit

Permalink
[QgsMapToolIdentifyFeature] allow initializing without any layer
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Sep 16, 2014
1 parent 5483ee8 commit fb30b84
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
10 changes: 9 additions & 1 deletion python/gui/qgsmaptoolidentifyfeature.sip
Expand Up @@ -5,7 +5,15 @@ class QgsMapToolIdentifyFeature : QgsMapToolIdentify
%End

public:
QgsMapToolIdentifyFeature( QgsVectorLayer* vl, QgsMapCanvas* canvas );
/**
* @brief QgsMapToolIdentifyFeature is a map tool to identify a feature on a chosen layer
* @param canvas the map canvas
* @param vl the vector layer. The map tool can be initialized without any layer and can be set afterward.
*/
QgsMapToolIdentifyFeature( QgsMapCanvas* canvas, QgsVectorLayer* vl = 0 );

//! change the layer used by the map tool to identify
void setLayer( QgsVectorLayer* vl );

void canvasReleaseEvent( QMouseEvent* e );

Expand Down
2 changes: 1 addition & 1 deletion src/gui/editorwidgets/qgsrelationreferencewidget.cpp
Expand Up @@ -516,7 +516,7 @@ void QgsRelationReferenceWidget::mapIdentification()
if ( !mCanvas )
return;

mMapTool = new QgsMapToolIdentifyFeature( mReferencedLayer, mCanvas );
mMapTool = new QgsMapToolIdentifyFeature( mCanvas, mReferencedLayer );
mCanvas->setMapTool( mMapTool );
mWindowWidget = window();
mWindowWidget->hide();
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsmaptoolidentifyfeature.cpp
Expand Up @@ -18,10 +18,10 @@
#include "qgsmaptoolidentifyfeature.h"
#include "qgsmapcanvas.h"

QgsMapToolIdentifyFeature::QgsMapToolIdentifyFeature( QgsVectorLayer* vl, QgsMapCanvas* canvas )
QgsMapToolIdentifyFeature::QgsMapToolIdentifyFeature( QgsMapCanvas* canvas, QgsVectorLayer* vl )
: QgsMapToolIdentify( canvas )
, mLayer( vl )
, mCanvas( canvas )
, mLayer( vl )
{
}

Expand Down
14 changes: 11 additions & 3 deletions src/gui/qgsmaptoolidentifyfeature.h
Expand Up @@ -19,7 +19,7 @@
#include "qgsmaptoolidentify.h"

/**
* @brief The QgsMapToolIdentifyFeature class is a map tool to be used to identify a feature on a chosen layer.
* @brief The QgsMapToolIdentifyFeature class is a map tool to identify a feature on a chosen layer.
* Once the map tool is enable, user can click on the map canvas to identify a feature.
* A signal will then be emitted.
*/
Expand All @@ -28,7 +28,15 @@ class GUI_EXPORT QgsMapToolIdentifyFeature : public QgsMapToolIdentify
Q_OBJECT

public:
QgsMapToolIdentifyFeature( QgsVectorLayer* vl, QgsMapCanvas* canvas );
/**
* @brief QgsMapToolIdentifyFeature is a map tool to identify a feature on a chosen layer
* @param canvas the map canvas
* @param vl the vector layer. The map tool can be initialized without any layer and can be set afterward.
*/
QgsMapToolIdentifyFeature( QgsMapCanvas* canvas, QgsVectorLayer* vl = 0 );

//! change the layer used by the map tool to identify
void setLayer( QgsVectorLayer* vl ){ mLayer = vl; }

virtual void canvasReleaseEvent( QMouseEvent* e );

Expand All @@ -40,8 +48,8 @@ class GUI_EXPORT QgsMapToolIdentifyFeature : public QgsMapToolIdentify
virtual void keyPressEvent( QKeyEvent* e );

private:
QgsVectorLayer* mLayer;
QgsMapCanvas* mCanvas;
QgsVectorLayer* mLayer;
};

#endif // QGSMAPTOOLIDENTIFYFEATURE_H

0 comments on commit fb30b84

Please sign in to comment.