def __init__(self, tree): DefaultTreeDelegate.__init__(self, tree) self.imgs = ( appdata.resources.GetPixmap("cross_gray"), appdata.resources.GetPixmap("cross_red"), appdata.resources.GetPixmap("dot_gray"), appdata.resources.GetPixmap("dot_red"), )
def editorEvent(self, event, model, option, index): item = self.tree.itemFromIndex(index) if item.parent and item.IconStyle() != -1: if event.type() == QEvent.MouseMove: self.tree.viewport().repaint() if event.type() == QEvent.MouseButtonRelease or event.type( ) == QEvent.MouseButtonDblClick and event.button( ) == Qt.LeftButton: closeButtonRect = self.imgs[0].rect().translated( self.closeIconPos(option)) if closeButtonRect.contains(event.pos()): self.tree.itemFromIndex(index).Destroy() return True return DefaultTreeDelegate.editorEvent(self, event, model, option, index)
def editorEvent(self, event, model, option, index): item = self.tree.itemFromIndex(index) if item.parent and item.IconStyle() != -1: if event.type() == QEvent.MouseMove: self.tree.viewport().repaint() if ( event.type() == QEvent.MouseButtonRelease or event.type() == QEvent.MouseButtonDblClick and event.button() == Qt.LeftButton ): closeButtonRect = self.imgs[0].rect().translated(self.closeIconPos(option)) if closeButtonRect.contains(event.pos()): self.tree.itemFromIndex(index).Destroy() return True return DefaultTreeDelegate.editorEvent(self, event, model, option, index)
def __init__(self, tree): DefaultTreeDelegate.__init__(self, tree) self.imgs = (appdata.resources.GetPixmap("cross_gray"), appdata.resources.GetPixmap("cross_red"), appdata.resources.GetPixmap("dot_gray"), appdata.resources.GetPixmap("dot_red"))