QGIS API Documentation
3.20.0-Odense (decaadbb31)
|
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 137 of file qgsexpressiontreeview.h.
QgsExpressionTreeView::QgsExpressionTreeView | ( | QWidget * | parent = nullptr | ) |
Constructor.
Definition at line 109 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 172 of file qgsexpressiontreeview.cpp.
QJsonDocument QgsExpressionTreeView::exportUserExpressions | ( | ) |
Create the expressions JSON document storing all the user expressions to be exported.
Definition at line 565 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 186 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 749 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 607 of file qgsexpressiontreeview.cpp.
void QgsExpressionTreeView::loadFieldNames | ( | const QgsFields & | fields | ) |
This allows loading fields without specifying a layer.
Definition at line 421 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 466 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 533 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 179 of file qgsexpressiontreeview.cpp.
QgsProject * QgsExpressionTreeView::project | ( | ) |
Returns the project currently associated with the widget.
Definition at line 184 of file qgsexpressiontreeview.cpp.
void QgsExpressionTreeView::refresh | ( | ) |
Refreshes the content of the tree.
Definition at line 164 of file qgsexpressiontreeview.cpp.
void QgsExpressionTreeView::removeFromUserExpressions | ( | const QString & | label | ) |
Removes the expression label from the user stored expressions.
Definition at line 525 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 490 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 508 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 150 of file qgsexpressiontreeview.cpp.
void QgsExpressionTreeView::setLayer | ( | QgsVectorLayer * | layer | ) |
Sets layer in order to get the fields and values.
Definition at line 138 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 159 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 189 of file qgsexpressiontreeview.cpp.
|
slot |
Sets the text to filter the expression tree.
Definition at line 196 of file qgsexpressiontreeview.cpp.
QStringList QgsExpressionTreeView::userExpressionLabels | ( | ) | const |
Returns the user expression labels.
Definition at line 560 of file qgsexpressiontreeview.cpp.