1 /***************************************************************************
2     qgsrelationadddlg.h
3     ---------------------
4     begin                : December 2015
5     copyright            : (C) 2015 by 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 #ifndef QGSRELATIONADDDLG_H
16 #define QGSRELATIONADDDLG_H
17 
18 #include <QDialog>
19 #include "qgis_app.h"
20 #include "ui_qgsrelationmanageradddialogbase.h"
21 #include "qgsrelation.h"
22 
23 class QDialogButtonBox;
24 class QComboBox;
25 class QLineEdit;
26 class QSpacerItem;
27 class QToolButton;
28 class QVBoxLayout;
29 class QHBoxLayout;
30 
31 class QgsVectorLayer;
32 class QgsFieldComboBox;
33 class QgsMapLayerComboBox;
34 
35 /**
36  * QgsRelationAddDlg allows configuring a new relation.
37  * Multiple field pairs can be set.
38  */
39 class APP_EXPORT QgsRelationAddDlg : public QDialog, private Ui::QgsRelationManagerAddDialogBase
40 {
41     Q_OBJECT
42 
43   public:
44     explicit QgsRelationAddDlg( QWidget *parent = nullptr );
45 
46     QString referencingLayerId();
47     QString referencedLayerId();
48     QList< QPair< QString, QString > > references();
49     QString relationId();
50     QString relationName();
51     QgsRelation::RelationStrength relationStrength();
52 
53   private slots:
54     void addFieldsRow();
55     void removeFieldsRow();
56     void updateFieldsMappingButtons();
57     void updateFieldsMappingHeaders();
58     void updateDialogButtons();
59     void updateChildRelationsComboBox();
60     void updateReferencedFieldsComboBoxes();
61     void updateReferencingFieldsComboBoxes();
62 
63   private:
64     bool isDefinitionValid();
65     void updateFieldsMapping();
66 
67     QgsMapLayerComboBox *mReferencedLayerCombobox = nullptr;
68     QgsMapLayerComboBox *mReferencingLayerCombobox = nullptr;
69 
70 };
71 
72 #endif // QGSRELATIONADDDLG_H
73