QGIS API Documentation  2.2.0-Valmiera
 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 
39  void setRelations( const QList<QgsRelation>& relations );
40  const QMap<QString, QgsRelation>& relations() const;
41  void addRelation( const QgsRelation& relation );
42  void removeRelation( const QString& name );
43  void removeRelation( const QgsRelation& relation );
44  QgsRelation relation( const QString& id ) const;
45  void clear();
46 
47  QList<QgsRelation> referencingRelations( QgsVectorLayer *layer = 0, int fieldIdx = -2 ) const;
48  QList<QgsRelation> referencedRelations( QgsVectorLayer *layer = 0 ) const;
49 
50  signals:
51  void relationsLoaded();
52 
53  public slots:
54 
55  private slots:
56  void readProject( const QDomDocument &doc );
57  void writeProject( QDomDocument &doc );
58 
59  private:
61  QMap<QString, QgsRelation> mRelations;
62 
64 };
65 
66 #endif // QGSRELATIONMANAGER_H