Skip to content

Commit

Permalink
Add method to reset vector layer for data defined button
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 17, 2016
1 parent b349eb8 commit eb5cc0c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions python/gui/qgsdatadefinedbutton.sip
Expand Up @@ -94,6 +94,13 @@ class QgsDataDefinedButton : QToolButton
*/
QgsDataDefined currentDataDefined() const;

/** Sets the vector layer associated with the button. This controls which fields are
* displayed within the widget's pop up menu.
* @param layer vector layer
* @note added in QGIS 3.0
*/
void setVectorLayer( QgsVectorLayer* layer );

/**
* Whether the current data definition or expression is to be used
*/
Expand Down
6 changes: 5 additions & 1 deletion src/gui/qgsdatadefinedbutton.cpp
Expand Up @@ -195,7 +195,6 @@ void QgsDataDefinedButton::init( const QgsVectorLayer* vl,
mActionDataTypes->setText( tr( "Field type: " ) + mDataTypesString );
}

updateFieldLists();
updateGui();
}

Expand All @@ -218,6 +217,11 @@ QgsDataDefined QgsDataDefinedButton::currentDataDefined() const
return dd;
}

void QgsDataDefinedButton::setVectorLayer( QgsVectorLayer* layer )
{
mVectorLayer = layer;
}

void QgsDataDefinedButton::mouseReleaseEvent( QMouseEvent *event )
{
// Ctrl-click to toggle activated state
Expand Down
7 changes: 7 additions & 0 deletions src/gui/qgsdatadefinedbutton.h
Expand Up @@ -127,6 +127,13 @@ class GUI_EXPORT QgsDataDefinedButton: public QToolButton
*/
QgsDataDefined currentDataDefined() const;

/** Sets the vector layer associated with the button. This controls which fields are
* displayed within the widget's pop up menu.
* @param layer vector layer
* @note added in QGIS 3.0
*/
void setVectorLayer( QgsVectorLayer* layer );

/**
* Whether the current data definition or expression is to be used
*/
Expand Down

0 comments on commit eb5cc0c

Please sign in to comment.