QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
QgsExpressionTreeView is a tree view to list all expressions functions, variables and fields that can be used in an expression. More...
#include <qgsexpressiontreeview.h>
Classes | |
class | MenuProvider |
Implementation of this interface can be implemented to allow QgsExpressionTreeView instance to provide custom context menus (opened upon right-click). More... | |
Public Slots | |
void | setSearchText (const QString &text) |
Sets the text to filter the expression tree. More... | |
Signals | |
void | currentExpressionItemChanged (QgsExpressionItem *item) |
Emitter when the current expression item changed. More... | |
void | expressionItemDoubleClicked (const QString &text) |
Emitted when a expression item is double clicked. More... | |
Public Member Functions | |
QgsExpressionTreeView (QWidget *parent=nullptr) | |
Constructor. More... | |
QgsExpressionItem * | currentItem () const |
Returns the current item or a nullptr. More... | |
QJsonDocument | exportUserExpressions () |
Create the expressions JSON document storing all the user expressions to be exported. More... | |
QgsExpressionContext | expressionContext () const |
Returns the expression context for the widget. More... | |
const QList< QgsExpressionItem * > | findExpressions (const QString &label) |
Returns the list of expression items matching a label. More... | |
void | loadExpressionsFromJson (const QJsonDocument &expressionsDocument) |
Load and permanently store the expressions from the expressions JSON document. More... | |
void | loadFieldNames (const QgsFields &fields) |
This allows loading fields without specifying a layer. More... | |
void | loadRecent (const QString &collection=QStringLiteral("generic")) |
Loads the recent expressions from the given collection. More... | |
void | loadUserExpressions () |
Loads the user expressions. More... | |
Q_DECL_DEPRECATED QStandardItemModel * | model () |
Returns a pointer to the dialog's function item model. More... | |
QgsProject * | project () |
Returns the project currently associated with the widget. More... | |
void | refresh () |
Refreshes the content of the tree. More... | |
void | removeFromUserExpressions (const QString &label) |
Removes the expression label from the user stored expressions. More... | |
void | saveToRecent (const QString &expressionText, const QString &collection="generic") |
Adds the current expression to the given collection. More... | |
void | saveToUserExpressions (const QString &label, const QString expression, const QString &helpText) |
Stores the user expression with given label and helpText. More... | |
void | setExpressionContext (const QgsExpressionContext &context) |
Sets the expression context for the tree view. More... | |
void | setLayer (QgsVectorLayer *layer) |
Sets layer in order to get the fields and values. More... | |
void | setMenuProvider (MenuProvider *provider) |
Sets the menu provider. More... | |
void | setProject (QgsProject *project) |
Sets the project currently associated with the widget. More... | |
QStringList | userExpressionLabels () const |
Returns the user expression labels. More... | |
QgsExpressionTreeView is a tree view to list all expressions functions, variables and fields that can be used in an expression.
Definition at line 136 of file qgsexpressiontreeview.h.
QgsExpressionTreeView::QgsExpressionTreeView | ( | QWidget * | parent = nullptr | ) |
Constructor.
Definition at line 107 of file qgsexpressiontreeview.cpp.
|
signal |
Emitter when the current expression item changed.
QgsExpressionItem * QgsExpressionTreeView::currentItem | ( | ) | const |
Returns the current item or a nullptr.
Definition at line 170 of file qgsexpressiontreeview.cpp.
QJsonDocument QgsExpressionTreeView::exportUserExpressions | ( | ) |
Create the expressions JSON document storing all the user expressions to be exported.
Definition at line 561 of file qgsexpressiontreeview.cpp.
|
inline |
Returns the expression context for the widget.
The context is used for the expression preview result and for populating the list of available functions and variables.
Definition at line 185 of file qgsexpressiontreeview.h.
|
signal |
Emitted when a expression item is double clicked.
const QList< QgsExpressionItem * > QgsExpressionTreeView::findExpressions | ( | const QString & | label | ) |
Returns the list of expression items matching a label.
Definition at line 745 of file qgsexpressiontreeview.cpp.
void QgsExpressionTreeView::loadExpressionsFromJson | ( | const QJsonDocument & | expressionsDocument | ) |
Load and permanently store the expressions from the expressions JSON document.
expressionsDocument | the parsed expressions JSON file |
Definition at line 603 of file qgsexpressiontreeview.cpp.
void QgsExpressionTreeView::loadFieldNames | ( | const QgsFields & | fields | ) |
This allows loading fields without specifying a layer.
Definition at line 417 of file qgsexpressiontreeview.cpp.
void QgsExpressionTreeView::loadRecent | ( | const QString & | collection = QStringLiteral( "generic" ) | ) |
Loads the recent expressions from the given collection.
By default it is loaded from the collection "generic".
Definition at line 462 of file qgsexpressiontreeview.cpp.
void QgsExpressionTreeView::loadUserExpressions | ( | ) |
Loads the user expressions.
This is done on request since it can be very slow if there are thousands of user expressions
Definition at line 529 of file qgsexpressiontreeview.cpp.
QStandardItemModel * QgsExpressionTreeView::model | ( | ) |
Returns a pointer to the dialog's function item model.
This method is exposed for testing purposes only - it should not be used to modify the model
Definition at line 177 of file qgsexpressiontreeview.cpp.
QgsProject * QgsExpressionTreeView::project | ( | ) |
Returns the project currently associated with the widget.
Definition at line 182 of file qgsexpressiontreeview.cpp.
void QgsExpressionTreeView::refresh | ( | ) |
Refreshes the content of the tree.
Definition at line 162 of file qgsexpressiontreeview.cpp.
void QgsExpressionTreeView::removeFromUserExpressions | ( | const QString & | label | ) |
Removes the expression label from the user stored expressions.
Definition at line 521 of file qgsexpressiontreeview.cpp.
void QgsExpressionTreeView::saveToRecent | ( | const QString & | expressionText, |
const QString & | collection = "generic" |
||
) |
Adds the current expression to the given collection.
By default it is saved to the collection "generic".
Definition at line 484 of file qgsexpressiontreeview.cpp.
void QgsExpressionTreeView::saveToUserExpressions | ( | const QString & | label, |
const QString | expression, | ||
const QString & | helpText | ||
) |
Stores the user expression with given label and helpText.
Definition at line 502 of file qgsexpressiontreeview.cpp.
void QgsExpressionTreeView::setExpressionContext | ( | const QgsExpressionContext & | context | ) |
Sets the expression context for the tree view.
The context is used to populate the list of available functions and variables.
context | expression context |
Definition at line 148 of file qgsexpressiontreeview.cpp.
void QgsExpressionTreeView::setLayer | ( | QgsVectorLayer * | layer | ) |
Sets layer in order to get the fields and values.
Definition at line 136 of file qgsexpressiontreeview.cpp.
void QgsExpressionTreeView::setMenuProvider | ( | QgsExpressionTreeView::MenuProvider * | provider | ) |
Sets the menu provider.
This does not take ownership of the provider
Definition at line 157 of file qgsexpressiontreeview.cpp.
void QgsExpressionTreeView::setProject | ( | QgsProject * | project | ) |
Sets the project currently associated with the widget.
This controls which layers and relations and other project-specific items are shown in the widget.
Definition at line 187 of file qgsexpressiontreeview.cpp.
|
slot |
Sets the text to filter the expression tree.
Definition at line 194 of file qgsexpressiontreeview.cpp.
QStringList QgsExpressionTreeView::userExpressionLabels | ( | ) | const |
Returns the user expression labels.
Definition at line 556 of file qgsexpressiontreeview.cpp.