E5Gui/E5TreeWidget.py

branch
Py2 comp.
changeset 2525
8b507a9a2d40
parent 2302
f29e9405c851
child 3057
10516539f238
equal deleted inserted replaced
2523:139f182b72f6 2525:8b507a9a2d40
4 # 4 #
5 5
6 """ 6 """
7 Module implementing specialized tree views. 7 Module implementing specialized tree views.
8 """ 8 """
9
10 from __future__ import unicode_literals # __IGNORE_WARNING__
9 11
10 from PyQt4.QtCore import pyqtSignal, Qt 12 from PyQt4.QtCore import pyqtSignal, Qt
11 from PyQt4.QtGui import QTreeWidget, QTreeWidgetItem, QAbstractItemView 13 from PyQt4.QtGui import QTreeWidget, QTreeWidgetItem, QAbstractItemView
12 14
13 15
30 """ 32 """
31 Constructor 33 Constructor
32 34
33 @param parent reference to the parent widget (QWidget) 35 @param parent reference to the parent widget (QWidget)
34 """ 36 """
35 super().__init__(parent) 37 super(E5TreeWidget, self).__init__(parent)
36 38
37 self.__refreshAllItemsNeeded = True 39 self.__refreshAllItemsNeeded = True
38 self.__allTreeItems = [] 40 self.__allTreeItems = []
39 self.__showMode = E5TreeWidget.ItemsCollapsed 41 self.__showMode = E5TreeWidget.ItemsCollapsed
40 42
124 Public method to add a top level item. 126 Public method to add a top level item.
125 127
126 @param item item to be added as a top level item (QTreeWidgetItem) 128 @param item item to be added as a top level item (QTreeWidgetItem)
127 """ 129 """
128 self.__allTreeItems.append(item) 130 self.__allTreeItems.append(item)
129 super().addTopLevelItem(item) 131 super(E5TreeWidget, self).addTopLevelItem(item)
130 132
131 def addTopLevelItems(self, items): 133 def addTopLevelItems(self, items):
132 """ 134 """
133 Public method to add a list of top level items. 135 Public method to add a list of top level items.
134 136
135 @param items items to be added as top level items (list of QTreeWidgetItem) 137 @param items items to be added as top level items (list of QTreeWidgetItem)
136 """ 138 """
137 self.__allTreeItems.extend(items) 139 self.__allTreeItems.extend(items)
138 super().addTopLevelItems(items) 140 super(E5TreeWidget, self).addTopLevelItems(items)
139 141
140 def insertTopLevelItem(self, index, item): 142 def insertTopLevelItem(self, index, item):
141 """ 143 """
142 Public method to insert a top level item. 144 Public method to insert a top level item.
143 145
144 @param index index for the insertion (integer) 146 @param index index for the insertion (integer)
145 @param item item to be inserted as a top level item (QTreeWidgetItem) 147 @param item item to be inserted as a top level item (QTreeWidgetItem)
146 """ 148 """
147 self.__allTreeItems.append(item) 149 self.__allTreeItems.append(item)
148 super().insertTopLevelItem(index, item) 150 super(E5TreeWidget, self).insertTopLevelItem(index, item)
149 151
150 def insertTopLevelItems(self, index, items): 152 def insertTopLevelItems(self, index, items):
151 """ 153 """
152 Public method to insert a list of top level items. 154 Public method to insert a list of top level items.
153 155
154 @param index index for the insertion (integer) 156 @param index index for the insertion (integer)
155 @param items items to be inserted as top level items (list of QTreeWidgetItem) 157 @param items items to be inserted as top level items (list of QTreeWidgetItem)
156 """ 158 """
157 self.__allTreeItems.extend(items) 159 self.__allTreeItems.extend(items)
158 super().insertTopLevelItems(index, items) 160 super(E5TreeWidget, self).insertTopLevelItems(index, items)
159 161
160 def deleteItem(self, item): 162 def deleteItem(self, item):
161 """ 163 """
162 Public method to delete an item. 164 Public method to delete an item.
163 165
223 def clear(self): 225 def clear(self):
224 """ 226 """
225 Public slot to clear the tree. 227 Public slot to clear the tree.
226 """ 228 """
227 self.__allTreeItems = [] 229 self.__allTreeItems = []
228 super().clear() 230 super(E5TreeWidget, self).clear()
229 231
230 def __scheduleRefresh(self): 232 def __scheduleRefresh(self):
231 """ 233 """
232 Private slot to schedule a refresh of the tree. 234 Private slot to schedule a refresh of the tree.
233 """ 235 """
245 return 247 return
246 elif evt.buttons() == Qt.MiddleButton: 248 elif evt.buttons() == Qt.MiddleButton:
247 self.itemMiddleButtonClicked.emit(self.itemAt(evt.pos())) 249 self.itemMiddleButtonClicked.emit(self.itemAt(evt.pos()))
248 return 250 return
249 else: 251 else:
250 super().mousePressEvent(evt) 252 super(E5TreeWidget, self).mousePressEvent(evt)
251 253
252 def __iterateAllItems(self, parent): 254 def __iterateAllItems(self, parent):
253 """ 255 """
254 Private method to iterate over the child items of the parent. 256 Private method to iterate over the child items of the parent.
255 257

eric ide

mercurial