QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsfieldexpressionwidget.cpp
Go to the documentation of this file.
1 
2 /***************************************************************************
3  qgsfieldexpressionwidget.cpp
4  --------------------------------------
5  Date : 01.04.2014
6  Copyright : (C) 2014 Denis Rouzaud
7  Email : [email protected]
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16 
17 #include <QHBoxLayout>
18 #include <QObject>
19 #include <QKeyEvent>
20 
21 #include "qgsapplication.h"
24 #include "qgsfieldproxymodel.h"
25 #include "qgsdistancearea.h"
26 #include "qgsfieldmodel.h"
27 #include "qgsvectorlayer.h"
28 #include "qgsproject.h"
31 
33  : QWidget( parent )
34  , mExpressionDialogTitle( tr( "Expression Dialog" ) )
35  , mDistanceArea( nullptr )
36 
37 {
38  QHBoxLayout *layout = new QHBoxLayout( this );
39  layout->setContentsMargins( 0, 0, 0, 0 );
40 
41  mCombo = new QComboBox( this );
42  mCombo->setEditable( true );
43  mCombo->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum );
44  int width = mCombo->minimumSizeHint().width();
45  mCombo->setMinimumWidth( width );
46 
47  mFieldProxyModel = new QgsFieldProxyModel( mCombo );
48  mFieldProxyModel->sourceFieldModel()->setAllowExpression( true );
49  mCombo->setModel( mFieldProxyModel );
50 
51  mButton = new QToolButton( this );
52  mButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
53  mButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mIconExpression.svg" ) ) );
54 
55  layout->addWidget( mCombo );
56  layout->addWidget( mButton );
57 
58  // give focus to the combo
59  // hence if the widget is used as a delegate
60  // it will allow pressing on the expression dialog button
61  setFocusProxy( mCombo );
62 
63  connect( mCombo->lineEdit(), &QLineEdit::textEdited, this, &QgsFieldExpressionWidget::expressionEdited );
64  connect( mCombo->lineEdit(), &QLineEdit::editingFinished, this, &QgsFieldExpressionWidget::expressionEditingFinished );
65  connect( mCombo, static_cast < void ( QComboBox::* )( int ) > ( &QComboBox::activated ), this, &QgsFieldExpressionWidget::currentFieldChanged );
66  connect( mButton, &QAbstractButton::clicked, this, &QgsFieldExpressionWidget::editExpression );
67  connect( mFieldProxyModel, &QAbstractItemModel::modelAboutToBeReset, this, &QgsFieldExpressionWidget::beforeResetModel );
68  connect( mFieldProxyModel, &QAbstractItemModel::modelReset, this, &QgsFieldExpressionWidget::afterResetModel );
69 
70  mExpressionContext = QgsExpressionContext();
71  mExpressionContext << QgsExpressionContextUtils::globalScope()
73 
74  mCombo->installEventFilter( this );
75 }
76 
78 {
79  mExpressionDialogTitle = title;
80 }
81 
82 void QgsFieldExpressionWidget::setFilters( QgsFieldProxyModel::Filters filters )
83 {
84  mFieldProxyModel->setFilters( filters );
85 }
86 
88 {
89  mCombo->lineEdit()->setClearButtonEnabled( allowEmpty );
90  mFieldProxyModel->sourceFieldModel()->setAllowEmptyFieldName( allowEmpty );
91 }
92 
94 {
95  return mFieldProxyModel->sourceFieldModel()->allowEmptyFieldName();
96 }
97 
99 {
100  QHBoxLayout *layout = dynamic_cast<QHBoxLayout *>( this->layout() );
101  if ( !layout )
102  return;
103 
104  if ( isLeft )
105  {
106  QLayoutItem *item = layout->takeAt( 1 );
107  layout->insertWidget( 0, item->widget() );
108  }
109  else
110  layout->addWidget( mCombo );
111 }
112 
114 {
115  mDistanceArea = std::shared_ptr<const QgsDistanceArea>( new QgsDistanceArea( da ) );
116 }
117 
119 {
120  return mCombo->currentText();
121 }
122 
124 {
126 }
127 
129 {
130  return asExpression();
131 }
132 
133 bool QgsFieldExpressionWidget::isValidExpression( QString *expressionError ) const
134 {
135  QString temp;
136  return QgsExpression::checkExpression( currentText(), &mExpressionContext, expressionError ? *expressionError : temp );
137 }
138 
140 {
141  return !mFieldProxyModel->sourceFieldModel()->isField( currentText() );
142 }
143 
144 QString QgsFieldExpressionWidget::currentField( bool *isExpression, bool *isValid ) const
145 {
146  QString text = currentText();
147  bool valueIsExpression = this->isExpression();
148  if ( isValid )
149  {
150  // valid if not an expression (ie, set to a field), or set to an expression and expression is valid
151  *isValid = !valueIsExpression || isValidExpression();
152  }
153  if ( isExpression )
154  {
155  *isExpression = valueIsExpression;
156  }
157  return text;
158 }
159 
161 {
162  return mFieldProxyModel->sourceFieldModel()->layer();
163 }
164 
166 {
167  mExpressionContextGenerator = generator;
168 }
169 
171 {
172  QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( layer );
173 
174  if ( mFieldProxyModel->sourceFieldModel()->layer() )
175  disconnect( mFieldProxyModel->sourceFieldModel()->layer(), &QgsVectorLayer::updatedFields, this, &QgsFieldExpressionWidget::reloadLayer );
176 
177  if ( vl )
178  mExpressionContext = vl->createExpressionContext();
179  else
180  mExpressionContext = QgsProject::instance()->createExpressionContext();
181 
182  mFieldProxyModel->sourceFieldModel()->setLayer( vl );
183 
184  if ( mFieldProxyModel->sourceFieldModel()->layer() )
185  connect( mFieldProxyModel->sourceFieldModel()->layer(), &QgsVectorLayer::updatedFields, this, &QgsFieldExpressionWidget::reloadLayer, Qt::UniqueConnection );
186 }
187 
188 void QgsFieldExpressionWidget::setField( const QString &fieldName )
189 {
190  if ( fieldName.isEmpty() )
191  {
192  setRow( -1 );
193  emit fieldChanged( QString() );
194  emit fieldChanged( QString(), true );
195  return;
196  }
197 
198  QModelIndex idx = mFieldProxyModel->sourceFieldModel()->indexFromName( fieldName );
199  if ( !idx.isValid() )
200  {
201  // try to remove quotes and white spaces
202  QString simpleFieldName = fieldName.trimmed();
203  if ( simpleFieldName.startsWith( '"' ) && simpleFieldName.endsWith( '"' ) )
204  {
205  simpleFieldName.remove( 0, 1 ).chop( 1 );
206  idx = mFieldProxyModel->sourceFieldModel()->indexFromName( simpleFieldName );
207  }
208 
209  if ( !idx.isValid() )
210  {
211  // new expression
212  mFieldProxyModel->sourceFieldModel()->setExpression( fieldName );
213  idx = mFieldProxyModel->sourceFieldModel()->indexFromName( fieldName );
214  }
215  }
216  QModelIndex proxyIndex = mFieldProxyModel->mapFromSource( idx );
217  mCombo->setCurrentIndex( proxyIndex.row() );
219 }
220 
222 {
223  mFieldProxyModel->sourceFieldModel()->setFields( fields );
224 }
225 
226 void QgsFieldExpressionWidget::setExpression( const QString &expression )
227 {
228  setField( expression );
229 }
230 
232 {
233  QString currentExpression = asExpression();
234  QgsVectorLayer *vl = layer();
235 
236  QgsExpressionContext context = mExpressionContextGenerator ? mExpressionContextGenerator->createExpressionContext() : mExpressionContext;
237 
238  QgsExpressionBuilderDialog dlg( vl, currentExpression, this, QStringLiteral( "generic" ), context );
239  if ( mDistanceArea )
240  {
241  dlg.setGeomCalculator( *mDistanceArea );
242  }
243  dlg.setWindowTitle( mExpressionDialogTitle );
244  dlg.setAllowEvalErrors( mAllowEvalErrors );
245 
246  if ( !vl )
247  dlg.expressionBuilder()->expressionTree()->loadFieldNames( mFieldProxyModel->sourceFieldModel()->fields() );
248 
249  if ( dlg.exec() )
250  {
251  QString newExpression = dlg.expressionText();
252  setField( newExpression );
253  }
254 }
255 
256 void QgsFieldExpressionWidget::expressionEdited( const QString &expression )
257 {
260 }
261 
263 {
264  const QString expression = mCombo->lineEdit()->text();
265  mFieldProxyModel->sourceFieldModel()->setExpression( expression );
266  QModelIndex idx = mFieldProxyModel->sourceFieldModel()->indexFromName( expression );
267  QModelIndex proxyIndex = mFieldProxyModel->mapFromSource( idx );
268  mCombo->setCurrentIndex( proxyIndex.row() );
270 }
271 
273 {
274  if ( event->type() == QEvent::EnabledChange )
275  {
277  }
278 }
279 
280 void QgsFieldExpressionWidget::reloadLayer()
281 {
282  setLayer( mFieldProxyModel->sourceFieldModel()->layer() );
283 }
284 
285 void QgsFieldExpressionWidget::beforeResetModel()
286 {
287  // Backup expression
288  mBackupExpression = mCombo->currentText();
289 }
290 
291 void QgsFieldExpressionWidget::afterResetModel()
292 {
293  // Restore expression
294  mCombo->lineEdit()->setText( mBackupExpression );
295 }
296 
297 bool QgsFieldExpressionWidget::eventFilter( QObject *watched, QEvent *event )
298 {
299  if ( watched == mCombo && event->type() == QEvent::KeyPress )
300  {
301  QKeyEvent *keyEvent = static_cast<QKeyEvent *>( event );
302  if ( keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return )
303  {
305  return true;
306  }
307  }
308  return QObject::eventFilter( watched, event );
309 }
310 
312 {
313  return mAllowEvalErrors;
314 }
315 
317 {
318  if ( allowEvalErrors == mAllowEvalErrors )
319  return;
320 
321  mAllowEvalErrors = allowEvalErrors;
322  emit allowEvalErrorsChanged();
323 }
324 
326 {
328 
329  bool isExpression, isValid;
330  QString fieldName = currentField( &isExpression, &isValid );
331 
332  // display tooltip if widget is shorter than expression
333  QFontMetrics metrics( mCombo->lineEdit()->font() );
334  if ( metrics.boundingRect( fieldName ).width() > mCombo->lineEdit()->width() )
335  {
336  mCombo->setToolTip( fieldName );
337  }
338  else
339  {
340  mCombo->setToolTip( QString() );
341  }
342 
343  emit fieldChanged( fieldName );
344  emit fieldChanged( fieldName, isValid );
345 }
346 
347 void QgsFieldExpressionWidget::updateLineEditStyle( const QString &expression )
348 {
349  QString stylesheet;
350  if ( !isEnabled() )
351  {
352  stylesheet = QStringLiteral( "QLineEdit { color: %1; }" ).arg( QColor( Qt::gray ).name() );
353  }
354  else
355  {
356  bool isExpression, isValid;
357  if ( !expression.isEmpty() )
358  {
359  isExpression = true;
360  isValid = isExpressionValid( expression );
361  }
362  else
363  {
364  currentField( &isExpression, &isValid );
365  }
366  QFont font = mCombo->lineEdit()->font();
367  font.setItalic( isExpression );
368  mCombo->lineEdit()->setFont( font );
369 
370  if ( isExpression && !isValid )
371  {
372  stylesheet = QStringLiteral( "QLineEdit { color: %1; }" ).arg( QColor( Qt::red ).name() );
373  }
374  }
375  mCombo->lineEdit()->setStyleSheet( stylesheet );
376 }
377 
378 bool QgsFieldExpressionWidget::isExpressionValid( const QString &expressionStr )
379 {
380  QgsExpression expression( expressionStr );
381  expression.prepare( &mExpressionContext );
382  return !expression.hasParserError();
383 }
384 
386 {
387  mExpressionContext.appendScope( scope );
388 }
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:370
QgsFieldExpressionWidget::asExpression
QString asExpression() const
Returns the currently selected field or expression.
Definition: qgsfieldexpressionwidget.cpp:123
qgsexpressioncontextutils.h
QgsFieldExpressionWidget::currentFieldChanged
void currentFieldChanged()
Definition: qgsfieldexpressionwidget.cpp:325
QgsFieldModel::setAllowEmptyFieldName
void setAllowEmptyFieldName(bool allowEmpty)
Sets whether an optional empty field ("not set") option is present in the model.
Definition: qgsfieldmodel.cpp:198
QgsApplication::getThemeIcon
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
Definition: qgsapplication.cpp:626
qgsfieldproxymodel.h
QgsFieldExpressionWidget::editExpression
void editExpression()
open the expression dialog to edit the current or add a new expression
Definition: qgsfieldexpressionwidget.cpp:231
QgsExpressionContextUtils::globalScope
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Definition: qgsexpressioncontextutils.cpp:34
QgsFieldExpressionWidget::QgsFieldExpressionWidget
QgsFieldExpressionWidget(QWidget *parent=nullptr)
QgsFieldExpressionWidget creates a widget with a combo box to display the fields and expression and a...
Definition: qgsfieldexpressionwidget.cpp:32
QgsFieldExpressionWidget::currentText
QString currentText() const
Returns the current text that is set in the expression area.
Definition: qgsfieldexpressionwidget.cpp:118
QgsFieldExpressionWidget::currentField
QString currentField(bool *isExpression=nullptr, bool *isValid=nullptr) const
currentField returns the currently selected field or expression if allowed
Definition: qgsfieldexpressionwidget.cpp:144
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:45
QgsFieldModel::setLayer
void setLayer(QgsVectorLayer *layer)
Set the layer from which fields are displayed.
Definition: qgsfieldmodel.cpp:83
QgsProject::instance
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:468
QgsFieldModel::setFields
void setFields(const QgsFields &fields)
Manually sets the fields to use for the model.
Definition: qgsfieldmodel.cpp:521
QgsFieldExpressionWidget::isExpression
bool isExpression() const
If the content is not just a simple field this method will return true.
Definition: qgsfieldexpressionwidget.cpp:139
QgsFieldExpressionWidget::setExpression
void setExpression(const QString &expression)
Sets the current expression text and if applicable also the field.
Definition: qgsfieldexpressionwidget.cpp:226
QgsFieldExpressionWidget::setAllowEmptyFieldName
void setAllowEmptyFieldName(bool allowEmpty)
Sets whether an optional empty field ("not set") option is shown in the combo box.
Definition: qgsfieldexpressionwidget.cpp:87
QgsFieldExpressionWidget::changeEvent
void changeEvent(QEvent *event) override
Definition: qgsfieldexpressionwidget.cpp:272
QgsFieldExpressionWidget::isExpressionValid
bool isExpressionValid(const QString &expressionStr)
Definition: qgsfieldexpressionwidget.cpp:378
QgsExpressionBuilderWidget::expressionTree
QgsExpressionTreeView * expressionTree() const
Returns the expression tree.
Definition: qgsexpressionbuilderwidget.cpp:579
QgsFieldProxyModel::setFilters
QgsFieldProxyModel * setFilters(QgsFieldProxyModel::Filters filters)
Set flags that affect how fields are filtered in the model.
Definition: qgsfieldproxymodel.cpp:28
QgsFieldExpressionWidget::isValidExpression
bool isValidExpression(QString *expressionError=nullptr) const
Returns true if the current expression is valid.
Definition: qgsfieldexpressionwidget.cpp:133
QgsExpression::checkExpression
static bool checkExpression(const QString &text, const QgsExpressionContext *context, QString &errorMessage)
Tests whether a string is a valid expression.
Definition: qgsexpression.cpp:40
QgsFieldExpressionWidget::registerExpressionContextGenerator
void registerExpressionContextGenerator(const QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
Definition: qgsfieldexpressionwidget.cpp:165
QgsFieldExpressionWidget::setGeomCalculator
void setGeomCalculator(const QgsDistanceArea &da)
Sets the geometry calculator used in the expression dialog.
Definition: qgsfieldexpressionwidget.cpp:113
qgsapplication.h
QgsFieldExpressionWidget::appendScope
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the current expression context.
Definition: qgsfieldexpressionwidget.cpp:385
QgsExpressionContextUtils::projectScope
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
Definition: qgsexpressioncontextutils.cpp:222
QgsFieldModel::isField
bool isField(const QString &expression) const
Returns true if a string represents a field reference, or false if it is an expression consisting of ...
Definition: qgsfieldmodel.cpp:77
QgsFieldExpressionWidget::filters
QgsFieldProxyModel::Filters filters
Definition: qgsfieldexpressionwidget.h:50
QgsFieldModel::setAllowExpression
void setAllowExpression(bool allowExpression)
Sets whether custom expressions are accepted and displayed in the model.
Definition: qgsfieldmodel.cpp:181
QgsFieldExpressionWidget::setLeftHandButtonStyle
void setLeftHandButtonStyle(bool isLeft)
Definition: qgsfieldexpressionwidget.cpp:98
QgsFieldProxyModel
The QgsFieldProxyModel class provides an easy to use model to display the list of fields of a layer.
Definition: qgsfieldproxymodel.h:33
QgsFieldExpressionWidget::expression
QString expression() const
Returns the currently selected field or expression.
Definition: qgsfieldexpressionwidget.cpp:128
QgsExpressionBuilderDialog
A generic dialog for building expression strings.
Definition: qgsexpressionbuilderdialog.h:31
QgsFieldExpressionWidget::expressionEditingFinished
void expressionEditingFinished()
when expression has been edited (finished) it will be added to the model
Definition: qgsfieldexpressionwidget.cpp:262
QgsFieldExpressionWidget::fieldChanged
void fieldChanged(const QString &fieldName)
Emitted when the currently selected field changes.
QgsExpressionBuilderDialog::expressionBuilder
QgsExpressionBuilderWidget * expressionBuilder()
The builder widget that is used by the dialog.
Definition: qgsexpressionbuilderdialog.cpp:40
QgsFieldExpressionWidget::allowEvalErrors
bool allowEvalErrors
Definition: qgsfieldexpressionwidget.h:52
QgsFieldExpressionWidget::setRow
void setRow(int row)
sets the current row in the widget
Definition: qgsfieldexpressionwidget.h:197
QgsFieldModel::allowEmptyFieldName
bool allowEmptyFieldName
Definition: qgsfieldmodel.h:43
QgsExpressionContextGenerator::createExpressionContext
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QgsFieldExpressionWidget::setFilters
void setFilters(QgsFieldProxyModel::Filters filters)
setFilters allows filtering according to the type of field
Definition: qgsfieldexpressionwidget.cpp:82
QgsExpressionBuilderDialog::setAllowEvalErrors
void setAllowEvalErrors(bool allowEvalErrors)
Allow accepting expressions with evaluation errors.
Definition: qgsexpressionbuilderdialog.cpp:97
QgsFieldExpressionWidget::expressionEdited
void expressionEdited(const QString &expression)
when expression is edited by the user in the line edit, it will be checked for validity
Definition: qgsfieldexpressionwidget.cpp:256
QgsFieldExpressionWidget::setField
void setField(const QString &fieldName)
sets the current field or expression in the widget
Definition: qgsfieldexpressionwidget.cpp:188
QgsFieldExpressionWidget::updateLineEditStyle
void updateLineEditStyle(const QString &expression=QString())
updateLineEditStyle will re-style (color/font) the line edit depending on content and status
Definition: qgsfieldexpressionwidget.cpp:347
QgsExpressionContextScope
Single scope for storing variables and functions for use within a QgsExpressionContext.
Definition: qgsexpressioncontext.h:112
QgsFieldProxyModel::sourceFieldModel
QgsFieldModel * sourceFieldModel()
Returns the QgsFieldModel used in this QSortFilterProxyModel.
Definition: qgsfieldproxymodel.h:62
QgsFieldExpressionWidget::setFields
void setFields(const QgsFields &fields)
Sets the fields used in the widget to fields, this allows the widget to work without a layer.
Definition: qgsfieldexpressionwidget.cpp:221
QgsExpressionBuilderDialog::setGeomCalculator
void setGeomCalculator(const QgsDistanceArea &da)
Sets geometry calculator used in distance/area calculations.
Definition: qgsexpressionbuilderdialog.cpp:86
QgsExpressionContext::appendScope
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
Definition: qgsexpressioncontext.cpp:490
qgsexpressioncontextgenerator.h
qgsvectorlayer.h
QgsExpressionBuilderDialog::expressionText
QString expressionText()
Definition: qgsexpressionbuilderdialog.cpp:50
QgsFieldExpressionWidget::allowEmptyFieldName
bool allowEmptyFieldName
Definition: qgsfieldexpressionwidget.h:51
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsMapLayer
Base class for all map layer types.
Definition: qgsmaplayer.h:83
qgsfieldmodel.h
QgsExpression::quotedColumnRef
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
Definition: qgsexpression.cpp:65
QgsFieldExpressionWidget::eventFilter
bool eventFilter(QObject *watched, QEvent *event) override
Definition: qgsfieldexpressionwidget.cpp:297
QgsDistanceArea
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
Definition: qgsdistancearea.h:50
QgsProject::createExpressionContext
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Definition: qgsproject.cpp:1861
qgsfieldexpressionwidget.h
qgsdistancearea.h
QgsFieldExpressionWidget::setAllowEvalErrors
void setAllowEvalErrors(bool allowEvalErrors)
Allow accepting expressions with evaluation errors.
Definition: qgsfieldexpressionwidget.cpp:316
QgsFieldModel::layer
QgsVectorLayer * layer
Definition: qgsfieldmodel.h:44
QgsFieldModel::fields
QgsFields fields() const
Returns the fields currently shown in the model.
Definition: qgsfieldmodel.cpp:529
QgsVectorLayer::updatedFields
void updatedFields()
Emitted whenever the fields available from this layer have been changed.
QgsFieldModel::indexFromName
QModelIndex indexFromName(const QString &fieldName)
Returns the index corresponding to a given fieldName.
Definition: qgsfieldmodel.cpp:32
QgsFieldModel::setExpression
void setExpression(const QString &expression)
Sets a single expression to be added after the fields at the end of the model.
Definition: qgsfieldmodel.cpp:218
QgsFieldExpressionWidget::layer
QgsVectorLayer * layer() const
Returns the layer currently associated with the widget.
Definition: qgsfieldexpressionwidget.cpp:160
QgsFieldExpressionWidget::allowEvalErrorsChanged
void allowEvalErrorsChanged()
Allow accepting expressions with evaluation errors.
QgsVectorLayer::createExpressionContext
QgsExpressionContext createExpressionContext() const FINAL
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Definition: qgsvectorlayer.cpp:4952
QgsExpression
Class for parsing and evaluation of expressions (formerly called "search strings").
Definition: qgsexpression.h:105
QgsExpressionContextGenerator
Abstract interface for generating an expression context.
Definition: qgsexpressioncontextgenerator.h:37
QgsFieldExpressionWidget::setLayer
void setLayer(QgsMapLayer *layer)
Sets the layer used to display the fields and expression.
Definition: qgsfieldexpressionwidget.cpp:170
QgsFieldExpressionWidget::setExpressionDialogTitle
void setExpressionDialogTitle(const QString &title)
define the title used in the expression dialog
Definition: qgsfieldexpressionwidget.cpp:77
qgsproject.h
QgsExpressionTreeView::loadFieldNames
void loadFieldNames(const QgsFields &fields)
This allows loading fields without specifying a layer.
Definition: qgsexpressiontreeview.cpp:417
qgsexpressionbuilderdialog.h