QGIS API Documentation  3.23.0-Master (eb871beae0)
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. 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...
 
QgsExpressionItemcurrentItem () 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...
 
QgsProjectproject ()
 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...
 

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 148 of file qgsexpressiontreeview.h.

Constructor & Destructor Documentation

◆ QgsExpressionTreeView()

QgsExpressionTreeView::QgsExpressionTreeView ( QWidget *  parent = nullptr)

Constructor.

Definition at line 109 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 172 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 564 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 197 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 750 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 606 of file qgsexpressiontreeview.cpp.

◆ loadFieldNames()

void QgsExpressionTreeView::loadFieldNames ( const QgsFields fields)

This allows loading fields without specifying a layer.

Definition at line 421 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 466 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 533 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:
since QGIS 3.14

Definition at line 179 of file qgsexpressiontreeview.cpp.

◆ project()

QgsProject * QgsExpressionTreeView::project ( )

Returns the project currently associated with the widget.

See also
setProject()

Definition at line 184 of file qgsexpressiontreeview.cpp.

◆ refresh()

void QgsExpressionTreeView::refresh ( )

Refreshes the content of the tree.

Definition at line 164 of file qgsexpressiontreeview.cpp.

◆ removeFromUserExpressions()

void QgsExpressionTreeView::removeFromUserExpressions ( const QString &  label)

Removes the expression label from the user stored expressions.

Definition at line 525 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 490 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 508 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 150 of file qgsexpressiontreeview.cpp.

◆ setLayer()

void QgsExpressionTreeView::setLayer ( QgsVectorLayer layer)

Sets layer in order to get the fields and values.

Definition at line 138 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 159 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 189 of file qgsexpressiontreeview.cpp.

◆ setSearchText

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

Sets the text to filter the expression tree.

Definition at line 196 of file qgsexpressiontreeview.cpp.

◆ userExpressionLabels()

QStringList QgsExpressionTreeView::userExpressionLabels ( ) const

Returns the user expression labels.

Definition at line 559 of file qgsexpressiontreeview.cpp.


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