QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Slots | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
QgsDataDefinedButton Class Reference

A button for defining data source field mappings or expressions. More...

#include <qgsdatadefinedbutton.h>

Collaboration diagram for QgsDataDefinedButton:
Collaboration graph
[legend]

Public Types

enum  DataType { AnyType = 0, String = 1, Int = 2, Double = 4 }

Public Slots

void setActive (bool active)
 Set whether the current data definition or expression is to be used.
void disableEnabledWidgets (bool disable)
 Set siblings' enabled property when data definition or expression is set/unset.
void checkCheckedWidgets (bool check)
 Set siblings' checked property when data definition or expression is active.

Signals

void dataDefinedChanged (const QString &definition)
 Emitted when data definition or expression is changed.
void dataDefinedActivated (bool active)
 Emitted when active state changed.

Public Member Functions

 QgsDataDefinedButton (QWidget *parent=0, const QgsVectorLayer *vl=0, const QgsDataDefined *datadefined=0, DataTypes datatypes=AnyType, QString description=QString(""))
 Construct a new data defined button.
 ~QgsDataDefinedButton ()
void init (const QgsVectorLayer *vl, const QgsDataDefined *datadefined=0, DataTypes datatypes=AnyType, QString description=QString(""))
 Initialize a newly constructed data defined button (useful if button already included from form layout)
QMap< QString, QString > definedProperty () const
bool isActive ()
 Whether the current data definition or expression is to be used.
bool useExpression ()
 Whether the current expression is to be used instead of field mapping.
QString getExpression () const
 The current defined expression.
QString getField () const
 The current defined field.
QString currentDefinition () const
 The current definition.
const DataTypes & validDataTypes () const
 The valid data types that will work for the definition (QVariant-coercible to expected type) Compared against the variant type of the QgsField from data source and expression result.
QString fullDescription () const
 The full definition description and current definition (internally generated on a contextual basis)
QString usageInfo () const
 The usage information about this data definition.
void setUsageInfo (const QString &info)
 Set the usage information about this data definition.
void registerEnabledWidgets (QList< QWidget * > wdgts)
 Register list of sibling widgets that get disabled/enabled when data definition or expression is set/unset.
void registerEnabledWidget (QWidget *wdgt)
 Register a sibling widget that gets disabled/enabled when data definition or expression is set/unset.
QList< QWidget * > registeredEnabledWidgets ()
 Return widget siblings that get disabled/enabled when data definition or expression is set/unset.
void clearEnabledWidgets ()
 Clears list of sibling widgets.
void registerCheckedWidgets (QList< QWidget * > wdgts)
 Register list of sibling widgets that get checked when data definition or expression is active.
void registerCheckedWidget (QWidget *wdgt)
 Register a sibling widget that get checked when data definition or expression is active.
QList< QWidget * > registeredCheckedWidgets ()
 Return widget siblings that get checked when data definition or expression is active.
void clearCheckedWidgets ()
 Clears list of checkable sibling widgets.

Static Public Member Functions

static QString trString ()
 Common descriptions for expected input values.
static QString boolDesc ()
static QString anyStringDesc ()
static QString intDesc ()
static QString intPosDesc ()
static QString intPosOneDesc ()
static QString doubleDesc ()
static QString doublePosDesc ()
static QString doubleXYDesc ()
static QString double180RotDesc ()
static QString intTranspDesc ()
static QString unitsMmMuDesc ()
static QString unitsMmMuPercentDesc ()
static QString colorNoAlphaDesc ()
static QString colorAlphaDesc ()
static QString textHorzAlignDesc ()
static QString textVertAlignDesc ()
static QString penJoinStyleDesc ()
static QString blendModesDesc ()
static QString svgPathDesc ()

Protected Member Functions

void mouseReleaseEvent (QMouseEvent *event)
void setUseExpression (bool use)
 Set whether the current expression is to be used instead of field mapping.
void setExpression (QString exp)
 Set the current defined expression.
void setField (QString field)
 Set the current defined field.

Private Slots

void aboutToShowMenu ()
void menuActionTriggered (QAction *action)

Private Member Functions

void showDescriptionDialog ()
void showExpressionDialog ()
void updateGui ()

Private Attributes

const QgsVectorLayermVectorLayer
QgsFields mFields
QStringList mFieldNameList
QStringList mFieldTypeList
QMap< QString, QString > mProperty
QList< QPointer< QWidget > > mEnabledWidgets
QList< QPointer< QWidget > > mCheckedWidgets
QMenu * mDefineMenu
QAction * mActionDataTypes
QMenu * mFieldsMenu
QAction * mActionActive
QAction * mActionDescription
QAction * mActionExpDialog
QAction * mActionExpression
QAction * mActionPasteExpr
QAction * mActionCopyExpr
QAction * mActionClearExpr
DataTypes mDataTypes
QString mDataTypesString
QString mInputDescription
QString mFullDescription
QString mUsageInfo
QString mCurrentDefinition

