QGIS API Documentation  master-3f58142
QgsExpressionBuilderWidget Class Reference

A reusable widget that can be used to build a expression string. More...

#include <qgsexpressionbuilderwidget.h>

+ Collaboration diagram for QgsExpressionBuilderWidget:

List of all members.

Public Slots

void currentChanged (const QModelIndex &index, const QModelIndex &)
void loadAllValues ()
void loadSampleValues ()
void on_expressionTree_doubleClicked (const QModelIndex &index)
void on_lblPreview_linkActivated (QString link)
void on_mValueListWidget_itemDoubleClicked (QListWidgetItem *item)
void on_txtExpressionString_textChanged ()
void on_txtSearchEdit_textChanged ()
void operatorButtonClicked ()
void showContextMenu (const QPoint &)

Signals

void expressionParsed (bool isValid)
 Emitted when the user changes the expression in the widget.

Public Member Functions

 QgsExpressionBuilderWidget (QWidget *parent)
 ~QgsExpressionBuilderWidget ()
QString expressionText ()
 Gets the expression string that has been set in the expression area.
bool isExpressionValid ()
void loadFieldNames ()
 Loads all the field names from the layer.
void loadFieldNames (const QgsFields &fields)
void registerItem (QString group, QString label, QString expressionText, QString helpText="", QgsExpressionItem::ItemType type=QgsExpressionItem::ExpressionNode)
 Registers a node item for the expression builder.
void setExpressionText (const QString &expression)
 Sets the expression string for the widget.
void setGeomCalculator (const QgsDistanceArea &da)
 Sets geometry calculator used in distance/area calculations.
void setLayer (QgsVectorLayer *layer)
 Sets layer in order to get the fields and values.

Private Slots

void setExpressionState (bool state)

Private Member Functions

void fillFieldValues (int fieldIndex, int countLimit)
QString loadFunctionHelp (QgsExpressionItem *functionName)

Private Attributes

QgsExpressionHighlighterhighlighter
QgsDistanceArea mDa
QMap< QString,
QgsExpressionItem * > 
mExpressionGroups
bool mExpressionValid
QgsFeature mFeature
QgsVectorLayermLayer
QStandardItemModel * mModel
QgsExpressionItemSearchProxymProxyModel

Detailed Description

A reusable widget that can be used to build a expression string.

See QgsExpressionBuilderDialog for exmaple of usage.

Definition at line 107 of file qgsexpressionbuilderwidget.h.


Constructor & Destructor Documentation


Member Function Documentation

void QgsExpressionBuilderWidget::currentChanged ( const QModelIndex &  index,
const QModelIndex &   
) [slot]
void QgsExpressionBuilderWidget::expressionParsed ( bool  isValid) [signal]

Emitted when the user changes the expression in the widget.

Users of this widget should connect to this signal to decide if to let the user continue.

Parameters:
isValidIs true if the expression the user has typed is valid.

Referenced by on_txtExpressionString_textChanged(), and QgsExpressionBuilderWidget().

Gets the expression string that has been set in the expression area.

Returns:
The expression as a string.

Definition at line 250 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::fillFieldValues ( int  fieldIndex,
int  countLimit 
) [private]

Definition at line 187 of file qgsexpressionbuilderwidget.cpp.

References mLayer, and QgsVectorLayer::uniqueValues().

Referenced by loadAllValues(), and loadSampleValues().

Loads all the field names from the layer.

Remarks:
Should this really be public couldn't we just do this for the user?

Definition at line 161 of file qgsexpressionbuilderwidget.cpp.

References mLayer, and QgsVectorLayer::pendingFields().

Definition at line 353 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::registerItem ( QString  group,
QString  label,
QString  expressionText,
QString  helpText = "",
QgsExpressionItem::ItemType  type = QgsExpressionItem::ExpressionNode 
)

Registers a node item for the expression builder.

Parameters:
groupThe group the item will be show in the tree view. If the group doesn't exsit it will be created.
labelThe label that is show to the user for the item in the tree.
expressionTextThe text that is inserted into the expression area when the user double clicks on the item.
helpTextThe help text that the user will see when item is selected.
typeThe type of the expression item.

Definition at line 215 of file qgsexpressionbuilderwidget.cpp.

References QgsExpression::group(), QgsExpressionItem::Header, mExpressionGroups, and mModel.

Referenced by loadFieldNames(), and QgsExpressionBuilderWidget().

void QgsExpressionBuilderWidget::setExpressionState ( bool  state) [private, slot]

Definition at line 409 of file qgsexpressionbuilderwidget.cpp.

References mExpressionValid.

Referenced by QgsExpressionBuilderWidget().

void QgsExpressionBuilderWidget::setExpressionText ( const QString &  expression)

Sets the expression string for the widget.

Definition at line 255 of file qgsexpressionbuilderwidget.cpp.

Sets geometry calculator used in distance/area calculations.

Note:
added in version 2.0

Definition at line 245 of file qgsexpressionbuilderwidget.cpp.

References mDa.

Sets layer in order to get the fields and values.

Note:
this needs to be called before calling loadFieldNames().

Definition at line 118 of file qgsexpressionbuilderwidget.cpp.

References mLayer.


Member Data Documentation

Definition at line 181 of file qgsexpressionbuilderwidget.h.

Referenced by registerItem().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines