QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 dot kuhn at gmx 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  explicit QgsRelationManager( QgsProject *project );
38 
44  void setRelations( const QList<QgsRelation>& relations );
45 
51  const QMap<QString, QgsRelation>& relations() const;
52 
58  void addRelation( const QgsRelation& relation );
59 
65  void removeRelation( const QString& id );
66 
72  void removeRelation( const QgsRelation& relation );
73 
81  QgsRelation relation( const QString& id ) const;
82 
86  void clear();
87 
96  QList<QgsRelation> referencingRelations( QgsVectorLayer *layer = 0, int fieldIdx = -2 ) const;
97 
105  QList<QgsRelation> referencedRelations( QgsVectorLayer *layer = 0 ) const;
106 
107  signals:
109  void relationsLoaded();
110 
115  void changed();
116 
117  private slots:
118  void readProject( const QDomDocument &doc );
119  void writeProject( QDomDocument &doc );
120  void layersRemoved( const QStringList& layers );
121 
122  private:
124  QMap<QString, QgsRelation> mRelations;
125 
126  QgsProject* mProject;
127 };
128 
129 #endif // QGSRELATIONMANAGER_H