+ //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(const ApiTrace::SearchRequest &request,
+ 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);
+
+ if (index.isValid()) {
+ m_ui.callView->setCurrentIndex(index);
+ m_searchWidget->setFound(true);
+ } else {
+ //call is filtered out, so continue searching but from the
+ // filtered call
+ if (!call) {
+ qDebug()<<"Error: search success with no call";
+ return;
+ }
+// qDebug()<<"filtered! search from "<<call->searchText()
+// <<", call idx = "<<call->index();
+
+ if (request.direction == ApiTrace::SearchRequest::Next) {
+ m_trace->findNext(call->parentFrame(), call,
+ request.text, request.cs);
+ } else {
+ m_trace->findNext(call->parentFrame(), call,
+ request.text, request.cs);
+ }
+ }
+ }
+ 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;
+ }
+ }
+
+ event = index.data(ApiTraceModel::EventRole).value<ApiTraceEvent*>();
+ Q_ASSERT(event);
+ if (!event) {
+ return 0;
+ }
+
+ ApiTraceFrame *frame = 0;
+ if (event->type() == ApiTraceCall::Frame) {
+ frame = static_cast<ApiTraceFrame*>(event);
+ }
+ return frame;
+}
+
+ApiTraceCall * MainWindow::currentCall() 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;
+ }
+ }
+
+ event = index.data(ApiTraceModel::EventRole).value<ApiTraceEvent*>();
+ Q_ASSERT(event);
+ if (!event) {
+ return 0;
+ }
+
+ ApiTraceCall *call = 0;
+ if (event->type() == ApiTraceCall::Call) {
+ call = static_cast<ApiTraceCall*>(event);
+ }
+
+ return call;
+
+}
+
+void MainWindow::slotFoundFrameStart(ApiTraceFrame *frame)
+{
+ Q_ASSERT(frame->isLoaded());
+ if (!frame || frame->isEmpty()) {
+ return;
+ }
+
+ QVector<ApiTraceCall*>::const_iterator itr;
+ QVector<ApiTraceCall*> calls = frame->calls();
+
+ itr = calls.constBegin();
+ while (itr != calls.constEnd()) {