QGIS API Documentation
2.4.0-Chugiak
|
The QgsFieldExpressionWidget class reates a widget to choose fields and edit expressions It contains a combo boxto display the fields and expression and a button to open the expression dialog. More...
#include <qgsfieldexpressionwidget.h>
Public Slots | |
void | setLayer (QgsVectorLayer *layer) |
set the layer used to display the fields and expression More... | |
void | setLayer (QgsMapLayer *layer) |
convenience slot to connect QgsMapLayerComboBox layer signal More... | |
void | setField (const QString &fieldName) |
sets the current field or expression in the widget More... | |
Signals | |
void | fieldChanged (QString fieldName) |
the signal is emitted when the currently selected field changes More... | |
void | fieldChanged (QString fieldName, bool isValid) |
fieldChanged signal with indication of the validity of the expression More... | |
Public Member Functions | |
QgsFieldExpressionWidget (QWidget *parent=0) | |
QgsFieldExpressionWidget creates a widget with a combo box to display the fields and expression and a button to open the expression dialog. More... | |
void | setExpressionDialogTitle (QString title) |
define the title used in the expression dialog More... | |
const QString | expressionDialogTitle () |
return the title used for the expression dialog More... | |
void | setFilters (QgsFieldProxyModel::Filters filters) |
setFilters allows fitering according to the type of field More... | |
void | setLeftHandButtonStyle (bool isLeft) |
QgsFieldProxyModel::Filters | filters () |
currently used filter on list of fields More... | |
void | setGeomCalculator (const QgsDistanceArea &da) |
set the geometry calculator used in the expression dialog More... | |
QString | currentField (bool *isExpression=0, bool *isValid=0) |
currentField returns the currently selected field or expression if allowed More... | |
bool | isValidExpression (QString *expressionError=0) |
Return true if the current expression is valid. More... | |
bool | isExpression () |
QString | currentText () |
Return the current text that is set in the expression area. More... | |
QgsVectorLayer * | layer () |
Returns the currently used layer. More... | |
Protected Slots | |
void | editExpression () |
open the expression dialog to edit the current or add a new expression More... | |
void | expressionEdited (const QString expression) |
when expression is edited by the user in the line edit, it will be checked for validity More... | |
void | expressionEditingFinished () |
when expression has been edited (finished) it will be added to the model More... | |
void | currentFieldChanged () |
void | updateLineEditStyle (const QString expression=QString()) |
updateLineEditStyle will re-style (color/font) the line edit depending on content and status More... | |
bool | isExpressionValid (const QString expressionStr) |
Protected Member Functions | |
void | changeEvent (QEvent *event) |
Properties | |
QString | expressionDialogTitle |
QgsFieldProxyModel::Filters | filters |
Private Attributes | |
QComboBox * | mCombo |
QToolButton * | mButton |
QgsFieldProxyModel * | mFieldProxyModel |
QString | mExpressionDialogTitle |
QSharedPointer< const QgsDistanceArea > | mDa |
The QgsFieldExpressionWidget class reates a widget to choose fields and edit expressions It contains a combo boxto display the fields and expression and a button to open the expression dialog.
The combo box is editable, allowing expressions to be edited inline. The validity of the expression is checked live on key press, invalid expressions are displayed in red. The expression will be added to the model (and the fieldChanged signals emitted) only when editing in the line edit is finished (focus lost, enter key pressed).
Definition at line 40 of file qgsfieldexpressionwidget.h.
|
explicit |
QgsFieldExpressionWidget creates a widget with a combo box to display the fields and expression and a button to open the expression dialog.
Definition at line 25 of file qgsfieldexpressionwidget.cpp.
References currentFieldChanged(), editExpression(), expressionEdited(), expressionEditingFinished(), QgsApplication::getThemeIcon(), mButton, mCombo, mFieldProxyModel, QgsFieldModel::setAllowExpression(), and QgsFieldProxyModel::sourceFieldModel().
|
protected |
Definition at line 200 of file qgsfieldexpressionwidget.cpp.
References updateLineEditStyle().
QString QgsFieldExpressionWidget::currentField | ( | bool * | isExpression = 0 , |
bool * | isValid = 0 |
||
) |
currentField returns the currently selected field or expression if allowed
isExpression | determines if the string returned is the name of a field or an expression |
isValid | determines if the expression (or field) returned is valid |
Definition at line 103 of file qgsfieldexpressionwidget.cpp.
References currentText(), isExpression(), and isValidExpression().
Referenced by currentFieldChanged(), and updateLineEditStyle().
|
protectedslot |
Definition at line 208 of file qgsfieldexpressionwidget.cpp.
References currentField(), fieldChanged(), isExpression(), mCombo, and updateLineEditStyle().
Referenced by expressionEditingFinished(), QgsFieldExpressionWidget(), and setField().
QString QgsFieldExpressionWidget::currentText | ( | ) |
Return the current text that is set in the expression area.
Definition at line 86 of file qgsfieldexpressionwidget.cpp.
References mCombo.
Referenced by currentField(), editExpression(), isExpression(), and isValidExpression().
|
protectedslot |
open the expression dialog to edit the current or add a new expression
Definition at line 164 of file qgsfieldexpressionwidget.cpp.
References currentText(), QgsExpressionBuilderDialog::expressionText(), layer(), mDa, mExpressionDialogTitle, setField(), and QgsExpressionBuilderDialog::setGeomCalculator().
Referenced by QgsFieldExpressionWidget().
|
inline |
return the title used for the expression dialog
Definition at line 57 of file qgsfieldexpressionwidget.h.
|
protectedslot |
when expression is edited by the user in the line edit, it will be checked for validity
Definition at line 183 of file qgsfieldexpressionwidget.cpp.
References fieldChanged(), isValidExpression(), and updateLineEditStyle().
Referenced by QgsFieldExpressionWidget().
|
protectedslot |
when expression has been edited (finished) it will be added to the model
Definition at line 189 of file qgsfieldexpressionwidget.cpp.
References currentFieldChanged(), QgsFieldModel::indexFromName(), mCombo, mFieldProxyModel, QgsDebugMsg, QgsFieldModel::setExpression(), and QgsFieldProxyModel::sourceFieldModel().
Referenced by QgsFieldExpressionWidget().
|
signal |
the signal is emitted when the currently selected field changes
Referenced by currentFieldChanged(), and expressionEdited().
|
signal |
fieldChanged signal with indication of the validity of the expression
|
inline |
currently used filter on list of fields
Definition at line 65 of file qgsfieldexpressionwidget.h.
bool QgsFieldExpressionWidget::isExpression | ( | ) |
Definition at line 98 of file qgsfieldexpressionwidget.cpp.
References currentText(), QgsFieldModel::isField(), mFieldProxyModel, and QgsFieldProxyModel::sourceFieldModel().
Referenced by currentField(), currentFieldChanged(), and updateLineEditStyle().
|
protectedslot |
Definition at line 265 of file qgsfieldexpressionwidget.cpp.
References QgsExpression::hasParserError(), layer(), QgsVectorLayer::pendingFields(), and QgsExpression::prepare().
Referenced by updateLineEditStyle().
bool QgsFieldExpressionWidget::isValidExpression | ( | QString * | expressionError = 0 | ) |
Return true if the current expression is valid.
Definition at line 91 of file qgsfieldexpressionwidget.cpp.
References currentText(), QgsExpression::isValid(), layer(), and QgsVectorLayer::pendingFields().
Referenced by currentField(), and expressionEdited().
QgsVectorLayer * QgsFieldExpressionWidget::layer | ( | ) |
Returns the currently used layer.
Definition at line 117 of file qgsfieldexpressionwidget.cpp.
References QgsFieldModel::layer(), mFieldProxyModel, and QgsFieldProxyModel::sourceFieldModel().
Referenced by editExpression(), isExpressionValid(), isValidExpression(), and setLayer().
void QgsFieldExpressionWidget::setExpressionDialogTitle | ( | QString | title | ) |
define the title used in the expression dialog
Definition at line 59 of file qgsfieldexpressionwidget.cpp.
References mExpressionDialogTitle.
|
slot |
sets the current field or expression in the widget
Definition at line 136 of file qgsfieldexpressionwidget.cpp.
References currentFieldChanged(), QgsFieldModel::indexFromName(), mCombo, mFieldProxyModel, QgsFieldModel::setExpression(), and QgsFieldProxyModel::sourceFieldModel().
Referenced by editExpression().
void QgsFieldExpressionWidget::setFilters | ( | QgsFieldProxyModel::Filters | filters | ) |
setFilters allows fitering according to the type of field
Definition at line 64 of file qgsfieldexpressionwidget.cpp.
References mFieldProxyModel, and QgsFieldProxyModel::setFilters().
void QgsFieldExpressionWidget::setGeomCalculator | ( | const QgsDistanceArea & | da | ) |
set the geometry calculator used in the expression dialog
Definition at line 81 of file qgsfieldexpressionwidget.cpp.
References mDa.
|
slot |
set the layer used to display the fields and expression
Definition at line 131 of file qgsfieldexpressionwidget.cpp.
References mFieldProxyModel, QgsFieldModel::setLayer(), and QgsFieldProxyModel::sourceFieldModel().
Referenced by setLayer().
|
slot |
convenience slot to connect QgsMapLayerComboBox layer signal
Definition at line 122 of file qgsfieldexpressionwidget.cpp.
References layer(), and setLayer().
void QgsFieldExpressionWidget::setLeftHandButtonStyle | ( | bool | isLeft | ) |
Definition at line 69 of file qgsfieldexpressionwidget.cpp.
References mCombo.
|
protectedslot |
updateLineEditStyle will re-style (color/font) the line edit depending on content and status
expression | if expression is given it will be evaluated for the given string, otherwise it takes current expression from the model |
Definition at line 230 of file qgsfieldexpressionwidget.cpp.
References currentField(), isExpression(), isExpressionValid(), and mCombo.
Referenced by changeEvent(), currentFieldChanged(), and expressionEdited().
|
private |
Definition at line 136 of file qgsfieldexpressionwidget.h.
Referenced by QgsFieldExpressionWidget().
|
private |
Definition at line 135 of file qgsfieldexpressionwidget.h.
Referenced by currentFieldChanged(), currentText(), expressionEditingFinished(), QgsFieldExpressionWidget(), setField(), setLeftHandButtonStyle(), and updateLineEditStyle().
|
private |
Definition at line 139 of file qgsfieldexpressionwidget.h.
Referenced by editExpression(), and setGeomCalculator().
|
private |
Definition at line 138 of file qgsfieldexpressionwidget.h.
Referenced by editExpression(), and setExpressionDialogTitle().
|
private |
Definition at line 137 of file qgsfieldexpressionwidget.h.
Referenced by expressionEditingFinished(), isExpression(), layer(), QgsFieldExpressionWidget(), setField(), setFilters(), and setLayer().
|
readwrite |
Definition at line 43 of file qgsfieldexpressionwidget.h.
|
readwrite |
Definition at line 45 of file qgsfieldexpressionwidget.h.