mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 23:42:23 -04:00
added code to handle ToolTipRole in SidebarModel
This commit is contained in:
parent
a5f2a73a85
commit
e494441366
1 changed files with 4 additions and 1 deletions
|
@ -394,6 +394,7 @@ class SidebarItem:
|
||||||
self.expanded = expanded
|
self.expanded = expanded
|
||||||
self.children: List["SidebarItem"] = []
|
self.children: List["SidebarItem"] = []
|
||||||
self.parentItem: Optional[SidebarItem] = None
|
self.parentItem: Optional[SidebarItem] = None
|
||||||
|
self.tooltip = None
|
||||||
|
|
||||||
def addChild(self, cb: "SidebarItem") -> None:
|
def addChild(self, cb: "SidebarItem") -> None:
|
||||||
self.children.append(cb)
|
self.children.append(cb)
|
||||||
|
@ -457,13 +458,15 @@ class SidebarModel(QAbstractItemModel):
|
||||||
if not index.isValid():
|
if not index.isValid():
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
||||||
if role not in (Qt.DisplayRole, Qt.DecorationRole):
|
if role not in (Qt.DisplayRole, Qt.DecorationRole, Qt.ToolTipRole):
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
||||||
item: SidebarItem = index.internalPointer()
|
item: SidebarItem = index.internalPointer()
|
||||||
|
|
||||||
if role == Qt.DisplayRole:
|
if role == Qt.DisplayRole:
|
||||||
return QVariant(item.name)
|
return QVariant(item.name)
|
||||||
|
elif role == Qt.ToolTipRole:
|
||||||
|
return QVariant(item.tooltip)
|
||||||
else:
|
else:
|
||||||
return QVariant(self.iconFromRef(item.icon))
|
return QVariant(self.iconFromRef(item.icon))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue