]> git.cworth.org Git - apitrace/blobdiff - gui/mainwindow.cpp
Lookup call state on double-click.
[apitrace] / gui / mainwindow.cpp
index 28dd6281a92602bb8dd44521e8cc83b8ad789331..039889ca1aa5bd0a9987cb35d2cc38eb808654cc 100644 (file)
@@ -36,6 +36,8 @@
 
 MainWindow::MainWindow()
     : QMainWindow(),
+      m_api(trace::API_GL),
+      m_initalCallNum(-1),
       m_selectedEvent(0),
       m_stateEvent(0),
       m_nonDefaultsLookupEvent(0)
@@ -59,6 +61,7 @@ void MainWindow::createTrace()
     if (dialog.exec() == QDialog::Accepted) {
         qDebug()<< "App : " <<dialog.applicationPath();
         qDebug()<< "  Arguments: "<<dialog.arguments();
+        m_traceProcess->setApi(dialog.api());
         m_traceProcess->setExecutablePath(dialog.applicationPath());
         m_traceProcess->setArguments(dialog.arguments());
         m_traceProcess->start();
@@ -79,7 +82,7 @@ void MainWindow::openTrace()
     }
 }
 
-void MainWindow::loadTrace(const QString &fileName)
+void MainWindow::loadTrace(const QString &fileName, int callNum)
 {
     if (!QFile::exists(fileName)) {
         QMessageBox::warning(this, tr("File Missing"),
@@ -87,6 +90,7 @@ void MainWindow::loadTrace(const QString &fileName)
         return;
     }
 
+    m_initalCallNum = callNum;
     newTraceFile(fileName);
 }
 
@@ -97,6 +101,10 @@ void MainWindow::callItemSelected(const QModelIndex &index)
 
     if (event && event->type() == ApiTraceEvent::Call) {
         ApiTraceCall *call = static_cast<ApiTraceCall*>(event);
+        m_ui.detailsDock->setWindowTitle(
+            tr("Details View. Frame %1, Call %2")
+            .arg(call->parentFrame() ? call->parentFrame()->number : 0)
+            .arg(call->index()));
         m_ui.detailsWebView->setHtml(call->toHtml());
         m_ui.detailsDock->show();
         if (call->hasBinaryData()) {
@@ -140,6 +148,10 @@ void MainWindow::callItemSelected(const QModelIndex &index)
     }
 }
 
+void MainWindow::callItemActivated(const QModelIndex &index) {
+    lookupState();
+}
+
 void MainWindow::replayStart()
 {
     if (m_trace->isSaving()) {
@@ -250,6 +262,10 @@ void MainWindow::finishedLoadingTrace()
     QFileInfo info(m_trace->fileName());
     statusBar()->showMessage(
         tr("Loaded %1").arg(info.fileName()), 3000);
+    if (m_initalCallNum >= 0) {
+        m_trace->findCallIndex(m_initalCallNum);
+        m_initalCallNum = -1;
+    }
 }
 
 void MainWindow::replayTrace(bool dumpState)
@@ -259,6 +275,7 @@ void MainWindow::replayTrace(bool dumpState)
     }
 
     m_retracer->setFileName(m_trace->fileName());
+    m_retracer->setAPI(m_api);
     m_retracer->setCaptureState(dumpState);
     if (m_retracer->captureState() && m_selectedEvent) {
         int index = 0;
@@ -458,8 +475,9 @@ static void addSurfaceItem(const ApiSurface &surface,
     int width = surface.size().width();
     int height = surface.size().height();
     QString descr =
-        QString::fromLatin1("%1, %2 x %3")
+        QString::fromLatin1("%1, %2, %3 x %4")
         .arg(label)
+        .arg(surface.formatName())
         .arg(width)
         .arg(height);
 
@@ -558,9 +576,12 @@ void MainWindow::fillStateForFrame()
 void MainWindow::showSettings()
 {
     SettingsDialog dialog;
+    dialog.setAPI(m_api);
     dialog.setFilterModel(m_proxyModel);
 
     dialog.exec();
+
+    m_api = dialog.getAPI();
 }
 
 void MainWindow::openHelp(const QUrl &url)
@@ -760,8 +781,10 @@ void MainWindow::initConnections()
     connect(m_ui.actionOptions, SIGNAL(triggered()),
             this, SLOT(showSettings()));
 
-    connect(m_ui.callView, SIGNAL(activated(const QModelIndex &)),
+    connect(m_ui.callView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
             this, SLOT(callItemSelected(const QModelIndex &)));
+    connect(m_ui.callView, SIGNAL(doubleClicked(const QModelIndex &)),
+            this, SLOT(callItemActivated(const QModelIndex &)));
     connect(m_ui.callView, SIGNAL(customContextMenuRequested(QPoint)),
             this, SLOT(customContextMenuRequested(QPoint)));
 
@@ -798,7 +821,7 @@ void MainWindow::initConnections()
     connect(m_ui.actionShowErrorsDock, SIGNAL(triggered(bool)),
             m_ui.errorsDock, SLOT(setVisible(bool)));
     connect(m_ui.errorsTreeWidget,
-            SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
+            SIGNAL(itemActivated(QTreeWidgetItem*, int)),
             this, SLOT(slotErrorSelected(QTreeWidgetItem*)));
 }