QGIS API Documentation
2.0.1-Dufour
|
A reusable widget that can be used to build a expression string. More...
#include <qgsexpressionbuilderwidget.h>
Public Slots | |
void | currentChanged (const QModelIndex &index, const QModelIndex &) |
void | on_expressionTree_doubleClicked (const QModelIndex &index) |
void | on_txtExpressionString_textChanged () |
void | on_txtSearchEdit_textChanged () |
void | on_lblPreview_linkActivated (QString link) |
void | on_mValueListWidget_itemDoubleClicked (QListWidgetItem *item) |
void | operatorButtonClicked () |
void | showContextMenu (const QPoint &) |
void | loadSampleValues () |
void | loadAllValues () |
Signals | |
void | expressionParsed (bool isValid) |
Emitted when the user changes the expression in the widget. |
Public Member Functions | |
QgsExpressionBuilderWidget (QWidget *parent) | |
~QgsExpressionBuilderWidget () | |
void | setLayer (QgsVectorLayer *layer) |
Sets layer in order to get the fields and values. | |
void | loadFieldNames () |
Loads all the field names from the layer. | |
void | loadFieldNames (const QgsFields &fields) |
void | setGeomCalculator (const QgsDistanceArea &da) |
Sets geometry calculator used in distance/area calculations. | |
QString | expressionText () |
Gets the expression string that has been set in the expression area. | |
void | setExpressionText (const QString &expression) |
Sets the expression string for the widget. | |
void | registerItem (QString group, QString label, QString expressionText, QString helpText="", QgsExpressionItem::ItemType type=QgsExpressionItem::ExpressionNode) |
Registers a node item for the expression builder. | |
bool | isExpressionValid () |
Private Slots | |
void | setExpressionState (bool state) |
Private Member Functions | |
void | fillFieldValues (int fieldIndex, int countLimit) |
QString | loadFunctionHelp (QgsExpressionItem *functionName) |
Private Attributes | |
QgsVectorLayer * | mLayer |
QStandardItemModel * | mModel |
QgsExpressionItemSearchProxy * | mProxyModel |
QMap< QString, QgsExpressionItem * > | mExpressionGroups |
QgsFeature | mFeature |
QgsExpressionHighlighter * | highlighter |
bool | mExpressionValid |
QgsDistanceArea | mDa |
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.
QgsExpressionBuilderWidget::QgsExpressionBuilderWidget | ( | QWidget * | parent | ) |
Definition at line 27 of file qgsexpressionbuilderwidget.cpp.
References currentChanged(), expressionParsed(), QgsExpression::functionCount(), QgsExpression::Functions(), QgsExpression::Function::group(), QgsExpression::Function::helptext(), highlighter, loadAllValues(), loadSampleValues(), mModel, mProxyModel, QgsExpression::Function::name(), operatorButtonClicked(), QgsExpression::Function::params(), registerItem(), setExpressionState(), showContextMenu(), QgsExpression::specialColumns(), and tr.
QgsExpressionBuilderWidget::~QgsExpressionBuilderWidget | ( | ) |
Definition at line 113 of file qgsexpressionbuilderwidget.cpp.
|
slot |
Definition at line 123 of file qgsexpressionbuilderwidget.cpp.
References QgsExpressionItem::Field, QgsExpressionItem::getItemType(), loadFunctionHelp(), mLayer, mModel, and mProxyModel.
Referenced by QgsExpressionBuilderWidget().
|
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.
isValid | Is true if the expression the user has typed is valid. |
Referenced by on_txtExpressionString_textChanged(), and QgsExpressionBuilderWidget().
QString QgsExpressionBuilderWidget::expressionText | ( | ) |
Gets the expression string that has been set in the expression area.
Definition at line 251 of file qgsexpressionbuilderwidget.cpp.
|
private |
Definition at line 188 of file qgsexpressionbuilderwidget.cpp.
References mLayer, and QgsVectorLayer::uniqueValues().
Referenced by loadAllValues(), and loadSampleValues().
bool QgsExpressionBuilderWidget::isExpressionValid | ( | ) |
Definition at line 241 of file qgsexpressionbuilderwidget.cpp.
References mExpressionValid.
|
slot |
Definition at line 398 of file qgsexpressionbuilderwidget.cpp.
References QgsVectorLayer::fieldNameIndex(), fillFieldValues(), mLayer, mModel, and mProxyModel.
Referenced by QgsExpressionBuilderWidget(), and showContextMenu().
void QgsExpressionBuilderWidget::loadFieldNames | ( | ) |
Loads all the field names from the layer.
Definition at line 162 of file qgsexpressionbuilderwidget.cpp.
References mLayer, and QgsVectorLayer::pendingFields().
void QgsExpressionBuilderWidget::loadFieldNames | ( | const QgsFields & | fields | ) |
Definition at line 172 of file qgsexpressionbuilderwidget.cpp.
References QgsExpressionHighlighter::addFields(), QgsFields::count(), QgsExpressionItem::Field, highlighter, QgsFields::isEmpty(), and registerItem().
|
private |
Definition at line 417 of file qgsexpressionbuilderwidget.cpp.
References QgsExpressionItem::Field, QgsExpressionItem::getHelpText(), QgsExpressionItem::getItemType(), QgsExpression::helptext(), and QgsApplication::reportStyleSheet().
Referenced by currentChanged().
|
slot |
Definition at line 384 of file qgsexpressionbuilderwidget.cpp.
References QgsVectorLayer::fieldNameIndex(), fillFieldValues(), mLayer, mModel, and mProxyModel.
Referenced by QgsExpressionBuilderWidget(), and showContextMenu().
|
slot |
Definition at line 146 of file qgsexpressionbuilderwidget.cpp.
References QgsExpressionItem::getExpressionText(), QgsExpressionItem::getItemType(), QgsExpressionItem::Header, mModel, and mProxyModel.
|
slot |
Definition at line 345 of file qgsexpressionbuilderwidget.cpp.
References QgsMessageViewer::setMessageAsHtml(), and tr.
|
slot |
Definition at line 354 of file qgsexpressionbuilderwidget.cpp.
|
slot |
Definition at line 261 of file qgsexpressionbuilderwidget.cpp.
References QgsExpression::evalErrorString(), QgsExpression::evaluate(), expressionParsed(), QgsVectorLayer::geometryType(), QgsVectorLayer::getFeatures(), QgsExpression::hasEvalError(), QgsExpression::hasParserError(), QgsFeature::isValid(), mDa, mFeature, mLayer, QgsExpression::needsGeometry(), QgsFeatureRequest::NoFlags, QgsFeatureRequest::NoGeometry, QGis::NoGeometry, QgsExpression::parserErrorString(), QgsVectorLayer::pendingFields(), QgsExpression::setGeomCalculator(), and tr.
|
slot |
Definition at line 336 of file qgsexpressionbuilderwidget.cpp.
References mProxyModel.
|
slot |
Definition at line 360 of file qgsexpressionbuilderwidget.cpp.
Referenced by QgsExpressionBuilderWidget().
void QgsExpressionBuilderWidget::registerItem | ( | QString | group, |
QString | label, | ||
QString | expressionText, | ||
QString | helpText = "" , |
||
QgsExpressionItem::ItemType | type = QgsExpressionItem::ExpressionNode |
||
) |
Registers a node item for the expression builder.
group | The group the item will be show in the tree view. If the group doesn't exsit it will be created. |
label | The label that is show to the user for the item in the tree. |
expressionText | The text that is inserted into the expression area when the user double clicks on the item. |
helpText | The help text that the user will see when item is selected. |
type | The type of the expression item. |
Definition at line 216 of file qgsexpressionbuilderwidget.cpp.
References QgsExpression::group(), QgsExpressionItem::Header, mExpressionGroups, and mModel.
Referenced by loadFieldNames(), and QgsExpressionBuilderWidget().
|
privateslot |
Definition at line 412 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 256 of file qgsexpressionbuilderwidget.cpp.
void QgsExpressionBuilderWidget::setGeomCalculator | ( | const QgsDistanceArea & | da | ) |
Sets geometry calculator used in distance/area calculations.
Definition at line 246 of file qgsexpressionbuilderwidget.cpp.
References mDa.
void QgsExpressionBuilderWidget::setLayer | ( | QgsVectorLayer * | layer | ) |
Sets layer in order to get the fields and values.
Definition at line 118 of file qgsexpressionbuilderwidget.cpp.
References mLayer.
|
slot |
Definition at line 367 of file qgsexpressionbuilderwidget.cpp.
References QgsExpressionItem::Field, QgsExpressionItem::getItemType(), loadAllValues(), loadSampleValues(), mLayer, mModel, mProxyModel, and tr.
Referenced by QgsExpressionBuilderWidget().
|
private |
Definition at line 183 of file qgsexpressionbuilderwidget.h.
Referenced by loadFieldNames(), and QgsExpressionBuilderWidget().
|
private |
Definition at line 185 of file qgsexpressionbuilderwidget.h.
Referenced by on_txtExpressionString_textChanged(), and setGeomCalculator().
|
private |
Definition at line 181 of file qgsexpressionbuilderwidget.h.
Referenced by registerItem().
|
private |
Definition at line 184 of file qgsexpressionbuilderwidget.h.
Referenced by isExpressionValid(), and setExpressionState().
|
private |
Definition at line 182 of file qgsexpressionbuilderwidget.h.
Referenced by on_txtExpressionString_textChanged().
|
private |
Definition at line 178 of file qgsexpressionbuilderwidget.h.
Referenced by currentChanged(), fillFieldValues(), loadAllValues(), loadFieldNames(), loadSampleValues(), on_txtExpressionString_textChanged(), setLayer(), and showContextMenu().
|
private |
Definition at line 179 of file qgsexpressionbuilderwidget.h.
Referenced by currentChanged(), loadAllValues(), loadSampleValues(), on_expressionTree_doubleClicked(), QgsExpressionBuilderWidget(), registerItem(), and showContextMenu().
|
private |
Definition at line 180 of file qgsexpressionbuilderwidget.h.
Referenced by currentChanged(), loadAllValues(), loadSampleValues(), on_expressionTree_doubleClicked(), on_txtSearchEdit_textChanged(), QgsExpressionBuilderWidget(), and showContextMenu().