From 335f6ad0f7f81a2bd928346d30949bee646cebe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Mon, 30 May 2011 16:32:25 +0200 Subject: QmlJSInspector: Renamed Observer to Inspector Manually redid Qt 4.8 commit 206ebd5af21d94c3f3b49d2cb645105a63e6f5fb, to make future code synchronization easier. In order not to have to change the QmlApplicationViewer again, a compatibility class QDeclarativeViewObserver is retained that subclasses QDeclarativeViewInspector. Change-Id: Ief87ae2f8f76b1db0c9d65085e4832424b277603 Reviewed-on: http://codereview.qt.nokia.com/242 Reviewed-by: Qt Sanity Bot Reviewed-by: Kai Koehne --- .../include/qdeclarativeinspectorservice.h | 105 ++++++++++++++++++ .../include/qdeclarativeobserverservice.h | 105 ------------------ .../include/qdeclarativeviewinspector.h | 120 +++++++++++++++++++++ .../include/qdeclarativeviewobserver.h | 81 ++------------ .../qmljsdebugger/include/qmlinspectorconstants.h | 71 ++++++++++++ .../qmljsdebugger/include/qmlobserverconstants.h | 71 ------------ 6 files changed, 303 insertions(+), 250 deletions(-) create mode 100644 share/qtcreator/qml/qmljsdebugger/include/qdeclarativeinspectorservice.h delete mode 100644 share/qtcreator/qml/qmljsdebugger/include/qdeclarativeobserverservice.h create mode 100644 share/qtcreator/qml/qmljsdebugger/include/qdeclarativeviewinspector.h create mode 100644 share/qtcreator/qml/qmljsdebugger/include/qmlinspectorconstants.h delete mode 100644 share/qtcreator/qml/qmljsdebugger/include/qmlobserverconstants.h (limited to 'share/qtcreator/qml/qmljsdebugger/include') diff --git a/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeinspectorservice.h b/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeinspectorservice.h new file mode 100644 index 0000000000..c28f0b50ba --- /dev/null +++ b/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeinspectorservice.h @@ -0,0 +1,105 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +**************************************************************************/ + +#ifndef QDECLARATIVEDESIGNDEBUGSERVER_H +#define QDECLARATIVEDESIGNDEBUGSERVER_H + +#include "qt_private/qdeclarativedebugservice_p.h" +#include "qmlinspectorconstants.h" +#include "qmljsdebugger_global.h" + +#include + +QT_FORWARD_DECLARE_CLASS(QColor) +QT_FORWARD_DECLARE_CLASS(QDeclarativeEngine) +QT_FORWARD_DECLARE_CLASS(QDeclarativeContext) +QT_FORWARD_DECLARE_CLASS(QDeclarativeWatcher) +QT_FORWARD_DECLARE_CLASS(QDataStream) + +namespace QmlJSDebugger { + +class QMLJSDEBUGGER_EXPORT QDeclarativeInspectorService : public QDeclarativeDebugService +{ + Q_OBJECT +public: + QDeclarativeInspectorService(); + static QDeclarativeInspectorService *instance(); + + void setDesignModeBehavior(bool inDesignMode); + void setCurrentObjects(QList items); + void setAnimationSpeed(qreal slowDownFactor); + void setAnimationPaused(bool paused); + void setCurrentTool(QmlJSDebugger::Constants::DesignTool toolId); + void reloaded(); + void setShowAppOnTop(bool showAppOnTop); + + QString idStringForObject(QObject *obj) const; + + void sendMessage(const QByteArray &message); + +public Q_SLOTS: + void selectedColorChanged(const QColor &color); + +Q_SIGNALS: + void debuggingClientChanged(bool hasDebuggingClient); + + void currentObjectsChanged(const QList &objects); + void designModeBehaviorChanged(bool inDesignMode); + void showAppOnTopChanged(bool showAppOnTop); + void reloadRequested(); + void selectToolRequested(); + void selectMarqueeToolRequested(); + void zoomToolRequested(); + void colorPickerToolRequested(); + + void objectCreationRequested(const QString &qml, QObject *parent, + const QStringList &imports, const QString &filename = QString(), int order = -1); + void objectReparentRequested(QObject *object, QObject *newParent); + void objectDeletionRequested(QObject *object); + + // 1 = normal speed, + // 1 < x < 16 = slowdown by some factor + void animationSpeedChangeRequested(qreal speedFactor); + void executionPauseChangeRequested(bool paused); + + void clearComponentCacheRequested(); + +protected: + virtual void statusChanged(Status status); + virtual void messageReceived(const QByteArray &); + +private: + QHash m_stringIdForObjectId; +}; + +} // namespace QmlJSDebugger + +#endif // QDECLARATIVEDESIGNDEBUGSERVER_H diff --git a/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeobserverservice.h b/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeobserverservice.h deleted file mode 100644 index 972a362788..0000000000 --- a/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeobserverservice.h +++ /dev/null @@ -1,105 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -**************************************************************************/ - -#ifndef QDECLARATIVEDESIGNDEBUGSERVER_H -#define QDECLARATIVEDESIGNDEBUGSERVER_H - -#include "qt_private/qdeclarativedebugservice_p.h" -#include "qmlobserverconstants.h" -#include "qmljsdebugger_global.h" - -#include - -QT_FORWARD_DECLARE_CLASS(QColor) -QT_FORWARD_DECLARE_CLASS(QDeclarativeEngine) -QT_FORWARD_DECLARE_CLASS(QDeclarativeContext) -QT_FORWARD_DECLARE_CLASS(QDeclarativeWatcher) -QT_FORWARD_DECLARE_CLASS(QDataStream) - -namespace QmlJSDebugger { - -class QMLJSDEBUGGER_EXPORT QDeclarativeObserverService : public QDeclarativeDebugService -{ - Q_OBJECT -public: - QDeclarativeObserverService(); - static QDeclarativeObserverService *instance(); - - void setDesignModeBehavior(bool inDesignMode); - void setCurrentObjects(QList items); - void setAnimationSpeed(qreal slowDownFactor); - void setAnimationPaused(bool paused); - void setCurrentTool(QmlJSDebugger::Constants::DesignTool toolId); - void reloaded(); - void setShowAppOnTop(bool showAppOnTop); - - QString idStringForObject(QObject *obj) const; - - void sendMessage(const QByteArray &message); - -public Q_SLOTS: - void selectedColorChanged(const QColor &color); - -Q_SIGNALS: - void debuggingClientChanged(bool hasDebuggingClient); - - void currentObjectsChanged(const QList &objects); - void designModeBehaviorChanged(bool inDesignMode); - void showAppOnTopChanged(bool showAppOnTop); - void reloadRequested(); - void selectToolRequested(); - void selectMarqueeToolRequested(); - void zoomToolRequested(); - void colorPickerToolRequested(); - - void objectCreationRequested(const QString &qml, QObject *parent, - const QStringList &imports, const QString &filename = QString(), int order = -1); - void objectReparentRequested(QObject *object, QObject *newParent); - void objectDeletionRequested(QObject *object); - - // 1 = normal speed, - // 1 < x < 16 = slowdown by some factor - void animationSpeedChangeRequested(qreal speedFactor); - void executionPauseChangeRequested(bool paused); - - void clearComponentCacheRequested(); - -protected: - virtual void statusChanged(Status status); - virtual void messageReceived(const QByteArray &); - -private: - QHash m_stringIdForObjectId; -}; - -} // namespace QmlJSDebugger - -#endif // QDECLARATIVEDESIGNDEBUGSERVER_H diff --git a/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeviewinspector.h b/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeviewinspector.h new file mode 100644 index 0000000000..6ba0427187 --- /dev/null +++ b/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeviewinspector.h @@ -0,0 +1,120 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +**************************************************************************/ + +#ifndef QDECLARATIVEVIEWINSPECTOR_H +#define QDECLARATIVEVIEWINSPECTOR_H + +#include "qmljsdebugger_global.h" +#include "qmlinspectorconstants.h" + +#include +#include + +QT_FORWARD_DECLARE_CLASS(QDeclarativeItem) +QT_FORWARD_DECLARE_CLASS(QMouseEvent) +QT_FORWARD_DECLARE_CLASS(QToolBar) + +namespace QmlJSDebugger { + +class CrumblePath; +class QDeclarativeViewInspectorPrivate; + +class QMLJSDEBUGGER_EXPORT QDeclarativeViewInspector : public QObject +{ + Q_OBJECT +public: + + explicit QDeclarativeViewInspector(QDeclarativeView *view, QObject *parent = 0); + ~QDeclarativeViewInspector(); + + void setSelectedItems(QList items); + QList selectedItems(); + + QDeclarativeView *declarativeView(); + + static QString idStringForObject(QObject *obj); + QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace); + + bool showAppOnTop() const; + +public Q_SLOTS: + void setDesignModeBehavior(bool value); + bool designModeBehavior(); + + void setShowAppOnTop(bool appOnTop); + + void setAnimationSpeed(qreal factor); + void setAnimationPaused(bool paused); + +Q_SIGNALS: + void designModeBehaviorChanged(bool inDesignMode); + void showAppOnTopChanged(bool showAppOnTop); + void reloadRequested(); + void marqueeSelectToolActivated(); + void selectToolActivated(); + void zoomToolActivated(); + void colorPickerActivated(); + void selectedColorChanged(const QColor &color); + + void animationSpeedChanged(qreal factor); + void animationPausedChanged(bool paused); + +protected: + bool eventFilter(QObject *obj, QEvent *event); + + bool leaveEvent(QEvent *); + bool mousePressEvent(QMouseEvent *event); + bool mouseMoveEvent(QMouseEvent *event); + bool mouseReleaseEvent(QMouseEvent *event); + bool keyPressEvent(QKeyEvent *event); + bool keyReleaseEvent(QKeyEvent *keyEvent); + bool mouseDoubleClickEvent(QMouseEvent *event); + bool wheelEvent(QWheelEvent *event); + + void setSelectedItemsForTools(QList items); + +private slots: + void animationSpeedChangeRequested(qreal factor); + void animationPausedChangeRequested(bool paused); + +private: + Q_DISABLE_COPY(QDeclarativeViewInspector) + + inline QDeclarativeViewInspectorPrivate *d_func() { return data.data(); } + QScopedPointer data; + friend class QDeclarativeViewInspectorPrivate; + friend class AbstractLiveEditTool; +}; + +} // namespace QmlJSDebugger + +#endif // QDECLARATIVEVIEWINSPECTOR_H diff --git a/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeviewobserver.h b/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeviewobserver.h index 2accbfa700..7621a9e8d7 100644 --- a/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeviewobserver.h +++ b/share/qtcreator/qml/qmljsdebugger/include/qdeclarativeviewobserver.h @@ -33,86 +33,19 @@ #ifndef QDECLARATIVEVIEWOBSERVER_H #define QDECLARATIVEVIEWOBSERVER_H -#include "qmljsdebugger_global.h" -#include "qmlobserverconstants.h" - -#include -#include - -QT_FORWARD_DECLARE_CLASS(QDeclarativeItem) -QT_FORWARD_DECLARE_CLASS(QMouseEvent) -QT_FORWARD_DECLARE_CLASS(QToolBar) +#include "qdeclarativeviewinspector.h" namespace QmlJSDebugger { -class CrumblePath; -class QDeclarativeViewObserverPrivate; - -class QMLJSDEBUGGER_EXPORT QDeclarativeViewObserver : public QObject +// Provided for compatibility with QmlApplicationViewer +class QMLJSDEBUGGER_EXPORT QDeclarativeViewObserver : public QDeclarativeViewInspector { Q_OBJECT -public: - - explicit QDeclarativeViewObserver(QDeclarativeView *view, QObject *parent = 0); - ~QDeclarativeViewObserver(); - - void setSelectedItems(QList items); - QList selectedItems(); - - QDeclarativeView *declarativeView(); - - static QString idStringForObject(QObject *obj); - QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace); - - bool showAppOnTop() const; - -public Q_SLOTS: - void setDesignModeBehavior(bool value); - bool designModeBehavior(); - void setShowAppOnTop(bool appOnTop); - - void setAnimationSpeed(qreal factor); - void setAnimationPaused(bool paused); - -Q_SIGNALS: - void designModeBehaviorChanged(bool inDesignMode); - void showAppOnTopChanged(bool showAppOnTop); - void reloadRequested(); - void marqueeSelectToolActivated(); - void selectToolActivated(); - void zoomToolActivated(); - void colorPickerActivated(); - void selectedColorChanged(const QColor &color); - - void animationSpeedChanged(qreal factor); - void animationPausedChanged(bool paused); - -protected: - bool eventFilter(QObject *obj, QEvent *event); - - bool leaveEvent(QEvent *); - bool mousePressEvent(QMouseEvent *event); - bool mouseMoveEvent(QMouseEvent *event); - bool mouseReleaseEvent(QMouseEvent *event); - bool keyPressEvent(QKeyEvent *event); - bool keyReleaseEvent(QKeyEvent *keyEvent); - bool mouseDoubleClickEvent(QMouseEvent *event); - bool wheelEvent(QWheelEvent *event); - - void setSelectedItemsForTools(QList items); - -private slots: - void animationSpeedChangeRequested(qreal factor); - void animationPausedChangeRequested(bool paused); - -private: - Q_DISABLE_COPY(QDeclarativeViewObserver) - - inline QDeclarativeViewObserverPrivate *d_func() { return data.data(); } - QScopedPointer data; - friend class QDeclarativeViewObserverPrivate; - friend class AbstractLiveEditTool; +public: + explicit QDeclarativeViewObserver(QDeclarativeView *view, QObject *parent = 0) + : QDeclarativeViewInspector(view, parent) + {} }; } // namespace QmlJSDebugger diff --git a/share/qtcreator/qml/qmljsdebugger/include/qmlinspectorconstants.h b/share/qtcreator/qml/qmljsdebugger/include/qmlinspectorconstants.h new file mode 100644 index 0000000000..eb5ac317e8 --- /dev/null +++ b/share/qtcreator/qml/qmljsdebugger/include/qmlinspectorconstants.h @@ -0,0 +1,71 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +**************************************************************************/ + +#ifndef QMLINSPECTORCONSTANTS_H +#define QMLINSPECTORCONSTANTS_H + +namespace QmlJSDebugger { +namespace Constants { + +enum DesignTool { + NoTool = 0, + SelectionToolMode = 1, + MarqueeSelectionToolMode = 2, + MoveToolMode = 3, + ResizeToolMode = 4, + ColorPickerMode = 5, + ZoomMode = 6 +}; + +enum ToolFlags { + NoToolFlags = 0, + UseCursorPos = 1 +}; + +static const int DragStartTime = 50; + +static const int DragStartDistance = 20; + +static const double ZoomSnapDelta = 0.04; + +static const int EditorItemDataKey = 1000; + +enum GraphicsItemTypes { + EditorItemType = 0xEAAA, + ResizeHandleItemType = 0xEAEA +}; + + +} // namespace Constants +} // namespace QmlJSDebugger + +#endif // QMLINSPECTORCONSTANTS_H diff --git a/share/qtcreator/qml/qmljsdebugger/include/qmlobserverconstants.h b/share/qtcreator/qml/qmljsdebugger/include/qmlobserverconstants.h deleted file mode 100644 index 30aefdf1f6..0000000000 --- a/share/qtcreator/qml/qmljsdebugger/include/qmlobserverconstants.h +++ /dev/null @@ -1,71 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -**************************************************************************/ - -#ifndef QMLOBSERVERCONSTANTS_H -#define QMLOBSERVERCONSTANTS_H - -namespace QmlJSDebugger { -namespace Constants { - -enum DesignTool { - NoTool = 0, - SelectionToolMode = 1, - MarqueeSelectionToolMode = 2, - MoveToolMode = 3, - ResizeToolMode = 4, - ColorPickerMode = 5, - ZoomMode = 6 -}; - -enum ToolFlags { - NoToolFlags = 0, - UseCursorPos = 1 -}; - -static const int DragStartTime = 50; - -static const int DragStartDistance = 20; - -static const double ZoomSnapDelta = 0.04; - -static const int EditorItemDataKey = 1000; - -enum GraphicsItemTypes { - EditorItemType = 0xEAAA, - ResizeHandleItemType = 0xEAEA -}; - - -} // namespace Constants -} // namespace QmlJSDebugger - -#endif // QMLOBSERVERCONSTANTS_H -- cgit v1.2.1