25 #include <QStringListModel> 42 , mComboBox( nullptr )
43 , mListWidget( nullptr )
44 , mLineEdit( nullptr )
66 for (
int i = 0; i < mListWidget->
count(); ++i )
80 if ( i.second == mLineEdit->
text() )
93 if (
config(
"AllowMulti" ).toBool() )
97 else if (
config(
"UseCompleter" ).toBool() )
110 mComboBox = qobject_cast<
QComboBox*>( editor );
111 mListWidget = qobject_cast<
QListWidget*>( editor );
112 mLineEdit = qobject_cast<
QLineEdit*>( editor );
116 if (
config(
"AllowNull" ).toBool() )
123 mComboBox->
addItem( element.second, element.first );
128 else if ( mListWidget )
134 item->
setData( Qt::UserRole, element.first );
136 mListWidget->addItem( item );
140 else if ( mLineEdit )
151 mLineEdit->setCompleter( completer );
157 return mListWidget || mLineEdit || mComboBox;
166 for (
int i = 0; i < mListWidget->
count(); ++i )
169 if (
config(
"OrderByValue" ).toBool() )
179 else if ( mComboBox )
183 else if ( mLineEdit )
187 if ( i.first == value )
189 mLineEdit->
setText( i.second );
214 if ( !config.
value(
"FilterExpression" ).toString().isEmpty() )
221 if ( ki >= 0 && vi >= 0 )
224 attributes << ki << vi;
228 bool requiresAllAttributes =
false;
238 requiresAllAttributes =
true;
249 if ( !requiresAllAttributes )
269 if ( config.
value(
"OrderByValue" ).toBool() )
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.
Wrapper for iterator of features from vector data provider or vector layer.
void setCaseSensitivity(Qt::CaseSensitivity caseSensitivity)
QString & append(QChar ch)
Q_DECL_DEPRECATED QVariant evaluate(const QgsFeature *f)
Evaluate the feature and return the result.
void append(const T &value)
Q_DECL_DEPRECATED bool prepare(const QgsFields &fields)
Get the expression ready for evaluation - find out column indexes.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
QStringList referencedColumns() const
Get list of columns referenced by the expression.
QString & prepend(QChar ch)
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
bool contains(const QString &str, Qt::CaseSensitivity cs) const
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
QString join(const QString &separator) const
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QString & remove(int position, int n)
QString tr(const char *sourceText, const char *disambiguation, int n)
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second.
QgsMapLayer * mapLayer(const QString &theLayerId)
Retrieve a pointer to a loaded layer by id.
void addItem(const QString &text, const QVariant &userData)
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
This class wraps a request for features to a vector layer (or directly its vector data provider)...
Lineedit with builtin clear button.
static const QString AllAttributes
A special attribute that if set matches all attributes.
QgsFeatureRequest & setFlags(const QgsFeatureRequest::Flags &flags)
Set flags that affect how features will be fetched.
QVariant itemData(int index, int role) const
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
int findData(const QVariant &data, int role, QFlags< Qt::MatchFlag > flags) const
QList< T > toList() const
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.
bool nextFeature(QgsFeature &f)
Geometry is not required. It may still be returned if e.g. required for a filter condition.
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.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
int fieldNameIndex(const QString &fieldName) const
Returns the index of a field name or -1 if the field does not exist.
const T value(const Key &key) const