28 connect( project, SIGNAL(
readProject(
const QDomDocument& ) ), SLOT(
readProject(
const QDomDocument& ) ) );
92 bool containsField =
false;
102 if ( !containsField )
107 relations.append( rel );
127 relations.append( rel );
138 QDomNodeList nodes = doc.elementsByTagName(
"relations" );
141 QDomNode node = nodes.item( 0 );
142 QDomNodeList relationNodes = node.childNodes();
143 int relCount = relationNodes.count();
144 for (
int i = 0; i < relCount; ++i )
151 QgsDebugMsg(
"No relations data present in this document" );
159 QDomNodeList nl = doc.elementsByTagName(
"qgis" );
162 QgsDebugMsg(
"Unable to find qgis element in project file" );
165 QDomNode qgisNode = nl.item( 0 );
167 QDomElement relationsNode = doc.createElement(
"relations" );
168 qgisNode.appendChild( relationsNode );
172 relation.
writeXML( relationsNode, doc );
178 Q_FOREACH(
const QString& layer, layers )
180 QMapIterator<QString, QgsRelation> it(
mRelations );
182 while ( it.hasNext() )
186 if ( it.value().referencedLayerId() == layer
187 || it.value().referencingLayerId() == layer )
void readProject(const QDomDocument &doc)
bool isValid() const
Returns the validity of this relation.
QMap< QString, QgsRelation > mRelations
The references.
void layersRemoved(const QStringList &layers)
void removeRelation(const QString &name)
QgsVectorLayer * referencedLayer() const
Access the referenced (parent) layer.
static QgsRelation createFromXML(const QDomNode &node)
Creates a relation from an XML structure.
void writeXML(QDomNode &node, QDomDocument &doc) const
Writes a relation to an XML structure.
void setRelations(const QList< QgsRelation > &relations)
QList< QgsRelation > referencedRelations(QgsVectorLayer *layer=0) const
const QMap< QString, QgsRelation > & relations() const
Defines a relation between matchin fields of the two involved tables of a relation.
QgsRelation relation(const QString &id) const
const QString & id() const
The id.
QgsVectorLayer * referencingLayer() const
Access the referencing (child) layer This is the layer which has the field(s) which point to another ...
void writeProject(QDomDocument &doc)
Reads and writes project states.
QList< QgsRelation > referencingRelations(QgsVectorLayer *layer=0, int fieldIdx=-2) const
QgsRelationManager(QgsProject *project)
const QString & referencingField() const
Get the name of the referencing field.
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
QList< FieldPair > fieldPairs() const
Returns the field pairs which form this relation The first element of each pair are the field names f...
Represents a vector layer which manages a vector based data sets.
int fieldNameIndex(const QString &fieldName) const
Returns the index of a field name or -1 if the field does not exist.
void addRelation(const QgsRelation &relation)