diff --git a/python/gui/editorwidgets/qgsrelationreferencewidget.sip b/python/gui/editorwidgets/qgsrelationreferencewidget.sip index ba90a36d5bc..343cfc97cb1 100644 --- a/python/gui/editorwidgets/qgsrelationreferencewidget.sip +++ b/python/gui/editorwidgets/qgsrelationreferencewidget.sip @@ -45,12 +45,21 @@ class QgsRelationReferenceWidget : QWidget bool openFormButtonVisible(); void setOpenFormButtonVisible( bool openFormButtonVisible ); + //! return the related feature (from the referenced layer) + //! if no feature is related, it returns an invalid feature + QgsFeature referencedFeature(); + public slots: //! open the form of the related feature in a new dialog void openForm(); - //! activate the map tool to select the related feature on the map + + //! activate the map tool to select a new related feature on the map void mapIdentification(); + //! unset the currently related feature + void deleteForeignKey(); + + protected: virtual void showEvent( QShowEvent* e ); diff --git a/python/gui/qgsmaptoolidentifyfeature.sip b/python/gui/qgsmaptoolidentifyfeature.sip index 93604d3a705..bae1e00e6c8 100644 --- a/python/gui/qgsmaptoolidentifyfeature.sip +++ b/python/gui/qgsmaptoolidentifyfeature.sip @@ -11,6 +11,8 @@ class QgsMapToolIdentifyFeature : QgsMapToolIdentify * @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 ); + + ~QgsMapToolIdentifyFeature(); //! change the layer used by the map tool to identify void setLayer( QgsVectorLayer* vl ); diff --git a/src/gui/editorwidgets/qgsrelationreferencewidget.cpp b/src/gui/editorwidgets/qgsrelationreferencewidget.cpp index c58d61487ed..da128492658 100644 --- a/src/gui/editorwidgets/qgsrelationreferencewidget.cpp +++ b/src/gui/editorwidgets/qgsrelationreferencewidget.cpp @@ -138,7 +138,8 @@ QgsRelationReferenceWidget::~QgsRelationReferenceWidget() { deleteHighlight(); unsetMapTool(); - delete mMapTool; + if ( mMapTool ) + delete mMapTool; } void QgsRelationReferenceWidget::setRelation( QgsRelation relation, bool allowNullValue ) @@ -277,7 +278,7 @@ void QgsRelationReferenceWidget::deleteForeignKey() emit foreignKeyChanged( QVariant( QVariant::Int ) ); } -QgsFeature QgsRelationReferenceWidget::relatedFeature() +QgsFeature QgsRelationReferenceWidget::referencedFeature() { QgsFeature f; if ( mReferencedLayer ) @@ -422,7 +423,7 @@ void QgsRelationReferenceWidget::highlightActionTriggered( QAction* action ) void QgsRelationReferenceWidget::openForm() { - QgsFeature feat = relatedFeature(); + QgsFeature feat = referencedFeature(); if ( !feat.isValid() ) return; @@ -439,7 +440,7 @@ void QgsRelationReferenceWidget::highlightFeature( QgsFeature f, CanvasExtent ca if ( !f.isValid() ) { - f = relatedFeature(); + f = referencedFeature(); if ( !f.isValid() ) return; } diff --git a/src/gui/editorwidgets/qgsrelationreferencewidget.h b/src/gui/editorwidgets/qgsrelationreferencewidget.h index 65c46ec2a71..72a3fc79a26 100644 --- a/src/gui/editorwidgets/qgsrelationreferencewidget.h +++ b/src/gui/editorwidgets/qgsrelationreferencewidget.h @@ -75,12 +75,20 @@ class GUI_EXPORT QgsRelationReferenceWidget : public QWidget bool openFormButtonVisible() {return mOpenFormButtonVisible;} void setOpenFormButtonVisible( bool openFormButtonVisible ); + //! return the related feature (from the referenced layer) + //! if no feature is related, it returns an invalid feature + QgsFeature referencedFeature(); + public slots: //! open the form of the related feature in a new dialog void openForm(); - //! activate the map tool to select the related feature on the map + + //! activate the map tool to select a new related feature on the map void mapIdentification(); + //! unset the currently related feature + void deleteForeignKey(); + protected: virtual void showEvent( QShowEvent* e ); @@ -93,13 +101,11 @@ class GUI_EXPORT QgsRelationReferenceWidget : public QWidget void highlightActionTriggered( QAction* action ); void deleteHighlight(); void comboReferenceChanged( int index ); - void deleteForeignKey(); void featureIdentified( const QgsFeature& feature ); void unsetMapTool(); void mapToolDeactivated(); private: - QgsFeature relatedFeature(); void highlightFeature( QgsFeature f = QgsFeature(), CanvasExtent canvasExtent = Fixed ); void updateAttributeEditorFrame( const QgsFeature feature ); diff --git a/src/gui/qgsmaptoolidentifyfeature.cpp b/src/gui/qgsmaptoolidentifyfeature.cpp index a0393d69377..43ff2287d02 100644 --- a/src/gui/qgsmaptoolidentifyfeature.cpp +++ b/src/gui/qgsmaptoolidentifyfeature.cpp @@ -29,6 +29,10 @@ QgsMapToolIdentifyFeature::QgsMapToolIdentifyFeature( QgsMapCanvas* canvas, QgsV mCursor = QCursor( cursorPixmap, 1, 1 ); } +QgsMapToolIdentifyFeature::~QgsMapToolIdentifyFeature() +{ +} + void QgsMapToolIdentifyFeature::canvasReleaseEvent( QMouseEvent* e ) { diff --git a/src/gui/qgsmaptoolidentifyfeature.h b/src/gui/qgsmaptoolidentifyfeature.h index 8da70d37782..917df157e85 100644 --- a/src/gui/qgsmaptoolidentifyfeature.h +++ b/src/gui/qgsmaptoolidentifyfeature.h @@ -35,8 +35,10 @@ class GUI_EXPORT QgsMapToolIdentifyFeature : public QgsMapToolIdentify */ QgsMapToolIdentifyFeature( QgsMapCanvas* canvas, QgsVectorLayer* vl = 0 ); + ~QgsMapToolIdentifyFeature(); + //! change the layer used by the map tool to identify - void setLayer( QgsVectorLayer* vl ){ mLayer = vl; } + void setLayer( QgsVectorLayer* vl ) { mLayer = vl; } virtual void canvasReleaseEvent( QMouseEvent* e );