16 #ifndef QGSEXPRESSIONBUILDER_H
17 #define QGSEXPRESSIONBUILDER_H
20 #include <QStandardItemModel>
21 #include <QSortFilterProxyModel>
23 #include "ui_qgsexpressionbuilder.h"
55 LoadUserExpressions = 1 << 2,
56 LoadAll = LoadRecent | LoadUserExpressions,
58 Q_DECLARE_FLAGS( Flags, Flag )
108 Q_DECL_DEPRECATED
void loadFieldsAndValues(
const QMap<QString, QStringList> &fieldValues )
SIP_DEPRECATED;
116 QString expressionText();
119 void setExpressionText(
const QString &expression );
126 QString expectedOutputFormat();
134 void setExpectedOutputFormat(
const QString &expected );
154 bool isExpressionValid();
161 Q_DECL_DEPRECATED
void saveToRecent(
const QString &collection =
"generic" )
SIP_DEPRECATED;
168 Q_DECL_DEPRECATED
void loadRecent( const QString &collection = QStringLiteral( "generic" ) )
SIP_DEPRECATED ;
188 Q_DECL_DEPRECATED
void saveToUserExpressions( const QString &label, const QString expression, const QString &helpText )
SIP_DEPRECATED;
195 Q_DECL_DEPRECATED
void removeFromUserExpressions( const QString &label )
SIP_DEPRECATED;
200 void newFunctionFile( const QString &fileName = "scratch" );
205 void saveFunctionFile( QString fileName );
210 void loadCodeFromFile( QString path );
215 void loadFunctionCode( const QString &code );
220 void updateFunctionFileList( const QString &path );
251 bool evalError() const;
259 bool parserError() const;
268 void loadSampleValues();
275 void loadAllValues();
284 void loadSampleUsedValues();
293 void loadAllUsedValues();
305 void setAutoSave(
bool enabled ) { mAutoSave = enabled; }
311 void storeCurrentUserExpression( );
318 void removeSelectedUserExpression( );
325 void editSelectedUserExpression();
332 const QList<QgsExpressionItem *> findExpressions(
const QString &label );
336 void indicatorClicked(
int line,
int index, Qt::KeyboardModifiers state );
337 void onExpressionParsed(
bool state );
339 void operatorButtonClicked();
340 void btnRun_pressed();
341 void btnNewFile_pressed();
342 void btnRemoveFile_pressed();
349 void exportUserExpressions_pressed();
356 void importUserExpressions_pressed();
357 void cmbFileNames_currentItemChanged( QListWidgetItem *item, QListWidgetItem *lastitem );
358 void insertExpressionText(
const QString &text );
359 void txtExpressionString_textChanged();
360 void txtSearchEditValues_textChanged();
361 void mValuesListView_doubleClicked(
const QModelIndex &index );
362 void txtPython_textChanged();
372 void expressionParsed(
bool isValid );
380 void evalErrorChanged();
388 void parserErrorChanged();
391 void showEvent( QShowEvent *e )
override;
399 , mExpressionBuilderWidget( expressionBuilderWidget ) {}
407 int FUNCTION_MARKER_ID = 25;
409 void createErrorMarkers( QList<QgsExpression::ParserError> errors );
411 void clearFunctionMarkers();
413 void runPythonCode(
const QString &code );
414 void fillFieldValues(
const QString &fieldName,
int countLimit,
bool forceUsedValues =
false );
417 QString helpStylesheet()
const;
422 std::unique_ptr<QStandardItemModel> mValuesModel;
423 std::unique_ptr<QSortFilterProxyModel> mProxyValues;
425 ExpressionTreeMenuProvider *mExpressionTreeMenuProvider =
nullptr;
427 bool mAutoSave =
true;
428 QString mFunctionsPath;
431 bool mExpressionValid =
false;
433 QPointer< QgsProject > mProject;
436 QString mUserExpressionsGroupName;
441 #endif // QGSEXPRESSIONBUILDER_H