16 #ifndef QGSEXPRESSIONTREEVIEW_H
17 #define QGSEXPRESSIONTREEVIEW_H
20 #include <QStandardItemModel>
21 #include <QSortFilterProxyModel>
49 const QString &expressionText,
50 const QString &helpText,
52 : QStandardItem( label )
54 mExpressionText = expressionText;
57 setData( itemType, ITEM_TYPE_ROLE );
61 const QString &expressionText,
63 : QStandardItem( label )
65 mExpressionText = expressionText;
67 setData( itemType, ITEM_TYPE_ROLE );
84 void setHelpText(
const QString &helpText ) { mHelpText = helpText; }
94 static const int CUSTOM_SORT_ROLE = Qt::UserRole + 1;
96 static const int ITEM_TYPE_ROLE = Qt::UserRole + 2;
98 static const int SEARCH_TAGS_ROLE = Qt::UserRole + 3;
100 static const int ITEM_NAME_ROLE = Qt::UserRole + 4;
102 static const int LAYER_ID_ROLE = Qt::UserRole + 5;
105 QString mExpressionText;
124 bool filterAcceptsRow(
int source_row,
const QModelIndex &source_parent )
const override;
131 void setFilterString(
const QString &
string );
135 bool lessThan(
const QModelIndex &left,
const QModelIndex &right )
const override;
139 QString mFilterString;
184 void loadFieldNames(
const QgsFields &fields );
218 void setMenuProvider( MenuProvider *provider );
236 Q_DECL_DEPRECATED QStandardItemModel *model()
SIP_SKIP;
242 void loadRecent( const QString &collection = QStringLiteral( "generic" ) );
248 void saveToRecent( const QString &expressionText, const QString &collection = "generic" );
253 void saveToUserExpressions( const QString &label, const QString &expression, const QString &helpText );
258 void removeFromUserExpressions( const QString &label );
264 void loadUserExpressions( );
274 QStringList userExpressionLabels() const
SIP_SKIP;
280 QJsonDocument exportUserExpressions();
286 void loadExpressionsFromJson( const QJsonDocument &expressionsDocument );
290 void expressionItemDoubleClicked( const QString &text );
297 void setSearchText( const QString &text );
301 void onDoubleClicked( const QModelIndex &index );
303 void showContextMenu( QPoint pt );
305 void currentItemChanged( const QModelIndex &index, const QModelIndex & );
308 void updateFunctionTree();
323 QgsExpressionItem *registerItem( const QString &group, const QString &label, const QString &expressionText,
324 const QString &helpText = QString(),
326 bool highlightedItem = false,
int sortOrder = 1,
327 const QIcon &icon = QIcon(),
328 const QStringList &tags = QStringList(),
329 const QString &name = QString() );
342 void registerItemForAllGroups( const QStringList &groups, const QString &label, const QString &expressionText,
343 const QString &helpText = QString(),
345 bool highlightedItem = false,
int sortOrder = 1, const QStringList &tags = QStringList() );
347 void loadExpressionContext();
348 void loadRelations();
351 void loadFieldNames();
364 void showMessageBoxConfirmExpressionOverwrite(
bool &isApplyToAll,
bool &isOkToOverwrite, const QString &label, const QString &oldExpression, const QString &newExpression );
378 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.
An expression item that can be used in the QgsExpressionBuilderWidget tree.
void setHelpText(const QString &helpText)
Set the help text for the current item.
QString getExpressionText() const
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)
QgsExpressionTreeView is a tree view to list all expressions functions, variables and fields that can...
QgsExpressionContext expressionContext() const
Returns the expression context for the widget.
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 data sets.
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.