28#include <QStringListModel>
30#include "moc_qgsvaluerelationsearchwidgetwrapper.cpp"
32using namespace Qt::StringLiterals;
55 int cbxIdx = mComboBox->currentIndex();
58 v = mComboBox->currentData();
64 const auto constMCache = mCache;
67 if ( i.value == mLineEdit->text() )
95 return fieldName +
" IS NULL";
97 return fieldName +
" IS NOT NULL";
103 switch ( v.userType() )
105 case QMetaType::Type::Int:
106 case QMetaType::Type::UInt:
107 case QMetaType::Type::Double:
108 case QMetaType::Type::LongLong:
109 case QMetaType::Type::ULongLong:
112 return fieldName +
'=' + v.toString();
114 return fieldName +
"<>" + v.toString();
121 return fieldName +
"='" + v.toString() +
'\'';
123 return fieldName +
"<>'" + v.toString() +
'\'';
135 mComboBox->setCurrentIndex( 0 );
139 mLineEdit->setText( QString() );
147 mComboBox->setEnabled( enabled );
151 mLineEdit->setEnabled( enabled );
162 QVariant vl =
value();
183 if ( exp == nullValue )
196 if (
config( u
"AllowMulti"_s ).toBool() )
200 else if (
config( u
"UseCompleter"_s ).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( u
"AllowNull"_s ).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 dataset.