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;
267 void setExpressionPreviewVisible(
bool isVisible );
276 void loadSampleValues();
283 void loadAllValues();
292 void loadSampleUsedValues();
301 void loadAllUsedValues();
313 void setAutoSave(
bool enabled ) { mAutoSave = enabled; }
319 void storeCurrentUserExpression( );
326 void removeSelectedUserExpression( );
333 void editSelectedUserExpression();
340 const QList<QgsExpressionItem *> findExpressions(
const QString &label );
344 void indicatorClicked(
int line,
int index, Qt::KeyboardModifiers state );
345 void onExpressionParsed(
bool state );
347 void operatorButtonClicked();
348 void btnRun_pressed();
349 void btnNewFile_pressed();
350 void btnRemoveFile_pressed();
357 void exportUserExpressions_pressed();
364 void importUserExpressions_pressed();
365 void cmbFileNames_currentItemChanged( QListWidgetItem *item, QListWidgetItem *lastitem );
366 void insertExpressionText(
const QString &text );
367 void txtExpressionString_textChanged();
368 void txtSearchEditValues_textChanged();
369 void mValuesListView_doubleClicked(
const QModelIndex &index );
370 void txtPython_textChanged();
380 void expressionParsed(
bool isValid );
388 void evalErrorChanged();
396 void parserErrorChanged();
399 void showEvent( QShowEvent *e )
override;
407 , mExpressionBuilderWidget( expressionBuilderWidget ) {}
415 int FUNCTION_MARKER_ID = 25;
417 void createErrorMarkers(
const QList<QgsExpression::ParserError> &errors );
419 void clearFunctionMarkers();
421 void runPythonCode(
const QString &code );
423 void fillFieldValues(
const QString &fieldName,
QgsVectorLayer *layer,
int countLimit,
bool forceUsedValues =
false );
426 QString helpStylesheet()
const;
429 void expressionContextUpdated();
434 std::unique_ptr<QStandardItemModel> mValuesModel;
435 std::unique_ptr<QSortFilterProxyModel> mProxyValues;
437 ExpressionTreeMenuProvider *mExpressionTreeMenuProvider =
nullptr;
439 bool mAutoSave =
true;
440 QString mFunctionsPath;
443 bool mExpressionValid =
false;
445 QPointer< QgsProject > mProject;
448 QString mUserExpressionsGroupName;
453 #endif // QGSEXPRESSIONBUILDER_H