]> git.cworth.org Git - apitrace/commitdiff
Make the editor a dialog.
authorZack Rusin <zack@kde.org>
Fri, 15 Apr 2011 23:29:45 +0000 (19:29 -0400)
committerZack Rusin <zack@kde.org>
Fri, 15 Apr 2011 23:29:45 +0000 (19:29 -0400)
gui/argumentseditor.cpp
gui/argumentseditor.h
gui/mainwindow.cpp
gui/mainwindow.h
gui/ui/argumentseditor.ui
gui/ui/mainwindow.ui

index f050ec374e4b08412ac105bcb75215277289d437..de467848125347d443f8b9dffe0ca58c47d40ff5 100644 (file)
@@ -120,7 +120,7 @@ bool BooleanComboBox::value() const
 }
 
 ArgumentsEditor::ArgumentsEditor(QWidget *parent)
-    : QWidget(parent),
+    : QDialog(parent),
       m_model(new QStandardItemModel()),
       m_call(0)
 {
index aa8452df3126b1bfd51e0bd644ed290ee8dceaba..4454e003cb312ae4e93378564acd8c5658b3e843 100644 (file)
@@ -3,9 +3,9 @@
 
 #include "ui_argumentseditor.h"
 #include <QComboBox>
+#include <QDialog>
 #include <QItemEditorFactory>
 #include <QStandardItemModel>
-#include <QWidget>
 
 class ApiTraceCall;
 
@@ -27,7 +27,7 @@ public:
     QByteArray valuePropertyName(QVariant::Type) const;
 };
 
-class ArgumentsEditor : public QWidget
+class ArgumentsEditor : public QDialog
 {
     Q_OBJECT
 public:
index 081f0bfe25baf382d55673cfb7d939c9be3442b8..d67bc03d5020475e8b0cd02cc841e1ef9d2a1642 100644 (file)
@@ -100,7 +100,6 @@ void MainWindow::callItemSelected(const QModelIndex &index)
         ApiTraceCall *call = static_cast<ApiTraceCall*>(event);
         m_ui.detailsWebView->setHtml(call->toHtml());
         m_ui.detailsDock->show();
-        m_argsEditor->setCall(call);
         if (call->hasBinaryData()) {
             QByteArray data =
                 call->argValues[call->binaryDataIndex()].toByteArray();
@@ -122,7 +121,6 @@ void MainWindow::callItemSelected(const QModelIndex &index)
                 }
             }
         }
