diff --git a/src/libs/qmldebug/basetoolsclient.h b/src/libs/qmldebug/basetoolsclient.h index 55a2a93fb2c..62ce6347394 100644 --- a/src/libs/qmldebug/basetoolsclient.h +++ b/src/libs/qmldebug/basetoolsclient.h @@ -42,34 +42,18 @@ class QMLDEBUG_EXPORT BaseToolsClient : public QmlDebugClient public: BaseToolsClient(QmlDebugConnection *client, QLatin1String clientName); - virtual void setCurrentObjects(const QList &debugIds) = 0; virtual void reload(const QHash &changesHash) = 0; virtual bool supportReload() const = 0; virtual void setDesignModeBehavior(bool inDesignMode) = 0; - virtual void setAnimationSpeed(qreal slowDownFactor) = 0; - virtual void setAnimationPaused(bool paused) = 0; virtual void changeToSelectTool() = 0; virtual void changeToSelectMarqueeTool() = 0; virtual void changeToZoomTool() = 0; virtual void showAppOnTop(bool showOnTop) = 0; - virtual void createQmlObject(const QString &qmlText, int parentDebugId, - const QStringList &imports, const QString &filename, - int order) = 0; - virtual void destroyQmlObject(int debugId) = 0; - virtual void reparentQmlObject(int debugId, int newParent) = 0; - - virtual void applyChangesToQmlFile() = 0; - virtual void applyChangesFromQmlFile() = 0; - - virtual QList currentObjects() const = 0; - // ### Qt 4.8: remove if we can have access to qdeclarativecontextdata or id's virtual void setObjectIdList( const QList &objectRoots) = 0; - virtual void clearComponentCache() = 0; - signals: void newState(QmlDebug::QmlDebugClient::State status); @@ -77,12 +61,8 @@ signals: void selectToolActivated(); void selectMarqueeToolActivated(); void zoomToolActivated(); - void animationSpeedChanged(qreal slowdownFactor); - void animationPausedChanged(bool paused); void designModeBehaviorChanged(bool inDesignMode); - void showAppOnTopChanged(bool showAppOnTop); void reloaded(); // the server has reloaded the document - void destroyedObject(int); void logActivity(QString client, QString message); diff --git a/src/libs/qmldebug/declarativetoolsclient.cpp b/src/libs/qmldebug/declarativetoolsclient.cpp index cb0e85f60ae..2aef5dd518e 100644 --- a/src/libs/qmldebug/declarativetoolsclient.cpp +++ b/src/libs/qmldebug/declarativetoolsclient.cpp @@ -55,21 +55,12 @@ class InspectorProtocol : public QObject public: enum Message { - AnimationSpeedChanged = 0, - AnimationPausedChanged = 19, // highest value ChangeTool = 1, - ClearComponentCache = 2, ColorChanged = 3, - CreateObject = 5, CurrentObjectsChanged = 6, - DestroyObject = 7, - MoveObject = 8, ObjectIdList = 9, Reload = 10, Reloaded = 11, - SetAnimationSpeed = 12, - SetAnimationPaused = 18, - SetCurrentObjects = 14, SetDesignMode = 15, ShowAppOnTop = 16, ToolChanged = 17 @@ -156,16 +147,16 @@ void DeclarativeToolsClient::messageReceived(const QByteArray &message) log(LogReceive, type, QString::fromLatin1("%1 [list of debug ids]").arg(objectCount)); - m_currentDebugIds.clear(); + QList currentDebugIds; for (int i = 0; i < objectCount; ++i) { int debugId; ds >> debugId; if (debugId != -1) - m_currentDebugIds << debugId; + currentDebugIds << debugId; } - emit currentObjectsChanged(m_currentDebugIds); + emit currentObjectsChanged(currentDebugIds); break; } case InspectorProtocol::ToolChanged: { @@ -182,25 +173,6 @@ void DeclarativeToolsClient::messageReceived(const QByteArray &message) emit selectMarqueeToolActivated(); break; } - case InspectorProtocol::AnimationSpeedChanged: { - qreal slowDownFactor; - ds >> slowDownFactor; - - log(LogReceive, type, QString::number(slowDownFactor)); - - emit animationSpeedChanged(slowDownFactor); - break; - } - case InspectorProtocol::AnimationPausedChanged: { - bool paused; - ds >> paused; - - log(LogReceive, type, paused ? QLatin1String("true") - : QLatin1String("false")); - - emit animationPausedChanged(paused); - break; - } case InspectorProtocol::SetDesignMode: { bool inDesignMode; ds >> inDesignMode; @@ -215,8 +187,6 @@ void DeclarativeToolsClient::messageReceived(const QByteArray &message) ds >> showAppOnTop; log(LogReceive, type, QLatin1String(showAppOnTop ? "true" : "false")); - - emit showAppOnTopChanged(showAppOnTop); break; } case InspectorProtocol::Reloaded: { @@ -229,37 +199,6 @@ void DeclarativeToolsClient::messageReceived(const QByteArray &message) } } -QList DeclarativeToolsClient::currentObjects() const -{ - return m_currentDebugIds; -} - -void DeclarativeToolsClient::setCurrentObjects(const QList &debugIds) -{ - if (!m_connection || !m_connection->isOpen()) - return; - - if (debugIds == m_currentDebugIds) - return; - - m_currentDebugIds = debugIds; - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - - InspectorProtocol::Message cmd = InspectorProtocol::SetCurrentObjects; - ds << cmd - << debugIds.length(); - - foreach (int id, debugIds) { - ds << id; - } - - log(LogSend, cmd, QString::fromLatin1("%1 [list of ids]").arg(debugIds.length())); - - sendMessage(message); -} - void DeclarativeToolsClient::setObjectIdList( const QList &objectRoots) { @@ -288,22 +227,6 @@ void DeclarativeToolsClient::setObjectIdList( sendMessage(message); } -void DeclarativeToolsClient::clearComponentCache() -{ - if (!m_connection || !m_connection->isOpen()) - return; - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - - InspectorProtocol::Message cmd = InspectorProtocol::ClearComponentCache; - ds << cmd; - - log(LogSend, cmd); - - sendMessage(message); -} - void DeclarativeToolsClient::reload(const QHash &changesHash) { @@ -340,41 +263,6 @@ void DeclarativeToolsClient::setDesignModeBehavior(bool inDesignMode) sendMessage(message); } -void DeclarativeToolsClient::setAnimationSpeed(qreal slowDownFactor) -{ - if (!m_connection || !m_connection->isOpen()) - return; - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - - InspectorProtocol::Message cmd = InspectorProtocol::SetAnimationSpeed; - ds << cmd - << slowDownFactor; - - - log(LogSend, cmd, QString::number(slowDownFactor)); - - sendMessage(message); -} - -void DeclarativeToolsClient::setAnimationPaused(bool paused) -{ - if (!m_connection || !m_connection->isOpen()) - return; - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - - InspectorProtocol::Message cmd = InspectorProtocol::SetAnimationPaused; - ds << cmd - << paused; - - log(LogSend, cmd, paused ? QLatin1String("true") : QLatin1String("false")); - - sendMessage(message); -} - void DeclarativeToolsClient::changeToSelectTool() { if (!m_connection || !m_connection->isOpen()) @@ -445,82 +333,6 @@ void DeclarativeToolsClient::showAppOnTop(bool showOnTop) sendMessage(message); } -void DeclarativeToolsClient::createQmlObject(const QString &qmlText, - int parentDebugId, - const QStringList &imports, - const QString &filename, int order) -{ - if (!m_connection || !m_connection->isOpen()) - return; - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - - InspectorProtocol::Message cmd = InspectorProtocol::CreateObject; - ds << cmd - << qmlText - << parentDebugId - << imports - << filename - << order; - - log(LogSend, cmd, QString::fromLatin1("%1 %2 [%3] %4").arg(qmlText, - QString::number(parentDebugId), - imports.join(QLatin1Char(',')), filename)); - - sendMessage(message); -} - -void DeclarativeToolsClient::destroyQmlObject(int debugId) -{ - if (!m_connection || !m_connection->isOpen()) - return; - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - - InspectorProtocol::Message cmd = InspectorProtocol::DestroyObject; - ds << cmd << debugId; - - log(LogSend, cmd, QString::number(debugId)); - - sendMessage(message); -} - -void DeclarativeToolsClient::reparentQmlObject(int debugId, int newParent) -{ - if (!m_connection || !m_connection->isOpen()) - return; - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - - InspectorProtocol::Message cmd = InspectorProtocol::MoveObject; - ds << cmd - << debugId - << newParent; - - log(LogSend, cmd, QString::fromLatin1("%1 %2").arg(QString::number(debugId), - QString::number(newParent))); - - sendMessage(message); -} - - -void DeclarativeToolsClient::applyChangesToQmlFile() -{ - if (!m_connection || !m_connection->isOpen()) - return; - - // TODO -} - -void DeclarativeToolsClient::applyChangesFromQmlFile() -{ - if (!m_connection || !m_connection->isOpen()) - return; - - // TODO -} - void DeclarativeToolsClient::log(LogDirection direction, int message, const QString &extra) diff --git a/src/libs/qmldebug/declarativetoolsclient.h b/src/libs/qmldebug/declarativetoolsclient.h index 847e043d3bd..330f9fedcc4 100644 --- a/src/libs/qmldebug/declarativetoolsclient.h +++ b/src/libs/qmldebug/declarativetoolsclient.h @@ -41,33 +41,17 @@ class QMLDEBUG_EXPORT DeclarativeToolsClient : public BaseToolsClient public: DeclarativeToolsClient(QmlDebugConnection *client); - void setCurrentObjects(const QList &debugIds); void reload(const QHash &changesHash); bool supportReload() const { return false; } void setDesignModeBehavior(bool inDesignMode); - void setAnimationSpeed(qreal slowDownFactor); - void setAnimationPaused(bool paused); void changeToSelectTool(); void changeToSelectMarqueeTool(); void changeToZoomTool(); void showAppOnTop(bool showOnTop); - void createQmlObject(const QString &qmlText, int parentDebugId, - const QStringList &imports, const QString &filename, - int order); - void destroyQmlObject(int debugId); - void reparentQmlObject(int debugId, int newParent); - - void applyChangesToQmlFile(); - void applyChangesFromQmlFile(); - - QList currentObjects() const; - // ### Qt 4.8: remove if we can have access to qdeclarativecontextdata or id's void setObjectIdList(const QList &objectRoots); - void clearComponentCache(); - protected: void messageReceived(const QByteArray &); @@ -77,7 +61,6 @@ private: const QString &extra = QString()); private: - QList m_currentDebugIds; QmlDebugConnection *m_connection; }; diff --git a/src/libs/qmldebug/qmltoolsclient.cpp b/src/libs/qmldebug/qmltoolsclient.cpp index fcb2371a259..1287c0f45ac 100644 --- a/src/libs/qmldebug/qmltoolsclient.cpp +++ b/src/libs/qmldebug/qmltoolsclient.cpp @@ -34,17 +34,10 @@ //INSPECTOR SERVICE PROTOCOL //
//
: [] -// : {"enable", "disable", "select", "reload", "setAnimationSpeed", -// "showAppOnTop", "createObject", "destroyObject", "moveObject", -// "clearCache"} +// : {"enable", "disable", "reload", "showAppOnTop"} // : select: // reload: > -// setAnimationSpeed: // showAppOnTop: -// createObject: -// destroyObject: -// moveObject: -// clearCache: void const char REQUEST[] = "request"; const char RESPONSE[] = "response"; @@ -53,12 +46,7 @@ const char ENABLE[] = "enable"; const char DISABLE[] = "disable"; const char SELECT[] = "select"; const char RELOAD[] = "reload"; -const char SET_ANIMATION_SPEED[] = "setAnimationSpeed"; const char SHOW_APP_ON_TOP[] = "showAppOnTop"; -const char CREATE_OBJECT[] = "createObject"; -const char DESTROY_OBJECT[] = "destroyObject"; -const char MOVE_OBJECT[] = "moveObject"; -const char CLEAR_CACHE[] = "clearCache"; namespace QmlDebug { @@ -66,9 +54,7 @@ QmlToolsClient::QmlToolsClient(QmlDebugConnection *client) : BaseToolsClient(client, QLatin1String("QmlInspector")), m_connection(client), m_requestId(0), - m_reloadQueryId(-1), - m_slowDownFactor(1), - m_destroyObjectQueryId(-1) + m_reloadQueryId(-1) { setObjectName(name()); } @@ -88,85 +74,36 @@ void QmlToolsClient::messageReceived(const QByteArray &message) if ((m_reloadQueryId != -1) && (m_reloadQueryId == requestId) && success) emit reloaded(); - if ((m_destroyObjectQueryId != -1) && (m_destroyObjectQueryId == requestId) - && success && !ds.atEnd()) { - int objectDebugId; - ds >> objectDebugId; - emit destroyedObject(objectDebugId); - } - log(LogReceive, type, QString::fromLatin1("requestId: %1 success: %2") .arg(QString::number(requestId)).arg(QString::number(success))); } else if (type == QByteArray(EVENT)) { QByteArray event; ds >> event; if (event == QByteArray(SELECT)) { - m_currentDebugIds.clear(); QList debugIds; ds >> debugIds; + debugIds.removeAll(-1); + QStringList debugIdStrings; foreach (int debugId, debugIds) { - if (debugId != -1) { - m_currentDebugIds << debugId; - debugIdStrings << QString::number(debugId); - } + debugIdStrings << QString::number(debugId); } log(LogReceive, type + ':' + event, QString::fromLatin1("[%1]").arg(debugIdStrings.join(QLatin1Char(',')))); - emit currentObjectsChanged(m_currentDebugIds); + emit currentObjectsChanged(debugIds); } } else { log(LogReceive, type, QLatin1String("Warning: Not handling message")); } } -QList QmlToolsClient::currentObjects() const -{ - return m_currentDebugIds; -} - -void QmlToolsClient::setCurrentObjects(const QList &debugIds) -{ - if (!m_connection || !m_connection->isOpen()) - return; - - if (debugIds == m_currentDebugIds) - return; - - m_currentDebugIds = debugIds; - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray(REQUEST) << m_requestId++ - << QByteArray(SELECT) << m_currentDebugIds; - - log(LogSend, SELECT, QString::fromLatin1("%1 [list of ids]").arg(debugIds.length())); - - sendMessage(message); -} - void QmlToolsClient::setObjectIdList( const QList &/*objectRoots*/) { //NOT IMPLEMENTED } -void QmlToolsClient::clearComponentCache() -{ - if (!m_connection || !m_connection->isOpen()) - return; - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray(REQUEST) << m_requestId++ - << QByteArray(CLEAR_CACHE); - - log(LogSend, CLEAR_CACHE); - - sendMessage(message); -} - void QmlToolsClient::reload(const QHash &changesHash) { if (!m_connection || !m_connection->isOpen()) @@ -202,32 +139,6 @@ void QmlToolsClient::setDesignModeBehavior(bool inDesignMode) sendMessage(message); } -void QmlToolsClient::setAnimationSpeed(qreal slowDownFactor) -{ - if (!m_connection || !m_connection->isOpen()) - return; - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray(REQUEST) << m_requestId++ - << QByteArray(SET_ANIMATION_SPEED) << slowDownFactor; - - log(LogSend, SET_ANIMATION_SPEED, QString::number(slowDownFactor)); - - sendMessage(message); - //Cache non-zero values - if (slowDownFactor) - m_slowDownFactor = slowDownFactor; -} - -void QmlToolsClient::setAnimationPaused(bool paused) -{ - if (paused) - setAnimationSpeed(0); - else - setAnimationSpeed(m_slowDownFactor); -} - void QmlToolsClient::changeToSelectTool() { // NOT IMPLEMENTED @@ -258,78 +169,6 @@ void QmlToolsClient::showAppOnTop(bool showOnTop) sendMessage(message); } -void QmlToolsClient::createQmlObject(const QString &qmlText, - int parentDebugId, - const QStringList &imports, - const QString &filename, int order) -{ - if (!m_connection || !m_connection->isOpen()) - return; - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray(REQUEST) << m_requestId++ - << QByteArray(CREATE_OBJECT) - << qmlText - << parentDebugId - << imports - << filename - << order; - - log(LogSend, CREATE_OBJECT, QString::fromLatin1("%1 %2 [%3] %4").arg(qmlText, - QString::number(parentDebugId), - imports.join(QLatin1Char(',')), filename)); - - sendMessage(message); -} - -void QmlToolsClient::destroyQmlObject(int debugId) -{ - if (!m_connection || !m_connection->isOpen()) - return; - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - m_destroyObjectQueryId = m_requestId; - ds << QByteArray(REQUEST) << m_requestId++ - << QByteArray(DESTROY_OBJECT) << debugId; - - log(LogSend, DESTROY_OBJECT, QString::number(debugId)); - - sendMessage(message); -} - -void QmlToolsClient::reparentQmlObject(int debugId, int newParent) -{ - if (!m_connection || !m_connection->isOpen()) - return; - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray(REQUEST) << m_requestId++ - << QByteArray(MOVE_OBJECT) << debugId << newParent; - - log(LogSend, MOVE_OBJECT, QString::fromLatin1("%1 %2").arg(QString::number(debugId), - QString::number(newParent))); - - sendMessage(message); -} - - -void QmlToolsClient::applyChangesToQmlFile() -{ - if (!m_connection || !m_connection->isOpen()) - return; - - // TODO -} - -void QmlToolsClient::applyChangesFromQmlFile() -{ - if (!m_connection || !m_connection->isOpen()) - return; - - // TODO -} - void QmlToolsClient::log(LogDirection direction, const QByteArray &message, const QString &extra) diff --git a/src/libs/qmldebug/qmltoolsclient.h b/src/libs/qmldebug/qmltoolsclient.h index 888725b0285..9640fb8f554 100644 --- a/src/libs/qmldebug/qmltoolsclient.h +++ b/src/libs/qmldebug/qmltoolsclient.h @@ -41,33 +41,17 @@ class QMLDEBUG_EXPORT QmlToolsClient : public BaseToolsClient public: explicit QmlToolsClient(QmlDebugConnection *client); - void setCurrentObjects(const QList &debugIds); void reload(const QHash &changesHash); bool supportReload() const { return true; } void setDesignModeBehavior(bool inDesignMode); - void setAnimationSpeed(qreal slowDownFactor); - void setAnimationPaused(bool paused); void changeToSelectTool(); void changeToSelectMarqueeTool(); void changeToZoomTool(); void showAppOnTop(bool showOnTop); - void createQmlObject(const QString &qmlText, int parentDebugId, - const QStringList &imports, const QString &filename, - int order); - void destroyQmlObject(int debugId); - void reparentQmlObject(int debugId, int newParent); - - void applyChangesToQmlFile(); - void applyChangesFromQmlFile(); - - QList currentObjects() const; - // ### Qt 4.8: remove if we can have access to qdeclarativecontextdata or id's void setObjectIdList(const QList &objectRoots); - void clearComponentCache(); - protected: void messageReceived(const QByteArray &); @@ -77,12 +61,9 @@ private: const QString &extra = QString()); private: - QList m_currentDebugIds; QmlDebugConnection *m_connection; int m_requestId; int m_reloadQueryId; - qreal m_slowDownFactor; - int m_destroyObjectQueryId; }; } // namespace QmlDebug