+}
+
+void MainWindow::slotErrorSelected(QTreeWidgetItem *current)
+{
+ if (current) {
+ int callIndex =
+ current->data(0, Qt::UserRole).toInt();
+ m_trace->findCallIndex(callIndex);
+ }
+}
+
+ApiTraceCall * MainWindow::selectedCall() const
+{
+ if (m_selectedEvent &&
+ m_selectedEvent->type() == ApiTraceEvent::Call) {
+ return static_cast<ApiTraceCall*>(m_selectedEvent);
+ }
+ return NULL;
+}
+
+void MainWindow::saveSelectedSurface()
+{
+ QTreeWidgetItem *item =
+ m_ui.surfacesTreeWidget->currentItem();
+
+ if (!item || !m_trace) {
+ return;
+ }
+
+ QVariant var = item->data(0, Qt::UserRole);
+ QImage img = var.value<QImage>();
+
+ QString imageIndex;
+ if (selectedCall()) {
+ imageIndex = tr("_call_%1")
+ .arg(selectedCall()->index());
+ } else if (selectedFrame()) {
+ ApiTraceCall *firstCall = selectedFrame()->call(0);
+ if (firstCall) {
+ imageIndex = tr("_frame_%1")
+ .arg(firstCall->index());
+ } else {
+ qDebug()<<"unknown frame number";
+ imageIndex = tr("_frame_%1")
+ .arg(firstCall->index());
+ }
+ }
+
+ //which of the surfaces are we saving
+ QTreeWidgetItem *parent = item->parent();
+ int parentIndex =
+ m_ui.surfacesTreeWidget->indexOfTopLevelItem(parent);
+ if (parentIndex < 0) {
+ parentIndex = 0;
+ }
+ int childIndex = 0;
+ if (parent) {
+ childIndex = parent->indexOfChild(item);
+ } else {
+ childIndex = m_ui.surfacesTreeWidget->indexOfTopLevelItem(item);
+ }
+
+
+ QString fileName =
+ tr("%1%2-%3_%4.png")
+ .arg(m_trace->fileName())
+ .arg(imageIndex)
+ .arg(parentIndex)
+ .arg(childIndex);
+ //qDebug()<<"save "<<fileName;
+ img.save(fileName, "PNG");
+ statusBar()->showMessage( tr("Saved '%1'").arg(fileName), 5000);
+}
+
+void MainWindow::loadProgess(int percent)
+{
+ m_progressBar->setValue(percent);
+}
+
+void MainWindow::slotSearchResult(ApiTrace::SearchResult result,
+ ApiTraceCall *call)
+{
+ switch (result) {
+ case ApiTrace::SearchResult_NotFound:
+ m_searchWidget->setFound(false);
+ break;
+ case ApiTrace::SearchResult_Found: {
+ QModelIndex index = m_proxyModel->indexForCall(call);
+ m_ui.callView->setCurrentIndex(index);
+ m_searchWidget->setFound(true);
+ }
+ break;
+ case ApiTrace::SearchResult_Wrapped:
+ m_searchWidget->setFound(false);
+ break;
+ }
+}
+
+ApiTraceFrame * MainWindow::currentFrame() const
+{
+ QModelIndex index = m_ui.callView->currentIndex();
+ ApiTraceEvent *event = 0;
+
+ if (!index.isValid()) {
+ index = m_proxyModel->index(0, 0, QModelIndex());
+ if (!index.isValid()) {
+ qDebug()<<"no currently valid index";
+ return 0;
+ }
+ }