75 |
77 |
76 def appendToParentItem(self, parent, item): |
78 def appendToParentItem(self, parent, item): |
77 """ |
79 """ |
78 Public method to append an item to a parent item. |
80 Public method to append an item to a parent item. |
79 |
81 |
80 @param parent text of the parent item (string) or |
82 @param parent text of the parent item or the parent item |
81 the parent item (QTreeWidgetItem) |
83 @type str or QTreeWidgetItem |
82 @param item item to be appended (QTreeWidgetItem) |
84 @param item item to be appended |
83 @return flag indicating success (boolean) |
85 @type QTreeWidgetItem |
|
86 @return flag indicating success |
|
87 @rtype bool |
84 @exception RuntimeError raised to indicate an illegal type for |
88 @exception RuntimeError raised to indicate an illegal type for |
85 the parent |
89 the parent |
86 """ |
90 """ |
87 if not isinstance(parent, (QTreeWidgetItem, str)): |
91 if not isinstance(parent, (QTreeWidgetItem, str)): |
88 raise RuntimeError("illegal type for parent") |
92 raise RuntimeError("illegal type for parent") |
105 |
109 |
106 def prependToParentItem(self, parent, item): |
110 def prependToParentItem(self, parent, item): |
107 """ |
111 """ |
108 Public method to prepend an item to a parent item. |
112 Public method to prepend an item to a parent item. |
109 |
113 |
110 @param parent text of the parent item (string) or |
114 @param parent text of the parent item or the parent item |
111 the parent item (QTreeWidgetItem) |
115 @type str or QTreeWidgetItem |
112 @param item item to be prepended (QTreeWidgetItem) |
116 @param item item to be prepended |
113 @return flag indicating success (boolean) |
117 @type QTreeWidgetItem |
|
118 @return flag indicating success |
|
119 @rtype bool |
114 @exception RuntimeError raised to indicate an illegal type for |
120 @exception RuntimeError raised to indicate an illegal type for |
115 the parent |
121 the parent |
116 """ |
122 """ |
117 if not isinstance(parent, (QTreeWidgetItem, str)): |
123 if not isinstance(parent, (QTreeWidgetItem, str)): |
118 raise RuntimeError("illegal type for parent") |
124 raise RuntimeError("illegal type for parent") |
135 |
141 |
136 def addTopLevelItem(self, item): |
142 def addTopLevelItem(self, item): |
137 """ |
143 """ |
138 Public method to add a top level item. |
144 Public method to add a top level item. |
139 |
145 |
140 @param item item to be added as a top level item (QTreeWidgetItem) |
146 @param item item to be added as a top level item |
|
147 @type QTreeWidgetItem |
141 """ |
148 """ |
142 self.__allTreeItems.append(item) |
149 self.__allTreeItems.append(item) |
143 super().addTopLevelItem(item) |
150 super().addTopLevelItem(item) |
144 |
151 |
145 def addTopLevelItems(self, items): |
152 def addTopLevelItems(self, items): |
146 """ |
153 """ |
147 Public method to add a list of top level items. |
154 Public method to add a list of top level items. |
148 |
155 |
149 @param items items to be added as top level items |
156 @param items items to be added as top level items |
150 (list of QTreeWidgetItem) |
157 @type list of QTreeWidgetItem |
151 """ |
158 """ |
152 self.__allTreeItems.extend(items) |
159 self.__allTreeItems.extend(items) |
153 super().addTopLevelItems(items) |
160 super().addTopLevelItems(items) |
154 |
161 |
155 def insertTopLevelItem(self, index, item): |
162 def insertTopLevelItem(self, index, item): |
156 """ |
163 """ |
157 Public method to insert a top level item. |
164 Public method to insert a top level item. |
158 |
165 |
159 @param index index for the insertion (integer) |
166 @param index index for the insertion |
160 @param item item to be inserted as a top level item (QTreeWidgetItem) |
167 @type int |
|
168 @param item item to be inserted as a top level item |
|
169 @type QTreeWidgetItem |
161 """ |
170 """ |
162 self.__allTreeItems.append(item) |
171 self.__allTreeItems.append(item) |
163 super().insertTopLevelItem(index, item) |
172 super().insertTopLevelItem(index, item) |
164 |
173 |
165 def insertTopLevelItems(self, index, items): |
174 def insertTopLevelItems(self, index, items): |
166 """ |
175 """ |
167 Public method to insert a list of top level items. |
176 Public method to insert a list of top level items. |
168 |
177 |
169 @param index index for the insertion (integer) |
178 @param index index for the insertion |
|
179 @type int |
170 @param items items to be inserted as top level items |
180 @param items items to be inserted as top level items |
171 (list of QTreeWidgetItem) |
181 @type list of QTreeWidgetItem |
172 """ |
182 """ |
173 self.__allTreeItems.extend(items) |
183 self.__allTreeItems.extend(items) |
174 super().insertTopLevelItems(index, items) |
184 super().insertTopLevelItems(index, items) |
175 |
185 |
176 def deleteItem(self, item): |
186 def deleteItem(self, item): |
177 """ |
187 """ |
178 Public method to delete an item. |
188 Public method to delete an item. |
179 |
189 |
180 @param item item to be deleted (QTreeWidgetItem) |
190 @param item item to be deleted |
|
191 @type QTreeWidgetItem |
181 """ |
192 """ |
182 if item in self.__allTreeItems: |
193 if item in self.__allTreeItems: |
183 self.__allTreeItems.remove(item) |
194 self.__allTreeItems.remove(item) |
184 |
195 |
185 self.__refreshAllItemsNeeded = True |
196 self.__refreshAllItemsNeeded = True |
188 |
199 |
189 def deleteItems(self, items): |
200 def deleteItems(self, items): |
190 """ |
201 """ |
191 Public method to delete a list of items. |
202 Public method to delete a list of items. |
192 |
203 |
193 @param items items to be deleted (list of QTreeWidgetItem) |
204 @param items items to be deleted |
|
205 @type list of QTreeWidgetItem |
194 """ |
206 """ |
195 for item in items: |
207 for item in items: |
196 self.deleteItem(item) |
208 self.deleteItem(item) |
197 |
209 |
198 def filterString(self, filterStr): |
210 def filterString(self, filterStr): |
199 """ |
211 """ |
200 Public slot to set a new filter. |
212 Public slot to set a new filter. |
201 |
213 |
202 @param filterStr filter to be set (string) |
214 @param filterStr filter to be set |
|
215 @type str |
203 """ |
216 """ |
204 self.expandAll() |
217 self.expandAll() |
205 allItems = self.allItems() |
218 allItems = self.allItems() |
206 |
219 |
207 if filterStr: |
220 if filterStr: |
267 |
281 |
268 def __iterateAllItems(self, parent): |
282 def __iterateAllItems(self, parent): |
269 """ |
283 """ |
270 Private method to iterate over the child items of the parent. |
284 Private method to iterate over the child items of the parent. |
271 |
285 |
272 @param parent parent item to iterate (QTreeWidgetItem) |
286 @param parent parent item to iterate |
|
287 @type QTreeWidgetItem |
273 """ |
288 """ |
274 count = parent.childCount() if parent else self.topLevelItemCount() |
289 count = parent.childCount() if parent else self.topLevelItemCount() |
275 |
290 |
276 for index in range(count): |
291 for index in range(count): |
277 itm = parent.child(index) if parent else self.topLevelItem(index) |
292 itm = parent.child(index) if parent else self.topLevelItem(index) |