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() )