@@ -79,73 +79,74 @@ class CORE_EXPORT QgsLayerTreeNode : public QObject
79
79
// ! Find out about type of the node. It is usually shorter to use convenience functions from QgsLayerTree namespace for that
80
80
NodeType nodeType () { return mNodeType ; }
81
81
// ! Get pointer to the parent. If parent is a null pointer, the node is a root node
82
- QgsLayerTreeNode* parent () { return mParent ; }
82
+ QgsLayerTreeNode * parent () { return mParent ; }
83
83
// ! Get list of children of the node. Children are owned by the parent
84
84
QList<QgsLayerTreeNode*> children () { return mChildren ; }
85
85
86
86
// ! Read layer tree from XML. Returns new instance
87
- static QgsLayerTreeNode* readXML ( QDomElement& element );
87
+ static QgsLayerTreeNode * readXML ( QDomElement & element );
88
88
// ! Write layer tree to XML
89
- virtual void writeXML ( QDomElement& parentElement ) = 0;
89
+ virtual void writeXML ( QDomElement & parentElement ) = 0;
90
90
91
91
// ! Return string with layer tree structure. For debug purposes only
92
92
virtual QString dump () const = 0;
93
93
94
94
// ! Create a copy of the node. Returns new instance
95
- virtual QgsLayerTreeNode* clone () const = 0;
95
+ virtual QgsLayerTreeNode * clone () const = 0;
96
96
97
97
// ! Return whether the node should be shown as expanded or collapsed in GUI
98
98
bool isExpanded () const ;
99
99
// ! Set whether the node should be shown as expanded or collapsed in GUI
100
100
void setExpanded ( bool expanded );
101
101
102
102
/* * Set a custom property for the node. Properties are stored in a map and saved in project file. */
103
- void setCustomProperty ( const QString& key, const QVariant& value );
103
+ void setCustomProperty ( const QString & key, const QVariant & value );
104
104
/* * Read a custom property from layer. Properties are stored in a map and saved in project file. */
105
- QVariant customProperty ( const QString& key, const QVariant& defaultValue = QVariant() ) const ;
105
+ QVariant customProperty ( const QString & key, const QVariant & defaultValue = QVariant() ) const ;
106
106
/* * Remove a custom property from layer. Properties are stored in a map and saved in project file. */
107
- void removeCustomProperty ( const QString& key );
107
+ void removeCustomProperty ( const QString & key );
108
108
/* * Return list of keys stored in custom properties */
109
109
QStringList customProperties () const ;
110
+ /* * Remove a child from a node */
111
+ bool takeChild ( QgsLayerTreeNode *node );
110
112
111
113
signals:
112
114
113
115
// ! Emitted when one or more nodes will be added to a node within the tree
114
- void willAddChildren ( QgsLayerTreeNode* node, int indexFrom, int indexTo );
116
+ void willAddChildren ( QgsLayerTreeNode * node, int indexFrom, int indexTo );
115
117
// ! Emitted when one or more nodes have been added to a node within the tree
116
- void addedChildren ( QgsLayerTreeNode* node, int indexFrom, int indexTo );
118
+ void addedChildren ( QgsLayerTreeNode * node, int indexFrom, int indexTo );
117
119
// ! Emitted when one or more nodes will be removed from a node within the tree
118
- void willRemoveChildren ( QgsLayerTreeNode* node, int indexFrom, int indexTo );
120
+ void willRemoveChildren ( QgsLayerTreeNode * node, int indexFrom, int indexTo );
119
121
// ! Emitted when one or more nodes has been removed from a node within the tree
120
- void removedChildren ( QgsLayerTreeNode* node, int indexFrom, int indexTo );
122
+ void removedChildren ( QgsLayerTreeNode * node, int indexFrom, int indexTo );
121
123
// ! Emitted when check state of a node within the tree has been changed
122
- void visibilityChanged ( QgsLayerTreeNode* node, Qt::CheckState state );
124
+ void visibilityChanged ( QgsLayerTreeNode * node, Qt::CheckState state );
123
125
// ! Emitted when a custom property of a node within the tree has been changed or removed
124
- void customPropertyChanged ( QgsLayerTreeNode* node, QString key );
126
+ void customPropertyChanged ( QgsLayerTreeNode * node, QString key );
125
127
// ! Emitted when the collapsed/expanded state of a node within the tree has been changed
126
- void expandedChanged ( QgsLayerTreeNode* node, bool expanded );
128
+ void expandedChanged ( QgsLayerTreeNode * node, bool expanded );
127
129
128
130
protected:
129
131
130
132
QgsLayerTreeNode ( NodeType t );
131
- QgsLayerTreeNode ( const QgsLayerTreeNode& other );
133
+ QgsLayerTreeNode ( const QgsLayerTreeNode & other );
132
134
133
135
// low-level utility functions
134
136
135
- void readCommonXML ( QDomElement& element );
136
- void writeCommonXML ( QDomElement& element );
137
+ void readCommonXML ( QDomElement & element );
138
+ void writeCommonXML ( QDomElement & element );
137
139
138
140
// ! Low-level insertion of children to the node. The children must not have any parent yet!
139
141
void insertChildrenPrivate ( int index, QList<QgsLayerTreeNode*> nodes );
140
142
// ! Low-level removal of children from the node.
141
- void removeChildrenPrivate ( int from, int count );
142
-
143
+ void removeChildrenPrivate ( int from, int count, bool destroy = true );
143
144
144
145
protected:
145
146
// ! type of the node - determines which subclass is used
146
147
NodeType mNodeType ;
147
148
// ! pointer to the parent node - null in case of root node
148
- QgsLayerTreeNode* mParent ;
149
+ QgsLayerTreeNode * mParent ;
149
150
// ! list of children - node is responsible for their deletion
150
151
QList<QgsLayerTreeNode*> mChildren ;
151
152
// ! whether the node should be shown in GUI as expanded
0 commit comments