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;
100 QString mExpressionText;
119 bool filterAcceptsRow(
int source_row,
const QModelIndex &source_parent )
const override;
123 bool lessThan(
const QModelIndex &left,
const QModelIndex &right )
const override;
168 void loadFieldNames(
const QgsFields &fields );
202 void setMenuProvider( MenuProvider *provider );
220 Q_DECL_DEPRECATED QStandardItemModel *model()
SIP_SKIP;
226 void loadRecent( const QString &collection = QStringLiteral( "generic" ) );
232 void saveToRecent( const QString &expressionText, const QString &collection = "generic" );
237 void saveToUserExpressions( const QString &label, const QString expression, const QString &helpText );
242 void removeFromUserExpressions( const QString &label );
248 void loadUserExpressions( );
258 QStringList userExpressionLabels() const
SIP_SKIP;
264 QJsonDocument exportUserExpressions();
270 void loadExpressionsFromJson( const QJsonDocument &expressionsDocument );
274 void expressionItemDoubleClicked( const QString &text );
281 void setSearchText( const QString &text );
285 void onDoubleClicked( const QModelIndex &index );
287 void showContextMenu( QPoint pt );
289 void currentItemChanged( const QModelIndex &index, const QModelIndex & );
292 void updateFunctionTree();
306 void registerItem( const QString &group, const QString &label, const QString &expressionText,
307 const QString &helpText = QString(),
309 bool highlightedItem = false,
int sortOrder = 1,
310 QIcon icon = QIcon(),
311 const QStringList &tags = QStringList() );
324 void registerItemForAllGroups( const QStringList &groups, const QString &label, const QString &expressionText,
325 const QString &helpText = QString(),
327 bool highlightedItem = false,
int sortOrder = 1, const QStringList &tags = QStringList() );
329 void loadExpressionContext();
330 void loadRelations();
332 void loadFieldNames();
345 void showMessageBoxConfirmExpressionOverwrite(
bool &isApplyToAll,
bool &isOkToOverwrite, const QString &label, const QString &oldExpression, const QString &newExpression );
352 MenuProvider *mMenuProvider =
nullptr;
359 QStringList mUserExpressionLabels;
362 #endif // QGSEXPRESSIONTREEVIEW_H