QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Slots | Signals | Public Member Functions | List of all members
QgsExpressionBuilderWidget Class Reference

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

#include <qgsexpressionbuilderwidget.h>

Inheritance diagram for QgsExpressionBuilderWidget:
Inheritance graph
[legend]

Public Slots

void currentChanged (const QModelIndex &index, const QModelIndex &)
 
void loadAllValues ()
 
void loadSampleValues ()
 
void on_btnNewFile_pressed ()
 
void on_btnRun_pressed ()
 
void on_btnSaveFile_pressed ()
 
void on_cmbFileNames_currentIndexChanged (int index)
 
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. More...
 

Public Member Functions

 QgsExpressionBuilderWidget (QWidget *parent)
 
 ~QgsExpressionBuilderWidget ()
 
QString expressionText ()
 Gets the expression string that has been set in the expression area. More...
 
bool isExpressionValid ()
 
void loadCodeFromFile (QString path)
 Load code from the given file into the function editor. More...
 
void loadFieldNames ()
 Loads all the field names from the layer. More...
 
void loadFieldNames (const QgsFields &fields)
 
void loadFunctionCode (QString code)
 Load code into the function editor. More...
 
void loadRecent (QString key)
 
void newFunctionFile (QString fileName="scratch")
 Create a new file in the function editor. More...
 
void registerItem (QString group, QString label, QString expressionText, QString helpText="", QgsExpressionItem::ItemType type=QgsExpressionItem::ExpressionNode)
 Registers a node item for the expression builder. More...
 
void saveFunctionFile (QString fileName)
 Save the current function editor text to the given file. More...
 
void saveToRecent (QString key)
 
void setExpressionText (const QString &expression)
 Sets the expression string for the widget. More...
 
void setGeomCalculator (const QgsDistanceArea &da)
 Sets geometry calculator used in distance/area calculations. More...
 
void setLayer (QgsVectorLayer *layer)
 Sets layer in order to get the fields and values. More...
 
void updateFunctionFileList (QString path)
 Update the list of function files found at the given path. More...
 

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)

Definition at line 31 of file qgsexpressionbuilderwidget.cpp.

QgsExpressionBuilderWidget::~QgsExpressionBuilderWidget ( )

Definition at line 83 of file qgsexpressionbuilderwidget.cpp.

Member Function Documentation

void QgsExpressionBuilderWidget::currentChanged ( const QModelIndex &  index,
const QModelIndex &   
)
slot

Definition at line 95 of file qgsexpressionbuilderwidget.cpp.

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.
QString QgsExpressionBuilderWidget::expressionText ( )

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

Returns
The expression as a string.

Definition at line 420 of file qgsexpressionbuilderwidget.cpp.

bool QgsExpressionBuilderWidget::isExpressionValid ( )

Definition at line 317 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::loadAllValues ( )
slot

Definition at line 568 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::loadCodeFromFile ( QString  path)

Load code from the given file into the function editor.

Definition at line 197 of file qgsexpressionbuilderwidget.cpp.

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

void QgsExpressionBuilderWidget::loadFieldNames ( const QgsFields fields)

Definition at line 248 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::loadFunctionCode ( QString  code)

Load code into the function editor.

Definition at line 205 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::loadRecent ( QString  key)

Definition at line 340 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::loadSampleValues ( )
slot

Definition at line 554 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::newFunctionFile ( QString  fileName = "scratch")

Create a new file in the function editor.

Definition at line 171 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::on_btnNewFile_pressed ( )
slot

Definition at line 183 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::on_btnRun_pressed ( )
slot

Definition at line 117 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::on_btnSaveFile_pressed ( )
slot

Definition at line 210 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::on_cmbFileNames_currentIndexChanged ( int  index)
slot

Definition at line 188 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::on_expressionTree_doubleClicked ( const QModelIndex &  index)
slot

Definition at line 222 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::on_lblPreview_linkActivated ( QString  link)
slot

Definition at line 512 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::on_mValueListWidget_itemDoubleClicked ( QListWidgetItem *  item)
slot

Definition at line 521 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::on_txtExpressionString_textChanged ( )
slot

Definition at line 430 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::on_txtSearchEdit_textChanged ( )
slot

Definition at line 503 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::operatorButtonClicked ( )
slot

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

void QgsExpressionBuilderWidget::saveFunctionFile ( QString  fileName)

Save the current function editor text to the given file.

Definition at line 133 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::saveToRecent ( QString  key)

Definition at line 322 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::setExpressionText ( const QString &  expression)

Sets the expression string for the widget.

Definition at line 425 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::setGeomCalculator ( const QgsDistanceArea da)

Sets geometry calculator used in distance/area calculations.

Definition at line 415 of file qgsexpressionbuilderwidget.cpp.

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

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

Definition at line 537 of file qgsexpressionbuilderwidget.cpp.

void QgsExpressionBuilderWidget::updateFunctionFileList ( QString  path)

Update the list of function files found at the given path.

Definition at line 156 of file qgsexpressionbuilderwidget.cpp.


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