25 #include <QStringListModel> 50 int cbxIdx = mComboBox->currentIndex();
53 v = mComboBox->currentData();
59 QStringList selection;
60 for (
int i = 0; i < mListWidget->count(); ++i )
62 QListWidgetItem *item = mListWidget->item( i );
63 if ( item->checkState() == Qt::Checked )
64 selection << item->data( Qt::UserRole ).toString();
67 v = selection.join( QStringLiteral(
"," ) ).prepend(
'{' ).append(
'}' );
74 if ( i.
value == mLineEdit->text() )
102 return fieldName +
" IS NULL";
104 return fieldName +
" IS NOT NULL";
106 QVariant v =
value();
114 case QVariant::Double:
115 case QVariant::LongLong:
116 case QVariant::ULongLong:
119 return fieldName +
'=' + v.toString();
121 return fieldName +
"<>" + v.toString();
128 return fieldName +
"='" + v.toString() +
'\'';
130 return fieldName +
"<>'" + v.toString() +
'\'';
142 mComboBox->setCurrentIndex( 0 );
146 mListWidget->clearSelection();
150 mLineEdit->setText( QString() );
158 mComboBox->setEnabled( enabled );
162 mListWidget->setEnabled( enabled );
166 mLineEdit->setEnabled( enabled );
177 QVariant vl =
value();
199 if ( exp == nullValue )
201 str = QStringLiteral(
"%1 IS NULL" ).arg( QgsExpression::quotedColumnRef( fieldName ) );
205 str = QStringLiteral(
"%1 = '%3'" )
206 .arg( QgsExpression::quotedColumnRef( fieldName ),
207 exp.replace(
'\'', QLatin1String(
"''" ) )
215 if (
config( QStringLiteral(
"AllowMulti" ) ).toBool() )
219 else if (
config( QStringLiteral(
"UseCompleter" ) ).toBool() )
225 return new QComboBox( parent );
233 mComboBox = qobject_cast<QComboBox *>( editor );
234 mListWidget = qobject_cast<QListWidget *>( editor );
235 mLineEdit = qobject_cast<QLineEdit *>( editor );
239 mComboBox->addItem( tr(
"Please select" ), QVariant() );
240 if (
config( QStringLiteral(
"AllowNull" ) ).toBool() )
242 mComboBox->addItem( tr(
"(no selection)" ), QVariant(
layer()->fields().at(
mFieldIdx ).type() ) );
247 mComboBox->addItem( element.
value, element.
key );
252 else if ( mListWidget )
256 QListWidgetItem *item =
nullptr;
257 item =
new QListWidgetItem( element.
value );
258 item->setData( Qt::UserRole, element.
key );
260 mListWidget->addItem( item );
264 else if ( mLineEdit )
267 values.reserve( mCache.size() );
273 QStringListModel *m =
new QStringListModel( values, mLineEdit );
274 QCompleter *completer =
new QCompleter( m, mLineEdit );
275 completer->setCaseSensitivity( Qt::CaseInsensitive );
276 mLineEdit->setCompleter( completer );
This class is a composition of two QSettings instances:
QgsField at(int i) const
Get field at particular index (must be in range 0..N-1)
QgsFields fields() const override
Returns the list of fields of this layer.
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
static QString nullRepresentation()
This string is used to represent the value NULL throughout QGIS.
Represents a vector layer which manages a vector based data sets.