16#ifndef QGSEXPRESSIONTREEVIEW_H
17#define QGSEXPRESSIONTREEVIEW_H
25#include <QSortFilterProxyModel>
26#include <QStandardItemModel>
47 : QStandardItem( label )
49 mExpressionText = expressionText;
56 : QStandardItem( label )
58 mExpressionText = expressionText;
77 void setHelpText(
const QString &helpText ) { mHelpText = helpText; }
98 QString mExpressionText;
118 bool filterAcceptsRow(
int source_row,
const QModelIndex &source_parent )
const override;
128 bool lessThan(
const QModelIndex &left,
const QModelIndex &right )
const override;
131 QString mFilterString;
178 void loadFieldNames(
const QgsFields &fields );
212 void setMenuProvider( MenuProvider *provider );
230 Q_DECL_DEPRECATED QStandardItemModel *model()
SIP_SKIP;
236 void loadRecent( const QString &collection = QStringLiteral(
"generic" ) );
242 void saveToRecent( const QString &expressionText, const QString &collection =
"generic" );
247 void saveToUserExpressions( const QString &label, const QString &expression, const QString &helpText );
252 void removeFromUserExpressions( const QString &label );
258 void loadUserExpressions();
268 QStringList userExpressionLabels() const
SIP_SKIP;
274 QJsonDocument exportUserExpressions();
280 void loadExpressionsFromJson( const QJsonDocument &expressionsDocument );
295 void onDoubleClicked( const QModelIndex &index );
297 void showContextMenu( QPoint pt );
299 void currentItemChanged( const QModelIndex &index, const QModelIndex & );
302 void updateFunctionTree();
317 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() );
330 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() );
332 void loadExpressionContext();
333 void loadRelations();
349 void showMessageBoxConfirmExpressionOverwrite(
bool &isApplyToAll,
bool &isOkToOverwrite, const QString &label, const QString &oldExpression, const QString &newExpression );
352 std::unique_ptr<QStandardItemModel> mModel;
363 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.