Static Private Attributes

static QIcon mIconDataDefine
static QIcon mIconDataDefineOn
static QIcon mIconDataDefineError
static QIcon mIconDataDefineExpression
static QIcon mIconDataDefineExpressionOn
static QIcon mIconDataDefineExpressionError

Detailed Description

A button for defining data source field mappings or expressions.

Note
added in QGIS 1.9

Definition at line 34 of file qgsdatadefinedbutton.h.

Member Enumeration Documentation

Enumerator:
AnyType 
String 
Int 
Double 

Definition at line 39 of file qgsdatadefinedbutton.h.

Constructor & Destructor Documentation

QgsDataDefinedButton::QgsDataDefinedButton ( QWidget *  parent = 0,
const QgsVectorLayer vl = 0,
const QgsDataDefined datadefined = 0,
DataTypes  datatypes = AnyType,
QString  description = QString( "" ) 
)

Construct a new data defined button.

Parameters
parentThe parent QWidget
vlPointer to the associated vector layer
datadefinedData defined property
datatypesThe expected data types to be compared against the variant type of the QgsField from data source and expression result
descriptionThe description of expected input data

Definition at line 38 of file qgsdatadefinedbutton.cpp.

References aboutToShowMenu(), checkCheckedWidgets(), dataDefinedActivated(), disableEnabledWidgets(), QgsApplication::getThemeIcon(), init(), mActionActive, mActionClearExpr, mActionCopyExpr, mActionDataTypes, mActionDescription, mActionExpDialog, mActionExpression, mActionPasteExpr, mDefineMenu, menuActionTriggered(), mFieldsMenu, mIconDataDefine, mIconDataDefineError, mIconDataDefineExpression, mIconDataDefineExpressionError, mIconDataDefineExpressionOn, mIconDataDefineOn, and tr.

QgsDataDefinedButton::~QgsDataDefinedButton ( )

Definition at line 93 of file qgsdatadefinedbutton.cpp.

References mCheckedWidgets, and mEnabledWidgets.

Member Function Documentation

void QgsDataDefinedButton::aboutToShowMenu ( )
privateslot
QString QgsDataDefinedButton::anyStringDesc ( )
static

Definition at line 611 of file qgsdatadefinedbutton.cpp.

References tr.

QString QgsDataDefinedButton::blendModesDesc ( )
static

Definition at line 691 of file qgsdatadefinedbutton.cpp.

References trString().

QString QgsDataDefinedButton::boolDesc ( )
static

Definition at line 606 of file qgsdatadefinedbutton.cpp.

References tr.

void QgsDataDefinedButton::checkCheckedWidgets ( bool  check)
slot

Set siblings' checked property when data definition or expression is active.

Definition at line 577 of file qgsdatadefinedbutton.cpp.

References mCheckedWidgets.

Referenced by QgsDataDefinedButton().

void QgsDataDefinedButton::clearCheckedWidgets ( )
inline

Clears list of checkable sibling widgets.

Definition at line 168 of file qgsdatadefinedbutton.h.

void QgsDataDefinedButton::clearEnabledWidgets ( )
inline

Clears list of sibling widgets.

Definition at line 146 of file qgsdatadefinedbutton.h.

QString QgsDataDefinedButton::colorAlphaDesc ( )
static

Definition at line 671 of file qgsdatadefinedbutton.cpp.

References tr.

QString QgsDataDefinedButton::colorNoAlphaDesc ( )
static

Definition at line 666 of file qgsdatadefinedbutton.cpp.

References tr.

QString QgsDataDefinedButton::currentDefinition ( ) const
inline

The current definition.

Returns
empty QString if not active, otherwise currently defined expression or field name

Definition at line 103 of file qgsdatadefinedbutton.h.

void QgsDataDefinedButton::dataDefinedActivated ( bool  active)
signal

Emitted when active state changed.

Parameters
activeWhether the definition is active

Referenced by QgsDataDefinedButton(), and setActive().

void QgsDataDefinedButton::dataDefinedChanged ( const QString &  definition)
signal

Emitted when data definition or expression is changed.

Parameters
definitionThe current definition or expression (empty string if inactive)

Referenced by updateGui().

QMap< QString, QString > QgsDataDefinedButton::definedProperty ( ) const
inline

