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 | |
| 15 | void ApiCallDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, |
| 16 | const QModelIndex &index) const |
| 17 | { |
Zack Rusin | 96130ac | 2011-03-27 01:48:36 -0400 | [diff] [blame^] | 18 | ApiTraceCall *call = index.data().value<ApiTraceCall*>(); |
Zack Rusin | 18eade5 | 2011-03-26 14:23:35 -0400 | [diff] [blame] | 19 | if (call) { |
| 20 | QStaticText text = call->staticText(); |
| 21 | //text.setTextWidth(option.rect.width()); |
Zack Rusin | 96130ac | 2011-03-27 01:48:36 -0400 | [diff] [blame^] | 22 | QStyledItemDelegate::paint(painter, option, index); |
Zack Rusin | 18eade5 | 2011-03-26 14:23:35 -0400 | [diff] [blame] | 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 | { |
Zack Rusin | 96130ac | 2011-03-27 01:48:36 -0400 | [diff] [blame^] | 32 | ApiTraceCall *call = index.data().value<ApiTraceCall*>(); |
Zack Rusin | 18eade5 | 2011-03-26 14:23:35 -0400 | [diff] [blame] | 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" |