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;
421 void expressionContextUpdated();
426 std::unique_ptr<QStandardItemModel> mValuesModel;
427 std::unique_ptr<QSortFilterProxyModel> mProxyValues;
429 ExpressionTreeMenuProvider *mExpressionTreeMenuProvider =
nullptr;
431 bool mAutoSave =
true;
432 QString mFunctionsPath;
435 bool mExpressionValid =
false;
437 QPointer< QgsProject > mProject;
440 QString mUserExpressionsGroupName;
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
A abstract base class for defining QgsExpression functions.
An expression item that can be used in the QgsExpressionBuilderWidget tree.
Abstract base class for all nodes that can appear in an expression.
QgsExpressionTreeView is a tree view to list all expressions functions, variables and fields that can...
Container of fields for a vector layer.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Represents a vector layer which manages a vector based data sets.