26 switch ( p1.first.type() )
28 case QVariant::String:
29 return p1.first.toString() < p2.first.toString();
32 case QVariant::Double:
33 return p1.first.toDouble() < p2.first.toDouble();
37 return p1.first.toInt() < p2.first.toInt();
45 return p1.second < p2.second;
63 int cbxIdx = mComboBox->currentIndex();
66 v = mComboBox->itemData( mComboBox->currentIndex() );
72 QStringList selection;
73 for (
int i = 0; i < mListWidget->count(); ++i )
75 QListWidgetItem* item = mListWidget->item( i );
76 if ( item->checkState() == Qt::Checked )
77 selection << item->data( Qt::UserRole ).toString();
80 v = selection.join(
"," ).prepend(
"{" ).append(
"}" );
88 if (
config(
"AllowMulti" ).toBool() )
90 return new QListWidget( parent );
94 return new QComboBox( parent );
102 mComboBox = qobject_cast<QComboBox*>( editor );
103 mListWidget = qobject_cast<QListWidget*>( editor );
107 if (
config(
"AllowNull" ).toBool() )
109 mComboBox->addItem(
tr(
"(no selection)" ), QVariant(
field().type() ) );
114 mComboBox->addItem( element.second, element.first );
117 connect( mComboBox, SIGNAL( currentIndexChanged(
int ) ),
this, SLOT(
valueChanged() ) );
119 else if ( mListWidget )
123 QListWidgetItem *item;
124 item =
new QListWidgetItem( element.second );
125 item->setData( Qt::UserRole, element.first );
127 mListWidget->addItem( item );
129 connect( mListWidget, SIGNAL( itemChanged( QListWidgetItem* ) ),
this, SLOT(
valueChanged() ) );
137 QStringList checkList = value.toString().remove( QChar(
'{' ) ).remove( QChar(
'}' ) ).split(
"," );
139 for (
int i = 0; i < mListWidget->count(); ++i )
141 QListWidgetItem* item = mListWidget->item( i );
142 if (
config(
"OrderByValue" ).toBool() )
144 item->setCheckState( checkList.contains( item->data( Qt::UserRole ).toString() ) ? Qt::Checked : Qt::Unchecked );
148 item->setCheckState( checkList.contains( item->data( Qt::UserRole ).toString() ) ? Qt::Checked : Qt::Unchecked );
152 else if ( mComboBox )
154 mComboBox->setCurrentIndex( mComboBox->findData( value ) );
167 int ki = layer->
fieldNameIndex( config.value(
"Key" ).toString() );
168 int vi = layer->
fieldNameIndex( config.value(
"Value" ).toString() );
171 if ( !config.value(
"FilterExpression" ).toString().isEmpty() )
173 e =
new QgsExpression( config.value(
"FilterExpression" ).toString() );
178 if ( ki >= 0 && vi >= 0 )
180 QSet<int> attributes;
181 attributes << ki << vi;
185 bool requiresAllAttributes =
false;
195 requiresAllAttributes =
true;
206 if ( !requiresAllAttributes )
216 if ( e && !e->
evaluate( &f ).toBool() )
225 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.
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.
QVariant evaluate(const QgsFeature *f=NULL)
Evaluate the feature and return the result.
bool prepare(const QgsFields &fields)
Get the expression ready for evaluation - find out column indexes.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
static QgsMapLayerRegistry * instance()
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
static const QString AllAttributes
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QgsMapLayer * mapLayer(QString theLayerId)
Retrieve a pointer to a loaded layer by id.
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
bool nextFeature(QgsFeature &f)
Geometry is not required. It may still be returned if e.g. required for a filter condition.
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.
QgsFeatureRequest & setFlags(Flags flags)
Set flags that affect how features will be fetched.