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,
107 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 );
152 bool isExpressionValid();
169 void setCustomPreviewGenerator(
const QString &label,
const QList< QPair< QString, QVariant > > &choices,
const std::function<
QgsExpressionContext(
const QVariant & ) > &previewContextGenerator );
185 void setCustomPreviewGenerator(
const QString &label,
const QList< QPair< QString, QVariant > > &choices, SIP_PYCALLABLE );
188 Py_BEGIN_ALLOW_THREADS
189 sipCpp->setCustomPreviewGenerator( *a0, *a1, [a2](
const QVariant &value )->
QgsExpressionContext
193 PyObject *s = sipCallMethod( NULL, a2,
"D", &value, sipType_QVariant, NULL );
197 if ( sipIsError == 0 )
201 sipReleaseType( t1, sipType_QgsExpressionContext, state );
216 Q_DECL_DEPRECATED
void saveToRecent(
const QString &collection =
"generic" )
SIP_DEPRECATED;
223 Q_DECL_DEPRECATED
void loadRecent( const QString &collection = QStringLiteral( "generic" ) )
SIP_DEPRECATED ;
243 Q_DECL_DEPRECATED
void saveToUserExpressions( const QString &label, const QString &expression, const QString &helpText )
SIP_DEPRECATED;
250 Q_DECL_DEPRECATED
void removeFromUserExpressions( const QString &label )
SIP_DEPRECATED;
255 void newFunctionFile( const QString &fileName = "scratch" );
260 void saveFunctionFile( QString fileName );
265 void loadCodeFromFile( QString path );
270 void loadFunctionCode( const QString &code );
275 void updateFunctionFileList( const QString &path );
302 bool evalError() const;
309 bool parserError() const;
316 void setExpressionPreviewVisible(
bool isVisible );
325 void loadSampleValues();
332 void loadAllValues();
341 void loadSampleUsedValues();
350 void loadAllUsedValues();
362 void setAutoSave(
bool enabled ) { mAutoSave = enabled; }
368 void storeCurrentUserExpression( );
375 void removeSelectedUserExpression( );
382 void editSelectedUserExpression();
389 const QList<QgsExpressionItem *> findExpressions(
const QString &label );
393 void indicatorClicked(
int line,
int index, Qt::KeyboardModifiers state );
394 void onExpressionParsed(
bool state );
396 void operatorButtonClicked();
397 void btnRun_pressed();
398 void btnNewFile_pressed();
399 void btnRemoveFile_pressed();
406 void exportUserExpressions_pressed();
413 void importUserExpressions_pressed();
414 void cmbFileNames_currentItemChanged( QListWidgetItem *item, QListWidgetItem *lastitem );
415 void insertExpressionText(
const QString &text );
416 void txtExpressionString_textChanged();
417 void txtSearchEditValues_textChanged();
418 void mValuesListView_doubleClicked(
const QModelIndex &index );
419 void txtPython_textChanged();
446 void showEvent( QShowEvent *e )
override;
454 , mExpressionBuilderWidget( expressionBuilderWidget ) {}
462 int FUNCTION_MARKER_ID = 25;
464 void createErrorMarkers(
const QList<QgsExpression::ParserError> &errors );
466 void clearFunctionMarkers();
468 void runPythonCode(
const QString &code );
470 void fillFieldValues(
const QString &fieldName,
QgsVectorLayer *layer,
int countLimit,
bool forceUsedValues =
false );
473 QString helpStylesheet()
const;
476 void expressionContextUpdated();
481 std::unique_ptr<QStandardItemModel> mValuesModel;
482 std::unique_ptr<QSortFilterProxyModel> mProxyValues;
484 ExpressionTreeMenuProvider *mExpressionTreeMenuProvider =
nullptr;
486 bool mAutoSave =
true;
487 QString mFunctionsPath;
490 bool mExpressionValid =
false;
492 QPointer< QgsProject > mProject;
495 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.
#define SIP_ENUM_BASETYPE(type)