mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add tooltips to top-level categories in tags_view
This commit is contained in:
parent
0a16be06e8
commit
2f7408d5bc
@ -126,7 +126,7 @@ class TagTreeItem(object): # {{{
|
|||||||
TAG = 1
|
TAG = 1
|
||||||
ROOT = 2
|
ROOT = 2
|
||||||
|
|
||||||
def __init__(self, data=None, category_icon=None, icon_map=None, parent=None):
|
def __init__(self, data=None, category_icon=None, icon_map=None, parent=None, tooltip=None):
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.children = []
|
self.children = []
|
||||||
if self.parent is not None:
|
if self.parent is not None:
|
||||||
@ -144,6 +144,7 @@ class TagTreeItem(object): # {{{
|
|||||||
elif self.type == self.TAG:
|
elif self.type == self.TAG:
|
||||||
icon_map[0] = data.icon
|
icon_map[0] = data.icon
|
||||||
self.tag, self.icon_state_map = data, list(map(QVariant, icon_map))
|
self.tag, self.icon_state_map = data, list(map(QVariant, icon_map))
|
||||||
|
self.tooltip = tooltip
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.type == self.ROOT:
|
if self.type == self.ROOT:
|
||||||
@ -175,6 +176,8 @@ class TagTreeItem(object): # {{{
|
|||||||
return self.icon
|
return self.icon
|
||||||
if role == Qt.FontRole:
|
if role == Qt.FontRole:
|
||||||
return self.bold_font
|
return self.bold_font
|
||||||
|
if role == Qt.ToolTipRole and self.tooltip is not None:
|
||||||
|
return QVariant(self.tooltip)
|
||||||
return NONE
|
return NONE
|
||||||
|
|
||||||
def tag_data(self, role):
|
def tag_data(self, role):
|
||||||
@ -228,7 +231,8 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
for i, r in enumerate(self.row_map):
|
for i, r in enumerate(self.row_map):
|
||||||
c = TagTreeItem(parent=self.root_item,
|
c = TagTreeItem(parent=self.root_item,
|
||||||
data=self.categories[i],
|
data=self.categories[i],
|
||||||
category_icon=self.category_icon_map[r])
|
category_icon=self.category_icon_map[r],
|
||||||
|
tooltip=_('The lookup/search name is "{0}"').format(r))
|
||||||
for tag in data[r]:
|
for tag in data[r]:
|
||||||
TagTreeItem(parent=c, data=tag, icon_map=self.icon_state_map)
|
TagTreeItem(parent=c, data=tag, icon_map=self.icon_state_map)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user