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

Last change on this file since 14412 was 10657, checked in by tbretz, 14 years ago
Added or improved documentation.
File size: 1.1 KB
Line 
1// **************************************************************************
2/** @class HtmlDelegate
3
4@brief A Qt-Delegate to display HTML text (QTextDocument) in a list
5
6*/
7// **************************************************************************
8#include "HtmlDelegate.h"
9
10#include <QPainter>
11#include <QTextDocument>
12
13void 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
30QSize 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}
Note: See TracBrowser for help on using the repository browser.