From df04e575856697b1f2817020ac4c036028f35b4c Mon Sep 17 00:00:00 2001
From: hjk <qtc-committer@nokia.com>
Date: Mon, 8 Nov 2010 15:41:44 +0100
Subject: [PATCH] debugger: move more gui bit from engine to plugin

---
 src/plugins/debugger/debuggerengine.cpp | 76 +----------------------
 src/plugins/debugger/debuggerengine.h   |  5 --
 src/plugins/debugger/debuggerplugin.cpp | 81 +++++++++++++++++++++++--
 src/plugins/debugger/gdb/gdbengine.cpp  |  4 +-
 4 files changed, 80 insertions(+), 86 deletions(-)

diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp
index 2bf8e9f3e27..daad800f3ba 100644
--- a/src/plugins/debugger/debuggerengine.cpp
+++ b/src/plugins/debugger/debuggerengine.cpp
@@ -93,6 +93,7 @@ using namespace TextEditor;
 #endif
 # define XSDEBUG(s) qDebug() << s
 
+
 ///////////////////////////////////////////////////////////////////////
 //
 // DebuggerStartParameters
@@ -211,9 +212,6 @@ public:
     ~DebuggerEnginePrivate() {}
 
 public slots:
-    void breakpointSetRemoveMarginActionTriggered();
-    void breakpointEnableDisableMarginActionTriggered();
-
     void doSetupInferior();
     void doRunEngine();
     void doShutdownEngine();
@@ -257,11 +255,6 @@ public slots:
         m_runControl->bringApplicationToForeground(m_inferiorPid);
     }
 
-private slots:
-    void slotEditBreakpoint();
-    void slotRunToLine();
-    void slotJumpToLine();
-
 public:
     DebuggerState state() const { return m_state; }
 
@@ -294,73 +287,6 @@ public:
     bool m_isSlaveEngine;
 };
 
-// Retrieve file name and line and optionally address
-// from the data set on the text editor context menu action.
-static bool positionFromContextActionData(const QObject *sender,
-                                          QString *fileName,
-                                          int *lineNumber,
-                                          quint64 *address = 0)
-{
-    if (const QAction *action = qobject_cast<const QAction *>(sender)) {
-        const QVariantList data = action->data().toList();
-        if (data.size() >= (address ? 3 : 2)) {
-            *fileName = data.front().toString();
-            *lineNumber = data.at(1).toInt();
-            if (address)
-                *address = data.at(2).toULongLong();
-            return true;
-        }
-    }
-    return false;
-}
-
-void DebuggerEnginePrivate::breakpointSetRemoveMarginActionTriggered()
-{
-    QString fileName;
-    int lineNumber;
-    quint64 address;
-    if (positionFromContextActionData(sender(), &fileName, &lineNumber, &address))
-        m_engine->breakHandler()->toggleBreakpoint(fileName, lineNumber, address);
- }
-
-
-void DebuggerEnginePrivate::slotRunToLine()
-{
-    // Run to line, file name and line number set as list.
-    QString fileName;
-    int lineNumber;
-    if (positionFromContextActionData(sender(), &fileName, &lineNumber)) {
-        m_engine->resetLocation();
-        m_engine->executeRunToLine(fileName, lineNumber);
-    }
-}
-
-void DebuggerEnginePrivate::slotJumpToLine()
-{
-    QString fileName;
-    int lineNumber;
-    if (positionFromContextActionData(sender(), &fileName, &lineNumber))
-        m_engine->executeJumpToLine(fileName, lineNumber);
-}
-
- void DebuggerEnginePrivate::breakpointEnableDisableMarginActionTriggered()
-{
-    QString fileName;
-    int lineNumber;
-    if (positionFromContextActionData(sender(), &fileName, &lineNumber))
-        m_engine->breakHandler()->toggleBreakpointEnabled(fileName, lineNumber);
-}
-
-void DebuggerEnginePrivate::slotEditBreakpoint()
-{
-    const QAction *act = qobject_cast<QAction *>(sender());
-    QTC_ASSERT(act, return);
-    const QVariant data = act->data();
-    QTC_ASSERT(qVariantCanConvert<BreakpointData *>(data), return);
-    BreakpointData *breakPointData = qvariant_cast<BreakpointData *>(data);
-    BreakWindow::editBreakpoint(breakPointData, ICore::instance()->mainWindow());
-}
-
 
 //////////////////////////////////////////////////////////////////////
 //
diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h
index 6c6b93133ec..c8272000a24 100644
--- a/src/plugins/debugger/debuggerengine.h
+++ b/src/plugins/debugger/debuggerengine.h
@@ -253,11 +253,6 @@ public:
     void breakByFunction(const QString &functionName);
     void breakByFunctionMain();
     
