QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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"
26 
27 class QgsProject;
28 class QgsVectorLayer;
29 
34 class CORE_EXPORT QgsRelationManager : public QObject
35 {
36  Q_OBJECT
37 
38  public:
39 
44  explicit QgsRelationManager( QgsProject *project = nullptr );
45 
49  QgsRelationContext context() const;
50 
56  void setRelations( const QList<QgsRelation> &relations );
57 
63  QMap<QString, QgsRelation> relations() const;
64 
72  void addRelation( const QgsRelation &relation );
73 
79  void removeRelation( const QString &id );
80 
86  void removeRelation( const QgsRelation &relation );
87 
96  Q_INVOKABLE QgsRelation relation( const QString &id ) const;
97 
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 
139  static QList<QgsRelation> discoverRelations( const QList<QgsRelation> &existingRelations, const QList<QgsVectorLayer *> &layers );
140 
141  signals:
143  void relationsLoaded();
144 
149  void changed();
150 
151  public slots:
152 
156  void updateRelationsStatus();
157 
158  private slots:
159  void readProject( const QDomDocument &doc, QgsReadWriteContext &context );
160  void writeProject( QDomDocument &doc );
161  void layersRemoved( const QStringList &layers );
162 
163  private:
165  QMap<QString, QgsRelation> mRelations;
166 
167  QgsProject *mProject = nullptr;
168 };
169 
170 #endif // QGSRELATIONMANAGER_H
QgsRelationManager
Definition: qgsrelationmanager.h:34
QgsReadWriteContext
Definition: qgsreadwritecontext.h:34
QgsProject
Definition: qgsproject.h:92
qgsrelation.h
QgsVectorLayer
Definition: qgsvectorlayer.h:385
QgsRelation
Definition: qgsrelation.h:41
QgsRelationContext
Definition: qgsrelationcontext.h:31