16 #ifndef QGSEXPRESSIONTREEVIEW_H
17 #define QGSEXPRESSIONTREEVIEW_H
20 #include <QStandardItemModel>
21 #include <QSortFilterProxyModel>
48 const QString &expressionText,
49 const QString &helpText,
51 : QStandardItem( label )
53 mExpressionText = expressionText;
56 setData( itemType, ITEM_TYPE_ROLE );
60 const QString &expressionText,
62 : QStandardItem( label )
64 mExpressionText = expressionText;
66 setData( itemType, ITEM_TYPE_ROLE );
83 void setHelpText(
const QString &helpText ) { mHelpText = helpText; }
93 static const int CUSTOM_SORT_ROLE = Qt::UserRole + 1;
95 static const int ITEM_TYPE_ROLE = Qt::UserRole + 2;
97 static const int SEARCH_TAGS_ROLE = Qt::UserRole + 3;
99 static const int ITEM_NAME_ROLE = Qt::UserRole + 4;
102 QString mExpressionText;
121 bool filterAcceptsRow(
int source_row,
const QModelIndex &source_parent )
const override;
125 bool lessThan(
const QModelIndex &left,
const QModelIndex &right )
const override;
170 void loadFieldNames(
const QgsFields &fields );
204 void setMenuProvider( MenuProvider *provider );
222 Q_DECL_DEPRECATED QStandardItemModel *model()
SIP_SKIP;
228 void loadRecent( const QString &collection = QStringLiteral( "generic" ) );
234 void saveToRecent( const QString &expressionText, const QString &collection = "generic" );
239 void saveToUserExpressions( const QString &label, const QString expression, const QString &helpText );
244 void removeFromUserExpressions( const QString &label );
250 void loadUserExpressions( );
260 QStringList userExpressionLabels() const
SIP_SKIP;
266 QJsonDocument exportUserExpressions();
272 void loadExpressionsFromJson( const QJsonDocument &expressionsDocument );
276 void expressionItemDoubleClicked( const QString &text );
283 void setSearchText( const QString &text );
287 void onDoubleClicked( const QModelIndex &index );
289 void showContextMenu( QPoint pt );
291 void currentItemChanged( const QModelIndex &index, const QModelIndex & );
294 void updateFunctionTree();
308 void registerItem( const QString &group, const QString &label, const QString &expressionText,
309 const QString &helpText = QString(),
311 bool highlightedItem = false,
int sortOrder = 1,
312 QIcon icon = QIcon(),
313 const QStringList &tags = QStringList(),
314 const QString &name = QString() );
327 void registerItemForAllGroups( const QStringList &groups, const QString &label, const QString &expressionText,
328 const QString &helpText = QString(),
330 bool highlightedItem = false,
int sortOrder = 1, const QStringList &tags = QStringList() );
332 void loadExpressionContext();
333 void loadRelations();
335 void loadFieldNames();
348 void showMessageBoxConfirmExpressionOverwrite(
bool &isApplyToAll,
bool &isOkToOverwrite, const QString &label, const QString &oldExpression, const QString &newExpression );
362 QStringList mUserExpressionLabels;
365 #endif // QGSEXPRESSIONTREEVIEW_H