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 );
371 MenuProvider *mMenuProvider =
nullptr;
378 QStringList mUserExpressionLabels;
381 #endif // QGSEXPRESSIONTREEVIEW_H