17#include "moc_qgsvaluerelationsearchwidgetwrapper.cpp"
27#include <QStringListModel>
52 int cbxIdx = mComboBox->currentIndex();
55 v = mComboBox->currentData();
61 const auto constMCache = mCache;
64 if ( i.value == mLineEdit->text() )
92 return fieldName +
" IS NULL";
94 return fieldName +
" IS NOT NULL";
100 switch ( v.userType() )
102 case QMetaType::Type::Int:
103 case QMetaType::Type::UInt:
104 case QMetaType::Type::Double:
105 case QMetaType::Type::LongLong:
106 case QMetaType::Type::ULongLong:
109 return fieldName +
'=' + v.toString();
111 return fieldName +
"<>" + v.toString();
118 return fieldName +
"='" + v.toString() +
'\'';
120 return fieldName +
"<>'" + v.toString() +
'\'';
132 mComboBox->setCurrentIndex( 0 );
136 mLineEdit->setText( QString() );
144 mComboBox->setEnabled( enabled );
148 mLineEdit->setEnabled( enabled );
159 QVariant vl =
value();
180 if ( exp == nullValue )
186 str = QStringLiteral(
"%1 = '%3'" )
194 if (
config( QStringLiteral(
"AllowMulti" ) ).toBool() )
198 else if (
config( QStringLiteral(
"UseCompleter" ) ).toBool() )
204 QComboBox *combo =
new QComboBox( parent );
205 combo->setMinimumContentsLength( 1 );
206 combo->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
215 mComboBox = qobject_cast<QComboBox *>( editor );
216 mLineEdit = qobject_cast<QLineEdit *>( editor );
220 mComboBox->addItem( tr(
"Please Select" ), QVariant() );
221 if (
config( QStringLiteral(
"AllowNull" ) ).toBool() )
226 const auto constMCache = mCache;
229 mComboBox->addItem( element.value, element.key );
234 else if ( mLineEdit )
237 values.reserve( mCache.size() );
243 QStringListModel *m =
new QStringListModel( values, mLineEdit );
244 QCompleter *completer =
new QCompleter( m, mLineEdit );
245 completer->setCaseSensitivity( Qt::CaseInsensitive );
246 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.