Skip to content

Commit 11be64d

Browse files
committed
more public methods, fix delete map tool
1 parent c665805 commit 11be64d

File tree

6 files changed

+33
-9
lines changed

6 files changed

+33
-9
lines changed

python/gui/editorwidgets/qgsrelationreferencewidget.sip

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,21 @@ class QgsRelationReferenceWidget : QWidget
4545
bool openFormButtonVisible();
4646
void setOpenFormButtonVisible( bool openFormButtonVisible );
4747

48+
//! return the related feature (from the referenced layer)
49+
//! if no feature is related, it returns an invalid feature
50+
QgsFeature referencedFeature();
51+
4852
public slots:
4953
//! open the form of the related feature in a new dialog
5054
void openForm();
51-
//! activate the map tool to select the related feature on the map
55+
56+
//! activate the map tool to select a new related feature on the map
5257
void mapIdentification();
5358

59+
//! unset the currently related feature
60+
void deleteForeignKey();
61+
62+
5463
protected:
5564
virtual void showEvent( QShowEvent* e );
5665

python/gui/qgsmaptoolidentifyfeature.sip

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ class QgsMapToolIdentifyFeature : QgsMapToolIdentify
1111
* @param vl the vector layer. The map tool can be initialized without any layer and can be set afterward.
1212
*/
1313
QgsMapToolIdentifyFeature( QgsMapCanvas* canvas, QgsVectorLayer* vl = 0 );
14+
15+
~QgsMapToolIdentifyFeature();
1416

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

src/gui/editorwidgets/qgsrelationreferencewidget.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ QgsRelationReferenceWidget::~QgsRelationReferenceWidget()
138138
{
139139
deleteHighlight();
140140
unsetMapTool();
141-
delete mMapTool;
141+
if ( mMapTool )
142+
delete mMapTool;
142143
}
143144

144145
void QgsRelationReferenceWidget::setRelation( QgsRelation relation, bool allowNullValue )
@@ -277,7 +278,7 @@ void QgsRelationReferenceWidget::deleteForeignKey()
277278
emit foreignKeyChanged( QVariant( QVariant::Int ) );
278279
}
279280

280-
QgsFeature QgsRelationReferenceWidget::relatedFeature()
281+
QgsFeature QgsRelationReferenceWidget::referencedFeature()
281282
{
282283
QgsFeature f;
283284
if ( mReferencedLayer )
@@ -422,7 +423,7 @@ void QgsRelationReferenceWidget::highlightActionTriggered( QAction* action )
422423

423424
void QgsRelationReferenceWidget::openForm()
424425
{
425-
QgsFeature feat = relatedFeature();
426+
QgsFeature feat = referencedFeature();
426427

427428
if ( !feat.isValid() )
428429
return;
@@ -439,7 +440,7 @@ void QgsRelationReferenceWidget::highlightFeature( QgsFeature f, CanvasExtent ca
439440

440441
if ( !f.isValid() )
441442
{
442-
f = relatedFeature();
443+
f = referencedFeature();
443444
if ( !f.isValid() )
444445
return;
445446
}

src/gui/editorwidgets/qgsrelationreferencewidget.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,20 @@ class GUI_EXPORT QgsRelationReferenceWidget : public QWidget
7575
bool openFormButtonVisible() {return mOpenFormButtonVisible;}
7676
void setOpenFormButtonVisible( bool openFormButtonVisible );
7777

78+
//! return the related feature (from the referenced layer)
79+
//! if no feature is related, it returns an invalid feature
80+
QgsFeature referencedFeature();
81+
7882
public slots:
7983
//! open the form of the related feature in a new dialog
8084
void openForm();
81-
//! activate the map tool to select the related feature on the map
85+
86+
//! activate the map tool to select a new related feature on the map
8287
void mapIdentification();
8388

89+
//! unset the currently related feature
90+
void deleteForeignKey();
91+
8492
protected:
8593
virtual void showEvent( QShowEvent* e );
8694

@@ -93,13 +101,11 @@ class GUI_EXPORT QgsRelationReferenceWidget : public QWidget
93101
void highlightActionTriggered( QAction* action );
94102
void deleteHighlight();
95103
void comboReferenceChanged( int index );
96-
void deleteForeignKey();
97104
void featureIdentified( const QgsFeature& feature );
98105
void unsetMapTool();
99106
void mapToolDeactivated();
100107

101108
private:
102-
QgsFeature relatedFeature();
103109
void highlightFeature( QgsFeature f = QgsFeature(), CanvasExtent canvasExtent = Fixed );
104110
void updateAttributeEditorFrame( const QgsFeature feature );
105111

src/gui/qgsmaptoolidentifyfeature.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ QgsMapToolIdentifyFeature::QgsMapToolIdentifyFeature( QgsMapCanvas* canvas, QgsV
2929
mCursor = QCursor( cursorPixmap, 1, 1 );
3030
}
3131

32+
QgsMapToolIdentifyFeature::~QgsMapToolIdentifyFeature()
33+
{
34+
}
35+
3236
void QgsMapToolIdentifyFeature::canvasReleaseEvent( QMouseEvent* e )
3337
{
3438

src/gui/qgsmaptoolidentifyfeature.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ class GUI_EXPORT QgsMapToolIdentifyFeature : public QgsMapToolIdentify
3535
*/
3636
QgsMapToolIdentifyFeature( QgsMapCanvas* canvas, QgsVectorLayer* vl = 0 );
3737

38+
~QgsMapToolIdentifyFeature();
39+
3840
//! change the layer used by the map tool to identify
39-
void setLayer( QgsVectorLayer* vl ){ mLayer = vl; }
41+
void setLayer( QgsVectorLayer* vl ) { mLayer = vl; }
4042

4143
virtual void canvasReleaseEvent( QMouseEvent* e );
4244

0 commit comments

Comments
 (0)