24 : mReferencingLayer( NULL )
25 , mReferencedLayer( NULL )
32 QDomElement elem = node.toElement();
34 if ( elem.tagName() !=
"relation" )
36 QgsLogger::warning( QApplication::translate(
"QgsRelation",
"Cannot create relation. Unexpected tag '%1'" ).arg( elem.tagName() ) );
43 QString
id = elem.attribute(
"id" );
44 QString
name = elem.attribute(
"name" );
51 if ( NULL == referencingLayer )
53 QgsLogger::warning( QApplication::translate(
"QgsRelation",
"Relation defined for layer '%1' which does not exist." ).arg( referencingLayerId ) );
57 QgsLogger::warning( QApplication::translate(
"QgsRelation",
"Relation defined for layer '%1' which is not of type VectorLayer." ).arg( referencingLayerId ) );
60 if ( NULL == referencedLayer )
62 QgsLogger::warning( QApplication::translate(
"QgsRelation",
"Relation defined for layer '%1' which does not exist." ).arg( referencedLayerId ) );
66 QgsLogger::warning( QApplication::translate(
"QgsRelation",
"Relation defined for layer '%1' which is not of type VectorLayer." ).arg( referencedLayerId ) );
76 QDomNodeList references = elem.elementsByTagName(
"fieldRef" );
77 for (
int i = 0; i < references.size(); ++i )
79 QDomElement refEl = references.at( i ).toElement();
81 QString referencingField = refEl.attribute(
"referencingField" );
82 QString referencedField = refEl.attribute(
"referencedField" );
84 relation.
addFieldPair( referencingField, referencedField );
94 QDomElement elem = doc.createElement(
"relation" );
102 QDomElement referenceElem = doc.createElement(
"fieldRef" );
103 referenceElem.setAttribute(
"referencingField", fields.first );
104 referenceElem.setAttribute(
"referencedField", fields.second );
105 elem.appendChild( referenceElem );
108 node.appendChild( elem );
154 QStringList conditions;
161 switch ( referencingField.
type() )
163 case QVariant::String:
177 QgsDebugMsg( QString(
"Filter conditions: '%1'" ).arg( conditions.join(
" AND " ) ) );
247 || -1 == mReferencedLayer->fieldNameIndex( fieldPair.second ) )