17#include "moc_qgsexpressionbuilderdialog.cpp" 
   25  , mInitialText( startText )
 
   34  builder->setExpressionContext( context );
 
   35  builder->setLayer( layer );
 
   36  builder->setExpressionText( startText );
 
   37  builder->expressionTree()->loadRecent( mRecentKey );
 
   38  builder->expressionTree()->loadUserExpressions();
 
   41  connect( buttonBox, &QDialogButtonBox::helpRequested, 
this, &QgsExpressionBuilderDialog::showHelp );
 
 
   56  return builder->expressionText();
 
 
   61  return builder->expectedOutputFormat();
 
 
   66  builder->setExpectedOutputFormat( expected );
 
 
   71  return builder->expressionContext();
 
 
   76  builder->setExpressionContext( context );
 
 
   86  builder->expressionTree()->saveToRecent( builder->expressionText(), mRecentKey );
 
 
   92  if ( builder->expressionText() != mInitialText )
 
   95    const bool askToDiscardEditedExpression = settings.
value( QStringLiteral( 
"askToDiscardEditedExpression" ), 
true, 
QgsSettings::Gui ).toBool();
 
   97    if ( askToDiscardEditedExpression )
 
   99      QMessageBox confirmMessage( QMessageBox::Question, tr( 
"Expression was Edited" ), tr( 
"The changes to the expression will be discarded. Would you like to continue?" ), QMessageBox::Yes | QMessageBox::No, 
this );
 
  100      confirmMessage.setCheckBox( 
new QCheckBox( tr( 
"Don't show this message again" ) ) );
 
  101      confirmMessage.checkBox()->setChecked( 
false );
 
  102      confirmMessage.button( QMessageBox::Yes )->setText( tr( 
"Discard changes" ) );
 
  104      int res = confirmMessage.exec();
 
  106      if ( confirmMessage.checkBox()->isChecked() )
 
  111      if ( res != QMessageBox::Yes )
 
 
  122  builder->setGeomCalculator( da );
 
 
  127  return mAllowEvalErrors;
 
 
  136  syncOkButtonEnabledState();
 
 
  140void QgsExpressionBuilderDialog::showHelp()
 
  145void QgsExpressionBuilderDialog::syncOkButtonEnabledState()
 
  147  QPushButton *okButton = buttonBox->button( QDialogButtonBox::Ok );
 
  149  if ( builder->parserError() )
 
  150    okButton->setEnabled( 
false );
 
  152    okButton->setEnabled( 
true );
 
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
 
void done(int r) override
Is called when the dialog get accepted or rejected Used to save geometry.
 
void setGeomCalculator(const QgsDistanceArea &da)
Sets geometry calculator used in distance/area calculations.
 
QgsExpressionBuilderDialog(QgsVectorLayer *layer, const QString &startText=QString(), QWidget *parent SIP_TRANSFERTHIS=nullptr, const QString &key="generic", const QgsExpressionContext &context=QgsExpressionContext())
 
void setExpressionText(const QString &text)
 
void setExpectedOutputFormat(const QString &expected)
Set the expected format string, which is shown in the dialog.
 
QgsExpressionBuilderWidget * expressionBuilder()
The builder widget that is used by the dialog.
 
void allowEvalErrorsChanged()
Allow accepting expressions with evaluation errors.
 
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context for the dialog.
 
void setAllowEvalErrors(bool allowEvalErrors)
Allow accepting expressions with evaluation errors.
 
QString expectedOutputFormat()
Returns the expected format string, which is shown in the dialog.
 
QgsExpressionContext expressionContext() const
Returns the expression context for the dialog.
 
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
 
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
 
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
 
Stores settings for use within QGIS.
 
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
 
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
 
Represents a vector layer which manages a vector based dataset.