QGIS API Documentation  2.2.0-Valmiera
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Slots | Signals | Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
QgsExpressionBuilderWidget Class Reference

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

#include <qgsexpressionbuilderwidget.h>

Collaboration diagram for QgsExpressionBuilderWidget:
Collaboration graph
[legend]

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 ()
void saveToRecent (QString key)
void loadRecent (QString key)

Private Slots

void setExpressionState (bool state)

Private Member Functions

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

Private Attributes

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

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

QgsExpressionBuilderWidget::QgsExpressionBuilderWidget ( QWidget *  parent)
QgsExpressionBuilderWidget::~QgsExpressionBuilderWidget ( )

Definition at line 110 of file qgsexpressionbuilderwidget.cpp.

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().

QString QgsExpressionBuilderWidget::expressionText ( )

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

Returns
The expression as a string.

Definition at line 283 of file qgsexpressionbuilderwidget.cpp.

Referenced by saveToRecent().

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

Definition at line 184 of file qgsexpressionbuilderwidget.cpp.

References mLayer, and QgsVectorLayer::uniqueValues().

Referenced by loadAllValues(), and loadSampleValues().

bool QgsExpressionBuilderWidget::isExpressionValid ( )

Definition at line 237 of file qgsexpressionbuilderwidget.cpp.

References mExpressionValid.

void QgsExpressionBuilderWidget::loadAllValues ( )
slot
void QgsExpressionBuilderWidget::loadFieldNames ( )

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 158 of file qgsexpressionbuilderwidget.cpp.

References mLayer, and QgsVectorLayer::pendingFields().

void QgsExpressionBuilderWidget::loadFieldNames ( const QgsFields fields)
QString QgsExpressionBuilderWidget::loadFunctionHelp ( QgsExpressionItem functionName)
private
void QgsExpressionBuilderWidget::loadRecent ( QString  key)

Definition at line 260 of file qgsexpressionbuilderwidget.cpp.

References mExpressionGroups, registerItem(), and tr.

Referenced by saveToRecent().

void QgsExpressionBuilderWidget::loadSampleValues ( )
slot
void QgsExpressionBuilderWidget::on_expressionTree_doubleClicked ( const QModelIndex &  index)
slot
void QgsExpressionBuilderWidget::on_lblPreview_linkActivated ( QString  link)
slot

Definition at line 377 of file qgsexpressionbuilderwidget.cpp.

References QgsMessageViewer::setMessageAsHtml(), and tr.

void QgsExpressionBuilderWidget::on_mValueListWidget_itemDoubleClicked ( QListWidgetItem *  item)
slot

Definition at line 386 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::on_txtExpressionString_textChanged ( )
slot
void QgsExpressionBuilderWidget::on_txtSearchEdit_textChanged ( )
slot

Definition at line 368 of file qgsexpressionbuilderwidget.cpp.

References mProxyModel.

void QgsExpressionBuilderWidget::operatorButtonClicked ( )
slot

Definition at line 392 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.

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 212 of file qgsexpressionbuilderwidget.cpp.

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

Referenced by loadFieldNames(), loadRecent(), and QgsExpressionBuilderWidget().

void QgsExpressionBuilderWidget::saveToRecent ( QString  key)

Definition at line 242 of file qgsexpressionbuilderwidget.cpp.

References expressionText(), and loadRecent().

void QgsExpressionBuilderWidget::setExpressionState ( bool  state)
privateslot

Definition at line 444 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 288 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::setGeomCalculator ( const QgsDistanceArea da)

Sets geometry calculator used in distance/area calculations.

Note
added in version 2.0

Definition at line 278 of file qgsexpressionbuilderwidget.cpp.

References mDa.

void QgsExpressionBuilderWidget::setLayer ( QgsVectorLayer layer)

Sets layer in order to get the fields and values.

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

Definition at line 115 of file qgsexpressionbuilderwidget.cpp.

References mLayer.

void QgsExpressionBuilderWidget::showContextMenu ( const QPoint &  pt)
slot

Member Data Documentation

QgsExpressionHighlighter* QgsExpressionBuilderWidget::highlighter
private

Definition at line 187 of file qgsexpressionbuilderwidget.h.

Referenced by loadFieldNames(), and QgsExpressionBuilderWidget().

QgsDistanceArea QgsExpressionBuilderWidget::mDa
private
QMap<QString, QgsExpressionItem*> QgsExpressionBuilderWidget::mExpressionGroups
private

Definition at line 185 of file qgsexpressionbuilderwidget.h.

Referenced by loadRecent(), and registerItem().

bool QgsExpressionBuilderWidget::mExpressionValid
private

Definition at line 188 of file qgsexpressionbuilderwidget.h.

Referenced by isExpressionValid(), and setExpressionState().

QgsFeature QgsExpressionBuilderWidget::mFeature
private

Definition at line 186 of file qgsexpressionbuilderwidget.h.

Referenced by on_txtExpressionString_textChanged().

QgsVectorLayer* QgsExpressionBuilderWidget::mLayer
private
QStandardItemModel* QgsExpressionBuilderWidget::mModel
private
QgsExpressionItemSearchProxy* QgsExpressionBuilderWidget::mProxyModel
private

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