]> git.cworth.org Git - apitrace/blobdiff - gui/apicalldelegate.cpp
Use skiplist-based FastCallSet within trace::CallSet
[apitrace] / gui / apicalldelegate.cpp
index 11ed3a5ca03d5c59c96b8c7bc05c67e2e5583bf8..9ad9f24ad535fe729cb478164b30410727014401 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "apitracecall.h"
 #include "apitracemodel.h"
+#include "thumbnail.h"
 
 #include <QApplication>
 #include <QDebug>
@@ -27,35 +28,47 @@ void ApiCallDelegate::paint(QPainter *painter,
     Q_ASSERT(index.column() == 0);
 
     if (event) {
-        QPoint offset;
+        QPoint offset = option.rect.topLeft();
         QStaticText text = event->staticText();
+        QSize textSize = text.size().toSize();
         //text.setTextWidth(option.rect.width());
         //QStyledItemDelegate::paint(painter, option, index);
         QStyle *style = QApplication::style();
         style->drawControl(QStyle::CE_ItemViewItem, &option, painter, 0);
+
+        // draw thumbnail of frame
+        if (event->type() == ApiTraceEvent::Frame) {
+            ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(event);
+            const QImage & thumbnail = frame->thumbnail();
+            if (!thumbnail.isNull()) {
+                painter->drawImage(offset, thumbnail);
+                offset += QPoint(textSize.height() + thumbnail.width(), option.rect.height()/2 - textSize.height()/2);
+            }
+        }
+
         if (event->hasState()) {
-            QPixmap px = m_stateEmblem.pixmap(option.rect.height(),
-                                              option.rect.height());
+            QPixmap px = m_stateEmblem.pixmap(textSize.height(),
+                                              textSize.height());
             painter->drawPixmap(option.rect.topLeft(), px);
-            offset = QPoint(option.rect.height() + 5, 0);
+            offset += QPoint(textSize.height() + 5, 0);
         }
         if (event->type() == ApiTraceEvent::Call) {
             ApiTraceCall *call = static_cast<ApiTraceCall*>(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);
+                QPixmap px = m_errorEmblem.pixmap(textSize.height(),
+                                                  textSize.height());
+                painter->drawPixmap(offset, px);
+                offset += QPoint(textSize.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);
+                QPixmap px = m_editEmblem.pixmap(textSize.height(),
+                                                 textSize.height());
+                painter->drawPixmap(offset, px);
+                offset += QPoint(textSize.height() + 5, 0);
             }
         }
 
-        painter->drawStaticText(option.rect.topLeft() + offset, text);
+        painter->drawStaticText(offset, text);
     } else {
         QStyledItemDelegate::paint(painter, option, index);
     }
@@ -64,8 +77,8 @@ void ApiCallDelegate::paint(QPainter *painter,
 QSize ApiCallDelegate::sizeHint(const QStyleOptionViewItem &option,
                                 const QModelIndex &index) const
 {
-    ApiTraceEvent *event =
-        index.data(ApiTraceModel::EventRole).value<ApiTraceEvent*>();
+    QVariant var = index.data(ApiTraceModel::EventRole);
+    ApiTraceEvent *event = var.value<ApiTraceEvent*>();
 
 #ifndef __APPLE__
     /* XXX: This fails on MacOSX, but seems safe to ignore */
@@ -76,7 +89,21 @@ QSize ApiCallDelegate::sizeHint(const QStyleOptionViewItem &option,
         QStaticText text = event->staticText();
         //text.setTextWidth(option.rect.width());
         //qDebug()<<"text size = "<<text.size();
-        return text.size().toSize();
+        QSize size = text.size().toSize();
+
+        // Adjust for thumbnail
+        if (event->type() == ApiTraceEvent::Frame) {
+            ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(event);
+            const QImage & thumbnail = frame->thumbnail();
+            if (!thumbnail.isNull()) {
+                size.rwidth() += thumbnail.width();
+                if (size.height() < thumbnail.height()) {
+                    size.setHeight(thumbnail.height());
+                }
+            }
+        }
+
+        return size;
     }
     return QStyledItemDelegate::sizeHint(option, index);
 }