FACT++  1.0
HtmlDelegate.cc
Go to the documentation of this file.
1 // **************************************************************************
7 // **************************************************************************
8 #include "HtmlDelegate.h"
9 
10 #include <QPainter>
11 #include <QTextDocument>
12 
13 void HtmlDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
14 {
15  QTextDocument doc;
16  doc.setPageSize(option.rect.size());
17  doc.setHtml(index.data().toString());
18 
19  // === This can be used if a scrolling is needed ===
20  // painter->save();
21  // painter->translate(option.rect.topLeft());
22  // QRect r(QPoint(0, 0), option.rect.size());
23  // doc.drawContents(painter, r);
24  // painter->restore();
25  // drawFocus(painter, option, option.rect);
26 
27  doc.drawContents(painter, option.rect);
28 }
29 
30 QSize HtmlDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
31 {
32  QTextDocument doc;
33  doc.setPageSize(option.rect.size());
34  doc.setHtml(index.data().toString());
35  return doc.size().toSize();
36 }
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: HtmlDelegate.cc:13
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: HtmlDelegate.cc:30