+
+ 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()) {
+ ApiTraceCall *call = *itr;
+ QModelIndex idx = m_proxyModel->indexForCall(call);
+ if (idx.isValid()) {
+ m_ui.callView->setCurrentIndex(idx);
+ m_ui.callView->scrollTo(idx, QAbstractItemView::PositionAtTop);
+ break;
+ }
+ ++itr;
+ }
+}
+
+void MainWindow::slotFoundFrameEnd(ApiTraceFrame *frame)
+{
+ Q_ASSERT(frame->isLoaded());
+ if (!frame || frame->isEmpty()) {
+ return;
+ }
+ QVector<ApiTraceCall*>::const_iterator itr;
+ QVector<ApiTraceCall*> calls = frame->calls();
+
+ itr = calls.constEnd();
+ do {
+ --itr;
+ ApiTraceCall *call = *itr;
+ QModelIndex idx = m_proxyModel->indexForCall(call);
+ if (idx.isValid()) {
+ m_ui.callView->setCurrentIndex(idx);
+ m_ui.callView->scrollTo(idx, QAbstractItemView::PositionAtBottom);
+ break;
+ }
+ } while (itr != calls.constBegin());
+}
+
+void MainWindow::slotJumpToResult(ApiTraceCall *call)
+{
+ QModelIndex idx = m_proxyModel->indexForCall(call);
+ if (idx.isValid()) {
+ activateWindow();
+ m_ui.callView->setFocus();
+ m_ui.callView->setCurrentIndex(idx);
+ m_ui.callView->scrollTo(idx, QAbstractItemView::PositionAtCenter);
+ } else {
+ statusBar()->showMessage(tr("Call has been filtered out."));
+ }