QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
Classes | Public Slots | Signals | Public Member Functions | List of all members
QgsExpressionTreeView Class Reference

QgsExpressionTreeView is a tree view to list all expressions functions, variables and fields that can be used in an expression. More...

#include <qgsexpressiontreeview.h>

Inheritance diagram for QgsExpressionTreeView:
Inheritance graph
[legend]

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

Detailed Description

QgsExpressionTreeView is a tree view to list all expressions functions, variables and fields that can be used in an expression.

See also
QgsExpressionBuilderWidget
Since
QGIS 3.14

Definition at line 142 of file qgsexpressiontreeview.h.

Constructor & Destructor Documentation

◆ QgsExpressionTreeView()

QgsExpressionTreeView::QgsExpressionTreeView ( QWidget *  parent = nullptr)

Constructor.

Definition at line 106 of file qgsexpressiontreeview.cpp.

Member Function Documentation

◆ currentExpressionItemChanged

void QgsExpressionTreeView::currentExpressionItemChanged ( QgsExpressionItem item)
signal

Emitter when the current expression item changed.

◆ currentItem()

QgsExpressionItem * QgsExpressionTreeView::currentItem ( ) const

Returns the current item or a nullptr.

Definition at line 169 of file qgsexpressiontreeview.cpp.

◆ exportUserExpressions()

QJsonDocument QgsExpressionTreeView::exportUserExpressions ( )

Create the expressions JSON document storing all the user expressions to be exported.

Returns
the created expressions JSON file

Definition at line 606 of file qgsexpressiontreeview.cpp.

◆ expressionContext()

QgsExpressionContext QgsExpressionTreeView::expressionContext ( ) const
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.

See also
setExpressionContext

Definition at line 193 of file qgsexpressiontreeview.h.

◆ expressionItemDoubleClicked

void QgsExpressionTreeView::expressionItemDoubleClicked ( const QString &  text)
signal

Emitted when a expression item is double clicked.

◆ findExpressions()

const QList< QgsExpressionItem * > QgsExpressionTreeView::findExpressions ( const QString &  label)

Returns the list of expression items matching a label.

Definition at line 787 of file qgsexpressiontreeview.cpp.

◆ loadExpressionsFromJson()

void QgsExpressionTreeView::loadExpressionsFromJson ( const QJsonDocument &  expressionsDocument)

Load and permanently store the expressions from the expressions JSON document.

Parameters
expressionsDocumentthe parsed expressions JSON file

Definition at line 646 of file qgsexpressiontreeview.cpp.

◆ loadFieldNames()

void QgsExpressionTreeView::loadFieldNames ( const QgsFields fields)

This allows loading fields without specifying a layer.

Definition at line 443 of file qgsexpressiontreeview.cpp.

◆ loadRecent()

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 508 of file qgsexpressiontreeview.cpp.

◆ loadUserExpressions()

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 575 of file qgsexpressiontreeview.cpp.

◆ model()

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

Note
will be removed in QGIS 4
Deprecated:
QGIS 3.14

Definition at line 176 of file qgsexpressiontreeview.cpp.

◆ project()

QgsProject * QgsExpressionTreeView::project ( )

Returns the project currently associated with the widget.

See also
setProject()

Definition at line 181 of file qgsexpressiontreeview.cpp.

◆ refresh()

void QgsExpressionTreeView::refresh ( )

Refreshes the content of the tree.

Definition at line 161 of file qgsexpressiontreeview.cpp.

◆ removeFromUserExpressions()

void QgsExpressionTreeView::removeFromUserExpressions ( const QString &  label)

Removes the expression label from the user stored expressions.

Definition at line 567 of file qgsexpressiontreeview.cpp.

◆ saveToRecent()

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 532 of file qgsexpressiontreeview.cpp.

◆ saveToUserExpressions()

void QgsExpressionTreeView::saveToUserExpressions ( const QString &  label,
const QString &  expression,
const QString &  helpText 
)

Stores the user expression with given label and helpText.

Definition at line 550 of file qgsexpressiontreeview.cpp.

◆ setExpressionContext()

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.

Parameters
contextexpression context
See also
expressionContext

Definition at line 147 of file qgsexpressiontreeview.cpp.

◆ setLayer()

void QgsExpressionTreeView::setLayer ( QgsVectorLayer layer)

Sets layer in order to get the fields and values.

Definition at line 135 of file qgsexpressiontreeview.cpp.

◆ setMenuProvider()

void QgsExpressionTreeView::setMenuProvider ( QgsExpressionTreeView::MenuProvider provider)

Sets the menu provider.

This does not take ownership of the provider

Definition at line 156 of file qgsexpressiontreeview.cpp.

◆ setProject()

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.

See also
project()

Definition at line 186 of file qgsexpressiontreeview.cpp.

◆ setSearchText

void QgsExpressionTreeView::setSearchText ( const QString &  text)
slot

Sets the text to filter the expression tree.

Definition at line 193 of file qgsexpressiontreeview.cpp.

◆ userExpressionLabels()

QStringList QgsExpressionTreeView::userExpressionLabels ( ) const

Returns the user expression labels.

Definition at line 601 of file qgsexpressiontreeview.cpp.


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