]> git.cworth.org Git - apitrace/blob - gui/apicalldelegate.cpp
add lots of quirks and details view
[apitrace] / gui / apicalldelegate.cpp
1 #include "apicalldelegate.h"
2
3 #include "apitracecall.h"
4
5 #include <QDebug>
6 #include <QPainter>
7 #include <QStaticText>
8 #include <QStyle>
9
10 ApiCallDelegate::ApiCallDelegate(QWidget *parent)
11     : QStyledItemDelegate(parent)
12 {
13 }
14
15 void ApiCallDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
16                             const QModelIndex &index) const
17 {
18     ApiTraceCall *call = index.data().value<ApiTraceCall*>();
19     if (call) {
20         QStaticText text = call->staticText();
21         //text.setTextWidth(option.rect.width());
22         QStyledItemDelegate::paint(painter, option, index);
23         painter->drawStaticText(option.rect.topLeft(), text);
24     } else{
25         QStyledItemDelegate::paint(painter, option, index);
26     }
27 }
28
29 QSize ApiCallDelegate::sizeHint(const QStyleOptionViewItem &option,
30                                 const QModelIndex &index) const
31 {
32     ApiTraceCall *call = index.data().value<ApiTraceCall*>();
33     if (call) {
34         QStaticText text = call->staticText();
35         //text.setTextWidth(option.rect.width());
36         return text.size().toSize();
37     }
38     return QStyledItemDelegate::sizeHint(option, index);
39 }
40
41
42 #include "apicalldelegate.moc"