Skip to content

Commit 33b6c41

Browse files
authoredApr 18, 2017
Merge pull request #4357 from nyalldawson/composer_layer_ref
Use weak layer references and loose matching for composer legend customisation
2 parents 302e9dd + 3535ee2 commit 33b6c41

33 files changed

+709
-316
lines changed
 

‎python/auto_sip.blacklist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,6 @@ core/fieldformatter/qgsrelationreferencefieldformatter.sip
217217
core/fieldformatter/qgsvaluemapfieldformatter.sip
218218
core/fieldformatter/qgsvaluerelationfieldformatter.sip
219219
core/layertree/qgslayertree.sip
220-
core/layertree/qgslayertreegroup.sip
221-
core/layertree/qgslayertreelayer.sip
222220
core/layertree/qgslayertreemodel.sip
223221
core/layertree/qgslayertreemodellegendnode.sip
224222
core/layertree/qgslayertreenode.sip

‎python/core/annotations/qgshtmlannotation.sip

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class QgsHtmlAnnotation: QgsAnnotation
3131

3232
~QgsHtmlAnnotation();
3333

34-
QSizeF minimumFrameSize() const;
34+
virtual QSizeF minimumFrameSize() const;
3535

3636
void setSourceFile( const QString &htmlFile );
3737
%Docstring
@@ -49,7 +49,7 @@ class QgsHtmlAnnotation: QgsAnnotation
4949
virtual void writeXml( QDomElement &elem, QDomDocument &doc ) const;
5050
virtual void readXml( const QDomElement &itemElem, const QDomDocument &doc );
5151

52-
void setAssociatedFeature( const QgsFeature &feature );
52+
virtual void setAssociatedFeature( const QgsFeature &feature );
5353

5454
static QgsHtmlAnnotation *create() /Factory/;
5555
%Docstring
@@ -59,7 +59,7 @@ class QgsHtmlAnnotation: QgsAnnotation
5959

6060
protected:
6161

62-
void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;
62+
virtual void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;
6363

6464
};
6565

‎python/core/annotations/qgssvgannotation.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class QgsSvgAnnotation: QgsAnnotation
5050

5151
protected:
5252

53-
void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;
53+
virtual void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;
5454

5555
};
5656

‎python/core/annotations/qgstextannotation.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class QgsTextAnnotation: QgsAnnotation
5252

5353
protected:
5454

55-
void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;
55+
virtual void renderAnnotation( QgsRenderContext &context, QSizeF size ) const;
5656

5757
};
5858

