Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

htmllistview: use a more generic paint method

Changeset d029220e4b17

Parent 79a895eec57e

by Steve Borho

Changes to one file · Browse files at d029220e4b17 Showing diff from parent 79a895eec57e Diff from another changeset...

 
88
89
90
91
 
 
92
93
94
 
95
96
97
98
99
100
101
 
 
 
 
 
 
 
 
 
102
103
104
105
 
 
106
107
108
109
 
 
 
 
110
111
112
 
88
89
90
 
91
92
93
 
 
94
95
 
 
 
 
 
 
96
97
98
99
100
101
102
103
104
105
106
107
 
108
109
110
 
 
 
111
112
113
114
115
116
117
@@ -88,25 +88,30 @@
  QItemDelegate.__init__(self, parent)     def paint(self, painter, option, index): - options = QStyleOptionViewItemV4(option) + text = index.model().data(index, Qt.DisplayRole).toString() + palette = QApplication.palette()   doc = QTextDocument() - doc.setHtml(index.data().toString()) - + doc.setDefaultFont(option.font)   painter.save() - if options.widget: - options.widget.style().drawControl(QStyle.CE_ItemViewItem, - options, painter) - painter.translate(options.rect.left(), options.rect.top()) - clip = QRectF(0, 0, options.rect.width(), options.rect.height()) - doc.drawContents(painter, clip) + if option.state & QStyle.State_Selected: + doc.setHtml('<font color=%s>%s</font>' % ( + palette.highlightedText().color().name(), text)) + bgcolor = palette.highlight().color() + painter.fillRect(option.rect, bgcolor) + else: + doc.setHtml(text) + painter.translate(option.rect.left(), option.rect.top()) + doc.drawContents(painter)   painter.restore()     def sizeHint(self, option, index): - options = QStyleOptionViewItemV4(option) + fm = option.fontMetrics + text = index.model().data(index, Qt.DisplayRole).toString()   doc = QTextDocument() - doc.setHtml(index.data().toString()) - doc.setTextWidth(options.rect.width()) - return QSize(doc.idealWidth(), doc.size().height()) + doc.setDefaultFont(option.font) + doc.setHtml(text) + doc.setTextWidth(option.rect.width()) + return QSize(doc.idealWidth() + 5, doc.size().height())      if __name__ == "__main__":