28#include <QStringListModel>
30#include "moc_qgsvaluerelationsearchwidgetwrapper.cpp"
32using namespace Qt::StringLiterals;
56 int cbxIdx = mComboBox->currentIndex();
59 v = mComboBox->currentData();
65 const auto constMCache = mCache;
68 if ( i.value == mLineEdit->text() )
96 return fieldName +
" IS NULL";
98 return fieldName +
" IS NOT NULL";
100 QVariant v =
value();
104 switch ( v.userType() )
106 case QMetaType::Type::Int:
107 case QMetaType::Type::UInt:
108 case QMetaType::Type::Double:
109 case QMetaType::Type::LongLong:
110 case QMetaType::Type::ULongLong:
113 return fieldName +
'=' + v.toString();
115 return fieldName +
"<>" + v.toString();
122 return fieldName +
"='" + v.toString() +
'\'';
124 return fieldName +
"<>'" + v.toString() +
'\'';
136 mComboBox->setCurrentIndex( 0 );
140 mLineEdit->setText( QString() );
148 mComboBox->setEnabled( enabled );
152 mLineEdit->setEnabled( enabled );
163 QVariant vl =
value();
184 if ( exp == nullValue )
198 if (
config( u
"AllowMulti"_s ).toBool() )
202 else if (
config( u
"UseCompleter"_s ).toBool() )
208 QComboBox *combo =
new QComboBox( parent );
209 combo->setMinimumContentsLength( 1 );
210 combo->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
219 mComboBox = qobject_cast<QComboBox *>( editor );
220 mLineEdit = qobject_cast<QLineEdit *>( editor );
224 mComboBox->addItem( tr(
"Please Select" ), QVariant() );
225 if (
config( u
"AllowNull"_s ).toBool() )
230 const auto constMCache = mCache;
233 mComboBox->addItem( element.value, element.key );
238 else if ( mLineEdit )
241 values.reserve( mCache.size() );
247 QStringListModel *m =
new QStringListModel( values, mLineEdit );
248 QCompleter *completer =
new QCompleter( m, mLineEdit );
249 completer->setCaseSensitivity( Qt::CaseInsensitive );
250 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.