16 #ifndef QGSFIELDEXPRESSIONWIDGET_H
17 #define QGSFIELDEXPRESSIONWIDGET_H
21 #include <QToolButton>
49 Q_PROPERTY( QString expressionDialogTitle READ expressionDialogTitle WRITE setExpressionDialogTitle )
50 Q_PROPERTY( QgsFieldProxyModel::Filters filters READ filters WRITE setFilters )
51 Q_PROPERTY(
bool allowEmptyFieldName READ allowEmptyFieldName WRITE setAllowEmptyFieldName )
52 Q_PROPERTY(
bool allowEvalErrors READ allowEvalErrors WRITE setAllowEvalErrors NOTIFY allowEvalErrorsChanged )
62 void setExpressionDialogTitle(
const QString &title );
77 void setFilters( QgsFieldProxyModel::Filters filters );
84 void setAllowEmptyFieldName(
bool allowEmpty );
91 bool allowEmptyFieldName()
const;
93 void setLeftHandButtonStyle(
bool isLeft );
96 QgsFieldProxyModel::Filters
filters()
const {
return mFieldProxyModel->filters(); }
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;
129 QString asExpression()
const;
140 QString expression()
const;
163 bool allowEvalErrors()
const;
171 void setAllowEvalErrors(
bool allowEvalErrors );
197 void setRow(
int row ) { mCombo->setCurrentIndex( row ); }
200 void setField(
const QString &fieldName );
206 void setFields(
const QgsFields &fields );
214 void setExpression(
const QString &expression );
218 void editExpression();
221 void expressionEdited(
const QString &expression );
224 void expressionEditingFinished();
226 void currentFieldChanged();
233 void updateLineEditStyle(
const QString &expression = QString() );
235 bool isExpressionValid(
const QString &expressionStr );
238 void changeEvent( QEvent *event )
override;
240 bool eventFilter( QObject *watched, QEvent *event )
override;
245 void beforeResetModel();
246 void afterResetModel();
249 QComboBox *mCombo =
nullptr;
250 QToolButton *mButton =
nullptr;
252 QString mExpressionDialogTitle;
253 std::shared_ptr<const QgsDistanceArea> mDistanceArea;
256 QString mBackupExpression;
257 bool mAllowEvalErrors =
false;
259 friend class TestQgsFieldExpressionWidget;
262 #endif // QGSFIELDEXPRESSIONWIDGET_H