26 , mMessageBar( messageBar )
51 cfg.insert(
"AllowNULL", configElement.
attribute(
"AllowNULL" ) ==
"1" );
52 cfg.insert(
"OrderByValue", configElement.
attribute(
"OrderByValue" ) ==
"1" );
53 cfg.insert(
"ShowForm", configElement.
attribute(
"ShowForm" ) ==
"1" );
54 cfg.insert(
"Relation", configElement.
attribute(
"Relation" ) );
55 cfg.insert(
"MapIdentification", configElement.
attribute(
"MapIdentification" ) ==
"1" );
56 cfg.insert(
"ReadOnly", configElement.
attribute(
"ReadOnly" ) ==
"1" );
57 cfg.insert(
"AllowAddFeatures", configElement.
attribute(
"AllowAddFeatures" ) ==
"1" );
60 if ( !filterNode.
isNull() )
65 for (
int i = 0; i < fieldNodes.
size(); i++ )
68 filterFields << fieldElement.
attribute(
"name" );
70 cfg.
insert(
"FilterFields", filterFields );
83 configElement.
setAttribute(
"AllowNULL", config[
"AllowNULL"].toBool() );
84 configElement.
setAttribute(
"OrderByValue", config[
"OrderByValue"].toBool() );
85 configElement.
setAttribute(
"ShowForm", config[
"ShowForm"].toBool() );
86 configElement.
setAttribute(
"Relation", config[
"Relation"].toString() );
87 configElement.
setAttribute(
"MapIdentification", config[
"MapIdentification"].toBool() );
88 configElement.
setAttribute(
"ReadOnly", config[
"ReadOnly"].toBool() );
89 configElement.
setAttribute(
"AllowAddFeatures", config[
"AllowAddFeatures"].toBool() );
91 if ( config.contains(
"FilterFields" ) )
95 Q_FOREACH (
const QString& field, config[
"FilterFields"].toStringList() )
103 filterFields.
setAttribute(
"ChainFilters", config[
"ChainFilters"].toBool() );
110 map.
insert( QgsRelationReferenceWidget::staticMetaObject.className(), 10 );
119 if ( !config.contains(
"Relation" ) )
121 QgsDebugMsg(
"Missing Relation in configuration" );
131 if ( vl != referencingLayer )
133 QgsDebugMsg(
"representValue() with inconsistent vl parameter w.r.t relation referencingLayer" );
137 if ( referencingFieldIdx != fieldIdx )
139 QgsDebugMsg(
"representValue() with inconsistent fieldIdx parameter w.r.t relation referencingFieldIdx" );
143 if ( !referencedLayer )
152 attrs[ referencingFieldIdx ] = value;
165 context.setFeature( feature );
166 QString title = expr.evaluate( &context ).toString();
167 if ( expr.hasEvalError() )
bool isValid() const
Returns the validity of this feature.
Class for parsing and evaluation of expressions (formerly called "search strings").
virtual QgsEditorConfigWidget * configWidget(QgsVectorLayer *vl, int fieldIdx, QWidget *parent) const override
Override this in your implementation.
QDomNodeList elementsByTagName(const QString &tagname) const
bool isValid() const
Returns the validity of this relation.
QDomNode appendChild(const QDomNode &newChild)
QString attribute(const QString &name, const QString &defValue) const
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
A bar for displaying non-blocking messages to the user.
QgsSearchWidgetWrapper * createSearchWidget(QgsVectorLayer *vl, int fieldIdx, QWidget *parent) const override
By default a simple QgsFilterLineEdit is returned as search widget.
virtual void writeConfig(const QgsEditorWidgetConfig &config, QDomElement &configElement, QDomDocument &doc, const QgsVectorLayer *layer, int fieldIdx) override
Serialize your configuration and save it in a xml doc.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsRelationManager * relationManager() const
int count() const
Return number of items.
Map canvas is a class for displaying all GIS data types on a canvas.
QgsFields fields() const
Returns the list of fields of this layer.
QDomElement toElement() const
virtual QMap< const char *, int > supportedWidgetTypes() override
Returns a list of widget types which this editor widget supports.
QVariantMap QgsEditorWidgetConfig
Holds a set of configuration parameters for a editor widget wrapper.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
QgsFeatureRequest getReferencedFeatureRequest(const QgsAttributes &attributes) const
Creates a request to return the feature on the referenced (parent) layer which is referenced by the p...
QString & insert(int position, QChar ch)
virtual QString representValue(QgsVectorLayer *vl, int fieldIdx, const QgsEditorWidgetConfig &config, const QVariant &cache, const QVariant &value) const override
Create a pretty String representation of the value.
void setAttribute(const QString &name, const QString &value)
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
This class wraps a request for features to a vector layer (or directly its vector data provider)...
virtual QVariant sortValue(QgsVectorLayer *vl, int fieldIdx, const QgsEditorWidgetConfig &config, const QVariant &cache, const QVariant &value) const override
If the default sort order should be overwritten for this widget, you can transform the value in here...
QList< FieldPair > fieldPairs() const
Returns the field pairs which form this relation The first element of each pair are the field names o...
virtual QgsEditorWidgetConfig readConfig(const QDomElement &configElement, QgsVectorLayer *layer, int fieldIdx) override
Read the config from an XML file and map it to a proper QgsEditorWidgetConfig.
QgsVectorLayer * referencedLayer() const
Access the referenced (parent) layer.
QgsRelationReferenceFactory(const QString &name, QgsMapCanvas *canvas, QgsMessageBar *messageBar)
QgsVectorLayer * referencingLayer() const
Access the referencing (child) layer This is the layer which has the field(s) which point to another ...
static QgsProject * instance()
Returns the QgsProject singleton instance.
iterator insert(const Key &key, const T &value)
static QgsExpressionContextScope * projectScope()
Creates a new scope which contains variables and functions relating to the current QGIS project...
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
QDomElement createElement(const QString &tagName)
bool nextFeature(QgsFeature &f)
QgsRelation relation(const QString &id) const
Get access to a relation by its id.
QString displayExpression() const
Get the preview expression, used to create a human readable preview string.
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.
virtual QgsEditorWidgetWrapper * create(QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent) const override
Override this in your implementation.
QDomNode at(int index) const