24 #include <QStringListModel>
30 switch ( p1.first.type() )
32 case QVariant::String:
33 return p1.first.toString() < p2.first.toString();
36 case QVariant::Double:
37 return p1.first.toDouble() < p2.first.toDouble();
41 return p1.first.toInt() < p2.first.toInt();
49 return p1.second < p2.second;
78 for (
int i = 0; i < mListWidget->
count(); ++i )
92 if ( i.second == mLineEdit->
text() )
105 if (
config(
"AllowMulti" ).toBool() )
109 else if (
config(
"UseCompleter" ).toBool() )
122 mComboBox = qobject_cast<
QComboBox*>( editor );
123 mListWidget = qobject_cast<
QListWidget*>( editor );
124 mLineEdit = qobject_cast<
QLineEdit*>( editor );
128 if (
config(
"AllowNull" ).toBool() )
135 mComboBox->
addItem( element.second, element.first );
140 else if ( mListWidget )
146 item->
setData( Qt::UserRole, element.first );
148 mListWidget->addItem( item );
152 else if ( mLineEdit )
163 mLineEdit->setCompleter( completer );
169 return mListWidget || mLineEdit || mComboBox;
178 for (
int i = 0; i < mListWidget->
count(); ++i )
181 if (
config(
"OrderByValue" ).toBool() )
191 else if ( mComboBox )
195 else if ( mLineEdit )
199 if ( i.first == value )
201 mLineEdit->
setText( i.second );
226 if ( !config.
value(
"FilterExpression" ).toString().isEmpty() )
233 if ( ki >= 0 && vi >= 0 )
236 attributes << ki << vi;
240 bool requiresAllAttributes =
false;
250 requiresAllAttributes =
true;
261 if ( !requiresAllAttributes )
281 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