summaryrefslogtreecommitdiff
path: root/gui/apicalldelegate.cpp
blob: 5376c0dcdb3d266a5964ffafb230b0c252945ae0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "apicalldelegate.h"

#include "apitracecall.h"

#include <QDebug>
#include <QPainter>
#include <QStaticText>
#include <QStyle>

ApiCallDelegate::ApiCallDelegate(QWidget *parent)
    : QStyledItemDelegate(parent)
{
}

void ApiCallDelegate::paint(QPainter *painter,
                            const QStyleOptionViewItem &option,
                            const QModelIndex &index) const
{
    ApiTraceCall *call = index.data().value<ApiTraceCall*>();
    if (call) {
        QStaticText text = call->staticText();
        //text.setTextWidth(option.rect.width());
        QStyledItemDelegate::paint(painter, option, index);
        painter->drawStaticText(option.rect.topLeft(), text);
    } else {
        ApiTraceFrame *frame = index.data().value<ApiTraceFrame*>();
        if (frame) {
            QStaticText text = frame->staticText();
            //text.setTextWidth(option.rect.width());
            QStyledItemDelegate::paint(painter, option, index);
            painter->drawStaticText(option.rect.topLeft(), text);
        } else {
            QStyledItemDelegate::paint(painter, option, index);
        }
    }
}

QSize ApiCallDelegate::sizeHint(const QStyleOptionViewItem &option,
                                const QModelIndex &index) const
{
    ApiTraceCall *call = index.data().value<ApiTraceCall*>();
    if (call) {
        QStaticText text = call->staticText();
        //text.setTextWidth(option.rect.width());
        return text.size().toSize();
    } else {
        ApiTraceFrame *frame = index.data().value<ApiTraceFrame*>();
        if (frame) {
            QStaticText text = frame->staticText();
            //text.setTextWidth(option.rect.width());
            return text.size().toSize();
        }
    }
    return QStyledItemDelegate::sizeHint(option, index);
}


#include "apicalldelegate.moc"