X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=gui%2Fapicalldelegate.cpp;h=11ed3a5ca03d5c59c96b8c7bc05c67e2e5583bf8;hb=48412ffde3dd4710c96d5e8d9cfdf1789e4d703a;hp=4eb542be2171bce1c410da3397fb8eb7592356c1;hpb=0b210a5f07344b85d9d04348daa9078db622eb6a;p=apitrace diff --git a/gui/apicalldelegate.cpp b/gui/apicalldelegate.cpp index 4eb542b..11ed3a5 100644 --- a/gui/apicalldelegate.cpp +++ b/gui/apicalldelegate.cpp @@ -11,7 +11,9 @@ ApiCallDelegate::ApiCallDelegate(QWidget *parent) : QStyledItemDelegate(parent), - m_stateEmblem(":/resources/dialog-information.png") + m_stateEmblem(":/resources/dialog-information.png"), + m_editEmblem(":/resources/document-edit.png"), + m_errorEmblem(":/resources/script-error.png") { } @@ -31,11 +33,28 @@ void ApiCallDelegate::paint(QPainter *painter, //QStyledItemDelegate::paint(painter, option, index); QStyle *style = QApplication::style(); style->drawControl(QStyle::CE_ItemViewItem, &option, painter, 0); - if (!event->state().isEmpty()) { - QPixmap px = m_stateEmblem.pixmap(option.rect.height(), option.rect.height()); + if (event->hasState()) { + QPixmap px = m_stateEmblem.pixmap(option.rect.height(), + option.rect.height()); painter->drawPixmap(option.rect.topLeft(), px); offset = QPoint(option.rect.height() + 5, 0); } + if (event->type() == ApiTraceEvent::Call) { + ApiTraceCall *call = static_cast(event); + if (call->hasError()) { + QPixmap px = m_errorEmblem.pixmap(option.rect.height(), + option.rect.height()); + painter->drawPixmap(option.rect.topLeft() + offset, px); + offset += QPoint(option.rect.height() + 5, 0); + } + if (call->edited()) { + QPixmap px = m_editEmblem.pixmap(option.rect.height(), + option.rect.height()); + painter->drawPixmap(option.rect.topLeft() + offset, px); + offset += QPoint(option.rect.height() + 5, 0); + } + } + painter->drawStaticText(option.rect.topLeft() + offset, text); } else { QStyledItemDelegate::paint(painter, option, index); @@ -48,7 +67,10 @@ QSize ApiCallDelegate::sizeHint(const QStyleOptionViewItem &option, ApiTraceEvent *event = index.data(ApiTraceModel::EventRole).value(); +#ifndef __APPLE__ + /* XXX: This fails on MacOSX, but seems safe to ignore */ Q_ASSERT(index.column() == 0); +#endif if (event) { QStaticText text = event->staticText();