mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-05 16:03:37 +02:00
Cleanup Tag browser text display
This commit is contained in:
parent
bb8bc9cea5
commit
82bb29424f
1 changed files with 7 additions and 11 deletions
|
|
@ -13,7 +13,7 @@
|
|||
from PyQt4.Qt import Qt, QTreeView, QApplication, pyqtSignal, QCheckBox, \
|
||||
QFont, QSize, QIcon, QPoint, QVBoxLayout, QComboBox, \
|
||||
QAbstractItemModel, QVariant, QModelIndex, QMenu, \
|
||||
QPushButton, QWidget, QItemDelegate, QString
|
||||
QPushButton, QWidget, QItemDelegate
|
||||
|
||||
from calibre.gui2 import config, NONE
|
||||
from calibre.utils.config import prefs
|
||||
|
|
@ -37,15 +37,15 @@ def paint(self, painter, option, index):
|
|||
QItemDelegate.paint(self, painter, option, index)
|
||||
return
|
||||
r = option.rect
|
||||
icon = self._parent.model().data(index, Qt.DecorationRole).toPyObject()
|
||||
model = self._parent.model()
|
||||
icon = model.data(index, Qt.DecorationRole).toPyObject()
|
||||
painter.save()
|
||||
if item.tag.state != 0 or not config['show_avg_rating']:
|
||||
if item.tag.state != 0 or not config['show_avg_rating'] or \
|
||||
item.tag.avg_rating is None:
|
||||
icon.paint(painter, r, Qt.AlignLeft)
|
||||
else:
|
||||
icon.paint(painter, r, Qt.AlignLeft, mode=QIcon.Disabled)
|
||||
rating = item.tag.avg_rating
|
||||
if rating is None:
|
||||
rating = 5.0
|
||||
painter.setClipRect(r.left(), r.bottom()-int(r.height()*(rating/5.0)),
|
||||
r.width(), r.height())
|
||||
icon.paint(painter, r, Qt.AlignLeft)
|
||||
|
|
@ -54,7 +54,7 @@ def paint(self, painter, option, index):
|
|||
# Paint the text
|
||||
r.setLeft(r.left()+r.height()+3)
|
||||
painter.drawText(r, Qt.AlignLeft|Qt.AlignVCenter,
|
||||
QString('[%d] %s'%(item.tag.count, item.tag.name)))
|
||||
model.data(index, Qt.DisplayRole).toString())
|
||||
painter.restore()
|
||||
|
||||
class TagsView(QTreeView): # {{{
|
||||
|
|
@ -345,11 +345,7 @@ def tag_data(self, role):
|
|||
if self.tag.count == 0:
|
||||
return QVariant('%s'%(self.tag.name))
|
||||
else:
|
||||
if self.tag.avg_rating is None:
|
||||
return QVariant('[%d] %s'%(self.tag.count, self.tag.name))
|
||||
else:
|
||||
return QVariant('[%d][%3.1f] %s'%(self.tag.count,
|
||||
self.tag.avg_rating, self.tag.name))
|
||||
return QVariant('[%d] %s'%(self.tag.count, self.tag.name))
|
||||
if role == Qt.EditRole:
|
||||
return QVariant(self.tag.name)
|
||||
if role == Qt.DecorationRole:
|
||||
|
|
|
|||
Loading…
Reference in a new issue