]> git.cworth.org Git - apitrace/blobdiff - gui/apitracemodel.cpp
Accept zero valued bitmasks.
[apitrace] / gui / apitracemodel.cpp
index acc4452c11e33d750464a61920de8b37e72518dc..d3f3e6a7545aedbcef8d6269de04fe05b358ac14 100644 (file)
@@ -43,9 +43,12 @@ QVariant ApiTraceModel::data(const QModelIndex &index, int role) const
         if (itm->type() == ApiTraceEvent::Call) {
             ApiTraceCall *call = static_cast<ApiTraceCall*>(itm);
             if (call->state().isEmpty())
-                return QString::fromLatin1("<b>%1</b>").arg(call->name);
+                return QString::fromLatin1("%1)&nbsp;<b>%2</b>")
+                    .arg(call->index)
+                    .arg(call->name);
             else
-                return QString::fromLatin1("<b>%1</b><br/>%2")
+                return QString::fromLatin1("%1)&nbsp;<b>%2</b><br/>%3")
+                    .arg(call->index)
                     .arg(call->name)
                     .arg(stateText);
         } else {
@@ -197,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)),
@@ -248,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"