From: Zack Rusin Date: Mon, 18 Apr 2011 22:03:34 +0000 (-0400) Subject: Implement an edit menu. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=9623dafd0781222c06a930a2f312607aaae24277;p=apitrace Implement an edit menu. fixes #6 --- diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index cd63962..f40a144 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -670,6 +670,15 @@ void MainWindow::initConnections() connect(m_ui.actionQuit, SIGNAL(triggered()), this, SLOT(close())); + connect(m_ui.actionFind, SIGNAL(triggered()), + this, SLOT(slotSearch())); + connect(m_ui.actionGo, SIGNAL(triggered()), + this, SLOT(slotGoTo())); + connect(m_ui.actionGoFrameStart, SIGNAL(triggered()), + this, SLOT(slotGoFrameStart())); + connect(m_ui.actionGoFrameEnd, SIGNAL(triggered()), + this, SLOT(slotGoFrameEnd())); + connect(m_ui.actionReplay, SIGNAL(triggered()), this, SLOT(replayStart())); connect(m_ui.actionStop, SIGNAL(triggered()), @@ -934,4 +943,59 @@ void MainWindow::slotSaved() m_progressBar->hide(); } +void MainWindow::slotGoFrameStart() +{ + ApiTraceFrame *frame = currentFrame(); + if (!frame || frame->calls.isEmpty()) { + return; + } + + QList::const_iterator itr; + + itr = frame->calls.constBegin(); + while (itr != frame->calls.constEnd()) { + ApiTraceCall *call = *itr; + QModelIndex idx = m_proxyModel->indexForCall(call); + if (idx.isValid()) { + m_ui.callView->setCurrentIndex(idx); + break; + } + ++itr; + } +} + +void MainWindow::slotGoFrameEnd() +{ + ApiTraceFrame *frame = currentFrame(); + if (!frame || frame->calls.isEmpty()) { + return; + } + QList::const_iterator itr; + + itr = frame->calls.constEnd(); + do { + --itr; + ApiTraceCall *call = *itr; + QModelIndex idx = m_proxyModel->indexForCall(call); + if (idx.isValid()) { + m_ui.callView->setCurrentIndex(idx); + break; + } + } while (itr != frame->calls.constBegin()); +} + +ApiTraceFrame * MainWindow::currentFrame() const +{ + if (m_selectedEvent) { + if (m_selectedEvent->type() == ApiTraceEvent::Frame) { + return static_cast(m_selectedEvent); + } else { + Q_ASSERT(m_selectedEvent->type() == ApiTraceEvent::Call); + ApiTraceCall *call = static_cast(m_selectedEvent); + return call->parentFrame(); + } + } + return NULL; +} + #include "mainwindow.moc" diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 07a1e91..b16dbb4 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -62,6 +62,8 @@ private slots: void editCall(); void slotStartedSaving(); void slotSaved(); + void slotGoFrameStart(); + void slotGoFrameEnd(); private: void initObjects(); @@ -69,6 +71,7 @@ private: void newTraceFile(const QString &fileName); void replayTrace(bool dumpState); void fillStateForFrame(); + ApiTraceFrame *currentFrame() const; private: Ui_MainWindow m_ui; diff --git a/gui/qapitrace.qrc b/gui/qapitrace.qrc index 6f6597f..4d8223f 100644 --- a/gui/qapitrace.qrc +++ b/gui/qapitrace.qrc @@ -6,9 +6,13 @@ resources/document-edit.png resources/document-new.png resources/document-open.png + resources/edit-find.png resources/edit-undo.png resources/emblem-locked.png + resources/go-bottom.png resources/go-down-search.png + resources/go-jump.png + resources/go-top.png resources/go-up-search.png resources/media-playback-start.png resources/media-playback-stop.png diff --git a/gui/resources/edit-find.png b/gui/resources/edit-find.png new file mode 100644 index 0000000..9b3fe6b Binary files /dev/null and b/gui/resources/edit-find.png differ diff --git a/gui/resources/go-bottom.png b/gui/resources/go-bottom.png new file mode 100644 index 0000000..a84d54b Binary files /dev/null and b/gui/resources/go-bottom.png differ diff --git a/gui/resources/go-jump.png b/gui/resources/go-jump.png new file mode 100644 index 0000000..2ed9038 Binary files /dev/null and b/gui/resources/go-jump.png differ diff --git a/gui/resources/go-top.png b/gui/resources/go-top.png new file mode 100644 index 0000000..5f16e58 Binary files /dev/null and b/gui/resources/go-top.png differ diff --git a/gui/ui/mainwindow.ui b/gui/ui/mainwindow.ui index c0c6237..76c391e 100644 --- a/gui/ui/mainwindow.ui +++ b/gui/ui/mainwindow.ui @@ -67,7 +67,17 @@ + + + &Edit + + + + + + + @@ -454,6 +464,54 @@ New + + + + :/resources/edit-find.png:/resources/edit-find.png + + + Find + + + Ctrl+F + + + + + + :/resources/go-jump.png:/resources/go-jump.png + + + Go to Call + + + Ctrl+G + + + + + + :/resources/go-top.png:/resources/go-top.png + + + Go to Frame Start + + + Ctrl+A + + + + + + :/resources/go-bottom.png:/resources/go-bottom.png + + + Go to Frame End + + + Ctrl+E + + stateDock vertexDataDock