49 Q_PROPERTY( QString expressionDialogTitle READ expressionDialogTitle WRITE setExpressionDialogTitle )
51 Q_PROPERTY(
bool allowEmptyFieldName READ allowEmptyFieldName WRITE setAllowEmptyFieldName )
52 Q_PROPERTY(
bool allowEvalErrors READ allowEvalErrors WRITE setAllowEvalErrors NOTIFY allowEvalErrorsChanged )
53 Q_PROPERTY(
bool buttonVisible READ buttonVisible WRITE setButtonVisible NOTIFY buttonVisibleChanged )
62 void setExpressionDialogTitle( const QString &title );
74 const QString expressionDialogTitle() {
return mExpressionDialogTitle; }
84 void setAllowEmptyFieldName(
bool allowEmpty );
91 bool allowEmptyFieldName()
const;
93 void setLeftHandButtonStyle(
bool isLeft );
106 QString currentField(
bool *isExpression =
nullptr,
bool *isValid =
nullptr )
const;
111 bool isValidExpression( QString *expressionError =
nullptr )
const;
116 bool isExpression()
const;
121 QString currentText()
const;
128 QString asExpression()
const;
138 QString expression()
const;
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 {
192 PyObject *s = sipCallMethod( NULL, a2,
"D", &value, sipType_QVariant, NULL );
196 if ( sipIsError == 0 )
200 sipReleaseType( t1, sipType_QgsExpressionContext, state );
214 bool allowEvalErrors()
const;
221 void setAllowEvalErrors(
bool allowEvalErrors );
230 bool buttonVisible()
const;
239 void setButtonVisible(
bool visible );
271 void setRow(
int row ) { mCombo->setCurrentIndex( row ); }
274 void setField(
const QString &fieldName );
280 void setFields(
const QgsFields &fields );
287 void setExpression(
const QString &expression );
291 void editExpression();
294 void expressionEdited(
const QString &expression );
297 void expressionEditingFinished();
299 void currentFieldChanged();
306 void updateLineEditStyle(
const QString &expression = QString() );
308 bool isExpressionValid(
const QString &expressionStr );
311 void changeEvent( QEvent *event )
override;
313 bool eventFilter( QObject *watched, QEvent *event )
override;
318 void beforeResetModel();
319 void afterResetModel();
322 QComboBox *mCombo =
nullptr;
323 QToolButton *mButton =
nullptr;
325 QString mExpressionDialogTitle;
326 std::shared_ptr<const QgsDistanceArea> mDistanceArea;
329 QString mBackupExpression;
330 bool mAllowEvalErrors =
false;
332 QString mCustomPreviewLabel;
333 QList<QPair<QString, QVariant>> mCustomChoices;
336 friend class TestQgsFieldExpressionWidget;
Abstract interface for generating an expression context.
Single scope for storing variables and functions for use within a QgsExpressionContext.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...