QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
qgsrelationmanager.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsrelationmanager.h
3 --------------------------------------
4 Date : 1.3.2013
5 Copyright : (C) 2013 Matthias Kuhn
6 Email : matthias at opengis dot ch
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSRELATIONMANAGER_H
17#define QGSRELATIONMANAGER_H
18
19#include "qgis_core.h"
20#include <QObject>
21#include <QPair>
22#include <QDomNode>
23#include <QDomDocument>
24
25#include "qgsrelation.h"
27
28class QgsProject;
29class QgsVectorLayer;
30
35class CORE_EXPORT QgsRelationManager : public QObject
36{
37 Q_OBJECT
38
39 public:
40
45 explicit QgsRelationManager( QgsProject *project = nullptr );
46
50 QgsRelationContext context() const;
51
57 void setRelations( const QList<QgsRelation> &relations );
58
64 QMap<QString, QgsRelation> relations() const;
65
73 void addRelation( const QgsRelation &relation );
74
80 void removeRelation( const QString &id );
81
87 void removeRelation( const QgsRelation &relation );
88
97 Q_INVOKABLE QgsRelation relation( const QString &id ) const;
98
105 QList<QgsRelation> relationsByName( const QString &name ) const;
106
110 void clear();
111
120 QList<QgsRelation> referencingRelations( const QgsVectorLayer *layer = nullptr, int fieldIdx = -2 ) const;
121
129 QList<QgsRelation> referencedRelations( const QgsVectorLayer *layer = nullptr ) const;
130
138 static QList<QgsRelation> discoverRelations( const QList<QgsRelation> &existingRelations, const QList<QgsVectorLayer *> &layers );
139
143 QMap<QString, QgsPolymorphicRelation> polymorphicRelations() const;
144
148 QgsPolymorphicRelation polymorphicRelation( const QString &polymorphicRelationId ) const;
149
153 void addPolymorphicRelation( const QgsPolymorphicRelation &polymorphicRelation );
154
158 void removePolymorphicRelation( const QString &polymorphicRelationId );
159
164 void setPolymorphicRelations( const QList<QgsPolymorphicRelation> &relations );
165
166 signals:
169
173 void changed();
174
175 public slots:
176
180 void updateRelationsStatus();
181
182 private slots:
183 void readProject( const QDomDocument &doc, QgsReadWriteContext &context );
184 void writeProject( QDomDocument &doc );
185 void layersRemoved( const QStringList &layers );
186
187 private:
189 QMap<QString, QgsRelation> mRelations;
190 QMap<QString, QgsPolymorphicRelation> mPolymorphicRelations;
191
192 QgsProject *mProject = nullptr;
193};
194
195#endif // QGSRELATIONMANAGER_H
A polymorphic relation consists of the same properties like a normal relation except for the referenc...
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
The class is used as a container of context for various read/write operations on other objects.
Context for relations.
This class manages a set of relations between layers.
void changed()
Emitted when relations are added or removed to the manager.
void relationsLoaded()
Emitted when the relations were loaded after reading a project.
Represents a relationship between two vector layers.
Definition qgsrelation.h:44
Represents a vector layer which manages a vector based data sets.