From 58032f0f89cd62f11f9c7cb50e8de1a996cd0285 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 3 Sep 2015 09:22:49 +0530 Subject: [PATCH] Yet another fix for book list header rendering The row numbers were being elided on one users computer. Probably because I forgot to set the correct font metrics on the option object in the paint method. In any cases we dont actually want elision for headers. --- src/calibre/gui2/library/views.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py index 14fbcec5e7..7f35dcef0e 100644 --- a/src/calibre/gui2/library/views.py +++ b/src/calibre/gui2/library/views.py @@ -72,11 +72,16 @@ class HeaderView(QHeaderView): # {{{ opt.section = logical_index opt.orientation = self.orientation() opt.textAlignment = Qt.AlignHCenter | Qt.AlignVCenter + opt.fontMetrics = self.fm model = self.parent().model() - opt.text = unicode(model.headerData(logical_index, opt.orientation, Qt.DisplayRole) or '') + style = self.style() + margin = 2 * style.pixelMetric(style.PM_HeaderMargin, None, self) if self.isSortIndicatorShown() and self.sortIndicatorSection() == logical_index: opt.sortIndicator = QStyleOptionHeader.SortDown if self.sortIndicatorOrder() == Qt.AscendingOrder else QStyleOptionHeader.SortUp - opt.text = opt.fontMetrics.elidedText(opt.text, Qt.ElideRight, rect.width() - 4) + margin += style.pixelMetric(style.PM_HeaderMarkSize, None, self) + opt.text = unicode(model.headerData(logical_index, opt.orientation, Qt.DisplayRole) or '') + if self.textElideMode() != Qt.ElideNone: + opt.text = opt.fontMetrics.elidedText(opt.text, Qt.ElideRight, rect.width() - margin) if self.isEnabled(): opt.state |= QStyle.State_Enabled if self.window().isActiveWindow():