mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
IGN:Tag release
This commit is contained in:
parent
e1bc54a782
commit
531413099d
@ -45,6 +45,7 @@ class TagTreeItem(object): # {{{
|
|||||||
parent=None, tooltip=None, category_key=None, temporary=False):
|
parent=None, tooltip=None, category_key=None, temporary=False):
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.children = []
|
self.children = []
|
||||||
|
self.blank = QIcon()
|
||||||
self.id_set = set()
|
self.id_set = set()
|
||||||
self.is_gst = False
|
self.is_gst = False
|
||||||
self.boxed = False
|
self.boxed = False
|
||||||
@ -1020,7 +1021,7 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
return NONE
|
return NONE
|
||||||
|
|
||||||
def flags(self, index, *args):
|
def flags(self, index, *args):
|
||||||
ans = Qt.ItemIsEnabled|Qt.ItemIsSelectable|Qt.ItemIsEditable
|
ans = Qt.ItemIsEnabled|Qt.ItemIsEditable
|
||||||
if index.isValid():
|
if index.isValid():
|
||||||
node = self.data(index, Qt.UserRole)
|
node = self.data(index, Qt.UserRole)
|
||||||
if node.type == TagTreeItem.TAG:
|
if node.type == TagTreeItem.TAG:
|
||||||
|
@ -11,8 +11,8 @@ import cPickle
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
from itertools import izip
|
from itertools import izip
|
||||||
|
|
||||||
from PyQt4.Qt import (QItemDelegate, Qt, QTreeView, pyqtSignal, QSize, QIcon,
|
from PyQt4.Qt import (QStyledItemDelegate, Qt, QTreeView, pyqtSignal, QSize,
|
||||||
QApplication, QMenu, QPoint, QModelIndex, QToolTip, QCursor)
|
QIcon, QApplication, QMenu, QPoint, QModelIndex, QToolTip, QCursor)
|
||||||
|
|
||||||
from calibre.gui2.tag_browser.model import (TagTreeItem, TAG_SEARCH_STATES,
|
from calibre.gui2.tag_browser.model import (TagTreeItem, TAG_SEARCH_STATES,
|
||||||
TagsModel)
|
TagsModel)
|
||||||
@ -20,37 +20,32 @@ from calibre.gui2 import config, gprefs
|
|||||||
from calibre.utils.search_query_parser import saved_searches
|
from calibre.utils.search_query_parser import saved_searches
|
||||||
from calibre.utils.icu import sort_key
|
from calibre.utils.icu import sort_key
|
||||||
|
|
||||||
class TagDelegate(QItemDelegate): # {{{
|
class TagDelegate(QStyledItemDelegate): # {{{
|
||||||
|
|
||||||
def paint(self, painter, option, index):
|
def paint(self, painter, option, index):
|
||||||
item = index.data(Qt.UserRole).toPyObject()
|
item = index.data(Qt.UserRole).toPyObject()
|
||||||
|
QStyledItemDelegate.paint(self, painter, option, index)
|
||||||
if item.type != TagTreeItem.TAG:
|
if item.type != TagTreeItem.TAG:
|
||||||
QItemDelegate.paint(self, painter, option, index)
|
|
||||||
return
|
return
|
||||||
r = option.rect
|
if (item.tag.state == 0 and config['show_avg_rating'] and
|
||||||
model = self.parent().model()
|
item.tag.avg_rating is not None):
|
||||||
icon = model.data(index, Qt.DecorationRole).toPyObject()
|
self.initStyleOption(option, index)
|
||||||
painter.save()
|
widget = self.parent()
|
||||||
if item.tag.state != 0 or not config['show_avg_rating'] or \
|
style = QApplication.style() if widget is None else widget.style()
|
||||||
item.tag.avg_rating is None:
|
r = style.subElementRect(style.SE_ItemViewItemDecoration,
|
||||||
icon.paint(painter, r, Qt.AlignLeft)
|
option, widget)
|
||||||
else:
|
icon = option.icon
|
||||||
|
painter.save()
|
||||||
|
painter.setClipRect(r)
|
||||||
painter.setOpacity(0.3)
|
painter.setOpacity(0.3)
|
||||||
icon.paint(painter, r, Qt.AlignLeft)
|
icon.paint(painter, r, option.decorationAlignment, icon.Normal,
|
||||||
|
icon.On)
|
||||||
painter.setOpacity(1)
|
painter.setOpacity(1)
|
||||||
rating = item.tag.avg_rating
|
rating = item.tag.avg_rating
|
||||||
painter.setClipRect(r.left(), r.bottom()-int(r.height()*(rating/5.0)),
|
painter.setClipRect(r.left(), r.bottom()-int(r.height()*(rating/5.0)),
|
||||||
r.width(), r.height())
|
r.width(), r.height())
|
||||||
icon.paint(painter, r, Qt.AlignLeft)
|
icon.paint(painter, r, Qt.AlignLeft)
|
||||||
painter.setClipRect(r)
|
painter.restore()
|
||||||
|
|
||||||
# Paint the text
|
|
||||||
if item.boxed:
|
|
||||||
painter.drawRoundedRect(r.adjusted(1,1,-1,-1), 5, 5)
|
|
||||||
r.setLeft(r.left()+r.height()+3)
|
|
||||||
painter.drawText(r, Qt.AlignLeft|Qt.AlignVCenter,
|
|
||||||
model.data(index, Qt.DisplayRole).toString())
|
|
||||||
painter.restore()
|
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
@ -79,9 +74,8 @@ class TagsView(QTreeView): # {{{
|
|||||||
self.disable_recounting = False
|
self.disable_recounting = False
|
||||||
self.setUniformRowHeights(True)
|
self.setUniformRowHeights(True)
|
||||||
self.setCursor(Qt.PointingHandCursor)
|
self.setCursor(Qt.PointingHandCursor)
|
||||||
self.setIconSize(QSize(30, 30))
|
self.setIconSize(QSize(20, 20))
|
||||||
self.setTabKeyNavigation(True)
|
self.setTabKeyNavigation(True)
|
||||||
self.setAlternatingRowColors(True)
|
|
||||||
self.setAnimated(True)
|
self.setAnimated(True)
|
||||||
self.setHeaderHidden(True)
|
self.setHeaderHidden(True)
|
||||||
self.setItemDelegate(TagDelegate(self))
|
self.setItemDelegate(TagDelegate(self))
|
||||||
@ -106,6 +100,24 @@ class TagsView(QTreeView): # {{{
|
|||||||
self._model.user_categories_edited.connect(self.user_categories_edited,
|
self._model.user_categories_edited.connect(self.user_categories_edited,
|
||||||
type=Qt.QueuedConnection)
|
type=Qt.QueuedConnection)
|
||||||
self._model.drag_drop_finished.connect(self.drag_drop_finished)
|
self._model.drag_drop_finished.connect(self.drag_drop_finished)
|
||||||
|
self.setStyleSheet('''
|
||||||
|
QTreeView {
|
||||||
|
background-color: palette(window);
|
||||||
|
color: palette(text);
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTreeView::item {
|
||||||
|
border: none;
|
||||||
|
padding-top:1ex;
|
||||||
|
padding-bottom:1ex;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTreeView::item:hover {
|
||||||
|
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);
|
||||||
|
border: 1px solid #bfcde4;
|
||||||
|
}
|
||||||
|
''')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hidden_categories(self):
|
def hidden_categories(self):
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user