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> |
| 8 | |
| 9 | ApiCallDelegate::ApiCallDelegate(QWidget *parent) |
| 10 | : QStyledItemDelegate(parent) |
| 11 | { |
| 12 | } |
| 13 | |
| 14 | void ApiCallDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, |
| 15 | const QModelIndex &index) const |
| 16 | { |
| 17 | ApiTraceCall *call = static_cast<ApiTraceCall*>(index.internalPointer()); |
| 18 | if (call) { |
| 19 | QStaticText text = call->staticText(); |
| 20 | //text.setTextWidth(option.rect.width()); |
| 21 | painter->drawStaticText(option.rect.topLeft(), text); |
| 22 | } else{ |
| 23 | QStyledItemDelegate::paint(painter, option, index); |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | QSize ApiCallDelegate::sizeHint(const QStyleOptionViewItem &option, |
| 28 | const QModelIndex &index) const |
| 29 | { |
| 30 | ApiTraceCall *call = static_cast<ApiTraceCall*>(index.internalPointer()); |
| 31 | if (call) { |
| 32 | QStaticText text = call->staticText(); |
| 33 | //text.setTextWidth(option.rect.width()); |
| 34 | return text.size().toSize(); |
| 35 | } |
| 36 | return QStyledItemDelegate::sizeHint(option, index); |
| 37 | } |
| 38 | |
| 39 | |
| 40 | #include "apicalldelegate.moc" |