27#include <QStringListModel>
29#include "moc_qgsvaluerelationsearchwidgetwrapper.cpp"
53 int cbxIdx = mComboBox->currentIndex();
56 v = mComboBox->currentData();
62 const auto constMCache = mCache;
65 if ( i.value == mLineEdit->text() )
93 return fieldName +
" IS NULL";
95 return fieldName +
" IS NOT NULL";
101 switch ( v.userType() )
103 case QMetaType::Type::Int:
104 case QMetaType::Type::UInt:
105 case QMetaType::Type::Double:
106 case QMetaType::Type::LongLong:
107 case QMetaType::Type::ULongLong:
110 return fieldName +
'=' + v.toString();
112 return fieldName +
"<>" + v.toString();
119 return fieldName +
"='" + v.toString() +
'\'';
121 return fieldName +
"<>'" + v.toString() +
'\'';
133 mComboBox->setCurrentIndex( 0 );
137 mLineEdit->setText( QString() );
145 mComboBox->setEnabled( enabled );
149 mLineEdit->setEnabled( enabled );
160 QVariant vl =
value();
181 if ( exp == nullValue )
187 str = QStringLiteral(
"%1 = '%3'" )
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 dataset.