55 mProject->
dirty(
true );
73 return mRelations.
value(
id );
86 return mRelations.
values();
97 bool containsField =
false;
102 containsField =
true;
107 if ( !containsField )
123 return mRelations.
values();
139 void QgsRelationManager::readProject(
const QDomDocument & doc )
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 )
168 QgsDebugMsg(
"Unable to find qgis element in project file" );
178 relation.
writeXML( relationsNode, doc );
182 void QgsRelationManager::layersRemoved(
const QStringList& layers )
184 bool relationsChanged =
false;
185 Q_FOREACH (
const QString& layer, layers )
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 )
bool isValid() const
Returns the validity of this relation.
QDomNode item(int index) const
QList< T > values() const
QDomNode appendChild(const QDomNode &newChild)
QgsVectorLayer * referencedLayer() const
Access the referenced (parent) layer.
static QgsRelation createFromXML(const QDomNode &node)
Creates a relation from an XML structure.
QDomNodeList childNodes() const
void writeXML(QDomNode &node, QDomDocument &doc) const
Writes a relation to an XML structure.
void clear()
Remove any relation managed by this class.
void setRelations(const QList< QgsRelation > &relations)
Will set the specified relations and remove any relation currently set.
QList< QgsRelation > referencedRelations(QgsVectorLayer *layer=0) const
Get all relations where this layer is the referenced part (i.e.
void append(const T &value)
const QMap< QString, QgsRelation > & relations() const
Get access to the relations managed by this class.
Defines a relation between matchin fields of the two involved tables of a relation.
QgsRelation relation(const QString &id) const
Get access to a relation by its id.
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 ...
QDomNodeList elementsByTagName(const QString &tagname) const
Reads and writes project states.
QList< QgsRelation > referencingRelations(QgsVectorLayer *layer=0, int fieldIdx=-2) const
Get all relations where the specified layer (and field) is the referencing part (i.e.
QgsRelationManager(QgsProject *project)
void relationsLoaded()
this signal is emitted when the relations were loaded after reading a 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.
void changed()
Emitted when relations are added or removed to the manager.
QList< FieldPair > fieldPairs() const
Returns the field pairs which form this relation The first element of each pair are the field names f...
iterator insert(const Key &key, const T &value)
void removeRelation(const QString &id)
Remove a relation.
QDomElement createElement(const QString &tagName)
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.
int fieldNameIndex(const QString &fieldName) const
Returns the index of a field name or -1 if the field does not exist.
QDomNode at(int index) const
const T value(const Key &key) const
int remove(const Key &key)
void addRelation(const QgsRelation &relation)
Add a relation.