Skip to content

Commit 5c20f07

Browse files
committedAug 19, 2016
Cleanup QgsEditFormConfig
* It's now implicitly shared, meaning that changes to the config can be supervised and a signal is sent from QgsVectorLayer and there is no risk of elements suddenly being deleted. * Remove a bunch of methods that were in QgsVectorLayer for legacy reasons.
1 parent 54fb32d commit 5c20f07

40 files changed

+1313
-1017
lines changed
 

‎doc/api_break.dox

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ attributeIndexes(), pkAttributeIndexes(), isSaveAndLoadStyleToDBSupported()</li>
216216
</li>
217217
</ul>
218218

219+
\subsection qgis_api_break_3_0_QgsEditFormConfig QgsEditFormConfig
220+
221+
<ul>
222+
<li>Does no longer inherit QObject
223+
</ul>
224+
219225
\subsection qgis_api_break_3_0_Qgis Qgis
220226

221227
<ul>
@@ -867,6 +873,13 @@ displayExpression instead. For the map tip use mapTipTemplate() instead.</li>
867873
<li>applyNamedStyle() replaced by applyNamedStyle()
868874
<li>isReadOnly() use readOnly()
869875
<li>Signal changeAttributeValue()
876+
<li>Deleted GroupData (Use QgsEditFormConfig::GroupData)
877+
<li>Deleted TabData (Use QgsEditFormConfig::TabData)
878+
<li>Deleted EditorLayout (Use QgsEditFormConfig::EditorLayout)
879+
<li>Deleted ValueRelationData (Use QgsEditFormConfig::editorWidgetConfig)
880+
<li>Deleted attributeEditorElementFromDomElement
881+
<li>editFormConfig() returns a copy instead of direct access (Use setEditFormConfig to update)
882+
<li>Removed valueRelation(), replaced with QgsEditFormConfig::editorWidgetConfig
870883
</ul>
871884

872885
\subsection qgis_api_break_3_0_QgsVectorLayerEditBuffer QgsVectorLayerEditBuffer

