Skip to content

Commit

Permalink
more public methods, fix delete map tool
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Sep 18, 2014
1 parent c665805 commit 11be64d
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 9 deletions.
11 changes: 10 additions & 1 deletion python/gui/editorwidgets/qgsrelationreferencewidget.sip
Expand Up @@ -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 );

Expand Down
2 changes: 2 additions & 0 deletions python/gui/qgsmaptoolidentifyfeature.sip
Expand Up @@ -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 );
Expand Down
9 changes: 5 additions & 4 deletions src/gui/editorwidgets/qgsrelationreferencewidget.cpp
Expand Up @@ -138,7 +138,8 @@ QgsRelationReferenceWidget::~QgsRelationReferenceWidget()
{
deleteHighlight();
unsetMapTool();
delete mMapTool;
if ( mMapTool )
delete mMapTool;
}

void QgsRelationReferenceWidget::setRelation( QgsRelation relation, bool allowNullValue )
Expand Down Expand Up @@ -277,7 +278,7 @@ void QgsRelationReferenceWidget::deleteForeignKey()
emit foreignKeyChanged( QVariant( QVariant::Int ) );
}

QgsFeature QgsRelationReferenceWidget::relatedFeature()
QgsFeature QgsRelationReferenceWidget::referencedFeature()
{
QgsFeature f;
if ( mReferencedLayer )
Expand Down Expand Up @@ -422,7 +423,7 @@ void QgsRelationReferenceWidget::highlightActionTriggered( QAction* action )

void QgsRelationReferenceWidget::openForm()
{
QgsFeature feat = relatedFeature();
QgsFeature feat = referencedFeature();

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

if ( !f.isValid() )
{
f = relatedFeature();
f = referencedFeature();
if ( !f.isValid() )
return;
}
Expand Down
12 changes: 9 additions & 3 deletions src/gui/editorwidgets/qgsrelationreferencewidget.h
Expand Up @@ -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 );

Expand All @@ -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 );

Expand Down
4 changes: 4 additions & 0 deletions src/gui/qgsmaptoolidentifyfeature.cpp
Expand Up @@ -29,6 +29,10 @@ QgsMapToolIdentifyFeature::QgsMapToolIdentifyFeature( QgsMapCanvas* canvas, QgsV
mCursor = QCursor( cursorPixmap, 1, 1 );
}

QgsMapToolIdentifyFeature::~QgsMapToolIdentifyFeature()
{
}

void QgsMapToolIdentifyFeature::canvasReleaseEvent( QMouseEvent* e )
{

Expand Down
4 changes: 3 additions & 1 deletion src/gui/qgsmaptoolidentifyfeature.h
Expand Up @@ -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 );

Expand Down

0 comments on commit 11be64d

Please sign in to comment.