25 #include <QStringListModel> 42 , mComboBox( nullptr )
43 , mListWidget( nullptr )
44 , mLineEdit( nullptr )
67 for (
int i = 0; i < mListWidget->
count(); ++i )
81 if ( i.second == mLineEdit->
text() )
94 if (
config(
"AllowMulti" ).toBool() )
98 else if (
config(
"UseCompleter" ).toBool() )
111 mComboBox = qobject_cast<
QComboBox*>( editor );
112 mListWidget = qobject_cast<
QListWidget*>( editor );
113 mLineEdit = qobject_cast<
QLineEdit*>( editor );
117 if (
config(
"AllowNull" ).toBool() )
124 mComboBox->
addItem( element.second, element.first );
129 else if ( mListWidget )
135 item->
setData( Qt::UserRole, element.first );
137 mListWidget->addItem( item );
141 else if ( mLineEdit )
152 mLineEdit->setCompleter( completer );
154 connect( mLineEdit, SIGNAL( textChanged(
QString ) ),
this, SLOT( onValueChanged() ) );
160 return mListWidget || mLineEdit || mComboBox;
169 for (
int i = 0; i < mListWidget->
count(); ++i )
175 else if ( mComboBox )
179 else if ( mLineEdit )
183 if ( i.first == value )
185 mLineEdit->
setText( i.second );
202 int ki = layer->
fieldNameIndex( config.value(
"Key" ).toString() );
203 int vi = layer->
fieldNameIndex( config.value(
"Value" ).toString() );
209 if ( !config.value(
"FilterExpression" ).toString().isEmpty() )
222 if ( config.value(
"OrderByValue" ).toBool() )
239 for (
int i = 0; i < mListWidget->
count(); ++i )
245 else if ( mComboBox )
249 else if ( mLineEdit )
257 if ( mEnabled == enabled )
264 for (
int i = 0; i < mListWidget->
count(); ++i )
Wrapper for iterator of features from vector data provider or vector layer.
void setCaseSensitivity(Qt::CaseSensitivity caseSensitivity)
QString & append(QChar ch)
void append(const T &value)
QgsMapLayer * mapLayer(const QString &theLayerId) const
Retrieve a pointer to a registered layer by layer ID.
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
QString & prepend(QChar ch)
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
bool contains(const QString &str, Qt::CaseSensitivity cs) const
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QString join(const QString &separator) const
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QString & remove(int position, int n)
QString tr(const char *sourceText, const char *disambiguation, int n)
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second.
void addItem(const QString &text, const QVariant &userData)
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
QVariantMap QgsEditorWidgetConfig
Holds a set of configuration parameters for a editor widget wrapper.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QList< int > QgsAttributeList
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
QgsFeatureRequest & setFlags(const QgsFeatureRequest::Flags &flags)
Set flags that affect how features will be fetched.
QVariant itemData(int index, int role) const
bool blockSignals(bool block)
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
int findData(const QVariant &data, int role, QFlags< Qt::MatchFlag > flags) const
bool nextFeature(QgsFeature &f)
Geometry is not required. It may still be returned if e.g. required for a filter condition.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Represents a vector layer which manages a vector based data sets.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
int fieldNameIndex(const QString &fieldName) const
Returns the index of a field name or -1 if the field does not exist.