Commit fe1cf36e authored by Kai Koehne's avatar Kai Koehne Committed by hjk

Remove support for debugging JS with Qt 4.7

Remove infrastructure to debug/inspect QML applications with Qt 4.7.

Change-Id: I277e9884e009475a29017f502bbe1d069317460f
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 9b3ab11f
......@@ -1183,18 +1183,6 @@
d.putSubItem("value", value)
\endcode
\section1 Debugging Helpers for QML
The debugging helpers for QML provide you with code completion for custom modules
(\c qmldump) and debugging Qt Quick UI projects (\c qmlobserver).
You have to build the QML Inspector once for each Qt version that you want
to debug
with. Select \gui{Tools > Options > Build & Run > Qt Versions}.
\note QML Inspector requires Qt 4.7.1 or later.
\section1 Enabling Debugging Helpers for Qt's Bootstrapped Applications
Qt's bootstrapped applications (such as moc and qmake) are built in a way
......
......@@ -30,12 +30,7 @@
\title Debugging Qt Quick Projects
\note You need Qt 4.7.1 or later to debug Qt Quick projects. Debugging
projects not created with the Qt Quick wizards is only supported with
Qt 4.8, or later.
To debug Qt Quick applications running on devices, you must install
Qt 4.7.4, or later, libraries on devices.
\note You need Qt 4.8 or later to debug Qt Quick projects.
For an example of how to debug Qt Quick Projects, see
\l{Debugging a Qt Quick Example Application}.
......
......@@ -50,12 +50,8 @@
\li qtc-debugging-helper
\li qtc-qmldbg
\li qtc-qmldump
\li qtc-qmlobserver
\endlist
The location depends on the platform. On Linux and other Unix platforms, the files
......
/****************************************************************************
**
** Copyright (C) 2013 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 "abstractliveedittool.h"
#include "qdeclarativeviewinspector.h"
#include "../qdeclarativeviewinspector_p.h"
#include <QDeclarativeEngine>
#include <QDebug>
#include <QGraphicsItem>
#include <QDeclarativeItem>
namespace QmlJSDebugger {
AbstractLiveEditTool::AbstractLiveEditTool(QDeclarativeViewInspector *editorView)
: QObject(editorView), m_inspector(editorView)
{
}
AbstractLiveEditTool::~AbstractLiveEditTool()
{
}
QDeclarativeViewInspector *AbstractLiveEditTool::inspector() const
{
return m_inspector;
}
QDeclarativeView *AbstractLiveEditTool::view() const
{
return m_inspector->declarativeView();
}
QGraphicsScene* AbstractLiveEditTool::scene() const
{
return view()->scene();
}
void AbstractLiveEditTool::updateSelectedItems()
{
selectedItemsChanged(items());
}
QList<QGraphicsItem*> AbstractLiveEditTool::items() const
{
return inspector()->selectedItems();
}
bool AbstractLiveEditTool::topItemIsMovable(const QList<QGraphicsItem*> & itemList)
{
QGraphicsItem *firstSelectableItem = topMovableGraphicsItem(itemList);
if (firstSelectableItem == 0)
return false;
if (toQDeclarativeItem(firstSelectableItem) != 0)
return true;
return false;
}
bool AbstractLiveEditTool::topSelectedItemIsMovable(const QList<QGraphicsItem*> &itemList)
{
QList<QGraphicsItem*> selectedItems = inspector()->selectedItems();
foreach (QGraphicsItem *item, itemList) {
QDeclarativeItem *declarativeItem = toQDeclarativeItem(item);
if (declarativeItem
&& selectedItems.contains(declarativeItem)
/*&& (declarativeItem->qmlItemNode().hasShowContent() || selectNonContentItems)*/)
return true;
}
return false;
}
bool AbstractLiveEditTool::topItemIsResizeHandle(const QList<QGraphicsItem*> &/*itemList*/)
{
return false;
}
QDeclarativeItem *AbstractLiveEditTool::toQDeclarativeItem(QGraphicsItem *item)
{
return qobject_cast<QDeclarativeItem*>(item->toGraphicsObject());
}
QGraphicsItem *AbstractLiveEditTool::topMovableGraphicsItem(const QList<QGraphicsItem*> &itemList)
{
foreach (QGraphicsItem *item, itemList) {
if (item->flags().testFlag(QGraphicsItem::ItemIsMovable))
return item;
}
return 0;
}
QDeclarativeItem *AbstractLiveEditTool::topMovableDeclarativeItem(const QList<QGraphicsItem*>
&itemList)
{
foreach (QGraphicsItem *item, itemList) {
QDeclarativeItem *declarativeItem = toQDeclarativeItem(item);
if (declarativeItem /*&& (declarativeItem->qmlItemNode().hasShowContent())*/)
return declarativeItem;
}
return 0;
}
QList<QGraphicsObject*> AbstractLiveEditTool::toGraphicsObjectList(const QList<QGraphicsItem*>
&itemList)
{
QList<QGraphicsObject*> gfxObjects;
foreach (QGraphicsItem *item, itemList) {
QGraphicsObject *obj = item->toGraphicsObject();
if (obj)
gfxObjects << obj;
}
return gfxObjects;
}
QString AbstractLiveEditTool::titleForItem(QGraphicsItem *item)
{
QString className("QGraphicsItem");
QString objectStringId;
QString constructedName;
QGraphicsObject *gfxObject = item->toGraphicsObject();
if (gfxObject) {
className = gfxObject->metaObject()->className();
className.remove(QRegExp("_QMLTYPE_\\d+"));
className.remove(QRegExp("_QML_\\d+"));
if (className.startsWith(QLatin1String("QDeclarative")))
className = className.remove(QLatin1String("QDeclarative"));
QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem*>(gfxObject);
if (declarativeItem) {
objectStringId = QDeclarativeViewInspector::idStringForObject(declarativeItem);
}
if (!objectStringId.isEmpty()) {
constructedName = objectStringId + " (" + className + QLatin1Char(')');
} else {
if (!gfxObject->objectName().isEmpty()) {
constructedName = gfxObject->objectName() + " (" + className + QLatin1Char(')');
} else {
constructedName = className;
}
}
}
return constructedName;
}
} // namespace QmlJSDebugger
/****************************************************************************
**
** Copyright (C) 2013 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 ABSTRACTLIVEEDITTOOL_H
#define ABSTRACTLIVEEDITTOOL_H
#include <QList>
#include <QObject>
QT_BEGIN_NAMESPACE
class QMouseEvent;
class QGraphicsItem;
class QDeclarativeItem;
class QKeyEvent;
class QGraphicsScene;
class QGraphicsObject;
class QWheelEvent;
class QDeclarativeView;
QT_END_NAMESPACE
namespace QmlJSDebugger {
class QDeclarativeViewInspector;
class FormEditorView;
class AbstractLiveEditTool : public QObject
{
Q_OBJECT
public:
AbstractLiveEditTool(QDeclarativeViewInspector *inspector);
virtual ~AbstractLiveEditTool();
virtual void mousePressEvent(QMouseEvent *event) = 0;
virtual void mouseMoveEvent(QMouseEvent *event) = 0;
virtual void mouseReleaseEvent(QMouseEvent *event) = 0;
virtual void mouseDoubleClickEvent(QMouseEvent *event) = 0;
virtual void hoverMoveEvent(QMouseEvent *event) = 0;
virtual void wheelEvent(QWheelEvent *event) = 0;
virtual void keyPressEvent(QKeyEvent *event) = 0;
virtual void keyReleaseEvent(QKeyEvent *keyEvent) = 0;
virtual void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList) = 0;
virtual void clear() = 0;
void updateSelectedItems();
QList<QGraphicsItem*> items() const;
void enterContext(QGraphicsItem *itemToEnter);
bool topItemIsMovable(const QList<QGraphicsItem*> &itemList);
bool topItemIsResizeHandle(const QList<QGraphicsItem*> &itemList);
bool topSelectedItemIsMovable(const QList<QGraphicsItem*> &itemList);
static QString titleForItem(QGraphicsItem *item);
static QList<QGraphicsObject*> toGraphicsObjectList(const QList<QGraphicsItem*> &itemList);
static QGraphicsItem* topMovableGraphicsItem(const QList<QGraphicsItem*> &itemList);
static QDeclarativeItem* topMovableDeclarativeItem(const QList<QGraphicsItem*> &itemList);
static QDeclarativeItem *toQDeclarativeItem(QGraphicsItem *item);
protected:
virtual void selectedItemsChanged(const QList<QGraphicsItem*> &objectList) = 0;
QDeclarativeViewInspector *inspector() const;
QDeclarativeView *view() const;
QGraphicsScene *scene() const;
private:
QDeclarativeViewInspector *m_inspector;
QList<QGraphicsItem*> m_itemList;
};
}
#endif // ABSTRACTLIVEEDITTOOL_H
/****************************************************************************
**
** Copyright (C) 2013 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 "boundingrecthighlighter.h"
#include "qdeclarativeviewinspector.h"
#include "qmlinspectorconstants.h"
#include <QGraphicsPolygonItem>
#include <QTimer>
#include <QObject>
#include <QDebug>
namespace QmlJSDebugger {
BoundingBox::BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem,
QObject *parent)
: QObject(parent),
highlightedObject(itemToHighlight),
highlightPolygon(0),
highlightPolygonEdge(0)
{
highlightPolygon = new BoundingBoxPolygonItem(parentItem);
highlightPolygonEdge = new BoundingBoxPolygonItem(parentItem);
highlightPolygon->setPen(QPen(QColor(0, 22, 159)));
highlightPolygonEdge->setPen(QPen(QColor(158, 199, 255)));
highlightPolygon->setFlag(QGraphicsItem::ItemIsSelectable, false);
highlightPolygonEdge->setFlag(QGraphicsItem::ItemIsSelectable, false);
}
BoundingBox::~BoundingBox()
{
highlightedObject.clear();
}
BoundingBoxPolygonItem::BoundingBoxPolygonItem(QGraphicsItem *item) : QGraphicsPolygonItem(item)
{
QPen pen;
pen.setColor(QColor(108, 141, 221));
pen.setWidth(1);
setPen(pen);
}
int BoundingBoxPolygonItem::type() const
{
return Constants::EditorItemType;
}
BoundingRectHighlighter::BoundingRectHighlighter(QDeclarativeViewInspector *view) :
LiveLayerItem(view->declarativeView()->scene()),
m_view(view)
{
}
BoundingRectHighlighter::~BoundingRectHighlighter()
{
}
void BoundingRectHighlighter::clear()
{
foreach (BoundingBox *box, m_boxes)
freeBoundingBox(box);
}
BoundingBox *BoundingRectHighlighter::boxFor(QGraphicsObject *item) const
{
foreach (BoundingBox *box, m_boxes) {
if (box->highlightedObject.data() == item)
return box;
}
return 0;
}
void BoundingRectHighlighter::highlight(QList<QGraphicsObject*> items)
{
if (items.isEmpty())
return;
QList<BoundingBox *> newBoxes;
foreach (QGraphicsObject *itemToHighlight, items) {
BoundingBox *box = boxFor(itemToHighlight);
if (!box)
box = createBoundingBox(itemToHighlight);
newBoxes << box;
}
qSort(newBoxes);
if (newBoxes != m_boxes) {
clear();
m_boxes << newBoxes;
}
highlightAll();
}
void BoundingRectHighlighter::highlight(QGraphicsObject* itemToHighlight)
{
if (!itemToHighlight)
return;
BoundingBox *box = boxFor(itemToHighlight);
if (!box) {
box = createBoundingBox(itemToHighlight);
m_boxes << box;
qSort(m_boxes);
}
highlightAll();
}
BoundingBox *BoundingRectHighlighter::createBoundingBox(QGraphicsObject *itemToHighlight)
{
if (!m_freeBoxes.isEmpty()) {
BoundingBox *box = m_freeBoxes.last();
if (box->highlightedObject.isNull()) {
box->highlightedObject = itemToHighlight;
box->highlightPolygon->show();
box->highlightPolygonEdge->show();
m_freeBoxes.removeLast();
return box;
}
}
BoundingBox *box = new BoundingBox(itemToHighlight, this, this);
connect(itemToHighlight, SIGNAL(xChanged()), this, SLOT(refresh()));
connect(itemToHighlight, SIGNAL(yChanged()), this, SLOT(refresh()));
connect(itemToHighlight, SIGNAL(widthChanged()), this, SLOT(refresh()));
connect(itemToHighlight, SIGNAL(heightChanged()), this, SLOT(refresh()));
connect(itemToHighlight, SIGNAL(rotationChanged()), this, SLOT(refresh()));
connect(itemToHighlight, SIGNAL(destroyed(QObject*)), this, SLOT(itemDestroyed(QObject*)));
return box;
}
void BoundingRectHighlighter::removeBoundingBox(BoundingBox *box)
{
delete box;
box = 0;
}
void BoundingRectHighlighter::freeBoundingBox(BoundingBox *box)
{
if (!box->highlightedObject.isNull()) {
disconnect(box->highlightedObject.data(), SIGNAL(xChanged()), this, SLOT(refresh()));
disconnect(box->highlightedObject.data(), SIGNAL(yChanged()), this, SLOT(refresh()));
disconnect(box->highlightedObject.data(), SIGNAL(widthChanged()), this, SLOT(refresh()));
disconnect(box->highlightedObject.data(), SIGNAL(heightChanged()), this, SLOT(refresh()));
disconnect(box->highlightedObject.data(), SIGNAL(rotationChanged()), this, SLOT(refresh()));
}
box->highlightedObject.clear();
box->highlightPolygon->hide();
box->highlightPolygonEdge->hide();
m_boxes.removeOne(box);
m_freeBoxes << box;
}
void BoundingRectHighlighter::itemDestroyed(QObject *obj)
{
foreach (BoundingBox *box, m_boxes) {
if (box->highlightedObject.data() == obj) {
freeBoundingBox(box);
break;
}
}
}
void BoundingRectHighlighter::highlightAll()
{
foreach (BoundingBox *box, m_boxes) {
Q_ASSERT(box);
if (box->highlightedObject.isNull()) {
// clear all highlights
clear();
return;
}
QGraphicsObject *item = box->highlightedObject.data();
QRectF boundingRectInSceneSpace(item->mapToScene(item->boundingRect()).boundingRect());
QRectF boundingRectInLayerItemSpace = mapRectFromScene(boundingRectInSceneSpace);
QRectF bboxRect = m_view->adjustToScreenBoundaries(boundingRectInLayerItemSpace);
QRectF edgeRect = bboxRect;
edgeRect.adjust(-1, -1, 1, 1);
box->highlightPolygon->setPolygon(QPolygonF(bboxRect));
box->highlightPolygonEdge->setPolygon(QPolygonF(edgeRect));
}
}
void BoundingRectHighlighter::refresh()
{
if (!m_boxes.isEmpty())
highlightAll();
}
} // namespace QmlJSDebugger
/****************************************************************************