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'" )
188 exp.replace(
'\'', QLatin1String(
"''" ) )
196 if (
config( QStringLiteral(
"AllowMulti" ) ).toBool() )
200 else if (
config( QStringLiteral(
"UseCompleter" ) ).toBool() )
206 QComboBox *combo =
new QComboBox( parent );
207 combo->setMinimumContentsLength( 1 );
208 combo->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
217 mComboBox = qobject_cast<QComboBox *>( editor );
218 mLineEdit = qobject_cast<QLineEdit *>( editor );
222 mComboBox->addItem( tr(
"Please Select" ), QVariant() );
223 if (
config( QStringLiteral(
"AllowNull" ) ).toBool() )
228 const auto constMCache = mCache;
231 mComboBox->addItem( element.value, element.key );
236 else if ( mLineEdit )
239 values.reserve( mCache.size() );
245 QStringListModel *m =
new QStringListModel( values, mLineEdit );
246 QCompleter *completer =
new QCompleter( m, mLineEdit );
247 completer->setCaseSensitivity( Qt::CaseInsensitive );
248 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.