Skip to content

Commit 468c784

Browse files
committedApr 18, 2017
sipify QgsLayerTreeGroup
1 parent 0b36ee3 commit 468c784

File tree

3 files changed

+336
-127
lines changed

3 files changed

+336
-127
lines changed
 

‎python/auto_sip.blacklist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ core/fieldformatter/qgsrelationreferencefieldformatter.sip
218218
core/fieldformatter/qgsvaluemapfieldformatter.sip
219219
core/fieldformatter/qgsvaluerelationfieldformatter.sip
220220
core/layertree/qgslayertree.sip
221-
core/layertree/qgslayertreegroup.sip
222221
core/layertree/qgslayertreelayer.sip
223222
core/layertree/qgslayertreemodel.sip
224223
core/layertree/qgslayertreemodellegendnode.sip
Lines changed: 197 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,227 @@
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 );
1626

17-
//! Get group's name
27+
QgsLayerTreeGroup( const QString &name = QString(), bool checked = true );
28+
%Docstring
29+
Constructor
30+
%End
31+
32+
1833
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.
34+
%Docstring
35+
Returns the group's name.
36+
:rtype: str
37+
%End
38+
39+
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-
//! \since QGIS 3.0
83177
virtual void resolveReferences( const QgsProject *project, bool looseMatching = false );
178+
%Docstring
179+
Calls resolveReferences() on child tree nodes
180+
.. versionadded:: 3.0
181+
%End
84182

85-
//! Check or uncheck a node and all its children (taking into account exclusion rules)
86183
virtual void setItemVisibilityCheckedRecursive( bool checked );
184+
%Docstring
185+
Check or uncheck a node and all its children (taking into account exclusion rules)
186+
%End
87187

88-
//! Return whether the group is mutually exclusive (only one child can be checked at a time)
89-
//! @note added in 2.12
90188
bool isMutuallyExclusive() const;
91-
//! Set whether the group is mutually exclusive (only one child can be checked at a time).
92-
//! The initial child index determines which child should be initially checked. The default value
93-
//! of -1 will determine automatically (either first one currently checked or none)
94-
//! @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+
95195
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
96202

97203
protected slots:
98-
void nodeVisibilityChanged( QgsLayerTreeNode* node );
204+
void nodeVisibilityChanged( QgsLayerTreeNode *node );
99205

100206
protected:
101207

102-
//! Set check state of children - if mutually exclusive
103208
void updateChildVisibilityMutuallyExclusive();
209+
%Docstring
210+
Set check state of children - if mutually exclusive
211+
%End
212+
213+
214+
104215

105216
private:
106-
QgsLayerTreeGroup( const QgsLayerTreeGroup& other );
217+
QgsLayerTreeGroup( const QgsLayerTreeGroup &other );
107218
};
219+
220+
221+
/************************************************************************
222+
* This file has been generated automatically from *
223+
* *
224+
* src/core/layertree/qgslayertreegroup.h *
225+
* *
226+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
227+
************************************************************************/

‎src/core/layertree/qgslayertreegroup.h

Lines changed: 139 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define QGSLAYERTREEGROUP_H
1818

1919
#include "qgis_core.h"
20+
#include "qgis.h"
2021
#include "qgslayertreenode.h"
2122

