QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 <QObject>
20 #include <QPair>
21 #include <QDomNode>
22 #include <QDomDocument>
23 
24 #include "qgsrelation.h"
25 
26 class QgsProject;
27 class QgsVectorLayer;
28 
32 class CORE_EXPORT QgsRelationManager : public QObject
33 {
34  Q_OBJECT
35 
36  public:
37 
41  explicit QgsRelationManager( QgsProject *project = nullptr );
42 
48  void setRelations( const QList<QgsRelation>& relations );
49 
55  const QMap<QString, QgsRelation>& relations() const;
56 
62  void addRelation( const QgsRelation& relation );
63 
69  void removeRelation( const QString& id );
70 
76  void removeRelation( const QgsRelation& relation );
77 
86  QgsRelation relation( const QString& id ) const;
87 
94  QList<QgsRelation> relationsByName( const QString& name ) const;
95 
99  void clear();
100 
109  QList<QgsRelation> referencingRelations( QgsVectorLayer *layer = nullptr, int fieldIdx = -2 ) const;
110 
118  QList<QgsRelation> referencedRelations( QgsVectorLayer *layer = nullptr ) const;
119 
120  signals:
122  void relationsLoaded();
123 
128  void changed();
129 
130  private slots:
131  void readProject( const QDomDocument &doc );
132  void writeProject( QDomDocument &doc );
133  void layersRemoved( const QStringList& layers );
134 
135  private:
137  QMap<QString, QgsRelation> mRelations;
138 
139  QgsProject* mProject;
140 };
141 
142 #endif // QGSRELATIONMANAGER_H
Reads and writes project states.
Definition: qgsproject.h:71
This class manages a set of relations between layers.
Represents a vector layer which manages a vector based data sets.