summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurindam Jana <aurindam.jana@digia.com>2012-10-04 14:54:59 +0200
committerhjk <qthjk@ovi.com>2012-10-05 11:03:01 +0200
commit9ac25a293252a1196dad29b493add514459777a6 (patch)
tree12b2e4aa58a7f310d0596bd067f458356ad58dea
parent614bb33589aa1fade05cd1b6b32b3acc848f2fd8 (diff)
downloadqt-creator-9ac25a293252a1196dad29b493add514459777a6.tar.gz
ScriptConsole: Move from Debugger to QmlJSTools
The console is now a part of qmljstools plugin. The console appears as an output pane. A dummy QScriptEngine evaluates expressions when a declarative debug session is not in progress. During a debug session, the expressions are evaluated by the debug services. Task-Number: QTCREATORBUG-7402 Change-Id: Ic2eeac44fb335c706be03b89f8672b0356efe984 Reviewed-by: Christiaan Janssen <christiaan.janssen@digia.com> Reviewed-by: hjk <qthjk@ovi.com>
-rw-r--r--src/plugins/debugger/debugger.pro12
-rw-r--r--src/plugins/debugger/debugger.qbs12
-rw-r--r--src/plugins/debugger/debugger.qrc6
-rw-r--r--src/plugins/debugger/debugger_dependencies.pri1
-rw-r--r--src/plugins/debugger/debuggerconstants.h6
-rw-r--r--src/plugins/debugger/debuggerengine.cpp22
-rw-r--r--src/plugins/debugger/debuggerengine.h6
-rw-r--r--src/plugins/debugger/debuggermainwindow.cpp7
-rw-r--r--src/plugins/debugger/debuggerplugin.cpp21
-rw-r--r--src/plugins/debugger/qml/qmlcppengine.cpp6
-rw-r--r--src/plugins/debugger/qml/qmlcppengine.h2
-rw-r--r--src/plugins/debugger/qml/qmlengine.cpp176
-rw-r--r--src/plugins/debugger/qml/qmlengine.h4
-rw-r--r--src/plugins/debugger/qml/qmlv8debuggerclient.cpp150
-rw-r--r--src/plugins/debugger/qml/qscriptdebuggerclient.cpp2
-rw-r--r--src/plugins/debugger/qtmessagelogeditor.h73
-rw-r--r--src/plugins/debugger/qtmessageloghandler.cpp405
-rw-r--r--src/plugins/debugger/qtmessageloghandler.h150
-rw-r--r--src/plugins/debugger/qtmessagelogproxymodel.cpp90
-rw-r--r--src/plugins/debugger/qtmessagelogproxymodel.h71
-rw-r--r--src/plugins/debugger/qtmessagelogview.h67
-rw-r--r--src/plugins/debugger/qtmessagelogwindow.cpp254
-rw-r--r--src/plugins/debugger/qtmessagelogwindow.h82
-rw-r--r--src/plugins/qmljstools/images/collapse.png (renamed from src/plugins/debugger/images/collapse.png)bin986 -> 986 bytes
-rw-r--r--src/plugins/qmljstools/images/error.png (renamed from src/plugins/debugger/images/error.png)bin1344 -> 1344 bytes
-rw-r--r--src/plugins/qmljstools/images/expand.png (renamed from src/plugins/debugger/images/expand.png)bin997 -> 997 bytes
-rw-r--r--src/plugins/qmljstools/images/log.png (renamed from src/plugins/debugger/images/log.png)bin1354 -> 1354 bytes
-rw-r--r--src/plugins/qmljstools/images/prompt.png (renamed from src/plugins/debugger/images/prompt.png)bin1049 -> 1049 bytes
-rw-r--r--src/plugins/qmljstools/images/warning.png (renamed from src/plugins/debugger/images/warning.png)bin1454 -> 1454 bytes
-rw-r--r--src/plugins/qmljstools/qmlconsoleedit.cpp (renamed from src/plugins/debugger/qtmessagelogeditor.cpp)111
-rw-r--r--src/plugins/qmljstools/qmlconsoleedit.h45
-rw-r--r--src/plugins/qmljstools/qmlconsoleitem.cpp123
-rw-r--r--src/plugins/qmljstools/qmlconsoleitem.h55
-rw-r--r--src/plugins/qmljstools/qmlconsoleitemdelegate.cpp (renamed from src/plugins/debugger/qtmessagelogitemdelegate.cpp)211
-rw-r--r--src/plugins/qmljstools/qmlconsoleitemdelegate.h (renamed from src/plugins/debugger/qtmessagelogitemdelegate.h)120
-rw-r--r--src/plugins/qmljstools/qmlconsoleitemmodel.cpp252
-rw-r--r--src/plugins/qmljstools/qmlconsoleitemmodel.h73
-rw-r--r--src/plugins/qmljstools/qmlconsolemanager.cpp162
-rw-r--r--src/plugins/qmljstools/qmlconsolemanager.h59
-rw-r--r--src/plugins/qmljstools/qmlconsolepane.cpp215
-rw-r--r--src/plugins/qmljstools/qmlconsolepane.h71
-rw-r--r--src/plugins/qmljstools/qmlconsoleproxymodel.cpp58
-rw-r--r--src/plugins/qmljstools/qmlconsoleproxymodel.h41
-rw-r--r--src/plugins/qmljstools/qmlconsoleview.cpp (renamed from src/plugins/debugger/qtmessagelogview.cpp)149
-rw-r--r--src/plugins/qmljstools/qmlconsoleview.h37
-rw-r--r--src/plugins/qmljstools/qmljsinterpreter.cpp58
-rw-r--r--src/plugins/qmljstools/qmljsinterpreter.h40
-rw-r--r--src/plugins/qmljstools/qmljstools-lib.pri45
-rw-r--r--src/plugins/qmljstools/qmljstools.pri2
-rw-r--r--src/plugins/qmljstools/qmljstools.pro67
-rw-r--r--src/plugins/qmljstools/qmljstools.qbs19
-rw-r--r--src/plugins/qmljstools/qmljstools.qrc10
-rw-r--r--src/plugins/qmljstools/qmljstoolsplugin.cpp5
-rw-r--r--src/plugins/qmljstools/qmljstoolsplugin.h2
54 files changed, 1781 insertions, 1874 deletions
diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro
index fa66556673..5dc236c39d 100644
--- a/src/plugins/debugger/debugger.pro
+++ b/src/plugins/debugger/debugger.pro
@@ -70,12 +70,6 @@ HEADERS += \
debuggertooltipmanager.h \
debuggersourcepathmappingwidget.h \
memoryview.h \
- qtmessagelogwindow.h \
- qtmessagelogeditor.h \
- qtmessagelogview.h \
- qtmessagelogproxymodel.h \
- qtmessagelogitemdelegate.h \
- qtmessageloghandler.h \
localsandexpressionswindow.h
SOURCES += \
@@ -123,12 +117,6 @@ SOURCES += \
debuggertooltipmanager.cpp \
debuggersourcepathmappingwidget.cpp \
memoryview.cpp \
- qtmessagelogwindow.cpp \
- qtmessagelogproxymodel.cpp \
- qtmessagelogview.cpp \
- qtmessagelogitemdelegate.cpp \
- qtmessageloghandler.cpp \
- qtmessagelogeditor.cpp \
localsandexpressionswindow.cpp
FORMS += \
diff --git a/src/plugins/debugger/debugger.qbs b/src/plugins/debugger/debugger.qbs
index 08b64d69cb..357a1df32d 100644
--- a/src/plugins/debugger/debugger.qbs
+++ b/src/plugins/debugger/debugger.qbs
@@ -101,18 +101,6 @@ QtcPlugin {
"outputcollector.h",
"procinterrupt.cpp",
"procinterrupt.h",
- "qtmessagelogeditor.cpp",
- "qtmessagelogeditor.h",
- "qtmessageloghandler.cpp",
- "qtmessageloghandler.h",
- "qtmessagelogitemdelegate.cpp",
- "qtmessagelogitemdelegate.h",
- "qtmessagelogproxymodel.cpp",
- "qtmessagelogproxymodel.h",
- "qtmessagelogview.cpp",
- "qtmessagelogview.h",
- "qtmessagelogwindow.cpp",
- "qtmessagelogwindow.h",
"registerhandler.cpp",
"registerhandler.h",
"registerwindow.cpp",
diff --git a/src/plugins/debugger/debugger.qrc b/src/plugins/debugger/debugger.qrc
index a75fb1625e..b1e7d73495 100644
--- a/src/plugins/debugger/debugger.qrc
+++ b/src/plugins/debugger/debugger.qrc
@@ -30,12 +30,6 @@
<file>images/location_16.png</file>
<file>images/location_24.png</file>
<file>images/pin.xpm</file>
- <file>images/collapse.png</file>
- <file>images/error.png</file>
- <file>images/expand.png</file>
- <file>images/log.png</file>
- <file>images/prompt.png</file>
- <file>images/warning.png</file>
<file>images/qml/zoom.png</file>
<file>images/qml/select.png</file>
<file>images/qml/app-on-top.png</file>
diff --git a/src/plugins/debugger/debugger_dependencies.pri b/src/plugins/debugger/debugger_dependencies.pri
index 732954b727..d9138c7329 100644
--- a/src/plugins/debugger/debugger_dependencies.pri
+++ b/src/plugins/debugger/debugger_dependencies.pri
@@ -3,6 +3,7 @@ include(../../plugins/cpptools/cpptools.pri)
include(../../plugins/find/find.pri)
include(../../plugins/projectexplorer/projectexplorer.pri)
include(../../plugins/texteditor/texteditor.pri)
+include(../../plugins/qmljstools/qmljstools.pri)
include(../../libs/cplusplus/cplusplus.pri)
include(../../libs/utils/utils.pri)
include(../../libs/qmljs/qmljs.pri)
diff --git a/src/plugins/debugger/debuggerconstants.h b/src/plugins/debugger/debuggerconstants.h
index 83c380b548..839d1d5f76 100644
--- a/src/plugins/debugger/debuggerconstants.h
+++ b/src/plugins/debugger/debuggerconstants.h
@@ -75,7 +75,6 @@ const char DOCKWIDGET_THREADS[] = "Debugger.Docks.Threads";
const char DOCKWIDGET_WATCHERS[] = "Debugger.Docks.LocalsAndWatchers";
const char DOCKWIDGET_QML_INSPECTOR[] = "Debugger.Docks.QmlInspector";
-const char DOCKWIDGET_QML_SCRIPTCONSOLE[] = "Debugger.Docks.ScriptConsole";
const char DOCKWIDGET_DEFAULT_AREA[] = "Debugger.Docks.DefaultArea";
} // namespace Constants
@@ -182,9 +181,8 @@ enum LogChannel
AppOutput, // stdout
AppError, // stderr
AppStuff, // (possibly) windows debug channel
- StatusBar, // LogStatus and also put to the status bar
- QtMessageLogOutput,
- QtMessageLogStatus
+ StatusBar, // LogStatus and also put to the status bar
+ ConsoleOutput // Used to output to console
};
enum DebuggerEngineType
diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp
index e6d18bb79f..679b75335d 100644
--- a/src/plugins/debugger/debuggerengine.cpp
+++ b/src/plugins/debugger/debuggerengine.cpp
@@ -48,7 +48,6 @@
#include "stackhandler.h"
#include "threadshandler.h"
#include "watchhandler.h"
-#include "qtmessageloghandler.h"
#include <coreplugin/icore.h>
#include <coreplugin/idocument.h>
@@ -66,6 +65,8 @@
#include <utils/qtcassert.h>
#include <utils/fileinprojectfinder.h>
+#include <qmljstools/qmlconsolemanager.h>
+
#include <QDebug>
#include <QTimer>
#include <QFile>
@@ -297,7 +298,6 @@ public:
StackHandler m_stackHandler;
ThreadsHandler m_threadsHandler;
WatchHandler m_watchHandler;
- QtMessageLogHandler m_qtMessageHandler;
QFutureInterface<void> m_progress;
DisassemblerAgent m_disassemblerAgent;
@@ -428,11 +428,6 @@ WatchHandler *DebuggerEngine::watchHandler() const
: &d->m_watchHandler;
}
-QtMessageLogHandler *DebuggerEngine::qtMessageLogHandler() const
-{
- return &d->m_qtMessageHandler;
-}
-
SourceFilesHandler *DebuggerEngine::sourceFilesHandler() const
{
return d->m_masterEngine
@@ -510,14 +505,6 @@ QAbstractItemModel *DebuggerEngine::sourceFilesModel() const
return model;
}
-QAbstractItemModel *DebuggerEngine::qtMessageLogModel() const
-{
- QAbstractItemModel *model = qtMessageLogHandler()->model();
- if (model->objectName().isEmpty()) // Make debugging easier.
- model->setObjectName(objectName() + QLatin1String("QtMessageLogModel"));
- return model;
-}
-
void DebuggerEngine::fetchMemory(MemoryAgent *, QObject *,
quint64 addr, quint64 length)
{
@@ -546,8 +533,9 @@ void DebuggerEngine::showMessage(const QString &msg, int channel, int timeout) c
}
//if (msg.size() && msg.at(0).isUpper() && msg.at(1).isUpper())
// qDebug() << qPrintable(msg) << "IN STATE" << state();
- if (channel == QtMessageLogOutput)
- qtMessageLogHandler()->appendMessage(QtMessageLogHandler::UndefinedType, msg);
+ QmlJSTools::QmlConsoleManager *consoleManager = QmlJSTools::QmlConsoleManager::instance();
+ if (channel == ConsoleOutput && consoleManager)
+ consoleManager->printToConsolePane(QmlJSTools::QmlConsoleItem::UndefinedType, msg);
debuggerCore()->showMessage(msg, channel, timeout);
if (d->m_runControl) {
diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h
index e4a260dae5..f819bfaa8a 100644
--- a/src/plugins/debugger/debuggerengine.h
+++ b/src/plugins/debugger/debuggerengine.h
@@ -77,7 +77,6 @@ class QmlAdapter;
class QmlCppEngine;
class DebuggerToolTipContext;
class MemoryMarkup;
-class QtMessageLogHandler;
struct WatchUpdateFlags
{
@@ -216,7 +215,6 @@ public:
virtual Internal::WatchHandler *watchHandler() const;
virtual Internal::SourceFilesHandler *sourceFilesHandler() const;
virtual Internal::BreakHandler *breakHandler() const;
- virtual Internal::QtMessageLogHandler *qtMessageLogHandler() const;
virtual QAbstractItemModel *modulesModel() const;
virtual QAbstractItemModel *registerModel() const;
@@ -229,7 +227,6 @@ public:
virtual QAbstractItemModel *toolTipsModel() const; // Deprecated, FIXME: use watchModel
virtual QAbstractItemModel *watchModel() const;
virtual QAbstractItemModel *sourceFilesModel() const;
- virtual QAbstractItemModel *qtMessageLogModel() const;
void progressPing();
void handleFinished();
@@ -273,6 +270,8 @@ public:
QString toFileInProject(const QUrl &fileUrl);
+ virtual bool evaluateScriptExpression(const QString &expression);
+
signals:
void stateChanged(Debugger::DebuggerState state);
// A new stack frame is on display including locals.
@@ -354,7 +353,6 @@ protected:
virtual void executeRunToFunction(const QString &functionName);
virtual void executeJumpToLine(const Internal::ContextData &data);
virtual void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
- virtual bool evaluateScriptExpression(const QString &expression);
virtual void frameUp();
virtual void frameDown();
diff --git a/src/plugins/debugger/debuggermainwindow.cpp b/src/plugins/debugger/debuggermainwindow.cpp
index 8e7bf33ee9..dedd020a9a 100644
--- a/src/plugins/debugger/debuggermainwindow.cpp
+++ b/src/plugins/debugger/debuggermainwindow.cpp
@@ -690,7 +690,6 @@ void DebuggerMainWindowPrivate::setSimpleDockWidgetArrangement()
QDockWidget *threadsDock = q->dockWidget(QLatin1String(DOCKWIDGET_THREADS));
QDockWidget *outputDock = q->dockWidget(QLatin1String(DOCKWIDGET_OUTPUT));
QDockWidget *qmlInspectorDock = q->dockWidget(QLatin1String(DOCKWIDGET_QML_INSPECTOR));
- QDockWidget *consoleDock = q->dockWidget(QLatin1String(DOCKWIDGET_QML_SCRIPTCONSOLE));
QDockWidget *modulesDock = q->dockWidget(QLatin1String(DOCKWIDGET_MODULES));
QDockWidget *registerDock = q->dockWidget(QLatin1String(DOCKWIDGET_REGISTER));
QDockWidget *sourceFilesDock = q->dockWidget(QLatin1String(DOCKWIDGET_SOURCE_FILES));
@@ -701,7 +700,6 @@ void DebuggerMainWindowPrivate::setSimpleDockWidgetArrangement()
QTC_ASSERT(snapshotsDock, return);
QTC_ASSERT(threadsDock, return);
QTC_ASSERT(outputDock, return);
- QTC_ASSERT(consoleDock, return);
QTC_ASSERT(modulesDock, return);
QTC_ASSERT(registerDock, return);
QTC_ASSERT(sourceFilesDock, return);
@@ -714,7 +712,7 @@ void DebuggerMainWindowPrivate::setSimpleDockWidgetArrangement()
// toolBar
// --------------------------------------------------------------------------------
- // stack,qmlinspector | breakpoints,modules,register,threads,sourceFiles,snapshots,scriptconsole
+ // stack,qmlinspector | breakpoints,modules,register,threads,sourceFiles,snapshots
//
q->splitDockWidget(toolBarDock, stackDock, Qt::Vertical);
q->splitDockWidget(stackDock, breakDock, Qt::Horizontal);
@@ -727,13 +725,10 @@ void DebuggerMainWindowPrivate::setSimpleDockWidgetArrangement()
q->tabifyDockWidget(breakDock, threadsDock);
q->tabifyDockWidget(breakDock, sourceFilesDock);
q->tabifyDockWidget(breakDock, snapshotsDock);
- q->tabifyDockWidget(breakDock, consoleDock);
if (m_activeDebugLanguages.testFlag(Debugger::QmlLanguage)) {
if (qmlInspectorDock)
qmlInspectorDock->show();
- if (consoleDock)
- consoleDock->show();
} else {
// CPP only
threadsDock->show();
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index 4e69d78942..5ae18c869b 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -46,7 +46,6 @@
#include "breakpoint.h"
#include "breakhandler.h"
#include "breakwindow.h"
-#include "qtmessagelogwindow.h"
#include "disassemblerlines.h"
#include "logwindow.h"
#include "moduleswindow.h"
@@ -126,6 +125,8 @@
# include <utils/winutils.h>
#endif
+#include <qmljstools/qmlconsolemanager.h>
+
#include <QComboBox>
#include <QDockWidget>
#include <QFileDialog>
@@ -1283,7 +1284,6 @@ public:
BaseWindow *m_breakWindow;
BreakHandler *m_breakHandler;
- QtMessageLogWindow *m_qtMessageLogWindow;
WatchWindow *m_returnWindow;
WatchWindow *m_localsWindow;
WatchWindow *m_watchersWindow;
@@ -1349,7 +1349,6 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin) :
m_threadsWindow = 0;
m_logWindow = 0;
m_localsAndExpressionsWindow = 0;
- m_qtMessageLogWindow = 0;
m_mainWindow = 0;
m_snapshotHandler = 0;
@@ -2066,12 +2065,18 @@ void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine)
m_threadsWindow->setModel(engine->threadsModel());
m_watchersWindow->setModel(engine->watchersModel());
m_inspectorWindow->setModel(engine->inspectorModel());
- m_qtMessageLogWindow->setModel(engine->qtMessageLogModel());
engine->watchHandler()->rebuildModel();
mainWindow()->setEngineDebugLanguages(engine->startParameters().languages);
mainWindow()->setCurrentEngine(engine);
+ QmlJSTools::QmlConsoleManager *consoleManager = QmlJSTools::QmlConsoleManager::instance();
+ if (consoleManager) {
+ if (engine->startParameters().languages & QmlLanguage)
+ consoleManager->setDebuggerEngine(engine);
+ else
+ consoleManager->setDebuggerEngine(0);
+ }
}
static void changeFontSize(QWidget *widget, qreal size)
@@ -2194,7 +2199,6 @@ void DebuggerPluginPrivate::setInitialState()
action(AutoDerefPointers)->setEnabled(true);
action(ExpandStack)->setEnabled(false);
- m_qtMessageLogWindow->setEnabled(true);
}
void DebuggerPluginPrivate::updateWatchersWindow(bool showWatch, bool showReturn)
@@ -2559,10 +2563,6 @@ void DebuggerPluginPrivate::showMessage(const QString &msg, int channel, int tim
m_logWindow->showInput(LogError, QLatin1String("ERROR: ") + msg);
m_logWindow->showOutput(LogError, QLatin1String("ERROR: ") + msg);
break;
- case QtMessageLogStatus:
- QTC_ASSERT(m_qtMessageLogWindow, return);
- m_qtMessageLogWindow->showStatus(msg, timeout);
- break;
default:
m_logWindow->showOutput(channel, msg);
break;
@@ -2739,8 +2739,6 @@ void DebuggerPluginPrivate::extensionsInitialized()
m_breakWindow->setObjectName(QLatin1String(DOCKWIDGET_BREAK));
m_breakWindow->setModel(m_breakHandler->model());
- m_qtMessageLogWindow = new QtMessageLogWindow();
- m_qtMessageLogWindow->setObjectName(QLatin1String(DOCKWIDGET_QML_SCRIPTCONSOLE));
m_modulesWindow = new ModulesWindow;
m_modulesWindow->setObjectName(QLatin1String(DOCKWIDGET_MODULES));
m_logWindow = new LogWindow;
@@ -2885,7 +2883,6 @@ void DebuggerPluginPrivate::extensionsInitialized()
dock->setProperty(DOCKWIDGET_DEFAULT_AREA, Qt::TopDockWidgetArea);
m_mainWindow->createDockWidget(CppLanguage, m_breakWindow);
- m_mainWindow->createDockWidget(QmlLanguage, m_qtMessageLogWindow);
m_mainWindow->createDockWidget(CppLanguage, m_snapshotWindow);
m_mainWindow->createDockWidget(CppLanguage, m_stackWindow);
m_mainWindow->createDockWidget(CppLanguage, m_threadsWindow);
diff --git a/src/plugins/debugger/qml/qmlcppengine.cpp b/src/plugins/debugger/qml/qmlcppengine.cpp
index fd38502e1f..ce981d83d1 100644
--- a/src/plugins/debugger/qml/qmlcppengine.cpp
+++ b/src/plugins/debugger/qml/qmlcppengine.cpp
@@ -34,7 +34,6 @@
#include "debuggerstartparameters.h"
#include "stackhandler.h"
#include "qmlengine.h"
-#include "qtmessageloghandler.h"
#include "watchdata.h"
#include <coreplugin/icore.h>
@@ -794,11 +793,6 @@ void QmlCppEngine::resetLocation()
DebuggerEngine::resetLocation();
}
-Internal::QtMessageLogHandler *QmlCppEngine::qtMessageLogHandler() const
-{
- return d->m_qmlEngine->qtMessageLogHandler();
-}
-
DebuggerEngine *QmlCppEngine::cppEngine() const
{
return d->m_cppEngine;
diff --git a/src/plugins/debugger/qml/qmlcppengine.h b/src/plugins/debugger/qml/qmlcppengine.h
index 7891cdc808..7c15704b4f 100644
--- a/src/plugins/debugger/qml/qmlcppengine.h
+++ b/src/plugins/debugger/qml/qmlcppengine.h
@@ -93,8 +93,6 @@ public:
int timeout = -1) const;
void resetLocation();
- Internal::QtMessageLogHandler *qtMessageLogHandler() const;
-
void notifyInferiorIll();
protected:
diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp
index a1a9af9ea9..d7aa4bf40a 100644
--- a/src/plugins/debugger/qml/qmlengine.cpp
+++ b/src/plugins/debugger/qml/qmlengine.cpp
@@ -50,7 +50,6 @@
#include "watchhandler.h"
#include "sourcefileshandler.h"
#include "watchutils.h"
-#include "qtmessageloghandler.h"
#include <extensionsystem/pluginmanager.h>
#include <qmldebug/baseenginedebugclient.h>
@@ -68,6 +67,9 @@
#include <texteditor/itexteditor.h>
+#include <qmljstools/qmlconsolemanager.h>
+#include <qmljstools/qmlconsoleitem.h>
+
#include <QDateTime>
#include <QDebug>
#include <QDir>
@@ -330,8 +332,6 @@ QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters)
m_noDebugOutputTimer.setInterval(8000);
connect(&m_noDebugOutputTimer, SIGNAL(timeout()), this, SLOT(tryToConnect()));
- qtMessageLogHandler()->setHasEditableRow(true);
-
connect(ModelManagerInterface::instance(),
SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
this,
@@ -1031,14 +1031,61 @@ void QmlEngine::synchronizeWatchers()
}
}
+QmlJSTools::QmlConsoleItem *constructLogItemTree(QmlJSTools::QmlConsoleItem *parent,
+ const QVariant &result,
+ const QString &key = QString())
+{
+ using namespace QmlJSTools;
+ bool sorted = debuggerCore()->boolSetting(SortStructMembers);
+ if (!result.isValid())
+ return 0;
+
+ QmlConsoleItem *item = new QmlConsoleItem(parent);
+ if (result.type() == QVariant::Map) {
+ if (key.isEmpty())
+ item->setText(_("Object"));
+ else
+ item->setText(key + _(" : Object"));
+
+ QMapIterator<QString, QVariant> i(result.toMap());
+ while (i.hasNext()) {
+ i.next();
+ QmlConsoleItem *child = constructLogItemTree(item, i.value(), i.key());
+ if (child)
+ item->insertChild(child, sorted);
+ }
+ } else if (result.type() == QVariant::List) {
+ if (key.isEmpty())
+ item->setText(_("List"));
+ else
+ item->setText(QString(_("[%1] : List")).arg(key));
+ QVariantList resultList = result.toList();
+ for (int i = 0; i < resultList.count(); i++) {
+ QmlConsoleItem *child = constructLogItemTree(item, resultList.at(i),
+ QString::number(i));
+ if (child)
+ item->insertChild(child, sorted);
+ }
+ } else if (result.canConvert(QVariant::String)) {
+ item->setText(result.toString());
+ } else {
+ item->setText(_("Unknown Value"));
+ }
+
+ return item;
+}
+
void QmlEngine::expressionEvaluated(quint32 queryId, const QVariant &result)
{
if (queryIds.contains(queryId)) {
queryIds.removeOne(queryId);
- QtMessageLogItem *item = constructLogItemTree(qtMessageLogHandler()->root(),
- result);
- if (item)
- qtMessageLogHandler()->appendItem(item);
+ using namespace QmlJSTools;
+ QmlConsoleManager *consoleManager = QmlConsoleManager::instance();
+ if (consoleManager) {
+ QmlConsoleItem *item = constructLogItemTree(consoleManager->rootItem(), result);
+ if (item)
+ consoleManager->printToConsolePane(item);
+ }
}
}
@@ -1092,35 +1139,40 @@ void QmlEngine::documentUpdated(QmlJS::Document::Ptr doc)
void QmlEngine::updateCurrentContext()
{
const QString context = state() == InferiorStopOk ?
- stackHandler()->currentFrame().function :
- m_inspectorAdapter.currentSelectedDisplayName();
- showMessage(tr("Context: ").append(context), QtMessageLogStatus);
+ stackHandler()->currentFrame().function
+ : m_inspectorAdapter.currentSelectedDisplayName();
+ QmlJSTools::QmlConsoleManager *consoleManager = QmlJSTools::QmlConsoleManager::instance();
+ if (consoleManager)
+ consoleManager->setContext(tr("Context: ").append(context));
}
void QmlEngine::appendDebugOutput(QtMsgType type, const QString &message,
const QmlDebug::QDebugContextInfo &info)
{
- QtMessageLogHandler::ItemType itemType;
+ using namespace QmlJSTools;
+ QmlConsoleItem::ItemType itemType;
switch (type) {
case QtDebugMsg:
- itemType = QtMessageLogHandler::DebugType;
+ itemType = QmlConsoleItem::DebugType;
break;
case QtWarningMsg:
- itemType = QtMessageLogHandler::WarningType;
+ itemType = QmlConsoleItem::WarningType;
break;
case QtCriticalMsg:
case QtFatalMsg:
- itemType = QtMessageLogHandler::ErrorType;
+ itemType = QmlConsoleItem::ErrorType;
break;
default:
//This case is not possible
return;
}
- QtMessageLogItem *item = new QtMessageLogItem(qtMessageLogHandler()->root(),
- itemType, message);
- item->file = info.file;
- item->line = info.line;
- qtMessageLogHandler()->appendItem(item);
+ QmlConsoleManager *consoleManager = QmlConsoleManager::instance();
+ if (consoleManager) {
+ QmlConsoleItem *item = new QmlConsoleItem(consoleManager->rootItem(), itemType, message);
+ item->file = info.file;
+ item->line = info.line;
+ consoleManager->printToConsolePane(item);
+ }
}
void QmlEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages languages)
@@ -1133,37 +1185,25 @@ void QmlEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages
bool QmlEngine::evaluateScriptExpression(const QString &expression)
{
bool didEvaluate = true;
- //Check if string is only white spaces
- if (!expression.trimmed().isEmpty()) {
- //check if it can be evaluated
- if (canEvaluateScript(expression)) {
- //Evaluate expression based on engine state
- //When engine->state() == InferiorStopOk, the expression
- //is sent to V8DebugService. In all other cases, the
- //expression is evaluated by QDeclarativeEngine.
- if (state() != InferiorStopOk) {
- QmlInspectorAgent *agent = m_inspectorAdapter.agent();
- quint32 queryId
- = agent->queryExpressionResult(
- m_inspectorAdapter.currentSelectedDebugId(),
- expression);
- if (queryId) {
- queryIds << queryId;
- } else {
- didEvaluate = false;
- qtMessageLogHandler()->
- appendItem(
- new QtMessageLogItem(
- qtMessageLogHandler()->root(),
- QtMessageLogHandler::ErrorType,
- _("Error evaluating expression.")));
- }
- } else {
- executeDebuggerCommand(expression, QmlLanguage);
- }
+ // Evaluate expression based on engine state
+ // When engine->state() == InferiorStopOk, the expression is sent to debuggerClient.
+ if (state() != InferiorStopOk) {
+ QmlInspectorAgent *agent = m_inspectorAdapter.agent();
+ quint32 queryId = agent->queryExpressionResult(m_inspectorAdapter.currentSelectedDebugId(),
+ expression);
+ if (queryId) {
+ queryIds << queryId;
} else {
didEvaluate = false;
+ using namespace QmlJSTools;
+ QmlConsoleManager *consoleManager = QmlConsoleManager::instance();
+ if (consoleManager) {
+ consoleManager->printToConsolePane(QmlConsoleItem::ErrorType,
+ _("Error evaluating expression."));
+ }
}
+ } else {
+ executeDebuggerCommand(expression, QmlLanguage);
}
return didEvaluate;
}
@@ -1270,48 +1310,6 @@ bool QmlEngine::canEvaluateScript(const QString &script)
return m_interpreter.canEvaluate();
}
-QtMessageLogItem *QmlEngine::constructLogItemTree(
- QtMessageLogItem *parent, const QVariant &result, const QString &key)
-{
- if (!result.isValid())
- return 0;
-
- QtMessageLogItem *item = new QtMessageLogItem(parent);
- if (result.type() == QVariant::Map) {
- if (key.isEmpty())
- item->setText(_("Object"));
- else
- item->setText(key + _(" : Object"));
-
- QMapIterator<QString, QVariant> i(result.toMap());
- while (i.hasNext()) {
- i.next();
- QtMessageLogItem *child = constructLogItemTree(item,
- i.value(), i.key());
- if (child)
- item->insertChild(child);
- }
- } else if (result.type() == QVariant::List) {
- if (key.isEmpty())
- item->setText(_("List"));
- else
- item->setText(QString(_("[%1] : List")).arg(key));
- QVariantList resultList = result.toList();
- for (int i = 0; i < resultList.count(); i++) {
- QtMessageLogItem *child = constructLogItemTree(item, resultList.at(i),
- QString::number(i));
- if (child)
- item->insertChild(child);
- }
- } else if (result.canConvert(QVariant::String)) {
- item->setText(result.toString());
- } else {
- item->setText(_("Unknown Value"));
- }
-
- return item;
-}
-
bool QmlEngine::adjustBreakpointLineAndColumn(
const QString &filePath, quint32 *line, quint32 *column, bool *valid)
{
diff --git a/src/plugins/debugger/qml/qmlengine.h b/src/plugins/debugger/qml/qmlengine.h
index f613a4c1da..ef8fef8f2a 100644
--- a/src/plugins/debugger/qml/qmlengine.h
+++ b/src/plugins/debugger/qml/qmlengine.h
@@ -53,7 +53,6 @@ namespace Debugger {
namespace Internal {
class QmlAdapter;
-class QtMessageLogItem;
class QmlEngine : public DebuggerEngine
{
@@ -181,9 +180,6 @@ private:
void updateEditor(Core::IEditor *editor, const QTextDocument *document);
bool canEvaluateScript(const QString &script);
- QtMessageLogItem *constructLogItemTree(QtMessageLogItem *parent,
- const QVariant &result,
- const QString &key = QString());
bool adjustBreakpointLineAndColumn(const QString &filePath, quint32 *line,
quint32 *column, bool *valid);
diff --git a/src/plugins/debugger/qml/qmlv8debuggerclient.cpp b/src/plugins/debugger/qml/qmlv8debuggerclient.cpp
index fcf5b224b1..a78ac1fcdd 100644
--- a/src/plugins/debugger/qml/qmlv8debuggerclient.cpp
+++ b/src/plugins/debugger/qml/qmlv8debuggerclient.cpp
@@ -37,12 +37,16 @@
#include "breakhandler.h"
#include "qmlengine.h"
#include "stackhandler.h"
-#include "qtmessageloghandler.h"
+#include "debuggercore.h"
+#include "debuggeractions.h"
#include <utils/qtcassert.h>
#include <coreplugin/editormanager/editormanager.h>
#include <texteditor/basetexteditor.h>
+#include <qmljstools/qmlconsoleitem.h>
+#include <qmljstools/qmlconsolemanager.h>
+
#include <QTextBlock>
#include <QVariant>
#include <QStack>
@@ -117,19 +121,14 @@ public:
void version();
//void profile(ProfileCommand command); //NOT SUPPORTED
void gc();
-
- QmlV8ObjectData extractData(const QVariant &data, const QVariant &refsVal);
void clearCache();
void logSendMessage(const QString &msg) const;
void logReceiveMessage(const QString &msg) const;
- QtMessageLogItem *constructLogItemTree(QtMessageLogItem *parent,
- const QmlV8ObjectData &objectData, const QVariant &refsVal);
private:
QByteArray packMessage(const QByteArray &type, const QByteArray &message = QByteArray());
QScriptValue initObject();
- QVariant valueFromRef(int handle, const QVariant &refsVal, bool *success);
public:
QmlV8DebuggerClient *q;
@@ -762,8 +761,23 @@ void QmlV8DebuggerClientPrivate::gc()
q->sendMessage(packMessage(V8REQUEST, jsonMessage.toString().toUtf8()));
}
-QmlV8ObjectData QmlV8DebuggerClientPrivate::extractData(const QVariant &data,
- const QVariant &refsVal)
+QVariant valueFromRef(int handle, const QVariant &refsVal, bool *success)
+{
+ *success = false;
+ QVariant variant;
+ const QVariantList refs = refsVal.toList();
+ foreach (const QVariant &ref, refs) {
+ const QVariantMap refData = ref.toMap();
+ if (refData.value(_(HANDLE)).toInt() == handle) {
+ variant = refData;
+ *success = true;
+ break;
+ }
+ }
+ return variant;
+}
+
+QmlV8ObjectData extractData(const QVariant &data, const QVariant &refsVal)
{
// { "handle" : <handle>,
// "type" : <"undefined", "null", "boolean", "number", "string", "object", "function" or "frame">
@@ -901,24 +915,6 @@ QScriptValue QmlV8DebuggerClientPrivate::initObject()
return jsonVal;
}
-QVariant QmlV8DebuggerClientPrivate::valueFromRef(int handle,
- const QVariant &refsVal,
- bool *success)
-{
- *success = false;
- QVariant variant;
- const QVariantList refs = refsVal.toList();
- foreach (const QVariant &ref, refs) {
- const QVariantMap refData = ref.toMap();
- if (refData.value(_(HANDLE)).toInt() == handle) {
- variant = refData;
- *success = true;
- break;
- }
- }
- return variant;
-}
-
void QmlV8DebuggerClientPrivate::logSendMessage(const QString &msg) const
{
if (engine)
@@ -931,34 +927,6 @@ void QmlV8DebuggerClientPrivate::logReceiveMessage(const QString &msg) const
engine->logMessage(QLatin1String("V8DebuggerClient"), QmlEngine::LogReceive, msg);
}
-QtMessageLogItem *QmlV8DebuggerClientPrivate::constructLogItemTree(
- QtMessageLogItem *parent,
- const QmlV8ObjectData &objectData,
- const QVariant &refsVal)
-{
- if (!objectData.value.isValid())
- return 0;
-
- QString text;
- if (objectData.name.isEmpty())
- text = objectData.value.toString();
- else
- text = QString(_("%1: %2")).arg(QString::fromLatin1(objectData.name))
- .arg(objectData.value.toString());
-
- QtMessageLogItem *item = new QtMessageLogItem(parent,
- QtMessageLogHandler::UndefinedType, text);
-
- foreach (const QVariant &property, objectData.properties) {
- QtMessageLogItem *child = constructLogItemTree(
- item, extractData(property, refsVal), refsVal);
- if (child)
- item->insertChild(child);
- }
-
- return item;
-}
-
///////////////////////////////////////////////////////////////////////
//
// QmlV8DebuggerClient
@@ -1126,9 +1094,8 @@ void QmlV8DebuggerClient::assignValueInDebugger(const WatchData * /*data*/,
d->evaluate(expression, false, false, stackHandler->currentIndex());
d->updateLocalsAndWatchers.append(d->sequence);
} else {
- d->engine->showMessage(QString(_("Cannot evaluate"
- "%1 in current stack frame")).
- arg(expression), QtMessageLogOutput);
+ d->engine->showMessage(QString(_("Cannot evaluate %1 in current stack frame")).arg(
+ expression), ConsoleOutput);
}
}
@@ -1145,9 +1112,8 @@ void QmlV8DebuggerClient::executeDebuggerCommand(const QString &command)
d->debuggerCommands.append(d->sequence);
} else {
//Currently cannot evaluate if not in a javascript break
- d->engine->showMessage(QString(_("Cannot evaluate %1"
- "in current stack frame")).
- arg(command), QtMessageLogOutput);
+ d->engine->showMessage(QString(_("Cannot evaluate %1 in current stack frame")).arg(
+ command), ConsoleOutput);
}
}
@@ -1630,17 +1596,17 @@ StackFrame QmlV8DebuggerClient::extractStackFrame(const QVariant &bodyVal, const
return stackFrame;
}
- QmlV8ObjectData objectData = d->extractData(body.value(_("func")), refsVal);
+ QmlV8ObjectData objectData = extractData(body.value(_("func")), refsVal);
QString functionName = objectData.value.toString();
if (functionName.isEmpty())
functionName = tr("Anonymous Function");
stackFrame.function = functionName;
- objectData = d->extractData(body.value(_("script")), refsVal);
+ objectData = extractData(body.value(_("script")), refsVal);
stackFrame.file = d->engine->toFileInProject(objectData.value.toString());
stackFrame.usable = QFileInfo(stackFrame.file).isReadable();
- objectData = d->extractData(body.value(_("receiver")), refsVal);
+ objectData = extractData(body.value(_("receiver")), refsVal);
stackFrame.to = objectData.value.toString();
stackFrame.line = body.value(_("line")).toInt() + 1;
@@ -1691,8 +1657,7 @@ void QmlV8DebuggerClient::setCurrentFrameDetails(const QVariant &bodyVal, const
data.exp = QByteArray("this");
data.name = QLatin1String(data.exp);
data.iname = QByteArray("local.") + data.exp;
- QmlV8ObjectData objectData = d->extractData(
- currentFrame.value(_("receiver")), refsVal);
+ QmlV8ObjectData objectData = extractData(currentFrame.value(_("receiver")), refsVal);
data.id = objectData.handle;
data.type = objectData.type;
data.value = objectData.value.toString();
@@ -1749,12 +1714,12 @@ void QmlV8DebuggerClient::updateScope(const QVariant &bodyVal, const QVariant &r
if (bodyMap.value(_("frameIndex")).toInt() != stackHandler->currentIndex())
return;
- QmlV8ObjectData objectData = d->extractData(bodyMap.value(_("object")), refsVal);
+ QmlV8ObjectData objectData = extractData(bodyMap.value(_("object")), refsVal);
QList<int> handlesToLookup;
QList<WatchData> locals;
foreach (const QVariant &property, objectData.properties) {
- QmlV8ObjectData localData = d->extractData(property, refsVal);
+ QmlV8ObjectData localData = extractData(property, refsVal);
WatchData data;
data.exp = localData.name;
//Check for v8 specific local data
@@ -1784,9 +1749,37 @@ void QmlV8DebuggerClient::updateScope(const QVariant &bodyVal, const QVariant &r
d->engine->watchHandler()->insertData(locals);
}
-void QmlV8DebuggerClient::updateEvaluationResult(int sequence, bool success, const QVariant &bodyVal,
+QmlJSTools::QmlConsoleItem *constructLogItemTree(QmlJSTools::QmlConsoleItem *parent,
+ const QmlV8ObjectData &objectData,
const QVariant &refsVal)
{
+ using namespace QmlJSTools;
+ bool sorted = debuggerCore()->boolSetting(SortStructMembers);
+ if (!objectData.value.isValid())
+ return 0;
+
+ QString text;
+ if (objectData.name.isEmpty())
+ text = objectData.value.toString();
+ else
+ text = QString(_("%1: %2")).arg(QString::fromAscii(objectData.name))
+ .arg(objectData.value.toString());
+
+ QmlConsoleItem *item = new QmlConsoleItem(parent, QmlConsoleItem::UndefinedType, text);
+
+ foreach (const QVariant &property, objectData.properties) {
+ QmlConsoleItem *child = constructLogItemTree(item, extractData(property, refsVal),
+ refsVal);
+ if (child)
+ item->insertChild(child, sorted);
+ }
+
+ return item;
+}
+
+void QmlV8DebuggerClient::updateEvaluationResult(int sequence, bool success,
+ const QVariant &bodyVal, const QVariant &refsVal)
+{
// { "seq" : <number>,
// "type" : "response",
// "request_seq" : <number>,
@@ -1809,17 +1802,20 @@ void QmlV8DebuggerClient::updateEvaluationResult(int sequence, bool success, con
} else if (d->debuggerCommands.contains(sequence)) {
d->updateLocalsAndWatchers.removeOne(sequence);
- QmlV8ObjectData body = d->extractData(bodyVal, refsVal);
- QtMessageLogItem *item = d->constructLogItemTree(d->engine->qtMessageLogHandler()->root(),
- body, refsVal);
- if (item)
- d->engine->qtMessageLogHandler()->appendItem(item);
+ QmlV8ObjectData body = extractData(bodyVal, refsVal);
+ using namespace QmlJSTools;
+ QmlConsoleManager *consoleManager = QmlConsoleManager::instance();
+ if (consoleManager) {
+ QmlConsoleItem *item = constructLogItemTree(consoleManager->rootItem(), body, refsVal);
+ if (item)
+ consoleManager->printToConsolePane(item);
+ }
//Update the locals
foreach (int index, d->currentFrameScopes)
d->scope(index);
} else {
- QmlV8ObjectData body = d->extractData(bodyVal, refsVal);
+ QmlV8ObjectData body = extractData(bodyVal, refsVal);
if (d->evaluatingExpression.contains(sequence)) {
QString exp = d->evaluatingExpression.take(sequence);
QList<WatchData> watchDataList;
@@ -1918,7 +1914,7 @@ void QmlV8DebuggerClient::expandLocalsAndWatchers(const QVariant &bodyVal, const
QStringList handlesList = body.keys();
WatchHandler *watchHandler = d->engine->watchHandler();
foreach (const QString &handle, handlesList) {
- QmlV8ObjectData bodyObjectData = d->extractData(
+ QmlV8ObjectData bodyObjectData = extractData(
body.value(handle), refsVal);
QByteArray prepend = d->localsAndWatchers.take(handle.toInt());
@@ -1955,7 +1951,7 @@ QList<WatchData> QmlV8DebuggerClient::createWatchDataList(const WatchData *paren
if (properties.count()) {
QTC_ASSERT(parent, return watchDataList);
foreach (const QVariant &property, properties) {
- QmlV8ObjectData propertyData = d->extractData(property, refsVal);
+ QmlV8ObjectData propertyData = extractData(property, refsVal);
WatchData data;
data.name = QString::fromUtf8(propertyData.name);
@@ -2021,7 +2017,7 @@ void QmlV8DebuggerClient::highlightExceptionCode(int lineNumber,
QString message = QString(_("%1: %2: %3")).arg(filePath).arg(lineNumber)
.arg(errorMessage);
- d->engine->showMessage(message, QtMessageLogOutput);
+ d->engine->showMessage(message, ConsoleOutput);
}
}
}
diff --git a/src/plugins/debugger/qml/qscriptdebuggerclient.cpp b/src/plugins/debugger/qml/qscriptdebuggerclient.cpp
index e8002db2ba..e9b156da15 100644
--- a/src/plugins/debugger/qml/qscriptdebuggerclient.cpp
+++ b/src/plugins/debugger/qml/qscriptdebuggerclient.cpp
@@ -514,7 +514,7 @@ void QScriptDebuggerClient::messageReceived(const QByteArray &data)
if (iname.startsWith("watch.")) {
watchHandler->insertIncompleteData(data);
} else if (iname == "console") {
- d->engine->showMessage(data.value, QtMessageLogOutput);
+ d->engine->showMessage(data.value, ConsoleOutput);
} else if (iname.startsWith("local.")) {
data.name = data.name.left(data.name.indexOf(QLatin1Char(' ')));
watchHandler->insertIncompleteData(data);
diff --git a/src/plugins/debugger/qtmessagelogeditor.h b/src/plugins/debugger/qtmessagelogeditor.h
deleted file mode 100644
index 28e8a75a73..0000000000
--- a/src/plugins/debugger/qtmessagelogeditor.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: http://www.qt-project.org/
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**************************************************************************/
-
-#ifndef QTMESSAGELOGEDITOR_H
-#define QTMESSAGELOGEDITOR_H
-
-#include <QModelIndex>
-#include <QTextEdit>
-
-namespace Debugger {
-namespace Internal {
-
-class QtMessageLogEditor : public QTextEdit
-{
- Q_OBJECT
-public:
- explicit QtMessageLogEditor(const QModelIndex &index,
- QWidget *parent = 0);
-
- QString getCurrentScript() const;
-
-protected:
- void keyPressEvent(QKeyEvent *e);
- void contextMenuEvent(QContextMenuEvent *event);
- void focusOutEvent(QFocusEvent *e);
-
-signals:
- void editingFinished();
-
-protected:
- void handleUpKey();
- void handleDownKey();
-
- void replaceCurrentScript(const QString &script);
-
-private:
- QModelIndex m_historyIndex;
- QString m_cachedScript;
- QImage m_prompt;
- int m_startOfEditableArea;
-};
-
-} //Internal
-} //Debugger
-
-#endif // QTMESSAGELOGEDITOR_H
diff --git a/src/plugins/debugger/qtmessageloghandler.cpp b/src/plugins/debugger/qtmessageloghandler.cpp
deleted file mode 100644
index ccb738a1ca..0000000000
--- a/src/plugins/debugger/qtmessageloghandler.cpp
+++ /dev/null
@@ -1,405 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: http://www.qt-project.org/
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**************************************************************************/
-
-#include "qtmessageloghandler.h"
-#include "debuggercore.h"
-#include "debuggeractions.h"
-
-#include <utils/qtcassert.h>
-
-#include <QFontMetrics>
-
-namespace Debugger {
-namespace Internal {
-
-///////////////////////////////////////////////////////////////////////
-//
-// QtMessageLogItem
-//
-///////////////////////////////////////////////////////////////////////
-
-QtMessageLogItem::QtMessageLogItem(QtMessageLogItem *parent,
- QtMessageLogHandler::ItemType itemType, const QString &text)
- : m_parentItem(parent),
- itemType(itemType),
- line(-1)
-
-{
- setText(text);
-}
-
-QtMessageLogItem::~QtMessageLogItem()
-{
- qDeleteAll(m_childItems);
-}
-
-QtMessageLogItem *QtMessageLogItem::child(int number)
-{
- return m_childItems.value(number);
-}
-
-int QtMessageLogItem::childCount() const
-{
- return m_childItems.size();
-}
-
-int QtMessageLogItem::childNumber() const
-{
- if (m_parentItem)
- return m_parentItem->m_childItems.indexOf(
- const_cast<QtMessageLogItem *>(this));
-
- return 0;
-}
-
-bool QtMessageLogItem::insertChildren(int position, int count)
-{
- if (position < 0 || position > m_childItems.size())
- return false;
-
- for (int row = 0; row < count; ++row) {
- QtMessageLogItem *item = new
- QtMessageLogItem(this , QtMessageLogHandler::UndefinedType,
- QString());
- m_childItems.insert(position, item);
- }
-
- return true;
-}
-
-void QtMessageLogItem::insertChild(QtMessageLogItem *item)
-{
- if (!debuggerCore()->boolSetting(SortStructMembers)) {
- m_childItems.insert(m_childItems.count(), item);
- return;
- }
-
- int i = 0;
- for (; i < m_childItems.count(); i++) {
- if (item->m_text < m_childItems[i]->m_text) {
- break;
- }
- }
- m_childItems.insert(i, item);
-}
-
-bool QtMessageLogItem::insertChild(int position, QtMessageLogItem *item)
-{
- if (position < 0 || position > m_childItems.size())
- return false;
-
- m_childItems.insert(position, item);
-
- return true;
-}
-
-QtMessageLogItem *QtMessageLogItem::parent()
-{
- return m_parentItem;
-}
-
-bool QtMessageLogItem::removeChildren(int position, int count)
-{
- if (position < 0 || position + count > m_childItems.size())
- return false;
-
- for (int row = 0; row < count; ++row)
- delete m_childItems.takeAt(position);
-
- return true;
-}
-
-bool QtMessageLogItem::detachChild(int position)
-{
- if (position < 0 || position > m_childItems.size())
- return false;
-
- m_childItems.removeAt(position);
-
- return true;
-}
-
-void QtMessageLogItem::setText(const QString &text)
-{
- m_text = text;
- for (int i = 0; i < m_text.length(); ++i) {
- if (m_text.at(i).isPunct())
- m_text.insert(++i, QChar(0x200b)); // ZERO WIDTH SPACE
- }
-}
-
-const QString &QtMessageLogItem::text() const
-{
- return m_text;
-}
-
-///////////////////////////////////////////////////////////////////////
-//
-// QtMessageLogHandler
-//
-///////////////////////////////////////////////////////////////////////
-
-QtMessageLogHandler::QtMessageLogHandler(QObject *parent) :
- QAbstractItemModel(parent),
- m_hasEditableRow(false),
- m_rootItem(new QtMessageLogItem(0)),
- m_maxSizeOfFileName(0)
-{
-}
-
-QtMessageLogHandler::~QtMessageLogHandler()
-{
- delete m_rootItem;
-}
-
-void QtMessageLogHandler::clear()
-{
- beginResetModel();
- delete m_rootItem;
- m_rootItem = new QtMessageLogItem(0);
- endResetModel();
-
- if (m_hasEditableRow)
- appendEditableRow();
-}
-
-bool QtMessageLogHandler::appendItem(QtMessageLogItem *item, int position)
-{
- if (position < 0)
- position = m_rootItem->childCount() - 1;
-
- beginInsertRows(QModelIndex(), position, position);
- bool success = m_rootItem->insertChild(position, item);
- endInsertRows();
-
- return success;
-}
-
-bool QtMessageLogHandler::appendMessage(QtMessageLogHandler::ItemType itemType,
- const QString &message, int position)
-{
- return appendItem(new QtMessageLogItem(m_rootItem, itemType, message), position);
-}
-
-void QtMessageLogHandler::setHasEditableRow(bool hasEditableRow)
-{
- if (m_hasEditableRow && !hasEditableRow)
- removeEditableRow();
-
- if (!m_hasEditableRow && hasEditableRow)
- appendEditableRow();
-
- m_hasEditableRow = hasEditableRow;
-}
-
-bool QtMessageLogHandler::hasEditableRow() const
-{
- return m_hasEditableRow;
-}
-
-void QtMessageLogHandler::appendEditableRow()
-{
- int position = m_rootItem->childCount();
- if (appendItem(new QtMessageLogItem(m_rootItem, QtMessageLogHandler::InputType), position))
- emit selectEditableRow(index(position, 0),
- QItemSelectionModel::ClearAndSelect);
-}
-
-void QtMessageLogHandler::removeEditableRow()
-{
- if (m_rootItem->child(m_rootItem->childCount() - 1)->itemType ==
- QtMessageLogHandler::InputType)
- removeRow(m_rootItem->childCount() - 1);
-}
-
-int QtMessageLogHandler::sizeOfFile(const QFont &font)
-{
- int lastReadOnlyRow = m_rootItem->childCount();
- if (m_hasEditableRow)
- lastReadOnlyRow -= 2;
- else
- lastReadOnlyRow -= 1;
- if (lastReadOnlyRow < 0)
- return 0;
- QString filename = m_rootItem->child(lastReadOnlyRow)->file;
- const int pos = filename.lastIndexOf(QLatin1Char('/'));
- if (pos != -1)
- filename = filename.mid(pos + 1);
-
- QFontMetrics fm(font);
- m_maxSizeOfFileName = qMax(m_maxSizeOfFileName, fm.width(filename));
-
- return m_maxSizeOfFileName;
-}
-
-int QtMessageLogHandler::sizeOfLineNumber(const QFont &font)
-{
- QFontMetrics fm(font);
- return fm.width(QLatin1String("88888"));
-}
-
-QVariant QtMessageLogHandler::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid())
- return QVariant();
-
- QtMessageLogItem *item = getItem(index);
-
- if (role == Qt::DisplayRole )
- return item->text();
- else if (role == QtMessageLogHandler::TypeRole)
- return int(item->itemType);
- else if (role == QtMessageLogHandler::FileRole)
- return item->file;
- else if (role == QtMessageLogHandler::LineRole)
- return item->line;
- else
- return QVariant();
-}
-
-QModelIndex QtMessageLogHandler::index(int row, int column,
- const QModelIndex &parent) const
-{
- if (parent.isValid() && parent.column() != 0)
- return QModelIndex();
-
- if (column > 0)
- return QModelIndex();
-
- QtMessageLogItem *parentItem = getItem(parent);
-
- QtMessageLogItem *childItem = parentItem->child(row);
- if (childItem)
- return createIndex(row, column, childItem);
- else
- return QModelIndex();
-}
-
-QModelIndex QtMessageLogHandler::parent(const QModelIndex &index) const
-{
- if (!index.isValid())
- return QModelIndex();
-
- QtMessageLogItem *childItem = getItem(index);
- QtMessageLogItem *parentItem = childItem->parent();
-
- if (parentItem == m_rootItem)
- return QModelIndex();
-
- //can parentItem be 0?
- if (!parentItem)
- return QModelIndex();
- return createIndex(parentItem->childNumber(), 0, parentItem);
-}
-
-int QtMessageLogHandler::rowCount(const QModelIndex &parent) const
-{
- QtMessageLogItem *parentItem = getItem(parent);
-
- return parentItem->childCount();
-}
-
-int QtMessageLogHandler::columnCount(const QModelIndex & /* parent */) const
-{
- return 1;
-}
-
-Qt::ItemFlags QtMessageLogHandler::flags(const QModelIndex &index) const
-{
- if (!index.isValid())
- return 0;
-
- QtMessageLogItem *item = getItem(index);
- if (m_hasEditableRow && item->parent() == m_rootItem
- && index.row() == m_rootItem->childCount() - 1)
- return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
- return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
-}
-
-bool QtMessageLogHandler::setData(const QModelIndex &index, const QVariant &value,
- int role)
-{
- QtMessageLogItem *item = getItem(index);
- bool result = false;
- if (role == Qt::DisplayRole) {
- item->setText(value.toString());
- result = true;
- } else if (role == QtMessageLogHandler::TypeRole) {
- item->itemType = (QtMessageLogHandler::ItemType)value.toInt();
- result = true;
- } else if (role == QtMessageLogHandler::FileRole) {
- item->file = value.toString();
- result = true;
- } else if (role == QtMessageLogHandler::LineRole) {
- item->line = value.toInt();
- result = true;
- }
-
- if (result)
- emit dataChanged(index, index);
-
- return result;
-}
-
-bool QtMessageLogHandler::insertRows(int position, int rows, const QModelIndex &parent)
-{
- QtMessageLogItem *parentItem = getItem(parent);
- bool success;
-
- beginInsertRows(parent, position, position + rows - 1);
- success = parentItem->insertChildren(position, rows);
- endInsertRows();
-
- return success;
-}
-
-bool QtMessageLogHandler::removeRows(int position, int rows, const QModelIndex &parent)
-{
- QtMessageLogItem *parentItem = getItem(parent);
- bool success = true;
-
- beginRemoveRows(parent, position, position + rows - 1);
- success = parentItem->removeChildren(position, rows);
- endRemoveRows();
-
- return success;
-}
-
-QtMessageLogItem *QtMessageLogHandler::getItem(const QModelIndex &index) const
-{
- if (index.isValid()) {
- QtMessageLogItem *item = static_cast<QtMessageLogItem*>(index.internalPointer());
- if (item) return item;
- }
- return m_rootItem;
-}
-
-} //Internal
-} //Debugger
diff --git a/src/plugins/debugger/qtmessageloghandler.h b/src/plugins/debugger/qtmessageloghandler.h
deleted file mode 100644
index d952f73b9d..0000000000
--- a/src/plugins/debugger/qtmessageloghandler.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: http://www.qt-project.org/
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**************************************************************************/
-
-#ifndef QTMESSAGELOGHANDLER_H
-#define QTMESSAGELOGHANDLER_H
-
-#include <QAbstractItemModel>
-#include <QItemSelectionModel>
-#include <QFont>
-
-namespace Debugger {
-namespace Internal {
-
-class QtMessageLogItem;
-class QtMessageLogHandler : public QAbstractItemModel
-{
- Q_OBJECT
-
-public:
- enum ItemType
- {
- InputType = 0x01,
- DebugType = 0x02,
- WarningType = 0x04,
- ErrorType = 0x08,
- UndefinedType = 0x10, //Can be used for unknown and for Return values
- DefaultTypes = InputType | UndefinedType
- };
- Q_DECLARE_FLAGS(ItemTypes, ItemType)
-
- enum Roles { TypeRole = Qt::UserRole, FileRole, LineRole };
-
- explicit QtMessageLogHandler(QObject *parent = 0);
- ~QtMessageLogHandler();
-
- void setHasEditableRow(bool hasEditableRow);
- bool hasEditableRow() const;
- void appendEditableRow();
- void removeEditableRow();
-
- bool appendItem(QtMessageLogItem *item, int position = -1);
- bool appendMessage(QtMessageLogHandler::ItemType itemType,
- const QString &message, int position = -1);
-
- QAbstractItemModel *model() { return this; }
-
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
-
- int sizeOfFile(const QFont &font);
- int sizeOfLineNumber(const QFont &font);
-
- QtMessageLogItem *root() const { return m_rootItem; }
-
-public slots:
- void clear();
-
-signals:
- void selectEditableRow(const QModelIndex &index,
- QItemSelectionModel::SelectionFlags flags);
- void rowInserted(const QModelIndex &index);
-
-protected:
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
-
- QModelIndex index(int row, int column,
- const QModelIndex &parent = QModelIndex()) const;
- QModelIndex parent(const QModelIndex &index) const;
-
-
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
-
- Qt::ItemFlags flags(const QModelIndex &index) const;
- bool setData(const QModelIndex &index, const QVariant &value,
- int role = Qt::EditRole);
-
- bool insertRows(int position, int rows,
- const QModelIndex &parent = QModelIndex());
- bool removeRows(int position, int rows,
- const QModelIndex &parent = QModelIndex());
-
- QtMessageLogItem *getItem(const QModelIndex &index) const;
-
-private:
- bool m_hasEditableRow;
- QtMessageLogItem *m_rootItem;
- int m_maxSizeOfFileName;
-};
-
-class QtMessageLogItem
-{
-public:
- QtMessageLogItem(QtMessageLogItem *parent,
- QtMessageLogHandler::ItemType type = QtMessageLogHandler::UndefinedType,
- const QString &data = QString());
- ~QtMessageLogItem();
-
- QtMessageLogItem *child(int number);
- int childCount() const;
- bool insertChildren(int position, int count);
- void insertChild(QtMessageLogItem *item);
- bool insertChild(int position, QtMessageLogItem *item);
- QtMessageLogItem *parent();
- bool removeChildren(int position, int count);
- bool detachChild(int position);
- int childNumber() const;
- void setText(const QString &text);
- const QString &text() const;
-
-private:
- QtMessageLogItem *m_parentItem;
- QList<QtMessageLogItem *> m_childItems;
- QString m_text;
-
-public:
- QtMessageLogHandler::ItemType itemType;
- QString file;
- int line;
-};
-
-} //Internal
-} //Debugger
-
-#endif // QTMESSAGELOGHANDLER_H
diff --git a/src/plugins/debugger/qtmessagelogproxymodel.cpp b/src/plugins/debugger/qtmessagelogproxymodel.cpp
deleted file mode 100644
index 8945893154..0000000000
--- a/src/plugins/debugger/qtmessagelogproxymodel.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: http://www.qt-project.org/
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**************************************************************************/
-
-#include "qtmessagelogproxymodel.h"
-
-namespace Debugger {
-namespace Internal {
-
-QtMessageLogProxyModel::QtMessageLogProxyModel(QObject *parent) :
- QSortFilterProxyModel(parent),
- m_filter(QtMessageLogHandler::DefaultTypes)
-{
-}
-
-void QtMessageLogProxyModel::setShowLogs(bool show)
-{
- m_filter = show ? m_filter | QtMessageLogHandler::DebugType :
- m_filter & ~QtMessageLogHandler::DebugType;
- setFilterRegExp(QString());
-}
-
-void QtMessageLogProxyModel::setShowWarnings(bool show)
-{
- m_filter = show ? m_filter | QtMessageLogHandler::WarningType :
- m_filter & ~QtMessageLogHandler::WarningType;
- setFilterRegExp(QString());
-}
-
-void QtMessageLogProxyModel::setShowErrors(bool show)
-{
- m_filter = show ? m_filter | QtMessageLogHandler::ErrorType :
- m_filter & ~QtMessageLogHandler::ErrorType;
- setFilterRegExp(QString());
-}
-
-void QtMessageLogProxyModel::selectEditableRow(const QModelIndex &index,
- QItemSelectionModel::SelectionFlags command)
-{
- emit setCurrentIndex(mapFromSource(index), command);
-}
-
-bool QtMessageLogProxyModel::filterAcceptsRow(int sourceRow,
- const QModelIndex &sourceParent) const
- {
- QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
- return m_filter.testFlag((QtMessageLogHandler::ItemType)
- sourceModel()->data(
- index, QtMessageLogHandler::TypeRole).toInt());
- }
-
-void QtMessageLogProxyModel::onRowsInserted(const QModelIndex &index, int start, int end)
-{
- int rowIndex = end;
- do {
- if (filterAcceptsRow(rowIndex, index)) {
- emit scrollToBottom();
- break;
- }
- } while (--rowIndex >= start);
-}
-
-} // namespace Internal
-} // namespace Debugger
diff --git a/src/plugins/debugger/qtmessagelogproxymodel.h b/src/plugins/debugger/qtmessagelogproxymodel.h
deleted file mode 100644
index 6d002590c3..0000000000
--- a/src/plugins/debugger/qtmessagelogproxymodel.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: http://www.qt-project.org/
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**************************************************************************/
-
-#ifndef QTMESSAGELOGPROXYMODEL_H
-#define QTMESSAGELOGPROXYMODEL_H
-
-#include "qtmessageloghandler.h"
-
-#include <QSortFilterProxyModel>
-#include <QItemSelectionModel>
-
-namespace Debugger {
-namespace Internal {
-
-class QtMessageLogProxyModel : public QSortFilterProxyModel
-{
- Q_OBJECT
-public:
- explicit QtMessageLogProxyModel(QObject *parent = 0);
-
-public slots:
- void setShowLogs(bool show);
- void setShowWarnings(bool show);
- void setShowErrors(bool show);
- void selectEditableRow(const QModelIndex &index,
- QItemSelectionModel::SelectionFlags command);
- void onRowsInserted(const QModelIndex &index, int start, int end);
-
-signals:
- void scrollToBottom();
- void setCurrentIndex(const QModelIndex &index,
- QItemSelectionModel::SelectionFlags command);
-
-protected:
- bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
-
-private:
- QFlags<QtMessageLogHandler::ItemType> m_filter;
-};
-
-} // namespace Internal
-} // namespace Debugger
-
-#endif // QTMESSAGELOGPROXYMODEL_H
diff --git a/src/plugins/debugger/qtmessagelogview.h b/src/plugins/debugger/qtmessagelogview.h
deleted file mode 100644
index 8c19a59ab5..0000000000
--- a/src/plugins/debugger/qtmessagelogview.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: http://www.qt-project.org/
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**************************************************************************/
-
-#ifndef QTMESSAGELOGVIEW_H
-#define QTMESSAGELOGVIEW_H
-
-#include <QTreeView>
-
-namespace Debugger {
-namespace Internal {
-
-class QtMessageLogView : public QTreeView
-{
- Q_OBJECT
-public:
- explicit QtMessageLogView(QWidget *parent = 0);
-
-public slots:
- void onScrollToBottom();
-
-protected:
- void mousePressEvent(QMouseEvent *event);
- void keyPressEvent(QKeyEvent *e);
- void resizeEvent(QResizeEvent *e);
- void drawBranches(QPainter *painter, const QRect &rect,
- const QModelIndex &index) const;
- void contextMenuEvent(QContextMenuEvent *event);
-
-private slots:
- void onRowActivated(const QModelIndex &index);
-
-private:
- void copyToClipboard(const QModelIndex &index);
- bool canShowItemInTextEditor(const QModelIndex &index);
-};
-
-} //Internal
-} //Debugger
-
-#endif // QTMESSAGELOGVIEW_H
diff --git a/src/plugins/debugger/qtmessagelogwindow.cpp b/src/plugins/debugger/qtmessagelogwindow.cpp
deleted file mode 100644
index f691f0d264..0000000000
--- a/src/plugins/debugger/qtmessagelogwindow.cpp
+++ /dev/null
@@ -1,254 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: http://www.qt-project.org/
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**************************************************************************/
-
-#include "qtmessagelogwindow.h"
-#include "qtmessagelogview.h"
-#include "qtmessageloghandler.h"
-#include "qtmessagelogitemdelegate.h"
-#include "debuggerstringutils.h"
-#include "qtmessagelogproxymodel.h"
-
-#include <utils/statuslabel.h>
-#include <utils/styledbar.h>
-#include <utils/savedaction.h>
-
-#include <coreplugin/icore.h>
-#include <coreplugin/coreconstants.h>
-#include <coreplugin/findplaceholder.h>
-
-#include <aggregation/aggregate.h>
-#include <find/treeviewfind.h>
-
-#include <QSettings>
-#include <QHBoxLayout>
-#include <QVBoxLayout>
-#include <QToolButton>
-
-static const char CONSOLE[] = "Console";
-static const char SHOW_LOG[] = "showLog";
-static const char SHOW_WARNING[] = "showWarning";
-static const char SHOW_ERROR[] = "showError";
-
-namespace Debugger {
-namespace Internal {
-
-/////////////////////////////////////////////////////////////////////
-//
-// QtMessageLogWindow
-//
-/////////////////////////////////////////////////////////////////////
-
-QtMessageLogWindow::QtMessageLogWindow(QWidget *parent)
- : QWidget(parent)
-{
- setWindowTitle(tr(CONSOLE));
- setObjectName(_(CONSOLE));
-
- const int statusBarHeight = 25;
-
- QVBoxLayout *vbox = new QVBoxLayout(this);
- vbox->setMargin(0);
- vbox->setSpacing(0);
-
- QWidget *statusbarContainer = new Utils::StyledBar();
- statusbarContainer->setStyleSheet(QLatin1String("background: #9B9B9B"));
- statusbarContainer->setFixedHeight(statusBarHeight);
- QHBoxLayout *hbox = new QHBoxLayout(statusbarContainer);
- hbox->setMargin(0);
- hbox->setSpacing(0);
-
- hbox->addSpacing(5);
-
- //Status Label
- m_statusLabel = new Utils::StatusLabel;
- hbox->addWidget(m_statusLabel);
- hbox->addWidget(new Utils::StyledSeparator);
-
- const int buttonWidth = 25;
- //Filters
- QToolButton *button = new QToolButton(this);
- button->setAutoRaise(true);
- button->setFixedWidth(buttonWidth);
- m_showLogAction = new Utils::SavedAction(this);
- m_showLogAction->setDefaultValue(true);
- m_showLogAction->setSettingsKey(_(CONSOLE), _(SHOW_LOG));
- m_showLogAction->setText(tr("Log"));
- m_showLogAction->setToolTip(tr("Show debug, log, and info messages."));
- m_showLogAction->setCheckable(true);
- m_showLogAction->setIcon(QIcon(_(":/debugger/images/log.png")));
- button->setDefaultAction(m_showLogAction);
- hbox->addWidget(button);
-
- button = new QToolButton(this);
- button->setAutoRaise(true);
- button->setFixedWidth(buttonWidth);
- m_showWarningAction = new Utils::SavedAction(this);
- m_showWarningAction->setDefaultValue(true);
- m_showWarningAction->setSettingsKey(_(CONSOLE), _(SHOW_WARNING));
- m_showWarningAction->setText(tr("Warning"));
- m_showWarningAction->setToolTip(tr("Show warning messages."));
- m_showWarningAction->setCheckable(true);
- m_showWarningAction->setIcon(QIcon(_(":/debugger/images/warning.png")));
- button->setDefaultAction(m_showWarningAction);
- hbox->addWidget(button);
-
- button = new QToolButton(this);
- button->setAutoRaise(true);
- button->setFixedWidth(buttonWidth);
- m_showErrorAction = new Utils::SavedAction(this);
- m_showErrorAction->setDefaultValue(true);
- m_showErrorAction->setSettingsKey(_(CONSOLE), _(SHOW_ERROR));
- m_showErrorAction->setText(tr("Error"));
- m_showErrorAction->setToolTip(tr("Show error and fatal messages."));
- m_showErrorAction->setCheckable(true);
- m_showErrorAction->setIcon(QIcon(_(":/debugger/images/error.png")));
- button->setDefaultAction(m_showErrorAction);
- hbox->addWidget(button);
- hbox->addWidget(new Utils::StyledSeparator);
-
- //Clear Button
- button = new QToolButton;
- button->setAutoRaise(true);
- button->setFixedWidth(buttonWidth);
- m_clearAction = new QAction(tr("Clear Console"), this);
- m_clearAction->setIcon(QIcon(_(Core::Constants::ICON_CLEAN_PANE)));
- button->setDefaultAction(m_clearAction);
- hbox->addWidget(button);
- hbox->addWidget(new Utils::StyledSeparator);
-
- m_treeView = new QtMessageLogView(this);
- m_treeView->setSizePolicy(QSizePolicy::MinimumExpanding,
- QSizePolicy::MinimumExpanding);
-
- m_proxyModel = new QtMessageLogProxyModel(this);
- connect(m_showLogAction, SIGNAL(toggled(bool)),
- m_proxyModel, SLOT(setShowLogs(bool)));
- connect(m_showWarningAction, SIGNAL(toggled(bool)),
- m_proxyModel, SLOT(setShowWarnings(bool)));
- connect(m_showErrorAction, SIGNAL(toggled(bool)),
- m_proxyModel, SLOT(setShowErrors(bool)));
-
- m_treeView->setModel(m_proxyModel);
- connect(m_proxyModel,
- SIGNAL(setCurrentIndex(QModelIndex,QItemSelectionModel::SelectionFlags)),
- m_treeView->selectionModel(),
- SLOT(setCurrentIndex(QModelIndex,QItemSelectionModel::SelectionFlags)));
- connect(m_proxyModel,
- SIGNAL(scrollToBottom()),
- m_treeView,
- SLOT(onScrollToBottom()));
-
- m_itemDelegate = new QtMessageLogItemDelegate(this);
- connect(m_treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
- m_itemDelegate, SLOT(currentChanged(QModelIndex,QModelIndex)));
- m_treeView->setItemDelegate(m_itemDelegate);
-
- vbox->addWidget(statusbarContainer);
- vbox->addWidget(m_treeView);
- vbox->addWidget(new Core::FindToolBarPlaceHolder(this));
-
- readSettings();
- connect(Core::ICore::instance(),
- SIGNAL(saveSettingsRequested()), SLOT(writeSettings()));
-
- Aggregation::Aggregate *aggregate = new Aggregation::Aggregate();
- aggregate->add(m_treeView);
- aggregate->add(new Find::TreeViewFind(m_treeView));
-}
-
-QtMessageLogWindow::~QtMessageLogWindow()
-{
- writeSettings();
-}
-
-void QtMessageLogWindow::readSettings()
-{
- QSettings *settings = Core::ICore::settings();
- m_showLogAction->readSettings(settings);
- m_showWarningAction->readSettings(settings);
- m_showErrorAction->readSettings(settings);
-}
-
-void QtMessageLogWindow::showStatus(const QString &context, int timeout)
-{
- m_statusLabel->showStatusMessage(context, timeout);
-}
-
-void QtMessageLogWindow::writeSettings() const
-{
- QSettings *settings = Core::ICore::settings();
- m_showLogAction->writeSettings(settings);
- m_showWarningAction->writeSettings(settings);
- m_showErrorAction->writeSettings(settings);
-}
-
-void QtMessageLogWindow::setModel(QAbstractItemModel *model)
-{
- QtMessageLogHandler *oldHandler = qobject_cast<QtMessageLogHandler *>(
- m_proxyModel->sourceModel());
- if (oldHandler) {
- disconnect(m_clearAction, SIGNAL(triggered()), oldHandler, SLOT(clear()));
- disconnect(oldHandler,
- SIGNAL(selectEditableRow(
- QModelIndex,QItemSelectionModel::SelectionFlags)),
- m_proxyModel,
- SLOT(selectEditableRow(
- QModelIndex,QItemSelectionModel::SelectionFlags)));
- disconnect(oldHandler,
- SIGNAL(rowsInserted(QModelIndex,int,int)),
- m_proxyModel,
- SLOT(onRowsInserted(QModelIndex,int,int)));
- }
-
- QtMessageLogHandler *newHandler = qobject_cast<QtMessageLogHandler *>(model);
- m_proxyModel->setSourceModel(newHandler);
- m_itemDelegate->setItemModel(newHandler);
-
- if (newHandler) {
- connect(m_clearAction, SIGNAL(triggered()), newHandler, SLOT(clear()));
- connect(newHandler,
- SIGNAL(selectEditableRow(
- QModelIndex,QItemSelectionModel::SelectionFlags)),
- m_proxyModel,
- SLOT(selectEditableRow(
- QModelIndex,QItemSelectionModel::SelectionFlags)));
-
- //Scroll to bottom when rows matching current filter settings are inserted
- //Not connecting rowsRemoved as the only way to remove rows is to clear the
- //model which will automatically reset the view.
- connect(newHandler,
- SIGNAL(rowsInserted(QModelIndex,int,int)),
- m_proxyModel,
- SLOT(onRowsInserted(QModelIndex,int,int)));
- }
-}
-
-} // namespace Internal
-} // namespace Debugger
diff --git a/src/plugins/debugger/qtmessagelogwindow.h b/src/plugins/debugger/qtmessagelogwindow.h
deleted file mode 100644
index 56c8569b86..0000000000
--- a/src/plugins/debugger/qtmessagelogwindow.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: http://www.qt-project.org/
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**************************************************************************/
-
-#ifndef QTMESSAGELOGWINDOW_H
-#define QTMESSAGELOGWINDOW_H
-
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QAbstractItemModel;
-class QAction;
-QT_END_NAMESPACE
-
-namespace Utils {
-class StatusLabel;
-class SavedAction;
-}
-
-namespace Debugger {
-namespace Internal {
-
-class QtMessageLogView;
-class QtMessageLogItemDelegate;
-class QtMessageLogProxyModel;
-class QtMessageLogWindow : public QWidget
-{
- Q_OBJECT
-
-public:
- QtMessageLogWindow(QWidget *parent = 0);
- ~QtMessageLogWindow();
-
- void setModel(QAbstractItemModel *model);
- void readSettings();
- void showStatus(const QString &context, int timeout);
-
-public slots:
- void writeSettings() const;
-
-private:
- Utils::StatusLabel *m_statusLabel;
- Utils::SavedAction *m_showLogAction;
- Utils::SavedAction *m_showWarningAction;
- Utils::SavedAction *m_showErrorAction;
- QAction *m_clearAction;
- QtMessageLogView *m_treeView;
- QtMessageLogItemDelegate *m_itemDelegate;
- QtMessageLogProxyModel *m_proxyModel;
-};
-
-} // namespace Internal
-} // namespace Debugger
-
-#endif // QTMESSAGELOGWINDOW_H
-
diff --git a/src/plugins/debugger/images/collapse.png b/src/plugins/qmljstools/images/collapse.png
index 64ae3720c1..64ae3720c1 100644
--- a/src/plugins/debugger/images/collapse.png
+++ b/src/plugins/qmljstools/images/collapse.png
Binary files differ
diff --git a/src/plugins/debugger/images/error.png b/src/plugins/qmljstools/images/error.png
index 39768b9f39..39768b9f39 100644
--- a/src/plugins/debugger/images/error.png
+++ b/src/plugins/qmljstools/images/error.png
Binary files differ
diff --git a/src/plugins/debugger/images/expand.png b/src/plugins/qmljstools/images/expand.png
index 7959bfc97e..7959bfc97e 100644
--- a/src/plugins/debugger/images/expand.png
+++ b/src/plugins/qmljstools/images/expand.png
Binary files differ
diff --git a/src/plugins/debugger/images/log.png b/src/plugins/qmljstools/images/log.png
index e4766f228b..e4766f228b 100644
--- a/src/plugins/debugger/images/log.png
+++ b/src/plugins/qmljstools/images/log.png
Binary files differ
diff --git a/src/plugins/debugger/images/prompt.png b/src/plugins/qmljstools/images/prompt.png
index a333a87198..a333a87198 100644
--- a/src/plugins/debugger/images/prompt.png
+++ b/src/plugins/qmljstools/images/prompt.png
Binary files differ
diff --git a/src/plugins/debugger/images/warning.png b/src/plugins/qmljstools/images/warning.png
index 3200efc4fd..3200efc4fd 100644
--- a/src/plugins/debugger/images/warning.png
+++ b/src/plugins/qmljstools/images/warning.png
Binary files differ
diff --git a/src/plugins/debugger/qtmessagelogeditor.cpp b/src/plugins/qmljstools/qmlconsoleedit.cpp
index b1b2730234..2a64d935ca 100644
--- a/src/plugins/debugger/qtmessagelogeditor.cpp
+++ b/src/plugins/qmljstools/qmlconsoleedit.cpp
@@ -1,38 +1,6 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: http://www.qt-project.org/
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**************************************************************************/
-
-#include "qtmessagelogeditor.h"
-#include "qtmessageloghandler.h"
-#include "debuggerstringutils.h"
-#include "debuggercore.h"
-#include "debuggerengine.h"
+#include "qmlconsoleedit.h"
+#include "qmlconsoleitemmodel.h"
+#include "qmlconsolemanager.h"
#include <utils/qtcassert.h>
@@ -40,54 +8,56 @@
#include <QMenu>
#include <QKeyEvent>
-namespace Debugger {
+namespace QmlJSTools {
namespace Internal {
///////////////////////////////////////////////////////////////////////
//
-// QtMessageLogEditor
+// QmlConsoleEdit
//
///////////////////////////////////////////////////////////////////////
-QtMessageLogEditor::QtMessageLogEditor(const QModelIndex &index,
- QWidget *parent) :
+QmlConsoleEdit::QmlConsoleEdit(const QModelIndex &index, QWidget *parent) :
QTextEdit(parent),
m_historyIndex(index),
- m_prompt(_(":/debugger/images/prompt.png")),
+ m_prompt(QLatin1String(":/qmljstools/images/prompt.png")),
m_startOfEditableArea(0)
{
setFrameStyle(QFrame::NoFrame);
setUndoRedoEnabled(false);
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
- document()->addResource(QTextDocument::ImageResource,
- QUrl(_("prompt")), m_prompt);
+ document()->addResource(QTextDocument::ImageResource, QUrl(QLatin1String("prompt")), m_prompt);
QTextImageFormat format;
- format.setName(_("prompt"));
+ format.setName(QLatin1String("prompt"));
format.setHeight(9);
format.setWidth(9);
- textCursor().insertText(_(" "));
+ textCursor().insertText(QLatin1String(" "));
textCursor().insertImage(format);
- textCursor().insertText(_(" "));
+ textCursor().insertText(QLatin1String(" "));
m_startOfEditableArea = textCursor().position();
ensureCursorVisible();
setTextInteractionFlags(Qt::TextEditorInteraction);
}
-void QtMessageLogEditor::keyPressEvent(QKeyEvent *e)
+void QmlConsoleEdit::keyPressEvent(QKeyEvent *e)
{
bool keyConsumed = false;
switch (e->key()) {
case Qt::Key_Return:
case Qt::Key_Enter: {
- keyConsumed = debuggerCore()->evaluateScriptExpression(getCurrentScript());
- if (keyConsumed) {
+ m_interpreter.clearText();
+ QString currentScript = getCurrentScript();
+ m_interpreter.appendText(currentScript);
+ if (currentScript.isEmpty()) {
+ emit editingFinished();
+ } else if (m_interpreter.canEvaluate()) {
+ QmlConsoleModel::evaluate(currentScript);
emit editingFinished();
- debuggerCore()->currentEngine()->qtMessageLogHandler()->appendEditableRow();
}
- }
break;
+ }
case Qt::Key_Backspace:
if (textCursor().selectionStart() <= m_startOfEditableArea)
@@ -99,14 +69,13 @@ void QtMessageLogEditor::keyPressEvent(QKeyEvent *e)
keyConsumed = true;
break;
- case Qt::Key_Home:
- {
+ case Qt::Key_Home: {
QTextCursor c(textCursor());
c.setPosition(m_startOfEditableArea);
setTextCursor(c);
keyConsumed = true;
- }
break;
+ }
case Qt::Key_Up:
handleUpKey();
@@ -161,10 +130,9 @@ void QtMessageLogEditor::keyPressEvent(QKeyEvent *e)
QTextEdit::keyPressEvent(e);
}
-void QtMessageLogEditor::contextMenuEvent(QContextMenuEvent *event)
+void QmlConsoleEdit::contextMenuEvent(QContextMenuEvent *event)
{
- //TODO:: on right click the editor closes
- //FIXIT
+ // TODO:: on right click the editor closes
return QTextEdit::contextMenuEvent(event);
QTextCursor cursor = textCursor();
@@ -193,12 +161,12 @@ void QtMessageLogEditor::contextMenuEvent(QContextMenuEvent *event)
delete menu;
}
-void QtMessageLogEditor::focusOutEvent(QFocusEvent * /*e*/)
+void QmlConsoleEdit::focusOutEvent(QFocusEvent * /*e*/)
{
emit editingFinished();
}
-void QtMessageLogEditor::handleUpKey()
+void QmlConsoleEdit::handleUpKey()
{
QTC_ASSERT(m_historyIndex.isValid(), return);
int currentRow = m_historyIndex.row();
@@ -210,19 +178,17 @@ void QtMessageLogEditor::handleUpKey()
currentRow--;
if (model->hasIndex(currentRow, 0)) {
QModelIndex index = model->index(currentRow, 0);
- if (QtMessageLogHandler::InputType == (QtMessageLogHandler::ItemType)model->data(
- index, QtMessageLogHandler::TypeRole).toInt()) {
+ if (QmlConsoleItem::InputType == (QmlConsoleItem::ItemType)model->data(
+ index, QmlConsoleItemModel::TypeRole).toInt()) {
m_historyIndex = index;
- replaceCurrentScript(model->data(
- index, Qt::DisplayRole).
- toString());
+ replaceCurrentScript(model->data(index, Qt::DisplayRole).toString());
break;
}
}
}
}
-void QtMessageLogEditor::handleDownKey()
+void QmlConsoleEdit::handleDownKey()
{
QTC_ASSERT(m_historyIndex.isValid(), return);
int currentRow = m_historyIndex.row();
@@ -231,32 +197,29 @@ void QtMessageLogEditor::handleDownKey()
currentRow++;
if (model->hasIndex(currentRow, 0)) {
QModelIndex index = model->index(currentRow, 0);
- if (QtMessageLogHandler::InputType == (QtMessageLogHandler::ItemType)model->data(
- index, QtMessageLogHandler::TypeRole).toInt()) {
+ if (QmlConsoleItem::InputType == (QmlConsoleItem::ItemType)model->data(
+ index, QmlConsoleItemModel::TypeRole).toInt()) {
m_historyIndex = index;
if (currentRow == model->rowCount() - 1)
replaceCurrentScript(m_cachedScript);
else
- replaceCurrentScript(model->data(
- index, Qt::DisplayRole).
- toString());
+ replaceCurrentScript(model->data(index, Qt::DisplayRole).toString());
break;
}
}
}
}
-QString QtMessageLogEditor::getCurrentScript() const
+QString QmlConsoleEdit::getCurrentScript() const
{
QTextCursor cursor = textCursor();
cursor.setPosition(m_startOfEditableArea);
cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
QString script = cursor.selectedText();
- //remove WS
return script.trimmed();
}
-void QtMessageLogEditor::replaceCurrentScript(const QString &script)
+void QmlConsoleEdit::replaceCurrentScript(const QString &script)
{
QTextCursor cursor = textCursor();
cursor.setPosition(m_startOfEditableArea);
@@ -266,5 +229,5 @@ void QtMessageLogEditor::replaceCurrentScript(const QString &script)
setTextCursor(cursor);
}
-} //Internal
-} //Debugger
+} // Internal
+} // QmlJSTools
diff --git a/src/plugins/qmljstools/qmlconsoleedit.h b/src/plugins/qmljstools/qmlconsoleedit.h
new file mode 100644
index 0000000000..749ed8ef0a
--- /dev/null
+++ b/src/plugins/qmljstools/qmlconsoleedit.h
@@ -0,0 +1,45 @@
+#ifndef QMLCONSOLEEDIT_H
+#define QMLCONSOLEEDIT_H
+
+#include "qmljsinterpreter.h"
+
+#include <QTextEdit>
+#include <QModelIndex>
+
+namespace QmlJSTools {
+namespace Internal {
+
+class QmlConsoleEdit : public QTextEdit
+{
+ Q_OBJECT
+public:
+ QmlConsoleEdit(const QModelIndex &index, QWidget *parent);
+
+ QString getCurrentScript() const;
+
+protected:
+ void keyPressEvent(QKeyEvent *e);
+ void contextMenuEvent(QContextMenuEvent *event);
+ void focusOutEvent(QFocusEvent *e);
+
+signals:
+ void editingFinished();
+
+protected:
+ void handleUpKey();
+ void handleDownKey();
+
+ void replaceCurrentScript(const QString &script);
+
+private:
+ QModelIndex m_historyIndex;
+ QString m_cachedScript;
+ QImage m_prompt;
+ int m_startOfEditableArea;
+ QmlJSInterpreter m_interpreter;
+};
+
+} // QmlJSTools
+} // Internal
+
+#endif // QMLCONSOLEEDIT_H
diff --git a/src/plugins/qmljstools/qmlconsoleitem.cpp b/src/plugins/qmljstools/qmlconsoleitem.cpp
new file mode 100644
index 0000000000..dbcd9fee61
--- /dev/null
+++ b/src/plugins/qmljstools/qmlconsoleitem.cpp
@@ -0,0 +1,123 @@
+#include "qmlconsoleitem.h"
+
+namespace QmlJSTools {
+
+///////////////////////////////////////////////////////////////////////
+//
+// QmlConsoleItem
+//
+///////////////////////////////////////////////////////////////////////
+
+QmlConsoleItem::QmlConsoleItem(QmlConsoleItem *parent, QmlConsoleItem::ItemType itemType,
+ const QString &text)
+ : m_parentItem(parent),
+ itemType(itemType),
+ line(-1)
+
+{
+ setText(text);
+}
+
+QmlConsoleItem::~QmlConsoleItem()
+{
+ qDeleteAll(m_childItems);
+}
+
+QmlConsoleItem *QmlConsoleItem::child(int number)
+{
+ return m_childItems.value(number);
+}
+
+int QmlConsoleItem::childCount() const
+{
+ return m_childItems.size();
+}
+
+int QmlConsoleItem::childNumber() const
+{
+ if (m_parentItem)
+ return m_parentItem->m_childItems.indexOf(const_cast<QmlConsoleItem *>(this));
+
+ return 0;
+}
+
+bool QmlConsoleItem::insertChildren(int position, int count)
+{
+ if (position < 0 || position > m_childItems.size())
+ return false;
+
+ for (int row = 0; row < count; ++row) {
+ QmlConsoleItem *item = new QmlConsoleItem(this, QmlConsoleItem::UndefinedType,
+ QString());
+ m_childItems.insert(position, item);
+ }
+
+ return true;
+}
+
+void QmlConsoleItem::insertChild(QmlConsoleItem *item, bool sorted)
+{
+ if (!sorted) {
+ m_childItems.insert(m_childItems.count(), item);
+ return;
+ }
+
+ int i = 0;
+ for (; i < m_childItems.count(); i++) {
+ if (item->m_text < m_childItems[i]->m_text)
+ break;
+ }
+ m_childItems.insert(i, item);
+}
+
+bool QmlConsoleItem::insertChild(int position, QmlConsoleItem *item)
+{
+ if (position < 0 || position > m_childItems.size())
+ return false;
+
+ m_childItems.insert(position, item);
+
+ return true;
+}
+
+QmlConsoleItem *QmlConsoleItem::parent()
+{
+ return m_parentItem;
+}
+
+bool QmlConsoleItem::removeChildren(int position, int count)
+{
+ if (position < 0 || position + count > m_childItems.size())
+ return false;
+
+ for (int row = 0; row < count; ++row)
+ delete m_childItems.takeAt(position);
+
+ return true;
+}
+
+bool QmlConsoleItem::detachChild(int position)
+{
+ if (position < 0 || position > m_childItems.size())
+ return false;
+
+ m_childItems.removeAt(position);
+
+ return true;
+}
+
+void QmlConsoleItem::setText(const QString &text)
+{
+ m_text = text;
+ for (int i = 0; i < m_text.length(); ++i) {
+ if (m_text.at(i).isPunct())
+ m_text.insert(++i, QChar(0x200b)); // ZERO WIDTH SPACE
+ }
+}
+
+const QString &QmlConsoleItem::text() const
+{
+ return m_text;
+}
+
+} // QmlJSTools
diff --git a/src/plugins/qmljstools/qmlconsoleitem.h b/src/plugins/qmljstools/qmlconsoleitem.h
new file mode 100644
index 0000000000..6663df388f
--- /dev/null
+++ b/src/plugins/qmljstools/qmlconsoleitem.h
@@ -0,0 +1,55 @@
+#ifndef QMLCONSOLEITEM_H
+#define QMLCONSOLEITEM_H
+
+#include "qmljstools_global.h"
+
+#include <QList>
+#include <QString>
+
+namespace QmlJSTools {
+
+class QMLJSTOOLS_EXPORT QmlConsoleItem
+{
+public:
+ enum ItemType
+ {
+ UndefinedType = 0x01, // Can be used for unknown and for Return values
+ DebugType = 0x02,
+ WarningType = 0x04,
+ ErrorType = 0x08,
+ InputType = 0x10,
+ DefaultTypes = InputType | UndefinedType
+ };
+ Q_DECLARE_FLAGS(ItemTypes, ItemType)
+
+ QmlConsoleItem(QmlConsoleItem *parent,
+ QmlConsoleItem::ItemType type = QmlConsoleItem::UndefinedType,
+ const QString &data = QString());
+ ~QmlConsoleItem();
+
+ QmlConsoleItem *child(int number);
+ int childCount() const;
+ bool insertChildren(int position, int count);
+ void insertChild(QmlConsoleItem *item, bool sorted);
+ bool insertChild(int position, QmlConsoleItem *item);
+ QmlConsoleItem *parent();
+ bool removeChildren(int position, int count);
+ bool detachChild(int position);
+ int childNumber() const;
+ void setText(const QString &text);
+ const QString &text() const;
+
+private:
+ QmlConsoleItem *m_parentItem;
+ QList<QmlConsoleItem *> m_childItems;
+ QString m_text;
+
+public:
+ QmlConsoleItem::ItemType itemType;
+ QString file;
+ int line;
+};
+
+} // QmlJSTools
+
+#endif // QMLCONSOLEITEM_H
diff --git a/src/plugins/debugger/qtmessagelogitemdelegate.cpp b/src/plugins/qmljstools/qmlconsoleitemdelegate.cpp
index 946dd2e78b..5f6c66f99c 100644
--- a/src/plugins/debugger/qtmessagelogitemdelegate.cpp
+++ b/src/plugins/qmljstools/qmlconsoleitemdelegate.cpp
@@ -1,35 +1,5 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: http://www.qt-project.org/
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**************************************************************************/
-
-#include "qtmessagelogitemdelegate.h"
-#include "qtmessagelogeditor.h"
+#include "qmlconsoleitemdelegate.h"
+#include "qmlconsoleedit.h"
#include <QPainter>
#include <QTreeView>
@@ -54,55 +24,54 @@ const char CONSOLE_BORDER_COLOR[] = "#C9C9C9";
const int ELLIPSIS_GRADIENT_WIDTH = 16;
-namespace Debugger {
+namespace QmlJSTools {
namespace Internal {
///////////////////////////////////////////////////////////////////////
//
-// QtMessageLogItemDelegate
+// QmlConsoleItemDelegate
//
///////////////////////////////////////////////////////////////////////
-QtMessageLogItemDelegate::QtMessageLogItemDelegate(QObject *parent) :
+QmlConsoleItemDelegate::QmlConsoleItemDelegate(QObject *parent) :
QStyledItemDelegate(parent),
- m_logIcon(QLatin1String(":/debugger/images/log.png")),
- m_warningIcon(QLatin1String(":/debugger/images/warning.png")),
- m_errorIcon(QLatin1String(":/debugger/images/error.png")),
- m_expandIcon(QLatin1String(":/debugger/images/expand.png")),
- m_collapseIcon(QLatin1String(":/debugger/images/collapse.png")),
- m_prompt(QLatin1String(":/debugger/images/prompt.png")),
- m_itemModel(0),
+ m_logIcon(QLatin1String(":/qmljstools/images/log.png")),
+ m_warningIcon(QLatin1String(":/qmljstools/images/warning.png")),
+ m_errorIcon(QLatin1String(":/qmljstools/images/error.png")),
+ m_expandIcon(QLatin1String(":/qmljstools/images/expand.png")),
+ m_collapseIcon(QLatin1String(":/qmljstools/images/collapse.png")),
+ m_prompt(QLatin1String(":/qmljstools/images/prompt.png")),
m_cachedHeight(0)
{
}
-void QtMessageLogItemDelegate::emitSizeHintChanged(const QModelIndex &index)
+void QmlConsoleItemDelegate::emitSizeHintChanged(const QModelIndex &index)
{
emit sizeHintChanged(index);
}
-QColor QtMessageLogItemDelegate::drawBackground(QPainter *painter, const QRect &rect,
- const QModelIndex &index,
- bool selected) const
+QColor QmlConsoleItemDelegate::drawBackground(QPainter *painter, const QRect &rect,
+ const QModelIndex &index,
+ bool selected) const
{
painter->save();
- QtMessageLogHandler::ItemType itemType = (QtMessageLogHandler::ItemType)index.data(
- QtMessageLogHandler::TypeRole).toInt();
+ QmlConsoleItem::ItemType itemType = (QmlConsoleItem::ItemType)index.data(
+ QmlConsoleItemModel::TypeRole).toInt();
QColor backgroundColor;
switch (itemType) {
- case QtMessageLogHandler::DebugType:
+ case QmlConsoleItem::DebugType:
backgroundColor = selected ? QColor(CONSOLE_LOG_BACKGROUND_SELECTED_COLOR) :
QColor(CONSOLE_LOG_BACKGROUND_COLOR);
break;
- case QtMessageLogHandler::WarningType:
+ case QmlConsoleItem::WarningType:
backgroundColor = selected ? QColor(CONSOLE_WARNING_BACKGROUND_SELECTED_COLOR) :
QColor(CONSOLE_WARNING_BACKGROUND_COLOR);
break;
- case QtMessageLogHandler::ErrorType:
+ case QmlConsoleItem::ErrorType:
backgroundColor = selected ? QColor(CONSOLE_ERROR_BACKGROUND_SELECTED_COLOR) :
QColor(CONSOLE_ERROR_BACKGROUND_COLOR);
break;
- case QtMessageLogHandler::InputType:
+ case QmlConsoleItem::InputType:
default:
backgroundColor = selected ? QColor(CONSOLE_EDITOR_BACKGROUND_SELECTED_COLOR) :
QColor(CONSOLE_EDITOR_BACKGROUND_COLOR);
@@ -117,37 +86,37 @@ QColor QtMessageLogItemDelegate::drawBackground(QPainter *painter, const QRect &
painter->setPen(QColor(CONSOLE_BORDER_COLOR));
if (!(index.flags() & Qt::ItemIsEditable))
painter->drawLine(0, rect.bottom(), rect.right(),
- rect.bottom());
+ rect.bottom());
painter->restore();
return backgroundColor;
}
-void QtMessageLogItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
- const QModelIndex &index) const
+void QmlConsoleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const
{
QStyleOptionViewItemV4 opt = option;
initStyleOption(&opt, index);
painter->save();
- //Set Colors
+ // Set Colors
QColor textColor;
QIcon taskIcon;
- QtMessageLogHandler::ItemType type = (QtMessageLogHandler::ItemType)index.data(
- QtMessageLogHandler::TypeRole).toInt();
+ QmlConsoleItem::ItemType type = (QmlConsoleItem::ItemType)index.data(
+ QmlConsoleItemModel::TypeRole).toInt();
switch (type) {
- case QtMessageLogHandler::DebugType:
+ case QmlConsoleItem::DebugType:
textColor = QColor(CONSOLE_LOG_TEXT_COLOR);
taskIcon = m_logIcon;
break;
- case QtMessageLogHandler::WarningType:
+ case QmlConsoleItem::WarningType:
textColor = QColor(CONSOLE_WARNING_TEXT_COLOR);
taskIcon = m_warningIcon;
break;
- case QtMessageLogHandler::ErrorType:
+ case QmlConsoleItem::ErrorType:
textColor = QColor(CONSOLE_ERROR_TEXT_COLOR);
taskIcon = m_errorIcon;
break;
- case QtMessageLogHandler::InputType:
+ case QmlConsoleItem::InputType:
textColor = QColor(CONSOLE_EDITOR_TEXT_COLOR);
taskIcon = m_prompt;
break;
@@ -156,11 +125,11 @@ void QtMessageLogItemDelegate::paint(QPainter *painter, const QStyleOptionViewIt
break;
}
- //Paint background
+ // Paint background
QColor backgroundColor = drawBackground(painter, opt.rect, index,
- bool(opt.state & QStyle::State_Selected));
+ bool(opt.state & QStyle::State_Selected));
- //Calculate positions
+ // Calculate positions
const QTreeView *view = qobject_cast<const QTreeView *>(opt.widget);
int level = 0;
QModelIndex idx(index);
@@ -168,14 +137,12 @@ void QtMessageLogItemDelegate::paint(QPainter *painter, const QStyleOptionViewIt
idx = idx.parent();
level++;
}
- int width = view->width() - level * view->indentation() -
- view->verticalScrollBar()->width();
+ int width = view->width() - level * view->indentation() - view->verticalScrollBar()->width();
bool showTypeIcon = index.parent() == QModelIndex();
- bool showExpandableIcon = type == QtMessageLogHandler::UndefinedType;
+ bool showExpandableIcon = type == QmlConsoleItem::UndefinedType;
QRect rect(opt.rect.x(), opt.rect.top(), width, opt.rect.height());
- ConsoleItemPositions positions(rect, opt.font, showTypeIcon,
- showExpandableIcon, m_itemModel);
+ ConsoleItemPositions positions(rect, opt.font, showTypeIcon, showExpandableIcon);
// Paint TaskIconArea:
if (showTypeIcon)
@@ -196,11 +163,10 @@ void QtMessageLogItemDelegate::paint(QPainter *painter, const QStyleOptionViewIt
tl.draw(painter, QPoint(positions.textAreaLeft(), positions.adjustedTop()));
} else {
QFontMetrics fm(opt.font);
- painter->drawText(positions.textArea(),
- fm.elidedText(str, Qt::ElideRight,
- positions.textAreaWidth()));
+ painter->drawText(positions.textArea(), fm.elidedText(str, Qt::ElideRight,
+ positions.textAreaWidth()));
}
- //skip if area is editable
+ // skip if area is editable
if (showExpandableIcon) {
// Paint ExpandableIconArea:
QIcon expandCollapseIcon;
@@ -210,16 +176,14 @@ void QtMessageLogItemDelegate::paint(QPainter *painter, const QStyleOptionViewIt
else
expandCollapseIcon = m_expandIcon;
}
- painter->drawPixmap(positions.expandCollapseIconLeft(),
- positions.adjustedTop(),
- expandCollapseIcon.pixmap(
- positions.expandCollapseIconWidth(),
- positions.expandCollapseIconHeight()));
+ painter->drawPixmap(positions.expandCollapseIconLeft(), positions.adjustedTop(),
+ expandCollapseIcon.pixmap(positions.expandCollapseIconWidth(),
+ positions.expandCollapseIconHeight()));
}
if (showFileLineInfo) {
- //Check for file info
- QString file = index.data(QtMessageLogHandler::FileRole).toString();
+ // Check for file info
+ QString file = index.data(QmlConsoleItemModel::FileRole).toString();
if (!file.isEmpty()) {
QFontMetrics fm(option.font);
// Paint FileArea
@@ -228,22 +192,20 @@ void QtMessageLogItemDelegate::paint(QPainter *painter, const QStyleOptionViewIt
file = file.mid(pos +1);
const int realFileWidth = fm.width(file);
painter->setClipRect(positions.fileArea());
- painter->drawText(positions.fileAreaLeft(),
- positions.adjustedTop() + fm.ascent(), file);
+ painter->drawText(positions.fileAreaLeft(), positions.adjustedTop() + fm.ascent(),
+ file);
if (realFileWidth > positions.fileAreaWidth()) {
// draw a gradient to mask the text
int gradientStart = positions.fileAreaLeft() - 1;
- QLinearGradient lg(gradientStart +
- ELLIPSIS_GRADIENT_WIDTH, 0, gradientStart, 0);
+ QLinearGradient lg(gradientStart + ELLIPSIS_GRADIENT_WIDTH, 0, gradientStart, 0);
lg.setColorAt(0, Qt::transparent);
lg.setColorAt(1, backgroundColor);
painter->fillRect(gradientStart, positions.adjustedTop(),
- ELLIPSIS_GRADIENT_WIDTH, positions.lineHeight(),
- lg);
+ ELLIPSIS_GRADIENT_WIDTH, positions.lineHeight(), lg);
}
// Paint LineArea
- QString lineText = index.data(QtMessageLogHandler::LineRole).toString();
+ QString lineText = index.data(QmlConsoleItemModel::LineRole).toString();
painter->setClipRect(positions.lineArea());
const int realLineWidth = fm.width(lineText);
painter->drawText(positions.lineAreaRight() - realLineWidth,
@@ -254,8 +216,8 @@ void QtMessageLogItemDelegate::paint(QPainter *painter, const QStyleOptionViewIt
painter->restore();
}
-QSize QtMessageLogItemDelegate::sizeHint(const QStyleOptionViewItem &option,
- const QModelIndex &index) const
+QSize QmlConsoleItemDelegate::sizeHint(const QStyleOptionViewItem &option,
+ const QModelIndex &index) const
{
QStyleOptionViewItemV4 opt = option;
initStyleOption(&opt, index);
@@ -267,8 +229,7 @@ QSize QtMessageLogItemDelegate::sizeHint(const QStyleOptionViewItem &option,
idx = idx.parent();
level++;
}
- int width = view->width() - level * view->indentation() -
- view->verticalScrollBar()->width();
+ int width = view->width() - level * view->indentation() - view->verticalScrollBar()->width();
if (index.flags() & Qt::ItemIsEditable)
return QSize(width, view->height() * 1/2);
@@ -276,14 +237,13 @@ QSize QtMessageLogItemDelegate::sizeHint(const QStyleOptionViewItem &option,
if (!selected && option.font == m_cachedFont && m_cachedHeight > 0)
return QSize(width, m_cachedHeight);
- QtMessageLogHandler::ItemType type = (QtMessageLogHandler::ItemType)index.data(
- QtMessageLogHandler::TypeRole).toInt();
+ QmlConsoleItem::ItemType type = (QmlConsoleItem::ItemType)index.data(
+ QmlConsoleItemModel::TypeRole).toInt();
bool showTypeIcon = index.parent() == QModelIndex();
- bool showExpandableIcon = type == QtMessageLogHandler::UndefinedType;
+ bool showExpandableIcon = type == QmlConsoleItem::UndefinedType;
QRect rect(level * view->indentation(), 0, width, 0);
- ConsoleItemPositions positions(rect, opt.font,
- showTypeIcon, showExpandableIcon, m_itemModel);
+ ConsoleItemPositions positions(rect, opt.font, showTypeIcon, showExpandableIcon);
QFontMetrics fm(option.font);
qreal height = fm.height();
@@ -308,58 +268,56 @@ QSize QtMessageLogItemDelegate::sizeHint(const QStyleOptionViewItem &option,
return QSize(width, height);
}
-QWidget *QtMessageLogItemDelegate::createEditor(QWidget *parent,
- const QStyleOptionViewItem &/*option*/,
- const QModelIndex &index) const
+QWidget *QmlConsoleItemDelegate::createEditor(QWidget *parent,
+ const QStyleOptionViewItem &/*option*/,
+ const QModelIndex &index) const
{
- QtMessageLogEditor *editor = new QtMessageLogEditor(index, parent);
- connect(editor, SIGNAL(editingFinished()),
- this, SLOT(commitAndCloseEditor()));
+ QmlConsoleEdit *editor = new QmlConsoleEdit(index, parent);
+ connect(editor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()));
return editor;
}
-void QtMessageLogItemDelegate::setEditorData(QWidget *editor,
- const QModelIndex &index) const
+void QmlConsoleItemDelegate::setEditorData(QWidget *editor,
+ const QModelIndex &index) const
{
- QtMessageLogEditor *edtr = qobject_cast<QtMessageLogEditor *>(editor);
+ QmlConsoleEdit *edtr = qobject_cast<QmlConsoleEdit *>(editor);
edtr->insertPlainText(index.data(Qt::DisplayRole).toString());
}
-void QtMessageLogItemDelegate::setModelData(QWidget *editor,
- QAbstractItemModel *model,
- const QModelIndex &index) const
+void QmlConsoleItemDelegate::setModelData(QWidget *editor,
+ QAbstractItemModel *model,
+ const QModelIndex &index) const
{
- QtMessageLogEditor *edtr = qobject_cast<QtMessageLogEditor *>(editor);
+ QmlConsoleEdit *edtr = qobject_cast<QmlConsoleEdit *>(editor);
model->setData(index, edtr->getCurrentScript(), Qt::DisplayRole);
- model->setData(index, QtMessageLogHandler::InputType, QtMessageLogHandler::TypeRole);
+ model->setData(index, QmlConsoleItem::InputType, QmlConsoleItemModel::TypeRole);
}
-void QtMessageLogItemDelegate::updateEditorGeometry(QWidget *editor,
- const QStyleOptionViewItem &option,
- const QModelIndex &/*index*/) const
+void QmlConsoleItemDelegate::updateEditorGeometry(QWidget *editor,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &/*index*/) const
{
QStyleOptionViewItemV4 opt = option;
- editor->setGeometry(QRect(opt.rect.x(), opt.rect.top(),
- opt.rect.width(), opt.rect.bottom()));
+ editor->setGeometry(QRect(opt.rect.x(), opt.rect.top(), opt.rect.width(), opt.rect.bottom()));
}
-void QtMessageLogItemDelegate::currentChanged(const QModelIndex &current,
- const QModelIndex &previous)
+void QmlConsoleItemDelegate::currentChanged(const QModelIndex &current,
+ const QModelIndex &previous)
{
emit sizeHintChanged(current);
emit sizeHintChanged(previous);
}
-void QtMessageLogItemDelegate::commitAndCloseEditor()
+void QmlConsoleItemDelegate::commitAndCloseEditor()
{
- QtMessageLogEditor *editor = qobject_cast<QtMessageLogEditor *>(sender());
+ QmlConsoleEdit *editor = qobject_cast<QmlConsoleEdit *>(sender());
emit commitData(editor);
emit closeEditor(editor);
}
-qreal QtMessageLogItemDelegate::layoutText(QTextLayout &tl, int width,
- bool *showFileLineInfo) const
+qreal QmlConsoleItemDelegate::layoutText(QTextLayout &tl, int width,
+ bool *showFileLineInfo) const
{
qreal height = 0;
tl.beginLayout();
@@ -379,10 +337,5 @@ qreal QtMessageLogItemDelegate::layoutText(QTextLayout &tl, int width,
return height;
}
-void QtMessageLogItemDelegate::setItemModel(QtMessageLogHandler *model)
-{
- m_itemModel = model;
-}
-
-} //Internal
-} //Debugger
+} // Internal
+} // QmlJSTools
diff --git a/src/plugins/debugger/qtmessagelogitemdelegate.h b/src/plugins/qmljstools/qmlconsoleitemdelegate.h
index 73944a2078..490f84692d 100644
--- a/src/plugins/debugger/qtmessagelogitemdelegate.h
+++ b/src/plugins/qmljstools/qmlconsoleitemdelegate.h
@@ -1,55 +1,24 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: http://www.qt-project.org/
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**************************************************************************/
-
-#ifndef QTMESSAGELOGITEMDELEGATE_H
-#define QTMESSAGELOGITEMDELEGATE_H
-
-#include "qtmessageloghandler.h"
+#ifndef QMLCONSOLEITEMDELEGATE_H
+#define QMLCONSOLEITEMDELEGATE_H
+
+#include "qmlconsoleitemmodel.h"
+#include "qmlconsolemanager.h"
-#include <QTextLayout>
#include <QStyledItemDelegate>
+#include <QTextLayout>
-namespace Debugger {
+namespace QmlJSTools {
namespace Internal {
-class QtMessageLogItemDelegate : public QStyledItemDelegate
+class QmlConsoleItemDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
- explicit QtMessageLogItemDelegate(QObject *parent = 0);
- void emitSizeHintChanged(const QModelIndex &index);
- QColor drawBackground(QPainter *painter, const QRect &rect,
- const QModelIndex &index,
- bool selected) const;
+ QmlConsoleItemDelegate(QObject *parent);
- void setItemModel(QtMessageLogHandler *model);
+ void emitSizeHintChanged(const QModelIndex &index);
+ QColor drawBackground(QPainter *painter, const QRect &rect, const QModelIndex &index,
+ bool selected) const;
public slots:
void currentChanged(const QModelIndex &current, const QModelIndex &previous);
@@ -62,11 +31,9 @@ protected:
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
- void setModelData(QWidget *editor, QAbstractItemModel *model,
- const QModelIndex &index) const;
+ void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
- void updateEditorGeometry(QWidget *editor,
- const QStyleOptionViewItem &option,
+ void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
private slots:
@@ -82,7 +49,6 @@ private:
const QIcon m_expandIcon;
const QIcon m_collapseIcon;
const QIcon m_prompt;
- QtMessageLogHandler *m_itemModel;
mutable int m_cachedHeight;
mutable QFont m_cachedFont;
};
@@ -102,11 +68,8 @@ private:
class ConsoleItemPositions
{
public:
- ConsoleItemPositions(const QRect &rect,
- const QFont &font,
- bool showTaskIconArea,
- bool showExpandableIconArea,
- QtMessageLogHandler *model = 0)
+ ConsoleItemPositions(const QRect &rect, const QFont &font, bool showTaskIconArea,
+ bool showExpandableIconArea)
: m_x(rect.x()),
m_width(rect.width()),
m_top(rect.top()),
@@ -117,10 +80,9 @@ public:
m_showExpandableIconArea(showExpandableIconArea)
{
m_fontHeight = QFontMetrics(font).height();
- if (model) {
- m_maxFileLength = model->sizeOfFile(font);
- m_maxLineLength = model->sizeOfLineNumber(font);
- }
+ QmlConsoleItemModel *model = QmlConsoleModel::qmlConsoleItemModel();
+ m_maxFileLength = model->sizeOfFile(font);
+ m_maxLineLength = model->sizeOfLineNumber(font);
}
int adjustedTop() const { return m_top + ITEM_PADDING; }
@@ -130,44 +92,41 @@ public:
int lineHeight() const { return m_fontHeight + 1; }
int minimumHeight() const { return typeIconHeight() + 2 * ITEM_PADDING; }
- //PROMPTAREA is same as TYPEICONAREA
+ // PROMPTAREA is same as TYPEICONAREA
int typeIconLeft() const { return adjustedLeft(); }
int typeIconWidth() const { return TASK_ICON_SIZE; }
int typeIconHeight() const { return TASK_ICON_SIZE; }
- int typeIconRight() const { return m_showTaskIconArea ?
- typeIconLeft() + typeIconWidth() : adjustedLeft(); }
- QRect typeIcon() const { return
- QRect(typeIconLeft(), adjustedTop(),
- typeIconWidth(), typeIconHeight()); }
-
- int expandCollapseIconLeft() const { return typeIconRight() +
- ITEM_SPACING; }
+ int typeIconRight() const { return m_showTaskIconArea ? typeIconLeft() + typeIconWidth()
+ : adjustedLeft(); }
+ QRect typeIcon() const { return QRect(typeIconLeft(), adjustedTop(), typeIconWidth(),
+ typeIconHeight()); }
+
+ int expandCollapseIconLeft() const { return typeIconRight() + ITEM_SPACING; }
int expandCollapseIconWidth() const { return TASK_ICON_SIZE; }
int expandCollapseIconHeight() const { return TASK_ICON_SIZE; }
int expandCollapseIconRight() const { return m_showExpandableIconArea ?
- expandCollapseIconLeft() + expandCollapseIconWidth() :
- typeIconRight(); }
- QRect expandCollapseIcon() const { return
- QRect(expandCollapseIconLeft(), adjustedTop(),
- expandCollapseIconWidth(), expandCollapseIconHeight()); }
+ expandCollapseIconLeft() + expandCollapseIconWidth() : typeIconRight(); }
+ QRect expandCollapseIcon() const { return QRect(expandCollapseIconLeft(), adjustedTop(),
+ expandCollapseIconWidth(),
+ expandCollapseIconHeight()); }
int textAreaLeft() const { return expandCollapseIconRight() + ITEM_SPACING; }
int textAreaWidth() const { return textAreaRight() - textAreaLeft(); }
int textAreaRight() const { return fileAreaLeft() - ITEM_SPACING; }
- QRect textArea() const { return
- QRect(textAreaLeft(), adjustedTop(), textAreaWidth(), lineHeight()); }
+ QRect textArea() const { return QRect(textAreaLeft(), adjustedTop(), textAreaWidth(),
+ lineHeight()); }
int fileAreaLeft() const { return fileAreaRight() - fileAreaWidth(); }
int fileAreaWidth() const { return m_maxFileLength; }
int fileAreaRight() const { return lineAreaLeft() - ITEM_SPACING; }
- QRect fileArea() const { return
- QRect(fileAreaLeft(), adjustedTop(), fileAreaWidth(), lineHeight()); }
+ QRect fileArea() const { return QRect(fileAreaLeft(), adjustedTop(), fileAreaWidth(),
+ lineHeight()); }
int lineAreaLeft() const { return lineAreaRight() - lineAreaWidth(); }
int lineAreaWidth() const { return m_maxLineLength; }
int lineAreaRight() const { return adjustedRight() - ITEM_SPACING; }
- QRect lineArea() const { return
- QRect(lineAreaLeft(), adjustedTop(), lineAreaWidth(), lineHeight()); }
+ QRect lineArea() const { return QRect(lineAreaLeft(), adjustedTop(), lineAreaWidth(),
+ lineHeight()); }
private:
int m_x;
@@ -186,7 +145,8 @@ public:
static const int ITEM_SPACING = 4;
};
-} //Internal
-} //Debugger
-#endif // QTMESSAGELOGITEMDELEGATE_H
+} // namespace Internal
+} // namespace QmlJSTools
+
+#endif // QMLCONSOLEITEMDELEGATE_H
diff --git a/src/plugins/qmljstools/qmlconsoleitemmodel.cpp b/src/plugins/qmljstools/qmlconsoleitemmodel.cpp
new file mode 100644
index 0000000000..c205ff7b57
--- /dev/null
+++ b/src/plugins/qmljstools/qmlconsoleitemmodel.cpp
@@ -0,0 +1,252 @@
+#include "qmlconsoleitemmodel.h"
+
+#include <utils/qtcassert.h>
+
+#include <QFontMetrics>
+
+namespace QmlJSTools {
+namespace Internal {
+
+///////////////////////////////////////////////////////////////////////
+//
+// QmlConsoleItemModel
+//
+///////////////////////////////////////////////////////////////////////
+
+QmlConsoleItemModel::QmlConsoleItemModel(QObject *parent) :
+ QAbstractItemModel(parent),
+ m_hasEditableRow(false),
+ m_rootItem(new QmlConsoleItem(0)),
+ m_maxSizeOfFileName(0)
+{
+}
+
+QmlConsoleItemModel::~QmlConsoleItemModel()
+{
+ delete m_rootItem;
+}
+
+void QmlConsoleItemModel::clear()
+{
+ beginResetModel();
+ reset();
+ delete m_rootItem;
+ m_rootItem = new QmlConsoleItem(0);
+ endResetModel();
+
+ if (m_hasEditableRow)
+ appendEditableRow();
+}
+
+bool QmlConsoleItemModel::appendItem(QmlConsoleItem *item, int position)
+{
+ if (position < 0)
+ position = m_rootItem->childCount() - 1;
+
+ if (position < 0)
+ position = 0;
+
+ beginInsertRows(QModelIndex(), position, position);
+ bool success = m_rootItem->insertChild(position, item);
+ endInsertRows();
+
+ return success;
+}
+
+bool QmlConsoleItemModel::appendMessage(QmlConsoleItem::ItemType itemType,
+ const QString &message, int position)
+{
+ return appendItem(new QmlConsoleItem(m_rootItem, itemType, message), position);
+}
+
+void QmlConsoleItemModel::setHasEditableRow(bool hasEditableRow)
+{
+ if (m_hasEditableRow && !hasEditableRow)
+ removeEditableRow();
+
+ if (!m_hasEditableRow && hasEditableRow)
+ appendEditableRow();
+
+ m_hasEditableRow = hasEditableRow;
+}
+
+bool QmlConsoleItemModel::hasEditableRow() const
+{
+ return m_hasEditableRow;
+}
+
+void QmlConsoleItemModel::appendEditableRow()
+{
+ int position = m_rootItem->childCount();
+ if (appendItem(new QmlConsoleItem(m_rootItem, QmlConsoleItem::InputType), position))
+ emit selectEditableRow(index(position, 0), QItemSelectionModel::ClearAndSelect);
+}
+
+void QmlConsoleItemModel::removeEditableRow()
+{
+ if (m_rootItem->child(m_rootItem->childCount() - 1)->itemType == QmlConsoleItem::InputType)
+ removeRow(m_rootItem->childCount() - 1);
+}
+
+int QmlConsoleItemModel::sizeOfFile(const QFont &font)
+{
+ int lastReadOnlyRow = m_rootItem->childCount();
+ if (m_hasEditableRow)
+ lastReadOnlyRow -= 2;
+ else
+ lastReadOnlyRow -= 1;
+ if (lastReadOnlyRow < 0)
+ return 0;
+ QString filename = m_rootItem->child(lastReadOnlyRow)->file;
+ const int pos = filename.lastIndexOf(QLatin1Char('/'));
+ if (pos != -1)
+ filename = filename.mid(pos + 1);
+
+ QFontMetrics fm(font);
+ m_maxSizeOfFileName = qMax(m_maxSizeOfFileName, fm.width(filename));
+
+ return m_maxSizeOfFileName;
+}
+
+int QmlConsoleItemModel::sizeOfLineNumber(const QFont &font)
+{
+ QFontMetrics fm(font);
+ return fm.width(QLatin1String("88888"));
+}
+
+QVariant QmlConsoleItemModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ QmlConsoleItem *item = getItem(index);
+
+ if (role == Qt::DisplayRole )
+ return item->text();
+ else if (role == QmlConsoleItemModel::TypeRole)
+ return int(item->itemType);
+ else if (role == QmlConsoleItemModel::FileRole)
+ return item->file;
+ else if (role == QmlConsoleItemModel::LineRole)
+ return item->line;
+ else
+ return QVariant();
+}
+
+QModelIndex QmlConsoleItemModel::index(int row, int column, const QModelIndex &parent) const
+{
+ if (parent.isValid() && parent.column() != 0)
+ return QModelIndex();
+
+ if (column > 0)
+ return QModelIndex();
+
+ QmlConsoleItem *parentItem = getItem(parent);
+
+ QmlConsoleItem *childItem = parentItem->child(row);
+ if (childItem)
+ return createIndex(row, column, childItem);
+ else
+ return QModelIndex();
+}
+
+QModelIndex QmlConsoleItemModel::parent(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return QModelIndex();
+
+ QmlConsoleItem *childItem = getItem(index);
+ QmlConsoleItem *parentItem = childItem->parent();
+
+ if (parentItem == m_rootItem)
+ return QModelIndex();
+
+ if (!parentItem)
+ return QModelIndex();
+ return createIndex(parentItem->childNumber(), 0, parentItem);
+}
+
+int QmlConsoleItemModel::rowCount(const QModelIndex &parent) const
+{
+ QmlConsoleItem *parentItem = getItem(parent);
+
+ return parentItem->childCount();
+}
+
+int QmlConsoleItemModel::columnCount(const QModelIndex & /* parent */) const
+{
+ return 1;
+}
+
+Qt::ItemFlags QmlConsoleItemModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return 0;
+
+ QmlConsoleItem *item = getItem(index);
+ if (m_hasEditableRow && item->parent() == m_rootItem
+ && index.row() == m_rootItem->childCount() - 1)
+ return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+}
+
+bool QmlConsoleItemModel::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ QmlConsoleItem *item = getItem(index);
+ bool result = false;
+ if (role == Qt::DisplayRole) {
+ item->setText(value.toString());
+ result = true;
+ } else if (role == QmlConsoleItemModel::TypeRole) {
+ item->itemType = (QmlConsoleItem::ItemType)value.toInt();
+ result = true;
+ } else if (role == QmlConsoleItemModel::FileRole) {
+ item->file = value.toString();
+ result = true;
+ } else if (role == QmlConsoleItemModel::LineRole) {
+ item->line = value.toInt();
+ result = true;
+ }
+
+ if (result)
+ emit dataChanged(index, index);
+
+ return result;
+}
+
+bool QmlConsoleItemModel::insertRows(int position, int rows, const QModelIndex &parent)
+{
+ QmlConsoleItem *parentItem = getItem(parent);
+ bool success;
+
+ beginInsertRows(parent, position, position + rows - 1);
+ success = parentItem->insertChildren(position, rows);
+ endInsertRows();
+
+ return success;
+}
+
+bool QmlConsoleItemModel::removeRows(int position, int rows, const QModelIndex &parent)
+{
+ QmlConsoleItem *parentItem = getItem(parent);
+ bool success = true;
+
+ beginRemoveRows(parent, position, position + rows - 1);
+ success = parentItem->removeChildren(position, rows);
+ endRemoveRows();
+
+ return success;
+}
+
+QmlConsoleItem *QmlConsoleItemModel::getItem(const QModelIndex &index) const
+{
+ if (index.isValid()) {
+ QmlConsoleItem *item = static_cast<QmlConsoleItem*>(index.internalPointer());
+ if (item)
+ return item;
+ }
+ return m_rootItem;
+}
+
+} // Internal
+} // QmlJSTools
diff --git a/src/plugins/qmljstools/qmlconsoleitemmodel.h b/src/plugins/qmljstools/qmlconsoleitemmodel.h
new file mode 100644
index 0000000000..df599c0854
--- /dev/null
+++ b/src/plugins/qmljstools/qmlconsoleitemmodel.h
@@ -0,0 +1,73 @@
+#ifndef QMLCONSOLEITEMMODEL_H
+#define QMLCONSOLEITEMMODEL_H
+
+#include "qmlconsoleitem.h"
+
+#include <QAbstractItemModel>
+#include <QItemSelectionModel>
+#include <QFont>
+
+namespace QmlJSTools {
+namespace Internal {
+
+class QmlConsoleItemModel : public QAbstractItemModel
+{
+ Q_OBJECT
+public:
+ enum Roles { TypeRole = Qt::UserRole, FileRole, LineRole };
+
+ explicit QmlConsoleItemModel(QObject *parent = 0);
+ ~QmlConsoleItemModel();
+
+ void setHasEditableRow(bool hasEditableRow);
+ bool hasEditableRow() const;
+ void appendEditableRow();
+ void removeEditableRow();
+
+ bool appendItem(QmlConsoleItem *item, int position = -1);
+ bool appendMessage(QmlConsoleItem::ItemType itemType, const QString &message,
+ int position = -1);
+
+ QAbstractItemModel *model() { return this; }
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+
+ int sizeOfFile(const QFont &font);
+ int sizeOfLineNumber(const QFont &font);
+
+ QmlConsoleItem *root() const { return m_rootItem; }
+
+public slots:
+ void clear();
+
+signals:
+ void selectEditableRow(const QModelIndex &index, QItemSelectionModel::SelectionFlags flags);
+ void rowInserted(const QModelIndex &index);
+
+protected:
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
+ QModelIndex parent(const QModelIndex &index) const;
+
+
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
+
+ bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex());
+
+ QmlConsoleItem *getItem(const QModelIndex &index) const;
+
+private:
+ bool m_hasEditableRow;
+ QmlConsoleItem *m_rootItem;
+ int m_maxSizeOfFileName;
+};
+
+} // Internal
+} // QmlJSTools
+
+#endif // QMLCONSOLEITEMMODEL_H
diff --git a/src/plugins/qmljstools/qmlconsolemanager.cpp b/src/plugins/qmljstools/qmlconsolemanager.cpp
new file mode 100644
index 0000000000..19d04b4dea
--- /dev/null
+++ b/src/plugins/qmljstools/qmlconsolemanager.cpp
@@ -0,0 +1,162 @@
+#include "qmlconsolemanager.h"
+#include "qmlconsolepane.h"
+#include "qmlconsoleitemmodel.h"
+
+#include <extensionsystem/pluginmanager.h>
+
+#include <debugger/debuggerengine.h>
+
+#include <QScriptEngine>
+#include <QVariant>
+
+namespace QmlJSTools {
+
+QmlConsoleManager *QmlConsoleManager::m_instance = 0;
+
+class QmlConsoleManagerPrivate
+{
+public:
+ QScriptEngine *scriptEngine;
+ Internal::QmlConsoleItemModel *qmlConsoleItemModel;
+ Internal::QmlConsolePane *qmlConsolePane;
+ Debugger::DebuggerEngine *debuggerEngine;
+};
+
+QmlConsoleManager::QmlConsoleManager(QObject *parent)
+ : QObject(parent),
+ d(new QmlConsoleManagerPrivate)
+{
+ m_instance = this;
+ d->scriptEngine = new QScriptEngine(this);
+ d->qmlConsoleItemModel = new Internal::QmlConsoleItemModel(this);
+ d->qmlConsoleItemModel->setHasEditableRow(true);
+ d->qmlConsolePane = new Internal::QmlConsolePane(this);
+ ExtensionSystem::PluginManager::addObject(d->qmlConsolePane);
+ d->debuggerEngine = 0;
+}
+
+QmlConsoleManager::~QmlConsoleManager()
+{
+ if (d->qmlConsolePane) {
+ ExtensionSystem::PluginManager::removeObject(d->qmlConsolePane);
+ }
+ delete d;
+ m_instance = 0;
+}
+
+void QmlConsoleManager::showConsolePane()
+{
+ if (d->qmlConsolePane)
+ d->qmlConsolePane->popup(Core::IOutputPane::ModeSwitch);
+}
+
+QmlConsoleItem *QmlConsoleManager::rootItem() const
+{
+ return d->qmlConsoleItemModel->root();
+}
+
+void QmlConsoleManager::setDebuggerEngine(Debugger::DebuggerEngine *debuggerEngine)
+{
+ d->debuggerEngine = debuggerEngine;
+}
+
+void QmlConsoleManager::setContext(const QString &context)
+{
+ d->qmlConsolePane->setContext(context);
+}
+
+void QmlConsoleManager::printToConsolePane(QmlConsoleItem::ItemType itemType,
+ const QString &text, bool bringToForeground)
+{
+ if (!d->qmlConsolePane)
+ return;
+ if (itemType == QmlConsoleItem::ErrorType)
+ bringToForeground = true;
+ if (bringToForeground)
+ d->qmlConsolePane->popup(Core::IOutputPane::ModeSwitch);
+ d->qmlConsoleItemModel->appendMessage(itemType, text);
+}
+
+void QmlConsoleManager::printToConsolePane(QmlConsoleItem *item, bool bringToForeground)
+{
+ if (!d->qmlConsolePane)
+ return;
+ if (item->itemType == QmlConsoleItem::ErrorType)
+ bringToForeground = true;
+ if (bringToForeground)
+ d->qmlConsolePane->popup(Core::IOutputPane::ModeSwitch);
+ d->qmlConsoleItemModel->appendItem(item);
+}
+
+namespace Internal {
+
+QmlConsoleItem *constructLogItemTree(QmlConsoleItem *parent, const QVariant &result,
+ const QString &key = QString())
+{
+ if (!result.isValid())
+ return 0;
+
+ QmlConsoleItem *item = new QmlConsoleItem(parent);
+ if (result.type() == QVariant::Map) {
+ if (key.isEmpty())
+ item->setText(QLatin1String("Object"));
+ else
+ item->setText(key + QLatin1String(" : Object"));
+
+ QMapIterator<QString, QVariant> i(result.toMap());
+ while (i.hasNext()) {
+ i.next();
+ QmlConsoleItem *child = constructLogItemTree(item, i.value(), i.key());
+ if (child)
+ item->insertChild(child, true);
+ }
+ } else if (result.type() == QVariant::List) {
+ if (key.isEmpty())
+ item->setText(QLatin1String("List"));
+ else
+ item->setText(QString(QLatin1String("[%1] : List")).arg(key));
+ QVariantList resultList = result.toList();
+ for (int i = 0; i < resultList.count(); i++) {
+ QmlConsoleItem *child = constructLogItemTree(item, resultList.at(i),
+ QString::number(i));
+ if (child)
+ item->insertChild(child, true);
+ }
+ } else if (result.canConvert(QVariant::String)) {
+ item->setText(result.toString());
+ } else {
+ item->setText(QLatin1String("Unknown Value"));
+ }
+
+ return item;
+}
+
+QmlConsoleItemModel *QmlConsoleModel::qmlConsoleItemModel()
+{
+ QmlConsoleManager *manager = QmlConsoleManager::instance();
+ if (manager)
+ return manager->d->qmlConsoleItemModel;
+ return 0;
+}
+
+void QmlConsoleModel::evaluate(const QString &expression)
+{
+ QmlConsoleManager *manager = QmlConsoleManager::instance();
+ if (manager) {
+ if (manager->d->debuggerEngine) {
+ QmlConsoleModel::qmlConsoleItemModel()->appendEditableRow();
+ manager->d->debuggerEngine->evaluateScriptExpression(expression);
+ } else {
+ QVariant result = manager->d->scriptEngine->evaluate(expression).toVariant();
+ QmlConsoleItem *root = manager->rootItem();
+ QmlConsoleItem *item = constructLogItemTree(root, result);
+ if (item) {
+ QmlConsoleModel::qmlConsoleItemModel()->appendEditableRow();
+ manager->printToConsolePane(item);
+ }
+ }
+ }
+}
+
+} // Internal
+} // QmlJSTools
diff --git a/src/plugins/qmljstools/qmlconsolemanager.h b/src/plugins/qmljstools/qmlconsolemanager.h
new file mode 100644
index 0000000000..aa8cc30ec6
--- /dev/null
+++ b/src/plugins/qmljstools/qmlconsolemanager.h
@@ -0,0 +1,59 @@
+#ifndef QMLCONSOLEMANAGER_H
+#define QMLCONSOLEMANAGER_H
+
+#include "qmljstools_global.h"
+#include "qmlconsoleitem.h"
+
+#include <QObject>
+
+namespace Debugger {
+class DebuggerEngine;
+}
+namespace QmlJSTools {
+
+namespace Internal {
+class QmlConsoleItemModel;
+class QmlConsoleModel;
+}
+
+class QmlConsoleManagerPrivate;
+class QMLJSTOOLS_EXPORT QmlConsoleManager : public QObject
+{
+ Q_OBJECT
+public:
+ QmlConsoleManager(QObject *parent);
+ ~QmlConsoleManager();
+
+ static QmlConsoleManager *instance() { return m_instance; }
+
+ void showConsolePane();
+
+ QmlConsoleItem *rootItem() const;
+
+ void setDebuggerEngine(Debugger::DebuggerEngine *debuggerEngine);
+ void setContext(const QString &context);
+
+ void printToConsolePane(QmlConsoleItem::ItemType itemType, const QString &text,
+ bool bringToForeground = false);
+ void printToConsolePane(QmlConsoleItem *item, bool bringToForeground = false);
+
+private:
+ QmlConsoleManagerPrivate *d;
+ static QmlConsoleManager *m_instance;
+ friend class Internal::QmlConsoleModel;
+};
+
+namespace Internal {
+
+class QmlConsoleModel
+{
+public:
+ static QmlConsoleItemModel *qmlConsoleItemModel();
+ static void evaluate(const QString &expression);
+};
+
+}
+
+} // namespace QmlJSTools
+
+#endif // QMLCONSOLEMANAGER_H
diff --git a/src/plugins/qmljstools/qmlconsolepane.cpp b/src/plugins/qmljstools/qmlconsolepane.cpp
new file mode 100644
index 0000000000..135b48981e
--- /dev/null
+++ b/src/plugins/qmljstools/qmlconsolepane.cpp
@@ -0,0 +1,215 @@
+#include "qmlconsolepane.h"
+#include "qmlconsoleview.h"
+#include "qmlconsoleproxymodel.h"
+#include "qmlconsoleitemmodel.h"
+#include "qmlconsolemanager.h"
+#include "qmlconsoleitemdelegate.h"
+
+#include <coreplugin/icore.h>
+#include <coreplugin/icontext.h>
+#include <coreplugin/findplaceholder.h>
+#include <utils/savedaction.h>
+#include <aggregation/aggregate.h>
+#include <find/treeviewfind.h>
+
+#include <QToolButton>
+#include <QLabel>
+#include <QVBoxLayout>
+
+static const char CONSOLE[] = "Console";
+static const char SHOW_LOG[] = "showLog";
+static const char SHOW_WARNING[] = "showWarning";
+static const char SHOW_ERROR[] = "showError";
+
+namespace QmlJSTools {
+namespace Internal {
+
+/////////////////////////////////////////////////////////////////////
+//
+// QmlConsolePane
+//
+/////////////////////////////////////////////////////////////////////
+
+QmlConsolePane::QmlConsolePane(QObject *parent)
+ : Core::IOutputPane(parent)
+{
+ m_consoleWidget = new QWidget;
+ m_consoleWidget->setWindowTitle(displayName());
+ m_consoleWidget->setEnabled(true);
+
+ QVBoxLayout *vbox = new QVBoxLayout(m_consoleWidget);
+ vbox->setMargin(0);
+ vbox->setSpacing(0);
+
+ m_consoleView = new QmlConsoleView(m_consoleWidget);
+ m_proxyModel = new QmlConsoleProxyModel(this);
+ m_proxyModel->setSourceModel(QmlConsoleModel::qmlConsoleItemModel());
+ connect(QmlConsoleModel::qmlConsoleItemModel(),
+ SIGNAL(selectEditableRow(QModelIndex, QItemSelectionModel::SelectionFlags)),
+ m_proxyModel,
+ SLOT(selectEditableRow(QModelIndex,QItemSelectionModel::SelectionFlags)));
+
+ //Scroll to bottom when rows matching current filter settings are inserted
+ //Not connecting rowsRemoved as the only way to remove rows is to clear the
+ //model which will automatically reset the view.
+ connect(QmlConsoleModel::qmlConsoleItemModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
+ m_proxyModel, SLOT(onRowsInserted(QModelIndex,int,int)));
+ m_consoleView->setModel(m_proxyModel);
+
+ connect(m_proxyModel,
+ SIGNAL(setCurrentIndex(QModelIndex,QItemSelectionModel::SelectionFlags)),
+ m_consoleView->selectionModel(),
+ SLOT(setCurrentIndex(QModelIndex,QItemSelectionModel::SelectionFlags)));
+ connect(m_proxyModel, SIGNAL(scrollToBottom()), m_consoleView, SLOT(onScrollToBottom()));
+
+ m_itemDelegate = new QmlConsoleItemDelegate(this);
+ connect(m_consoleView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
+ m_itemDelegate, SLOT(currentChanged(QModelIndex,QModelIndex)));
+ m_consoleView->setItemDelegate(m_itemDelegate);
+
+ Aggregation::Aggregate *aggregate = new Aggregation::Aggregate();
+ aggregate->add(m_consoleView);
+ aggregate->add(new Find::TreeViewFind(m_consoleView));
+
+ vbox->addWidget(m_consoleView);
+ vbox->addWidget(new Core::FindToolBarPlaceHolder(m_consoleWidget));
+
+ m_showDebugButton = new QToolButton(m_consoleWidget);
+ m_showDebugButton->setAutoRaise(true);
+
+ m_showDebugButtonAction = new Utils::SavedAction(this);
+ m_showDebugButtonAction->setDefaultValue(true);
+ m_showDebugButtonAction->setSettingsKey(QLatin1String(CONSOLE), QLatin1String(SHOW_LOG));
+ m_showDebugButtonAction->setToolTip(tr("Show debug, log, and info messages."));
+ m_showDebugButtonAction->setCheckable(true);
+ m_showDebugButtonAction->setIcon(QIcon(QLatin1String(":/qmljstools/images/log.png")));
+ connect(m_showDebugButtonAction, SIGNAL(toggled(bool)), m_proxyModel, SLOT(setShowLogs(bool)));
+ m_showDebugButton->setDefaultAction(m_showDebugButtonAction);
+
+ m_showWarningButton = new QToolButton(m_consoleWidget);
+ m_showWarningButton->setAutoRaise(true);
+
+ m_showWarningButtonAction = new Utils::SavedAction(this);
+ m_showWarningButtonAction->setDefaultValue(true);
+ m_showWarningButtonAction->setSettingsKey(QLatin1String(CONSOLE), QLatin1String(SHOW_WARNING));
+ m_showWarningButtonAction->setToolTip(tr("Show debug, log, and info messages."));
+ m_showWarningButtonAction->setCheckable(true);
+ m_showWarningButtonAction->setIcon(QIcon(QLatin1String(":/qmljstools/images/warning.png")));
+ connect(m_showWarningButtonAction, SIGNAL(toggled(bool)), m_proxyModel,
+ SLOT(setShowWarnings(bool)));
+ m_showWarningButton->setDefaultAction(m_showWarningButtonAction);
+
+ m_showErrorButton = new QToolButton(m_consoleWidget);
+ m_showErrorButton->setAutoRaise(true);
+
+ m_showErrorButtonAction = new Utils::SavedAction(this);
+ m_showErrorButtonAction->setDefaultValue(true);
+ m_showErrorButtonAction->setSettingsKey(QLatin1String(CONSOLE), QLatin1String(SHOW_ERROR));
+ m_showErrorButtonAction->setToolTip(tr("Show debug, log, and info messages."));
+ m_showErrorButtonAction->setCheckable(true);
+ m_showErrorButtonAction->setIcon(QIcon(QLatin1String(":/qmljstools/images/error.png")));
+ connect(m_showErrorButtonAction, SIGNAL(toggled(bool)), m_proxyModel,
+ SLOT(setShowErrors(bool)));
+ m_showErrorButton->setDefaultAction(m_showErrorButtonAction);
+
+ m_spacer = new QWidget(m_consoleWidget);
+ m_spacer->setMinimumWidth(30);
+
+ m_statusLabel = new QLabel(m_consoleWidget);
+
+ readSettings();
+ connect(Core::ICore::instance(), SIGNAL(saveSettingsRequested()), SLOT(writeSettings()));
+}
+
+QmlConsolePane::~QmlConsolePane()
+{
+ writeSettings();
+ delete m_consoleWidget;
+}
+
+QWidget *QmlConsolePane::outputWidget(QWidget *)
+{
+ return m_consoleWidget;
+}
+
+QList<QWidget *> QmlConsolePane::toolBarWidgets() const
+{
+ return QList<QWidget *>() << m_showDebugButton << m_showWarningButton << m_showErrorButton
+ << m_spacer << m_statusLabel;
+}
+
+int QmlConsolePane::priorityInStatusBar() const
+{
+ return 20;
+}
+
+void QmlConsolePane::clearContents()
+{
+ QmlConsoleModel::qmlConsoleItemModel()->clear();
+}
+
+void QmlConsolePane::visibilityChanged(bool /*visible*/)
+{
+}
+
+bool QmlConsolePane::canFocus() const
+{
+ return true;
+}
+
+bool QmlConsolePane::hasFocus() const
+{
+ return m_consoleWidget->hasFocus();
+}
+
+void QmlConsolePane::setFocus()
+{
+ m_consoleWidget->setFocus();
+}
+
+bool QmlConsolePane::canNext() const
+{
+ return false;
+}
+
+bool QmlConsolePane::canPrevious() const
+{
+ return false;
+}
+
+void QmlConsolePane::goToNext()
+{
+}
+
+void QmlConsolePane::goToPrev()
+{
+}
+
+bool QmlConsolePane::canNavigate() const
+{
+ return false;
+}
+
+void QmlConsolePane::readSettings()
+{
+ QSettings *settings = Core::ICore::settings();
+ m_showDebugButtonAction->readSettings(settings);
+ m_showWarningButtonAction->readSettings(settings);
+ m_showErrorButtonAction->readSettings(settings);
+}
+
+void QmlConsolePane::setContext(const QString &context)
+{
+ m_statusLabel->setText(context);
+}
+
+void QmlConsolePane::writeSettings() const
+{
+ QSettings *settings = Core::ICore::settings();
+ m_showDebugButtonAction->writeSettings(settings);
+ m_showWarningButtonAction->writeSettings(settings);
+ m_showErrorButtonAction->writeSettings(settings);
+}
+
+} // Internal
+} // QmlJSTools
diff --git a/src/plugins/qmljstools/qmlconsolepane.h b/src/plugins/qmljstools/qmlconsolepane.h
new file mode 100644
index 0000000000..348a9f8cfa
--- /dev/null
+++ b/src/plugins/qmljstools/qmlconsolepane.h
@@ -0,0 +1,71 @@
+#ifndef QMLCONSOLEPANE_H
+#define QMLCONSOLEPANE_H
+
+#include <coreplugin/ioutputpane.h>
+
+QT_BEGIN_NAMESPACE
+class QToolButton;
+class QLabel;
+QT_END_NAMESPACE
+
+namespace Utils {
+class SavedAction;
+}
+
+namespace QmlJSTools {
+
+namespace Internal {
+
+class QmlConsoleView;
+class QmlConsoleItemDelegate;
+class QmlConsoleProxyModel;
+class QmlConsoleItemModel;
+
+class QmlConsolePane : public Core::IOutputPane
+{
+ Q_OBJECT
+public:
+ QmlConsolePane(QObject *parent);
+ ~QmlConsolePane();
+
+ QWidget *outputWidget(QWidget *);
+ QList<QWidget *> toolBarWidgets() const;
+ QString displayName() const { return tr("Console"); }
+ int priorityInStatusBar() const;
+ void clearContents();
+ void visibilityChanged(bool visible);
+ bool canFocus() const;
+ bool hasFocus() const;
+ void setFocus();
+
+ bool canNext() const;
+ bool canPrevious() const;
+ void goToNext();
+ void goToPrev();
+ bool canNavigate() const;
+
+ void readSettings();
+ void setContext(const QString &context);
+
+public slots:
+ void writeSettings() const;
+
+private:
+ QToolButton *m_showDebugButton;
+ QToolButton *m_showWarningButton;
+ QToolButton *m_showErrorButton;
+ Utils::SavedAction *m_showDebugButtonAction;
+ Utils::SavedAction *m_showWarningButtonAction;
+ Utils::SavedAction *m_showErrorButtonAction;
+ QWidget *m_spacer;
+ QLabel *m_statusLabel;
+ QmlConsoleView *m_consoleView;
+ QmlConsoleItemDelegate *m_itemDelegate;
+ QmlConsoleProxyModel *m_proxyModel;
+ QWidget *m_consoleWidget;
+};
+
+} // namespace Internal
+} // namespace QmlJSTools
+
+#endif // QMLCONSOLEPANE_H
diff --git a/src/plugins/qmljstools/qmlconsoleproxymodel.cpp b/src/plugins/qmljstools/qmlconsoleproxymodel.cpp
new file mode 100644
index 0000000000..6c4be63fdb
--- /dev/null
+++ b/src/plugins/qmljstools/qmlconsoleproxymodel.cpp
@@ -0,0 +1,58 @@
+#include "qmlconsoleproxymodel.h"
+#include "qmlconsoleitemmodel.h"
+
+namespace QmlJSTools {
+namespace Internal {
+
+QmlConsoleProxyModel::QmlConsoleProxyModel(QObject *parent) :
+ QSortFilterProxyModel(parent),
+ m_filter(QmlConsoleItem::DefaultTypes)
+{
+}
+
+void QmlConsoleProxyModel::setShowLogs(bool show)
+{
+ m_filter = show ? m_filter | QmlConsoleItem::DebugType : m_filter & ~QmlConsoleItem::DebugType;
+ setFilterRegExp(QString());
+}
+
+void QmlConsoleProxyModel::setShowWarnings(bool show)
+{
+ m_filter = show ? m_filter | QmlConsoleItem::WarningType
+ : m_filter & ~QmlConsoleItem::WarningType;
+ setFilterRegExp(QString());
+}
+
+void QmlConsoleProxyModel::setShowErrors(bool show)
+{
+ m_filter = show ? m_filter | QmlConsoleItem::ErrorType : m_filter & ~QmlConsoleItem::ErrorType;
+ setFilterRegExp(QString());
+}
+
+void QmlConsoleProxyModel::selectEditableRow(const QModelIndex &index,
+ QItemSelectionModel::SelectionFlags command)
+{
+ emit setCurrentIndex(mapFromSource(index), command);
+}
+
+bool QmlConsoleProxyModel::filterAcceptsRow(int sourceRow,
+ const QModelIndex &sourceParent) const
+ {
+ QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
+ return m_filter.testFlag((QmlConsoleItem::ItemType)sourceModel()->data(
+ index, QmlConsoleItemModel::TypeRole).toInt());
+ }
+
+void QmlConsoleProxyModel::onRowsInserted(const QModelIndex &index, int start, int end)
+{
+ int rowIndex = end;
+ do {
+ if (filterAcceptsRow(rowIndex, index)) {
+ emit scrollToBottom();
+ break;
+ }
+ } while (--rowIndex >= start);
+}
+
+} // Internal
+} // QmlJSTools
diff --git a/src/plugins/qmljstools/qmlconsoleproxymodel.h b/src/plugins/qmljstools/qmlconsoleproxymodel.h
new file mode 100644
index 0000000000..bfc5a21441
--- /dev/null
+++ b/src/plugins/qmljstools/qmlconsoleproxymodel.h
@@ -0,0 +1,41 @@
+#ifndef QMLCONSOLEPROXYMODEL_H
+#define QMLCONSOLEPROXYMODEL_H
+
+#include "qmlconsoleitem.h"
+
+#include <QSortFilterProxyModel>
+#include <QItemSelectionModel>
+
+namespace QmlJSTools {
+namespace Internal {
+
+class QmlConsoleProxyModel : public QSortFilterProxyModel
+{
+ Q_OBJECT
+public:
+ explicit QmlConsoleProxyModel(QObject *parent);
+
+public slots:
+ void setShowLogs(bool show);
+ void setShowWarnings(bool show);
+ void setShowErrors(bool show);
+ void selectEditableRow(const QModelIndex &index,
+ QItemSelectionModel::SelectionFlags command);
+ void onRowsInserted(const QModelIndex &index, int start, int end);
+
+signals:
+ void scrollToBottom();
+ void setCurrentIndex(const QModelIndex &index,
+ QItemSelectionModel::SelectionFlags command);
+
+protected:
+ bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
+
+private:
+ QFlags<QmlConsoleItem::ItemType> m_filter;
+};
+
+} // Internal
+} // QmlJSTools
+
+#endif // QMLCONSOLEPROXYMODEL_H
diff --git a/src/plugins/debugger/qtmessagelogview.cpp b/src/plugins/qmljstools/qmlconsoleview.cpp
index f3b12b8e0d..3599cabdb7 100644
--- a/src/plugins/debugger/qtmessagelogview.cpp
+++ b/src/plugins/qmljstools/qmlconsoleview.cpp
@@ -1,39 +1,6 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: http://www.qt-project.org/
-**
-**
-** GNU Lesser General Public License Usage
-**
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this file.
-** Please review the following information to ensure the GNU Lesser General
-** Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** Other Usage
-**
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**************************************************************************/
-
-#include "qtmessagelogview.h"
-#include "qtmessagelogitemdelegate.h"
-#include "qtmessageloghandler.h"
-#include "debuggerstringutils.h"
-#include "debuggercore.h"
-#include "debuggerengine.h"
+#include "qmlconsoleview.h"
+#include "qmlconsoleitemdelegate.h"
+#include "qmlconsoleitemmodel.h"
#include <texteditor/basetexteditor.h>
@@ -47,24 +14,20 @@
#include <QUrl>
#include <QScrollBar>
-namespace Debugger {
+namespace QmlJSTools {
namespace Internal {
-class QtMessageLogViewViewStyle : public QProxyStyle
+class QmlConsoleViewStyle : public QProxyStyle
{
public:
- void drawPrimitive(PrimitiveElement element,
- const QStyleOption *option,
- QPainter *painter,
+ void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter,
const QWidget *widget = 0) const
{
if (element != QStyle::PE_PanelItemViewRow)
QProxyStyle::drawPrimitive(element, option, painter, widget);
}
- int styleHint(StyleHint hint,
- const QStyleOption *option = 0,
- const QWidget *widget = 0,
+ int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0,
QStyleHintReturn *returnData = 0) const {
if (hint == SH_ItemView_ShowDecorationSelected)
return 0;
@@ -75,11 +38,11 @@ public:
///////////////////////////////////////////////////////////////////////
//
-// QtMessageLogView
+// QmlConsoleView
//
///////////////////////////////////////////////////////////////////////
-QtMessageLogView::QtMessageLogView(QWidget *parent) :
+QmlConsoleView::QmlConsoleView(QWidget *parent) :
QTreeView(parent)
{
setFrameStyle(QFrame::NoFrame);
@@ -103,36 +66,35 @@ QtMessageLogView::QtMessageLogView(QWidget *parent) :
"QTreeView::branch:open:has-children:has-siblings {"
"border-image: none;"
"image: none; }"));
- QtMessageLogViewViewStyle *style = new QtMessageLogViewViewStyle;
+ QmlConsoleViewStyle *style = new QmlConsoleViewStyle;
setStyle(style);
style->setParent(this);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
- connect(this, SIGNAL(activated(QModelIndex)),
- SLOT(onRowActivated(QModelIndex)));
+ connect(this, SIGNAL(activated(QModelIndex)), SLOT(onRowActivated(QModelIndex)));
}
-void QtMessageLogView::onScrollToBottom()
+void QmlConsoleView::onScrollToBottom()
{
- //Keep scrolling to bottom if scroll bar is at maximum()
+ // Keep scrolling to bottom if scroll bar is at maximum()
if (verticalScrollBar()->value() == verticalScrollBar()->maximum())
scrollToBottom();
}
-void QtMessageLogView::mousePressEvent(QMouseEvent *event)
+void QmlConsoleView::mousePressEvent(QMouseEvent *event)
{
QPoint pos = event->pos();
QModelIndex index = indexAt(pos);
if (index.isValid()) {
- QtMessageLogHandler::ItemType type = (QtMessageLogHandler::ItemType)index.data(
- QtMessageLogHandler::TypeRole).toInt();
+ QmlConsoleItem::ItemType type = (QmlConsoleItem::ItemType)index.data(
+ QmlConsoleItemModel::TypeRole).toInt();
bool handled = false;
- if (type == QtMessageLogHandler::UndefinedType) {
+ if (type == QmlConsoleItem::UndefinedType) {
bool showTypeIcon = index.parent() == QModelIndex();
- ConsoleItemPositions positions(visualRect(index), viewOptions().font,
- showTypeIcon, true);
+ ConsoleItemPositions positions(visualRect(index), viewOptions().font, showTypeIcon,
+ true);
if (positions.expandCollapseIcon().contains(pos)) {
if (isExpanded(index))
@@ -145,13 +107,12 @@ void QtMessageLogView::mousePressEvent(QMouseEvent *event)
if (!handled)
QTreeView::mousePressEvent(event);
} else {
- selectionModel()->setCurrentIndex(model()->index(
- model()->rowCount() - 1, 0),
- QItemSelectionModel::ClearAndSelect);
+ selectionModel()->setCurrentIndex(model()->index(model()->rowCount() - 1, 0),
+ QItemSelectionModel::ClearAndSelect);
}
}
-void QtMessageLogView::keyPressEvent(QKeyEvent *e)
+void QmlConsoleView::keyPressEvent(QKeyEvent *e)
{
if (!e->modifiers() && e->key() == Qt::Key_Return) {
emit activated(currentIndex());
@@ -161,22 +122,22 @@ void QtMessageLogView::keyPressEvent(QKeyEvent *e)
QTreeView::keyPressEvent(e);
}
-void QtMessageLogView::resizeEvent(QResizeEvent *e)
+void QmlConsoleView::resizeEvent(QResizeEvent *e)
{
- static_cast<QtMessageLogItemDelegate *>(itemDelegate())->emitSizeHintChanged(
+ static_cast<QmlConsoleItemDelegate *>(itemDelegate())->emitSizeHintChanged(
selectionModel()->currentIndex());
QTreeView::resizeEvent(e);
}
-void QtMessageLogView::drawBranches(QPainter *painter, const QRect &rect,
- const QModelIndex &index) const
+void QmlConsoleView::drawBranches(QPainter *painter, const QRect &rect,
+ const QModelIndex &index) const
{
- static_cast<QtMessageLogItemDelegate *>(itemDelegate())->drawBackground(
- painter, rect, index, false);
+ static_cast<QmlConsoleItemDelegate *>(itemDelegate())->drawBackground(painter, rect, index,
+ false);
QTreeView::drawBranches(painter, rect, index);
}
-void QtMessageLogView::contextMenuEvent(QContextMenuEvent *event)
+void QmlConsoleView::contextMenuEvent(QContextMenuEvent *event)
{
QModelIndex itemIndex = indexAt(event->pos());
QMenu menu;
@@ -195,69 +156,59 @@ void QtMessageLogView::contextMenuEvent(QContextMenuEvent *event)
if (a == 0)
return;
- if (a == copy)
+ if (a == copy) {
copyToClipboard(itemIndex);
- else if (a == show)
+ } else if (a == show) {
onRowActivated(itemIndex);
- else if (a == clear) {
- QAbstractProxyModel *proxyModel =
- qobject_cast<QAbstractProxyModel *>(model());
- QtMessageLogHandler *handler =
- qobject_cast<QtMessageLogHandler *>(proxyModel->sourceModel());
+ } else if (a == clear) {
+ QAbstractProxyModel *proxyModel = qobject_cast<QAbstractProxyModel *>(model());
+ QmlConsoleItemModel *handler = qobject_cast<QmlConsoleItemModel *>(
+ proxyModel->sourceModel());
handler->clear();
}
}
-void QtMessageLogView::onRowActivated(const QModelIndex &index)
+void QmlConsoleView::onRowActivated(const QModelIndex &index)
{
if (!index.isValid())
return;
- //See if we have file and line Info
+ // See if we have file and line Info
QString filePath = model()->data(index,
- QtMessageLogHandler::FileRole).toString();
+ QmlConsoleItemModel::FileRole).toString();
if (!filePath.isEmpty()) {
- filePath = debuggerCore()->currentEngine()->toFileInProject(
- QUrl(filePath));
QFileInfo fi(filePath);
if (fi.exists() && fi.isFile() && fi.isReadable()) {
- int line = model()->data(index,
- QtMessageLogHandler::LineRole).toInt();
- TextEditor::BaseTextEditorWidget::openEditorAt(
- fi.canonicalFilePath(), line);
+ int line = model()->data(index, QmlConsoleItemModel::LineRole).toInt();
+ TextEditor::BaseTextEditorWidget::openEditorAt(fi.canonicalFilePath(), line);
}
}
}
-void QtMessageLogView::copyToClipboard(const QModelIndex &index)
+void QmlConsoleView::copyToClipboard(const QModelIndex &index)
{
if (!index.isValid())
return;
QString contents = model()->data(index).toString();
- //See if we have file and line Info
- QString filePath = model()->data(index,
- QtMessageLogHandler::FileRole).toString();
+ // See if we have file and line Info
+ QString filePath = model()->data(index, QmlConsoleItemModel::FileRole).toString();
if (!filePath.isEmpty()) {
- contents = QString(_("%1 %2: %3")).arg(contents).arg(filePath).arg(
- model()->data(index,
- QtMessageLogHandler::LineRole).toString());
+ contents = QString(QLatin1String("%1 %2: %3")).arg(contents).arg(filePath).arg(
+ model()->data(index, QmlConsoleItemModel::LineRole).toString());
}
QClipboard *cb = QApplication::clipboard();
cb->setText(contents);
}
-bool QtMessageLogView::canShowItemInTextEditor(const QModelIndex &index)
+bool QmlConsoleView::canShowItemInTextEditor(const QModelIndex &index)
{
if (!index.isValid())
return false;
- //See if we have file and line Info
- QString filePath = model()->data(index,
- QtMessageLogHandler::FileRole).toString();
+ // See if we have file and line Info
+ QString filePath = model()->data(index, QmlConsoleItemModel::FileRole).toString();
if (!filePath.isEmpty()) {
- filePath = debuggerCore()->currentEngine()->toFileInProject(
- QUrl(filePath));
QFileInfo fi(filePath);
if (fi.exists() && fi.isFile() && fi.isReadable()) {
return true;
@@ -266,5 +217,5 @@ bool QtMessageLogView::canShowItemInTextEditor(const QModelIndex &index)
return false;
}
-} //Internal
-} //Debugger
+} // Internal
+} // QmlJSTools
diff --git a/src/plugins/qmljstools/qmlconsoleview.h b/src/plugins/qmljstools/qmlconsoleview.h
new file mode 100644
index 0000000000..844e2a8570
--- /dev/null
+++ b/src/plugins/qmljstools/qmlconsoleview.h
@@ -0,0 +1,37 @@
+#ifndef QMLCONSOLEVIEW_H
+#define QMLCONSOLEVIEW_H
+
+#include <QTreeView>
+
+namespace QmlJSTools {
+namespace Internal {
+
+class QmlConsoleView : public QTreeView
+{
+ Q_OBJECT
+public:
+ QmlConsoleView(QWidget *parent);
+
+public slots:
+ void onScrollToBottom();
+
+protected:
+ void mousePressEvent(QMouseEvent *event);
+ void keyPressEvent(QKeyEvent *e);
+ void resizeEvent(QResizeEvent *e);
+ void drawBranches(QPainter *painter, const QRect &rect,
+ const QModelIndex &index) const;
+ void contextMenuEvent(QContextMenuEvent *event);
+
+private slots:
+ void onRowActivated(const QModelIndex &index);
+
+private:
+ void copyToClipboard(const QModelIndex &index);
+ bool canShowItemInTextEditor(const QModelIndex &index);
+};
+
+} // Internal
+} // QmlJSTools
+
+#endif // QMLCONSOLEVIEW_H
diff --git a/src/plugins/qmljstools/qmljsinterpreter.cpp b/src/plugins/qmljstools/qmljsinterpreter.cpp
new file mode 100644
index 0000000000..c6fddc4373
--- /dev/null
+++ b/src/plugins/qmljstools/qmljsinterpreter.cpp
@@ -0,0 +1,58 @@
+#include "qmljsinterpreter.h"
+
+namespace QmlJSTools {
+namespace Internal {
+
+bool QmlJSInterpreter::canEvaluate()
+{
+ int yyaction = 0;
+ int yytoken = -1;
+ int yytos = -1;
+
+ setCode(m_code, 1);
+ m_tokens.append(T_FEED_JS_PROGRAM);
+
+ do {
+ if (++yytos == m_stateStack.size())
+ m_stateStack.resize(m_stateStack.size() * 2);
+
+ m_stateStack[yytos] = yyaction;
+
+again:
+ if (yytoken == -1 && action_index[yyaction] != -TERMINAL_COUNT) {
+ if (m_tokens.isEmpty())
+ yytoken = lex();
+ else
+ yytoken = m_tokens.takeFirst();
+ }
+
+ yyaction = t_action(yyaction, yytoken);
+ if (yyaction > 0) {
+ if (yyaction == ACCEPT_STATE) {
+ --yytos;
+ return true;
+ }
+ yytoken = -1;
+ } else if (yyaction < 0) {
+ const int ruleno = -yyaction - 1;
+ yytos -= rhs[ruleno];
+ yyaction = nt_action(m_stateStack[yytos], lhs[ruleno] - TERMINAL_COUNT);
+ }
+ } while (yyaction);
+
+ const int errorState = m_stateStack[yytos];
+ if (t_action(errorState, T_AUTOMATIC_SEMICOLON) && canInsertAutomaticSemicolon(yytoken)) {
+ yyaction = errorState;
+ m_tokens.prepend(yytoken);
+ yytoken = T_SEMICOLON;
+ goto again;
+ }
+
+ if (yytoken != EOF_SYMBOL)
+ return true;
+
+ return false;
+}
+
+} // namespace Internal
+} // namespace QmlJSTools
diff --git a/src/plugins/qmljstools/qmljsinterpreter.h b/src/plugins/qmljstools/qmljsinterpreter.h
new file mode 100644
index 0000000000..ca8c920c84
--- /dev/null
+++ b/src/plugins/qmljstools/qmljsinterpreter.h
@@ -0,0 +1,40 @@
+#ifndef QMLJSINTERPRETER_H
+#define QMLJSINTERPRETER_H
+
+#include <qmljs/parser/qmljslexer_p.h>
+#include <qmljs/parser/qmljsengine_p.h>
+
+#include <QVector>
+#include <QString>
+#include <QList>
+
+namespace QmlJSTools {
+namespace Internal {
+
+class QmlJSInterpreter: QmlJS::Lexer
+{
+public:
+ QmlJSInterpreter()
+ : Lexer(&m_engine),
+ m_stateStack(128)
+ {
+
+ }
+
+ void clearText() { m_code.clear(); }
+ void appendText(const QString &text) { m_code += text; }
+
+ QString code() const { return m_code; }
+ bool canEvaluate();
+
+private:
+ QmlJS::Engine m_engine;
+ QVector<int> m_stateStack;
+ QList<int> m_tokens;
+ QString m_code;
+};
+
+} // namespace Internal
+} // namespace QmlJSTools
+
+#endif // QMLJSINTERPRETER_H
diff --git a/src/plugins/qmljstools/qmljstools-lib.pri b/src/plugins/qmljstools/qmljstools-lib.pri
deleted file mode 100644
index e618816549..0000000000
--- a/src/plugins/qmljstools/qmljstools-lib.pri
+++ /dev/null
@@ -1,45 +0,0 @@
-!dll {
- DEFINES += QMLJSTOOLS_STATIC
-}
-
-INCLUDEPATH += $$PWD/..
-
-HEADERS += \
- $$PWD/qmljstools_global.h \
- $$PWD/qmljstoolsplugin.h \
- $$PWD/qmljstoolsconstants.h \
- $$PWD/qmljstoolssettings.h \
- $$PWD/qmljscodestylepreferencesfactory.h \
- $$PWD/qmljsmodelmanager.h \
- $$PWD/qmljsqtstylecodeformatter.h \
- $$PWD/qmljsrefactoringchanges.h \
- $$PWD/qmljsplugindumper.h \
- $$PWD/qmljsfunctionfilter.h \
- $$PWD/qmljslocatordata.h \
- $$PWD/qmljsindenter.h \
- $$PWD/qmljscodestylesettingspage.h \
- $$PWD/qmljsfindexportedcpptypes.h \
- $$PWD/qmljssemanticinfo.h
-
-SOURCES += \
- $$PWD/qmljstoolsplugin.cpp \
- $$PWD/qmljstoolssettings.cpp \
- $$PWD/qmljscodestylepreferencesfactory.cpp \
- $$PWD/qmljsmodelmanager.cpp \
- $$PWD/qmljsqtstylecodeformatter.cpp \
- $$PWD/qmljsrefactoringchanges.cpp \
- $$PWD/qmljsplugindumper.cpp \
- $$PWD/qmljsfunctionfilter.cpp \
- $$PWD/qmljslocatordata.cpp \
- $$PWD/qmljsindenter.cpp \
- $$PWD/qmljscodestylesettingspage.cpp \
- $$PWD/qmljsfindexportedcpptypes.cpp \
- $$PWD/qmljssemanticinfo.cpp
-
-FORMS += \
- $$PWD/qmljscodestylesettingspage.ui
-
-equals(TEST, 1) {
- SOURCES += \
- $$PWD/qmljstools_test.cpp
-}
diff --git a/src/plugins/qmljstools/qmljstools.pri b/src/plugins/qmljstools/qmljstools.pri
index 75415d0c1f..1d36f5e406 100644
--- a/src/plugins/qmljstools/qmljstools.pri
+++ b/src/plugins/qmljstools/qmljstools.pri
@@ -1,5 +1,3 @@
include(qmljstools_dependencies.pri)
-INCLUDEPATH *= $$PWD/..
-
LIBS *= -l$$qtLibraryName(QmlJSTools)
diff --git a/src/plugins/qmljstools/qmljstools.pro b/src/plugins/qmljstools/qmljstools.pro
index 86426bb3b7..9313110d88 100644
--- a/src/plugins/qmljstools/qmljstools.pro
+++ b/src/plugins/qmljstools/qmljstools.pro
@@ -7,4 +7,69 @@ include(qmljstools_dependencies.pri)
DEFINES += QT_NO_CAST_TO_ASCII
DEFINES += QMLJSTOOLS_LIBRARY
-include(qmljstools-lib.pri)
+!dll {
+ DEFINES += QMLJSTOOLS_STATIC
+}
+
+QT += script
+
+HEADERS += \
+ $$PWD/qmljstoolsplugin.h \
+ $$PWD/qmljstoolsconstants.h \
+ $$PWD/qmljstoolssettings.h \
+ $$PWD/qmljscodestylepreferencesfactory.h \
+ $$PWD/qmljsmodelmanager.h \
+ $$PWD/qmljsqtstylecodeformatter.h \
+ $$PWD/qmljsrefactoringchanges.h \
+ $$PWD/qmljsplugindumper.h \
+ $$PWD/qmljsfunctionfilter.h \
+ $$PWD/qmljslocatordata.h \
+ $$PWD/qmljsindenter.h \
+ $$PWD/qmljscodestylesettingspage.h \
+ $$PWD/qmljsfindexportedcpptypes.h \
+ $$PWD/qmljssemanticinfo.h \
+ $$PWD/qmljstools_global.h \
+ $$PWD/qmlconsolemanager.h \
+ $$PWD/qmlconsoleitem.h \
+ $$PWD/qmlconsoleitemmodel.h \
+ $$PWD/qmlconsolepane.h \
+ $$PWD/qmlconsoleview.h \
+ $$PWD/qmlconsoleitemdelegate.h \
+ $$PWD/qmlconsoleedit.h \
+ $$PWD/qmljsinterpreter.h \
+ $$PWD/qmlconsoleproxymodel.h
+
+SOURCES += \
+ $$PWD/qmljstoolsplugin.cpp \
+ $$PWD/qmljstoolssettings.cpp \
+ $$PWD/qmljscodestylepreferencesfactory.cpp \
+ $$PWD/qmljsmodelmanager.cpp \
+ $$PWD/qmljsqtstylecodeformatter.cpp \
+ $$PWD/qmljsrefactoringchanges.cpp \
+ $$PWD/qmljsplugindumper.cpp \
+ $$PWD/qmljsfunctionfilter.cpp \
+ $$PWD/qmljslocatordata.cpp \
+ $$PWD/qmljsindenter.cpp \
+ $$PWD/qmljscodestylesettingspage.cpp \
+ $$PWD/qmljsfindexportedcpptypes.cpp \
+ $$PWD/qmljssemanticinfo.cpp \
+ $$PWD/qmlconsolemanager.cpp \
+ $$PWD/qmlconsoleitem.cpp \
+ $$PWD/qmlconsoleitemmodel.cpp \
+ $$PWD/qmlconsolepane.cpp \
+ $$PWD/qmlconsoleview.cpp \
+ $$PWD/qmlconsoleitemdelegate.cpp \
+ $$PWD/qmlconsoleedit.cpp \
+ $$PWD/qmljsinterpreter.cpp \
+ $$PWD/qmlconsoleproxymodel.cpp
+
+RESOURCES += \
+ qmljstools.qrc
+
+FORMS += \
+ $$PWD/qmljscodestylesettingspage.ui
+
+equals(TEST, 1) {
+ SOURCES += \
+ $$PWD/qmljstools_test.cpp
+}
diff --git a/src/plugins/qmljstools/qmljstools.qbs b/src/plugins/qmljstools/qmljstools.qbs
index 079f804d7e..e1567641d1 100644
--- a/src/plugins/qmljstools/qmljstools.qbs
+++ b/src/plugins/qmljstools/qmljstools.qbs
@@ -53,6 +53,25 @@ QtcPlugin {
"qmljstoolsplugin.h",
"qmljstoolssettings.cpp",
"qmljstoolssettings.h",
+ "qmlconsolemanager.cpp",
+ "qmlconsolemanager.h",
+ "qmlconsoleitem.cpp",
+ "qmlconsoleitem.h",
+ "qmlcomsoleitemmodel.cpp",
+ "qmlconsoleitemmodel.h",
+ "qmlconsolepane.cpp",
+ "qmlconsolepane.h",
+ "qmlconsoleview.cpp",
+ "qmlconsoleview.h",
+ "qmlconsoleitemdelegate.cpp",
+ "qmlconsoleitemdelegate.h",
+ "qmlconsoleedit.cpp",
+ "qmlconsoleedit.h",
+ "qmljsinterpreter.cpp",
+ "qmljsinterpreter.h",
+ "qmljsconsoleproxymodel.cpp",
+ "qmljsconsoleproxymodel.h",
+ "qmljstools.qrc"
]
Group {
diff --git a/src/plugins/qmljstools/qmljstools.qrc b/src/plugins/qmljstools/qmljstools.qrc
new file mode 100644
index 0000000000..9e396a3995
--- /dev/null
+++ b/src/plugins/qmljstools/qmljstools.qrc
@@ -0,0 +1,10 @@
+<RCC>
+ <qresource prefix="/qmljstools">
+ <file>images/prompt.png</file>
+ <file>images/collapse.png</file>
+ <file>images/warning.png</file>
+ <file>images/log.png</file>
+ <file>images/expand.png</file>
+ <file>images/error.png</file>
+ </qresource>
+</RCC>
diff --git a/src/plugins/qmljstools/qmljstoolsplugin.cpp b/src/plugins/qmljstools/qmljstoolsplugin.cpp
index f24a36db5e..8ef62aace6 100644
--- a/src/plugins/qmljstools/qmljstoolsplugin.cpp
+++ b/src/plugins/qmljstools/qmljstoolsplugin.cpp
@@ -35,6 +35,7 @@
#include "qmljscodestylesettingspage.h"
#include "qmljstoolsconstants.h"
#include "qmljstoolssettings.h"
+#include "qmlconsolemanager.h"
#include <extensionsystem/pluginmanager.h>
@@ -52,6 +53,7 @@
#include <QSettings>
#include <QMenu>
+using namespace QmlJSTools;
using namespace QmlJSTools::Internal;
enum { debug = 0 };
@@ -68,6 +70,7 @@ QmlJSToolsPlugin::~QmlJSToolsPlugin()
{
m_instance = 0;
m_modelManager = 0; // deleted automatically
+ m_consoleManager = 0; // deleted automatically
}
bool QmlJSToolsPlugin::initialize(const QStringList &arguments, QString *error)
@@ -79,6 +82,8 @@ bool QmlJSToolsPlugin::initialize(const QStringList &arguments, QString *error)
// Objects
m_modelManager = new ModelManager(this);
+ m_consoleManager = new QmlConsoleManager(this);
+
// Core::VCSManager *vcsManager = core->vcsManager();
// Core::DocumentManager *fileManager = core->fileManager();
// connect(vcsManager, SIGNAL(repositoryChanged(QString)),
diff --git a/src/plugins/qmljstools/qmljstoolsplugin.h b/src/plugins/qmljstools/qmljstoolsplugin.h
index 14144c37bb..f5b46c8cd1 100644
--- a/src/plugins/qmljstools/qmljstoolsplugin.h
+++ b/src/plugins/qmljstools/qmljstoolsplugin.h
@@ -46,6 +46,7 @@ QT_END_NAMESPACE
namespace QmlJSTools {
class QmlJSToolsSettings;
+class QmlConsoleManager;
namespace Internal {
@@ -77,6 +78,7 @@ private slots:
private:
ModelManager *m_modelManager;
+ QmlConsoleManager *m_consoleManager;
QmlJSToolsSettings *m_settings;
QAction *m_resetCodeModelAction;