mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Speedup startup by loading icons for news sources on demand. Fixes #5974 (use HEAD for cover check, fix conversion tooltip display, disable sorting of metadata display, fix ratings display)
This commit is contained in:
parent
4f87f15e4b
commit
d034426f10
@ -96,19 +96,21 @@ class NewsItem(NewsTreeItem):
|
|||||||
builtin, custom, scheduler_config, parent):
|
builtin, custom, scheduler_config, parent):
|
||||||
NewsTreeItem.__init__(self, builtin, custom, scheduler_config, parent)
|
NewsTreeItem.__init__(self, builtin, custom, scheduler_config, parent)
|
||||||
self.urn, self.title = urn, title
|
self.urn, self.title = urn, title
|
||||||
|
self.icon = self.default_icon = None
|
||||||
|
self.default_icon = default_icon
|
||||||
if 'custom:' in self.urn:
|
if 'custom:' in self.urn:
|
||||||
self.icon = custom_icon
|
self.icon = custom_icon
|
||||||
else:
|
|
||||||
icon = I('news/%s.png'%self.urn[8:])
|
|
||||||
if os.path.exists(icon):
|
|
||||||
self.icon = QVariant(QIcon(icon))
|
|
||||||
else:
|
|
||||||
self.icon = default_icon
|
|
||||||
|
|
||||||
def data(self, role):
|
def data(self, role):
|
||||||
if role == Qt.DisplayRole:
|
if role == Qt.DisplayRole:
|
||||||
return QVariant(self.title)
|
return QVariant(self.title)
|
||||||
if role == Qt.DecorationRole:
|
if role == Qt.DecorationRole:
|
||||||
|
if self.icon is None:
|
||||||
|
icon = I('news/%s.png'%self.urn[8:])
|
||||||
|
if os.path.exists(icon):
|
||||||
|
self.icon = QVariant(QIcon(icon))
|
||||||
|
else:
|
||||||
|
self.icon = self.default_icon
|
||||||
return self.icon
|
return self.icon
|
||||||
return NONE
|
return NONE
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user