1 #include "mainwindow.h"
4 #include "apitracecall.h"
5 #include "apicalldelegate.h"
6 #include "apitracemodel.h"
7 #include "apitracefilter.h"
8 #include "argumentseditor.h"
9 #include "imageviewer.h"
10 #include "jumpwidget.h"
12 #include "searchwidget.h"
13 #include "settingsdialog.h"
14 #include "shaderssourcewidget.h"
15 #include "tracedialog.h"
16 #include "traceprocess.h"
17 #include "ui_retracerdialog.h"
18 #include "vertexdatainterpreter.h"
22 #include <QDesktopServices>
24 #include <QFileDialog>
26 #include <QMessageBox>
27 #include <QProgressBar>
31 #include <QVBoxLayout>
36 MainWindow::MainWindow()
46 void MainWindow::createTrace()
50 if (!m_traceProcess->canTrace()) {
54 tr("Current configuration doesn't support tracing."));
58 if (dialog.exec() == QDialog::Accepted) {
59 qDebug()<< "App : " <<dialog.applicationPath();
60 qDebug()<< " Arguments: "<<dialog.arguments();
61 m_traceProcess->setExecutablePath(dialog.applicationPath());
62 m_traceProcess->setArguments(dialog.arguments());
63 m_traceProcess->start();
67 void MainWindow::openTrace()
70 QFileDialog::getOpenFileName(
74 tr("Trace Files (*.trace)"));
76 qDebug()<< "File name : " <<fileName;
78 newTraceFile(fileName);
81 void MainWindow::loadTrace(const QString &fileName)
83 if (!QFile::exists(fileName)) {
84 QMessageBox::warning(this, tr("File Missing"),
85 tr("File '%1' doesn't exist.").arg(fileName));
88 qDebug()<< "Loading : " <<fileName;
90 m_progressBar->setValue(0);
91 newTraceFile(fileName);
94 void MainWindow::callItemSelected(const QModelIndex &index)
96 ApiTraceEvent *event =
97 index.data(ApiTraceModel::EventRole).value<ApiTraceEvent*>();
99 if (event && event->type() == ApiTraceEvent::Call) {
100 ApiTraceCall *call = static_cast<ApiTraceCall*>(event);
101 m_ui.detailsWebView->setHtml(call->toHtml());
102 m_ui.detailsDock->show();
103 if (call->hasBinaryData()) {
105 call->arguments()[call->binaryDataIndex()].toByteArray();
106 m_vdataInterpreter->setData(data);
107 QVariantList args = call->arguments();
109 for (int i = 0; i < call->argNames().count(); ++i) {
110 QString name = call->argNames()[i];
111 if (name == QLatin1String("stride")) {
112 int stride = args[i].toInt();
113 m_ui.vertexStrideSB->setValue(stride);
114 } else if (name == QLatin1String("size")) {
115 int components = args[i].toInt();
116 m_ui.vertexComponentsSB->setValue(components);
117 } else if (name == QLatin1String("type")) {
118 QString val = args[i].toString();
119 int textIndex = m_ui.vertexTypeCB->findText(val);
121 m_ui.vertexTypeCB->setCurrentIndex(textIndex);
125 m_ui.vertexDataDock->setVisible(call->hasBinaryData());
126 m_selectedEvent = call;
128 if (event && event->type() == ApiTraceEvent::Frame) {
129 m_selectedEvent = static_cast<ApiTraceFrame*>(event);
132 m_ui.detailsDock->hide();
133 m_ui.vertexDataDock->hide();
135 if (m_selectedEvent && !m_selectedEvent->state().isEmpty()) {
138 m_ui.stateDock->hide();
141 void MainWindow::replayStart()
144 Ui_RetracerDialog dlgUi;
147 dlgUi.doubleBufferingCB->setChecked(
148 m_retracer->isDoubleBuffered());
149 dlgUi.benchmarkCB->setChecked(
150 m_retracer->isBenchmarking());
152 if (dlg.exec() == QDialog::Accepted) {
153 m_retracer->setDoubleBuffered(
154 dlgUi.doubleBufferingCB->isChecked());
155 m_retracer->setBenchmarking(
156 dlgUi.benchmarkCB->isChecked());
161 void MainWindow::replayStop()
164 m_ui.actionStop->setEnabled(false);
165 m_ui.actionReplay->setEnabled(true);
166 m_ui.actionLookupState->setEnabled(true);
169 void MainWindow::newTraceFile(const QString &fileName)
171 m_traceFileName = fileName;
172 m_trace->setFileName(fileName);
174 if (m_traceFileName.isEmpty()) {
175 m_ui.actionReplay->setEnabled(false);
176 m_ui.actionLookupState->setEnabled(false);
177 setWindowTitle(tr("QApiTrace"));
179 QFileInfo info(fileName);
180 m_ui.actionReplay->setEnabled(true);
181 m_ui.actionLookupState->setEnabled(true);
183 tr("QApiTrace - %1").arg(info.fileName()));
187 void MainWindow::replayFinished(const QString &output)
189 m_ui.actionStop->setEnabled(false);
190 m_ui.actionReplay->setEnabled(true);
191 m_ui.actionLookupState->setEnabled(true);
193 m_progressBar->hide();
194 if (output.length() < 80) {
195 statusBar()->showMessage(output);
198 statusBar()->showMessage(
199 tr("Replaying finished!"), 2000);
202 void MainWindow::replayError(const QString &message)
204 m_ui.actionStop->setEnabled(false);
205 m_ui.actionReplay->setEnabled(true);
206 m_ui.actionLookupState->setEnabled(true);
209 m_progressBar->hide();
210 statusBar()->showMessage(
211 tr("Replaying unsuccessful."), 2000);
212 QMessageBox::warning(
213 this, tr("Replay Failed"), message);
216 void MainWindow::startedLoadingTrace()
219 m_progressBar->show();
220 QFileInfo info(m_trace->fileName());
221 statusBar()->showMessage(
222 tr("Loading %1...").arg(info.fileName()));
225 void MainWindow::finishedLoadingTrace()
227 m_progressBar->hide();
231 QFileInfo info(m_trace->fileName());
232 statusBar()->showMessage(
233 tr("Loaded %1").arg(info.fileName()), 3000);
236 void MainWindow::replayTrace(bool dumpState)
238 if (m_traceFileName.isEmpty())
241 m_retracer->setFileName(m_traceFileName);
242 m_retracer->setCaptureState(dumpState);
243 if (m_retracer->captureState() && m_selectedEvent) {
245 if (m_selectedEvent->type() == ApiTraceEvent::Call) {
246 index = static_cast<ApiTraceCall*>(m_selectedEvent)->index();
247 } else if (m_selectedEvent->type() == ApiTraceEvent::Frame) {
248 ApiTraceFrame *frame =
249 static_cast<ApiTraceFrame*>(m_selectedEvent);
250 if (frame->calls.isEmpty()) {
251 //XXX i guess we could still get the current state
252 qDebug()<<"tried to get a state for an empty frame";
255 index = frame->calls.first()->index();
257 qDebug()<<"Unknown event type";
260 m_retracer->setCaptureAtCallNumber(index);
264 m_ui.actionStop->setEnabled(true);
265 m_progressBar->show();
267 statusBar()->showMessage(
268 tr("Looking up the state..."));
270 statusBar()->showMessage(
271 tr("Replaying the trace file..."));
274 void MainWindow::lookupState()
276 if (!m_selectedEvent) {
277 QMessageBox::warning(
278 this, tr("Unknown Event"),
279 tr("To inspect the state select an event in the event list."));
282 m_stateEvent = m_selectedEvent;
286 MainWindow::~MainWindow()
291 variantToString(const QVariant &var, QString &str)
293 if (var.type() == QVariant::List) {
294 QVariantList lst = var.toList();
295 str += QLatin1String("[");
296 for (int i = 0; i < lst.count(); ++i) {
297 QVariant val = lst[i];
298 variantToString(val, str);
299 if (i < lst.count() - 1)
300 str += QLatin1String(", ");
302 str += QLatin1String("]");
303 } else if (var.type() == QVariant::Map) {
304 Q_ASSERT(!"unsupported state type");
305 } else if (var.type() == QVariant::Hash) {
306 Q_ASSERT(!"unsupported state type");
308 str += var.toString();
312 static QTreeWidgetItem *
313 variantToItem(const QString &key, const QVariant &var, const QVariant &defaultVar);
316 variantMapToItems(const QVariantMap &map, const QVariantMap &defaultMap, QList<QTreeWidgetItem *> &items)
318 QVariantMap::const_iterator itr;
319 for (itr = map.constBegin(); itr != map.constEnd(); ++itr) {
320 QString key = itr.key();
321 QVariant var = itr.value();
322 QVariant defaultVar = defaultMap[key];
324 QTreeWidgetItem *item = variantToItem(key, var, defaultVar);
332 variantListToItems(const QVariantList &lst, const QVariantList &defaultLst, QList<QTreeWidgetItem *> &items)
334 for (int i = 0; i < lst.count(); ++i) {
335 QString key = QString::number(i);
336 QVariant var = lst[i];
339 if (i < defaultLst.count()) {
340 defaultVar = defaultLst[i];
343 QTreeWidgetItem *item = variantToItem(key, var, defaultVar);
351 isVariantDeep(const QVariant &var)
353 if (var.type() == QVariant::List) {
354 QVariantList lst = var.toList();
355 for (int i = 0; i < lst.count(); ++i) {
356 if (isVariantDeep(lst[i])) {
361 } else if (var.type() == QVariant::Map) {
363 } else if (var.type() == QVariant::Hash) {
370 static QTreeWidgetItem *
371 variantToItem(const QString &key, const QVariant &var, const QVariant &defaultVar)
373 if (var == defaultVar) {
379 bool deep = isVariantDeep(var);
381 variantToString(var, val);
384 //qDebug()<<"key = "<<key;
385 //qDebug()<<"val = "<<val;
390 QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidgetItem *)0, lst);
393 QList<QTreeWidgetItem *> children;
394 if (var.type() == QVariant::Map) {
395 QVariantMap map = var.toMap();
396 QVariantMap defaultMap = defaultVar.toMap();
397 variantMapToItems(map, defaultMap, children);
399 if (var.type() == QVariant::List) {
400 QVariantList lst = var.toList();
401 QVariantList defaultLst = defaultVar.toList();
402 variantListToItems(lst, defaultLst, children);
404 item->addChildren(children);
410 void MainWindow::fillStateForFrame()
414 if (!m_selectedEvent || m_selectedEvent->state().isEmpty())
417 bool nonDefaults = m_ui.nonDefaultsCB->isChecked();
418 QVariantMap defaultParams;
420 ApiTraceState defaultState = m_trace->defaultState();
421 defaultParams = defaultState.parameters();
424 const ApiTraceState &state = m_selectedEvent->state();
425 m_ui.stateTreeWidget->clear();
426 params = state.parameters();
427 QList<QTreeWidgetItem *> items;
428 variantMapToItems(params, defaultParams, items);
429 m_ui.stateTreeWidget->insertTopLevelItems(0, items);
431 QMap<QString, QString> shaderSources = state.shaderSources();
432 if (shaderSources.isEmpty()) {
433 m_sourcesWidget->setShaders(shaderSources);
435 m_sourcesWidget->setShaders(shaderSources);
438 const QList<ApiTexture> &textures =
440 const QList<ApiFramebuffer> &fbos =
441 state.framebuffers();
443 m_ui.surfacesTreeWidget->clear();
444 if (textures.isEmpty() && fbos.isEmpty()) {
445 m_ui.surfacesTab->setDisabled(false);
447 m_ui.surfacesTreeWidget->setIconSize(QSize(64, 64));
448 if (!textures.isEmpty()) {
449 QTreeWidgetItem *textureItem =
450 new QTreeWidgetItem(m_ui.surfacesTreeWidget);
451 textureItem->setText(0, tr("Textures"));
452 if (textures.count() <= 6)
453 textureItem->setExpanded(true);
455 for (int i = 0; i < textures.count(); ++i) {
456 const ApiTexture &texture =
458 QIcon icon(QPixmap::fromImage(texture.thumb()));
459 QTreeWidgetItem *item = new QTreeWidgetItem(textureItem);
460 item->setIcon(0, icon);
461 int width = texture.size().width();
462 int height = texture.size().height();
464 QString::fromLatin1("%1, %2 x %3")
465 .arg(texture.target())
468 item->setText(1, descr);
470 item->setData(0, Qt::UserRole,
474 if (!fbos.isEmpty()) {
475 QTreeWidgetItem *fboItem =
476 new QTreeWidgetItem(m_ui.surfacesTreeWidget);
477 fboItem->setText(0, tr("Framebuffers"));
478 if (fbos.count() <= 6)
479 fboItem->setExpanded(true);
481 for (int i = 0; i < fbos.count(); ++i) {
482 const ApiFramebuffer &fbo =
484 QIcon icon(QPixmap::fromImage(fbo.thumb()));
485 QTreeWidgetItem *item = new QTreeWidgetItem(fboItem);
486 item->setIcon(0, icon);
487 int width = fbo.size().width();
488 int height = fbo.size().height();
490 QString::fromLatin1("%1, %2 x %3")
494 item->setText(1, descr);
496 item->setData(0, Qt::UserRole,
500 m_ui.surfacesTab->setEnabled(true);
502 m_ui.stateDock->show();
505 void MainWindow::showSettings()
507 SettingsDialog dialog;
508 dialog.setFilterModel(m_proxyModel);
513 void MainWindow::openHelp(const QUrl &url)
515 QDesktopServices::openUrl(url);
518 void MainWindow::showSurfacesMenu(const QPoint &pos)
520 QTreeWidget *tree = m_ui.surfacesTreeWidget;
521 QTreeWidgetItem *item = tree->itemAt(pos);
525 QMenu menu(tr("Surfaces"), this);
527 QAction *act = menu.addAction(tr("View Image"));
528 act->setStatusTip(tr("View the currently selected surface"));
529 connect(act, SIGNAL(triggered()),
530 SLOT(showSelectedSurface()));
532 menu.exec(tree->viewport()->mapToGlobal(pos));
535 void MainWindow::showSelectedSurface()
537 QTreeWidgetItem *item =
538 m_ui.surfacesTreeWidget->currentItem();
543 QVariant var = item->data(0, Qt::UserRole);
544 m_imageViewer->setImage(var.value<QImage>());
545 m_imageViewer->show();
546 m_imageViewer->raise();
547 m_imageViewer->activateWindow();
550 void MainWindow::initObjects()
552 m_ui.stateTreeWidget->sortByColumn(0, Qt::AscendingOrder);
554 m_sourcesWidget = new ShadersSourceWidget(m_ui.shadersTab);
555 QVBoxLayout *layout = new QVBoxLayout;
556 layout->addWidget(m_sourcesWidget);
557 m_ui.shadersTab->setLayout(layout);
559 m_trace = new ApiTrace();
560 m_retracer = new Retracer(this);
562 m_vdataInterpreter = new VertexDataInterpreter(this);
563 m_vdataInterpreter->setListWidget(m_ui.vertexDataListWidget);
564 m_vdataInterpreter->setStride(
565 m_ui.vertexStrideSB->value());
566 m_vdataInterpreter->setComponents(
567 m_ui.vertexComponentsSB->value());
568 m_vdataInterpreter->setStartingOffset(
569 m_ui.startingOffsetSB->value());
570 m_vdataInterpreter->setTypeFromString(
571 m_ui.vertexTypeCB->currentText());
573 m_imageViewer = new ImageViewer(this);
575 m_model = new ApiTraceModel();
576 m_model->setApiTrace(m_trace);
577 m_proxyModel = new ApiTraceFilter();
578 m_proxyModel->setSourceModel(m_model);
579 m_ui.callView->setModel(m_proxyModel);
580 m_ui.callView->setItemDelegate(new ApiCallDelegate);
581 m_ui.callView->resizeColumnToContents(0);
582 m_ui.callView->header()->swapSections(0, 1);
583 m_ui.callView->setColumnWidth(1, 42);
584 m_ui.callView->setContextMenuPolicy(Qt::CustomContextMenu);
586 m_progressBar = new QProgressBar();
587 m_progressBar->setRange(0, 0);
588 statusBar()->addPermanentWidget(m_progressBar);
589 m_progressBar->hide();
591 m_argsEditor = new ArgumentsEditor(this);
593 m_ui.detailsDock->hide();
594 m_ui.vertexDataDock->hide();
595 m_ui.stateDock->hide();
596 setDockOptions(dockOptions() | QMainWindow::ForceTabbedDocks);
598 tabifyDockWidget(m_ui.stateDock, m_ui.vertexDataDock);
600 m_ui.surfacesTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
602 m_ui.detailsWebView->page()->setLinkDelegationPolicy(
603 QWebPage::DelegateExternalLinks);
605 m_jumpWidget = new JumpWidget(this);
606 m_ui.centralLayout->addWidget(m_jumpWidget);
607 m_jumpWidget->hide();
609 m_searchWidget = new SearchWidget(this);
610 m_ui.centralLayout->addWidget(m_searchWidget);
611 m_searchWidget->hide();
613 m_traceProcess = new TraceProcess(this);
615 new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_G),
616 this, SLOT(slotGoTo()));
617 new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_F),
618 this, SLOT(slotSearch()));
621 void MainWindow::initConnections()
623 connect(m_trace, SIGNAL(startedLoadingTrace()),
624 this, SLOT(startedLoadingTrace()));
625 connect(m_trace, SIGNAL(finishedLoadingTrace()),
626 this, SLOT(finishedLoadingTrace()));
628 connect(m_retracer, SIGNAL(finished(const QString&)),
629 this, SLOT(replayFinished(const QString&)));
630 connect(m_retracer, SIGNAL(error(const QString&)),
631 this, SLOT(replayError(const QString&)));
632 connect(m_retracer, SIGNAL(foundState(const ApiTraceState&)),
633 this, SLOT(replayStateFound(const ApiTraceState&)));
635 connect(m_ui.vertexInterpretButton, SIGNAL(clicked()),
636 m_vdataInterpreter, SLOT(interpretData()));
637 connect(m_ui.vertexTypeCB, SIGNAL(currentIndexChanged(const QString&)),
638 m_vdataInterpreter, SLOT(setTypeFromString(const QString&)));
639 connect(m_ui.vertexStrideSB, SIGNAL(valueChanged(int)),
640 m_vdataInterpreter, SLOT(setStride(int)));
641 connect(m_ui.vertexComponentsSB, SIGNAL(valueChanged(int)),
642 m_vdataInterpreter, SLOT(setComponents(int)));
643 connect(m_ui.startingOffsetSB, SIGNAL(valueChanged(int)),
644 m_vdataInterpreter, SLOT(setStartingOffset(int)));
647 connect(m_ui.actionNew, SIGNAL(triggered()),
648 this, SLOT(createTrace()));
649 connect(m_ui.actionOpen, SIGNAL(triggered()),
650 this, SLOT(openTrace()));
651 connect(m_ui.actionQuit, SIGNAL(triggered()),
652 this, SLOT(close()));
654 connect(m_ui.actionReplay, SIGNAL(triggered()),
655 this, SLOT(replayStart()));
656 connect(m_ui.actionStop, SIGNAL(triggered()),
657 this, SLOT(replayStop()));
658 connect(m_ui.actionLookupState, SIGNAL(triggered()),
659 this, SLOT(lookupState()));
660 connect(m_ui.actionOptions, SIGNAL(triggered()),
661 this, SLOT(showSettings()));
663 connect(m_ui.callView, SIGNAL(activated(const QModelIndex &)),
664 this, SLOT(callItemSelected(const QModelIndex &)));
665 connect(m_ui.callView, SIGNAL(customContextMenuRequested(QPoint)),
666 this, SLOT(customContextMenuRequested(QPoint)));
668 connect(m_ui.surfacesTreeWidget,
669 SIGNAL(customContextMenuRequested(const QPoint &)),
670 SLOT(showSurfacesMenu(const QPoint &)));
671 connect(m_ui.surfacesTreeWidget,
672 SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)),
673 SLOT(showSelectedSurface()));
675 connect(m_ui.detailsWebView, SIGNAL(linkClicked(const QUrl&)),
676 this, SLOT(openHelp(const QUrl&)));
678 connect(m_ui.nonDefaultsCB, SIGNAL(toggled(bool)),
679 this, SLOT(fillState(bool)));
681 connect(m_jumpWidget, SIGNAL(jumpTo(int)),
682 SLOT(slotJumpTo(int)));
684 connect(m_searchWidget,
685 SIGNAL(searchNext(const QString&, Qt::CaseSensitivity)),
686 SLOT(slotSearchNext(const QString&, Qt::CaseSensitivity)));
687 connect(m_searchWidget,
688 SIGNAL(searchPrev(const QString&, Qt::CaseSensitivity)),
689 SLOT(slotSearchPrev(const QString&, Qt::CaseSensitivity)));
691 connect(m_traceProcess, SIGNAL(tracedFile(const QString&)),
692 SLOT(createdTrace(const QString&)));
693 connect(m_traceProcess, SIGNAL(error(const QString&)),
694 SLOT(traceError(const QString&)));
697 void MainWindow::replayStateFound(const ApiTraceState &state)
699 m_stateEvent->setState(state);
700 m_model->stateSetOnEvent(m_stateEvent);
701 if (m_selectedEvent == m_stateEvent) {
704 m_ui.stateDock->hide();
708 void MainWindow::slotGoTo()
710 m_searchWidget->hide();
711 m_jumpWidget->show();
714 void MainWindow::slotJumpTo(int callNum)
716 QModelIndex index = m_proxyModel->callIndex(callNum);
717 if (index.isValid()) {
718 m_ui.callView->setCurrentIndex(index);
722 void MainWindow::createdTrace(const QString &path)
724 qDebug()<<"Done tracing "<<path;
728 void MainWindow::traceError(const QString &msg)
730 QMessageBox::warning(
736 void MainWindow::slotSearch()
738 m_jumpWidget->hide();
739 m_searchWidget->show();
742 void MainWindow::slotSearchNext(const QString &str, Qt::CaseSensitivity sensitivity)
744 QModelIndex index = m_ui.callView->currentIndex();
745 ApiTraceEvent *event = 0;
748 if (!index.isValid()) {
749 index = m_proxyModel->index(0, 0, QModelIndex());
750 if (!index.isValid()) {
751 qDebug()<<"no currently valid index";
752 m_searchWidget->setFound(false);
757 event = index.data(ApiTraceModel::EventRole).value<ApiTraceEvent*>();
758 ApiTraceCall *call = 0;
760 if (event->type() == ApiTraceCall::Call)
761 call = static_cast<ApiTraceCall*>(event);
763 Q_ASSERT(event->type() == ApiTraceCall::Frame);
764 ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(event);
765 call = frame->calls.value(0);
769 m_searchWidget->setFound(false);
772 const QList<ApiTraceCall*> &calls = m_trace->calls();
773 int callNum = calls.indexOf(call);
775 for (int i = callNum + 1; i < calls.count(); ++i) {
776 ApiTraceCall *testCall = calls[i];
777 QString txt = testCall->filterText();
778 if (txt.contains(str, sensitivity)) {
779 QModelIndex index = m_proxyModel->indexForCall(testCall);
780 /* if it's not valid it means that the proxy model has already
782 if (index.isValid()) {
783 m_ui.callView->setCurrentIndex(index);
784 m_searchWidget->setFound(true);
789 m_searchWidget->setFound(false);
792 void MainWindow::slotSearchPrev(const QString &str, Qt::CaseSensitivity sensitivity)
794 QModelIndex index = m_ui.callView->currentIndex();
795 ApiTraceEvent *event = 0;
798 if (!index.isValid()) {
799 index = m_proxyModel->index(0, 0, QModelIndex());
800 if (!index.isValid()) {
801 qDebug()<<"no currently valid index";
802 m_searchWidget->setFound(false);
807 event = index.data(ApiTraceModel::EventRole).value<ApiTraceEvent*>();
808 ApiTraceCall *call = 0;
810 if (event->type() == ApiTraceCall::Call)
811 call = static_cast<ApiTraceCall*>(event);
813 Q_ASSERT(event->type() == ApiTraceCall::Frame);
814 ApiTraceFrame *frame = static_cast<ApiTraceFrame*>(event);
815 call = frame->calls.value(0);
819 m_searchWidget->setFound(false);
822 const QList<ApiTraceCall*> &calls = m_trace->calls();
823 int callNum = calls.indexOf(call);
825 for (int i = callNum - 1; i >= 0; --i) {
826 ApiTraceCall *testCall = calls[i];
827 QString txt = testCall->filterText();
828 if (txt.contains(str, sensitivity)) {
829 QModelIndex index = m_proxyModel->indexForCall(testCall);
830 /* if it's not valid it means that the proxy model has already
832 if (index.isValid()) {
833 m_ui.callView->setCurrentIndex(index);
834 m_searchWidget->setFound(true);
839 m_searchWidget->setFound(false);
842 void MainWindow::fillState(bool nonDefaults)
845 ApiTraceState defaultState = m_trace->defaultState();
846 if (defaultState.isEmpty()) {
847 m_ui.nonDefaultsCB->blockSignals(true);
848 m_ui.nonDefaultsCB->setChecked(false);
849 m_ui.nonDefaultsCB->blockSignals(false);
850 int ret = QMessageBox::question(
851 this, tr("Empty Default State"),
852 tr("The applcation needs to figure out the "
853 "default state for the current trace. "
854 "This only has to be done once and "
855 "afterwards you will be able to enable "
856 "displaying of non default state for all calls."
857 "\nDo you want to lookup the default state now?"),
858 QMessageBox::Yes | QMessageBox::No);
859 if (ret != QMessageBox::Yes)
861 ApiTraceFrame *firstFrame =
863 ApiTraceEvent *oldSelected = m_selectedEvent;
866 m_selectedEvent = firstFrame;
868 m_selectedEvent = oldSelected;
874 void MainWindow::customContextMenuRequested(QPoint pos)
877 QModelIndex index = m_ui.callView->indexAt(pos);
879 callItemSelected(index);
880 if (!index.isValid())
883 ApiTraceEvent *event =
884 index.data(ApiTraceModel::EventRole).value<ApiTraceEvent*>();
885 if (!event || event->type() != ApiTraceEvent::Call)
888 menu.addAction(QIcon(":/resources/media-record.png"),
889 tr("Lookup state"), this, SLOT(lookupState()));
890 menu.addAction(tr("Edit"), this, SLOT(editCall()));
892 menu.exec(QCursor::pos());
895 void MainWindow::editCall()
897 if (m_selectedEvent && m_selectedEvent->type() == ApiTraceEvent::Call) {
898 ApiTraceCall *call = static_cast<ApiTraceCall*>(m_selectedEvent);
899 m_argsEditor->setCall(call);
900 m_argsEditor->show();
904 #include "mainwindow.moc"