Definition at line 77 of file qgsdatadefinedbutton.h.

void QgsDataDefinedButton::disableEnabledWidgets ( bool  disable)
slot

Set siblings' enabled property when data definition or expression is set/unset.

Definition at line 542 of file qgsdatadefinedbutton.cpp.

References mEnabledWidgets.

Referenced by QgsDataDefinedButton().

QString QgsDataDefinedButton::double180RotDesc ( )
static

Definition at line 646 of file qgsdatadefinedbutton.cpp.

References tr.

QString QgsDataDefinedButton::doubleDesc ( )
static

Definition at line 631 of file qgsdatadefinedbutton.cpp.

References tr.

QString QgsDataDefinedButton::doublePosDesc ( )
static

Definition at line 636 of file qgsdatadefinedbutton.cpp.

References tr.

QString QgsDataDefinedButton::doubleXYDesc ( )
static

Definition at line 641 of file qgsdatadefinedbutton.cpp.

References tr.

QString QgsDataDefinedButton::fullDescription ( ) const
inline

The full definition description and current definition (internally generated on a contextual basis)

Definition at line 114 of file qgsdatadefinedbutton.h.

QString QgsDataDefinedButton::getExpression ( ) const
inline

The current defined expression.

Definition at line 92 of file qgsdatadefinedbutton.h.

Referenced by aboutToShowMenu(), menuActionTriggered(), showExpressionDialog(), and updateGui().

QString QgsDataDefinedButton::getField ( ) const
inline

The current defined field.

Definition at line 97 of file qgsdatadefinedbutton.h.

Referenced by aboutToShowMenu(), menuActionTriggered(), and updateGui().

void QgsDataDefinedButton::init ( const QgsVectorLayer vl,
const QgsDataDefined datadefined = 0,
DataTypes  datatypes = AnyType,
QString  description = QString( "" ) 
)

Initialize a newly constructed data defined button (useful if button already included from form layout)

Parameters
vlPointer to the associated vector layer
datadefinedData defined property
datatypesThe expected data types to be compared against the variant type of the QgsField from data source and expression result
descriptionThe description of expected input data

Definition at line 99 of file qgsdatadefinedbutton.cpp.

References AnyType, QgsFields::at(), QgsFields::count(), Double, QgsDataDefined::expressionString(), QgsDataDefined::field(), Int, QgsDataDefined::isActive(), mActionDataTypes, mCurrentDefinition, mDataTypes, mDataTypesString, mFieldNameList, mFieldTypeList, mFullDescription, mInputDescription, mProperty, mUsageInfo, mVectorLayer, QgsField::name(), QgsVectorLayer::pendingFields(), String, tr, QgsField::type(), updateGui(), and QgsDataDefined::useExpression().

Referenced by QgsDataDefinedButton().

QString QgsDataDefinedButton::intDesc ( )
static

Definition at line 616 of file qgsdatadefinedbutton.cpp.

References tr.

QString QgsDataDefinedButton::intPosDesc ( )
static

Definition at line 621 of file qgsdatadefinedbutton.cpp.

References tr.

QString QgsDataDefinedButton::intPosOneDesc ( )
static

Definition at line 626 of file qgsdatadefinedbutton.cpp.

References tr.

QString QgsDataDefinedButton::intTranspDesc ( )
static

Definition at line 651 of file qgsdatadefinedbutton.cpp.

References tr.

bool QgsDataDefinedButton::isActive ( )
inline

Whether the current data definition or expression is to be used.

Definition at line 82 of file qgsdatadefinedbutton.h.

Referenced by aboutToShowMenu(), menuActionTriggered(), mouseReleaseEvent(), setActive(), and updateGui().

void QgsDataDefinedButton::menuActionTriggered ( QAction *  action)
privateslot
void QgsDataDefinedButton::mouseReleaseEvent ( QMouseEvent *  event)
protected

Definition at line 193 of file qgsdatadefinedbutton.cpp.

References isActive(), setActive(), and updateGui().

QString QgsDataDefinedButton::penJoinStyleDesc ( )
static

Definition at line 686 of file qgsdatadefinedbutton.cpp.

References trString().

void QgsDataDefinedButton::registerCheckedWidget ( QWidget *  wdgt)

Register a sibling widget that get checked when data definition or expression is active.

Definition at line 558 of file qgsdatadefinedbutton.cpp.

References mCheckedWidgets.

Referenced by registerCheckedWidgets().

void QgsDataDefinedButton::registerCheckedWidgets ( QList< QWidget * >  wdgts)

Register list of sibling widgets that get checked when data definition or expression is active.

