Skip to content

Commit

Permalink
Add a method for creating a QgsDataDefined from a QgsDataDefinedButton
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 8, 2015
1 parent 2c38552 commit d970daa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/gui/qgsdatadefinedbutton.sip
Expand Up @@ -70,6 +70,13 @@ class QgsDataDefinedButton : QToolButton
*/
void updateDataDefined( QgsDataDefined* dd ) const;

/** Returns a QgsDataDefined which reflects the current settings from the
* button.
* @note added in QGIS 2.9
* @see updateDataDefined
*/
QgsDataDefined currentDataDefined() const;

/**
* Whether the current data definition or expression is to be used
*/
Expand Down
7 changes: 7 additions & 0 deletions src/gui/qgsdatadefinedbutton.cpp
Expand Up @@ -204,6 +204,13 @@ void QgsDataDefinedButton::updateDataDefined( QgsDataDefined *dd ) const
dd->setField( getField() );
}

QgsDataDefined QgsDataDefinedButton::currentDataDefined() const
{
QgsDataDefined dd;
updateDataDefined( &dd );
return dd;
}

void QgsDataDefinedButton::mouseReleaseEvent( QMouseEvent *event )
{
// Ctrl-click to toggle activated state
Expand Down
8 changes: 8 additions & 0 deletions src/gui/qgsdatadefinedbutton.h
Expand Up @@ -92,9 +92,17 @@ class GUI_EXPORT QgsDataDefinedButton: public QToolButton
/** Updates a QgsDataDefined with the current settings from the button
* @param dd QgsDataDefined to update
* @note added in QGIS 2.9
* @see currentDataDefined
*/
void updateDataDefined( QgsDataDefined* dd ) const;

/** Returns a QgsDataDefined which reflects the current settings from the
* button.
* @note added in QGIS 2.9
* @see updateDataDefined
*/
QgsDataDefined currentDataDefined() const;

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

0 comments on commit d970daa

Please sign in to comment.