]> git.cworth.org Git - apitrace/blobdiff - gui/apitracemodel.cpp
Filter text was missing the first paren.
[apitrace] / gui / apitracemodel.cpp
index 501dd98c0d9408edd763baaefa7bf21492fdf5bd..d3f3e6a7545aedbcef8d6269de04fe05b358ac14 100644 (file)
@@ -38,6 +38,30 @@ QVariant ApiTraceModel::data(const QModelIndex &index, int role) const
         return itm->staticText().text();
     case Qt::DecorationRole:
         return QImage();
+    case Qt::ToolTipRole: {
+        const QString stateText = tr("State info available.");
+        if (itm->type() == ApiTraceEvent::Call) {
+            ApiTraceCall *call = static_cast<ApiTraceCall*>(itm);
+            if (call->state().isEmpty())
+                return QString::fromLatin1("%1)&nbsp;<b>%2</b>")
+                    .arg(call->index)
+                    .arg(call->name);
+            else
+                return QString::fromLatin1("%1)&nbsp;<b>%2</b><br/>%3")
+                    .arg(call->index)
+                    .arg(call->name)
+                    .arg(stateText);
+        } else {
+            ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(itm);
+            QString text = frame->staticText().text();
+            if (frame->state().isEmpty())
+                return QString::fromLatin1("<b>%1</b>").arg(text);
+            else
+                return QString::fromLatin1("<b>%1</b><br/>%2")
+                    .arg(text)
+                    .arg(stateText);
+        }
+    }
     case ApiTraceModel::EventRole:
         return QVariant::fromValue(itm);
     }
@@ -176,6 +200,8 @@ void ApiTraceModel::setApiTrace(ApiTrace *trace)
     if (m_trace)
         disconnect(m_trace);
     m_trace = trace;
+    connect(m_trace, SIGNAL(invalidated()),
+            this, SLOT(invalidateFrames()));
     connect(m_trace, SIGNAL(framesInvalidated()),
             this, SLOT(invalidateFrames()));
     connect(m_trace, SIGNAL(framesAdded(int, int)),
@@ -227,4 +253,27 @@ void ApiTraceModel::stateSetOnEvent(ApiTraceEvent *event)
     }
 }
 
+QModelIndex ApiTraceModel::callIndex(int callNum) const
+{
+    ApiTraceCall *call = m_trace->callWithIndex(callNum);
+    return indexForCall(call);
+}
+
+QModelIndex ApiTraceModel::indexForCall(ApiTraceCall *call) const
+{
+    if (!call) {
+        return QModelIndex();
+    }
+
+    ApiTraceFrame *frame = call->parentFrame;
+    Q_ASSERT(frame);
+
+    int row = frame->calls.indexOf(call);
+    if (row < 0) {
+        qDebug() << "Couldn't find call num "<<call->index<<" inside parent!";
+        return QModelIndex();
+    }
+    return createIndex(row, 0, call);
+}
+
 #include "apitracemodel.moc"