Definition at line 550 of file qgsdatadefinedbutton.cpp.

References registerCheckedWidget().

QList< QWidget * > QgsDataDefinedButton::registeredCheckedWidgets ( )

Return widget siblings that get checked when data definition or expression is active.

Returns
unguarded pointers from guarded ones

Definition at line 567 of file qgsdatadefinedbutton.cpp.

References mCheckedWidgets.

QList< QWidget * > QgsDataDefinedButton::registeredEnabledWidgets ( )

Return widget siblings that get disabled/enabled when data definition or expression is set/unset.

Returns
unguarded pointers from guarded ones

Definition at line 532 of file qgsdatadefinedbutton.cpp.

References mEnabledWidgets.

void QgsDataDefinedButton::registerEnabledWidget ( QWidget *  wdgt)

Register a sibling widget that gets disabled/enabled when data definition or expression is set/unset.

Definition at line 523 of file qgsdatadefinedbutton.cpp.

References mEnabledWidgets.

Referenced by registerEnabledWidgets().

void QgsDataDefinedButton::registerEnabledWidgets ( QList< QWidget * >  wdgts)

Register list of sibling widgets that get disabled/enabled when data definition or expression is set/unset.

Definition at line 515 of file qgsdatadefinedbutton.cpp.

References registerEnabledWidget().

void QgsDataDefinedButton::setActive ( bool  active)
slot

Set whether the current data definition or expression is to be used.

Definition at line 506 of file qgsdatadefinedbutton.cpp.

References dataDefinedActivated(), isActive(), and mProperty.

Referenced by menuActionTriggered(), mouseReleaseEvent(), showExpressionDialog(), and updateGui().

void QgsDataDefinedButton::setExpression ( QString  exp)
inlineprotected

Set the current defined expression.

Definition at line 234 of file qgsdatadefinedbutton.h.

Referenced by menuActionTriggered(), and showExpressionDialog().

void QgsDataDefinedButton::setField ( QString  field)
inlineprotected

Set the current defined field.

Definition at line 239 of file qgsdatadefinedbutton.h.

Referenced by menuActionTriggered().

void QgsDataDefinedButton::setUsageInfo ( const QString &  info)
inline

Set the usage information about this data definition.

Definition at line 124 of file qgsdatadefinedbutton.h.

void QgsDataDefinedButton::setUseExpression ( bool  use)
inlineprotected

Set whether the current expression is to be used instead of field mapping.

Definition at line 229 of file qgsdatadefinedbutton.h.

Referenced by menuActionTriggered(), showExpressionDialog(), and updateGui().

void QgsDataDefinedButton::showDescriptionDialog ( )
private

Definition at line 387 of file qgsdatadefinedbutton.cpp.

References mFullDescription, QgsMessageViewer::setMessageAsHtml(), and tr.

Referenced by menuActionTriggered().

void QgsDataDefinedButton::showExpressionDialog ( )
private
QString QgsDataDefinedButton::svgPathDesc ( )
static

Definition at line 698 of file qgsdatadefinedbutton.cpp.

References trString().

QString QgsDataDefinedButton::textHorzAlignDesc ( )
static

Definition at line 676 of file qgsdatadefinedbutton.cpp.

References trString().

QString QgsDataDefinedButton::textVertAlignDesc ( )
static

Definition at line 681 of file qgsdatadefinedbutton.cpp.

References trString().

QString QgsDataDefinedButton::trString ( )
static

Common descriptions for expected input values.

Definition at line 600 of file qgsdatadefinedbutton.cpp.

References tr.

Referenced by blendModesDesc(), penJoinStyleDesc(), svgPathDesc(), textHorzAlignDesc(), textVertAlignDesc(), unitsMmMuDesc(), and unitsMmMuPercentDesc().

QString QgsDataDefinedButton::unitsMmMuDesc ( )
static

Definition at line 656 of file qgsdatadefinedbutton.cpp.

References trString().

QString QgsDataDefinedButton::unitsMmMuPercentDesc ( )
static

Definition at line 661 of file qgsdatadefinedbutton.cpp.

References trString().

void QgsDataDefinedButton::updateGui ( )
private
QString QgsDataDefinedButton::usageInfo ( ) const
inline

The usage information about this data definition.

Definition at line 119 of file qgsdatadefinedbutton.h.

bool QgsDataDefinedButton::useExpression ( )
inline

Whether the current expression is to be used instead of field mapping.

Definition at line 87 of file qgsdatadefinedbutton.h.

Referenced by aboutToShowMenu(), menuActionTriggered(), and updateGui().

const DataTypes& QgsDataDefinedButton::validDataTypes ( ) const
inline

