Merge pull request #595 from campagnola/treewidget-one-root-item

Fix: make TreeWidget.invisibleRootItem return a singleton
This commit is contained in:
Luke Campagnola 2017-10-17 11:03:45 -07:00 committed by GitHub
commit 99363d0496

View File

@ -17,7 +17,11 @@ class TreeWidget(QtGui.QTreeWidget):
def __init__(self, parent=None):
QtGui.QTreeWidget.__init__(self, parent)
#self.itemWidgets = WeakKeyDictionary()
# wrap this item so that we can propagate tree change information
# to children.
self._invRootItem = InvisibleRootItem(QtGui.QTreeWidget.invisibleRootItem(self))
self.setAcceptDrops(True)
self.setDragEnabled(True)
self.setEditTriggers(QtGui.QAbstractItemView.EditKeyPressed|QtGui.QAbstractItemView.SelectedClicked)
@ -210,9 +214,7 @@ class TreeWidget(QtGui.QTreeWidget):
#self.informTreeWidgetChange(item)
def invisibleRootItem(self):
# wrap this item so that we can propagate tree change information
# to children.
return InvisibleRootItem(QtGui.QTreeWidget.invisibleRootItem(self))
return self._invRootItem
def itemFromIndex(self, index):
"""Return the item and column corresponding to a QModelIndex.