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;
117 QString expressionText();
120 void setExpressionText(
const QString &expression );
127 QString expectedOutputFormat();
135 void setExpectedOutputFormat(
const QString &expected );
155 bool isExpressionValid();
162 Q_DECL_DEPRECATED
void saveToRecent(
const QString &collection =
"generic" )
SIP_DEPRECATED;
169 Q_DECL_DEPRECATED
void loadRecent( const QString &collection = QStringLiteral( "generic" ) )
SIP_DEPRECATED ;
189 Q_DECL_DEPRECATED
void saveToUserExpressions( const QString &label, const QString expression, const QString &helpText )
SIP_DEPRECATED;
196 Q_DECL_DEPRECATED
void removeFromUserExpressions( const QString &label )
SIP_DEPRECATED;
201 void newFunctionFile( const QString &fileName = "scratch" );
206 void saveFunctionFile( QString fileName );
211 void loadCodeFromFile( QString path );
216 void loadFunctionCode( const QString &code );
221 void updateFunctionFileList( const QString &path );
252 bool evalError() const;
260 bool parserError() const;
269 void loadSampleValues();
276 void loadAllValues();
285 void loadSampleUsedValues();
294 void loadAllUsedValues();
306 void setAutoSave(
bool enabled ) { mAutoSave = enabled; }
312 void storeCurrentUserExpression( );
319 void removeSelectedUserExpression( );
326 void editSelectedUserExpression();
333 const QList<QgsExpressionItem *> findExpressions(
const QString &label );
337 void indicatorClicked(
int line,
int index, Qt::KeyboardModifiers state );
338 void onExpressionParsed(
bool state );
340 void operatorButtonClicked();
341 void btnRun_pressed();
342 void btnNewFile_pressed();
343 void btnRemoveFile_pressed();
350 void exportUserExpressions_pressed();
357 void importUserExpressions_pressed();
358 void cmbFileNames_currentItemChanged( QListWidgetItem *item, QListWidgetItem *lastitem );
359 void insertExpressionText(
const QString &text );
360 void txtExpressionString_textChanged();
361 void txtSearchEditValues_textChanged();
362 void mValuesListView_doubleClicked(
const QModelIndex &index );
363 void txtPython_textChanged();
392 void showEvent( QShowEvent *e )
override;
400 , mExpressionBuilderWidget( expressionBuilderWidget ) {}
408 int FUNCTION_MARKER_ID = 25;
410 void createErrorMarkers( QList<QgsExpression::ParserError> errors );
412 void clearFunctionMarkers();
414 void runPythonCode(
const QString &code );
415 void fillFieldValues(
const QString &fieldName,
int countLimit,
bool forceUsedValues =
false );
418 QString helpStylesheet()
const;
423 std::unique_ptr<QStandardItemModel> mValuesModel;
424 std::unique_ptr<QSortFilterProxyModel> mProxyValues;
426 ExpressionTreeMenuProvider *mExpressionTreeMenuProvider =
nullptr;
428 bool mAutoSave =
true;
429 QString mFunctionsPath;
432 bool mExpressionValid =
false;
434 QPointer< QgsProject > mProject;
437 QString mUserExpressionsGroupName;
442 #endif // QGSEXPRESSIONBUILDER_H