]> git.cworth.org Git - apitrace/blobdiff - gui/mainwindow.cpp
Delete loadertest and cleanup some of the new api.
[apitrace] / gui / mainwindow.cpp
index 7d4cab8f7e064b5d9d6baa4476b2cdb19a345782..3382faebe6d5ea44f4ba14112efb902a39ab4871 100644 (file)
@@ -268,7 +268,7 @@ void MainWindow::replayTrace(bool dumpState)
                 qDebug()<<"tried to get a state for an empty frame";
                 return;
             }
-            index = frame->calls().first()->index();
+            index = frame->lastCallIndex();
         } else {
             qDebug()<<"Unknown event type";
             return;
@@ -698,6 +698,8 @@ void MainWindow::initConnections()
             this, SLOT(slotFoundFrameStart(ApiTraceFrame*)));
     connect(m_trace, SIGNAL(foundFrameEnd(ApiTraceFrame*)),
             this, SLOT(slotFoundFrameEnd(ApiTraceFrame*)));
+    connect(m_trace, SIGNAL(foundCallIndex(ApiTraceCall*)),
+            this, SLOT(slotJumpToResult(ApiTraceCall*)));
 
     connect(m_retracer, SIGNAL(finished(const QString&)),
             this, SLOT(replayFinished(const QString&)));
@@ -705,8 +707,8 @@ void MainWindow::initConnections()
             this, SLOT(replayError(const QString&)));
     connect(m_retracer, SIGNAL(foundState(ApiTraceState*)),
             this, SLOT(replayStateFound(ApiTraceState*)));
-    connect(m_retracer, SIGNAL(retraceErrors(const QList<RetraceError>&)),
-            this, SLOT(slotRetraceErrors(const QList<RetraceError>&)));
+    connect(m_retracer, SIGNAL(retraceErrors(const QList<ApiTraceError>&)),
+            this, SLOT(slotRetraceErrors(const QList<ApiTraceError>&)));
 
     connect(m_ui.vertexInterpretButton, SIGNAL(clicked()),
             m_vdataInterpreter, SLOT(interpretData()));
@@ -808,10 +810,7 @@ void MainWindow::slotGoTo()
 
 void MainWindow::slotJumpTo(int callNum)
 {
-    QModelIndex index = m_proxyModel->callIndex(callNum);
-    if (index.isValid()) {
-        m_ui.callView->setCurrentIndex(index);
-    }
+    m_trace->findCallIndex(callNum);
 }
 
 void MainWindow::createdTrace(const QString &path)
@@ -874,11 +873,16 @@ void MainWindow::fillState(bool nonDefaults)
             m_ui.nonDefaultsCB->blockSignals(false);
             ApiTraceFrame *firstFrame =
                 m_trace->frameAt(0);
-            ApiTraceEvent *oldSelected = m_selectedEvent;
             if (!firstFrame)
                 return;
+            if (!firstFrame->isLoaded()) {
+                m_trace->loadFrame(firstFrame);
+                return;
+            }
+            ApiTraceCall *firstCall = firstFrame->calls().first();
+            ApiTraceEvent *oldSelected = m_selectedEvent;
             m_nonDefaultsLookupEvent = m_selectedEvent;
-            m_selectedEvent = firstFrame;
+            m_selectedEvent = firstCall;
             lookupState();
             m_selectedEvent = oldSelected;
         }
@@ -978,20 +982,17 @@ void MainWindow::slotTraceChanged(ApiTraceCall *call)
     }
 }
 
-void MainWindow::slotRetraceErrors(const QList<RetraceError> &errors)
+void MainWindow::slotRetraceErrors(const QList<ApiTraceError> &errors)
 {
     m_ui.errorsTreeWidget->clear();
 
-    foreach(RetraceError error, errors) {
-        ApiTraceCall *call = m_trace->callWithIndex(error.callIndex);
-        if (!call)
-            continue;
-        call->setError(error.message);
+    foreach(ApiTraceError error, errors) {
+        m_trace->setCallError(error);
 
         QTreeWidgetItem *item =
             new QTreeWidgetItem(m_ui.errorsTreeWidget);
         item->setData(0, Qt::DisplayRole, error.callIndex);
-        item->setData(0, Qt::UserRole, QVariant::fromValue(call));
+        item->setData(0, Qt::UserRole, error.callIndex);
         QString type = error.type;
         type[0] = type[0].toUpper();
         item->setData(1, Qt::DisplayRole, type);
@@ -1002,15 +1003,9 @@ void MainWindow::slotRetraceErrors(const QList<RetraceError> &errors)
 void MainWindow::slotErrorSelected(QTreeWidgetItem *current)
 {
     if (current) {
-        ApiTraceCall *call =
-            current->data(0, Qt::UserRole).value<ApiTraceCall*>();
-        Q_ASSERT(call);
-        QModelIndex index = m_proxyModel->indexForCall(call);
-        if (index.isValid()) {
-            m_ui.callView->setCurrentIndex(index);
-        } else {
-            statusBar()->showMessage(tr("Call has been filtered out."));
-        }
+        int callIndex =
+            current->data(0, Qt::UserRole).toInt();
+        m_trace->findCallIndex(callIndex);
     }
 }
 
@@ -1085,16 +1080,16 @@ void MainWindow::slotSearchResult(ApiTrace::SearchResult result,
                                   ApiTraceCall *call)
 {
     switch (result) {
-    case ApiTrace::SearchNotFound:
+    case ApiTrace::SearchResult_NotFound:
         m_searchWidget->setFound(false);
         break;
-    case ApiTrace::SearchFound: {
+    case ApiTrace::SearchResult_Found: {
         QModelIndex index = m_proxyModel->indexForCall(call);
         m_ui.callView->setCurrentIndex(index);
         m_searchWidget->setFound(true);
     }
         break;
-    case ApiTrace::SearchWrapped:
+    case ApiTrace::SearchResult_Wrapped:
         m_searchWidget->setFound(false);
         break;
     }
@@ -1156,7 +1151,7 @@ ApiTraceCall * MainWindow::currentCall() const
 
 void MainWindow::slotFoundFrameStart(ApiTraceFrame *frame)
 {
-    Q_ASSERT(frame->loaded());
+    Q_ASSERT(frame->isLoaded());
     if (!frame || frame->isEmpty()) {
         return;
     }
@@ -1178,7 +1173,7 @@ void MainWindow::slotFoundFrameStart(ApiTraceFrame *frame)
 
 void MainWindow::slotFoundFrameEnd(ApiTraceFrame *frame)
 {
-    Q_ASSERT(frame->loaded());
+    Q_ASSERT(frame->isLoaded());
     if (!frame || frame->isEmpty()) {
         return;
     }
@@ -1197,4 +1192,14 @@ void MainWindow::slotFoundFrameEnd(ApiTraceFrame *frame)
     } while (itr != calls.constBegin());
 }
 
+void MainWindow::slotJumpToResult(ApiTraceCall *call)
+{
+    QModelIndex index = m_proxyModel->indexForCall(call);
+    if (index.isValid()) {
+        m_ui.callView->setCurrentIndex(index);
+    } else {
+        statusBar()->showMessage(tr("Call has been filtered out."));
+    }
+}
+
 #include "mainwindow.moc"