74 return mRelations.
value(
id );
100 return mRelations.
values();
109 if ( fieldIdx != -2 )
111 bool containsField =
false;
116 containsField =
true;
121 if ( !containsField )
137 return mRelations.
values();
153 void QgsRelationManager::readProject(
const QDomDocument & doc )
162 int relCount = relationNodes.
count();
163 for (
int i = 0; i < relCount; ++i )
170 QgsDebugMsg(
"No relations data present in this document" );
177 void QgsRelationManager::writeProject(
QDomDocument & doc )
182 QgsDebugMsg(
"Unable to find qgis element in project file" );
192 relation.
writeXML( relationsNode, doc );
196 void QgsRelationManager::layersRemoved(
const QStringList& layers )
198 bool relationsChanged =
false;
199 Q_FOREACH (
const QString& layer, layers )
207 if ( it.
value().referencedLayerId() == layer
208 || it.
value().referencingLayerId() == layer )
211 relationsChanged =
true;
215 if ( relationsChanged )
void setDirty(bool b=true)
Flag the project as dirty (modified).
bool isValid() const
Returns the validity of this relation.
QDomNode item(int index) const
QList< T > values() const
QDomNode appendChild(const QDomNode &newChild)
void writeXML(QDomNode &node, QDomDocument &doc) const
Writes a relation to an XML structure.
static QgsRelation createFromXML(const QDomNode &node)
Creates a relation from an XML structure.
QDomNodeList childNodes() const
QString id() const
A (project-wide) unique id for this relation.
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.
const char * name() const
void append(const T &value)
QList< QgsRelation > referencingRelations(QgsVectorLayer *layer=nullptr, int fieldIdx=-2) const
Get all relations where the specified layer (and field) is the referencing part (i.e.
Defines a relation between matching fields of the two involved tables of a relation.
QList< QgsRelation > relationsByName(const QString &name) const
Returns a list of relations with matching names.
QDomNodeList elementsByTagName(const QString &tagname) const
Reads and writes project states.
QList< QgsRelation > referencedRelations(QgsVectorLayer *layer=nullptr) const
Get all relations where this layer is the referenced part (i.e.
const QMap< QString, QgsRelation > & relations() const
Get access to the relations managed by this class.
QList< FieldPair > fieldPairs() const
Returns the field pairs which form this relation The first element of each pair are the field names o...
QgsVectorLayer * referencedLayer() const
Access the referenced (parent) layer.
void relationsLoaded()
This signal is emitted when the relations were loaded after reading a project.
QgsVectorLayer * referencingLayer() const
Access the referencing (child) layer This is the layer which has the field(s) which point to another ...
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.
iterator insert(const Key &key, const T &value)
void removeRelation(const QString &id)
Remove a relation.
QDomElement createElement(const QString &tagName)
QgsRelationManager(QgsProject *project=nullptr)
Constructor for QgsRelationManager.
QgsRelation relation(const QString &id) const
Get access to a relation by its id.
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 compare(const QString &other) const
QString referencingField() const
Get the name of the referencing (child) field.
int fieldNameIndex(const QString &fieldName) const
Returns the index of a field name or -1 if the field does not exist.
QString name() const
Returns a human readable name for this relation.
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.