mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
31f109df7e
commit
292eaa393a
@ -58,13 +58,12 @@ class TagDelegate(QStyledItemDelegate): # {{{
|
|||||||
tr = style.subElementRect(style.SE_ItemViewItemText, option, widget)
|
tr = style.subElementRect(style.SE_ItemViewItemText, option, widget)
|
||||||
count = unicode(index.data(COUNT_ROLE))
|
count = unicode(index.data(COUNT_ROLE))
|
||||||
width = painter.fontMetrics().boundingRect(count).width()
|
width = painter.fontMetrics().boundingRect(count).width()
|
||||||
|
text = index.data(Qt.DisplayRole)
|
||||||
r = QRect(tr)
|
r = QRect(tr)
|
||||||
r.setRight(r.right() - 1)
|
r.setRight(r.right() - 1), r.setLeft(r.right() - width - 4)
|
||||||
r.setLeft(r.right() - width - 4)
|
|
||||||
painter.drawText(r, Qt.AlignCenter | Qt.TextSingleLine, count)
|
painter.drawText(r, Qt.AlignCenter | Qt.TextSingleLine, count)
|
||||||
tr.setRight(r.left() - 1)
|
tr.setRight(r.left() - 1)
|
||||||
flags = Qt.AlignVCenter | Qt.AlignLeft | Qt.TextSingleLine
|
flags = Qt.AlignVCenter | Qt.AlignLeft | Qt.TextSingleLine
|
||||||
text = index.data(Qt.DisplayRole)
|
|
||||||
lr = QRect(tr)
|
lr = QRect(tr)
|
||||||
lr.setRight(lr.right() * 2)
|
lr.setRight(lr.right() * 2)
|
||||||
br = painter.boundingRect(lr, flags, text)
|
br = painter.boundingRect(lr, flags, text)
|
||||||
@ -81,13 +80,15 @@ class TagDelegate(QStyledItemDelegate): # {{{
|
|||||||
painter.drawText(tr, flags, text)
|
painter.drawText(tr, flags, text)
|
||||||
|
|
||||||
def paint(self, painter, option, index):
|
def paint(self, painter, option, index):
|
||||||
item = index.data(Qt.UserRole)
|
|
||||||
QStyledItemDelegate.paint(self, painter, option, QModelIndex())
|
QStyledItemDelegate.paint(self, painter, option, QModelIndex())
|
||||||
widget = self.parent()
|
widget = self.parent()
|
||||||
style = QApplication.style() if widget is None else widget.style()
|
style = QApplication.style() if widget is None else widget.style()
|
||||||
self.initStyleOption(option, index)
|
self.initStyleOption(option, index)
|
||||||
|
item = index.data(Qt.UserRole)
|
||||||
self.draw_icon(style, painter, option, widget)
|
self.draw_icon(style, painter, option, widget)
|
||||||
|
painter.save()
|
||||||
self.draw_text(style, painter, option, widget, index, item)
|
self.draw_text(style, painter, option, widget, index, item)
|
||||||
|
painter.restore()
|
||||||
if item.boxed:
|
if item.boxed:
|
||||||
r = style.subElementRect(style.SE_ItemViewItemFocusRect, option,
|
r = style.subElementRect(style.SE_ItemViewItemFocusRect, option,
|
||||||
widget)
|
widget)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user