Zack Rusin | 18eade5 | 2011-03-26 14:23:35 -0400 | [diff] [blame] | 1 | #include "apicalldelegate.h" |
| 2 | |
| 3 | #include "apitracecall.h" |
| 4 | |
| 5 | #include <QDebug> |
| 6 | #include <QPainter> |
| 7 | #include <QStaticText> |
Zack Rusin | 96130ac | 2011-03-27 01:48:36 -0400 | [diff] [blame] | 8 | #include <QStyle> |
Zack Rusin | 18eade5 | 2011-03-26 14:23:35 -0400 | [diff] [blame] | 9 | |
| 10 | ApiCallDelegate::ApiCallDelegate(QWidget *parent) |
| 11 | : QStyledItemDelegate(parent) |
| 12 | { |
| 13 | } |
| 14 | |
Zack Rusin | f6667d1 | 2011-03-30 11:03:37 -0400 | [diff] [blame^] | 15 | void ApiCallDelegate::paint(QPainter *painter, |
| 16 | const QStyleOptionViewItem &option, |
Zack Rusin | 18eade5 | 2011-03-26 14:23:35 -0400 | [diff] [blame] | 17 | const QModelIndex &index) const |
| 18 | { |
Zack Rusin | 96130ac | 2011-03-27 01:48:36 -0400 | [diff] [blame] | 19 | ApiTraceCall *call = index.data().value<ApiTraceCall*>(); |
Zack Rusin | 18eade5 | 2011-03-26 14:23:35 -0400 | [diff] [blame] | 20 | if (call) { |
| 21 | QStaticText text = call->staticText(); |
| 22 | //text.setTextWidth(option.rect.width()); |
Zack Rusin | 96130ac | 2011-03-27 01:48:36 -0400 | [diff] [blame] | 23 | QStyledItemDelegate::paint(painter, option, index); |
Zack Rusin | 18eade5 | 2011-03-26 14:23:35 -0400 | [diff] [blame] | 24 | painter->drawStaticText(option.rect.topLeft(), text); |
Zack Rusin | f6667d1 | 2011-03-30 11:03:37 -0400 | [diff] [blame^] | 25 | } else { |
| 26 | ApiTraceFrame *frame = index.data().value<ApiTraceFrame*>(); |
| 27 | if (frame) { |
| 28 | QStaticText text = frame->staticText(); |
| 29 | //text.setTextWidth(option.rect.width()); |
| 30 | QStyledItemDelegate::paint(painter, option, index); |
| 31 | painter->drawStaticText(option.rect.topLeft(), text); |
| 32 | } else { |
| 33 | QStyledItemDelegate::paint(painter, option, index); |
| 34 | } |
Zack Rusin | 18eade5 | 2011-03-26 14:23:35 -0400 | [diff] [blame] | 35 | } |
| 36 | } |
| 37 | |
| 38 | QSize ApiCallDelegate::sizeHint(const QStyleOptionViewItem &option, |
| 39 | const QModelIndex &index) const |
| 40 | { |
Zack Rusin | 96130ac | 2011-03-27 01:48:36 -0400 | [diff] [blame] | 41 | ApiTraceCall *call = index.data().value<ApiTraceCall*>(); |
Zack Rusin | 18eade5 | 2011-03-26 14:23:35 -0400 | [diff] [blame] | 42 | if (call) { |
| 43 | QStaticText text = call->staticText(); |
| 44 | //text.setTextWidth(option.rect.width()); |
| 45 | return text.size().toSize(); |
Zack Rusin | f6667d1 | 2011-03-30 11:03:37 -0400 | [diff] [blame^] | 46 | } else { |
| 47 | ApiTraceFrame *frame = index.data().value<ApiTraceFrame*>(); |
| 48 | if (frame) { |
| 49 | QStaticText text = frame->staticText(); |
| 50 | //text.setTextWidth(option.rect.width()); |
| 51 | return text.size().toSize(); |
| 52 | } |
Zack Rusin | 18eade5 | 2011-03-26 14:23:35 -0400 | [diff] [blame] | 53 | } |
| 54 | return QStyledItemDelegate::sizeHint(option, index); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | #include "apicalldelegate.moc" |