more public methods, fix delete map tool

This commit is contained in:
Denis Rouzaud 2014-09-18 16:41:03 +02:00
parent c665805873
commit 11be64db85
6 changed files with 33 additions and 9 deletions

View File

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

View File

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

View File

@ -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;
}

View File

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

View File

@ -29,6 +29,10 @@ QgsMapToolIdentifyFeature::QgsMapToolIdentifyFeature( QgsMapCanvas* canvas, QgsV
mCursor = QCursor( cursorPixmap, 1, 1 );
}
QgsMapToolIdentifyFeature::~QgsMapToolIdentifyFeature()
{
}
void QgsMapToolIdentifyFeature::canvasReleaseEvent( QMouseEvent* e )
{

View File

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