2223
class QgsMapLayer;
@@ -33,99 +34,181 @@ class CORE_EXPORT QgsLayerTreeGroup : public QgsLayerTreeNode
3334
{
3435
Q_OBJECT
3536
public:
36-
//! Constructor
37+
38+
/**
39+
* Constructor
40+
*/
3741
QgsLayerTreeGroup( const QString &name = QString(), bool checked = true );
42+
43+
#ifndef SIP_RUN
3844
QgsLayerTreeGroup( const QgsLayerTreeGroup &other );
45+
#endif
3946

40-
//! Get group's name
47+
/**
48+
* Returns the group's name.
49+
*/
4150
QString name() const override;
42-
//! Set group's name
51+
52+
/**
53+
* Sets the group's name.
54+
*/
4355
void setName( const QString &n ) override;
4456

45-
//! Insert a new group node with given name at specified position. Newly created node is owned by this group.
57+
/**
58+
* Insert a new group node with given name at specified position. The newly created node is owned by this group.
59+
*/
4660
QgsLayerTreeGroup *insertGroup( int index, const QString &name );
47-
//! Append a new group node with given name. Newly created node is owned by this group.
61+
62+
/**
63+
* Append a new group node with given name. Newly created node is owned by this group.
64+
*/
4865
QgsLayerTreeGroup *addGroup( const QString &name );
49-
//! Insert a new layer node for given map layer at specified position. Newly created node is owned by this group.
66+
67+
/**
68+
* Insert a new layer node for given map layer at specified position. The newly created node is owned by this group.
69+
*/
5070
QgsLayerTreeLayer *insertLayer( int index, QgsMapLayer *layer );
51-
//! Append a new layer node for given map layer. Newly created node is owned by this group.
71+
72+
/**
73+
* Append a new layer node for given map layer. The newly created node is owned by this group.
74+
*/
5275
QgsLayerTreeLayer *addLayer( QgsMapLayer *layer );
5376

54-
//! Insert existing nodes at specified position. The nodes must not have a parent yet. The nodes will be owned by this group.
55-
void insertChildNodes( int index, const QList<QgsLayerTreeNode *> &nodes );
56-
//! Insert existing node at specified position. The node must not have a parent yet. The node will be owned by this group.
57-
void insertChildNode( int index, QgsLayerTreeNode *node );
58-
//! Append an existing node. The node must not have a parent yet. The node will be owned by this group.
59-
void addChildNode( QgsLayerTreeNode *node );
77+
/**
78+
* Insert existing nodes at specified position. The nodes must not have a parent yet. The nodes will be owned by this group.
79+
*/
80+
void insertChildNodes( int index, const QList<QgsLayerTreeNode *> &nodes SIP_TRANSFER );
6081

61-
//! Remove a child node from this group. The node will be deleted.
82+
/**
83+
* Insert existing node at specified position. The node must not have a parent yet. The node will be owned by this group.
84+
*/
85+
void insertChildNode( int index, QgsLayerTreeNode *node SIP_TRANSFER );
86+
87+
/**
88+
* Append an existing node. The node must not have a parent yet. The node will be owned by this group.
89+
*/
90+
void addChildNode( QgsLayerTreeNode *node SIP_TRANSFER );
91+
92+
/**
93+
* Remove a child node from this group. The node will be deleted.
94+
*/
6295
void removeChildNode( QgsLayerTreeNode *node );
63-
//! Remove map layer's node from this group. The node will be deleted.
96+
97+
/**
98+
* Remove map layer's node from this group. The node will be deleted.
99+
*/
64100
void removeLayer( QgsMapLayer *layer );
65-
//! Remove child nodes from index "from". The nodes will be deleted.
101+
102+
/**
103+
* Remove child nodes from index "from". The nodes will be deleted.
104+
*/
66105
void removeChildren( int from, int count );
67-
//! Remove all child group nodes without layers. The groupnodes will be deleted.
106+
107+
/**
108+
* Remove all child group nodes without layers. The groupnodes will be deleted.
109+
*/
68110
void removeChildrenGroupWithoutLayers();
69-
//! Remove all child nodes. The nodes will be deleted.
111+
112+
/**
113+
* Remove all child nodes. The nodes will be deleted.
114+
*/
70115
void removeAllChildren();
71116

72-
//! Find layer node representing the map layer. Searches recursively the whole sub-tree.
73-
//! \since QGIS 3.0
117+
/**
118+
* Find layer node representing the map layer. Searches recursively the whole sub-tree.
119+
* \since QGIS 3.0
120+
*/
74121
QgsLayerTreeLayer *findLayer( QgsMapLayer *layer ) const;
75-
//! Find layer node representing the map layer specified by its ID. Searches recursively the whole sub-tree.
122+
123+
/**
124+
* Find layer node representing the map layer specified by its ID. Searches recursively the whole sub-tree.
125+
*/
76126
QgsLayerTreeLayer *findLayer( const QString &layerId ) const;
77-
//! Find all layer nodes. Searches recursively the whole sub-tree.
127+
128+
/**
129+
* Find all layer nodes. Searches recursively the whole sub-tree.
130+
*/
78131
QList<QgsLayerTreeLayer *> findLayers() const;
79-
//! Find layer IDs used in all layer nodes. Searches recursively the whole sub-tree.
132+
133+
/**
134+
* Find layer IDs used in all layer nodes. Searches recursively the whole sub-tree.
135+
*/
80136
QStringList findLayerIds() const;
81-
//! Find group node with specified name. Searches recursively the whole sub-tree.
82-
QgsLayerTreeGroup *findGroup( const QString &name );
83137

84-
//! Read group (tree) from XML element <layer-tree-group> and return the newly created group (or null on error).
85-
//! Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
86-
static QgsLayerTreeGroup *readXml( QDomElement &element );
87-
//! Read group (tree) from XML element <layer-tree-group> and return the newly created group (or null on error).
88-
//! Also resolves textual references to layers from the project (calls resolveReferences() internally).
89-
//! \since QGIS 3.0
90-
static QgsLayerTreeGroup *readXml( QDomElement &element, const QgsProject *project );
138+
/**
139+
* Find group node with specified name. Searches recursively the whole sub-tree.
140+
*/
141+
QgsLayerTreeGroup *findGroup( const QString &name );
91142

92-
//! Write group (tree) as XML element <layer-tree-group> and add it to the given parent element
143+
/**
144+
* Read group (tree) from XML element <layer-tree-group> and return the newly created group (or null on error).
145+
* Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
146+
*/
147+
static QgsLayerTreeGroup *readXml( QDomElement &element ) SIP_FACTORY;
148+
149+
/**
150+
* Read group (tree) from XML element <layer-tree-group> and return the newly created group (or null on error).
151+
* Also resolves textual references to layers from the project (calls resolveReferences() internally).
152+
* \since QGIS 3.0
153+
*/
154+
static QgsLayerTreeGroup *readXml( QDomElement &element, const QgsProject *project ) SIP_FACTORY;
155+
156+
/**
157+
* Write group (tree) as XML element <layer-tree-group> and add it to the given parent element
158+
*/
93159
virtual void writeXml( QDomElement &parentElement ) override;
94-
//! Read children from XML and append them to the group.
95-
//! Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
160+
161+
/**
162+
* Read children from XML and append them to the group.
163+
* Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
164+
*/
96165
void readChildrenFromXml( QDomElement &element );
97166

98-
//! Return text representation of the tree. For debugging purposes only.
167+
/**
168+
* Return text representation of the tree. For debugging purposes only.
169+
*/
99170
virtual QString dump() const override;
100171

101-
//! Return a clone of the group. The children are cloned too.
102-
virtual QgsLayerTreeGroup *clone() const override;
172+
/**
173+
* Return a clone of the group. The children are cloned too.
174+
*/
175+
virtual QgsLayerTreeGroup *clone() const override SIP_FACTORY;
103176

104-
//! Calls resolveReferences() on child tree nodes
105-
//! \since QGIS 3.0
177+
/**
178+
* Calls resolveReferences() on child tree nodes
179+
* \since QGIS 3.0
180+
*/
106181
virtual void resolveReferences( const QgsProject *project, bool looseMatching = false ) override;
107182

108-
//! Check or uncheck a node and all its children (taking into account exclusion rules)
183+
/**
184+
* Check or uncheck a node and all its children (taking into account exclusion rules)
185+
*/
109186
virtual void setItemVisibilityCheckedRecursive( bool checked ) override;
110187

111-
//! Return whether the group is mutually exclusive (only one child can be checked at a time)
112-
//! \since QGIS 2.12
188+
/**
189+
* Return whether the group is mutually exclusive (only one child can be checked at a time)
190+
* \since QGIS 2.12
191+
*/
113192
bool isMutuallyExclusive() const;
114-
//! Set whether the group is mutually exclusive (only one child can be checked at a time).
115-
//! The initial child index determines which child should be initially checked. The default value
116-
//! of -1 will determine automatically (either first one currently checked or none)
117-
//! \since QGIS 2.12
193+
194+
/**
195+
* Set whether the group is mutually exclusive (only one child can be checked at a time).
196+
* The initial child index determines which child should be initially checked. The default value
197+
* of -1 will determine automatically (either first one currently checked or none)
198+
* \since QGIS 2.12
199+
*/
118200
void setIsMutuallyExclusive( bool enabled, int initialChildIndex = -1 );
119201

120202
protected slots:
121203
void nodeVisibilityChanged( QgsLayerTreeNode *node );
122204

123205
protected:
124206

125-
//! Set check state of children - if mutually exclusive
207+
/**
208+
* Set check state of children - if mutually exclusive
209+
*/
126210
void updateChildVisibilityMutuallyExclusive();
127211

128-
protected:
129212
QString mName;
130213

131214
bool mChangingChildVisibility;
@@ -135,6 +218,13 @@ class CORE_EXPORT QgsLayerTreeGroup : public QgsLayerTreeNode
135218
//! Keeps track which child has been most recently selected
136219
//! (so if the whole group is unchecked and checked again, we know which child to check)
137220
int mMutuallyExclusiveChildIndex;
221+
222+
private:
223+
224+
#ifdef SIP_RUN
225+
QgsLayerTreeGroup( const QgsLayerTreeGroup &other );
226+
#endif
227+
138228
};
139229

140230

0 commit comments

Comments
 (0)
Please sign in to comment.