+void MainWindow::slotSearch()
+{
+ m_jumpWidget->hide();
+ m_searchWidget->show();
+}
+
+void MainWindow::slotSearchNext(const QString &str, Qt::CaseSensitivity sensitivity)
+{
+ QModelIndex index = m_ui.callView->currentIndex();
+ ApiTraceEvent *event =
+ index.data(ApiTraceModel::EventRole).value<ApiTraceEvent*>();
+ ApiTraceCall *call = 0;
+
+ if (event->type() == ApiTraceCall::Call)
+ call = static_cast<ApiTraceCall*>(event);
+ else {
+ Q_ASSERT(event->type() == ApiTraceCall::Frame);
+ ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(event);
+ call = frame->calls.value(0);
+ }
+
+ if (!call) {
+ m_searchWidget->setFound(false);
+ return;
+ }
+ const QList<ApiTraceCall*> &calls = m_trace->calls();
+ int callNum = calls.indexOf(call);
+
+ for (int i = callNum + 1; i < calls.count(); ++i) {
+ ApiTraceCall *testCall = calls[i];
+ QString txt = testCall->filterText();
+ if (txt.contains(str, sensitivity)) {
+ QModelIndex index = m_proxyModel->callIndex(testCall->index);
+ /* if it's not valid it means that the proxy model has already
+ * filtered it out */
+ if (index.isValid()) {
+ m_ui.callView->setCurrentIndex(index);
+ m_searchWidget->setFound(true);
+ return;
+ }
+ }
+ }
+ m_searchWidget->setFound(false);
+}
+
+void MainWindow::slotSearchPrev(const QString &str, Qt::CaseSensitivity sensitivity)
+{
+ QModelIndex index = m_ui.callView->currentIndex();
+ ApiTraceEvent *event =
+ index.data(ApiTraceModel::EventRole).value<ApiTraceEvent*>();
+ ApiTraceCall *call = 0;
+
+ if (event->type() == ApiTraceCall::Call)
+ call = static_cast<ApiTraceCall*>(event);
+ else {
+ Q_ASSERT(event->type() == ApiTraceCall::Frame);
+ ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(event);
+ call = frame->calls.value(0);
+ }
+
+ if (!call) {
+ m_searchWidget->setFound(false);
+ return;
+ }
+ const QList<ApiTraceCall*> &calls = m_trace->calls();
+ int callNum = calls.indexOf(call);
+
+ for (int i = callNum - 1; i >= 0; --i) {
+ ApiTraceCall *testCall = calls[i];
+ QString txt = testCall->filterText();
+ if (txt.contains(str, sensitivity)) {
+ QModelIndex index = m_proxyModel->callIndex(testCall->index);
+ /* if it's not valid it means that the proxy model has already
+ * filtered it out */
+ if (index.isValid()) {
+ m_ui.callView->setCurrentIndex(index);
+ m_searchWidget->setFound(true);
+ return;
+ }
+ }
+ }
+ m_searchWidget->setFound(false);
+}
+