forked from qt-creator/qt-creator
Debugger: Remove the dependence on QmlJSTools
Change-Id: I26765134c19b9a6cf1e7ad26f313e2d4f8faf258 Reviewed-by: Christiaan Janssen <christiaan.janssen@digia.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/**************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
||||||
** Contact: http://www.qt-project.org/legal
|
** Contact: http://www.qt-project.org/legal
|
||||||
@@ -27,17 +27,17 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "qmlconsoleitem.h"
|
#include "consoleitem.h"
|
||||||
|
|
||||||
namespace QmlJSTools {
|
namespace QmlJS {
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// QmlConsoleItem
|
// ConsoleItem
|
||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
QmlConsoleItem::QmlConsoleItem(QmlConsoleItem *parent, QmlConsoleItem::ItemType itemType,
|
ConsoleItem::ConsoleItem(ConsoleItem *parent, ConsoleItem::ItemType itemType,
|
||||||
const QString &text)
|
const QString &text)
|
||||||
: m_parentItem(parent),
|
: m_parentItem(parent),
|
||||||
itemType(itemType),
|
itemType(itemType),
|
||||||
@@ -47,36 +47,36 @@ QmlConsoleItem::QmlConsoleItem(QmlConsoleItem *parent, QmlConsoleItem::ItemType
|
|||||||
setText(text);
|
setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlConsoleItem::~QmlConsoleItem()
|
ConsoleItem::~ConsoleItem()
|
||||||
{
|
{
|
||||||
qDeleteAll(m_childItems);
|
qDeleteAll(m_childItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlConsoleItem *QmlConsoleItem::child(int number)
|
ConsoleItem *ConsoleItem::child(int number)
|
||||||
{
|
{
|
||||||
return m_childItems.value(number);
|
return m_childItems.value(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
int QmlConsoleItem::childCount() const
|
int ConsoleItem::childCount() const
|
||||||
{
|
{
|
||||||
return m_childItems.size();
|
return m_childItems.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int QmlConsoleItem::childNumber() const
|
int ConsoleItem::childNumber() const
|
||||||
{
|
{
|
||||||
if (m_parentItem)
|
if (m_parentItem)
|
||||||
return m_parentItem->m_childItems.indexOf(const_cast<QmlConsoleItem *>(this));
|
return m_parentItem->m_childItems.indexOf(const_cast<ConsoleItem *>(this));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlConsoleItem::insertChildren(int position, int count)
|
bool ConsoleItem::insertChildren(int position, int count)
|
||||||
{
|
{
|
||||||
if (position < 0 || position > m_childItems.size())
|
if (position < 0 || position > m_childItems.size())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (int row = 0; row < count; ++row) {
|
for (int row = 0; row < count; ++row) {
|
||||||
QmlConsoleItem *item = new QmlConsoleItem(this, QmlConsoleItem::UndefinedType,
|
ConsoleItem *item = new ConsoleItem(this, ConsoleItem::UndefinedType,
|
||||||
QString());
|
QString());
|
||||||
m_childItems.insert(position, item);
|
m_childItems.insert(position, item);
|
||||||
}
|
}
|
||||||
@@ -84,7 +84,7 @@ bool QmlConsoleItem::insertChildren(int position, int count)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlConsoleItem::insertChild(QmlConsoleItem *item, bool sorted)
|
void ConsoleItem::insertChild(ConsoleItem *item, bool sorted)
|
||||||
{
|
{
|
||||||
if (!sorted) {
|
if (!sorted) {
|
||||||
m_childItems.insert(m_childItems.count(), item);
|
m_childItems.insert(m_childItems.count(), item);
|
||||||
@@ -99,7 +99,7 @@ void QmlConsoleItem::insertChild(QmlConsoleItem *item, bool sorted)
|
|||||||
m_childItems.insert(i, item);
|
m_childItems.insert(i, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlConsoleItem::insertChild(int position, QmlConsoleItem *item)
|
bool ConsoleItem::insertChild(int position, ConsoleItem *item)
|
||||||
{
|
{
|
||||||
if (position < 0 || position > m_childItems.size())
|
if (position < 0 || position > m_childItems.size())
|
||||||
return false;
|
return false;
|
||||||
@@ -109,12 +109,12 @@ bool QmlConsoleItem::insertChild(int position, QmlConsoleItem *item)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlConsoleItem *QmlConsoleItem::parent()
|
ConsoleItem *ConsoleItem::parent()
|
||||||
{
|
{
|
||||||
return m_parentItem;
|
return m_parentItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlConsoleItem::removeChildren(int position, int count)
|
bool ConsoleItem::removeChildren(int position, int count)
|
||||||
{
|
{
|
||||||
if (position < 0 || position + count > m_childItems.size())
|
if (position < 0 || position + count > m_childItems.size())
|
||||||
return false;
|
return false;
|
||||||
@@ -125,7 +125,7 @@ bool QmlConsoleItem::removeChildren(int position, int count)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlConsoleItem::detachChild(int position)
|
bool ConsoleItem::detachChild(int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position > m_childItems.size())
|
if (position < 0 || position > m_childItems.size())
|
||||||
return false;
|
return false;
|
||||||
@@ -135,7 +135,7 @@ bool QmlConsoleItem::detachChild(int position)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlConsoleItem::setText(const QString &text)
|
void ConsoleItem::setText(const QString &text)
|
||||||
{
|
{
|
||||||
m_text = text;
|
m_text = text;
|
||||||
for (int i = 0; i < m_text.length(); ++i) {
|
for (int i = 0; i < m_text.length(); ++i) {
|
||||||
@@ -144,9 +144,9 @@ void QmlConsoleItem::setText(const QString &text)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &QmlConsoleItem::text() const
|
const QString &ConsoleItem::text() const
|
||||||
{
|
{
|
||||||
return m_text;
|
return m_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // QmlJSTools
|
} // QmlJS
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/**************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
||||||
** Contact: http://www.qt-project.org/legal
|
** Contact: http://www.qt-project.org/legal
|
||||||
@@ -27,17 +27,17 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef QMLCONSOLEITEM_H
|
#ifndef CONSOLEITEM_H
|
||||||
#define QMLCONSOLEITEM_H
|
#define CONSOLEITEM_H
|
||||||
|
|
||||||
#include "qmljstools_global.h"
|
#include "qmljs_global.h"
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace QmlJSTools {
|
namespace QmlJS {
|
||||||
|
|
||||||
class QMLJSTOOLS_EXPORT QmlConsoleItem
|
class QMLJS_EXPORT ConsoleItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum ItemType
|
enum ItemType
|
||||||
@@ -51,17 +51,17 @@ public:
|
|||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(ItemTypes, ItemType)
|
Q_DECLARE_FLAGS(ItemTypes, ItemType)
|
||||||
|
|
||||||
QmlConsoleItem(QmlConsoleItem *parent,
|
ConsoleItem(ConsoleItem *parent,
|
||||||
QmlConsoleItem::ItemType type = QmlConsoleItem::UndefinedType,
|
ConsoleItem::ItemType type = ConsoleItem::UndefinedType,
|
||||||
const QString &data = QString());
|
const QString &data = QString());
|
||||||
~QmlConsoleItem();
|
~ConsoleItem();
|
||||||
|
|
||||||
QmlConsoleItem *child(int number);
|
ConsoleItem *child(int number);
|
||||||
int childCount() const;
|
int childCount() const;
|
||||||
bool insertChildren(int position, int count);
|
bool insertChildren(int position, int count);
|
||||||
void insertChild(QmlConsoleItem *item, bool sorted);
|
void insertChild(ConsoleItem *item, bool sorted);
|
||||||
bool insertChild(int position, QmlConsoleItem *item);
|
bool insertChild(int position, ConsoleItem *item);
|
||||||
QmlConsoleItem *parent();
|
ConsoleItem *parent();
|
||||||
bool removeChildren(int position, int count);
|
bool removeChildren(int position, int count);
|
||||||
bool detachChild(int position);
|
bool detachChild(int position);
|
||||||
int childNumber() const;
|
int childNumber() const;
|
||||||
@@ -69,16 +69,16 @@ public:
|
|||||||
const QString &text() const;
|
const QString &text() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QmlConsoleItem *m_parentItem;
|
ConsoleItem *m_parentItem;
|
||||||
QList<QmlConsoleItem *> m_childItems;
|
QList<ConsoleItem *> m_childItems;
|
||||||
QString m_text;
|
QString m_text;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QmlConsoleItem::ItemType itemType;
|
ConsoleItem::ItemType itemType;
|
||||||
QString file;
|
QString file;
|
||||||
int line;
|
int line;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // QmlJSTools
|
} // QmlJS
|
||||||
|
|
||||||
#endif // QMLCONSOLEITEM_H
|
#endif // CONSOLEITEM_H
|
||||||
54
src/libs/qmljs/consolemanagerinterface.cpp
Normal file
54
src/libs/qmljs/consolemanagerinterface.cpp
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://qt.digia.com/licensing. For further information
|
||||||
|
** use the contact form at http://qt.digia.com/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, 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, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "consolemanagerinterface.h"
|
||||||
|
|
||||||
|
namespace QmlJS {
|
||||||
|
|
||||||
|
static ConsoleManagerInterface *g_instance = 0;
|
||||||
|
|
||||||
|
ConsoleManagerInterface::ConsoleManagerInterface(QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
{
|
||||||
|
Q_ASSERT(!g_instance);
|
||||||
|
g_instance = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConsoleManagerInterface::~ConsoleManagerInterface()
|
||||||
|
{
|
||||||
|
Q_ASSERT(g_instance == this);
|
||||||
|
g_instance = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConsoleManagerInterface *ConsoleManagerInterface::instance()
|
||||||
|
{
|
||||||
|
return g_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // QmlJS
|
||||||
64
src/libs/qmljs/consolemanagerinterface.h
Normal file
64
src/libs/qmljs/consolemanagerinterface.h
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://qt.digia.com/licensing. For further information
|
||||||
|
** use the contact form at http://qt.digia.com/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, 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, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CONSOLEMANAGERINTERFACE_H
|
||||||
|
#define CONSOLEMANAGERINTERFACE_H
|
||||||
|
|
||||||
|
#include "qmljs_global.h"
|
||||||
|
#include "consoleitem.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
namespace QmlJS {
|
||||||
|
|
||||||
|
class IScriptEvaluator;
|
||||||
|
class QMLJS_EXPORT ConsoleManagerInterface : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ConsoleManagerInterface(QObject *parent = 0);
|
||||||
|
~ConsoleManagerInterface();
|
||||||
|
|
||||||
|
static ConsoleManagerInterface *instance();
|
||||||
|
|
||||||
|
virtual void showConsolePane() = 0;
|
||||||
|
|
||||||
|
virtual ConsoleItem *rootItem() const = 0;
|
||||||
|
|
||||||
|
virtual void setScriptEvaluator(IScriptEvaluator *scriptEvaluator) = 0;
|
||||||
|
virtual void setContext(const QString &context) = 0;
|
||||||
|
|
||||||
|
virtual void printToConsolePane(ConsoleItem::ItemType itemType, const QString &text,
|
||||||
|
bool bringToForeground = false) = 0;
|
||||||
|
virtual void printToConsolePane(ConsoleItem *item, bool bringToForeground = false) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // QmlJS
|
||||||
|
|
||||||
|
#endif // CONSOLEMANAGERINTERFACE_H
|
||||||
48
src/libs/qmljs/iscriptevaluator.h
Normal file
48
src/libs/qmljs/iscriptevaluator.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://qt.digia.com/licensing. For further information
|
||||||
|
** use the contact form at http://qt.digia.com/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, 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, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef ISCRIPTEVALUATOR_H
|
||||||
|
#define ISCRIPTEVALUATOR_H
|
||||||
|
|
||||||
|
#include "qmljs_global.h"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace QmlJS {
|
||||||
|
|
||||||
|
class QMLJS_EXPORT IScriptEvaluator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IScriptEvaluator() {}
|
||||||
|
|
||||||
|
virtual bool evaluateScript(const QString &script) = 0;
|
||||||
|
};
|
||||||
|
} // QmlJS
|
||||||
|
|
||||||
|
#endif // ISCRIPTEVALUATOR_H
|
||||||
@@ -33,7 +33,10 @@ HEADERS += \
|
|||||||
$$PWD/qmljsscopechain.h \
|
$$PWD/qmljsscopechain.h \
|
||||||
$$PWD/qmljsutils.h \
|
$$PWD/qmljsutils.h \
|
||||||
$$PWD/qmljsstaticanalysismessage.h \
|
$$PWD/qmljsstaticanalysismessage.h \
|
||||||
$$PWD/jsoncheck.h
|
$$PWD/jsoncheck.h \
|
||||||
|
$$PWD/consolemanagerinterface.h \
|
||||||
|
$$PWD/consoleitem.h \
|
||||||
|
$$PWD/iscriptevaluator.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/qmljsbind.cpp \
|
$$PWD/qmljsbind.cpp \
|
||||||
@@ -58,7 +61,9 @@ SOURCES += \
|
|||||||
$$PWD/qmljsscopechain.cpp \
|
$$PWD/qmljsscopechain.cpp \
|
||||||
$$PWD/qmljsutils.cpp \
|
$$PWD/qmljsutils.cpp \
|
||||||
$$PWD/qmljsstaticanalysismessage.cpp \
|
$$PWD/qmljsstaticanalysismessage.cpp \
|
||||||
$$PWD/jsoncheck.cpp
|
$$PWD/jsoncheck.cpp \
|
||||||
|
$$PWD/consolemanagerinterface.cpp \
|
||||||
|
$$PWD/consoleitem.cpp
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
$$PWD/qmljs.qrc
|
$$PWD/qmljs.qrc
|
||||||
|
|||||||
@@ -96,6 +96,11 @@ QtcLibrary {
|
|||||||
"parser/qmljsmemorypool_p.h",
|
"parser/qmljsmemorypool_p.h",
|
||||||
"parser/qmljsparser.cpp",
|
"parser/qmljsparser.cpp",
|
||||||
"parser/qmljsparser_p.h",
|
"parser/qmljsparser_p.h",
|
||||||
|
"consolemanagerinterface.cpp",
|
||||||
|
"consolemanagerinterface.h",
|
||||||
|
"consoleitem.cpp",
|
||||||
|
"consoleitem.h",
|
||||||
|
"iscriptevaluator.h"
|
||||||
]
|
]
|
||||||
|
|
||||||
ProductModule {
|
ProductModule {
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ Alternatively, this plugin may be used under the terms of the GNU Lesser General
|
|||||||
<dependency name=\"Core\" version=\"$$QTCREATOR_VERSION\"/>
|
<dependency name=\"Core\" version=\"$$QTCREATOR_VERSION\"/>
|
||||||
<dependency name=\"Find\" version=\"$$QTCREATOR_VERSION\"/>
|
<dependency name=\"Find\" version=\"$$QTCREATOR_VERSION\"/>
|
||||||
<dependency name=\"CppTools\" version=\"$$QTCREATOR_VERSION\"/>
|
<dependency name=\"CppTools\" version=\"$$QTCREATOR_VERSION\"/>
|
||||||
<dependency name=\"QmlJsTools\" version=\"$$QTCREATOR_VERSION\"/>
|
|
||||||
<!-- Debugger plugin adds items to the editor\'s context menu -->
|
<!-- Debugger plugin adds items to the editor\'s context menu -->
|
||||||
<dependency name=\"CppEditor\" version=\"$$QTCREATOR_VERSION\" type=\"optional\"/>
|
<dependency name=\"CppEditor\" version=\"$$QTCREATOR_VERSION\" type=\"optional\"/>
|
||||||
</dependencyList>
|
</dependencyList>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ include(../../plugins/cpptools/cpptools.pri)
|
|||||||
include(../../plugins/find/find.pri)
|
include(../../plugins/find/find.pri)
|
||||||
include(../../plugins/projectexplorer/projectexplorer.pri)
|
include(../../plugins/projectexplorer/projectexplorer.pri)
|
||||||
include(../../plugins/texteditor/texteditor.pri)
|
include(../../plugins/texteditor/texteditor.pri)
|
||||||
include(../../plugins/qmljstools/qmljstools.pri)
|
|
||||||
include(../../libs/cplusplus/cplusplus.pri)
|
include(../../libs/cplusplus/cplusplus.pri)
|
||||||
include(../../libs/utils/utils.pri)
|
include(../../libs/utils/utils.pri)
|
||||||
include(../../libs/qmljs/qmljs.pri)
|
include(../../libs/qmljs/qmljs.pri)
|
||||||
|
|||||||
@@ -116,7 +116,6 @@ public:
|
|||||||
virtual void openMemoryEditor() = 0;
|
virtual void openMemoryEditor() = 0;
|
||||||
virtual void languagesChanged() = 0;
|
virtual void languagesChanged() = 0;
|
||||||
virtual void executeDebuggerCommand(const QString &command, DebuggerLanguages languages) = 0;
|
virtual void executeDebuggerCommand(const QString &command, DebuggerLanguages languages) = 0;
|
||||||
virtual bool evaluateScriptExpression(const QString &expression) = 0;
|
|
||||||
|
|
||||||
virtual Utils::SavedAction *action(int code) const = 0;
|
virtual Utils::SavedAction *action(int code) const = 0;
|
||||||
virtual bool boolSetting(int code) const = 0;
|
virtual bool boolSetting(int code) const = 0;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/fileinprojectfinder.h>
|
#include <utils/fileinprojectfinder.h>
|
||||||
|
|
||||||
#include <qmljstools/qmlconsolemanager.h>
|
#include <qmljs/consolemanagerinterface.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@@ -532,9 +532,9 @@ void DebuggerEngine::showMessage(const QString &msg, int channel, int timeout) c
|
|||||||
}
|
}
|
||||||
//if (msg.size() && msg.at(0).isUpper() && msg.at(1).isUpper())
|
//if (msg.size() && msg.at(0).isUpper() && msg.at(1).isUpper())
|
||||||
// qDebug() << qPrintable(msg) << "IN STATE" << state();
|
// qDebug() << qPrintable(msg) << "IN STATE" << state();
|
||||||
QmlJSTools::QmlConsoleManager *consoleManager = QmlJSTools::QmlConsoleManager::instance();
|
QmlJS::ConsoleManagerInterface *consoleManager = QmlJS::ConsoleManagerInterface::instance();
|
||||||
if (channel == ConsoleOutput && consoleManager)
|
if (channel == ConsoleOutput && consoleManager)
|
||||||
consoleManager->printToConsolePane(QmlJSTools::QmlConsoleItem::UndefinedType, msg);
|
consoleManager->printToConsolePane(QmlJS::ConsoleItem::UndefinedType, msg);
|
||||||
|
|
||||||
debuggerCore()->showMessage(msg, channel, timeout);
|
debuggerCore()->showMessage(msg, channel, timeout);
|
||||||
if (d->m_runControl) {
|
if (d->m_runControl) {
|
||||||
@@ -1655,12 +1655,6 @@ void DebuggerEngine::executeDebuggerCommand(const QString &, DebuggerLanguages)
|
|||||||
showStatusMessage(tr("This debugger cannot handle user input."));
|
showStatusMessage(tr("This debugger cannot handle user input."));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DebuggerEngine::evaluateScriptExpression(const QString &)
|
|
||||||
{
|
|
||||||
showStatusMessage(tr("This debugger cannot handle user input."));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
BreakHandler *DebuggerEngine::breakHandler() const
|
BreakHandler *DebuggerEngine::breakHandler() const
|
||||||
{
|
{
|
||||||
return debuggerCore()->breakHandler();
|
return debuggerCore()->breakHandler();
|
||||||
|
|||||||
@@ -269,8 +269,6 @@ public:
|
|||||||
|
|
||||||
QString toFileInProject(const QUrl &fileUrl);
|
QString toFileInProject(const QUrl &fileUrl);
|
||||||
|
|
||||||
virtual bool evaluateScriptExpression(const QString &expression);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void stateChanged(Debugger::DebuggerState state);
|
void stateChanged(Debugger::DebuggerState state);
|
||||||
// A new stack frame is on display including locals.
|
// A new stack frame is on display including locals.
|
||||||
|
|||||||
@@ -124,8 +124,6 @@
|
|||||||
# include <utils/winutils.h>
|
# include <utils/winutils.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <qmljstools/qmlconsolemanager.h>
|
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
@@ -964,7 +962,6 @@ public slots:
|
|||||||
void aboutToSaveSession();
|
void aboutToSaveSession();
|
||||||
|
|
||||||
void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
|
void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
|
||||||
bool evaluateScriptExpression(const QString &expression);
|
|
||||||
void coreShutdown();
|
void coreShutdown();
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
@@ -2069,13 +2066,6 @@ void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine)
|
|||||||
|
|
||||||
mainWindow()->setEngineDebugLanguages(engine->startParameters().languages);
|
mainWindow()->setEngineDebugLanguages(engine->startParameters().languages);
|
||||||
mainWindow()->setCurrentEngine(engine);
|
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)
|
static void changeFontSize(QWidget *widget, qreal size)
|
||||||
@@ -2490,11 +2480,6 @@ void DebuggerPluginPrivate::showStatusMessage(const QString &msg0, int timeout)
|
|||||||
m_statusLabel->showStatusMessage(msg, timeout);
|
m_statusLabel->showStatusMessage(msg, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DebuggerPluginPrivate::evaluateScriptExpression(const QString &expression)
|
|
||||||
{
|
|
||||||
return currentEngine()->evaluateScriptExpression(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebuggerPluginPrivate::openMemoryEditor()
|
void DebuggerPluginPrivate::openMemoryEditor()
|
||||||
{
|
{
|
||||||
AddressDialog dialog;
|
AddressDialog dialog;
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
#include <texteditor/itexteditor.h>
|
#include <texteditor/itexteditor.h>
|
||||||
#include <qmljseditor/qmljseditorconstants.h>
|
#include <qmljseditor/qmljseditorconstants.h>
|
||||||
#include <cppeditor/cppeditorconstants.h>
|
#include <cppeditor/cppeditorconstants.h>
|
||||||
|
#include <qmljs/consolemanagerinterface.h>
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
@@ -400,11 +401,6 @@ void QmlCppEngine::executeDebuggerCommand(const QString &command, DebuggerLangua
|
|||||||
d->m_cppEngine->executeDebuggerCommand(command, languages);
|
d->m_cppEngine->executeDebuggerCommand(command, languages);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlCppEngine::evaluateScriptExpression(const QString &expression)
|
|
||||||
{
|
|
||||||
return d->m_qmlEngine->evaluateScriptExpression(expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void QmlCppEngine::setupEngine()
|
void QmlCppEngine::setupEngine()
|
||||||
@@ -466,6 +462,9 @@ void QmlCppEngine::shutdownEngine()
|
|||||||
{
|
{
|
||||||
EDEBUG("\nMASTER SHUTDOWN ENGINE");
|
EDEBUG("\nMASTER SHUTDOWN ENGINE");
|
||||||
d->m_cppEngine->shutdownSlaveEngine();
|
d->m_cppEngine->shutdownSlaveEngine();
|
||||||
|
QmlJS::ConsoleManagerInterface *consoleManager = QmlJS::ConsoleManagerInterface::instance();
|
||||||
|
if (consoleManager)
|
||||||
|
consoleManager->setScriptEvaluator(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlCppEngine::quitDebugger()
|
void QmlCppEngine::quitDebugger()
|
||||||
|
|||||||
@@ -110,7 +110,6 @@ protected:
|
|||||||
void executeRunToFunction(const QString &functionName);
|
void executeRunToFunction(const QString &functionName);
|
||||||
void executeJumpToLine(const ContextData &data);
|
void executeJumpToLine(const ContextData &data);
|
||||||
void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
|
void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
|
||||||
bool evaluateScriptExpression(const QString &expression);
|
|
||||||
|
|
||||||
void setupEngine();
|
void setupEngine();
|
||||||
void setupInferior();
|
void setupInferior();
|
||||||
|
|||||||
@@ -50,11 +50,12 @@
|
|||||||
#include "sourcefileshandler.h"
|
#include "sourcefileshandler.h"
|
||||||
#include "watchutils.h"
|
#include "watchutils.h"
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
|
||||||
#include <qmldebug/baseenginedebugclient.h>
|
#include <qmldebug/baseenginedebugclient.h>
|
||||||
#include <qmljseditor/qmljseditorconstants.h>
|
#include <qmljseditor/qmljseditorconstants.h>
|
||||||
#include <qmljs/parser/qmljsast_p.h>
|
#include <qmljs/parser/qmljsast_p.h>
|
||||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||||
|
#include <qmljs/consolemanagerinterface.h>
|
||||||
|
#include <qmljs/consoleitem.h>
|
||||||
|
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -66,9 +67,6 @@
|
|||||||
|
|
||||||
#include <texteditor/itexteditor.h>
|
#include <texteditor/itexteditor.h>
|
||||||
|
|
||||||
#include <qmljstools/qmlconsolemanager.h>
|
|
||||||
#include <qmljstools/qmlconsoleitem.h>
|
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@@ -261,6 +259,11 @@ public:
|
|||||||
quint32 *column;
|
quint32 *column;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QmlJS::ConsoleManagerInterface *qmlConsoleManager()
|
||||||
|
{
|
||||||
|
return QmlJS::ConsoleManagerInterface::instance();
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// QmlEngine
|
// QmlEngine
|
||||||
@@ -276,8 +279,6 @@ QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters)
|
|||||||
{
|
{
|
||||||
setObjectName(QLatin1String("QmlEngine"));
|
setObjectName(QLatin1String("QmlEngine"));
|
||||||
|
|
||||||
ExtensionSystem::PluginManager::addObject(this);
|
|
||||||
|
|
||||||
connect(&m_adapter, SIGNAL(connectionError(QAbstractSocket::SocketError)),
|
connect(&m_adapter, SIGNAL(connectionError(QAbstractSocket::SocketError)),
|
||||||
SLOT(connectionError(QAbstractSocket::SocketError)));
|
SLOT(connectionError(QAbstractSocket::SocketError)));
|
||||||
connect(&m_adapter, SIGNAL(serviceConnectionError(QString)),
|
connect(&m_adapter, SIGNAL(serviceConnectionError(QString)),
|
||||||
@@ -331,25 +332,23 @@ QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters)
|
|||||||
m_noDebugOutputTimer.setInterval(8000);
|
m_noDebugOutputTimer.setInterval(8000);
|
||||||
connect(&m_noDebugOutputTimer, SIGNAL(timeout()), this, SLOT(tryToConnect()));
|
connect(&m_noDebugOutputTimer, SIGNAL(timeout()), this, SLOT(tryToConnect()));
|
||||||
|
|
||||||
connect(ModelManagerInterface::instance(),
|
ModelManagerInterface *mmIface = ModelManagerInterface::instance();
|
||||||
SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
|
if (mmIface) {
|
||||||
this,
|
connect(ModelManagerInterface::instance(), SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
|
||||||
SLOT(documentUpdated(QmlJS::Document::Ptr)));
|
this, SLOT(documentUpdated(QmlJS::Document::Ptr)));
|
||||||
|
}
|
||||||
// we won't get any debug output
|
// we won't get any debug output
|
||||||
if (startParameters.useTerminal) {
|
if (startParameters.useTerminal) {
|
||||||
m_noDebugOutputTimer.setInterval(0);
|
m_noDebugOutputTimer.setInterval(0);
|
||||||
m_retryOnConnectFail = true;
|
m_retryOnConnectFail = true;
|
||||||
m_automaticConnect = true;
|
m_automaticConnect = true;
|
||||||
}
|
}
|
||||||
|
if (qmlConsoleManager())
|
||||||
|
qmlConsoleManager()->setScriptEvaluator(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlEngine::~QmlEngine()
|
QmlEngine::~QmlEngine()
|
||||||
{
|
{
|
||||||
if (ExtensionSystem::PluginManager::allObjects().contains(this)) {
|
|
||||||
ExtensionSystem::PluginManager::removeObject(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Core::IEditor *> editorsToClose;
|
QList<Core::IEditor *> editorsToClose;
|
||||||
|
|
||||||
QHash<QString, QWeakPointer<TextEditor::ITextEditor> >::iterator iter;
|
QHash<QString, QWeakPointer<TextEditor::ITextEditor> >::iterator iter;
|
||||||
@@ -649,6 +648,8 @@ void QmlEngine::shutdownInferior()
|
|||||||
|
|
||||||
void QmlEngine::shutdownEngine()
|
void QmlEngine::shutdownEngine()
|
||||||
{
|
{
|
||||||
|
if (qmlConsoleManager())
|
||||||
|
qmlConsoleManager()->setScriptEvaluator(0);
|
||||||
m_noDebugOutputTimer.stop();
|
m_noDebugOutputTimer.stop();
|
||||||
|
|
||||||
// double check (ill engine?):
|
// double check (ill engine?):
|
||||||
@@ -1030,16 +1031,16 @@ void QmlEngine::synchronizeWatchers()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlJSTools::QmlConsoleItem *constructLogItemTree(QmlJSTools::QmlConsoleItem *parent,
|
QmlJS::ConsoleItem *constructLogItemTree(QmlJS::ConsoleItem *parent,
|
||||||
const QVariant &result,
|
const QVariant &result,
|
||||||
const QString &key = QString())
|
const QString &key = QString())
|
||||||
{
|
{
|
||||||
using namespace QmlJSTools;
|
using namespace QmlJS;
|
||||||
bool sorted = debuggerCore()->boolSetting(SortStructMembers);
|
bool sorted = debuggerCore()->boolSetting(SortStructMembers);
|
||||||
if (!result.isValid())
|
if (!result.isValid())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
QmlConsoleItem *item = new QmlConsoleItem(parent);
|
ConsoleItem *item = new ConsoleItem(parent);
|
||||||
if (result.type() == QVariant::Map) {
|
if (result.type() == QVariant::Map) {
|
||||||
if (key.isEmpty())
|
if (key.isEmpty())
|
||||||
item->setText(_("Object"));
|
item->setText(_("Object"));
|
||||||
@@ -1049,7 +1050,7 @@ QmlJSTools::QmlConsoleItem *constructLogItemTree(QmlJSTools::QmlConsoleItem *par
|
|||||||
QMapIterator<QString, QVariant> i(result.toMap());
|
QMapIterator<QString, QVariant> i(result.toMap());
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
i.next();
|
i.next();
|
||||||
QmlConsoleItem *child = constructLogItemTree(item, i.value(), i.key());
|
ConsoleItem *child = constructLogItemTree(item, i.value(), i.key());
|
||||||
if (child)
|
if (child)
|
||||||
item->insertChild(child, sorted);
|
item->insertChild(child, sorted);
|
||||||
}
|
}
|
||||||
@@ -1060,7 +1061,7 @@ QmlJSTools::QmlConsoleItem *constructLogItemTree(QmlJSTools::QmlConsoleItem *par
|
|||||||
item->setText(QString(_("[%1] : List")).arg(key));
|
item->setText(QString(_("[%1] : List")).arg(key));
|
||||||
QVariantList resultList = result.toList();
|
QVariantList resultList = result.toList();
|
||||||
for (int i = 0; i < resultList.count(); i++) {
|
for (int i = 0; i < resultList.count(); i++) {
|
||||||
QmlConsoleItem *child = constructLogItemTree(item, resultList.at(i),
|
ConsoleItem *child = constructLogItemTree(item, resultList.at(i),
|
||||||
QString::number(i));
|
QString::number(i));
|
||||||
if (child)
|
if (child)
|
||||||
item->insertChild(child, sorted);
|
item->insertChild(child, sorted);
|
||||||
@@ -1078,10 +1079,10 @@ void QmlEngine::expressionEvaluated(quint32 queryId, const QVariant &result)
|
|||||||
{
|
{
|
||||||
if (queryIds.contains(queryId)) {
|
if (queryIds.contains(queryId)) {
|
||||||
queryIds.removeOne(queryId);
|
queryIds.removeOne(queryId);
|
||||||
using namespace QmlJSTools;
|
using namespace QmlJS;
|
||||||
QmlConsoleManager *consoleManager = QmlConsoleManager::instance();
|
ConsoleManagerInterface *consoleManager = qmlConsoleManager();
|
||||||
if (consoleManager) {
|
if (consoleManager) {
|
||||||
QmlConsoleItem *item = constructLogItemTree(consoleManager->rootItem(), result);
|
ConsoleItem *item = constructLogItemTree(consoleManager->rootItem(), result);
|
||||||
if (item)
|
if (item)
|
||||||
consoleManager->printToConsolePane(item);
|
consoleManager->printToConsolePane(item);
|
||||||
}
|
}
|
||||||
@@ -1140,7 +1141,7 @@ void QmlEngine::updateCurrentContext()
|
|||||||
const QString context = state() == InferiorStopOk ?
|
const QString context = state() == InferiorStopOk ?
|
||||||
stackHandler()->currentFrame().function
|
stackHandler()->currentFrame().function
|
||||||
: m_inspectorAdapter.currentSelectedDisplayName();
|
: m_inspectorAdapter.currentSelectedDisplayName();
|
||||||
QmlJSTools::QmlConsoleManager *consoleManager = QmlJSTools::QmlConsoleManager::instance();
|
QmlJS::ConsoleManagerInterface *consoleManager = qmlConsoleManager();
|
||||||
if (consoleManager)
|
if (consoleManager)
|
||||||
consoleManager->setContext(tr("Context: ").append(context));
|
consoleManager->setContext(tr("Context: ").append(context));
|
||||||
}
|
}
|
||||||
@@ -1148,26 +1149,26 @@ void QmlEngine::updateCurrentContext()
|
|||||||
void QmlEngine::appendDebugOutput(QtMsgType type, const QString &message,
|
void QmlEngine::appendDebugOutput(QtMsgType type, const QString &message,
|
||||||
const QmlDebug::QDebugContextInfo &info)
|
const QmlDebug::QDebugContextInfo &info)
|
||||||
{
|
{
|
||||||
using namespace QmlJSTools;
|
using namespace QmlJS;
|
||||||
QmlConsoleItem::ItemType itemType;
|
ConsoleItem::ItemType itemType;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QtDebugMsg:
|
case QtDebugMsg:
|
||||||
itemType = QmlConsoleItem::DebugType;
|
itemType = ConsoleItem::DebugType;
|
||||||
break;
|
break;
|
||||||
case QtWarningMsg:
|
case QtWarningMsg:
|
||||||
itemType = QmlConsoleItem::WarningType;
|
itemType = ConsoleItem::WarningType;
|
||||||
break;
|
break;
|
||||||
case QtCriticalMsg:
|
case QtCriticalMsg:
|
||||||
case QtFatalMsg:
|
case QtFatalMsg:
|
||||||
itemType = QmlConsoleItem::ErrorType;
|
itemType = ConsoleItem::ErrorType;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//This case is not possible
|
//This case is not possible
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QmlConsoleManager *consoleManager = QmlConsoleManager::instance();
|
ConsoleManagerInterface *consoleManager = qmlConsoleManager();
|
||||||
if (consoleManager) {
|
if (consoleManager) {
|
||||||
QmlConsoleItem *item = new QmlConsoleItem(consoleManager->rootItem(), itemType, message);
|
ConsoleItem *item = new ConsoleItem(consoleManager->rootItem(), itemType, message);
|
||||||
item->file = info.file;
|
item->file = info.file;
|
||||||
item->line = info.line;
|
item->line = info.line;
|
||||||
consoleManager->printToConsolePane(item);
|
consoleManager->printToConsolePane(item);
|
||||||
@@ -1181,7 +1182,7 @@ void QmlEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlEngine::evaluateScriptExpression(const QString &expression)
|
bool QmlEngine::evaluateScript(const QString &expression)
|
||||||
{
|
{
|
||||||
bool didEvaluate = true;
|
bool didEvaluate = true;
|
||||||
// Evaluate expression based on engine state
|
// Evaluate expression based on engine state
|
||||||
@@ -1194,10 +1195,10 @@ bool QmlEngine::evaluateScriptExpression(const QString &expression)
|
|||||||
queryIds << queryId;
|
queryIds << queryId;
|
||||||
} else {
|
} else {
|
||||||
didEvaluate = false;
|
didEvaluate = false;
|
||||||
using namespace QmlJSTools;
|
using namespace QmlJS;
|
||||||
QmlConsoleManager *consoleManager = QmlConsoleManager::instance();
|
ConsoleManagerInterface *consoleManager = qmlConsoleManager();
|
||||||
if (consoleManager) {
|
if (consoleManager) {
|
||||||
consoleManager->printToConsolePane(QmlConsoleItem::ErrorType,
|
consoleManager->printToConsolePane(ConsoleItem::ErrorType,
|
||||||
_("Error evaluating expression."));
|
_("Error evaluating expression."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1312,20 +1313,23 @@ bool QmlEngine::canEvaluateScript(const QString &script)
|
|||||||
bool QmlEngine::adjustBreakpointLineAndColumn(
|
bool QmlEngine::adjustBreakpointLineAndColumn(
|
||||||
const QString &filePath, quint32 *line, quint32 *column, bool *valid)
|
const QString &filePath, quint32 *line, quint32 *column, bool *valid)
|
||||||
{
|
{
|
||||||
bool success = true;
|
bool success = false;
|
||||||
//check if file is in the latest snapshot
|
//check if file is in the latest snapshot
|
||||||
//ignoring documentChangedOnDisk
|
//ignoring documentChangedOnDisk
|
||||||
//TODO:: update breakpoints if document is changed.
|
//TODO:: update breakpoints if document is changed.
|
||||||
Document::Ptr doc = ModelManagerInterface::instance()->newestSnapshot().
|
ModelManagerInterface *mmIface = ModelManagerInterface::instance();
|
||||||
document(filePath);
|
if (mmIface) {
|
||||||
if (doc.isNull()) {
|
Document::Ptr doc = mmIface->newestSnapshot().
|
||||||
ModelManagerInterface::instance()->updateSourceFiles(
|
document(filePath);
|
||||||
QStringList() << filePath, false);
|
if (doc.isNull()) {
|
||||||
success = false;
|
ModelManagerInterface::instance()->updateSourceFiles(
|
||||||
} else {
|
QStringList() << filePath, false);
|
||||||
ASTWalker walker;
|
} else {
|
||||||
walker(doc->ast(), line, column);
|
ASTWalker walker;
|
||||||
*valid = walker.done;
|
walker(doc->ast(), line, column);
|
||||||
|
*valid = walker.done;
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
#include <qmldebug/qdebugmessageclient.h>
|
#include <qmldebug/qdebugmessageclient.h>
|
||||||
#include <qmldebug/qmloutputparser.h>
|
#include <qmldebug/qmloutputparser.h>
|
||||||
#include <qmljs/qmljsdocument.h>
|
#include <qmljs/qmljsdocument.h>
|
||||||
|
#include <qmljs/iscriptevaluator.h>
|
||||||
#include <utils/outputformat.h>
|
#include <utils/outputformat.h>
|
||||||
|
|
||||||
#include <QAbstractSocket>
|
#include <QAbstractSocket>
|
||||||
@@ -53,7 +54,7 @@ namespace Internal {
|
|||||||
|
|
||||||
class QmlAdapter;
|
class QmlAdapter;
|
||||||
|
|
||||||
class QmlEngine : public DebuggerEngine
|
class QmlEngine : public DebuggerEngine, QmlJS::IScriptEvaluator
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -161,7 +162,7 @@ private:
|
|||||||
void updateWatchData(const WatchData &data,
|
void updateWatchData(const WatchData &data,
|
||||||
const WatchUpdateFlags &flags);
|
const WatchUpdateFlags &flags);
|
||||||
void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
|
void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
|
||||||
bool evaluateScriptExpression(const QString &expression);
|
bool evaluateScript(const QString &expression);
|
||||||
|
|
||||||
bool hasCapability(unsigned) const;
|
bool hasCapability(unsigned) const;
|
||||||
void quitDebugger();
|
void quitDebugger();
|
||||||
|
|||||||
@@ -302,40 +302,42 @@ void QmlInspectorAdapter::createPreviewForEditor(Core::IEditor *newEditor)
|
|||||||
QString filename = newEditor->document()->fileName();
|
QString filename = newEditor->document()->fileName();
|
||||||
QmlJS::ModelManagerInterface *modelManager =
|
QmlJS::ModelManagerInterface *modelManager =
|
||||||
QmlJS::ModelManagerInterface::instance();
|
QmlJS::ModelManagerInterface::instance();
|
||||||
QmlJS::Document::Ptr doc = modelManager->snapshot().document(filename);
|
if (modelManager) {
|
||||||
if (!doc) {
|
QmlJS::Document::Ptr doc = modelManager->snapshot().document(filename);
|
||||||
if (filename.endsWith(QLatin1String(".qml")) || filename.endsWith(QLatin1String(".js"))) {
|
if (!doc) {
|
||||||
// add to list of docs that we have to update when
|
if (filename.endsWith(QLatin1String(".qml")) || filename.endsWith(QLatin1String(".js"))) {
|
||||||
// snapshot figures out that there's a new document
|
// add to list of docs that we have to update when
|
||||||
m_pendingPreviewDocumentNames.append(filename);
|
// snapshot figures out that there's a new document
|
||||||
|
m_pendingPreviewDocumentNames.append(filename);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
if (!doc->qmlProgram() && !filename.endsWith(QLatin1String(".js")))
|
||||||
}
|
return;
|
||||||
if (!doc->qmlProgram() && !filename.endsWith(QLatin1String(".js")))
|
|
||||||
return;
|
|
||||||
|
|
||||||
QmlJS::Document::Ptr initdoc = m_loadedSnapshot.document(filename);
|
QmlJS::Document::Ptr initdoc = m_loadedSnapshot.document(filename);
|
||||||
if (!initdoc)
|
if (!initdoc)
|
||||||
initdoc = doc;
|
initdoc = doc;
|
||||||
|
|
||||||
if (m_textPreviews.contains(filename)) {
|
if (m_textPreviews.contains(filename)) {
|
||||||
QmlLiveTextPreview *preview = m_textPreviews.value(filename);
|
QmlLiveTextPreview *preview = m_textPreviews.value(filename);
|
||||||
preview->associateEditor(newEditor);
|
preview->associateEditor(newEditor);
|
||||||
} else {
|
} else {
|
||||||
QmlLiveTextPreview *preview
|
QmlLiveTextPreview *preview
|
||||||
= new QmlLiveTextPreview(doc, initdoc, this, this);
|
= new QmlLiveTextPreview(doc, initdoc, this, this);
|
||||||
connect(preview,
|
connect(preview,
|
||||||
SIGNAL(selectedItemsChanged(QList<int>)),
|
SIGNAL(selectedItemsChanged(QList<int>)),
|
||||||
SLOT(selectObjectsFromEditor(QList<int>)));
|
SLOT(selectObjectsFromEditor(QList<int>)));
|
||||||
|
|
||||||
preview->setApplyChangesToQmlInspector(
|
preview->setApplyChangesToQmlInspector(
|
||||||
debuggerCore()->action(QmlUpdateOnSave)->isChecked());
|
debuggerCore()->action(QmlUpdateOnSave)->isChecked());
|
||||||
connect(preview, SIGNAL(reloadRequest()),
|
connect(preview, SIGNAL(reloadRequest()),
|
||||||
this, SLOT(onReload()));
|
this, SLOT(onReload()));
|
||||||
|
|
||||||
m_textPreviews.insert(newEditor->document()->fileName(), preview);
|
m_textPreviews.insert(newEditor->document()->fileName(), preview);
|
||||||
preview->associateEditor(newEditor);
|
preview->associateEditor(newEditor);
|
||||||
preview->updateDebugIds();
|
preview->updateDebugIds();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,15 +428,17 @@ void QmlInspectorAdapter::setActiveEngineClient(BaseEngineDebugClient *client)
|
|||||||
m_engineClient->status() == QmlDebug::Enabled) {
|
m_engineClient->status() == QmlDebug::Enabled) {
|
||||||
QmlJS::ModelManagerInterface *modelManager
|
QmlJS::ModelManagerInterface *modelManager
|
||||||
= QmlJS::ModelManagerInterface::instance();
|
= QmlJS::ModelManagerInterface::instance();
|
||||||
QmlJS::Snapshot snapshot = modelManager->snapshot();
|
if (modelManager) {
|
||||||
for (QHash<QString, QmlLiveTextPreview *>::const_iterator it
|
QmlJS::Snapshot snapshot = modelManager->snapshot();
|
||||||
= m_textPreviews.constBegin();
|
for (QHash<QString, QmlLiveTextPreview *>::const_iterator it
|
||||||
it != m_textPreviews.constEnd(); ++it) {
|
= m_textPreviews.constBegin();
|
||||||
QmlJS::Document::Ptr doc = snapshot.document(it.key());
|
it != m_textPreviews.constEnd(); ++it) {
|
||||||
it.value()->resetInitialDoc(doc);
|
QmlJS::Document::Ptr doc = snapshot.document(it.key());
|
||||||
}
|
it.value()->resetInitialDoc(doc);
|
||||||
|
}
|
||||||
|
|
||||||
initializePreviews();
|
initializePreviews();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,22 +447,24 @@ void QmlInspectorAdapter::initializePreviews()
|
|||||||
Core::EditorManager *em = Core::EditorManager::instance();
|
Core::EditorManager *em = Core::EditorManager::instance();
|
||||||
QmlJS::ModelManagerInterface *modelManager
|
QmlJS::ModelManagerInterface *modelManager
|
||||||
= QmlJS::ModelManagerInterface::instance();
|
= QmlJS::ModelManagerInterface::instance();
|
||||||
m_loadedSnapshot = modelManager->snapshot();
|
if (modelManager) {
|
||||||
|
m_loadedSnapshot = modelManager->snapshot();
|
||||||
|
|
||||||
if (!m_listeningToEditorManager) {
|
if (!m_listeningToEditorManager) {
|
||||||
m_listeningToEditorManager = true;
|
m_listeningToEditorManager = true;
|
||||||
connect(em, SIGNAL(editorAboutToClose(Core::IEditor*)),
|
connect(em, SIGNAL(editorAboutToClose(Core::IEditor*)),
|
||||||
this, SLOT(removePreviewForEditor(Core::IEditor*)));
|
this, SLOT(removePreviewForEditor(Core::IEditor*)));
|
||||||
connect(em, SIGNAL(editorOpened(Core::IEditor*)),
|
connect(em, SIGNAL(editorOpened(Core::IEditor*)),
|
||||||
this, SLOT(createPreviewForEditor(Core::IEditor*)));
|
this, SLOT(createPreviewForEditor(Core::IEditor*)));
|
||||||
connect(modelManager,
|
connect(modelManager,
|
||||||
SIGNAL(documentChangedOnDisk(QmlJS::Document::Ptr)),
|
SIGNAL(documentChangedOnDisk(QmlJS::Document::Ptr)),
|
||||||
this, SLOT(updatePendingPreviewDocuments(QmlJS::Document::Ptr)));
|
this, SLOT(updatePendingPreviewDocuments(QmlJS::Document::Ptr)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// initial update
|
||||||
|
foreach (Core::IEditor *editor, em->openedEditors())
|
||||||
|
createPreviewForEditor(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// initial update
|
|
||||||
foreach (Core::IEditor *editor, em->openedEditors())
|
|
||||||
createPreviewForEditor(editor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlInspectorAdapter::showConnectionStatusMessage(const QString &message)
|
void QmlInspectorAdapter::showConnectionStatusMessage(const QString &message)
|
||||||
@@ -542,13 +548,15 @@ void QmlInspectorAdapter::onReloaded()
|
|||||||
{
|
{
|
||||||
QmlJS::ModelManagerInterface *modelManager =
|
QmlJS::ModelManagerInterface *modelManager =
|
||||||
QmlJS::ModelManagerInterface::instance();
|
QmlJS::ModelManagerInterface::instance();
|
||||||
QmlJS::Snapshot snapshot = modelManager->snapshot();
|
if (modelManager) {
|
||||||
m_loadedSnapshot = snapshot;
|
QmlJS::Snapshot snapshot = modelManager->snapshot();
|
||||||
for (QHash<QString, QmlLiveTextPreview *>::const_iterator it
|
m_loadedSnapshot = snapshot;
|
||||||
= m_textPreviews.constBegin();
|
for (QHash<QString, QmlLiveTextPreview *>::const_iterator it
|
||||||
it != m_textPreviews.constEnd(); ++it) {
|
= m_textPreviews.constBegin();
|
||||||
QmlJS::Document::Ptr doc = snapshot.document(it.key());
|
it != m_textPreviews.constEnd(); ++it) {
|
||||||
it.value()->resetInitialDoc(doc);
|
QmlJS::Document::Ptr doc = snapshot.document(it.key());
|
||||||
|
it.value()->resetInitialDoc(doc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_agent->reloadEngines();
|
m_agent->reloadEngines();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -363,10 +363,10 @@ QmlLiveTextPreview::QmlLiveTextPreview(const QmlJS::Document::Ptr &doc,
|
|||||||
|
|
||||||
QmlJS::ModelManagerInterface *modelManager
|
QmlJS::ModelManagerInterface *modelManager
|
||||||
= QmlJS::ModelManagerInterface::instance();
|
= QmlJS::ModelManagerInterface::instance();
|
||||||
|
if (modelManager) {
|
||||||
connect(modelManager, SIGNAL(documentChangedOnDisk(QmlJS::Document::Ptr)),
|
connect(modelManager, SIGNAL(documentChangedOnDisk(QmlJS::Document::Ptr)),
|
||||||
SLOT(documentChanged(QmlJS::Document::Ptr)));
|
SLOT(documentChanged(QmlJS::Document::Ptr)));
|
||||||
|
}
|
||||||
connect(m_inspectorAdapter->agent(), SIGNAL(objectTreeUpdated()),
|
connect(m_inspectorAdapter->agent(), SIGNAL(objectTreeUpdated()),
|
||||||
SLOT(updateDebugIds()));
|
SLOT(updateDebugIds()));
|
||||||
connect(this,
|
connect(this,
|
||||||
|
|||||||
@@ -43,8 +43,8 @@
|
|||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <texteditor/basetexteditor.h>
|
#include <texteditor/basetexteditor.h>
|
||||||
|
|
||||||
#include <qmljstools/qmlconsoleitem.h>
|
#include <qmljs/consolemanagerinterface.h>
|
||||||
#include <qmljstools/qmlconsolemanager.h>
|
#include <qmljs/consoleitem.h>
|
||||||
|
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
@@ -1748,11 +1748,11 @@ void QmlV8DebuggerClient::updateScope(const QVariant &bodyVal, const QVariant &r
|
|||||||
d->engine->watchHandler()->insertData(locals);
|
d->engine->watchHandler()->insertData(locals);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlJSTools::QmlConsoleItem *constructLogItemTree(QmlJSTools::QmlConsoleItem *parent,
|
QmlJS::ConsoleItem *constructLogItemTree(QmlJS::ConsoleItem *parent,
|
||||||
const QmlV8ObjectData &objectData,
|
const QmlV8ObjectData &objectData,
|
||||||
const QVariant &refsVal)
|
const QVariant &refsVal)
|
||||||
{
|
{
|
||||||
using namespace QmlJSTools;
|
using namespace QmlJS;
|
||||||
bool sorted = debuggerCore()->boolSetting(SortStructMembers);
|
bool sorted = debuggerCore()->boolSetting(SortStructMembers);
|
||||||
if (!objectData.value.isValid())
|
if (!objectData.value.isValid())
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1764,10 +1764,10 @@ QmlJSTools::QmlConsoleItem *constructLogItemTree(QmlJSTools::QmlConsoleItem *par
|
|||||||
text = QString(_("%1: %2")).arg(QString::fromAscii(objectData.name))
|
text = QString(_("%1: %2")).arg(QString::fromAscii(objectData.name))
|
||||||
.arg(objectData.value.toString());
|
.arg(objectData.value.toString());
|
||||||
|
|
||||||
QmlConsoleItem *item = new QmlConsoleItem(parent, QmlConsoleItem::UndefinedType, text);
|
ConsoleItem *item = new ConsoleItem(parent, ConsoleItem::UndefinedType, text);
|
||||||
|
|
||||||
foreach (const QVariant &property, objectData.properties) {
|
foreach (const QVariant &property, objectData.properties) {
|
||||||
QmlConsoleItem *child = constructLogItemTree(item, extractData(property, refsVal),
|
ConsoleItem *child = constructLogItemTree(item, extractData(property, refsVal),
|
||||||
refsVal);
|
refsVal);
|
||||||
if (child)
|
if (child)
|
||||||
item->insertChild(child, sorted);
|
item->insertChild(child, sorted);
|
||||||
@@ -1802,10 +1802,10 @@ void QmlV8DebuggerClient::updateEvaluationResult(int sequence, bool success,
|
|||||||
} else if (d->debuggerCommands.contains(sequence)) {
|
} else if (d->debuggerCommands.contains(sequence)) {
|
||||||
d->updateLocalsAndWatchers.removeOne(sequence);
|
d->updateLocalsAndWatchers.removeOne(sequence);
|
||||||
QmlV8ObjectData body = extractData(bodyVal, refsVal);
|
QmlV8ObjectData body = extractData(bodyVal, refsVal);
|
||||||
using namespace QmlJSTools;
|
using namespace QmlJS;
|
||||||
QmlConsoleManager *consoleManager = QmlConsoleManager::instance();
|
ConsoleManagerInterface *consoleManager = ConsoleManagerInterface::instance();
|
||||||
if (consoleManager) {
|
if (consoleManager) {
|
||||||
QmlConsoleItem *item = constructLogItemTree(consoleManager->rootItem(), body, refsVal);
|
ConsoleItem *item = constructLogItemTree(consoleManager->rootItem(), body, refsVal);
|
||||||
if (item)
|
if (item)
|
||||||
consoleManager->printToConsolePane(item);
|
consoleManager->printToConsolePane(item);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
|
||||||
|
using namespace QmlJS;
|
||||||
|
|
||||||
namespace QmlJSTools {
|
namespace QmlJSTools {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -207,7 +209,7 @@ void QmlConsoleEdit::handleUpKey()
|
|||||||
currentRow--;
|
currentRow--;
|
||||||
if (model->hasIndex(currentRow, 0)) {
|
if (model->hasIndex(currentRow, 0)) {
|
||||||
QModelIndex index = model->index(currentRow, 0);
|
QModelIndex index = model->index(currentRow, 0);
|
||||||
if (QmlConsoleItem::InputType == (QmlConsoleItem::ItemType)model->data(
|
if (ConsoleItem::InputType == (ConsoleItem::ItemType)model->data(
|
||||||
index, QmlConsoleItemModel::TypeRole).toInt()) {
|
index, QmlConsoleItemModel::TypeRole).toInt()) {
|
||||||
m_historyIndex = index;
|
m_historyIndex = index;
|
||||||
replaceCurrentScript(model->data(index, Qt::DisplayRole).toString());
|
replaceCurrentScript(model->data(index, Qt::DisplayRole).toString());
|
||||||
@@ -226,7 +228,7 @@ void QmlConsoleEdit::handleDownKey()
|
|||||||
currentRow++;
|
currentRow++;
|
||||||
if (model->hasIndex(currentRow, 0)) {
|
if (model->hasIndex(currentRow, 0)) {
|
||||||
QModelIndex index = model->index(currentRow, 0);
|
QModelIndex index = model->index(currentRow, 0);
|
||||||
if (QmlConsoleItem::InputType == (QmlConsoleItem::ItemType)model->data(
|
if (ConsoleItem::InputType == (ConsoleItem::ItemType)model->data(
|
||||||
index, QmlConsoleItemModel::TypeRole).toInt()) {
|
index, QmlConsoleItemModel::TypeRole).toInt()) {
|
||||||
m_historyIndex = index;
|
m_historyIndex = index;
|
||||||
if (currentRow == model->rowCount() - 1)
|
if (currentRow == model->rowCount() - 1)
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ const char CONSOLE_BORDER_COLOR[] = "#C9C9C9";
|
|||||||
|
|
||||||
const int ELLIPSIS_GRADIENT_WIDTH = 16;
|
const int ELLIPSIS_GRADIENT_WIDTH = 16;
|
||||||
|
|
||||||
|
using namespace QmlJS;
|
||||||
|
|
||||||
namespace QmlJSTools {
|
namespace QmlJSTools {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -84,23 +86,23 @@ QColor QmlConsoleItemDelegate::drawBackground(QPainter *painter, const QRect &re
|
|||||||
bool selected) const
|
bool selected) const
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
QmlConsoleItem::ItemType itemType = (QmlConsoleItem::ItemType)index.data(
|
ConsoleItem::ItemType itemType = (ConsoleItem::ItemType)index.data(
|
||||||
QmlConsoleItemModel::TypeRole).toInt();
|
QmlConsoleItemModel::TypeRole).toInt();
|
||||||
QColor backgroundColor;
|
QColor backgroundColor;
|
||||||
switch (itemType) {
|
switch (itemType) {
|
||||||
case QmlConsoleItem::DebugType:
|
case ConsoleItem::DebugType:
|
||||||
backgroundColor = selected ? QColor(CONSOLE_LOG_BACKGROUND_SELECTED_COLOR) :
|
backgroundColor = selected ? QColor(CONSOLE_LOG_BACKGROUND_SELECTED_COLOR) :
|
||||||
QColor(CONSOLE_LOG_BACKGROUND_COLOR);
|
QColor(CONSOLE_LOG_BACKGROUND_COLOR);
|
||||||
break;
|
break;
|
||||||
case QmlConsoleItem::WarningType:
|
case ConsoleItem::WarningType:
|
||||||
backgroundColor = selected ? QColor(CONSOLE_WARNING_BACKGROUND_SELECTED_COLOR) :
|
backgroundColor = selected ? QColor(CONSOLE_WARNING_BACKGROUND_SELECTED_COLOR) :
|
||||||
QColor(CONSOLE_WARNING_BACKGROUND_COLOR);
|
QColor(CONSOLE_WARNING_BACKGROUND_COLOR);
|
||||||
break;
|
break;
|
||||||
case QmlConsoleItem::ErrorType:
|
case ConsoleItem::ErrorType:
|
||||||
backgroundColor = selected ? QColor(CONSOLE_ERROR_BACKGROUND_SELECTED_COLOR) :
|
backgroundColor = selected ? QColor(CONSOLE_ERROR_BACKGROUND_SELECTED_COLOR) :
|
||||||
QColor(CONSOLE_ERROR_BACKGROUND_COLOR);
|
QColor(CONSOLE_ERROR_BACKGROUND_COLOR);
|
||||||
break;
|
break;
|
||||||
case QmlConsoleItem::InputType:
|
case ConsoleItem::InputType:
|
||||||
default:
|
default:
|
||||||
backgroundColor = selected ? QColor(CONSOLE_EDITOR_BACKGROUND_SELECTED_COLOR) :
|
backgroundColor = selected ? QColor(CONSOLE_EDITOR_BACKGROUND_SELECTED_COLOR) :
|
||||||
QColor(CONSOLE_EDITOR_BACKGROUND_COLOR);
|
QColor(CONSOLE_EDITOR_BACKGROUND_COLOR);
|
||||||
@@ -130,22 +132,22 @@ void QmlConsoleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem
|
|||||||
// Set Colors
|
// Set Colors
|
||||||
QColor textColor;
|
QColor textColor;
|
||||||
QIcon taskIcon;
|
QIcon taskIcon;
|
||||||
QmlConsoleItem::ItemType type = (QmlConsoleItem::ItemType)index.data(
|
ConsoleItem::ItemType type = (ConsoleItem::ItemType)index.data(
|
||||||
QmlConsoleItemModel::TypeRole).toInt();
|
QmlConsoleItemModel::TypeRole).toInt();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QmlConsoleItem::DebugType:
|
case ConsoleItem::DebugType:
|
||||||
textColor = QColor(CONSOLE_LOG_TEXT_COLOR);
|
textColor = QColor(CONSOLE_LOG_TEXT_COLOR);
|
||||||
taskIcon = m_logIcon;
|
taskIcon = m_logIcon;
|
||||||
break;
|
break;
|
||||||
case QmlConsoleItem::WarningType:
|
case ConsoleItem::WarningType:
|
||||||
textColor = QColor(CONSOLE_WARNING_TEXT_COLOR);
|
textColor = QColor(CONSOLE_WARNING_TEXT_COLOR);
|
||||||
taskIcon = m_warningIcon;
|
taskIcon = m_warningIcon;
|
||||||
break;
|
break;
|
||||||
case QmlConsoleItem::ErrorType:
|
case ConsoleItem::ErrorType:
|
||||||
textColor = QColor(CONSOLE_ERROR_TEXT_COLOR);
|
textColor = QColor(CONSOLE_ERROR_TEXT_COLOR);
|
||||||
taskIcon = m_errorIcon;
|
taskIcon = m_errorIcon;
|
||||||
break;
|
break;
|
||||||
case QmlConsoleItem::InputType:
|
case ConsoleItem::InputType:
|
||||||
textColor = QColor(CONSOLE_EDITOR_TEXT_COLOR);
|
textColor = QColor(CONSOLE_EDITOR_TEXT_COLOR);
|
||||||
taskIcon = m_prompt;
|
taskIcon = m_prompt;
|
||||||
break;
|
break;
|
||||||
@@ -168,7 +170,7 @@ void QmlConsoleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem
|
|||||||
}
|
}
|
||||||
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 showTypeIcon = index.parent() == QModelIndex();
|
||||||
bool showExpandableIcon = type == QmlConsoleItem::UndefinedType;
|
bool showExpandableIcon = type == ConsoleItem::UndefinedType;
|
||||||
|
|
||||||
QRect rect(opt.rect.x(), opt.rect.top(), width, opt.rect.height());
|
QRect rect(opt.rect.x(), opt.rect.top(), width, opt.rect.height());
|
||||||
ConsoleItemPositions positions(rect, opt.font, showTypeIcon, showExpandableIcon);
|
ConsoleItemPositions positions(rect, opt.font, showTypeIcon, showExpandableIcon);
|
||||||
@@ -266,10 +268,10 @@ QSize QmlConsoleItemDelegate::sizeHint(const QStyleOptionViewItem &option,
|
|||||||
if (!selected && option.font == m_cachedFont && m_cachedHeight > 0)
|
if (!selected && option.font == m_cachedFont && m_cachedHeight > 0)
|
||||||
return QSize(width, m_cachedHeight);
|
return QSize(width, m_cachedHeight);
|
||||||
|
|
||||||
QmlConsoleItem::ItemType type = (QmlConsoleItem::ItemType)index.data(
|
ConsoleItem::ItemType type = (ConsoleItem::ItemType)index.data(
|
||||||
QmlConsoleItemModel::TypeRole).toInt();
|
QmlConsoleItemModel::TypeRole).toInt();
|
||||||
bool showTypeIcon = index.parent() == QModelIndex();
|
bool showTypeIcon = index.parent() == QModelIndex();
|
||||||
bool showExpandableIcon = type == QmlConsoleItem::UndefinedType;
|
bool showExpandableIcon = type == ConsoleItem::UndefinedType;
|
||||||
|
|
||||||
QRect rect(level * view->indentation(), 0, width, 0);
|
QRect rect(level * view->indentation(), 0, width, 0);
|
||||||
ConsoleItemPositions positions(rect, opt.font, showTypeIcon, showExpandableIcon);
|
ConsoleItemPositions positions(rect, opt.font, showTypeIcon, showExpandableIcon);
|
||||||
@@ -320,7 +322,7 @@ void QmlConsoleItemDelegate::setModelData(QWidget *editor,
|
|||||||
{
|
{
|
||||||
QmlConsoleEdit *edtr = qobject_cast<QmlConsoleEdit *>(editor);
|
QmlConsoleEdit *edtr = qobject_cast<QmlConsoleEdit *>(editor);
|
||||||
model->setData(index, edtr->getCurrentScript(), Qt::DisplayRole);
|
model->setData(index, edtr->getCurrentScript(), Qt::DisplayRole);
|
||||||
model->setData(index, QmlConsoleItem::InputType, QmlConsoleItemModel::TypeRole);
|
model->setData(index, ConsoleItem::InputType, QmlConsoleItemModel::TypeRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlConsoleItemDelegate::updateEditorGeometry(QWidget *editor,
|
void QmlConsoleItemDelegate::updateEditorGeometry(QWidget *editor,
|
||||||
|
|||||||
@@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
|
|
||||||
|
using namespace QmlJS;
|
||||||
|
|
||||||
namespace QmlJSTools {
|
namespace QmlJSTools {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -45,7 +47,7 @@ namespace Internal {
|
|||||||
QmlConsoleItemModel::QmlConsoleItemModel(QObject *parent) :
|
QmlConsoleItemModel::QmlConsoleItemModel(QObject *parent) :
|
||||||
QAbstractItemModel(parent),
|
QAbstractItemModel(parent),
|
||||||
m_hasEditableRow(false),
|
m_hasEditableRow(false),
|
||||||
m_rootItem(new QmlConsoleItem(0)),
|
m_rootItem(new ConsoleItem(0)),
|
||||||
m_maxSizeOfFileName(0)
|
m_maxSizeOfFileName(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -60,14 +62,14 @@ void QmlConsoleItemModel::clear()
|
|||||||
beginResetModel();
|
beginResetModel();
|
||||||
reset();
|
reset();
|
||||||
delete m_rootItem;
|
delete m_rootItem;
|
||||||
m_rootItem = new QmlConsoleItem(0);
|
m_rootItem = new ConsoleItem(0);
|
||||||
endResetModel();
|
endResetModel();
|
||||||
|
|
||||||
if (m_hasEditableRow)
|
if (m_hasEditableRow)
|
||||||
appendEditableRow();
|
appendEditableRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlConsoleItemModel::appendItem(QmlConsoleItem *item, int position)
|
bool QmlConsoleItemModel::appendItem(ConsoleItem *item, int position)
|
||||||
{
|
{
|
||||||
if (position < 0)
|
if (position < 0)
|
||||||
position = m_rootItem->childCount() - 1;
|
position = m_rootItem->childCount() - 1;
|
||||||
@@ -82,10 +84,10 @@ bool QmlConsoleItemModel::appendItem(QmlConsoleItem *item, int position)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlConsoleItemModel::appendMessage(QmlConsoleItem::ItemType itemType,
|
bool QmlConsoleItemModel::appendMessage(ConsoleItem::ItemType itemType,
|
||||||
const QString &message, int position)
|
const QString &message, int position)
|
||||||
{
|
{
|
||||||
return appendItem(new QmlConsoleItem(m_rootItem, itemType, message), position);
|
return appendItem(new ConsoleItem(m_rootItem, itemType, message), position);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlConsoleItemModel::setHasEditableRow(bool hasEditableRow)
|
void QmlConsoleItemModel::setHasEditableRow(bool hasEditableRow)
|
||||||
@@ -107,13 +109,13 @@ bool QmlConsoleItemModel::hasEditableRow() const
|
|||||||
void QmlConsoleItemModel::appendEditableRow()
|
void QmlConsoleItemModel::appendEditableRow()
|
||||||
{
|
{
|
||||||
int position = m_rootItem->childCount();
|
int position = m_rootItem->childCount();
|
||||||
if (appendItem(new QmlConsoleItem(m_rootItem, QmlConsoleItem::InputType), position))
|
if (appendItem(new ConsoleItem(m_rootItem, ConsoleItem::InputType), position))
|
||||||
emit selectEditableRow(index(position, 0), QItemSelectionModel::ClearAndSelect);
|
emit selectEditableRow(index(position, 0), QItemSelectionModel::ClearAndSelect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlConsoleItemModel::removeEditableRow()
|
void QmlConsoleItemModel::removeEditableRow()
|
||||||
{
|
{
|
||||||
if (m_rootItem->child(m_rootItem->childCount() - 1)->itemType == QmlConsoleItem::InputType)
|
if (m_rootItem->child(m_rootItem->childCount() - 1)->itemType == ConsoleItem::InputType)
|
||||||
removeRow(m_rootItem->childCount() - 1);
|
removeRow(m_rootItem->childCount() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +150,7 @@ QVariant QmlConsoleItemModel::data(const QModelIndex &index, int role) const
|
|||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
QmlConsoleItem *item = getItem(index);
|
ConsoleItem *item = getItem(index);
|
||||||
|
|
||||||
if (role == Qt::DisplayRole )
|
if (role == Qt::DisplayRole )
|
||||||
return item->text();
|
return item->text();
|
||||||
@@ -170,9 +172,9 @@ QModelIndex QmlConsoleItemModel::index(int row, int column, const QModelIndex &p
|
|||||||
if (column > 0)
|
if (column > 0)
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
QmlConsoleItem *parentItem = getItem(parent);
|
ConsoleItem *parentItem = getItem(parent);
|
||||||
|
|
||||||
QmlConsoleItem *childItem = parentItem->child(row);
|
ConsoleItem *childItem = parentItem->child(row);
|
||||||
if (childItem)
|
if (childItem)
|
||||||
return createIndex(row, column, childItem);
|
return createIndex(row, column, childItem);
|
||||||
else
|
else
|
||||||
@@ -184,8 +186,8 @@ QModelIndex QmlConsoleItemModel::parent(const QModelIndex &index) const
|
|||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
QmlConsoleItem *childItem = getItem(index);
|
ConsoleItem *childItem = getItem(index);
|
||||||
QmlConsoleItem *parentItem = childItem->parent();
|
ConsoleItem *parentItem = childItem->parent();
|
||||||
|
|
||||||
if (parentItem == m_rootItem)
|
if (parentItem == m_rootItem)
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
@@ -197,7 +199,7 @@ QModelIndex QmlConsoleItemModel::parent(const QModelIndex &index) const
|
|||||||
|
|
||||||
int QmlConsoleItemModel::rowCount(const QModelIndex &parent) const
|
int QmlConsoleItemModel::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
QmlConsoleItem *parentItem = getItem(parent);
|
ConsoleItem *parentItem = getItem(parent);
|
||||||
|
|
||||||
return parentItem->childCount();
|
return parentItem->childCount();
|
||||||
}
|
}
|
||||||
@@ -212,7 +214,7 @@ Qt::ItemFlags QmlConsoleItemModel::flags(const QModelIndex &index) const
|
|||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
QmlConsoleItem *item = getItem(index);
|
ConsoleItem *item = getItem(index);
|
||||||
if (m_hasEditableRow && item->parent() == m_rootItem
|
if (m_hasEditableRow && item->parent() == m_rootItem
|
||||||
&& index.row() == m_rootItem->childCount() - 1)
|
&& index.row() == m_rootItem->childCount() - 1)
|
||||||
return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
return Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
@@ -221,13 +223,13 @@ Qt::ItemFlags QmlConsoleItemModel::flags(const QModelIndex &index) const
|
|||||||
|
|
||||||
bool QmlConsoleItemModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
bool QmlConsoleItemModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
{
|
{
|
||||||
QmlConsoleItem *item = getItem(index);
|
ConsoleItem *item = getItem(index);
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
item->setText(value.toString());
|
item->setText(value.toString());
|
||||||
result = true;
|
result = true;
|
||||||
} else if (role == QmlConsoleItemModel::TypeRole) {
|
} else if (role == QmlConsoleItemModel::TypeRole) {
|
||||||
item->itemType = (QmlConsoleItem::ItemType)value.toInt();
|
item->itemType = (ConsoleItem::ItemType)value.toInt();
|
||||||
result = true;
|
result = true;
|
||||||
} else if (role == QmlConsoleItemModel::FileRole) {
|
} else if (role == QmlConsoleItemModel::FileRole) {
|
||||||
item->file = value.toString();
|
item->file = value.toString();
|
||||||
@@ -245,7 +247,7 @@ bool QmlConsoleItemModel::setData(const QModelIndex &index, const QVariant &valu
|
|||||||
|
|
||||||
bool QmlConsoleItemModel::insertRows(int position, int rows, const QModelIndex &parent)
|
bool QmlConsoleItemModel::insertRows(int position, int rows, const QModelIndex &parent)
|
||||||
{
|
{
|
||||||
QmlConsoleItem *parentItem = getItem(parent);
|
ConsoleItem *parentItem = getItem(parent);
|
||||||
bool success;
|
bool success;
|
||||||
|
|
||||||
beginInsertRows(parent, position, position + rows - 1);
|
beginInsertRows(parent, position, position + rows - 1);
|
||||||
@@ -257,7 +259,7 @@ bool QmlConsoleItemModel::insertRows(int position, int rows, const QModelIndex &
|
|||||||
|
|
||||||
bool QmlConsoleItemModel::removeRows(int position, int rows, const QModelIndex &parent)
|
bool QmlConsoleItemModel::removeRows(int position, int rows, const QModelIndex &parent)
|
||||||
{
|
{
|
||||||
QmlConsoleItem *parentItem = getItem(parent);
|
ConsoleItem *parentItem = getItem(parent);
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
beginRemoveRows(parent, position, position + rows - 1);
|
beginRemoveRows(parent, position, position + rows - 1);
|
||||||
@@ -267,10 +269,10 @@ bool QmlConsoleItemModel::removeRows(int position, int rows, const QModelIndex &
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlConsoleItem *QmlConsoleItemModel::getItem(const QModelIndex &index) const
|
ConsoleItem *QmlConsoleItemModel::getItem(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
QmlConsoleItem *item = static_cast<QmlConsoleItem*>(index.internalPointer());
|
ConsoleItem *item = static_cast<ConsoleItem*>(index.internalPointer());
|
||||||
if (item)
|
if (item)
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
#ifndef QMLCONSOLEITEMMODEL_H
|
#ifndef QMLCONSOLEITEMMODEL_H
|
||||||
#define QMLCONSOLEITEMMODEL_H
|
#define QMLCONSOLEITEMMODEL_H
|
||||||
|
|
||||||
#include "qmlconsoleitem.h"
|
#include <qmljs/consoleitem.h>
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QItemSelectionModel>
|
#include <QItemSelectionModel>
|
||||||
@@ -53,8 +53,8 @@ public:
|
|||||||
void appendEditableRow();
|
void appendEditableRow();
|
||||||
void removeEditableRow();
|
void removeEditableRow();
|
||||||
|
|
||||||
bool appendItem(QmlConsoleItem *item, int position = -1);
|
bool appendItem(QmlJS::ConsoleItem *item, int position = -1);
|
||||||
bool appendMessage(QmlConsoleItem::ItemType itemType, const QString &message,
|
bool appendMessage(QmlJS::ConsoleItem::ItemType itemType, const QString &message,
|
||||||
int position = -1);
|
int position = -1);
|
||||||
|
|
||||||
QAbstractItemModel *model() { return this; }
|
QAbstractItemModel *model() { return this; }
|
||||||
@@ -64,7 +64,7 @@ public:
|
|||||||
int sizeOfFile(const QFont &font);
|
int sizeOfFile(const QFont &font);
|
||||||
int sizeOfLineNumber(const QFont &font);
|
int sizeOfLineNumber(const QFont &font);
|
||||||
|
|
||||||
QmlConsoleItem *root() const { return m_rootItem; }
|
QmlJS::ConsoleItem *root() const { return m_rootItem; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void clear();
|
void clear();
|
||||||
@@ -88,11 +88,11 @@ protected:
|
|||||||
bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
|
bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
|
||||||
bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex());
|
bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex());
|
||||||
|
|
||||||
QmlConsoleItem *getItem(const QModelIndex &index) const;
|
QmlJS::ConsoleItem *getItem(const QModelIndex &index) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_hasEditableRow;
|
bool m_hasEditableRow;
|
||||||
QmlConsoleItem *m_rootItem;
|
QmlJS::ConsoleItem *m_rootItem;
|
||||||
int m_maxSizeOfFileName;
|
int m_maxSizeOfFileName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -33,14 +33,14 @@
|
|||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
#include <debugger/debuggerengine.h>
|
#include <qmljs/iscriptevaluator.h>
|
||||||
|
|
||||||
#include <QScriptEngine>
|
#include <QScriptEngine>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
namespace QmlJSTools {
|
using namespace QmlJS;
|
||||||
|
|
||||||
QmlConsoleManager *QmlConsoleManager::m_instance = 0;
|
namespace QmlJSTools {
|
||||||
|
|
||||||
class QmlConsoleManagerPrivate
|
class QmlConsoleManagerPrivate
|
||||||
{
|
{
|
||||||
@@ -48,29 +48,26 @@ public:
|
|||||||
QScriptEngine *scriptEngine;
|
QScriptEngine *scriptEngine;
|
||||||
Internal::QmlConsoleItemModel *qmlConsoleItemModel;
|
Internal::QmlConsoleItemModel *qmlConsoleItemModel;
|
||||||
Internal::QmlConsolePane *qmlConsolePane;
|
Internal::QmlConsolePane *qmlConsolePane;
|
||||||
Debugger::DebuggerEngine *debuggerEngine;
|
QmlJS::IScriptEvaluator *scriptEvaluator;
|
||||||
};
|
};
|
||||||
|
|
||||||
QmlConsoleManager::QmlConsoleManager(QObject *parent)
|
QmlConsoleManager::QmlConsoleManager(QObject *parent)
|
||||||
: QObject(parent),
|
: ConsoleManagerInterface(parent),
|
||||||
d(new QmlConsoleManagerPrivate)
|
d(new QmlConsoleManagerPrivate)
|
||||||
{
|
{
|
||||||
m_instance = this;
|
|
||||||
d->scriptEngine = new QScriptEngine(this);
|
d->scriptEngine = new QScriptEngine(this);
|
||||||
d->qmlConsoleItemModel = new Internal::QmlConsoleItemModel(this);
|
d->qmlConsoleItemModel = new Internal::QmlConsoleItemModel(this);
|
||||||
d->qmlConsoleItemModel->setHasEditableRow(true);
|
d->qmlConsoleItemModel->setHasEditableRow(true);
|
||||||
d->qmlConsolePane = new Internal::QmlConsolePane(this);
|
d->qmlConsolePane = new Internal::QmlConsolePane(this);
|
||||||
|
d->scriptEvaluator = 0;
|
||||||
ExtensionSystem::PluginManager::addObject(d->qmlConsolePane);
|
ExtensionSystem::PluginManager::addObject(d->qmlConsolePane);
|
||||||
d->debuggerEngine = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlConsoleManager::~QmlConsoleManager()
|
QmlConsoleManager::~QmlConsoleManager()
|
||||||
{
|
{
|
||||||
if (d->qmlConsolePane) {
|
if (d->qmlConsolePane)
|
||||||
ExtensionSystem::PluginManager::removeObject(d->qmlConsolePane);
|
ExtensionSystem::PluginManager::removeObject(d->qmlConsolePane);
|
||||||
}
|
|
||||||
delete d;
|
delete d;
|
||||||
m_instance = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlConsoleManager::showConsolePane()
|
void QmlConsoleManager::showConsolePane()
|
||||||
@@ -79,15 +76,15 @@ void QmlConsoleManager::showConsolePane()
|
|||||||
d->qmlConsolePane->popup(Core::IOutputPane::ModeSwitch);
|
d->qmlConsolePane->popup(Core::IOutputPane::ModeSwitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlConsoleItem *QmlConsoleManager::rootItem() const
|
ConsoleItem *QmlConsoleManager::rootItem() const
|
||||||
{
|
{
|
||||||
return d->qmlConsoleItemModel->root();
|
return d->qmlConsoleItemModel->root();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlConsoleManager::setDebuggerEngine(Debugger::DebuggerEngine *debuggerEngine)
|
void QmlConsoleManager::setScriptEvaluator(QmlJS::IScriptEvaluator *scriptEvaluator)
|
||||||
{
|
{
|
||||||
d->debuggerEngine = debuggerEngine;
|
d->scriptEvaluator = scriptEvaluator;
|
||||||
if (!debuggerEngine)
|
if (!scriptEvaluator)
|
||||||
setContext(QString());
|
setContext(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,23 +93,23 @@ void QmlConsoleManager::setContext(const QString &context)
|
|||||||
d->qmlConsolePane->setContext(context);
|
d->qmlConsolePane->setContext(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlConsoleManager::printToConsolePane(QmlConsoleItem::ItemType itemType,
|
void QmlConsoleManager::printToConsolePane(ConsoleItem::ItemType itemType,
|
||||||
const QString &text, bool bringToForeground)
|
const QString &text, bool bringToForeground)
|
||||||
{
|
{
|
||||||
if (!d->qmlConsolePane)
|
if (!d->qmlConsolePane)
|
||||||
return;
|
return;
|
||||||
if (itemType == QmlConsoleItem::ErrorType)
|
if (itemType == ConsoleItem::ErrorType)
|
||||||
bringToForeground = true;
|
bringToForeground = true;
|
||||||
if (bringToForeground)
|
if (bringToForeground)
|
||||||
d->qmlConsolePane->popup(Core::IOutputPane::ModeSwitch);
|
d->qmlConsolePane->popup(Core::IOutputPane::ModeSwitch);
|
||||||
d->qmlConsoleItemModel->appendMessage(itemType, text);
|
d->qmlConsoleItemModel->appendMessage(itemType, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlConsoleManager::printToConsolePane(QmlConsoleItem *item, bool bringToForeground)
|
void QmlConsoleManager::printToConsolePane(ConsoleItem *item, bool bringToForeground)
|
||||||
{
|
{
|
||||||
if (!d->qmlConsolePane)
|
if (!d->qmlConsolePane)
|
||||||
return;
|
return;
|
||||||
if (item->itemType == QmlConsoleItem::ErrorType)
|
if (item->itemType == ConsoleItem::ErrorType)
|
||||||
bringToForeground = true;
|
bringToForeground = true;
|
||||||
if (bringToForeground)
|
if (bringToForeground)
|
||||||
d->qmlConsolePane->popup(Core::IOutputPane::ModeSwitch);
|
d->qmlConsolePane->popup(Core::IOutputPane::ModeSwitch);
|
||||||
@@ -121,13 +118,13 @@ void QmlConsoleManager::printToConsolePane(QmlConsoleItem *item, bool bringToFor
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
QmlConsoleItem *constructLogItemTree(QmlConsoleItem *parent, const QVariant &result,
|
ConsoleItem *constructLogItemTree(ConsoleItem *parent, const QVariant &result,
|
||||||
const QString &key = QString())
|
const QString &key = QString())
|
||||||
{
|
{
|
||||||
if (!result.isValid())
|
if (!result.isValid())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
QmlConsoleItem *item = new QmlConsoleItem(parent);
|
ConsoleItem *item = new ConsoleItem(parent);
|
||||||
if (result.type() == QVariant::Map) {
|
if (result.type() == QVariant::Map) {
|
||||||
if (key.isEmpty())
|
if (key.isEmpty())
|
||||||
item->setText(QLatin1String("Object"));
|
item->setText(QLatin1String("Object"));
|
||||||
@@ -137,7 +134,7 @@ QmlConsoleItem *constructLogItemTree(QmlConsoleItem *parent, const QVariant &res
|
|||||||
QMapIterator<QString, QVariant> i(result.toMap());
|
QMapIterator<QString, QVariant> i(result.toMap());
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
i.next();
|
i.next();
|
||||||
QmlConsoleItem *child = constructLogItemTree(item, i.value(), i.key());
|
ConsoleItem *child = constructLogItemTree(item, i.value(), i.key());
|
||||||
if (child)
|
if (child)
|
||||||
item->insertChild(child, true);
|
item->insertChild(child, true);
|
||||||
}
|
}
|
||||||
@@ -148,7 +145,7 @@ QmlConsoleItem *constructLogItemTree(QmlConsoleItem *parent, const QVariant &res
|
|||||||
item->setText(QString(QLatin1String("[%1] : List")).arg(key));
|
item->setText(QString(QLatin1String("[%1] : List")).arg(key));
|
||||||
QVariantList resultList = result.toList();
|
QVariantList resultList = result.toList();
|
||||||
for (int i = 0; i < resultList.count(); i++) {
|
for (int i = 0; i < resultList.count(); i++) {
|
||||||
QmlConsoleItem *child = constructLogItemTree(item, resultList.at(i),
|
ConsoleItem *child = constructLogItemTree(item, resultList.at(i),
|
||||||
QString::number(i));
|
QString::number(i));
|
||||||
if (child)
|
if (child)
|
||||||
item->insertChild(child, true);
|
item->insertChild(child, true);
|
||||||
@@ -164,7 +161,7 @@ QmlConsoleItem *constructLogItemTree(QmlConsoleItem *parent, const QVariant &res
|
|||||||
|
|
||||||
QmlConsoleItemModel *QmlConsoleModel::qmlConsoleItemModel()
|
QmlConsoleItemModel *QmlConsoleModel::qmlConsoleItemModel()
|
||||||
{
|
{
|
||||||
QmlConsoleManager *manager = QmlConsoleManager::instance();
|
QmlConsoleManager *manager = qobject_cast<QmlConsoleManager *>(QmlConsoleManager::instance());
|
||||||
if (manager)
|
if (manager)
|
||||||
return manager->d->qmlConsoleItemModel;
|
return manager->d->qmlConsoleItemModel;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -172,15 +169,15 @@ QmlConsoleItemModel *QmlConsoleModel::qmlConsoleItemModel()
|
|||||||
|
|
||||||
void QmlConsoleModel::evaluate(const QString &expression)
|
void QmlConsoleModel::evaluate(const QString &expression)
|
||||||
{
|
{
|
||||||
QmlConsoleManager *manager = QmlConsoleManager::instance();
|
QmlConsoleManager *manager = qobject_cast<QmlConsoleManager *>(QmlConsoleManager::instance());
|
||||||
if (manager) {
|
if (manager) {
|
||||||
if (manager->d->debuggerEngine) {
|
if (manager->d->scriptEvaluator) {
|
||||||
QmlConsoleModel::qmlConsoleItemModel()->appendEditableRow();
|
QmlConsoleModel::qmlConsoleItemModel()->appendEditableRow();
|
||||||
manager->d->debuggerEngine->evaluateScriptExpression(expression);
|
manager->d->scriptEvaluator->evaluateScript(expression);
|
||||||
} else {
|
} else {
|
||||||
QVariant result = manager->d->scriptEngine->evaluate(expression).toVariant();
|
QVariant result = manager->d->scriptEngine->evaluate(expression).toVariant();
|
||||||
QmlConsoleItem *root = manager->rootItem();
|
ConsoleItem *root = manager->rootItem();
|
||||||
QmlConsoleItem *item = constructLogItemTree(root, result);
|
ConsoleItem *item = constructLogItemTree(root, result);
|
||||||
if (item) {
|
if (item) {
|
||||||
QmlConsoleModel::qmlConsoleItemModel()->appendEditableRow();
|
QmlConsoleModel::qmlConsoleItemModel()->appendEditableRow();
|
||||||
manager->printToConsolePane(item);
|
manager->printToConsolePane(item);
|
||||||
|
|||||||
@@ -31,12 +31,13 @@
|
|||||||
#define QMLCONSOLEMANAGER_H
|
#define QMLCONSOLEMANAGER_H
|
||||||
|
|
||||||
#include "qmljstools_global.h"
|
#include "qmljstools_global.h"
|
||||||
#include "qmlconsoleitem.h"
|
|
||||||
|
#include <qmljs/consolemanagerinterface.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace Debugger {
|
namespace QmlJS {
|
||||||
class DebuggerEngine;
|
class IScriptEvaluator;
|
||||||
}
|
}
|
||||||
namespace QmlJSTools {
|
namespace QmlJSTools {
|
||||||
|
|
||||||
@@ -46,29 +47,26 @@ class QmlConsoleModel;
|
|||||||
}
|
}
|
||||||
|
|
||||||
class QmlConsoleManagerPrivate;
|
class QmlConsoleManagerPrivate;
|
||||||
class QMLJSTOOLS_EXPORT QmlConsoleManager : public QObject
|
class QMLJSTOOLS_EXPORT QmlConsoleManager : public QmlJS::ConsoleManagerInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
QmlConsoleManager(QObject *parent);
|
QmlConsoleManager(QObject *parent);
|
||||||
~QmlConsoleManager();
|
~QmlConsoleManager();
|
||||||
|
|
||||||
static QmlConsoleManager *instance() { return m_instance; }
|
|
||||||
|
|
||||||
void showConsolePane();
|
void showConsolePane();
|
||||||
|
|
||||||
QmlConsoleItem *rootItem() const;
|
QmlJS::ConsoleItem *rootItem() const;
|
||||||
|
|
||||||
void setDebuggerEngine(Debugger::DebuggerEngine *debuggerEngine);
|
void setScriptEvaluator(QmlJS::IScriptEvaluator *scriptEvaluator);
|
||||||
void setContext(const QString &context);
|
void setContext(const QString &context);
|
||||||
|
|
||||||
void printToConsolePane(QmlConsoleItem::ItemType itemType, const QString &text,
|
void printToConsolePane(QmlJS::ConsoleItem::ItemType itemType, const QString &text,
|
||||||
bool bringToForeground = false);
|
bool bringToForeground = false);
|
||||||
void printToConsolePane(QmlConsoleItem *item, bool bringToForeground = false);
|
void printToConsolePane(QmlJS::ConsoleItem *item, bool bringToForeground = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QmlConsoleManagerPrivate *d;
|
QmlConsoleManagerPrivate *d;
|
||||||
static QmlConsoleManager *m_instance;
|
|
||||||
friend class Internal::QmlConsoleModel;
|
friend class Internal::QmlConsoleModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -30,31 +30,33 @@
|
|||||||
#include "qmlconsoleproxymodel.h"
|
#include "qmlconsoleproxymodel.h"
|
||||||
#include "qmlconsoleitemmodel.h"
|
#include "qmlconsoleitemmodel.h"
|
||||||
|
|
||||||
|
using namespace QmlJS;
|
||||||
|
|
||||||
namespace QmlJSTools {
|
namespace QmlJSTools {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
QmlConsoleProxyModel::QmlConsoleProxyModel(QObject *parent) :
|
QmlConsoleProxyModel::QmlConsoleProxyModel(QObject *parent) :
|
||||||
QSortFilterProxyModel(parent),
|
QSortFilterProxyModel(parent),
|
||||||
m_filter(QmlConsoleItem::DefaultTypes)
|
m_filter(ConsoleItem::DefaultTypes)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlConsoleProxyModel::setShowLogs(bool show)
|
void QmlConsoleProxyModel::setShowLogs(bool show)
|
||||||
{
|
{
|
||||||
m_filter = show ? m_filter | QmlConsoleItem::DebugType : m_filter & ~QmlConsoleItem::DebugType;
|
m_filter = show ? m_filter | ConsoleItem::DebugType : m_filter & ~ConsoleItem::DebugType;
|
||||||
setFilterRegExp(QString());
|
setFilterRegExp(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlConsoleProxyModel::setShowWarnings(bool show)
|
void QmlConsoleProxyModel::setShowWarnings(bool show)
|
||||||
{
|
{
|
||||||
m_filter = show ? m_filter | QmlConsoleItem::WarningType
|
m_filter = show ? m_filter | ConsoleItem::WarningType
|
||||||
: m_filter & ~QmlConsoleItem::WarningType;
|
: m_filter & ~ConsoleItem::WarningType;
|
||||||
setFilterRegExp(QString());
|
setFilterRegExp(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlConsoleProxyModel::setShowErrors(bool show)
|
void QmlConsoleProxyModel::setShowErrors(bool show)
|
||||||
{
|
{
|
||||||
m_filter = show ? m_filter | QmlConsoleItem::ErrorType : m_filter & ~QmlConsoleItem::ErrorType;
|
m_filter = show ? m_filter | ConsoleItem::ErrorType : m_filter & ~ConsoleItem::ErrorType;
|
||||||
setFilterRegExp(QString());
|
setFilterRegExp(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +70,7 @@ bool QmlConsoleProxyModel::filterAcceptsRow(int sourceRow,
|
|||||||
const QModelIndex &sourceParent) const
|
const QModelIndex &sourceParent) const
|
||||||
{
|
{
|
||||||
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||||
return m_filter.testFlag((QmlConsoleItem::ItemType)sourceModel()->data(
|
return m_filter.testFlag((ConsoleItem::ItemType)sourceModel()->data(
|
||||||
index, QmlConsoleItemModel::TypeRole).toInt());
|
index, QmlConsoleItemModel::TypeRole).toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
#ifndef QMLCONSOLEPROXYMODEL_H
|
#ifndef QMLCONSOLEPROXYMODEL_H
|
||||||
#define QMLCONSOLEPROXYMODEL_H
|
#define QMLCONSOLEPROXYMODEL_H
|
||||||
|
|
||||||
#include "qmlconsoleitem.h"
|
#include <qmljs/consoleitem.h>
|
||||||
|
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QItemSelectionModel>
|
#include <QItemSelectionModel>
|
||||||
@@ -61,7 +61,7 @@ protected:
|
|||||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
|
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QFlags<QmlConsoleItem::ItemType> m_filter;
|
QFlags<QmlJS::ConsoleItem::ItemType> m_filter;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
|
|||||||
@@ -43,6 +43,8 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
|
||||||
|
using namespace QmlJS;
|
||||||
|
|
||||||
namespace QmlJSTools {
|
namespace QmlJSTools {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -117,10 +119,10 @@ void QmlConsoleView::mousePressEvent(QMouseEvent *event)
|
|||||||
QPoint pos = event->pos();
|
QPoint pos = event->pos();
|
||||||
QModelIndex index = indexAt(pos);
|
QModelIndex index = indexAt(pos);
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
QmlConsoleItem::ItemType type = (QmlConsoleItem::ItemType)index.data(
|
ConsoleItem::ItemType type = (ConsoleItem::ItemType)index.data(
|
||||||
QmlConsoleItemModel::TypeRole).toInt();
|
QmlConsoleItemModel::TypeRole).toInt();
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
if (type == QmlConsoleItem::UndefinedType) {
|
if (type == ConsoleItem::UndefinedType) {
|
||||||
bool showTypeIcon = index.parent() == QModelIndex();
|
bool showTypeIcon = index.parent() == QModelIndex();
|
||||||
ConsoleItemPositions positions(visualRect(index), viewOptions().font, showTypeIcon,
|
ConsoleItemPositions positions(visualRect(index), viewOptions().font, showTypeIcon,
|
||||||
true);
|
true);
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ HEADERS += \
|
|||||||
$$PWD/qmljssemanticinfo.h \
|
$$PWD/qmljssemanticinfo.h \
|
||||||
$$PWD/qmljstools_global.h \
|
$$PWD/qmljstools_global.h \
|
||||||
$$PWD/qmlconsolemanager.h \
|
$$PWD/qmlconsolemanager.h \
|
||||||
$$PWD/qmlconsoleitem.h \
|
|
||||||
$$PWD/qmlconsoleitemmodel.h \
|
$$PWD/qmlconsoleitemmodel.h \
|
||||||
$$PWD/qmlconsolepane.h \
|
$$PWD/qmlconsolepane.h \
|
||||||
$$PWD/qmlconsoleview.h \
|
$$PWD/qmlconsoleview.h \
|
||||||
@@ -54,7 +53,6 @@ SOURCES += \
|
|||||||
$$PWD/qmljsfindexportedcpptypes.cpp \
|
$$PWD/qmljsfindexportedcpptypes.cpp \
|
||||||
$$PWD/qmljssemanticinfo.cpp \
|
$$PWD/qmljssemanticinfo.cpp \
|
||||||
$$PWD/qmlconsolemanager.cpp \
|
$$PWD/qmlconsolemanager.cpp \
|
||||||
$$PWD/qmlconsoleitem.cpp \
|
|
||||||
$$PWD/qmlconsoleitemmodel.cpp \
|
$$PWD/qmlconsoleitemmodel.cpp \
|
||||||
$$PWD/qmlconsolepane.cpp \
|
$$PWD/qmlconsolepane.cpp \
|
||||||
$$PWD/qmlconsoleview.cpp \
|
$$PWD/qmlconsoleview.cpp \
|
||||||
|
|||||||
@@ -55,8 +55,6 @@ QtcPlugin {
|
|||||||
"qmljstoolssettings.h",
|
"qmljstoolssettings.h",
|
||||||
"qmlconsolemanager.cpp",
|
"qmlconsolemanager.cpp",
|
||||||
"qmlconsolemanager.h",
|
"qmlconsolemanager.h",
|
||||||
"qmlconsoleitem.cpp",
|
|
||||||
"qmlconsoleitem.h",
|
|
||||||
"qmlconsoleitemmodel.cpp",
|
"qmlconsoleitemmodel.cpp",
|
||||||
"qmlconsoleitemmodel.h",
|
"qmlconsoleitemmodel.h",
|
||||||
"qmlconsolepane.cpp",
|
"qmlconsolepane.cpp",
|
||||||
|
|||||||
Reference in New Issue
Block a user