‎python/core/core.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
%Include qgsactionmanager.sip
2525
%Include qgsaggregatecalculator.sip
2626
%Include qgsattributetableconfig.sip
27+
%Include qgsattributeeditorelement.sip
2728
%Include qgsbrowsermodel.sip
2829
%Include qgsclipper.sip
2930
%Include qgscolorscheme.sip
Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
/***************************************************************************
2+
qgsattributeeditorelement.sip - QgsAttributeEditorElement
3+
4+
---------------------
5+
begin : 18.8.2016
6+
copyright : (C) 2016 by Matthias Kuhn
7+
email : matthias@opengis.ch
8+
***************************************************************************
9+
* *
10+
* This program is free software; you can redistribute it and/or modify *
11+
* it under the terms of the GNU General Public License as published by *
12+
* the Free Software Foundation; either version 2 of the License, or *
13+
* (at your option) any later version. *
14+
* *
15+
***************************************************************************/
16+
17+
/** \ingroup core
18+
* This is an abstract base class for any elements of a drag and drop form.
19+
*
20+
* This can either be a container which will be represented on the screen
21+
* as a tab widget or ca collapsible group box. Or it can be a field which will
22+
* then be represented based on the QgsEditorWidget type and configuration.
23+
* Or it can be a relation and embed the form of several children of another
24+
* layer.
25+
*/
26+
27+
class QgsAttributeEditorElement
28+
{
29+
%TypeHeaderCode
30+
#include <qgsattributeeditorelement.h>
31+
%End
32+
33+
%ConvertToSubClassCode
34+
switch( sipCpp->type() )
35+
{
36+
case QgsAttributeEditorElement::AeTypeContainer:
37+
sipType = sipType_QgsAttributeEditorContainer;
38+
break;
39+
case QgsAttributeEditorElement::AeTypeField:
40+
sipType = sipType_QgsAttributeEditorField;
41+
break;
42+
case QgsAttributeEditorElement::AeTypeRelation:
43+
sipType = sipType_QgsAttributeEditorRelation;
44+
break;
45+
default:
46+
sipType = nullptr;
47+
break;
48+
}
49+
%End
50+
public:
51+
enum AttributeEditorType
52+
{
53+
AeTypeContainer, //!< A container
54+
AeTypeField, //!< A field
55+
AeTypeRelation, //!< A relation
56+
AeTypeInvalid //!< Invalid
57+
};
58+
59+
/**
60+
* Constructor
61+
*
62+
* @param type The type of the new element. Should never
63+
* @param name
64+
* @param parent
65+
*/
66+
QgsAttributeEditorElement( AttributeEditorType type, const QString& name, QgsAttributeEditorElement* parent = nullptr );
67+
68+
/**
69+
* Return the name of this element
70+
*
71+
* @return The name for this element
72+
*/
73+
QString name() const;
74+
75+
/**
76+
* The type of this element
77+
*
78+
* @return The type
79+
*/
80+
AttributeEditorType type();
81+
82+
/**
83+
* Get the parent of this element.
84+
*
85+
* @note Added in QGIS 3.0
86+
*/
87+
QgsAttributeEditorElement* parent() const;
88+
89+
/**
90+
* Is reimplemented in classes inheriting from this to serialize it.
91+
*
92+
* @param doc The QDomDocument which is used to create new XML elements
93+
*
94+
* @return An DOM element which represents this element
95+
*/
96+
virtual QDomElement toDomElement( QDomDocument& doc ) const = 0;
97+
98+
virtual QgsAttributeEditorElement* clone( QgsAttributeEditorElement* parent ) const = 0 /Factory/;
99+
};
100+
101+
102+
/** \ingroup core
103+
* This is a container for attribute editors, used to group them visually in the
104+
* attribute form if it is set to the drag and drop designer.
105+
*/
106+
class QgsAttributeEditorContainer : QgsAttributeEditorElement
107+
{
108+
%TypeHeaderCode
109+
#include <qgsattributeeditorelement.h>
110+
%End
111+
%ConvertToSubClassCode
112+
switch ( sipCpp->type() )
113+
{
114+
case QgsAttributeEditorElement::AeTypeContainer: sipType = sipType_QgsAttributeEditorContainer; break;
115+
case QgsAttributeEditorElement::AeTypeField: sipType = sipType_QgsAttributeEditorField; break;
116+
case QgsAttributeEditorElement::AeTypeRelation: sipType = sipType_QgsAttributeEditorRelation; break;
117+
}
118+
%End
119+
public:
120+
/**
121+
* Creates a new attribute editor container
122+
*
123+
* @param name The name to show as title
124+
* @param parent The parent. May be another container.
125+
*/
126+
QgsAttributeEditorContainer( const QString& name, QgsAttributeEditorElement* parent );
127+
128+
/**
129+
* Will serialize this containers information into a QDomElement for saving it in an XML file.
130+
*
131+
* @param doc The QDomDocument used to generate the QDomElement
132+
*
133+
* @return The XML element
134+
*/
135+
virtual QDomElement toDomElement( QDomDocument& doc ) const;
136+
137+
/**
138+
* Add a child element to this container. This may be another container, a field or a relation.
139+
*
140+
* @param element The element to add as child
141+
*/
142+
virtual void addChildElement( QgsAttributeEditorElement* element /Transfer/ );
143+
144+
/**
145+
* Determines if this container is rendered as collapsible group box or tab in a tabwidget
146+
*
147+
* @param isGroupBox If true, this will be a group box
148+
*/
149+
virtual void setIsGroupBox( bool isGroupBox );
150+
151+
/**
152+
* Returns if this container is going to be rendered as a group box
153+
*
154+
* @return True if it will be a group box, false if it will be a tab
155+
*/
156+
virtual bool isGroupBox() const;
157+
158+
/**
159+
* Get a list of the children elements of this container
160+
*
161+
* @return A list of elements
162+
*/
163+
QList<QgsAttributeEditorElement*> children() const;
164+
165+
/**
166+
* Traverses the element tree to find any element of the specified type
167+
*
168+
* @param type The type which should be searched
169+
*
170+
* @return A list of elements of the type which has been searched for
171+
*/
172+
virtual QList<QgsAttributeEditorElement*> findElements( AttributeEditorType type ) const;
173+
174+
/**
175+
* Clear all children from this container.
176+
*/
177+
void clear();
178+
179+
/**
180+
* Change the name of this container
181+
*/
182+
void setName( const QString& name );
183+
184+
/**
185+
* Get the number of columns in this group
186+
*/
187+
int columnCount() const;
188+
189+
/**
190+
* Set the number of columns in this group
191+
*/
192+
void setColumnCount( int columnCount );
193+
194+
/**
195+
* Creates a deep copy of this element. To be implemented by subclasses.
196+
*
197+
* @note Added in QGIS 3.0
198+
*/
199+
virtual QgsAttributeEditorElement* clone(QgsAttributeEditorElement* parent) const /Factory/;
200+
};
201+
202+
/** \ingroup core
203+
* This element will load a field's widget onto the form.
204+
*/
205+
class QgsAttributeEditorField : public QgsAttributeEditorElement
206+
{
207+
%TypeHeaderCode
208+
#include <qgsattributeeditorelement.h>
209+
%End
210+
public:
211+
/**
212+
* Creates a new attribute editor element which represents a field
213+
*
214+
* @param name The name of the element
215+
* @param idx The index of the field which should be embedded
216+
* @param parent The parent of this widget (used as container)
217+
*/
218+
QgsAttributeEditorField( const QString& name, int idx, QgsAttributeEditorElement *parent );
219+
220+
/**
221+
* Will serialize this elements information into a QDomElement for saving it in an XML file.
222+
*
223+
* @param doc The QDomDocument used to generate the QDomElement
224+
*
225+
* @return The XML element
226+
*/
227+
virtual QDomElement toDomElement( QDomDocument& doc ) const;
228+
229+
/**
230+
* Return the index of the field
231+
* @return
232+
*/
233+
int idx() const;
234+
235+
virtual QgsAttributeEditorElement* clone( QgsAttributeEditorElement* parent ) const /Factory/;
236+
};
237+
238+
/** \ingroup core
239+
* This element will load a relation editor onto the form.
240+
*/
241+
class QgsAttributeEditorRelation : QgsAttributeEditorElement
242+
{
243+
%TypeHeaderCode
244+
#include <qgsattributeeditorelement.h>
245+
%End
246+
public:
247+
/**
248+
* Creates a new element which embeds a relation.
249+
*
250+
* @param name The name of this element
251+
* @param relationId The id of the relation to embed
252+
* @param parent The parent (used as container)
253+
*/
254+
QgsAttributeEditorRelation( const QString& name, const QString &relationId, QgsAttributeEditorElement* parent );
255+
256+
/**
257+
* Creates a new element which embeds a relation.
258+
*
259+
* @param name The name of this element
260+
* @param relation The relation to embed
261+
* @param parent The parent (used as container)
262+
*/
263+
QgsAttributeEditorRelation( const QString& name, const QgsRelation& relation, QgsAttributeEditorElement* parent );
264+
265+
/**
266+
* Will serialize this elements information into a QDomElement for saving it in an XML file.
267+
*
268+
* @param doc The QDomDocument used to generate the QDomElement
269+
*
270+
* @return The XML element
271+
*/
272+
virtual QDomElement toDomElement( QDomDocument& doc ) const;
273+
274+
/**
275+
* Get the id of the relation which shall be embedded
276+
*
277+
* @return the id
278+
*/
279+
const QgsRelation& relation() const;
280+
281+
/**
282+
* Initializes the relation from the id
283+
*
284+
* @param relManager The relation manager to use for the initialization
285+
* @return true if the relation was found in the relationmanager
286+
*/
287+
bool init( QgsRelationManager* relManager );
288+
289+
virtual QgsAttributeEditorElement* clone(QgsAttributeEditorElement* parent) const /Factory/;
290+
};

0 commit comments

Comments
 (0)
Please sign in to comment.