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;
143 mExpressionContextCallback = fnGetExpressionContext;
144 mExpressionContextCallbackContext = context;
206 QgsExpressionContext context = mExpressionContextCallback ? mExpressionContextCallback( mExpressionContextCallbackContext ) : *mExpressionContext;
241 if ( event->
type() == QEvent::EnabledChange )
247 void QgsFieldExpressionWidget::reloadLayer()
252 void QgsFieldExpressionWidget::beforeResetModel()
258 void QgsFieldExpressionWidget::afterResetModel()
273 if ( metrics.width( fieldName ) > mCombo->
lineEdit()->
width() )
291 palette.
setColor( QPalette::Text, Qt::gray );
309 if ( isExpression && !isValid )
311 palette.
setColor( QPalette::Text, Qt::red );
315 palette.
setColor( QPalette::Text, Qt::black );
Class for parsing and evaluation of expressions (formerly called "search strings").
QgsFieldProxyModel * setFilters(const QgsFieldProxyModel::Filters &filters)
setFilters set flags that affect how fields are filtered
Base class for all map layer types.
void setContentsMargins(int left, int top, int right, int bottom)
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
QgsFieldModel * sourceFieldModel()
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)
static Q_DECL_DEPRECATED bool isValid(const QString &text, const QgsFields &fields, QString &errorMessage)
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
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.