26#include <QStringListModel>
51 int cbxIdx = mComboBox->currentIndex();
54 v = mComboBox->currentData();
60 const auto constMCache = mCache;
63 if ( i.value == mLineEdit->text() )
91 return fieldName +
" IS NULL";
93 return fieldName +
" IS NOT NULL";
99 switch ( v.userType() )
101 case QMetaType::Type::Int:
102 case QMetaType::Type::UInt:
103 case QMetaType::Type::Double:
104 case QMetaType::Type::LongLong:
105 case QMetaType::Type::ULongLong:
108 return fieldName +
'=' + v.toString();
110 return fieldName +
"<>" + v.toString();
117 return fieldName +
"='" + v.toString() +
'\'';
119 return fieldName +
"<>'" + v.toString() +
'\'';
131 mComboBox->setCurrentIndex( 0 );
135 mLineEdit->setText( QString() );
143 mComboBox->setEnabled( enabled );
147 mLineEdit->setEnabled( enabled );
158 QVariant vl =
value();
179 if ( exp == nullValue )
185 str = QStringLiteral(
"%1 = '%3'" )
187 exp.replace(
'\'', QLatin1String(
"''" ) )
195 if (
config( QStringLiteral(
"AllowMulti" ) ).toBool() )
199 else if (
config( QStringLiteral(
"UseCompleter" ) ).toBool() )
205 QComboBox *combo =
new QComboBox( parent );
206 combo->setMinimumContentsLength( 1 );
207 combo->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
216 mComboBox = qobject_cast<QComboBox *>( editor );
217 mLineEdit = qobject_cast<QLineEdit *>( editor );
221 mComboBox->addItem( tr(
"Please Select" ), QVariant() );
222 if (
config( QStringLiteral(
"AllowNull" ) ).toBool() )
227 const auto constMCache = mCache;
230 mComboBox->addItem( element.value, element.key );
235 else if ( mLineEdit )
238 values.reserve( mCache.size() );
244 QStringListModel *m =
new QStringListModel( values, mLineEdit );
245 QCompleter *completer =
new QCompleter( m, mLineEdit );
246 completer->setCaseSensitivity( Qt::CaseInsensitive );
247 mLineEdit->setCompleter( completer );
static QString nullRepresentation()
Returns the string used to represent the value NULL throughout QGIS.
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
static QVariant createNullVariant(QMetaType::Type metaType)
Helper method to properly create a null QVariant from a metaType Returns the created QVariant.
Represents a vector layer which manages a vector based data sets.