]> git.cworth.org Git - apitrace/commitdiff
Implement an edit menu.
authorZack Rusin <zack@kde.org>
Mon, 18 Apr 2011 22:03:34 +0000 (18:03 -0400)
committerZack Rusin <zack@kde.org>
Mon, 18 Apr 2011 22:03:34 +0000 (18:03 -0400)
fixes #6

gui/mainwindow.cpp
gui/mainwindow.h
gui/qapitrace.qrc
gui/resources/edit-find.png [new file with mode: 0644]
gui/resources/go-bottom.png [new file with mode: 0644]
gui/resources/go-jump.png [new file with mode: 0644]
gui/resources/go-top.png [new file with mode: 0644]
gui/ui/mainwindow.ui

index cd63962d068f704e57984efa77002ccfc0024348..f40a1441f61eed895f1e7ba1a40af7e118684380 100644 (file)
@@ -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<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"
index 07a1e912798767bcef9bb73519a7eb475d33a412..b16dbb4de1a1dd130b2307c82fa3198c97f33343 100644 (file)
@@ -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;
index 6f6597fef7b4809c9396d17214c8ddfb30b3a13b..4d8223f058af16d3fb027d2e9b89c66c61b7de1c 100644 (file)
@@ -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>
diff --git a/gui/resources/edit-find.png b/gui/resources/edit-find.png
new file mode 100644 (file)
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 (file)
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 (file)
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 (file)
index 0000000..5f16e58
Binary files /dev/null and b/gui/resources/go-top.png differ
index c0c623770b66bebd7fec46569a2af51f23264dd7..76c391e59d536969a33f7dc9e89bc7303b5ecbaf 100644 (file)
     <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"/>
     <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>