The valid data types that will work for the definition (QVariant-coercible to expected type) Compared against the variant type of the QgsField from data source and expression result.

Definition at line 109 of file qgsdatadefinedbutton.h.

Member Data Documentation

QAction* QgsDataDefinedButton::mActionActive
private
QAction* QgsDataDefinedButton::mActionClearExpr
private
QAction* QgsDataDefinedButton::mActionCopyExpr
private
QAction* QgsDataDefinedButton::mActionDataTypes
private

Definition at line 255 of file qgsdatadefinedbutton.h.

Referenced by aboutToShowMenu(), init(), and QgsDataDefinedButton().

QAction* QgsDataDefinedButton::mActionDescription
private
QAction* QgsDataDefinedButton::mActionExpDialog
private
QAction* QgsDataDefinedButton::mActionExpression
private
QAction* QgsDataDefinedButton::mActionPasteExpr
private
QList< QPointer<QWidget> > QgsDataDefinedButton::mCheckedWidgets
private
QString QgsDataDefinedButton::mCurrentDefinition
private

Definition at line 271 of file qgsdatadefinedbutton.h.

Referenced by init(), and updateGui().

DataTypes QgsDataDefinedButton::mDataTypes
private

Definition at line 266 of file qgsdatadefinedbutton.h.

Referenced by init().

QString QgsDataDefinedButton::mDataTypesString
private

Definition at line 267 of file qgsdatadefinedbutton.h.

Referenced by aboutToShowMenu(), init(), and updateGui().

QMenu* QgsDataDefinedButton::mDefineMenu
private

Definition at line 254 of file qgsdatadefinedbutton.h.

Referenced by aboutToShowMenu(), and QgsDataDefinedButton().

QList< QPointer<QWidget> > QgsDataDefinedButton::mEnabledWidgets
private
QStringList QgsDataDefinedButton::mFieldNameList
private

Definition at line 248 of file qgsdatadefinedbutton.h.

Referenced by aboutToShowMenu(), init(), and updateGui().

QgsFields QgsDataDefinedButton::mFields
private

Definition at line 247 of file qgsdatadefinedbutton.h.

QMenu* QgsDataDefinedButton::mFieldsMenu
private
QStringList QgsDataDefinedButton::mFieldTypeList
private

Definition at line 249 of file qgsdatadefinedbutton.h.

Referenced by aboutToShowMenu(), and init().

QString QgsDataDefinedButton::mFullDescription
private

Definition at line 269 of file qgsdatadefinedbutton.h.

Referenced by aboutToShowMenu(), init(), showDescriptionDialog(), and updateGui().

QIcon QgsDataDefinedButton::mIconDataDefine
staticprivate

Definition at line 273 of file qgsdatadefinedbutton.h.

Referenced by QgsDataDefinedButton(), and updateGui().

QIcon QgsDataDefinedButton::mIconDataDefineError
staticprivate

Definition at line 275 of file qgsdatadefinedbutton.h.

Referenced by QgsDataDefinedButton(), and updateGui().

QIcon QgsDataDefinedButton::mIconDataDefineExpression
staticprivate

Definition at line 276 of file qgsdatadefinedbutton.h.

Referenced by QgsDataDefinedButton(), and updateGui().

QIcon QgsDataDefinedButton::mIconDataDefineExpressionError
staticprivate

Definition at line 278 of file qgsdatadefinedbutton.h.

Referenced by QgsDataDefinedButton(), and updateGui().

QIcon QgsDataDefinedButton::mIconDataDefineExpressionOn
staticprivate

Definition at line 277 of file qgsdatadefinedbutton.h.

Referenced by QgsDataDefinedButton(), and updateGui().

QIcon QgsDataDefinedButton::mIconDataDefineOn
staticprivate

Definition at line 274 of file qgsdatadefinedbutton.h.

Referenced by QgsDataDefinedButton(), and updateGui().

QString QgsDataDefinedButton::mInputDescription
private

Definition at line 268 of file qgsdatadefinedbutton.h.

Referenced by init(), and updateGui().

QMap< QString, QString > QgsDataDefinedButton::mProperty
private

Definition at line 250 of file qgsdatadefinedbutton.h.

Referenced by init(), and setActive().

QString QgsDataDefinedButton::mUsageInfo
private

Definition at line 270 of file qgsdatadefinedbutton.h.

Referenced by init(), and updateGui().

const QgsVectorLayer* QgsDataDefinedButton::mVectorLayer
private

Definition at line 246 of file qgsdatadefinedbutton.h.

Referenced by init(), and showExpressionDialog().


The documentation for this class was generated from the following files: