16#ifndef QGSEXPRESSIONTREEVIEW_H
17#define QGSEXPRESSIONTREEVIEW_H
25#include <QSortFilterProxyModel>
26#include <QStandardItemModel>
30using namespace Qt::StringLiterals;
50 : QStandardItem( label )
52 mExpressionText = expressionText;
59 : QStandardItem( label )
61 mExpressionText = expressionText;
80 void setHelpText(
const QString &helpText ) { mHelpText = helpText; }
101 QString mExpressionText;
121 bool filterAcceptsRow(
int source_row,
const QModelIndex &source_parent )
const override;
131 bool lessThan(
const QModelIndex &left,
const QModelIndex &right )
const override;
134 QString mFilterString;
181 void loadFieldNames(
const QgsFields &fields );
215 void setMenuProvider( MenuProvider *provider );
233 Q_DECL_DEPRECATED QStandardItemModel *model()
SIP_SKIP;
239 void loadRecent( const QString &collection = u
"generic"_s );
245 void saveToRecent( const QString &expressionText, const QString &collection =
"generic" );
250 void saveToUserExpressions( const QString &label, const QString &expression, const QString &helpText );
255 void removeFromUserExpressions( const QString &label );
261 void loadUserExpressions();
271 QStringList userExpressionLabels() const
SIP_SKIP;
277 QJsonDocument exportUserExpressions();
283 void loadExpressionsFromJson( const QJsonDocument &expressionsDocument );
298 void onDoubleClicked( const QModelIndex &index );
300 void showContextMenu( QPoint pt );
302 void currentItemChanged( const QModelIndex &index, const QModelIndex & );
305 void updateFunctionTree();
320 QgsExpressionItem *registerItem( const QString &group, const QString &label, const QString &expressionText, const QString &helpText = QString(),
QgsExpressionItem::ItemType type =
QgsExpressionItem::ExpressionNode,
bool highlightedItem = false,
int sortOrder = 1, const QIcon &icon = QIcon(), const QStringList &tags = QStringList(), const QString &name = QString() );
333 void registerItemForAllGroups( const QStringList &groups, const QString &label, const QString &expressionText, const QString &helpText = QString(),
QgsExpressionItem::ItemType type =
QgsExpressionItem::ExpressionNode,
bool highlightedItem = false,
int sortOrder = 1, const QStringList &tags = QStringList() );
335 void loadExpressionContext();
336 void loadRelations();
352 void showMessageBoxConfirmExpressionOverwrite(
bool &isApplyToAll,
bool &isOkToOverwrite, const QString &label, const QString &oldExpression, const QString &newExpression );
355 std::unique_ptr<QStandardItemModel> mModel;
366 QStringList mUserExpressionLabels;
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Search proxy used to filter the QgsExpressionBuilderWidget tree.
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
void setFilterString(const QString &string)
Sets the search filter string.
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
QgsExpressionItemSearchProxy()
An expression item that can be used in the QgsExpressionBuilderWidget tree.
void setHelpText(const QString &helpText)
Set the help text for the current item.
static const int LAYER_ID_ROLE
Layer ID role.
QString getExpressionText() const
static const int SEARCH_TAGS_ROLE
Search tags role.
static const int ITEM_TYPE_ROLE
Item type role.
static const int CUSTOM_SORT_ROLE
Custom sort order role.
QgsExpressionItem(const QString &label, const QString &expressionText, const QString &helpText, QgsExpressionItem::ItemType itemType=ExpressionNode)
QgsExpressionItem::ItemType getItemType() const
Gets the type of expression item, e.g., header, field, ExpressionNode.
QString getHelpText() const
Gets the help text that is associated with this expression item.
QgsExpressionItem(const QString &label, const QString &expressionText, QgsExpressionItem::ItemType itemType=ExpressionNode)
static const int ITEM_NAME_ROLE
Item name role.
A tree view to list all expressions functions, variables and fields that can be used in an expression...
void expressionItemDoubleClicked(const QString &text)
Emitted when a expression item is double clicked.
void currentExpressionItemChanged(QgsExpressionItem *item)
Emitter when the current expression item changed.
QgsExpressionTreeView(QWidget *parent=nullptr)
Constructor.
void setSearchText(const QString &text)
Sets the text to filter the expression tree.
QgsExpressionContext expressionContext() const
Returns the expression context for the widget.
void loadFieldNames(const QgsFields &fields)
This allows loading fields without specifying a layer.
Container of fields for a vector layer.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Represents a vector layer which manages a vector based dataset.