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 c74b93df047157a6ff8ca3ffa2dd2f624760824f Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Fri, 24 Jun 2011 14:00:17 +0100 Subject: runonphone: Fix usb device enumeration on Mac OS X The change in 763f3acd879648648465475aef773fe0876934a9, when merged in a315c693d0f3dd64711b8459d86b89ddc48e8c1a, broke the usb device enumeration on OS X. This commit makes it work again, but now we look for two /dev entries per device (although only one of them exists). If many usb devices are connected, this increases the risk for false matches - if that ever happens, the iteration/checking that was removed in 763f3acd879648648465475aef773fe0876934a9 could be readded within the #ifdef Q_OS_MAC, making it add only one regexp per device again. Merge-request: 2633 Reviewed-by: Shane Kearns --- tools/runonphone/serenum_unix.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/runonphone/serenum_unix.cpp b/tools/runonphone/serenum_unix.cpp index dc9e1d6..d0e7665 100644 --- a/tools/runonphone/serenum_unix.cpp +++ b/tools/runonphone/serenum_unix.cpp @@ -148,7 +148,8 @@ QList enumerateSerialPorts(int loglevel) foreach (int i, usableInterfaces) { #ifdef Q_OS_MAC eligibleInterfaces << QString("^cu\\.usbmodem.*%1$") - .arg(QString("%1").arg(descriptor.bInterfaceNumber, 1, 16).toUpper()); + .arg(QString("%1").arg(i, 1, 16).toUpper()); + eligibleInterfacesInfo << InterfaceInfo(manufacturerString, productString, device->descriptor.idVendor, device->descriptor.idProduct); #else // ### manufacturer and product strings are only readable as root :( if (!manufacturerString.isEmpty() && !productString.isEmpty()) { @@ -161,7 +162,11 @@ QList enumerateSerialPorts(int loglevel) } #endif } +#ifndef Q_OS_MAC + // On mac, we need a 1-1 mapping between eligibleInterfaces and eligibleInterfacesInfo + // in order to find the friendly name for an interface eligibleInterfacesInfo << InterfaceInfo(manufacturerString, productString, device->descriptor.idVendor, device->descriptor.idProduct); +#endif } } } -- cgit v0.12 From 75c04d43cc8264f142d26f9524b325dbc362cae5 Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Fri, 24 Jun 2011 14:00:19 +0100 Subject: runonphone: Include the manufacturer name in the friendly name on OS X This helps automatic detection of devices such as N8-00, that don't include Nokia in the product name (while devices from earlier generations did include it, such as "Nokia 5800 XpressMusic"). Merge-request: 2633 Reviewed-by: Shane Kearns --- tools/runonphone/serenum_unix.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/runonphone/serenum_unix.cpp b/tools/runonphone/serenum_unix.cpp index d0e7665..9a33dab 100644 --- a/tools/runonphone/serenum_unix.cpp +++ b/tools/runonphone/serenum_unix.cpp @@ -190,7 +190,8 @@ QList enumerateSerialPorts(int loglevel) if (loglevel > 1) qDebug() << " found device file:" << info.fileName() << endl; #ifdef Q_OS_MAC - friendlyName = eligibleInterfacesInfo[eligibleInterfaces.indexOf(iface)].product; + InterfaceInfo info = eligibleInterfacesInfo[eligibleInterfaces.indexOf(iface)]; + friendlyName = info.manufacturer + " " + info.product; #endif usable = true; break; -- cgit v0.12 From 37a21edbfb01f902bbfc033727066ed1ee1354e7 Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Fri, 24 Jun 2011 14:00:29 +0100 Subject: runonphone: Change the upload option to allow uploading any file This allows uploading of any file to any directory on the phone. Merge-request: 1271 Reviewed-by: Shane Kearns --- tools/runonphone/main.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/runonphone/main.cpp b/tools/runonphone/main.cpp index e400062..d749106 100644 --- a/tools/runonphone/main.cpp +++ b/tools/runonphone/main.cpp @@ -62,7 +62,7 @@ void printUsage(QTextStream& outstream, QString exeName) << "-t, --timeout terminate test if timeout occurs" << endl << "-v, --verbose show debugging output" << endl << "-q, --quiet hide progress messages" << endl - << "-u, --upload upload executable file to phone" << endl + << "-u, --upload upload file to phone" << endl << "-d, --download copy file from phone to PC after running test" << endl << "--nocrashlog Don't capture call stack if test crashes" << endl << "--crashlogpath Path to save crash logs (default=working dir)" << endl @@ -86,6 +86,7 @@ int main(int argc, char *argv[]) QTextStream outstream(stdout); QTextStream errstream(stderr); QString uploadLocalFile; + QString uploadRemoteFile; QString downloadRemoteFile; QString downloadLocalFile; int loglevel=1; @@ -121,10 +122,8 @@ int main(int argc, char *argv[]) errstream << "Executable file (" << uploadLocalFile << ") doesn't exist" << endl; return 1; } - if (!(QFileInfo(uploadLocalFile).suffix() == "exe")) { - errstream << "File (" << uploadLocalFile << ") must be an executable" << endl; - return 1; - } + CHECK_PARAMETER_EXISTS + uploadRemoteFile = it.next(); } else if (arg == "--download" || arg == "-d") { CHECK_PARAMETER_EXISTS @@ -161,7 +160,8 @@ int main(int argc, char *argv[]) } } - if (exeFile.isEmpty() && sisFile.isEmpty() && uploadLocalFile.isEmpty() && + if (exeFile.isEmpty() && sisFile.isEmpty() && + (uploadLocalFile.isEmpty() || uploadRemoteFile.isEmpty()) && (downloadLocalFile.isEmpty() || downloadRemoteFile.isEmpty())) { printUsage(outstream, args[0]); return 1; @@ -211,7 +211,7 @@ int main(int argc, char *argv[]) } else if (!uploadLocalFile.isEmpty() && uploadInfo.exists()) { launcher->addStartupActions(trk::Launcher::ActionCopy); - launcher->setCopyFileName(uploadLocalFile, QString("c:\\sys\\bin\\") + uploadInfo.fileName()); + launcher->setCopyFileName(uploadLocalFile, uploadRemoteFile); } if (!exeFile.isEmpty()) { launcher->addStartupActions(trk::Launcher::ActionRun); -- 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 482d3d048f96509c2b90096475eb7b1401c4a04c Mon Sep 17 00:00:00 2001 From: mread Date: Mon, 27 Jun 2011 15:08:48 +0100 Subject: Fixing winscw def file broken by recent merge QtGui's def file had duplicated lines and a gap in the ordinal sequence. Reviewed-by: Shane Kearns --- src/s60installs/bwins/QtGuiu.def | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index 318f16f..d4b39e4 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -5029,7 +5029,6 @@ EXPORTS ?hasSelection@QTextCursor@@QBE_NXZ @ 5028 NONAME ; bool QTextCursor::hasSelection(void) const ?hasStaticContents@QWindowSurface@@IBE_NXZ @ 5029 NONAME ; bool QWindowSurface::hasStaticContents(void) const ?hasStaticContentsSupport@QWindowSurface@@QBE_NXZ @ 5030 NONAME ABSENT ; bool QWindowSurface::hasStaticContentsSupport(void) const - ?hasStaticContentsSupport@QWindowSurface@@UBE_NXZ @ 5030 NONAME ABSENT ; bool QWindowSurface::hasStaticContentsSupport(void) const ?hasThemeIcon@QIcon@@SA_NABVQString@@@Z @ 5031 NONAME ; bool QIcon::hasThemeIcon(class QString const &) ?hasTracking@QAbstractSlider@@QBE_NXZ @ 5032 NONAME ; bool QAbstractSlider::hasTracking(void) const ?hasTranslateOnlySceneTransform@QGraphicsItemPrivate@@QAE_NXZ @ 5033 NONAME ; bool QGraphicsItemPrivate::hasTranslateOnlySceneTransform(void) @@ -12855,7 +12854,6 @@ EXPORTS ?updateMicroFocus@QGraphicsItem@@IAEXXZ @ 12853 NONAME ; void QGraphicsItem::updateMicroFocus(void) ?populate@QTextureGlyphCache@@QAEXPAVQFontEngine@@HPBIPBUQFixedPoint@@@Z @ 12854 NONAME ABSENT ; void QTextureGlyphCache::populate(class QFontEngine *, int, unsigned int const *, struct QFixedPoint const *) ?hasPartialUpdateSupport@QWindowSurface@@QBE_NXZ @ 12855 NONAME ABSENT ; bool QWindowSurface::hasPartialUpdateSupport(void) const - ?hasPartialUpdateSupport@QWindowSurface@@UBE_NXZ @ 12855 NONAME ABSENT ; bool QWindowSurface::hasPartialUpdateSupport(void) const ?scroll@QRuntimePixmapData@@UAE_NHHABVQRect@@@Z @ 12856 NONAME ; bool QRuntimePixmapData::scroll(int, int, class QRect const &) ?qt_draw_glyphs@@YAXPAVQPainter@@PBIPBVQPointF@@H@Z @ 12857 NONAME ABSENT ; void qt_draw_glyphs(class QPainter *, unsigned int const *, class QPointF const *, int) ?nativeDisplay@QEgl@@YAHXZ @ 12858 NONAME ; int QEgl::nativeDisplay(void) @@ -14036,11 +14034,11 @@ EXPORTS ?releaseAllGpuResources@QSymbianGraphicsSystemEx@@UAEXXZ @ 14033 NONAME ; void QSymbianGraphicsSystemEx::releaseAllGpuResources(void) ?cursorMoveStyle@QLineControl@@QBE?AW4CursorMoveStyle@Qt@@XZ @ 14034 NONAME ; enum Qt::CursorMoveStyle QLineControl::cursorMoveStyle(void) const ?hasBCM2727@QSymbianGraphicsSystemEx@@UAE_NXZ @ 14035 NONAME ABSENT ; bool QSymbianGraphicsSystemEx::hasBCM2727(void) - ??0QSymbianGraphicsSystemEx@@QAE@XZ @ 14038 NONAME ABSENT ; QSymbianGraphicsSystemEx::QSymbianGraphicsSystemEx(void) - ?hasBCM2727@QSymbianGraphicsSystemEx@@SA_NXZ @ 14039 NONAME ; bool QSymbianGraphicsSystemEx::hasBCM2727(void) - ?getClusterLength@QTextEngine@@AAEHPAGPBUHB_CharAttributes@@HHHPAH@Z @ 14040 NONAME ; int QTextEngine::getClusterLength(unsigned short *, struct HB_CharAttributes const *, int, int, int, int *) - ?positionInLigature@QTextEngine@@QAEHPBUQScriptItem@@HUQFixed@@1H_N@Z @ 14041 NONAME ; int QTextEngine::positionInLigature(struct QScriptItem const *, int, struct QFixed, struct QFixed, int, bool) - ?supportsTransformations@QPaintEngineEx@@UBE_NMABVQTransform@@@Z @ 14042 NONAME ; bool QPaintEngineEx::supportsTransformations(float, class QTransform const &) const - ?drawStaticTextItem@QPaintEngineEx@@UAEXPAVQStaticTextItem@@@Z @ 14043 NONAME ; void QPaintEngineEx::drawStaticTextItem(class QStaticTextItem *) - ?constImageRef@QVolatileImage@@QBEABVQImage@@XZ @ 14044 NONAME ; class QImage const & QVolatileImage::constImageRef(void) const - ?toVolatileImage@QPixmapData@@UBE?AVQVolatileImage@@XZ @ 14045 NONAME ; class QVolatileImage QPixmapData::toVolatileImage(void) const + ??0QSymbianGraphicsSystemEx@@QAE@XZ @ 14036 NONAME ABSENT ; QSymbianGraphicsSystemEx::QSymbianGraphicsSystemEx(void) + ?hasBCM2727@QSymbianGraphicsSystemEx@@SA_NXZ @ 14037 NONAME ; bool QSymbianGraphicsSystemEx::hasBCM2727(void) + ?getClusterLength@QTextEngine@@AAEHPAGPBUHB_CharAttributes@@HHHPAH@Z @ 14038 NONAME ; int QTextEngine::getClusterLength(unsigned short *, struct HB_CharAttributes const *, int, int, int, int *) + ?positionInLigature@QTextEngine@@QAEHPBUQScriptItem@@HUQFixed@@1H_N@Z @ 14039 NONAME ; int QTextEngine::positionInLigature(struct QScriptItem const *, int, struct QFixed, struct QFixed, int, bool) + ?supportsTransformations@QPaintEngineEx@@UBE_NMABVQTransform@@@Z @ 14040 NONAME ; bool QPaintEngineEx::supportsTransformations(float, class QTransform const &) const + ?drawStaticTextItem@QPaintEngineEx@@UAEXPAVQStaticTextItem@@@Z @ 14041 NONAME ; void QPaintEngineEx::drawStaticTextItem(class QStaticTextItem *) + ?constImageRef@QVolatileImage@@QBEABVQImage@@XZ @ 14042 NONAME ; class QImage const & QVolatileImage::constImageRef(void) const + ?toVolatileImage@QPixmapData@@UBE?AVQVolatileImage@@XZ @ 14043 NONAME ; class QVolatileImage QPixmapData::toVolatileImage(void) const -- 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 f3cc24f2983189cd66b34529cf9fa721f9bf3607 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 29 Jun 2011 13:05:11 +0200 Subject: Remove openvglite plugin This code does not compile, and it has not been maintained for almost two years. Reviewed-by: jlind --- src/plugins/platforms/openvglite/main.cpp | 71 -------- src/plugins/platforms/openvglite/openvglite.pro | 12 -- .../openvglite/qgraphicssystem_vglite.cpp | 193 --------------------- .../platforms/openvglite/qgraphicssystem_vglite.h | 93 ---------- .../platforms/openvglite/qwindowsurface_vglite.cpp | 131 -------------- .../platforms/openvglite/qwindowsurface_vglite.h | 91 ---------- 6 files changed, 591 deletions(-) delete mode 100644 src/plugins/platforms/openvglite/main.cpp delete mode 100644 src/plugins/platforms/openvglite/openvglite.pro delete mode 100644 src/plugins/platforms/openvglite/qgraphicssystem_vglite.cpp delete mode 100644 src/plugins/platforms/openvglite/qgraphicssystem_vglite.h delete mode 100644 src/plugins/platforms/openvglite/qwindowsurface_vglite.cpp delete mode 100644 src/plugins/platforms/openvglite/qwindowsurface_vglite.h diff --git a/src/plugins/platforms/openvglite/main.cpp b/src/plugins/platforms/openvglite/main.cpp deleted file mode 100644 index 19220a6..0000000 --- a/src/plugins/platforms/openvglite/main.cpp +++ /dev/null @@ -1,71 +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 plugins 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 -#include "qgraphicssystem_vglite.h" - -QT_BEGIN_NAMESPACE - -class QVGGraphicsSystemPlugin : public QGraphicsSystemPlugin -{ -public: - QStringList keys() const; - QGraphicsSystem *create(const QString&); -}; - -QStringList QVGGraphicsSystemPlugin::keys() const -{ - QStringList list; - list << "OpenVG"; - return list; -} - -QGraphicsSystem* QVGGraphicsSystemPlugin::create(const QString& system) -{ - if (system.toLower() == "openvg") - return new QVGLiteGraphicsSystem; - - return 0; -} - -Q_EXPORT_PLUGIN2(openvg, QVGGraphicsSystemPlugin) - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/openvglite/openvglite.pro b/src/plugins/platforms/openvglite/openvglite.pro deleted file mode 100644 index 9d7860a..0000000 --- a/src/plugins/platforms/openvglite/openvglite.pro +++ /dev/null @@ -1,12 +0,0 @@ -TARGET = qvglitegraphicssystem -include(../../qpluginbase.pri) - -QT += openvg - -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems - -SOURCES = main.cpp qgraphicssystem_vglite.cpp qwindowsurface_vglite.cpp -HEADERS = qgraphicssystem_vglite.h qwindowsurface_vglite.h - -target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems -INSTALLS += target diff --git a/src/plugins/platforms/openvglite/qgraphicssystem_vglite.cpp b/src/plugins/platforms/openvglite/qgraphicssystem_vglite.cpp deleted file mode 100644 index 203896f..0000000 --- a/src/plugins/platforms/openvglite/qgraphicssystem_vglite.cpp +++ /dev/null @@ -1,193 +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 plugins 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 "qgraphicssystem_vglite.h" -#include "qwindowsurface_vglite.h" -#include -#include -#include -#ifdef OPENVG_USBHP_INIT -extern "C" { -#include -}; -#endif - -QT_BEGIN_NAMESPACE - -QVGLiteGraphicsSystem::QVGLiteGraphicsSystem() - : w(0), h(0), d(0), dw(0), dh(0), physWidth(0), physHeight(0), - surface(0), context(0), rootWindow(0), - screenFormat(QImage::Format_RGB16), preservedSwap(false) -{ -#ifdef OPENVG_USBHP_INIT - initLibrary(); -#endif - - // The graphics system is also the screen definition. - mScreens.append(this); - - QString displaySpec = QString::fromLatin1(qgetenv("QWS_DISPLAY")); - QStringList displayArgs = displaySpec.split(QLatin1Char(':')); - - // Initialize EGL and create the global EGL context. - context = qt_vg_create_context(0); - if (!context) { - qFatal("QVGLiteGraphicsSystem: could not initialize EGL"); - return; - } - - // Get the root window handle to use. Default to zero. - QRegExp winidRx(QLatin1String("winid=?(\\d+)")); - int winidIdx = displayArgs.indexOf(winidRx); - int handle = 0; - if (winidIdx >= 0) { - winidRx.exactMatch(displayArgs.at(winidIdx)); - handle = winidRx.cap(1).toInt(); - } - - // Create a full-screen window based on the native handle. - // If the context is premultiplied, the window should be too. - QEglProperties props; -#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT - EGLint surfaceType = 0; - if (context->configAttrib(EGL_SURFACE_TYPE, &surfaceType) && - (surfaceType & EGL_VG_ALPHA_FORMAT_PRE_BIT) != 0) - props.setValue(EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE); -#endif - rootWindow = eglCreateWindowSurface - (context->display(), context->config(), - (EGLNativeWindowType)handle, props.properties()); - if (rootWindow == EGL_NO_SURFACE) { - delete context; - context = 0; - qFatal("QVGLiteGraphicsSystem: could not create full-screen window"); - return; - } - - // Try to turn on preserved swap behaviour on the root window. - // This will allow us to optimize compositing to focus on just - // the screen region that has changed. Otherwise we must - // re-composite the entire screen every frame. -#if !defined(QVG_NO_PRESERVED_SWAP) - eglGetError(); // Clear error state first. - eglSurfaceAttrib(context->display(), rootWindow, - EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); - preservedSwap = (eglGetError() == EGL_SUCCESS); -#else - preservedSwap = false; -#endif - - // Fetch the root window properties. - eglQuerySurface(context->display(), rootWindow, EGL_WIDTH, &w); - eglQuerySurface(context->display(), rootWindow, EGL_HEIGHT, &h); - screenFormat = qt_vg_config_to_image_format(context); - switch (screenFormat) { - case QImage::Format_ARGB32_Premultiplied: - case QImage::Format_ARGB32: - case QImage::Format_RGB32: - default: - d = 32; - break; - case QImage::Format_RGB16: - case QImage::Format_ARGB4444_Premultiplied: - d = 16; - break; - } - dw = w; - dh = h; - qDebug("screen size: %dx%dx%d", w, h, d); - - // Handle display physical size spec. From qscreenlinuxfb_qws.cpp. - QRegExp mmWidthRx(QLatin1String("mmWidth=?(\\d+)")); - int dimIdxW = displayArgs.indexOf(mmWidthRx); - QRegExp mmHeightRx(QLatin1String("mmHeight=?(\\d+)")); - int dimIdxH = displayArgs.indexOf(mmHeightRx); - if (dimIdxW >= 0) { - mmWidthRx.exactMatch(displayArgs.at(dimIdxW)); - physWidth = mmWidthRx.cap(1).toInt(); - if (dimIdxH < 0) - physHeight = dh*physWidth/dw; - } - if (dimIdxH >= 0) { - mmHeightRx.exactMatch(displayArgs.at(dimIdxH)); - physHeight = mmHeightRx.cap(1).toInt(); - if (dimIdxW < 0) - physWidth = dw*physHeight/dh; - } - if (dimIdxW < 0 && dimIdxH < 0) { - const int dpi = 72; - physWidth = qRound(dw * 25.4 / dpi); - physHeight = qRound(dh * 25.4 / dpi); - } -} - -QVGLiteGraphicsSystem::~QVGLiteGraphicsSystem() -{ -} - -QPixmapData *QVGLiteGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const -{ -#if !defined(QVGLite_NO_SINGLE_CONTEXT) && !defined(QVGLite_NO_PIXMAP_DATA) - // Pixmaps can use QVGLitePixmapData; bitmaps must use raster. - if (type == QPixmapData::PixmapType) - return new QVGPixmapData(type); - else - return new QRasterPixmapData(type); -#else - return new QRasterPixmapData(type); -#endif -} - -QWindowSurface *QVGLiteGraphicsSystem::createWindowSurface(QWidget *widget) const -{ - if (widget->windowType() == Qt::Desktop) - return 0; // Don't create an explicit window surface for the destkop. - if (surface) { - qWarning() << "QVGLiteGraphicsSystem: only one window surface " - "is supported at a time"; - return 0; - } - surface = new QVGLiteWindowSurface - (const_cast(this), widget); - return surface; -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/openvglite/qgraphicssystem_vglite.h b/src/plugins/platforms/openvglite/qgraphicssystem_vglite.h deleted file mode 100644 index 41b1d28..0000000 --- a/src/plugins/platforms/openvglite/qgraphicssystem_vglite.h +++ /dev/null @@ -1,93 +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 plugins 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 QGRAPHICSSYSTEM_VGLITE_H -#define QGRAPHICSSYSTEM_VGLITE_H - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QVGLiteWindowSurface; - -class QVGLiteGraphicsSystem : public QGraphicsSystem, - public QGraphicsSystemScreen -{ -public: - QVGLiteGraphicsSystem(); - ~QVGLiteGraphicsSystem(); - - QPixmapData *createPixmapData(QPixmapData::PixelType type) const; - QWindowSurface *createWindowSurface(QWidget *widget) const; - QList screens() const { return mScreens; } - - QRect geometry() const { return QRect(0, 0, w, h); } - int depth() const { return d; } - QImage::Format format() const { return screenFormat; } - QSize physicalSize() const { return QSize(physWidth, physHeight); } - -private: - friend class QVGLiteWindowSurface; - - int w; - int h; - int d; - - int dw; - int dh; - - int physWidth; - int physHeight; - - mutable QVGLiteWindowSurface *surface; - QEglContext *context; - EGLSurface rootWindow; - QImage::Format screenFormat; - bool preservedSwap; - - QList mScreens; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/openvglite/qwindowsurface_vglite.cpp b/src/plugins/platforms/openvglite/qwindowsurface_vglite.cpp deleted file mode 100644 index dad23c1..0000000 --- a/src/plugins/platforms/openvglite/qwindowsurface_vglite.cpp +++ /dev/null @@ -1,131 +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 plugins 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 "qwindowsurface_vglite.h" -#include "qgraphicssystem_vglite.h" -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QVGLiteWindowSurface::QVGLiteWindowSurface - (QVGLiteGraphicsSystem *gs, QWidget *window) - : QWindowSurface(window), graphicsSystem(gs), - isPaintingActive(false), engine(0) -{ -} - -QVGLiteWindowSurface::~QVGLiteWindowSurface() -{ - graphicsSystem->surface = 0; - if (engine) - qt_vg_destroy_paint_engine(engine); -} - -QPaintDevice *QVGLiteWindowSurface::paintDevice() -{ - qt_vg_make_current(graphicsSystem->context, graphicsSystem->rootWindow); - isPaintingActive = true; - // TODO: clear the parts of the back buffer that are not - // covered by the window surface to black. - return this; -} - -void QVGLiteWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) -{ - Q_UNUSED(widget); - Q_UNUSED(region); - Q_UNUSED(offset); - QEglContext *context = graphicsSystem->context; - if (context) { - if (!isPaintingActive) - qt_vg_make_current(context, graphicsSystem->rootWindow); - context->swapBuffers(); - qt_vg_done_current(context); - context->setSurface(EGL_NO_SURFACE); - isPaintingActive = false; - } -} - -void QVGLiteWindowSurface::setGeometry(const QRect &rect) -{ - QWindowSurface::setGeometry(rect); -} - -bool QVGLiteWindowSurface::scroll(const QRegion &area, int dx, int dy) -{ - return QWindowSurface::scroll(area, dx, dy); -} - -void QVGLiteWindowSurface::beginPaint(const QRegion ®ion) -{ - Q_UNUSED(region); -} - -void QVGLiteWindowSurface::endPaint(const QRegion ®ion) -{ - Q_UNUSED(region); -} - -QPaintEngine *QVGLiteWindowSurface::paintEngine() const -{ - if (!engine) - engine = qt_vg_create_paint_engine(); - return engine; -} - -// We need to get access to QWidget::metric() from QVGLiteWindowSurface::metric, -// but it is not a friend of QWidget. To get around this, we create a -// fake QX11PaintEngine class, which is a friend. -class QX11PaintEngine -{ -public: - static int metric(const QWidget *widget, QPaintDevice::PaintDeviceMetric met) - { - return widget->metric(met); - } -}; - -int QVGLiteWindowSurface::metric(PaintDeviceMetric met) const -{ - return QX11PaintEngine::metric(window(), met); -} diff --git a/src/plugins/platforms/openvglite/qwindowsurface_vglite.h b/src/plugins/platforms/openvglite/qwindowsurface_vglite.h deleted file mode 100644 index b6e22d8..0000000 --- a/src/plugins/platforms/openvglite/qwindowsurface_vglite.h +++ /dev/null @@ -1,91 +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 plugins 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 QWINDOWSURFACE_VGLITE_H -#define QWINDOWSURFACE_VGLITE_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -QT_BEGIN_NAMESPACE - -class QVGLiteGraphicsSystem; -class QVGPaintEngine; - -class Q_OPENVG_EXPORT QVGLiteWindowSurface : public QWindowSurface, public QPaintDevice -{ -public: - QVGLiteWindowSurface(QVGLiteGraphicsSystem *gs, QWidget *window); - ~QVGLiteWindowSurface(); - - QPaintDevice *paintDevice(); - void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); - void setGeometry(const QRect &rect); - bool scroll(const QRegion &area, int dx, int dy); - - void beginPaint(const QRegion ®ion); - void endPaint(const QRegion ®ion); - - QPaintEngine *paintEngine() const; - -protected: - int metric(PaintDeviceMetric metric) const; - -private: - QVGLiteGraphicsSystem *graphicsSystem; - bool isPaintingActive; - mutable QVGPaintEngine *engine; -}; - -QT_END_NAMESPACE - -#endif // QWINDOWSURFACE_VGLITE_H -- 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 f54c5d9133d7aa7636988db36fa6cc51d26434b6 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 30 Jun 2011 11:57:09 +0200 Subject: Fix transformations on DirectWrite rasterized text There were a few bugs in the DirectWrite font engine that caused transformed text to break. First of all, alphaMapForGlyph() ignored the transform, so no gray antialiased text would be transformed. Second of all, the imageForGlyph() function would use the wrong bounding box for the rasterized glyph, causing its positioning to become a little bit off when rotating. The fix is to get the bounding box from the system and add a margin to this instead of trying to predict how it will appear after the vertical hinting etc. has been applied. So that the positioning metrics are in sync with the actual metrics used by the alphaMap* functions, we also need to implement the alphaMapBoundingBox() function. Task-number: QTBUG-19829 Reviewed-by: Jiang Jiang --- src/gui/text/qfontenginedirectwrite.cpp | 145 ++++++++++++++++++++++---------- src/gui/text/qfontenginedirectwrite_p.h | 6 +- 2 files changed, 104 insertions(+), 47 deletions(-) diff --git a/src/gui/text/qfontenginedirectwrite.cpp b/src/gui/text/qfontenginedirectwrite.cpp index 890cad9..b6a172e 100644 --- a/src/gui/text/qfontenginedirectwrite.cpp +++ b/src/gui/text/qfontenginedirectwrite.cpp @@ -390,6 +390,60 @@ glyph_metrics_t QFontEngineDirectWrite::boundingBox(const QGlyphLayout &glyphs) return glyph_metrics_t(0, -m_ascent, w - lastRightBearing(glyphs), m_ascent + m_descent, w, 0); } +glyph_metrics_t QFontEngineDirectWrite::alphaMapBoundingBox(glyph_t glyph, QFixed subPixelPosition, + const QTransform &matrix, + GlyphFormat /*format*/) +{ + glyph_metrics_t bbox = QFontEngine::boundingBox(glyph, matrix); // To get transformed advance + + UINT16 glyphIndex = glyph; + FLOAT glyphAdvance = 0; + + DWRITE_GLYPH_OFFSET glyphOffset; + glyphOffset.advanceOffset = 0; + glyphOffset.ascenderOffset = 0; + + DWRITE_GLYPH_RUN glyphRun; + glyphRun.fontFace = m_directWriteFontFace; + glyphRun.fontEmSize = fontDef.pixelSize; + glyphRun.glyphCount = 1; + glyphRun.glyphIndices = &glyphIndex; + glyphRun.glyphAdvances = &glyphAdvance; + glyphRun.isSideways = false; + glyphRun.bidiLevel = 0; + glyphRun.glyphOffsets = &glyphOffset; + + DWRITE_MATRIX transform; + transform.dx = subPixelPosition.toReal(); + transform.dy = 0; + transform.m11 = matrix.m11(); + transform.m12 = matrix.m12(); + transform.m21 = matrix.m21(); + transform.m22 = matrix.m22(); + + IDWriteGlyphRunAnalysis *glyphAnalysis = NULL; + HRESULT hr = m_directWriteFactory->CreateGlyphRunAnalysis( + &glyphRun, + 1.0f, + &transform, + DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC, + DWRITE_MEASURING_MODE_NATURAL, + 0.0, 0.0, + &glyphAnalysis + ); + + if (SUCCEEDED(hr)) { + RECT rect; + glyphAnalysis->GetAlphaTextureBounds(DWRITE_TEXTURE_CLEARTYPE_3x1, &rect); + glyphAnalysis->Release(); + + return glyph_metrics_t(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, + bbox.xoff, bbox.yoff); + } else { + return glyph_metrics_t(); + } +} + glyph_metrics_t QFontEngineDirectWrite::boundingBox(glyph_t g) { if (m_directWriteFontFace == 0) @@ -459,9 +513,10 @@ qreal QFontEngineDirectWrite::maxCharWidth() const extern uint qt_pow_gamma[256]; -QImage QFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition) +QImage QFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, + const QTransform &xform) { - QImage im = imageForGlyph(glyph, subPixelPosition, 0, QTransform()); + QImage im = imageForGlyph(glyph, subPixelPosition, 0, xform); QImage indexed(im.width(), im.height(), QImage::Format_Indexed8); QVector colors(256); @@ -492,12 +547,8 @@ QImage QFontEngineDirectWrite::imageForGlyph(glyph_t t, int margin, const QTransform &xform) { - glyph_metrics_t metrics = QFontEngine::boundingBox(t, xform); - int width = (metrics.width + margin * 2 + 4).ceil().toInt() ; - int height = (metrics.height + margin * 2 + 4).ceil().toInt(); - UINT16 glyphIndex = t; - FLOAT glyphAdvance = metrics.xoff.toReal(); + FLOAT glyphAdvance = 0; DWRITE_GLYPH_OFFSET glyphOffset; glyphOffset.advanceOffset = 0; @@ -513,12 +564,9 @@ QImage QFontEngineDirectWrite::imageForGlyph(glyph_t t, glyphRun.bidiLevel = 0; glyphRun.glyphOffsets = &glyphOffset; - QFixed x = margin - metrics.x.round() + subPixelPosition; - QFixed y = margin - metrics.y.floor(); - DWRITE_MATRIX transform; - transform.dx = x.toReal(); - transform.dy = y.toReal(); + transform.dx = subPixelPosition.toReal(); + transform.dy = 0; transform.m11 = xform.m11(); transform.m12 = xform.m12(); transform.m21 = xform.m21(); @@ -537,48 +585,53 @@ QImage QFontEngineDirectWrite::imageForGlyph(glyph_t t, if (SUCCEEDED(hr)) { RECT rect; - rect.left = 0; - rect.top = 0; - rect.right = width; - rect.bottom = height; - - int size = width * height * 3; - BYTE *alphaValues = new BYTE[size]; - qMemSet(alphaValues, size, 0); - - hr = glyphAnalysis->CreateAlphaTexture(DWRITE_TEXTURE_CLEARTYPE_3x1, - &rect, - alphaValues, - size); - - if (SUCCEEDED(hr)) { - QImage img(width, height, QImage::Format_RGB32); - img.fill(0xffffffff); + glyphAnalysis->GetAlphaTextureBounds(DWRITE_TEXTURE_CLEARTYPE_3x1, &rect); - for (int y=0; y(img.scanLine(y)); - BYTE *src = alphaValues + width * 3 * y; + rect.left -= margin; + rect.top -= margin; + rect.right += margin; + rect.bottom += margin; - for (int x=0; x 0) { + BYTE *alphaValues = new BYTE[size]; + qMemSet(alphaValues, size, 0); + + hr = glyphAnalysis->CreateAlphaTexture(DWRITE_TEXTURE_CLEARTYPE_3x1, + &rect, + alphaValues, + size); + + if (SUCCEEDED(hr)) { + QImage img(width, height, QImage::Format_RGB32); + img.fill(0xffffffff); + + for (int y=0; y(img.scanLine(y)); + BYTE *src = alphaValues + width * 3 * y; + + for (int x=0; xRelease(); + delete[] alphaValues; + return img; + } else { + delete[] alphaValues; - return img; - } else { - delete[] alphaValues; - glyphAnalysis->Release(); - - qErrnoWarning("QFontEngineDirectWrite::imageForGlyph: CreateAlphaTexture failed"); + qErrnoWarning("QFontEngineDirectWrite::imageForGlyph: CreateAlphaTexture failed"); + } } + glyphAnalysis->Release(); } else { qErrnoWarning("QFontEngineDirectWrite::imageForGlyph: CreateGlyphRunAnalysis failed"); } diff --git a/src/gui/text/qfontenginedirectwrite_p.h b/src/gui/text/qfontenginedirectwrite_p.h index d0086fc..edf1e6a 100644 --- a/src/gui/text/qfontenginedirectwrite_p.h +++ b/src/gui/text/qfontenginedirectwrite_p.h @@ -86,6 +86,10 @@ public: glyph_metrics_t boundingBox(const QGlyphLayout &glyphs); glyph_metrics_t boundingBox(glyph_t g); + glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, + QFixed subPixelPosition, + const QTransform &matrix, + GlyphFormat format); QFixed ascent() const; QFixed descent() const; @@ -97,7 +101,7 @@ public: bool supportsSubPixelPositions() const; - QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition); + QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t); QImage alphaRGBMapForGlyph(glyph_t t, QFixed subPixelPosition, int margin, const QTransform &xform); -- cgit v0.12 From d58eec3c932d1cdbcf3b42534e8fe870ec109487 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 30 Jun 2011 12:54:46 +0200 Subject: Fix resource leak in QFontEngineDirectWrite Bug introduced by f54c5d9133d7aa7636988db36fa6cc51d26434b6. The release statement has to come before the return statement :) Reviewed-by: Jiang Jiang --- src/gui/text/qfontenginedirectwrite.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qfontenginedirectwrite.cpp b/src/gui/text/qfontenginedirectwrite.cpp index b6a172e..d693273 100644 --- a/src/gui/text/qfontenginedirectwrite.cpp +++ b/src/gui/text/qfontenginedirectwrite.cpp @@ -623,15 +623,16 @@ QImage QFontEngineDirectWrite::imageForGlyph(glyph_t t, } delete[] alphaValues; + glyphAnalysis->Release(); + return img; } else { delete[] alphaValues; + glyphAnalysis->Release(); qErrnoWarning("QFontEngineDirectWrite::imageForGlyph: CreateAlphaTexture failed"); } } - - glyphAnalysis->Release(); } else { qErrnoWarning("QFontEngineDirectWrite::imageForGlyph: CreateGlyphRunAnalysis failed"); } -- cgit v0.12 From 2b6cf174153c6a680bac94eb666a131a3aad3891 Mon Sep 17 00:00:00 2001 From: Jani Hautakangas Date: Thu, 30 Jun 2011 14:28:39 +0300 Subject: Introduce QPixmap::fromSymbianRSgImage(RSgImage*) to GL engine Initial implementation of QPixmap::fromSymbianRSgImage(RSgImage*) on OpenGL graphics system. Task-number: QTBUG-15254 Reviewed-by: Laszlo Agocs --- mkspecs/common/symbian/symbian.conf | 3 + src/opengl/qgl.cpp | 1 + src/opengl/qgl_symbian.cpp | 109 +----- src/opengl/qpixmapdata_gl_p.h | 15 +- src/opengl/qpixmapdata_symbiangl.cpp | 627 ++++++++++++++++------------------- src/opengl/qwindowsurface_gl.cpp | 55 ++- 6 files changed, 339 insertions(+), 471 deletions(-) diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index 0288ada..e30347b 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -88,6 +88,9 @@ QMAKE_LIBS_S60 = -lavkon -leikcoctl -lgfxtrans exists($${EPOCROOT}epoc32/include/platform/sgresource/sgimage.h) { QMAKE_LIBS_OPENVG += -lsgresource + QMAKE_LIBS_OPENGL_QT += -lsgresource + QMAKE_LIBS_OPENGL_ES1_QT += -lsgresource + QMAKE_LIBS_OPENGL_ES2_QT += -lsgresource } contains(QMAKE_HOST.os,Windows) { diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 4fee886..161e099 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -5920,6 +5920,7 @@ void QGLTexture::freeTexture() } id = 0; + boundPixmap = 0; boundKey = 0; } #endif diff --git a/src/opengl/qgl_symbian.cpp b/src/opengl/qgl_symbian.cpp index 21671a6..b8e5c22 100644 --- a/src/opengl/qgl_symbian.cpp +++ b/src/opengl/qgl_symbian.cpp @@ -40,7 +40,6 @@ ****************************************************************************/ #include "qgl.h" -#include #include #include #include @@ -55,7 +54,7 @@ #include "qpixmapdata_gl_p.h" #include "qgltexturepool_p.h" #include "qcolormap.h" -#include + QT_BEGIN_NAMESPACE @@ -73,7 +72,7 @@ QT_BEGIN_NAMESPACE #endif #endif -extern int qt_gl_pixmap_serial; +Q_OPENGL_EXPORT extern QGLWidget* qt_gl_share_widget(); /* QGLTemporaryContext implementation @@ -266,6 +265,11 @@ void QGLWidget::resizeEvent(QResizeEvent *) if (!isValid()) return; + // Shared widget can ignore resize events which + // may happen due to orientation change + if (this == qt_gl_share_widget()) + return; + if (QGLContext::currentContext()) doneCurrent(); @@ -378,103 +382,4 @@ void QGLWidgetPrivate::recreateEglSurface() eglSurfaceWindowId = currentId; } -static inline bool knownGoodFormat(QImage::Format format) -{ - switch (format) { - case QImage::Format_RGB16: // EColor64K - case QImage::Format_RGB32: // EColor16MU - case QImage::Format_ARGB32_Premultiplied: // EColor16MAP - return true; - default: - return false; - } -} - -void QGLPixmapData::fromNativeType(void* pixmap, NativeType type) -{ - if (type == QPixmapData::FbsBitmap) { - CFbsBitmap *bitmap = reinterpret_cast(pixmap); - QSize size(bitmap->SizeInPixels().iWidth, bitmap->SizeInPixels().iHeight); - if (size.width() == w && size.height() == h) - setSerialNumber(++qt_gl_pixmap_serial); - resize(size.width(), size.height()); - m_source = QVolatileImage(bitmap); - if (pixelType() == BitmapType) { - m_source.ensureFormat(QImage::Format_MonoLSB); - } else if (!knownGoodFormat(m_source.format())) { - m_source.beginDataAccess(); - QImage::Format format = idealFormat(m_source.imageRef(), Qt::AutoColor); - m_source.endDataAccess(true); - m_source.ensureFormat(format); - } - m_hasAlpha = m_source.hasAlphaChannel(); - m_hasFillColor = false; - m_dirty = true; - - } else if (type == QPixmapData::VolatileImage && pixmap) { - // Support QS60Style in more efficient skin graphics retrieval. - QVolatileImage *img = static_cast(pixmap); - if (img->width() == w && img->height() == h) - setSerialNumber(++qt_gl_pixmap_serial); - resize(img->width(), img->height()); - m_source = *img; - m_hasAlpha = m_source.hasAlphaChannel(); - m_hasFillColor = false; - m_dirty = true; - } else if (type == QPixmapData::NativeImageHandleProvider && pixmap) { - destroyTexture(); - nativeImageHandleProvider = static_cast(pixmap); - // Cannot defer the retrieval, we need at least the size right away. - createFromNativeImageHandleProvider(); - } -} - -void* QGLPixmapData::toNativeType(NativeType type) -{ - if (type == QPixmapData::FbsBitmap) { - if (m_source.isNull()) - m_source = QVolatileImage(w, h, QImage::Format_ARGB32_Premultiplied); - return m_source.duplicateNativeImage(); - } - return 0; -} - -bool QGLPixmapData::initFromNativeImageHandle(void *handle, const QString &type) -{ - if (type == QLatin1String("RSgImage")) { - fromNativeType(handle, QPixmapData::SgImage); - return true; - } else if (type == QLatin1String("CFbsBitmap")) { - fromNativeType(handle, QPixmapData::FbsBitmap); - return true; - } - return false; -} - -void QGLPixmapData::createFromNativeImageHandleProvider() -{ - void *handle = 0; - QString type; - nativeImageHandleProvider->get(&handle, &type); - if (handle) { - if (initFromNativeImageHandle(handle, type)) { - nativeImageHandle = handle; - nativeImageType = type; - } else { - qWarning("QGLPixmapData: Unknown native image type '%s'", qPrintable(type)); - } - } else { - qWarning("QGLPixmapData: Native handle is null"); - } -} - -void QGLPixmapData::releaseNativeImageHandle() -{ - if (nativeImageHandleProvider && nativeImageHandle) { - nativeImageHandleProvider->release(nativeImageHandle, nativeImageType); - nativeImageHandle = 0; - nativeImageType = QString(); - } -} - QT_END_NAMESPACE diff --git a/src/opengl/qpixmapdata_gl_p.h b/src/opengl/qpixmapdata_gl_p.h index bf1a303..3d22ad1 100644 --- a/src/opengl/qpixmapdata_gl_p.h +++ b/src/opengl/qpixmapdata_gl_p.h @@ -61,6 +61,9 @@ #ifdef Q_OS_SYMBIAN #include "private/qvolatileimage_p.h" +#ifdef QT_SYMBIAN_SUPPORTS_SGIMAGE +# include +#endif #endif QT_BEGIN_NAMESPACE @@ -72,8 +75,7 @@ class QGLPixmapData; #ifdef Q_OS_SYMBIAN class QNativeImageHandleProvider; -#endif - +#else class QGLFramebufferObjectPool { public: @@ -102,7 +104,7 @@ public: private: QGLPixmapData *data; }; - +#endif class Q_OPENGL_EXPORT QGLPixmapData : public QPixmapData { @@ -194,6 +196,9 @@ private: mutable QNativeImageHandleProvider *nativeImageHandleProvider; void *nativeImageHandle; QString nativeImageType; +#ifdef QT_SYMBIAN_SUPPORTS_SGIMAGE + RSgImage *m_sgImage; +#endif #else mutable QImage m_source; #endif @@ -208,9 +213,9 @@ private: mutable bool m_hasFillColor; mutable bool m_hasAlpha; - +#ifndef Q_OS_SYMBIAN mutable QGLPixmapGLPaintDevice m_glDevice; - +#endif friend class QGLPixmapGLPaintDevice; friend class QMeeGoPixmapData; friend class QMeeGoLivePixmapData; diff --git a/src/opengl/qpixmapdata_symbiangl.cpp b/src/opengl/qpixmapdata_symbiangl.cpp index 8c3d61a..372b5ca 100644 --- a/src/opengl/qpixmapdata_symbiangl.cpp +++ b/src/opengl/qpixmapdata_symbiangl.cpp @@ -58,181 +58,61 @@ #include #include +#include + #include "qgltexturepool_p.h" QT_BEGIN_NAMESPACE Q_OPENGL_EXPORT extern QGLWidget* qt_gl_share_widget(); -static inline int areaDiff(const QSize &size, const QGLFramebufferObject *fbo) -{ - return qAbs(size.width() * size.height() - fbo->width() * fbo->height()); -} - -extern int qt_next_power_of_two(int v); - -static inline QSize maybeRoundToNextPowerOfTwo(const QSize &sz) -{ -#ifdef QT_OPENGL_ES_2 - QSize rounded(qt_next_power_of_two(sz.width()), qt_next_power_of_two(sz.height())); - if (rounded.width() * rounded.height() < 1.20 * sz.width() * sz.height()) - return rounded; -#endif - return sz; -} - - -QGLFramebufferObject *QGLFramebufferObjectPool::acquire(const QSize &requestSize, const QGLFramebufferObjectFormat &requestFormat, bool strictSize) +class QGLSgImageTextureCleanup { - QGLFramebufferObject *chosen = 0; - QGLFramebufferObject *candidate = 0; - for (int i = 0; !chosen && i < m_fbos.size(); ++i) { - QGLFramebufferObject *fbo = m_fbos.at(i); +public: + QGLSgImageTextureCleanup() {} - if (strictSize) { - if (fbo->size() == requestSize && fbo->format() == requestFormat) { - chosen = fbo; - break; - } else { - continue; - } - } - - if (fbo->format() == requestFormat) { - // choose the fbo with a matching format and the closest size - if (!candidate || areaDiff(requestSize, candidate) > areaDiff(requestSize, fbo)) - candidate = fbo; - } - - if (candidate) { - m_fbos.removeOne(candidate); - - const QSize fboSize = candidate->size(); - QSize sz = fboSize; - - if (sz.width() < requestSize.width()) - sz.setWidth(qMax(requestSize.width(), qRound(sz.width() * 1.5))); - if (sz.height() < requestSize.height()) - sz.setHeight(qMax(requestSize.height(), qRound(sz.height() * 1.5))); - - // wasting too much space? - if (sz.width() * sz.height() > requestSize.width() * requestSize.height() * 4) - sz = requestSize; - - if (sz != fboSize) { - delete candidate; - candidate = new QGLFramebufferObject(maybeRoundToNextPowerOfTwo(sz), requestFormat); - } - - chosen = candidate; + ~QGLSgImageTextureCleanup() + { + QList keys = m_cache.keys(); + while(keys.size() > 0) { + QGLPixmapData *data = m_cache.take(keys.takeAt(0)); + if (data) + data->destroyTexture(); } } - if (!chosen) { - if (strictSize) - chosen = new QGLFramebufferObject(requestSize, requestFormat); - else - chosen = new QGLFramebufferObject(maybeRoundToNextPowerOfTwo(requestSize), requestFormat); - } + static QGLSgImageTextureCleanup *cleanupForContext(const QGLContext *context); - if (!chosen->isValid()) { - delete chosen; - chosen = 0; + void insert(quint64 key, QGLPixmapData *data) + { + m_cache.insert(key, data); } - return chosen; -} - -void QGLFramebufferObjectPool::release(QGLFramebufferObject *fbo) -{ - if (fbo) - m_fbos << fbo; -} - - -QPaintEngine* QGLPixmapGLPaintDevice::paintEngine() const -{ - return data->paintEngine(); -} - -void QGLPixmapGLPaintDevice::beginPaint() -{ - if (!data->isValid()) - return; - - // QGLPaintDevice::beginPaint will store the current binding and replace - // it with m_thisFBO: - m_thisFBO = data->m_renderFbo->handle(); - QGLPaintDevice::beginPaint(); - - Q_ASSERT(data->paintEngine()->type() == QPaintEngine::OpenGL2); - - // QPixmap::fill() is deferred until now, where we actually need to do the fill: - if (data->needsFill()) { - const QColor &c = data->fillColor(); - float alpha = c.alphaF(); - glDisable(GL_SCISSOR_TEST); - glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha); - glClear(GL_COLOR_BUFFER_BIT); + void remove(quint64 key) + { + m_cache.take(key); } - else if (!data->isUninitialized()) { - // If the pixmap (GL Texture) has valid content (it has been - // uploaded from an image or rendered into before), we need to - // copy it from the texture to the render FBO. - - glDisable(GL_DEPTH_TEST); - glDisable(GL_SCISSOR_TEST); - glDisable(GL_BLEND); - -#if !defined(QT_OPENGL_ES_2) - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, data->width(), data->height(), 0, -999999, 999999); -#endif - - glViewport(0, 0, data->width(), data->height()); - - // Pass false to bind so it doesn't copy the FBO into the texture! - context()->drawTexture(QRect(0, 0, data->width(), data->height()), data->bind(false)); - } -} - -void QGLPixmapGLPaintDevice::endPaint() -{ - if (!data->isValid()) - return; - data->copyBackFromRenderFbo(false); +private: - // Base's endPaint will restore the previous FBO binding - QGLPaintDevice::endPaint(); - - qgl_fbo_pool()->release(data->m_renderFbo); - data->m_renderFbo = 0; -} + QCache m_cache; +}; -QGLContext* QGLPixmapGLPaintDevice::context() const +static void qt_sgimage_texture_cleanup_free(void *data) { - data->ensureCreated(); - return data->m_ctx; + delete reinterpret_cast(data); } -QSize QGLPixmapGLPaintDevice::size() const -{ - return data->size(); -} +Q_GLOBAL_STATIC_WITH_ARGS(QGLContextResource, qt_sgimage_texture_cleanup, (qt_sgimage_texture_cleanup_free)) -bool QGLPixmapGLPaintDevice::alphaRequested() const +QGLSgImageTextureCleanup *QGLSgImageTextureCleanup::cleanupForContext(const QGLContext *context) { - return data->m_hasAlpha; -} - -void QGLPixmapGLPaintDevice::setPixmapData(QGLPixmapData* d) -{ - data = d; + QGLSgImageTextureCleanup *p = reinterpret_cast(qt_sgimage_texture_cleanup()->value(context)); + if (!p) { + QGLShareContextScope scope(context); + qt_sgimage_texture_cleanup()->insert(context, p = new QGLSgImageTextureCleanup); + } + return p; } int qt_gl_pixmap_serial = 0; @@ -244,16 +124,28 @@ QGLPixmapData::QGLPixmapData(PixelType type) , m_ctx(0) , nativeImageHandleProvider(0) , nativeImageHandle(0) +#ifdef QT_SYMBIAN_SUPPORTS_SGIMAGE + , m_sgImage(0) +#endif , m_dirty(false) , m_hasFillColor(false) , m_hasAlpha(false) { setSerialNumber(++qt_gl_pixmap_serial); - m_glDevice.setPixmapData(this); } QGLPixmapData::~QGLPixmapData() { + if (m_sgImage) { + if (m_texture.id) { + QGLSgImageTextureCleanup::cleanupForContext(m_ctx)->remove(m_texture.id); + destroyTexture(); + } + + m_sgImage->Close(); + delete m_sgImage; + m_sgImage = 0; + } delete m_engine; } @@ -275,6 +167,16 @@ bool QGLPixmapData::isValidContext(const QGLContext *ctx) const // That's why if source pixels are valid we return false // to simulate raster pixmaps. Only QPixmaps created from // SgImage will enable usage of QGLPixmapData. +#ifdef QT_SYMBIAN_SUPPORTS_SGIMAGE + if (m_sgImage) { + // SgImage texture + if (ctx == m_ctx) + return true; + + const QGLContext *share_ctx = qt_gl_share_widget()->context(); + return ctx == share_ctx || QGLContext::areSharing(ctx, share_ctx); + } +#endif return false; } @@ -313,72 +215,45 @@ void QGLPixmapData::ensureCreated() const QGLShareContextScope ctx(qt_gl_share_widget()->context()); m_ctx = ctx; - const GLenum internal_format = m_hasAlpha ? GL_RGBA : GL_RGB; -#ifdef QT_OPENGL_ES_2 - const GLenum external_format = internal_format; -#else - const GLenum external_format = qt_gl_preferredTextureFormat(); -#endif - const GLenum target = GL_TEXTURE_2D; - - GLenum type = GL_UNSIGNED_BYTE; - // Avoid conversion when pixmap is created from CFbsBitmap of EColor64K. - if (!m_source.isNull() && m_source.format() == QImage::Format_RGB16) - type = GL_UNSIGNED_SHORT_5_6_5; - - if (!m_texture.id) { - m_texture.id = QGLTexturePool::instance()->createTexture( - target, - 0, internal_format, - w, h, - external_format, - type, - &m_texture); - if (!m_texture.id) { - m_texture.failedToAlloc = true; - return; - } - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); +#ifdef QT_SYMBIAN_SUPPORTS_SGIMAGE + if (m_sgImage) { + qt_resolve_eglimage_gl_extensions(ctx); // ensure initialized - m_texture.inTexturePool = true; - } else if (m_texture.inTexturePool) { - glBindTexture(target, m_texture.id); - QGLTexturePool::instance()->useTexture(&m_texture); - } + bool textureIsBound = false; + GLuint newTextureId; - if (!m_source.isNull() && m_texture.id) { - if (external_format == GL_RGB) { - m_source.beginDataAccess(); - QImage tx; - if (type == GL_UNSIGNED_BYTE) - tx = m_source.imageRef().convertToFormat(QImage::Format_RGB888).mirrored(false, true); - else if (type == GL_UNSIGNED_SHORT_5_6_5) - tx = m_source.imageRef().mirrored(false, true); - m_source.endDataAccess(true); + EGLint imgAttr[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE }; + EGLImageKHR image = QEgl::eglCreateImageKHR(QEgl::display() + , EGL_NO_CONTEXT + , EGL_NATIVE_PIXMAP_KHR + , (EGLClientBuffer)m_sgImage + , imgAttr); - glBindTexture(target, m_texture.id); - if (!tx.isNull()) - glTexSubImage2D(target, 0, 0, 0, w, h, external_format, - type, tx.constBits()); - else - qWarning("QGLPixmapData: Failed to create GL_RGB image of size %dx%d", w, h); - } else { - // do byte swizzling ARGB -> RGBA - m_source.beginDataAccess(); - const QImage tx = ctx->d_func()->convertToGLFormat(m_source.imageRef(), true, external_format); - m_source.endDataAccess(true); - glBindTexture(target, m_texture.id); - if (!tx.isNull()) - glTexSubImage2D(target, 0, 0, 0, w, h, external_format, - type, tx.constBits()); - else - qWarning("QGLPixmapData: Failed to create GL_RGBA image of size %dx%d", w, h); + glGenTextures(1, &newTextureId); + glBindTexture( GL_TEXTURE_2D, newTextureId); + + if (image != EGL_NO_IMAGE_KHR) { + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); + GLint err = glGetError(); + if (err == GL_NO_ERROR) + textureIsBound = true; + + QEgl::eglDestroyImageKHR(QEgl::display(), image); } - if (useFramebufferObjects()) - m_source = QVolatileImage(); + if (textureIsBound) { + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + m_texture.id = newTextureId; + m_texture.boundPixmap = const_cast(this); + QGLSgImageTextureCleanup::cleanupForContext(m_ctx)->insert(m_texture.id, const_cast(this)); + } else { + qWarning("QGLPixmapData: Failed to create texture from a SgImage image of size %dx%d", w, h); + glDeleteTextures(1, &newTextureId); + } } +#endif } @@ -538,42 +413,7 @@ bool QGLPixmapData::scroll(int dx, int dy, const QRect &rect) void QGLPixmapData::copy(const QPixmapData *data, const QRect &rect) { - if (data->classId() != QPixmapData::OpenGLClass || !static_cast(data)->useFramebufferObjects()) { - QPixmapData::copy(data, rect); - return; - } - - const QGLPixmapData *other = static_cast(data); - if (other->m_renderFbo) { - QGLShareContextScope ctx(qt_gl_share_widget()->context()); - - resize(rect.width(), rect.height()); - m_hasAlpha = other->m_hasAlpha; - ensureCreated(); - - if (!ctx->d_ptr->fbo) - glGenFramebuffers(1, &ctx->d_ptr->fbo); - - glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, ctx->d_ptr->fbo); - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, - GL_TEXTURE_2D, m_texture.id, 0); - - if (!other->m_renderFbo->isBound()) - glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, other->m_renderFbo->handle()); - - glDisable(GL_SCISSOR_TEST); - if (ctx->d_ptr->active_engine && ctx->d_ptr->active_engine->type() == QPaintEngine::OpenGL2) - static_cast(ctx->d_ptr->active_engine)->invalidateState(); - - glBlitFramebufferEXT(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height(), - 0, 0, w, h, - GL_COLOR_BUFFER_BIT, - GL_NEAREST); - - glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo); - } else { - QPixmapData::copy(data, rect); - } + QPixmapData::copy(data, rect); } void QGLPixmapData::fill(const QColor &color) @@ -590,11 +430,6 @@ void QGLPixmapData::fill(const QColor &color) m_hasAlpha = color.alpha() != 255; } - if (useFramebufferObjects()) { - m_source = QVolatileImage(); - m_hasFillColor = true; - m_fillColor = color; - } else { forceToImage(); if (m_source.depth() == 32) { @@ -605,7 +440,6 @@ void QGLPixmapData::fill(const QColor &color) m_source.fill(1); else m_source.fill(0); - } } } @@ -645,9 +479,7 @@ QImage QGLPixmapData::toImage() const if (!isValid()) return QImage(); - if (m_renderFbo) { - copyBackFromRenderFbo(true); - } else if (!m_source.isNull()) { + if (!m_source.isNull()) { // QVolatileImage::toImage() will make a copy always so no check // for active painting is needed. QImage img = m_source.toImage(); @@ -668,58 +500,9 @@ QImage QGLPixmapData::toImage() const return qt_gl_read_texture(QSize(w, h), true, true); } -struct TextureBuffer -{ - QGLFramebufferObject *fbo; - QGL2PaintEngineEx *engine; -}; - -Q_GLOBAL_STATIC(QGLFramebufferObjectPool, _qgl_fbo_pool) -QGLFramebufferObjectPool* qgl_fbo_pool() -{ - return _qgl_fbo_pool(); -} - void QGLPixmapData::copyBackFromRenderFbo(bool keepCurrentFboBound) const { - if (!isValid()) - return; - - m_hasFillColor = false; - - const QGLContext *share_ctx = qt_gl_share_widget()->context(); - QGLShareContextScope ctx(share_ctx); - - ensureCreated(); - - if (!ctx->d_ptr->fbo) - glGenFramebuffers(1, &ctx->d_ptr->fbo); - - glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, ctx->d_ptr->fbo); - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, - GL_TEXTURE_2D, m_texture.id, 0); - - const int x0 = 0; - const int x1 = w; - const int y0 = 0; - const int y1 = h; - - if (!m_renderFbo->isBound()) - glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, m_renderFbo->handle()); - - glDisable(GL_SCISSOR_TEST); - - glBlitFramebufferEXT(x0, y0, x1, y1, - x0, y0, x1, y1, - GL_COLOR_BUFFER_BIT, - GL_NEAREST); - - if (keepCurrentFboBound) { - glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo); - } else { - glBindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, m_renderFbo->handle()); - ctx->d_ptr->current_fbo = m_renderFbo->handle(); - } + // We don't use FBOs on Symbian } bool QGLPixmapData::useFramebufferObjects() const @@ -733,32 +516,6 @@ QPaintEngine* QGLPixmapData::paintEngine() const if (!isValid()) return 0; - if (m_renderFbo) - return m_engine; - - if (useFramebufferObjects()) { - extern QGLWidget* qt_gl_share_widget(); - - if (!QGLContext::currentContext()) - qt_gl_share_widget()->makeCurrent(); - QGLShareContextScope ctx(qt_gl_share_widget()->context()); - - QGLFramebufferObjectFormat format; - format.setAttachment(QGLFramebufferObject::CombinedDepthStencil); - format.setSamples(4); - format.setInternalTextureFormat(GLenum(m_hasAlpha ? GL_RGBA : GL_RGB)); - - m_renderFbo = qgl_fbo_pool()->acquire(size(), format); - - if (m_renderFbo) { - if (!m_engine) - m_engine = new QGL2PaintEngineEx; - return m_engine; - } - - qWarning() << "Failed to create pixmap texture buffer of size " << size() << ", falling back to raster paint engine"; - } - // If the application wants to paint into the QPixmap, we first // force it to QImage format and then paint into that. // This is simpler than juggling multiple GL contexts. @@ -773,25 +530,16 @@ QPaintEngine* QGLPixmapData::paintEngine() const extern QRgb qt_gl_convertToGLFormat(QRgb src_pixel, GLenum texture_format); -// If copyBack is true, bind will copy the contents of the render -// FBO to the texture (which is not bound to the texture, as it's -// a multisample FBO). GLuint QGLPixmapData::bind(bool copyBack) const { - if (m_renderFbo && copyBack) { - copyBackFromRenderFbo(true); - } else { - ensureCreated(); - } + ensureCreated(); GLuint id = m_texture.id; glBindTexture(GL_TEXTURE_2D, id); if (m_hasFillColor) { - if (!useFramebufferObjects()) { m_source = QVolatileImage(w, h, QImage::Format_ARGB32_Premultiplied); m_source.fill(PREMUL(m_fillColor.rgba())); - } m_hasFillColor = false; @@ -860,7 +608,21 @@ void QGLPixmapData::forceToImage() void QGLPixmapData::destroyTexture() { - // Destroy SgImage texture + if (m_texture.id) { + QGLWidget *shareWidget = qt_gl_share_widget(); + if (shareWidget) { + m_texture.options |= QGLContext::MemoryManagedBindOption; + m_texture.freeTexture(); + m_texture.options &= ~QGLContext::MemoryManagedBindOption; + } else if(QGLContext::currentContext()) { + glDeleteTextures(1, &m_texture.id); + m_texture.id = 0; + m_texture.boundPixmap = 0; + m_texture.boundKey = 0; + } + m_ctx = 0; + m_dirty = true; + } } void QGLPixmapData::detachTextureFromPool() @@ -885,7 +647,180 @@ void QGLPixmapData::reclaimTexture() QGLPaintDevice *QGLPixmapData::glDevice() const { - return &m_glDevice; + return 0; +} + +static inline bool knownGoodFormat(QImage::Format format) +{ + switch (format) { + case QImage::Format_RGB16: // EColor64K + case QImage::Format_RGB32: // EColor16MU + case QImage::Format_ARGB32_Premultiplied: // EColor16MAP + return true; + default: + return false; + } +} + +static inline int symbianPixeFormatBitsPerPixel(TUidPixelFormat pixelFormat) +{ + switch (pixelFormat) { + case EUidPixelFormatP_1: + case EUidPixelFormatL_1: + return 1; + case EUidPixelFormatP_2: + case EUidPixelFormatL_2: + return 2; + case EUidPixelFormatP_4: + case EUidPixelFormatL_4: + return 4; + case EUidPixelFormatRGB_332: + case EUidPixelFormatA_8: + case EUidPixelFormatBGR_332: + case EUidPixelFormatP_8: + case EUidPixelFormatL_8: + return 8; + case EUidPixelFormatRGB_565: + case EUidPixelFormatBGR_565: + case EUidPixelFormatARGB_1555: + case EUidPixelFormatXRGB_1555: + case EUidPixelFormatARGB_4444: + case EUidPixelFormatARGB_8332: + case EUidPixelFormatBGRX_5551: + case EUidPixelFormatBGRA_5551: + case EUidPixelFormatBGRA_4444: + case EUidPixelFormatBGRX_4444: + case EUidPixelFormatAP_88: + case EUidPixelFormatXRGB_4444: + case EUidPixelFormatXBGR_4444: + return 16; + case EUidPixelFormatBGR_888: + case EUidPixelFormatRGB_888: + return 24; + case EUidPixelFormatXRGB_8888: + case EUidPixelFormatBGRX_8888: + case EUidPixelFormatXBGR_8888: + case EUidPixelFormatBGRA_8888: + case EUidPixelFormatARGB_8888: + case EUidPixelFormatABGR_8888: + case EUidPixelFormatARGB_8888_PRE: + case EUidPixelFormatABGR_8888_PRE: + case EUidPixelFormatBGRA_8888_PRE: + case EUidPixelFormatARGB_2101010: + case EUidPixelFormatABGR_2101010: + return 32; + default: + return 32; + }; +} + +void QGLPixmapData::fromNativeType(void* pixmap, NativeType type) +{ + if (type == QPixmapData::SgImage && pixmap) { +#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL) + RSgImage *sgImage = reinterpret_cast(pixmap); + + m_sgImage = new RSgImage; + m_sgImage->Open(sgImage->Id()); + + TSgImageInfo info; + sgImage->GetInfo(info); + + w = info.iSizeInPixels.iWidth; + h = info.iSizeInPixels.iHeight; + d = symbianPixeFormatBitsPerPixel((TUidPixelFormat)info.iPixelFormat); + + m_source = QVolatileImage(); + m_hasAlpha = true; + m_hasFillColor = false; + m_dirty = true; + is_null = (w <= 0 || h <= 0); +#endif + } else if (type == QPixmapData::FbsBitmap && pixmap) { + CFbsBitmap *bitmap = reinterpret_cast(pixmap); + QSize size(bitmap->SizeInPixels().iWidth, bitmap->SizeInPixels().iHeight); + if (size.width() == w && size.height() == h) + setSerialNumber(++qt_gl_pixmap_serial); + resize(size.width(), size.height()); + m_source = QVolatileImage(bitmap); + if (pixelType() == BitmapType) { + m_source.ensureFormat(QImage::Format_MonoLSB); + } else if (!knownGoodFormat(m_source.format())) { + m_source.beginDataAccess(); + QImage::Format format = idealFormat(m_source.imageRef(), Qt::AutoColor); + m_source.endDataAccess(true); + m_source.ensureFormat(format); + } + m_hasAlpha = m_source.hasAlphaChannel(); + m_hasFillColor = false; + m_dirty = true; + d = m_source.depth(); + } else if (type == QPixmapData::VolatileImage && pixmap) { + // Support QS60Style in more efficient skin graphics retrieval. + QVolatileImage *img = static_cast(pixmap); + if (img->width() == w && img->height() == h) + setSerialNumber(++qt_gl_pixmap_serial); + resize(img->width(), img->height()); + m_source = *img; + m_hasAlpha = m_source.hasAlphaChannel(); + m_hasFillColor = false; + m_dirty = true; + d = m_source.depth(); + } else if (type == QPixmapData::NativeImageHandleProvider && pixmap) { + destroyTexture(); + nativeImageHandleProvider = static_cast(pixmap); + // Cannot defer the retrieval, we need at least the size right away. + createFromNativeImageHandleProvider(); + } +} + +void* QGLPixmapData::toNativeType(NativeType type) +{ + if (type == QPixmapData::FbsBitmap) { + if (m_source.isNull()) + m_source = QVolatileImage(w, h, QImage::Format_ARGB32_Premultiplied); + return m_source.duplicateNativeImage(); + } + + return 0; +} + +bool QGLPixmapData::initFromNativeImageHandle(void *handle, const QString &type) +{ + if (type == QLatin1String("RSgImage")) { + fromNativeType(handle, QPixmapData::SgImage); + return true; + } else if (type == QLatin1String("CFbsBitmap")) { + fromNativeType(handle, QPixmapData::FbsBitmap); + return true; + } + return false; +} + +void QGLPixmapData::createFromNativeImageHandleProvider() +{ + void *handle = 0; + QString type; + nativeImageHandleProvider->get(&handle, &type); + if (handle) { + if (initFromNativeImageHandle(handle, type)) { + nativeImageHandle = handle; + nativeImageType = type; + } else { + qWarning("QGLPixmapData: Unknown native image type '%s'", qPrintable(type)); + } + } else { + qWarning("QGLPixmapData: Native handle is null"); + } +} + +void QGLPixmapData::releaseNativeImageHandle() +{ + if (nativeImageHandleProvider && nativeImageHandle) { + nativeImageHandleProvider->release(nativeImageHandle, nativeImageType); + nativeImageHandle = 0; + nativeImageType = QString(); + } } QT_END_NAMESPACE diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 17b2044..b48fe2c 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -184,7 +184,7 @@ QGLGraphicsSystem::QGLGraphicsSystem(bool useX11GL) class QGLGlobalShareWidget { public: - QGLGlobalShareWidget() : refCount(0), widget(0), initializing(false) {} + QGLGlobalShareWidget() : widget(0), initializing(false) {} QGLWidget *shareWidget() { if (!initializing && !widget && !cleanedUp) { @@ -223,7 +223,6 @@ public: } static bool cleanedUp; - int refCount; private: QGLWidget *widget; @@ -354,14 +353,10 @@ QGLWindowSurface::~QGLWindowSurface() if (QGLGlobalShareWidget::cleanedUp) return; - --(_qt_gl_share_widget()->refCount); - #ifdef Q_OS_SYMBIAN - if (_qt_gl_share_widget()->refCount <= 0) { // Destroy the context if necessary. if (!qt_gl_share_widget()->context()->isSharing()) qt_destroy_gl_share_widget(); - } #endif } @@ -410,9 +405,6 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) ctx->create(qt_gl_share_widget()->context()); - if (widget != qt_gl_share_widget()) - ++(_qt_gl_share_widget()->refCount); - #ifndef QT_NO_EGL static bool checkedForNOKSwapRegion = false; static bool haveNOKSwapRegion = false; @@ -719,6 +711,7 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, 0); } else { +#ifndef Q_OS_SYMBIAN // We don't have FBO pool on Symbian // can't do sub-region blits with multisample FBOs QGLFramebufferObject *temp = qgl_fbo_pool()->acquire(d_ptr->fbo->size(), QGLFramebufferObjectFormat()); @@ -741,6 +734,7 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, 0); qgl_fbo_pool()->release(temp); +#endif // Q_OS_SYMBIAN } ctx->d_ptr->current_fbo = 0; @@ -823,18 +817,43 @@ void QGLWindowSurface::updateGeometry() { if (wd->extraData() && wd->extraData()->glContext) { #ifdef Q_OS_SYMBIAN // Symbian needs to recreate the context when native window size changes if (d_ptr->size != geometry().size()) { - if (window() != qt_gl_share_widget()) - --(_qt_gl_share_widget()->refCount); + QGLContext *ctx = reinterpret_cast(wd->extraData()->glContext); + + if (ctx == QGLContext::currentContext()) + ctx->doneCurrent(); - delete wd->extraData()->glContext; - wd->extraData()->glContext = 0; - d_ptr->ctx = 0; + ctx->d_func()->destroyEglSurfaceForDevice(); + + // Delete other contexts (shouldn't happen too often, if at all) + while (d_ptr->contexts.size()) { + QGLContext **ctxPtrPtr = d_ptr->contexts.takeFirst(); + if ((*ctxPtrPtr) != ctx) + delete *ctxPtrPtr; + } + union { QGLContext **ctxPtrPtr; void **voidPtrPtr; }; + voidPtrPtr = &wd->extraData()->glContext; + d_ptr->contexts << ctxPtrPtr; + + ctx->d_func()->eglSurface = ctx->d_func()->eglContext->createSurface(window()); + + // Partial update supported has been decided already in previous hijackWindow call. + // Reset swap behaviour based on that flag. + if (hasPartialUpdateSupport()) { + eglSurfaceAttrib(QEgl::display(), ctx->d_func()->eglSurfaceForDevice(), + EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); + + if (eglGetError() != EGL_SUCCESS) + qWarning("QGLWindowSurface::updateGeometry() - could not re-enable preserved swap behaviour"); + } else { + eglSurfaceAttrib(QEgl::display(), ctx->d_func()->eglSurfaceForDevice(), + EGL_SWAP_BEHAVIOR, EGL_BUFFER_DESTROYED); + + if (eglGetError() != EGL_SUCCESS) + qWarning("QGLWindowSurface::updateGeometry() - could not re-enable destroyed swap behaviour"); + } } - else #endif - { - hijack = false; // we already have gl context for widget - } + hijack = false; // we already have gl context for widget } if (hijack) -- cgit v0.12 From 7168aebb1b452b6f22a35be5ae31ccdc3e3e23df Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 30 Jun 2011 15:16:10 +0300 Subject: Do not try to open VKB if it is already open in Symbian If QEvent::RequestSoftwareInputPanel was handled when there was already an active virtual keyboard that had a child dialog open such as symbol or writing language selection dialog, the VKB would be brought to foreground on top of the child dialog, causing several problems, such as options menu and letter keys no longer working in VKB. Fixed by checking if VKB is already open before opening it again. Task-number: QT-5133 Reviewed-by: Sami Merila --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 59 +++++++++++++++++-------- 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index aa87955..602c734 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -54,6 +54,7 @@ #include #include +#include #include // You only find these enumerations on SDK 5 onwards, so we need to provide our own @@ -72,6 +73,10 @@ // EAknEditorFlagEnablePartialScreen is only valid from Sym^3 onwards. #define QT_EAknEditorFlagEnablePartialScreen 0x200000 +// Properties to detect VKB status from AknFepInternalPSKeys.h +#define QT_EPSUidAknFep 0x100056de +#define QT_EAknFepTouchInputActive 0x00000004 + QT_BEGIN_NAMESPACE Q_GUI_EXPORT void qt_s60_setPartialScreenInputMode(bool enable) @@ -307,28 +312,46 @@ bool QCoeFepInputContext::filterEvent(const QEvent *event) return false; if (event->type() == QEvent::RequestSoftwareInputPanel) { - // Notify S60 that we want the virtual keyboard to show up. - QSymbianControl *sControl; - sControl = focusWidget()->effectiveWinId()->MopGetObject(sControl); - Q_ASSERT(sControl); - - // The FEP UI temporarily steals focus when it shows up the first time, causing - // all sorts of weird effects on the focused widgets. Since it will immediately give - // back focus to us, we temporarily disable focus handling until the job's done. - if (sControl) { - sControl->setIgnoreFocusChanged(true); + // Only request virtual keyboard if it is not yet active or if this is the first time + // panel is requested for this application. + static bool firstTime = true; + int vkbActive = 0; + + if (firstTime) { + // Sometimes the global QT_EAknFepTouchInputActive value can be left incorrect at + // application exit if the application is exited when input panel is active. + // Therefore we always want to open the panel the first time application requests it. + firstTime = false; + } else { + const TUid KPSUidAknFep = {QT_EPSUidAknFep}; + // No need to check for return value, as vkbActive stays zero in that case + RProperty::Get(KPSUidAknFep, QT_EAknFepTouchInputActive, vkbActive); } - ensureInputCapabilitiesChanged(); - m_fepState->ReportAknEdStateEventL(MAknEdStateObserver::QT_EAknActivatePenInputRequest); + if (!vkbActive) { + // Notify S60 that we want the virtual keyboard to show up. + QSymbianControl *sControl; + sControl = focusWidget()->effectiveWinId()->MopGetObject(sControl); + Q_ASSERT(sControl); + + // The FEP UI temporarily steals focus when it shows up the first time, causing + // all sorts of weird effects on the focused widgets. Since it will immediately give + // back focus to us, we temporarily disable focus handling until the job's done. + if (sControl) { + sControl->setIgnoreFocusChanged(true); + } + + ensureInputCapabilitiesChanged(); + m_fepState->ReportAknEdStateEventL(MAknEdStateObserver::QT_EAknActivatePenInputRequest); - if (sControl) { - sControl->setIgnoreFocusChanged(false); + if (sControl) { + sControl->setIgnoreFocusChanged(false); + } + //If m_pointerHandler has already been set, it means that fep inline editing is in progress. + //When this is happening, do not filter out pointer events. + if (!m_pointerHandler) + return true; } - //If m_pointerHandler has already been set, it means that fep inline editing is in progress. - //When this is happening, do not filter out pointer events. - if (!m_pointerHandler) - return true; } return false; -- cgit v0.12 From 1614f30732ff417a8dc7ea89fcfb4a724ece6109 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 30 Jun 2011 17:31:07 +0300 Subject: The qmlshadersplugin deployment must be scoped same as its building The check "contains(QT_CONFIG, opengl)" is used to include shaders subdir, so the same check needs to be used when defining deployment for shaders in s60installs.pro Task-number: QTBUG-20192 Reviewed-by: TrustMe --- src/s60installs/s60installs.pro | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index 573e585..9a34227 100755 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -150,19 +150,23 @@ symbian: { folderlistmodelImport.sources = $$QT_BUILD_TREE/imports/Qt/labs/folderlistmodel/qmlfolderlistmodelplugin$${QT_LIBINFIX}.dll gesturesImport.sources = $$QT_BUILD_TREE/imports/Qt/labs/gestures/qmlgesturesplugin$${QT_LIBINFIX}.dll particlesImport.sources = $$QT_BUILD_TREE/imports/Qt/labs/particles/qmlparticlesplugin$${QT_LIBINFIX}.dll - shadersImport.sources = $$QT_BUILD_TREE/imports/Qt/labs/shaders/qmlshadersplugin$${QT_LIBINFIX}.dll folderlistmodelImport.sources += $$QT_SOURCE_TREE/src/imports/folderlistmodel/qmldir gesturesImport.sources += $$QT_SOURCE_TREE/src/imports/gestures/qmldir particlesImport.sources += $$QT_SOURCE_TREE/src/imports/particles/qmldir - shadersImport.sources += $$QT_SOURCE_TREE/src/imports/shaders/qmldir folderlistmodelImport.path = c:$$QT_IMPORTS_BASE_DIR/Qt/labs/folderlistmodel gesturesImport.path = c:$$QT_IMPORTS_BASE_DIR/Qt/labs/gestures particlesImport.path = c:$$QT_IMPORTS_BASE_DIR/Qt/labs/particles - shadersImport.path = c:$$QT_IMPORTS_BASE_DIR/Qt/labs/shaders - DEPLOYMENT += folderlistmodelImport gesturesImport particlesImport shadersImport + DEPLOYMENT += folderlistmodelImport gesturesImport particlesImport + + contains(QT_CONFIG, opengl) { + shadersImport.sources = $$QT_BUILD_TREE/imports/Qt/labs/shaders/qmlshadersplugin$${QT_LIBINFIX}.dll \ + $$QT_SOURCE_TREE/src/imports/shaders/qmldir + shadersImport.path = c:$$QT_IMPORTS_BASE_DIR/Qt/labs/shaders + DEPLOYMENT += shadersImport + } } graphicssystems_plugins.path = c:$$QT_PLUGINS_BASE_DIR/graphicssystems -- cgit v0.12 From f8b3ea2988bb57e67d38cfc00d2fbfb950564421 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Thu, 30 Jun 2011 20:24:38 +0200 Subject: Doc: Updated documentation with \since 4.8 declarations. --- src/corelib/io/qfile.cpp | 2 ++ src/corelib/tools/qlocale.qdoc | 1 + src/corelib/tools/qpoint.cpp | 9 +++++++++ src/corelib/tools/qset.qdoc | 1 + src/corelib/tools/qstring.cpp | 3 +++ src/corelib/xml/qxmlstream.cpp | 5 ++++- src/gui/graphicsview/qgraphicsgridlayout.cpp | 2 ++ src/gui/itemviews/qabstractproxymodel.cpp | 9 +++++++++ src/gui/kernel/qgenericplugin_qpa.cpp | 1 + src/gui/kernel/qgenericpluginfactory_qpa.cpp | 1 + src/gui/kernel/qplatformcursor_qpa.cpp | 2 ++ src/gui/kernel/qplatformwindowformat_qpa.cpp | 8 ++++++-- src/gui/kernel/qsizepolicy.qdoc | 2 ++ src/gui/kernel/qwidget_qpa.cpp | 6 ++++++ src/gui/painting/qprinterinfo.cpp | 4 ++++ src/gui/text/qfontmetrics.cpp | 3 +++ src/gui/text/qplatformfontdatabase_qpa.cpp | 2 ++ src/gui/text/qtextcursor.cpp | 1 + src/gui/text/qtextlayout.cpp | 16 ++++++++++++---- src/gui/widgets/qcheckbox.cpp | 1 + src/gui/widgets/qlineedit.cpp | 4 ++++ src/gui/widgets/qradiobutton.cpp | 1 + src/gui/widgets/qtabwidget.cpp | 1 + src/network/bearer/qnetworkconfigmanager.cpp | 1 + src/network/kernel/qnetworkproxy.cpp | 8 ++++++++ src/opengl/qgl_qpa.cpp | 6 ++++++ tools/assistant/lib/qhelpsearchquerywidget.cpp | 6 ++++++ 27 files changed, 99 insertions(+), 7 deletions(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 66edf58..929b2f9 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -358,6 +358,7 @@ QFilePrivate::setError(QFile::FileError err, int errNum) /*! \enum QFile::FileHandleFlag + \since 4.8 This enum is used when opening a file to specify additional options which only apply to files and not to a generic @@ -1657,6 +1658,7 @@ bool QFile::atEnd() const /*! \fn bool QFile::seek(qint64 pos) + \since 4.8 For random-access devices, this function sets the current position to \a pos, returning true on success, or false if an error occurred. diff --git a/src/corelib/tools/qlocale.qdoc b/src/corelib/tools/qlocale.qdoc index fd139c3..5d4f305 100644 --- a/src/corelib/tools/qlocale.qdoc +++ b/src/corelib/tools/qlocale.qdoc @@ -608,6 +608,7 @@ /*! \enum QLocale::Script + \since 4.8 This enumerated type is used to specify a script. diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp index bd32fe7..ae6ed71 100644 --- a/src/corelib/tools/qpoint.cpp +++ b/src/corelib/tools/qpoint.cpp @@ -188,6 +188,7 @@ QT_BEGIN_NAMESPACE /*! \fn QPoint &QPoint::operator*=(float factor) + \since 4.8 Multiplies this point's coordinates by the given \a factor, and returns a reference to this point. @@ -200,6 +201,7 @@ QT_BEGIN_NAMESPACE /*! \fn QPoint &QPoint::operator*=(double factor) + \since 4.8 Multiplies this point's coordinates by the given \a factor, and returns a reference to this point. For example: @@ -214,6 +216,7 @@ QT_BEGIN_NAMESPACE /*! \fn QPoint &QPoint::operator*=(int factor) + \since 4.8 Multiplies this point's coordinates by the given \a factor, and returns a reference to this point. @@ -259,6 +262,7 @@ QT_BEGIN_NAMESPACE /*! \fn const QPoint operator*(const QPoint &point, float factor) \relates QPoint + \since 4.8 Returns a copy of the given \a point multiplied by the given \a factor. @@ -271,6 +275,7 @@ QT_BEGIN_NAMESPACE /*! \fn const QPoint operator*(const QPoint &point, double factor) \relates QPoint + \since 4.8 Returns a copy of the given \a point multiplied by the given \a factor. @@ -283,6 +288,7 @@ QT_BEGIN_NAMESPACE /*! \fn const QPoint operator*(const QPoint &point, int factor) \relates QPoint + \since 4.8 Returns a copy of the given \a point multiplied by the given \a factor. @@ -293,6 +299,7 @@ QT_BEGIN_NAMESPACE \fn const QPoint operator*(float factor, const QPoint &point) \overload \relates QPoint + \since 4.8 Returns a copy of the given \a point multiplied by the given \a factor. */ @@ -301,6 +308,7 @@ QT_BEGIN_NAMESPACE \fn const QPoint operator*(double factor, const QPoint &point) \overload \relates QPoint + \since 4.8 Returns a copy of the given \a point multiplied by the given \a factor. */ @@ -309,6 +317,7 @@ QT_BEGIN_NAMESPACE \fn const QPoint operator*(int factor, const QPoint &point) \overload \relates QPoint + \since 4.8 Returns a copy of the given \a point multiplied by the given \a factor. */ diff --git a/src/corelib/tools/qset.qdoc b/src/corelib/tools/qset.qdoc index f562c68..31129e0 100644 --- a/src/corelib/tools/qset.qdoc +++ b/src/corelib/tools/qset.qdoc @@ -124,6 +124,7 @@ /*! \fn void QSet::swap(QSet &other) + \since 4.8 Swaps set \a other with this set. This operation is very fast and never fails. diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index ee45cfd..791bfff 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -839,18 +839,21 @@ int QString::grow(int size) /*! \typedef QString::const_reference + \since 4.8 The QString::const_reference typedef provides an STL-style const reference for QString. */ /*! \typedef QString::reference + \since 4.8 The QString::const_reference typedef provides an STL-style reference for QString. */ /*! \typedef QString::value_type + \since 4.8 The QString::const_reference typedef provides an STL-style value type for QString. diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp index caaffd3..9682688 100644 --- a/src/corelib/xml/qxmlstream.cpp +++ b/src/corelib/xml/qxmlstream.cpp @@ -3381,7 +3381,10 @@ int QXmlStreamWriter::autoFormattingIndent() const } /*! - Returns \c true if the stream failed to write to the underlying device. + \since 4.8 + + Returns true if the stream failed to write to the underlying device; + otherwise returns false. The error status is never reset. Writes happening after the error occurred are ignored, even if the error condition is cleared. diff --git a/src/gui/graphicsview/qgraphicsgridlayout.cpp b/src/gui/graphicsview/qgraphicsgridlayout.cpp index 2fbfc5d..fb4bd32 100644 --- a/src/gui/graphicsview/qgraphicsgridlayout.cpp +++ b/src/gui/graphicsview/qgraphicsgridlayout.cpp @@ -600,6 +600,8 @@ void QGraphicsGridLayout::removeAt(int index) } /*! + \since 4.8 + Removes the layout item \a item without destroying it. Ownership of the item is transferred to the caller. diff --git a/src/gui/itemviews/qabstractproxymodel.cpp b/src/gui/itemviews/qabstractproxymodel.cpp index 48c84ac..f00b7ee 100644 --- a/src/gui/itemviews/qabstractproxymodel.cpp +++ b/src/gui/itemviews/qabstractproxymodel.cpp @@ -298,6 +298,7 @@ bool QAbstractProxyModel::setHeaderData(int section, Qt::Orientation orientation /*! \reimp + \since 4.8 */ QModelIndex QAbstractProxyModel::buddy(const QModelIndex &index) const { @@ -307,6 +308,7 @@ QModelIndex QAbstractProxyModel::buddy(const QModelIndex &index) const /*! \reimp + \since 4.8 */ bool QAbstractProxyModel::canFetchMore(const QModelIndex &parent) const { @@ -316,6 +318,7 @@ bool QAbstractProxyModel::canFetchMore(const QModelIndex &parent) const /*! \reimp + \since 4.8 */ void QAbstractProxyModel::fetchMore(const QModelIndex &parent) { @@ -325,6 +328,7 @@ void QAbstractProxyModel::fetchMore(const QModelIndex &parent) /*! \reimp + \since 4.8 */ void QAbstractProxyModel::sort(int column, Qt::SortOrder order) { @@ -334,6 +338,7 @@ void QAbstractProxyModel::sort(int column, Qt::SortOrder order) /*! \reimp + \since 4.8 */ QSize QAbstractProxyModel::span(const QModelIndex &index) const { @@ -343,6 +348,7 @@ QSize QAbstractProxyModel::span(const QModelIndex &index) const /*! \reimp + \since 4.8 */ bool QAbstractProxyModel::hasChildren(const QModelIndex &parent) const { @@ -352,6 +358,7 @@ bool QAbstractProxyModel::hasChildren(const QModelIndex &parent) const /*! \reimp + \since 4.8 */ QMimeData* QAbstractProxyModel::mimeData(const QModelIndexList &indexes) const { @@ -364,6 +371,7 @@ QMimeData* QAbstractProxyModel::mimeData(const QModelIndexList &indexes) const /*! \reimp + \since 4.8 */ QStringList QAbstractProxyModel::mimeTypes() const { @@ -373,6 +381,7 @@ QStringList QAbstractProxyModel::mimeTypes() const /*! \reimp + \since 4.8 */ Qt::DropActions QAbstractProxyModel::supportedDropActions() const { diff --git a/src/gui/kernel/qgenericplugin_qpa.cpp b/src/gui/kernel/qgenericplugin_qpa.cpp index e7b65b7..dae512d 100644 --- a/src/gui/kernel/qgenericplugin_qpa.cpp +++ b/src/gui/kernel/qgenericplugin_qpa.cpp @@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE \class QGenericPlugin \ingroup plugins \ingroup qpa + \since 4.8 \brief The QGenericPlugin class is an abstract base class for window-system related plugins in Qt QPA. diff --git a/src/gui/kernel/qgenericpluginfactory_qpa.cpp b/src/gui/kernel/qgenericpluginfactory_qpa.cpp index fb6a0d8..86e146a 100644 --- a/src/gui/kernel/qgenericpluginfactory_qpa.cpp +++ b/src/gui/kernel/qgenericpluginfactory_qpa.cpp @@ -61,6 +61,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, /*! \class QGenericPluginFactory \ingroup qpa + \since 4.8 \brief The QGenericPluginFactory class creates window-system related plugin drivers in Qt QPA. diff --git a/src/gui/kernel/qplatformcursor_qpa.cpp b/src/gui/kernel/qplatformcursor_qpa.cpp index 0695486..0426226 100644 --- a/src/gui/kernel/qplatformcursor_qpa.cpp +++ b/src/gui/kernel/qplatformcursor_qpa.cpp @@ -53,6 +53,7 @@ QList > QPlatformCursorPrivate::instances; /*! \class QPlatformCursor + \since 4.8 \brief The QPlatformCursor class provides information about pointer device events (movement, buttons), and requests to change @@ -105,6 +106,7 @@ QPlatformCursor::QPlatformCursor(QPlatformScreen *scr ) /*! \class QPlatformCursorImage + \since 4.8 \brief The QPlatformCursorImage class provides a set of graphics intended to be used as cursors. diff --git a/src/gui/kernel/qplatformwindowformat_qpa.cpp b/src/gui/kernel/qplatformwindowformat_qpa.cpp index 482ae68..4ab8dfd 100644 --- a/src/gui/kernel/qplatformwindowformat_qpa.cpp +++ b/src/gui/kernel/qplatformwindowformat_qpa.cpp @@ -101,11 +101,11 @@ public: /*! \class QPlatformWindowFormat + \ingroup painting + \since 4.8 \brief The QPlatformWindowFormat class specifies the display format of an OpenGL rendering context and if possible attributes of the corresponding QPlatformWindow. - \ingroup painting - QWidget has a setter and getter function for QPlatformWindowFormat. These functions can be used by the application programmer to signal what kind of format he wants to the window and glcontext should have. However, it is not always possible to fulfill these requirements. The application @@ -937,6 +937,8 @@ void QPlatformWindowFormat::setDefaultFormat(const QPlatformWindowFormat &f) /*! + \since 4.8 + Returns true if all the options of the two QPlatformWindowFormat objects \a a and \a b are equal; otherwise returns false. @@ -960,6 +962,8 @@ bool operator==(const QPlatformWindowFormat& a, const QPlatformWindowFormat& b) /*! + \since 4.8 + Returns false if all the options of the two QPlatformWindowFormat objects \a a and \a b are equal; otherwise returns true. diff --git a/src/gui/kernel/qsizepolicy.qdoc b/src/gui/kernel/qsizepolicy.qdoc index 593560e..7002ed3 100644 --- a/src/gui/kernel/qsizepolicy.qdoc +++ b/src/gui/kernel/qsizepolicy.qdoc @@ -263,6 +263,7 @@ /*! \fn void QSizePolicy::setWidthForHeight(bool dependent) + \since 4.8 Sets the flag determining whether the widget's width depends on its height, to \a dependent. @@ -276,6 +277,7 @@ /*! \fn bool QSizePolicy::hasWidthForHeight() const + \since 4.8 Returns true if the widget's width depends on its height; otherwise returns false. diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp index 56c3010..224f574 100644 --- a/src/gui/kernel/qwidget_qpa.cpp +++ b/src/gui/kernel/qwidget_qpa.cpp @@ -690,6 +690,7 @@ int QWidget::metric(PaintDeviceMetric m) const /*! \preliminary + \since 4.8 Sets the window to be the platform \a window specified. @@ -710,6 +711,7 @@ void QWidget::setPlatformWindow(QPlatformWindow *window) /*! \preliminary + \since 4.8 Returns the QPlatformWindow this widget will be drawn into. */ @@ -724,6 +726,8 @@ QPlatformWindow *QWidget::platformWindow() const } /*! + \since 4.8 + Sets the platform window format for the widget to the \a format specified. */ void QWidget::setPlatformWindowFormat(const QPlatformWindowFormat &format) @@ -743,6 +747,8 @@ void QWidget::setPlatformWindowFormat(const QPlatformWindowFormat &format) } /*! + \since 4.8 + Returns the platform window format for the widget. */ QPlatformWindowFormat QWidget::platformWindowFormat() const diff --git a/src/gui/painting/qprinterinfo.cpp b/src/gui/painting/qprinterinfo.cpp index a7ddc85..c00a1cc 100644 --- a/src/gui/painting/qprinterinfo.cpp +++ b/src/gui/painting/qprinterinfo.cpp @@ -79,6 +79,8 @@ QPrinterInfo::QPrinterInfo() } /*! + \since 4.8 + Constructs a copy of \a other. */ QPrinterInfo::QPrinterInfo(const QPrinterInfo &other) @@ -117,6 +119,8 @@ QPrinterInfo::~QPrinterInfo() } /*! + \since 4.8 + Sets the QPrinterInfo object to be equal to \a other. */ QPrinterInfo &QPrinterInfo::operator=(const QPrinterInfo &other) diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index 9e1646f..f3d4107 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -442,6 +442,8 @@ bool QFontMetrics::inFont(QChar ch) const } /*! + \since 4.8 + Returns true if the character encoded in UCS-4/UTF-32 is a valid character in the font; otherwise returns false. */ @@ -1330,6 +1332,7 @@ bool QFontMetricsF::inFont(QChar ch) const /*! \fn bool QFontMetricsF::inFontUcs4(uint ch) const + \since 4.8 Returns true if the character given by \a ch, encoded in UCS-4/UTF-32, is a valid character in the font; otherwise returns false. diff --git a/src/gui/text/qplatformfontdatabase_qpa.cpp b/src/gui/text/qplatformfontdatabase_qpa.cpp index 7e829db..d1d1f94 100644 --- a/src/gui/text/qplatformfontdatabase_qpa.cpp +++ b/src/gui/text/qplatformfontdatabase_qpa.cpp @@ -203,6 +203,7 @@ bool QSupportedWritingSystems::supported(QFontDatabase::WritingSystem writingSys \brief The QSupportedWritingSystems class is used when registering fonts with the internal Qt fontdatabase \ingroup painting + \since 4.8 Its to provide an easy to use interface for indicating what writing systems a specific font supports. @@ -322,6 +323,7 @@ QString QPlatformFontDatabase::fontDir() const \class QPlatformFontDatabase \brief The QPlatformFontDatabase class makes it possible to customize how fonts are discovered and how they are rendered + \since 4.8 \ingroup painting diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index 8bbe86c..7e7ca6c 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -2569,6 +2569,7 @@ QTextDocument *QTextCursor::document() const /*! \enum Qt::CursorMoveStyle + \since 4.8 This enum describes the movement style available to text cursors. The options are: diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index c1bc846..7990667 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -579,6 +579,8 @@ bool QTextLayout::cacheEnabled() const } /*! + \since 4.8 + Set the cursor movement style. If the QTextLayout is backed by a document, you can ignore this and use the option in QTextDocument, this option is for widgets like QLineEdit or custom widgets without @@ -592,6 +594,8 @@ void QTextLayout::setCursorMoveStyle(Qt::CursorMoveStyle style) } /*! + \since 4.8 + The cursor movement style of this QTextLayout. The default is Qt::LogicalMoveStyle. @@ -725,9 +729,11 @@ int QTextLayout::previousCursorPosition(int oldPos, CursorMode mode) const } /*! + \since 4.8 + Returns the cursor position to the right of \a oldPos, next to it. - It's dependent on the visual position of characters, after bi-directional - reordering. + The position is dependent on the visual position of characters, after + bi-directional reordering. \sa leftCursorPosition(), nextCursorPosition() */ @@ -739,9 +745,11 @@ int QTextLayout::rightCursorPosition(int oldPos) const } /*! + \since 4.8 + Returns the cursor position to the left of \a oldPos, next to it. - It's dependent on the visual position of characters, after bi-directional - reordering. + The position is dependent on the visual position of characters, after + bi-directional reordering. \sa rightCursorPosition(), previousCursorPosition() */ diff --git a/src/gui/widgets/qcheckbox.cpp b/src/gui/widgets/qcheckbox.cpp index 9904a15..2210488 100644 --- a/src/gui/widgets/qcheckbox.cpp +++ b/src/gui/widgets/qcheckbox.cpp @@ -303,6 +303,7 @@ QSize QCheckBox::sizeHint() const /*! \reimp + \since 4.8 */ QSize QCheckBox::minimumSizeHint() const { diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 2d63f63..7d35766 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1128,6 +1128,8 @@ void QLineEdit::setDragEnabled(bool b) */ /*! + \since 4.8 + Returns the movement style for the cursor in the line edit. */ Qt::CursorMoveStyle QLineEdit::cursorMoveStyle() const @@ -1137,6 +1139,8 @@ Qt::CursorMoveStyle QLineEdit::cursorMoveStyle() const } /*! + \since 4.8 + Sets the movement style for the cursor in the line edit to the given \a style. */ diff --git a/src/gui/widgets/qradiobutton.cpp b/src/gui/widgets/qradiobutton.cpp index eeef40e..9ce4eba 100644 --- a/src/gui/widgets/qradiobutton.cpp +++ b/src/gui/widgets/qradiobutton.cpp @@ -206,6 +206,7 @@ QSize QRadioButton::sizeHint() const /*! \reimp + \since 4.8 */ QSize QRadioButton::minimumSizeHint() const { diff --git a/src/gui/widgets/qtabwidget.cpp b/src/gui/widgets/qtabwidget.cpp index c6551e5..78dda23 100644 --- a/src/gui/widgets/qtabwidget.cpp +++ b/src/gui/widgets/qtabwidget.cpp @@ -885,6 +885,7 @@ QSize QTabWidget::minimumSizeHint() const /*! \reimp + \since 4.8 */ int QTabWidget::heightForWidth(int width) const { diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp index fdb36e8..8065025 100644 --- a/src/network/bearer/qnetworkconfigmanager.cpp +++ b/src/network/bearer/qnetworkconfigmanager.cpp @@ -126,6 +126,7 @@ QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate() /*! \fn void QNetworkConfigurationManager::configurationRemoved(const QNetworkConfiguration &config) + \since 4.8 This signal is emitted when a configuration is about to be removed from the system. The removed configuration, specified by \a config, is invalid but retains name and identifier. diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp index 4f9836e..6d4df44 100644 --- a/src/network/kernel/qnetworkproxy.cpp +++ b/src/network/kernel/qnetworkproxy.cpp @@ -916,6 +916,8 @@ QNetworkProxyQuery::QNetworkProxyQuery(quint16 bindPort, const QString &protocol #ifndef QT_NO_BEARERMANAGEMENT /*! + \since 4.8 + Constructs a QNetworkProxyQuery with the URL \a requestUrl and sets the query type to \a queryType. The specified \a networkConfiguration is used to resolve the proxy settings. @@ -931,6 +933,8 @@ QNetworkProxyQuery::QNetworkProxyQuery(const QNetworkConfiguration &networkConfi } /*! + \since 4.8 + Constructs a QNetworkProxyQuery of type \a queryType and sets the protocol tag to be \a protocolTag. This constructor is suitable for QNetworkProxyQuery::TcpSocket queries, because it sets the @@ -953,6 +957,8 @@ QNetworkProxyQuery::QNetworkProxyQuery(const QNetworkConfiguration &networkConfi } /*! + \since 4.8 + Constructs a QNetworkProxyQuery of type \a queryType and sets the protocol tag to be \a protocolTag. This constructor is suitable for QNetworkProxyQuery::TcpSocket queries because it sets the @@ -1197,6 +1203,8 @@ QNetworkConfiguration QNetworkProxyQuery::networkConfiguration() const } /*! + \since 4.8 + Sets the network configuration component of this QNetworkProxyQuery object to be \a networkConfiguration. The network configuration can be used to return different proxy settings based on the network in diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index 9ba8b75..518c860 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -53,6 +53,8 @@ QT_BEGIN_NAMESPACE /*! + \since 4.8 + Returns an OpenGL format for the platform window format specified by \a format. */ QGLFormat QGLFormat::fromPlatformWindowFormat(const QPlatformWindowFormat &format) @@ -87,6 +89,8 @@ QGLFormat QGLFormat::fromPlatformWindowFormat(const QPlatformWindowFormat &forma } /*! + \since 4.8 + Returns a platform window format for the OpenGL format specified by \a format. */ QPlatformWindowFormat QGLFormat::toPlatformWindowFormat(const QGLFormat &format) @@ -387,6 +391,8 @@ QGLContext::QGLContext(QPlatformGLContext *platformContext) } /*! + \since 4.8 + Returns a OpenGL context for the platform-specific OpenGL context given by \a platformContext. */ diff --git a/tools/assistant/lib/qhelpsearchquerywidget.cpp b/tools/assistant/lib/qhelpsearchquerywidget.cpp index faa80c0..9307638 100644 --- a/tools/assistant/lib/qhelpsearchquerywidget.cpp +++ b/tools/assistant/lib/qhelpsearchquerywidget.cpp @@ -511,6 +511,8 @@ QHelpSearchQueryWidget::~QHelpSearchQueryWidget() } /*! + \since 4.8 + Expands the search query widget so that the extended search fields are shown. */ void QHelpSearchQueryWidget::expandExtendedSearch() @@ -520,6 +522,8 @@ void QHelpSearchQueryWidget::expandExtendedSearch() } /*! + \since 4.8 + Collapses the search query widget so that only the default search field is shown. */ @@ -542,6 +546,8 @@ QList QHelpSearchQueryWidget::query() const } /*! + \since 4.8 + Sets the QHelpSearchQueryWidget input fields to the values specified by \a queryList search field name. Please note that one has to call the search engine's search(QList &queryList) function to perform the -- cgit v0.12 From 9b35303c88ef38bb763b794a5897c12197c2210e Mon Sep 17 00:00:00 2001 From: Jani Hautakangas Date: Fri, 1 Jul 2011 13:10:43 +0300 Subject: Update QtOpenGL section in Symbian platform notes. Task-number: QTBUG-20216 Reviewed-by: Laszlo Agocs --- doc/src/external-resources.qdoc | 5 +++++ doc/src/platforms/platform-notes.qdoc | 42 ++++++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/doc/src/external-resources.qdoc b/doc/src/external-resources.qdoc index 5522082..04d7ccb 100644 --- a/doc/src/external-resources.qdoc +++ b/doc/src/external-resources.qdoc @@ -483,3 +483,8 @@ \externalpage http://www.symbiansigned.com \title Symbian Signed */ + +/*! + \externalpage http://www.developer.nokia.com/Community/Wiki/Graphics_memory_handling + \title Graphics Out Of Memory monitor +*/ diff --git a/doc/src/platforms/platform-notes.qdoc b/doc/src/platforms/platform-notes.qdoc index 87b6298..231c58a 100644 --- a/doc/src/platforms/platform-notes.qdoc +++ b/doc/src/platforms/platform-notes.qdoc @@ -752,11 +752,43 @@ plugin. If the Helix plugin fails to load, the MMF plugin, if present on the device, will be loaded instead. - \section1 QtOpenGL Support - - Qt 4.7 introduces the QtOpenGL module to Symbian^3. QtOpenGL is supported on - devices which support OpenGL ES 2.0. Symbian platforms prior to Symbian^3 - are not supported. + \section1 Hardware Accelerated Rendering + + The default graphics system on Symbian^3 is OpenVG, which uses OpenVG + hardware to accelerate \l QPainter functions. There are a few exceptions, + where Qt will use software rendering fallback. + + Devices like the N8 and C7 only have 32Mb of GPU memory and limited support + for EGL surface transparency. These devices can be identified by querying + the\c GL_RENDERER or \c VG_RENDERER string which evaluates to \c {VideoCore III}. + On these devices, Qt will use software rendering in cases listed below. + + \list + \o Translucent windows + \o Dialogs + \o Popups + \endlist + + \section1 QtOpenGL Support in Symbian + + Qt 4.7 introduces the \l {QtOpenGL} module to Symbian^3. QtOpenGL is + supported on devices which support OpenGL ES 2.0. Symbian platforms prior + to Symbian^3 are not supported. + + \l QGLWidget usage as a \l QGraphicsView viewport is not recommended on + Symbian. The OpenVG graphics system is not able to manage OpenGL graphics + resources. Also, a QGLWidget object is not able to release its GPU resources + when the application goes to the background. If OpenGL functionality is + needed, OpenGL graphics system usage is recommended. If an application + decides to use QGLWidget, then it is the application's responsibility to + destroy and release QGLWidget and related OpenGL resources when the + application goes to the background. Otherwise, the \l{Graphics Out Of Memory monitor} + may decide to kill the application as it consumes GPU resources while in the + background. + + \note \l QGLBuffer, \l QGLFramebufferObject, \l QGLPixelBuffer, \l + QGLShader, and \l QGLShaderProgram are direct GPU resources and it is the + application's responsibility to manage them. \section1 UI Performance in devices prior to Symbian^3 -- cgit v0.12 From 14486b5047d185a36efe09abe25a01742c02d4cf Mon Sep 17 00:00:00 2001 From: aavit Date: Fri, 1 Jul 2011 12:51:09 +0200 Subject: update 4.8.0 changes file --- dist/changes-4.8.0 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dist/changes-4.8.0 b/dist/changes-4.8.0 index be67901..7dffa68 100644 --- a/dist/changes-4.8.0 +++ b/dist/changes-4.8.0 @@ -27,7 +27,9 @@ General Improvements Third party components ---------------------- - - Updated libpng to version x.y.z + - Updated libpng to version 1.5.1 + - Updated libjpeg to version 8c + - Updated zlib to version 1.2.5 **************************************************************************** @@ -65,6 +67,7 @@ QtGui - Deprecate qGenericMatrixFromMatrix4x4 and qGenericMatrixToMatrix4x4 - QListView diverses optimisations [QTBUG-11438] - QTreeWidget/QListWidget: use localeAwareCompare for string comparisons [QTBUG-10839] + - PNG image I/O: Much improved support for text annotations, including iTXt fields. QtNetwork --------- -- cgit v0.12 From 20d1bf0db865c93424c55838833b7d4d2551b758 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Fri, 1 Jul 2011 14:27:22 +0300 Subject: QS60Style: provide more standard icons Add custom standard icons for Symbian iconography. Additionally, map few existing standard icon enums to new icons. Task-number: QT-5116 Reviewed-by: Miikka Heikkinen --- src/gui/styles/qs60style.cpp | 350 ++++++++++++++++++++++++++++++++++++++- src/gui/styles/qs60style.h | 88 ++++++++++ src/gui/styles/qs60style_p.h | 106 +++++++++++- src/gui/styles/qs60style_s60.cpp | 100 +++++++++++ 4 files changed, 638 insertions(+), 6 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 6625416..1b84aba 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -3404,6 +3404,12 @@ QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; + int metric = PM_ToolBarIconSize; +#if defined(Q_WS_S60) + //Support version specific standard icons only with Symbian/S60 platform. + QSysInfo::S60Version versionSupport = QSysInfo::SV_S60_Unknown; +#endif + switch(standardIcon) { case SP_MessageBoxWarning: // By default, S60 messagebox icons have 4:3 ratio. Value is from S60 LAF documentation. @@ -3474,11 +3480,353 @@ QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, adjustedFlags |= QS60StylePrivate::SF_PointEast; part = QS60StyleEnums::SP_QgnIndiSubmenu; break; + case SP_TitleBarMenuButton: +#if defined(Q_WS_S60) + versionSupport = QSysInfo::SV_S60_5_3; +#endif + metric = PM_SmallIconSize; + part = QS60StyleEnums::SP_QtgToolBarOptions; + break; + case SP_DirHomeIcon: + metric = PM_SmallIconSize; + part = QS60StyleEnums::SP_QgnIndiBrowserTbHome; + break; + case SP_BrowserReload: + metric = PM_SmallIconSize; + part = QS60StyleEnums::SP_QgnIndiBrowserTbReload; + break; + case SP_BrowserStop: + metric = PM_SmallIconSize; + part = QS60StyleEnums::SP_QgnIndiBrowserTbStop; + break; +#if defined(Q_WS_S60) + case SP_MediaPlay: + versionSupport = QSysInfo::SV_S60_5_3; + metric = PM_SmallIconSize; + part = QS60StyleEnums::SP_QtgToolBarPlay; + break; + case SP_MediaStop: + versionSupport = QSysInfo::SV_S60_5_3; + metric = PM_SmallIconSize; + part = QS60StyleEnums::SP_QtgToolBarStop; + break; + case SP_MediaPause: + versionSupport = QSysInfo::SV_S60_5_3; + metric = PM_SmallIconSize; + part = QS60StyleEnums::SP_QtgToolBarPause; + break; + case SP_MediaSkipForward: + versionSupport = QSysInfo::SV_S60_5_3; + metric = PM_SmallIconSize; + part = QS60StyleEnums::SP_QtgToolBarNext; + break; + case SP_MediaSkipBackward: + versionSupport = QSysInfo::SV_S60_5_3; + metric = PM_SmallIconSize; + part = QS60StyleEnums::SP_QtgToolBarPrevious; + break; + case SP_MediaSeekForward: + versionSupport = QSysInfo::SV_S60_5_3; + metric = PM_SmallIconSize; + part = QS60StyleEnums::SP_QtgToolBarForward; + break; + case SP_MediaSeekBackward: + versionSupport = QSysInfo::SV_S60_5_3; + metric = PM_SmallIconSize; + part = QS60StyleEnums::SP_QtgToolBarRewind; + break; +#endif +// Custom icons + case SP_CustomToolBarAdd: + part = QS60StyleEnums::SP_QtgToolBarAdd; + break; + case SP_CustomToolBarAddDetail: + part = QS60StyleEnums::SP_QtgToolBarAddDetail; + break; + case SP_CustomToolBarAgain: + part = QS60StyleEnums::SP_QtgToolBarAgain; + break; + case SP_CustomToolBarAgenda: + part = QS60StyleEnums::SP_QtgToolBarAgenda; + break; + case SP_CustomToolBarAudioOff: + part = QS60StyleEnums::SP_QtgToolBarAudioOff; + break; + case SP_CustomToolBarAudioOn: + part = QS60StyleEnums::SP_QtgToolBarAudioOn; + break; + case SP_CustomToolBarBack: + part = QS60StyleEnums::SP_QtgToolBarBack; + break; + case SP_CustomToolBarBluetoothOff: + part = QS60StyleEnums::SP_QtgToolBarBluetoothOff; + break; + case SP_CustomToolBarBluetoothOn: + part = QS60StyleEnums::SP_QtgToolBarBluetoothOn; + break; + case SP_CustomToolBarCancel: + part = QS60StyleEnums::SP_QtgToolBarCancel; + break; + case SP_CustomToolBarDelete: + part = QS60StyleEnums::SP_QtgToolBarDelete; + break; + case SP_CustomToolBarDone: + part = QS60StyleEnums::SP_QtgToolBarDone; + break; + case SP_CustomToolBarEdit: + part = QS60StyleEnums::SP_QtgToolBarEdit; + break; + case SP_CustomToolBarEmailSend: + part = QS60StyleEnums::SP_QtgToolBarEmailSend; + break; + case SP_CustomToolBarEmergencyCall: + part = QS60StyleEnums::SP_QtgToolBarEmergencyCall; + break; + case SP_CustomToolBarFavouriteAdd: + part = QS60StyleEnums::SP_QtgToolBarFavouriteAdd; + break; + case SP_CustomToolBarFavouriteRemove: + part = QS60StyleEnums::SP_QtgToolBarFavouriteRemove; + break; + case SP_CustomToolBarFavourites: + part = QS60StyleEnums::SP_QtgToolBarFavourites; + break; + case SP_CustomToolBarGo: + part = QS60StyleEnums::SP_QtgToolBarGo; + break; + case SP_CustomToolBarHome: + part = QS60StyleEnums::SP_QtgToolBarHome; + break; + case SP_CustomToolBarList: + part = QS60StyleEnums::SP_QtgToolBarList; + break; + case SP_CustomToolBarLock: + part = QS60StyleEnums::SP_QtgToolBarLock; + break; + case SP_CustomToolBarLogs: + part = QS60StyleEnums::SP_QtgToolBarLogs; + break; + case SP_CustomToolBarMenu: + part = QS60StyleEnums::SP_QtgToolBarMenu; + break; + case SP_CustomToolBarNewContact: + part = QS60StyleEnums::SP_QtgToolBarNewContact; + break; + case SP_CustomToolBarNewGroup: + part = QS60StyleEnums::SP_QtgToolBarNewGroup; + break; + case SP_CustomToolBarNowPlay: + part = QS60StyleEnums::SP_QtgToolBarNowPlay; + break; + case SP_CustomToolBarOptions: + part = QS60StyleEnums::SP_QtgToolBarOptions; + break; + case SP_CustomToolBarOther: + part = QS60StyleEnums::SP_QtgToolBarOther; + break; + case SP_CustomToolBarOvi: + part = QS60StyleEnums::SP_QtgToolBarOvi; + break; + case SP_CustomToolBarRead: + part = QS60StyleEnums::SP_QtgToolBarRead; + break; + case SP_CustomToolBarRefresh: + part = QS60StyleEnums::SP_QtgToolBarRefresh; + break; + case SP_CustomToolBarRemoveDetail: + part = QS60StyleEnums::SP_QtgToolBarRemoveDetail; + break; + case SP_CustomToolBarRepeat: + part = QS60StyleEnums::SP_QtgToolBarRepeat; + break; + case SP_CustomToolBarRepeatOff: + part = QS60StyleEnums::SP_QtgToolBarRepeatOff; + break; + case SP_CustomToolBarRepeatOne: + part = QS60StyleEnums::SP_QtgToolBarRepeatOne; + break; + case SP_CustomToolBarSearch: + part = QS60StyleEnums::SP_QtgToolBarSearch; + break; + case SP_CustomToolBarSelfTimer: + part = QS60StyleEnums::SP_QtgToolBarSelfTimer; + break; + case SP_CustomToolBarSend: + part = QS60StyleEnums::SP_QtgToolBarSend; + break; + case SP_CustomToolBarShare: + part = QS60StyleEnums::SP_QtgToolBarShare; + break; + case SP_CustomToolBarShift: + part = QS60StyleEnums::SP_QtgToolBarShift; + break; + case SP_CustomToolBarShuffle: + part = QS60StyleEnums::SP_QtgToolBarShuffle; + break; + case SP_CustomToolBarShuffleOff: + part = QS60StyleEnums::SP_QtgToolBarShuffleOff; + break; + case SP_CustomToolBarSignalOff: + part = QS60StyleEnums::SP_QtgToolBarSignalOff; + break; + case SP_CustomToolBarSignalOn: + part = QS60StyleEnums::SP_QtgToolBarSignalOn; + break; + case SP_CustomToolBarSync: + part = QS60StyleEnums::SP_QtgToolBarSync; + break; + case SP_CustomToolBarUnlock: + part = QS60StyleEnums::SP_QtgToolBarUnlock; + break; + case SP_CustomToolBarUnmark: + part = QS60StyleEnums::SP_QtgToolBarUnmark; + break; + case SP_CustomToolBarView: + part = QS60StyleEnums::SP_QtgToolBarView; + break; + case SP_CustomToolBarWlanOff: + part = QS60StyleEnums::SP_QtgToolBarWlanOff; + break; + case SP_CustomToolBarWlanOn: + part = QS60StyleEnums::SP_QtgToolBarWlanOn; + break; +#if defined(Q_WS_S60) + case SP_CustomCameraCaptureButton: + versionSupport = QSysInfo::SV_S60_5_2; + part = QS60StyleEnums::SP_QtgGrafCameraButtonCaptureNormal; + break; + case SP_CustomCameraCaptureButtonPressed: + versionSupport = QSysInfo::SV_S60_5_2; + part = QS60StyleEnums::SP_QtgGrafCameraButtonCapturePressed; + break; + case SP_CustomCameraPauseButton: + versionSupport = QSysInfo::SV_S60_5_2; + part = QS60StyleEnums::SP_QtgGrafCameraButtonPauseNormal; + break; + case SP_CustomCameraPauseButtonPressed: + versionSupport = QSysInfo::SV_S60_5_2; + part = QS60StyleEnums::SP_QtgGrafCameraButtonPausePressed; + break; + case SP_CustomCameraPlayButton: + versionSupport = QSysInfo::SV_S60_5_2; + part = QS60StyleEnums::SP_QtgGrafCameraButtonPlayNormal; + break; + case SP_CustomCameraPlayButtonPressed: + versionSupport = QSysInfo::SV_S60_5_2; + part = QS60StyleEnums::SP_QtgGrafCameraButtonPlayPressed; + break; + case SP_CustomCameraRecButton: + versionSupport = QSysInfo::SV_S60_5_2; + part = QS60StyleEnums::SP_QtgGrafCameraButtonRecNormal; + break; + case SP_CustomCameraRecButtonPressed: + versionSupport = QSysInfo::SV_S60_5_2; + part = QS60StyleEnums::SP_QtgGrafCameraButtonRecPressed; + break; + case SP_CustomCameraStopButton: + versionSupport = QSysInfo::SV_S60_5_2; + part = QS60StyleEnums::SP_QtgGrafCameraButtonStopNormal; + break; + case SP_CustomCameraStopButtonPressed: + versionSupport = QSysInfo::SV_S60_5_2; + part = QS60StyleEnums::SP_QtgGrafCameraButtonStopPressed; + break; +#endif + case SP_CustomTabAll: + part = QS60StyleEnums::SP_QtgTabAll; + break; + case SP_CustomTabArtist: + part = QS60StyleEnums::SP_QtgTabArtist; + break; + case SP_CustomTabFavourite: + part = QS60StyleEnums::SP_QtgTabFavourite; + break; + case SP_CustomTabGenre: + part = QS60StyleEnums::SP_QtgTabGenre; + break; + case SP_CustomTabLanguage: + part = QS60StyleEnums::SP_QtgTabLanguage; + break; + case SP_CustomTabMusicAlbum: + part = QS60StyleEnums::SP_QtgTabMusicAlbum; + break; + case SP_CustomTabPhotosAlbum: + part = QS60StyleEnums::SP_QtgTabPhotosAlbum; + break; + case SP_CustomTabPhotosAll: + part = QS60StyleEnums::SP_QtgTabPhotosAll; + break; + case SP_CustomTabPlaylist: + part = QS60StyleEnums::SP_QtgTabPlaylist; + break; + case SP_CustomTabServices: + part = QS60StyleEnums::SP_QtgTabServices; + break; + case SP_CustomTabSongs: + part = QS60StyleEnums::SP_QtgTabSongs; + break; + case SP_CustomTabVideos: + part = QS60StyleEnums::SP_QtgTabVideos; + break; + case SP_CustomToolBarEditDisabled: + part = QS60StyleEnums::SP_QtgToolBarEditDisabled; + break; + case SP_CustomToolBarImageTools: + part = QS60StyleEnums::SP_QtgToolBarImageTools; + break; + case SP_CustomToolBarNextFrame: + part = QS60StyleEnums::SP_QtgToolBarNextFrame; + break; + case SP_CustomToolBarPreviousFrame: + part = QS60StyleEnums::SP_QtgToolBarPreviousFrame; + break; + case SP_CustomToolBarRedoDisabled: + part = QS60StyleEnums::SP_QtgToolBarRedoDisabled; + break; + case SP_CustomToolBarRedo: + part = QS60StyleEnums::SP_QtgToolBarRedo; + break; + case SP_CustomToolBarRemoveDisabled: + part = QS60StyleEnums::SP_QtgToolBarRemoveDisabled; + break; + case SP_CustomToolBarSearchDisabled: + part = QS60StyleEnums::SP_QtgToolBarSearchDisabled; + break; + case SP_CustomToolBarSelectContent: + part = QS60StyleEnums::SP_QtgToolBarSelectContent; + break; + case SP_CustomToolBarSendDimmed: + part = QS60StyleEnums::SP_QtgToolBarSendDimmed; + break; + case SP_CustomToolBarTools: + part = QS60StyleEnums::SP_QtgToolBarTools; + break; + case SP_CustomToolBarTrim: + part = QS60StyleEnums::SP_QtgToolBarTrim; + break; default: return QCommonStyle::standardIconImplementation(standardIcon, option, widget); } + +#if defined(Q_WS_S60) + //If new custom standardIcon is missing version information, assume S60 5.3. + if (standardIcon >= SP_CustomToolBarAdd) { + if (versionSupport == QSysInfo::SV_Unknown) + versionSupport = QSysInfo::SV_S60_5_3; + metric = PM_SmallIconSize; + } + + // Toolbar icons are only available from SV_S60_5_3 onwards. Use common style for earlier releases. + if ((versionSupport != QSysInfo::SV_Unknown) && QSysInfo::s60Version() < versionSupport) { + return QCommonStyle::standardIconImplementation(standardIcon, option, widget); + } +#else + if (standardIcon >= SP_CustomToolBarAdd) + metric = PM_SmallIconSize; +#endif + const QS60StylePrivate::SkinElementFlags flags = adjustedFlags; - const int iconDimension = QS60StylePrivate::pixelMetric(PM_ToolBarIconSize); + const int iconDimension = QS60StylePrivate::pixelMetric(metric); const QRect iconSize = (!option) ? QRect(0, 0, iconDimension * iconWidthMultiplier, iconDimension * iconHeightMultiplier) : option->rect; const QPixmap cachedPixMap(QS60StylePrivate::cachedPart(part, iconSize.size(), 0, flags)); diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h index 8ec5eb9..0e76cf2 100644 --- a/src/gui/styles/qs60style.h +++ b/src/gui/styles/qs60style.h @@ -62,6 +62,94 @@ enum { PM_CbaIconHeight }; +enum { + SP_CustomToolBarAdd = QStyle::SP_CustomBase + 1, + SP_CustomToolBarAddDetail, + SP_CustomToolBarAgain, + SP_CustomToolBarAgenda, + SP_CustomToolBarAudioOff, + SP_CustomToolBarAudioOn, + SP_CustomToolBarBack, + SP_CustomToolBarBluetoothOff, + SP_CustomToolBarBluetoothOn, + SP_CustomToolBarCancel, + SP_CustomToolBarDelete, + SP_CustomToolBarDone, + SP_CustomToolBarEdit, + SP_CustomToolBarEditDisabled, + SP_CustomToolBarEmailSend, + SP_CustomToolBarEmergencyCall, + SP_CustomToolBarFavouriteAdd, + SP_CustomToolBarFavouriteRemove, + SP_CustomToolBarFavourites, + SP_CustomToolBarGo, + SP_CustomToolBarHome, + SP_CustomToolBarImageTools, + SP_CustomToolBarList, + SP_CustomToolBarLock, + SP_CustomToolBarLogs, + SP_CustomToolBarMenu, + SP_CustomToolBarNewContact, + SP_CustomToolBarNewGroup, + SP_CustomToolBarNextFrame, + SP_CustomToolBarNowPlay, + SP_CustomToolBarOptions, + SP_CustomToolBarOther, + SP_CustomToolBarOvi, + SP_CustomToolBarPreviousFrame, + SP_CustomToolBarRead, + SP_CustomToolBarRedoDisabled, + SP_CustomToolBarRedo, + SP_CustomToolBarRefresh, + SP_CustomToolBarRemoveDetail, + SP_CustomToolBarRemoveDisabled, + SP_CustomToolBarRepeat, + SP_CustomToolBarRepeatOff, + SP_CustomToolBarRepeatOne, + SP_CustomToolBarSearch, + SP_CustomToolBarSearchDisabled, + SP_CustomToolBarSelectContent, + SP_CustomToolBarSelfTimer, + SP_CustomToolBarSend, + SP_CustomToolBarSendDimmed, + SP_CustomToolBarShare, + SP_CustomToolBarShift, + SP_CustomToolBarShuffle, + SP_CustomToolBarShuffleOff, + SP_CustomToolBarSignalOff, + SP_CustomToolBarSignalOn, + SP_CustomToolBarSync, + SP_CustomToolBarTools, + SP_CustomToolBarTrim, + SP_CustomToolBarUnlock, + SP_CustomToolBarUnmark, + SP_CustomToolBarView, + SP_CustomToolBarWlanOff, + SP_CustomToolBarWlanOn, + SP_CustomCameraCaptureButton, + SP_CustomCameraCaptureButtonPressed, + SP_CustomCameraPauseButton, + SP_CustomCameraPauseButtonPressed, + SP_CustomCameraPlayButton, + SP_CustomCameraPlayButtonPressed, + SP_CustomCameraRecButton, + SP_CustomCameraRecButtonPressed, + SP_CustomCameraStopButton, + SP_CustomCameraStopButtonPressed, + SP_CustomTabAll, + SP_CustomTabArtist, + SP_CustomTabFavourite, + SP_CustomTabGenre, + SP_CustomTabLanguage, + SP_CustomTabMusicAlbum, + SP_CustomTabPhotosAlbum, + SP_CustomTabPhotosAll, + SP_CustomTabPlaylist, + SP_CustomTabServices, + SP_CustomTabSongs, + SP_CustomTabVideos +}; + class QS60StylePrivate; class Q_GUI_EXPORT QS60Style : public QCommonStyle diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index b759fa7..586f1f6 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -142,11 +142,11 @@ public: SP_QgnGrafNsliderMiddle, SP_QgnIndiCheckboxOff, SP_QgnIndiCheckboxOn, - SP_QgnIndiHlColSuper, // Available in S60 release 3.2 and later. - SP_QgnIndiHlExpSuper, // Available in S60 release 3.2 and later. - SP_QgnIndiHlLineBranch, // Available in S60 release 3.2 and later. - SP_QgnIndiHlLineEnd, // Available in S60 release 3.2 and later. - SP_QgnIndiHlLineStraight, // Available in S60 release 3.2 and later. + SP_QgnIndiHlColSuper, + SP_QgnIndiHlExpSuper, + SP_QgnIndiHlLineBranch, + SP_QgnIndiHlLineEnd, + SP_QgnIndiHlLineStraight, SP_QgnIndiMarkedAdd, SP_QgnIndiNaviArrowLeft, SP_QgnIndiNaviArrowRight, @@ -311,6 +311,102 @@ public: SP_QsnFrListSideLPressed, SP_QsnFrListSideRPressed, SP_QsnFrListCenterPressed, + SP_QtgToolBarAdd, + SP_QtgToolBarAddDetail, + SP_QtgToolBarAgain, + SP_QtgToolBarAgenda, + SP_QtgToolBarAudioOff, + SP_QtgToolBarAudioOn, + SP_QtgToolBarBack, + SP_QtgToolBarBluetoothOff, + SP_QtgToolBarBluetoothOn, + SP_QtgToolBarCancel, + SP_QtgToolBarDelete, + SP_QtgToolBarDetails, + SP_QtgToolBarDone, + SP_QtgToolBarEdit, + SP_QtgToolBarEditDisabled, + SP_QtgToolBarEmailSend, + SP_QtgToolBarEmergencyCall, + SP_QtgToolBarFavouriteAdd, + SP_QtgToolBarFavouriteRemove, + SP_QtgToolBarFavourites, + SP_QtgToolBarForward, + SP_QtgToolBarGo, + SP_QtgToolBarHome, + SP_QtgToolBarImageTools, + SP_QtgToolBarList, + SP_QtgToolBarLock, + SP_QtgToolBarLogs, + SP_QtgToolBarMenu, + SP_QtgToolBarNewContact, + SP_QtgToolBarNewGroup, + SP_QtgToolBarNext, + SP_QtgToolBarNextFrame, + SP_QtgToolBarNowPlay, + SP_QtgToolBarOptions, + SP_QtgToolBarOther, + SP_QtgToolBarOvi, + SP_QtgToolBarPause, + SP_QtgToolBarPlay, + SP_QtgToolBarPrevious, + SP_QtgToolBarPreviousFrame, + SP_QtgToolBarRead, + SP_QtgToolBarRedo, + SP_QtgToolBarRedoDisabled, + SP_QtgToolBarRefresh, + SP_QtgToolBarRemoveDetail, + SP_QtgToolBarRemoveDisabled, + SP_QtgToolBarRepeat, + SP_QtgToolBarRepeatOff, + SP_QtgToolBarRepeatOne, + SP_QtgToolBarRewind, + SP_QtgToolBarSearch, + SP_QtgToolBarSearchDisabled, + SP_QtgToolBarSelectContent, + SP_QtgToolBarSelfTimer, + SP_QtgToolBarSend, + SP_QtgToolBarSendDimmed, + SP_QtgToolBarShare, + SP_QtgToolBarShift, + SP_QtgToolBarShuffle, + SP_QtgToolBarShuffleOff, + SP_QtgToolBarSignalOff, + SP_QtgToolBarSignalOn, + SP_QtgToolBarStop, + SP_QtgToolBarSync, + SP_QtgToolBarTools, + SP_QtgToolBarTrim, + SP_QtgToolBarUnlock, + SP_QtgToolBarUnmark, + SP_QtgToolBarView, + SP_QtgToolBarWlanOff, + SP_QtgToolBarWlanOn, + SP_QtgGrafCameraButtonCaptureNormal, + SP_QtgGrafCameraButtonCapturePressed, + SP_QtgGrafCameraButtonPauseNormal, + SP_QtgGrafCameraButtonPausePressed, + SP_QtgGrafCameraButtonPlayNormal, + SP_QtgGrafCameraButtonPlayPressed, + SP_QtgGrafCameraButtonRecNormal, + SP_QtgGrafCameraButtonRecPressed, + SP_QtgGrafCameraButtonStopNormal, + SP_QtgGrafCameraButtonStopPressed, + SP_QtgTabAll, + SP_QtgTabArtist, + SP_QtgTabFavourite, + SP_QtgTabGenre, + SP_QtgTabLanguage, + SP_QtgTabMusicAlbum, + SP_QtgTabPhotosAlbum, + SP_QtgTabPhotosAll, + SP_QtgTabPlaylist, + SP_QtgTabServices, + SP_QtgTabSongs, + SP_QtgTabVideos, + SP_QgnIndiBrowserTbReload, + SP_QgnIndiBrowserTbHome, + SP_QgnIndiBrowserTbStop, }; enum ColorLists { diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 6b66a09..c88d49a 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -413,6 +413,106 @@ const partMapEntry QS60StyleModeSpecifics::m_partMap[] = { /* SP_QsnFrListSideLPressed */ {KAknsIIDQsnFrListSideL, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2691}, /* SP_QsnFrListSideRPressed */ {KAknsIIDQsnFrListSideR, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2692}, /* SP_QsnFrListCenterPressed */ {KAknsIIDQsnFrListCenter, ENoDraw, ES60_3_X, EAknsMajorSkin, 0x2693}, + + /* SP_QtgToolBarAdd */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x27c0}, //KAknsIIDQtgToolbarAdd + /* SP_QtgToolBarAddDetail */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2778}, //KAknsIIDQtgToolbarAddDetail + /* SP_QtgToolbarAgain */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x271a}, //KAknsIIDQtgToolbarAgain + /* SP_QtgToolBarAgenda */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x281a}, //KAknsIIDQtgToolbarAgenda + /* SP_QtgToolBarAudioOff */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2751}, //KAknsIIDQtgToolbarAudioOff + /* SP_QtgToolBarAudioOn */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2752}, //KAknsIIDQtgToolbarAudioOn + /* SP_CustomToolBarBack */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x271b}, //KAknsIIDQtgToolbarBack + /* SP_QtgToolBarBluetoothOff */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2753}, //KAknsIIDQtgToolbarBluetoothOff + /* SP_QtgToolBarBluetoothOn */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2754}, //KAknsIIDQtgToolbarBluetoothOn + /* SP_QtgToolBarCancel */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2895}, //KAknsIIDQtgToolbarCancel + /* SP_QtgToolBarDelete */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2755}, //KAknsIIDQtgToolbarDelete + /* SP_QtgToolBarDetails */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x271e}, //KAknsIIDQtgToolbarDetails + /* SP_QtgToolBarDone */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x271f}, //KAknsIIDQtgToolbarDone + /* SP_QtgToolBarEdit */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2720}, //KAknsIIDQtgToolbarEdit + /* SP_QtgToolBarEditDisabled */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2946}, //KAknsIIDQtgToolbarEditDisabled + /* SP_QtgToolBarEmailSend */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x292f}, //KAknsIIDQtgToolbarEmailSend + /* SP_QtgToolBarEmergencyCall */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2721}, //KAknsIIDQtgToolbarEmergencyCall + /* SP_QtgToolBarFavouriteAdd */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x28ed}, //KAknsIIDQtgToolbarFavouriteAdd + /* SP_QtgToolBarFavouriteRemove */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x28ee}, //KAknsIIDQtgToolbarFavouriteRemove + /* SP_QtgToolBarFavourites */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x28b8}, //KAknsIIDQtgToolbarFavourites + /* SP_QtgToolBarForward */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x281b}, //KAknsIIDQtgToolbarForward + /* SP_QtgToolBarGo */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2930}, //KAknsIIDQtgToolbarGo + /* SP_QtgToolBarHome */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2722}, //KAknsIIDQtgToolbarHome + /* SP_QtgToolBarImageTools */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2947}, //KAknsIIDQtgToolbarImageTools + /* SP_QtgToolBarList */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x28b9}, //KAknsIIDQtgToolbarList + /* SP_QtgToolBarLock */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2723}, //KAknsIIDQtgToolbarLock + /* SP_QtgToolBarLogs */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x281c}, //KAknsIIDQtgToolbarLogs + /* SP_QtgToolBarMenu */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2724}, //KAknsIIDQtgToolbarMenu + /* SP_QtgToolBarNewContact */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2779}, //KAknsIIDQtgToolbarNewContact + /* SP_QtgToolBarNewGroup */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x277a}, //KAknsIIDQtgToolbarNewGroup + /* SP_QtgToolBarNext */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x281d}, //KAknsIIDQtgToolbarNext + /* SP_QtgToolBarNextFrame */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2981}, //KAknsIIDQtgToolbarNextFrame + /* SP_QtgToolBarNowPlay */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x28ef}, //KAknsIIDQtgToolbarNowplay + /* SP_QtgToolBarOptions */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2725}, //KAknsIIDQtgToolbarOptions + /* SP_QtgToolBarOther */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2726}, //KAknsIIDQtgToolbarOther + /* SP_QtgToolBarOvi */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2931}, //KAknsIIDQtgToolbarOvi + /* SP_QtgToolBarPause */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2727}, //KAknsIIDQtgToolbarPause + /* SP_QtgToolBarPlay */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2728}, //KAknsIIDQtgToolbarPlay + /* SP_QtgToolBarPrevious */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x281e}, //KAknsIIDQtgToolbarPrevious + /* SP_QtgToolBarPreviousFrame */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2982}, //KAknsIIDQtgToolbarPreviousFrame + /* SP_QtgToolBarRead */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2729}, //KAknsIIDQtgToolbarRead + /* SP_QtgToolBarRedo */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2948}, //KAknsIIDQtgToolbarRedo + /* SP_QtgToolBarRedoDisabled */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2949}, //KAknsIIDQtgToolbarRedoDisabled + /* SP_QtgToolBarRefresh */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2932}, //KAknsIIDQtgToolbarRefresh + /* SP_QtgToolBarRemoveDetail */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x277b}, //KAknsIIDQtgToolbarRemoveDetail + /* SP_QtgToolBarRemoveDisabled */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x294a}, //KAknsIIDQtgToolbarRemoveDisabled + /* SP_QtgToolBarRepeat */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x281f}, //KAknsIIDQtgToolbarRepeat + /* SP_QtgToolBarRepeatOff */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2820}, //KAknsIIDQtgToolbarRepeatOff + /* SP_QtgToolBarRepeatOne */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2821}, //KAknsIIDQtgToolbarRepeatOne + /* SP_QtgToolBarRewind */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2822}, //KAknsIIDQtgToolbarRewind + /* SP_QtgToolBarSearch */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x272a}, //KAknsIIDQtgToolbarSearch + /* SP_QtgToolBarSearchDisabled */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x294b}, //KAknsIIDQtgToolbarSearchDisabled + /* SP_QtgToolBarSelectContent */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x294c}, //KAknsIIDQtgToolbarSelectContent + /* SP_QtgToolBarSelfTimer */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2756}, //KAknsIIDQtgToolbarSelfTimer + /* SP_QtgToolBarSend */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x272b}, //KAknsIIDQtgToolbarSend + /* SP_QtgToolBarSendDimmed */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x29b0}, //KAknsIIDQtgToolbarSendDimmed + /* SP_QtgToolBarShare */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2823}, //KAknsIIDQtgToolbarShare + /* SP_QtgToolBarShift */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x272c}, //KAknsIIDQtgToolbarShift + /* SP_QtgToolBarShuffle */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2824}, //KAknsIIDQtgToolbarShuffle + /* SP_QtgToolBarShuffleOff */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2825}, //KAknsIIDQtgToolbarShuffleOff + /* SP_QtgToolBarSignalOff */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2757}, //KAknsIIDQtgToolbarSignalOff + /* SP_QtgToolBarSignalOn */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2758}, //KAknsIIDQtgToolbarSignalOn + /* SP_QtgToolBarStop */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x272d}, //KAknsIIDQtgToolbarStop + /* SP_QtgToolBarSync */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2894}, //KAknsIIDQtgToolbarSync + /* SP_QtgToolBarTools */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2983}, //KAknsIIDQtgToolbarTools + /* SP_QtgToolBarTrim */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2954}, //KAknsIIDQtgToolbarTrim + /* SP_QtgToolBarUnlock */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x272e}, //KAknsIIDQtgToolbarUnlock + /* SP_QtgToolBarUnmark */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x272f}, //KAknsIIDQtgToolbarUnmark + /* SP_QtgToolBarView */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2730}, //KAknsIIDQtgToolbarView + /* SP_QtgToolBarWlanOff */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2759}, //KAknsIIDQtgToolbarWlanOff + /* SP_QtgToolBarWlanOn */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x275a}, //KAknsIIDQtgToolbarWlanOn + + /* SP_QtgGrafCameraButtonCaptureNormal */ {KAknsIIDNone, EDrawIcon, ES60_Pre52, EAknsMajorGeneric, 0x2743}, //KAknsIIDQtgGrafCameraButtonCaptureNormal (already in 9.2) + /* SP_QtgGrafCameraButtonCapturePressed */ {KAknsIIDNone, EDrawIcon, ES60_Pre52, EAknsMajorGeneric, 0x2744}, //KAknsIIDQtgGrafCameraButtonCapturePressed + /* SP_QtgGrafCameraButtonPauseNormal */ {KAknsIIDNone, EDrawIcon, ES60_Pre52, EAknsMajorGeneric, 0x2745}, //KAknsIIDQtgGrafCameraButtonPauseNormal + /* SP_QtgGrafCameraButtonPausePressed */ {KAknsIIDNone, EDrawIcon, ES60_Pre52, EAknsMajorGeneric, 0x2746}, //KAknsIIDQtgGrafCameraButtonPausePressed + /* SP_QtgGrafCameraButtonPlayNormal */ {KAknsIIDNone, EDrawIcon, ES60_Pre52, EAknsMajorGeneric, 0x2747}, //KAknsIIDQtgGrafCameraButtonPlayNormal + /* SP_QtgGrafCameraButtonPlayPressed */ {KAknsIIDNone, EDrawIcon, ES60_Pre52, EAknsMajorGeneric, 0x2748}, //KAknsIIDQtgGrafCameraButtonPlayPressed + /* SP_QtgGrafCameraButtonRecNormal */ {KAknsIIDNone, EDrawIcon, ES60_Pre52, EAknsMajorGeneric, 0x2749}, //KAknsIIDQtgGrafCameraButtonRecNormal + /* SP_QtgGrafCameraButtonRecPressed */ {KAknsIIDNone, EDrawIcon, ES60_Pre52, EAknsMajorGeneric, 0x274a}, //KAknsIIDQtgGrafCameraButtonRecPressed + /* SP_QtgGrafCameraButtonStopNormal */ {KAknsIIDNone, EDrawIcon, ES60_Pre52, EAknsMajorGeneric, 0x274b}, //KAknsIIDQtgGrafCameraButtonStopNormal + /* SP_QtgGrafCameraButtonStopPressed */ {KAknsIIDNone, EDrawIcon, ES60_Pre52, EAknsMajorGeneric, 0x274c}, //KAknsIIDQtgGrafCameraButtonStopPressed + + /* SP_QtgTabAll */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2851}, //KAknsIIDQtgTabAll + /* SP_QtgTabArtist */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x288f}, //KAknsIIDQtgTabArtist + /* SP_QtgTabFavourite */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x28eb}, //KAknsIIDQtgTabFavourite + /* SP_QtgTabGenre */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2890}, //KAknsIIDQtgTabGenre + /* SP_QtgTabLanguage */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x28ec}, //KAknsIIDQtgTabLanguage + /* SP_QtgTabMusicAlbum */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2891}, //KAknsIIDQtgTabMusicAlbum + /* SP_QtgTabPhotosAlbum */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2818}, //KAknsIIDQtgTabPhotosAlbum + /* SP_QtgTabPhotosAll */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2819}, //KAknsIIDQtgTabPhotosAll + /* SP_QtgTabPlaylist */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2892}, //KAknsIIDQtgTabPlaylist + /* SP_QtgTabServices */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x274f}, //KAknsIIDQtgTabServices + /* SP_QtgTabSongs */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2893}, //KAknsIIDQtgTabSongs + /* SP_QtgTabVideos */ {KAknsIIDNone, EDrawIcon, ES60_Pre53, EAknsMajorGeneric, 0x2750}, //KAknsIIDQtgTabVideos + + /* SP_QgnIndiBrowserTbReload */ {KAknsIIDQgnIndiBrowserTbReload, EDrawIcon, ES60_All, -1, -1}, + /* SP_QgnIndiBrowserTbHome */ {KAknsIIDQgnIndiBrowserTbHome, EDrawIcon, ES60_All, -1, -1}, + /* SP_QgnIndiBrowserTbStop */ {KAknsIIDQgnIndiBrowserTbStop, EDrawIcon, ES60_All, -1, -1}, }; QPixmap QS60StyleModeSpecifics::skinnedGraphics( -- cgit v0.12 From 3ac6c3847a2abab63f8c45d856b19d3b38e2c78a Mon Sep 17 00:00:00 2001 From: David Boddie Date: Thu, 16 Jun 2011 16:10:38 +0200 Subject: Doc: Removed non-ASCII characters from the documentation. (cherry picked from commit 1bd6f1bd280ee6e1ecd4de2291c8ccfb4d06b7a4) --- doc/src/platforms/supported-platforms.qdoc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/src/platforms/supported-platforms.qdoc b/doc/src/platforms/supported-platforms.qdoc index 9d47695..ba59c37 100644 --- a/doc/src/platforms/supported-platforms.qdoc +++ b/doc/src/platforms/supported-platforms.qdoc @@ -334,8 +334,8 @@ \section2 Advanced Text Layout Engine - Qt for Windows CE supports TrueType® and raster fonts. Qt also has - extended Unicode support and right-to-left languages. Qt’s rich text + Qt for Windows CE supports TrueType and raster fonts. Qt also has + extended Unicode support and right-to-left languages. Qt's rich text engine adds capabilities for complex text layouts including tables, path tracing and text which flows around shapes. @@ -373,7 +373,7 @@ by embedded Linux. You can use Qt to create highly memory efficient devices and applications that have completely unique user experiences. - Qt runs anywhere Linux runs. Qt’s intuitive API means fewer lines of + Qt runs anywhere Linux runs. Qt's intuitive API means fewer lines of code and higher level functionality in less time. Use the code from one single code-base and rebuild for all \l{Supported Platforms} {supported platforms}. @@ -410,7 +410,7 @@ frame buffer} that will match the physical device display, pixel for pixel. This gives the developer a realistic testing infrastructure testing on the desktop where the frame buffer simulates the physical - device display’s width, height and color depth. + device display's width, height and color depth. \section2 Inter-Process Communication (IPC) @@ -421,7 +421,7 @@ \section2 Extended Font Format Qt supports a wide range of font formats on embedded Linux including: - TrueType®, Postscript® Type1 and Qt pre-rendered fonts. Qt has + TrueType, Postscript Type1 and Qt pre-rendered fonts. Qt has extended Unicode support including automatic data extraction at build time and automatic update at runtime. @@ -681,7 +681,7 @@ \group platform-details Qt is a cross-platform application and UI framework. Using Qt, - you can write web-enabled applications once and deploy them + you can write GUI applications once and deploy them across desktop, mobile and embedded operating systems without rewriting the source code. -- cgit v0.12 From 8304ca4edd7bd71dd0398451e62a281eac54d0a6 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Thu, 16 Jun 2011 20:20:50 +0200 Subject: Doc: Added more appropriate links to help reduce confusion. Task-number: QTBUG-19919 (cherry picked from commit 26c29a2dd7efa4c66063d1255e1f694462cbae85) --- src/gui/widgets/qtextedit.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp index 2670089..61d4fed 100644 --- a/src/gui/widgets/qtextedit.cpp +++ b/src/gui/widgets/qtextedit.cpp @@ -2472,6 +2472,8 @@ bool QTextEdit::find(const QString &exp, QTextDocument::FindFlags options) and the text edit will try to guess the right format. Use setHtml() or setPlainText() directly to avoid text edit's guessing. + + \sa toPlainText(), toHtml() */ void QTextEdit::setText(const QString &text) { -- cgit v0.12 From e32db846484eb3f9e2cc109d1c9250d326ee97d0 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Thu, 16 Jun 2011 20:24:11 +0200 Subject: Doc: Added a simple introduction to Qt and fixed links. (cherry picked from commit 9ed61311bce15b8f1bb4b30ee9133f1a2355f41d) --- doc/src/declarative/declarativeui.qdoc | 2 +- doc/src/declarative/qtquick-intro.qdoc | 2 +- doc/src/index.qdoc | 4 +- doc/src/qt-features.qdoc | 204 +++++++++++++++++++++++++++++++++ doc/src/qt4-intro.qdoc | 2 +- 5 files changed, 209 insertions(+), 5 deletions(-) create mode 100644 doc/src/qt-features.qdoc diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc index d89ca53..cecccf6 100644 --- a/doc/src/declarative/declarativeui.qdoc +++ b/doc/src/declarative/declarativeui.qdoc @@ -46,7 +46,7 @@ Qt applications. \section1 Getting Started \list -\o \l{Intro to Qt Quick}{Introduction to Qt Quick} +\o \l{Introduction to Qt Quick} \o \l{QML for Qt Programmers}{QML Programming for Qt Programmers} \o \l{Getting Started Programming with QML} diff --git a/doc/src/declarative/qtquick-intro.qdoc b/doc/src/declarative/qtquick-intro.qdoc index bdad2c3..4cd5db3 100644 --- a/doc/src/declarative/qtquick-intro.qdoc +++ b/doc/src/declarative/qtquick-intro.qdoc @@ -27,7 +27,7 @@ /*! \page qml-intro.html -\title Intro to Qt Quick +\title Introduction to Qt Quick Qt Quick is a collection of technologies that are designed to help developers create the kind of intuitive, modern, and fluid user interfaces that are diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc index 979c654..2ce6781 100644 --- a/doc/src/index.qdoc +++ b/doc/src/index.qdoc @@ -36,8 +36,8 @@ What is Qt \enddiv \list - \o \l{Qt Whitepaper}{Qt C++ Framework} - \o \l{Intro to Qt Quick}{Qt Quick} + \o \l{Qt Features Overview} + \o \l{Introduction to Qt Quick}{Qt Quick} \o \l{external: Qt Mobility Manual}{Qt Mobility} \o \l{Qt WebKit} \endlist diff --git a/doc/src/qt-features.qdoc b/doc/src/qt-features.qdoc new file mode 100644 index 0000000..0ae00b0 --- /dev/null +++ b/doc/src/qt-features.qdoc @@ -0,0 +1,204 @@ +/**************************************************************************** +** +** 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 documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. +** +** 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$ +** +****************************************************************************/ + +/*! + \page qt-overview.html + \title Qt Features Overview + + This document provides a summary of the most important features of Qt, + providing links to other pages in the documentation that cover these + features in more detail. It is not intended to be a comprehensive + guide to Qt's features. + + \section1 Fundamental Technologies in Qt + + Qt is built upon a set of core technologies, provided by the \l QtCore + and \l QtGui modules. These include the following: + + \list + \o \l{The Tulip Container Classes}, a set of template container classes. + \o \l{The Arthur Paint System}, the Qt 4 painting framework. + \o \l{The Interview Framework}, a model/view architecture for item views + and the \l{QtSQL Module}, which also uses this architecture. + \o \l{The Scribe Classes}, a framework for creating text documents, + performing low-level text layout and writing OpenDocument files. + \o A collection of \l{Qt Widget Gallery}{common desktop widgets}, styled + to fit in on each supported platform. + \o \l{The Qt 4 Main Window Classes}, a main window, toolbar, menu, and + docking architecture. + \o The \l{Graphics View} framework provides a canvas for producing + interactive graphics. + \o The \l{QtNetwork Module} provides support for TCP, UDP and local + sockets that are integrated with Qt's event model, including support + for Secure Socket Layer (SSL) communications, + \l{QNetworkProxy}{network proxy} servers and + \l{Bearer Management}{network bearer management}. + \o Enhanced \l{qt4-threads.html}{thread support} allows + \l{Signals & Slots}{signal-slot} connections across threads and + per-thread event loops. + Additionally, \l{Thread Support in Qt}{a framework for concurrent programming} + using Qt paradigms makes common threading tasks easier. + \o A \l{resource system} for embedding images and other resource files + into executable files makes it easier to deploy applications. + \o A \l{QTestLib Manual}{unit testing framework} for Qt applications and + libraries. + \endlist + + The mature classes provided by these technologies have been used to build + robust, cross-platform desktop applications. They are augmented by a number + of additional technologies and improvements that have appeared over the + lifetime of Qt 4. + + \section1 Graphical User Interfaces + + \div{class="float-right"} + \inlineimage gtk-tabwidget.png + \enddiv + \div{class="float-right"} + \inlineimage gtk-progressbar.png + \br + \inlineimage gtk-checkbox.png + \br + \inlineimage plastique-combobox.png + \br + \inlineimage plastique-radiobutton.png + \enddiv + + Alongside the support for traditional desktop user interfaces, Qt includes + support for declarative UI development with \l{Qt Quick}, a set of + technologies for creating fluid, dynamic user interfaces. A starting point + for exploring this approach can be found in the \l{Introduction to Qt Quick} + guide. + + Qt provides a range of standard user interface elements, called widgets, + for each supported platform. Widgets can be used as containers for other + widgets, as windows, and as regular controls that the user interacts with. + Where the platform supports it, widgets can be made to appear partially + transparent, and may be styled with \l{Qt Style Sheets}. + + Support for \l{QTouchEvent}{touch input} and \l{Gestures Programming}{gestures} + enable widgets to be used to create intuitive user interfaces for + touch-enabled devices. + + User interfaces can also be created dynamically at run-time with the + features provided by the \l{QtUiTools} module. + + A selection of available widgets are shown in the \l{Qt Widget Gallery}. + An introduction to the concepts behind widgets can be found in the + \l{Widgets Tutorial}. + + \clearfloat + \section1 Painting, Printing and Rendering + + \div{class="float-left"} + \inlineimage qpainter-affinetransformations.png + \enddiv + + Widgets are just one of many kinds of paint device that Qt can render onto. + This support for unified painting makes it possible for applications to use + the same painting code for different tasks, as well as allowing Qt to be + extended to support additional file formats. + + Qt provides support for common bitmap image formats, + \l{QtSvg Module}{Scalable Vector Graphics} (SVG) drawings and animations, + Postscript and Portable Document Format (PDF) files. Postscript and PDF are + integrated with \l{Printing with Qt}{Qt's printing system}, which also + allows printed output to be previewed. + + Interactive graphics can be created with the + \l{The Animation Framework}{animation framework}, allowing animations to be + used with both widgets and graphics items. Animations can be used with the + \l{The State Machine Framework}{state machine framework}, which provides a + way to express application logic and integrate it with the user interface. + Animations can be enhanced with a collection of + \l{QGraphicsEffect}{graphics effects} that operate on graphics items and + can be applied individually or combined to create more complex effects. + + Qt supports integration with \l{QtOpenGL}{OpenGL} on a number of levels, + providing convenience functions for handling textures and colors, as well + as providing support for pixel and sample buffers. Future support for + higher level 3D integration is provided by Qt3D enablers which include + \l{QMatrix4x4}{matrix multiplication}, \l{QQuaternion}{quaternions}, and an + API for \l{QGLShader}{vertex and fragment shaders}. + + Two APIs are provided for multimedia. The + \l{Phonon Overview}{Phonon Multimedia Framework} has traditionally been + used on desktop platforms. A set of + \l{QtMultimedia Module}{multimedia services} provides low-level access to + the system's audio system and is often used on mobile devices. + + \clearfloat + \section1 Infrastructure + + \div{class="float-right"} + \inlineimage qtscript-context2d.png + \enddiv + + Facilities for Inter-Process Communication (IPC) and Remote Procedure + Calling (RPC) mechanisms are available on platforms that support the + \l{intro-to-dbus.html}{D-Bus} message bus system. + + An \l{Undo Framework}{Undo framework} based on the + \l{Books about GUI Design#Design Patterns}{Command pattern} is designed to + enable a consistent approach to handling data in editing applications. + + The \l{QtScript} and \l{QtScriptTools} modules provide support for + application scripting and debugging using the ECMAScript language. + + The \l{QtHelp Module} provides the foundations of an interactive help + system that can be used in conjunction with Qt Creator or integrated into + applications directly. + + XML handling is supported in a number of places in Qt. The \l QtCore module + provides classes for reading and writing XML streams. The \l QtXmlPatterns + module includes XQuery, XPath and XSLT support, providing facilities for + XML processing beyond that supported by the QtXml module, which contains + SAX and DOM parsers. XML schema validation in the QtXmlPatterns module + covers large parts of version 1.0 of the specification. + + \clearfloat + \section1 Web Client Integration + + Integration between \l{Webkit in Qt}{Qt and WebKit} makes it possible for + developers to use a fully-featured Web browser engine to display documents + and access online services. Developers can access the browser's environment + to create documents and run scripts within one or more browser widgets. + + A \l{QWebElement}{DOM access API} for QtWebKit provides a cleaner and safer + way to access elements and structures of Web pages without the use of + JavaScript. + + \section1 Further Reading + + Many of the technologies mentioned here, as well as other, more specific + features, are listed in the \l{What's New in Qt 4} document. A complete + list of Qt's modules can be found on the \l{All Modules} page, which + also includes more domain-specific technologies. + + The tools that are supplied with Qt are covered by the listing in the + \l{Qt's Tools} document. +*/ diff --git a/doc/src/qt4-intro.qdoc b/doc/src/qt4-intro.qdoc index 41d8b2e..d75bdca 100644 --- a/doc/src/qt4-intro.qdoc +++ b/doc/src/qt4-intro.qdoc @@ -132,7 +132,7 @@ In Qt 4.4: \list - \o \l{Webkit in QT}{Qt WebKit integration}, making it possible for developers + \o \l{WebKit in Qt}{Qt WebKit integration}, making it possible for developers to use a fully-featured Web browser to display documents and access online services. \o A multimedia API provided by the \l{Phonon Overview}{Phonon Multimedia Framework}. -- cgit v0.12 From a8f466030b5774adb558ca88552a473f28aa2c89 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Thu, 30 Jun 2011 19:08:43 +0200 Subject: Modified \since command behavior slightly to handle project and version. (The since argument can contain a project name and version, defaulting to the qdoc project if only a version number is specified.) Refactored common code into the Generator class. Fixed \sincelist HTML generation for tables containing only one item. (cherry picked from commit 6a2f18140bbc41207eb2f5e2323b699600d89606) --- tools/qdoc3/ditaxmlgenerator.cpp | 83 ----------------------- tools/qdoc3/ditaxmlgenerator.h | 11 --- tools/qdoc3/doc.cpp | 2 +- tools/qdoc3/generator.cpp | 142 +++++++++++++++++++++++++++++++++++++-- tools/qdoc3/generator.h | 12 ++++ tools/qdoc3/htmlgenerator.cpp | 103 +++++----------------------- tools/qdoc3/htmlgenerator.h | 11 --- tools/qdoc3/node.cpp | 10 +++ tools/qdoc3/node.h | 2 +- 9 files changed, 174 insertions(+), 202 deletions(-) diff --git a/tools/qdoc3/ditaxmlgenerator.cpp b/tools/qdoc3/ditaxmlgenerator.cpp index b801e1e..ae7385e 100644 --- a/tools/qdoc3/ditaxmlgenerator.cpp +++ b/tools/qdoc3/ditaxmlgenerator.cpp @@ -62,25 +62,6 @@ QT_BEGIN_NAMESPACE #define COMMAND_VERSION Doc::alias("version") int DitaXmlGenerator::id = 0; -QString DitaXmlGenerator::sinceTitles[] = - { - " New Namespaces", - " New Classes", - " New Member Functions", - " New Functions in Namespaces", - " New Global Functions", - " New Macros", - " New Enum Types", - " New Typedefs", - " New Properties", - " New Variables", - " New QML Elements", - " New Qml Properties", - " New Qml Signals", - " New Qml Methods", - "" - }; - /* The strings in this array must appear in the same order as the values in enum DitaXmlGenerator::DitaTag. @@ -3952,70 +3933,6 @@ void DitaXmlGenerator::findAllClasses(const InnerNode* node) } } -/*! - For generating the "New Classes... in 4.x" section on the - What's New in 4.x" page. - */ -void DitaXmlGenerator::findAllSince(const InnerNode* node) -{ - NodeList::const_iterator child = node->childNodes().constBegin(); - while (child != node->childNodes().constEnd()) { - QString sinceVersion = (*child)->since(); - if (((*child)->access() != Node::Private) && !sinceVersion.isEmpty()) { - NewSinceMaps::iterator nsmap = newSinceMaps.find(sinceVersion); - if (nsmap == newSinceMaps.end()) - nsmap = newSinceMaps.insert(sinceVersion,NodeMultiMap()); - NewClassMaps::iterator ncmap = newClassMaps.find(sinceVersion); - if (ncmap == newClassMaps.end()) - ncmap = newClassMaps.insert(sinceVersion,NodeMap()); - NewClassMaps::iterator nqcmap = newQmlClassMaps.find(sinceVersion); - if (nqcmap == newQmlClassMaps.end()) - nqcmap = newQmlClassMaps.insert(sinceVersion,NodeMap()); - - if ((*child)->type() == Node::Function) { - FunctionNode *func = static_cast(*child); - if ((func->status() > Node::Obsolete) && - (func->metaness() != FunctionNode::Ctor) && - (func->metaness() != FunctionNode::Dtor)) { - nsmap.value().insert(func->name(),(*child)); - } - } - else if ((*child)->url().isEmpty()) { - if ((*child)->type() == Node::Class && !(*child)->doc().isEmpty()) { - QString className = (*child)->name(); - if ((*child)->parent() && - (*child)->parent()->type() == Node::Namespace && - !(*child)->parent()->name().isEmpty()) - className = (*child)->parent()->name()+"::"+className; - nsmap.value().insert(className,(*child)); - ncmap.value().insert(className,(*child)); - } - else if ((*child)->subType() == Node::QmlClass) { - QString className = (*child)->name(); - if ((*child)->parent() && - (*child)->parent()->type() == Node::Namespace && - !(*child)->parent()->name().isEmpty()) - className = (*child)->parent()->name()+"::"+className; - nsmap.value().insert(className,(*child)); - nqcmap.value().insert(className,(*child)); - } - } - else { - QString name = (*child)->name(); - if ((*child)->parent() && - (*child)->parent()->type() == Node::Namespace && - !(*child)->parent()->name().isEmpty()) - name = (*child)->parent()->name()+"::"+name; - nsmap.value().insert(name,(*child)); - } - if ((*child)->isInnerNode()) { - findAllSince(static_cast(*child)); - } - } - ++child; - } -} - void DitaXmlGenerator::findAllFunctions(const InnerNode* node) { NodeList::ConstIterator c = node->childNodes().begin(); diff --git a/tools/qdoc3/ditaxmlgenerator.h b/tools/qdoc3/ditaxmlgenerator.h index 408f46c..d8d3563 100644 --- a/tools/qdoc3/ditaxmlgenerator.h +++ b/tools/qdoc3/ditaxmlgenerator.h @@ -51,12 +51,6 @@ QT_BEGIN_NAMESPACE -typedef QMultiMap NodeMultiMap; -typedef QMap NewSinceMaps; -typedef QMap ParentMaps; -typedef QMap NodeMap; -typedef QMap NewClassMaps; - typedef QMap GuidMap; typedef QMap GuidMaps; @@ -418,7 +412,6 @@ class DitaXmlGenerator : public PageGenerator void findAllFunctions(const InnerNode *node); void findAllLegaleseTexts(const InnerNode *node); void findAllNamespaces(const InnerNode *node); - void findAllSince(const InnerNode *node); static int hOffset(const Node *node); static bool isThreeColumnEnumValueTable(const Atom *atom); virtual QString getLink(const Atom *atom, @@ -515,10 +508,6 @@ class DitaXmlGenerator : public PageGenerator #endif QMap funcIndex; QMap legaleseTexts; - NewSinceMaps newSinceMaps; - static QString sinceTitles[]; - NewClassMaps newClassMaps; - NewClassMaps newQmlClassMaps; static int id; static QString ditaTags[]; QStack xmlWriterStack; diff --git a/tools/qdoc3/doc.cpp b/tools/qdoc3/doc.cpp index 479931d..37f68f8 100644 --- a/tools/qdoc3/doc.cpp +++ b/tools/qdoc3/doc.cpp @@ -828,7 +828,7 @@ void DocParser::parse(const QString& source, append(Atom::AnnotatedList, getArgument()); break; case CMD_SINCELIST: - append(Atom::SinceList, getArgument()); + append(Atom::SinceList, getRestOfLine().simplified()); break; case CMD_GENERATELIST: append(Atom::GeneratedList, getArgument()); diff --git a/tools/qdoc3/generator.cpp b/tools/qdoc3/generator.cpp index 3367301..c20d2b4 100644 --- a/tools/qdoc3/generator.cpp +++ b/tools/qdoc3/generator.cpp @@ -77,6 +77,25 @@ QString Generator::outDir; QString Generator::project; QHash Generator::outputPrefixes; +QString Generator::sinceTitles[] = + { + " New Namespaces", + " New Classes", + " New Member Functions", + " New Functions in Namespaces", + " New Global Functions", + " New Macros", + " New Enum Types", + " New Typedefs", + " New Properties", + " New Variables", + " New QML Elements", + " New QML Properties", + " New QML Signals", + " New QML Methods", + "" + }; + static void singularPlural(Text& text, const NodeList& nodes) { if (nodes.count() == 1) @@ -760,8 +779,18 @@ QString Generator::typeString(const Node *node) case Node::Class: return "class"; case Node::Fake: - default: - return "documentation"; + { + switch (node->subType()) { + case Node::QmlClass: + return "element"; + case Node::QmlPropertyGroup: + return "property group"; + case Node::QmlBasicType: + return "type"; + default: + return "documentation"; + } + } case Node::Enum: return "enum"; case Node::Typedef: @@ -770,6 +799,8 @@ QString Generator::typeString(const Node *node) return "function"; case Node::Property: return "property"; + default: + return "documentation"; } } @@ -1091,11 +1122,21 @@ void Generator::generateSince(const Node *node, CodeMarker *marker) text << " was introduced or modified in "; else text << " was introduced in "; - if (project.isEmpty()) - text << "version"; - else - text << project; - text << " " << node->since() << "." << Atom::ParaRight; + + QStringList since = node->since().split(" "); + if (since.count() == 1) { + // Handle legacy use of \since . + if (project.isEmpty()) + text << "version"; + else + text << project; + text << " " << since[0]; + } else { + // Reconstruct the string. + text << " " << since.join(" "); + } + + text << "." << Atom::ParaRight; generateText(text, node, marker); } } @@ -1346,4 +1387,91 @@ QStringList Generator::getMetadataElements(const InnerNode* inner, const QString return s; } +/*! + For generating the "New Classes... in 4.6" section on the + What's New in 4.6" page. + */ +void Generator::findAllSince(const InnerNode *node) +{ + NodeList::const_iterator child = node->childNodes().constBegin(); + + // Traverse the tree, starting at the node supplied. + + while (child != node->childNodes().constEnd()) { + + QString sinceString = (*child)->since(); + + if (((*child)->access() != Node::Private) && !sinceString.isEmpty()) { + + // Insert a new entry into each map for each new since string found. + NewSinceMaps::iterator nsmap = newSinceMaps.find(sinceString); + if (nsmap == newSinceMaps.end()) + nsmap = newSinceMaps.insert(sinceString,NodeMultiMap()); + + NewClassMaps::iterator ncmap = newClassMaps.find(sinceString); + if (ncmap == newClassMaps.end()) + ncmap = newClassMaps.insert(sinceString,NodeMap()); + + NewClassMaps::iterator nqcmap = newQmlClassMaps.find(sinceString); + if (nqcmap == newQmlClassMaps.end()) + nqcmap = newQmlClassMaps.insert(sinceString,NodeMap()); + + if ((*child)->type() == Node::Function) { + // Insert functions into the general since map. + FunctionNode *func = static_cast(*child); + if ((func->status() > Node::Obsolete) && + (func->metaness() != FunctionNode::Ctor) && + (func->metaness() != FunctionNode::Dtor)) { + nsmap.value().insert(func->name(),(*child)); + } + } + else if ((*child)->url().isEmpty()) { + if ((*child)->type() == Node::Class && !(*child)->doc().isEmpty()) { + // Insert classes into the since and class maps. + QString className = (*child)->name(); + if ((*child)->parent() && + (*child)->parent()->type() == Node::Namespace && + !(*child)->parent()->name().isEmpty()) + className = (*child)->parent()->name()+"::"+className; + + nsmap.value().insert(className,(*child)); + ncmap.value().insert(className,(*child)); + } + else if ((*child)->subType() == Node::QmlClass) { + // Insert QML elements into the since and element maps. + QString className = (*child)->name(); + if ((*child)->parent() && + (*child)->parent()->type() == Node::Namespace && + !(*child)->parent()->name().isEmpty()) + className = (*child)->parent()->name()+"::"+className; + + nsmap.value().insert(className,(*child)); + nqcmap.value().insert(className,(*child)); + } + else if ((*child)->type() == Node::QmlProperty) { + // Insert QML properties into the since map. + QString propertyName = (*child)->name(); + nsmap.value().insert(propertyName,(*child)); + } + } + else { + // Insert external documents into the general since map. + QString name = (*child)->name(); + if ((*child)->parent() && + (*child)->parent()->type() == Node::Namespace && + !(*child)->parent()->name().isEmpty()) + name = (*child)->parent()->name()+"::"+name; + + nsmap.value().insert(name,(*child)); + } + + // Find child nodes with since commands. + if ((*child)->isInnerNode()) { + findAllSince(static_cast(*child)); + } + } + ++child; + } +} + QT_END_NAMESPACE diff --git a/tools/qdoc3/generator.h b/tools/qdoc3/generator.h index e5e9747..e66915b 100644 --- a/tools/qdoc3/generator.h +++ b/tools/qdoc3/generator.h @@ -57,6 +57,12 @@ QT_BEGIN_NAMESPACE +typedef QMap NodeMap; +typedef QMultiMap NodeMultiMap; +typedef QMap NewSinceMaps; +typedef QMap ParentMaps; +typedef QMap NewClassMaps; + class ClassNode; class Config; class CodeMarker; @@ -152,6 +158,7 @@ class Generator QString getMetadataElement(const InnerNode* inner, const QString& t); QStringList getMetadataElements(const InnerNode* inner, const QString& t); + void findAllSince(const InnerNode *node); private: void generateReimplementedFrom(const FunctionNode *func, @@ -180,6 +187,11 @@ class Generator const NodeList& subs, CodeMarker *marker); + static QString sinceTitles[]; + NewSinceMaps newSinceMaps; + NewClassMaps newClassMaps; + NewClassMaps newQmlClassMaps; + private: QString amp; QString lt; diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 52da178..655c3b4 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -66,25 +66,6 @@ bool HtmlGenerator::debugging_on = false; QString HtmlGenerator::divNavTop = ""; -QString HtmlGenerator::sinceTitles[] = - { - " New Namespaces", - " New Classes", - " New Member Functions", - " New Functions in Namespaces", - " New Global Functions", - " New Macros", - " New Enum Types", - " New Typedefs", - " New Properties", - " New Variables", - " New QML Elements", - " New QML Properties", - " New QML Signals", - " New QML Methods", - "" - }; - static bool showBrokenLinks = false; static QRegExp linkTag("(<@link node=\"([^\"]+)\">).*()"); @@ -606,14 +587,18 @@ int HtmlGenerator::generateAtom(const Atom *atom, ncmap = newClassMaps.find(atom->string()); NewClassMaps::const_iterator nqcmap; nqcmap = newQmlClassMaps.find(atom->string()); + if ((nsmap != newSinceMaps.constEnd()) && !nsmap.value().isEmpty()) { QList
sections; QList
::ConstIterator s; + for (int i=0; itype()) { case Node::Fake: @@ -1346,6 +1331,7 @@ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker) // Generate brief text and status for modules. generateBrief(fake, marker); generateStatus(fake, marker); + generateSince(fake, marker); if (moduleNamespaceMap.contains(fake->name())) { out() << "" << divNavTop << "\n"; @@ -1362,6 +1348,7 @@ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker) // Generate brief text and status for modules. generateBrief(fake, marker); generateStatus(fake, marker); + generateSince(fake, marker); out() << "
    \n"; @@ -1393,6 +1380,7 @@ void HtmlGenerator::generateFakeNode(const FakeNode *fake, CodeMarker *marker) generateQmlInherits(qml_cn, marker); generateQmlInheritedBy(qml_cn, marker); generateQmlInstantiates(qml_cn, marker); + generateSince(qml_cn, marker); QString allQmlMembersLink = generateAllQmlMembersFile(qml_cn, marker); if (!allQmlMembersLink.isEmpty()) { @@ -2242,9 +2230,6 @@ void HtmlGenerator::generateCompactList(const Node *relative, for (int i=0; i element to contain all the
    elements. */ out() << "
    \n"; + numTableRows = 0; + + int curParNr = 0; + int curParOffset = 0; - for (int i=0; i\n"; curParOffset++; } - out() << "
    \n"; + if (classMap.count() > 0) + out() << "\n"; + out() << "\n"; } @@ -3357,70 +3348,6 @@ void HtmlGenerator::findAllClasses(const InnerNode *node) } } -/*! - For generating the "New Classes... in 4.6" section on the - What's New in 4.6" page. - */ -void HtmlGenerator::findAllSince(const InnerNode *node) -{ - NodeList::const_iterator child = node->childNodes().constBegin(); - while (child != node->childNodes().constEnd()) { - QString sinceVersion = (*child)->since(); - if (((*child)->access() != Node::Private) && !sinceVersion.isEmpty()) { - NewSinceMaps::iterator nsmap = newSinceMaps.find(sinceVersion); - if (nsmap == newSinceMaps.end()) - nsmap = newSinceMaps.insert(sinceVersion,NodeMultiMap()); - NewClassMaps::iterator ncmap = newClassMaps.find(sinceVersion); - if (ncmap == newClassMaps.end()) - ncmap = newClassMaps.insert(sinceVersion,NodeMap()); - NewClassMaps::iterator nqcmap = newQmlClassMaps.find(sinceVersion); - if (nqcmap == newQmlClassMaps.end()) - nqcmap = newQmlClassMaps.insert(sinceVersion,NodeMap()); - - if ((*child)->type() == Node::Function) { - FunctionNode *func = static_cast(*child); - if ((func->status() > Node::Obsolete) && - (func->metaness() != FunctionNode::Ctor) && - (func->metaness() != FunctionNode::Dtor)) { - nsmap.value().insert(func->name(),(*child)); - } - } - else if ((*child)->url().isEmpty()) { - if ((*child)->type() == Node::Class && !(*child)->doc().isEmpty()) { - QString className = (*child)->name(); - if ((*child)->parent() && - (*child)->parent()->type() == Node::Namespace && - !(*child)->parent()->name().isEmpty()) - className = (*child)->parent()->name()+"::"+className; - nsmap.value().insert(className,(*child)); - ncmap.value().insert(className,(*child)); - } - else if ((*child)->subType() == Node::QmlClass) { - QString className = (*child)->name(); - if ((*child)->parent() && - (*child)->parent()->type() == Node::Namespace && - !(*child)->parent()->name().isEmpty()) - className = (*child)->parent()->name()+"::"+className; - nsmap.value().insert(className,(*child)); - nqcmap.value().insert(className,(*child)); - } - } - else { - QString name = (*child)->name(); - if ((*child)->parent() && - (*child)->parent()->type() == Node::Namespace && - !(*child)->parent()->name().isEmpty()) - name = (*child)->parent()->name()+"::"+name; - nsmap.value().insert(name,(*child)); - } - if ((*child)->isInnerNode()) { - findAllSince(static_cast(*child)); - } - } - ++child; - } -} - void HtmlGenerator::findAllFunctions(const InnerNode *node) { NodeList::ConstIterator c = node->childNodes().begin(); diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h index 70ec0b7..e36c562 100644 --- a/tools/qdoc3/htmlgenerator.h +++ b/tools/qdoc3/htmlgenerator.h @@ -56,12 +56,6 @@ QT_BEGIN_NAMESPACE -typedef QMultiMap NodeMultiMap; -typedef QMap NewSinceMaps; -typedef QMap ParentMaps; -typedef QMap NodeMap; -typedef QMap NewClassMaps; - class HelpProjectWriter; class HtmlGenerator : public PageGenerator @@ -224,7 +218,6 @@ class HtmlGenerator : public PageGenerator void findAllFunctions(const InnerNode *node); void findAllLegaleseTexts(const InnerNode *node); void findAllNamespaces(const InnerNode *node); - void findAllSince(const InnerNode *node); static int hOffset(const Node *node); static bool isThreeColumnEnumValueTable(const Atom *atom); virtual QString getLink(const Atom *atom, @@ -292,10 +285,6 @@ class HtmlGenerator : public PageGenerator NodeMap qmlClasses; QMap funcIndex; QMap legaleseTexts; - NewSinceMaps newSinceMaps; - static QString sinceTitles[]; - NewClassMaps newClassMaps; - NewClassMaps newQmlClassMaps; static int id; public: static bool debugging_on; diff --git a/tools/qdoc3/node.cpp b/tools/qdoc3/node.cpp index 683c210..87bbd93 100644 --- a/tools/qdoc3/node.cpp +++ b/tools/qdoc3/node.cpp @@ -157,6 +157,16 @@ void Node::setLink(LinkType linkType, const QString &link, const QString &desc) } /*! + Sets the information about the project and version a node was introduced + in. The string is simplified, removing excess whitespace before being + stored. +*/ +void Node::setSince(const QString &since) +{ + sinc = since.simplified(); +} + +/*! Returns a string representing the access specifier. */ QString Node::accessString() const diff --git a/tools/qdoc3/node.h b/tools/qdoc3/node.h index e1e9440..cb16bea 100644 --- a/tools/qdoc3/node.h +++ b/tools/qdoc3/node.h @@ -151,7 +151,7 @@ class Node void setDoc(const Doc& doc, bool replace = false); void setStatus(Status status) { sta = status; } void setThreadSafeness(ThreadSafeness safeness) { saf = safeness; } - void setSince(const QString &since) { sinc = since; } + void setSince(const QString &since); void setRelates(InnerNode* pseudoParent); void setModuleName(const QString &module) { mod = module; } void setLink(LinkType linkType, const QString &link, const QString &desc); -- cgit v0.12 From 0d2cfeb64899e0a482eb29bebb79a74b04c7ef0f Mon Sep 17 00:00:00 2001 From: David Boddie Date: Thu, 30 Jun 2011 19:13:55 +0200 Subject: Doc: Removed whitespace. (cherry picked from commit 01b3f508d1f7e9951baf60f487feadfa98ba4751) --- doc/src/qt4-intro.qdoc | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/src/qt4-intro.qdoc b/doc/src/qt4-intro.qdoc index d75bdca..1547a7c 100644 --- a/doc/src/qt4-intro.qdoc +++ b/doc/src/qt4-intro.qdoc @@ -610,7 +610,6 @@ introduced in Qt 4.7. \sincelist 4.7 - */ /*! -- cgit v0.12 From 0db519c9fc585e509dd8138cefcb4762ed3f8b7c Mon Sep 17 00:00:00 2001 From: David Boddie Date: Thu, 30 Jun 2011 19:14:30 +0200 Subject: Doc: Standardized on QtQuick for \since declarations. (cherry picked from commit 609dc22f719ecb8d48349fd56f84960bbf46d731) --- src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp | 4 ++-- src/declarative/graphicsitems/qdeclarativeborderimage.cpp | 4 ++-- src/declarative/graphicsitems/qdeclarativeflickable.cpp | 4 ++-- src/declarative/graphicsitems/qdeclarativegridview.cpp | 2 +- src/declarative/graphicsitems/qdeclarativeimage.cpp | 4 ++-- src/declarative/graphicsitems/qdeclarativeitem.cpp | 2 +- src/declarative/graphicsitems/qdeclarativelistview.cpp | 2 +- src/declarative/graphicsitems/qdeclarativemousearea.cpp | 2 +- src/declarative/graphicsitems/qdeclarativepositioners.cpp | 6 +++--- src/declarative/graphicsitems/qdeclarativerepeater.cpp | 6 +++--- src/declarative/graphicsitems/qdeclarativetext.cpp | 8 ++++---- src/declarative/graphicsitems/qdeclarativetextedit.cpp | 10 +++++----- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 8 ++++---- 13 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp index 8787a5e..b1ebec8 100644 --- a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp @@ -114,7 +114,7 @@ QT_BEGIN_NAMESPACE /*! \qmlproperty bool AnimatedImage::cache - \since Quick 1.1 + \since QtQuick 1.1 Specifies whether the image should be cached. The default value is true. Setting \a cache to false is useful when dealing with large images, @@ -123,7 +123,7 @@ QT_BEGIN_NAMESPACE /*! \qmlproperty bool AnimatedImage::mirror - \since Quick 1.1 + \since QtQuick 1.1 This property holds whether the image should be horizontally inverted (effectively displaying a mirrored image). diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp index 9c274e9..4b4efb6 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp @@ -215,7 +215,7 @@ QDeclarativeBorderImage::~QDeclarativeBorderImage() /*! \qmlproperty bool BorderImage::cache - \since Quick 1.1 + \since QtQuick 1.1 Specifies whether the image should be cached. The default value is true. Setting \a cache to false is useful when dealing with large images, @@ -224,7 +224,7 @@ QDeclarativeBorderImage::~QDeclarativeBorderImage() /*! \qmlproperty bool BorderImage::mirror - \since Quick 1.1 + \since QtQuick 1.1 This property holds whether the image should be horizontally inverted (effectively displaying a mirrored image). diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 13bb8ef..dbab8cc 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -1393,7 +1393,7 @@ void QDeclarativeFlickable::setContentHeight(qreal h) /*! \qmlmethod Flickable::resizeContent(real width, real height, QPointF center) \preliminary - \since Quick 1.1 + \since QtQuick 1.1 Resizes the content to \a width x \a height about \a center. @@ -1433,7 +1433,7 @@ void QDeclarativeFlickable::resizeContent(qreal w, qreal h, QPointF center) /*! \qmlmethod Flickable::returnToBounds() \preliminary - \since Quick 1.1 + \since QtQuick 1.1 Ensures the content is within legal bounds. diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index a0264f7..7972b6f 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -2587,7 +2587,7 @@ void QDeclarativeGridView::positionViewAtIndex(int index, int mode) /*! \qmlmethod GridView::positionViewAtBeginning() \qmlmethod GridView::positionViewAtEnd() - \since Quick 1.1 + \since QtQuick 1.1 Positions the view at the beginning or end, taking into account any header or footer. diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index e6bb798..9b9d680 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -473,7 +473,7 @@ QRectF QDeclarativeImage::boundingRect() const /*! \qmlproperty bool Image::cache - \since Quick 1.1 + \since QtQuick 1.1 Specifies whether the image should be cached. The default value is true. Setting \a cache to false is useful when dealing with large images, @@ -482,7 +482,7 @@ QRectF QDeclarativeImage::boundingRect() const /*! \qmlproperty bool Image::mirror - \since Quick 1.1 + \since QtQuick 1.1 This property holds whether the image should be horizontally inverted (effectively displaying a mirrored image). diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 805ca4d..d36d163 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -3480,7 +3480,7 @@ qreal QDeclarativeItem::implicitHeight() const /*! \qmlproperty real Item::implicitWidth \qmlproperty real Item::implicitHeight - \since Quick 1.1 + \since QtQuick 1.1 Defines the natural width or height of the Item if no \l width or \l height is specified. diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 7a5e433..d714404 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -3009,7 +3009,7 @@ void QDeclarativeListView::positionViewAtIndex(int index, int mode) /*! \qmlmethod ListView::positionViewAtBeginning() \qmlmethod ListView::positionViewAtEnd() - \since Quick 1.1 + \since QtQuick 1.1 Positions the view at the beginning or end, taking into account any header or footer. diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index 18f008a..0e06a4c 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -419,7 +419,7 @@ void QDeclarativeMouseArea::setEnabled(bool a) /*! \qmlproperty bool MouseArea::preventStealing - \since Quick 1.1 + \since QtQuick 1.1 This property holds whether the mouse events may be stolen from this MouseArea. diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index f3d1a68..483cad4 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -584,7 +584,7 @@ QDeclarativeRow::QDeclarativeRow(QDeclarativeItem *parent) /*! \qmlproperty enumeration Row::layoutDirection - \since Quick 1.1 + \since QtQuick 1.1 This property holds the layoutDirection of the row. @@ -878,7 +878,7 @@ void QDeclarativeGrid::setFlow(Flow flow) /*! \qmlproperty enumeration Grid::layoutDirection - \since Quick 1.1 + \since QtQuick 1.1 This property holds the layout direction of the layout. @@ -1236,7 +1236,7 @@ void QDeclarativeFlow::setFlow(Flow flow) /*! \qmlproperty enumeration Flow::layoutDirection - \since Quick 1.1 + \since QtQuick 1.1 This property holds the layout direction of the layout. diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp index 813c255..e881b96 100644 --- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp +++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp @@ -128,7 +128,7 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate() /*! \qmlsignal Repeater::onItemAdded(int index, Item item) - \since Quick 1.1 + \since QtQuick 1.1 This handler is called when an item is added to the repeater. The \a index parameter holds the index at which the item has been inserted within the @@ -137,7 +137,7 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate() /*! \qmlsignal Repeater::onItemRemoved(int index, Item item) - \since Quick 1.1 + \since QtQuick 1.1 This handler is called when an item is removed from the repeater. The \a index parameter holds the index at which the item was removed from the repeater, @@ -306,7 +306,7 @@ int QDeclarativeRepeater::count() const /*! \qmlmethod Item Repeater::itemAt(index) - \since Quick 1.1 + \since QtQuick 1.1 Returns the \l Item that has been created at the given \a index, or \c null if no item exists at \a index. diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 54ff406..20e4eef 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -1190,7 +1190,7 @@ void QDeclarativeText::setWrapMode(WrapMode mode) /*! \qmlproperty int Text::lineCount - \since Quick 1.1 + \since QtQuick 1.1 Returns the number of lines visible in the text item. @@ -1206,7 +1206,7 @@ int QDeclarativeText::lineCount() const /*! \qmlproperty bool Text::truncated - \since Quick 1.1 + \since QtQuick 1.1 Returns true if the text has been truncated due to \l maximumLineCount or \l elide. @@ -1223,7 +1223,7 @@ bool QDeclarativeText::truncated() const /*! \qmlproperty int Text::maximumLineCount - \since Quick 1.1 + \since QtQuick 1.1 Set this property to limit the number of lines that the text item will show. If elide is set to Text.ElideRight, the text will be elided appropriately. @@ -1457,7 +1457,7 @@ qreal QDeclarativeText::paintedHeight() const /*! \qmlproperty real Text::lineHeight - \since Quick 1.1 + \since QtQuick 1.1 Sets the line height for the text. The value can be in pixels or a multiplier depending on lineHeightMode. diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 20b2e76..ca7e948 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -107,7 +107,7 @@ TextEdit { /*! \qmlsignal TextEdit::onLinkActivated(string link) - \since Quick 1.1 + \since QtQuick 1.1 This handler is called when the user clicks on a link embedded in the text. The link must be in rich text or HTML format and the @@ -615,7 +615,7 @@ void QDeclarativeTextEdit::setWrapMode(WrapMode mode) /*! \qmlproperty int TextEdit::lineCount - \since Quick 1.1 + \since QtQuick 1.1 Returns the total number of lines in the textEdit item. */ @@ -709,7 +709,7 @@ void QDeclarativeTextEdit::moveCursorSelection(int pos) /*! \qmlmethod void TextEdit::moveCursorSelection(int position, SelectionMode mode = TextEdit.SelectCharacters) - \since Quick 1.1 + \since QtQuick 1.1 Moves the cursor to \a position and updates the selection according to the optional \a mode parameter. (To only move the cursor, set the \l cursorPosition property.) @@ -1074,7 +1074,7 @@ void QDeclarativeTextEdit::setSelectByMouse(bool on) /*! \qmlproperty enum TextEdit::mouseSelectionMode - \since Quick 1.1 + \since QtQuick 1.1 Specifies how text should be selected using a mouse. @@ -1220,7 +1220,7 @@ void QDeclarativeTextEditPrivate::focusChanged(bool hasFocus) /*! \qmlmethod void TextEdit::deselect() - \since Quick 1.1 + \since QtQuick 1.1 Removes active text selection. */ diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index d2897eb..7014571 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -1014,7 +1014,7 @@ int QDeclarativeTextInput::positionAt(int x) const /*! \qmlmethod int TextInput::positionAt(int x, CursorPosition position = CursorBetweenCharacters) - \since Quick 1.1 + \since QtQuick 1.1 This function returns the character position at x pixels from the left of the textInput. Position 0 is before the @@ -1402,7 +1402,7 @@ QVariant QDeclarativeTextInput::inputMethodQuery(Qt::InputMethodQuery property) /*! \qmlmethod void TextInput::deselect() - \since Quick 1.1 + \since QtQuick 1.1 Removes active text selection. */ @@ -1574,7 +1574,7 @@ void QDeclarativeTextInput::setSelectByMouse(bool on) /*! \qmlproperty enum TextInput::mouseSelectionMode - \since Quick 1.1 + \since QtQuick 1.1 Specifies how text should be selected using a mouse. @@ -1622,7 +1622,7 @@ void QDeclarativeTextInput::moveCursorSelection(int position) /*! \qmlmethod void TextInput::moveCursorSelection(int position, SelectionMode mode = TextInput.SelectCharacters) - \since Quick 1.1 + \since QtQuick 1.1 Moves the cursor to \a position and updates the selection according to the optional \a mode parameter. (To only move the cursor, set the \l cursorPosition property.) -- cgit v0.12 From 16355187f69d4431b79b05201b36729c8e5102fe Mon Sep 17 00:00:00 2001 From: David Boddie Date: Thu, 30 Jun 2011 19:16:21 +0200 Subject: Doc: Fixed \since declarations. (cherry picked from commit 358e018dbb4b4dbdbfc702a6d462f113a1357e1e) --- src/gui/kernel/qkeysequence.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 117b72f..5fc72d4 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -933,7 +933,7 @@ QKeySequence::QKeySequence(const QString &key) } /*! - \since 4.x + \since 4.7 Creates a key sequence from the \a key string based on \a format. */ QKeySequence::QKeySequence(const QString &key, QKeySequence::SequenceFormat format) @@ -1130,7 +1130,7 @@ int QKeySequence::assign(const QString &ks) /*! \fn int QKeySequence::assign(const QString &keys, QKeySequence::SequenceFormat format) - \since 4.x + \since 4.7 Adds the given \a keys to the key sequence (based on \a format). \a keys may contain up to four key codes, provided they are -- cgit v0.12 From 8a6dc154ef1fa71e85f02d011d6cbeb63e2ca3bb Mon Sep 17 00:00:00 2001 From: David Boddie Date: Thu, 30 Jun 2011 20:48:32 +0200 Subject: Doc: Clarified the range of return values from QLineF::angle(). Task-number: QTBUG-20197 (cherry picked from commit 86608d537eabc3cf7e1d1ddd1d0a2f90ccc2de2a) --- src/corelib/tools/qline.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qline.cpp b/src/corelib/tools/qline.cpp index af3b7d5..0f67652 100644 --- a/src/corelib/tools/qline.cpp +++ b/src/corelib/tools/qline.cpp @@ -564,8 +564,9 @@ qreal QLineF::length() const Returns the angle of the line in degrees. - Positive values for the angles mean counter-clockwise while negative values - mean the clockwise direction. Zero degrees is at the 3 o'clock position. + The return value will be in the range of values from 0.0 up to but not + including 360.0. The angles are measured counter-clockwise from a point + on the x-axis to the right of the origin (x > 0). \sa setAngle() */ -- cgit v0.12 From 3b6a61953bcd319a6df55d66116ce92f7525ec00 Mon Sep 17 00:00:00 2001 From: Honglei Zhang Date: Sun, 3 Jul 2011 20:22:41 +0300 Subject: Enable key capture and RemCon interfaces for Qt apps on Symbian The volume and other multimedia keys in Symbian are not delivered through the normal key events, but through a seperate API called CRemConCoreApiTarget. The commit implements the feature that multimedia key events are delivered via normal key events to Qt Application, if the Qt::AA_CaptureMultimediaKeys is defined. Task-number: QTBUG-4415 Reviewed-by: Sami Merila Reviewed-by: Miikka Heikkinen --- src/corelib/global/qnamespace.h | 1 + src/corelib/global/qnamespace.qdoc | 9 + src/gui/kernel/qkeymapper_p.h | 2 + src/gui/kernel/qkeymapper_s60.cpp | 195 +++++++------ src/gui/s60framework/qs60keycapture.cpp | 308 +++++++++++++++++++++ src/gui/s60framework/qs60keycapture_p.h | 116 ++++++++ src/gui/s60framework/qs60mainappui.cpp | 17 ++ src/gui/s60framework/s60framework.pri | 21 +- .../qs60mainapplication/qs60mainapplication.pro | 1 + .../tst_qs60mainapplication.cpp | 259 +++++++++++++++++ 10 files changed, 838 insertions(+), 91 deletions(-) create mode 100644 src/gui/s60framework/qs60keycapture.cpp create mode 100644 src/gui/s60framework/qs60keycapture_p.h diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 99479d0..e247533 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -546,6 +546,7 @@ public: AA_S60DontConstructApplicationPanes = 8, AA_S60DisablePartialScreenInputMode = 9, AA_X11InitThreads = 10, + AA_CaptureMultimediaKeys = 11, // Add new attributes before this line AA_AttributeCount diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 9f59c6e..7d3b7f6 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -167,6 +167,15 @@ construction in order to make Xlib calls thread-safe. This attribute must be set before QApplication is constructed. + \value AA_CaptureMultimediaKeys Enables application to receive multimedia key events + (play, next, previous etc). This includes also external sources such as headsets. + Application can not use Remote Control framework on Symbian if this attribute is + set. On Symbian, multimedia key event routing may vary between different devices. + For example, application on background may receive multimedia key events only if + it has active audio stream i.e. it is playing music or video. This attribute must + be set before QApplication is constructed. This attribute is only supported in Symbian + platform. + \omitvalue AA_AttributeCount */ diff --git a/src/gui/kernel/qkeymapper_p.h b/src/gui/kernel/qkeymapper_p.h index 2607c2a..1d624f9 100644 --- a/src/gui/kernel/qkeymapper_p.h +++ b/src/gui/kernel/qkeymapper_p.h @@ -213,6 +213,8 @@ public: int mapS60ScanCodesToQt(TUint s60key); int mapQtToS60Key(int qtKey); int mapQtToS60ScanCodes(int qtKey); + int mapS60RemConIdToS60Key(int s60RemConId); + int mapS60RemConIdToS60ScanCodes(int s60RemConId); void updateInputLanguage(); #endif }; diff --git a/src/gui/kernel/qkeymapper_s60.cpp b/src/gui/kernel/qkeymapper_s60.cpp index 1113b77..2a7083e 100644 --- a/src/gui/kernel/qkeymapper_s60.cpp +++ b/src/gui/kernel/qkeymapper_s60.cpp @@ -87,97 +87,104 @@ QString QKeyMapperPrivate::translateKeyEvent(int keySym, Qt::KeyboardModifiers / } #include +#include struct KeyMapping{ TKeyCode s60KeyCode; TStdScanCode s60ScanCode; + TRemConCoreApiOperationId s60RemConId; Qt::Key qtKey; }; using namespace Qt; +// key mapping table in the format of +// {S60 key code, S60 scan code, S60 RemCon operation Id, Qt key code} static const KeyMapping keyMapping[] = { - {EKeyBackspace, EStdKeyBackspace, Key_Backspace}, - {EKeyTab, EStdKeyTab, Key_Tab}, - {EKeyEnter, EStdKeyEnter, Key_Enter}, - {EKeyEscape, EStdKeyEscape, Key_Escape}, - {EKeySpace, EStdKeySpace, Key_Space}, - {EKeyDelete, EStdKeyDelete, Key_Delete}, - {EKeyPrintScreen, EStdKeyPrintScreen, Key_SysReq}, - {EKeyPause, EStdKeyPause, Key_Pause}, - {EKeyHome, EStdKeyHome, Key_Home}, - {EKeyEnd, EStdKeyEnd, Key_End}, - {EKeyPageUp, EStdKeyPageUp, Key_PageUp}, - {EKeyPageDown, EStdKeyPageDown, Key_PageDown}, - {EKeyInsert, EStdKeyInsert, Key_Insert}, - {EKeyLeftArrow, EStdKeyLeftArrow, Key_Left}, - {EKeyRightArrow, EStdKeyRightArrow, Key_Right}, - {EKeyUpArrow, EStdKeyUpArrow, Key_Up}, - {EKeyDownArrow, EStdKeyDownArrow, Key_Down}, - {EKeyLeftShift, EStdKeyLeftShift, Key_Shift}, - {EKeyRightShift, EStdKeyRightShift, Key_Shift}, - {EKeyLeftAlt, EStdKeyLeftAlt, Key_Alt}, - {EKeyRightAlt, EStdKeyRightAlt, Key_AltGr}, - {EKeyLeftCtrl, EStdKeyLeftCtrl, Key_Control}, - {EKeyRightCtrl, EStdKeyRightCtrl, Key_Control}, - {EKeyLeftFunc, EStdKeyLeftFunc, Key_Super_L}, - {EKeyRightFunc, EStdKeyRightFunc, Key_Super_R}, - {EKeyCapsLock, EStdKeyCapsLock, Key_CapsLock}, - {EKeyNumLock, EStdKeyNumLock, Key_NumLock}, - {EKeyScrollLock, EStdKeyScrollLock, Key_ScrollLock}, - {EKeyF1, EStdKeyF1, Key_F1}, - {EKeyF2, EStdKeyF2, Key_F2}, - {EKeyF3, EStdKeyF3, Key_F3}, - {EKeyF4, EStdKeyF4, Key_F4}, - {EKeyF5, EStdKeyF5, Key_F5}, - {EKeyF6, EStdKeyF6, Key_F6}, - {EKeyF7, EStdKeyF7, Key_F7}, - {EKeyF8, EStdKeyF8, Key_F8}, - {EKeyF9, EStdKeyF9, Key_F9}, - {EKeyF10, EStdKeyF10, Key_F10}, - {EKeyF11, EStdKeyF11, Key_F11}, - {EKeyF12, EStdKeyF12, Key_F12}, - {EKeyF13, EStdKeyF13, Key_F13}, - {EKeyF14, EStdKeyF14, Key_F14}, - {EKeyF15, EStdKeyF15, Key_F15}, - {EKeyF16, EStdKeyF16, Key_F16}, - {EKeyF17, EStdKeyF17, Key_F17}, - {EKeyF18, EStdKeyF18, Key_F18}, - {EKeyF19, EStdKeyF19, Key_F19}, - {EKeyF20, EStdKeyF20, Key_F20}, - {EKeyF21, EStdKeyF21, Key_F21}, - {EKeyF22, EStdKeyF22, Key_F22}, - {EKeyF23, EStdKeyF23, Key_F23}, - {EKeyF24, EStdKeyF24, Key_F24}, - {EKeyOff, EStdKeyOff, Key_PowerOff}, -// {EKeyMenu, EStdKeyMenu, Key_Menu}, // Menu is EKeyApplication0 - {EKeyHelp, EStdKeyHelp, Key_Help}, - {EKeyDial, EStdKeyDial, Key_Call}, - {EKeyIncVolume, EStdKeyIncVolume, Key_VolumeUp}, - {EKeyDecVolume, EStdKeyDecVolume, Key_VolumeDown}, - {EKeyDevice0, EStdKeyDevice0, Key_Context1}, // Found by manual testing. - {EKeyDevice1, EStdKeyDevice1, Key_Context2}, // Found by manual testing. - {EKeyDevice3, EStdKeyDevice3, Key_Select}, - {EKeyDevice7, EStdKeyDevice7, Key_Camera}, - {EKeyApplication0, EStdKeyApplication0, Key_Menu}, // Found by manual testing. - {EKeyApplication1, EStdKeyApplication1, Key_Launch1}, // Found by manual testing. - {EKeyApplication2, EStdKeyApplication2, Key_MediaPlay}, // Found by manual testing. - {EKeyApplication3, EStdKeyApplication3, Key_MediaStop}, // Found by manual testing. - {EKeyApplication4, EStdKeyApplication4, Key_MediaNext}, // Found by manual testing. - {EKeyApplication5, EStdKeyApplication5, Key_MediaPrevious}, // Found by manual testing. - {EKeyApplication6, EStdKeyApplication6, Key_Launch6}, - {EKeyApplication7, EStdKeyApplication7, Key_Launch7}, - {EKeyApplication8, EStdKeyApplication8, Key_Launch8}, - {EKeyApplication9, EStdKeyApplication9, Key_Launch9}, - {EKeyApplicationA, EStdKeyApplicationA, Key_LaunchA}, - {EKeyApplicationB, EStdKeyApplicationB, Key_LaunchB}, - {EKeyApplicationC, EStdKeyApplicationC, Key_LaunchC}, - {EKeyApplicationD, EStdKeyApplicationD, Key_LaunchD}, - {EKeyApplicationE, EStdKeyApplicationE, Key_LaunchE}, - {EKeyApplicationF, EStdKeyApplicationF, Key_LaunchF}, - {EKeyApplication19, EStdKeyApplication19, Key_CameraFocus}, - {EKeyYes, EStdKeyYes, Key_Yes}, - {EKeyNo, EStdKeyNo, Key_No}, - {TKeyCode(0), TStdScanCode(0), Qt::Key(0)} + {EKeyBackspace, EStdKeyBackspace, ENop, Key_Backspace}, + {EKeyTab, EStdKeyTab, ENop, Key_Tab}, + {EKeyEnter, EStdKeyEnter, ERemConCoreApiEnter, Key_Enter}, + {EKeyEscape, EStdKeyEscape, ENop, Key_Escape}, + {EKeySpace, EStdKeySpace, ENop, Key_Space}, + {EKeyDelete, EStdKeyDelete, ENop, Key_Delete}, + {EKeyPrintScreen, EStdKeyPrintScreen, ENop, Key_SysReq}, + {EKeyPause, EStdKeyPause, ENop, Key_Pause}, + {EKeyHome, EStdKeyHome, ENop, Key_Home}, + {EKeyEnd, EStdKeyEnd, ENop, Key_End}, + {EKeyPageUp, EStdKeyPageUp, ERemConCoreApiPageUp, Key_PageUp}, + {EKeyPageDown, EStdKeyPageDown, ERemConCoreApiPageDown, Key_PageDown}, + {EKeyInsert, EStdKeyInsert, ENop, Key_Insert}, + {EKeyLeftArrow, EStdKeyLeftArrow, ERemConCoreApiLeft, Key_Left}, + {EKeyRightArrow, EStdKeyRightArrow, ERemConCoreApiRight, Key_Right}, + {EKeyUpArrow, EStdKeyUpArrow, ERemConCoreApiUp, Key_Up}, + {EKeyDownArrow, EStdKeyDownArrow, ERemConCoreApiDown, Key_Down}, + {EKeyLeftShift, EStdKeyLeftShift, ENop, Key_Shift}, + {EKeyRightShift, EStdKeyRightShift, ENop, Key_Shift}, + {EKeyLeftAlt, EStdKeyLeftAlt, ENop, Key_Alt}, + {EKeyRightAlt, EStdKeyRightAlt, ENop, Key_AltGr}, + {EKeyLeftCtrl, EStdKeyLeftCtrl, ENop, Key_Control}, + {EKeyRightCtrl, EStdKeyRightCtrl, ENop, Key_Control}, + {EKeyLeftFunc, EStdKeyLeftFunc, ENop, Key_Super_L}, + {EKeyRightFunc, EStdKeyRightFunc, ENop, Key_Super_R}, + {EKeyCapsLock, EStdKeyCapsLock, ENop, Key_CapsLock}, + {EKeyNumLock, EStdKeyNumLock, ENop, Key_NumLock}, + {EKeyScrollLock, EStdKeyScrollLock, ENop, Key_ScrollLock}, + {EKeyF1, EStdKeyF1, ERemConCoreApiF1, Key_F1}, + {EKeyF2, EStdKeyF2, ERemConCoreApiF2, Key_F2}, + {EKeyF3, EStdKeyF3, ERemConCoreApiF3, Key_F3}, + {EKeyF4, EStdKeyF4, ERemConCoreApiF4, Key_F4}, + {EKeyF5, EStdKeyF5, ERemConCoreApiF5, Key_F5}, + {EKeyF6, EStdKeyF6, ENop, Key_F6}, + {EKeyF7, EStdKeyF7, ENop, Key_F7}, + {EKeyF8, EStdKeyF8, ENop, Key_F8}, + {EKeyF9, EStdKeyF9, ENop, Key_F9}, + {EKeyF10, EStdKeyF10, ENop, Key_F10}, + {EKeyF11, EStdKeyF11, ENop, Key_F11}, + {EKeyF12, EStdKeyF12, ENop, Key_F12}, + {EKeyF13, EStdKeyF13, ENop, Key_F13}, + {EKeyF14, EStdKeyF14, ENop, Key_F14}, + {EKeyF15, EStdKeyF15, ENop, Key_F15}, + {EKeyF16, EStdKeyF16, ENop, Key_F16}, + {EKeyF17, EStdKeyF17, ENop, Key_F17}, + {EKeyF18, EStdKeyF18, ENop, Key_F18}, + {EKeyF19, EStdKeyF19, ENop, Key_F19}, + {EKeyF20, EStdKeyF20, ENop, Key_F20}, + {EKeyF21, EStdKeyF21, ENop, Key_F21}, + {EKeyF22, EStdKeyF22, ENop, Key_F22}, + {EKeyF23, EStdKeyF23, ENop, Key_F23}, + {EKeyF24, EStdKeyF24, ENop, Key_F24}, + {EKeyOff, EStdKeyOff, ENop, Key_PowerOff}, +// {EKeyMenu, EStdKeyMenu, ENop, Key_Menu}, // Menu is EKeyApplication0 + {EKeyHelp, EStdKeyHelp, ERemConCoreApiHelp, Key_Help}, + {EKeyDial, EStdKeyDial, ENop, Key_Call}, + {EKeyIncVolume, EStdKeyIncVolume, ERemConCoreApiVolumeUp, Key_VolumeUp}, + {EKeyDecVolume, EStdKeyDecVolume, ERemConCoreApiVolumeDown, Key_VolumeDown}, + {EKeyDevice0, EStdKeyDevice0, ENop, Key_Context1}, // Found by manual testing. + {EKeyDevice1, EStdKeyDevice1, ENop, Key_Context2}, // Found by manual testing. + {EKeyDevice3, EStdKeyDevice3, ERemConCoreApiSelect, Key_Select}, + {EKeyDevice7, EStdKeyDevice7, ENop, Key_Camera}, + {EKeyApplication0, EStdKeyApplication0, ENop, Key_Menu}, // Found by manual testing. + {EKeyApplication1, EStdKeyApplication1, ENop, Key_Launch1}, // Found by manual testing. + {EKeyApplication2, EStdKeyApplication2, ERemConCoreApiPlay, Key_MediaPlay}, // Found by manual testing. + {EKeyApplication3, EStdKeyApplication3, ERemConCoreApiStop, Key_MediaStop}, // Found by manual testing. + {EKeyApplication4, EStdKeyApplication4, ERemConCoreApiForward, Key_MediaNext}, // Found by manual testing. + {EKeyApplication5, EStdKeyApplication5, ERemConCoreApiBackward, Key_MediaPrevious}, // Found by manual testing. + {EKeyApplication6, EStdKeyApplication6, ENop, Key_Launch6}, + {EKeyApplication7, EStdKeyApplication7, ENop, Key_Launch7}, + {EKeyApplication8, EStdKeyApplication8, ENop, Key_Launch8}, + {EKeyApplication9, EStdKeyApplication9, ENop, Key_Launch9}, + {EKeyApplicationA, EStdKeyApplicationA, ENop, Key_LaunchA}, + {EKeyApplicationB, EStdKeyApplicationB, ENop, Key_LaunchB}, + {EKeyApplicationC, EStdKeyApplicationC, ENop, Key_LaunchC}, + {EKeyApplicationD, EStdKeyApplicationD, ENop, Key_LaunchD}, + {EKeyApplicationE, EStdKeyApplicationE, ENop, Key_LaunchE}, + {EKeyApplicationF, EStdKeyApplicationF, ENop, Key_LaunchF}, + {EKeyApplication19, EStdKeyApplication19, ENop, Key_CameraFocus}, + {EKeyYes, EStdKeyYes, ENop, Key_Yes}, + {EKeyNo, EStdKeyNo, ENop, Key_No}, + {EKeyDevice20, EStdKeyDevice20, ERemConCoreApiPausePlayFunction, Key_MediaTogglePlayPause}, + {EKeyDevice21, EStdKeyDevice21, ERemConCoreApiRewind, Key_AudioRewind}, + {EKeyDevice22, EStdKeyDevice22, ERemConCoreApiFastForward, Key_AudioForward}, + {TKeyCode(0), TStdScanCode(0), ENop, Qt::Key(0)} }; int QKeyMapperPrivate::mapS60KeyToQt(TUint s60key) @@ -228,6 +235,30 @@ int QKeyMapperPrivate::mapQtToS60ScanCodes(int qtKey) return res; } +int QKeyMapperPrivate::mapS60RemConIdToS60Key(int s60RemConId) +{ + int res = KErrUnknown; + for (int i = 0; keyMapping[i].s60KeyCode != 0; i++) { + if (keyMapping[i].s60RemConId == s60RemConId) { + res = keyMapping[i].s60KeyCode; + break; + } + } + return res; +} + +int QKeyMapperPrivate::mapS60RemConIdToS60ScanCodes(int s60RemConId) +{ + int res = KErrUnknown; + for (int i = 0; keyMapping[i].s60KeyCode != 0; i++) { + if (keyMapping[i].s60RemConId == s60RemConId) { + res = keyMapping[i].s60ScanCode; + break; + } + } + return res; +} + void QKeyMapperPrivate::updateInputLanguage() { #ifdef Q_WS_S60 diff --git a/src/gui/s60framework/qs60keycapture.cpp b/src/gui/s60framework/qs60keycapture.cpp new file mode 100644 index 0000000..db4cc0e --- /dev/null +++ b/src/gui/s60framework/qs60keycapture.cpp @@ -0,0 +1,308 @@ +/**************************************************************************** +** +** 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 QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include "qkeymapper_p.h" +#include "qs60keycapture_p.h" + +QT_BEGIN_NAMESPACE + +/* + * Helper class for sending key handling responses to RemCon. +*/ +class CResponseHandler : public CActive +{ +public: + static CResponseHandler *NewL(CRemConCoreApiTarget &remConCoreApiTarget); + virtual ~CResponseHandler(); + void CompleteAnyKey(TRemConCoreApiOperationId operationId); + +private: + CResponseHandler(CRemConCoreApiTarget &remConCoreApiTarget); + + void RunL(); + void DoCancel(); + +private: + RArray iResponseArray; + CRemConCoreApiTarget &iRemConCoreApiTarget; +}; + +CResponseHandler::CResponseHandler(CRemConCoreApiTarget &remConCoreApiTarget) + : CActive(CActive::EPriorityStandard), + iRemConCoreApiTarget(remConCoreApiTarget) +{ + CActiveScheduler::Add(this); +} + +CResponseHandler *CResponseHandler::NewL(CRemConCoreApiTarget &remConCoreApiTarget) +{ + CResponseHandler *self = + new (ELeave) CResponseHandler(remConCoreApiTarget); + return self; +} + +CResponseHandler::~CResponseHandler() +{ + Cancel(); + iResponseArray.Close(); +} + +void CResponseHandler::CompleteAnyKey(TRemConCoreApiOperationId operationId) +{ + if (!IsActive()) { + TInt error = KErrNone; + iRemConCoreApiTarget.SendResponse(iStatus, operationId, error); + SetActive(); + } else { + // already active. Append to array and complete later. + iResponseArray.Append(operationId); + } +} + +void CResponseHandler::DoCancel() +{ + iRemConCoreApiTarget.Cancel(); +} + +void CResponseHandler::RunL() +{ + // if any existing -> Send response + if (iResponseArray.Count()) { + CompleteAnyKey(iResponseArray[0]); + // Remove already completed key + iResponseArray.Remove(0); + iResponseArray.Compress(); + } +} + + +/* + * QS60KeyCapture provides media key handling using services from RemCon. + */ +QS60KeyCapture::QS60KeyCapture(CCoeEnv *env, QObject *parent): + QObject(parent), coeEnv(env), selector(0), target(0), handler(0) +{ + initRemCon(); + + TTimeIntervalMicroSeconds32 initialTime; + TTimeIntervalMicroSeconds32 time; + coeEnv->WsSession().GetKeyboardRepeatRate(initialTime, time); + initialRepeatTime = (initialTime.Int() / 1000); // msecs + repeatTime = (time.Int() / 1000); // msecs + + int clickTimeout = initialRepeatTime + repeatTime; + + volumeUpClickTimer.setSingleShot(true); + volumeDownClickTimer.setSingleShot(true); + repeatTimer.setSingleShot(true); + + volumeUpClickTimer.setInterval(clickTimeout); + volumeDownClickTimer.setInterval(clickTimeout); + repeatTimer.setInterval(initialRepeatTime); + + connect(&volumeUpClickTimer, SIGNAL(timeout()), this, SLOT(volumeUpClickTimerExpired())); + connect(&volumeDownClickTimer, SIGNAL(timeout()), this, SLOT(volumeDownClickTimerExpired())); + connect(&repeatTimer, SIGNAL(timeout()), this, SLOT(repeatTimerExpired())); +} + +/* + * Initializes RemCon connection for receiving key events + */ +void QS60KeyCapture::initRemCon() +{ + try { + QT_TRAP_THROWING( + selector = CRemConInterfaceSelector::NewL(); + target = CRemConCoreApiTarget::NewL(*selector, *this); + handler = CResponseHandler::NewL(*target); + selector->OpenTargetL()); + } catch (const std::exception &e) { + delete handler; + delete selector; + selector = 0; + target = 0; + handler = 0; + } +} + +QS60KeyCapture::~QS60KeyCapture() +{ + delete handler; + delete selector; +} + +void QS60KeyCapture::MrccatoCommand(TRemConCoreApiOperationId operationId, + TRemConCoreApiButtonAction buttonAction) +{ + if (!target) + return; + + switch (operationId) { + // Volume up/down keys auto repeat if user hold the key long enough + case ERemConCoreApiVolumeUp: + case ERemConCoreApiVolumeDown: + { + // Side key events are sent using following scheme: + // - ButtonClick is sent first + // - if nothing happens before repeat timer expires, no further events are generated + // - if user holds the button longer, ButtonPress is sent and + // when button is finally released ButtonRelease is sent. + + QTimer &timer = (operationId == ERemConCoreApiVolumeUp) ? volumeUpClickTimer : volumeDownClickTimer; + + switch (buttonAction) { + case ERemConCoreApiButtonPress: + if (timer.isActive()) { + timer.stop(); + // force repeat event + repeatKeyEvent = mapToKeyEvent(operationId); + repeatTimerExpired(); + } else { + sendKey(operationId, QEvent::KeyPress); + repeatTimer.start(initialRepeatTime); + } + break; + case ERemConCoreApiButtonRelease: + timer.stop(); + sendKey(operationId, QEvent::KeyRelease); + repeatTimer.stop(); + break; + case ERemConCoreApiButtonClick: + if (timer.isActive()) { + timer.stop(); + sendKey(operationId, QEvent::KeyRelease); + } + sendKey(operationId, QEvent::KeyPress); + timer.start(); + repeatTimer.stop(); + break; + default: + break; + } + } + break; + default: + switch (buttonAction) { + case ERemConCoreApiButtonPress: + sendKey(operationId, QEvent::KeyPress); + repeatTimer.start(initialRepeatTime); + break; + case ERemConCoreApiButtonRelease: + sendKey(operationId, QEvent::KeyRelease); + repeatTimer.stop(); + break; + case ERemConCoreApiButtonClick: + sendKey(operationId, QEvent::KeyPress); + sendKey(operationId, QEvent::KeyRelease); + repeatTimer.stop(); + break; + default: + break; + } + break; + } + + if (handler) + handler->CompleteAnyKey(operationId); +} + +/* + * Sends volume up KeyRelease event + */ +void QS60KeyCapture::volumeUpClickTimerExpired() +{ + sendKey(ERemConCoreApiVolumeUp, QEvent::KeyRelease); +} + +/* + * Sends volume down KeyRelease event + */ +void QS60KeyCapture::volumeDownClickTimerExpired() +{ + sendKey(ERemConCoreApiVolumeDown, QEvent::KeyRelease); +} + +/* + * Repeats last key event + */ +void QS60KeyCapture::repeatTimerExpired() +{ + // set auto repeat flag on + repeatKeyEvent.iRepeats = 1; + coeEnv->SimulateKeyEventL(repeatKeyEvent, EEventKey); + repeatTimer.start(repeatTime); +} + +/* + * Maps RemCon operation id to key event (includes key code and scan codes) + */ +TKeyEvent QS60KeyCapture::mapToKeyEvent(TRemConCoreApiOperationId operationId) +{ + TKeyEvent keyEvent; + keyEvent.iModifiers = 0; + keyEvent.iRepeats = 0; + keyEvent.iCode = qt_keymapper_private()->mapS60RemConIdToS60Key(operationId); + keyEvent.iScanCode = qt_keymapper_private()->mapS60RemConIdToS60ScanCodes(operationId); + return keyEvent; +} + +/* + * Delivers key events to the application. + * RemCon operations are converted to simulated key events + */ +void QS60KeyCapture::sendKey(TRemConCoreApiOperationId operationId, QEvent::Type type) +{ + TKeyEvent keyEvent = mapToKeyEvent(operationId); + + if (type == QEvent::KeyPress) { + coeEnv->SimulateKeyEventL(keyEvent, EEventKeyDown); + coeEnv->SimulateKeyEventL(keyEvent, EEventKey); + // save the key press event for repeats + repeatKeyEvent = keyEvent; + } else { + coeEnv->SimulateKeyEventL(keyEvent, EEventKeyUp); + } +} + +QT_END_NAMESPACE diff --git a/src/gui/s60framework/qs60keycapture_p.h b/src/gui/s60framework/qs60keycapture_p.h new file mode 100644 index 0000000..41cb765 --- /dev/null +++ b/src/gui/s60framework/qs60keycapture_p.h @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** 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 QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QS60KEYCAPTURE_P_H +#define QS60KEYCAPTURE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#ifdef Q_OS_SYMBIAN + +#include +#include +#include +#include +#include + +class CRemConInterfaceSelector; +class CRemConCoreApiTarget; +class CResponseHandler; +class CCoeEnv; + +QT_BEGIN_NAMESPACE + +class QS60KeyCapture: public QObject, + public MRemConCoreApiTargetObserver +{ + Q_OBJECT +public: + QS60KeyCapture(CCoeEnv *env, QObject *parent = 0); + ~QS60KeyCapture(); + + void MrccatoCommand(TRemConCoreApiOperationId operationId, + TRemConCoreApiButtonAction buttonAct); + +private slots: + void volumeUpClickTimerExpired(); + void volumeDownClickTimerExpired(); + void repeatTimerExpired(); + +private: + void sendKey(TRemConCoreApiOperationId operationId, QEvent::Type type); + TKeyEvent mapToKeyEvent(TRemConCoreApiOperationId operationId); + void initRemCon(); + +private: + QS60KeyCapture(); + Q_DISABLE_COPY(QS60KeyCapture) + + CCoeEnv *coeEnv; + + CRemConInterfaceSelector *selector; + CRemConCoreApiTarget *target; + CResponseHandler *handler; + + QTimer volumeUpClickTimer; + QTimer volumeDownClickTimer; + + TKeyEvent repeatKeyEvent; + int initialRepeatTime; // time before first repeat key event + int repeatTime; // time between subsequent repeat key events + QTimer repeatTimer; +}; + +QT_END_NAMESPACE + +#endif // Q_OS_SYMBIAN +#endif // QS60KEYCAPTURE_P_H diff --git a/src/gui/s60framework/qs60mainappui.cpp b/src/gui/s60framework/qs60mainappui.cpp index bfd1825..f120287 100644 --- a/src/gui/s60framework/qs60mainappui.cpp +++ b/src/gui/s60framework/qs60mainappui.cpp @@ -59,6 +59,7 @@ #include #include #include +#include "qs60keycapture_p.h" //Animated wallpapers in Qt applications are not supported. const TInt KAknDisableAnimationBackground = 0x02000000; @@ -66,6 +67,20 @@ const TInt KAknSingleClickCompatible = 0x01000000; QT_BEGIN_NAMESPACE +static QS60KeyCapture *qt_S60KeyCapture = 0; + +static void installS60KeyCapture(CCoeEnv *env) +{ + if (QApplication::testAttribute(Qt::AA_CaptureMultimediaKeys)) + qt_S60KeyCapture = new QS60KeyCapture(env); +} + +static void removeS60KeyCapture() +{ + delete qt_S60KeyCapture; + qt_S60KeyCapture = 0; +} + /*! \class QS60MainAppUi \since 4.6 @@ -127,6 +142,7 @@ void QS60MainAppUi::ConstructL() } #endif BaseConstructL(flags); + installS60KeyCapture(iCoeEnv); } /*! @@ -142,6 +158,7 @@ QS60MainAppUi::QS60MainAppUi() */ QS60MainAppUi::~QS60MainAppUi() { + removeS60KeyCapture(); } /*! diff --git a/src/gui/s60framework/s60framework.pri b/src/gui/s60framework/s60framework.pri index 19525b7..e30d2c0 100644 --- a/src/gui/s60framework/s60framework.pri +++ b/src/gui/s60framework/s60framework.pri @@ -1,10 +1,13 @@ SOURCES += s60framework/qs60mainapplication.cpp \ - s60framework/qs60mainappui.cpp \ - s60framework/qs60maindocument.cpp - -HEADERS += s60framework/qs60mainapplication_p.h \ - s60framework/qs60mainapplication.h \ - s60framework/qs60mainappui.h \ - s60framework/qs60maindocument.h - -!isEmpty(QT_LIBINFIX): DEFINES += QT_LIBINFIX_UNQUOTED=$$QT_LIBINFIX \ No newline at end of file + s60framework/qs60mainappui.cpp \ + s60framework/qs60maindocument.cpp \ + s60framework/qs60keycapture.cpp +HEADERS += qs60keycapture_p.h \ + s60framework/qs60mainapplication_p.h \ + s60framework/qs60mainapplication.h \ + s60framework/qs60mainappui.h \ + s60framework/qs60maindocument.h \ + s60framework/qs60keycapture_p.h +LIBS += -lremconcoreapi \ + -lremconinterfacebase +!isEmpty(QT_LIBINFIX):DEFINES += QT_LIBINFIX_UNQUOTED=$$QT_LIBINFIX diff --git a/tests/auto/qs60mainapplication/qs60mainapplication.pro b/tests/auto/qs60mainapplication/qs60mainapplication.pro index bbd6c30..de3f59d 100644 --- a/tests/auto/qs60mainapplication/qs60mainapplication.pro +++ b/tests/auto/qs60mainapplication/qs60mainapplication.pro @@ -2,3 +2,4 @@ load(qttest_p4) SOURCES += tst_qs60mainapplication.cpp symbian:LIBS += -lapparc -leikcore -lcone -lavkon +symbian:LIBS += -lremconcoreapi -lremconinterfacebase \ No newline at end of file diff --git a/tests/auto/qs60mainapplication/tst_qs60mainapplication.cpp b/tests/auto/qs60mainapplication/tst_qs60mainapplication.cpp index 069fd14..967ce4e 100644 --- a/tests/auto/qs60mainapplication/tst_qs60mainapplication.cpp +++ b/tests/auto/qs60mainapplication/tst_qs60mainapplication.cpp @@ -59,6 +59,8 @@ public slots: void cleanup(); private slots: void customQS60MainApplication(); + void testMultimediaKeys_data(); + void testMultimediaKeys(); }; void tst_QS60MainApplication::initTestCase() @@ -115,6 +117,201 @@ CApaApplication *factory() { return new (ELeave) CustomMainApplication; } + +#include +#include +#include +#include +#include + +class KeyGenerator : public QObject, + public MRemConCoreApiControllerObserver +{ + Q_OBJECT +public: + KeyGenerator(QObject *parent = 0); + ~KeyGenerator(); + void MrccacoResponse(TRemConCoreApiOperationId operationId, TInt error); + + void simulateKey(int qtKey); + +private: + void init(); + void cleanup(); + + CRemConInterfaceSelector *interfaceSelector; + CRemConCoreApiController *coreController; +}; + +KeyGenerator::KeyGenerator(QObject *parent) : QObject(parent) +{ + init(); +} + +KeyGenerator::~KeyGenerator() +{ + cleanup(); +} + +void KeyGenerator::MrccacoResponse(TRemConCoreApiOperationId operationId, TInt error) +{ + Q_UNUSED(operationId); + Q_UNUSED(error); +} + +/* + * Generates keyPress and keyRelease events for given key + */ +void KeyGenerator::simulateKey(int qtKey) +{ + if (!coreController) + return; + + TRemConCoreApiButtonAction action = ERemConCoreApiButtonClick; + TUint numRemotes = 0; + TRequestStatus status; + bool wait = true; + + switch (qtKey) { + // media keys + case Qt::Key_VolumeUp: + coreController->VolumeUp(status, numRemotes, action); + break; + case Qt::Key_VolumeDown: + coreController->VolumeDown(status, numRemotes, action); + break; + case Qt::Key_MediaStop: + coreController->Stop(status, numRemotes, action); + break; + case Qt::Key_MediaTogglePlayPause: + coreController->PausePlayFunction(status, numRemotes, action); + break; + case Qt::Key_MediaNext: + coreController->Forward(status, numRemotes, action); + break; + case Qt::Key_MediaPrevious: + coreController->Backward(status, numRemotes, action); + break; + case Qt::Key_AudioForward: + coreController->FastForward(status, numRemotes, action); + break; + case Qt::Key_AudioRewind: + coreController->Rewind(status, numRemotes, action); + break; + // accessory keys + case Qt::Key_Select: + coreController->Select(status, numRemotes, action); + break; + case Qt::Key_Enter: + coreController->Enter(status, numRemotes, action); + break; + case Qt::Key_PageUp: + coreController->PageUp(status, numRemotes, action); + break; + case Qt::Key_PageDown: + coreController->PageDown(status, numRemotes, action); + break; + case Qt::Key_Left: + coreController->Left(status, numRemotes, action); + break; + case Qt::Key_Right: + coreController->Right(status, numRemotes, action); + break; + case Qt::Key_Up: + coreController->Up(status, numRemotes, action); + break; + case Qt::Key_Down: + coreController->Down(status, numRemotes, action); + break; + case Qt::Key_Help: + coreController->Help(status, numRemotes, action); + break; + case Qt::Key_F1: + coreController->F1(status, numRemotes, action); + break; + case Qt::Key_F2: + coreController->F2(status, numRemotes, action); + break; + case Qt::Key_F3: + coreController->F3(status, numRemotes, action); + break; + case Qt::Key_F4: + coreController->F4(status, numRemotes, action); + break; + case Qt::Key_F5: + coreController->F5(status, numRemotes, action); + break; + default: + wait = false; + break; + } + + if (wait) + User::WaitForRequest(status); +} + +void KeyGenerator::init() +{ + try { + QT_TRAP_THROWING(interfaceSelector = CRemConInterfaceSelector::NewL()); + QT_TRAP_THROWING(coreController = CRemConCoreApiController::NewL(*interfaceSelector, *this)); + QT_TRAP_THROWING(interfaceSelector->OpenControllerL()); + } catch (const std::exception &e) { + cleanup(); + } +} + +void KeyGenerator::cleanup() +{ + delete interfaceSelector; + interfaceSelector = 0; + coreController = 0; +} + +const int keyEventTimeout = 2000; // 2secs + +class TestWidget : public QWidget +{ + Q_OBJECT +public: + TestWidget(QWidget *parent = 0); + ~TestWidget(); + +signals: + void keyPress(int key); + void keyRelease(int key); + +protected: + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *event); + +private: + QTimer exitTimer; +}; + +TestWidget::TestWidget(QWidget *parent) : QWidget(parent) +{ + // quit if no events are received + exitTimer.setSingleShot(true); + exitTimer.start(keyEventTimeout); + connect(&exitTimer, SIGNAL(timeout()), qApp, SLOT(quit())); +} + +TestWidget::~TestWidget() +{ +} + +void TestWidget::keyPressEvent(QKeyEvent *event) +{ + emit keyPress(event->key()); +} + +void TestWidget::keyReleaseEvent(QKeyEvent *event) +{ + emit keyRelease(event->key()); + qApp->quit(); // test is done so quit immediately +} + #endif // Q_WS_S60 void tst_QS60MainApplication::customQS60MainApplication() @@ -129,5 +326,67 @@ void tst_QS60MainApplication::customQS60MainApplication() #endif } +void tst_QS60MainApplication::testMultimediaKeys_data() +{ + QTest::addColumn("key"); + + QTest::newRow("Key_VolumeUp") << (int)Qt::Key_VolumeUp; + QTest::newRow("Key_VolumeDown") << (int)Qt::Key_VolumeDown; + QTest::newRow("Key_MediaStop") << (int)Qt::Key_MediaStop; + QTest::newRow("Key_MediaTogglePlayPause") << (int)Qt::Key_MediaTogglePlayPause; + QTest::newRow("Key_MediaNext") << (int)Qt::Key_MediaNext; + QTest::newRow("Key_MediaPrevious") << (int)Qt::Key_MediaPrevious; + QTest::newRow("Key_AudioForward") << (int)Qt::Key_AudioForward; + QTest::newRow("Key_AudioRewind") << (int)Qt::Key_AudioRewind; + + QTest::newRow("Key_Select") << (int)Qt::Key_Select; + QTest::newRow("Key_Enter") << (int)Qt::Key_Enter; + QTest::newRow("Key_PageUp") << (int)Qt::Key_PageUp; + QTest::newRow("Key_PageDown") << (int)Qt::Key_PageDown; + QTest::newRow("Key_Left") << (int)Qt::Key_Left; + QTest::newRow("Key_Right") << (int)Qt::Key_Right; + QTest::newRow("Key_Up") << (int)Qt::Key_Up; + QTest::newRow("Key_Down") << (int)Qt::Key_Down; + QTest::newRow("Key_Help") << (int)Qt::Key_Help; + QTest::newRow("Key_F1") << (int)Qt::Key_F1; + QTest::newRow("Key_F2") << (int)Qt::Key_F2; + QTest::newRow("Key_F3") << (int)Qt::Key_F3; + QTest::newRow("Key_F4") << (int)Qt::Key_F4; + QTest::newRow("Key_F5") << (int)Qt::Key_F5; +} + +void tst_QS60MainApplication::testMultimediaKeys() +{ +#ifndef Q_WS_S60 + QSKIP("This is an S60-only test", SkipAll); +#elif __WINS__ + QSKIP("S60 emulator not supported", SkipAll); +#else + QApplication::setAttribute(Qt::AA_CaptureMultimediaKeys); + int argc = 1; + char *argv = "tst_qs60mainapplication"; + QApplication app(argc, &argv); + + QFETCH(int, key); + KeyGenerator keyGen; + keyGen.simulateKey(key); + + TestWidget widget; + QSignalSpy keyPressSpy(&widget, SIGNAL(keyPress(int))); + QSignalSpy keyReleaseSpy(&widget, SIGNAL(keyRelease(int))); + + widget.show(); + app.exec(); + + QCOMPARE(keyPressSpy.count(), 1); + QList arguments = keyPressSpy.takeFirst(); + QVERIFY(arguments.at(0).toInt() == key); + + QCOMPARE(keyReleaseSpy.count(), 1); + arguments = keyReleaseSpy.takeFirst(); + QVERIFY(arguments.at(0).toInt() == key); +#endif +} + QTEST_APPLESS_MAIN(tst_QS60MainApplication) #include "tst_qs60mainapplication.moc" -- 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 From 685d89b68dd11263d53a2c0982f057965f7262f2 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Mon, 4 Jul 2011 13:03:02 +0300 Subject: Regression: QS60Style - All standardIcons are drawn as "small icons" StandardIcon enum comparison should be done with bitwise operation, not with value. Task-number: QTBUG-20240 Reviewed-by: Tomi Vihria --- src/gui/styles/qs60style.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 1b84aba..fc5589c 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -3810,7 +3810,7 @@ QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, #if defined(Q_WS_S60) //If new custom standardIcon is missing version information, assume S60 5.3. - if (standardIcon >= SP_CustomToolBarAdd) { + if (standardIcon & QStyle::SP_CustomBase) { if (versionSupport == QSysInfo::SV_Unknown) versionSupport = QSysInfo::SV_S60_5_3; metric = PM_SmallIconSize; -- cgit v0.12 From 57993ba7a181c92acfa8a0213ed1260c3b85fbd4 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Mon, 4 Jul 2011 11:14:42 +0200 Subject: Fix horizontal center alignment with trailing space Text drawn with horizontal center alignment (AlignHCenter) and QTextOption::IncludeTrailingSpaces flag as off should consider the trailing space width (leading space width for RTL lines), because textAdvance here ignores the space. Disregard that space width here in alignLine will make RTL lines aligned a bit to the right. In short, for something like this: |w1|space|text|w2| |<- totalWidth ->| we want to have w1 + spaceWidth = w2 = (totalWidth - textWidth)/2, so that the actual rendered text will appear at the center of the bounding rect. Task-number: QTBUG-18303 Reviewed-by: Eskil --- src/gui/text/qtextlayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 4b3c9e7..0fbf838 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -76,7 +76,7 @@ static QFixed alignLine(QTextEngine *eng, const QScriptLine &line) if (align & Qt::AlignRight) x = line.width - (line.textAdvance + eng->leadingSpaceWidth(line)); else if (align & Qt::AlignHCenter) - x = (line.width - line.textAdvance)/2; + x = (line.width - (line.textAdvance))/2 - eng->leadingSpaceWidth(line); } return x; } -- cgit v0.12 From b07919b3de8cff3e44b7271062372b14bcda5b83 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Sun, 22 May 2011 21:36:10 +0200 Subject: Add DBus VirtualObject to handle multiple paths. When a virtual object is registered with the SubPath option it will handle all dbus calls to itself and all child paths. It needs to reimplement handleMessage for that purpose. Introspection needs to be implemented manually in the introspect function. Reviewed-by: Thiago Macieira --- src/dbus/dbus.pro | 9 +- src/dbus/qdbusconnection.cpp | 52 +++++- src/dbus/qdbusconnection.h | 16 +- src/dbus/qdbusconnection_p.h | 13 +- src/dbus/qdbusintegrator.cpp | 18 +- src/dbus/qdbusinternalfilters.cpp | 8 +- src/dbus/qdbusvirtualobject.cpp | 97 ++++++++++ src/dbus/qdbusvirtualobject.h | 81 +++++++++ tests/auto/qdbusconnection/tst_qdbusconnection.cpp | 202 ++++++++++++++++++++- tests/auto/qdbusinterface/tst_qdbusinterface.cpp | 71 +++++++- 10 files changed, 555 insertions(+), 12 deletions(-) create mode 100644 src/dbus/qdbusvirtualobject.cpp create mode 100644 src/dbus/qdbusvirtualobject.h diff --git a/src/dbus/dbus.pro b/src/dbus/dbus.pro index 08c9ea1..d21b380 100644 --- a/src/dbus/dbus.pro +++ b/src/dbus/dbus.pro @@ -44,7 +44,8 @@ PUB_HEADERS = qdbusargument.h \ qdbusmetatype.h \ qdbuspendingcall.h \ qdbuspendingreply.h \ - qdbuscontext.h + qdbuscontext.h \ + qdbusvirtualobject.h HEADERS += $$PUB_HEADERS \ qdbusconnection_p.h \ qdbusmessage_p.h \ @@ -60,7 +61,8 @@ HEADERS += $$PUB_HEADERS \ qdbuspendingcall_p.h \ qdbus_symbols_p.h \ qdbusservicewatcher.h \ - qdbusunixfiledescriptor.h + qdbusunixfiledescriptor.h \ + qdbusvirtualobject.h SOURCES += qdbusconnection.cpp \ qdbusconnectioninterface.cpp \ qdbuserror.cpp \ @@ -87,4 +89,5 @@ SOURCES += qdbusconnection.cpp \ qdbuspendingreply.cpp \ qdbus_symbols.cpp \ qdbusservicewatcher.cpp \ - qdbusunixfiledescriptor.cpp + qdbusunixfiledescriptor.cpp \ + qdbusvirtualobject.cpp diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index 0b4133c..e524103 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -222,6 +222,18 @@ void QDBusConnectionManager::setConnection(const QString &name, QDBusConnectionP */ /*! + \internal + \since 4.8 + \enum QDBusConnection::VirtualObjectRegisterOption + Specifies the options for registering virtual objects with the connection. The possible values are: + + \value SingleNode register a virtual object to handle one path only + \value SubPath register a virtual object so that it handles all sub paths + + \sa registerVirtualObject(), QDBusVirtualObject +*/ + +/*! \enum QDBusConnection::UnregisterMode The mode for unregistering an object path: @@ -801,9 +813,21 @@ bool QDBusConnection::registerObject(const QString &path, QObject *object, Regis // this node exists // consider it free if there's no object here and the user is not trying to // replace the object sub-tree - if ((options & ExportChildObjects && !node->children.isEmpty()) || node->obj) + if (node->obj) return false; + if (options & QDBusConnectionPrivate::VirtualObject) { + // technically the check for children needs to go even deeper + if (options & SubPath) { + foreach (const QDBusConnectionPrivate::ObjectTreeNode &child, node->children) { + if (child.obj) + return false; + } + } + } else { + if ((options & ExportChildObjects && !node->children.isEmpty())) + return false; + } // we can add the object here node->obj = object; node->flags = options; @@ -813,6 +837,13 @@ bool QDBusConnection::registerObject(const QString &path, QObject *object, Regis return true; } + // if a virtual object occupies this path, return false + if (node->obj && (node->flags & QDBusConnectionPrivate::VirtualObject) && (node->flags & QDBusConnection::SubPath)) { + qDebug("Cannot register object at %s because QDBusVirtualObject handles all sub-paths.", + qPrintable(path)); + return false; + } + // find the position where we'd insert the node QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator it = qLowerBound(node->children.begin(), node->children.end(), pathComponents.at(i)); @@ -841,6 +872,21 @@ bool QDBusConnection::registerObject(const QString &path, QObject *object, Regis } /*! + \internal + \since 4.8 + Registers a QDBusTreeNode for a path. It can handle a path including all child paths, thus + handling multiple DBus nodes. + + To unregister a QDBusTreeNode use the unregisterObject() function with its path. +*/ +bool QDBusConnection::registerVirtualObject(const QString &path, QDBusVirtualObject *treeNode, + VirtualObjectRegisterOption options) +{ + int opts = options | QDBusConnectionPrivate::VirtualObject; + return registerObject(path, (QObject*) treeNode, (RegisterOptions) opts); +} + +/*! Unregisters an object that was registered with the registerObject() at the object path given by \a path and, if \a mode is QDBusConnection::UnregisterTree, all of its sub-objects too. @@ -905,6 +951,8 @@ QObject *QDBusConnection::objectRegisteredAt(const QString &path) const while (node) { if (pathComponents.count() == i) return node->obj; + if ((node->flags & QDBusConnectionPrivate::VirtualObject) && (node->flags & QDBusConnection::SubPath)) + return node->obj; QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator it = qLowerBound(node->children.constBegin(), node->children.constEnd(), pathComponents.at(i)); @@ -917,6 +965,8 @@ QObject *QDBusConnection::objectRegisteredAt(const QString &path) const return 0; } + + /*! Returns a QDBusConnectionInterface object that represents the D-Bus server interface on this connection. diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h index 4bdd055..8b126af 100644 --- a/src/dbus/qdbusconnection.h +++ b/src/dbus/qdbusconnection.h @@ -69,6 +69,7 @@ class QDBusError; class QDBusMessage; class QDBusPendingCall; class QDBusConnectionInterface; +class QDBusVirtualObject; class QObject; class QDBusConnectionPrivate; @@ -104,8 +105,8 @@ public: // Qt 4.2 had a misspelling here ExportAllSignal = ExportAllSignals, #endif - ExportChildObjects = 0x1000 + // Reserved = 0xff000000 }; enum UnregisterMode { UnregisterNode, @@ -113,6 +114,15 @@ public: }; Q_DECLARE_FLAGS(RegisterOptions, RegisterOption) + enum VirtualObjectRegisterOption { + SingleNode = 0x0, + SubPath = 0x1 + // Reserved = 0xff000000 + }; +#ifndef Q_QDOC + Q_DECLARE_FLAGS(VirtualObjectRegisterOptions, VirtualObjectRegisterOption) +#endif + enum ConnectionCapability { UnixFileDescriptorPassing = 0x0001 }; @@ -163,6 +173,9 @@ public: void unregisterObject(const QString &path, UnregisterMode mode = UnregisterNode); QObject *objectRegisteredAt(const QString &path) const; + bool registerVirtualObject(const QString &path, QDBusVirtualObject *object, + VirtualObjectRegisterOption options = SingleNode); + bool registerService(const QString &serviceName); bool unregisterService(const QString &serviceName); @@ -192,6 +205,7 @@ private: }; Q_DECLARE_OPERATORS_FOR_FLAGS(QDBusConnection::RegisterOptions) +Q_DECLARE_OPERATORS_FOR_FLAGS(QDBusConnection::VirtualObjectRegisterOptions) QT_END_NAMESPACE diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index 12bcb21..d481cf1 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -129,6 +129,11 @@ public: QByteArray matchRule; }; + enum TreeNodeType { + Object = 0x0, + VirtualObject = 0x01000000 + }; + struct ObjectTreeNode { typedef QVector DataList; @@ -143,8 +148,12 @@ public: { return QStringRef(&name) < other; } QString name; - QObject* obj; + union { + QObject *obj; + QDBusVirtualObject *treeNode; + }; int flags; + DataList children; }; @@ -333,7 +342,7 @@ extern bool qDBusInterfaceInObject(QObject *obj, const QString &interface_name); extern QString qDBusInterfaceFromMetaObject(const QMetaObject *mo); // in qdbusinternalfilters.cpp -extern QString qDBusIntrospectObject(const QDBusConnectionPrivate::ObjectTreeNode &node); +extern QString qDBusIntrospectObject(const QDBusConnectionPrivate::ObjectTreeNode &node, const QString &path); extern QDBusMessage qDBusPropertyGet(const QDBusConnectionPrivate::ObjectTreeNode &node, const QDBusMessage &msg); extern QDBusMessage qDBusPropertySet(const QDBusConnectionPrivate::ObjectTreeNode &node, diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index f3f3d0b..2cde07e 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -57,6 +57,7 @@ #include "qdbusabstractadaptor.h" #include "qdbusabstractadaptor_p.h" #include "qdbusutil_p.h" +#include "qdbusvirtualobject.h" #include "qdbusmessage_p.h" #include "qdbuscontext_p.h" #include "qdbuspendingcall_p.h" @@ -442,7 +443,11 @@ static bool findObject(const QDBusConnectionPrivate::ObjectTreeNode *root, // walk the object tree const QDBusConnectionPrivate::ObjectTreeNode *node = root; - while (start < length && node && !(node->flags & QDBusConnection::ExportChildObjects)) { + while (start < length && node) { + if (node->flags & QDBusConnection::ExportChildObjects) + break; + if ((node->flags & QDBusConnectionPrivate::VirtualObject) && (node->flags & QDBusConnection::SubPath)) + break; int end = fullpath.indexOf(QLatin1Char('/'), start); end = (end == -1 ? length : end); QStringRef pathComponent(&fullpath, start, end - start); @@ -1328,7 +1333,7 @@ bool QDBusConnectionPrivate::activateInternalFilters(const ObjectTreeNode &node, if (interface.isEmpty() || interface == QLatin1String(DBUS_INTERFACE_INTROSPECTABLE)) { if (msg.member() == QLatin1String("Introspect") && msg.signature().isEmpty()) { //qDebug() << "QDBusConnectionPrivate::activateInternalFilters introspect" << msg.d_ptr->msg; - QDBusMessage reply = msg.createReply(qDBusIntrospectObject(node)); + QDBusMessage reply = msg.createReply(qDBusIntrospectObject(node, msg.path())); send(reply); return true; } @@ -1375,6 +1380,15 @@ void QDBusConnectionPrivate::activateObject(ObjectTreeNode &node, const QDBusMes // object may be null + if (node.flags & QDBusConnectionPrivate::VirtualObject) { + if (node.treeNode->handleMessage(msg, q(this))) { + return; + } else { + if (activateInternalFilters(node, msg)) + return; + } + } + if (pathStartPos != msg.path().length()) { node.flags &= ~QDBusConnection::ExportAllSignals; node.obj = findChildObject(&node, msg.path(), pathStartPos); diff --git a/src/dbus/qdbusinternalfilters.cpp b/src/dbus/qdbusinternalfilters.cpp index 2b142a7..b874a64 100644 --- a/src/dbus/qdbusinternalfilters.cpp +++ b/src/dbus/qdbusinternalfilters.cpp @@ -56,6 +56,7 @@ #include "qdbusmetatype_p.h" #include "qdbusmessage_p.h" #include "qdbusutil_p.h" +#include "qdbusvirtualobject.h" #ifndef QT_NO_DBUS @@ -108,7 +109,7 @@ static QString generateSubObjectXml(QObject *object) // declared as extern in qdbusconnection_p.h -QString qDBusIntrospectObject(const QDBusConnectionPrivate::ObjectTreeNode &node) +QString qDBusIntrospectObject(const QDBusConnectionPrivate::ObjectTreeNode &node, const QString &path) { // object may be null @@ -155,6 +156,11 @@ QString qDBusIntrospectObject(const QDBusConnectionPrivate::ObjectTreeNode &node } } + // is it a virtual node that handles introspection itself? + if (node.flags & QDBusConnectionPrivate::VirtualObject) { + xml_data += node.treeNode->introspect(path); + } + xml_data += QLatin1String( propertiesInterfaceXml ); } diff --git a/src/dbus/qdbusvirtualobject.cpp b/src/dbus/qdbusvirtualobject.cpp new file mode 100644 index 0000000..f1c17b5 --- /dev/null +++ b/src/dbus/qdbusvirtualobject.cpp @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** 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 QtDBus module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qdbusvirtualobject.h" + +#ifndef QT_NO_DBUS + +QT_BEGIN_NAMESPACE + +QDBusVirtualObject::QDBusVirtualObject(QObject *parent) : + QObject(parent) +{ +} + +QDBusVirtualObject::~QDBusVirtualObject() +{ +} + +QT_END_NAMESPACE + + +/*! + \internal + \class QDBusVirtualObject + \inmodule QtDBus + \since 4.8 + + \brief The QDBusVirtualObject class is used to handle several DBus paths with one class. +*/ + +/*! + \internal + \fn bool QDBusVirtualObject::handleMessage(const QDBusMessage &message, const QDBusConnection &connection) = 0 + + This function needs to handle all messages to the path of the + virtual object, when the SubPath option is specified. + The service, path, interface and methos are all part of the message. + Must return true when the message is handled, otherwise false (will generate dbus error message). +*/ + + +/*! + \internal + \fn QString QDBusVirtualObject::introspect(const QString &path) const + + This function needs to handle the introspection of the + virtual object. It must return xml of the form: + + \code + + + + \endcode + + If you pass the SubPath option, this introspection has to include all child nodes. + Otherwise QDBus handles the introspection of the child nodes. +*/ + +#endif // QT_NO_DBUS diff --git a/src/dbus/qdbusvirtualobject.h b/src/dbus/qdbusvirtualobject.h new file mode 100644 index 0000000..e51dca5 --- /dev/null +++ b/src/dbus/qdbusvirtualobject.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 QtDBus module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDBUSTREENODE_H +#define QDBUSTREENODE_H + +#include +#include +#include + +#ifndef QT_NO_DBUS + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(DBus) + +class QDBusMessage; +class QDBusConnection; + +class QDBusVirtualObjectPrivate; +class Q_DBUS_EXPORT QDBusVirtualObject : public QObject +{ + Q_OBJECT +public: + explicit QDBusVirtualObject(QObject *parent = 0); + virtual ~QDBusVirtualObject(); + + virtual QString introspect(const QString &path) const = 0; + virtual bool handleMessage(const QDBusMessage &message, const QDBusConnection &connection) = 0; + +private: + Q_DECLARE_PRIVATE(QDBusVirtualObject) + Q_DISABLE_COPY(QDBusVirtualObject) +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QT_NO_DBUS +#endif diff --git a/tests/auto/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/qdbusconnection/tst_qdbusconnection.cpp index e06e3a8..6490bfe 100644 --- a/tests/auto/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/qdbusconnection/tst_qdbusconnection.cpp @@ -113,6 +113,10 @@ private slots: void serviceRegistrationRaceCondition(); + void registerVirtualObject(); + void callVirtualObject(); + void callVirtualObjectLocal(); + public: QString serviceName() const { return "com.trolltech.Qt.Autotests.QDBusConnection"; } bool callMethod(const QDBusConnection &conn, const QString &path); @@ -823,7 +827,6 @@ bool tst_QDBusConnection::callMethod(const QDBusConnection &conn, const QString { QDBusMessage msg = QDBusMessage::createMethodCall(conn.baseService(), path, "", "method"); QDBusMessage reply = conn.call(msg, QDBus::Block/*WithGui*/); - if (reply.type() != QDBusMessage::ReplyMessage) return false; if (MyObject::path == path) { @@ -1098,6 +1101,203 @@ void tst_QDBusConnection::serviceRegistrationRaceCondition() QCOMPARE(recv.count, 1); } +class VirtualObject: public QDBusVirtualObject +{ + Q_OBJECT +public: + VirtualObject() :success(true) {} + + QString introspect(const QString &path) const + { + return QString(); + } + + bool handleMessage(const QDBusMessage &message, const QDBusConnection &connection) { + ++callCount; + lastMessage = message; + + if (success) { + QDBusMessage reply = message.createReply(replyArguments); + connection.send(reply); + } + emit messageReceived(message); + return success; + } +signals: + void messageReceived(const QDBusMessage &message) const; + +public: + mutable QDBusMessage lastMessage; + QVariantList replyArguments; + mutable int callCount; + bool success; +}; + + +void tst_QDBusConnection::registerVirtualObject() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QVERIFY(con.isConnected()); + + QString path = "/tree/node"; + QString childPath = "/tree/node/child"; + QString childChildPath = "/tree/node/child/another"; + + { + // Register VirtualObject that handles child paths. Unregister by going out of scope. + VirtualObject obj; + QVERIFY(con.registerVirtualObject(path, &obj, QDBusConnection::SubPath)); + QCOMPARE(con.objectRegisteredAt(path), static_cast(&obj)); + QCOMPARE(con.objectRegisteredAt(childPath), static_cast(&obj)); + QCOMPARE(con.objectRegisteredAt(childChildPath), static_cast(&obj)); + } + QCOMPARE(con.objectRegisteredAt(path), static_cast(0)); + QCOMPARE(con.objectRegisteredAt(childPath), static_cast(0)); + + { + // Register VirtualObject that handles child paths. Unregister by calling unregister. + VirtualObject obj; + QVERIFY(con.registerVirtualObject(path, &obj, QDBusConnection::SubPath)); + QCOMPARE(con.objectRegisteredAt(path), static_cast(&obj)); + QCOMPARE(con.objectRegisteredAt(childPath), static_cast(&obj)); + QCOMPARE(con.objectRegisteredAt(childChildPath), static_cast(&obj)); + con.unregisterObject(path); + QCOMPARE(con.objectRegisteredAt(path), static_cast(0)); + QCOMPARE(con.objectRegisteredAt(childPath), static_cast(0)); + } + + { + // Single node has no sub path handling. + VirtualObject obj; + QVERIFY(con.registerVirtualObject(path, &obj, QDBusConnection::SingleNode)); + QCOMPARE(con.objectRegisteredAt(path), static_cast(&obj)); + QCOMPARE(con.objectRegisteredAt(childPath), static_cast(0)); + } + + { + // Register VirtualObject that handles child paths. Try to register an object on a child path of that. + VirtualObject obj; + QVERIFY(con.registerVirtualObject(path, &obj, QDBusConnection::SubPath)); + QCOMPARE(con.objectRegisteredAt(path), static_cast(&obj)); + + QObject objectAtSubPath; + QVERIFY(!con.registerObject(path, &objectAtSubPath)); + QVERIFY(!con.registerObject(childPath, &objectAtSubPath)); + QCOMPARE(con.objectRegisteredAt(childPath), static_cast(&obj)); + } + + { + // Register object, make sure no SubPath handling object can be registered on a parent path. + QObject objectAtSubPath; + QVERIFY(con.registerObject(childPath, &objectAtSubPath)); + QCOMPARE(con.objectRegisteredAt(childPath), static_cast(&objectAtSubPath)); + + VirtualObject obj; + QVERIFY(!con.registerVirtualObject(path, &obj, QDBusConnection::SubPath)); + QCOMPARE(con.objectRegisteredAt(path), static_cast(0)); + } + QCOMPARE(con.objectRegisteredAt(path), static_cast(0)); + QCOMPARE(con.objectRegisteredAt(childPath), static_cast(0)); + QCOMPARE(con.objectRegisteredAt(childChildPath), static_cast(0)); +} + +void tst_QDBusConnection::callVirtualObject() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QVERIFY(con.isConnected()); + + QDBusConnection con2 = QDBusConnection::connectToBus(QDBusConnection::SessionBus, "con2"); + + QString path = "/tree/node"; + QString childPath = "/tree/node/child"; + + // register one object at root: + VirtualObject obj; + QVERIFY(con.registerVirtualObject(path, &obj, QDBusConnection::SubPath)); + obj.callCount = 0; + obj.replyArguments << 42 << 47u; + + QObject::connect(&obj, SIGNAL(messageReceived(QDBusMessage)), &QTestEventLoop::instance(), SLOT(exitLoop())); + + QDBusMessage message = QDBusMessage::createMethodCall(con.baseService(), path, QString(), "hello"); + QDBusPendingCall reply = con2.asyncCall(message); + + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QCOMPARE(obj.callCount, 1); + QCOMPARE(obj.lastMessage.service(), con2.baseService()); + QCOMPARE(obj.lastMessage.interface(), QString()); + QCOMPARE(obj.lastMessage.path(), path); + reply.waitForFinished(); + QVERIFY(reply.isValid()); + QCOMPARE(reply.reply().arguments(), obj.replyArguments); + + // call sub path + QDBusMessage childMessage = QDBusMessage::createMethodCall(con.baseService(), childPath, QString(), "helloChild"); + obj.replyArguments.clear(); + obj.replyArguments << 99; + QDBusPendingCall childReply = con2.asyncCall(childMessage); + + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QCOMPARE(obj.callCount, 2); + QCOMPARE(obj.lastMessage.service(), con2.baseService()); + QCOMPARE(obj.lastMessage.interface(), QString()); + QCOMPARE(obj.lastMessage.path(), childPath); + + childReply.waitForFinished(); + QVERIFY(childReply.isValid()); + QCOMPARE(childReply.reply().arguments(), obj.replyArguments); + + // let the call fail by having the virtual object return false + obj.success = false; + QDBusMessage errorMessage = QDBusMessage::createMethodCall(con.baseService(), childPath, QString(), "someFunc"); + QDBusPendingCall errorReply = con2.asyncCall(errorMessage); + + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + QTest::qWait(100); + QVERIFY(errorReply.isError()); + qDebug() << errorReply.reply().arguments(); + QCOMPARE(errorReply.reply().errorName(), QString("org.freedesktop.DBus.Error.UnknownObject")); + + QDBusConnection::disconnectFromBus("con2"); +} + +void tst_QDBusConnection::callVirtualObjectLocal() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QVERIFY(con.isConnected()); + + QString path = "/tree/node"; + QString childPath = "/tree/node/child"; + + // register one object at root: + VirtualObject obj; + QVERIFY(con.registerVirtualObject(path, &obj, QDBusConnection::SubPath)); + obj.callCount = 0; + obj.replyArguments << 42 << 47u; + + QDBusMessage message = QDBusMessage::createMethodCall(con.baseService(), path, QString(), "hello"); + QDBusMessage reply = con.call(message, QDBus::Block, 5000); + QCOMPARE(obj.callCount, 1); + QCOMPARE(obj.lastMessage.service(), con.baseService()); + QCOMPARE(obj.lastMessage.interface(), QString()); + QCOMPARE(obj.lastMessage.path(), path); + QCOMPARE(obj.replyArguments, reply.arguments()); + + obj.replyArguments << QString("alien abduction"); + QDBusMessage subPathMessage = QDBusMessage::createMethodCall(con.baseService(), childPath, QString(), "hello"); + QDBusMessage subPathReply = con.call(subPathMessage , QDBus::Block, 5000); + QCOMPARE(obj.callCount, 2); + QCOMPARE(obj.lastMessage.service(), con.baseService()); + QCOMPARE(obj.lastMessage.interface(), QString()); + QCOMPARE(obj.lastMessage.path(), childPath); + QCOMPARE(obj.replyArguments, subPathReply.arguments()); +} + QString MyObject::path; QTEST_MAIN(tst_QDBusConnection) diff --git a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp index 96ab311..9156818 100644 --- a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp @@ -200,6 +200,7 @@ private slots: void invalidAfterServiceOwnerChanged(); void introspect(); void introspectUnknownTypes(); + void introspectVirtualObject(); void callMethod(); void invokeMethod(); void invokeMethodWithReturn(); @@ -361,7 +362,6 @@ void tst_QDBusInterface::invalidAfterServiceOwnerChanged() void tst_QDBusInterface::introspect() { - QDBusConnection con = QDBusConnection::sessionBus(); QDBusInterface iface(QDBusConnection::sessionBus().baseService(), QLatin1String("/"), TEST_INTERFACE_NAME); @@ -394,6 +394,75 @@ void tst_QDBusInterface::introspectUnknownTypes() QVERIFY(mo->indexOfProperty("prop1") != -1); int pidx = mo->indexOfProperty("prop1"); QCOMPARE(mo->property(pidx).typeName(), "QDBusRawType<0x7e>*"); + + + + QDBusMessage message = QDBusMessage::createMethodCall(con.baseService(), "/unknownTypes", "org.freedesktop.DBus.Introspectable", "Introspect"); + QDBusMessage reply = con.call(message, QDBus::Block, 5000); + qDebug() << "REPL: " << reply.arguments(); + +} + + +class VirtualObject: public QDBusVirtualObject +{ + Q_OBJECT +public: + VirtualObject() :success(true) {} + + QString introspect(const QString &path) const { + if (path == "/some/path/superNode") + return "zitroneneis"; + if (path == "/some/path/superNode/foo") + return " \n" + " \n" + " \n" ; + return QString(); + } + + bool handleMessage(const QDBusMessage &message, const QDBusConnection &connection) { + ++callCount; + lastMessage = message; + + if (success) { + QDBusMessage reply = message.createReply(replyArguments); + connection.send(reply); + } + emit messageReceived(message); + return success; + } +signals: + void messageReceived(const QDBusMessage &message) const; + +public: + mutable QDBusMessage lastMessage; + QVariantList replyArguments; + mutable int callCount; + bool success; +}; + +void tst_QDBusInterface::introspectVirtualObject() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + QVERIFY(con.isConnected()); + VirtualObject obj; + + obj.success = false; + + QString path = "/some/path/superNode"; + QVERIFY(con.registerVirtualObject(path, &obj, QDBusConnection::SubPath)); + + QDBusMessage message = QDBusMessage::createMethodCall(con.baseService(), path, "org.freedesktop.DBus.Introspectable", "Introspect"); + QDBusMessage reply = con.call(message, QDBus::Block, 5000); + QVERIFY(reply.arguments().at(0).toString().contains( + QRegExp(".*zitroneneis.*.*" + ".*\n" + ".*.* --- doc/src/external-resources.qdoc | 5 ++ doc/src/index.qdoc | 2 +- doc/src/qt-webpages.qdoc | 59 ++++++++++++++--------- doc/src/qt4-intro.qdoc | 101 +++++++++++++++++++++++++++++++++++++++- 4 files changed, 142 insertions(+), 25 deletions(-) diff --git a/doc/src/external-resources.qdoc b/doc/src/external-resources.qdoc index 5431ec8..8b5d039 100644 --- a/doc/src/external-resources.qdoc +++ b/doc/src/external-resources.qdoc @@ -493,3 +493,8 @@ \externalpage http://msdn.microsoft.com/en-us/library/dd318066.aspx \title Microsoft Active Accessibility Event Constants */ + +/*! + \externalpage http://www.rfc-editor.org/rfc/bcp/bcp47.txt + \title RFC 5646 - BCP47 +*/ diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc index 2ce6781..bd21a12 100644 --- a/doc/src/index.qdoc +++ b/doc/src/index.qdoc @@ -49,8 +49,8 @@ \o \l{external: Qt Simulator Manual}{Qt Simulator} \endlist \list + \o \l{What's New in Qt 4.8} - latest release \o \l{Supported Platforms}{Platform Support} - \o \l{What's New in Qt 4.7} - latest release \endlist \enddiv \div {class="sectionlist normallist"} diff --git a/doc/src/qt-webpages.qdoc b/doc/src/qt-webpages.qdoc index 7f456b9..208814b 100644 --- a/doc/src/qt-webpages.qdoc +++ b/doc/src/qt-webpages.qdoc @@ -209,7 +209,7 @@ \title Qt Docs Web Start Page */ /*! - \externalpage http://doc.qt.nokia.com/qtcreator/creator-qml-application.html + \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-qml-application.html \title external: Developing Qt Quick Applications with Creator */ /*! @@ -233,35 +233,35 @@ \title Qt Whitepaper */ /*! - \externalpage http://doc.qt.nokia.com/qtcreator/creator-visual-editor.html + \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-visual-editor.html \title external: Developing Qt Quick Applications */ /*! - \externalpage http://doc.qt.nokia.com/qtcreator/creator-publish-ovi.html + \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-publish-ovi.html \title external: Publishing Applications to Ovi Store */ /*! - \externalpage http://doc.qt.nokia.com/qtcreator/index.html + \externalpage qthelp://com.nokia.qtcreator.221/doc/index.html \title external: Qt Creator Manual */ /*! - \externalpage http://doc.qt.nokia.com/qtcreator/creator-developing-symbian.html + \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-developing-symbian.html \title external: Setting Up Development Environment for Symbian */ /*! - \externalpage http://doc.qt.nokia.com/qtcreator/creator-developing-maemo.html + \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-developing-maemo.html \title external: Setting Up Development Environment for Maemo */ /*! - \externalpage http://doc.qt.nokia.com/qtmobility/index.html + \externalpage qthelp://com.nokia.qtmobility.111/mobility/index.html \title external: Qt Mobility Manual */ /*! - \externalpage http://doc.qt.nokia.com/qtmobility/qml-plugins.html + \externalpage qthelp://com.nokia.qtmobility.111/mobility/qml-plugins.html \title external: Qt Mobility QML Plugins */ /*! - \externalpage http://doc.qt.nokia.com/qtsimulator/index.html + \externalpage qthelp://com.nokia.qt.simulator.110/doc/index.html \title external: Qt Simulator Manual */ /*! @@ -269,51 +269,51 @@ \title Qt SDK Product Page */ /*! - \externalpage http://doc.qt.nokia.com/nokia-qtsdk-latest/index.html + \externalpage qthelp://com.nokia.qt.sdk.11/doc/index.html \title external: Qt SDK Manual */ /*! - \externalpage http://doc.qt.nokia.com/qtcreator/creator-project-managing.html + \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-project-managing.html \title external: Creating Qt Projects in Creator */ /*! - \externalpage http://doc.qt.nokia.com/qtcreator/creator-building-running.html + \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-building-running.html \title external: Building and Running Applications in Creator */ /*! - \externalpage http://doc.qt.nokia.com/qtcreator/creator-running-targets.html + \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-running-targets.html \title external: Set Compiler Targets in Creator */ /*! - \externalpage http://doc.qt.nokia.com/qtcreator/creator-build-settings.html + \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-build-settings.html \title external: Build Settings in Creator */ /*! - \externalpage http://doc.qt.nokia.com/qtcreator/creator-run-settings.html + \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-run-settings.html \title external: Run Settings in Creator */ /*! - \externalpage http://doc.qt.nokia.com/qtcreator/creator-using-qt-designer.html + \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-using-qt-designer.html \title external: Designer in Creator */ /*! - \externalpage http://doc.qt.nokia.com/qtcreator/creator-debugging.html + \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-debugging.html \title external: Debugging Applications in Creator */ /*! - \externalpage http://doc.qt.nokia.com/qtcreator/creator-deployment-symbian.html + \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-deployment-symbian.html \title external: Symbian Deployment in Creator */ /*! - \externalpage http://doc.qt.nokia.com/qtcreator/creator-deployment-maemo.html + \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-deployment-maemo.html \title external: Maemo Deployment in Creator */ /*! - \externalpage http://doc.qt.nokia.com/qtmobility/multimedia.html + \externalpage qthelp://com.nokia.qtmobility.111/mobility/multimedia.html \title external: Mobility Multimedia */ /*! - \externalpage http://doc.qt.nokia.com/qtmobility/location-overview.html + \externalpage qthelp://com.nokia.qtmobility.111/mobility/location-overview.html \title external: Mobility Location */ /*! @@ -329,7 +329,7 @@ \title Training Day at Qt Developer Days 2009 */ /*! - \externalpage http://doc.qt.nokia.com/qtmobility/all-examples.html + \externalpage qthelp://com.nokia.qtmobility.111/mobility/all-examples.html \title external: Qt Mobility Examples */ /*! @@ -539,3 +539,18 @@ \externalpage http://qt.nokia.com/partners/qt-in-education/qt-in-education-course-material/ \title Qt in Education Course Material */ + +/*! + \externalpage http://developer.qt.nokia.com/ + \title Qt Developer Network +*/ + +/*! + \externalpage http://developer.qt.nokia.com/wiki/Qt_Modules_Maturity_Level + \title Qt Modules' Maturity Levels - Modules List +*/ + +/*! + \externalpage http://labs.qt.nokia.com/2011/05/03/qt-modules-maturity-level/ + \title Qt Modules' Maturity Level - Description +*/ diff --git a/doc/src/qt4-intro.qdoc b/doc/src/qt4-intro.qdoc index 1547a7c..01103a8 100644 --- a/doc/src/qt4-intro.qdoc +++ b/doc/src/qt4-intro.qdoc @@ -62,6 +62,12 @@ The following features have been added to Qt since the first release of Qt 4. + In Qt 4.8: + \list + \o \l{Qt Quick} 1.1 offers changes to the \l{QML Elements} and performance + upgrades + \ + \endlist In Qt 4.7: \list \o Declarative UI Development with \l{Qt Quick}, technologies for creating @@ -118,7 +124,7 @@ 64-bit Macintosh hardware. \o The QtXmlPatterns module has been extended to cover XSLT, a transformation language for XML documents. - \o Qt Script introduced its debugger, + \o Qt Script introduced its debugger, providing error reporting for scripts, and to let users track down bugs in their own scripts. \o Qt 4.5 includes support for writing rich text documents as @@ -489,6 +495,97 @@ */ /*! + \page qt4-8-intro.html + \title What's New in Qt 4.8 + + Qt 4.8 provides many improvements and enhancements over the previous + releases in the Qt 4 series. This document covers the most important + features in this release, separated by category. + + A list of other Qt 4 features can be found on the \bold{\l{What's + New in Qt 4}} page. + + \section1 Qt Quick 1.1 + Qt Quick 1.1 introduces \l{What's New in Qt Quick}{new changes} such as + new properties and better performance. + + \list + \o \l {QML Right-to-left User Interfaces}{Right-To-Left} text support + \o Improved image caching + \o Text input improvements - Support for split-screen virtual keyboard + \o \l PinchArea Element - enables simple pinch gesture handling + \o New properties for \l{QML Elements}. + \endlist + + + \section1 Qt Platform Abstraction -- \e Lighthouse + + \e QPA allows porting Qt to different windowing systems and devices + easier. It provides a clean abstraction layer for porting QtGui to new + window systems. + + \section1 Qt WebKit 2.2 + + The new Qt WebKit release introduces bug fixes, performance improvements, + and greater compiler compatibility. + + \section1 Threaded OpenGL + + Many Qt OpenGL functions are now thread-safe. Threads that cater to + different situations are now available. + + \list + \o Buffer swapping thread + \o Texture uploading thread + \o \l QPainter thread + \endlist + + \section1 Deprecated Items in Qt 4.8 + + As part of Open Governance, modules in Qt 4.8 will receive maintainers and + receive different support levels. + + Currently, a module has an activity classification, the \e{Module Maturity Level}. + As well, a list of modules and their maturity level is in the \l{Qt Developer Network}. + + \list + \o \l{Qt Modules' Maturity Level - Description} - description of the + different \e{maturity levels} + \o \l{Qt Modules' Maturity Levels - Modules List} - list of the Qt + modules and their maturity level + \endlist + \section1 Additions to the Qt API + + Qt 4.8 introduces changes to the Qt API. + \list + \o Localization API + Changes to the Localization APIs include improvements to \l QLocale and more + support for different language code formats. + + \list + \o \l {QLocale::quoteString()} - for localized quotes + \o \l {QLocale::createSeparatedList()} - for localized list separation (e.g. "1, 2 and 3") + \o \l {QLocale::bcp47Name()} - for locale names in the canonical form + according to \l {RFC 5646 - BCP47} + \o \l {QLocale::matchingLocales()} - to get a list of locales that match a + criteria - e.g. a list of locales that use French language. + \o \l {QLocale::firstDayOfWeek()} + \o \l {QLocale::weekdays()} + \o \l{QLocale::currencySymbol()} + \o \l{QLocale::toCurrencyString()} - number formatting for currencies + \o \l{QLocale::uiLanguages()} + \o \l{QLocale::nativeLanguageName()} + \o \l{QLocale::nativeCountryName()} + \endlist + \o IP Multicast API + \o Multithreaded HTTP + \endlist + + \section1 New Classes, Functions, Macros, etc. + \sincelist 4.8 +*/ + +/*! \page qt4-7-intro.html \title What's New in Qt 4.7 @@ -685,7 +782,7 @@ \list \o Simplify complex application semantics. \o Use of states to reduce code bloat. - \o Use states to improve maintainability. + \o Use states to improve maintainability. \o Makes event-driven programming robust and more reusable. \endlist -- cgit v0.12 From 19e9fd70bb39c10b69eb6220c2d5b772e126324c Mon Sep 17 00:00:00 2001 From: Jerome Pasion Date: Mon, 4 Jul 2011 16:16:32 +0200 Subject: Committing the qt-webpages.qdoc file with the online links Reviewed-by: David Boddie --- doc/src/qt-webpages.qdoc | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/doc/src/qt-webpages.qdoc b/doc/src/qt-webpages.qdoc index 208814b..c993575 100644 --- a/doc/src/qt-webpages.qdoc +++ b/doc/src/qt-webpages.qdoc @@ -209,7 +209,7 @@ \title Qt Docs Web Start Page */ /*! - \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-qml-application.html + \externalpage http://doc.qt.nokia.com/qtcreator/creator-qml-application.html \title external: Developing Qt Quick Applications with Creator */ /*! @@ -233,35 +233,35 @@ \title Qt Whitepaper */ /*! - \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-visual-editor.html + \externalpage http://doc.qt.nokia.com/qtcreator/creator-visual-editor.html \title external: Developing Qt Quick Applications */ /*! - \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-publish-ovi.html + \externalpage http://doc.qt.nokia.com/qtcreator/creator-publish-ovi.html \title external: Publishing Applications to Ovi Store */ /*! - \externalpage qthelp://com.nokia.qtcreator.221/doc/index.html + \externalpage http://doc.qt.nokia.com/qtcreator/index.html \title external: Qt Creator Manual */ /*! - \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-developing-symbian.html + \externalpage http://doc.qt.nokia.com/qtcreator/creator-developing-symbian.html \title external: Setting Up Development Environment for Symbian */ /*! - \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-developing-maemo.html + \externalpage http://doc.qt.nokia.com/qtcreator/creator-developing-maemo.html \title external: Setting Up Development Environment for Maemo */ /*! - \externalpage qthelp://com.nokia.qtmobility.111/mobility/index.html + \externalpage http://doc.qt.nokia.com/qtmobility/index.html \title external: Qt Mobility Manual */ /*! - \externalpage qthelp://com.nokia.qtmobility.111/mobility/qml-plugins.html + \externalpage http://doc.qt.nokia.com/qtmobility/qml-plugins.html \title external: Qt Mobility QML Plugins */ /*! - \externalpage qthelp://com.nokia.qt.simulator.110/doc/index.html + \externalpage http://doc.qt.nokia.com/qtsimulator/index.html \title external: Qt Simulator Manual */ /*! @@ -269,51 +269,51 @@ \title Qt SDK Product Page */ /*! - \externalpage qthelp://com.nokia.qt.sdk.11/doc/index.html + \externalpage http://doc.qt.nokia.com/nokia-qtsdk-latest/index.html \title external: Qt SDK Manual */ /*! - \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-project-managing.html + \externalpage http://doc.qt.nokia.com/qtcreator/creator-project-managing.html \title external: Creating Qt Projects in Creator */ /*! - \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-building-running.html + \externalpage http://doc.qt.nokia.com/qtcreator/creator-building-running.html \title external: Building and Running Applications in Creator */ /*! - \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-running-targets.html + \externalpage http://doc.qt.nokia.com/qtcreator/creator-running-targets.html \title external: Set Compiler Targets in Creator */ /*! - \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-build-settings.html + \externalpage http://doc.qt.nokia.com/qtcreator/creator-build-settings.html \title external: Build Settings in Creator */ /*! - \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-run-settings.html + \externalpage http://doc.qt.nokia.com/qtcreator/creator-run-settings.html \title external: Run Settings in Creator */ /*! - \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-using-qt-designer.html + \externalpage http://doc.qt.nokia.com/qtcreator/creator-using-qt-designer.html \title external: Designer in Creator */ /*! - \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-debugging.html + \externalpage http://doc.qt.nokia.com/qtcreator/creator-debugging.html \title external: Debugging Applications in Creator */ /*! - \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-deployment-symbian.html + \externalpage http://doc.qt.nokia.com/qtcreator/creator-deployment-symbian.html \title external: Symbian Deployment in Creator */ /*! - \externalpage qthelp://com.nokia.qtcreator.221/doc/creator-deployment-maemo.html + \externalpage http://doc.qt.nokia.com/qtcreator/creator-deployment-maemo.html \title external: Maemo Deployment in Creator */ /*! - \externalpage qthelp://com.nokia.qtmobility.111/mobility/multimedia.html + \externalpage http://doc.qt.nokia.com/qtmobility/multimedia.html \title external: Mobility Multimedia */ /*! - \externalpage qthelp://com.nokia.qtmobility.111/mobility/location-overview.html + \externalpage http://doc.qt.nokia.com/qtmobility/location-overview.html \title external: Mobility Location */ /*! @@ -329,7 +329,7 @@ \title Training Day at Qt Developer Days 2009 */ /*! - \externalpage qthelp://com.nokia.qtmobility.111/mobility/all-examples.html + \externalpage http://doc.qt.nokia.com/qtmobility/all-examples.html \title external: Qt Mobility Examples */ /*! -- cgit v0.12 From 0e9e4422205da5c27ab2c758d730b958df7ac872 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Mon, 4 Jul 2011 15:27:13 +0200 Subject: Add font related changes in 4.8 into changes Reviewed-by: Eskil --- dist/changes-4.8.0 | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/dist/changes-4.8.0 b/dist/changes-4.8.0 index 7dffa68..f59e09a 100644 --- a/dist/changes-4.8.0 +++ b/dist/changes-4.8.0 @@ -68,6 +68,14 @@ QtGui - QListView diverses optimisations [QTBUG-11438] - QTreeWidget/QListWidget: use localeAwareCompare for string comparisons [QTBUG-10839] - PNG image I/O: Much improved support for text annotations, including iTXt fields. + - QRawFont and QGlyphRun are introduced for low-level text rendering. [QTBUG-18252] + - QFont: hintingPreference() is introduced to control hinting in font rendering and + subpixel positioning of glyphs for Windows, Mac OS X and X11/raster. [QTBUG-10615] + - Subpixel positioned text layout is supported in raster and OpenGL paint engines. + - QFont: styleName() is added to allow selecting fonts with irregular style names + like UltraLight. [QTBUG-19366] + - Visual text cursor movement behavior is added to QTextEdit and QLineEdit controls, + which can be used as an optional mode for bi-directional text editing. [QTBUG-13859] QtNetwork --------- @@ -108,15 +116,22 @@ QtScript Qt for Linux/X11 ---------------- - + - Now takes font hinting settings from GConf by default if running in + GNOME desktop. + - Various fixes to FontConfig font matching code to make it consistent + with other X11 programs. [QTBUG-2148, QTBUG-19947, QTBUG-14269] Qt for Windows -------------- - + - DirectWrite experimental text shaping engine is added with subpixel + positioning support. [QTBUG-12678] Qt for Mac OS X --------------- - + - raster graphics system is now made as the default paint engine for + Mac OS X. [QTBUG-12615] + - HarfBuzz can now be used as an optional text layout engine on Mac OS X. + [QTBUG-17728] Qt for Embedded Linux --------------------- -- cgit v0.12 From 25bbcf9605f65548d7f581304b7d8ad300aa9937 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 4 Jul 2011 16:44:29 +0200 Subject: Applied fix (dea9ca8b7a4166e1c3d3fc374621ad02c1220d3a)from qt5/qtbase. --- examples/opengl/cube/geometryengine.cpp | 2 ++ examples/opengl/cube/mainwidget.cpp | 2 ++ examples/opengl/cube/mainwidget.h | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/opengl/cube/geometryengine.cpp b/examples/opengl/cube/geometryengine.cpp index 3001ed5..c05dde5 100644 --- a/examples/opengl/cube/geometryengine.cpp +++ b/examples/opengl/cube/geometryengine.cpp @@ -61,6 +61,8 @@ GeometryEngine::~GeometryEngine() void GeometryEngine::init() { + initializeGLFunctions(); + //! [0] // Generate 2 VBOs glGenBuffers(2, vboIds); diff --git a/examples/opengl/cube/mainwidget.cpp b/examples/opengl/cube/mainwidget.cpp index 2a2cd63..1116526 100644 --- a/examples/opengl/cube/mainwidget.cpp +++ b/examples/opengl/cube/mainwidget.cpp @@ -118,6 +118,8 @@ void MainWidget::timerEvent(QTimerEvent *e) void MainWidget::initializeGL() { + initializeGLFunctions(); + qglClearColor(Qt::black); qDebug() << "Initializing shaders..."; diff --git a/examples/opengl/cube/mainwidget.h b/examples/opengl/cube/mainwidget.h index 33ab0d8..c6da29f 100644 --- a/examples/opengl/cube/mainwidget.h +++ b/examples/opengl/cube/mainwidget.h @@ -42,6 +42,7 @@ #define MAINWIDGET_H #include +#include #include #include @@ -52,7 +53,7 @@ class QGLShaderProgram; class GeometryEngine; -class MainWidget : public QGLWidget +class MainWidget : public QGLWidget, protected QGLFunctions { Q_OBJECT public: -- cgit v0.12 From df48d66d6e0af1281e1909b47054d45c729b675e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 4 Jul 2011 15:41:16 +0200 Subject: Fixed missing painting with X11 paint engine. Re-introduce some "lost" code from 4.7. Task-number: QTBUG-19639 Reviewed-by: Olivier Goffart --- src/gui/painting/qpaintengine_x11.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index 994986b..147d2ec 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -1611,6 +1611,8 @@ void QX11PaintEnginePrivate::fillPolygon_dev(const QPointF *polygonPoints, int p && (fill.style() != Qt::NoBrush) && ((has_fill_texture && fill.texture().hasAlpha()) || antialias || !solid_fill || has_alpha_pen != has_alpha_brush)) { + tessellator->tessellate((QPointF *)clippedPoints, clippedCount, + mode == QPaintEngine::WindingMode); if (tessellator->size > 0) { XRenderPictureAttributes attrs; attrs.poly_edge = antialias ? PolyEdgeSmooth : PolyEdgeSharp; -- cgit v0.12 From f7bba6cc700f5f6b1ff6a40b8c475924de206022 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 4 Jul 2011 17:40:53 +0200 Subject: Lion Support: Hand made rendering of selected tab text Reviewed-by: Jens Bache-Wiig --- src/gui/styles/qmacstyle_mac.mm | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 40c28f6..efe2e7d 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -3681,9 +3681,27 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter proxy()->drawItemText(p, nr, alignment, np, tab->state & State_Enabled, tab->text, QPalette::WindowText); p->restore(); - } + QCommonStyle::drawControl(ce, &myTab, p, w); + } else if (qMacVersion() >= QSysInfo::MV_10_7 && (tab->state & State_Selected)) { + p->save(); + rotateTabPainter(p, myTab.shape, myTab.rect); - QCommonStyle::drawControl(ce, &myTab, p, w); + QPalette np = tab->palette; + np.setColor(QPalette::WindowText, QColor(0, 0, 0, 75)); + QRect nr = subElementRect(SE_TabBarTabText, opt, w); + nr.moveTop(-1); + int alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextHideMnemonic; + proxy()->drawItemText(p, nr, alignment, np, tab->state & State_Enabled, + tab->text, QPalette::WindowText); + + np.setColor(QPalette::WindowText, QColor(255, 255, 255, 255)); + nr.moveTop(-2); + proxy()->drawItemText(p, nr, alignment, np, tab->state & State_Enabled, + tab->text, QPalette::WindowText); + p->restore(); + } else { + QCommonStyle::drawControl(ce, &myTab, p, w); + } } else { p->save(); CGContextSetShouldAntialias(cg, true); -- cgit v0.12 From d26e33fbced5badee325bd2e09b266097ab65c98 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 30 May 2011 19:16:20 +0200 Subject: Adding Kazakh entry to the codec alias table A Symbian update after "Anna" may come with Kazakh support. Task-number: QTBUG-19024 Reviewed-by: Olivier Goffart --- src/corelib/codecs/qtextcodec_symbian.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/codecs/qtextcodec_symbian.cpp b/src/corelib/codecs/qtextcodec_symbian.cpp index c8a7357..4710ec7 100644 --- a/src/corelib/codecs/qtextcodec_symbian.cpp +++ b/src/corelib/codecs/qtextcodec_symbian.cpp @@ -123,7 +123,8 @@ static const QSymbianCodecInitData codecsData[] = { { /*536929574*/ 536929574, 38, "EUC-KR\0" }, { /*536936703*/ 536936703, 0, "CP949\0" }, { /*536936705*/ 536936705, 37, "ISO-2022-KR\0csISO2022KR\0" }, - { /*536941517*/ 536941517, 36, "KS_C_5601-1987\0iso-ir-149\0KS_C_5601-1989\0KSC_5601\0Korean\0csKSC56011987\0" } + { /*536941517*/ 536941517, 36, "KS_C_5601-1987\0iso-ir-149\0KS_C_5601-1989\0KSC_5601\0Korean\0csKSC56011987\0" }, + { /*537124345*/ 537124345, 119, "KZ-1048\0" } }; -- cgit v0.12 From 75346e6df350a040c1c3f91790a3945aa983fbfc Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 4 Jul 2011 18:43:28 +0200 Subject: Adding "hkscs_2004" to the codec alias table Task-Number: QTBUG-19024 Reviewed-by: Olivier Goffart --- src/corelib/codecs/qtextcodec_symbian.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/codecs/qtextcodec_symbian.cpp b/src/corelib/codecs/qtextcodec_symbian.cpp index 4710ec7..504a7c8 100644 --- a/src/corelib/codecs/qtextcodec_symbian.cpp +++ b/src/corelib/codecs/qtextcodec_symbian.cpp @@ -119,6 +119,7 @@ static const QSymbianCodecInitData codecsData[] = { { /*271082504*/ 271082504, 0, "portuguese_locking_gsm7ext\0" }, { /*271082505*/ 271082505, 0, "portuguese_locking_single\0" }, { /*271082506*/ 271082506, 0, "spanish_gsm7_single\0" }, + { /*271082762*/ 271082762, 0, "hkscs_2004\0" }, { /*271085624*/ 271085624, 114, "GB18030\0" }, { /*536929574*/ 536929574, 38, "EUC-KR\0" }, { /*536936703*/ 536936703, 0, "CP949\0" }, -- cgit v0.12 From 73a62a79f17c71b0af3bd94db9da45be689b347b Mon Sep 17 00:00:00 2001 From: Jan-Arve Saether Date: Tue, 5 Jul 2011 10:39:35 +0200 Subject: Make this feature public for Qt 4.8 (was privately added for Qt 4.7) --- src/gui/graphicsview/qgraphicslayout.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/graphicsview/qgraphicslayout.cpp b/src/gui/graphicsview/qgraphicslayout.cpp index 6fbe849..d01c3af 100644 --- a/src/gui/graphicsview/qgraphicslayout.cpp +++ b/src/gui/graphicsview/qgraphicslayout.cpp @@ -466,7 +466,6 @@ void QGraphicsLayout::addChildLayoutItem(QGraphicsLayoutItem *layoutItem) static bool g_instantInvalidatePropagation = false; /*! - \internal \since 4.8 \sa instantInvalidatePropagation() @@ -496,7 +495,6 @@ void QGraphicsLayout::setInstantInvalidatePropagation(bool enable) } /*! - \internal \since 4.8 \sa setInstantInvalidatePropagation() -- cgit v0.12 From f51b5fe09c63e4b3c2ab5a4d06e162c43d38207d Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 5 Jul 2011 10:33:59 +0200 Subject: Don't issue GL calls when the geometry is empty This works as a band-aid and optimization for QT-5104, because in the text in the example, which contains latin text and has a latin default font set, will think of all spaces between the cyrillic characters as latin characters, hence it will make separate text items for them and issue separate glDrawElements() calls. By cutting off if there are no glyphs to draw, we can avoid hitting the actual bug for this and several other use cases, making it less likely to happen. Task-number: QT-5104 Reviewed-by: Samuel --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 52450b6..5d2221f 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1696,6 +1696,8 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp } int numGlyphs = vertexCoordinates->vertexCount() / 4; + if (numGlyphs == 0) + return; if (elementIndices.size() < numGlyphs*6) { Q_ASSERT(elementIndices.size() % 6 == 0); -- cgit v0.12 From edced802d26da8347a827f041561d0e33d79c95e Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Tue, 5 Jul 2011 13:05:15 +0300 Subject: QS60Style: QMessageBox theme background is incorrect Use correct native theme graphic for dialog backgrounds. In the past, native menu background graphic was used for dialogs and menus. Task-number: QTBUG-9924 Reviewed-by: Tomi Vihria --- src/gui/styles/qs60style.cpp | 10 +++++++++- src/gui/styles/qs60style_p.h | 2 ++ src/gui/styles/qs60style_s60.cpp | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index fc5589c..13157ff 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -146,6 +146,7 @@ const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameEleme {SE_Editor, QS60StyleEnums::SP_QsnFrInputCenter}, {SE_TableItemPressed, QS60StyleEnums::SP_QsnFrGridCenterPressed}, {SE_ListItemPressed, QS60StyleEnums::SP_QsnFrListCenterPressed}, + {SE_DialogBackground, QS60StyleEnums::SP_QsnFrPopupCenter}, }; static const int frameElementsCount = @@ -268,6 +269,9 @@ void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter, case SE_PopupBackground: drawFrame(SF_PopupBackground, painter, rect, flags | SF_PointNorth); break; + case SE_DialogBackground: + drawFrame(SF_DialogBackground, painter, rect, flags | SF_PointNorth); + break; case SE_SettingsList: drawFrame(SF_SettingsList, painter, rect, flags | SF_PointNorth); break; @@ -2306,10 +2310,14 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti if (QS60StylePrivate::canDrawThemeBackground(option->palette.base(), widget) && QS60StylePrivate::equalToThemePalette(option->palette.window().texture().cacheKey(), QPalette::Window)) { const bool comboMenu = qobject_cast(widget); + const bool menu = qobject_cast(widget); // Add margin area to the background, to avoid background being cut for first and last item. const int verticalMenuAdjustment = comboMenu ? QS60StylePrivate::pixelMetric(PM_MenuVMargin) : 0; const QRect adjustedMenuRect = option->rect.adjusted(0, -verticalMenuAdjustment, 0, verticalMenuAdjustment); - QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_PopupBackground, painter, adjustedMenuRect, flags); + if (comboMenu || menu) + QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_PopupBackground, painter, adjustedMenuRect, flags); + else + QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_DialogBackground, painter, adjustedMenuRect, flags); } else { commonStyleDraws = true; } diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 586f1f6..10a43e2 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -541,6 +541,7 @@ public: SE_DropArea, SE_TableItemPressed, SE_ListItemPressed, + SE_DialogBackground, }; enum SkinFrameElements { @@ -560,6 +561,7 @@ public: SF_ButtonInactive, SF_TableItemPressed, SF_ListItemPressed, + SF_DialogBackground, }; enum SkinElementFlag { diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index c88d49a..67181af 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -1196,6 +1196,10 @@ void QS60StyleModeSpecifics::frameIdAndCenterId(QS60StylePrivate::SkinFrameEleme centerId.Set(KAknsIIDQsnFrPopupCenterSubmenu); frameId.Set(KAknsIIDQsnFrPopupSub); break; + case QS60StylePrivate::SF_DialogBackground: + centerId.Set(KAknsIIDQsnFrPopupCenter); + frameId.Set(KAknsIIDQsnFrPopup); + break; case QS60StylePrivate::SF_SettingsList: // Starting from S60_5_3, the root theme has been changed so that KAknsIIDQsnFrSetOpt is empty. // Set the theme ID to None, to avoid theme server trying to draw the empty frame. -- cgit v0.12 From 799ee8f8ad18bffe9b689f3e17d0049f14794d62 Mon Sep 17 00:00:00 2001 From: mread Date: Tue, 5 Jul 2011 11:18:00 +0100 Subject: whitespace fixes Making these whitespace fixes in preparation for fixing a compile error and my editor likes to fix whitespace. --- src/plugins/bearer/symbian/symbianengine.cpp | 58 ++++++++++++++-------------- src/plugins/bearer/symbian/symbianengine.h | 16 ++++---- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index 04edbb7..1902292 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -255,7 +255,7 @@ void SymbianEngine::updateConfigurationsL() #ifdef SNAP_FUNCTIONALITY_AVAILABLE // S60 version is >= Series60 3rd Edition Feature Pack 2 TInt error = KErrNone; - + // Loop through all IAPs RArray connectionMethods; // IAPs CleanupClosePushL(connectionMethods); @@ -289,7 +289,7 @@ void SymbianEngine::updateConfigurationsL() CleanupStack::PopAndDestroy(&connectionMethod); } CleanupStack::PopAndDestroy(&connectionMethods); - + // Loop through all SNAPs RArray destinations; CleanupClosePushL(destinations); @@ -459,7 +459,7 @@ void SymbianEngine::updateConfigurationsL() break; } } - } + } } foreach (const QString &oldIface, knownSnapConfigs) { @@ -489,13 +489,13 @@ SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; TUint32 iapId = connectionMethod.GetIntAttributeL(CMManager::ECmIapId); QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(iapId)); - + HBufC *pName = connectionMethod.GetStringAttributeL(CMManager::ECmName); CleanupStack::PushL(pName); QT_TRYCATCH_LEAVING(cpPriv->name = QString::fromUtf16(pName->Ptr(),pName->Length())); CleanupStack::PopAndDestroy(pName); pName = NULL; - + TUint32 bearerId = connectionMethod.GetIntAttributeL(CMManager::ECmCommsDBBearerType); switch (bearerId) { case KCommDbBearerCSD: @@ -520,7 +520,7 @@ SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( cpPriv->bearerType = QNetworkConfiguration::BearerUnknown; break; } - + TInt error = KErrNone; TUint32 bearerType = connectionMethod.GetIntAttributeL(CMManager::ECmBearerType); switch (bearerType) { @@ -544,13 +544,13 @@ SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( CleanupStack::PopAndDestroy(pName); pName = NULL; } - + cpPriv->state = QNetworkConfiguration::Defined; TBool isConnected = connectionMethod.GetBoolAttributeL(CMManager::ECmConnected); if (isConnected) { cpPriv->state = QNetworkConfiguration::Active; } - + cpPriv->isValid = true; cpPriv->id = ident; cpPriv->numericId = iapId; @@ -566,7 +566,7 @@ bool SymbianEngine::readNetworkConfigurationValuesFromCommsDb( { TRAPD(error, readNetworkConfigurationValuesFromCommsDbL(aApId,apNetworkConfiguration)); if (error != KErrNone) { - return false; + return false; } return true; } @@ -574,22 +574,22 @@ bool SymbianEngine::readNetworkConfigurationValuesFromCommsDb( void SymbianEngine::readNetworkConfigurationValuesFromCommsDbL( TUint32 aApId, SymbianNetworkConfigurationPrivate *apNetworkConfiguration) { - CApDataHandler* pDataHandler = CApDataHandler::NewLC(*ipCommsDB); - CApAccessPointItem* pAPItem = CApAccessPointItem::NewLC(); + CApDataHandler* pDataHandler = CApDataHandler::NewLC(*ipCommsDB); + CApAccessPointItem* pAPItem = CApAccessPointItem::NewLC(); TBuf name; - + CApUtils* pApUtils = CApUtils::NewLC(*ipCommsDB); TUint32 apId = pApUtils->WapIdFromIapIdL(aApId); - + pDataHandler->AccessPointDataL(apId,*pAPItem); pAPItem->ReadTextL(EApIapName, name); if (name.Compare(_L("Easy WLAN")) == 0) { // "Easy WLAN" won't be accepted to the Configurations list User::Leave(KErrNotFound); } - + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(aApId)); - + QT_TRYCATCH_LEAVING(apNetworkConfiguration->name = QString::fromUtf16(name.Ptr(),name.Length())); apNetworkConfiguration->isValid = true; apNetworkConfiguration->id = ident; @@ -600,7 +600,7 @@ void SymbianEngine::readNetworkConfigurationValuesFromCommsDbL( apNetworkConfiguration->purpose = QNetworkConfiguration::UnknownPurpose; apNetworkConfiguration->roamingSupported = false; switch (pAPItem->BearerTypeL()) { - case EApBearerTypeCSD: + case EApBearerTypeCSD: apNetworkConfiguration->bearerType = QNetworkConfiguration::Bearer2G; break; case EApBearerTypeGPRS: @@ -625,7 +625,7 @@ void SymbianEngine::readNetworkConfigurationValuesFromCommsDbL( apNetworkConfiguration->bearerType = QNetworkConfiguration::BearerUnknown; break; } - + CleanupStack::PopAndDestroy(pApUtils); CleanupStack::PopAndDestroy(pAPItem); CleanupStack::PopAndDestroy(pDataHandler); @@ -664,7 +664,7 @@ QNetworkConfigurationPrivatePointer SymbianEngine::defaultConfigurationL() ptr = accessPointConfigurations.value(iface); } #endif - + if (ptr) { QMutexLocker configLocker(&ptr->mutex); if (ptr->isValid) @@ -684,7 +684,7 @@ void SymbianEngine::updateActiveAccessPoints() TUint connectionCount; iConnectionMonitor.GetConnectionCount(connectionCount, status); User::WaitForRequest(status); - + // Go through all connections and set state of related IAPs to Active. // Status needs to be checked carefully, because ConnMon lists also e.g. // WLAN connections that are being currently tried --> we don't want to @@ -763,7 +763,7 @@ void SymbianEngine::accessPointScanningReady(TBool scanSuccessful, TConnMonIapIn iUpdateGoingOn = false; if (scanSuccessful) { QList unavailableConfigs = accessPointConfigurations.keys(); - + // Set state of returned IAPs to Discovered // if state is not already Active for(TUint i=0; iConnectionId(); TUint subConnectionCount = 0; - TUint apId; + TUint apId; TRequestStatus status; iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); User::WaitForRequest(status); @@ -1088,7 +1088,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) // Connection has been successfully opened TUint connectionId = realEvent->ConnectionId(); TUint subConnectionCount = 0; - TUint apId; + TUint apId; TRequestStatus status; iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); User::WaitForRequest(status); @@ -1144,7 +1144,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) connectionId, QNetworkSession::Disconnected); ); } - + bool online = false; foreach (const QString &iface, accessPointConfigurations.keys()) { QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(iface); @@ -1160,7 +1160,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) } } } - break; + break; case EConnMonIapAvailabilityChange: { @@ -1174,7 +1174,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); if (ptr) { - // Configuration is either Discovered or Active + // Configuration is either Discovered or Active QT_TRYCATCH_LEAVING(changeConfigurationStateAtMinTo(ptr, QNetworkConfiguration::Discovered)); unDiscoveredConfigs.removeOne(ident); } @@ -1360,7 +1360,7 @@ AccessPointsAvailabilityScanner::AccessPointsAvailabilityScanner(SymbianEngine& RConnectionMonitor& connectionMonitor) : CActive(CActive::EPriorityHigh), iOwner(owner), iConnectionMonitor(connectionMonitor) { - CActiveScheduler::Add(this); + CActiveScheduler::Add(this); } AccessPointsAvailabilityScanner::~AccessPointsAvailabilityScanner() diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index 3b3a78a..b2cf0b3 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -145,10 +145,10 @@ public: Q_SIGNALS: void onlineStateChanged(bool isOnline); - + void configurationStateChanged(quint32 accessPointId, quint32 connMonId, QNetworkSession::State newState); - + public Q_SLOTS: void updateConfigurations(); void delayedConfigurationUpdate(); @@ -169,8 +169,8 @@ private: TUint32 aApId, SymbianNetworkConfigurationPrivate *apNetworkConfiguration); void readNetworkConfigurationValuesFromCommsDbL( TUint32 aApId, SymbianNetworkConfigurationPrivate *apNetworkConfiguration); -#endif - +#endif + void updateConfigurationsL(); void updateActiveAccessPoints(); void updateAvailableAccessPoints(); @@ -188,7 +188,7 @@ protected: // From CActive void RunL(); void DoCancel(); - + private: // MConnectionMonitorObserver void EventL(const CConnMonEventBase& aEvent); @@ -198,7 +198,7 @@ private: #endif private: // Data - bool iFirstUpdate; + bool iFirstUpdate; CCommsDatabase* ipCommsDB; RConnectionMonitor iConnectionMonitor; @@ -225,11 +225,11 @@ class AccessPointsAvailabilityScanner : public CActive { public: AccessPointsAvailabilityScanner(SymbianEngine& owner, - RConnectionMonitor& connectionMonitor); + RConnectionMonitor& connectionMonitor); ~AccessPointsAvailabilityScanner(); void StartScanning(); - + protected: // From CActive void RunL(); void DoCancel(); -- cgit v0.12 From 756d289e08e75142e92e6e4472de8ad52cdcdc9a Mon Sep 17 00:00:00 2001 From: mread Date: Tue, 5 Jul 2011 11:21:39 +0100 Subject: Fixing WINSCW compile error Refactoring the body of a large TRAP into a separate function. This was not compiling on WINSCW, perhaps due to the use of #ifdef within the TRAP macro expansion. It does compile now. Reviewed-by: Sami Merila --- src/plugins/bearer/symbian/symbianengine.cpp | 21 ++++++++++++--------- src/plugins/bearer/symbian/symbianengine.h | 2 ++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index 1902292..fc2791a 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -104,15 +104,7 @@ void SymbianEngine::initialize() return; } - TRAP(error, { - iConnectionMonitor.ConnectL(); - CleanupClosePushL(iConnectionMonitor); -#ifdef SNAP_FUNCTIONALITY_AVAILABLE - User::LeaveIfError(iConnectionMonitor.SetUintAttribute(EBearerIdAll, 0, KBearerGroupThreshold, 1)); -#endif - iConnectionMonitor.NotifyEventL(*this); - CleanupStack::Pop(); - }); + TRAP(error, StartConnectionMonitorNotifyL()); if (error != KErrNone) { iInitOk = false; return; @@ -148,6 +140,17 @@ void SymbianEngine::initialize() startCommsDatabaseNotifications(); } +void SymbianEngine::StartConnectionMonitorNotifyL() +{ + iConnectionMonitor.ConnectL(); + CleanupClosePushL(iConnectionMonitor); +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + User::LeaveIfError(iConnectionMonitor.SetUintAttribute(EBearerIdAll, 0, KBearerGroupThreshold, 1)); +#endif + iConnectionMonitor.NotifyEventL(*this); + CleanupStack::Pop(); +} + SymbianEngine::~SymbianEngine() { Cancel(); diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index b2cf0b3..a205c97 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -184,6 +184,8 @@ private: void startMonitoringIAPData(TUint32 aIapId); QNetworkConfigurationPrivatePointer dataByConnectionId(TUint aConnectionId); + void StartConnectionMonitorNotifyL(); + protected: // From CActive void RunL(); -- cgit v0.12 From eecc9d287c6d9db62b24ee2c80eb994a5552e41f Mon Sep 17 00:00:00 2001 From: Stanislav Ionascu Date: Tue, 5 Jul 2011 12:48:11 +0200 Subject: Fixes switching runtime graphics system when the maximized window is shown or hidden. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 1287 Reviewed-by: Samuel Rødal --- src/plugins/graphicssystems/meego/qmeegographicssystem.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp index 6268d4b..a034b0e 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp @@ -174,6 +174,14 @@ bool QMeeGoGraphicsSystemSwitchHandler::eventFilter(QObject *object, QEvent *eve QMeeGoGraphicsSystem::switchToMeeGo(); } } + } else if (event->type() == QEvent::Show + && QMeeGoGraphicsSystem::switchPolicy == QMeeGoGraphicsSystem::AutomaticSwitch) { + if (visibleWidgets() > 0) + QMeeGoGraphicsSystem::switchToMeeGo(); + } else if (event->type() == QEvent::Hide + && QMeeGoGraphicsSystem::switchPolicy == QMeeGoGraphicsSystem::AutomaticSwitch) { + if (visibleWidgets() == 0) + QMeeGoGraphicsSystem::switchToRaster(); } // resume processing of event -- cgit v0.12 From 83e93784a2da9e1898790e4455225da220f44d81 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Tue, 5 Jul 2011 13:40:57 +0200 Subject: Fix regressions in previous QFontDatabase patch 1. QtFontStyle::Key comparison should either use styleName or style, etc., but not both. 2. When initializing a QFont from QFontDatabase::font(), style and weight parameters should always be set even when we found a match styleName, in case these parameters will be used for comparison later. Reviewed-by: Eskil --- src/gui/text/qfontdatabase.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 8b5e443..5f50c40 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -226,9 +226,9 @@ struct QtFontStyle signed int stretch : 12; bool operator==(const Key & other) { - return styleName == other.styleName && style == other.style && - weight == other.weight && - (stretch == 0 || other.stretch == 0 || stretch == other.stretch); + return (!styleName.isEmpty() && !other.styleName.isEmpty() && styleName == other.styleName) || + (style == other.style && weight == other.weight && + (stretch == 0 || other.stretch == 0 || stretch == other.stretch)); } bool operator!=(const Key &other) { return !operator==(other); @@ -2030,16 +2030,12 @@ QFont QFontDatabase::font(const QString &family, const QString &style, if (!s) // no styles found? return QApplication::font(); - if (s->key.styleName.isEmpty()) { - QFont fnt(family, pointSize, s->key.weight); - fnt.setStyle((QFont::Style)s->key.style); - return fnt; - } else { - // found a perfect match - QFont fnt(family, pointSize); + + QFont fnt(family, pointSize, s->key.weight); + fnt.setStyle((QFont::Style)s->key.style); + if (!s->key.styleName.isEmpty()) fnt.setStyleName(s->key.styleName); - return fnt; - } + return fnt; } -- cgit v0.12 From 56d49960bb99b7a4c18fc106fcca4effaeea8782 Mon Sep 17 00:00:00 2001 From: Jan-Arve Saether Date: Tue, 5 Jul 2011 14:04:28 +0200 Subject: My changes for 4.8.0 --- dist/changes-4.8.0 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dist/changes-4.8.0 b/dist/changes-4.8.0 index ae6d2c5..2f5858b 100644 --- a/dist/changes-4.8.0 +++ b/dist/changes-4.8.0 @@ -62,6 +62,7 @@ QtGui - QTabBar: reduced minimumSizeHint if ElideMode is set. - QComboBox: Fixed a color propagation issue with the lineedit. [QTBUG-5950] + - QGraphicsLayout: Made setInstantInvalidatePropagation() public - Deprecate qGenericMatrixFromMatrix4x4 and qGenericMatrixToMatrix4x4 - QListView diverses optimisations [QTBUG-11438] - QTreeWidget/QListWidget: use localeAwareCompare for string comparisons [QTBUG-10839] @@ -76,6 +77,8 @@ QtGui - Accessibility: Make QTabWidget child hierarchy consistent. - Accessibility: Report correct window title and application name. - Accessibility: Return text attributes for QTextEdit. + - Accessibility: Make accessibility work on Windows with alien widgets + - Accessibility: Several enablers for accessible graphicsview and Qt Quick applications. QtNetwork -- cgit v0.12 From 9ef422955154199e6f2d5569cb4074a5967f53e9 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 5 Jul 2011 14:06:43 +0200 Subject: Lion Support: Fix QSpinBox look Also sets the read-only state in QStyleOptionSpinBox, wich wasn't before. Reviewed-by: Jens Bache-Wiig --- src/gui/styles/qmacstyle_mac.mm | 2 +- src/gui/widgets/qabstractspinbox.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index efe2e7d..321db25 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -4725,7 +4725,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex HIThemeFrameDrawInfo fdi; fdi.version = qt_mac_hitheme_version; - fdi.state = tds; + fdi.state = ((sb->state & State_ReadOnly) || !(sb->state & State_Enabled)) ? kThemeStateInactive : kThemeStateActive; fdi.kind = kHIThemeFrameTextFieldSquare; fdi.isFocused = false; HIRect hirect = qt_hirectForQRect(lineeditRect); diff --git a/src/gui/widgets/qabstractspinbox.cpp b/src/gui/widgets/qabstractspinbox.cpp index 4372ae3..7a985a1 100644 --- a/src/gui/widgets/qabstractspinbox.cpp +++ b/src/gui/widgets/qabstractspinbox.cpp @@ -1655,6 +1655,8 @@ void QAbstractSpinBox::initStyleOption(QStyleOptionSpinBox *option) const : (QAbstractSpinBox::StepDownEnabled|QAbstractSpinBox::StepUpEnabled); option->frame = d->frame; + if (d->readOnly) + option->state |= QStyle::State_ReadOnly; } /*! -- cgit v0.12 From d9bdaeff3b25ae72fe766bf54a4f76f23d97705b Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Tue, 5 Jul 2011 16:14:01 +0300 Subject: Support partial input mode Connect the internal private API to the QApplication public attribute. This allows the enabling/disabling of the splitview functionality from apps without any hacks. Task-number: QTBUG-16572 Reviewed-by: Tomi Vihria --- src/gui/inputmethod/qcoefepinputcontext_p.h | 1 + src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 16 ++++++++++++---- src/gui/kernel/qapplication.cpp | 4 ++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_p.h b/src/gui/inputmethod/qcoefepinputcontext_p.h index e929880..9fd2703 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_p.h +++ b/src/gui/inputmethod/qcoefepinputcontext_p.h @@ -108,6 +108,7 @@ private: bool needsInputPanel(); void commitTemporaryPreeditString(); bool isWidgetVisible(QWidget *widget, int offset = 0); + bool isPartialKeyboardSupported(); private Q_SLOTS: void ensureInputCapabilitiesChanged(); diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 602c734..567f83b 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -83,6 +83,8 @@ Q_GUI_EXPORT void qt_s60_setPartialScreenInputMode(bool enable) { S60->partial_keyboard = enable; + QApplication::setAttribute(Qt::AA_S60DisablePartialScreenInputMode, !S60->partial_keyboard); + QInputContext *ic = 0; if (QApplication::focusWidget()) { ic = QApplication::focusWidget()->inputContext(); @@ -111,7 +113,7 @@ QCoeFepInputContext::QCoeFepInputContext(QObject *parent) m_fepState->SetObjectProvider(this); int defaultFlags = EAknEditorFlagDefault; if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0) { - if (S60->partial_keyboard) { + if (isPartialKeyboardSupported()) { defaultFlags |= QT_EAknEditorFlagEnablePartialScreen; } defaultFlags |= QT_EAknEditorFlagSelectionVisible; @@ -420,7 +422,8 @@ void QCoeFepInputContext::mouseHandler(int x, QMouseEvent *event) //If splitview is open and T9 word is tapped, pass the pointer event to pointer handler. //This will open the "suggested words" list. Pass pointer position always as zero, to make //full word replacement in case user makes a selection. - if (S60->partial_keyboard && S60->partialKeyboardOpen + if (isPartialKeyboardSupported() + && S60->partialKeyboardOpen && m_pointerHandler && !(currentHints & Qt::ImhNoPredictiveText) && (x > 0 && x < m_preeditString.length())) { @@ -534,6 +537,11 @@ bool QCoeFepInputContext::isWidgetVisible(QWidget *widget, int offset) return visible; } +bool QCoeFepInputContext::isPartialKeyboardSupported() +{ + return (S60->partial_keyboard || !QApplication::testAttribute(Qt::AA_S60DisablePartialScreenInputMode)); +} + // Ensure that the input widget is visible in the splitview rect. void QCoeFepInputContext::ensureFocusWidgetVisible(QWidget *widget) @@ -644,7 +652,7 @@ void QCoeFepInputContext::updateHints(bool mustUpdateInputCapabilities) // we need to update its state separately. if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0) { TInt currentFlags = m_fepState->Flags(); - if (S60->partial_keyboard) + if (isPartialKeyboardSupported()) currentFlags |= QT_EAknEditorFlagEnablePartialScreen; else currentFlags &= ~QT_EAknEditorFlagEnablePartialScreen; @@ -761,7 +769,7 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) flags = 0; if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0) { - if (S60->partial_keyboard) + if (isPartialKeyboardSupported()) flags |= QT_EAknEditorFlagEnablePartialScreen; flags |= QT_EAknEditorFlagSelectionVisible; } diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 4552255..34ce9a8 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -1017,6 +1017,10 @@ void QApplicationPrivate::initialize() QApplicationPrivate::wheel_scroll_lines = 3; #endif +#ifdef Q_WS_S60 + q->setAttribute(Qt::AA_S60DisablePartialScreenInputMode); +#endif + if (qt_is_gui_used) initializeMultitouch(); } -- cgit v0.12 From be63b3e85c50e56b18d0f0bf93ad3b1c74049117 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Tue, 5 Jul 2011 15:53:57 +0200 Subject: Add a null check for the backend in QNetworkReplyImpl. This is a blurry attempt to fix a crash happening during bearer session loss/recovery. Reviewed-by: Markus Goetz --- src/network/access/qnetworkreplyimpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 574b6e9..8a0a944 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -924,7 +924,7 @@ bool QNetworkReplyImplPrivate::migrateBackend() return true; // Backend does not support resuming download. - if (!backend->canResume()) + if (backend && !backend->canResume()) return false; state = QNetworkReplyImplPrivate::Reconnecting; -- cgit v0.12 From ca0b81567d76d3af82ce025e029fb5efa50846ed Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Tue, 5 Jul 2011 17:13:04 +0300 Subject: Support partial input mode - documentation update Update the documentation related to the QApplication attribute. Task-number: QTBUG-16572 Reviewed-by: Tomi Vihria --- src/corelib/global/qnamespace.qdoc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 87b8255..eabaf10 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -156,12 +156,16 @@ whole lifetime. This attribute must be set before QApplication is constructed. - \omitvalue AA_S60DisablePartialScreenInputMode By default in Symbian^3, - a separate editing window is opened on top of an application. This is exactly - like editing on previous versions of Symbian behave. When this attribute - is true, a virtual keyboard window is shown on top of application and it - is ensured that the focused text widget is visible. This is only supported in - Symbian^3. (internal) + \value AA_S60DisablePartialScreenInputMode By default in Symbian^3, a separate + editing window is opened on top of an application. This is exactly like + editing on previous versions of Symbian behave. When this attribute is false, + a non-fullscreen virtual keyboard window is shown on top of application and + it is ensured that the focused text input widget is visible. + The auto-translation of input widget is only supported for applications + based on QGraphicsView, but the non-fullscreen virtual keyboard will + work for any kind of application (i.e. QWidgets-based). By default this + attribute is true. This attribute must be set after QApplication is + constructed. This is only supported in Symbian^3 and later Symbian releases. \omitvalue AA_AttributeCount */ -- cgit v0.12 From b487fb1cc1a3be4a197ec458fc3b575d7b57d6a5 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 5 Jul 2011 16:21:50 +0200 Subject: HTTP internals: do not discard data if not receiving gzip end marker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit some servers send gzip data without the gzip end markers. In that case, we should deliver all content and tear down the gzip data structures. Reviewed-by: Markus Goetz Patch-by: Tor Arne Vestbø and Peter Hartmann Task-number: QTBUG-16022 --- src/network/access/qhttpnetworkconnectionchannel.cpp | 7 +++++-- src/network/access/qhttpnetworkreply.cpp | 10 ++++++++-- src/network/access/qhttpnetworkreply_p.h | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 63f923f..7c2e2a1 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -599,8 +599,11 @@ bool QHttpNetworkConnectionChannel::expand(bool dataComplete) int ret = Z_OK; if (content.size()) ret = reply->d_func()->gunzipBodyPartially(content, inflated); - int retCheck = (dataComplete) ? Z_STREAM_END : Z_OK; - if (ret >= retCheck) { + if (ret >= Z_OK) { + if (dataComplete && ret == Z_OK && !reply->d_func()->streamEnd) { + reply->d_func()->gunzipBodyPartiallyEnd(); + reply->d_func()->streamEnd = true; + } if (inflated.size()) { reply->d_func()->totalProgress += inflated.size(); reply->d_func()->appendUncompressedReplyData(inflated); diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index 516841a..01360d5 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -434,12 +434,18 @@ int QHttpNetworkReplyPrivate::gunzipBodyPartially(QByteArray &compressed, QByteA } while (inflateStrm.avail_out == 0); // clean up and return if (ret <= Z_ERRNO || ret == Z_STREAM_END) { - inflateEnd(&inflateStrm); - initInflate = false; + gunzipBodyPartiallyEnd(); } streamEnd = (ret == Z_STREAM_END); return ret; } + +void QHttpNetworkReplyPrivate::gunzipBodyPartiallyEnd() +{ + inflateEnd(&inflateStrm); + initInflate = false; +} + #endif qint64 QHttpNetworkReplyPrivate::readStatus(QAbstractSocket *socket) diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h index 05feaa9..365308f 100644 --- a/src/network/access/qhttpnetworkreply_p.h +++ b/src/network/access/qhttpnetworkreply_p.h @@ -200,6 +200,7 @@ public: #ifndef QT_NO_COMPRESS bool gzipCheckHeader(QByteArray &content, int &pos); int gunzipBodyPartially(QByteArray &compressed, QByteArray &inflated); + void gunzipBodyPartiallyEnd(); #endif void removeAutoDecompressHeader(); -- cgit v0.12 From cc504be6500911d9109f513a60c8116cacb39fe4 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 5 Jul 2011 17:32:54 +0200 Subject: HTTP internals: continue gzip decompression if buffer fills exactly Reviewed-by: Markus Goetz Reviewed-by: Prasanth Ullattil Task-number: QTBUG-12908 --- src/network/access/qhttpnetworkreply.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index 01360d5..0f2fcba 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -431,7 +431,7 @@ int QHttpNetworkReplyPrivate::gunzipBodyPartially(QByteArray &compressed, QByteA } have = sizeof(out) - inflateStrm.avail_out; inflated.append(QByteArray((const char *)out, have)); - } while (inflateStrm.avail_out == 0); + } while (inflateStrm.avail_out == 0 && inflateStrm.avail_in > 0); // clean up and return if (ret <= Z_ERRNO || ret == Z_STREAM_END) { gunzipBodyPartiallyEnd(); -- cgit v0.12 From db1c29aaed0730db38f19dfb376fd2c03d08c04e Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 5 Jul 2011 14:06:01 +0200 Subject: Fix QScopedPointerarray default constructor Since the compiler cannod find the template argument if there is no argument passed to the constructor, this effectively means there is no default constructor. Add a default constructor Task-number: QTBUG-20256 Change-Id: I310d5e1f3f94a8fe69fd3a5c46f2f51bca60facd Reviewed-on: http://codereview.qt.nokia.com/1165 Reviewed-by: Qt Sanity Bot Reviewed-by: Denis Dzyubenko (cherry picked from commit d789e40c58c1ce8441d3bb4d6ca8d01fe02ad1a7) --- src/corelib/tools/qscopedpointer.h | 4 +++- tests/auto/qscopedpointer/tst_qscopedpointer.cpp | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index b15bcac..a24f62e 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -208,8 +208,10 @@ template > class QScopedArrayPointer : public QScopedPointer { public: + inline QScopedArrayPointer() : QScopedPointer(0) {} + template - explicit inline QScopedArrayPointer(D *p = 0, typename QtPrivate::QScopedArrayEnsureSameType::Type = 0) + explicit inline QScopedArrayPointer(D *p, typename QtPrivate::QScopedArrayEnsureSameType::Type = 0) : QScopedPointer(p) { } diff --git a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp index 1a6f944..06c0ecb 100644 --- a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp +++ b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp @@ -72,6 +72,7 @@ private Q_SLOTS: void isNullSignature(); void objectSize(); void comparison(); + void array(); // TODO instanciate on const object }; @@ -437,5 +438,26 @@ void tst_QScopedPointer::comparison() QCOMPARE( int(RefCounted::instanceCount), 0 ); } +void tst_QScopedPointer::array() +{ + int instCount = RefCounted::instanceCount; + { + QScopedArrayPointer array; + array.reset(new RefCounted[42]); + QCOMPARE(instCount + 42, int(RefCounted::instanceCount)); + } + QCOMPARE(instCount, int(RefCounted::instanceCount)); + { + QScopedArrayPointer array(new RefCounted[42]); + QCOMPARE(instCount + 42, int(RefCounted::instanceCount)); + array.reset(new RefCounted[28]); + QCOMPARE(instCount + 28, int(RefCounted::instanceCount)); + array.reset(0); + QCOMPARE(instCount, int(RefCounted::instanceCount)); + } + QCOMPARE(instCount, int(RefCounted::instanceCount)); +} + + QTEST_MAIN(tst_QScopedPointer) #include "tst_qscopedpointer.moc" -- cgit v0.12 From e5e1ff0d6f4e6a8457da61b5b215730de6f960bd Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 6 Jul 2011 11:44:57 +0200 Subject: Fix bidi reordering when part of text is rendered by fallback font If the fallback font is used for part of a RTL text, we need to position the different text items accordingly, subtracting the advance instead of adding it. Task-number: QTBUG-17117 Done-with: Lars --- src/gui/painting/qpainter.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index a4ab00a..604c1ab 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -6512,6 +6512,10 @@ void QPainter::drawTextItem(const QPointF &p, const QTextItem &_ti) qreal x = p.x(); qreal y = p.y(); + bool rtl = ti.flags & QTextItem::RightToLeft; + if (rtl) + x += ti.width.toReal(); + int start = 0; int end, i; for (end = 0; end < ti.glyphs.numGlyphs; ++end) { @@ -6528,14 +6532,19 @@ void QPainter::drawTextItem(const QPointF &p, const QTextItem &_ti) ti2.width += ti.glyphs.effectiveAdvance(i); } + if (rtl) + x -= ti2.width.toReal(); + d->engine->drawTextItem(QPointF(x, y), ti2); + if (!rtl) + x += ti2.width.toReal(); + // reset the high byte for all glyphs and advance to the next sub-string const int hi = which << 24; for (i = start; i < end; ++i) { glyphs.glyphs[i] = hi | glyphs.glyphs[i]; } - x += ti2.width.toReal(); // change engine start = end; @@ -6550,6 +6559,9 @@ void QPainter::drawTextItem(const QPointF &p, const QTextItem &_ti) ti2.width += ti.glyphs.effectiveAdvance(i); } + if (rtl) + x -= ti2.width.toReal(); + if (d->extended) d->extended->drawTextItem(QPointF(x, y), ti2); else -- cgit v0.12 From dd0205e0fbacf340508686cc136d70eda7bf664d Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Wed, 6 Jul 2011 11:50:58 +0200 Subject: Move styleName out of QtFontStyle::Key Makes the code clearer and more explicit. Reviewed-by: Eskil --- src/gui/text/qfontdatabase.cpp | 77 ++++++++++++++++++++++---------------- src/gui/text/qfontdatabase_mac.cpp | 6 +-- src/gui/text/qfontdatabase_qpa.cpp | 2 +- src/gui/text/qfontdatabase_win.cpp | 8 ++-- src/gui/text/qfontdatabase_x11.cpp | 10 ++--- 5 files changed, 57 insertions(+), 46 deletions(-) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 5f50c40..dc8fd45 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -218,16 +218,13 @@ struct QtFontStyle Key(const QString &styleString); Key() : style(QFont::StyleNormal), weight(QFont::Normal), stretch(0) { } - Key(const Key &o) : styleName(o.styleName), style(o.style), - weight(o.weight), stretch(o.stretch) { } - QString styleName; + Key(const Key &o) : style(o.style), weight(o.weight), stretch(o.stretch) { } uint style : 2; signed int weight : 8; signed int stretch : 12; bool operator==(const Key & other) { - return (!styleName.isEmpty() && !other.styleName.isEmpty() && styleName == other.styleName) || - (style == other.style && weight == other.weight && + return (style == other.style && weight == other.weight && (stretch == 0 || other.stretch == 0 || stretch == other.stretch)); } bool operator!=(const Key &other) { @@ -280,6 +277,7 @@ struct QtFontStyle bool smoothScalable : 1; signed int count : 30; QtFontSize *pixelSizes; + QString styleName; #ifdef Q_WS_X11 const char *weightName; @@ -293,7 +291,7 @@ struct QtFontStyle }; QtFontStyle::Key::Key(const QString &styleString) - : styleName(styleString), style(QFont::StyleNormal), weight(QFont::Normal), stretch(0) + : style(QFont::StyleNormal), weight(QFont::Normal), stretch(0) { weight = getFontWeight(styleString); @@ -354,13 +352,20 @@ struct QtFontFoundry int count; QtFontStyle **styles; - QtFontStyle *style(const QtFontStyle::Key &, bool = false); + QtFontStyle *style(const QtFontStyle::Key &, const QString & = QString(), bool = false); }; -QtFontStyle *QtFontFoundry::style(const QtFontStyle::Key &key, bool create) +QtFontStyle *QtFontFoundry::style(const QtFontStyle::Key &key, const QString &styleName, bool create) { int pos = 0; if (count) { + // if styleName for searching first if possible + if (!styleName.isEmpty()) { + for (; pos < count; pos++) { + if (styles[pos]->styleName == styleName) + return styles[pos]; + } + } int low = 0; int high = count; pos = count / 2; @@ -387,6 +392,7 @@ QtFontStyle *QtFontFoundry::style(const QtFontStyle::Key &key, bool create) } QtFontStyle *style = new QtFontStyle(key); + style->styleName = styleName; memmove(styles + pos + 1, styles + pos, (count-pos)*sizeof(QtFontStyle *)); styles[pos] = style; count++; @@ -815,7 +821,7 @@ void QFontDatabasePrivate::addFont(const QString &familyname, const char *foundr } QtFontFoundry *foundry = f->foundry(QString::fromLatin1(foundryname), true); - QtFontStyle *style = foundry->style(styleKey, true); + QtFontStyle *style = foundry->style(styleKey, QString(), true); style->smoothScalable = (pixelSize == 0); style->antialiased = antialiased; QtFontSize *size = style->pixelSize(pixelSize?pixelSize:SMOOTH_SCALABLE, true); @@ -1132,7 +1138,8 @@ QString QFontDatabase::resolveFontFamilyAlias(const QString &family) #endif QT_END_INCLUDE_NAMESPACE -static QtFontStyle *bestStyle(QtFontFoundry *foundry, const QtFontStyle::Key &styleKey) +static QtFontStyle *bestStyle(QtFontFoundry *foundry, const QtFontStyle::Key &styleKey, + const QString &styleName = QString()) { int best = 0; int dist = 0xffff; @@ -1140,7 +1147,7 @@ static QtFontStyle *bestStyle(QtFontFoundry *foundry, const QtFontStyle::Key &st for ( int i = 0; i < foundry->count; i++ ) { QtFontStyle *style = foundry->styles[i]; - if (!styleKey.styleName.isEmpty() && styleKey.styleName == style->key.styleName) { + if (!styleName.isEmpty() && styleName == style->styleName) { dist = 0; best = i; break; @@ -1797,16 +1804,16 @@ QStringList QFontDatabase::styles(const QString &family) const for (int k = 0; k < foundry->count; k++) { QtFontStyle::Key ke(foundry->styles[k]->key); ke.stretch = 0; - allStyles.style(ke, true); + allStyles.style(ke, foundry->styles[k]->styleName, true); } } } for (int i = 0; i < allStyles.count; i++) { - l.append(allStyles.styles[i]->key.styleName.isEmpty() ? + l.append(allStyles.styles[i]->styleName.isEmpty() ? styleStringHelper(allStyles.styles[i]->key.weight, (QFont::Style)allStyles.styles[i]->key.style) : - allStyles.styles[i]->key.styleName); + allStyles.styles[i]->styleName); } return l; } @@ -1865,7 +1872,9 @@ bool QFontDatabase::isBitmapScalable(const QString &family, QtFontFoundry *foundry = f->foundries[j]; if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) { for (int k = 0; k < foundry->count; k++) - if ((style.isEmpty() || foundry->styles[k]->key == styleKey) + if ((style.isEmpty() || + foundry->styles[k]->styleName == style || + foundry->styles[k]->key == styleKey) && foundry->styles[k]->bitmapScalable && !foundry->styles[k]->smoothScalable) { bitmapScalable = true; goto end; @@ -1904,7 +1913,9 @@ bool QFontDatabase::isSmoothlyScalable(const QString &family, const QString &sty QtFontFoundry *foundry = f->foundries[j]; if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) { for (int k = 0; k < foundry->count; k++) - if ((style.isEmpty() || foundry->styles[k]->key == styleKey) && foundry->styles[k]->smoothScalable) { + if ((style.isEmpty() || + foundry->styles[k]->styleName == style || + foundry->styles[k]->key == styleKey) && foundry->styles[k]->smoothScalable) { smoothScalable = true; goto end; } @@ -1937,7 +1948,7 @@ bool QFontDatabase::isScalable(const QString &family, \sa smoothSizes(), standardSizes() */ QList QFontDatabase::pointSizes(const QString &family, - const QString &style) + const QString &styleName) { #if defined(Q_WS_WIN) // windows and macosx are always smoothly scalable @@ -1953,7 +1964,7 @@ QList QFontDatabase::pointSizes(const QString &family, QT_PREPEND_NAMESPACE(load)(familyName); - QtFontStyle::Key styleKey(style); + QtFontStyle::Key styleKey(styleName); QList sizes; @@ -1970,7 +1981,7 @@ QList QFontDatabase::pointSizes(const QString &family, for (int j = 0; j < fam->count; j++) { QtFontFoundry *foundry = fam->foundries[j]; if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) { - QtFontStyle *style = foundry->style(styleKey); + QtFontStyle *style = foundry->style(styleKey, styleName); if (!style) continue; if (style->smoothScalable) { @@ -2021,20 +2032,20 @@ QFont QFontDatabase::font(const QString &family, const QString &style, QtFontFoundry *foundry = f->foundries[j]; if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) { for (int k = 0; k < foundry->count; k++) - allStyles.style(foundry->styles[k]->key, true); + allStyles.style(foundry->styles[k]->key, foundry->styles[k]->styleName, true); } } QtFontStyle::Key styleKey(style); - QtFontStyle *s = bestStyle(&allStyles, styleKey); + QtFontStyle *s = bestStyle(&allStyles, styleKey, style); if (!s) // no styles found? return QApplication::font(); QFont fnt(family, pointSize, s->key.weight); fnt.setStyle((QFont::Style)s->key.style); - if (!s->key.styleName.isEmpty()) - fnt.setStyleName(s->key.styleName); + if (!s->styleName.isEmpty()) + fnt.setStyleName(s->styleName); return fnt; } @@ -2048,11 +2059,11 @@ QFont QFontDatabase::font(const QString &family, const QString &style, \sa pointSizes(), standardSizes() */ QList QFontDatabase::smoothSizes(const QString &family, - const QString &style) + const QString &styleName) { #ifdef Q_WS_WIN Q_UNUSED(family); - Q_UNUSED(style); + Q_UNUSED(styleName); return QFontDatabase::standardSizes(); #else bool smoothScalable = false; @@ -2063,7 +2074,7 @@ QList QFontDatabase::smoothSizes(const QString &family, QT_PREPEND_NAMESPACE(load)(familyName); - QtFontStyle::Key styleKey(style); + QtFontStyle::Key styleKey(styleName); QList sizes; @@ -2080,7 +2091,7 @@ QList QFontDatabase::smoothSizes(const QString &family, for (int j = 0; j < fam->count; j++) { QtFontFoundry *foundry = fam->foundries[j]; if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) { - QtFontStyle *style = foundry->style(styleKey); + QtFontStyle *style = foundry->style(styleKey, styleName); if (!style) continue; if (style->smoothScalable) { @@ -2147,12 +2158,12 @@ bool QFontDatabase::italic(const QString &family, const QString &style) const QtFontFoundry *foundry = f->foundries[j]; if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) { for (int k = 0; k < foundry->count; k++) - allStyles.style(foundry->styles[k]->key, true); + allStyles.style(foundry->styles[k]->key, foundry->styles[k]->styleName, true); } } QtFontStyle::Key styleKey(style); - QtFontStyle *s = allStyles.style(styleKey); + QtFontStyle *s = allStyles.style(styleKey, style); return s && s->key.style == QFont::StyleItalic; } @@ -2182,12 +2193,12 @@ bool QFontDatabase::bold(const QString &family, if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) { for (int k = 0; k < foundry->count; k++) - allStyles.style(foundry->styles[k]->key, true); + allStyles.style(foundry->styles[k]->key, foundry->styles[k]->styleName, true); } } QtFontStyle::Key styleKey(style); - QtFontStyle *s = allStyles.style(styleKey); + QtFontStyle *s = allStyles.style(styleKey, style); return s && s->key.weight >= QFont::Bold; } @@ -2218,12 +2229,12 @@ int QFontDatabase::weight(const QString &family, if (foundryName.isEmpty() || foundry->name.compare(foundryName, Qt::CaseInsensitive) == 0) { for (int k = 0; k < foundry->count; k++) - allStyles.style(foundry->styles[k]->key, true); + allStyles.style(foundry->styles[k]->key, foundry->styles[k]->styleName, true); } } QtFontStyle::Key styleKey(style); - QtFontStyle *s = allStyles.style(styleKey); + QtFontStyle *s = allStyles.style(styleKey, style); return s ? s->key.weight : -1; } diff --git a/src/gui/text/qfontdatabase_mac.cpp b/src/gui/text/qfontdatabase_mac.cpp index 0f6d6bf..fc8247d 100644 --- a/src/gui/text/qfontdatabase_mac.cpp +++ b/src/gui/text/qfontdatabase_mac.cpp @@ -113,7 +113,7 @@ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) { QtFontFoundry *foundry = family->foundry(foundry_name, true); QtFontStyle::Key styleKey; - styleKey.styleName = style_name; + QString styleName = style_name; if(QCFType styles = (CFDictionaryRef)CTFontDescriptorCopyAttribute(font, kCTFontTraitsAttribute)) { if(CFNumberRef weight = (CFNumberRef)CFDictionaryGetValue(styles, kCTFontWeightTrait)) { Q_ASSERT(CFNumberIsFloatType(weight)); @@ -134,7 +134,7 @@ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) { } } - QtFontStyle *style = foundry->style(styleKey, true); + QtFontStyle *style = foundry->style(styleKey, styleName, true); style->smoothScalable = true; if(QCFType size = (CFNumberRef)CTFontDescriptorCopyAttribute(font, kCTFontSizeAttribute)) { //qDebug() << "WHEE"; @@ -207,7 +207,7 @@ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) { QtFontFamily *family = db->family(familyName, true); QtFontFoundry *foundry = family->foundry(QString(), true); - QtFontStyle *style = foundry->style(styleKey, true); + QtFontStyle *style = foundry->style(styleKey, QString(), true); style->pixelSize(0, true); style->smoothScalable = true; diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp index fd5c6b4..6b6f4f1 100644 --- a/src/gui/text/qfontdatabase_qpa.cpp +++ b/src/gui/text/qfontdatabase_qpa.cpp @@ -73,7 +73,7 @@ Q_GUI_EXPORT void qt_registerFont(const QString &familyName, const QString &fou } QtFontFoundry *foundry = f->foundry(foundryname, true); - QtFontStyle *fontStyle = foundry->style(styleKey, true); + QtFontStyle *fontStyle = foundry->style(styleKey, QString(), true); fontStyle->smoothScalable = scalable; fontStyle->antialiased = antialiased; QtFontSize *size = fontStyle->pixelSize(pixelSize?pixelSize:SMOOTH_SCALABLE, true); diff --git a/src/gui/text/qfontdatabase_win.cpp b/src/gui/text/qfontdatabase_win.cpp index 20f945a..788eb30 100644 --- a/src/gui/text/qfontdatabase_win.cpp +++ b/src/gui/text/qfontdatabase_win.cpp @@ -284,7 +284,7 @@ void addFontToDatabase(QString familyName, const QString &scriptName, family->english_name = getEnglishName(familyName); QtFontFoundry *foundry = family->foundry(foundryName, true); - QtFontStyle *style = foundry->style(styleKey, true); + QtFontStyle *style = foundry->style(styleKey, QString(), true); style->smoothScalable = scalable; style->pixelSize( size, TRUE); @@ -292,14 +292,14 @@ void addFontToDatabase(QString familyName, const QString &scriptName, if (styleKey.weight <= QFont::DemiBold) { QtFontStyle::Key key(styleKey); key.weight = QFont::Bold; - QtFontStyle *style = foundry->style(key, true); + QtFontStyle *style = foundry->style(key, QString(), true); style->smoothScalable = scalable; style->pixelSize( size, TRUE); } if (styleKey.style != QFont::StyleItalic) { QtFontStyle::Key key(styleKey); key.style = QFont::StyleItalic; - QtFontStyle *style = foundry->style(key, true); + QtFontStyle *style = foundry->style(key, QString(), true); style->smoothScalable = scalable; style->pixelSize( size, TRUE); } @@ -307,7 +307,7 @@ void addFontToDatabase(QString familyName, const QString &scriptName, QtFontStyle::Key key(styleKey); key.weight = QFont::Bold; key.style = QFont::StyleItalic; - QtFontStyle *style = foundry->style(key, true); + QtFontStyle *style = foundry->style(key, QString(), true); style->smoothScalable = scalable; style->pixelSize( size, TRUE); } diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp index ed94fa6..922a97f 100644 --- a/src/gui/text/qfontdatabase_x11.cpp +++ b/src/gui/text/qfontdatabase_x11.cpp @@ -680,7 +680,7 @@ static void loadXlfds(const char *reqFamily, int encoding_id) family->fontFileIndex = -1; family->symbol_checked = true; QtFontFoundry *foundry = family->foundry(QLatin1String(foundryName), true); - QtFontStyle *style = foundry->style(styleKey, true); + QtFontStyle *style = foundry->style(styleKey, QString(), true); delete [] style->weightName; style->weightName = qstrdup(tokens[Weight]); @@ -1145,7 +1145,7 @@ static void loadFontConfig() family->fontFileIndex = index_value; QtFontStyle::Key styleKey; - styleKey.styleName = style_value ? QString::fromUtf8((const char *) style_value) : QString(); + QString styleName = style_value ? QString::fromUtf8((const char *) style_value) : QString(); styleKey.style = (slant_value == FC_SLANT_ITALIC) ? QFont::StyleItalic : ((slant_value == FC_SLANT_OBLIQUE) @@ -1160,7 +1160,7 @@ static void loadFontConfig() QtFontFoundry *foundry = family->foundry(foundry_value ? QString::fromUtf8((const char *)foundry_value) : QString(), true); - QtFontStyle *style = foundry->style(styleKey, true); + QtFontStyle *style = foundry->style(styleKey, styleName, true); if (spacing_value < FC_MONO) family->fixedPitch = false; @@ -1212,7 +1212,7 @@ static void loadFontConfig() for (int i = 0; i < 4; ++i) { styleKey.style = (i%2) ? QFont::StyleNormal : QFont::StyleItalic; styleKey.weight = (i > 1) ? QFont::Bold : QFont::Normal; - QtFontStyle *style = foundry->style(styleKey, true); + QtFontStyle *style = foundry->style(styleKey, QString(), true); style->smoothScalable = true; QtFontSize *size = style->pixelSize(SMOOTH_SCALABLE, true); QtFontEncoding *enc = size->encodingID(-1, 0, 0, 0, 0, true); @@ -1360,7 +1360,7 @@ static void initializeDb() if (equiv) continue; // let's fake one... - equiv = foundry->style(key, true); + equiv = foundry->style(key, QString(), true); equiv->smoothScalable = true; QtFontSize *equiv_size = equiv->pixelSize(SMOOTH_SCALABLE, true); -- cgit v0.12 From c1ec1a95806cda54d5b4e9f8ed159a611bd75964 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 5 Jul 2011 17:05:11 +0200 Subject: Implement text interface for QLineEdit. Add boundary helper functions to the QAccessibleTextInterface. Move LineEdit over to use QTextBoundaryFinder. Reviewed-by: Jan-Arve --- src/gui/accessible/qaccessible2.cpp | 112 +++++++++++++++++++++++ src/plugins/accessible/widgets/simplewidgets.cpp | 40 +++++--- tests/auto/qaccessibility/tst_qaccessibility.cpp | 55 ++++++++++- 3 files changed, 194 insertions(+), 13 deletions(-) diff --git a/src/gui/accessible/qaccessible2.cpp b/src/gui/accessible/qaccessible2.cpp index 35b24f6..b62a7a4 100644 --- a/src/gui/accessible/qaccessible2.cpp +++ b/src/gui/accessible/qaccessible2.cpp @@ -42,6 +42,7 @@ #include "qaccessible2.h" #include "qapplication.h" #include "qclipboard.h" +#include "qtextboundaryfinder.h" #ifndef QT_NO_ACCESSIBILITY @@ -132,6 +133,117 @@ QT_BEGIN_NAMESPACE \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink */ + +/*! + \internal +*/ +QString Q_GUI_EXPORT textBeforeOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, + int *startOffset, int *endOffset, const QString& text) +{ + QTextBoundaryFinder::BoundaryType type; + switch (boundaryType) { + case QAccessible2::CharBoundary: + type = QTextBoundaryFinder::Grapheme; + break; + case QAccessible2::WordBoundary: + type = QTextBoundaryFinder::Word; + break; + case QAccessible2::SentenceBoundary: + type = QTextBoundaryFinder::Sentence; + break; + default: + // in any other case return the whole line + *startOffset = 0; + *endOffset = text.length(); + return text; + } + + QTextBoundaryFinder boundary(type, text); + boundary.setPosition(offset); + + if (!boundary.isAtBoundary()) { + boundary.toPreviousBoundary(); + } + boundary.toPreviousBoundary(); + *startOffset = boundary.position(); + boundary.toNextBoundary(); + *endOffset = boundary.position(); + + return text.mid(*startOffset, *endOffset - *startOffset); +} + +/*! + \internal +*/ +QString Q_GUI_EXPORT textAfterOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, + int *startOffset, int *endOffset, const QString& text) +{ + QTextBoundaryFinder::BoundaryType type; + switch (boundaryType) { + case QAccessible2::CharBoundary: + type = QTextBoundaryFinder::Grapheme; + break; + case QAccessible2::WordBoundary: + type = QTextBoundaryFinder::Word; + break; + case QAccessible2::SentenceBoundary: + type = QTextBoundaryFinder::Sentence; + break; + default: + // in any other case return the whole line + *startOffset = 0; + *endOffset = text.length(); + return text; + } + + QTextBoundaryFinder boundary(type, text); + boundary.setPosition(offset); + + boundary.toNextBoundary(); + *startOffset = boundary.position(); + boundary.toNextBoundary(); + *endOffset = boundary.position(); + + return text.mid(*startOffset, *endOffset - *startOffset); +} + +/*! + \internal +*/ +QString Q_GUI_EXPORT textAtOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, + int *startOffset, int *endOffset, const QString& text) +{ + QTextBoundaryFinder::BoundaryType type; + switch (boundaryType) { + case QAccessible2::CharBoundary: + type = QTextBoundaryFinder::Grapheme; + break; + case QAccessible2::WordBoundary: + type = QTextBoundaryFinder::Word; + break; + case QAccessible2::SentenceBoundary: + type = QTextBoundaryFinder::Sentence; + break; + default: + // in any other case return the whole line + *startOffset = 0; + *endOffset = text.length(); + return text; + } + + QTextBoundaryFinder boundary(type, text); + boundary.setPosition(offset); + + if (!boundary.isAtBoundary()) { + boundary.toPreviousBoundary(); + } + *startOffset = boundary.position(); + boundary.toNextBoundary(); + *endOffset = boundary.position(); + + return text.mid(*startOffset, *endOffset - *startOffset); +} + QAccessibleSimpleEditableTextInterface::QAccessibleSimpleEditableTextInterface( QAccessibleInterface *accessibleInterface) : iface(accessibleInterface) diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp index ad56cbd..4f469e5 100644 --- a/src/plugins/accessible/widgets/simplewidgets.cpp +++ b/src/plugins/accessible/widgets/simplewidgets.cpp @@ -68,6 +68,13 @@ extern QList childWidgets(const QWidget *widget, bool includeTopLevel QString Q_GUI_EXPORT qt_accStripAmp(const QString &text); QString Q_GUI_EXPORT qt_accHotKey(const QString &text); +QString Q_GUI_EXPORT textBeforeOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, + int *startOffset, int *endOffset, const QString& text); +QString Q_GUI_EXPORT textAtOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, + int *startOffset, int *endOffset, const QString& text); +QString Q_GUI_EXPORT textAfterOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, + int *startOffset, int *endOffset, const QString& text); + /*! \class QAccessibleButton \brief The QAccessibleButton class implements the QAccessibleInterface for button type widgets. @@ -815,25 +822,34 @@ QString QAccessibleLineEdit::text(int startOffset, int endOffset) return lineEdit()->text().mid(startOffset, endOffset - startOffset); } -QString QAccessibleLineEdit::textBeforeOffset (int /*offset*/, BoundaryType /*boundaryType*/, - int * /*startOffset*/, int * /*endOffset*/) +QString QAccessibleLineEdit::textBeforeOffset(int offset, BoundaryType boundaryType, + int *startOffset, int *endOffset) { - // TODO - return QString(); + if (lineEdit()->echoMode() != QLineEdit::Normal) { + *startOffset = *endOffset = -1; + return QString(); + } + return textBeforeOffsetFromString(offset, boundaryType, startOffset, endOffset, lineEdit()->text()); } -QString QAccessibleLineEdit::textAfterOffset(int /*offset*/, BoundaryType /*boundaryType*/, - int * /*startOffset*/, int * /*endOffset*/) +QString QAccessibleLineEdit::textAfterOffset(int offset, BoundaryType boundaryType, + int *startOffset, int *endOffset) { - // TODO - return QString(); + if (lineEdit()->echoMode() != QLineEdit::Normal) { + *startOffset = *endOffset = -1; + return QString(); + } + return textAfterOffsetFromString(offset, boundaryType, startOffset, endOffset, lineEdit()->text()); } -QString QAccessibleLineEdit::textAtOffset(int /*offset*/, BoundaryType /*boundaryType*/, - int * /*startOffset*/, int * /*endOffset*/) +QString QAccessibleLineEdit::textAtOffset(int offset, BoundaryType boundaryType, + int *startOffset, int *endOffset) { - // TODO - return QString(); + if (lineEdit()->echoMode() != QLineEdit::Normal) { + *startOffset = *endOffset = -1; + return QString(); + } + return textAtOffsetFromString(offset, boundaryType, startOffset, endOffset, lineEdit()->text()); } void QAccessibleLineEdit::removeSelection(int selectionIndex) diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index aedb87e..d764187 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -3058,8 +3058,61 @@ void tst_QAccessibility::lineEditTest() delete iface; delete le; delete le2; - delete toplevel; QTestAccessibility::clearEvents(); + + // IA2 + QString cite = "I always pass on good advice. It is the only thing to do with it. It is never of any use to oneself. --Oscar Wilde"; + QLineEdit *le3 = new QLineEdit(cite, toplevel); + iface = QAccessible::queryAccessibleInterface(le3); + QAccessibleTextInterface* textIface = iface->textInterface(); + le3->deselect(); + le3->setCursorPosition(3); + QCOMPARE(textIface->cursorPosition(), 3); + QCOMPARE(textIface->selectionCount(), 0); + int start, end; + + QCOMPARE(textIface->text(0, 8), QString::fromLatin1("I always")); + QCOMPARE(textIface->textAtOffset(0, QAccessible2::CharBoundary,&start,&end), QString::fromLatin1("I")); + QCOMPARE(start, 0); + QCOMPARE(end, 1); + QCOMPARE(textIface->textBeforeOffset(0, QAccessible2::CharBoundary,&start,&end), QString()); + QCOMPARE(textIface->textAfterOffset(0, QAccessible2::CharBoundary,&start,&end), QString::fromLatin1(" ")); + QCOMPARE(start, 1); + QCOMPARE(end, 2); + + QCOMPARE(textIface->textAtOffset(5, QAccessible2::CharBoundary,&start,&end), QString::fromLatin1("a")); + QCOMPARE(start, 5); + QCOMPARE(end, 6); + QCOMPARE(textIface->textBeforeOffset(5, QAccessible2::CharBoundary,&start,&end), QString::fromLatin1("w")); + QCOMPARE(textIface->textAfterOffset(5, QAccessible2::CharBoundary,&start,&end), QString::fromLatin1("y")); + + QCOMPARE(textIface->textAtOffset(5, QAccessible2::WordBoundary,&start,&end), QString::fromLatin1("always")); + QCOMPARE(start, 2); + QCOMPARE(end, 8); + + QCOMPARE(textIface->textAtOffset(2, QAccessible2::WordBoundary,&start,&end), QString::fromLatin1("always")); + QCOMPARE(textIface->textAtOffset(7, QAccessible2::WordBoundary,&start,&end), QString::fromLatin1("always")); + QCOMPARE(textIface->textAtOffset(8, QAccessible2::WordBoundary,&start,&end), QString::fromLatin1(" ")); + QCOMPARE(textIface->textAtOffset(25, QAccessible2::WordBoundary,&start,&end), QString::fromLatin1("advice")); + QCOMPARE(textIface->textAtOffset(92, QAccessible2::WordBoundary,&start,&end), QString::fromLatin1("oneself")); + + QCOMPARE(textIface->textBeforeOffset(5, QAccessible2::WordBoundary,&start,&end), QString::fromLatin1(" ")); + QCOMPARE(textIface->textAfterOffset(5, QAccessible2::WordBoundary,&start,&end), QString::fromLatin1(" ")); + QCOMPARE(textIface->textAtOffset(5, QAccessible2::SentenceBoundary,&start,&end), QString::fromLatin1("I always pass on good advice. ")); + QCOMPARE(start, 0); + QCOMPARE(end, 30); + + QCOMPARE(textIface->textBeforeOffset(40, QAccessible2::SentenceBoundary,&start,&end), QString::fromLatin1("I always pass on good advice. ")); + QCOMPARE(textIface->textAfterOffset(5, QAccessible2::SentenceBoundary,&start,&end), QString::fromLatin1("It is the only thing to do with it. ")); + + QCOMPARE(textIface->textAtOffset(5, QAccessible2::ParagraphBoundary,&start,&end), cite); + QCOMPARE(start, 0); + QCOMPARE(end, cite.length()); + QCOMPARE(textIface->textAtOffset(5, QAccessible2::LineBoundary,&start,&end), cite); + QCOMPARE(textIface->textAtOffset(5, QAccessible2::NoBoundary,&start,&end), cite); + + delete iface; + delete toplevel; } void tst_QAccessibility::workspaceTest() -- cgit v0.12 From b3e0d76d558d35e40f1c4f1b5b1b14ba79f8eef6 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Wed, 6 Jul 2011 14:32:10 +0300 Subject: On symbian QMessageBox does not look like native dialog If API QMessageBox::setInformativeText() is used to set informative text to the messagebox, the text is added to the "icon column", which makes the messagebox look really weird. Use layoutDirection() and add informative text to the same column where other text elements are added. Task-number: QTBUG-9924 Reviewed-by: Tomi Vihria --- src/gui/dialogs/qmessagebox.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp index 6a1c04a..f18fe60 100644 --- a/src/gui/dialogs/qmessagebox.cpp +++ b/src/gui/dialogs/qmessagebox.cpp @@ -2507,7 +2507,12 @@ void QMessageBox::setInformativeText(const QString &text) label->hide(); QTextBrowser *textBrowser = new QTextBrowser(this); textBrowser->setOpenExternalLinks(true); - grid->addWidget(textBrowser, 1, 1, 1, 1); +#if defined(Q_OS_SYMBIAN) + const int preferredTextColumn = (QApplication::layoutDirection() == Qt::LeftToRight) ? 0 : 1; +#else + const int preferredTextColumn = 1; +#endif + grid->addWidget(textBrowser, 1, preferredTextColumn, 1, 1); d->textBrowser = textBrowser; #else grid->addWidget(label, 1, 1, 1, 1); -- cgit v0.12 From f9b521fc492b82ea510b448ffd785273db0b8e74 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Wed, 6 Jul 2011 13:35:49 +0200 Subject: Fix Windows compile --- src/gui/text/qfontdatabase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index dc8fd45..3762f39 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -1953,7 +1953,7 @@ QList QFontDatabase::pointSizes(const QString &family, #if defined(Q_WS_WIN) // windows and macosx are always smoothly scalable Q_UNUSED(family); - Q_UNUSED(style); + Q_UNUSED(styleName); return standardSizes(); #else bool smoothScalable = false; -- cgit v0.12 From d2303b008e86f36a34eed2b6f0ea79ce41b5e1b3 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 6 Jul 2011 13:42:49 +0200 Subject: Fix compilation with c++0x mode Reviewed-by: Olivier --- src/corelib/tools/qstringlist.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h index 2159512..f4689b4 100644 --- a/src/corelib/tools/qstringlist.h +++ b/src/corelib/tools/qstringlist.h @@ -71,7 +71,7 @@ public: inline QStringList(const QStringList &l) : QList(l) { } inline QStringList(const QList &l) : QList(l) { } #ifdef Q_COMPILER_INITIALIZER_LISTS - inline QStringList(std::initializer_list args) : QList(args) { } + inline QStringList(std::initializer_list args) : QList(args) { } #endif inline void sort(); -- cgit v0.12 From 8032d6f4ced50837e126f28c1475ad89eaf91ad7 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Wed, 6 Jul 2011 14:31:33 +0200 Subject: Remove some metrics parsing code from Core Text The respective value in some of the default fonts like Lucida Grande are simply not reliable. It seems that the only reliable way to get such information is by going through all the glyphs. It seems that these code are not well tested on Mac and should be removed for now since it caused visible regressions in QLineEdit rendering. Reviewed-by: Eskil --- src/gui/text/qfontengine_coretext.mm | 20 +++----------------- src/gui/text/qfontengine_coretext_p.h | 3 --- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm index 64b8682..07711a3 100644 --- a/src/gui/text/qfontengine_coretext.mm +++ b/src/gui/text/qfontengine_coretext.mm @@ -492,17 +492,6 @@ void QCoreTextFontEngine::init() avgCharWidth = QFixed::fromReal(width * fontDef.pixelSize / emSize); } else avgCharWidth = QFontEngine::averageCharWidth(); - - ctMaxCharWidth = ctMinLeftBearing = ctMinRightBearing = 0; - QByteArray hheaTable = getSfntTable(MAKE_TAG('h', 'h', 'e', 'a')); - if (hheaTable.size() >= 16) { - quint16 width = qFromBigEndian(reinterpret_cast(hheaTable.constData() + 10)); - ctMaxCharWidth = width * fontDef.pixelSize / emSize; - qint16 bearing = qFromBigEndian(reinterpret_cast(hheaTable.constData() + 12)); - ctMinLeftBearing = bearing * fontDef.pixelSize / emSize; - bearing = qFromBigEndian(reinterpret_cast(hheaTable.constData() + 14)); - ctMinRightBearing = bearing * fontDef.pixelSize / emSize; - } } bool QCoreTextFontEngine::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, @@ -599,20 +588,17 @@ QFixed QCoreTextFontEngine::averageCharWidth() const qreal QCoreTextFontEngine::maxCharWidth() const { - return (fontDef.styleStrategy & QFont::ForceIntegerMetrics) - ? qRound(ctMaxCharWidth) : ctMaxCharWidth; + return 0; } qreal QCoreTextFontEngine::minLeftBearing() const { - return (fontDef.styleStrategy & QFont::ForceIntegerMetrics) - ? qRound(ctMinLeftBearing) : ctMinLeftBearing; + return 0; } qreal QCoreTextFontEngine::minRightBearing() const { - return (fontDef.styleStrategy & QFont::ForceIntegerMetrics) - ? qRound(ctMinRightBearing) : ctMinLeftBearing; + return 0; } void QCoreTextFontEngine::draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight) diff --git a/src/gui/text/qfontengine_coretext_p.h b/src/gui/text/qfontengine_coretext_p.h index 3ca8a0a..efe8295 100644 --- a/src/gui/text/qfontengine_coretext_p.h +++ b/src/gui/text/qfontengine_coretext_p.h @@ -103,9 +103,6 @@ private: int synthesisFlags; CGAffineTransform transform; QFixed avgCharWidth; - qreal ctMaxCharWidth; - qreal ctMinLeftBearing; - qreal ctMinRightBearing; friend class QCoreTextFontEngineMulti; }; -- cgit v0.12 From 6415e22649dd8620728c8c32b918c7afb8efc4dc Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Wed, 6 Jul 2011 15:24:06 +0200 Subject: Fix S60 compile --- src/gui/text/qfontdatabase_s60.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index 980b5de..2f4d055 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -508,7 +508,7 @@ static bool registerScreenDeviceFont(int screenDeviceFontIndex, QtFontFamily *family = privateDb()->family(familyName, true); family->fixedPitch = faceAttrib.IsMonoWidth(); QtFontFoundry *foundry = family->foundry(QString(), true); - QtFontStyle *style = foundry->style(styleKey, true); + QtFontStyle *style = foundry->style(styleKey, QString(), true); style->smoothScalable = typefaceSupport.iIsScalable; style->pixelSize(0, true); -- cgit v0.12 From de85cf25be61c746b1a47a58873b5758d8e8ad5d Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 6 Jul 2011 16:37:14 +0200 Subject: Use Q_DECL_CONSTEXPR in QFlags Change-Id: I851e0b1c3f80a7b33a38cb1ab2665dc0f3c73adc Reviewed-on: http://codereview.qt.nokia.com/1248 Reviewed-by: Qt Sanity Bot Reviewed-by: Gabriel de Dietrich (cherry picked from commit c0c6dd2b022cfd667f32b8a48bcac86ac07d3880) --- src/corelib/global/qglobal.h | 30 +++++++++++++++--------------- tests/auto/qflags/tst_qflags.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 1f5f537..892ae73 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -2267,9 +2267,9 @@ class QFlags int i; public: typedef Enum enum_type; - inline QFlags(const QFlags &f) : i(f.i) {} - inline QFlags(Enum f) : i(f) {} - inline QFlags(Zero = 0) : i(0) {} + Q_DECL_CONSTEXPR inline QFlags(const QFlags &f) : i(f.i) {} + Q_DECL_CONSTEXPR inline QFlags(Enum f) : i(f) {} + Q_DECL_CONSTEXPR inline QFlags(Zero = 0) : i(0) {} inline QFlags(QFlag f) : i(f) {} inline QFlags &operator=(const QFlags &f) { i = f.i; return *this; } @@ -2280,18 +2280,18 @@ public: inline QFlags &operator^=(QFlags f) { i ^= f.i; return *this; } inline QFlags &operator^=(Enum f) { i ^= f; return *this; } - inline operator int() const { return i; } + Q_DECL_CONSTEXPR inline operator int() const { return i; } - inline QFlags operator|(QFlags f) const { QFlags g; g.i = i | f.i; return g; } - inline QFlags operator|(Enum f) const { QFlags g; g.i = i | f; return g; } - inline QFlags operator^(QFlags f) const { QFlags g; g.i = i ^ f.i; return g; } - inline QFlags operator^(Enum f) const { QFlags g; g.i = i ^ f; return g; } - inline QFlags operator&(int mask) const { QFlags g; g.i = i & mask; return g; } - inline QFlags operator&(uint mask) const { QFlags g; g.i = i & mask; return g; } - inline QFlags operator&(Enum f) const { QFlags g; g.i = i & f; return g; } - inline QFlags operator~() const { QFlags g; g.i = ~i; return g; } + Q_DECL_CONSTEXPR inline QFlags operator|(QFlags f) const { return QFlags(Enum(i | f.i)); } + Q_DECL_CONSTEXPR inline QFlags operator|(Enum f) const { return QFlags(Enum(i | f)); } + Q_DECL_CONSTEXPR inline QFlags operator^(QFlags f) const { return QFlags(Enum(i ^ f.i)); } + Q_DECL_CONSTEXPR inline QFlags operator^(Enum f) const { return QFlags(Enum(i ^ f)); } + Q_DECL_CONSTEXPR inline QFlags operator&(int mask) const { return QFlags(Enum(i & mask)); } + Q_DECL_CONSTEXPR inline QFlags operator&(uint mask) const { return QFlags(Enum(i & mask)); } + Q_DECL_CONSTEXPR inline QFlags operator&(Enum f) const { return QFlags(Enum(i & f)); } + Q_DECL_CONSTEXPR inline QFlags operator~() const { return QFlags(Enum(~i)); } - inline bool operator!() const { return !i; } + Q_DECL_CONSTEXPR inline bool operator!() const { return !i; } inline bool testFlag(Enum f) const { return (i & f) == f && (f != 0 || i == int(f) ); } }; @@ -2304,9 +2304,9 @@ inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) \ { return QIncompatibleFlag(int(f1) | f2); } #define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \ -inline QFlags operator|(Flags::enum_type f1, Flags::enum_type f2) \ +Q_DECL_CONSTEXPR inline QFlags operator|(Flags::enum_type f1, Flags::enum_type f2) \ { return QFlags(f1) | f2; } \ -inline QFlags operator|(Flags::enum_type f1, QFlags f2) \ +Q_DECL_CONSTEXPR inline QFlags operator|(Flags::enum_type f1, QFlags f2) \ { return f2 | f1; } Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) diff --git a/tests/auto/qflags/tst_qflags.cpp b/tests/auto/qflags/tst_qflags.cpp index 87025b6..85e64a6 100644 --- a/tests/auto/qflags/tst_qflags.cpp +++ b/tests/auto/qflags/tst_qflags.cpp @@ -47,6 +47,7 @@ private slots: void testFlag() const; void testFlagZeroFlag() const; void testFlagMultiBits() const; + void constExpr(); }; void tst_QFlags::testFlag() const @@ -96,5 +97,32 @@ void tst_QFlags::testFlagMultiBits() const } } +template bool verifyConstExpr(T n) { return n == N; } + +void tst_QFlags::constExpr() +{ +#ifdef Q_COMPILER_CONSTEXPR + Qt::MouseButtons btn = Qt::LeftButton | Qt::RightButton; + switch (btn) { + case Qt::LeftButton: QVERIFY(false); break; + case Qt::RightButton: QVERIFY(false); break; + case Qt::LeftButton | Qt::RightButton: QVERIFY(true); break; + default: QVERIFY(false); + } + + QVERIFY(verifyConstExpr<(Qt::LeftButton | Qt::RightButton) & Qt::LeftButton>(Qt::LeftButton)); + QVERIFY(verifyConstExpr<(Qt::LeftButton | Qt::RightButton) & Qt::MiddleButton>(0)); + QVERIFY(verifyConstExpr<(Qt::LeftButton | Qt::RightButton) | Qt::MiddleButton>(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton)); + QVERIFY(verifyConstExpr<~(Qt::LeftButton | Qt::RightButton)>(~(Qt::LeftButton | Qt::RightButton))); + QVERIFY(verifyConstExpr(Qt::LeftButton ^ Qt::RightButton)); + QVERIFY(verifyConstExpr(0)); + QVERIFY(verifyConstExpr(Qt::RightButton)); + QVERIFY(verifyConstExpr(0xff)); + + QVERIFY(!verifyConstExpr(!Qt::MouseButtons(Qt::LeftButton))); +#endif +} + + QTEST_MAIN(tst_QFlags) #include "tst_qflags.moc" -- cgit v0.12 From f650c43d130d28fa7eca2f6accf8aacd76ae508d Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 6 Jul 2011 16:35:04 +0200 Subject: Add Q_DECL_CONSTEXPR Defined to the c++0x constexpr when compiler supports it Change-Id: I82687fe46848eedf3cffc39982106749b3dde8aa Reviewed-on: http://codereview.qt.nokia.com/1247 Reviewed-by: Qt Sanity Bot Reviewed-by: Gabriel de Dietrich (cherry picked from commit 28f927f8e092a02e233559f6da7fa96cf722c77d) --- src/corelib/global/qglobal.h | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 892ae73..9c7f1c6 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -536,6 +536,11 @@ namespace QT_NAMESPACE {} # define Q_COMPILER_LAMBDA # define Q_COMPILER_UNICODE_STRINGS # endif +# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 + /* C++0x features supported in GCC 4.6: */ +# define Q_COMPILER_CONSTEXPR +# endif + # endif /* IBM compiler versions are a bit messy. There are actually two products: @@ -1135,6 +1140,12 @@ redefine to built-in booleans to make autotests work properly */ # define QT_FASTCALL #endif +#ifdef Q_COMPILER_CONSTEXPR +# define Q_DECL_CONSTEXPR constexpr +#else +# define Q_DECL_CONSTEXPR +#endif + //defines the type for the WNDPROC on windows //the alignment needs to be forced for sse2 to not crash with mingw #if defined(Q_WS_WIN) @@ -1166,25 +1177,25 @@ typedef double qreal; */ template -inline T qAbs(const T &t) { return t >= 0 ? t : -t; } +Q_DECL_CONSTEXPR inline T qAbs(const T &t) { return t >= 0 ? t : -t; } -inline int qRound(qreal d) +Q_DECL_CONSTEXPR inline int qRound(qreal d) { return d >= qreal(0.0) ? int(d + qreal(0.5)) : int(d - int(d-1) + qreal(0.5)) + int(d-1); } #if defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) || defined(QT_ARCH_SYMBIAN) -inline qint64 qRound64(double d) +Q_DECL_CONSTEXPR inline qint64 qRound64(double d) { return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qreal(qint64(d-1)) + 0.5) + qint64(d-1); } #else -inline qint64 qRound64(qreal d) +Q_DECL_CONSTEXPR inline qint64 qRound64(qreal d) { return d >= qreal(0.0) ? qint64(d + qreal(0.5)) : qint64(d - qreal(qint64(d-1)) + qreal(0.5)) + qint64(d-1); } #endif template -inline const T &qMin(const T &a, const T &b) { if (a < b) return a; return b; } +Q_DECL_CONSTEXPR inline const T &qMin(const T &a, const T &b) { return (a < b) ? a : b; } template -inline const T &qMax(const T &a, const T &b) { if (a < b) return b; return a; } +Q_DECL_CONSTEXPR inline const T &qMax(const T &a, const T &b) { return (a < b) ? b : a; } template -inline const T &qBound(const T &min, const T &val, const T &max) +Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max) { return qMax(min, qMin(max, val)); } #ifdef QT3_SUPPORT @@ -1978,12 +1989,12 @@ inline bool operator!=(QBool b1, bool b2) { return !b1 != !b2; } inline bool operator!=(bool b1, QBool b2) { return !b1 != !b2; } inline bool operator!=(QBool b1, QBool b2) { return !b1 != !b2; } -static inline bool qFuzzyCompare(double p1, double p2) +Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2) { return (qAbs(p1 - p2) <= 0.000000000001 * qMin(qAbs(p1), qAbs(p2))); } -static inline bool qFuzzyCompare(float p1, float p2) +Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2) { return (qAbs(p1 - p2) <= 0.00001f * qMin(qAbs(p1), qAbs(p2))); } @@ -1991,7 +2002,7 @@ static inline bool qFuzzyCompare(float p1, float p2) /*! \internal */ -static inline bool qFuzzyIsNull(double d) +Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d) { return qAbs(d) <= 0.000000000001; } @@ -1999,7 +2010,7 @@ static inline bool qFuzzyIsNull(double d) /*! \internal */ -static inline bool qFuzzyIsNull(float f) +Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f) { return qAbs(f) <= 0.00001f; } -- cgit v0.12 From ba65e2741c47912a800132b90f7dbaf2551b04c4 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Wed, 6 Jul 2011 17:08:41 +0200 Subject: Fix raster subpixel positioning in Lion In Lion, the x position returned by CTFontGetBoundingRectsForGlyphs can be fractional, we need to round().truncate() it as we did in QTextureGlyphCache to save the baseLineX. Reviewed-by: Eskil --- src/gui/text/qfontengine_coretext.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm index 07711a3..afeb0a0 100644 --- a/src/gui/text/qfontengine_coretext.mm +++ b/src/gui/text/qfontengine_coretext.mm @@ -750,7 +750,7 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition CGContextSetFont(ctx, cgFont); - qreal pos_x = -br.x.toReal() + subPixelPosition.toReal() + margin; + qreal pos_x = -br.x.round().truncate() + subPixelPosition.toReal() + margin; qreal pos_y = im.height() + br.y.toReal() - margin; CGContextSetTextPosition(ctx, pos_x, pos_y); -- cgit v0.12 From 52c2bf0e0dc5bcad1b75f9b8d817b39ca7754476 Mon Sep 17 00:00:00 2001 From: Casper van Donderen Date: Thu, 7 Jul 2011 11:01:28 +0200 Subject: Update the Window title when closing the last tab. Fixes: QTBUG-20243 Reviewed-By: Kevin Wright --- demos/browser/tabwidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/browser/tabwidget.cpp b/demos/browser/tabwidget.cpp index 9ce9fb8..d8b9db1 100644 --- a/demos/browser/tabwidget.cpp +++ b/demos/browser/tabwidget.cpp @@ -438,6 +438,7 @@ WebView *TabWidget::newTab(bool makeCurrent) addTab(emptyWidget, tr("(Untitled)")); connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); + currentChanged(currentIndex()); return 0; } -- cgit v0.12 From 99aef9769379a74accce481f6290a30bf8024216 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Thu, 7 Jul 2011 13:08:05 +0300 Subject: Regression: Some QMenus are shown completely transparent in Symbian Fix for menu transparency (QTBUG-16857) unveiled an issue in the QS60Style when drawing QMenu background. Style skips drawing of the menu background, since placeHolder texture for QPalette::Window is not replaced with real background for menus. Therefore, we need to check if the widget's palette is still untouched when deciding whether or not to draw the menu background. Task-number: QTBUG-20255 Reviewed-by: Tomi Vihria --- src/gui/styles/qs60style.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 13157ff..bb2d701 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -506,8 +506,10 @@ bool QS60StylePrivate::equalToThemePalette(qint64 cacheKey, QPalette::ColorRole { if (!m_themePalette) return false; - if (cacheKey == m_themePalette->brush(role).texture().cacheKey()) + if ((m_placeHolderTexture && (cacheKey == m_placeHolderTexture->cacheKey())) + || (cacheKey == m_themePalette->brush(role).texture().cacheKey())) return true; + return false; } -- cgit v0.12 From 997c2dfed7a04da2fac577f1c29b89bda4939e2d Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Thu, 7 Jul 2011 12:37:47 +0200 Subject: Fix license header. Reviewed-by: TrustMe --- src/dbus/qdbusvirtualobject.cpp | 34 +++++++++++++++++----------------- src/dbus/qdbusvirtualobject.h | 34 +++++++++++++++++----------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/dbus/qdbusvirtualobject.cpp b/src/dbus/qdbusvirtualobject.cpp index f1c17b5..992ccbf 100644 --- a/src/dbus/qdbusvirtualobject.cpp +++ b/src/dbus/qdbusvirtualobject.cpp @@ -7,29 +7,29 @@ ** This file is part of the QtDBus module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** ** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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 +** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** +** 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. ** ** ** diff --git a/src/dbus/qdbusvirtualobject.h b/src/dbus/qdbusvirtualobject.h index e51dca5..be323de 100644 --- a/src/dbus/qdbusvirtualobject.h +++ b/src/dbus/qdbusvirtualobject.h @@ -7,29 +7,29 @@ ** This file is part of the QtDBus module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** ** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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 +** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** +** 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. ** ** ** -- cgit v0.12 From 999047177846695a809aa1a730330ce676d85959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Fri, 3 Jun 2011 17:55:09 +0200 Subject: Fix QProcess emitting two started signals on X11 On X11 QProcess would emit two started signals when calling QProcess::waitForStarted(). We should expect that the private implementation of waitForStarted() should emit the started signal and return true or false appropriately. Task-number: QTBUG-7039 Change-Id: I3d381399ab7a39bf57db03a110fa6747a4fc6a24 Reviewed-on: http://codereview.qt.nokia.com/331 Reviewed-by: Thiago Macieira (cherry picked from commit 883b120d2f39c532cdd1a98d962af83be5adc4bd) --- src/corelib/io/qprocess.cpp | 11 ++++------- tests/auto/qprocess/tst_qprocess.cpp | 28 ++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 4b689c5..e900663 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1683,13 +1683,10 @@ QProcessEnvironment QProcess::processEnvironment() const bool QProcess::waitForStarted(int msecs) { Q_D(QProcess); - if (d->processState == QProcess::Starting) { - if (!d->waitForStarted(msecs)) - return false; - setProcessState(QProcess::Running); - emit started(); - } - return d->processState == QProcess::Running; + if (d->processState == QProcess::Running) + return true; + + return d->waitForStarted(msecs); } /*! \reimp diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp index 91e0abe..f54dfa3 100644 --- a/tests/auto/qprocess/tst_qprocess.cpp +++ b/tests/auto/qprocess/tst_qprocess.cpp @@ -73,7 +73,7 @@ Q_DECLARE_METATYPE(QProcess::ProcessState); { \ const bool ret = Process.Fn; \ if (ret == false) \ - qWarning("QProcess error: %d: %s", Process.error(), qPrintable(Process.errorString())); \ + qWarning("QProcess error: %d: %s", Process.error(), qPrintable(Process.errorString())); \ QVERIFY(ret); \ } @@ -157,6 +157,7 @@ private slots: void startFinishStartFinish(); void invalidProgramString_data(); void invalidProgramString(); + void onlyOneStartedSignal(); // keep these at the end, since they use lots of processes and sometimes // caused obscure failures to occur in tests that followed them (esp. on the Mac) @@ -2089,7 +2090,7 @@ void tst_QProcess::setStandardInputFile() #endif QPROCESS_VERIFY(process, waitForFinished()); - QByteArray all = process.readAll(); + QByteArray all = process.readAll(); QCOMPARE(all.size(), int(sizeof data) - 1); // testProcessEcho drops the ending \0 QVERIFY(all == data); } @@ -2442,6 +2443,29 @@ void tst_QProcess::invalidProgramString() QVERIFY(!QProcess::startDetached(programString)); } +//----------------------------------------------------------------------------- +void tst_QProcess::onlyOneStartedSignal() +{ + QProcess process; + + QSignalSpy spyStarted(&process, SIGNAL(started())); + QSignalSpy spyFinished(&process, SIGNAL(finished(int, QProcess::ExitStatus))); + + process.start("testProcessNormal/testProcessNormal"); + QVERIFY(process.waitForStarted(5000)); + QVERIFY(process.waitForFinished(5000)); + QCOMPARE(spyStarted.count(), 1); + QCOMPARE(spyFinished.count(), 1); + + spyStarted.clear(); + spyFinished.clear(); + + process.start("testProcessNormal/testProcessNormal"); + QVERIFY(process.waitForFinished(5000)); + QCOMPARE(spyStarted.count(), 1); + QCOMPARE(spyFinished.count(), 1); +} + QTEST_MAIN(tst_QProcess) #include "tst_qprocess.moc" #endif -- cgit v0.12 From bd476c6e4b238290a92cfd4693c709e9010b282b Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Thu, 7 Jul 2011 13:08:10 +0200 Subject: Revert 344a4dcfe and part of 93bce787 Due to subpixel grid change, these changes are no longer needed. Reviewed-by: Eskil --- src/gui/painting/qtextureglyphcache.cpp | 4 +--- src/gui/text/qfontengine_coretext.mm | 7 ++++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index fdba9c9..abd0ed1 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -367,9 +367,7 @@ void QImageTextureGlyphCache::createTextureData(int width, int height) int QImageTextureGlyphCache::glyphMargin() const { -#if (defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)) - return 1; -#elif defined(Q_WS_X11) +#if (defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)) || defined(Q_WS_X11) return 0; #else return m_type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0; diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm index afeb0a0..6a9201d 100644 --- a/src/gui/text/qfontengine_coretext.mm +++ b/src/gui/text/qfontengine_coretext.mm @@ -718,8 +718,9 @@ void QCoreTextFontEngine::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *position QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition, int margin, bool aa) { + Q_UNUSED(margin); const glyph_metrics_t br = boundingBox(glyph); - QImage im(qRound(br.width) + margin * 2, qRound(br.height) + margin * 2, QImage::Format_RGB32); + QImage im(qRound(br.width) + 2, qRound(br.height) + 2, QImage::Format_RGB32); im.fill(0); CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); @@ -750,8 +751,8 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition CGContextSetFont(ctx, cgFont); - qreal pos_x = -br.x.round().truncate() + subPixelPosition.toReal() + margin; - qreal pos_y = im.height() + br.y.toReal() - margin; + qreal pos_x = -br.x.round().truncate() + subPixelPosition.toReal(); + qreal pos_y = im.height() + br.y.toReal(); CGContextSetTextPosition(ctx, pos_x, pos_y); CGSize advance; -- cgit v0.12 From 459dc4a3bf0dc0ac54fc558379fdf551949dd1c6 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Thu, 7 Jul 2011 14:53:09 +0200 Subject: Fix editable combobox style on Mac Reviewed-by: Jens Bache-Wiig --- src/gui/styles/qmacstyle_mac.mm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 40c28f6..74e3440 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -1195,15 +1195,15 @@ QRect QMacStylePrivate::comboboxEditBounds(const QRect &outerBounds, const HIThe QRect ret = outerBounds; switch (bdi.kind){ case kThemeComboBox: - ret.adjust(5, 8, -21, -4); + ret.adjust(5, 8, -22, -4); break; case kThemeComboBoxSmall: - ret.adjust(4, 5, -18, 0); - ret.setHeight(16); + ret.adjust(4, 6, -20, 0); + ret.setHeight(14); break; case kThemeComboBoxMini: - ret.adjust(4, 5, -16, 0); - ret.setHeight(13); + ret.adjust(4, 5, -18, -1); + ret.setHeight(12); break; case kThemePopupButton: ret.adjust(10, 3, -23, -3); -- cgit v0.12 From 73df7890923f377f19147466d9317fe1ec064b1d Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 7 Jul 2011 14:17:58 +0100 Subject: Fix memory leak in QHostInfo QHostInfo was leaking in the code path where it removes duplicate name lookups after one has completed. Task-number: QT-5121 Reviewed-by: Markus Goetz --- src/network/kernel/qhostinfo.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 328145c..94fd692 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -481,6 +481,7 @@ void QHostInfoRunnable::run() iterator.remove(); hostInfo.setLookupId(postponed->id); postponed->resultEmitter.emitResultsReady(hostInfo); + delete postponed; } } } -- cgit v0.12 From 55cfbdb7c64068ae68f7baaceb8acfb96cb0c07e 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 (cherry picked from commit a2d97672bfaace677a4308db93f5802ba53af46e) --- .../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 4a465cc..b8577e9 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 0d670396f7e4b24f0800ad0e7f219727a47bfba6 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 (cherry picked from commit 6fb7cdf8741ca924413dd7cbc09fad91ddc04823) --- .../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 ca877686aa220d20905dce171efc4c8b035c0af5 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 (cherry picked from commit 20f8357c8ee570f57091e20b9c0a9a1455dc1e8d) --- 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 247c0d8c3030267720766a48ed9ee681edc62085 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 (cherry picked from commit 343069c7843321b33f06bfd42d476abae76dcece) --- .../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 d8af562509f8624837f6fa4a617bc6e976b0731d 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 (cherry picked from commit 927b22b06ee2e749395e73f457fe3c16ea087864) --- .../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 b05a2394e13a12fcb2f7e3b766e0b37bb1163eb7 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 (cherry picked from commit 8fbb802fa50d0a01c9c01d007a3e016c45fa863c) --- .../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 cf23188de237009136fa1480ab8fd9e3ca364769 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 (cherry picked from commit e7bebcf0c59368340df524db4a53ae2595d057d7) --- .../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 b8577e9..0a98c01 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(); } @@ -1384,7 +1378,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) { @@ -1412,7 +1406,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) { @@ -1668,7 +1662,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; } /*! @@ -1682,13 +1676,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; } /*! @@ -1724,7 +1718,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; } /*! @@ -1739,30 +1733,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(); } } @@ -1779,20 +1773,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(); } } @@ -1802,20 +1796,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 afc3eac..59e4cbb 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 //---------------------------------------------------------------------------- @@ -344,9 +348,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()) { @@ -872,7 +879,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(); @@ -1059,6 +1066,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; @@ -1080,25 +1099,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); @@ -1155,9 +1162,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()); } @@ -1167,8 +1179,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()); } @@ -1178,7 +1196,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. @@ -1198,9 +1215,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 @@ -1221,14 +1249,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(); @@ -1552,6 +1580,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 { @@ -2096,7 +2126,8 @@ bool QDeclarativeGridView::event(QEvent *event) { Q_D(QDeclarativeGridView); if (event->type() == QEvent::User) { - d->layout(); + if (d->layoutScheduled) + d->layout(); return true; } @@ -2110,7 +2141,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; @@ -2126,7 +2157,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) { @@ -2871,7 +2902,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()) { @@ -2905,6 +2935,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 8695bc6..57b7dea 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 { @@ -1007,7 +997,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() @@ -1318,29 +1308,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; @@ -1356,9 +1337,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; @@ -1375,6 +1356,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); } @@ -1396,12 +1398,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()); } @@ -1410,9 +1419,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()); } @@ -1422,7 +1437,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. @@ -1436,7 +1450,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; @@ -1448,8 +1462,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) { @@ -1487,14 +1503,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(); @@ -1870,6 +1886,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) { @@ -2555,7 +2573,8 @@ bool QDeclarativeListView::event(QEvent *event) { Q_D(QDeclarativeListView); if (event->type() == QEvent::User) { - d->layout(); + if (d->layoutScheduled) + d->layout(); return true; } @@ -2574,7 +2593,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) { @@ -2608,7 +2627,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 From 4fcb7c233c3c8d748d66bf698df059ad7546ae88 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Fri, 8 Jul 2011 01:22:39 -0700 Subject: Rename textBeforeOffsetFromString to start with q. Exported functions should start with q. Reviewed-by: TrustMe --- src/gui/accessible/qaccessible2.cpp | 6 +++--- src/plugins/accessible/widgets/simplewidgets.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gui/accessible/qaccessible2.cpp b/src/gui/accessible/qaccessible2.cpp index b62a7a4..078ff13 100644 --- a/src/gui/accessible/qaccessible2.cpp +++ b/src/gui/accessible/qaccessible2.cpp @@ -137,7 +137,7 @@ QT_BEGIN_NAMESPACE /*! \internal */ -QString Q_GUI_EXPORT textBeforeOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, +QString Q_GUI_EXPORT qTextBeforeOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, int *startOffset, int *endOffset, const QString& text) { QTextBoundaryFinder::BoundaryType type; @@ -175,7 +175,7 @@ QString Q_GUI_EXPORT textBeforeOffsetFromString(int offset, QAccessible2::Bounda /*! \internal */ -QString Q_GUI_EXPORT textAfterOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, +QString Q_GUI_EXPORT qTextAfterOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, int *startOffset, int *endOffset, const QString& text) { QTextBoundaryFinder::BoundaryType type; @@ -210,7 +210,7 @@ QString Q_GUI_EXPORT textAfterOffsetFromString(int offset, QAccessible2::Boundar /*! \internal */ -QString Q_GUI_EXPORT textAtOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, +QString Q_GUI_EXPORT qTextAtOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, int *startOffset, int *endOffset, const QString& text) { QTextBoundaryFinder::BoundaryType type; diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp index 4f469e5..36e786f 100644 --- a/src/plugins/accessible/widgets/simplewidgets.cpp +++ b/src/plugins/accessible/widgets/simplewidgets.cpp @@ -68,11 +68,11 @@ extern QList childWidgets(const QWidget *widget, bool includeTopLevel QString Q_GUI_EXPORT qt_accStripAmp(const QString &text); QString Q_GUI_EXPORT qt_accHotKey(const QString &text); -QString Q_GUI_EXPORT textBeforeOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, +QString Q_GUI_EXPORT qTextBeforeOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, int *startOffset, int *endOffset, const QString& text); -QString Q_GUI_EXPORT textAtOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, +QString Q_GUI_EXPORT qTextAtOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, int *startOffset, int *endOffset, const QString& text); -QString Q_GUI_EXPORT textAfterOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, +QString Q_GUI_EXPORT qTextAfterOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, int *startOffset, int *endOffset, const QString& text); /*! @@ -829,7 +829,7 @@ QString QAccessibleLineEdit::textBeforeOffset(int offset, BoundaryType boundaryT *startOffset = *endOffset = -1; return QString(); } - return textBeforeOffsetFromString(offset, boundaryType, startOffset, endOffset, lineEdit()->text()); + return qTextBeforeOffsetFromString(offset, boundaryType, startOffset, endOffset, lineEdit()->text()); } QString QAccessibleLineEdit::textAfterOffset(int offset, BoundaryType boundaryType, @@ -839,7 +839,7 @@ QString QAccessibleLineEdit::textAfterOffset(int offset, BoundaryType boundaryTy *startOffset = *endOffset = -1; return QString(); } - return textAfterOffsetFromString(offset, boundaryType, startOffset, endOffset, lineEdit()->text()); + return qTextAfterOffsetFromString(offset, boundaryType, startOffset, endOffset, lineEdit()->text()); } QString QAccessibleLineEdit::textAtOffset(int offset, BoundaryType boundaryType, @@ -849,7 +849,7 @@ QString QAccessibleLineEdit::textAtOffset(int offset, BoundaryType boundaryType, *startOffset = *endOffset = -1; return QString(); } - return textAtOffsetFromString(offset, boundaryType, startOffset, endOffset, lineEdit()->text()); + return qTextAtOffsetFromString(offset, boundaryType, startOffset, endOffset, lineEdit()->text()); } void QAccessibleLineEdit::removeSelection(int selectionIndex) -- cgit v0.12 From 8b66982ec7b4b5d2071931c288973dce73dc9875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 8 Jul 2011 09:56:00 +0200 Subject: Use more numerically robust algorithm to compute QBezier::pointAt(). QBezier::pointAt() could potentially return values outside the bezier's bounds, even when the bezier was a straight horizontal line. For example, with y = 0.5, it would produce y=0.5 or y=0.49999999999999 for different values of t, which when rounded cause jittering in a QML PathView. Task-number: QTBUG-17007 Task-number: QTBUG-18133 Reviewed-by: Kim --- src/gui/painting/qbezier_p.h | 36 ++++++++++++++-------------- tests/auto/qpainterpath/tst_qpainterpath.cpp | 21 ++++++++++++++++ 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/gui/painting/qbezier_p.h b/src/gui/painting/qbezier_p.h index 399dd89..f1f7eb1 100644 --- a/src/gui/painting/qbezier_p.h +++ b/src/gui/painting/qbezier_p.h @@ -162,27 +162,27 @@ inline void QBezier::coefficients(qreal t, qreal &a, qreal &b, qreal &c, qreal & inline QPointF QBezier::pointAt(qreal t) const { -#if 1 - qreal a, b, c, d; - coefficients(t, a, b, c, d); - return QPointF(a*x1 + b*x2 + c*x3 + d*x4, a*y1 + b*y2 + c*y3 + d*y4); -#else // numerically more stable: + qreal x, y; + qreal m_t = 1. - t; - qreal a = x1*m_t + x2*t; - qreal b = x2*m_t + x3*t; - qreal c = x3*m_t + x4*t; - a = a*m_t + b*t; - b = b*m_t + c*t; - qreal x = a*m_t + b*t; - qreal a = y1*m_t + y2*t; - qreal b = y2*m_t + y3*t; - qreal c = y3*m_t + y4*t; - a = a*m_t + b*t; - b = b*m_t + c*t; - qreal y = a*m_t + b*t; + { + qreal a = x1*m_t + x2*t; + qreal b = x2*m_t + x3*t; + qreal c = x3*m_t + x4*t; + a = a*m_t + b*t; + b = b*m_t + c*t; + x = a*m_t + b*t; + } + { + qreal a = y1*m_t + y2*t; + qreal b = y2*m_t + y3*t; + qreal c = y3*m_t + y4*t; + a = a*m_t + b*t; + b = b*m_t + c*t; + y = a*m_t + b*t; + } return QPointF(x, y); -#endif } inline QPointF QBezier::normalVector(qreal t) const diff --git a/tests/auto/qpainterpath/tst_qpainterpath.cpp b/tests/auto/qpainterpath/tst_qpainterpath.cpp index 3941a11..33315ad 100644 --- a/tests/auto/qpainterpath/tst_qpainterpath.cpp +++ b/tests/auto/qpainterpath/tst_qpainterpath.cpp @@ -114,6 +114,8 @@ private slots: void connectPathMoveTo(); void translate(); + + void lineWithinBounds(); }; // Testing get/set functions @@ -1306,6 +1308,25 @@ void tst_QPainterPath::translate() QCOMPARE(complexPath.translated(-offset), untranslatedComplexPath); } + +void tst_QPainterPath::lineWithinBounds() +{ + const int iteration_count = 3; + volatile const qreal yVal = 0.5; + QPointF a(0.0, yVal); + QPointF b(1000.0, yVal); + QPointF c(2000.0, yVal); + QPointF d(3000.0, yVal); + QPainterPath path; + path.moveTo(QPointF(0, yVal)); + path.cubicTo(QPointF(1000.0, yVal), QPointF(2000.0, yVal), QPointF(3000.0, yVal)); + for(int i=0; i<=iteration_count; i++) { + qreal actual = path.pointAtPercent(qreal(i) / iteration_count).y(); + QVERIFY(actual == yVal); // don't use QCOMPARE, don't want fuzzy comparison + } +} + + QTEST_APPLESS_MAIN(tst_QPainterPath) #include "tst_qpainterpath.moc" -- cgit v0.12 From 440b891855f1e6e5e83106d128ad345560f0fd1d Mon Sep 17 00:00:00 2001 From: Honglei Zhang Date: Fri, 8 Jul 2011 13:21:39 +0300 Subject: Fix license header in qs60keycapture_p.h and qs60keycapture.cpp Commit bad513727833e207f7f8ca0d7c07c44c1addfb57 has old license header in qs60keycature_p.h and qs60keycapture.cpp. New header is used. Reviewed-by: Trust Me --- src/gui/s60framework/qs60keycapture.cpp | 36 ++++++++++++++++----------------- src/gui/s60framework/qs60keycapture_p.h | 36 ++++++++++++++++----------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/gui/s60framework/qs60keycapture.cpp b/src/gui/s60framework/qs60keycapture.cpp index db4cc0e..415c3e1 100644 --- a/src/gui/s60framework/qs60keycapture.cpp +++ b/src/gui/s60framework/qs60keycapture.cpp @@ -4,32 +4,32 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtGui module of the Qt Toolkit. +** This file is part of the Symbian application wrapper of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** ** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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 +** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** +** 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. ** ** ** diff --git a/src/gui/s60framework/qs60keycapture_p.h b/src/gui/s60framework/qs60keycapture_p.h index 41cb765..a50fad7 100644 --- a/src/gui/s60framework/qs60keycapture_p.h +++ b/src/gui/s60framework/qs60keycapture_p.h @@ -4,32 +4,32 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtGui module of the Qt Toolkit. +** This file is part of the Symbian application wrapper of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** ** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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 +** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** +** 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. ** ** ** -- cgit v0.12 From c5f3ea858679d07d753e29af87f04efadd7683e9 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Fri, 8 Jul 2011 13:39:36 +0200 Subject: Use truncate only for subpixel boundingBox x position Since Lion, Core Text starts to return fractional values for x origin in the glyph bounding box. To get correct alignment we need to make it integer, it seems that round will cut certain pixels (x = 0.6 will be round to 1, then that glyph will be moved too much to the left in image glyph cache). Reverting 4297b85a appears to work fine on previous version of Mac OS X as well. This change will not affect Windows (DirectWrite) and FreeType font engines since they both return integer values for that. Reviewed-by: Eskil --- src/gui/painting/qtextureglyphcache.cpp | 2 +- src/gui/text/qfontengine_coretext.mm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index abd0ed1..3973abd 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -198,7 +198,7 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const Coord c = { 0, 0, // will be filled in later glyph_width, glyph_height, // texture coords - metrics.x.round().truncate(), + metrics.x.truncate(), -metrics.y.truncate() }; // baseline for horizontal scripts listItemCoordinates.insert(key, c); diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm index 6a9201d..64d4a24 100644 --- a/src/gui/text/qfontengine_coretext.mm +++ b/src/gui/text/qfontengine_coretext.mm @@ -751,7 +751,7 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition CGContextSetFont(ctx, cgFont); - qreal pos_x = -br.x.round().truncate() + subPixelPosition.toReal(); + qreal pos_x = -br.x.truncate() + subPixelPosition.toReal(); qreal pos_y = im.height() + br.y.toReal(); CGContextSetTextPosition(ctx, pos_x, pos_y); -- cgit v0.12 From 9eb176928280acaabcee99d52c2379ddd3a44490 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 8 Jul 2011 10:42:49 +0200 Subject: Use memmove in QListData::append(int) as regions overlap. It's undefined behaviour to memcpy regions with overlapping area. You have to use memmove. Change-Id: I912c819bf7ab26ba1e60028ee9d7c833dfc5138a Reviewed-on: http://codereview.qt.nokia.com/1355 Reviewed-by: Olivier Goffart (cherry picked from commit d96b7b809e614dd416709acec768529457120b9f) --- src/corelib/tools/qlist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp index 36a9c60..e68ddd5 100644 --- a/src/corelib/tools/qlist.cpp +++ b/src/corelib/tools/qlist.cpp @@ -237,7 +237,7 @@ void **QListData::append(int n) if (b - n >= 2 * d->alloc / 3) { // we have enough space. Just not at the end -> move it. e -= b; - ::memcpy(d->array, d->array + b, e * sizeof(void *)); + ::memmove(d->array, d->array + b, e * sizeof(void *)); d->begin = 0; } else { realloc(grow(d->alloc + n)); -- cgit v0.12 From 96960787f7cb6f3937cdf7e3da77988259979008 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 8 Jul 2011 16:49:28 +0100 Subject: Fix resource leak in symbian socket engine Timer created when a socket is being used synchronously was not being closed on destruction of the socket engine. Reviewed-by: mread --- src/network/socket/qsymbiansocketengine.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/network/socket/qsymbiansocketengine.cpp b/src/network/socket/qsymbiansocketengine.cpp index 0aa5a5a..966af88 100644 --- a/src/network/socket/qsymbiansocketengine.cpp +++ b/src/network/socket/qsymbiansocketengine.cpp @@ -264,6 +264,7 @@ QSymbianSocketEnginePrivate::QSymbianSocketEnginePrivate() : QSymbianSocketEnginePrivate::~QSymbianSocketEnginePrivate() { + selectTimer.Close(); } -- cgit v0.12 From 8ce9dc02cd5031f26c7fec10484a8c47904c46f5 Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Fri, 8 Jul 2011 18:52:36 +0200 Subject: sync win32-g++-cross with win32-g++ (lib prefix and extension) qmake now needs library prefix and extension to be supplied. This was added to plain win32-g++ in dbbf06e. Now added to win32-g++-cross. Without this, static libraries get named 'X.lib' instead of 'libX.a'. Merge-request: 1283 Reviewed-by: Oswald Buddenhagen --- mkspecs/unsupported/win32-g++-cross/qmake.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mkspecs/unsupported/win32-g++-cross/qmake.conf b/mkspecs/unsupported/win32-g++-cross/qmake.conf index 01e2f10..0538e86 100644 --- a/mkspecs/unsupported/win32-g++-cross/qmake.conf +++ b/mkspecs/unsupported/win32-g++-cross/qmake.conf @@ -62,6 +62,8 @@ QMAKE_LFLAGS_WINDOWS = -Wl,-subsystem,windows QMAKE_LFLAGS_DLL = -shared QMAKE_LINK_OBJECT_MAX = 10 QMAKE_LINK_OBJECT_SCRIPT= object_script +QMAKE_PREFIX_STATICLIB = lib +QMAKE_EXTENSION_STATICLIB = a QMAKE_LIBS = -- cgit v0.12 From 59b2938758ebf563bedf943ddd4636176ca8d15e Mon Sep 17 00:00:00 2001 From: mread Date: Tue, 5 Jul 2011 11:21:39 +0100 Subject: Fixing WINSCW compile error Refactoring the body of a large TRAP into a separate function. This was not compiling on WINSCW, perhaps due to the use of #ifdef within the TRAP macro expansion. It does compile now. Reviewed-by: Sami Merila --- src/plugins/bearer/symbian/symbianengine.cpp | 21 ++++++++++++--------- src/plugins/bearer/symbian/symbianengine.h | 2 ++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index 04edbb7..38ae0c8 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -104,15 +104,7 @@ void SymbianEngine::initialize() return; } - TRAP(error, { - iConnectionMonitor.ConnectL(); - CleanupClosePushL(iConnectionMonitor); -#ifdef SNAP_FUNCTIONALITY_AVAILABLE - User::LeaveIfError(iConnectionMonitor.SetUintAttribute(EBearerIdAll, 0, KBearerGroupThreshold, 1)); -#endif - iConnectionMonitor.NotifyEventL(*this); - CleanupStack::Pop(); - }); + TRAP(error, StartConnectionMonitorNotifyL()); if (error != KErrNone) { iInitOk = false; return; @@ -148,6 +140,17 @@ void SymbianEngine::initialize() startCommsDatabaseNotifications(); } +void SymbianEngine::StartConnectionMonitorNotifyL() +{ + iConnectionMonitor.ConnectL(); + CleanupClosePushL(iConnectionMonitor); +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + User::LeaveIfError(iConnectionMonitor.SetUintAttribute(EBearerIdAll, 0, KBearerGroupThreshold, 1)); +#endif + iConnectionMonitor.NotifyEventL(*this); + CleanupStack::Pop(); +} + SymbianEngine::~SymbianEngine() { Cancel(); diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index 3b3a78a..7455d25 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -184,6 +184,8 @@ private: void startMonitoringIAPData(TUint32 aIapId); QNetworkConfigurationPrivatePointer dataByConnectionId(TUint aConnectionId); + void StartConnectionMonitorNotifyL(); + protected: // From CActive void RunL(); -- cgit v0.12 From 79a271180e512eae196220d4c52d405c1cee5b8d Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 11 Jul 2011 11:15:05 +0200 Subject: Doc: fix typo Reviewed-by: TrustMe --- doc/src/deployment/deployment.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/deployment/deployment.qdoc b/doc/src/deployment/deployment.qdoc index 47219bf..a359787 100644 --- a/doc/src/deployment/deployment.qdoc +++ b/doc/src/deployment/deployment.qdoc @@ -746,7 +746,7 @@ If the shared library has dependencies that are different from the application using it, the manifest file needs to be embedded into the DLL - binary. Since Qt 4.1.3, the follwoing \c CONFIG options are available for + binary. Since Qt 4.1.3, the following \c CONFIG options are available for embedding manifests: \snippet doc/src/snippets/code/doc_src_deployment.qdoc 20 -- cgit v0.12 From 1f90ae36cff8acf581d1624bf011fe3a55c623c0 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Fri, 8 Jul 2011 17:40:43 +0200 Subject: Fix crash when app font is added Loading app fonts will clear the application font cache, but QFontPrivate::engineWithScript will try to load the font again, in Mac the font engine used here must be the one used for shaping, because subsequent sub font engines may be added to it during the shaping process (QCoreTextFontEngineMulti::stringToCMap). That is why we need to fetch the font engine directly from QTextEngine's fontEngine cache instead of QFontCache. Task-number: QTBUG-20250 Reviewed-by: Eskil --- src/gui/text/qtextengine.cpp | 35 +++++++++++++++++++++-------------- src/gui/text/qtextengine_p.h | 4 +++- src/gui/text/qtextlayout.cpp | 8 ++++---- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 8ddf3eb..c900918 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -3051,6 +3051,22 @@ QTextItemInt::QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFo : justified(false), underlineStyle(QTextCharFormat::NoUnderline), charFormat(format), num_chars(0), chars(0), logClusters(0), f(0), fontEngine(0) { + f = font; + fontEngine = f->d->engineForScript(si.analysis.script); + Q_ASSERT(fontEngine); + + initWithScriptItem(si); +} + +QTextItemInt::QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars_, int numChars, QFontEngine *fe, const QTextCharFormat &format) + : flags(0), justified(false), underlineStyle(QTextCharFormat::NoUnderline), charFormat(format), + num_chars(numChars), chars(chars_), logClusters(0), f(font), glyphs(g), fontEngine(fe) +{ +} + +// Fix up flags and underlineStyle with given info +void QTextItemInt::initWithScriptItem(const QScriptItem &si) +{ // explicitly initialize flags so that initFontAttributes can be called // multiple times on the same TextItem flags = 0; @@ -3058,13 +3074,10 @@ QTextItemInt::QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFo flags |= QTextItem::RightToLeft; ascent = si.ascent; descent = si.descent; - f = font; - fontEngine = f->d->engineForScript(si.analysis.script); - Q_ASSERT(fontEngine); - if (format.hasProperty(QTextFormat::TextUnderlineStyle)) { - underlineStyle = format.underlineStyle(); - } else if (format.boolProperty(QTextFormat::FontUnderline) + if (charFormat.hasProperty(QTextFormat::TextUnderlineStyle)) { + underlineStyle = charFormat.underlineStyle(); + } else if (charFormat.boolProperty(QTextFormat::FontUnderline) || f->d->underline) { underlineStyle = QTextCharFormat::SingleUnderline; } @@ -3073,18 +3086,12 @@ QTextItemInt::QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFo if (underlineStyle == QTextCharFormat::SingleUnderline) flags |= QTextItem::Underline; - if (f->d->overline || format.fontOverline()) + if (f->d->overline || charFormat.fontOverline()) flags |= QTextItem::Overline; - if (f->d->strikeOut || format.fontStrikeOut()) + if (f->d->strikeOut || charFormat.fontStrikeOut()) flags |= QTextItem::StrikeOut; } -QTextItemInt::QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars_, int numChars, QFontEngine *fe) - : flags(0), justified(false), underlineStyle(QTextCharFormat::NoUnderline), - num_chars(numChars), chars(chars_), logClusters(0), f(font), glyphs(g), fontEngine(fe) -{ -} - QTextItemInt QTextItemInt::midItem(QFontEngine *fontEngine, int firstGlyphIndex, int numGlyphs) const { QTextItemInt ti = *this; diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 055974a..b1bd0c3 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -312,11 +312,13 @@ public: logClusters(0), f(0), fontEngine(0) {} QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFormat &format = QTextCharFormat()); - QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars, int numChars, QFontEngine *fe); + QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars, int numChars, QFontEngine *fe, + const QTextCharFormat &format = QTextCharFormat()); /// copy the structure items, adjusting the glyphs arrays to the right subarrays. /// the width of the returned QTextItemInt is not adjusted, for speed reasons QTextItemInt midItem(QFontEngine *fontEngine, int firstGlyphIndex, int numGlyphs) const; + void initWithScriptItem(const QScriptItem &si); QFixed descent; QFixed ascent; diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index c1bc846..2d5b453 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -2381,13 +2381,13 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR unsigned short *logClusters = eng->logClusters(&si); QGlyphLayout glyphs = eng->shapedGlyphs(&si); - QTextItemInt gf(si, &f, format); - gf.glyphs = glyphs.mid(iterator.glyphsStart, iterator.glyphsEnd - iterator.glyphsStart); - gf.chars = eng->layoutData->string.unicode() + iterator.itemStart; + QTextItemInt gf(glyphs.mid(iterator.glyphsStart, iterator.glyphsEnd - iterator.glyphsStart), + &f, eng->layoutData->string.unicode() + iterator.itemStart, + iterator.itemEnd - iterator.itemStart, eng->fontEngine(si), format); gf.logClusters = logClusters + iterator.itemStart - si.position; - gf.num_chars = iterator.itemEnd - iterator.itemStart; gf.width = iterator.itemWidth; gf.justified = line.justified; + gf.initWithScriptItem(si); Q_ASSERT(gf.fontEngine); -- cgit v0.12 From 64dc31c660fd23ec77c51f406ba473a6ca0b3c13 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 11 Jul 2011 14:07:34 +0200 Subject: Fix compiler warning in qtextdocument.cpp Missing QLatin1String() wrapper to ensure codec of text. Reviewed-by: Jiang Jiang --- src/gui/text/qtextdocument.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 0abafb8..143dc1a 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -2710,7 +2710,7 @@ void QTextHtmlExporter::emitBlock(const QTextBlock &block) html += QLatin1Char('>'); if (block.begin().atEnd()) - html += "
    "; + html += QLatin1String("
    "); QTextBlock::Iterator it = block.begin(); if (fragmentMarkers && !it.atEnd() && block == doc->begin()) -- cgit v0.12