17 #include <QHBoxLayout> 27 , mExpressionDialogTitle( tr(
"Expression dialog" ) )
29 , mExpressionContextCallback( nullptr )
30 , mExpressionContextCallbackContext( nullptr )
37 mCombo->
setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum );
43 mCombo->
setModel( mFieldProxyModel );
46 mButton->
setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
61 connect( mFieldProxyModel, SIGNAL( modelAboutToBeReset() ),
this, SLOT( beforeResetModel() ) );
62 connect( mFieldProxyModel, SIGNAL( modelReset() ),
this, SLOT( afterResetModel() ) );
73 mExpressionDialogTitle = title;
138 *isExpression = valueIsExpression;
150 mExpressionContextCallback = fnGetExpressionContext;
151 mExpressionContextCallbackContext = context;
218 QgsExpressionContext context = mExpressionContextCallback ? mExpressionContextCallback( mExpressionContextCallbackContext ) : *mExpressionContext;
253 if ( event->
type() == QEvent::EnabledChange )
259 void QgsFieldExpressionWidget::reloadLayer()
264 void QgsFieldExpressionWidget::beforeResetModel()
270 void QgsFieldExpressionWidget::afterResetModel()
285 if ( metrics.width( fieldName ) > mCombo->
lineEdit()->
width() )
303 palette.
setColor( QPalette::Text, Qt::gray );
321 if ( isExpression && !isValid )
323 palette.
setColor( QPalette::Text, Qt::red );
327 palette.
setColor( QPalette::Text, Qt::black );
Class for parsing and evaluation of expressions (formerly called "search strings").
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
QgsFieldProxyModel * setFilters(const QgsFieldProxyModel::Filters &filters)
Set flags that affect how fields are filtered in the model.
Base class for all map layer types.
void setContentsMargins(int left, int top, int right, int bottom)
QgsFieldModel * sourceFieldModel()
Returns the QgsFieldModel used in this QSortFilterProxyModel.
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
void setColor(ColorGroup group, ColorRole role, const QColor &color)
Q_DECL_DEPRECATED bool prepare(const QgsFields &fields)
Get the expression ready for evaluation - find out column indexes.
static QIcon getThemeIcon(const QString &theName)
Helper to get a theme icon.
void setExpression(const QString &expression)
setExpression sets a single expression to be added after the fields at the end of the model ...
QString & remove(int position, int n)
void setEditable(bool editable)
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
virtual QLayoutItem * takeAt(int index)
QgsVectorLayer * layer()
returns the currently used layer
bool isField(const QString &expression)
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
The QgsFieldProxyModel class provides an easy to use model to display the list of fields of a layer...
virtual QSize minimumSizeHint() const
bool isValid() const
Checks if this expression is valid.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setLayer(QgsVectorLayer *layer)
set the layer of whch fields are displayed
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
void setGeomCalculator(const QgsDistanceArea &da)
Sets geometry calculator used in distance/area calculations.
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
void setAllowExpression(bool allowExpression)
returns the currently used layer
void setItalic(bool enable)
General purpose distance and area calculator.
QLineEdit * lineEdit() const
void setModel(QAbstractItemModel *model)
virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const
void setCurrentIndex(int index)
static QgsExpressionContextScope * projectScope()
Creates a new scope which contains variables and functions relating to the current QGIS project...
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
QModelIndex indexFromName(const QString &fieldName)
return the index corresponding to a given fieldName
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Represents a vector layer which manages a vector based data sets.
A generic dialog for building expression strings.