28 connect( project, SIGNAL( readProject(
const QDomDocument& ) ), SLOT( readProject(
const QDomDocument& ) ) );
29 connect( project, SIGNAL( writeProject( QDomDocument& ) ), SLOT( writeProject( QDomDocument& ) ) );
55 mProject->
dirty(
true );
61 mRelations.remove(
id );
67 mRelations.remove( relation.
id() );
73 return mRelations.value(
id );
86 return mRelations.values();
97 bool containsField =
false;
102 containsField =
true;
107 if ( !containsField )
112 relations.append( rel );
123 return mRelations.values();
132 relations.append( rel );
139 void QgsRelationManager::readProject(
const QDomDocument & doc )
143 QDomNodeList nodes = doc.elementsByTagName(
"relations" );
146 QDomNode node = nodes.item( 0 );
147 QDomNodeList relationNodes = node.childNodes();
148 int relCount = relationNodes.count();
149 for (
int i = 0; i < relCount; ++i )
156 QgsDebugMsg(
"No relations data present in this document" );
163 void QgsRelationManager::writeProject( QDomDocument & doc )
165 QDomNodeList nl = doc.elementsByTagName(
"qgis" );
168 QgsDebugMsg(
"Unable to find qgis element in project file" );
171 QDomNode qgisNode = nl.item( 0 );
173 QDomElement relationsNode = doc.createElement(
"relations" );
174 qgisNode.appendChild( relationsNode );
178 relation.
writeXML( relationsNode, doc );
182 void QgsRelationManager::layersRemoved(
const QStringList& layers )
184 bool relationsChanged =
false;
185 Q_FOREACH (
const QString& layer, layers )
187 QMapIterator<QString, QgsRelation> it( mRelations );
189 while ( it.hasNext() )
193 if ( it.value().referencedLayerId() == layer
194 || it.value().referencingLayerId() == layer )
196 mRelations.remove( it.key() );
197 relationsChanged =
true;
201 if ( relationsChanged )