-    void executeStepX();
-    void executeStepOutX();
-    void executeStepNextX();
-    void executeReturnX();
-
     DebuggerState state() const;
     DebuggerState lastGoodState() const;
     DebuggerState targetState() const;
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index 771b0e5d06d..f8b846f6f6a 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -409,11 +409,29 @@ static QToolButton *toolButton(QAction *action)
     return button;
 }
 
+// Retrieve file name and line and optionally address
+// from the data set on the text editor context menu action.
+static bool positionFromContextActionData(const QObject *sender,
+                                          QString *fileName,
+                                          int *lineNumber,
+                                          quint64 *address = 0)
+{
+    if (const QAction *action = qobject_cast<const QAction *>(sender)) {
+        const QVariantList data = action->data().toList();
+        if (data.size() >= (address ? 3 : 2)) {
+            *fileName = data.front().toString();
+            *lineNumber = data.at(1).toInt();
+            if (address)
+                *address = data.at(2).toULongLong();
+            return true;
+        }
+    }
+    return false;
+}
+
 namespace Debugger {
 namespace Internal {
 
-static const char *Role = "ROLE";
-
 // FIXME: Outdated?
 // The createCdbEngine function takes a list of options pages it can add to.
 // This allows for having a "enabled" toggle on the page independently
@@ -854,6 +872,25 @@ public:
     DebuggerEngine *currentEngine() const { return m_currentEngine; }
 
 public slots:
+    void selectThread(int index);
+
+    void breakpointSetRemoveMarginActionTriggered()
+    {
+        QString fileName;
+        int lineNumber;
+        quint64 address;
+        if (positionFromContextActionData(sender(), &fileName, &lineNumber, &address))
+            m_breakHandler->toggleBreakpoint(fileName, lineNumber, address);
+     }
+
+    void breakpointEnableDisableMarginActionTriggered()
+    {
+        QString fileName;
+        int lineNumber;
+        if (positionFromContextActionData(sender(), &fileName, &lineNumber))
+            m_breakHandler->toggleBreakpointEnabled(fileName, lineNumber);
+    }
+
     void updateWatchersHeader(int section, int, int newSize)
     {
         m_watchersWindow->header()->resizeSection(section, newSize);
@@ -988,8 +1025,17 @@ public slots:
             currentEngine()->executeNext();
     }
 
-    void handleExecStepOut() { resetLocation(); currentEngine()->executeStepOut(); }
-    void handleExecReturn() { resetLocation(); currentEngine()->executeReturn(); }
+    void handleExecStepOut()
+    {
+        resetLocation();
+        currentEngine()->executeStepOut();
+    }
+
+    void handleExecReturn()
+    {
+        resetLocation();
+        currentEngine()->executeReturn();
+    }
 
     void handleExecJumpToLine()
     {
@@ -1011,6 +1057,33 @@ public slots:
         currentEngine()->executeRunToFunction(); // FIXME: move code from engine here.
     }
 
+    void slotEditBreakpoint()
+    {
+        const QAction *act = qobject_cast<QAction *>(sender());
+        QTC_ASSERT(act, return);
+        const QVariant data = act->data();
+        QTC_ASSERT(qVariantCanConvert<BreakpointData *>(data), return);
+        BreakpointData *breakPointData = qvariant_cast<BreakpointData *>(data);
+        BreakWindow::editBreakpoint(breakPointData, ICore::instance()->mainWindow());
+    }
+
+    void slotRunToLine()
+    {
+        // Run to line, file name and line number set as list.
+        QString fileName;
+        int lineNumber;
+        if (positionFromContextActionData(sender(), &fileName, &lineNumber))
+            handleExecRunToLine();
+    }
+
+    void slotJumpToLine()
+    {
+        QString fileName;
+        int lineNumber;
+        if (positionFromContextActionData(sender(), &fileName, &lineNumber))
+            currentEngine()->executeJumpToLine(fileName, lineNumber);
+    }
+
     void handleAddToWatchWindow()
     {
         // Requires a selection, but that's the only case we want anyway.
diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index af97def426e..ea1456e40dc 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -1310,13 +1310,13 @@ void GdbEngine::handleStopResponse(const GdbMi &data)
             if (isLeavableFunction(funcName, fileName)) {
                 //showMessage(_("LEAVING ") + funcName);
                 ++stepCounter;
-                executeStepOutX();
+                executeStepOut();
                 return;
             }
             if (isSkippableFunction(funcName, fileName)) {
                 //showMessage(_("SKIPPING ") + funcName);
                 ++stepCounter;
-                executeStepX();
+                executeStep();
                 return;
             }
             //if (stepCounter)
-- 
GitLab