QGIS API Documentation 3.41.0-Master (45a0abf3bec)
|
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. | |
Signals | |
void | currentExpressionItemChanged (QgsExpressionItem *item) |
Emitter when the current expression item changed. | |
void | expressionItemDoubleClicked (const QString &text) |
Emitted when a expression item is double clicked. | |
Public Member Functions | |
QgsExpressionTreeView (QWidget *parent=nullptr) | |
Constructor. | |
QgsExpressionItem * | currentItem () const |
Returns the current item or a nullptr. | |
QJsonDocument | exportUserExpressions () |
Create the expressions JSON document storing all the user expressions to be exported. | |
QgsExpressionContext | expressionContext () const |
Returns the expression context for the widget. | |
const QList< QgsExpressionItem * > | findExpressions (const QString &label) |
Returns the list of expression items matching a label. | |
void | loadExpressionsFromJson (const QJsonDocument &expressionsDocument) |
Load and permanently store the expressions from the expressions JSON document. | |
void | loadFieldNames (const QgsFields &fields) |
This allows loading fields without specifying a layer. | |
void | loadRecent (const QString &collection=QStringLiteral("generic")) |
Loads the recent expressions from the given collection. | |
void | loadUserExpressions () |
Loads the user expressions. | |
Q_DECL_DEPRECATED QStandardItemModel * | model () |
Returns a pointer to the dialog's function item model. | |
QgsProject * | project () |
Returns the project currently associated with the widget. | |
void | refresh () |
Refreshes the content of the tree. | |
void | removeFromUserExpressions (const QString &label) |
Removes the expression label from the user stored expressions. | |
void | saveToRecent (const QString &expressionText, const QString &collection="generic") |
Adds the current expression to the given collection. | |
void | saveToUserExpressions (const QString &label, const QString &expression, const QString &helpText) |
Stores the user expression with given label and helpText. | |
void | setExpressionContext (const QgsExpressionContext &context) |
Sets the expression context for the tree view. | |
void | setLayer (QgsVectorLayer *layer) |
Sets layer in order to get the fields and values. | |
void | setMenuProvider (MenuProvider *provider) |
Sets the menu provider. | |
void | setProject (QgsProject *project) |
Sets the project currently associated with the widget. | |
QStringList | userExpressionLabels () const |
Returns the user expression labels. | |
QgsExpressionTreeView is a tree view to list all expressions functions, variables and fields that can be used in an expression.
Definition at line 150 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 618 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 199 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 804 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 660 of file qgsexpressiontreeview.cpp.
void QgsExpressionTreeView::loadFieldNames | ( | const QgsFields & | fields | ) |
This allows loading fields without specifying a layer.
Definition at line 454 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 520 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 587 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 579 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 544 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 562 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 613 of file qgsexpressiontreeview.cpp.