24 #include <QStringListModel> 30 switch ( p1.first.type() )
32 case QVariant::String:
33 return p1.first.toString() < p2.first.toString();
35 case QVariant::Double:
36 return p1.first.toDouble() < p2.first.toDouble();
39 return p1.first.toInt() < p2.first.toInt();
46 return p1.second < p2.second;
51 , mComboBox( nullptr )
52 , mListWidget( nullptr )
53 , mLineEdit( nullptr )
75 for (
int i = 0; i < mListWidget->
count(); ++i )
89 if ( i.second == mLineEdit->
text() )
102 if (
config(
"AllowMulti" ).toBool() )
106 else if (
config(
"UseCompleter" ).toBool() )
119 mComboBox = qobject_cast<
QComboBox*>( editor );
120 mListWidget = qobject_cast<
QListWidget*>( editor );
121 mLineEdit = qobject_cast<
QLineEdit*>( editor );
125 if (
config(
"AllowNull" ).toBool() )
132 mComboBox->
addItem( element.second, element.first );
137 else if ( mListWidget )
143 item->
setData( Qt::UserRole, element.first );
145 mListWidget->addItem( item );
149 else if ( mLineEdit )
160 mLineEdit->setCompleter( completer );
166 return mListWidget || mLineEdit || mComboBox;
175 for (
int i = 0; i < mListWidget->
count(); ++i )
178 if (
config(
"OrderByValue" ).toBool() )
188 else if ( mComboBox )
192 else if ( mLineEdit )
196 if ( i.first == value )
198 mLineEdit->
setText( i.second );
223 if ( !config.
value(
"FilterExpression" ).toString().isEmpty() )
230 if ( ki >= 0 && vi >= 0 )
233 attributes << ki << vi;
237 bool requiresAllAttributes =
false;
247 requiresAllAttributes =
true;
258 if ( !requiresAllAttributes )
278 if ( config.
value(
"OrderByValue" ).toBool() )
Class for parsing and evaluation of expressions (formerly called "search strings").
Wrapper for iterator of features from vector data provider or vector layer.
void setCaseSensitivity(Qt::CaseSensitivity caseSensitivity)
QString & append(QChar ch)
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
QStringList referencedColumns() const
Get list of columns referenced by the expression.
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
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.
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)
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...
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
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.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
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.
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