source: trunk/FACT++/gui/HtmlDelegate.cc@ 10525

Last change on this file since 10525 was 10475, checked in by tbretz, 14 years ago
Changed the QTextDocument to be of a fixed size so that no horizontal scroll bars are needed.
File size: 886 bytes
Line 
1#include "HtmlDelegate.h"
2
3#include <QtGui/QPainter>
4#include <QtGui/QTextDocument>
5
6void HtmlDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
7{
8 QTextDocument doc;
9 doc.setPageSize(option.rect.size());
10 doc.setHtml(index.data().toString());
11
12 // === This can be used if a scrolling is needed ===
13 // painter->save();
14 // painter->translate(option.rect.topLeft());
15 // QRect r(QPoint(0, 0), option.rect.size());
16 // doc.drawContents(painter, r);
17 // painter->restore();
18 // drawFocus(painter, option, option.rect);
19
20 doc.drawContents(painter, option.rect);
21}
22
23QSize HtmlDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
24{
25 QTextDocument doc;
26 doc.setPageSize(option.rect.size());
27 doc.setHtml(index.data().toString());
28 return doc.size().toSize();
29}
Note: See TracBrowser for help on using the repository browser.