17#include "moc_qgsuniquevaluewidgetwrapper.cpp"
37 value = mComboBox->currentData();
44 value = mLineEdit->text();
52 if (
config( QStringLiteral(
"Editable" ) ).toBool() )
56 QComboBox *combo =
new QComboBox( parent );
57 combo->setMinimumContentsLength( 1 );
58 combo->setSizeAdjustPolicy( QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon );
65 mComboBox = qobject_cast<QComboBox *>( editor );
66 mLineEdit = qobject_cast<QLineEdit *>( editor );
72 const auto constValues = values;
73 for (
const QVariant &v : constValues )
77 mComboBox->addItem( v.toString(), v );
82 sValues << v.toString();
89 if ( fle && !(
field().type() == QMetaType::Type::Int ||
field().type() == QMetaType::Type::Double ||
field().type() == QMetaType::Type::LongLong ||
field().type() == QMetaType::Type::QDate ) )
94 QCompleter *
c =
new QCompleter( sValues );
95 c->setCaseSensitivity( Qt::CaseInsensitive );
96 c->setCompletionMode( QCompleter::PopupCompletion );
97 mLineEdit->setCompleter(
c );
99 connect( mLineEdit, &QLineEdit::textChanged,
this, [=](
const QString &
value ) {
115 return mComboBox || mLineEdit;
130void QgsUniqueValuesWidgetWrapper::updateValues(
const QVariant &value,
const QVariantList & )
134 mComboBox->setCurrentIndex( mComboBox->findData(
value ) );
142 mLineEdit->setText(
value.toString() );
static QString nullRepresentation()
Returns the string used to represent the value NULL throughout QGIS.
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
void setNullValue(const QString &nullValue)
Sets the string representation for null values in the widget.
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.
QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const FINAL
Calculates a list of unique values contained within an attribute in the layer.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
#define Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_PUSH
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.