QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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
106 QList<QgsRelation> relationsByName( const QString &name ) const;
107
111 void clear();
112
121 QList<QgsRelation> referencingRelations( const QgsVectorLayer *layer = nullptr, int fieldIdx = -2 ) const;
122
130 QList<QgsRelation> referencedRelations( const QgsVectorLayer *layer = nullptr ) const;
131
140 static QList<QgsRelation> discoverRelations( const QList<QgsRelation> &existingRelations, const QList<QgsVectorLayer *> &layers );
141
145 QMap<QString, QgsPolymorphicRelation> polymorphicRelations() const;
146
150 QgsPolymorphicRelation polymorphicRelation( const QString &polymorphicRelationId ) const;
151
155 void addPolymorphicRelation( const QgsPolymorphicRelation &polymorphicRelation );
156
160 void removePolymorphicRelation( const QString &polymorphicRelationId );
161
166 void setPolymorphicRelations( const QList<QgsPolymorphicRelation> &relations );
167
168 signals:
171
176 void changed();
177
178 public slots:
179
183 void updateRelationsStatus();
184
185 private slots:
186 void readProject( const QDomDocument &doc, QgsReadWriteContext &context );
187 void writeProject( QDomDocument &doc );
188 void layersRemoved( const QStringList &layers );
189
190 private:
192 QMap<QString, QgsRelation> mRelations;
193 QMap<QString, QgsPolymorphicRelation> mPolymorphicRelations;
194
195 QgsProject *mProject = nullptr;
196};
197
198#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:104
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 vector layer which manages a vector based data sets.