-        m_ui.argsEditorDock->show();
         m_ui.vertexDataDock->setVisible(call->hasBinaryData());
         m_selectedEvent = call;
     } else {
@@ -582,6 +580,7 @@ void MainWindow::initObjects()
     m_ui.callView->resizeColumnToContents(0);
     m_ui.callView->header()->swapSections(0, 1);
     m_ui.callView->setColumnWidth(1, 42);
+    m_ui.callView->setContextMenuPolicy(Qt::CustomContextMenu);
 
     m_progressBar = new QProgressBar();
     m_progressBar->setRange(0, 0);
@@ -589,16 +588,13 @@ void MainWindow::initObjects()
     m_progressBar->hide();
 
     m_argsEditor = new ArgumentsEditor(this);
-    m_ui.argsEditorLayout->addWidget(m_argsEditor);
 
     m_ui.detailsDock->hide();
     m_ui.vertexDataDock->hide();
     m_ui.stateDock->hide();
-    m_ui.argsEditorDock->hide();
     setDockOptions(dockOptions() | QMainWindow::ForceTabbedDocks);
 
     tabifyDockWidget(m_ui.stateDock, m_ui.vertexDataDock);
-    tabifyDockWidget(m_ui.vertexDataDock, m_ui.argsEditorDock);
 
     m_ui.surfacesTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
 
@@ -665,6 +661,8 @@ void MainWindow::initConnections()
 
     connect(m_ui.callView, SIGNAL(activated(const QModelIndex &)),
             this, SLOT(callItemSelected(const QModelIndex &)));
+    connect(m_ui.callView, SIGNAL(customContextMenuRequested(QPoint)),
+            this, SLOT(customContextMenuRequested(QPoint)));
 
     connect(m_ui.surfacesTreeWidget,
             SIGNAL(customContextMenuRequested(const QPoint &)),
@@ -872,4 +870,34 @@ void MainWindow::fillState(bool nonDefaults)
     fillStateForFrame();
 }
 
+void MainWindow::customContextMenuRequested(QPoint pos)
+{
+    QMenu menu;
+    QModelIndex index = m_ui.callView->indexAt(pos);
+
+    callItemSelected(index);
+    if (!index.isValid())
+        return;
+
+    ApiTraceEvent *event =
+        index.data(ApiTraceModel::EventRole).value<ApiTraceEvent*>();
+    if (!event || event->type() != ApiTraceEvent::Call)
+        return;
+
+    menu.addAction(QIcon(":/resources/media-record.png"),
+                   tr("Lookup state"), this, SLOT(lookupState()));
+    menu.addAction(tr("Edit"), this, SLOT(editCall()));
+
+    menu.exec(QCursor::pos());
+}
+
+void MainWindow::editCall()
+{
+    if (m_selectedEvent && m_selectedEvent->type() == ApiTraceEvent::Call) {
+        ApiTraceCall *call = static_cast<ApiTraceCall*>(m_selectedEvent);
+        m_argsEditor->setCall(call);
+        m_argsEditor->show();
+    }
+}
+
 #include "mainwindow.moc"
index 99f722d0bccd0a1c18117e795fdf694f52567663..d2c9f28e798cacc0294da9b080bd4c20ef1536e0 100644 (file)
@@ -58,6 +58,8 @@ private slots:
     void slotSearchNext(const QString &str, Qt::CaseSensitivity sensitivity);
     void slotSearchPrev(const QString &str, Qt::CaseSensitivity sensitivity);
     void fillState(bool nonDefaults);
+    void customContextMenuRequested(QPoint pos);
+    void editCall();
 
 private:
     void initObjects();
index 268e838e7af34edcf466ad14632ce3836524485b..9ee0769dad941920be09c1522e2899976b0bf233 100644 (file)
@@ -1,17 +1,23 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ui version="4.0">
  <class>ArgumentsEditor</class>
- <widget class="QWidget" name="ArgumentsEditor">
+ <widget class="QDialog" name="ArgumentsEditor">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>290</width>
-    <height>472</height>
+    <width>481</width>
+    <height>615</height>
    </rect>
   </property>
   <property name="windowTitle">
-   <string>Form</string>
+   <string>Trace Arguments Editor</string>
+  </property>
+  <property name="sizeGripEnabled">
+   <bool>false</bool>
+  </property>
+  <property name="modal">
+   <bool>true</bool>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout_2">
    <item>
@@ -92,7 +98,7 @@
    <item>
     <widget class="QTabWidget" name="argsTabWidget">
      <property name="currentIndex">
-      <number>1</number>
+      <number>0</number>
      </property>
      <widget class="QWidget" name="tab">
       <attribute name="title">
          <item>
           <widget class="QComboBox" name="selectStringCB"/>
          </item>
-         <item>
-          <widget class="QCheckBox" name="editableBox">
-           <property name="text">
-            <string>Editable</string>
-           </property>
-          </widget>
-         </item>
          <item>
           <spacer name="horizontalSpacer_4">
            <property name="orientation">
      </widget>
     </widget>
    </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <customwidgets>
  <resources>
   <include location="../qapitrace.qrc"/>
  </resources>
- <connections/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>ArgumentsEditor</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>ArgumentsEditor</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
 </ui>
index c5f05268f287e63fd5a67b1a3211ed93884169d5..d18a0725fe537bcf6fb53c68e26c905f7e6791c7 100644 (file)
     </layout>
    </widget>
   </widget>
-  <widget class="QDockWidget" name="argsEditorDock">
-   <property name="windowTitle">
-    <string>Arguments Editor</string>
-   </property>
-   <attribute name="dockWidgetArea">
-    <number>2</number>
-   </attribute>
-   <widget class="QWidget" name="dockWidgetContents_4">
-    <layout class="QVBoxLayout" name="verticalLayout_6">
-     <item>
-      <layout class="QVBoxLayout" name="argsEditorLayout"/>
-     </item>
-    </layout>
-   </widget>
-  </widget>
   <action name="actionExit">
    <property name="text">
     <string>Exit</string>