Skip to content

Commit

Permalink
Implement an edit menu.
Browse files Browse the repository at this point in the history
fixes #6
  • Loading branch information
zackr committed Apr 18, 2011
1 parent 0ad49cb commit 9623daf
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 0 deletions.
64 changes: 64 additions & 0 deletions gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down Expand Up @@ -934,4 +943,59 @@ void MainWindow::slotSaved()
m_progressBar->hide();
}

void MainWindow::slotGoFrameStart()
{
ApiTraceFrame *frame = currentFrame();
if (!frame || frame->calls.isEmpty()) {
return;
}

QList<ApiTraceCall*>::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<ApiTraceCall*>::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<ApiTraceFrame*>(m_selectedEvent);
} else {
Q_ASSERT(m_selectedEvent->type() == ApiTraceEvent::Call);
ApiTraceCall *call = static_cast<ApiTraceCall*>(m_selectedEvent);
return call->parentFrame();
}
}
return NULL;
}

#include "mainwindow.moc"
3 changes: 3 additions & 0 deletions gui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,16 @@ private slots:
void editCall();
void slotStartedSaving();
void slotSaved();
void slotGoFrameStart();
void slotGoFrameEnd();

private:
void initObjects();
void initConnections();
void newTraceFile(const QString &fileName);
void replayTrace(bool dumpState);
void fillStateForFrame();
ApiTraceFrame *currentFrame() const;

private:
Ui_MainWindow m_ui;
Expand Down
4 changes: 4 additions & 0 deletions gui/qapitrace.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
<file>resources/document-edit.png</file>
<file>resources/document-new.png</file>
<file>resources/document-open.png</file>
<file>resources/edit-find.png</file>
<file>resources/edit-undo.png</file>
<file>resources/emblem-locked.png</file>
<file>resources/go-bottom.png</file>
<file>resources/go-down-search.png</file>
<file>resources/go-jump.png</file>
<file>resources/go-top.png</file>
<file>resources/go-up-search.png</file>
<file>resources/media-playback-start.png</file>
<file>resources/media-playback-stop.png</file>
Expand Down
Binary file added gui/resources/edit-find.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gui/resources/go-bottom.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gui/resources/go-jump.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gui/resources/go-top.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions gui/ui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,17 @@
<addaction name="separator"/>
<addaction name="actionOptions"/>
</widget>
<widget class="QMenu" name="menuEdit">
<property name="title">
<string>&amp;Edit</string>
</property>
<addaction name="actionFind"/>
<addaction name="actionGo"/>
<addaction name="actionGoFrameStart"/>
<addaction name="actionGoFrameEnd"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
<addaction name="menu_Trace"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
Expand Down Expand Up @@ -454,6 +464,54 @@
<string>New</string>
</property>
</action>
<action name="actionFind">
<property name="icon">
<iconset resource="../qapitrace.qrc">
<normaloff>:/resources/edit-find.png</normaloff>:/resources/edit-find.png</iconset>
</property>
<property name="text">
<string>Find</string>
</property>
<property name="shortcut">
<string>Ctrl+F</string>
</property>
</action>
<action name="actionGo">
<property name="icon">
<iconset resource="../qapitrace.qrc">
<normaloff>:/resources/go-jump.png</normaloff>:/resources/go-jump.png</iconset>
</property>
<property name="text">
<string>Go to Call</string>
</property>
<property name="shortcut">
<string>Ctrl+G</string>
</property>
</action>
<action name="actionGoFrameStart">
<property name="icon">
<iconset resource="../qapitrace.qrc">
<normaloff>:/resources/go-top.png</normaloff>:/resources/go-top.png</iconset>
</property>
<property name="text">
<string>Go to Frame Start</string>
</property>
<property name="shortcut">
<string>Ctrl+A</string>
</property>
</action>
<action name="actionGoFrameEnd">
<property name="icon">
<iconset resource="../qapitrace.qrc">
<normaloff>:/resources/go-bottom.png</normaloff>:/resources/go-bottom.png</iconset>
</property>
<property name="text">
<string>Go to Frame End</string>
</property>
<property name="shortcut">
<string>Ctrl+E</string>
</property>
</action>
<zorder>stateDock</zorder>
<zorder>vertexDataDock</zorder>
</widget>
Expand Down

0 comments on commit 9623daf

Please sign in to comment.