From 2b529b77bc8caf0f4e56ea6dd1af4f0423fd74d6 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 15 Jun 2009 19:08:16 +0200 Subject: small refactoring so remote debugger can use the same code --- src/scripttools/debugging/qscriptdebugger.cpp | 41 ++++++++++++++++++++++ src/scripttools/debugging/qscriptdebugger_p.h | 5 +++ .../debugging/qscriptenginedebugger.cpp | 39 ++++---------------- 3 files changed, 52 insertions(+), 33 deletions(-) diff --git a/src/scripttools/debugging/qscriptdebugger.cpp b/src/scripttools/debugging/qscriptdebugger.cpp index 454d051..181f4ae 100644 --- a/src/scripttools/debugging/qscriptdebugger.cpp +++ b/src/scripttools/debugging/qscriptdebugger.cpp @@ -94,6 +94,8 @@ #include #include #include +#include +#include #include QT_BEGIN_NAMESPACE @@ -1905,6 +1907,45 @@ QAction *QScriptDebugger::goToLineAction(QObject *parent) const return d->goToLineAction; } +QMenu *QScriptDebugger::createStandardMenu(QWidget *widgetParent, QObject *actionParent) +{ + QMenu *menu = new QMenu(widgetParent); + menu->setTitle(QObject::tr("Debug")); + menu->addAction(action(ContinueAction, actionParent)); + menu->addAction(action(InterruptAction, actionParent)); + menu->addAction(action(StepIntoAction, actionParent)); + menu->addAction(action(StepOverAction, actionParent)); + menu->addAction(action(StepOutAction, actionParent)); + menu->addAction(action(RunToCursorAction, actionParent)); + menu->addAction(action(RunToNewScriptAction, actionParent)); + + menu->addSeparator(); + menu->addAction(action(ToggleBreakpointAction, actionParent)); + + menu->addSeparator(); + menu->addAction(action(ClearDebugOutputAction, actionParent)); + menu->addAction(action(ClearErrorLogAction, actionParent)); + menu->addAction(action(ClearConsoleAction, actionParent)); + + return menu; +} + +QToolBar *QScriptDebugger::createStandardToolBar(QWidget *widgetParent, QObject *actionParent) +{ + QToolBar *tb = new QToolBar(widgetParent); + tb->setObjectName(QLatin1String("qtscriptdebugger_standardToolBar")); + tb->addAction(action(ContinueAction, actionParent)); + tb->addAction(action(InterruptAction, actionParent)); + tb->addAction(action(StepIntoAction, actionParent)); + tb->addAction(action(StepOverAction, actionParent)); + tb->addAction(action(StepOutAction, actionParent)); + tb->addAction(action(RunToCursorAction, actionParent)); + tb->addAction(action(RunToNewScriptAction, actionParent)); + tb->addSeparator(); + tb->addAction(action(FindInScriptAction, actionParent)); + return tb; +} + /*! \reimp */ diff --git a/src/scripttools/debugging/qscriptdebugger_p.h b/src/scripttools/debugging/qscriptdebugger_p.h index 6d8fcab..e8fcf21 100644 --- a/src/scripttools/debugging/qscriptdebugger_p.h +++ b/src/scripttools/debugging/qscriptdebugger_p.h @@ -70,6 +70,8 @@ class QScriptErrorLogWidgetInterface; class QScriptDebuggerWidgetFactoryInterface; class QAction; class QEvent; +class QMenu; +class QToolBar; class QScriptDebuggerPrivate; class Q_AUTOTEST_EXPORT QScriptDebugger : public QObject @@ -165,6 +167,9 @@ public: QAction *clearConsoleAction(QObject *parent) const; QAction *clearErrorLogAction(QObject *parent) const; + QMenu *createStandardMenu(QWidget *widgetParent, QObject *actionParent); + QToolBar *createStandardToolBar(QWidget *widgetParent, QObject *actionParent); + bool eventFilter(QObject *, QEvent *e); Q_SIGNALS: diff --git a/src/scripttools/debugging/qscriptenginedebugger.cpp b/src/scripttools/debugging/qscriptenginedebugger.cpp index a278e14..6ee6c98 100644 --- a/src/scripttools/debugging/qscriptenginedebugger.cpp +++ b/src/scripttools/debugging/qscriptenginedebugger.cpp @@ -49,9 +49,7 @@ #include #include #include -#include #include -#include #include // this has to be outside the namespace @@ -589,25 +587,9 @@ QMainWindow *QScriptEngineDebugger::standardWindow() const */ QMenu *QScriptEngineDebugger::createStandardMenu(QWidget *parent) { - QMenu *menu = new QMenu(parent); - menu->setTitle(QObject::tr("Debug")); - menu->addAction(action(ContinueAction)); - menu->addAction(action(InterruptAction)); - menu->addAction(action(StepIntoAction)); - menu->addAction(action(StepOverAction)); - menu->addAction(action(StepOutAction)); - menu->addAction(action(RunToCursorAction)); - menu->addAction(action(RunToNewScriptAction)); - - menu->addSeparator(); - menu->addAction(action(ToggleBreakpointAction)); - - menu->addSeparator(); - menu->addAction(action(ClearDebugOutputAction)); - menu->addAction(action(ClearErrorLogAction)); - menu->addAction(action(ClearConsoleAction)); - - return menu; + Q_D(QScriptEngineDebugger); + d->createDebugger(); + return d->debugger->createStandardMenu(parent, this); } /*! @@ -618,18 +600,9 @@ QMenu *QScriptEngineDebugger::createStandardMenu(QWidget *parent) */ QToolBar *QScriptEngineDebugger::createStandardToolBar(QWidget *parent) { - QToolBar *tb = new QToolBar(parent); - tb->setObjectName(QLatin1String("qtscriptdebugger_standardToolBar")); - tb->addAction(action(ContinueAction)); - tb->addAction(action(InterruptAction)); - tb->addAction(action(StepIntoAction)); - tb->addAction(action(StepOverAction)); - tb->addAction(action(StepOutAction)); - tb->addAction(action(RunToCursorAction)); - tb->addAction(action(RunToNewScriptAction)); - tb->addSeparator(); - tb->addAction(action(FindInScriptAction)); - return tb; + Q_D(QScriptEngineDebugger); + d->createDebugger(); + return d->debugger->createStandardToolBar(parent, this); } /*! -- cgit v0.12