QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Signals | Public Member Functions | List of all members
QgsRelationManager Class Reference

This class manages a set of relations between layers. More...

#include <qgsrelationmanager.h>

Signals

void relationsLoaded ()
 this signal is emitted when the relations were loaded after reading a project
void changed ()
 Emitted when relations are added or removed to the manager.

Public Member Functions

 QgsRelationManager (QgsProject *project)
void setRelations (const QList< QgsRelation > &relations)
 Will set the specified relations and remove any relation currently set.
const QMap< QString,
QgsRelation > & 
relations () const
 Get access to the relations managed by this class.
void addRelation (const QgsRelation &relation)
 Add a relation.
void removeRelation (const QString &id)
 Remove a relation.
void removeRelation (const QgsRelation &relation)
 Remove a relation.
QgsRelation relation (const QString &id) const
 Get access to a relation by its id.
void clear ()
 Remove any relation managed by this class.
QList< QgsRelationreferencingRelations (QgsVectorLayer *layer=0, int fieldIdx=-2) const
 Get all relations where the specified layer (and field) is the referencing part (i.e.
QList< QgsRelationreferencedRelations (QgsVectorLayer *layer=0) const
 Get all relations where this layer is the referenced part (i.e.

Detailed Description

This class manages a set of relations between layers.

Constructor & Destructor Documentation

QgsRelationManager::QgsRelationManager ( QgsProject project)
explicit

Member Function Documentation

void QgsRelationManager::addRelation ( const QgsRelation relation)

Add a relation.

Parameters
relationThe relation to add.
void QgsRelationManager::changed ( )
signal

Emitted when relations are added or removed to the manager.

Note
added in QGIS 2.5
void QgsRelationManager::clear ( )

Remove any relation managed by this class.

QList< QgsRelation > QgsRelationManager::referencedRelations ( QgsVectorLayer layer = 0) const

Get all relations where this layer is the referenced part (i.e.

the parent table with the primary key being referenced from another layer).

Parameters
layerThe layer which should be searched for.
Returns
A list of relations where the specified layer is the referenced part.
QList< QgsRelation > QgsRelationManager::referencingRelations ( QgsVectorLayer layer = 0,
int  fieldIdx = -2 
) const

Get all relations where the specified layer (and field) is the referencing part (i.e.

the child table with the foreign key).

Parameters
layerThe layer which should be searched for.
fieldIdxThe field which should be part of the foreign key. If not set will return all relations.
Returns
A list of relations matching the given layer and fieldIdx.
QgsRelation QgsRelationManager::relation ( const QString &  id) const

Get access to a relation by its id.

Parameters
idThe id to search for
Returns
A relation. Invalid if not found.
const QMap< QString, QgsRelation > & QgsRelationManager::relations ( ) const

Get access to the relations managed by this class.

Returns
A QMap where the key is the relation id, the value the relation object.
void QgsRelationManager::relationsLoaded ( )
signal

this signal is emitted when the relations were loaded after reading a project

void QgsRelationManager::removeRelation ( const QString &  id)

Remove a relation.

Parameters
idThe id of the relation to remove.
void QgsRelationManager::removeRelation ( const QgsRelation relation)

Remove a relation.

Parameters
relationThe relation to remove.
void QgsRelationManager::setRelations ( const QList< QgsRelation > &  relations)

Will set the specified relations and remove any relation currently set.

Parameters
relationsA list of relations to set.

The documentation for this class was generated from the following files: