From d349c879e1d55e4cd2b7d31c08e2796c0fec4020 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 21 Jun 2011 16:38:44 +0200 Subject: QDeclarativeDebug: Add code coverage information Add messages to track the lines of JavaScript that are executed. Patch done by Janne Virranmaki Reviewed-by: kkoehne --- src/declarative/debugger/qjsdebuggeragent.cpp | 42 +++++++-- src/declarative/debugger/qjsdebuggeragent_p.h | 12 +++ src/declarative/debugger/qjsdebugservice.cpp | 53 ++++++++++- src/declarative/debugger/qjsdebugservice_p.h | 24 +++++ .../tst_qdeclarativedebugjs.cpp | 101 +++++++++++++++++++++ 5 files changed, 225 insertions(+), 7 deletions(-) diff --git a/src/declarative/debugger/qjsdebuggeragent.cpp b/src/declarative/debugger/qjsdebuggeragent.cpp index dff637b..683032b 100644 --- a/src/declarative/debugger/qjsdebuggeragent.cpp +++ b/src/declarative/debugger/qjsdebuggeragent.cpp @@ -41,6 +41,7 @@ #include "private/qjsdebuggeragent_p.h" #include "private/qdeclarativedebughelper_p.h" +#include "private/qjsdebugservice_p.h" #include #include @@ -56,7 +57,7 @@ class QJSDebuggerAgentPrivate { public: QJSDebuggerAgentPrivate(QJSDebuggerAgent *q) - : q(q), state(NoState), isInitialized(false) + : q(q), state(NoState), isInitialized(false), coverageEnabled(false) {} void continueExec(); @@ -80,6 +81,7 @@ public: QStringList watchExpressions; QSet knownObjectIds; bool isInitialized; + bool coverageEnabled; }; namespace { @@ -261,6 +263,12 @@ bool QJSDebuggerAgent::isInitialized() const return d->isInitialized; } +void QJSDebuggerAgent::setCoverageEnabled(bool enabled) +{ + d->isInitialized = true; + d->coverageEnabled = enabled; +} + void QJSDebuggerAgent::setBreakpoints(const JSAgentBreakpoints &breakpoints) { d->breakpoints = breakpoints; @@ -417,10 +425,16 @@ void QJSDebuggerAgent::setProperty(qint64 objectId, \reimp */ void QJSDebuggerAgent::scriptLoad(qint64 id, const QString &program, - const QString &fileName, int) + const QString &fileName, int baseLineNumber) { - Q_UNUSED(program); d->filenames.insert(id, fileName); + + if (d->coverageEnabled) { + JSAgentCoverageData rd = {"COVERAGE", QJSDebugService::instance()->m_timer.elapsed(), (int)CoverageScriptLoad, + id, program, fileName, baseLineNumber, + 0, 0, QString()}; + QJSDebugService::instance()->processMessage(rd); + } } /*! @@ -450,8 +464,14 @@ void QJSDebuggerAgent::contextPop() */ void QJSDebuggerAgent::functionEntry(qint64 scriptId) { - Q_UNUSED(scriptId); d->stepDepth++; + + if (d->coverageEnabled) { + JSAgentCoverageData rd = {"COVERAGE", QJSDebugService::instance()->m_timer.elapsed(), (int)CoverageFuncEntry, + scriptId, QString(), QString(), 0, 0, 0, QString()}; + QJSDebugService::instance()->processMessage(rd); + QJSDebugService::instance()->m_timer.restart(); + } } /*! @@ -459,9 +479,13 @@ void QJSDebuggerAgent::functionEntry(qint64 scriptId) */ void QJSDebuggerAgent::functionExit(qint64 scriptId, const QScriptValue &returnValue) { - Q_UNUSED(scriptId); - Q_UNUSED(returnValue); d->stepDepth--; + + if (d->coverageEnabled) { + JSAgentCoverageData rd = {"COVERAGE", QJSDebugService::instance()->m_timer.elapsed(), (int)CoverageFuncExit, + scriptId, QString(), QString(), 0, 0, 0, returnValue.toString()}; + QJSDebugService::instance()->processMessage(rd); + } } /*! @@ -470,6 +494,12 @@ void QJSDebuggerAgent::functionExit(qint64 scriptId, const QScriptValue &returnV void QJSDebuggerAgent::positionChange(qint64 scriptId, int lineNumber, int columnNumber) { d->positionChange(scriptId, lineNumber, columnNumber); + + if (d->coverageEnabled) { + JSAgentCoverageData rd = {"COVERAGE", QJSDebugService::instance()->m_timer.elapsed(), (int)CoveragePosChange, + scriptId, QString(), QString(), 0, lineNumber, columnNumber, QString()}; + QJSDebugService::instance()->processMessage(rd); + } } void QJSDebuggerAgentPrivate::positionChange(qint64 scriptId, int lineNumber, int columnNumber) diff --git a/src/declarative/debugger/qjsdebuggeragent_p.h b/src/declarative/debugger/qjsdebuggeragent_p.h index 4b27fc8..e999080 100644 --- a/src/declarative/debugger/qjsdebuggeragent_p.h +++ b/src/declarative/debugger/qjsdebuggeragent_p.h @@ -78,6 +78,17 @@ enum JSDebuggerState StoppedState }; +enum JSCoverageMessage { + CoverageLocation, + CoverageScriptLoad, + CoveragePosChange, + CoverageFuncEntry, + CoverageFuncExit, + CoverageComplete, + + CoverageMaximumMessage +}; + struct JSAgentWatchData { QByteArray exp; @@ -165,6 +176,7 @@ public: void stepInto(); void stepOut(); void continueExecution(); + void setCoverageEnabled(bool enabled); JSAgentWatchData executeExpression(const QString &expr); QList expandObjectById(quint64 objectId); diff --git a/src/declarative/debugger/qjsdebugservice.cpp b/src/declarative/debugger/qjsdebugservice.cpp index ad84f65..03d1f76 100644 --- a/src/declarative/debugger/qjsdebugservice.cpp +++ b/src/declarative/debugger/qjsdebugservice.cpp @@ -49,10 +49,22 @@ Q_GLOBAL_STATIC(QJSDebugService, serviceInstance) +// convert to a QByteArray that can be sent to the debug client +QByteArray JSAgentCoverageData::toByteArray() const +{ + QByteArray data; + //### using QDataStream is relatively expensive + QDataStream ds(&data, QIODevice::WriteOnly); + ds << prefix << time << messageType << scriptId << program << fileName << baseLineNumber + << lineNumber << columnNumber << returnValue; + return data; +} + QJSDebugService::QJSDebugService(QObject *parent) : QDeclarativeDebugService(QLatin1String("JSDebugger"), parent) - , m_agent(0) + , m_agent(0), m_deferredSend(true) { + m_timer.start(); } QJSDebugService::~QJSDebugService() @@ -186,6 +198,13 @@ void QJSDebugService::messageReceived(const QByteArray &message) QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("PONG") << ping; sendMessage(reply); + } else if (command == "COVERAGE") { + bool enabled; + ds >> enabled; + m_agent->setCoverageEnabled(enabled); + if (!enabled) { + sendMessages(); + } } else { qDebug() << Q_FUNC_INFO << "Unknown command" << command; } @@ -206,3 +225,35 @@ void QJSDebugService::executionStopped(bool becauseOfException, << becauseOfException << exception; sendMessage(reply); } + +/* + Either send the message directly, or queue up + a list of messages to send later (via sendMessages) +*/ +void QJSDebugService::processMessage(const JSAgentCoverageData &message) +{ + if (m_deferredSend) + m_data.append(message); + else + sendMessage(message.toByteArray()); +} + +/* + Send the messages queued up by processMessage +*/ +void QJSDebugService::sendMessages() +{ + if (m_deferredSend) { + //### this is a suboptimal way to send batched messages + for (int i = 0; i < m_data.count(); ++i) + sendMessage(m_data.at(i).toByteArray()); + m_data.clear(); + + //indicate completion + QByteArray data; + QDataStream ds(&data, QIODevice::WriteOnly); + ds << QByteArray("COVERAGE") << (qint64)-1 << (int)CoverageComplete; + sendMessage(data); + } +} + diff --git a/src/declarative/debugger/qjsdebugservice_p.h b/src/declarative/debugger/qjsdebugservice_p.h index 7e7642e..4f99043 100644 --- a/src/declarative/debugger/qjsdebugservice_p.h +++ b/src/declarative/debugger/qjsdebugservice_p.h @@ -54,6 +54,7 @@ // #include +#include #include "private/qdeclarativedebugservice_p.h" @@ -66,6 +67,23 @@ QT_MODULE(Declarative) class QDeclarativeEngine; class QJSDebuggerAgent; +struct JSAgentCoverageData +{ + QByteArray prefix; + qint64 time; + int messageType; + + qint64 scriptId; + QString program; + QString fileName; + int baseLineNumber; + int lineNumber; + int columnNumber; + QString returnValue; + + QByteArray toByteArray() const; +}; + class QJSDebugService : public QDeclarativeDebugService { Q_OBJECT @@ -78,6 +96,9 @@ public: void addEngine(QDeclarativeEngine *); void removeEngine(QDeclarativeEngine *); + void processMessage(const JSAgentCoverageData &message); + + QElapsedTimer m_timer; protected: void statusChanged(Status status); @@ -88,8 +109,11 @@ private Q_SLOTS: const QString &exception); private: + void sendMessages(); QList m_engines; QPointer m_agent; + bool m_deferredSend; + QList m_data; }; QT_END_NAMESPACE diff --git a/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp b/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp index a40bcc0..1990c0d 100644 --- a/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp +++ b/tests/auto/declarative/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp @@ -69,6 +69,8 @@ public: void expandObjectById(const QByteArray& objectName, quint64 objectId); void setProperty(const QByteArray& id, qint64 objectId, const QString &property, const QString &value); void activateFrame(int frameId); + void startCoverageCompleted(); + void startCoverageRun(); // info from last exec JSAgentWatchData exec_data; @@ -94,6 +96,11 @@ signals: void stopped(); void expanded(); void watchTriggered(); + void coverageScriptLoaded(); + void coverageFuncEntered(); + void coverageFuncExited(); + void coveragePosChanged(); + void coverageCompleted(); protected: virtual void statusChanged(Status status); @@ -156,6 +163,9 @@ private slots: void setProperty4(); void activateFrame2(); void verifyQMLOptimizerDisabled(); + void testCoverageCompleted(); + void testCoverageRun(); + }; @@ -280,6 +290,28 @@ void QJSDebugClient::activateFrame(int frameId) sendMessage(reply); } +void QJSDebugClient::startCoverageRun() +{ + QByteArray reply; + QDataStream rs(&reply, QIODevice::WriteOnly); + QByteArray cmd = "COVERAGE"; + bool enabled = true; + rs << cmd + << enabled; + sendMessage(reply); +} + +void QJSDebugClient::startCoverageCompleted() +{ + QByteArray reply; + QDataStream rs(&reply, QIODevice::WriteOnly); + QByteArray cmd = "COVERAGE"; + bool enabled = false; + rs << cmd + << enabled; + sendMessage(reply); +} + void QJSDebugClient::statusChanged(Status /*status*/) { emit statusHasChanged(); @@ -317,6 +349,30 @@ void QJSDebugClient::messageReceived(const QByteArray &data) stream >> ping; QCOMPARE(ping, m_ping); emit pong(); + } else if (command == "COVERAGE") { + qint64 time; + int messageType; + qint64 scriptId; + QString program; + QString fileName; + int baseLineNumber; + int lineNumber; + int columnNumber; + QString returnValue; + + stream >> time >> messageType >> scriptId >> program >> fileName >> baseLineNumber + >> lineNumber >> columnNumber >> returnValue; + if (messageType == CoverageComplete) { + emit coverageCompleted(); + } else if (messageType == CoverageScriptLoad) { + emit coverageScriptLoaded(); + } else if (messageType == CoveragePosChange) { + emit coveragePosChanged(); + } else if (messageType == CoverageFuncEntry) { + emit coverageFuncEntered(); + } else if (messageType == CoverageFuncExit) { + emit coverageFuncExited(); + } } else { QFAIL("Unknown message :" + command); } @@ -1336,6 +1392,51 @@ void tst_QDeclarativeDebugJS::verifyQMLOptimizerDisabled() QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(stopped()))); } + +void tst_QDeclarativeDebugJS::testCoverageCompleted() +{ + QJSDebugProcess process; + process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + QVERIFY(process.waitForStarted()); + + QDeclarativeDebugConnection connection; + connection.connectToHost("127.0.0.1", 3771); + QVERIFY(connection.waitForConnected()); + + QJSDebugClient client(&connection); + QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged()))); + if (client.status() == QJSDebugClient::Unavailable) + QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged()))); + QCOMPARE(client.status(), QJSDebugClient::Enabled); + + client.startCoverageCompleted(); + QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coverageCompleted()))); +} + +void tst_QDeclarativeDebugJS::testCoverageRun() +{ + QJSDebugProcess process; + process.start(QStringList() << "-qmljsdebugger=port:3771,block" << TEST_FILE("backtrace1.qml")); + QVERIFY(process.waitForStarted()); + + QDeclarativeDebugConnection connection; + connection.connectToHost("127.0.0.1", 3771); + QVERIFY(connection.waitForConnected()); + + QJSDebugClient client(&connection); + QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged()))); + if (client.status() == QJSDebugClient::Unavailable) + QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(statusHasChanged()))); + QCOMPARE(client.status(), QJSDebugClient::Enabled); + + client.startCoverageRun(); + client.startCoverageCompleted(); + QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coverageScriptLoaded()))); + QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coveragePosChanged()))); + //QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coverageFuncEntered()))); + //QVERIFY(QDeclarativeDebugTest::waitForSignal(&client, SIGNAL(coverageFuncExited()))); +} + QTEST_MAIN(tst_QDeclarativeDebugJS) #include "tst_qdeclarativedebugjs.moc" -- cgit v0.12 From 19b666195e293a71ef918f4a7f91d7f8be5f69bc Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Wed, 22 Jun 2011 14:59:48 +0200 Subject: qmlplugindump: Build debug version if possible. Done-with: owolff --- tools/qmlplugindump/qmlplugindump.pro | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/qmlplugindump/qmlplugindump.pro b/tools/qmlplugindump/qmlplugindump.pro index 53827e2..e9fcdc7 100644 --- a/tools/qmlplugindump/qmlplugindump.pro +++ b/tools/qmlplugindump/qmlplugindump.pro @@ -16,5 +16,22 @@ HEADERS += \ OTHER_FILES += Info.plist macx: QMAKE_INFO_PLIST = Info.plist +# Build debug and release versions of the tool on Windows - +# if debug and release versions of Qt have been built. +!build_pass:win32 { + CONFIG -= debug release debug_and_release build_all + + contains(QT_CONFIG,debug):contains(QT_CONFIG,release) { + CONFIG += debug_and_release build_all + } else { + contains(QT_CONFIG,debug): CONFIG += debug + contains(QT_CONFIG,release): CONFIG += release + } +} + +CONFIG(debug, debug|release) { + win32: TARGET = $$join(TARGET,,,d) +} + target.path = $$[QT_INSTALL_BINS] INSTALLS += target -- cgit v0.12 From 21af9f0be1dd0d9be6c3767074fdfbd54e3b8372 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Wed, 22 Jun 2011 17:13:56 +0200 Subject: qmlplugindump: For extended types, remove exports of the base object. Reviewed-by: Kai Koehne --- tools/qmlplugindump/main.cpp | 47 +++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index 403e3b6..b414c3f 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -160,29 +160,36 @@ QSet collectReachableMetaObjects(const QString &importCode, collectReachableMetaObjects(ty, &metas); } - // Adjust ids of extended objects. - // The chain ends up being: - // __extended__.originalname - the base object - // __extension_0_.originalname - first extension - // .. - // __extension_n-2_.originalname - second to last extension - // originalname - last extension - // ### does this actually work for multiple extensions? it seems like the prototypes might be wrong - foreach (const QByteArray &extendedCpp, extensions.keys()) { - cppToId.remove(extendedCpp); - const QByteArray extendedId = convertToId(extendedCpp); - cppToId.insert(extendedCpp, "__extended__." + extendedId); - QSet extensionCppNames = extensions.value(extendedCpp); - int c = 0; + // Adjust exports of the base object if there are extensions. + // For each export of a base object there can be a single extension object overriding it. + // Example: QDeclarativeGraphicsWidget overrides the QtQuick/QGraphicsWidget export + // of QGraphicsWidget. + foreach (const QByteArray &baseCpp, extensions.keys()) { + QSet baseExports = qmlTypesByCppName.value(baseCpp); + + const QSet extensionCppNames = extensions.value(baseCpp); foreach (const QByteArray &extensionCppName, extensionCppNames) { - if (c != extensionCppNames.size() - 1) { - QByteArray adjustedName = QString("__extension__%1.%2").arg(QString::number(c), QString(extendedId)).toAscii(); - cppToId.insert(extensionCppName, adjustedName); - } else { - cppToId.insert(extensionCppName, extendedId); + const QSet extensionExports = qmlTypesByCppName.value(extensionCppName); + + // remove extension exports from base imports + // unfortunately the QDeclarativeType pointers don't match, so can't use QSet::substract + QSet newBaseExports; + foreach (const QDeclarativeType *baseExport, baseExports) { + bool match = false; + foreach (const QDeclarativeType *extensionExport, extensionExports) { + if (baseExport->module() == extensionExport->module() + && baseExport->majorVersion() == extensionExport->majorVersion() + && baseExport->minorVersion() == extensionExport->minorVersion()) { + match = true; + break; + } + } + if (!match) + newBaseExports.insert(baseExport); } - ++c; + baseExports = newBaseExports; } + qmlTypesByCppName[baseCpp] = baseExports; } // find even more QMetaObjects by instantiating QML types and running -- cgit v0.12 From 4995fedcfbfc4c82412bdc126dfd37b81841354c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 8 Jun 2011 17:47:47 +0200 Subject: QmlInspector: Share code between QGV/SG based QML debugging Introduced AbstractViewInspector, which forms the base class for QDeclarativeViewInspector and SGViewInspector and is where common code, like handling the protocol is placed. Some virtual and pure virtual functions exist which the subclasses will override or implement for QDeclarativeView/QSGView specific stuff. (cherry picked from commit 092c7fb12d32b3d1cd933707bf9e55156e2ae306 in Qt 5 / QtDeclarative, to make synchronizing future changes easier) Change-Id: Iff0e655538bb3753507fa76be378f3dbd68988fc Reviewed-by: Kai Koehne --- .../qmldbg_inspector/abstractviewinspector.cpp | 490 +++++++++++++++++ .../qmldbg_inspector/abstractviewinspector.h | 155 ++++++ .../qmldbg_inspector/qdeclarativeinspectorplugin.h | 4 +- .../qmldbg_inspector/qdeclarativeviewinspector.cpp | 580 +++------------------ .../qmldbg_inspector/qdeclarativeviewinspector_p.h | 56 +- .../qdeclarativeviewinspector_p_p.h | 35 +- .../qmldbg_inspector/qmldbg_inspector.pro | 2 + .../qmldbg_inspector/qmlinspectorconstants_p.h | 5 - 8 files changed, 732 insertions(+), 595 deletions(-) create mode 100644 src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp create mode 100644 src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp new file mode 100644 index 0000000..fdec0e7 --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp @@ -0,0 +1,490 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "abstractviewinspector.h" + +#include "editor/qmltoolbar_p.h" +#include "qdeclarativeinspectorprotocol.h" + +#include +#include +#include +#include "QtDeclarative/private/qdeclarativeinspectorservice_p.h" + +#include +#include + +static inline void initEditorResource() { Q_INIT_RESOURCE(editor); } + +QT_BEGIN_NAMESPACE + +const char * const KEY_TOOLBOX_GEOMETRY = "toolBox/geometry"; + + +class ToolBox : public QWidget +{ + Q_OBJECT + +public: + ToolBox(QWidget *parent = 0); + ~ToolBox(); + + QmlToolBar *toolBar() const { return m_toolBar; } + +private: + QSettings m_settings; + QmlToolBar *m_toolBar; +}; + +ToolBox::ToolBox(QWidget *parent) + : QWidget(parent, Qt::Tool) + , m_settings(QLatin1String("Nokia"), QLatin1String("QmlInspector"), this) + , m_toolBar(new QmlToolBar) +{ + setWindowFlags((windowFlags() & ~Qt::WindowCloseButtonHint) | Qt::CustomizeWindowHint); + setWindowTitle(tr("Qt Quick Toolbox")); + + QVBoxLayout *verticalLayout = new QVBoxLayout; + verticalLayout->setMargin(0); + verticalLayout->addWidget(m_toolBar); + setLayout(verticalLayout); + + restoreGeometry(m_settings.value(QLatin1String(KEY_TOOLBOX_GEOMETRY)).toByteArray()); +} + +ToolBox::~ToolBox() +{ + m_settings.setValue(QLatin1String(KEY_TOOLBOX_GEOMETRY), saveGeometry()); +} + + +AbstractViewInspector::AbstractViewInspector(QObject *parent) : + QObject(parent), + m_toolBox(0), + m_showAppOnTop(false), + m_designModeBehavior(false), + m_animationPaused(false), + m_slowDownFactor(1.0), + m_debugService(0) +{ + initEditorResource(); + + m_debugService = QDeclarativeInspectorService::instance(); + connect(m_debugService, SIGNAL(gotMessage(QByteArray)), + this, SLOT(handleMessage(QByteArray))); +} + +void AbstractViewInspector::createQmlObject(const QString &qml, QObject *parent, + const QStringList &importList, + const QString &filename) +{ + if (!parent) + return; + + QString imports; + foreach (const QString &s, importList) { + imports += s; + imports += QLatin1Char('\n'); + } + + QDeclarativeContext *parentContext = declarativeEngine()->contextForObject(parent); + QDeclarativeComponent component(declarativeEngine()); + QByteArray constructedQml = QString(imports + qml).toLatin1(); + + component.setData(constructedQml, QUrl::fromLocalFile(filename)); + QObject *newObject = component.create(parentContext); + if (newObject) + reparentQmlObject(newObject, parent); +} + +void AbstractViewInspector::clearComponentCache() +{ + declarativeEngine()->clearComponentCache(); +} + +void AbstractViewInspector::setDesignModeBehavior(bool value) +{ + if (m_designModeBehavior == value) + return; + + m_designModeBehavior = value; + emit designModeBehaviorChanged(value); + sendDesignModeBehavior(value); +} + +void AbstractViewInspector::setAnimationSpeed(qreal slowDownFactor) +{ + Q_ASSERT(slowDownFactor > 0); + if (m_slowDownFactor == slowDownFactor) + return; + + animationSpeedChangeRequested(slowDownFactor); + sendAnimationSpeed(slowDownFactor); +} + +void AbstractViewInspector::setAnimationPaused(bool paused) +{ + if (m_animationPaused == paused) + return; + + animationPausedChangeRequested(paused); + sendAnimationPaused(paused); +} + +void AbstractViewInspector::animationSpeedChangeRequested(qreal factor) +{ + if (m_slowDownFactor != factor) { + m_slowDownFactor = factor; + emit animationSpeedChanged(factor); + } + + const float effectiveFactor = m_animationPaused ? 0 : factor; + QDeclarativeDebugHelper::setAnimationSlowDownFactor(effectiveFactor); +} + +void AbstractViewInspector::animationPausedChangeRequested(bool paused) +{ + if (m_animationPaused != paused) { + m_animationPaused = paused; + emit animationPausedChanged(paused); + } + + const float effectiveFactor = paused ? 0 : m_slowDownFactor; + QDeclarativeDebugHelper::setAnimationSlowDownFactor(effectiveFactor); +} + +void AbstractViewInspector::setShowAppOnTop(bool appOnTop) +{ + if (viewWidget()) { + QWidget *window = viewWidget()->window(); + Qt::WindowFlags flags = window->windowFlags(); + if (appOnTop) + flags |= Qt::WindowStaysOnTopHint; + else + flags &= ~Qt::WindowStaysOnTopHint; + + window->setWindowFlags(flags); + window->show(); + } + + m_showAppOnTop = appOnTop; + sendShowAppOnTop(appOnTop); + + emit showAppOnTopChanged(appOnTop); +} + +void AbstractViewInspector::setToolBoxVisible(bool visible) +{ +#if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_MAEMO_5) && !defined(Q_WS_SIMULATOR) + if (!m_toolBox && visible) + createToolBox(); + if (m_toolBox) + m_toolBox->setVisible(visible); +#else + Q_UNUSED(visible) +#endif +} + +void AbstractViewInspector::createToolBox() +{ + m_toolBox = new ToolBox(viewWidget()); + + QmlToolBar *toolBar = m_toolBox->toolBar(); + + QObject::connect(this, SIGNAL(selectedColorChanged(QColor)), + toolBar, SLOT(setColorBoxColor(QColor))); + + QObject::connect(this, SIGNAL(designModeBehaviorChanged(bool)), + toolBar, SLOT(setDesignModeBehavior(bool))); + + QObject::connect(toolBar, SIGNAL(designModeBehaviorChanged(bool)), + this, SLOT(setDesignModeBehavior(bool))); + QObject::connect(toolBar, SIGNAL(animationSpeedChanged(qreal)), this, SLOT(setAnimationSpeed(qreal))); + QObject::connect(toolBar, SIGNAL(animationPausedChanged(bool)), this, SLOT(setAnimationPaused(bool))); + QObject::connect(toolBar, SIGNAL(colorPickerSelected()), this, SLOT(changeToColorPickerTool())); + QObject::connect(toolBar, SIGNAL(zoomToolSelected()), this, SLOT(changeToZoomTool())); + QObject::connect(toolBar, SIGNAL(selectToolSelected()), this, SLOT(changeToSingleSelectTool())); + QObject::connect(toolBar, SIGNAL(marqueeSelectToolSelected()), + this, SLOT(changeToMarqueeSelectTool())); + + QObject::connect(toolBar, SIGNAL(applyChangesFromQmlFileSelected()), + this, SLOT(applyChangesFromClient())); + + QObject::connect(this, SIGNAL(animationSpeedChanged(qreal)), toolBar, SLOT(setAnimationSpeed(qreal))); + QObject::connect(this, SIGNAL(animationPausedChanged(bool)), toolBar, SLOT(setAnimationPaused(bool))); + + QObject::connect(this, SIGNAL(selectToolActivated()), toolBar, SLOT(activateSelectTool())); + + // disabled features + //connect(d->m_toolBar, SIGNAL(applyChangesToQmlFileSelected()), SLOT(applyChangesToClient())); + //connect(q, SIGNAL(resizeToolActivated()), d->m_toolBar, SLOT(activateSelectTool())); + //connect(q, SIGNAL(moveToolActivated()), d->m_toolBar, SLOT(activateSelectTool())); + + QObject::connect(this, SIGNAL(colorPickerActivated()), toolBar, SLOT(activateColorPicker())); + QObject::connect(this, SIGNAL(zoomToolActivated()), toolBar, SLOT(activateZoom())); + QObject::connect(this, SIGNAL(marqueeSelectToolActivated()), + toolBar, SLOT(activateMarqueeSelectTool())); +} + +void AbstractViewInspector::changeToColorPickerTool() +{ + changeTool(InspectorProtocol::ColorPickerTool); +} + +void AbstractViewInspector::changeToZoomTool() +{ + changeTool(InspectorProtocol::ZoomTool); +} + +void AbstractViewInspector::changeToSingleSelectTool() +{ + changeTool(InspectorProtocol::SelectTool); +} + +void AbstractViewInspector::changeToMarqueeSelectTool() +{ + changeTool(InspectorProtocol::SelectMarqueeTool); +} + +void AbstractViewInspector::handleMessage(const QByteArray &message) +{ + QDataStream ds(message); + + InspectorProtocol::Message type; + ds >> type; + + switch (type) { + case InspectorProtocol::SetCurrentObjects: { + int itemCount = 0; + ds >> itemCount; + + QList selectedObjects; + for (int i = 0; i < itemCount; ++i) { + int debugId = -1; + ds >> debugId; + if (QObject *obj = QDeclarativeDebugService::objectForId(debugId)) + selectedObjects << obj; + } + + changeCurrentObjects(selectedObjects); + break; + } + case InspectorProtocol::Reload: { + reloadView(); + break; + } + case InspectorProtocol::SetAnimationSpeed: { + qreal speed; + ds >> speed; + animationSpeedChangeRequested(speed); + break; + } + case InspectorProtocol::SetAnimationPaused: { + bool paused; + ds >> paused; + animationPausedChangeRequested(paused); + break; + } + case InspectorProtocol::ChangeTool: { + InspectorProtocol::Tool tool; + ds >> tool; + changeTool(tool); + break; + } + case InspectorProtocol::SetDesignMode: { + bool inDesignMode; + ds >> inDesignMode; + setDesignModeBehavior(inDesignMode); + break; + } + case InspectorProtocol::ShowAppOnTop: { + bool showOnTop; + ds >> showOnTop; + setShowAppOnTop(showOnTop); + break; + } + case InspectorProtocol::CreateObject: { + QString qml; + int parentId; + QString filename; + QStringList imports; + ds >> qml >> parentId >> imports >> filename; + createQmlObject(qml, QDeclarativeDebugService::objectForId(parentId), + imports, filename); + break; + } + case InspectorProtocol::DestroyObject: { + int debugId; + ds >> debugId; + if (QObject *obj = QDeclarativeDebugService::objectForId(debugId)) + obj->deleteLater(); + break; + } + case InspectorProtocol::MoveObject: { + int debugId, newParent; + ds >> debugId >> newParent; + reparentQmlObject(QDeclarativeDebugService::objectForId(debugId), + QDeclarativeDebugService::objectForId(newParent)); + break; + } + case InspectorProtocol::ObjectIdList: { + int itemCount; + ds >> itemCount; + m_stringIdForObjectId.clear(); + for (int i = 0; i < itemCount; ++i) { + int itemDebugId; + QString itemIdString; + ds >> itemDebugId + >> itemIdString; + + m_stringIdForObjectId.insert(itemDebugId, itemIdString); + } + break; + } + case InspectorProtocol::ClearComponentCache: { + clearComponentCache(); + break; + } + default: + qWarning() << "Warning: Not handling message:" << type; + } +} + +void AbstractViewInspector::sendDesignModeBehavior(bool inDesignMode) +{ + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + + ds << InspectorProtocol::SetDesignMode + << inDesignMode; + + m_debugService->sendMessage(message); +} + +void AbstractViewInspector::sendCurrentObjects(const QList &objects) +{ + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + + ds << InspectorProtocol::CurrentObjectsChanged + << objects.length(); + + foreach (QObject *object, objects) { + int id = QDeclarativeDebugService::idForObject(object); + ds << id; + } + + m_debugService->sendMessage(message); +} + +void AbstractViewInspector::sendCurrentTool(Constants::DesignTool toolId) +{ + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + + ds << InspectorProtocol::ToolChanged + << toolId; + + m_debugService->sendMessage(message); +} + +void AbstractViewInspector::sendAnimationSpeed(qreal slowDownFactor) +{ + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + + ds << InspectorProtocol::AnimationSpeedChanged + << slowDownFactor; + + m_debugService->sendMessage(message); +} + +void AbstractViewInspector::sendAnimationPaused(bool paused) +{ + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + + ds << InspectorProtocol::AnimationPausedChanged + << paused; + + m_debugService->sendMessage(message); +} + +void AbstractViewInspector::sendReloaded() +{ + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + + ds << InspectorProtocol::Reloaded; + + m_debugService->sendMessage(message); +} + +void AbstractViewInspector::sendShowAppOnTop(bool showAppOnTop) +{ + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + + ds << InspectorProtocol::ShowAppOnTop << showAppOnTop; + + m_debugService->sendMessage(message); +} + +void AbstractViewInspector::sendColorChanged(const QColor &color) +{ + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + + ds << InspectorProtocol::ColorChanged + << color; + + m_debugService->sendMessage(message); +} + +QString AbstractViewInspector::idStringForObject(QObject *obj) const +{ + const int id = QDeclarativeDebugService::idForObject(obj); + return m_stringIdForObjectId.value(id); +} + +QT_END_NAMESPACE + +#include "abstractviewinspector.moc" diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h new file mode 100644 index 0000000..b89a6eb --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ABSTRACTVIEWINSPECTOR_H +#define ABSTRACTVIEWINSPECTOR_H + +#include +#include +#include +#include + +#include "qdeclarativeinspectorprotocol.h" +#include "qmlinspectorconstants_p.h" + +QT_BEGIN_NAMESPACE + +class QDeclarativeEngine; +class QDeclarativeInspectorService; +class ToolBox; + +/* + * The common code between QSGView and QDeclarativeView inspectors lives here, + */ +class AbstractViewInspector : public QObject +{ + Q_OBJECT + +public: + explicit AbstractViewInspector(QObject *parent = 0); + + virtual void changeCurrentObjects(const QList &objects) = 0; + + virtual void reloadView() = 0; + + void createQmlObject(const QString &qml, QObject *parent, + const QStringList &importList, + const QString &filename = QString()); + + virtual void reparentQmlObject(QObject *object, QObject *newParent) = 0; + + virtual void changeTool(InspectorProtocol::Tool tool) = 0; + + void clearComponentCache(); + + virtual QWidget *viewWidget() const = 0; + virtual QDeclarativeEngine *declarativeEngine() const = 0; + + + bool showAppOnTop() const { return m_showAppOnTop; } + bool designModeBehavior() const { return m_designModeBehavior; } + + bool animationPaused() const { return m_animationPaused; } + qreal slowDownFactor() const { return m_slowDownFactor; } + + void sendCurrentObjects(const QList &); + void sendAnimationSpeed(qreal slowDownFactor); + void sendAnimationPaused(bool paused); + void sendCurrentTool(Constants::DesignTool toolId); + void sendReloaded(); + void sendShowAppOnTop(bool showAppOnTop); + + QString idStringForObject(QObject *obj) const; + +public slots: + void sendDesignModeBehavior(bool inDesignMode); + void sendColorChanged(const QColor &color); + + void changeToColorPickerTool(); + void changeToZoomTool(); + void changeToSingleSelectTool(); + void changeToMarqueeSelectTool(); + + virtual void setDesignModeBehavior(bool value); + + void setShowAppOnTop(bool appOnTop); + + void setAnimationSpeed(qreal factor); + void setAnimationPaused(bool paused); + +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); + +private slots: + void handleMessage(const QByteArray &message); + +private: + void animationSpeedChangeRequested(qreal factor); + void animationPausedChangeRequested(bool paused); + + void setToolBoxVisible(bool visible); + void createToolBox(); + + ToolBox *m_toolBox; + + bool m_showAppOnTop; + bool m_designModeBehavior; + + bool m_animationPaused; + qreal m_slowDownFactor; + + QHash m_stringIdForObjectId; + QDeclarativeInspectorService *m_debugService; +}; + +QT_END_NAMESPACE + +#endif // ABSTRACTVIEWINSPECTOR_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.h index 3e28643..e271c07 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.h @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE -class QDeclarativeViewInspector; +class AbstractViewInspector; class QDeclarativeInspectorPlugin : public QObject, public QDeclarativeInspectorInterface { @@ -63,7 +63,7 @@ public: void deactivate(); private: - QPointer m_inspector; + QPointer m_inspector; }; QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp index 19bfdaa..be0422d 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp @@ -39,84 +39,28 @@ ** ****************************************************************************/ -#include "QtDeclarative/private/qdeclarativeinspectorservice_p.h" -#include "QtDeclarative/private/qdeclarativedebughelper_p.h" - #include "qdeclarativeviewinspector_p.h" #include "qdeclarativeviewinspector_p_p.h" -#include "qdeclarativeinspectorprotocol.h" #include "editor/liveselectiontool_p.h" #include "editor/zoomtool_p.h" #include "editor/colorpickertool_p.h" #include "editor/livelayeritem_p.h" #include "editor/boundingrecthighlighter_p.h" -#include "editor/qmltoolbar_p.h" #include #include #include #include #include -#include #include #include #include -#include - -static inline void initEditorResource() { Q_INIT_RESOURCE(editor); } QT_BEGIN_NAMESPACE -const char * const KEY_TOOLBOX_GEOMETRY = "toolBox/geometry"; - -const int SceneChangeUpdateInterval = 5000; - - -class ToolBox : public QWidget -{ - Q_OBJECT - -public: - ToolBox(QWidget *parent = 0); - ~ToolBox(); - - QmlToolBar *toolBar() const { return m_toolBar; } - -private: - QSettings m_settings; - QmlToolBar *m_toolBar; -}; - -ToolBox::ToolBox(QWidget *parent) - : QWidget(parent, Qt::Tool) - , m_settings(QLatin1String("Nokia"), QLatin1String("QmlInspector"), this) - , m_toolBar(new QmlToolBar) -{ - setWindowFlags((windowFlags() & ~Qt::WindowCloseButtonHint) | Qt::CustomizeWindowHint); - setWindowTitle(tr("Qt Quick Toolbox")); - - QVBoxLayout *verticalLayout = new QVBoxLayout; - verticalLayout->setMargin(0); - verticalLayout->addWidget(m_toolBar); - setLayout(verticalLayout); - - restoreGeometry(m_settings.value(QLatin1String(KEY_TOOLBOX_GEOMETRY)).toByteArray()); -} - -ToolBox::~ToolBox() -{ - m_settings.setValue(QLatin1String(KEY_TOOLBOX_GEOMETRY), saveGeometry()); -} - - QDeclarativeViewInspectorPrivate::QDeclarativeViewInspectorPrivate(QDeclarativeViewInspector *q) : - q(q), - designModeBehavior(false), - showAppOnTop(false), - animationPaused(false), - slowDownFactor(1.0f), - toolBox(0) + q(q) { } @@ -126,11 +70,9 @@ QDeclarativeViewInspectorPrivate::~QDeclarativeViewInspectorPrivate() QDeclarativeViewInspector::QDeclarativeViewInspector(QDeclarativeView *view, QObject *parent) : - QObject(parent), + AbstractViewInspector(parent), data(new QDeclarativeViewInspectorPrivate(this)) { - initEditorResource(); - data->view = view; data->manipulatorLayer = new LiveLayerItem(view->scene()); data->selectionTool = new LiveSelectionTool(this); @@ -144,10 +86,6 @@ QDeclarativeViewInspector::QDeclarativeViewInspector(QDeclarativeView *view, data->setViewport(data->view->viewport()); - data->debugService = QDeclarativeInspectorService::instance(); - connect(data->debugService, SIGNAL(gotMessage(QByteArray)), - this, SLOT(handleMessage(QByteArray))); - connect(data->view, SIGNAL(statusChanged(QDeclarativeView::Status)), data.data(), SLOT(_q_onStatusChanged(QDeclarativeView::Status))); @@ -156,29 +94,57 @@ QDeclarativeViewInspector::QDeclarativeViewInspector(QDeclarativeView *view, connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)), this, SLOT(sendColorChanged(QColor))); - data->_q_changeToSingleSelectTool(); + changeTool(InspectorProtocol::SelectTool); } QDeclarativeViewInspector::~QDeclarativeViewInspector() { } -void QDeclarativeViewInspectorPrivate::_q_setToolBoxVisible(bool visible) +void QDeclarativeViewInspector::changeCurrentObjects(const QList &objects) { -#if !defined(Q_OS_SYMBIAN) && !defined(Q_WS_MAEMO_5) && !defined(Q_WS_SIMULATOR) - if (!toolBox && visible) - createToolBox(); - if (toolBox) - toolBox->setVisible(visible); -#else - Q_UNUSED(visible) -#endif + QList items; + QList gfxObjects; + foreach (QObject *obj, objects) { + if (QDeclarativeItem *declarativeItem = qobject_cast(obj)) { + items << declarativeItem; + gfxObjects << declarativeItem; + } + } + if (designModeBehavior()) { + data->setSelectedItemsForTools(items); + data->clearHighlight(); + data->highlight(gfxObjects); + } } -void QDeclarativeViewInspectorPrivate::_q_reloadView() +void QDeclarativeViewInspector::reloadView() { - clearHighlight(); - emit q->reloadRequested(); + data->clearHighlight(); + emit reloadRequested(); +} + +void QDeclarativeViewInspector::changeTool(InspectorProtocol::Tool tool) +{ + switch (tool) { + case InspectorProtocol::ColorPickerTool: + data->changeToColorPickerTool(); + break; + case InspectorProtocol::SelectMarqueeTool: + data->changeToMarqueeSelectTool(); + break; + case InspectorProtocol::SelectTool: + data->changeToSingleSelectTool(); + break; + case InspectorProtocol::ZoomTool: + data->changeToZoomTool(); + break; + } +} + +QDeclarativeEngine *QDeclarativeViewInspector::declarativeEngine() const +{ + return data->view->engine(); } void QDeclarativeViewInspectorPrivate::setViewport(QWidget *widget) @@ -268,7 +234,7 @@ bool QDeclarativeViewInspector::eventFilter(QObject *obj, QEvent *event) bool QDeclarativeViewInspector::leaveEvent(QEvent * /*event*/) { - if (!data->designModeBehavior) + if (!designModeBehavior()) return false; data->clearHighlight(); return true; @@ -276,7 +242,7 @@ bool QDeclarativeViewInspector::leaveEvent(QEvent * /*event*/) bool QDeclarativeViewInspector::mousePressEvent(QMouseEvent *event) { - if (!data->designModeBehavior) + if (!designModeBehavior()) return false; data->cursorPos = event->pos(); data->currentTool->mousePressEvent(event); @@ -285,7 +251,7 @@ bool QDeclarativeViewInspector::mousePressEvent(QMouseEvent *event) bool QDeclarativeViewInspector::mouseMoveEvent(QMouseEvent *event) { - if (!data->designModeBehavior) { + if (!designModeBehavior()) { data->clearEditorItems(); return false; } @@ -307,7 +273,7 @@ bool QDeclarativeViewInspector::mouseMoveEvent(QMouseEvent *event) bool QDeclarativeViewInspector::mouseReleaseEvent(QMouseEvent *event) { - if (!data->designModeBehavior) + if (!designModeBehavior()) return false; data->cursorPos = event->pos(); @@ -317,7 +283,7 @@ bool QDeclarativeViewInspector::mouseReleaseEvent(QMouseEvent *event) bool QDeclarativeViewInspector::keyPressEvent(QKeyEvent *event) { - if (!data->designModeBehavior) + if (!designModeBehavior()) return false; data->currentTool->keyPressEvent(event); @@ -326,25 +292,25 @@ bool QDeclarativeViewInspector::keyPressEvent(QKeyEvent *event) bool QDeclarativeViewInspector::keyReleaseEvent(QKeyEvent *event) { - if (!data->designModeBehavior) + if (!designModeBehavior()) return false; switch (event->key()) { case Qt::Key_V: - data->_q_changeToSingleSelectTool(); + changeTool(InspectorProtocol::SelectTool); break; // disabled because multiselection does not do anything useful without design mode // case Qt::Key_M: -// data->_q_changeToMarqueeSelectTool(); +// changeTool(InspectorProtocol::SelectMarqueeTool); // break; case Qt::Key_I: - data->_q_changeToColorPickerTool(); + changeTool(InspectorProtocol::ColorPickerTool); break; case Qt::Key_Z: - data->_q_changeToZoomTool(); + changeTool(InspectorProtocol::ZoomTool); break; case Qt::Key_Space: - setAnimationPaused(!data->animationPaused); + setAnimationPaused(!animationPaused()); break; default: break; @@ -354,35 +320,7 @@ bool QDeclarativeViewInspector::keyReleaseEvent(QKeyEvent *event) return true; } -void QDeclarativeViewInspectorPrivate::_q_createQmlObject(const QString &qml, QObject *parent, - const QStringList &importList, - const QString &filename) -{ - if (!parent) - return; - - QString imports; - foreach (const QString &s, importList) { - imports += s; - imports += QLatin1Char('\n'); - } - - QDeclarativeContext *parentContext = view->engine()->contextForObject(parent); - QDeclarativeComponent component(view->engine(), q); - QByteArray constructedQml = QString(imports + qml).toLatin1(); - - component.setData(constructedQml, QUrl::fromLocalFile(filename)); - QObject *newObject = component.create(parentContext); - if (newObject) { - newObject->setParent(parent); - QDeclarativeItem *parentItem = qobject_cast(parent); - QDeclarativeItem *newItem = qobject_cast(newObject); - if (parentItem && newItem) - newItem->setParentItem(parentItem); - } -} - -void QDeclarativeViewInspectorPrivate::_q_reparentQmlObject(QObject *object, QObject *newParent) +void QDeclarativeViewInspector::reparentQmlObject(QObject *object, QObject *newParent) { if (!newParent) return; @@ -394,11 +332,6 @@ void QDeclarativeViewInspectorPrivate::_q_reparentQmlObject(QObject *object, QOb item->setParentItem(newParentItem); } -void QDeclarativeViewInspectorPrivate::_q_clearComponentCache() -{ - view->engine()->clearComponentCache(); -} - void QDeclarativeViewInspectorPrivate::_q_removeFromSelection(QObject *obj) { QList items = selectedItems(); @@ -409,7 +342,7 @@ void QDeclarativeViewInspectorPrivate::_q_removeFromSelection(QObject *obj) bool QDeclarativeViewInspector::mouseDoubleClickEvent(QMouseEvent * /*event*/) { - if (!data->designModeBehavior) + if (!designModeBehavior()) return false; return true; @@ -417,70 +350,12 @@ bool QDeclarativeViewInspector::mouseDoubleClickEvent(QMouseEvent * /*event*/) bool QDeclarativeViewInspector::wheelEvent(QWheelEvent *event) { - if (!data->designModeBehavior) + if (!designModeBehavior()) return false; data->currentTool->wheelEvent(event); return true; } -void QDeclarativeViewInspector::setDesignModeBehavior(bool value) -{ - emit designModeBehaviorChanged(value); - - if (data->toolBox) - data->toolBox->toolBar()->setDesignModeBehavior(value); - sendDesignModeBehavior(value); - - data->designModeBehavior = value; - - if (!data->designModeBehavior) - data->clearEditorItems(); -} - -bool QDeclarativeViewInspector::designModeBehavior() -{ - return data->designModeBehavior; -} - -bool QDeclarativeViewInspector::showAppOnTop() const -{ - return data->showAppOnTop; -} - -void QDeclarativeViewInspector::setShowAppOnTop(bool appOnTop) -{ - if (data->view) { - QWidget *window = data->view->window(); - Qt::WindowFlags flags = window->windowFlags(); - if (appOnTop) - flags |= Qt::WindowStaysOnTopHint; - else - flags &= ~Qt::WindowStaysOnTopHint; - - window->setWindowFlags(flags); - window->show(); - } - - data->showAppOnTop = appOnTop; - sendShowAppOnTop(appOnTop); - - emit showAppOnTopChanged(appOnTop); -} - -void QDeclarativeViewInspectorPrivate::changeTool(Constants::DesignTool tool, - Constants::ToolFlags /*flags*/) -{ - switch (tool) { - case Constants::SelectionToolMode: - _q_changeToSingleSelectTool(); - break; - case Constants::NoTool: - default: - currentTool = 0; - break; - } -} - void QDeclarativeViewInspectorPrivate::setSelectedItemsForTools(const QList &items) { foreach (const QWeakPointer &obj, currentSelection) { @@ -542,7 +417,7 @@ QList QDeclarativeViewInspector::selectedItems() const return data->selectedItems(); } -QDeclarativeView *QDeclarativeViewInspector::declarativeView() +QDeclarativeView *QDeclarativeViewInspector::declarativeView() const { return data->view; } @@ -591,7 +466,7 @@ QList QDeclarativeViewInspectorPrivate::selectableItems( return filterForSelection(itemlist); } -void QDeclarativeViewInspectorPrivate::_q_changeToSingleSelectTool() +void QDeclarativeViewInspectorPrivate::changeToSingleSelectTool() { currentToolMode = Constants::SelectionToolMode; selectionTool->setRubberbandSelectionMode(false); @@ -613,7 +488,7 @@ void QDeclarativeViewInspectorPrivate::changeToSelectTool() currentTool->updateSelectedItems(); } -void QDeclarativeViewInspectorPrivate::_q_changeToMarqueeSelectTool() +void QDeclarativeViewInspectorPrivate::changeToMarqueeSelectTool() { changeToSelectTool(); currentToolMode = Constants::MarqueeSelectionToolMode; @@ -623,7 +498,7 @@ void QDeclarativeViewInspectorPrivate::_q_changeToMarqueeSelectTool() q->sendCurrentTool(Constants::MarqueeSelectionToolMode); } -void QDeclarativeViewInspectorPrivate::_q_changeToZoomTool() +void QDeclarativeViewInspectorPrivate::changeToZoomTool() { currentToolMode = Constants::ZoomMode; currentTool->clear(); @@ -634,7 +509,7 @@ void QDeclarativeViewInspectorPrivate::_q_changeToZoomTool() q->sendCurrentTool(Constants::ZoomMode); } -void QDeclarativeViewInspectorPrivate::_q_changeToColorPickerTool() +void QDeclarativeViewInspectorPrivate::changeToColorPickerTool() { if (currentTool == colorPickerTool) return; @@ -648,53 +523,14 @@ void QDeclarativeViewInspectorPrivate::_q_changeToColorPickerTool() q->sendCurrentTool(Constants::ColorPickerMode); } -void QDeclarativeViewInspector::setAnimationSpeed(qreal slowDownFactor) -{ - Q_ASSERT(slowDownFactor > 0); - if (data->slowDownFactor == slowDownFactor) - return; - - animationSpeedChangeRequested(slowDownFactor); - sendAnimationSpeed(slowDownFactor); -} - -void QDeclarativeViewInspector::setAnimationPaused(bool paused) -{ - if (data->animationPaused == paused) - return; - - animationPausedChangeRequested(paused); - sendAnimationPaused(paused); -} - -void QDeclarativeViewInspector::animationSpeedChangeRequested(qreal factor) -{ - if (data->slowDownFactor != factor) { - data->slowDownFactor = factor; - emit animationSpeedChanged(factor); - } - - const float effectiveFactor = data->animationPaused ? 0 : factor; - QDeclarativeDebugHelper::setAnimationSlowDownFactor(effectiveFactor); -} -void QDeclarativeViewInspector::animationPausedChangeRequested(bool paused) -{ - if (data->animationPaused != paused) { - data->animationPaused = paused; - emit animationPausedChanged(paused); - } - - const float effectiveFactor = paused ? 0 : data->slowDownFactor; - QDeclarativeDebugHelper::setAnimationSlowDownFactor(effectiveFactor); -} - - -void QDeclarativeViewInspectorPrivate::_q_applyChangesFromClient() +static bool isEditorItem(QGraphicsItem *item) { + return (item->type() == Constants::EditorItemType + || item->type() == Constants::ResizeHandleItemType + || item->data(Constants::EditorItemDataKey).toBool()); } - QList QDeclarativeViewInspectorPrivate::filterForSelection( QList &itemlist) const { @@ -706,36 +542,12 @@ QList QDeclarativeViewInspectorPrivate::filterForSelection( return itemlist; } -bool QDeclarativeViewInspectorPrivate::isEditorItem(QGraphicsItem *item) const -{ - return (item->type() == Constants::EditorItemType - || item->type() == Constants::ResizeHandleItemType - || item->data(Constants::EditorItemDataKey).toBool()); -} - void QDeclarativeViewInspectorPrivate::_q_onStatusChanged(QDeclarativeView::Status status) { if (status == QDeclarativeView::Ready) q->sendReloaded(); } -void QDeclarativeViewInspectorPrivate::_q_onCurrentObjectsChanged(QList objects) -{ - QList items; - QList gfxObjects; - foreach (QObject *obj, objects) { - if (QDeclarativeItem *declarativeItem = qobject_cast(obj)) { - items << declarativeItem; - gfxObjects << declarativeItem; - } - } - if (designModeBehavior) { - setSelectedItemsForTools(items); - clearHighlight(); - highlight(gfxObjects); - } -} - // adjusts bounding boxes on edges of screen to be visible QRectF QDeclarativeViewInspector::adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace) { @@ -758,264 +570,4 @@ QRectF QDeclarativeViewInspector::adjustToScreenBoundaries(const QRectF &boundin return boundingRect; } -void QDeclarativeViewInspectorPrivate::createToolBox() -{ - toolBox = new ToolBox(q->declarativeView()); - - QmlToolBar *toolBar = toolBox->toolBar(); - - QObject::connect(q, SIGNAL(selectedColorChanged(QColor)), - toolBar, SLOT(setColorBoxColor(QColor))); - - QObject::connect(q, SIGNAL(designModeBehaviorChanged(bool)), - toolBar, SLOT(setDesignModeBehavior(bool))); - - QObject::connect(toolBar, SIGNAL(designModeBehaviorChanged(bool)), - q, SLOT(setDesignModeBehavior(bool))); - QObject::connect(toolBar, SIGNAL(animationSpeedChanged(qreal)), q, SLOT(setAnimationSpeed(qreal))); - QObject::connect(toolBar, SIGNAL(animationPausedChanged(bool)), q, SLOT(setAnimationPaused(bool))); - QObject::connect(toolBar, SIGNAL(colorPickerSelected()), this, SLOT(_q_changeToColorPickerTool())); - QObject::connect(toolBar, SIGNAL(zoomToolSelected()), this, SLOT(_q_changeToZoomTool())); - QObject::connect(toolBar, SIGNAL(selectToolSelected()), this, SLOT(_q_changeToSingleSelectTool())); - QObject::connect(toolBar, SIGNAL(marqueeSelectToolSelected()), - this, SLOT(_q_changeToMarqueeSelectTool())); - - QObject::connect(toolBar, SIGNAL(applyChangesFromQmlFileSelected()), - this, SLOT(_q_applyChangesFromClient())); - - QObject::connect(q, SIGNAL(animationSpeedChanged(qreal)), toolBar, SLOT(setAnimationSpeed(qreal))); - QObject::connect(q, SIGNAL(animationPausedChanged(bool)), toolBar, SLOT(setAnimationPaused(bool))); - - QObject::connect(q, SIGNAL(selectToolActivated()), toolBar, SLOT(activateSelectTool())); - - // disabled features - //connect(d->m_toolBar, SIGNAL(applyChangesToQmlFileSelected()), SLOT(applyChangesToClient())); - //connect(q, SIGNAL(resizeToolActivated()), d->m_toolBar, SLOT(activateSelectTool())); - //connect(q, SIGNAL(moveToolActivated()), d->m_toolBar, SLOT(activateSelectTool())); - - QObject::connect(q, SIGNAL(colorPickerActivated()), toolBar, SLOT(activateColorPicker())); - QObject::connect(q, SIGNAL(zoomToolActivated()), toolBar, SLOT(activateZoom())); - QObject::connect(q, SIGNAL(marqueeSelectToolActivated()), - toolBar, SLOT(activateMarqueeSelectTool())); -} - -void QDeclarativeViewInspector::handleMessage(const QByteArray &message) -{ - QDataStream ds(message); - - InspectorProtocol::Message type; - ds >> type; - - switch (type) { - case InspectorProtocol::SetCurrentObjects: { - int itemCount = 0; - ds >> itemCount; - - QList selectedObjects; - for (int i = 0; i < itemCount; ++i) { - int debugId = -1; - ds >> debugId; - if (QObject *obj = QDeclarativeDebugService::objectForId(debugId)) - selectedObjects << obj; - } - - data->_q_onCurrentObjectsChanged(selectedObjects); - break; - } - case InspectorProtocol::Reload: { - data->_q_reloadView(); - break; - } - case InspectorProtocol::SetAnimationSpeed: { - qreal speed; - ds >> speed; - animationSpeedChangeRequested(speed); - break; - } - case InspectorProtocol::SetAnimationPaused: { - bool paused; - ds >> paused; - animationPausedChangeRequested(paused); - break; - } - case InspectorProtocol::ChangeTool: { - InspectorProtocol::Tool tool; - ds >> tool; - switch (tool) { - case InspectorProtocol::ColorPickerTool: - data->_q_changeToColorPickerTool(); - break; - case InspectorProtocol::SelectTool: - data->_q_changeToSingleSelectTool(); - break; - case InspectorProtocol::SelectMarqueeTool: - data->_q_changeToMarqueeSelectTool(); - break; - case InspectorProtocol::ZoomTool: - data->_q_changeToZoomTool(); - break; - default: - qWarning() << "Warning: Unhandled tool:" << tool; - } - break; - } - case InspectorProtocol::SetDesignMode: { - bool inDesignMode; - ds >> inDesignMode; - setDesignModeBehavior(inDesignMode); - break; - } - case InspectorProtocol::ShowAppOnTop: { - bool showOnTop; - ds >> showOnTop; - setShowAppOnTop(showOnTop); - break; - } - case InspectorProtocol::CreateObject: { - QString qml; - int parentId; - QString filename; - QStringList imports; - ds >> qml >> parentId >> imports >> filename; - data->_q_createQmlObject(qml, QDeclarativeDebugService::objectForId(parentId), - imports, filename); - break; - } - case InspectorProtocol::DestroyObject: { - int debugId; - ds >> debugId; - if (QObject* obj = QDeclarativeDebugService::objectForId(debugId)) - obj->deleteLater(); - break; - } - case InspectorProtocol::MoveObject: { - int debugId, newParent; - ds >> debugId >> newParent; - data->_q_reparentQmlObject(QDeclarativeDebugService::objectForId(debugId), - QDeclarativeDebugService::objectForId(newParent)); - break; - } - case InspectorProtocol::ObjectIdList: { - int itemCount; - ds >> itemCount; - data->stringIdForObjectId.clear(); - for (int i = 0; i < itemCount; ++i) { - int itemDebugId; - QString itemIdString; - ds >> itemDebugId - >> itemIdString; - - data->stringIdForObjectId.insert(itemDebugId, itemIdString); - } - break; - } - case InspectorProtocol::ClearComponentCache: { - data->_q_clearComponentCache(); - break; - } - default: - qWarning() << "Warning: Not handling message:" << type; - } -} - -void QDeclarativeViewInspector::sendDesignModeBehavior(bool inDesignMode) -{ - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - - ds << InspectorProtocol::SetDesignMode - << inDesignMode; - - data->debugService->sendMessage(message); -} - -void QDeclarativeViewInspector::sendCurrentObjects(const QList &objects) -{ - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - - ds << InspectorProtocol::CurrentObjectsChanged - << objects.length(); - - foreach (QObject *object, objects) { - int id = QDeclarativeDebugService::idForObject(object); - ds << id; - } - - data->debugService->sendMessage(message); -} - -void QDeclarativeViewInspector::sendCurrentTool(Constants::DesignTool toolId) -{ - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - - ds << InspectorProtocol::ToolChanged - << toolId; - - data->debugService->sendMessage(message); -} - -void QDeclarativeViewInspector::sendAnimationSpeed(qreal slowDownFactor) -{ - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - - ds << InspectorProtocol::AnimationSpeedChanged - << slowDownFactor; - - data->debugService->sendMessage(message); -} - -void QDeclarativeViewInspector::sendAnimationPaused(bool paused) -{ - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - - ds << InspectorProtocol::AnimationPausedChanged - << paused; - - data->debugService->sendMessage(message); -} - -void QDeclarativeViewInspector::sendReloaded() -{ - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - - ds << InspectorProtocol::Reloaded; - - data->debugService->sendMessage(message); -} - -void QDeclarativeViewInspector::sendShowAppOnTop(bool showAppOnTop) -{ - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - - ds << InspectorProtocol::ShowAppOnTop << showAppOnTop; - - data->debugService->sendMessage(message); -} - -void QDeclarativeViewInspector::sendColorChanged(const QColor &color) -{ - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - - ds << InspectorProtocol::ColorChanged - << color; - - data->debugService->sendMessage(message); -} - -QString QDeclarativeViewInspector::idStringForObject(QObject *obj) const -{ - int id = QDeclarativeDebugService::idForObject(obj); - QString idString = data->stringIdForObjectId.value(id, QString()); - return idString; -} - QT_END_NAMESPACE - -#include "qdeclarativeviewinspector.moc" diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h index 4efa093..c89a259 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h @@ -43,7 +43,9 @@ #define QDECLARATIVEVIEWINSPECTOR_P_H #include + #include "qmlinspectorconstants_p.h" +#include "abstractviewinspector.h" #include #include @@ -60,7 +62,7 @@ QT_MODULE(Declarative) class QDeclarativeViewInspectorPrivate; -class QDeclarativeViewInspector : public QObject +class QDeclarativeViewInspector : public AbstractViewInspector { Q_OBJECT @@ -68,49 +70,21 @@ public: explicit QDeclarativeViewInspector(QDeclarativeView *view, QObject *parent = 0); ~QDeclarativeViewInspector(); + // AbstractViewInspector + void changeCurrentObjects(const QList &objects); + void reloadView(); + void reparentQmlObject(QObject *object, QObject *newParent); + void changeTool(InspectorProtocol::Tool tool); + QWidget *viewWidget() const { return declarativeView(); } + QDeclarativeEngine *declarativeEngine() const; + void setSelectedItems(QList items); QList selectedItems() const; - QDeclarativeView *declarativeView(); + QDeclarativeView *declarativeView() const; QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace); - bool showAppOnTop() const; - - void sendDesignModeBehavior(bool inDesignMode); - void sendCurrentObjects(const QList &); - void sendAnimationSpeed(qreal slowDownFactor); - void sendAnimationPaused(bool paused); - void sendCurrentTool(Constants::DesignTool toolId); - void sendReloaded(); - void sendShowAppOnTop(bool showAppOnTop); - - QString idStringForObject(QObject *obj) const; - -public Q_SLOTS: - void sendColorChanged(const QColor &color); - - 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); @@ -125,12 +99,6 @@ protected: void setSelectedItemsForTools(QList items); -private slots: - void handleMessage(const QByteArray &message); - - void animationSpeedChangeRequested(qreal factor); - void animationPausedChangeRequested(bool paused); - private: Q_DISABLE_COPY(QDeclarativeViewInspector) diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p_p.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p_p.h index 11cbe0f..a412df3 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p_p.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p_p.h @@ -61,7 +61,6 @@ class ZoomTool; class ColorPickerTool; class LiveLayerItem; class BoundingRectHighlighter; -class ToolBox; class AbstractLiveEditTool; class QDeclarativeViewInspectorPrivate : public QObject @@ -73,9 +72,7 @@ public: QDeclarativeView *view; QDeclarativeViewInspector *q; - QDeclarativeInspectorService *debugService; QWeakPointer viewport; - QHash stringIdForObjectId; QPointF cursorPos; QList > currentSelection; @@ -90,18 +87,9 @@ public: BoundingRectHighlighter *boundingRectHighlighter; - bool designModeBehavior; - bool showAppOnTop; - - bool animationPaused; - qreal slowDownFactor; - - ToolBox *toolBox; - void setViewport(QWidget *widget); void clearEditorItems(); - void createToolBox(); void changeToSelectTool(); QList filterForSelection(QList &itemlist) const; @@ -113,32 +101,19 @@ public: void setSelectedItems(const QList &items); QList selectedItems() const; - void changeTool(Constants::DesignTool tool, - Constants::ToolFlags flags = Constants::NoToolFlags); - void clearHighlight(); void highlight(const QList &item); inline void highlight(QGraphicsObject *item) { highlight(QList() << item); } - bool isEditorItem(QGraphicsItem *item) const; + void changeToSingleSelectTool(); + void changeToMarqueeSelectTool(); + void changeToZoomTool(); + void changeToColorPickerTool(); public slots: - void _q_setToolBoxVisible(bool visible); - - void _q_reloadView(); void _q_onStatusChanged(QDeclarativeView::Status status); - void _q_onCurrentObjectsChanged(QList objects); - void _q_applyChangesFromClient(); - void _q_createQmlObject(const QString &qml, QObject *parent, - const QStringList &imports, const QString &filename = QString()); - void _q_reparentQmlObject(QObject *, QObject *); - - void _q_changeToSingleSelectTool(); - void _q_changeToMarqueeSelectTool(); - void _q_changeToZoomTool(); - void _q_changeToColorPickerTool(); - void _q_clearComponentCache(); + void _q_removeFromSelection(QObject *); public: diff --git a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro index f8d7ee8..fd2a744 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro +++ b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro @@ -7,6 +7,7 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/qmltooling QTDIR_build:REQUIRES += "contains(QT_CONFIG, declarative)" SOURCES += \ + abstractviewinspector.cpp \ qdeclarativeinspectorplugin.cpp \ qdeclarativeviewinspector.cpp \ editor/abstractliveedittool.cpp \ @@ -24,6 +25,7 @@ SOURCES += \ editor/toolbarcolorbox.cpp HEADERS += \ + abstractviewinspector.h \ qdeclarativeinspectorplugin.h \ qdeclarativeinspectorprotocol.h \ qdeclarativeviewinspector_p.h \ diff --git a/src/plugins/qmltooling/qmldbg_inspector/qmlinspectorconstants_p.h b/src/plugins/qmltooling/qmldbg_inspector/qmlinspectorconstants_p.h index 40ec325..9f6b116 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qmlinspectorconstants_p.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qmlinspectorconstants_p.h @@ -62,11 +62,6 @@ enum DesignTool { ZoomMode = 6 }; -enum ToolFlags { - NoToolFlags = 0, - UseCursorPos = 1 -}; - static const int DragStartTime = 50; static const int DragStartDistance = 20; -- cgit v0.12 From eef8e3febcbeb5a008024b67c9528cecc67f7d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 8 Jun 2011 19:37:25 +0200 Subject: QmlInspector: Removed private header postfix and Qt namespace Renamed the headers back to normal since they are not included in a Qt library. Also took the classes out of the Qt namespace and back into the QmlJSDebugger namespace. This is mainly to make it easier again to port changes back into the version of the inspector shipped with Qt Creator. (cherry picked from commit febfd367f8483ef6cae31b89b04422e0058e5ae7 in Qt 5 / QtDeclarative, to make synchronizing future changes easier) Change-Id: I74acdbe7e5493c8b5d34b34ad9070c424128754e Reviewed-by: Kai Koehne --- .../qmldbg_inspector/abstractviewinspector.cpp | 6 +- .../qmldbg_inspector/abstractviewinspector.h | 9 +- .../editor/abstractliveedittool.cpp | 9 +- .../qmldbg_inspector/editor/abstractliveedittool.h | 113 +++++++++++++++++ .../editor/abstractliveedittool_p.h | 119 ------------------ .../editor/boundingrecthighlighter.cpp | 11 +- .../editor/boundingrecthighlighter.h | 115 +++++++++++++++++ .../editor/boundingrecthighlighter_p.h | 121 ------------------ .../qmldbg_inspector/editor/colorpickertool.cpp | 8 +- .../qmldbg_inspector/editor/colorpickertool.h | 93 ++++++++++++++ .../qmldbg_inspector/editor/colorpickertool_p.h | 99 --------------- .../qmldbg_inspector/editor/livelayeritem.cpp | 8 +- .../qmldbg_inspector/editor/livelayeritem.h | 67 ++++++++++ .../qmldbg_inspector/editor/livelayeritem_p.h | 73 ----------- .../editor/liverubberbandselectionmanipulator.cpp | 8 +- .../editor/liverubberbandselectionmanipulator.h | 96 ++++++++++++++ .../editor/liverubberbandselectionmanipulator_p.h | 102 --------------- .../editor/liveselectionindicator.cpp | 11 +- .../editor/liveselectionindicator.h | 80 ++++++++++++ .../editor/liveselectionindicator_p.h | 86 ------------- .../editor/liveselectionrectangle.cpp | 8 +- .../editor/liveselectionrectangle.h | 77 ++++++++++++ .../editor/liveselectionrectangle_p.h | 83 ------------- .../qmldbg_inspector/editor/liveselectiontool.cpp | 10 +- .../qmldbg_inspector/editor/liveselectiontool.h | 120 ++++++++++++++++++ .../qmldbg_inspector/editor/liveselectiontool_p.h | 126 ------------------- .../editor/livesingleselectionmanipulator.cpp | 8 +- .../editor/livesingleselectionmanipulator.h | 89 +++++++++++++ .../editor/livesingleselectionmanipulator_p.h | 95 -------------- .../qmldbg_inspector/editor/qmltoolbar.cpp | 8 +- .../qmldbg_inspector/editor/qmltoolbar.h | 132 ++++++++++++++++++++ .../qmldbg_inspector/editor/qmltoolbar_p.h | 138 --------------------- .../editor/subcomponentmasklayeritem.cpp | 10 +- .../editor/subcomponentmasklayeritem.h | 71 +++++++++++ .../editor/subcomponentmasklayeritem_p.h | 77 ------------ .../qmldbg_inspector/editor/toolbarcolorbox.cpp | 8 +- .../qmldbg_inspector/editor/toolbarcolorbox.h | 81 ++++++++++++ .../qmldbg_inspector/editor/toolbarcolorbox_p.h | 87 ------------- .../qmldbg_inspector/editor/zoomtool.cpp | 8 +- .../qmltooling/qmldbg_inspector/editor/zoomtool.h | 107 ++++++++++++++++ .../qmldbg_inspector/editor/zoomtool_p.h | 113 ----------------- .../qdeclarativeinspectorplugin.cpp | 7 +- .../qmldbg_inspector/qdeclarativeinspectorplugin.h | 4 +- .../qdeclarativeinspectorprotocol.h | 10 +- .../qmldbg_inspector/qdeclarativeviewinspector.cpp | 16 +-- .../qmldbg_inspector/qdeclarativeviewinspector.h | 109 ++++++++++++++++ .../qmldbg_inspector/qdeclarativeviewinspector_p.h | 108 ++++++++-------- .../qdeclarativeviewinspector_p_p.h | 127 ------------------- .../qmldbg_inspector/qmldbg_inspector.pro | 30 ++--- .../qmldbg_inspector/qmlinspectorconstants.h | 77 ++++++++++++ .../qmldbg_inspector/qmlinspectorconstants_p.h | 85 ------------- 51 files changed, 1582 insertions(+), 1681 deletions(-) create mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.h delete mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool_p.h create mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.h delete mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter_p.h create mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.h delete mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool_p.h create mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.h delete mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem_p.h create mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.h delete mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator_p.h create mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.h delete mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator_p.h create mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.h delete mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle_p.h create mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.h delete mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool_p.h create mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator.h delete mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator_p.h create mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.h delete mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar_p.h create mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.h delete mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem_p.h create mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.h delete mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox_p.h create mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.h delete mode 100644 src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool_p.h create mode 100644 src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h delete mode 100644 src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p_p.h create mode 100644 src/plugins/qmltooling/qmldbg_inspector/qmlinspectorconstants.h delete mode 100644 src/plugins/qmltooling/qmldbg_inspector/qmlinspectorconstants_p.h diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp index fdec0e7..a698819 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp @@ -41,7 +41,7 @@ #include "abstractviewinspector.h" -#include "editor/qmltoolbar_p.h" +#include "editor/qmltoolbar.h" #include "qdeclarativeinspectorprotocol.h" #include @@ -54,7 +54,7 @@ static inline void initEditorResource() { Q_INIT_RESOURCE(editor); } -QT_BEGIN_NAMESPACE +namespace QmlJSDebugger { const char * const KEY_TOOLBOX_GEOMETRY = "toolBox/geometry"; @@ -485,6 +485,6 @@ QString AbstractViewInspector::idStringForObject(QObject *obj) const return m_stringIdForObjectId.value(id); } -QT_END_NAMESPACE +} // namespace QmlJSDebugger #include "abstractviewinspector.moc" diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h index b89a6eb..0a56ead 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h +++ b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h @@ -48,12 +48,15 @@ #include #include "qdeclarativeinspectorprotocol.h" -#include "qmlinspectorconstants_p.h" +#include "qmlinspectorconstants.h" QT_BEGIN_NAMESPACE - class QDeclarativeEngine; class QDeclarativeInspectorService; +QT_END_NAMESPACE + +namespace QmlJSDebugger { + class ToolBox; /* @@ -150,6 +153,6 @@ private: QDeclarativeInspectorService *m_debugService; }; -QT_END_NAMESPACE +} // namespace QmlJSDebugger #endif // ABSTRACTVIEWINSPECTOR_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.cpp index 36e6ba0..4353e97 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#include "abstractliveedittool_p.h" -#include "../qdeclarativeviewinspector_p_p.h" +#include "abstractliveedittool.h" +#include "../qdeclarativeviewinspector_p.h" #include @@ -48,7 +48,7 @@ #include #include -QT_BEGIN_NAMESPACE +namespace QmlJSDebugger { AbstractLiveEditTool::AbstractLiveEditTool(QDeclarativeViewInspector *editorView) : QObject(editorView), m_inspector(editorView) @@ -192,4 +192,5 @@ QString AbstractLiveEditTool::titleForItem(QGraphicsItem *item) return constructedName; } -QT_END_NAMESPACE + +} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.h b/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.h new file mode 100644 index 0000000..accec79 --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.h @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ABSTRACTLIVEEDITTOOL_H +#define ABSTRACTLIVEEDITTOOL_H + +#include +#include + +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 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 &itemList) = 0; + + virtual void clear() = 0; + + void updateSelectedItems(); + QList items() const; + + bool topItemIsMovable(const QList &itemList); + bool topItemIsResizeHandle(const QList &itemList); + bool topSelectedItemIsMovable(const QList &itemList); + + QString titleForItem(QGraphicsItem *item); + + static QList toGraphicsObjectList(const QList &itemList); + static QGraphicsItem* topMovableGraphicsItem(const QList &itemList); + static QDeclarativeItem* topMovableDeclarativeItem(const QList &itemList); + static QDeclarativeItem *toQDeclarativeItem(QGraphicsItem *item); + +protected: + virtual void selectedItemsChanged(const QList &objectList) = 0; + + QDeclarativeViewInspector *inspector() const; + QDeclarativeView *view() const; + QGraphicsScene *scene() const; + +private: + QDeclarativeViewInspector *m_inspector; + QList m_itemList; +}; + +} + +#endif // ABSTRACTLIVEEDITTOOL_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool_p.h deleted file mode 100644 index 17eb6ea..0000000 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool_p.h +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef ABSTRACTLIVEEDITTOOL_H -#define ABSTRACTLIVEEDITTOOL_H - -#include -#include - -QT_BEGIN_NAMESPACE -class QMouseEvent; -class QGraphicsItem; -class QDeclarativeItem; -class QKeyEvent; -class QGraphicsScene; -class QGraphicsObject; -class QWheelEvent; -class QDeclarativeView; -QT_END_NAMESPACE - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QDeclarativeViewInspector; - -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 &itemList) = 0; - - virtual void clear() = 0; - - void updateSelectedItems(); - QList items() const; - - bool topItemIsMovable(const QList &itemList); - bool topItemIsResizeHandle(const QList &itemList); - bool topSelectedItemIsMovable(const QList &itemList); - - QString titleForItem(QGraphicsItem *item); - - static QList toGraphicsObjectList(const QList &itemList); - static QGraphicsItem* topMovableGraphicsItem(const QList &itemList); - static QDeclarativeItem* topMovableDeclarativeItem(const QList &itemList); - static QDeclarativeItem *toQDeclarativeItem(QGraphicsItem *item); - -protected: - virtual void selectedItemsChanged(const QList &objectList) = 0; - - QDeclarativeViewInspector *inspector() const; - QDeclarativeView *view() const; - QGraphicsScene *scene() const; - -private: - QDeclarativeViewInspector *m_inspector; - QList m_itemList; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // ABSTRACTLIVEEDITTOOL_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.cpp index 3f95005..da9f442 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.cpp @@ -39,10 +39,10 @@ ** ****************************************************************************/ -#include "boundingrecthighlighter_p.h" +#include "boundingrecthighlighter.h" -#include "../qdeclarativeviewinspector_p.h" -#include "../qmlinspectorconstants_p.h" +#include "../qdeclarativeviewinspector.h" +#include "../qmlinspectorconstants.h" #include @@ -50,7 +50,7 @@ #include #include -QT_BEGIN_NAMESPACE +namespace QmlJSDebugger { BoundingBox::BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem, QObject *parent) @@ -236,4 +236,5 @@ void BoundingRectHighlighter::refresh() highlightAll(); } -QT_END_NAMESPACE + +} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.h b/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.h new file mode 100644 index 0000000..81883ee --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter.h @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef BOUNDINGRECTHIGHLIGHTER_H +#define BOUNDINGRECTHIGHLIGHTER_H + +#include "livelayeritem.h" + +#include +#include + +QT_FORWARD_DECLARE_CLASS(QGraphicsItem) +QT_FORWARD_DECLARE_CLASS(QPainter) +QT_FORWARD_DECLARE_CLASS(QWidget) +QT_FORWARD_DECLARE_CLASS(QStyleOptionGraphicsItem) +QT_FORWARD_DECLARE_CLASS(QTimer) + +namespace QmlJSDebugger { + +class QDeclarativeViewInspector; +class BoundingBox; + +class BoundingRectHighlighter : public LiveLayerItem +{ + Q_OBJECT +public: + explicit BoundingRectHighlighter(QDeclarativeViewInspector *view); + ~BoundingRectHighlighter(); + void clear(); + void highlight(QList items); + void highlight(QGraphicsObject* item); + +private slots: + void refresh(); + void itemDestroyed(QObject *); + +private: + BoundingBox *boxFor(QGraphicsObject *item) const; + void highlightAll(); + BoundingBox *createBoundingBox(QGraphicsObject *itemToHighlight); + void removeBoundingBox(BoundingBox *box); + void freeBoundingBox(BoundingBox *box); + +private: + Q_DISABLE_COPY(BoundingRectHighlighter) + + QDeclarativeViewInspector *m_view; + QList m_boxes; + QList m_freeBoxes; +}; + +class BoundingBox : public QObject +{ + Q_OBJECT +public: + explicit BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem, + QObject *parent = 0); + ~BoundingBox(); + QWeakPointer highlightedObject; + QGraphicsPolygonItem *highlightPolygon; + QGraphicsPolygonItem *highlightPolygonEdge; + +private: + Q_DISABLE_COPY(BoundingBox) + +}; + +class BoundingBoxPolygonItem : public QGraphicsPolygonItem +{ +public: + explicit BoundingBoxPolygonItem(QGraphicsItem *item); + int type() const; +}; + +} // namespace QmlJSDebugger + +#endif // BOUNDINGRECTHIGHLIGHTER_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter_p.h deleted file mode 100644 index e2928f7..0000000 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/boundingrecthighlighter_p.h +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef BOUNDINGRECTHIGHLIGHTER_H -#define BOUNDINGRECTHIGHLIGHTER_H - -#include "livelayeritem_p.h" - -#include -#include - -QT_FORWARD_DECLARE_CLASS(QGraphicsItem) -QT_FORWARD_DECLARE_CLASS(QPainter) -QT_FORWARD_DECLARE_CLASS(QWidget) -QT_FORWARD_DECLARE_CLASS(QStyleOptionGraphicsItem) -QT_FORWARD_DECLARE_CLASS(QTimer) - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QDeclarativeViewInspector; -class BoundingBox; - -class BoundingRectHighlighter : public LiveLayerItem -{ - Q_OBJECT -public: - explicit BoundingRectHighlighter(QDeclarativeViewInspector *view); - ~BoundingRectHighlighter(); - void clear(); - void highlight(QList items); - void highlight(QGraphicsObject* item); - -private slots: - void refresh(); - void itemDestroyed(QObject *); - -private: - BoundingBox *boxFor(QGraphicsObject *item) const; - void highlightAll(); - BoundingBox *createBoundingBox(QGraphicsObject *itemToHighlight); - void removeBoundingBox(BoundingBox *box); - void freeBoundingBox(BoundingBox *box); - -private: - Q_DISABLE_COPY(BoundingRectHighlighter) - - QDeclarativeViewInspector *m_view; - QList m_boxes; - QList m_freeBoxes; -}; - -class BoundingBox : public QObject -{ - Q_OBJECT -public: - explicit BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem, - QObject *parent = 0); - ~BoundingBox(); - QWeakPointer highlightedObject; - QGraphicsPolygonItem *highlightPolygon; - QGraphicsPolygonItem *highlightPolygonEdge; - -private: - Q_DISABLE_COPY(BoundingBox) - -}; - -class BoundingBoxPolygonItem : public QGraphicsPolygonItem -{ -public: - explicit BoundingBoxPolygonItem(QGraphicsItem *item); - int type() const; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // BOUNDINGRECTHIGHLIGHTER_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.cpp index bdae3d8..9cef6b5 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.cpp @@ -39,9 +39,9 @@ ** ****************************************************************************/ -#include "colorpickertool_p.h" +#include "colorpickertool.h" -#include "../qdeclarativeviewinspector_p.h" +#include "../qdeclarativeviewinspector.h" #include #include @@ -51,7 +51,7 @@ #include #include -QT_BEGIN_NAMESPACE +namespace QmlJSDebugger { ColorPickerTool::ColorPickerTool(QDeclarativeViewInspector *view) : AbstractLiveEditTool(view) @@ -128,4 +128,4 @@ void ColorPickerTool::pickColor(const QPoint &pos) emit selectedColorChanged(m_selectedColor); } -QT_END_NAMESPACE +} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.h b/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.h new file mode 100644 index 0000000..8c8152b --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef COLORPICKERTOOL_H +#define COLORPICKERTOOL_H + +#include "abstractliveedittool.h" + +#include + +QT_FORWARD_DECLARE_CLASS(QPoint) + +namespace QmlJSDebugger { + +class ColorPickerTool : public AbstractLiveEditTool +{ + Q_OBJECT +public: + explicit ColorPickerTool(QDeclarativeViewInspector *view); + + virtual ~ColorPickerTool(); + + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseDoubleClickEvent(QMouseEvent *event); + + void hoverMoveEvent(QMouseEvent *event); + + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *keyEvent); + + void wheelEvent(QWheelEvent *event); + + void itemsAboutToRemoved(const QList &itemList); + + void clear(); + +signals: + void selectedColorChanged(const QColor &color); + +protected: + + void selectedItemsChanged(const QList &itemList); + +private: + void pickColor(const QPoint &pos); + +private: + QColor m_selectedColor; +}; + +} // namespace QmlJSDebugger + +#endif // COLORPICKERTOOL_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool_p.h deleted file mode 100644 index 580c175..0000000 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool_p.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef COLORPICKERTOOL_H -#define COLORPICKERTOOL_H - -#include "abstractliveedittool_p.h" - -#include - -QT_FORWARD_DECLARE_CLASS(QPoint) - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class ColorPickerTool : public AbstractLiveEditTool -{ - Q_OBJECT -public: - explicit ColorPickerTool(QDeclarativeViewInspector *view); - - virtual ~ColorPickerTool(); - - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); - - void hoverMoveEvent(QMouseEvent *event); - - void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *keyEvent); - - void wheelEvent(QWheelEvent *event); - - void itemsAboutToRemoved(const QList &itemList); - - void clear(); - -signals: - void selectedColorChanged(const QColor &color); - -protected: - - void selectedItemsChanged(const QList &itemList); - -private: - void pickColor(const QPoint &pos); - -private: - QColor m_selectedColor; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // COLORPICKERTOOL_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.cpp index c28893e..fb7118f 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.cpp @@ -39,13 +39,13 @@ ** ****************************************************************************/ -#include "livelayeritem_p.h" +#include "livelayeritem.h" -#include "../qmlinspectorconstants_p.h" +#include "../qmlinspectorconstants.h" #include -QT_BEGIN_NAMESPACE +namespace QmlJSDebugger { LiveLayerItem::LiveLayerItem(QGraphicsScene* scene) : QGraphicsObject() @@ -89,4 +89,4 @@ QList LiveLayerItem::findAllChildItems(const QGraphicsItem *item return itemList; } -QT_END_NAMESPACE +} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.h b/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.h new file mode 100644 index 0000000..4dccc0b --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef LIVELAYERITEM_H +#define LIVELAYERITEM_H + +#include + +namespace QmlJSDebugger { + +class LiveLayerItem : public QGraphicsObject +{ +public: + LiveLayerItem(QGraphicsScene *scene); + ~LiveLayerItem(); + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, + QWidget *widget = 0); + QRectF boundingRect() const; + int type() const; + + QList findAllChildItems() const; + +protected: + QList findAllChildItems(const QGraphicsItem *item) const; +}; + +} + +#endif // LIVELAYERITEM_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem_p.h deleted file mode 100644 index da622e1..0000000 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/livelayeritem_p.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LIVELAYERITEM_H -#define LIVELAYERITEM_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class LiveLayerItem : public QGraphicsObject -{ -public: - LiveLayerItem(QGraphicsScene *scene); - ~LiveLayerItem(); - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget = 0); - QRectF boundingRect() const; - int type() const; - - QList findAllChildItems() const; - -protected: - QList findAllChildItems(const QGraphicsItem *item) const; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // LIVELAYERITEM_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.cpp index d32847d..b08682a 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.cpp @@ -39,15 +39,15 @@ ** ****************************************************************************/ -#include "liverubberbandselectionmanipulator_p.h" +#include "liverubberbandselectionmanipulator.h" -#include "../qdeclarativeviewinspector_p_p.h" +#include "../qdeclarativeviewinspector_p.h" #include #include -QT_BEGIN_NAMESPACE +namespace QmlJSDebugger { LiveRubberBandSelectionManipulator::LiveRubberBandSelectionManipulator(QGraphicsObject *layerItem, QDeclarativeViewInspector *editorView) @@ -162,4 +162,4 @@ bool LiveRubberBandSelectionManipulator::isActive() const return m_isActive; } -QT_END_NAMESPACE +} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.h b/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.h new file mode 100644 index 0000000..aa15a34 --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef RUBBERBANDSELECTIONMANIPULATOR_H +#define RUBBERBANDSELECTIONMANIPULATOR_H + +#include "liveselectionrectangle.h" + +#include + +QT_FORWARD_DECLARE_CLASS(QGraphicsItem) + +namespace QmlJSDebugger { + +class QDeclarativeViewInspector; + +class LiveRubberBandSelectionManipulator +{ +public: + enum SelectionType { + ReplaceSelection, + AddToSelection, + RemoveFromSelection + }; + + LiveRubberBandSelectionManipulator(QGraphicsObject *layerItem, + QDeclarativeViewInspector *editorView); + + void setItems(const QList &itemList); + + void begin(const QPointF& beginPoint); + void update(const QPointF& updatePoint); + void end(); + + void clear(); + + void select(SelectionType selectionType); + + QPointF beginPoint() const; + + bool isActive() const; + +protected: + QGraphicsItem *topFormEditorItem(const QList &itemList); + +private: + QList m_itemList; + QList m_oldSelectionList; + LiveSelectionRectangle m_selectionRectangleElement; + QPointF m_beginPoint; + QDeclarativeViewInspector *m_editorView; + QGraphicsItem *m_beginFormEditorItem; + bool m_isActive; +}; + +} + +#endif // RUBBERBANDSELECTIONMANIPULATOR_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator_p.h deleted file mode 100644 index 9abcb2b..0000000 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/liverubberbandselectionmanipulator_p.h +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef RUBBERBANDSELECTIONMANIPULATOR_H -#define RUBBERBANDSELECTIONMANIPULATOR_H - -#include "liveselectionrectangle_p.h" - -#include - -QT_FORWARD_DECLARE_CLASS(QGraphicsItem) - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QDeclarativeViewInspector; - -class LiveRubberBandSelectionManipulator -{ -public: - enum SelectionType { - ReplaceSelection, - AddToSelection, - RemoveFromSelection - }; - - LiveRubberBandSelectionManipulator(QGraphicsObject *layerItem, - QDeclarativeViewInspector *editorView); - - void setItems(const QList &itemList); - - void begin(const QPointF& beginPoint); - void update(const QPointF& updatePoint); - void end(); - - void clear(); - - void select(SelectionType selectionType); - - QPointF beginPoint() const; - - bool isActive() const; - -protected: - QGraphicsItem *topFormEditorItem(const QList &itemList); - -private: - QList m_itemList; - QList m_oldSelectionList; - LiveSelectionRectangle m_selectionRectangleElement; - QPointF m_beginPoint; - QDeclarativeViewInspector *m_editorView; - QGraphicsItem *m_beginFormEditorItem; - bool m_isActive; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // RUBBERBANDSELECTIONMANIPULATOR_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.cpp index 4450fc5..c57bc0e 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.cpp @@ -39,17 +39,17 @@ ** ****************************************************************************/ -#include "liveselectionindicator_p.h" +#include "liveselectionindicator.h" -#include "../qdeclarativeviewinspector_p_p.h" -#include "../qmlinspectorconstants_p.h" +#include "../qdeclarativeviewinspector_p.h" +#include "../qmlinspectorconstants.h" #include #include #include #include -QT_BEGIN_NAMESPACE +namespace QmlJSDebugger { LiveSelectionIndicator::LiveSelectionIndicator(QDeclarativeViewInspector *viewInspector, QGraphicsObject *layerItem) @@ -114,4 +114,5 @@ void LiveSelectionIndicator::setItems(const QList } } -QT_END_NAMESPACE +} //namespace QmlJSDebugger + diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.h b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.h new file mode 100644 index 0000000..7b8cc12 --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef LIVESELECTIONINDICATOR_H +#define LIVESELECTIONINDICATOR_H + +#include +#include + +QT_BEGIN_NAMESPACE +class QGraphicsObject; +class QGraphicsRectItem; +class QGraphicsItem; +class QPolygonF; +QT_END_NAMESPACE + +namespace QmlJSDebugger { + +class QDeclarativeViewInspector; + +class LiveSelectionIndicator +{ +public: + LiveSelectionIndicator(QDeclarativeViewInspector *viewInspector, QGraphicsObject *layerItem); + ~LiveSelectionIndicator(); + + void show(); + void hide(); + + void clear(); + + void setItems(const QList > &itemList); + +private: + QHash m_indicatorShapeHash; + QWeakPointer m_layerItem; + QDeclarativeViewInspector *m_view; +}; + +} + +#endif // LIVESELECTIONINDICATOR_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator_p.h deleted file mode 100644 index fa6eb30..0000000 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionindicator_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LIVESELECTIONINDICATOR_H -#define LIVESELECTIONINDICATOR_H - -#include -#include - -QT_BEGIN_NAMESPACE -class QGraphicsObject; -class QGraphicsRectItem; -class QGraphicsItem; -class QPolygonF; -QT_END_NAMESPACE - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QDeclarativeViewInspector; - -class LiveSelectionIndicator -{ -public: - LiveSelectionIndicator(QDeclarativeViewInspector *viewInspector, QGraphicsObject *layerItem); - ~LiveSelectionIndicator(); - - void show(); - void hide(); - - void clear(); - - void setItems(const QList > &itemList); - -private: - QHash m_indicatorShapeHash; - QWeakPointer m_layerItem; - QDeclarativeViewInspector *m_view; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // LIVESELECTIONINDICATOR_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.cpp index 267079a..4e14458 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.cpp @@ -39,9 +39,9 @@ ** ****************************************************************************/ -#include "liveselectionrectangle_p.h" +#include "liveselectionrectangle.h" -#include "../qmlinspectorconstants_p.h" +#include "../qmlinspectorconstants.h" #include #include @@ -52,7 +52,7 @@ #include -QT_BEGIN_NAMESPACE +namespace QmlJSDebugger { class SelectionRectShape : public QGraphicsRectItem { @@ -110,4 +110,4 @@ void LiveSelectionRectangle::setRect(const QPointF &firstPoint, m_controlShape->setRect(rect); } -QT_END_NAMESPACE +} diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.h b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.h new file mode 100644 index 0000000..730cca5 --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef LIVESELECTIONRECTANGLE_H +#define LIVESELECTIONRECTANGLE_H + +#include + +QT_FORWARD_DECLARE_CLASS(QGraphicsObject) +QT_FORWARD_DECLARE_CLASS(QGraphicsRectItem) +QT_FORWARD_DECLARE_CLASS(QPointF) +QT_FORWARD_DECLARE_CLASS(QRectF) + +namespace QmlJSDebugger { + +class LiveSelectionRectangle +{ +public: + LiveSelectionRectangle(QGraphicsObject *layerItem); + ~LiveSelectionRectangle(); + + void show(); + void hide(); + + void clear(); + + void setRect(const QPointF &firstPoint, + const QPointF &secondPoint); + + QRectF rect() const; + +private: + QGraphicsRectItem *m_controlShape; + QWeakPointer m_layerItem; +}; + +} // namespace QmlJSDebugger + +#endif // LIVESELECTIONRECTANGLE_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle_p.h deleted file mode 100644 index 5da9fb8..0000000 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectionrectangle_p.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LIVESELECTIONRECTANGLE_H -#define LIVESELECTIONRECTANGLE_H - -#include - -QT_FORWARD_DECLARE_CLASS(QGraphicsObject) -QT_FORWARD_DECLARE_CLASS(QGraphicsRectItem) -QT_FORWARD_DECLARE_CLASS(QPointF) -QT_FORWARD_DECLARE_CLASS(QRectF) - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class LiveSelectionRectangle -{ -public: - LiveSelectionRectangle(QGraphicsObject *layerItem); - ~LiveSelectionRectangle(); - - void show(); - void hide(); - - void clear(); - - void setRect(const QPointF &firstPoint, - const QPointF &secondPoint); - - QRectF rect() const; - -private: - QGraphicsRectItem *m_controlShape; - QWeakPointer m_layerItem; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // LIVESELECTIONRECTANGLE_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp index c55cba3..91dd43b 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp @@ -39,10 +39,10 @@ ** ****************************************************************************/ -#include "liveselectiontool_p.h" -#include "livelayeritem_p.h" +#include "liveselectiontool.h" +#include "livelayeritem.h" -#include "../qdeclarativeviewinspector_p_p.h" +#include "../qdeclarativeviewinspector_p.h" #include #include @@ -57,7 +57,7 @@ #include -QT_BEGIN_NAMESPACE +namespace QmlJSDebugger { LiveSelectionTool::LiveSelectionTool(QDeclarativeViewInspector *editorView) : AbstractLiveEditTool(editorView), @@ -435,4 +435,4 @@ void LiveSelectionTool::selectUnderPoint(QMouseEvent *event) m_singleSelectionManipulator.end(event->pos()); } -QT_END_NAMESPACE +} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.h b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.h new file mode 100644 index 0000000..a3dcd0a --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.h @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef LIVESELECTIONTOOL_H +#define LIVESELECTIONTOOL_H + +#include "abstractliveedittool.h" +#include "liverubberbandselectionmanipulator.h" +#include "livesingleselectionmanipulator.h" +#include "liveselectionindicator.h" + +#include +#include + +QT_FORWARD_DECLARE_CLASS(QGraphicsItem) +QT_FORWARD_DECLARE_CLASS(QMouseEvent) +QT_FORWARD_DECLARE_CLASS(QKeyEvent) +QT_FORWARD_DECLARE_CLASS(QAction) + +namespace QmlJSDebugger { + +class LiveSelectionTool : public AbstractLiveEditTool +{ + Q_OBJECT + +public: + LiveSelectionTool(QDeclarativeViewInspector* editorView); + ~LiveSelectionTool(); + + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseDoubleClickEvent(QMouseEvent *event); + void hoverMoveEvent(QMouseEvent *event); + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *keyEvent); + void wheelEvent(QWheelEvent *event); + + void itemsAboutToRemoved(const QList &itemList); +// QVariant itemChange(const QList &itemList, +// QGraphicsItem::GraphicsItemChange change, +// const QVariant &value ); + +// void update(); + + void clear(); + + void selectedItemsChanged(const QList &itemList); + + void selectUnderPoint(QMouseEvent *event); + + void setSelectOnlyContentItems(bool selectOnlyContentItems); + + void setRubberbandSelectionMode(bool value); + +private slots: + void contextMenuElementSelected(); + void contextMenuElementHovered(QAction *action); + void repaintBoundingRects(); + +private: + void createContextMenu(QList itemList, QPoint globalPos); + LiveSingleSelectionManipulator::SelectionType getSelectionType(Qt::KeyboardModifiers modifiers); + bool alreadySelected(const QList &itemList) const; + +private: + bool m_rubberbandSelectionMode; + LiveRubberBandSelectionManipulator m_rubberbandSelectionManipulator; + LiveSingleSelectionManipulator m_singleSelectionManipulator; + LiveSelectionIndicator m_selectionIndicator; + //ResizeIndicator m_resizeIndicator; + QTime m_mousePressTimer; + bool m_selectOnlyContentItems; + + QList > m_selectedItemList; + + QList m_contextMenuItemList; +}; + +} // namespace QmlJSDebugger + +#endif // LIVESELECTIONTOOL_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool_p.h deleted file mode 100644 index 7562f3e..0000000 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool_p.h +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LIVESELECTIONTOOL_H -#define LIVESELECTIONTOOL_H - -#include "abstractliveedittool_p.h" -#include "liverubberbandselectionmanipulator_p.h" -#include "livesingleselectionmanipulator_p.h" -#include "liveselectionindicator_p.h" - -#include -#include - -QT_FORWARD_DECLARE_CLASS(QGraphicsItem) -QT_FORWARD_DECLARE_CLASS(QMouseEvent) -QT_FORWARD_DECLARE_CLASS(QKeyEvent) -QT_FORWARD_DECLARE_CLASS(QAction) - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class LiveSelectionTool : public AbstractLiveEditTool -{ - Q_OBJECT - -public: - LiveSelectionTool(QDeclarativeViewInspector* editorView); - ~LiveSelectionTool(); - - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); - void hoverMoveEvent(QMouseEvent *event); - void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *keyEvent); - void wheelEvent(QWheelEvent *event); - - void itemsAboutToRemoved(const QList &itemList); -// QVariant itemChange(const QList &itemList, -// QGraphicsItem::GraphicsItemChange change, -// const QVariant &value ); - -// void update(); - - void clear(); - - void selectedItemsChanged(const QList &itemList); - - void selectUnderPoint(QMouseEvent *event); - - void setSelectOnlyContentItems(bool selectOnlyContentItems); - - void setRubberbandSelectionMode(bool value); - -private slots: - void contextMenuElementSelected(); - void contextMenuElementHovered(QAction *action); - void repaintBoundingRects(); - -private: - void createContextMenu(QList itemList, QPoint globalPos); - LiveSingleSelectionManipulator::SelectionType getSelectionType(Qt::KeyboardModifiers modifiers); - bool alreadySelected(const QList &itemList) const; - -private: - bool m_rubberbandSelectionMode; - LiveRubberBandSelectionManipulator m_rubberbandSelectionManipulator; - LiveSingleSelectionManipulator m_singleSelectionManipulator; - LiveSelectionIndicator m_selectionIndicator; - //ResizeIndicator m_resizeIndicator; - QTime m_mousePressTimer; - bool m_selectOnlyContentItems; - - QList > m_selectedItemList; - - QList m_contextMenuItemList; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // LIVESELECTIONTOOL_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator.cpp index ee9843b..34c1469 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator.cpp @@ -39,13 +39,13 @@ ** ****************************************************************************/ -#include "livesingleselectionmanipulator_p.h" +#include "livesingleselectionmanipulator.h" -#include "../qdeclarativeviewinspector_p_p.h" +#include "../qdeclarativeviewinspector_p.h" #include -QT_BEGIN_NAMESPACE +namespace QmlJSDebugger { LiveSingleSelectionManipulator::LiveSingleSelectionManipulator(QDeclarativeViewInspector *editorView) : m_editorView(editorView), @@ -148,4 +148,4 @@ QPointF LiveSingleSelectionManipulator::beginPoint() const return m_beginPoint; } -QT_END_NAMESPACE +} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator.h b/src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator.h new file mode 100644 index 0000000..ac65711 --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef LIVESINGLESELECTIONMANIPULATOR_H +#define LIVESINGLESELECTIONMANIPULATOR_H + +#include +#include + +QT_FORWARD_DECLARE_CLASS(QGraphicsItem) + +namespace QmlJSDebugger { + +class QDeclarativeViewInspector; + +class LiveSingleSelectionManipulator +{ +public: + LiveSingleSelectionManipulator(QDeclarativeViewInspector *editorView); + + enum SelectionType { + ReplaceSelection, + AddToSelection, + RemoveFromSelection, + InvertSelection + }; + + void begin(const QPointF& beginPoint); + void update(const QPointF& updatePoint); + void end(const QPointF& updatePoint); + + void select(SelectionType selectionType, const QList &items, + bool selectOnlyContentItems); + void select(SelectionType selectionType, bool selectOnlyContentItems); + + void clear(); + + QPointF beginPoint() const; + + bool isActive() const; + +private: + QList m_oldSelectionList; + QPointF m_beginPoint; + QDeclarativeViewInspector *m_editorView; + bool m_isActive; +}; + +} // namespace QmlJSDebugger + +#endif // LIVESINGLESELECTIONMANIPULATOR_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator_p.h deleted file mode 100644 index 40b5fc0..0000000 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/livesingleselectionmanipulator_p.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LIVESINGLESELECTIONMANIPULATOR_H -#define LIVESINGLESELECTIONMANIPULATOR_H - -#include -#include - -QT_FORWARD_DECLARE_CLASS(QGraphicsItem) - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QDeclarativeViewInspector; - -class LiveSingleSelectionManipulator -{ -public: - LiveSingleSelectionManipulator(QDeclarativeViewInspector *editorView); - - enum SelectionType { - ReplaceSelection, - AddToSelection, - RemoveFromSelection, - InvertSelection - }; - - void begin(const QPointF& beginPoint); - void update(const QPointF& updatePoint); - void end(const QPointF& updatePoint); - - void select(SelectionType selectionType, const QList &items, - bool selectOnlyContentItems); - void select(SelectionType selectionType, bool selectOnlyContentItems); - - void clear(); - - QPointF beginPoint() const; - - bool isActive() const; - -private: - QList m_oldSelectionList; - QPointF m_beginPoint; - QDeclarativeViewInspector *m_editorView; - bool m_isActive; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // LIVESINGLESELECTIONMANIPULATOR_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.cpp index 0a72674..4e0e375 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#include "qmltoolbar_p.h" -#include "toolbarcolorbox_p.h" +#include "qmltoolbar.h" +#include "toolbarcolorbox.h" #include #include @@ -49,7 +49,7 @@ #include -QT_BEGIN_NAMESPACE +namespace QmlJSDebugger { QmlToolBar::QmlToolBar(QWidget *parent) : QToolBar(parent) @@ -325,4 +325,4 @@ void QmlToolBar::activateToQml() emit applyChangesToQmlFileSelected(); } -QT_END_NAMESPACE +} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.h b/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.h new file mode 100644 index 0000000..2abf166 --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar.h @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLTOOLBAR_H +#define QMLTOOLBAR_H + +#include +#include + +#include "../qmlinspectorconstants.h" + +QT_FORWARD_DECLARE_CLASS(QActionGroup) + +namespace QmlJSDebugger { + +class ToolBarColorBox; + +class QmlToolBar : public QToolBar +{ + Q_OBJECT + +public: + explicit QmlToolBar(QWidget *parent = 0); + ~QmlToolBar(); + +public slots: + void setDesignModeBehavior(bool inDesignMode); + void setColorBoxColor(const QColor &color); + void activateColorPicker(); + void activateSelectTool(); + void activateMarqueeSelectTool(); + void activateZoom(); + + void setAnimationSpeed(qreal slowDownFactor); + void setAnimationPaused(bool paused); + +signals: + void animationSpeedChanged(qreal factor); + void animationPausedChanged(bool paused); + + void designModeBehaviorChanged(bool inDesignMode); + void colorPickerSelected(); + void selectToolSelected(); + void marqueeSelectToolSelected(); + void zoomToolSelected(); + + void applyChangesToQmlFileSelected(); + void applyChangesFromQmlFileSelected(); + +private slots: + void setDesignModeBehaviorOnClick(bool inDesignMode); + void activatePlayOnClick(); + void activateColorPickerOnClick(); + void activateSelectToolOnClick(); + void activateMarqueeSelectToolOnClick(); + void activateZoomOnClick(); + + void activateFromQml(); + void activateToQml(); + + void changeAnimationSpeed(); + + void updatePlayAction(); + +private: + class Ui { + public: + QAction *designmode; + QAction *play; + QAction *select; + QAction *selectMarquee; + QAction *zoom; + QAction *colorPicker; + QAction *toQml; + QAction *fromQml; + QIcon playIcon; + QIcon pauseIcon; + ToolBarColorBox *colorBox; + + QActionGroup *playSpeedMenuActions; + }; + + bool m_emitSignals; + bool m_paused; + qreal m_animationSpeed; + + Constants::DesignTool m_activeTool; + + Ui *ui; +}; + +} + +#endif // QMLTOOLBAR_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar_p.h deleted file mode 100644 index 0401804..0000000 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/qmltoolbar_p.h +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLTOOLBAR_H -#define QMLTOOLBAR_H - -#include -#include - -#include "../qmlinspectorconstants_p.h" - -QT_FORWARD_DECLARE_CLASS(QActionGroup) - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class ToolBarColorBox; - -class QmlToolBar : public QToolBar -{ - Q_OBJECT - -public: - explicit QmlToolBar(QWidget *parent = 0); - ~QmlToolBar(); - -public slots: - void setDesignModeBehavior(bool inDesignMode); - void setColorBoxColor(const QColor &color); - void activateColorPicker(); - void activateSelectTool(); - void activateMarqueeSelectTool(); - void activateZoom(); - - void setAnimationSpeed(qreal slowDownFactor); - void setAnimationPaused(bool paused); - -signals: - void animationSpeedChanged(qreal factor); - void animationPausedChanged(bool paused); - - void designModeBehaviorChanged(bool inDesignMode); - void colorPickerSelected(); - void selectToolSelected(); - void marqueeSelectToolSelected(); - void zoomToolSelected(); - - void applyChangesToQmlFileSelected(); - void applyChangesFromQmlFileSelected(); - -private slots: - void setDesignModeBehaviorOnClick(bool inDesignMode); - void activatePlayOnClick(); - void activateColorPickerOnClick(); - void activateSelectToolOnClick(); - void activateMarqueeSelectToolOnClick(); - void activateZoomOnClick(); - - void activateFromQml(); - void activateToQml(); - - void changeAnimationSpeed(); - - void updatePlayAction(); - -private: - class Ui { - public: - QAction *designmode; - QAction *play; - QAction *select; - QAction *selectMarquee; - QAction *zoom; - QAction *colorPicker; - QAction *toQml; - QAction *fromQml; - QIcon playIcon; - QIcon pauseIcon; - ToolBarColorBox *colorBox; - - QActionGroup *playSpeedMenuActions; - }; - - bool m_emitSignals; - bool m_paused; - qreal m_animationSpeed; - - Constants::DesignTool m_activeTool; - - Ui *ui; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMLTOOLBAR_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.cpp index 2ed3179..5d99886 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.cpp @@ -39,14 +39,14 @@ ** ****************************************************************************/ -#include "subcomponentmasklayeritem_p.h" +#include "subcomponentmasklayeritem.h" -#include "../qmlinspectorconstants_p.h" -#include "../qdeclarativeviewinspector_p.h" +#include "../qmlinspectorconstants.h" +#include "../qdeclarativeviewinspector.h" #include -QT_BEGIN_NAMESPACE +namespace QmlJSDebugger { SubcomponentMaskLayerItem::SubcomponentMaskLayerItem(QDeclarativeViewInspector *inspector, QGraphicsItem *parentItem) : @@ -127,4 +127,4 @@ QGraphicsItem *SubcomponentMaskLayerItem::currentItem() const return m_currentItem; } -QT_END_NAMESPACE +} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.h b/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.h new file mode 100644 index 0000000..e41d70a --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SUBCOMPONENTMASKLAYERITEM_H +#define SUBCOMPONENTMASKLAYERITEM_H + +#include + +namespace QmlJSDebugger { + +class QDeclarativeViewInspector; + +class SubcomponentMaskLayerItem : public QGraphicsPolygonItem +{ +public: + explicit SubcomponentMaskLayerItem(QDeclarativeViewInspector *inspector, + QGraphicsItem *parentItem = 0); + int type() const; + void setCurrentItem(QGraphicsItem *item); + void setBoundingBox(const QRectF &boundingBox); + QGraphicsItem *currentItem() const; + QRectF itemRect() const; + +private: + QDeclarativeViewInspector *m_inspector; + QGraphicsItem *m_currentItem; + QGraphicsRectItem *m_borderRect; + QRectF m_itemPolyRect; +}; + +} // namespace QmlJSDebugger + +#endif // SUBCOMPONENTMASKLAYERITEM_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem_p.h deleted file mode 100644 index 07ce881..0000000 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/subcomponentmasklayeritem_p.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SUBCOMPONENTMASKLAYERITEM_H -#define SUBCOMPONENTMASKLAYERITEM_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QDeclarativeViewInspector; - -class SubcomponentMaskLayerItem : public QGraphicsPolygonItem -{ -public: - explicit SubcomponentMaskLayerItem(QDeclarativeViewInspector *inspector, - QGraphicsItem *parentItem = 0); - int type() const; - void setCurrentItem(QGraphicsItem *item); - void setBoundingBox(const QRectF &boundingBox); - QGraphicsItem *currentItem() const; - QRectF itemRect() const; - -private: - QDeclarativeViewInspector *m_inspector; - QGraphicsItem *m_currentItem; - QGraphicsRectItem *m_borderRect; - QRectF m_itemPolyRect; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // SUBCOMPONENTMASKLAYERITEM_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.cpp index 154ddf2..0914662 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.cpp @@ -39,9 +39,9 @@ ** ****************************************************************************/ -#include "toolbarcolorbox_p.h" +#include "toolbarcolorbox.h" -#include "../qmlinspectorconstants_p.h" +#include "../qmlinspectorconstants.h" #include #include @@ -56,7 +56,7 @@ #include #include -QT_BEGIN_NAMESPACE +namespace QmlJSDebugger { ToolBarColorBox::ToolBarColorBox(QWidget *parent) : QLabel(parent) @@ -131,4 +131,4 @@ void ToolBarColorBox::copyColorToClipboard() clipboard->setText(m_color.name()); } -QT_END_NAMESPACE +} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.h b/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.h new file mode 100644 index 0000000..8ef75a4 --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TOOLBARCOLORBOX_H +#define TOOLBARCOLORBOX_H + +#include +#include +#include + +QT_FORWARD_DECLARE_CLASS(QContextMenuEvent) +QT_FORWARD_DECLARE_CLASS(QAction) + +namespace QmlJSDebugger { + +class ToolBarColorBox : public QLabel +{ + Q_OBJECT + +public: + explicit ToolBarColorBox(QWidget *parent = 0); + void setColor(const QColor &color); + +protected: + void contextMenuEvent(QContextMenuEvent *ev); + void mousePressEvent(QMouseEvent *ev); + void mouseMoveEvent(QMouseEvent *ev); +private slots: + void copyColorToClipboard(); + +private: + QPixmap createDragPixmap(int size = 24) const; + +private: + bool m_dragStarted; + QPoint m_dragBeginPoint; + QAction *m_copyHexColor; + QColor m_color; +}; + +} // namespace QmlJSDebugger + +#endif // TOOLBARCOLORBOX_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox_p.h deleted file mode 100644 index c3e064c..0000000 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/toolbarcolorbox_p.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TOOLBARCOLORBOX_H -#define TOOLBARCOLORBOX_H - -#include -#include -#include - -QT_FORWARD_DECLARE_CLASS(QContextMenuEvent) -QT_FORWARD_DECLARE_CLASS(QAction) - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class ToolBarColorBox : public QLabel -{ - Q_OBJECT - -public: - explicit ToolBarColorBox(QWidget *parent = 0); - void setColor(const QColor &color); - -protected: - void contextMenuEvent(QContextMenuEvent *ev); - void mousePressEvent(QMouseEvent *ev); - void mouseMoveEvent(QMouseEvent *ev); -private slots: - void copyColorToClipboard(); - -private: - QPixmap createDragPixmap(int size = 24) const; - -private: - bool m_dragStarted; - QPoint m_dragBeginPoint; - QAction *m_copyHexColor; - QColor m_color; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // TOOLBARCOLORBOX_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp index 969c9d5..3a4b6bf 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp @@ -39,9 +39,9 @@ ** ****************************************************************************/ -#include "zoomtool_p.h" +#include "zoomtool.h" -#include "../qdeclarativeviewinspector_p_p.h" +#include "../qdeclarativeviewinspector_p.h" #include #include @@ -52,7 +52,7 @@ #include #include -QT_BEGIN_NAMESPACE +namespace QmlJSDebugger { ZoomTool::ZoomTool(QDeclarativeViewInspector *view) : AbstractLiveEditTool(view), @@ -333,4 +333,4 @@ qreal ZoomTool::nextZoomScale(ZoomDirection direction) const return 1.0f; } -QT_END_NAMESPACE +} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.h b/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.h new file mode 100644 index 0000000..94735cf --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ZOOMTOOL_H +#define ZOOMTOOL_H + +#include "abstractliveedittool.h" +#include "liverubberbandselectionmanipulator.h" + +QT_FORWARD_DECLARE_CLASS(QAction) + +namespace QmlJSDebugger { + +class ZoomTool : public AbstractLiveEditTool +{ + Q_OBJECT + +public: + enum ZoomDirection { + ZoomIn, + ZoomOut + }; + + explicit ZoomTool(QDeclarativeViewInspector *view); + + virtual ~ZoomTool(); + + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void mouseDoubleClickEvent(QMouseEvent *event); + + void hoverMoveEvent(QMouseEvent *event); + void wheelEvent(QWheelEvent *event); + + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *keyEvent); + void itemsAboutToRemoved(const QList &itemList); + + void clear(); + +protected: + void selectedItemsChanged(const QList &itemList); + +private slots: + void zoomTo100(); + void zoomIn(); + void zoomOut(); + +private: + qreal nextZoomScale(ZoomDirection direction) const; + void scaleView(const QPointF ¢erPos); + +private: + bool m_dragStarted; + QPoint m_mousePos; // in view coords + QPointF m_dragBeginPos; + QAction *m_zoomTo100Action; + QAction *m_zoomInAction; + QAction *m_zoomOutAction; + LiveRubberBandSelectionManipulator *m_rubberbandManipulator; + + qreal m_smoothZoomMultiplier; + qreal m_currentScale; +}; + +} // namespace QmlJSDebugger + +#endif // ZOOMTOOL_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool_p.h b/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool_p.h deleted file mode 100644 index 14fa4d5..0000000 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool_p.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef ZOOMTOOL_H -#define ZOOMTOOL_H - -#include "abstractliveedittool_p.h" -#include "liverubberbandselectionmanipulator_p.h" - -QT_FORWARD_DECLARE_CLASS(QAction) - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class ZoomTool : public AbstractLiveEditTool -{ - Q_OBJECT - -public: - enum ZoomDirection { - ZoomIn, - ZoomOut - }; - - explicit ZoomTool(QDeclarativeViewInspector *view); - - virtual ~ZoomTool(); - - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); - - void hoverMoveEvent(QMouseEvent *event); - void wheelEvent(QWheelEvent *event); - - void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *keyEvent); - void itemsAboutToRemoved(const QList &itemList); - - void clear(); - -protected: - void selectedItemsChanged(const QList &itemList); - -private slots: - void zoomTo100(); - void zoomIn(); - void zoomOut(); - -private: - qreal nextZoomScale(ZoomDirection direction) const; - void scaleView(const QPointF ¢erPos); - -private: - bool m_dragStarted; - QPoint m_mousePos; // in view coords - QPointF m_dragBeginPos; - QAction *m_zoomTo100Action; - QAction *m_zoomInAction; - QAction *m_zoomOutAction; - LiveRubberBandSelectionManipulator *m_rubberbandManipulator; - - qreal m_smoothZoomMultiplier; - qreal m_currentScale; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // ZOOMTOOL_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.cpp b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.cpp index a266eb9..932f911 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.cpp @@ -46,7 +46,7 @@ #include #include -QT_BEGIN_NAMESPACE +namespace QmlJSDebugger { QDeclarativeInspectorPlugin::QDeclarativeInspectorPlugin() : m_inspector(0) @@ -75,7 +75,6 @@ void QDeclarativeInspectorPlugin::deactivate() delete m_inspector; } -Q_EXPORT_PLUGIN2(declarativeinspector, QDeclarativeInspectorPlugin) - -QT_END_NAMESPACE +} // namespace QmlJSDebugger +Q_EXPORT_PLUGIN2(declarativeinspector, QmlJSDebugger::QDeclarativeInspectorPlugin) diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.h index e271c07..5429253 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorplugin.h @@ -45,7 +45,7 @@ #include #include -QT_BEGIN_NAMESPACE +namespace QmlJSDebugger { class AbstractViewInspector; @@ -66,6 +66,6 @@ private: QPointer m_inspector; }; -QT_END_NAMESPACE +} // namespace QmlJSDebugger #endif // QDECLARATIVEINSPECTORPLUGIN_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorprotocol.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorprotocol.h index 2878bc1..082abeb 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorprotocol.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeinspectorprotocol.h @@ -47,11 +47,7 @@ #include #include -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) +namespace QmlJSDebugger { class InspectorProtocol : public QObject { @@ -136,8 +132,6 @@ inline QDebug operator<< (QDebug dbg, InspectorProtocol::Tool tool) return dbg; } -QT_END_NAMESPACE - -QT_END_HEADER +} // namespace QmlJSDebugger #endif // QDECLARATIVEINSPECTORPROTOCOL_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp index be0422d..462fd19 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp @@ -39,14 +39,14 @@ ** ****************************************************************************/ +#include "qdeclarativeviewinspector.h" #include "qdeclarativeviewinspector_p.h" -#include "qdeclarativeviewinspector_p_p.h" -#include "editor/liveselectiontool_p.h" -#include "editor/zoomtool_p.h" -#include "editor/colorpickertool_p.h" -#include "editor/livelayeritem_p.h" -#include "editor/boundingrecthighlighter_p.h" +#include "editor/liveselectiontool.h" +#include "editor/zoomtool.h" +#include "editor/colorpickertool.h" +#include "editor/livelayeritem.h" +#include "editor/boundingrecthighlighter.h" #include #include @@ -57,7 +57,7 @@ #include #include -QT_BEGIN_NAMESPACE +namespace QmlJSDebugger { QDeclarativeViewInspectorPrivate::QDeclarativeViewInspectorPrivate(QDeclarativeViewInspector *q) : q(q) @@ -570,4 +570,4 @@ QRectF QDeclarativeViewInspector::adjustToScreenBoundaries(const QRectF &boundin return boundingRect; } -QT_END_NAMESPACE +} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h new file mode 100644 index 0000000..c08ef54 --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEVIEWINSPECTOR_H +#define QDECLARATIVEVIEWINSPECTOR_H + +#include + +#include "qmlinspectorconstants.h" +#include "abstractviewinspector.h" + +#include +#include + +QT_FORWARD_DECLARE_CLASS(QDeclarativeItem) +QT_FORWARD_DECLARE_CLASS(QMouseEvent) +QT_FORWARD_DECLARE_CLASS(QToolBar) + +namespace QmlJSDebugger { + +class QDeclarativeViewInspectorPrivate; + +class QDeclarativeViewInspector : public AbstractViewInspector +{ + Q_OBJECT + +public: + explicit QDeclarativeViewInspector(QDeclarativeView *view, QObject *parent = 0); + ~QDeclarativeViewInspector(); + + // AbstractViewInspector + void changeCurrentObjects(const QList &objects); + void reloadView(); + void reparentQmlObject(QObject *object, QObject *newParent); + void changeTool(InspectorProtocol::Tool tool); + QWidget *viewWidget() const { return declarativeView(); } + QDeclarativeEngine *declarativeEngine() const; + + void setSelectedItems(QList items); + QList selectedItems() const; + + QDeclarativeView *declarativeView() const; + + QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace); + +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: + 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/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h index c89a259..cd8d749 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h @@ -42,74 +42,80 @@ #ifndef QDECLARATIVEVIEWINSPECTOR_P_H #define QDECLARATIVEVIEWINSPECTOR_P_H -#include +#include "qdeclarativeviewinspector.h" -#include "qmlinspectorconstants_p.h" -#include "abstractviewinspector.h" +#include +#include -#include -#include +#include "QtDeclarative/private/qdeclarativeinspectorservice_p.h" -QT_FORWARD_DECLARE_CLASS(QDeclarativeItem) -QT_FORWARD_DECLARE_CLASS(QMouseEvent) -QT_FORWARD_DECLARE_CLASS(QToolBar) +namespace QmlJSDebugger { -QT_BEGIN_HEADER +class QDeclarativeViewInspector; +class LiveSelectionTool; +class ZoomTool; +class ColorPickerTool; +class LiveLayerItem; +class BoundingRectHighlighter; +class AbstractLiveEditTool; -QT_BEGIN_NAMESPACE +class QDeclarativeViewInspectorPrivate : public QObject +{ + Q_OBJECT +public: + QDeclarativeViewInspectorPrivate(QDeclarativeViewInspector *); + ~QDeclarativeViewInspectorPrivate(); -QT_MODULE(Declarative) + QDeclarativeView *view; + QDeclarativeViewInspector *q; + QWeakPointer viewport; -class QDeclarativeViewInspectorPrivate; + QPointF cursorPos; + QList > currentSelection; -class QDeclarativeViewInspector : public AbstractViewInspector -{ - Q_OBJECT + Constants::DesignTool currentToolMode; + AbstractLiveEditTool *currentTool; -public: - explicit QDeclarativeViewInspector(QDeclarativeView *view, QObject *parent = 0); - ~QDeclarativeViewInspector(); - - // AbstractViewInspector - void changeCurrentObjects(const QList &objects); - void reloadView(); - void reparentQmlObject(QObject *object, QObject *newParent); - void changeTool(InspectorProtocol::Tool tool); - QWidget *viewWidget() const { return declarativeView(); } - QDeclarativeEngine *declarativeEngine() const; - - void setSelectedItems(QList items); - QList selectedItems() const; + LiveSelectionTool *selectionTool; + ZoomTool *zoomTool; + ColorPickerTool *colorPickerTool; + LiveLayerItem *manipulatorLayer; - QDeclarativeView *declarativeView() const; + BoundingRectHighlighter *boundingRectHighlighter; - QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace); + void setViewport(QWidget *widget); -protected: - bool eventFilter(QObject *obj, QEvent *event); + void clearEditorItems(); + void changeToSelectTool(); + QList filterForSelection(QList &itemlist) const; - 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); + QList selectableItems(const QPoint &pos) const; + QList selectableItems(const QPointF &scenePos) const; + QList selectableItems(const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const; - void setSelectedItemsForTools(QList items); + void setSelectedItemsForTools(const QList &items); + void setSelectedItems(const QList &items); + QList selectedItems() const; -private: - Q_DISABLE_COPY(QDeclarativeViewInspector) + void clearHighlight(); + void highlight(const QList &item); + inline void highlight(QGraphicsObject *item) + { highlight(QList() << item); } - inline QDeclarativeViewInspectorPrivate *d_func() { return data.data(); } - QScopedPointer data; - friend class QDeclarativeViewInspectorPrivate; - friend class AbstractLiveEditTool; -}; + void changeToSingleSelectTool(); + void changeToMarqueeSelectTool(); + void changeToZoomTool(); + void changeToColorPickerTool(); + +public slots: + void _q_onStatusChanged(QDeclarativeView::Status status); -QT_END_NAMESPACE + void _q_removeFromSelection(QObject *); + +public: + static QDeclarativeViewInspectorPrivate *get(QDeclarativeViewInspector *v) { return v->d_func(); } +}; -QT_END_HEADER +} // namespace QmlJSDebugger #endif // QDECLARATIVEVIEWINSPECTOR_P_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p_p.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p_p.h deleted file mode 100644 index a412df3..0000000 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p_p.h +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEVIEWINSPECTOR_P_P_H -#define QDECLARATIVEVIEWINSPECTOR_P_P_H - -#include "qdeclarativeviewinspector_p.h" - -#include -#include - -#include "QtDeclarative/private/qdeclarativeinspectorservice_p.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QDeclarativeViewInspector; -class LiveSelectionTool; -class ZoomTool; -class ColorPickerTool; -class LiveLayerItem; -class BoundingRectHighlighter; -class AbstractLiveEditTool; - -class QDeclarativeViewInspectorPrivate : public QObject -{ - Q_OBJECT -public: - QDeclarativeViewInspectorPrivate(QDeclarativeViewInspector *); - ~QDeclarativeViewInspectorPrivate(); - - QDeclarativeView *view; - QDeclarativeViewInspector *q; - QWeakPointer viewport; - - QPointF cursorPos; - QList > currentSelection; - - Constants::DesignTool currentToolMode; - AbstractLiveEditTool *currentTool; - - LiveSelectionTool *selectionTool; - ZoomTool *zoomTool; - ColorPickerTool *colorPickerTool; - LiveLayerItem *manipulatorLayer; - - BoundingRectHighlighter *boundingRectHighlighter; - - void setViewport(QWidget *widget); - - void clearEditorItems(); - void changeToSelectTool(); - QList filterForSelection(QList &itemlist) const; - - QList selectableItems(const QPoint &pos) const; - QList selectableItems(const QPointF &scenePos) const; - QList selectableItems(const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const; - - void setSelectedItemsForTools(const QList &items); - void setSelectedItems(const QList &items); - QList selectedItems() const; - - void clearHighlight(); - void highlight(const QList &item); - inline void highlight(QGraphicsObject *item) - { highlight(QList() << item); } - - void changeToSingleSelectTool(); - void changeToMarqueeSelectTool(); - void changeToZoomTool(); - void changeToColorPickerTool(); - -public slots: - void _q_onStatusChanged(QDeclarativeView::Status status); - - void _q_removeFromSelection(QObject *); - -public: - static QDeclarativeViewInspectorPrivate *get(QDeclarativeViewInspector *v) { return v->d_func(); } -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEVIEWINSPECTOR_P_P_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro index fd2a744..6c56e62 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro +++ b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro @@ -28,22 +28,22 @@ HEADERS += \ abstractviewinspector.h \ qdeclarativeinspectorplugin.h \ qdeclarativeinspectorprotocol.h \ + qdeclarativeviewinspector.h \ qdeclarativeviewinspector_p.h \ - qdeclarativeviewinspector_p_p.h \ - qmlinspectorconstants_p.h \ - editor/abstractliveedittool_p.h \ - editor/liveselectiontool_p.h \ - editor/livelayeritem_p.h \ - editor/livesingleselectionmanipulator_p.h \ - editor/liverubberbandselectionmanipulator_p.h \ - editor/liveselectionrectangle_p.h \ - editor/liveselectionindicator_p.h \ - editor/boundingrecthighlighter_p.h \ - editor/subcomponentmasklayeritem_p.h \ - editor/zoomtool_p.h \ - editor/colorpickertool_p.h \ - editor/qmltoolbar_p.h \ - editor/toolbarcolorbox_p.h + qmlinspectorconstants.h \ + editor/abstractliveedittool.h \ + editor/liveselectiontool.h \ + editor/livelayeritem.h \ + editor/livesingleselectionmanipulator.h \ + editor/liverubberbandselectionmanipulator.h \ + editor/liveselectionrectangle.h \ + editor/liveselectionindicator.h \ + editor/boundingrecthighlighter.h \ + editor/subcomponentmasklayeritem.h \ + editor/zoomtool.h \ + editor/colorpickertool.h \ + editor/qmltoolbar.h \ + editor/toolbarcolorbox.h RESOURCES += editor/editor.qrc diff --git a/src/plugins/qmltooling/qmldbg_inspector/qmlinspectorconstants.h b/src/plugins/qmltooling/qmldbg_inspector/qmlinspectorconstants.h new file mode 100644 index 0000000..5335222 --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/qmlinspectorconstants.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLINSPECTORCONSTANTS_H +#define QMLINSPECTORCONSTANTS_H + +#include + +namespace QmlJSDebugger { +namespace Constants { + +enum DesignTool { + NoTool = 0, + SelectionToolMode = 1, + MarqueeSelectionToolMode = 2, + MoveToolMode = 3, + ResizeToolMode = 4, + ColorPickerMode = 5, + ZoomMode = 6 +}; + +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/src/plugins/qmltooling/qmldbg_inspector/qmlinspectorconstants_p.h b/src/plugins/qmltooling/qmldbg_inspector/qmlinspectorconstants_p.h deleted file mode 100644 index 9f6b116..0000000 --- a/src/plugins/qmltooling/qmldbg_inspector/qmlinspectorconstants_p.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** 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. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLINSPECTORCONSTANTS_H -#define QMLINSPECTORCONSTANTS_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -namespace Constants { - -enum DesignTool { - NoTool = 0, - SelectionToolMode = 1, - MarqueeSelectionToolMode = 2, - MoveToolMode = 3, - ResizeToolMode = 4, - ColorPickerMode = 5, - ZoomMode = 6 -}; - -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 - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMLINSPECTORCONSTANTS_H -- cgit v0.12 From 201d6b8d0bfed588d609fd5619470ced78c7718d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Thu, 9 Jun 2011 13:30:47 +0200 Subject: QmlInspector: Unified mouse and keyboard event handling Introduced a common AbstractTool interface so that the AbstractViewInspector can forward mouse and keyboard events and also implement the keys to switch tools. The AbstractLiveEditTool still exists as the base class for all QDeclarativeView based tools. (cherry picked from commit 0f2e1526068ed11bb981357fdeb406f5c804717b in Qt 5 / QtDeclarative, to make synchronizing future changes easier) Change-Id: Idf9f29d2ea111a6fef7145890a190f5cd22a8b8c Reviewed-by: Kai Koehne --- .../qmltooling/qmldbg_inspector/abstracttool.cpp | 54 +++++++ .../qmltooling/qmldbg_inspector/abstracttool.h | 85 ++++++++++ .../qmldbg_inspector/abstractviewinspector.cpp | 121 ++++++++++++++ .../qmldbg_inspector/abstractviewinspector.h | 20 +++ .../editor/abstractliveedittool.cpp | 8 +- .../qmldbg_inspector/editor/abstractliveedittool.h | 15 +- .../qmldbg_inspector/qdeclarativeviewinspector.cpp | 177 ++++----------------- .../qmldbg_inspector/qdeclarativeviewinspector.h | 11 +- .../qmldbg_inspector/qdeclarativeviewinspector_p.h | 3 - .../qmldbg_inspector/qmldbg_inspector.pro | 6 +- 10 files changed, 320 insertions(+), 180 deletions(-) create mode 100644 src/plugins/qmltooling/qmldbg_inspector/abstracttool.cpp create mode 100644 src/plugins/qmltooling/qmldbg_inspector/abstracttool.h diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstracttool.cpp b/src/plugins/qmltooling/qmldbg_inspector/abstracttool.cpp new file mode 100644 index 0000000..39ced2a --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/abstracttool.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "abstracttool.h" + +#include "abstractviewinspector.h" + +namespace QmlJSDebugger { + +AbstractTool::AbstractTool(AbstractViewInspector *inspector) : + QObject(inspector), + m_inspector(inspector) +{ +} + +} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstracttool.h b/src/plugins/qmltooling/qmldbg_inspector/abstracttool.h new file mode 100644 index 0000000..0a216bf --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_inspector/abstracttool.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** 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. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ABSTRACTTOOL_H +#define ABSTRACTTOOL_H + +#include + +QT_BEGIN_NAMESPACE +class QMouseEvent; +class QKeyEvent; +class QWheelEvent; +QT_END_NAMESPACE + +namespace QmlJSDebugger { + +class AbstractViewInspector; + +class AbstractTool : public QObject +{ + Q_OBJECT + +public: + explicit AbstractTool(AbstractViewInspector *inspector); + + AbstractViewInspector *inspector() const { return m_inspector; } + + virtual void leaveEvent(QEvent *event) = 0; + + 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; + +private: + AbstractViewInspector *m_inspector; +}; + +} // namespace QmlJSDebugger + +#endif // ABSTRACTTOOL_H diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp index a698819..3323d54 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.cpp @@ -41,6 +41,7 @@ #include "abstractviewinspector.h" +#include "abstracttool.h" #include "editor/qmltoolbar.h" #include "qdeclarativeinspectorprotocol.h" @@ -50,6 +51,7 @@ #include "QtDeclarative/private/qdeclarativeinspectorservice_p.h" #include +#include #include static inline void initEditorResource() { Q_INIT_RESOURCE(editor); } @@ -99,6 +101,7 @@ ToolBox::~ToolBox() AbstractViewInspector::AbstractViewInspector(QObject *parent) : QObject(parent), m_toolBox(0), + m_currentTool(0), m_showAppOnTop(false), m_designModeBehavior(false), m_animationPaused(false), @@ -284,6 +287,124 @@ void AbstractViewInspector::changeToMarqueeSelectTool() changeTool(InspectorProtocol::SelectMarqueeTool); } +bool AbstractViewInspector::eventFilter(QObject *obj, QEvent *event) +{ + if (!designModeBehavior()) + return QObject::eventFilter(obj, event); + + switch (event->type()) { + case QEvent::Leave: + if (leaveEvent(event)) + return true; + break; + case QEvent::MouseButtonPress: + if (mousePressEvent(static_cast(event))) + return true; + break; + case QEvent::MouseMove: + if (mouseMoveEvent(static_cast(event))) + return true; + break; + case QEvent::MouseButtonRelease: + if (mouseReleaseEvent(static_cast(event))) + return true; + break; + case QEvent::KeyPress: + if (keyPressEvent(static_cast(event))) + return true; + break; + case QEvent::KeyRelease: + if (keyReleaseEvent(static_cast(event))) + return true; + break; + case QEvent::MouseButtonDblClick: + if (mouseDoubleClickEvent(static_cast(event))) + return true; + break; + case QEvent::Wheel: + if (wheelEvent(static_cast(event))) + return true; + break; + default: + break; + } + + return QObject::eventFilter(obj, event); +} + +bool AbstractViewInspector::leaveEvent(QEvent *event) +{ + m_currentTool->leaveEvent(event); + return true; +} + +bool AbstractViewInspector::mousePressEvent(QMouseEvent *event) +{ + m_currentTool->mousePressEvent(event); + return true; +} + +bool AbstractViewInspector::mouseMoveEvent(QMouseEvent *event) +{ + if (event->buttons()) { + m_currentTool->mouseMoveEvent(event); + } else { + m_currentTool->hoverMoveEvent(event); + } + return true; +} + +bool AbstractViewInspector::mouseReleaseEvent(QMouseEvent *event) +{ + m_currentTool->mouseReleaseEvent(event); + return true; +} + +bool AbstractViewInspector::keyPressEvent(QKeyEvent *event) +{ + m_currentTool->keyPressEvent(event); + return true; +} + +bool AbstractViewInspector::keyReleaseEvent(QKeyEvent *event) +{ + switch (event->key()) { + case Qt::Key_V: + changeTool(InspectorProtocol::SelectTool); + break; +// disabled because multiselection does not do anything useful without design mode +// case Qt::Key_M: +// changeTool(InspectorProtocol::SelectMarqueeTool); +// break; + case Qt::Key_I: + changeTool(InspectorProtocol::ColorPickerTool); + break; + case Qt::Key_Z: + changeTool(InspectorProtocol::ZoomTool); + break; + case Qt::Key_Space: + setAnimationPaused(!animationPaused()); + break; + default: + break; + } + + m_currentTool->keyReleaseEvent(event); + return true; +} + +bool AbstractViewInspector::mouseDoubleClickEvent(QMouseEvent *event) +{ + m_currentTool->mouseDoubleClickEvent(event); + return true; +} + +bool AbstractViewInspector::wheelEvent(QWheelEvent *event) +{ + m_currentTool->wheelEvent(event); + return true; +} + void AbstractViewInspector::handleMessage(const QByteArray &message) { QDataStream ds(message); diff --git a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h index 0a56ead..7202bcc 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h +++ b/src/plugins/qmltooling/qmldbg_inspector/abstractviewinspector.h @@ -53,10 +53,14 @@ QT_BEGIN_NAMESPACE class QDeclarativeEngine; class QDeclarativeInspectorService; +class QKeyEvent; +class QMouseEvent; +class QWheelEvent; QT_END_NAMESPACE namespace QmlJSDebugger { +class AbstractTool; class ToolBox; /* @@ -131,6 +135,21 @@ signals: void animationSpeedChanged(qreal factor); void animationPausedChanged(bool paused); +protected: + bool eventFilter(QObject *, QEvent *); + + virtual bool leaveEvent(QEvent *); + virtual bool mousePressEvent(QMouseEvent *event); + virtual bool mouseMoveEvent(QMouseEvent *event); + virtual bool mouseReleaseEvent(QMouseEvent *event); + virtual bool keyPressEvent(QKeyEvent *event); + virtual bool keyReleaseEvent(QKeyEvent *keyEvent); + virtual bool mouseDoubleClickEvent(QMouseEvent *event); + virtual bool wheelEvent(QWheelEvent *event); + + AbstractTool *currentTool() const { return m_currentTool; } + void setCurrentTool(AbstractTool *tool) { m_currentTool = tool; } + private slots: void handleMessage(const QByteArray &message); @@ -142,6 +161,7 @@ private: void createToolBox(); ToolBox *m_toolBox; + AbstractTool *m_currentTool; bool m_showAppOnTop; bool m_designModeBehavior; diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.cpp index 4353e97..dce147c 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.cpp @@ -51,7 +51,7 @@ namespace QmlJSDebugger { AbstractLiveEditTool::AbstractLiveEditTool(QDeclarativeViewInspector *editorView) - : QObject(editorView), m_inspector(editorView) + : AbstractTool(editorView) { } @@ -62,12 +62,12 @@ AbstractLiveEditTool::~AbstractLiveEditTool() QDeclarativeViewInspector *AbstractLiveEditTool::inspector() const { - return m_inspector; + return static_cast(AbstractTool::inspector()); } QDeclarativeView *AbstractLiveEditTool::view() const { - return m_inspector->declarativeView(); + return inspector()->declarativeView(); } QGraphicsScene* AbstractLiveEditTool::scene() const @@ -175,7 +175,7 @@ QString AbstractLiveEditTool::titleForItem(QGraphicsItem *item) QDeclarativeItem *declarativeItem = qobject_cast(gfxObject); if (declarativeItem) { - objectStringId = m_inspector->idStringForObject(declarativeItem); + objectStringId = inspector()->idStringForObject(declarativeItem); } if (!objectStringId.isEmpty()) { diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.h b/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.h index accec79..04b5f4e 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.h +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/abstractliveedittool.h @@ -43,7 +43,7 @@ #define ABSTRACTLIVEEDITTOOL_H #include -#include +#include "../abstracttool.h" QT_BEGIN_NAMESPACE class QMouseEvent; @@ -60,7 +60,7 @@ namespace QmlJSDebugger { class QDeclarativeViewInspector; -class AbstractLiveEditTool : public QObject +class AbstractLiveEditTool : public AbstractTool { Q_OBJECT public: @@ -68,16 +68,8 @@ public: 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; + void leaveEvent(QEvent *) {} - 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 &itemList) = 0; virtual void clear() = 0; @@ -104,7 +96,6 @@ protected: QGraphicsScene *scene() const; private: - QDeclarativeViewInspector *m_inspector; QList m_itemList; }; diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp index 462fd19..67a581d 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp @@ -49,13 +49,9 @@ #include "editor/boundingrecthighlighter.h" #include -#include -#include -#include #include #include #include -#include namespace QmlJSDebugger { @@ -79,7 +75,7 @@ QDeclarativeViewInspector::QDeclarativeViewInspector(QDeclarativeView *view, data->zoomTool = new ZoomTool(this); data->colorPickerTool = new ColorPickerTool(this); data->boundingRectHighlighter = new BoundingRectHighlighter(this); - data->currentTool = data->selectionTool; + setCurrentTool(data->selectionTool); // to capture ChildRemoved event when viewport changes data->view->installEventFilter(this); @@ -142,6 +138,11 @@ void QDeclarativeViewInspector::changeTool(InspectorProtocol::Tool tool) } } +AbstractLiveEditTool *QDeclarativeViewInspector::currentTool() const +{ + return static_cast(AbstractViewInspector::currentTool()); +} + QDeclarativeEngine *QDeclarativeViewInspector::declarativeEngine() const { return data->view->engine(); @@ -181,143 +182,39 @@ bool QDeclarativeViewInspector::eventFilter(QObject *obj, QEvent *event) return QObject::eventFilter(obj, event); } - // Event from viewport - switch (event->type()) { - case QEvent::Leave: { - if (leaveEvent(event)) - return true; - break; - } - case QEvent::MouseButtonPress: { - if (mousePressEvent(static_cast(event))) - return true; - break; - } - case QEvent::MouseMove: { - if (mouseMoveEvent(static_cast(event))) - return true; - break; - } - case QEvent::MouseButtonRelease: { - if (mouseReleaseEvent(static_cast(event))) - return true; - break; - } - case QEvent::KeyPress: { - if (keyPressEvent(static_cast(event))) - return true; - break; - } - case QEvent::KeyRelease: { - if (keyReleaseEvent(static_cast(event))) - return true; - break; - } - case QEvent::MouseButtonDblClick: { - if (mouseDoubleClickEvent(static_cast(event))) - return true; - break; - } - case QEvent::Wheel: { - if (wheelEvent(static_cast(event))) - return true; - break; - } - default: { - break; - } - } //switch - - // standard event processing - return QObject::eventFilter(obj, event); + return AbstractViewInspector::eventFilter(obj, event); } -bool QDeclarativeViewInspector::leaveEvent(QEvent * /*event*/) +bool QDeclarativeViewInspector::leaveEvent(QEvent *event) { - if (!designModeBehavior()) - return false; data->clearHighlight(); - return true; + return AbstractViewInspector::leaveEvent(event); } bool QDeclarativeViewInspector::mousePressEvent(QMouseEvent *event) { - if (!designModeBehavior()) - return false; data->cursorPos = event->pos(); - data->currentTool->mousePressEvent(event); - return true; + return AbstractViewInspector::mousePressEvent(event); } bool QDeclarativeViewInspector::mouseMoveEvent(QMouseEvent *event) { - if (!designModeBehavior()) { - data->clearEditorItems(); - return false; - } data->cursorPos = event->pos(); QList selItems = data->selectableItems(event->pos()); if (!selItems.isEmpty()) { - declarativeView()->setToolTip(data->currentTool->titleForItem(selItems.first())); + declarativeView()->setToolTip(currentTool()->titleForItem(selItems.first())); } else { declarativeView()->setToolTip(QString()); } - if (event->buttons()) { - data->currentTool->mouseMoveEvent(event); - } else { - data->currentTool->hoverMoveEvent(event); - } - return true; + + return AbstractViewInspector::mouseMoveEvent(event); } bool QDeclarativeViewInspector::mouseReleaseEvent(QMouseEvent *event) { - if (!designModeBehavior()) - return false; - data->cursorPos = event->pos(); - data->currentTool->mouseReleaseEvent(event); - return true; -} - -bool QDeclarativeViewInspector::keyPressEvent(QKeyEvent *event) -{ - if (!designModeBehavior()) - return false; - - data->currentTool->keyPressEvent(event); - return true; -} - -bool QDeclarativeViewInspector::keyReleaseEvent(QKeyEvent *event) -{ - if (!designModeBehavior()) - return false; - - switch (event->key()) { - case Qt::Key_V: - changeTool(InspectorProtocol::SelectTool); - break; -// disabled because multiselection does not do anything useful without design mode -// case Qt::Key_M: -// changeTool(InspectorProtocol::SelectMarqueeTool); -// break; - case Qt::Key_I: - changeTool(InspectorProtocol::ColorPickerTool); - break; - case Qt::Key_Z: - changeTool(InspectorProtocol::ZoomTool); - break; - case Qt::Key_Space: - setAnimationPaused(!animationPaused()); - break; - default: - break; - } - - data->currentTool->keyReleaseEvent(event); - return true; + return AbstractViewInspector::mouseReleaseEvent(event); } void QDeclarativeViewInspector::reparentQmlObject(QObject *object, QObject *newParent) @@ -340,22 +237,6 @@ void QDeclarativeViewInspectorPrivate::_q_removeFromSelection(QObject *obj) setSelectedItems(items); } -bool QDeclarativeViewInspector::mouseDoubleClickEvent(QMouseEvent * /*event*/) -{ - if (!designModeBehavior()) - return false; - - return true; -} - -bool QDeclarativeViewInspector::wheelEvent(QWheelEvent *event) -{ - if (!designModeBehavior()) - return false; - data->currentTool->wheelEvent(event); - return true; -} - void QDeclarativeViewInspectorPrivate::setSelectedItemsForTools(const QList &items) { foreach (const QWeakPointer &obj, currentSelection) { @@ -378,7 +259,7 @@ void QDeclarativeViewInspectorPrivate::setSelectedItemsForTools(const QListupdateSelectedItems(); + q->currentTool()->updateSelectedItems(); } void QDeclarativeViewInspectorPrivate::setSelectedItems(const QList &items) @@ -468,7 +349,6 @@ QList QDeclarativeViewInspectorPrivate::selectableItems( void QDeclarativeViewInspectorPrivate::changeToSingleSelectTool() { - currentToolMode = Constants::SelectionToolMode; selectionTool->setRubberbandSelectionMode(false); changeToSelectTool(); @@ -479,19 +359,18 @@ void QDeclarativeViewInspectorPrivate::changeToSingleSelectTool() void QDeclarativeViewInspectorPrivate::changeToSelectTool() { - if (currentTool == selectionTool) + if (q->currentTool() == selectionTool) return; - currentTool->clear(); - currentTool = selectionTool; - currentTool->clear(); - currentTool->updateSelectedItems(); + q->currentTool()->clear(); + q->setCurrentTool(selectionTool); + q->currentTool()->clear(); + q->currentTool()->updateSelectedItems(); } void QDeclarativeViewInspectorPrivate::changeToMarqueeSelectTool() { changeToSelectTool(); - currentToolMode = Constants::MarqueeSelectionToolMode; selectionTool->setRubberbandSelectionMode(true); emit q->marqueeSelectToolActivated(); @@ -500,10 +379,9 @@ void QDeclarativeViewInspectorPrivate::changeToMarqueeSelectTool() void QDeclarativeViewInspectorPrivate::changeToZoomTool() { - currentToolMode = Constants::ZoomMode; - currentTool->clear(); - currentTool = zoomTool; - currentTool->clear(); + q->currentTool()->clear(); + q->setCurrentTool(zoomTool); + q->currentTool()->clear(); emit q->zoomToolActivated(); q->sendCurrentTool(Constants::ZoomMode); @@ -511,13 +389,12 @@ void QDeclarativeViewInspectorPrivate::changeToZoomTool() void QDeclarativeViewInspectorPrivate::changeToColorPickerTool() { - if (currentTool == colorPickerTool) + if (q->currentTool() == colorPickerTool) return; - currentToolMode = Constants::ColorPickerMode; - currentTool->clear(); - currentTool = colorPickerTool; - currentTool->clear(); + q->currentTool()->clear(); + q->setCurrentTool(colorPickerTool); + q->currentTool()->clear(); emit q->colorPickerActivated(); q->sendCurrentTool(Constants::ColorPickerMode); diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h index c08ef54..3cd53ff 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h @@ -50,12 +50,9 @@ #include #include -QT_FORWARD_DECLARE_CLASS(QDeclarativeItem) -QT_FORWARD_DECLARE_CLASS(QMouseEvent) -QT_FORWARD_DECLARE_CLASS(QToolBar) - namespace QmlJSDebugger { +class AbstractLiveEditTool; class QDeclarativeViewInspectorPrivate; class QDeclarativeViewInspector : public AbstractViewInspector @@ -88,12 +85,8 @@ protected: 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); + AbstractLiveEditTool *currentTool() const; private: Q_DISABLE_COPY(QDeclarativeViewInspector) diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h index cd8d749..a6e6a3c 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h @@ -73,9 +73,6 @@ public: QPointF cursorPos; QList > currentSelection; - Constants::DesignTool currentToolMode; - AbstractLiveEditTool *currentTool; - LiveSelectionTool *selectionTool; ZoomTool *zoomTool; ColorPickerTool *colorPickerTool; diff --git a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro index 6c56e62..0116441 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro +++ b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro @@ -22,7 +22,8 @@ SOURCES += \ editor/zoomtool.cpp \ editor/colorpickertool.cpp \ editor/qmltoolbar.cpp \ - editor/toolbarcolorbox.cpp + editor/toolbarcolorbox.cpp \ + abstracttool.cpp HEADERS += \ abstractviewinspector.h \ @@ -43,7 +44,8 @@ HEADERS += \ editor/zoomtool.h \ editor/colorpickertool.h \ editor/qmltoolbar.h \ - editor/toolbarcolorbox.h + editor/toolbarcolorbox.h \ + abstracttool.h RESOURCES += editor/editor.qrc -- cgit v0.12 From c70aef5c0fa2bfcf63457d679ed956f5077fefff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Thu, 9 Jun 2011 17:17:24 +0200 Subject: QmlInspector: Some cleanup in the Color Picker tool Also, the tool now picks a color on press rather than on release. (cherry picked from commit e045046c694ea98c5f3b651c99e1cb9eed2e045c in Qt 5 / QtDeclarative, to make synchronizing future changes easier) Change-Id: I068801ff969c9eadd538dd93b92916677b2c97ca Reviewed-by: Kai Koehne --- .../qmldbg_inspector/editor/colorpickertool.cpp | 37 ++-------------------- .../qmldbg_inspector/editor/colorpickertool.h | 17 +++++----- 2 files changed, 10 insertions(+), 44 deletions(-) diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.cpp index 9cef6b5..72e1380 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.cpp @@ -61,56 +61,23 @@ ColorPickerTool::ColorPickerTool(QDeclarativeViewInspector *view) : ColorPickerTool::~ColorPickerTool() { - } -void ColorPickerTool::mousePressEvent(QMouseEvent * /*event*/) -{ -} - -void ColorPickerTool::mouseMoveEvent(QMouseEvent *event) +void ColorPickerTool::mousePressEvent(QMouseEvent *event) { pickColor(event->pos()); } -void ColorPickerTool::mouseReleaseEvent(QMouseEvent *event) +void ColorPickerTool::mouseMoveEvent(QMouseEvent *event) { pickColor(event->pos()); } -void ColorPickerTool::mouseDoubleClickEvent(QMouseEvent * /*event*/) -{ -} - - -void ColorPickerTool::hoverMoveEvent(QMouseEvent * /*event*/) -{ -} - -void ColorPickerTool::keyPressEvent(QKeyEvent * /*event*/) -{ -} - -void ColorPickerTool::keyReleaseEvent(QKeyEvent * /*keyEvent*/) -{ -} -void ColorPickerTool::wheelEvent(QWheelEvent * /*event*/) -{ -} - -void ColorPickerTool::itemsAboutToRemoved(const QList &/*itemList*/) -{ -} - void ColorPickerTool::clear() { view()->setCursor(Qt::CrossCursor); } -void ColorPickerTool::selectedItemsChanged(const QList &/*itemList*/) -{ -} - void ColorPickerTool::pickColor(const QPoint &pos) { QRgb fillColor = view()->backgroundBrush().color().rgb(); diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.h b/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.h index 8c8152b..a28ffea 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.h +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/colorpickertool.h @@ -60,17 +60,17 @@ public: void mousePressEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *) {} + void mouseDoubleClickEvent(QMouseEvent *) {} - void hoverMoveEvent(QMouseEvent *event); + void hoverMoveEvent(QMouseEvent *) {} - void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *keyEvent); + void keyPressEvent(QKeyEvent *) {} + void keyReleaseEvent(QKeyEvent *) {} - void wheelEvent(QWheelEvent *event); + void wheelEvent(QWheelEvent *) {} - void itemsAboutToRemoved(const QList &itemList); + void itemsAboutToRemoved(const QList &) {} void clear(); @@ -78,8 +78,7 @@ signals: void selectedColorChanged(const QColor &color); protected: - - void selectedItemsChanged(const QList &itemList); + void selectedItemsChanged(const QList &) {} private: void pickColor(const QPoint &pos); -- cgit v0.12 From cf56b0be5ee15663c8b3e6b87dc4161bbbc911b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Fri, 10 Jun 2011 17:52:25 +0200 Subject: QmlInspector: Some code cleanups * Inlined empty method implementations * Removed unused QDeclarativeViewInspectorPrivate::cursosPos * Small simplification in setting shortcuts * Prefer const & for QList parameter (cherry picked from commit df1835f06c99d95a6f35ab84abc5fa7950cb5fe7 in Qt 5 / QtDeclarative, to make synchronizing future changes easier) Change-Id: Ib543c8433380e82f2fdf096d0962682595d7e2bf Reviewed-by: Kai Koehne --- .../qmldbg_inspector/editor/liveselectiontool.cpp | 25 +++++----------------- .../qmldbg_inspector/editor/liveselectiontool.h | 8 +++---- .../qmldbg_inspector/editor/zoomtool.cpp | 8 ------- .../qmltooling/qmldbg_inspector/editor/zoomtool.h | 4 ++-- .../qmldbg_inspector/qdeclarativeviewinspector.cpp | 14 ------------ .../qmldbg_inspector/qdeclarativeviewinspector.h | 2 -- .../qmldbg_inspector/qdeclarativeviewinspector_p.h | 1 - 7 files changed, 11 insertions(+), 51 deletions(-) diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp index 91dd43b..6085d81 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp @@ -132,7 +132,7 @@ void LiveSelectionTool::mousePressEvent(QMouseEvent *event) } } -void LiveSelectionTool::createContextMenu(QList itemList, QPoint globalPos) +void LiveSelectionTool::createContextMenu(const QList &itemList, QPoint globalPos) { QMenu contextMenu; connect(&contextMenu, SIGNAL(hovered(QAction*)), @@ -143,7 +143,6 @@ void LiveSelectionTool::createContextMenu(QList itemList, QPoint contextMenu.addAction(tr("Items")); contextMenu.addSeparator(); int shortcutKey = Qt::Key_1; - bool addKeySequence = true; int i = 0; foreach (QGraphicsItem * const item, itemList) { @@ -158,12 +157,11 @@ void LiveSelectionTool::createContextMenu(QList itemList, QPoint } elementAction->setData(i); - if (addKeySequence) - elementAction->setShortcut(QKeySequence(shortcutKey)); - shortcutKey++; - if (shortcutKey > Qt::Key_9) - addKeySequence = false; + if (shortcutKey <= Qt::Key_9) { + elementAction->setShortcut(QKeySequence(shortcutKey)); + shortcutKey++; + } ++i; } @@ -305,10 +303,6 @@ void LiveSelectionTool::mouseReleaseEvent(QMouseEvent *event) } } -void LiveSelectionTool::mouseDoubleClickEvent(QMouseEvent * /*event*/) -{ -} - void LiveSelectionTool::keyPressEvent(QKeyEvent *event) { switch (event->key()) { @@ -323,11 +317,6 @@ void LiveSelectionTool::keyPressEvent(QKeyEvent *event) } } -void LiveSelectionTool::keyReleaseEvent(QKeyEvent * /*keyEvent*/) -{ - -} - void LiveSelectionTool::wheelEvent(QWheelEvent *event) { if (event->orientation() == Qt::Horizontal || m_rubberbandSelectionMode) @@ -372,10 +361,6 @@ void LiveSelectionTool::setSelectOnlyContentItems(bool selectOnlyContentItems) m_selectOnlyContentItems = selectOnlyContentItems; } -void LiveSelectionTool::itemsAboutToRemoved(const QList &/*itemList*/) -{ -} - void LiveSelectionTool::clear() { view()->setCursor(Qt::ArrowCursor); diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.h b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.h index a3dcd0a..2c281cd 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.h +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.h @@ -68,13 +68,13 @@ public: void mousePressEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); + void mouseDoubleClickEvent(QMouseEvent *) {} void hoverMoveEvent(QMouseEvent *event); void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *keyEvent); + void keyReleaseEvent(QKeyEvent *) {} void wheelEvent(QWheelEvent *event); - void itemsAboutToRemoved(const QList &itemList); + void itemsAboutToRemoved(const QList &) {} // QVariant itemChange(const QList &itemList, // QGraphicsItem::GraphicsItemChange change, // const QVariant &value ); @@ -97,7 +97,7 @@ private slots: void repaintBoundingRects(); private: - void createContextMenu(QList itemList, QPoint globalPos); + void createContextMenu(const QList &itemList, QPoint globalPos); LiveSingleSelectionManipulator::SelectionType getSelectionType(Qt::KeyboardModifiers modifiers); bool alreadySelected(const QList &itemList) const; diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp index 3a4b6bf..c8ade82 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.cpp @@ -242,19 +242,11 @@ void ZoomTool::keyReleaseEvent(QKeyEvent *event) } -void ZoomTool::itemsAboutToRemoved(const QList &/*itemList*/) -{ -} - void ZoomTool::clear() { view()->setCursor(Qt::ArrowCursor); } -void ZoomTool::selectedItemsChanged(const QList &/*itemList*/) -{ -} - void ZoomTool::scaleView(const QPointF ¢erPos) { diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.h b/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.h index 94735cf..de93559 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.h +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/zoomtool.h @@ -73,12 +73,12 @@ public: void keyPressEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *keyEvent); - void itemsAboutToRemoved(const QList &itemList); + void itemsAboutToRemoved(const QList &) {} void clear(); protected: - void selectedItemsChanged(const QList &itemList); + void selectedItemsChanged(const QList &) {} private slots: void zoomTo100(); diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp index 67a581d..3351df9 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp @@ -191,16 +191,8 @@ bool QDeclarativeViewInspector::leaveEvent(QEvent *event) return AbstractViewInspector::leaveEvent(event); } -bool QDeclarativeViewInspector::mousePressEvent(QMouseEvent *event) -{ - data->cursorPos = event->pos(); - return AbstractViewInspector::mousePressEvent(event); -} - bool QDeclarativeViewInspector::mouseMoveEvent(QMouseEvent *event) { - data->cursorPos = event->pos(); - QList selItems = data->selectableItems(event->pos()); if (!selItems.isEmpty()) { declarativeView()->setToolTip(currentTool()->titleForItem(selItems.first())); @@ -211,12 +203,6 @@ bool QDeclarativeViewInspector::mouseMoveEvent(QMouseEvent *event) return AbstractViewInspector::mouseMoveEvent(event); } -bool QDeclarativeViewInspector::mouseReleaseEvent(QMouseEvent *event) -{ - data->cursorPos = event->pos(); - return AbstractViewInspector::mouseReleaseEvent(event); -} - void QDeclarativeViewInspector::reparentQmlObject(QObject *object, QObject *newParent) { if (!newParent) diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h index 3cd53ff..c77cd2c 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h @@ -82,9 +82,7 @@ protected: bool eventFilter(QObject *obj, QEvent *event); bool leaveEvent(QEvent *); - bool mousePressEvent(QMouseEvent *event); bool mouseMoveEvent(QMouseEvent *event); - bool mouseReleaseEvent(QMouseEvent *event); AbstractLiveEditTool *currentTool() const; diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h index a6e6a3c..bfa857c 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h @@ -70,7 +70,6 @@ public: QDeclarativeViewInspector *q; QWeakPointer viewport; - QPointF cursorPos; QList > currentSelection; LiveSelectionTool *selectionTool; -- cgit v0.12 From a0bd8d2dc68fdf993821b5eb881769448b34dffd Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Mon, 27 Jun 2011 11:01:20 +0200 Subject: qmldump: Fix export comparison. Compare the full uri/name, not just the uri. Also QDeclarativeType::module was not available in 4.7.3. Mirrors http://codereview.qt.nokia.com/759 Reviewed-by: kkoehne --- tools/qmlplugindump/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index b414c3f..454f0f8 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -177,7 +177,7 @@ QSet collectReachableMetaObjects(const QString &importCode, foreach (const QDeclarativeType *baseExport, baseExports) { bool match = false; foreach (const QDeclarativeType *extensionExport, extensionExports) { - if (baseExport->module() == extensionExport->module() + if (baseExport->qmlTypeName() == extensionExport->qmlTypeName() && baseExport->majorVersion() == extensionExport->majorVersion() && baseExport->minorVersion() == extensionExport->minorVersion()) { match = true; -- cgit v0.12 From a2d97672bfaace677a4308db93f5802ba53af46e Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 28 Jun 2011 15:35:58 +1000 Subject: Velocities reported by Flickable in onFlickStarted can be 0 Ensure the smoothed velocity is set at the start of the flick. Ensure that the smoothed velocity animation isn't restarted unless there is new valid data. Change-Id: I00f8bbf1fe91faeea752b093c4658ad0f53ad06d Task-number: QTBUG-19676 Reviewed-by: Bea Lam --- .../graphicsitems/qdeclarativeflickable.cpp | 30 +++++++--- .../tst_qdeclarativeflickable.cpp | 69 ++++++++++++++++++++++ 2 files changed, 90 insertions(+), 9 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index ce7566b..2fc2480 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -910,18 +910,24 @@ void QDeclarativeFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEv qreal velocity = vData.velocity; if (vData.atBeginning || vData.atEnd) velocity /= 2; - if (qAbs(velocity) > MinimumFlickVelocity && qAbs(event->pos().y() - pressPos.y()) > FlickThreshold) + if (q->yflick() && qAbs(velocity) > MinimumFlickVelocity && qAbs(event->pos().y() - pressPos.y()) > FlickThreshold) { + velocityTimeline.reset(vData.smoothVelocity); + vData.smoothVelocity.setValue(-velocity); flickY(velocity); - else + } else { fixupY(); + } velocity = hData.velocity; if (hData.atBeginning || hData.atEnd) velocity /= 2; - if (qAbs(velocity) > MinimumFlickVelocity && qAbs(event->pos().x() - pressPos.x()) > FlickThreshold) + if (q->xflick() && qAbs(velocity) > MinimumFlickVelocity && qAbs(event->pos().x() - pressPos.x()) > FlickThreshold) { + velocityTimeline.reset(hData.smoothVelocity); + hData.smoothVelocity.setValue(-velocity); flickX(velocity); - else + } else { fixupX(); + } if (!timeline.isActive()) q->movementEnding(); @@ -1121,19 +1127,25 @@ void QDeclarativeFlickable::viewportMoved() qreal prevX = d->lastFlickablePosition.x(); qreal prevY = d->lastFlickablePosition.y(); - d->velocityTimeline.clear(); if (d->pressed || d->calcVelocity) { int elapsed = QDeclarativeItemPrivate::restart(d->velocityTime); if (elapsed > 0) { qreal horizontalVelocity = (prevX - d->hData.move.value()) * 1000 / elapsed; + if (qAbs(horizontalVelocity) > 0) { + d->velocityTimeline.reset(d->hData.smoothVelocity); + d->velocityTimeline.move(d->hData.smoothVelocity, horizontalVelocity, d->reportedVelocitySmoothing); + d->velocityTimeline.move(d->hData.smoothVelocity, 0, d->reportedVelocitySmoothing); + } qreal verticalVelocity = (prevY - d->vData.move.value()) * 1000 / elapsed; - d->velocityTimeline.move(d->hData.smoothVelocity, horizontalVelocity, d->reportedVelocitySmoothing); - d->velocityTimeline.move(d->hData.smoothVelocity, 0, d->reportedVelocitySmoothing); - d->velocityTimeline.move(d->vData.smoothVelocity, verticalVelocity, d->reportedVelocitySmoothing); - d->velocityTimeline.move(d->vData.smoothVelocity, 0, d->reportedVelocitySmoothing); + if (qAbs(verticalVelocity) > 0) { + d->velocityTimeline.reset(d->vData.smoothVelocity); + d->velocityTimeline.move(d->vData.smoothVelocity, verticalVelocity, d->reportedVelocitySmoothing); + d->velocityTimeline.move(d->vData.smoothVelocity, 0, d->reportedVelocitySmoothing); + } } } else { if (d->timeline.time() > d->vTime) { + d->velocityTimeline.clear(); qreal horizontalVelocity = (prevX - d->hData.move.value()) * 1000 / (d->timeline.time() - d->vTime); qreal verticalVelocity = (prevY - d->vData.move.value()) * 1000 / (d->timeline.time() - d->vTime); d->hData.smoothVelocity.setValue(horizontalVelocity); diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp index b077fdc..31a6b10 100644 --- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp +++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp @@ -78,6 +78,7 @@ private slots: void testQtQuick11Attributes(); void testQtQuick11Attributes_data(); void wheel(); + void flickVelocity(); private: QDeclarativeEngine engine; @@ -480,6 +481,74 @@ void tst_qdeclarativeflickable::wheel() delete canvas; } +void tst_qdeclarativeflickable::flickVelocity() +{ + QDeclarativeView *canvas = new QDeclarativeView; + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml")); + canvas->show(); + canvas->setFocus(); + QVERIFY(canvas->rootObject() != 0); + + QDeclarativeFlickable *flickable = qobject_cast(canvas->rootObject()); + QVERIFY(flickable != 0); + + QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(20, 90))); + { + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,80)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv); + } + QTest::qWait(10); + { + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,70)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv); + } + QTest::qWait(10); + { + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,60)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv); + } + QTest::qWait(10); + { + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,50)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv); + } + QTest::qWait(10); + + QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(20, 50))); + + QVERIFY(flickable->verticalVelocity() > 0.0); + QTRY_VERIFY(flickable->verticalVelocity() == 0.0); + + QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(20, 10))); + { + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,20)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv); + } + QTest::qWait(10); + { + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,30)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv); + } + QTest::qWait(10); + { + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,40)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv); + } + QTest::qWait(10); + { + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,50)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv); + } + QTest::qWait(10); + + QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(20, 50))); + + QVERIFY(flickable->verticalVelocity() < 0.0); + QTRY_VERIFY(flickable->verticalVelocity() == 0.0); + + delete canvas; +} + template T *tst_qdeclarativeflickable::findItem(QGraphicsObject *parent, const QString &objectName) -- cgit v0.12 From 6fb7cdf8741ca924413dd7cbc09fad91ddc04823 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 29 Jun 2011 16:23:28 +1000 Subject: Reduce timing dependancy in flickable test Interval of 10ms between synthesized flick move events is too prone to timing difference on CI platforms. Change-Id: Id5da794a7294868c8f5e544fa71edeec967e31ca Task-number: QTBUG-19676 Reviewed-by: Bea Lam --- .../qdeclarativeflickable/data/flickable03.qml | 2 +- .../tst_qdeclarativeflickable.cpp | 69 +++++++--------------- 2 files changed, 22 insertions(+), 49 deletions(-) diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml index a3e92fe..8359ad1 100644 --- a/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml +++ b/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml @@ -1,7 +1,7 @@ import QtQuick 1.0 Flickable { - width: 100; height: 100 + width: 100; height: 200 contentWidth: column.width; contentHeight: column.height Column { diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp index 31a6b10..05925cd 100644 --- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp +++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp @@ -83,6 +83,7 @@ private slots: private: QDeclarativeEngine engine; + void flick(QGraphicsView *canvas, const QPoint &from, const QPoint &to, int duration); template T *findItem(QGraphicsObject *parent, const QString &objectName); }; @@ -492,63 +493,35 @@ void tst_qdeclarativeflickable::flickVelocity() QDeclarativeFlickable *flickable = qobject_cast(canvas->rootObject()); QVERIFY(flickable != 0); - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(20, 90))); - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,80)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - QTest::qWait(10); - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,70)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - QTest::qWait(10); - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,60)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - QTest::qWait(10); - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,50)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - QTest::qWait(10); - - QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(20, 50))); - + // flick up + flick(canvas, QPoint(20,190), QPoint(20, 50), 100); QVERIFY(flickable->verticalVelocity() > 0.0); QTRY_VERIFY(flickable->verticalVelocity() == 0.0); - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(20, 10))); - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,20)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - QTest::qWait(10); - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,30)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - QTest::qWait(10); - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,40)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - QTest::qWait(10); - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,50)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - QTest::qWait(10); - - QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(20, 50))); - + // flick down + flick(canvas, QPoint(20,10), QPoint(20, 100), 100); QVERIFY(flickable->verticalVelocity() < 0.0); QTRY_VERIFY(flickable->verticalVelocity() == 0.0); delete canvas; } +void tst_qdeclarativeflickable::flick(QGraphicsView *canvas, const QPoint &from, const QPoint &to, int duration) +{ + const int pointCount = 5; + QPoint diff = to - from; + + // send press, five equally spaced moves, and release. + QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(from)); + + for (int i = 0; i < pointCount; ++i) { + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(from + (i+1)*diff/pointCount), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv); + QTest::qWait(duration/pointCount); + } + + QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(to)); +} template T *tst_qdeclarativeflickable::findItem(QGraphicsObject *parent, const QString &objectName) -- cgit v0.12 From 20f8357c8ee570f57091e20b9c0a9a1455dc1e8d Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 29 Jun 2011 16:33:04 +1000 Subject: Flickable is too sensitive. Drag, stop, release should result in a pan, which does not trigger a flick. The current flick threshold velocity is too low, leading to flicks when a pan gesture is more desireable. Change-Id: I3aa3bf28cc0ccbb043f3390ff4e044ea587ba3ff Task-number: QTBUG-19933 Reviewed-by: Bea Lam --- src/declarative/graphicsitems/qdeclarativeflickable_p_p.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h index 46b2104..1c749cd 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h @@ -67,7 +67,11 @@ QT_BEGIN_NAMESPACE // Really slow flicks can be annoying. -const qreal MinimumFlickVelocity = 75.0; +#ifndef QML_FLICK_MINVELOCITY +#define QML_FLICK_MINVELOCITY 175 +#endif + +const qreal MinimumFlickVelocity = QML_FLICK_MINVELOCITY; class QDeclarativeFlickableVisibleArea; class QDeclarativeFlickablePrivate : public QDeclarativeItemPrivate, public QDeclarativeItemChangeListener -- cgit v0.12 From a39e975465a5dc0548891ccd93c4ff04165b60cd Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Wed, 29 Jun 2011 10:06:39 +0200 Subject: qmlplugindump: Improve error message for misbehaving plugin components. Mirrors 6244008dcb43dde15dea3becbbec07d941b4759c in Qt Creator/2.3. Reviewed-by: Kai Koehne --- tools/qmlplugindump/main.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index 454f0f8..af291ee 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -68,6 +68,9 @@ QString pluginImportPath; bool verbose = false; +QString currentProperty; +QString inObjectInstantiation; + void collectReachableMetaObjects(const QMetaObject *meta, QSet *metas) { if (! meta || metas->contains(meta)) @@ -81,8 +84,6 @@ void collectReachableMetaObjects(const QMetaObject *meta, QSetsuperClass(), metas); } -QString currentProperty; - void collectReachableMetaObjects(QObject *object, QSet *metas) { if (! object) @@ -214,7 +215,10 @@ QSet collectReachableMetaObjects(const QString &importCode, QDeclarativeComponent c(engine); c.setData(code, QUrl::fromLocalFile(pluginImportPath + "/typeinstance.qml")); + inObjectInstantiation = tyName; QObject *object = c.create(); + inObjectInstantiation.clear(); + if (object) collectReachableMetaObjects(object, &metas); else @@ -433,6 +437,8 @@ void sigSegvHandler(int) { fprintf(stderr, "Error: SEGV\n"); if (!currentProperty.isEmpty()) fprintf(stderr, "While processing the property '%s', which probably has uninitialized data.\n", currentProperty.toLatin1().constData()); + if (!inObjectInstantiation.isEmpty()) + fprintf(stderr, "While instantiating the object '%s'.\n", inObjectInstantiation.toLatin1().constData()); exit(EXIT_SEGV); } #endif -- cgit v0.12 From d7ab0007d4b051f3cf12f01157b8b78d2fddf7c8 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Wed, 29 Jun 2011 14:00:34 +0200 Subject: qmlplugindump: Fix dumping with -path on Mac. If the current working directory was a direct parent of the qmldir path the exported modules had the path as the module URI on macs. Also changes the QtQuick export back to 1.0 to make it work with Qt 4.7.3. The version of that import statement does not actually matter as long as it's valid. Mirrors a change in Qt Creator: http://codereview.qt.nokia.com/896 Reviewed-by: Kai Koehne --- tools/qmlplugindump/main.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index af291ee..ae06d02 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -272,6 +272,9 @@ public: if (qmlTyName.startsWith(relocatableModuleUri + QLatin1Char('/'))) { qmlTyName.remove(0, relocatableModuleUri.size() + 1); } + if (qmlTyName.startsWith("./")) { + qmlTyName.remove(0, 2); + } exports += enquote(QString("%1 %2.%3").arg( qmlTyName, QString::number(qmlTy->majorVersion()), @@ -536,11 +539,16 @@ int main(int argc, char *argv[]) QDeclarativeView view; QDeclarativeEngine *engine = view.engine(); - if (!pluginImportPath.isEmpty()) + if (!pluginImportPath.isEmpty()) { + QDir cur = QDir::current(); + cur.cd(pluginImportPath); + pluginImportPath = cur.absolutePath(); + QDir::setCurrent(pluginImportPath); engine->addImportPath(pluginImportPath); + } // find all QMetaObjects reachable from the builtin module - QByteArray importCode("import QtQuick 1.1\n"); + QByteArray importCode("import QtQuick 1.0\n"); QSet defaultReachable = collectReachableMetaObjects(importCode, engine); // this will hold the meta objects we want to dump information of -- cgit v0.12 From 343069c7843321b33f06bfd42d476abae76dcece Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 30 Jun 2011 12:05:14 +1000 Subject: Try to fix Mac CI test failure Try slowing down the flick to give the slow CI machine a better chance of success. Change-Id: Id61473e73a38bb888b9bee47cffb913c936155b9 Task-number: QTBUG-19676 Reviewed-by: Bea Lam --- .../declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp index 05925cd..7cb7e6f 100644 --- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp +++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp @@ -494,12 +494,12 @@ void tst_qdeclarativeflickable::flickVelocity() QVERIFY(flickable != 0); // flick up - flick(canvas, QPoint(20,190), QPoint(20, 50), 100); + flick(canvas, QPoint(20,190), QPoint(20, 50), 200); QVERIFY(flickable->verticalVelocity() > 0.0); QTRY_VERIFY(flickable->verticalVelocity() == 0.0); // flick down - flick(canvas, QPoint(20,10), QPoint(20, 100), 100); + flick(canvas, QPoint(20,10), QPoint(20, 140), 200); QVERIFY(flickable->verticalVelocity() < 0.0); QTRY_VERIFY(flickable->verticalVelocity() == 0.0); -- cgit v0.12 From 927b22b06ee2e749395e73f457fe3c16ea087864 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 30 Jun 2011 17:09:34 +1000 Subject: Try again to fix flickable velocity on Mac. Change-Id: Id2693a69739886f9a171f3f6438a5404dff8e901 Task-number: QTBUG-19676 Reviewed-by: Bea Lam --- .../auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp index 7cb7e6f..d3763a7 100644 --- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp +++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp @@ -518,6 +518,7 @@ void tst_qdeclarativeflickable::flick(QGraphicsView *canvas, const QPoint &from, QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(from + (i+1)*diff/pointCount), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); QApplication::sendEvent(canvas->viewport(), &mv); QTest::qWait(duration/pointCount); + QCoreApplication::processEvents(); } QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(to)); -- cgit v0.12 From 8fbb802fa50d0a01c9c01d007a3e016c45fa863c Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 4 Jul 2011 09:52:15 +1000 Subject: Skip flick velocity test on Mac. Change-Id: Ib995961d7b1a939e5feb86d72a82408d1ceebe88 Task-number: QTBUG-19676 Reviewed-by: Bea Lam --- .../declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp index d3763a7..4d4c30b 100644 --- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp +++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp @@ -484,6 +484,10 @@ void tst_qdeclarativeflickable::wheel() void tst_qdeclarativeflickable::flickVelocity() { +#ifdef Q_WS_MAC + QSKIP("Producing flicks on Mac CI impossible due to timing problems", SkipAll); +#endif + QDeclarativeView *canvas = new QDeclarativeView; canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml")); canvas->show(); -- cgit v0.12 From e7bebcf0c59368340df524db4a53ae2595d057d7 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 4 Jul 2011 10:08:15 +1000 Subject: Flicking behaviour of ListView/GridView SnapOnItem is inconsistent Improve the response of the views when SnapOneItem/Row is enabled. In this case it is best to be much more reactive to the user input since even a small movement in a particular direction indicates a change to the next/previous item. Change-Id: I6a8eb689c3b12cdc67f24106032e36bba82d2846 Task-number: QTBUG-19874 Reviewed-by: Bea Lam --- .../graphicsitems/qdeclarativeflickable.cpp | 106 ++++++++-------- .../graphicsitems/qdeclarativeflickable_p_p.h | 9 +- .../graphicsitems/qdeclarativegridview.cpp | 97 ++++++++++----- .../graphicsitems/qdeclarativelistview.cpp | 133 ++++++++++++--------- .../tst_qdeclarativegridview.cpp | 8 +- 5 files changed, 200 insertions(+), 153 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 2fc2480..1e04559 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -168,9 +168,7 @@ QDeclarativeFlickablePrivate::QDeclarativeFlickablePrivate() : contentItem(new QDeclarativeItem) , hData(this, &QDeclarativeFlickablePrivate::setRoundedViewportX) , vData(this, &QDeclarativeFlickablePrivate::setRoundedViewportY) - , flickingHorizontally(false), flickingVertically(false) , hMoved(false), vMoved(false) - , movingHorizontally(false), movingVertically(false) , stealMouse(false), pressed(false), interactive(true), calcVelocity(false) , deceleration(QML_FLICK_DEFAULTDECELERATION) , maxVelocity(QML_FLICK_DEFAULTMAXVELOCITY), reportedVelocitySmoothing(100) @@ -294,18 +292,18 @@ void QDeclarativeFlickablePrivate::flick(AxisData &data, qreal minExtent, qreal else timeline.accel(data.move, v, deceleration, maxDistance); timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this)); - if (!flickingHorizontally && q->xflick()) { - flickingHorizontally = true; + if (!hData.flicking && q->xflick()) { + hData.flicking = true; emit q->flickingChanged(); emit q->flickingHorizontallyChanged(); - if (!flickingVertically) + if (!vData.flicking) emit q->flickStarted(); } - if (!flickingVertically && q->yflick()) { - flickingVertically = true; + if (!vData.flicking && q->yflick()) { + vData.flicking = true; emit q->flickingChanged(); emit q->flickingVerticallyChanged(); - if (!flickingHorizontally) + if (!hData.flicking) emit q->flickStarted(); } } else { @@ -614,11 +612,11 @@ void QDeclarativeFlickable::setInteractive(bool interactive) Q_D(QDeclarativeFlickable); if (interactive != d->interactive) { d->interactive = interactive; - if (!interactive && (d->flickingHorizontally || d->flickingVertically)) { + if (!interactive && (d->hData.flicking || d->vData.flicking)) { d->timeline.clear(); d->vTime = d->timeline.time(); - d->flickingHorizontally = false; - d->flickingVertically = false; + d->hData.flicking = false; + d->vData.flicking = false; emit flickingChanged(); emit flickingHorizontallyChanged(); emit flickingVerticallyChanged(); @@ -771,8 +769,8 @@ void QDeclarativeFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEven pressPos = event->pos(); hData.pressPos = hData.move.value(); vData.pressPos = vData.move.value(); - flickingHorizontally = false; - flickingVertically = false; + hData.flicking = false; + vData.flicking = false; QDeclarativeItemPrivate::start(pressTime); QDeclarativeItemPrivate::start(velocityTime); } @@ -897,17 +895,13 @@ void QDeclarativeFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEv return; // if we drag then pause before release we should not cause a flick. - if (QDeclarativeItemPrivate::elapsed(lastPosTime) < 100) { - vData.updateVelocity(); - hData.updateVelocity(); - } else { - hData.velocity = 0.0; - vData.velocity = 0.0; - } + qint64 elapsed = QDeclarativeItemPrivate::elapsed(lastPosTime); + vData.updateVelocity(); + hData.updateVelocity(); vTime = timeline.time(); - qreal velocity = vData.velocity; + qreal velocity = elapsed < 100 ? vData.velocity : 0; if (vData.atBeginning || vData.atEnd) velocity /= 2; if (q->yflick() && qAbs(velocity) > MinimumFlickVelocity && qAbs(event->pos().y() - pressPos.y()) > FlickThreshold) { @@ -918,7 +912,7 @@ void QDeclarativeFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEv fixupY(); } - velocity = hData.velocity; + velocity = elapsed < 100 ? hData.velocity : 0; if (hData.atBeginning || hData.atEnd) velocity /= 2; if (q->xflick() && qAbs(velocity) > MinimumFlickVelocity && qAbs(event->pos().x() - pressPos.x()) > FlickThreshold) { @@ -984,9 +978,9 @@ void QDeclarativeFlickable::wheelEvent(QGraphicsSceneWheelEvent *event) valid = true; } if (valid) { - d->flickingVertically = false; + d->vData.flicking = false; d->flickY(d->vData.velocity); - if (d->flickingVertically) { + if (d->vData.flicking) { d->vMoved = true; movementStarting(); } @@ -1002,9 +996,9 @@ void QDeclarativeFlickable::wheelEvent(QGraphicsSceneWheelEvent *event) valid = true; } if (valid) { - d->flickingHorizontally = false; + d->hData.flicking = false; d->flickX(d->hData.velocity); - if (d->flickingHorizontally) { + if (d->hData.flicking) { d->hMoved = true; movementStarting(); } @@ -1153,7 +1147,7 @@ void QDeclarativeFlickable::viewportMoved() } } - if (!d->vData.inOvershoot && !d->vData.fixingUp && d->flickingVertically + if (!d->vData.inOvershoot && !d->vData.fixingUp && d->vData.flicking && (d->vData.move.value() > minYExtent() || d->vData.move.value() < maxYExtent()) && qAbs(d->vData.smoothVelocity.value()) > 100) { // Increase deceleration if we've passed a bound @@ -1163,7 +1157,7 @@ void QDeclarativeFlickable::viewportMoved() d->timeline.accel(d->vData.move, -d->vData.smoothVelocity.value(), d->deceleration*QML_FLICK_OVERSHOOTFRICTION, maxDistance); d->timeline.callback(QDeclarativeTimeLineCallback(&d->vData.move, d->fixupY_callback, d)); } - if (!d->hData.inOvershoot && !d->hData.fixingUp && d->flickingHorizontally + if (!d->hData.inOvershoot && !d->hData.fixingUp && d->hData.flicking && (d->hData.move.value() > minXExtent() || d->hData.move.value() < maxXExtent()) && qAbs(d->hData.smoothVelocity.value()) > 100) { // Increase deceleration if we've passed a bound @@ -1195,7 +1189,7 @@ void QDeclarativeFlickable::geometryChanged(const QRectF &newGeometry, emit contentWidthChanged(); } // Make sure that we're entirely in view. - if (!d->pressed && !d->movingHorizontally && !d->movingVertically) { + if (!d->pressed && !d->hData.moving && !d->vData.moving) { d->fixupMode = QDeclarativeFlickablePrivate::Immediate; d->fixupX(); } @@ -1208,7 +1202,7 @@ void QDeclarativeFlickable::geometryChanged(const QRectF &newGeometry, emit contentHeightChanged(); } // Make sure that we're entirely in view. - if (!d->pressed && !d->movingHorizontally && !d->movingVertically) { + if (!d->pressed && !d->hData.moving && !d->vData.moving) { d->fixupMode = QDeclarativeFlickablePrivate::Immediate; d->fixupY(); } @@ -1363,7 +1357,7 @@ void QDeclarativeFlickable::setContentWidth(qreal w) else d->contentItem->setWidth(w); // Make sure that we're entirely in view. - if (!d->pressed && !d->movingHorizontally && !d->movingVertically) { + if (!d->pressed && !d->hData.moving && !d->vData.moving) { d->fixupMode = QDeclarativeFlickablePrivate::Immediate; d->fixupX(); } else if (!d->pressed && d->hData.fixingUp) { @@ -1391,7 +1385,7 @@ void QDeclarativeFlickable::setContentHeight(qreal h) else d->contentItem->setHeight(h); // Make sure that we're entirely in view. - if (!d->pressed && !d->movingHorizontally && !d->movingVertically) { + if (!d->pressed && !d->hData.moving && !d->vData.moving) { d->fixupMode = QDeclarativeFlickablePrivate::Immediate; d->fixupY(); } else if (!d->pressed && d->vData.fixingUp) { @@ -1647,7 +1641,7 @@ void QDeclarativeFlickable::setFlickDeceleration(qreal deceleration) bool QDeclarativeFlickable::isFlicking() const { Q_D(const QDeclarativeFlickable); - return d->flickingHorizontally || d->flickingVertically; + return d->hData.flicking || d->vData.flicking; } /*! @@ -1661,13 +1655,13 @@ bool QDeclarativeFlickable::isFlicking() const bool QDeclarativeFlickable::isFlickingHorizontally() const { Q_D(const QDeclarativeFlickable); - return d->flickingHorizontally; + return d->hData.flicking; } bool QDeclarativeFlickable::isFlickingVertically() const { Q_D(const QDeclarativeFlickable); - return d->flickingVertically; + return d->vData.flicking; } /*! @@ -1703,7 +1697,7 @@ void QDeclarativeFlickable::setPressDelay(int delay) bool QDeclarativeFlickable::isMoving() const { Q_D(const QDeclarativeFlickable); - return d->movingHorizontally || d->movingVertically; + return d->hData.moving || d->vData.moving; } /*! @@ -1718,30 +1712,30 @@ bool QDeclarativeFlickable::isMoving() const bool QDeclarativeFlickable::isMovingHorizontally() const { Q_D(const QDeclarativeFlickable); - return d->movingHorizontally; + return d->hData.moving; } bool QDeclarativeFlickable::isMovingVertically() const { Q_D(const QDeclarativeFlickable); - return d->movingVertically; + return d->vData.moving; } void QDeclarativeFlickable::movementStarting() { Q_D(QDeclarativeFlickable); - if (d->hMoved && !d->movingHorizontally) { - d->movingHorizontally = true; + if (d->hMoved && !d->hData.moving) { + d->hData.moving = true; emit movingChanged(); emit movingHorizontallyChanged(); - if (!d->movingVertically) + if (!d->vData.moving) emit movementStarted(); } - else if (d->vMoved && !d->movingVertically) { - d->movingVertically = true; + else if (d->vMoved && !d->vData.moving) { + d->vData.moving = true; emit movingChanged(); emit movingVerticallyChanged(); - if (!d->movingHorizontally) + if (!d->hData.moving) emit movementStarted(); } } @@ -1758,20 +1752,20 @@ void QDeclarativeFlickable::movementEnding() void QDeclarativeFlickable::movementXEnding() { Q_D(QDeclarativeFlickable); - if (d->flickingHorizontally) { - d->flickingHorizontally = false; + if (d->hData.flicking) { + d->hData.flicking = false; emit flickingChanged(); emit flickingHorizontallyChanged(); - if (!d->flickingVertically) + if (!d->vData.flicking) emit flickEnded(); } if (!d->pressed && !d->stealMouse) { - if (d->movingHorizontally) { - d->movingHorizontally = false; + if (d->hData.moving) { + d->hData.moving = false; d->hMoved = false; emit movingChanged(); emit movingHorizontallyChanged(); - if (!d->movingVertically) + if (!d->vData.moving) emit movementEnded(); } } @@ -1781,20 +1775,20 @@ void QDeclarativeFlickable::movementXEnding() void QDeclarativeFlickable::movementYEnding() { Q_D(QDeclarativeFlickable); - if (d->flickingVertically) { - d->flickingVertically = false; + if (d->vData.flicking) { + d->vData.flicking = false; emit flickingChanged(); emit flickingVerticallyChanged(); - if (!d->flickingHorizontally) + if (!d->hData.flicking) emit flickEnded(); } if (!d->pressed && !d->stealMouse) { - if (d->movingVertically) { - d->movingVertically = false; + if (d->vData.moving) { + d->vData.moving = false; d->vMoved = false; emit movingChanged(); emit movingVerticallyChanged(); - if (!d->movingHorizontally) + if (!d->hData.moving) emit movementEnded(); } } diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h index 1c749cd..d73a907 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h @@ -63,6 +63,7 @@ #include #include +#include "qplatformdefs.h" QT_BEGIN_NAMESPACE @@ -98,7 +99,7 @@ public: struct AxisData { AxisData(QDeclarativeFlickablePrivate *fp, void (QDeclarativeFlickablePrivate::*func)(qreal)) : move(fp, func), viewSize(-1), smoothVelocity(fp), atEnd(false), atBeginning(true) - , fixingUp(false), inOvershoot(false) + , fixingUp(false), inOvershoot(false), moving(false), flicking(false) {} void reset() { @@ -125,6 +126,8 @@ public: bool atBeginning : 1; bool fixingUp : 1; bool inOvershoot : 1; + bool moving : 1; + bool flicking : 1; }; void flickX(qreal velocity); @@ -156,12 +159,8 @@ public: AxisData vData; QDeclarativeTimeLine timeline; - bool flickingHorizontally : 1; - bool flickingVertically : 1; bool hMoved : 1; bool vMoved : 1; - bool movingHorizontally : 1; - bool movingVertically : 1; bool stealMouse : 1; bool pressed : 1; bool interactive : 1; diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 36f6e29..2642800 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -52,9 +52,13 @@ #include #include +#include "qplatformdefs.h" QT_BEGIN_NAMESPACE +#ifndef QML_FLICK_SNAPONETHRESHOLD +#define QML_FLICK_SNAPONETHRESHOLD 30 +#endif //---------------------------------------------------------------------------- @@ -345,9 +349,12 @@ public: Q_Q(const QDeclarativeGridView); qreal snapPos = 0; if (!visibleItems.isEmpty()) { + qreal highlightStart = isRightToLeftTopToBottom() && highlightRangeStartValid ? size()-highlightRangeEnd : highlightRangeStart; + pos += highlightStart; pos += rowSize()/2; snapPos = visibleItems.first()->rowPos() - visibleIndex / columns * rowSize(); snapPos = pos - fmodf(pos - snapPos, qreal(rowSize())); + snapPos -= highlightStart; qreal maxExtent; qreal minExtent; if (isRightToLeftTopToBottom()) { @@ -875,7 +882,7 @@ void QDeclarativeGridViewPrivate::updateHighlight() { if ((!currentItem && highlight) || (currentItem && !highlight)) createHighlight(); - if (currentItem && autoHighlight && highlight && !movingHorizontally && !movingVertically) { + if (currentItem && autoHighlight && highlight && !hData.moving && !vData.moving) { // auto-update highlight highlightXAnimator->to = currentItem->item->x(); highlightYAnimator->to = currentItem->item->y(); @@ -1062,6 +1069,18 @@ void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m if (snapMode != QDeclarativeGridView::NoSnap) { qreal tempPosition = isRightToLeftTopToBottom() ? -position()-size() : position(); + if (snapMode == QDeclarativeGridView::SnapOneRow && moveReason == Mouse) { + // if we've been dragged < rowSize()/2 then bias towards the next row + qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset); + qreal bias = 0; + if (data.velocity > 0 && dist > QML_FLICK_SNAPONETHRESHOLD && dist < rowSize()/2) + bias = rowSize()/2; + else if (data.velocity < 0 && dist < -QML_FLICK_SNAPONETHRESHOLD && dist > -rowSize()/2) + bias = -rowSize()/2; + if (isRightToLeftTopToBottom()) + bias = -bias; + tempPosition -= bias; + } FxGridItem *topItem = snapItemAt(tempPosition+highlightStart); FxGridItem *bottomItem = snapItemAt(tempPosition+highlightEnd); qreal pos; @@ -1083,25 +1102,13 @@ void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m } } else if (bottomItem) { if (isRightToLeftTopToBottom()) - pos = qMax(qMin(-bottomItem->rowPos() + highlightStart - size(), -maxExtent), -minExtent); + pos = qMax(qMin(-bottomItem->rowPos() + highlightEnd - size(), -maxExtent), -minExtent); else - pos = qMax(qMin(bottomItem->rowPos() - highlightStart, -maxExtent), -minExtent); + pos = qMax(qMin(bottomItem->rowPos() - highlightEnd, -maxExtent), -minExtent); } else { QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent); return; } - if (currentItem && haveHighlightRange && highlightRange == QDeclarativeGridView::StrictlyEnforceRange) { - updateHighlight(); - qreal currPos = currentItem->rowPos(); - if (isRightToLeftTopToBottom()) - pos = -pos-size(); // Transform Pos if required - if (pos < currPos + rowSize() - highlightEnd) - pos = currPos + rowSize() - highlightEnd; - if (pos > currPos - highlightStart) - pos = currPos - highlightStart; - if (isRightToLeftTopToBottom()) - pos = -pos-size(); // Untransform - } qreal dist = qAbs(data.move + pos); if (dist > 0) { timeline.reset(data.move); @@ -1158,9 +1165,14 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m if (velocity > 0) { if (data.move.value() < minExtent) { if (snapMode == QDeclarativeGridView::SnapOneRow) { - if (FxGridItem *item = firstVisibleItem()) { - maxDistance = qAbs(item->rowPos() + dataValue); - } + // if we've been dragged < averageSize/2 then bias towards the next item + qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset); + qreal bias = dist < rowSize()/2 ? rowSize()/2 : 0; + if (isRightToLeftTopToBottom()) + bias = -bias; + data.flickTarget = -snapPosAt(-dataValue - bias); + maxDistance = qAbs(data.flickTarget - data.move.value()); + velocity = maxVelocity; } else { maxDistance = qAbs(minExtent - data.move.value()); } @@ -1170,8 +1182,14 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m } else { if (data.move.value() > maxExtent) { if (snapMode == QDeclarativeGridView::SnapOneRow) { - qreal pos = snapPosAt(-dataValue) + (isRightToLeftTopToBottom() ? 0 : rowSize()); - maxDistance = qAbs(pos + dataValue); + // if we've been dragged < averageSize/2 then bias towards the next item + qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset); + qreal bias = -dist < rowSize()/2 ? rowSize()/2 : 0; + if (isRightToLeftTopToBottom()) + bias = -bias; + data.flickTarget = -snapPosAt(-dataValue + bias); + maxDistance = qAbs(data.flickTarget - data.move.value()); + velocity = -maxVelocity; } else { maxDistance = qAbs(maxExtent - data.move.value()); } @@ -1181,7 +1199,6 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m } bool overShoot = boundsBehavior == QDeclarativeFlickable::DragAndOvershootBounds; - qreal highlightStart = isRightToLeftTopToBottom() && highlightRangeStartValid ? size()-highlightRangeEnd : highlightRangeStart; if (maxDistance > 0 || overShoot) { // This mode requires the grid to stop exactly on a row boundary. @@ -1201,9 +1218,20 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m dist = qMin(dist, maxDistance); if (v > 0) dist = -dist; - qreal distTemp = isRightToLeftTopToBottom() ? -dist : dist; - data.flickTarget = -snapPosAt(-(dataValue - highlightStart) + distTemp) + highlightStart; + if (snapMode != QDeclarativeGridView::SnapOneRow) { + qreal distTemp = isRightToLeftTopToBottom() ? -dist : dist; + data.flickTarget = -snapPosAt(-dataValue + distTemp); + } data.flickTarget = isRightToLeftTopToBottom() ? -data.flickTarget+size() : data.flickTarget; + if (overShoot) { + if (data.flickTarget >= minExtent) { + overshootDist = overShootDistance(vSize); + data.flickTarget += overshootDist; + } else if (data.flickTarget <= maxExtent) { + overshootDist = overShootDistance(vSize); + data.flickTarget -= overshootDist; + } + } qreal adjDist = -data.flickTarget + data.move.value(); if (qAbs(adjDist) > qAbs(dist)) { // Prevent painfully slow flicking - adjust velocity to suit flickDeceleration @@ -1224,14 +1252,14 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m timeline.reset(data.move); timeline.accel(data.move, v, accel, maxDistance + overshootDist); timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this)); - if (!flickingHorizontally && q->xflick()) { - flickingHorizontally = true; + if (!hData.flicking && q->xflick()) { + hData.flicking = true; emit q->flickingChanged(); emit q->flickingHorizontallyChanged(); emit q->flickStarted(); } - if (!flickingVertically && q->yflick()) { - flickingVertically = true; + if (!vData.flicking && q->yflick()) { + vData.flicking = true; emit q->flickingChanged(); emit q->flickingVerticallyChanged(); emit q->flickStarted(); @@ -1555,6 +1583,8 @@ void QDeclarativeGridView::setCurrentIndex(int index) if (index == d->currentIndex) return; if (isComponentComplete() && d->isValid()) { + if (d->layoutScheduled) + d->layout(); d->moveReason = QDeclarativeGridViewPrivate::SetIndex; d->updateCurrent(index); } else { @@ -2108,7 +2138,8 @@ bool QDeclarativeGridView::event(QEvent *event) { Q_D(QDeclarativeGridView); if (event->type() == QEvent::User) { - d->layout(); + if (d->layoutScheduled) + d->layout(); return true; } @@ -2122,7 +2153,7 @@ void QDeclarativeGridView::viewportMoved() if (!d->itemCount) return; d->lazyRelease = true; - if (d->flickingHorizontally || d->flickingVertically) { + if (d->hData.flicking || d->vData.flicking) { if (yflick()) { if (d->vData.velocity > 0) d->bufferMode = QDeclarativeGridViewPrivate::BufferBefore; @@ -2138,7 +2169,7 @@ void QDeclarativeGridView::viewportMoved() } } refill(); - if (d->flickingHorizontally || d->flickingVertically || d->movingHorizontally || d->movingVertically) + if (d->hData.flicking || d->vData.flicking || d->hData.moving || d->vData.moving) d->moveReason = QDeclarativeGridViewPrivate::Mouse; if (d->moveReason != QDeclarativeGridViewPrivate::SetIndex) { if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) { @@ -2884,7 +2915,6 @@ void QDeclarativeGridView::itemsRemoved(int modelIndex, int count) d->itemCount -= count; bool currentRemoved = d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count; bool removedVisible = false; - // Remove the items from the visible list, skipping anything already marked for removal QList::Iterator it = d->visibleItems.begin(); while (it != d->visibleItems.end()) { @@ -2918,6 +2948,11 @@ void QDeclarativeGridView::itemsRemoved(int modelIndex, int count) } } + // If we removed items before visible items a layout may be + // required to ensure item 0 is in the first column. + if (!removedVisible && modelIndex < d->visibleIndex) + d->scheduleLayout(); + // fix current if (d->currentIndex >= modelIndex + count) { d->currentIndex -= count; diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 225b031..e0bee7e 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -53,9 +53,14 @@ #include #include #include +#include "qplatformdefs.h" QT_BEGIN_NAMESPACE +#ifndef QML_FLICK_SNAPONETHRESHOLD +#define QML_FLICK_SNAPONETHRESHOLD 30 +#endif + void QDeclarativeViewSection::setProperty(const QString &property) { if (property != m_property) { @@ -234,21 +239,6 @@ public: return visibleItems.count() ? visibleItems.first() : 0; } - FxListItem *nextVisibleItem() const { - const qreal pos = isRightToLeft() ? -position()-size() : position(); - bool foundFirst = false; - for (int i = 0; i < visibleItems.count(); ++i) { - FxListItem *item = visibleItems.at(i); - if (item->index != -1) { - if (foundFirst) - return item; - else if (item->position() < pos && item->endPosition() > pos) - foundFirst = true; - } - } - return 0; - } - // Returns the item before modelIndex, if created. // May return an item marked for removal. FxListItem *itemBefore(int modelIndex) const { @@ -1010,7 +1000,7 @@ void QDeclarativeListViewPrivate::updateHighlight() { if ((!currentItem && highlight) || (currentItem && !highlight)) createHighlight(); - if (currentItem && autoHighlight && highlight && !movingHorizontally && !movingVertically) { + if (currentItem && autoHighlight && highlight && !hData.moving && !vData.moving) { // auto-update highlight highlightPosAnimator->to = isRightToLeft() ? -currentItem->itemPosition()-currentItem->itemSize() @@ -1321,29 +1311,20 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m highlightEnd = highlightRangeEnd; } - if (currentItem && haveHighlightRange && highlightRange == QDeclarativeListView::StrictlyEnforceRange - && moveReason != QDeclarativeListViewPrivate::SetIndex) { - updateHighlight(); - qreal pos = currentItem->itemPosition(); - if (viewPos < pos + currentItem->itemSize() - highlightEnd) - viewPos = pos + currentItem->itemSize() - highlightEnd; - if (viewPos > pos - highlightStart) - viewPos = pos - highlightStart; - if (isRightToLeft()) - viewPos = -viewPos-size(); - - timeline.reset(data.move); - if (viewPos != position()) { - if (fixupMode != Immediate) { - timeline.move(data.move, -viewPos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); - data.fixingUp = true; - } else { - timeline.set(data.move, -viewPos); - } - } - vTime = timeline.time(); - } else if (snapMode != QDeclarativeListView::NoSnap && moveReason != QDeclarativeListViewPrivate::SetIndex) { + if (snapMode != QDeclarativeListView::NoSnap && moveReason != QDeclarativeListViewPrivate::SetIndex) { qreal tempPosition = isRightToLeft() ? -position()-size() : position(); + if (snapMode == QDeclarativeListView::SnapOneItem && moveReason == Mouse) { + // if we've been dragged < averageSize/2 then bias towards the next item + qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset); + qreal bias = 0; + if (data.velocity > 0 && dist > QML_FLICK_SNAPONETHRESHOLD && dist < averageSize/2) + bias = averageSize/2; + else if (data.velocity < 0 && dist < -QML_FLICK_SNAPONETHRESHOLD && dist > -averageSize/2) + bias = -averageSize/2; + if (isRightToLeft()) + bias = -bias; + tempPosition -= bias; + } FxListItem *topItem = snapItemAt(tempPosition+highlightStart); FxListItem *bottomItem = snapItemAt(tempPosition+highlightEnd); qreal pos; @@ -1359,9 +1340,9 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m } } else if (bottomItem && isInBounds) { if (isRightToLeft()) - pos = qMax(qMin(-bottomItem->position() + highlightStart - size(), -maxExtent), -minExtent); + pos = qMax(qMin(-bottomItem->position() + highlightEnd - size(), -maxExtent), -minExtent); else - pos = qMax(qMin(bottomItem->position() - highlightStart, -maxExtent), -minExtent); + pos = qMax(qMin(bottomItem->position() - highlightEnd, -maxExtent), -minExtent); } else { QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent); return; @@ -1378,6 +1359,27 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m } vTime = timeline.time(); } + } else if (currentItem && haveHighlightRange && highlightRange == QDeclarativeListView::StrictlyEnforceRange + && moveReason != QDeclarativeListViewPrivate::SetIndex) { + updateHighlight(); + qreal pos = currentItem->itemPosition(); + if (viewPos < pos + currentItem->itemSize() - highlightEnd) + viewPos = pos + currentItem->itemSize() - highlightEnd; + if (viewPos > pos - highlightStart) + viewPos = pos - highlightStart; + if (isRightToLeft()) + viewPos = -viewPos-size(); + + timeline.reset(data.move); + if (viewPos != position()) { + if (fixupMode != Immediate) { + timeline.move(data.move, -viewPos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); + data.fixingUp = true; + } else { + timeline.set(data.move, -viewPos); + } + } + vTime = timeline.time(); } else { QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent); } @@ -1399,12 +1401,19 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m } qreal maxDistance = 0; qreal dataValue = isRightToLeft() ? -data.move.value()+size() : data.move.value(); + qreal highlightStart = isRightToLeft() && highlightRangeStartValid ? size()-highlightRangeEnd : highlightRangeStart; // -ve velocity means list is moving up/left if (velocity > 0) { if (data.move.value() < minExtent) { - if (snapMode == QDeclarativeListView::SnapOneItem) { - if (FxListItem *item = isRightToLeft() ? nextVisibleItem() : firstVisibleItem()) - maxDistance = qAbs(item->position() + dataValue); + if (snapMode == QDeclarativeListView::SnapOneItem && !hData.flicking && !vData.flicking) { + // if we've been dragged < averageSize/2 then bias towards the next item + qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset); + qreal bias = dist < averageSize/2 ? averageSize/2 : 0; + if (isRightToLeft()) + bias = -bias; + data.flickTarget = -snapPosAt(-(dataValue - highlightStart) - bias) + highlightStart; + maxDistance = qAbs(data.flickTarget - data.move.value()); + velocity = maxVelocity; } else { maxDistance = qAbs(minExtent - data.move.value()); } @@ -1413,9 +1422,15 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m data.flickTarget = minExtent; } else { if (data.move.value() > maxExtent) { - if (snapMode == QDeclarativeListView::SnapOneItem) { - if (FxListItem *item = isRightToLeft() ? firstVisibleItem() : nextVisibleItem()) - maxDistance = qAbs(item->position() + dataValue); + if (snapMode == QDeclarativeListView::SnapOneItem && !hData.flicking && !vData.flicking) { + // if we've been dragged < averageSize/2 then bias towards the next item + qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset); + qreal bias = -dist < averageSize/2 ? averageSize/2 : 0; + if (isRightToLeft()) + bias = -bias; + data.flickTarget = -snapPosAt(-(dataValue - highlightStart) + bias) + highlightStart; + maxDistance = qAbs(data.flickTarget - data.move.value()); + velocity = -maxVelocity; } else { maxDistance = qAbs(maxExtent - data.move.value()); } @@ -1425,7 +1440,6 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m } bool overShoot = boundsBehavior == QDeclarativeFlickable::DragAndOvershootBounds; - qreal highlightStart = isRightToLeft() && highlightRangeStartValid ? size()-highlightRangeEnd : highlightRangeStart; if (maxDistance > 0 || overShoot) { // These modes require the list to stop exactly on an item boundary. @@ -1439,7 +1453,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m else v = maxVelocity; } - if (!flickingHorizontally && !flickingVertically) { + if (!hData.flicking && !vData.flicking) { // the initial flick - estimate boundary qreal accel = deceleration; qreal v2 = v * v; @@ -1451,8 +1465,10 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m if (v > 0) dist = -dist; if ((maxDistance > 0.0 && v2 / (2.0f * maxDistance) < accel) || snapMode == QDeclarativeListView::SnapOneItem) { - qreal distTemp = isRightToLeft() ? -dist : dist; - data.flickTarget = -snapPosAt(-(dataValue - highlightStart) + distTemp) + highlightStart; + if (snapMode != QDeclarativeListView::SnapOneItem) { + qreal distTemp = isRightToLeft() ? -dist : dist; + data.flickTarget = -snapPosAt(-(dataValue - highlightStart) + distTemp) + highlightStart; + } data.flickTarget = isRightToLeft() ? -data.flickTarget+size() : data.flickTarget; if (overShoot) { if (data.flickTarget >= minExtent) { @@ -1490,14 +1506,14 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m timeline.reset(data.move); timeline.accel(data.move, v, accel, maxDistance + overshootDist); timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this)); - if (!flickingHorizontally && q->xflick()) { - flickingHorizontally = true; + if (!hData.flicking && q->xflick()) { + hData.flicking = true; emit q->flickingChanged(); emit q->flickingHorizontallyChanged(); emit q->flickStarted(); } - if (!flickingVertically && q->yflick()) { - flickingVertically = true; + if (!vData.flicking && q->yflick()) { + vData.flicking = true; emit q->flickingChanged(); emit q->flickingVerticallyChanged(); emit q->flickStarted(); @@ -1873,6 +1889,8 @@ void QDeclarativeListView::setCurrentIndex(int index) if (index == d->currentIndex) return; if (isComponentComplete() && d->isValid()) { + if (d->layoutScheduled) + d->layout(); d->moveReason = QDeclarativeListViewPrivate::SetIndex; d->updateCurrent(index); } else if (d->currentIndex != index) { @@ -2565,7 +2583,8 @@ bool QDeclarativeListView::event(QEvent *event) { Q_D(QDeclarativeListView); if (event->type() == QEvent::User) { - d->layout(); + if (d->layoutScheduled) + d->layout(); return true; } @@ -2584,7 +2603,7 @@ void QDeclarativeListView::viewportMoved() d->inViewportMoved = true; d->lazyRelease = true; refill(); - if (d->flickingHorizontally || d->flickingVertically || d->movingHorizontally || d->movingVertically) + if (d->hData.flicking || d->vData.flicking || d->hData.moving || d->vData.moving) d->moveReason = QDeclarativeListViewPrivate::Mouse; if (d->moveReason != QDeclarativeListViewPrivate::SetIndex) { if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) { @@ -2618,7 +2637,7 @@ void QDeclarativeListView::viewportMoved() } } - if ((d->flickingHorizontally || d->flickingVertically) && d->correctFlick && !d->inFlickCorrection) { + if ((d->hData.flicking || d->vData.flicking) && d->correctFlick && !d->inFlickCorrection) { d->inFlickCorrection = true; // Near an end and it seems that the extent has changed? // Recalculate the flick so that we don't end up in an odd position. diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index e3f7980..4342ff3 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -450,12 +450,12 @@ void tst_QDeclarativeGridView::removed() model.removeItem(1); // Confirm items positioned correctly - for (int i = 6; i < 18; ++i) { + for (int i = 3; i < 15; ++i) { QDeclarativeItem *item = findItem(contentItem, "wrapper", i); if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); - QTRY_VERIFY(item->x() == (i%3)*80); - QTRY_VERIFY(item->y() == (i/3)*60); + QTRY_COMPARE(item->x(), (i%3)*80.0); + QTRY_COMPARE(item->y(), 60+(i/3)*60.0); } // Remove currentIndex @@ -476,7 +476,7 @@ void tst_QDeclarativeGridView::removed() if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_VERIFY(item->x() == (i%3)*80); - QTRY_VERIFY(item->y() == (i/3)*60); + QTRY_VERIFY(item->y() == 60+(i/3)*60); } // remove item outside current view. -- cgit v0.12