Lines changed: 207 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,232 @@
1-
/**
2-
* Layer tree group node serves as a container for layers and further groups.
3-
*
4-
* Group names do not need to be unique within one tree nor within one parent.
5-
*
6-
* @note added in 2.4
7-
*/
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/layertree/qgslayertreegroup.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
812
class QgsLayerTreeGroup : QgsLayerTreeNode
913
{
10-
%TypeHeaderCode
11-
#include <qgslayertreegroup.h>
14+
%Docstring
15+
Layer tree group node serves as a container for layers and further groups.
16+
17+
Group names do not need to be unique within one tree nor within one parent.
18+
19+
.. versionadded:: 2.4
1220
%End
1321

22+
%TypeHeaderCode
23+
#include "qgslayertreegroup.h"
24+
%End
1425
public:
15-
QgsLayerTreeGroup( const QString& name = QString(), Qt::CheckState checked = Qt::Checked );
16-
17-
//! Get group's name
18-
QString name() const;
19-
//! Set group's name
20-
void setName( const QString& n );
21-
22-
//! Insert a new group node with given name at specified position. Newly created node is owned by this group.
23-
QgsLayerTreeGroup* insertGroup( int index, const QString& name );
24-
//! Append a new group node with given name. Newly created node is owned by this group.
25-
QgsLayerTreeGroup* addGroup( const QString& name );
26-
//! Insert a new layer node for given map layer at specified position. Newly created node is owned by this group.
27-
QgsLayerTreeLayer* insertLayer( int index, QgsMapLayer* layer );
28-
//! Append a new layer node for given map layer. Newly created node is owned by this group.
29-
QgsLayerTreeLayer* addLayer( QgsMapLayer* layer );
30-
31-
//! Insert existing nodes at specified position. The nodes must not have a parent yet. The nodes will be owned by this group.
32-
void insertChildNodes( int index, const QList<QgsLayerTreeNode*>& nodes /Transfer/ );
33-
//! Insert existing node at specified position. The node must not have a parent yet. The node will be owned by this group.
34-
void insertChildNode( int index, QgsLayerTreeNode* node /Transfer/ );
35-
//! Append an existing node. The node must not have a parent yet. The node will be owned by this group.
36-
void addChildNode( QgsLayerTreeNode* node /Transfer/ );
37-
38-
//! Remove a child node from this group. The node will be deleted.
39-
void removeChildNode( QgsLayerTreeNode* node );
40-
//! Remove map layer's node from this group. The node will be deleted.
41-
void removeLayer( QgsMapLayer* layer );
42-
//! Remove child nodes from index "from". The nodes will be deleted.
26+
27+
QgsLayerTreeGroup( const QString &name = QString(), bool checked = true );
28+
%Docstring
29+
Constructor
30+
%End
31+
32+
33+
virtual QString name() const;
34+
%Docstring
35+
Returns the group's name.
36+
:rtype: str
37+
%End
38+
39+
virtual void setName( const QString &n );
40+
%Docstring
41+
Sets the group's name.
42+
%End
43+
44+
QgsLayerTreeGroup *insertGroup( int index, const QString &name );
45+
%Docstring
46+
Insert a new group node with given name at specified position. The newly created node is owned by this group.
47+
:rtype: QgsLayerTreeGroup
48+
%End
49+
50+
QgsLayerTreeGroup *addGroup( const QString &name );
51+
%Docstring
52+
Append a new group node with given name. Newly created node is owned by this group.
53+
:rtype: QgsLayerTreeGroup
54+
%End
55+
56+
QgsLayerTreeLayer *insertLayer( int index, QgsMapLayer *layer );
57+
%Docstring
58+
Insert a new layer node for given map layer at specified position. The newly created node is owned by this group.
59+
:rtype: QgsLayerTreeLayer
60+
%End
61+
62+
QgsLayerTreeLayer *addLayer( QgsMapLayer *layer );
63+
%Docstring
64+
Append a new layer node for given map layer. The newly created node is owned by this group.
65+
:rtype: QgsLayerTreeLayer
66+
%End
67+
68+
void insertChildNodes( int index, const QList<QgsLayerTreeNode *> &nodes /Transfer/ );
69+
%Docstring
70+
Insert existing nodes at specified position. The nodes must not have a parent yet. The nodes will be owned by this group.
71+
%End
72+
73+
void insertChildNode( int index, QgsLayerTreeNode *node /Transfer/ );
74+
%Docstring
75+
Insert existing node at specified position. The node must not have a parent yet. The node will be owned by this group.
76+
%End
77+
78+
void addChildNode( QgsLayerTreeNode *node /Transfer/ );
79+
%Docstring
80+
Append an existing node. The node must not have a parent yet. The node will be owned by this group.
81+
%End
82+
83+
void removeChildNode( QgsLayerTreeNode *node );
84+
%Docstring
85+
Remove a child node from this group. The node will be deleted.
86+
%End
87+
88+
void removeLayer( QgsMapLayer *layer );
89+
%Docstring
90+
Remove map layer's node from this group. The node will be deleted.
91+
%End
92+
4393
void removeChildren( int from, int count );
44-
//! Remove all child group nodes without layers. The groupnodes will be deleted.
94+
%Docstring
95+
Remove child nodes from index "from". The nodes will be deleted.
96+
%End
97+
4598
void removeChildrenGroupWithoutLayers();
46-
//! Remove all child nodes. The nodes will be deleted.
99+
%Docstring
100+
Remove all child group nodes without layers. The groupnodes will be deleted.
101+
%End
102+
47103
void removeAllChildren();
104+
%Docstring
105+
Remove all child nodes. The nodes will be deleted.
106+
%End
107+
108+
QgsLayerTreeLayer *findLayer( QgsMapLayer *layer ) const;
109+
%Docstring
110+
Find layer node representing the map layer. Searches recursively the whole sub-tree.
111+
.. versionadded:: 3.0
112+
:rtype: QgsLayerTreeLayer
113+
%End
114+
115+
QgsLayerTreeLayer *findLayer( const QString &layerId ) const;
116+
%Docstring
117+
Find layer node representing the map layer specified by its ID. Searches recursively the whole sub-tree.
118+
:rtype: QgsLayerTreeLayer
119+
%End
120+
121+
QList<QgsLayerTreeLayer *> findLayers() const;
122+
%Docstring
123+
Find all layer nodes. Searches recursively the whole sub-tree.
124+
:rtype: list of QgsLayerTreeLayer
125+
%End
48126

49-
//! Find layer node representing the map layer. Searches recursively the whole sub-tree.
50-
//! @note added in 3.0
51-
QgsLayerTreeLayer* findLayer( QgsMapLayer* layer ) const;
52-
//! Find layer node representing the map layer specified by its ID. Searches recursively the whole sub-tree.
53-
QgsLayerTreeLayer* findLayer( const QString& layerId );
54-
//! Find all layer nodes. Searches recursively the whole sub-tree.
55-
QList<QgsLayerTreeLayer*> findLayers() const;
56-
//! Find layer IDs used in all layer nodes. Searches recursively the whole sub-tree.
57127
QStringList findLayerIds() const;
58-
//! Find group node with specified name. Searches recursively the whole sub-tree.
59-
QgsLayerTreeGroup* findGroup( const QString& name );
60-
61-
//! Read group (tree) from XML element <layer-tree-group> and return the newly created group (or null on error).
62-
//! Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
63-
static QgsLayerTreeGroup* readXml( QDomElement& element ) /Factory/;
64-
//! Read group (tree) from XML element <layer-tree-group> and return the newly created group (or null on error).
65-
//! Also resolves textual references to layers from the project (calls resolveReferences() internally).
66-
//! @note added in 3.0
67-
static QgsLayerTreeGroup* readXml( QDomElement& element, const QgsProject* project ) /Factory/;
68-
69-
//! Write group (tree) as XML element <layer-tree-group> and add it to the given parent element
70-
virtual void writeXml( QDomElement& parentElement );
71-
//! Read children from XML and append them to the group.
72-
//! Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
73-
void readChildrenFromXml( QDomElement& element );
74-
75-
//! Return text representation of the tree. For debugging purposes only.
128+
%Docstring
129+
Find layer IDs used in all layer nodes. Searches recursively the whole sub-tree.
130+
:rtype: list of str
131+
%End
132+
133+
QgsLayerTreeGroup *findGroup( const QString &name );
134+
%Docstring
135+
Find group node with specified name. Searches recursively the whole sub-tree.
136+
:rtype: QgsLayerTreeGroup
137+
%End
138+
139+
static QgsLayerTreeGroup *readXml( QDomElement &element ) /Factory/;
140+
%Docstring
141+
Read group (tree) from XML element <layer-tree-group> and return the newly created group (or null on error).
142+
Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
143+
:rtype: QgsLayerTreeGroup
144+
%End
145+
146+
static QgsLayerTreeGroup *readXml( QDomElement &element, const QgsProject *project ) /Factory/;
147+
%Docstring
148+
Read group (tree) from XML element <layer-tree-group> and return the newly created group (or null on error).
149+
Also resolves textual references to layers from the project (calls resolveReferences() internally).
150+
.. versionadded:: 3.0
151+
:rtype: QgsLayerTreeGroup
152+
%End
153+
154+
virtual void writeXml( QDomElement &parentElement );
155+
%Docstring
156+
Write group (tree) as XML element <layer-tree-group> and add it to the given parent element
157+
%End
158+
159+
void readChildrenFromXml( QDomElement &element );
160+
%Docstring
161+
Read children from XML and append them to the group.
162+
Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
163+
%End
164+
76165
virtual QString dump() const;
166+
%Docstring
167+
Return text representation of the tree. For debugging purposes only.
168+
:rtype: str
169+
%End
77170

78-
//! Return a clone of the group. The children are cloned too.
79-
virtual QgsLayerTreeGroup* clone() const /Factory/;
171+
virtual QgsLayerTreeGroup *clone() const /Factory/;
172+
%Docstring
173+
Return a clone of the group. The children are cloned too.
174+
:rtype: QgsLayerTreeGroup
175+
%End
80176

81-
//! Calls resolveReferences() on child tree nodes
82-
//! @note added in 3.0
83-
virtual void resolveReferences( const QgsProject* project );
177+
virtual void resolveReferences( const QgsProject *project, bool looseMatching = false );
178+
%Docstring
179+
Calls resolveReferences() on child tree nodes
180+
.. versionadded:: 3.0
181+
%End
182+
183+
virtual void setItemVisibilityCheckedRecursive( bool checked );
184+
%Docstring
185+
Check or uncheck a node and all its children (taking into account exclusion rules)
186+
%End
84187

85-
//! Return whether the group is mutually exclusive (only one child can be checked at a time)
86-
//! @note added in 2.12
87188
bool isMutuallyExclusive() const;
88-
//! Set whether the group is mutually exclusive (only one child can be checked at a time).
89-
//! The initial child index determines which child should be initially checked. The default value
90-
//! of -1 will determine automatically (either first one currently checked or none)
91-
//! @note added in 2.12
189+
%Docstring
190+
Return whether the group is mutually exclusive (only one child can be checked at a time)
191+
.. versionadded:: 2.12
192+
:rtype: bool
193+
%End
194+
92195
void setIsMutuallyExclusive( bool enabled, int initialChildIndex = -1 );
196+
%Docstring
197+
Set whether the group is mutually exclusive (only one child can be checked at a time).
198+
The initial child index determines which child should be initially checked. The default value
199+
of -1 will determine automatically (either first one currently checked or none)
200+
.. versionadded:: 2.12
201+
%End
93202

94203
protected slots:
95-
void nodeVisibilityChanged( QgsLayerTreeNode* node );
204+
void nodeVisibilityChanged( QgsLayerTreeNode *node );
96205

97206
protected:
98207

99-
//! Set check state of children - if mutually exclusive
100208
void updateChildVisibilityMutuallyExclusive();
209+
%Docstring
210+
Set check state of children - if mutually exclusive
211+
%End
212+
213+
214+
215+
101216

102217
private:
103-
QgsLayerTreeGroup( const QgsLayerTreeGroup& other );
218+
219+
QgsLayerTreeGroup( const QgsLayerTreeGroup &other );
220+
%Docstring
221+
Copies are not allowed
222+
%End
104223
};
224+
225+
226+
/************************************************************************
227+
* This file has been generated automatically from *
228+
* *
229+
* src/core/layertree/qgslayertreegroup.h *
230+
* *
231+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
232+
************************************************************************/

0 commit comments

Comments
 (0)
Please sign in to comment.