diff options
Diffstat (limited to 'src')
230 files changed, 41 insertions, 70744 deletions
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 14e045ce4a..a932eb724e 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -121,7 +121,7 @@ static inline QString buildTypeNameForDebug(const QMetaObject *metaObject) For example, if there is a \c main.qml file like this: \qml - import QtQuick 1.0 + import QtQuick 2.0 Item { width: 200 diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp index 709af9e7b9..3f838d5fd1 100644 --- a/src/declarative/qml/qdeclarativecontext.cpp +++ b/src/declarative/qml/qdeclarativecontext.cpp @@ -84,7 +84,7 @@ QDeclarativeContextPrivate::QDeclarativeContextPrivate() context->setContextProperty("myModel", &modelData); QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0\nListView { model: myModel }", QUrl()); + component.setData("import QtQuick 2.0\nListView { model: myModel }", QUrl()); QObject *window = component.create(context); \endcode @@ -116,7 +116,7 @@ QDeclarativeContextPrivate::QDeclarativeContextPrivate() context->setContextObject(&myDataSet); QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0\nListView { model: myModel }", QUrl()); + component.setData("import QtQuick 2.0\nListView { model: myModel }", QUrl()); component.create(context); \endcode diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index e02cdee45d..6097fd437f 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -137,7 +137,7 @@ void qmlRegisterBaseTypes(const char *uri, int versionMajor, int versionMinor) \qml // MyRect.qml - import QtQuick 1.0 + import QtQuick 2.0 Item { width: 200; height: 200 @@ -197,7 +197,7 @@ It is not instantiable; to use it, call the members of the global \c Qt object d For example: \qml -import QtQuick 1.0 +import QtQuick 2.0 Text { color: Qt.rgba(1, 0, 0, 1) @@ -484,7 +484,7 @@ QDeclarativeWorkerScriptEngine *QDeclarativeEnginePrivate::getWorkerScriptEngine \code QDeclarativeEngine engine; QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0\nText { text: \"Hello world!\" }", QUrl()); + component.setData("import QtQuick 2.0\nText { text: \"Hello world!\" }", QUrl()); QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(component.create()); //add item to view, etc diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp index 25d85f407b..94ed7b7296 100644 --- a/src/declarative/qml/qdeclarativeexpression.cpp +++ b/src/declarative/qml/qdeclarativeexpression.cpp @@ -173,7 +173,7 @@ QDeclarativeExpression *QDeclarativeExpressionPrivate::create(QDeclarativeContex For example, given a file \c main.qml like this: \qml - import QtQuick 1.0 + import QtQuick 2.0 Item { width: 200; height: 200 diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index fdb14c5e28..a679ead8d4 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -88,7 +88,7 @@ For example, for the following QML code: \qml // MyItem.qml -import QtQuick 1.0 +import QtQuick 2.0 Text { text: "A bit of text" } \endqml diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp index ee1f8bcd21..c008e2a28a 100644 --- a/src/declarative/qml/qdeclarativevme.cpp +++ b/src/declarative/qml/qdeclarativevme.cpp @@ -436,7 +436,7 @@ QObject *QDeclarativeVME::run(QList<QDeclarativeError> *errors, // A component that is logically created within another component instance shares the // same instances of script imports. For example: // - // import QtQuick 1.0 + // import QtQuick 2.0 // import "test.js" as Test // ListView { // model: Test.getModel() diff --git a/src/declarative/qml/v4/qv4bindings.cpp b/src/declarative/qml/v4/qv4bindings.cpp index a1f4593c2e..eed4efc87b 100644 --- a/src/declarative/qml/v4/qv4bindings.cpp +++ b/src/declarative/qml/v4/qv4bindings.cpp @@ -453,12 +453,7 @@ static bool testCompareVariants(const QVariant &qtscriptRaw, const QVariant &v4) int type = qtscript.userType(); - if (type == qMetaTypeId<QDeclarative1AnchorLine>()) { - QDeclarative1AnchorLine la = qvariant_cast<QDeclarative1AnchorLine>(qtscript); - QDeclarative1AnchorLine ra = qvariant_cast<QDeclarative1AnchorLine>(v4); - - return la == ra; - } else if (type == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) { + if (type == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) { return QDeclarativeMetaType::QQuickAnchorLineCompare(qtscript.constData(), v4.constData()); } else if (type == QMetaType::Double) { @@ -538,9 +533,7 @@ static void testBindingResult(const QString &binding, int line, int column, v4value = result.getqreal(); break; default: - if (resultType == qMetaTypeId<QDeclarative1AnchorLine>()) { - v4value = qVariantFromValue<QDeclarative1AnchorLine>(*(QDeclarative1AnchorLine *)result.typeDataPtr()); - } else if (resultType == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) { + if (resultType == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) { v4value = QVariant(QDeclarativeMetaType::QQuickAnchorLineMetaTypeId(), result.typeDataPtr()); } else { iserror = true; diff --git a/src/declarative/qml/v4/qv4compiler.cpp b/src/declarative/qml/v4/qv4compiler.cpp index 0d29872f4c..42e56d12c9 100644 --- a/src/declarative/qml/v4/qv4compiler.cpp +++ b/src/declarative/qml/v4/qv4compiler.cpp @@ -345,9 +345,7 @@ void QV4CompilerPrivate::visitName(IR::Name *e) break; default: - if (propTy == qMetaTypeId<QDeclarative1AnchorLine>()) { - regType = PODValueType; - } else if (propTy == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) { + if (propTy == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) { regType = PODValueType; } else if (QDeclarativeMetaType::isQObject(propTy)) { regType = QObjectStarType; @@ -990,9 +988,6 @@ void QV4CompilerPrivate::visitRet(IR::Ret *s) case IR::UrlType: test.regType = QMetaType::QUrl; break; - case IR::AnchorLineType: - test.regType = qMetaTypeId<QDeclarative1AnchorLine>(); - break; case IR::SGAnchorLineType: test.regType = QDeclarativeMetaType::QQuickAnchorLineMetaTypeId(); break; diff --git a/src/declarative/qml/v4/qv4compiler_p_p.h b/src/declarative/qml/v4/qv4compiler_p_p.h index b9e4976eb8..85a7c36f87 100644 --- a/src/declarative/qml/v4/qv4compiler_p_p.h +++ b/src/declarative/qml/v4/qv4compiler_p_p.h @@ -63,36 +63,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -// NOTE: This is a copy of QDeclarative1AnchorLine: src/qtquick1/graphicsitems/qdeclarativeanchors_p_p.h -class QGraphicsObject; -class QDeclarative1AnchorLine -{ -public: - QDeclarative1AnchorLine() : item(0), anchorLine(Invalid) {} - - enum AnchorLine { - Invalid = 0x0, - Left = 0x01, - Right = 0x02, - Top = 0x04, - Bottom = 0x08, - HCenter = 0x10, - VCenter = 0x20, - Baseline = 0x40, - Horizontal_Mask = Left | Right | HCenter, - Vertical_Mask = Top | Bottom | VCenter | Baseline - }; - - QGraphicsObject *item; - AnchorLine anchorLine; -}; - -inline bool operator==(const QDeclarative1AnchorLine& a, const QDeclarative1AnchorLine& b) -{ - return a.item == b.item && a.anchorLine == b.anchorLine; -} - - template <typename _Key, typename _Value> class QDeclarativeAssociationList { @@ -269,8 +239,6 @@ private: QT_END_NAMESPACE -Q_DECLARE_METATYPE(QDeclarative1AnchorLine) - QT_END_HEADER #endif // QV4COMPILER_P_P_H diff --git a/src/declarative/qml/v4/qv4ir.cpp b/src/declarative/qml/v4/qv4ir.cpp index 83acd05a0f..149479d757 100644 --- a/src/declarative/qml/v4/qv4ir.cpp +++ b/src/declarative/qml/v4/qv4ir.cpp @@ -59,7 +59,6 @@ inline const char *typeName(Type t) case VoidType: return "void"; case StringType: return "string"; case UrlType: return "url"; - case AnchorLineType: return "AnchorLine"; case SGAnchorLineType: return "SGAnchorLine"; case AttachType: return "AttachType"; case ObjectType: return "object"; diff --git a/src/declarative/qml/v4/qv4ir_p.h b/src/declarative/qml/v4/qv4ir_p.h index e57b29da79..2ed403fc29 100644 --- a/src/declarative/qml/v4/qv4ir_p.h +++ b/src/declarative/qml/v4/qv4ir_p.h @@ -142,7 +142,6 @@ enum Type { VoidType, StringType, UrlType, - AnchorLineType, SGAnchorLineType, AttachType, ObjectType, diff --git a/src/declarative/qml/v4/qv4irbuilder.cpp b/src/declarative/qml/v4/qv4irbuilder.cpp index 35b36ae114..2cc1c6eaab 100644 --- a/src/declarative/qml/v4/qv4irbuilder.cpp +++ b/src/declarative/qml/v4/qv4irbuilder.cpp @@ -70,11 +70,9 @@ static IR::Type irTypeFromVariantType(int t, QDeclarativeEnginePrivate *engine, return IR::UrlType; default: - if (t == qMetaTypeId<QDeclarative1AnchorLine>()) - return IR::AnchorLineType; - else if (t == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) + if (t == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) { return IR::SGAnchorLineType; - else if (engine->metaObjectForType(t)) { + } else if (engine->metaObjectForType(t)) { return IR::ObjectType; } diff --git a/src/imports/gestures/gestures.pro b/src/imports/gestures/gestures.pro deleted file mode 100644 index 36244a1d71..0000000000 --- a/src/imports/gestures/gestures.pro +++ /dev/null @@ -1,16 +0,0 @@ -TARGET = qmlgesturesplugin -TARGETPATH = Qt/labs/gestures -include(../qimportbase.pri) - -QT += core-private gui-private declarative-private qtquick1 qtquick1-private widgets-private v8-private - -SOURCES += qdeclarativegesturearea.cpp plugin.cpp -HEADERS += qdeclarativegesturearea_p.h - -DESTDIR = $$QT.declarative.imports/$$TARGETPATH -target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -qmldir.files += $$PWD/qmldir -qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -INSTALLS += target qmldir diff --git a/src/imports/gestures/plugin.cpp b/src/imports/gestures/plugin.cpp deleted file mode 100644 index 83ac3d66dc..0000000000 --- a/src/imports/gestures/plugin.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 <QtDeclarative/qdeclarativeextensionplugin.h> -#include <QtDeclarative/qdeclarative.h> - -#include "qdeclarativegesturearea_p.h" - -QT_BEGIN_NAMESPACE - -class GestureAreaQmlPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - virtual void registerTypes(const char *uri) - { - Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.gestures")); -#ifndef QT_NO_GESTURES - qmlRegisterCustomType<QDeclarativeGestureArea>(uri,1,0, "GestureArea", new QDeclarativeGestureAreaParser); - - qmlRegisterUncreatableType<QGesture>(uri, 1, 0, "Gesture", QLatin1String("Do not create objects of this type.")); - qmlRegisterUncreatableType<QPanGesture>(uri, 1, 0, "PanGesture", QLatin1String("Do not create objects of this type.")); - qmlRegisterUncreatableType<QTapGesture>(uri, 1, 0, "TapGesture", QLatin1String("Do not create objects of this type.")); - qmlRegisterUncreatableType<QTapAndHoldGesture>(uri, 1, 0, "TapAndHoldGesture", QLatin1String("Do not create objects of this type.")); - qmlRegisterUncreatableType<QPinchGesture>(uri, 1, 0, "PinchGesture", QLatin1String("Do not create objects of this type.")); - qmlRegisterUncreatableType<QSwipeGesture>(uri, 1, 0, "SwipeGesture", QLatin1String("Do not create objects of this type.")); -#endif - } -}; - -QT_END_NAMESPACE - -#include "plugin.moc" - -Q_EXPORT_PLUGIN2(qmlgesturesplugin, QT_PREPEND_NAMESPACE(GestureAreaQmlPlugin)); diff --git a/src/imports/gestures/qdeclarativegesturearea.cpp b/src/imports/gestures/qdeclarativegesturearea.cpp deleted file mode 100644 index 8a23ef1e77..0000000000 --- a/src/imports/gestures/qdeclarativegesturearea.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qdeclarativegesturearea_p.h" - -#include <qdeclarativeexpression.h> -#include <qdeclarativecontext.h> -#include <qdeclarativeinfo.h> - -#include <private/qdeclarativeproperty_p.h> -#include <private/qdeclarativescript_p.h> -#include <QtQuick1/private/qdeclarativeitem_p.h> - -#include <QtCore/qdebug.h> -#include <QtCore/qstringlist.h> - -#include <QtGui/qevent.h> - -#include <private/qobject_p.h> - -#ifndef QT_NO_GESTURES - -QT_BEGIN_NAMESPACE - -class QDeclarativeGestureAreaPrivate : public QDeclarativeItemPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeGestureArea) -public: - QDeclarativeGestureAreaPrivate() : componentcomplete(false), gesture(0) {} - - typedef QMap<Qt::GestureType,QDeclarativeExpression*> Bindings; - Bindings bindings; - - bool componentcomplete; - - QByteArray data; - - QGesture *gesture; - - bool gestureEvent(QGestureEvent *event); -}; - -/*! - \qmlclass GestureArea QDeclarativeGestureArea - \ingroup qml-basic-interaction-elements - - \brief The GestureArea item enables simple gesture handling. - \inherits Item - - A GestureArea is like a MouseArea, but it has signals for gesture events. - - \warning Elements in the Qt.labs module are not guaranteed to remain compatible - in future versions. - - \warning GestureArea is an experimental element whose development has - been discontinued. PinchArea is available in QtQuick 1.1 and handles - two finger gesture input. - - \note This element is only functional on devices with touch input. - - \qml - import Qt.labs.gestures 1.0 - - GestureArea { - anchors.fill: parent - // onPan: ... gesture.acceleration ... - // onPinch: ... gesture.rotationAngle ... - // onSwipe: ... - // onTapAndHold: ... - // onTap: ... - // onGesture: ... - } - \endqml - - Each signal has a \e gesture parameter that has the - properties of the gesture. - - \table - \header \o Signal \o Type \o Property \o Description - \row \o onTap \o point \o position \o the position of the tap - \row \o onTapAndHold \o point \o position \o the position of the tap - \row \o onPan \o real \o acceleration \o the acceleration of the pan - \row \o onPan \o point \o delta \o the offset from the previous input position to the current input - \row \o onPan \o point \o offset \o the total offset from the first input position to the current input position - \row \o onPan \o point \o lastOffset \o the previous value of offset - \row \o onPinch \o point \o centerPoint \o the midpoint between the two input points - \row \o onPinch \o point \o lastCenterPoint \o the previous value of centerPoint - \row \o onPinch \o point \o startCenterPoint \o the first value of centerPoint - \row \o onPinch \o real \o rotationAngle \o the angle covered by the gesture motion - \row \o onPinch \o real \o lastRotationAngle \o the previous value of rotationAngle - \row \o onPinch \o real \o totalRotationAngle \o the complete angle covered by the gesture - \row \o onPinch \o real \o scaleFactor \o the change in distance between the two input points - \row \o onPinch \o real \o lastScaleFactor \o the previous value of scaleFactor - \row \o onPinch \o real \o totalScaleFactor \o the complete scale factor of the gesture - \row \o onSwipe \o real \o swipeAngle \o the angle of the swipe - \endtable - - Custom gestures, handled by onGesture, will have custom properties. - - GestureArea is an invisible item: it is never painted. - - \sa MouseArea -*/ - -/*! - \internal - \class QDeclarativeGestureArea - \brief The QDeclarativeGestureArea class provides simple gesture handling. - -*/ -QDeclarativeGestureArea::QDeclarativeGestureArea(QDeclarativeItem *parent) : - QDeclarativeItem(*(new QDeclarativeGestureAreaPrivate), parent) -{ - setAcceptedMouseButtons(Qt::LeftButton); - setAcceptTouchEvents(true); -} - -QDeclarativeGestureArea::~QDeclarativeGestureArea() -{ -} - -QByteArray -QDeclarativeGestureAreaParser::compile(const QList<QDeclarativeCustomParserProperty> &props) -{ - QByteArray rv; - QDataStream ds(&rv, QIODevice::WriteOnly); - - for(int ii = 0; ii < props.count(); ++ii) - { - QString propName = props.at(ii).name(); - Qt::GestureType type; - - if (propName == QLatin1String("onTap")) { - type = Qt::TapGesture; - } else if (propName == QLatin1String("onTapAndHold")) { - type = Qt::TapAndHoldGesture; - } else if (propName == QLatin1String("onPan")) { - type = Qt::PanGesture; - } else if (propName == QLatin1String("onPinch")) { - type = Qt::PinchGesture; - } else if (propName == QLatin1String("onSwipe")) { - type = Qt::SwipeGesture; - } else if (propName == QLatin1String("onGesture")) { - type = Qt::CustomGesture; - } else { - error(props.at(ii), QDeclarativeGestureArea::tr("Cannot assign to non-existent property \"%1\"").arg(propName)); - return QByteArray(); - } - - QList<QVariant> values = props.at(ii).assignedValues(); - - for (int i = 0; i < values.count(); ++i) { - const QVariant &value = values.at(i); - - if (value.userType() == qMetaTypeId<QDeclarativeCustomParserNode>()) { - error(props.at(ii), QDeclarativeGestureArea::tr("GestureArea: nested objects not allowed")); - return QByteArray(); - } else if (value.userType() == qMetaTypeId<QDeclarativeCustomParserProperty>()) { - error(props.at(ii), QDeclarativeGestureArea::tr("GestureArea: syntax error")); - return QByteArray(); - } else { - QDeclarativeScript::Variant v = qvariant_cast<QDeclarativeScript::Variant>(value); - if (v.isScript()) { - ds << propName; - ds << int(type); - ds << v.asScript(); - } else { - error(props.at(ii), QDeclarativeGestureArea::tr("GestureArea: script expected")); - return QByteArray(); - } - } - } - } - - return rv; -} - -void QDeclarativeGestureAreaParser::setCustomData(QObject *object, - const QByteArray &data) -{ - QDeclarativeGestureArea *ga = static_cast<QDeclarativeGestureArea*>(object); - ga->d_func()->data = data; -} - - -void QDeclarativeGestureArea::connectSignals() -{ - Q_D(QDeclarativeGestureArea); - if (!d->componentcomplete) - return; - - QDataStream ds(d->data); - while (!ds.atEnd()) { - QString propName; - ds >> propName; - int gesturetype; - ds >> gesturetype; - QString script; - ds >> script; - QDeclarativeExpression *exp = new QDeclarativeExpression(qmlContext(this), this, script); - d->bindings.insert(Qt::GestureType(gesturetype),exp); - grabGesture(Qt::GestureType(gesturetype)); - } -} - -void QDeclarativeGestureArea::componentComplete() -{ - QDeclarativeItem::componentComplete(); - Q_D(QDeclarativeGestureArea); - d->componentcomplete=true; - connectSignals(); -} - -QGesture *QDeclarativeGestureArea::gesture() const -{ - Q_D(const QDeclarativeGestureArea); - return d->gesture; -} - -bool QDeclarativeGestureArea::sceneEvent(QEvent *event) -{ - Q_D(QDeclarativeGestureArea); - if (event->type() == QEvent::Gesture) - return d->gestureEvent(static_cast<QGestureEvent*>(event)); - return QDeclarativeItem::sceneEvent(event); -} - -bool QDeclarativeGestureAreaPrivate::gestureEvent(QGestureEvent *event) -{ - bool accept = true; - for (Bindings::Iterator it = bindings.begin(); it != bindings.end(); ++it) { - if ((gesture = event->gesture(it.key()))) { - QDeclarativeExpression *expr = it.value(); - expr->evaluate(); - if (expr->hasError()) - qmlInfo(q_func()) << expr->error(); - event->setAccepted(true); // XXX only if value returns true? - } - } - return accept; -} - -QT_END_NAMESPACE - -#endif // QT_NO_GESTURES diff --git a/src/imports/gestures/qdeclarativegesturearea_p.h b/src/imports/gestures/qdeclarativegesturearea_p.h deleted file mode 100644 index 969997d702..0000000000 --- a/src/imports/gestures/qdeclarativegesturearea_p.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEGESTUREAREA_H -#define QDECLARATIVEGESTUREAREA_H - -#include <qdeclarativeitem.h> -#include <qdeclarativescriptstring.h> -#include <private/qdeclarativecustomparser_p.h> - -#include <QtCore/qobject.h> -#include <QtCore/qstring.h> -#include <QtWidgets/qgesture.h> - -#ifndef QT_NO_GESTURES - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeBoundSignal; -class QDeclarativeContext; -class QDeclarativeGestureAreaPrivate; -class QDeclarativeGestureArea : public QDeclarativeItem -{ - Q_OBJECT - - Q_PROPERTY(QGesture *gesture READ gesture) - -public: - QDeclarativeGestureArea(QDeclarativeItem *parent=0); - ~QDeclarativeGestureArea(); - - QGesture *gesture() const; - -protected: - bool sceneEvent(QEvent *event); - -private: - void connectSignals(); - void componentComplete(); - friend class QDeclarativeGestureAreaParser; - - Q_DISABLE_COPY(QDeclarativeGestureArea) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeGestureArea) -}; - -class QDeclarativeGestureAreaParser : public QDeclarativeCustomParser -{ -public: - virtual QByteArray compile(const QList<QDeclarativeCustomParserProperty> &); - virtual void setCustomData(QObject *, const QByteArray &); -}; - - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeGestureArea) - -QT_END_HEADER - -#endif // QT_NO_GESTURES - -#endif diff --git a/src/imports/gestures/qmldir b/src/imports/gestures/qmldir deleted file mode 100644 index 2a31920a40..0000000000 --- a/src/imports/gestures/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin qmlgesturesplugin diff --git a/src/imports/imports.pro b/src/imports/imports.pro index ea8e78d01e..241ea18081 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -1,5 +1,5 @@ TEMPLATE = subdirs -SUBDIRS += qtquick2 qtquick1 qt47 folderlistmodel particles gestures etcprovider localstorage +SUBDIRS += qtquick2 folderlistmodel etcprovider localstorage contains(QT_CONFIG, qmltest): SUBDIRS += testlib -contains(QT_CONFIG, xmlpatterns) : SUBDIRS += xmllistmodel
\ No newline at end of file +contains(QT_CONFIG, xmlpatterns) : SUBDIRS += xmllistmodel diff --git a/src/imports/particles/V1/qdeclarativeparticles.cpp b/src/imports/particles/V1/qdeclarativeparticles.cpp deleted file mode 100644 index 88cb5941e7..0000000000 --- a/src/imports/particles/V1/qdeclarativeparticles.cpp +++ /dev/null @@ -1,1296 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qdeclarativeparticles_p.h" - -#include <qdeclarativeinfo.h> -#include <QtQuick1/private/qdeclarativeitem_p.h> - -#include <QtQuick1/private/qdeclarativepixmapcache_p.h> -#include <QtCore/QAbstractAnimation> - -#include <QPainter> -#include <QtWidgets/qdrawutil.h> -#include <QVarLengthArray> - -#include <stdlib.h> -#include <math.h> - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#define M_PI_2 (M_PI / 2.) -#endif -#ifndef INT_MAX -#define INT_MAX 2147483647 -#endif - -QT_BEGIN_NAMESPACE -#define PI_SQR 9.8696044 -// parabolic approximation -inline qreal fastSin(qreal theta) -{ - const qreal b = 4 / M_PI; - const qreal c = -4 / PI_SQR; - - qreal y = b * theta + c * theta * qAbs(theta); - return y; -} - -inline qreal fastCos(qreal theta) -{ - theta += M_PI_2; - if (theta > M_PI) - theta -= 2 * M_PI; - - return fastSin(theta); -} - -class QDeclarativeParticle -{ -public: - QDeclarativeParticle(int time) : lifeSpan(1000), fadeOutAge(800) - , opacity(0), birthTime(time), x_velocity(0), y_velocity(0) - , state(FadeIn), data(0) - { - } - - int lifeSpan; - int fadeOutAge; - qreal x; - qreal y; - qreal opacity; - int birthTime; - qreal x_velocity; - qreal y_velocity; - enum State { FadeIn, Solid, FadeOut }; - State state; - void *data; -}; - -//--------------------------------------------------------------------------- - -/*! - \class QDeclarativeParticleMotion - \ingroup group_effects - \brief The QDeclarativeParticleMotion class is the base class for particle motion. - \internal - - This class causes the particles to remain static. -*/ - -/*! - Constructs a QDeclarativeParticleMotion with parent object \a parent. -*/ -QDeclarativeParticleMotion::QDeclarativeParticleMotion(QObject *parent) : - QObject(parent) -{ -} - -/*! - Move the \a particle to its new position. \a interval is the number of - milliseconds elapsed since it was last moved. -*/ -void QDeclarativeParticleMotion::advance(QDeclarativeParticle &particle, int interval) -{ - Q_UNUSED(particle); - Q_UNUSED(interval); -} - -/*! - The \a particle has just been created. Some motion strategies require - additional state information. This can be allocated by this function. -*/ -void QDeclarativeParticleMotion::created(QDeclarativeParticle &particle) -{ - Q_UNUSED(particle); -} - -/*! - The \a particle is about to be destroyed. Any additional memory - that has been allocated for the particle should be freed. -*/ -void QDeclarativeParticleMotion::destroy(QDeclarativeParticle &particle) -{ - Q_UNUSED(particle); -} - -/*! - \qmlclass ParticleMotionLinear QDeclarativeParticleMotionLinear - \ingroup qml-particle-elements - \since 4.7 - \brief The ParticleMotionLinear object moves particles linearly. - - \sa Particles - - This is the default motion, and moves the particles according to the - properties specified in the Particles element. - - It has no further properties. -*/ -void QDeclarativeParticleMotionLinear::advance(QDeclarativeParticle &p, int interval) -{ - p.x += interval * p.x_velocity; - p.y += interval * p.y_velocity; -} - -/*! - \qmlclass ParticleMotionGravity QDeclarativeParticleMotionGravity - \ingroup qml-particle-elements - \since 4.7 - \brief The ParticleMotionGravity object moves particles towards a point. - - This motion attracts the particles to the specified point with the specified acceleration. - To mimic earth gravity, set yattractor to -6360000 and acceleration to 9.8. - - The defaults are all 0, not earth gravity, and so no motion will occur without setting - at least the acceleration property. - - - \sa Particles -*/ - -/*! - \qmlproperty real ParticleMotionGravity::xattractor - \qmlproperty real ParticleMotionGravity::yattractor - These properties hold the x and y coordinates of the point attracting the particles. -*/ - -/*! - \qmlproperty real ParticleMotionGravity::acceleration - This property holds the acceleration to apply to the particles. -*/ - -/*! - \property QDeclarativeParticleMotionGravity::xattractor - \brief the x coordinate of the point attracting the particles. -*/ - -/*! - \property QDeclarativeParticleMotionGravity::yattractor - \brief the y coordinate of the point attracting the particles. -*/ - -/*! - \property QDeclarativeParticleMotionGravity::acceleration - \brief the acceleration to apply to the particles. -*/ - -void QDeclarativeParticleMotionGravity::setXAttractor(qreal x) -{ - if (qFuzzyCompare(x, _xAttr)) - return; - _xAttr = x; - emit xattractorChanged(); -} - -void QDeclarativeParticleMotionGravity::setYAttractor(qreal y) -{ - if (qFuzzyCompare(y, _yAttr)) - return; - _yAttr = y; - emit yattractorChanged(); -} - -void QDeclarativeParticleMotionGravity::setAcceleration(qreal accel) -{ - qreal scaledAccel = accel/1000000.0; - if (qFuzzyCompare(scaledAccel, _accel)) - return; - _accel = scaledAccel; - emit accelerationChanged(); -} - -void QDeclarativeParticleMotionGravity::advance(QDeclarativeParticle &p, int interval) -{ - qreal xdiff = _xAttr - p.x; - qreal ydiff = _yAttr - p.y; - qreal absXdiff = qAbs(xdiff); - qreal absYdiff = qAbs(ydiff); - - qreal xcomp = xdiff / (absXdiff + absYdiff); - qreal ycomp = ydiff / (absXdiff + absYdiff); - - p.x_velocity += xcomp * _accel * interval; - p.y_velocity += ycomp * _accel * interval; - - p.x += interval * p.x_velocity; - p.y += interval * p.y_velocity; -} - -/*! - \qmlclass ParticleMotionWander QDeclarativeParticleMotionWander - \ingroup qml-particle-elements - \since 4.7 - \brief The ParticleMotionWander object moves particles in a somewhat random fashion. - - The particles will continue roughly in the original direction, however will randomly - drift to each side. - - The code below produces an effect similar to falling snow. - - \qml -Rectangle { - width: 240 - height: 320 - color: "black" - - Particles { - y: 0 - width: parent.width - height: 30 - source: "star.png" - lifeSpan: 5000 - count: 50 - angle: 70 - angleDeviation: 36 - velocity: 30 - velocityDeviation: 10 - ParticleMotionWander { - xvariance: 30 - pace: 100 - } - } -} - \endqml - - \sa Particles -*/ - -/*! - \qmlproperty real ParticleMotionWander::xvariance - \qmlproperty real ParticleMotionWander::yvariance - - These properties set the amount to wander in the x and y directions. -*/ - -/*! - \qmlproperty real ParticleMotionWander::pace - This property holds how quickly the paricles will move from side to side. -*/ - -void QDeclarativeParticleMotionWander::advance(QDeclarativeParticle &p, int interval) -{ - if (!particles) - particles = qobject_cast<QDeclarativeParticles*>(parent()); - if (particles) { - Data *d = (Data*)p.data; - if (_xvariance != 0.) { - qreal xdiff = p.x_velocity - d->x_targetV; - if ((xdiff > d->x_peak && d->x_var > 0.0) || (xdiff < -d->x_peak && d->x_var < 0.0)) { - d->x_var = -d->x_var; - d->x_peak = _xvariance + _xvariance * qreal(qrand()) / RAND_MAX; - } - p.x_velocity += d->x_var * interval; - } - p.x += interval * p.x_velocity; - - if (_yvariance != 0.) { - qreal ydiff = p.y_velocity - d->y_targetV; - if ((ydiff > d->y_peak && d->y_var > 0.0) || (ydiff < -d->y_peak && d->y_var < 0.0)) { - d->y_var = -d->y_var; - d->y_peak = _yvariance + _yvariance * qreal(qrand()) / RAND_MAX; - } - p.y_velocity += d->y_var * interval; - } - p.y += interval * p.y_velocity; - } -} - -void QDeclarativeParticleMotionWander::created(QDeclarativeParticle &p) -{ - if (!p.data) { - Data *d = new Data; - p.data = (void*)d; - d->x_targetV = p.x_velocity; - d->y_targetV = p.y_velocity; - d->x_peak = _xvariance; - d->y_peak = _yvariance; - d->x_var = _pace * qreal(qrand()) / RAND_MAX / 1000.0; - d->y_var = _pace * qreal(qrand()) / RAND_MAX / 1000.0; - } -} - -void QDeclarativeParticleMotionWander::destroy(QDeclarativeParticle &p) -{ - if (p.data) - delete (Data*)p.data; -} - -void QDeclarativeParticleMotionWander::setXVariance(qreal var) -{ - qreal scaledVar = var / 1000.0; - if (qFuzzyCompare(scaledVar, _xvariance)) - return; - _xvariance = scaledVar; - emit xvarianceChanged(); -} - -void QDeclarativeParticleMotionWander::setYVariance(qreal var) -{ - qreal scaledVar = var / 1000.0; - if (qFuzzyCompare(scaledVar, _yvariance)) - return; - _yvariance = scaledVar; - emit yvarianceChanged(); -} - -void QDeclarativeParticleMotionWander::setPace(qreal pace) -{ - qreal scaledPace = pace / 1000.0; - if (qFuzzyCompare(scaledPace, _pace)) - return; - _pace = scaledPace; - emit paceChanged(); -} - -//--------------------------------------------------------------------------- -class QDeclarativeParticlesPainter : public QDeclarativeItem -{ -public: - QDeclarativeParticlesPainter(QDeclarativeParticlesPrivate *p, QDeclarativeItem* parent) - : QDeclarativeItem(parent), d(p) - { - setFlag(QGraphicsItem::ItemHasNoContents, false); - maxX = minX = maxY = minY = 0; - } - - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); - - void updateSize(); - - qreal maxX; - qreal minX; - qreal maxY; - qreal minY; - QDeclarativeParticlesPrivate* d; -}; - -//an animation that just gives a tick -template<class T, void (T::*method)(int)> -class TickAnimationProxy : public QAbstractAnimation -{ -public: - TickAnimationProxy(T *p, QObject *parent = 0) : QAbstractAnimation(parent), m_p(p) {} - virtual int duration() const { return -1; } -protected: - virtual void updateCurrentTime(int msec) { (m_p->*method)(msec); } - -private: - T *m_p; -}; - -//--------------------------------------------------------------------------- -class QDeclarativeParticlesPrivate : public QDeclarativeItemPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeParticles) -public: - QDeclarativeParticlesPrivate() - : count(1), emissionRate(-1), emissionVariance(0.5), lifeSpan(1000) - , lifeSpanDev(1000), fadeInDur(200), fadeOutDur(300) - , angle(0), angleDev(0), velocity(0), velocityDev(0), emissionCarry(0.) - , addParticleTime(0), addParticleCount(0), lastAdvTime(0) - , motion(0), clock(this) - { - } - - ~QDeclarativeParticlesPrivate() - { - } - - void init() - { - Q_Q(QDeclarativeParticles); - paintItem = new QDeclarativeParticlesPainter(this, q); - } - - void tick(int time); - void createParticle(int time); - void updateOpacity(QDeclarativeParticle &p, int age); - - QUrl url; - QDeclarative1Pixmap image; - int count; - int emissionRate; - qreal emissionVariance; - int lifeSpan; - int lifeSpanDev; - int fadeInDur; - int fadeOutDur; - qreal angle; - qreal angleDev; - qreal velocity; - qreal velocityDev; - qreal emissionCarry; - int addParticleTime; - int addParticleCount; - int lastAdvTime; - QDeclarativeParticleMotion *motion; - QDeclarativeParticlesPainter *paintItem; - - - QList<QPair<int, int> > bursts;//countLeft, emissionRate pairs - QList<QDeclarativeParticle> particles; - TickAnimationProxy<QDeclarativeParticlesPrivate, &QDeclarativeParticlesPrivate::tick> clock; - -}; - -void QDeclarativeParticlesPrivate::tick(int time) -{ - Q_Q(QDeclarativeParticles); - if (!motion) - motion = new QDeclarativeParticleMotionLinear(q); - - int oldCount = particles.count(); - int removed = 0; - int interval = time - lastAdvTime; - for (int i = 0; i < particles.count(); ) { - QDeclarativeParticle &particle = particles[i]; - int age = time - particle.birthTime; - if (age >= particle.lifeSpan) { - QDeclarativeParticle part = particles.takeAt(i); - motion->destroy(part); - ++removed; - } else { - updateOpacity(particle, age); - motion->advance(particle, interval); - ++i; - } - } - - if(emissionRate == -1)//Otherwise leave emission to the emission rate - while(removed-- && ((count == -1) || particles.count() < count)) - createParticle(time); - - if (!addParticleTime) - addParticleTime = time; - - //Possibly emit new particles - if (((count == -1) || particles.count() < count) && emissionRate - && !(count==-1 && emissionRate==-1)) { - int emissionCount = -1; - if (emissionRate != -1){ - qreal variance = 1.; - if (emissionVariance > 0.){ - variance += (qreal(qrand())/RAND_MAX) * emissionVariance * (qrand()%2?-1.:1.); - } - qreal emission = emissionRate * (qreal(interval)/1000.); - emission = emission * variance + emissionCarry; - double tmpDbl; - emissionCarry = modf(emission, &tmpDbl); - emissionCount = (int)tmpDbl; - emissionCount = qMax(0,emissionCount); - } - while(((count == -1) || particles.count() < count) && - (emissionRate==-1 || emissionCount--)) - createParticle(time); - } - - //Deal with emissions from requested bursts - for(int i=0; i<bursts.size(); i++){ - int emission = 0; - if(bursts[i].second == -1){ - emission = bursts[i].first; - }else{ - qreal variance = 1.; - if (emissionVariance > 0.){ - variance += (qreal(qrand())/RAND_MAX) * emissionVariance * (qrand()%2?-1.:1.); - } - qreal workingEmission = bursts[i].second * (qreal(interval)/1000.); - workingEmission *= variance; - emission = (int)workingEmission; - emission = qMax(emission, 0); - } - emission = qMin(emission, bursts[i].first); - bursts[i].first -= emission; - while(emission--) - createParticle(time); - } - for(int i=bursts.size()-1; i>=0; i--) - if(bursts[i].first <= 0) - bursts.removeAt(i); - - lastAdvTime = time; - paintItem->updateSize(); - paintItem->update(); - if (!(oldCount || particles.count()) && (!count || !emissionRate) && bursts.isEmpty()) { - lastAdvTime = 0; - clock.stop(); - } -} - -void QDeclarativeParticlesPrivate::createParticle(int time) -{ - Q_Q(QDeclarativeParticles); - QDeclarativeParticle p(time); - p.x = q->x() + q->width() * qreal(qrand()) / RAND_MAX - image.width()/2.0; - p.y = q->y() + q->height() * qreal(qrand()) / RAND_MAX - image.height()/2.0; - p.lifeSpan = lifeSpan; - if (lifeSpanDev) - p.lifeSpan += int(lifeSpanDev/2 - lifeSpanDev * qreal(qrand()) / RAND_MAX); - p.fadeOutAge = p.lifeSpan - fadeOutDur; - if (fadeInDur == 0.) { - p.state= QDeclarativeParticle::Solid; - p.opacity = 1.0; - } - qreal a = angle; - if (angleDev) - a += angleDev/2 - angleDev * qreal(qrand()) / RAND_MAX; - if (a > M_PI) - a = a - 2 * M_PI; - qreal v = velocity; - if (velocityDev) - v += velocityDev/2 - velocityDev * qreal(qrand()) / RAND_MAX; - p.x_velocity = v * fastCos(a); - p.y_velocity = v * fastSin(a); - particles.append(p); - motion->created(particles.last()); -} - -void QDeclarativeParticlesPrivate::updateOpacity(QDeclarativeParticle &p, int age) -{ - switch (p.state) { - case QDeclarativeParticle::FadeIn: - if (age <= fadeInDur) { - p.opacity = qreal(age) / fadeInDur; - break; - } else { - p.opacity = 1.0; - p.state = QDeclarativeParticle::Solid; - // Fall through - } - case QDeclarativeParticle::Solid: - if (age <= p.fadeOutAge) { - break; - } else { - p.state = QDeclarativeParticle::FadeOut; - // Fall through - } - case QDeclarativeParticle::FadeOut: - p.opacity = qreal(p.lifeSpan - age) / fadeOutDur; - break; - } -} - -/*! - \qmlclass Particles QDeclarativeParticles - \ingroup qml-particle-elements - \since 4.7 - \brief The Particles object generates and moves particles. - \inherits Item - - Particles are available in the \bold{Qt.labs.particles 1.0} module. - \e {Elements in the Qt.labs module are not guaranteed to remain compatible - in future versions.} - - This element provides preliminary support for particles in QML, - and may be heavily changed or removed in later versions. - - The particles created by this object cannot be dealt with - directly, they can only be controlled through the parameters of - the Particles object. The particles are all the same pixmap, - specified by the user. - - The particles are painted relative to the parent of the Particles - object. Moving the Particles object will not move the particles - already emitted. - - The below example creates two differently behaving particle - sources. The top one has particles falling from the top like - snow, the lower one has particles expelled up like a fountain. - - \qml -import QtQuick 1.0 -import Qt.labs.particles 1.0 - -Rectangle { - width: 240 - height: 320 - color: "black" - Particles { - y: 0 - width: parent.width - height: 30 - source: "star.png" - lifeSpan: 5000 - count: 50 - angle: 70 - angleDeviation: 36 - velocity: 30 - velocityDeviation: 10 - ParticleMotionWander { - xvariance: 30 - pace: 100 - } - } - Particles { - y: 300 - x: 120 - width: 1 - height: 1 - source: "star.png" - lifeSpan: 5000 - count: 200 - angle: 270 - angleDeviation: 45 - velocity: 50 - velocityDeviation: 30 - ParticleMotionGravity { - yattractor: 1000 - xattractor: 0 - acceleration: 25 - } - } -} - \endqml - \image particles.gif -*/ - -QDeclarativeParticles::QDeclarativeParticles(QDeclarativeItem *parent) - : QDeclarativeItem(*(new QDeclarativeParticlesPrivate), parent) -{ - Q_D(QDeclarativeParticles); - d->init(); -} - -QDeclarativeParticles::~QDeclarativeParticles() -{ -} - -/*! - \qmlproperty string Particles::source - This property holds the URL of the particle image. -*/ - -/*! - \property QDeclarativeParticles::source - \brief the URL of the particle image. -*/ -QUrl QDeclarativeParticles::source() const -{ - Q_D(const QDeclarativeParticles); - return d->url; -} - -void QDeclarativeParticles::imageLoaded() -{ - Q_D(QDeclarativeParticles); - if (d->image.isError()) - qmlInfo(this) << d->image.error(); - d->paintItem->updateSize(); - d->paintItem->update(); -} - -void QDeclarativeParticles::setSource(const QUrl &name) -{ - Q_D(QDeclarativeParticles); - - if ((d->url.isEmpty() == name.isEmpty()) && name == d->url) - return; - - if (name.isEmpty()) { - d->url = name; - d->image.clear(this); - d->paintItem->updateSize(); - d->paintItem->update(); - } else { - d->url = name; - Q_ASSERT(!name.isRelative()); - d->image.load(qmlEngine(this), d->url); - if (d->image.isLoading()) { - d->image.connectFinished(this, SLOT(imageLoaded())); - } else { - if (d->image.isError()) - qmlInfo(this) << d->image.error(); - //### unify with imageLoaded - d->paintItem->updateSize(); - d->paintItem->update(); - } - } - emit sourceChanged(); -} - -/*! - \qmlproperty int Particles::count - This property holds the maximum number of particles - - The particles element emits particles until it has count active - particles. When this number is reached, new particles are not emitted until - some of the current particles reach the end of their lifespan. - - If count is -1 then there is no maximum number of active particles, and - particles will be constantly emitted at the rate specified by emissionRate. - - The default value for count is 1. - - If both count and emissionRate are set to -1, nothing will be emitted. - -*/ - -/*! - \property QDeclarativeParticles::count - \brief the maximum number of particles -*/ -int QDeclarativeParticles::count() const -{ - Q_D(const QDeclarativeParticles); - return d->count; -} - -void QDeclarativeParticles::setCount(int cnt) -{ - Q_D(QDeclarativeParticles); - if (cnt == d->count) - return; - - int oldCount = d->count; - d->count = cnt; - d->addParticleTime = 0; - d->addParticleCount = d->particles.count(); - if (!oldCount && d->clock.state() != QAbstractAnimation::Running && d->count && d->emissionRate) { - d->clock.start(); - } - d->paintItem->updateSize(); - d->paintItem->update(); - emit countChanged(); -} - - -/*! - \qmlproperty int Particles::emissionRate - This property holds the target number of particles to emit every second. - - The particles element will emit up to emissionRate particles every - second. Fewer particles may be emitted per second if the maximum number of - particles has been reached. - - If emissionRate is set to -1 there is no limit to the number of - particles emitted per second, and particles will be instantly emitted to - reach the maximum number of particles specified by count. - - The default value for emissionRate is -1. - - If both count and emissionRate are set to -1, nothing will be emitted. -*/ - -/*! - \property QDeclarativeParticles::emissionRate - \brief the emission rate of particles -*/ -int QDeclarativeParticles::emissionRate() const -{ - Q_D(const QDeclarativeParticles); - return d->emissionRate; -} -void QDeclarativeParticles::setEmissionRate(int er) -{ - Q_D(QDeclarativeParticles); - if(er == d->emissionRate) - return; - d->emissionRate = er; - if (d->clock.state() != QAbstractAnimation::Running && d->count && d->emissionRate) { - d->clock.start(); - } - emit emissionRateChanged(); -} - -/*! - \qmlproperty real Particles::emissionVariance - This property holds how inconsistent the rate of particle emissions are. - It is a number between 0 (no variance) and 1 (some variance). - - The expected number of particles emitted per second is emissionRate. If - emissionVariance is 0 then particles will be emitted consistently throughout - each second to reach that number. If emissionVariance is greater than 0 the - rate of particle emission will vary randomly throughout the second, with the - consequence that the actual number of particles emitted in one second will - vary randomly as well. - - emissionVariance is the maximum deviation from emitting - emissionRate particles per second. An emissionVariance of 0 means you should - get exactly emissionRate particles emitted per second, - and an emissionVariance of 1 means you will get between zero and two times - emissionRate particles per second, but you should get emissionRate particles - per second on average. - - Note that even with an emissionVariance of 0 there may be some variance due - to performance and hardware constraints. - - The default value of emissionVariance is 0.5 -*/ - -/*! - \property QDeclarativeParticles::emissionVariance - \brief how much the particle emission amounts vary per tick -*/ - -qreal QDeclarativeParticles::emissionVariance() const -{ - Q_D(const QDeclarativeParticles); - return d->emissionVariance; -} - -void QDeclarativeParticles::setEmissionVariance(qreal ev) -{ - Q_D(QDeclarativeParticles); - if(d->emissionVariance == ev) - return; - d->emissionVariance = ev; - emit emissionVarianceChanged(); -} - -/*! - \qmlproperty int Particles::lifeSpan - \qmlproperty int Particles::lifeSpanDeviation - - These properties describe the life span of each particle. - - The default lifespan for a particle is 1000ms. - - lifeSpanDeviation randomly varies the lifeSpan up to the specified variation. For - example, the following creates particles whose lifeSpan will vary - from 150ms to 250ms: - - \qml -Particles { - source: "star.png" - lifeSpan: 200 - lifeSpanDeviation: 100 -} - \endqml -*/ - -/*! - \property QDeclarativeParticles::lifeSpan - \brief the life span of each particle. - - Default value is 1000ms. - - \sa QDeclarativeParticles::lifeSpanDeviation -*/ -int QDeclarativeParticles::lifeSpan() const -{ - Q_D(const QDeclarativeParticles); - return d->lifeSpan; -} - -void QDeclarativeParticles::setLifeSpan(int ls) -{ - Q_D(QDeclarativeParticles); - if(d->lifeSpan == ls) - return; - d->lifeSpan = ls; - emit lifeSpanChanged(); -} - -/*! - \property QDeclarativeParticles::lifeSpanDeviation - \brief the maximum possible deviation from the set lifeSpan. - - Randomly varies the lifeSpan up to the specified variation. For - example, the following creates particles whose lifeSpan will vary - from 150ms to 250ms: - -\qml -Particles { - source: "star.png" - lifeSpan: 200 - lifeSpanDeviation: 100 -} -\endqml - - \sa QDeclarativeParticles::lifeSpan -*/ -int QDeclarativeParticles::lifeSpanDeviation() const -{ - Q_D(const QDeclarativeParticles); - return d->lifeSpanDev; -} - -void QDeclarativeParticles::setLifeSpanDeviation(int dev) -{ - Q_D(QDeclarativeParticles); - if(d->lifeSpanDev == dev) - return; - d->lifeSpanDev = dev; - emit lifeSpanDeviationChanged(); -} - -/*! - \qmlproperty int Particles::fadeInDuration - \qmlproperty int Particles::fadeOutDuration - These properties hold the time taken to fade the particles in and out. - - By default fade in is 200ms and fade out is 300ms. -*/ - -/*! - \property QDeclarativeParticles::fadeInDuration - \brief the time taken to fade in the particles. - - Default value is 200ms. -*/ -int QDeclarativeParticles::fadeInDuration() const -{ - Q_D(const QDeclarativeParticles); - return d->fadeInDur; -} - -void QDeclarativeParticles::setFadeInDuration(int dur) -{ - Q_D(QDeclarativeParticles); - if (dur < 0.0 || dur == d->fadeInDur) - return; - d->fadeInDur = dur; - emit fadeInDurationChanged(); -} - -/*! - \property QDeclarativeParticles::fadeOutDuration - \brief the time taken to fade out the particles. - - Default value is 300ms. -*/ -int QDeclarativeParticles::fadeOutDuration() const -{ - Q_D(const QDeclarativeParticles); - return d->fadeOutDur; -} - -void QDeclarativeParticles::setFadeOutDuration(int dur) -{ - Q_D(QDeclarativeParticles); - if (dur < 0.0 || d->fadeOutDur == dur) - return; - d->fadeOutDur = dur; - emit fadeOutDurationChanged(); -} - -/*! - \qmlproperty real Particles::angle - \qmlproperty real Particles::angleDeviation - - These properties control particle direction. - - angleDeviation randomly varies the direction up to the specified variation. For - example, the following creates particles whose initial direction will - vary from 15 degrees to 105 degrees: - - \qml -Particles { - source: "star.png" - angle: 60 - angleDeviation: 90 -} - \endqml -*/ - -/*! - \property QDeclarativeParticles::angle - \brief the initial angle of direction. - - \sa QDeclarativeParticles::angleDeviation -*/ -qreal QDeclarativeParticles::angle() const -{ - Q_D(const QDeclarativeParticles); - return d->angle * 180.0 / M_PI; -} - -void QDeclarativeParticles::setAngle(qreal angle) -{ - Q_D(QDeclarativeParticles); - qreal radAngle = angle * M_PI / 180.0; - if(radAngle == d->angle) - return; - d->angle = radAngle; - emit angleChanged(); -} - -/*! - \property QDeclarativeParticles::angleDeviation - \brief the maximum possible deviation from the set angle. - - Randomly varies the direction up to the specified variation. For - example, the following creates particles whose initial direction will - vary from 15 degrees to 105 degrees: - -\qml -Particles { - source: "star.png" - angle: 60 - angleDeviation: 90 -} -\endqml - - \sa QDeclarativeParticles::angle -*/ -qreal QDeclarativeParticles::angleDeviation() const -{ - Q_D(const QDeclarativeParticles); - return d->angleDev * 180.0 / M_PI; -} - -void QDeclarativeParticles::setAngleDeviation(qreal dev) -{ - Q_D(QDeclarativeParticles); - qreal radDev = dev * M_PI / 180.0; - if(radDev == d->angleDev) - return; - d->angleDev = radDev; - emit angleDeviationChanged(); -} - -/*! - \qmlproperty real Particles::velocity - \qmlproperty real Particles::velocityDeviation - - These properties control the velocity of the particles. - - velocityDeviation randomly varies the velocity up to the specified variation. For - example, the following creates particles whose initial velocity will - vary from 40 to 60. - - \qml -Particles { - source: "star.png" - velocity: 50 - velocityDeviation: 20 -} - \endqml -*/ - -/*! - \property QDeclarativeParticles::velocity - \brief the initial velocity of the particles. - - \sa QDeclarativeParticles::velocityDeviation -*/ -qreal QDeclarativeParticles::velocity() const -{ - Q_D(const QDeclarativeParticles); - return d->velocity * 1000.0; -} - -void QDeclarativeParticles::setVelocity(qreal velocity) -{ - Q_D(QDeclarativeParticles); - qreal realVel = velocity / 1000.0; - if(realVel == d->velocity) - return; - d->velocity = realVel; - emit velocityChanged(); -} - -/*! - \property QDeclarativeParticles::velocityDeviation - \brief the maximum possible deviation from the set velocity. - - Randomly varies the velocity up to the specified variation. For - example, the following creates particles whose initial velocity will - vary from 40 to 60. - -\qml -Particles { - source: "star.png" - velocity: 50 - velocityDeviation: 20 -} -\endqml - - \sa QDeclarativeParticles::velocity -*/ -qreal QDeclarativeParticles::velocityDeviation() const -{ - Q_D(const QDeclarativeParticles); - return d->velocityDev * 1000.0; -} - -void QDeclarativeParticles::setVelocityDeviation(qreal velocity) -{ - Q_D(QDeclarativeParticles); - qreal realDev = velocity / 1000.0; - if(realDev == d->velocityDev) - return; - d->velocityDev = realDev; - emit velocityDeviationChanged(); -} - -/*! - \qmlproperty ParticleMotion Particles::motion - This property sets the type of motion to apply to the particles. - - When a particle is created it will have an initial direction and velocity. - The motion of the particle during its lifeSpan is then influenced by the - motion property. - - Default motion is ParticleMotionLinear. -*/ - -/*! - \property QDeclarativeParticles::motion - \brief sets the type of motion to apply to the particles. - - When a particle is created it will have an initial direction and velocity. - The motion of the particle during its lifeSpan is then influenced by the - motion property. - - Default motion is QDeclarativeParticleMotionLinear. -*/ -QDeclarativeParticleMotion *QDeclarativeParticles::motion() const -{ - Q_D(const QDeclarativeParticles); - return d->motion; -} - -void QDeclarativeParticles::setMotion(QDeclarativeParticleMotion *motion) -{ - Q_D(QDeclarativeParticles); - if (motion == d->motion) - return; - d->motion = motion; - emit motionChanged(); -} - -/*! - \qmlmethod Particles::burst(int count, int emissionRate) - - Initiates a burst of particles. - - This method takes two arguments. The first argument is the number - of particles to emit and the second argument is the emissionRate for the - burst. If the second argument is omitted, it is treated as -1. The burst - of particles has a separate emissionRate and count to the normal emission of - particles. The burst uses the same values as normal emission for all other - properties, including emissionVariance. - - The normal emission of particles will continue during the burst, however - the particles created by the burst count towards the maximum number used by - normal emission. To avoid this behavior, use two Particles elements. - -*/ -void QDeclarativeParticles::burst(int count, int emissionRate) -{ - Q_D(QDeclarativeParticles); - d->bursts << qMakePair(count, emissionRate); - if (d->clock.state() != QAbstractAnimation::Running) - d->clock.start(); -} - -void QDeclarativeParticlesPainter::updateSize() -{ - if (!d->componentComplete) - return; - - const int parentX = parentItem()->x(); - const int parentY = parentItem()->y(); - for (int i = 0; i < d->particles.count(); ++i) { - const QDeclarativeParticle &particle = d->particles.at(i); - if(particle.x > maxX) - maxX = particle.x; - if(particle.x < minX) - minX = particle.x; - if(particle.y > maxY) - maxY = particle.y; - if(particle.y < minY) - minY = particle.y; - } - - int myWidth = (int)(maxX-minX+0.5)+d->image.width(); - int myX = (int)(minX - parentX); - int myHeight = (int)(maxY-minY+0.5)+d->image.height(); - int myY = (int)(minY - parentY); - setWidth(myWidth); - setHeight(myHeight); - setX(myX); - setY(myY); -} - -void QDeclarativeParticles::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) -{ - Q_UNUSED(p); - //painting is done by the ParticlesPainter, so it can have the right size -} - -void QDeclarativeParticlesPainter::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) -{ - if (d->image.isNull() || d->particles.isEmpty()) - return; - - const int myX = x() + parentItem()->x(); - const int myY = y() + parentItem()->y(); - - QVarLengthArray<QPainter::PixmapFragment, 256> pixmapData; - pixmapData.resize(d->particles.count()); - - const QRectF sourceRect = d->image.rect(); - qreal halfPWidth = sourceRect.width()/2.; - qreal halfPHeight = sourceRect.height()/2.; - for (int i = 0; i < d->particles.count(); ++i) { - const QDeclarativeParticle &particle = d->particles.at(i); - pixmapData[i].x = particle.x - myX + halfPWidth; - pixmapData[i].y = particle.y - myY + halfPHeight; - pixmapData[i].opacity = particle.opacity; - - //these never change - pixmapData[i].rotation = 0; - pixmapData[i].scaleX = 1; - pixmapData[i].scaleY = 1; - pixmapData[i].sourceLeft = sourceRect.left(); - pixmapData[i].sourceTop = sourceRect.top(); - pixmapData[i].width = sourceRect.width(); - pixmapData[i].height = sourceRect.height(); - } - p->drawPixmapFragments(pixmapData.data(), d->particles.count(), d->image); -} - -void QDeclarativeParticles::componentComplete() -{ - Q_D(QDeclarativeParticles); - QDeclarativeItem::componentComplete(); - if (d->count && d->emissionRate) { - d->paintItem->updateSize(); - d->clock.start(); - } - if (d->lifeSpanDev > d->lifeSpan) - d->lifeSpanDev = d->lifeSpan; -} - -QT_END_NAMESPACE diff --git a/src/imports/particles/V1/qdeclarativeparticles_p.h b/src/imports/particles/V1/qdeclarativeparticles_p.h deleted file mode 100644 index c2d076cb3e..0000000000 --- a/src/imports/particles/V1/qdeclarativeparticles_p.h +++ /dev/null @@ -1,257 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEPARTICLES_H -#define QDECLARATIVEPARTICLES_H - -#include <QtQuick1/qdeclarativeitem.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeParticle; -class QDeclarativeParticles; -class QDeclarativeParticleMotion : public QObject -{ - Q_OBJECT -public: - QDeclarativeParticleMotion(QObject *parent=0); - - virtual void advance(QDeclarativeParticle &, int interval); - virtual void created(QDeclarativeParticle &); - virtual void destroy(QDeclarativeParticle &); -}; - -class QDeclarativeParticleMotionLinear : public QDeclarativeParticleMotion -{ - Q_OBJECT -public: - QDeclarativeParticleMotionLinear(QObject *parent=0) - : QDeclarativeParticleMotion(parent) {} - - virtual void advance(QDeclarativeParticle &, int interval); -}; - -class QDeclarativeParticleMotionGravity : public QDeclarativeParticleMotion -{ - Q_OBJECT - - Q_PROPERTY(qreal xattractor READ xAttractor WRITE setXAttractor NOTIFY xattractorChanged) - Q_PROPERTY(qreal yattractor READ yAttractor WRITE setYAttractor NOTIFY yattractorChanged) - Q_PROPERTY(qreal acceleration READ acceleration WRITE setAcceleration NOTIFY accelerationChanged) -public: - QDeclarativeParticleMotionGravity(QObject *parent=0) - : QDeclarativeParticleMotion(parent), _xAttr(0.0), _yAttr(0.0), _accel(0.00005) {} - - qreal xAttractor() const { return _xAttr; } - void setXAttractor(qreal x); - - qreal yAttractor() const { return _yAttr; } - void setYAttractor(qreal y); - - qreal acceleration() const { return _accel * 1000000; } - void setAcceleration(qreal accel); - - virtual void advance(QDeclarativeParticle &, int interval); - -Q_SIGNALS: - void xattractorChanged(); - void yattractorChanged(); - void accelerationChanged(); - -private: - qreal _xAttr; - qreal _yAttr; - qreal _accel; -}; - -class QDeclarativeParticleMotionWander : public QDeclarativeParticleMotion -{ - Q_OBJECT -public: - QDeclarativeParticleMotionWander() - : QDeclarativeParticleMotion(), particles(0), _xvariance(0), _yvariance(0), _pace(100) {} - - virtual void advance(QDeclarativeParticle &, int interval); - virtual void created(QDeclarativeParticle &); - virtual void destroy(QDeclarativeParticle &); - - struct Data { - qreal x_targetV; - qreal y_targetV; - qreal x_peak; - qreal y_peak; - qreal x_var; - qreal y_var; - }; - - Q_PROPERTY(qreal xvariance READ xVariance WRITE setXVariance NOTIFY xvarianceChanged) - qreal xVariance() const { return _xvariance * 1000.0; } - void setXVariance(qreal var); - - Q_PROPERTY(qreal yvariance READ yVariance WRITE setYVariance NOTIFY yvarianceChanged) - qreal yVariance() const { return _yvariance * 1000.0; } - void setYVariance(qreal var); - - Q_PROPERTY(qreal pace READ pace WRITE setPace NOTIFY paceChanged) - qreal pace() const { return _pace * 1000.0; } - void setPace(qreal pace); - -Q_SIGNALS: - void xvarianceChanged(); - void yvarianceChanged(); - void paceChanged(); - -private: - QDeclarativeParticles *particles; - qreal _xvariance; - qreal _yvariance; - qreal _pace; -}; - -class QDeclarativeParticlesPrivate; -class QDeclarativeParticles : public QDeclarativeItem -{ - Q_OBJECT - - Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) - Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged) - Q_PROPERTY(int emissionRate READ emissionRate WRITE setEmissionRate NOTIFY emissionRateChanged) - Q_PROPERTY(qreal emissionVariance READ emissionVariance WRITE setEmissionVariance NOTIFY emissionVarianceChanged) - Q_PROPERTY(int lifeSpan READ lifeSpan WRITE setLifeSpan NOTIFY lifeSpanChanged) - Q_PROPERTY(int lifeSpanDeviation READ lifeSpanDeviation WRITE setLifeSpanDeviation NOTIFY lifeSpanDeviationChanged) - Q_PROPERTY(int fadeInDuration READ fadeInDuration WRITE setFadeInDuration NOTIFY fadeInDurationChanged) - Q_PROPERTY(int fadeOutDuration READ fadeOutDuration WRITE setFadeOutDuration NOTIFY fadeOutDurationChanged) - Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged) - Q_PROPERTY(qreal angleDeviation READ angleDeviation WRITE setAngleDeviation NOTIFY angleDeviationChanged) - Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity NOTIFY velocityChanged) - Q_PROPERTY(qreal velocityDeviation READ velocityDeviation WRITE setVelocityDeviation NOTIFY velocityDeviationChanged) - Q_PROPERTY(QDeclarativeParticleMotion *motion READ motion WRITE setMotion NOTIFY motionChanged) - Q_CLASSINFO("DefaultProperty", "motion") - -public: - QDeclarativeParticles(QDeclarativeItem *parent=0); - ~QDeclarativeParticles(); - - QUrl source() const; - void setSource(const QUrl &); - - int count() const; - void setCount(int cnt); - - int emissionRate() const; - void setEmissionRate(int); - - qreal emissionVariance() const; - void setEmissionVariance(qreal); - - int lifeSpan() const; - void setLifeSpan(int); - - int lifeSpanDeviation() const; - void setLifeSpanDeviation(int); - - int fadeInDuration() const; - void setFadeInDuration(int); - - int fadeOutDuration() const; - void setFadeOutDuration(int); - - qreal angle() const; - void setAngle(qreal); - - qreal angleDeviation() const; - void setAngleDeviation(qreal); - - qreal velocity() const; - void setVelocity(qreal); - - qreal velocityDeviation() const; - void setVelocityDeviation(qreal); - - QDeclarativeParticleMotion *motion() const; - void setMotion(QDeclarativeParticleMotion *); - - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); - -public Q_SLOTS: - void burst(int count, int emissionRate=-1); - -protected: - virtual void componentComplete(); - -Q_SIGNALS: - void sourceChanged(); - void countChanged(); - void emissionRateChanged(); - void emissionVarianceChanged(); - void lifeSpanChanged(); - void lifeSpanDeviationChanged(); - void fadeInDurationChanged(); - void fadeOutDurationChanged(); - void angleChanged(); - void angleDeviationChanged(); - void velocityChanged(); - void velocityDeviationChanged(); - void emittingChanged(); - void motionChanged(); - -private Q_SLOTS: - void imageLoaded(); - -private: - Q_DISABLE_COPY(QDeclarativeParticles) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeParticles) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeParticleMotion) -QML_DECLARE_TYPE(QDeclarativeParticleMotionLinear) -QML_DECLARE_TYPE(QDeclarativeParticleMotionGravity) -QML_DECLARE_TYPE(QDeclarativeParticleMotionWander) -QML_DECLARE_TYPE(QDeclarativeParticles) - -QT_END_HEADER - -#endif diff --git a/src/imports/particles/particles.cpp b/src/imports/particles/particles.cpp deleted file mode 100644 index b6db7fb943..0000000000 --- a/src/imports/particles/particles.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 <QtDeclarative/qdeclarativeextensionplugin.h> -#include <QtDeclarative/qdeclarative.h> - -#include "V1/qdeclarativeparticles_p.h" - -QT_BEGIN_NAMESPACE - -class QParticlesQmlModule : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - virtual void registerTypes(const char *uri) - { - Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.particles")); - qmlRegisterType<QDeclarativeParticleMotion>(uri,1,0,"ParticleMotion"); - qmlRegisterType<QDeclarativeParticleMotionGravity>(uri,1,0,"ParticleMotionGravity"); - qmlRegisterType<QDeclarativeParticleMotionLinear>(uri,1,0,"ParticleMotionLinear"); - qmlRegisterType<QDeclarativeParticleMotionWander>(uri,1,0,"ParticleMotionWander"); - qmlRegisterType<QDeclarativeParticles>(uri,1,0,"Particles"); - } -}; - -QT_END_NAMESPACE - -#include "particles.moc" - -Q_EXPORT_PLUGIN2(qmlparticlesplugin, QT_PREPEND_NAMESPACE(QParticlesQmlModule)); - diff --git a/src/imports/particles/particles.pro b/src/imports/particles/particles.pro deleted file mode 100644 index 3c523aca4a..0000000000 --- a/src/imports/particles/particles.pro +++ /dev/null @@ -1,23 +0,0 @@ -TARGET = qmlparticlesplugin -TARGETPATH = Qt/labs/particles -include(../qimportbase.pri) - -HEADERS += \ - V1/qdeclarativeparticles_p.h - -SOURCES += \ - particles.cpp \ - V1/qdeclarativeparticles.cpp - -QT += declarative opengl core gui declarative-private core-private gui-private qtquick1 qtquick1-private widgets-private v8-private - -OTHER_FILES += \ - qmldir - -DESTDIR = $$QT.declarative.imports/$$TARGETPATH -target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -qmldir.files += $$PWD/qmldir -qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -INSTALLS += target qmldir diff --git a/src/imports/particles/qmldir b/src/imports/particles/qmldir deleted file mode 100644 index aeebd2c99b..0000000000 --- a/src/imports/particles/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin qmlparticlesplugin diff --git a/src/imports/qt47/plugin.cpp b/src/imports/qt47/plugin.cpp deleted file mode 100644 index 92a375a233..0000000000 --- a/src/imports/qt47/plugin.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtDeclarative/qdeclarativeextensionplugin.h> -#include <QtDeclarative/qdeclarative.h> - -#include <QtQuick1/private/qtquick1_p.h> - -QT_BEGIN_NAMESPACE - -//![class decl] -class Qt47Plugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - virtual void registerTypes(const char *uri) - { - Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt")); - Q_UNUSED(uri); - QDeclarativeQtQuick1Module::defineModule(QDeclarativeQtQuick1Module::Qt47); - } -}; -//![class decl] - -QT_END_NAMESPACE - -#include "plugin.moc" - -//![plugin export decl] -Q_EXPORT_PLUGIN2(qt47plugin, QT_PREPEND_NAMESPACE(Qt47Plugin)); -//![plugin export decl] - diff --git a/src/imports/qt47/qmldir b/src/imports/qt47/qmldir deleted file mode 100644 index cf3a7273d5..0000000000 --- a/src/imports/qt47/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin qt47plugin diff --git a/src/imports/qt47/qt47.pro b/src/imports/qt47/qt47.pro deleted file mode 100644 index 7bddc89e44..0000000000 --- a/src/imports/qt47/qt47.pro +++ /dev/null @@ -1,20 +0,0 @@ -TARGET = qt47plugin -TARGETPATH = Qt -include(../qimportbase.pri) - -SOURCES += \ - plugin.cpp - -QT += declarative qtquick1 opengl qtquick1-private - - -OTHER_FILES += \ - qmldir - -DESTDIR = $$QT.declarative.imports/$$TARGETPATH -target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -qmldir.files += $$PWD/qmldir -qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -INSTALLS += target qmldir diff --git a/src/imports/qtquick1/plugin.cpp b/src/imports/qtquick1/plugin.cpp deleted file mode 100644 index c4527ff468..0000000000 --- a/src/imports/qtquick1/plugin.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtDeclarative/qdeclarativeextensionplugin.h> -#include <QtDeclarative/qdeclarative.h> - -#include <QtQuick1/private/qtquick1_p.h> - -QT_BEGIN_NAMESPACE - -//![class decl] -class QtQuick1Plugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - virtual void registerTypes(const char *uri) - { - Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick")); - Q_UNUSED(uri); - QDeclarativeQtQuick1Module::defineModule(QDeclarativeQtQuick1Module::QtQuick1); - } -}; -//![class decl] - -QT_END_NAMESPACE - -#include "plugin.moc" - -//![plugin export decl] -Q_EXPORT_PLUGIN2(qtquick1plugin, QT_PREPEND_NAMESPACE(QtQuick1Plugin)); -//![plugin export decl] - diff --git a/src/imports/qtquick1/qmldir b/src/imports/qtquick1/qmldir deleted file mode 100644 index f68e439f53..0000000000 --- a/src/imports/qtquick1/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin qtquick1plugin diff --git a/src/imports/qtquick1/qtquick1.pro b/src/imports/qtquick1/qtquick1.pro deleted file mode 100644 index f7a9953b5b..0000000000 --- a/src/imports/qtquick1/qtquick1.pro +++ /dev/null @@ -1,20 +0,0 @@ -TARGET = qtquick1plugin -TARGETPATH = QtQuick.1 -include(../qimportbase.pri) - -SOURCES += \ - plugin.cpp - -QT += declarative qtquick1 opengl qtquick1-private - - -OTHER_FILES += \ - qmldir - -DESTDIR = $$QT.declarative.imports/$$TARGETPATH -target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -qmldir.files += $$PWD/qmldir -qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -INSTALLS += target qmldir diff --git a/src/imports/xmllistmodel/qdeclarativexmllistmodel.cpp b/src/imports/xmllistmodel/qdeclarativexmllistmodel.cpp index ceafb21cc4..db7fec2c97 100644 --- a/src/imports/xmllistmodel/qdeclarativexmllistmodel.cpp +++ b/src/imports/xmllistmodel/qdeclarativexmllistmodel.cpp @@ -625,7 +625,7 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla A XmlListModel could create a model from this data, like this: \qml - import QtQuick 1.0 + import QtQuick 2.0 XmlListModel { id: xmlModel @@ -1157,4 +1157,4 @@ void QDeclarativeXmlListModel::queryCompleted(const QDeclarativeXmlQueryResult & QT_END_NAMESPACE -#include <qdeclarativexmllistmodel.moc>
\ No newline at end of file +#include <qdeclarativexmllistmodel.moc> diff --git a/src/plugins/accessible/accessible.pro b/src/plugins/accessible/accessible.pro index 71165af784..77cba71ace 100644 --- a/src/plugins/accessible/accessible.pro +++ b/src/plugins/accessible/accessible.pro @@ -1,3 +1,2 @@ TEMPLATE = subdirs SUBDIRS += quick -SUBDIRS += qtquick1 diff --git a/src/plugins/accessible/qtquick1/main.cpp b/src/plugins/accessible/qtquick1/main.cpp deleted file mode 100644 index 12c6fcdc3a..0000000000 --- a/src/plugins/accessible/qtquick1/main.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qdeclarativeaccessible.h" -#include "qaccessibledeclarativeview.h" -#include "qaccessibledeclarativeitem.h" - -#include <QtQuick1/qdeclarativeitem.h> -#include <QtWidgets/qgraphicsview.h> - -#include <qaccessibleplugin.h> -#include <qplugin.h> -#include <qvariant.h> -#include <qaccessible.h> - -#ifndef QT_NO_ACCESSIBILITY - -QT_BEGIN_NAMESPACE - -class AccessibleQtQuick1Factory : public QAccessiblePlugin -{ -public: - AccessibleQtQuick1Factory(); - - QStringList keys() const; - QAccessibleInterface *create(const QString &classname, QObject *object); -}; - -AccessibleQtQuick1Factory::AccessibleQtQuick1Factory() -{ -} - -QStringList AccessibleQtQuick1Factory::keys() const -{ - QStringList list; - list << QLatin1String("QDeclarativeView"); - list << QLatin1String("QDeclarativeItem"); - return list; -} - -QAccessibleInterface *AccessibleQtQuick1Factory::create(const QString &classname, QObject *object) -{ - if (classname == QLatin1String("QDeclarativeView")) { - QWidget *widget = qobject_cast<QWidget*>(object); - if (qobject_cast<QDeclarativeView *>(widget) != 0) - return new QAccessibleDeclarativeView(widget); - } else if (classname == QLatin1String("QDeclarativeItem")) { - QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(object); - if (!item->scene()) - return 0; - - QList<QGraphicsView *> views = item->scene()->views(); - if (views.isEmpty()) - return 0; - QGraphicsView *view = views.at(0); // Accessibility support for the first view only. - // (Not a problem for QDeclarative) - return new QAccessibleDeclarativeItem(item, view); - } - - return 0; -} - -Q_EXPORT_STATIC_PLUGIN(AccessibleQtQuick1Factory) -Q_EXPORT_PLUGIN2(qtaccessibleqtquick1, AccessibleQtQuick1Factory) - -QT_END_NAMESPACE - -#endif // QT_NO_ACCESSIBILITY diff --git a/src/plugins/accessible/qtquick1/qaccessibledeclarativeitem.cpp b/src/plugins/accessible/qtquick1/qaccessibledeclarativeitem.cpp deleted file mode 100644 index 6748e2602f..0000000000 --- a/src/plugins/accessible/qtquick1/qaccessibledeclarativeitem.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qaccessibledeclarativeitem.h" - -#include <QtQuick1/qdeclarativeitem.h> -#include <QtQuick1/private/qdeclarativeaccessibleattached_p.h> - -QT_BEGIN_NAMESPACE - -QAccessibleDeclarativeItem::QAccessibleDeclarativeItem(QGraphicsObject *item, QGraphicsView *view) - :QDeclarativeAccessible(item) - ,m_item(item) - ,m_view(view) -{ - -} - -int QAccessibleDeclarativeItem::childCount() const -{ - QList<QGraphicsItem *> children = m_item->childItems(); - return children.count(); -} - -QRect QAccessibleDeclarativeItem::rect() const -{ - QRectF sceneRect = m_item->sceneTransform().mapRect(m_item->boundingRect()); - QPoint pos = m_view->mapFromScene(m_view->mapToGlobal(sceneRect.topLeft().toPoint())); - QSize size = sceneRect.size().toSize(); - return QRect(pos, size); -} - -QRect QAccessibleDeclarativeItem::viewRect() const -{ - QPoint screenPos = m_view->mapToGlobal(m_view->pos()); - return QRect(screenPos, m_view->size()); -} - -bool QAccessibleDeclarativeItem::clipsChildren() const -{ - return static_cast<QDeclarativeItem *>(m_item)->clip(); -} - -static inline bool isAncestor(const QObject *ancestorCandidate, const QObject *child) -{ - while (child) { - if (child == ancestorCandidate) - return true; - child = child->parent(); - } - return false; -} - - -QAccessibleInterface *QAccessibleDeclarativeItem::parent() const -{ - QGraphicsItem *parent = m_item->parentItem(); - QGraphicsObject *parentObj = parent ? parent->toGraphicsObject() : 0; - if (parent && !parentObj) - qWarning("Can not make QGraphicsItems accessible"); - QAccessibleInterface *ancestor = (parentObj - ? new QAccessibleDeclarativeItem(parentObj, m_view) - : QAccessible::queryAccessibleInterface(m_view)); - return ancestor; -} - -QAccessibleInterface *QAccessibleDeclarativeItem::child(int index) const -{ - QList<QGraphicsItem *> children = m_item->childItems(); - - if (index >= children.count()) - return 0; - - QGraphicsItem *child = children.at(index); - QGraphicsObject *childObject = qobject_cast<QGraphicsObject *>(child); - if (!childObject) - return 0; - - return new QAccessibleDeclarativeItem(childObject, m_view); -} - -int QAccessibleDeclarativeItem::navigate(QAccessible::RelationFlag rel, int entry, QAccessibleInterface **target) const -{ - Q_UNUSED(rel); - Q_UNUSED(entry); - *target = 0; - return -1; -} - -/*! \reimp */ -QAccessibleInterface *QAccessibleDeclarativeItem::focusChild() const -{ - QGraphicsObject *focusObject = 0; - if (m_item->hasFocus()) { - focusObject = m_item->toGraphicsObject(); - } else { - if (QGraphicsScene *scene = m_view->scene()) { - if (QGraphicsItem *focusItem = scene->focusItem()) { - if (m_item->isAncestorOf(focusItem)) { - focusObject = focusItem->toGraphicsObject(); - } - } - } - } - if (focusObject) - return new QAccessibleDeclarativeItem(focusObject, m_view); //###queryAccessibleInterface? - return 0; -} - -int QAccessibleDeclarativeItem::indexOfChild(const QAccessibleInterface *iface) const -{ - // ### No QAccessibleInterfaces are created with a QGraphicsItem. - // However, we want to support QML, not QGraphicsView in general. - // And since the UI is written in QML, this means we can assume that *all* - // QGraphicsItems are actually QGraphicsObjects - - const QGraphicsObject *childObj = static_cast<QGraphicsObject*>(iface->object()); - if (m_item == childObj) - return 0; - - QList<QGraphicsItem*> kids = m_item->childItems(); - int index = kids.indexOf(const_cast<QGraphicsItem*>(static_cast<const QGraphicsItem*>(childObj))); - if (index != -1) { - ++index; - } - return index; -} - -QAccessible::State QAccessibleDeclarativeItem::state() const -{ - QAccessible::State state; - state.focused = m_item->hasFocus(); - return state; -} - -QAccessible::Role QAccessibleDeclarativeItem::role() const -{ - // ### Workaround for setAccessibleRole() not working. - // Text items are special since they are defined - // entirely from C++ (setting the role from QML works.) -// if (qobject_cast<QDeclarative1Text*>(m_item)) -// return QAccessible::StaticText; - - QVariant v = QDeclarativeAccessibleAttached::property(m_item, "role"); - bool ok; - QAccessible::Role role = (QAccessible::Role)v.toInt(&ok); - if (!ok) // Not sure if this check is needed. - role = QAccessible::Pane; - return role; -} - -bool QAccessibleDeclarativeItem::isAccessible() const -{ - return true; -} - -QString QAccessibleDeclarativeItem::text(QAccessible::Text textType) const -{ - // handles generic behaviour not specific to an item - switch (textType) { - case QAccessible::Name: { - QVariant accessibleName = QDeclarativeAccessibleAttached::property(object(), "name"); - if (!accessibleName.isNull()) - return accessibleName.toString(); - break;} - case QAccessible::Description: { - QVariant accessibleDecription = QDeclarativeAccessibleAttached::property(object(), "description"); - if (!accessibleDecription.isNull()) - return accessibleDecription.toString(); - break;} - case QAccessible::Value: - case QAccessible::Help: - case QAccessible::Accelerator: - default: - break; - } - - // the following blocks handles item-specific behaviour - if (role() == QAccessible::EditableText) { - if (textType == QAccessible::Value) { - QVariant text = object()->property("text"); - return text.toString(); - } else if (textType == QAccessible::Name) { - return object()->objectName(); - } - } else { - if (textType == QAccessible::Name) { - QVariant text = object()->property("text"); - return text.toString(); - } - } - - - return QString(); -} - -QT_END_NAMESPACE diff --git a/src/plugins/accessible/qtquick1/qaccessibledeclarativeitem.h b/src/plugins/accessible/qtquick1/qaccessibledeclarativeitem.h deleted file mode 100644 index 45bf6f941a..0000000000 --- a/src/plugins/accessible/qtquick1/qaccessibledeclarativeitem.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QACCESSIBLEDECLARATIVEITEM_H -#define QACCESSIBLEDECLARATIVEITEM_H - -#include "qdeclarativeaccessible.h" - -#include <QtWidgets/qgraphicsview.h> -#include <QtWidgets/qgraphicsitem.h> - -QT_BEGIN_NAMESPACE - -class QAccessibleDeclarativeItem : public QDeclarativeAccessible -{ -public: - QAccessibleDeclarativeItem(QGraphicsObject *item, QGraphicsView *view); - - QRect rect() const; - QRect viewRect() const; - - bool clipsChildren() const; - - QAccessibleInterface *focusChild() const; - - QAccessibleInterface *parent() const; - QAccessibleInterface *child(int index) const; - int childCount() const; - int navigate(QAccessible::RelationFlag rel, int entry, QAccessibleInterface **target) const; - int indexOfChild(const QAccessibleInterface *iface) const; - - QAccessible::State state() const; - QAccessible::Role role() const; - QString text(QAccessible::Text) const; - - virtual bool isAccessible() const; -private: - QGraphicsObject *m_item; - QGraphicsView *m_view; -}; - -QT_END_NAMESPACE - -#endif // QACCESSIBLEGRAPHICSVIEWIMPLEMENTATION_H diff --git a/src/plugins/accessible/qtquick1/qaccessibledeclarativeview.cpp b/src/plugins/accessible/qtquick1/qaccessibledeclarativeview.cpp deleted file mode 100644 index e5b78a4517..0000000000 --- a/src/plugins/accessible/qtquick1/qaccessibledeclarativeview.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qaccessibledeclarativeview.h" -#include "qdeclarativeaccessible.h" -#include "qaccessibledeclarativeitem.h" - - -#ifndef QT_NO_ACCESSIBILITY - -QT_BEGIN_NAMESPACE - -QAccessibleDeclarativeView::QAccessibleDeclarativeView(QWidget *widget) - :QAccessibleWidget(widget) -{ - m_view = static_cast<QDeclarativeView *>(widget); -} - -int QAccessibleDeclarativeView::childCount() const -{ - return 1; -} - -QAccessibleInterface *QAccessibleDeclarativeView::child(int index) const -{ - if (index == 0) { - QDeclarativeItem *declarativeRoot = m_view->accessibleRootItem(); - return new QAccessibleDeclarativeItem(declarativeRoot, m_view); - } - return 0; -} - -QAccessibleInterface *QAccessibleDeclarativeView::childAt(int x, int y) const -{ - Q_UNUSED(x); - Q_UNUSED(y); - return child(0); // return the top-level QML item -} - -int QAccessibleDeclarativeView::indexOfChild(const QAccessibleInterface *iface) const -{ - if (iface) { - QDeclarativeItem *declarativeRoot = m_view->accessibleRootItem(); - if (declarativeRoot == iface->object()) - return 0; - } - return -1; -} - -QT_END_NAMESPACE - -#endif // QT_NO_ACCESSIBILITY diff --git a/src/plugins/accessible/qtquick1/qaccessibledeclarativeview.h b/src/plugins/accessible/qtquick1/qaccessibledeclarativeview.h deleted file mode 100644 index d6fc0e2384..0000000000 --- a/src/plugins/accessible/qtquick1/qaccessibledeclarativeview.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QACCESSIBLEDECLARATIVEVIEW_H -#define QACCESSIBLEDECLARATIVEVIEW_H - -#include <QtGui/qaccessible2.h> -#include <QtWidgets/qaccessiblewidget.h> - -#include <QtQuick1/qdeclarativeview.h> -#include <QtQuick1/qdeclarativeitem.h> -#include <QtWidgets/qwidget.h> - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_ACCESSIBILITY - -class QAccessibleDeclarativeView: public QAccessibleWidget -{ -public: - explicit QAccessibleDeclarativeView(QWidget *widget); - - QAccessibleInterface *child(int index) const; - int childCount() const; - QAccessibleInterface *childAt(int x, int y) const; - int indexOfChild(const QAccessibleInterface *iface) const; - -private: - QDeclarativeView *m_view; -}; - -#endif // QT_NO_ACCESSIBILITY - -QT_END_NAMESPACE - -#endif // QACCESSIBLEDECLARATIVEVIEW_H diff --git a/src/plugins/accessible/qtquick1/qtquick1.pro b/src/plugins/accessible/qtquick1/qtquick1.pro deleted file mode 100644 index f4602e4420..0000000000 --- a/src/plugins/accessible/qtquick1/qtquick1.pro +++ /dev/null @@ -1,22 +0,0 @@ -contains(QT_CONFIG, accessibility) { - -TARGET = qtaccessibleqtquick1 -load(qt_plugin) -include ($$PWD/../shared/qaccessiblebase.pri) - -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private -DESTDIR = $$QT.gui.plugins/accessible - -QTDIR_build:REQUIRES += "contains(QT_CONFIG, accessibility)" - -DEFINES+=Q_ACCESSIBLE_QUICK_ITEM_ENABLE_DEBUG_DESCRIPTION - -SOURCES += \ - main.cpp \ - qaccessibledeclarativeview.cpp \ - qaccessibledeclarativeitem.cpp - -HEADERS += \ - qaccessibledeclarativeview.h \ - qaccessibledeclarativeitem.h -} diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/abstractliveedittool.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/abstractliveedittool.cpp deleted file mode 100644 index 38ac8a376e..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/abstractliveedittool.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "abstractliveedittool.h" -#include "qdeclarativeviewinspector_p.h" - -#include <QDeclarativeEngine> - -#include <QtDebug> -#include <QGraphicsItem> -#include <QDeclarativeItem> - -namespace QmlJSDebugger { -namespace QtQuick1 { - -AbstractLiveEditTool::AbstractLiveEditTool(QDeclarativeViewInspector *editorView) - : AbstractTool(editorView) -{ -} - - -AbstractLiveEditTool::~AbstractLiveEditTool() -{ -} - -QDeclarativeViewInspector *AbstractLiveEditTool::inspector() const -{ - return static_cast<QDeclarativeViewInspector*>(AbstractTool::inspector()); -} - -QDeclarativeView *AbstractLiveEditTool::view() const -{ - return inspector()->declarativeView(); -} - -QGraphicsScene* AbstractLiveEditTool::scene() const -{ - return view()->scene(); -} - -void AbstractLiveEditTool::updateSelectedItems() -{ - selectedItemsChanged(items()); -} - -QList<QGraphicsItem*> AbstractLiveEditTool::items() const -{ - return inspector()->selectedItems(); -} - -bool AbstractLiveEditTool::topItemIsMovable(const QList<QGraphicsItem*> & itemList) -{ - QGraphicsItem *firstSelectableItem = topMovableGraphicsItem(itemList); - if (firstSelectableItem == 0) - return false; - if (toQDeclarativeItem(firstSelectableItem) != 0) - return true; - - return false; - -} - -bool AbstractLiveEditTool::topSelectedItemIsMovable(const QList<QGraphicsItem*> &itemList) -{ - QList<QGraphicsItem*> selectedItems = inspector()->selectedItems(); - - foreach (QGraphicsItem *item, itemList) { - QDeclarativeItem *declarativeItem = toQDeclarativeItem(item); - if (declarativeItem - && selectedItems.contains(declarativeItem) - /*&& (declarativeItem->qmlItemNode().hasShowContent() || selectNonContentItems)*/) - return true; - } - - return false; - -} - -bool AbstractLiveEditTool::topItemIsResizeHandle(const QList<QGraphicsItem*> &/*itemList*/) -{ - return false; -} - -QDeclarativeItem *AbstractLiveEditTool::toQDeclarativeItem(QGraphicsItem *item) -{ - return qobject_cast<QDeclarativeItem*>(item->toGraphicsObject()); -} - -QGraphicsItem *AbstractLiveEditTool::topMovableGraphicsItem(const QList<QGraphicsItem*> &itemList) -{ - foreach (QGraphicsItem *item, itemList) { - if (item->flags().testFlag(QGraphicsItem::ItemIsMovable)) - return item; - } - return 0; -} - -QDeclarativeItem *AbstractLiveEditTool::topMovableDeclarativeItem(const QList<QGraphicsItem*> - &itemList) -{ - foreach (QGraphicsItem *item, itemList) { - QDeclarativeItem *declarativeItem = toQDeclarativeItem(item); - if (declarativeItem /*&& (declarativeItem->qmlItemNode().hasShowContent())*/) - return declarativeItem; - } - - return 0; -} - -QList<QGraphicsObject*> AbstractLiveEditTool::toGraphicsObjectList(const QList<QGraphicsItem*> - &itemList) -{ - QList<QGraphicsObject*> gfxObjects; - foreach (QGraphicsItem *item, itemList) { - QGraphicsObject *obj = item->toGraphicsObject(); - if (obj) - gfxObjects << obj; - } - - return gfxObjects; -} - -QString AbstractLiveEditTool::titleForItem(QGraphicsItem *item) -{ - QString className(QLatin1String("QGraphicsItem")); - QString objectStringId; - - QString constructedName; - - QGraphicsObject *gfxObject = item->toGraphicsObject(); - if (gfxObject) { - className = QLatin1String(gfxObject->metaObject()->className()); - - className.remove(QRegExp(QLatin1String("_QMLTYPE_\\d+"))); - className.remove(QRegExp(QLatin1String("_QML_\\d+"))); - if (className.startsWith(QLatin1String("QDeclarative"))) - className = className.remove(QLatin1String("QDeclarative")); - - QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem*>(gfxObject); - if (declarativeItem) { - objectStringId = inspector()->idStringForObject(declarativeItem); - } - - if (!objectStringId.isEmpty()) { - constructedName = objectStringId + QLatin1String(" (") + className + QLatin1Char(')'); - } else { - if (!gfxObject->objectName().isEmpty()) { - constructedName = gfxObject->objectName() + QLatin1String(" (") + className + QLatin1Char(')'); - } else { - constructedName = className; - } - } - } - - return constructedName; -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/abstractliveedittool.h b/src/plugins/qmltooling/qmldbg_qtquick1/abstractliveedittool.h deleted file mode 100644 index 8b82ccd7ed..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/abstractliveedittool.h +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 <QtCore/QList> -#include "abstracttool.h" - -QT_BEGIN_NAMESPACE -class QMouseEvent; -class QGraphicsItem; -class QDeclarativeItem; -class QKeyEvent; -class QGraphicsScene; -class QGraphicsObject; -class QWheelEvent; -class QDeclarativeView; -QT_END_NAMESPACE - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class QDeclarativeViewInspector; - -class AbstractLiveEditTool : public AbstractTool -{ - Q_OBJECT -public: - AbstractLiveEditTool(QDeclarativeViewInspector *inspector); - - virtual ~AbstractLiveEditTool(); - - void leaveEvent(QEvent *) {} - - virtual void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList) = 0; - - virtual void clear() = 0; - - void updateSelectedItems(); - QList<QGraphicsItem*> items() const; - - bool topItemIsMovable(const QList<QGraphicsItem*> &itemList); - bool topItemIsResizeHandle(const QList<QGraphicsItem*> &itemList); - bool topSelectedItemIsMovable(const QList<QGraphicsItem*> &itemList); - - QString titleForItem(QGraphicsItem *item); - - static QList<QGraphicsObject*> toGraphicsObjectList(const QList<QGraphicsItem*> &itemList); - static QGraphicsItem* topMovableGraphicsItem(const QList<QGraphicsItem*> &itemList); - static QDeclarativeItem* topMovableDeclarativeItem(const QList<QGraphicsItem*> &itemList); - static QDeclarativeItem *toQDeclarativeItem(QGraphicsItem *item); - -protected: - virtual void selectedItemsChanged(const QList<QGraphicsItem*> &objectList) = 0; - - QDeclarativeViewInspector *inspector() const; - QDeclarativeView *view() const; - QGraphicsScene *scene() const; - -private: - QList<QGraphicsItem*> m_itemList; -}; - -} // namespace QtQuick1 -} // namesacpe QmlJSDebugger - -#endif // ABSTRACTLIVEEDITTOOL_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/boundingrecthighlighter.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/boundingrecthighlighter.cpp deleted file mode 100644 index 4be624c2dc..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/boundingrecthighlighter.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "boundingrecthighlighter.h" - -#include "qdeclarativeviewinspector.h" -#include "qmlinspectorconstants.h" - -#include <QtWidgets/QGraphicsPolygonItem> - -#include <QtCore/QTimer> -#include <QtCore/QObject> -#include <QtCore/QDebug> - -namespace QmlJSDebugger { -namespace QtQuick1 { - -BoundingBox::BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem, - QObject *parent) - : QObject(parent), - highlightedObject(itemToHighlight), - highlightPolygon(0), - highlightPolygonEdge(0) -{ - highlightPolygon = new BoundingBoxPolygonItem(parentItem); - highlightPolygonEdge = new BoundingBoxPolygonItem(parentItem); - - highlightPolygon->setPen(QPen(QColor(0, 22, 159))); - highlightPolygonEdge->setPen(QPen(QColor(158, 199, 255))); - - highlightPolygon->setFlag(QGraphicsItem::ItemIsSelectable, false); - highlightPolygonEdge->setFlag(QGraphicsItem::ItemIsSelectable, false); -} - -BoundingBox::~BoundingBox() -{ - highlightedObject.clear(); -} - -BoundingBoxPolygonItem::BoundingBoxPolygonItem(QGraphicsItem *item) : QGraphicsPolygonItem(item) -{ - QPen pen; - pen.setColor(QColor(108, 141, 221)); - pen.setWidth(1); - setPen(pen); -} - -int BoundingBoxPolygonItem::type() const -{ - return Constants::EditorItemType; -} - -BoundingRectHighlighter::BoundingRectHighlighter(QDeclarativeViewInspector *view) : - LiveLayerItem(view->declarativeView()->scene()), - m_view(view) -{ -} - -BoundingRectHighlighter::~BoundingRectHighlighter() -{ - -} - -void BoundingRectHighlighter::clear() -{ - foreach (BoundingBox *box, m_boxes) - freeBoundingBox(box); -} - -BoundingBox *BoundingRectHighlighter::boxFor(QGraphicsObject *item) const -{ - foreach (BoundingBox *box, m_boxes) { - if (box->highlightedObject.data() == item) - return box; - } - return 0; -} - -void BoundingRectHighlighter::highlight(QList<QGraphicsObject*> items) -{ - if (items.isEmpty()) - return; - - QList<BoundingBox *> newBoxes; - foreach (QGraphicsObject *itemToHighlight, items) { - BoundingBox *box = boxFor(itemToHighlight); - if (!box) - box = createBoundingBox(itemToHighlight); - - newBoxes << box; - } - qSort(newBoxes); - - if (newBoxes != m_boxes) { - clear(); - m_boxes << newBoxes; - } - - highlightAll(); -} - -void BoundingRectHighlighter::highlight(QGraphicsObject* itemToHighlight) -{ - if (!itemToHighlight) - return; - - BoundingBox *box = boxFor(itemToHighlight); - if (!box) { - box = createBoundingBox(itemToHighlight); - m_boxes << box; - qSort(m_boxes); - } - - highlightAll(); -} - -BoundingBox *BoundingRectHighlighter::createBoundingBox(QGraphicsObject *itemToHighlight) -{ - if (!m_freeBoxes.isEmpty()) { - BoundingBox *box = m_freeBoxes.last(); - if (box->highlightedObject.isNull()) { - box->highlightedObject = itemToHighlight; - box->highlightPolygon->show(); - box->highlightPolygonEdge->show(); - m_freeBoxes.removeLast(); - return box; - } - } - - BoundingBox *box = new BoundingBox(itemToHighlight, this, this); - - connect(itemToHighlight, SIGNAL(xChanged()), this, SLOT(refresh())); - connect(itemToHighlight, SIGNAL(yChanged()), this, SLOT(refresh())); - connect(itemToHighlight, SIGNAL(widthChanged()), this, SLOT(refresh())); - connect(itemToHighlight, SIGNAL(heightChanged()), this, SLOT(refresh())); - connect(itemToHighlight, SIGNAL(rotationChanged()), this, SLOT(refresh())); - connect(itemToHighlight, SIGNAL(destroyed(QObject*)), this, SLOT(itemDestroyed(QObject*))); - - return box; -} - -void BoundingRectHighlighter::removeBoundingBox(BoundingBox *box) -{ - delete box; - box = 0; -} - -void BoundingRectHighlighter::freeBoundingBox(BoundingBox *box) -{ - if (!box->highlightedObject.isNull()) { - disconnect(box->highlightedObject.data(), SIGNAL(xChanged()), this, SLOT(refresh())); - disconnect(box->highlightedObject.data(), SIGNAL(yChanged()), this, SLOT(refresh())); - disconnect(box->highlightedObject.data(), SIGNAL(widthChanged()), this, SLOT(refresh())); - disconnect(box->highlightedObject.data(), SIGNAL(heightChanged()), this, SLOT(refresh())); - disconnect(box->highlightedObject.data(), SIGNAL(rotationChanged()), this, SLOT(refresh())); - } - - box->highlightedObject.clear(); - box->highlightPolygon->hide(); - box->highlightPolygonEdge->hide(); - m_boxes.removeOne(box); - m_freeBoxes << box; -} - -void BoundingRectHighlighter::itemDestroyed(QObject *obj) -{ - foreach (BoundingBox *box, m_boxes) { - if (box->highlightedObject.data() == obj) { - freeBoundingBox(box); - break; - } - } -} - -void BoundingRectHighlighter::highlightAll() -{ - foreach (BoundingBox *box, m_boxes) { - if (box && box->highlightedObject.isNull()) { - // clear all highlights - clear(); - return; - } - QGraphicsObject *item = box->highlightedObject.data(); - - QRectF boundingRectInSceneSpace(item->mapToScene(item->boundingRect()).boundingRect()); - QRectF boundingRectInLayerItemSpace = mapRectFromScene(boundingRectInSceneSpace); - QRectF bboxRect = m_view->adjustToScreenBoundaries(boundingRectInLayerItemSpace); - QRectF edgeRect = bboxRect; - edgeRect.adjust(-1, -1, 1, 1); - - box->highlightPolygon->setPolygon(QPolygonF(bboxRect)); - box->highlightPolygonEdge->setPolygon(QPolygonF(edgeRect)); - } -} - -void BoundingRectHighlighter::refresh() -{ - if (!m_boxes.isEmpty()) - highlightAll(); -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/boundingrecthighlighter.h b/src/plugins/qmltooling/qmldbg_qtquick1/boundingrecthighlighter.h deleted file mode 100644 index 38e724edc5..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/boundingrecthighlighter.h +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 <QtCore/QObject> -#include <QtCore/QWeakPointer> - -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 { -namespace QtQuick1 { - -class QDeclarativeViewInspector; -class BoundingBox; - -class BoundingRectHighlighter : public LiveLayerItem -{ - Q_OBJECT -public: - explicit BoundingRectHighlighter(QDeclarativeViewInspector *view); - ~BoundingRectHighlighter(); - void clear(); - void highlight(QList<QGraphicsObject*> 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<BoundingBox* > m_boxes; - QList<BoundingBox* > m_freeBoxes; -}; - -class BoundingBox : public QObject -{ - Q_OBJECT -public: - explicit BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem, - QObject *parent = 0); - ~BoundingBox(); - QWeakPointer<QGraphicsObject> highlightedObject; - QGraphicsPolygonItem *highlightPolygon; - QGraphicsPolygonItem *highlightPolygonEdge; - -private: - Q_DISABLE_COPY(BoundingBox) - -}; - -class BoundingBoxPolygonItem : public QGraphicsPolygonItem -{ -public: - explicit BoundingBoxPolygonItem(QGraphicsItem *item); - int type() const; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // BOUNDINGRECTHIGHLIGHTER_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/colorpickertool.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/colorpickertool.cpp deleted file mode 100644 index 3e975e7f8e..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/colorpickertool.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "colorpickertool.h" - -#include "qdeclarativeviewinspector.h" - -#include <QtGui/QMouseEvent> -#include <QtGui/QKeyEvent> -#include <QtCore/QRectF> -#include <QtGui/QRgb> -#include <QtGui/QImage> -#include <QtWidgets/QApplication> -#include <QtGui/QPalette> - -namespace QmlJSDebugger { -namespace QtQuick1 { - -ColorPickerTool::ColorPickerTool(QDeclarativeViewInspector *view) : - AbstractLiveEditTool(view) -{ - m_selectedColor.setRgb(0,0,0); -} - -ColorPickerTool::~ColorPickerTool() -{ -} - -void ColorPickerTool::mousePressEvent(QMouseEvent *event) -{ - pickColor(event->pos()); -} - -void ColorPickerTool::mouseMoveEvent(QMouseEvent *event) -{ - pickColor(event->pos()); -} - -void ColorPickerTool::clear() -{ - view()->setCursor(Qt::CrossCursor); -} - -void ColorPickerTool::pickColor(const QPoint &pos) -{ - QRgb fillColor = view()->backgroundBrush().color().rgb(); - if (view()->backgroundBrush().style() == Qt::NoBrush) - fillColor = view()->palette().color(QPalette::Base).rgb(); - - QRectF target(0,0, 1, 1); - QRect source(pos.x(), pos.y(), 1, 1); - QImage img(1, 1, QImage::Format_ARGB32); - img.fill(fillColor); - QPainter painter(&img); - view()->render(&painter, target, source); - m_selectedColor = QColor::fromRgb(img.pixel(0, 0)); - - emit selectedColorChanged(m_selectedColor); -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/colorpickertool.h b/src/plugins/qmltooling/qmldbg_qtquick1/colorpickertool.h deleted file mode 100644 index 25605b8c63..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/colorpickertool.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 <QtGui/QColor> - -QT_FORWARD_DECLARE_CLASS(QPoint) - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class ColorPickerTool : public AbstractLiveEditTool -{ - Q_OBJECT -public: - explicit ColorPickerTool(QDeclarativeViewInspector *view); - - virtual ~ColorPickerTool(); - - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *) {} - void mouseDoubleClickEvent(QMouseEvent *) {} - - void hoverMoveEvent(QMouseEvent *) {} - - void keyPressEvent(QKeyEvent *) {} - void keyReleaseEvent(QKeyEvent *) {} - - void wheelEvent(QWheelEvent *) {} - - void itemsAboutToRemoved(const QList<QGraphicsItem*> &) {} - - void clear(); - -signals: - void selectedColorChanged(const QColor &color); - -protected: - void selectedItemsChanged(const QList<QGraphicsItem*> &) {} - -private: - void pickColor(const QPoint &pos); - -private: - QColor m_selectedColor; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // COLORPICKERTOOL_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/livelayeritem.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/livelayeritem.cpp deleted file mode 100644 index 08e36af603..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/livelayeritem.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "livelayeritem.h" - -#include "qmlinspectorconstants.h" - -#include <QGraphicsScene> - -namespace QmlJSDebugger { -namespace QtQuick1 { - -LiveLayerItem::LiveLayerItem(QGraphicsScene* scene) - : QGraphicsObject() -{ - scene->addItem(this); - setZValue(1); - setFlag(QGraphicsItem::ItemIsMovable, false); -} - -LiveLayerItem::~LiveLayerItem() -{ -} - -void LiveLayerItem::paint(QPainter * /*painter*/, const QStyleOptionGraphicsItem * /*option*/, - QWidget * /*widget*/) -{ -} - -int LiveLayerItem::type() const -{ - return Constants::EditorItemType; -} - -QRectF LiveLayerItem::boundingRect() const -{ - return childrenBoundingRect(); -} - -QList<QGraphicsItem*> LiveLayerItem::findAllChildItems() const -{ - return findAllChildItems(this); -} - -QList<QGraphicsItem*> LiveLayerItem::findAllChildItems(const QGraphicsItem *item) const -{ - QList<QGraphicsItem*> itemList(item->childItems()); - - foreach (QGraphicsItem *childItem, item->childItems()) - itemList += findAllChildItems(childItem); - - return itemList; -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/livelayeritem.h b/src/plugins/qmltooling/qmldbg_qtquick1/livelayeritem.h deleted file mode 100644 index a2af69c1b2..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/livelayeritem.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 <QtWidgets/QGraphicsObject> - -namespace QmlJSDebugger { -namespace QtQuick1 { - -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<QGraphicsItem*> findAllChildItems() const; - -protected: - QList<QGraphicsItem*> findAllChildItems(const QGraphicsItem *item) const; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // LIVELAYERITEM_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/liverubberbandselectionmanipulator.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/liverubberbandselectionmanipulator.cpp deleted file mode 100644 index 27f63a6137..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/liverubberbandselectionmanipulator.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "liverubberbandselectionmanipulator.h" - -#include "qdeclarativeviewinspector_p.h" - -#include <QtWidgets/QGraphicsItem> - -#include <QtCore/QDebug> - -namespace QmlJSDebugger { -namespace QtQuick1 { - -LiveRubberBandSelectionManipulator::LiveRubberBandSelectionManipulator(QGraphicsObject *layerItem, - QDeclarativeViewInspector *editorView) - : m_selectionRectangleElement(layerItem), - m_editorView(editorView), - m_beginFormEditorItem(0), - m_isActive(false) -{ - m_selectionRectangleElement.hide(); -} - -void LiveRubberBandSelectionManipulator::clear() -{ - m_selectionRectangleElement.clear(); - m_isActive = false; - m_beginPoint = QPointF(); - m_itemList.clear(); - m_oldSelectionList.clear(); -} - -QGraphicsItem *LiveRubberBandSelectionManipulator::topFormEditorItem(const QList<QGraphicsItem*> - &itemList) -{ - if (itemList.isEmpty()) - return 0; - - return itemList.first(); -} - -void LiveRubberBandSelectionManipulator::begin(const QPointF &beginPoint) -{ - m_beginPoint = beginPoint; - m_selectionRectangleElement.setRect(m_beginPoint, m_beginPoint); - m_selectionRectangleElement.show(); - m_isActive = true; - QDeclarativeViewInspectorPrivate *inspectorPrivate - = QDeclarativeViewInspectorPrivate::get(m_editorView); - m_beginFormEditorItem = topFormEditorItem(inspectorPrivate->selectableItems(beginPoint)); - m_oldSelectionList = m_editorView->selectedItems(); -} - -void LiveRubberBandSelectionManipulator::update(const QPointF &updatePoint) -{ - m_selectionRectangleElement.setRect(m_beginPoint, updatePoint); -} - -void LiveRubberBandSelectionManipulator::end() -{ - m_oldSelectionList.clear(); - m_selectionRectangleElement.hide(); - m_isActive = false; -} - -void LiveRubberBandSelectionManipulator::select(SelectionType selectionType) -{ - QDeclarativeViewInspectorPrivate *inspectorPrivate - = QDeclarativeViewInspectorPrivate::get(m_editorView); - QList<QGraphicsItem*> itemList - = inspectorPrivate->selectableItems(m_selectionRectangleElement.rect(), - Qt::IntersectsItemShape); - QList<QGraphicsItem*> newSelectionList; - - foreach (QGraphicsItem* item, itemList) { - if (item - && item->parentItem() - && !newSelectionList.contains(item) - //&& m_beginFormEditorItem->childItems().contains(item) // TODO activate this test - ) - { - newSelectionList.append(item); - } - } - - if (newSelectionList.isEmpty() && m_beginFormEditorItem) - newSelectionList.append(m_beginFormEditorItem); - - QList<QGraphicsItem*> resultList; - - switch (selectionType) { - case AddToSelection: { - resultList.append(m_oldSelectionList); - resultList.append(newSelectionList); - } - break; - case ReplaceSelection: { - resultList.append(newSelectionList); - } - break; - case RemoveFromSelection: { - QSet<QGraphicsItem*> oldSelectionSet(m_oldSelectionList.toSet()); - QSet<QGraphicsItem*> newSelectionSet(newSelectionList.toSet()); - resultList.append(oldSelectionSet.subtract(newSelectionSet).toList()); - } - } - - m_editorView->setSelectedItems(resultList); -} - - -void LiveRubberBandSelectionManipulator::setItems(const QList<QGraphicsItem*> &itemList) -{ - m_itemList = itemList; -} - -QPointF LiveRubberBandSelectionManipulator::beginPoint() const -{ - return m_beginPoint; -} - -bool LiveRubberBandSelectionManipulator::isActive() const -{ - return m_isActive; -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/liverubberbandselectionmanipulator.h b/src/plugins/qmltooling/qmldbg_qtquick1/liverubberbandselectionmanipulator.h deleted file mode 100644 index 1e8c54ef8e..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/liverubberbandselectionmanipulator.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 <QtCore/QPointF> - -QT_FORWARD_DECLARE_CLASS(QGraphicsItem) - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class QDeclarativeViewInspector; - -class LiveRubberBandSelectionManipulator -{ -public: - enum SelectionType { - ReplaceSelection, - AddToSelection, - RemoveFromSelection - }; - - LiveRubberBandSelectionManipulator(QGraphicsObject *layerItem, - QDeclarativeViewInspector *editorView); - - void setItems(const QList<QGraphicsItem*> &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<QGraphicsItem*> &itemList); - -private: - QList<QGraphicsItem*> m_itemList; - QList<QGraphicsItem*> m_oldSelectionList; - LiveSelectionRectangle m_selectionRectangleElement; - QPointF m_beginPoint; - QDeclarativeViewInspector *m_editorView; - QGraphicsItem *m_beginFormEditorItem; - bool m_isActive; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // RUBBERBANDSELECTIONMANIPULATOR_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionindicator.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionindicator.cpp deleted file mode 100644 index d1aee7b36b..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionindicator.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "liveselectionindicator.h" - -#include "qdeclarativeviewinspector_p.h" -#include "qmlinspectorconstants.h" - -#include <QtWidgets/QGraphicsRectItem> -#include <QtWidgets/QGraphicsObject> -#include <QtWidgets/QGraphicsScene> -#include <QtGui/QPen> - -namespace QmlJSDebugger { -namespace QtQuick1 { - -LiveSelectionIndicator::LiveSelectionIndicator(QDeclarativeViewInspector *viewInspector, - QGraphicsObject *layerItem) - : m_layerItem(layerItem) - , m_view(viewInspector) -{ -} - -LiveSelectionIndicator::~LiveSelectionIndicator() -{ - clear(); -} - -void LiveSelectionIndicator::show() -{ - foreach (QGraphicsRectItem *item, m_indicatorShapeHash) - item->show(); -} - -void LiveSelectionIndicator::hide() -{ - foreach (QGraphicsRectItem *item, m_indicatorShapeHash) - item->hide(); -} - -void LiveSelectionIndicator::clear() -{ - if (!m_layerItem.isNull()) { - QGraphicsScene *scene = m_layerItem.data()->scene(); - foreach (QGraphicsRectItem *item, m_indicatorShapeHash) { - scene->removeItem(item); - delete item; - } - } - - m_indicatorShapeHash.clear(); - -} - -void LiveSelectionIndicator::setItems(const QList<QWeakPointer<QGraphicsObject> > &itemList) -{ - clear(); - - foreach (const QWeakPointer<QGraphicsObject> &object, itemList) { - if (object.isNull()) - continue; - - QGraphicsItem *item = object.data(); - - if (!m_indicatorShapeHash.contains(item)) { - QGraphicsRectItem *selectionIndicator = new QGraphicsRectItem(m_layerItem.data()); - m_indicatorShapeHash.insert(item, selectionIndicator); - - const QRectF boundingRect = m_view->adjustToScreenBoundaries(item->mapRectToScene(item->boundingRect())); - const QRectF boundingRectInLayerItemSpace = m_layerItem.data()->mapRectFromScene(boundingRect); - - selectionIndicator->setData(Constants::EditorItemDataKey, true); - selectionIndicator->setFlag(QGraphicsItem::ItemIsSelectable, false); - selectionIndicator->setRect(boundingRectInLayerItemSpace); - selectionIndicator->setPen(QColor(108, 141, 221)); - } - } -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionindicator.h b/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionindicator.h deleted file mode 100644 index 3d5e10d7e5..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionindicator.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 <QtCore/QWeakPointer> -#include <QtCore/QHash> - -QT_BEGIN_NAMESPACE -class QGraphicsObject; -class QGraphicsRectItem; -class QGraphicsItem; -class QPolygonF; -QT_END_NAMESPACE - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class QDeclarativeViewInspector; - -class LiveSelectionIndicator -{ -public: - LiveSelectionIndicator(QDeclarativeViewInspector *viewInspector, QGraphicsObject *layerItem); - ~LiveSelectionIndicator(); - - void show(); - void hide(); - - void clear(); - - void setItems(const QList<QWeakPointer<QGraphicsObject> > &itemList); - -private: - QHash<QGraphicsItem*, QGraphicsRectItem *> m_indicatorShapeHash; - QWeakPointer<QGraphicsObject> m_layerItem; - QDeclarativeViewInspector *m_view; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // LIVESELECTIONINDICATOR_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionrectangle.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionrectangle.cpp deleted file mode 100644 index 559d86b815..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionrectangle.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "liveselectionrectangle.h" - -#include "qmlinspectorconstants.h" - -#include <QtGui/QPen> -#include <QtWidgets/QGraphicsRectItem> -#include <QtWidgets/QGraphicsObject> -#include <QtWidgets/QGraphicsScene> - -#include <QtCore/QtDebug> - -#include <cmath> - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class SelectionRectShape : public QGraphicsRectItem -{ -public: - SelectionRectShape(QGraphicsItem *parent = 0) : QGraphicsRectItem(parent) {} - int type() const { return Constants::EditorItemType; } -}; - -LiveSelectionRectangle::LiveSelectionRectangle(QGraphicsObject *layerItem) - : m_controlShape(new SelectionRectShape(layerItem)), - m_layerItem(layerItem) -{ - m_controlShape->setPen(QPen(Qt::black)); - m_controlShape->setBrush(QColor(128, 128, 128, 50)); -} - -LiveSelectionRectangle::~LiveSelectionRectangle() -{ - if (m_layerItem) - m_layerItem.data()->scene()->removeItem(m_controlShape); -} - -void LiveSelectionRectangle::clear() -{ - hide(); -} -void LiveSelectionRectangle::show() -{ - m_controlShape->show(); -} - -void LiveSelectionRectangle::hide() -{ - m_controlShape->hide(); -} - -QRectF LiveSelectionRectangle::rect() const -{ - return m_controlShape->mapFromScene(m_controlShape->rect()).boundingRect(); -} - -void LiveSelectionRectangle::setRect(const QPointF &firstPoint, - const QPointF &secondPoint) -{ - double firstX = std::floor(firstPoint.x()) + 0.5; - double firstY = std::floor(firstPoint.y()) + 0.5; - double secondX = std::floor(secondPoint.x()) + 0.5; - double secondY = std::floor(secondPoint.y()) + 0.5; - QPointF topLeftPoint(firstX < secondX ? firstX : secondX, - firstY < secondY ? firstY : secondY); - QPointF bottomRightPoint(firstX > secondX ? firstX : secondX, - firstY > secondY ? firstY : secondY); - - QRectF rect(topLeftPoint, bottomRightPoint); - m_controlShape->setRect(rect); -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionrectangle.h b/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionrectangle.h deleted file mode 100644 index de1dadb01d..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionrectangle.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 <QtCore/QWeakPointer> - -QT_FORWARD_DECLARE_CLASS(QGraphicsObject) -QT_FORWARD_DECLARE_CLASS(QGraphicsRectItem) -QT_FORWARD_DECLARE_CLASS(QPointF) -QT_FORWARD_DECLARE_CLASS(QRectF) - -namespace QmlJSDebugger { -namespace QtQuick1 { - -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<QGraphicsObject> m_layerItem; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // LIVESELECTIONRECTANGLE_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectiontool.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/liveselectiontool.cpp deleted file mode 100644 index 5a22cdd4f4..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectiontool.cpp +++ /dev/null @@ -1,425 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "liveselectiontool.h" -#include "livelayeritem.h" - -#include "qdeclarativeviewinspector_p.h" - -#include <QtWidgets/QApplication> -#include <QtGui/QWheelEvent> -#include <QtGui/QMouseEvent> -#include <QtGui/QClipboard> -#include <QtWidgets/QMenu> -#include <QtWidgets/QAction> -#include <QtWidgets/QGraphicsObject> - -#include <QtQuick1/QDeclarativeItem> -#include <QtDeclarative/QDeclarativeEngine> - -#include <QtCore/QDebug> - -namespace QmlJSDebugger { -namespace QtQuick1 { - -LiveSelectionTool::LiveSelectionTool(QDeclarativeViewInspector *editorView) : - AbstractLiveEditTool(editorView), - m_rubberbandSelectionMode(false), - m_rubberbandSelectionManipulator( - QDeclarativeViewInspectorPrivate::get(editorView)->manipulatorLayer, editorView), - m_singleSelectionManipulator(editorView), - m_selectionIndicator(editorView, - QDeclarativeViewInspectorPrivate::get(editorView)->manipulatorLayer), - //m_resizeIndicator(editorView->manipulatorLayer()), - m_selectOnlyContentItems(true) -{ - -} - -LiveSelectionTool::~LiveSelectionTool() -{ -} - -void LiveSelectionTool::setRubberbandSelectionMode(bool value) -{ - m_rubberbandSelectionMode = value; -} - -LiveSingleSelectionManipulator::SelectionType LiveSelectionTool::getSelectionType(Qt::KeyboardModifiers - modifiers) -{ - LiveSingleSelectionManipulator::SelectionType selectionType - = LiveSingleSelectionManipulator::ReplaceSelection; - if (modifiers.testFlag(Qt::ControlModifier)) { - selectionType = LiveSingleSelectionManipulator::RemoveFromSelection; - } else if (modifiers.testFlag(Qt::ShiftModifier)) { - selectionType = LiveSingleSelectionManipulator::AddToSelection; - } - return selectionType; -} - -bool LiveSelectionTool::alreadySelected(const QList<QGraphicsItem*> &itemList) const -{ - QDeclarativeViewInspectorPrivate *inspectorPrivate - = QDeclarativeViewInspectorPrivate::get(inspector()); - const QList<QGraphicsItem*> selectedItems = inspectorPrivate->selectedItems(); - - if (selectedItems.isEmpty()) - return false; - - foreach (QGraphicsItem *item, itemList) - if (selectedItems.contains(item)) - return true; - - return false; -} - -void LiveSelectionTool::mousePressEvent(QMouseEvent *event) -{ - QDeclarativeViewInspectorPrivate *inspectorPrivate - = QDeclarativeViewInspectorPrivate::get(inspector()); - QList<QGraphicsItem*> itemList = inspectorPrivate->selectableItems(event->pos()); - LiveSingleSelectionManipulator::SelectionType selectionType = getSelectionType(event->modifiers()); - - if (event->buttons() & Qt::LeftButton) { - m_mousePressTimer.start(); - - if (m_rubberbandSelectionMode) { - m_rubberbandSelectionManipulator.begin(event->pos()); - } else { - m_singleSelectionManipulator.begin(event->pos()); - m_singleSelectionManipulator.select(selectionType, m_selectOnlyContentItems); - } - } else if (event->buttons() & Qt::RightButton) { - createContextMenu(itemList, event->globalPos()); - } -} - -void LiveSelectionTool::createContextMenu(const QList<QGraphicsItem*> &itemList, QPoint globalPos) -{ - QMenu contextMenu; - connect(&contextMenu, SIGNAL(hovered(QAction*)), - this, SLOT(contextMenuElementHovered(QAction*))); - - m_contextMenuItemList = itemList; - - contextMenu.addAction(tr("Items")); - contextMenu.addSeparator(); - int shortcutKey = Qt::Key_1; - int i = 0; - - foreach (QGraphicsItem * const item, itemList) { - QString itemTitle = titleForItem(item); - QAction *elementAction = contextMenu.addAction(itemTitle, this, - SLOT(contextMenuElementSelected())); - - if (inspector()->selectedItems().contains(item)) { - QFont boldFont = elementAction->font(); - boldFont.setBold(true); - elementAction->setFont(boldFont); - } - - elementAction->setData(i); - - if (shortcutKey <= Qt::Key_9) { - elementAction->setShortcut(QKeySequence(shortcutKey)); - shortcutKey++; - } - - ++i; - } - // add root item separately - // QString itemTitle = QString(tr("%1")).arg(titleForItem(view()->currentRootItem())); - // contextMenu.addAction(itemTitle, this, SLOT(contextMenuElementSelected())); - // m_contextMenuItemList.append(view()->currentRootItem()); - - contextMenu.exec(globalPos); - m_contextMenuItemList.clear(); -} - -void LiveSelectionTool::contextMenuElementSelected() -{ - QAction *senderAction = static_cast<QAction*>(sender()); - int itemListIndex = senderAction->data().toInt(); - if (itemListIndex >= 0 && itemListIndex < m_contextMenuItemList.length()) { - - QPointF updatePt(0, 0); - QGraphicsItem *item = m_contextMenuItemList.at(itemListIndex); - m_singleSelectionManipulator.begin(updatePt); - m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::InvertSelection, - QList<QGraphicsItem*>() << item, - false); - m_singleSelectionManipulator.end(updatePt); - } -} - -void LiveSelectionTool::contextMenuElementHovered(QAction *action) -{ - int itemListIndex = action->data().toInt(); - if (itemListIndex >= 0 && itemListIndex < m_contextMenuItemList.length()) { - QGraphicsObject *item = m_contextMenuItemList.at(itemListIndex)->toGraphicsObject(); - QDeclarativeViewInspectorPrivate::get(inspector())->highlight(item); - } -} - -void LiveSelectionTool::mouseMoveEvent(QMouseEvent *event) -{ - if (m_singleSelectionManipulator.isActive()) { - QPointF mouseMovementVector = m_singleSelectionManipulator.beginPoint() - event->pos(); - - if ((mouseMovementVector.toPoint().manhattanLength() > Constants::DragStartDistance) - && (m_mousePressTimer.elapsed() > Constants::DragStartTime)) - { - m_singleSelectionManipulator.end(event->pos()); - //view()->changeToMoveTool(m_singleSelectionManipulator.beginPoint()); - return; - } - } else if (m_rubberbandSelectionManipulator.isActive()) { - QPointF mouseMovementVector = m_rubberbandSelectionManipulator.beginPoint() - event->pos(); - - if ((mouseMovementVector.toPoint().manhattanLength() > Constants::DragStartDistance) - && (m_mousePressTimer.elapsed() > Constants::DragStartTime)) { - m_rubberbandSelectionManipulator.update(event->pos()); - - if (event->modifiers().testFlag(Qt::ControlModifier)) - m_rubberbandSelectionManipulator.select( - LiveRubberBandSelectionManipulator::RemoveFromSelection); - else if (event->modifiers().testFlag(Qt::ShiftModifier)) - m_rubberbandSelectionManipulator.select( - LiveRubberBandSelectionManipulator::AddToSelection); - else - m_rubberbandSelectionManipulator.select( - LiveRubberBandSelectionManipulator::ReplaceSelection); - } - } -} - -void LiveSelectionTool::hoverMoveEvent(QMouseEvent * event) -{ -// ### commented out until move tool is re-enabled -// QList<QGraphicsItem*> itemList = view()->items(event->pos()); -// if (!itemList.isEmpty() && !m_rubberbandSelectionMode) { -// -// foreach (QGraphicsItem *item, itemList) { -// if (item->type() == Constants::ResizeHandleItemType) { -// ResizeHandleItem* resizeHandle = ResizeHandleItem::fromGraphicsItem(item); -// if (resizeHandle) -// view()->changeTool(Constants::ResizeToolMode); -// return; -// } -// } -// if (topSelectedItemIsMovable(itemList)) -// view()->changeTool(Constants::MoveToolMode); -// } - QDeclarativeViewInspectorPrivate *inspectorPrivate - = QDeclarativeViewInspectorPrivate::get(inspector()); - - QList<QGraphicsItem*> selectableItemList = inspectorPrivate->selectableItems(event->pos()); - if (!selectableItemList.isEmpty()) { - QGraphicsObject *item = selectableItemList.first()->toGraphicsObject(); - if (item) - QDeclarativeViewInspectorPrivate::get(inspector())->highlight(item); - - return; - } - - QDeclarativeViewInspectorPrivate::get(inspector())->clearHighlight(); -} - -void LiveSelectionTool::mouseReleaseEvent(QMouseEvent *event) -{ - if (m_singleSelectionManipulator.isActive()) { - m_singleSelectionManipulator.end(event->pos()); - } - else if (m_rubberbandSelectionManipulator.isActive()) { - - QPointF mouseMovementVector = m_rubberbandSelectionManipulator.beginPoint() - event->pos(); - if (mouseMovementVector.toPoint().manhattanLength() < Constants::DragStartDistance) { - m_singleSelectionManipulator.begin(event->pos()); - - if (event->modifiers().testFlag(Qt::ControlModifier)) - m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::RemoveFromSelection, - m_selectOnlyContentItems); - else if (event->modifiers().testFlag(Qt::ShiftModifier)) - m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::AddToSelection, - m_selectOnlyContentItems); - else - m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::InvertSelection, - m_selectOnlyContentItems); - - m_singleSelectionManipulator.end(event->pos()); - } else { - m_rubberbandSelectionManipulator.update(event->pos()); - - if (event->modifiers().testFlag(Qt::ControlModifier)) - m_rubberbandSelectionManipulator.select( - LiveRubberBandSelectionManipulator::RemoveFromSelection); - else if (event->modifiers().testFlag(Qt::ShiftModifier)) - m_rubberbandSelectionManipulator.select( - LiveRubberBandSelectionManipulator::AddToSelection); - else - m_rubberbandSelectionManipulator.select( - LiveRubberBandSelectionManipulator::ReplaceSelection); - - m_rubberbandSelectionManipulator.end(); - } - } -} - -void LiveSelectionTool::keyPressEvent(QKeyEvent *event) -{ - switch (event->key()) { - case Qt::Key_Left: - case Qt::Key_Right: - case Qt::Key_Up: - case Qt::Key_Down: - // disabled for now, cannot move stuff yet. - //view()->changeTool(Constants::MoveToolMode); - //view()->currentTool()->keyPressEvent(event); - break; - } -} - -void LiveSelectionTool::wheelEvent(QWheelEvent *event) -{ - if (event->orientation() == Qt::Horizontal || m_rubberbandSelectionMode) - return; - - QDeclarativeViewInspectorPrivate *inspectorPrivate - = QDeclarativeViewInspectorPrivate::get(inspector()); - QList<QGraphicsItem*> itemList = inspectorPrivate->selectableItems(event->pos()); - - if (itemList.isEmpty()) - return; - - int selectedIdx = 0; - if (!inspector()->selectedItems().isEmpty()) { - selectedIdx = itemList.indexOf(inspector()->selectedItems().first()); - if (selectedIdx >= 0) { - if (event->delta() > 0) { - selectedIdx++; - if (selectedIdx == itemList.length()) - selectedIdx = 0; - } else if (event->delta() < 0) { - selectedIdx--; - if (selectedIdx == -1) - selectedIdx = itemList.length() - 1; - } - } else { - selectedIdx = 0; - } - } - - QPointF updatePt(0, 0); - m_singleSelectionManipulator.begin(updatePt); - m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::ReplaceSelection, - QList<QGraphicsItem*>() << itemList.at(selectedIdx), - false); - m_singleSelectionManipulator.end(updatePt); - -} - -void LiveSelectionTool::setSelectOnlyContentItems(bool selectOnlyContentItems) -{ - m_selectOnlyContentItems = selectOnlyContentItems; -} - -void LiveSelectionTool::clear() -{ - view()->setCursor(Qt::ArrowCursor); - m_rubberbandSelectionManipulator.clear(), - m_singleSelectionManipulator.clear(); - m_selectionIndicator.clear(); - //m_resizeIndicator.clear(); -} - -void LiveSelectionTool::selectedItemsChanged(const QList<QGraphicsItem*> &itemList) -{ - foreach (const QWeakPointer<QGraphicsObject> &obj, m_selectedItemList) { - if (!obj.isNull()) { - disconnect(obj.data(), SIGNAL(xChanged()), this, SLOT(repaintBoundingRects())); - disconnect(obj.data(), SIGNAL(yChanged()), this, SLOT(repaintBoundingRects())); - disconnect(obj.data(), SIGNAL(widthChanged()), this, SLOT(repaintBoundingRects())); - disconnect(obj.data(), SIGNAL(heightChanged()), this, SLOT(repaintBoundingRects())); - disconnect(obj.data(), SIGNAL(rotationChanged()), this, SLOT(repaintBoundingRects())); - } - } - - QList<QGraphicsObject*> objects = toGraphicsObjectList(itemList); - m_selectedItemList.clear(); - - foreach (QGraphicsObject *obj, objects) { - m_selectedItemList.append(obj); - connect(obj, SIGNAL(xChanged()), this, SLOT(repaintBoundingRects())); - connect(obj, SIGNAL(yChanged()), this, SLOT(repaintBoundingRects())); - connect(obj, SIGNAL(widthChanged()), this, SLOT(repaintBoundingRects())); - connect(obj, SIGNAL(heightChanged()), this, SLOT(repaintBoundingRects())); - connect(obj, SIGNAL(rotationChanged()), this, SLOT(repaintBoundingRects())); - } - - m_selectionIndicator.setItems(m_selectedItemList); - //m_resizeIndicator.setItems(toGraphicsObjectList(itemList)); -} - -void LiveSelectionTool::repaintBoundingRects() -{ - m_selectionIndicator.setItems(m_selectedItemList); -} - -void LiveSelectionTool::selectUnderPoint(QMouseEvent *event) -{ - m_singleSelectionManipulator.begin(event->pos()); - - if (event->modifiers().testFlag(Qt::ControlModifier)) - m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::RemoveFromSelection, - m_selectOnlyContentItems); - else if (event->modifiers().testFlag(Qt::ShiftModifier)) - m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::AddToSelection, - m_selectOnlyContentItems); - else - m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::InvertSelection, - m_selectOnlyContentItems); - - m_singleSelectionManipulator.end(event->pos()); -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectiontool.h b/src/plugins/qmltooling/qmldbg_qtquick1/liveselectiontool.h deleted file mode 100644 index f6046d4c59..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectiontool.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 <QtCore/QList> -#include <QtCore/QTime> - -QT_FORWARD_DECLARE_CLASS(QGraphicsItem) -QT_FORWARD_DECLARE_CLASS(QMouseEvent) -QT_FORWARD_DECLARE_CLASS(QKeyEvent) -QT_FORWARD_DECLARE_CLASS(QAction) - -namespace QmlJSDebugger { -namespace QtQuick1 { - -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 *) {} - void hoverMoveEvent(QMouseEvent *event); - void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *) {} - void wheelEvent(QWheelEvent *event); - - void itemsAboutToRemoved(const QList<QGraphicsItem*> &) {} -// QVariant itemChange(const QList<QGraphicsItem*> &itemList, -// QGraphicsItem::GraphicsItemChange change, -// const QVariant &value ); - -// void update(); - - void clear(); - - void selectedItemsChanged(const QList<QGraphicsItem*> &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(const QList<QGraphicsItem*> &itemList, QPoint globalPos); - LiveSingleSelectionManipulator::SelectionType getSelectionType(Qt::KeyboardModifiers modifiers); - bool alreadySelected(const QList<QGraphicsItem*> &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<QWeakPointer<QGraphicsObject> > m_selectedItemList; - - QList<QGraphicsItem*> m_contextMenuItemList; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // LIVESELECTIONTOOL_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/livesingleselectionmanipulator.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/livesingleselectionmanipulator.cpp deleted file mode 100644 index d58ab4e0dc..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/livesingleselectionmanipulator.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "livesingleselectionmanipulator.h" - -#include "qdeclarativeviewinspector_p.h" - -#include <QtDebug> - -namespace QmlJSDebugger { -namespace QtQuick1 { - -LiveSingleSelectionManipulator::LiveSingleSelectionManipulator(QDeclarativeViewInspector *editorView) - : m_editorView(editorView), - m_isActive(false) -{ -} - - -void LiveSingleSelectionManipulator::begin(const QPointF &beginPoint) -{ - m_beginPoint = beginPoint; - m_isActive = true; - m_oldSelectionList = QDeclarativeViewInspectorPrivate::get(m_editorView)->selectedItems(); -} - -void LiveSingleSelectionManipulator::update(const QPointF &/*updatePoint*/) -{ - m_oldSelectionList.clear(); -} - -void LiveSingleSelectionManipulator::clear() -{ - m_beginPoint = QPointF(); - m_oldSelectionList.clear(); -} - - -void LiveSingleSelectionManipulator::end(const QPointF &/*updatePoint*/) -{ - m_oldSelectionList.clear(); - m_isActive = false; -} - -void LiveSingleSelectionManipulator::select(SelectionType selectionType, - const QList<QGraphicsItem*> &items, - bool /*selectOnlyContentItems*/) -{ - QGraphicsItem *selectedItem = 0; - - foreach (QGraphicsItem* item, items) - { - //FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item); - if (item - /*&& !formEditorItem->qmlItemNode().isRootNode() - && (formEditorItem->qmlItemNode().hasShowContent() || !selectOnlyContentItems)*/) - { - selectedItem = item; - break; - } - } - - QList<QGraphicsItem*> resultList; - - switch (selectionType) { - case AddToSelection: { - resultList.append(m_oldSelectionList); - if (selectedItem && !m_oldSelectionList.contains(selectedItem)) - resultList.append(selectedItem); - } - break; - case ReplaceSelection: { - if (selectedItem) - resultList.append(selectedItem); - } - break; - case RemoveFromSelection: { - resultList.append(m_oldSelectionList); - if (selectedItem) - resultList.removeAll(selectedItem); - } - break; - case InvertSelection: { - if (selectedItem - && !m_oldSelectionList.contains(selectedItem)) - { - resultList.append(selectedItem); - } - } - } - - m_editorView->setSelectedItems(resultList); -} - -void LiveSingleSelectionManipulator::select(SelectionType selectionType, bool selectOnlyContentItems) -{ - QDeclarativeViewInspectorPrivate *inspectorPrivate = - QDeclarativeViewInspectorPrivate::get(m_editorView); - QList<QGraphicsItem*> itemList = inspectorPrivate->selectableItems(m_beginPoint); - select(selectionType, itemList, selectOnlyContentItems); -} - - -bool LiveSingleSelectionManipulator::isActive() const -{ - return m_isActive; -} - -QPointF LiveSingleSelectionManipulator::beginPoint() const -{ - return m_beginPoint; -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/livesingleselectionmanipulator.h b/src/plugins/qmltooling/qmldbg_qtquick1/livesingleselectionmanipulator.h deleted file mode 100644 index a9aa65593d..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/livesingleselectionmanipulator.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 <QtCore/QPointF> -#include <QtCore/QList> - -QT_FORWARD_DECLARE_CLASS(QGraphicsItem) - -namespace QmlJSDebugger { -namespace QtQuick1 { - -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<QGraphicsItem*> &items, - bool selectOnlyContentItems); - void select(SelectionType selectionType, bool selectOnlyContentItems); - - void clear(); - - QPointF beginPoint() const; - - bool isActive() const; - -private: - QList<QGraphicsItem*> m_oldSelectionList; - QPointF m_beginPoint; - QDeclarativeViewInspector *m_editorView; - bool m_isActive; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // LIVESINGLESELECTIONMANIPULATOR_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/qdeclarativeviewinspector.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/qdeclarativeviewinspector.cpp deleted file mode 100644 index 3f2506cf03..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/qdeclarativeviewinspector.cpp +++ /dev/null @@ -1,447 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qdeclarativeviewinspector.h" -#include "qdeclarativeviewinspector_p.h" - -#include "liveselectiontool.h" -#include "zoomtool.h" -#include "colorpickertool.h" -#include "livelayeritem.h" -#include "boundingrecthighlighter.h" - -#include <QtQuick1/QDeclarativeItem> -#include <QtGui/QMouseEvent> - -namespace QmlJSDebugger { -namespace QtQuick1 { - -QDeclarativeViewInspectorPrivate::QDeclarativeViewInspectorPrivate(QDeclarativeViewInspector *q) : - q(q) -{ -} - -QDeclarativeViewInspectorPrivate::~QDeclarativeViewInspectorPrivate() -{ -} - -QDeclarativeViewInspector::QDeclarativeViewInspector(QDeclarativeView *view, - QObject *parent) : - AbstractViewInspector(parent), - data(new QDeclarativeViewInspectorPrivate(this)) -{ - data->view = view; - data->manipulatorLayer = new LiveLayerItem(view->scene()); - data->selectionTool = new LiveSelectionTool(this); - data->zoomTool = new ZoomTool(this); - data->colorPickerTool = new ColorPickerTool(this); - data->boundingRectHighlighter = new BoundingRectHighlighter(this); - setCurrentTool(data->selectionTool); - - // to capture ChildRemoved event when viewport changes - data->view->installEventFilter(this); - - data->setViewport(data->view->viewport()); - - connect(data->view, SIGNAL(statusChanged(QDeclarativeView::Status)), - data.data(), SLOT(_q_onStatusChanged(QDeclarativeView::Status))); - - connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)), - SIGNAL(selectedColorChanged(QColor))); - connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)), - this, SLOT(sendColorChanged(QColor))); - - changeTool(InspectorProtocol::SelectTool); -} - -QDeclarativeViewInspector::~QDeclarativeViewInspector() -{ -} - -void QDeclarativeViewInspector::changeCurrentObjects(const QList<QObject*> &objects) -{ - QList<QGraphicsItem*> items; - QList<QGraphicsObject*> gfxObjects; - foreach (QObject *obj, objects) { - if (QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem*>(obj)) { - items << declarativeItem; - gfxObjects << declarativeItem; - } - } - if (designModeBehavior()) { - data->setSelectedItemsForTools(items); - data->clearHighlight(); - data->highlight(gfxObjects); - } -} - -void QDeclarativeViewInspector::reloadView() -{ - 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; - } -} - -Qt::WindowFlags QDeclarativeViewInspector::windowFlags() const -{ - return declarativeView()->window()->windowFlags(); -} - -void QDeclarativeViewInspector::setWindowFlags(Qt::WindowFlags flags) -{ - declarativeView()->window()->setWindowFlags(flags); - declarativeView()->window()->show(); -} - -AbstractLiveEditTool *QDeclarativeViewInspector::currentTool() const -{ - return static_cast<AbstractLiveEditTool*>(AbstractViewInspector::currentTool()); -} - -QDeclarativeEngine *QDeclarativeViewInspector::declarativeEngine() const -{ - return data->view->engine(); -} - -void QDeclarativeViewInspectorPrivate::setViewport(QWidget *widget) -{ - if (viewport.data() == widget) - return; - - if (viewport) - viewport.data()->removeEventFilter(q); - - viewport = widget; - if (viewport) { - // make sure we get mouse move events - viewport.data()->setMouseTracking(true); - viewport.data()->installEventFilter(q); - } -} - -void QDeclarativeViewInspectorPrivate::clearEditorItems() -{ - clearHighlight(); - setSelectedItems(QList<QGraphicsItem*>()); -} - -bool QDeclarativeViewInspector::eventFilter(QObject *obj, QEvent *event) -{ - if (obj == data->view) { - // Event from view - if (event->type() == QEvent::ChildRemoved) { - // Might mean that viewport has changed - if (data->view->viewport() != data->viewport.data()) - data->setViewport(data->view->viewport()); - } - return QObject::eventFilter(obj, event); - } - - return AbstractViewInspector::eventFilter(obj, event); -} - -bool QDeclarativeViewInspector::leaveEvent(QEvent *event) -{ - data->clearHighlight(); - return AbstractViewInspector::leaveEvent(event); -} - -bool QDeclarativeViewInspector::mouseMoveEvent(QMouseEvent *event) -{ - QList<QGraphicsItem*> selItems = data->selectableItems(event->pos()); - if (!selItems.isEmpty()) { - declarativeView()->setToolTip(currentTool()->titleForItem(selItems.first())); - } else { - declarativeView()->setToolTip(QString()); - } - - return AbstractViewInspector::mouseMoveEvent(event); -} - -void QDeclarativeViewInspector::reparentQmlObject(QObject *object, QObject *newParent) -{ - if (!newParent) - return; - - object->setParent(newParent); - QDeclarativeItem *newParentItem = qobject_cast<QDeclarativeItem*>(newParent); - QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(object); - if (newParentItem && item) - item->setParentItem(newParentItem); -} - -void QDeclarativeViewInspectorPrivate::_q_removeFromSelection(QObject *obj) -{ - QList<QGraphicsItem*> items = selectedItems(); - if (QGraphicsItem *item = qobject_cast<QGraphicsObject*>(obj)) - items.removeOne(item); - setSelectedItems(items); -} - -void QDeclarativeViewInspectorPrivate::setSelectedItemsForTools(const QList<QGraphicsItem *> &items) -{ - foreach (const QWeakPointer<QGraphicsObject> &obj, currentSelection) { - if (QGraphicsItem *item = obj.data()) { - if (!items.contains(item)) { - QObject::disconnect(obj.data(), SIGNAL(destroyed(QObject*)), - this, SLOT(_q_removeFromSelection(QObject*))); - currentSelection.removeOne(obj); - } - } - } - - foreach (QGraphicsItem *item, items) { - if (QGraphicsObject *obj = item->toGraphicsObject()) { - if (!currentSelection.contains(obj)) { - QObject::connect(obj, SIGNAL(destroyed(QObject*)), - this, SLOT(_q_removeFromSelection(QObject*))); - currentSelection.append(obj); - } - } - } - - q->currentTool()->updateSelectedItems(); -} - -void QDeclarativeViewInspectorPrivate::setSelectedItems(const QList<QGraphicsItem *> &items) -{ - QList<QWeakPointer<QGraphicsObject> > oldList = currentSelection; - setSelectedItemsForTools(items); - if (oldList != currentSelection) { - QList<QObject*> objectList; - foreach (const QWeakPointer<QGraphicsObject> &graphicsObject, currentSelection) { - if (graphicsObject) - objectList << graphicsObject.data(); - } - - q->sendCurrentObjects(objectList); - } -} - -QList<QGraphicsItem *> QDeclarativeViewInspectorPrivate::selectedItems() const -{ - QList<QGraphicsItem *> selection; - foreach (const QWeakPointer<QGraphicsObject> &selectedObject, currentSelection) { - if (selectedObject.data()) - selection << selectedObject.data(); - } - - return selection; -} - -void QDeclarativeViewInspector::setSelectedItems(QList<QGraphicsItem *> items) -{ - data->setSelectedItems(items); -} - -QList<QGraphicsItem *> QDeclarativeViewInspector::selectedItems() const -{ - return data->selectedItems(); -} - -QDeclarativeView *QDeclarativeViewInspector::declarativeView() const -{ - return data->view; -} - -void QDeclarativeViewInspectorPrivate::clearHighlight() -{ - boundingRectHighlighter->clear(); -} - -void QDeclarativeViewInspectorPrivate::highlight(const QList<QGraphicsObject *> &items) -{ - if (items.isEmpty()) - return; - - QList<QGraphicsObject*> objectList; - foreach (QGraphicsItem *item, items) { - QGraphicsItem *child = item; - - if (child) { - QGraphicsObject *childObject = child->toGraphicsObject(); - if (childObject) - objectList << childObject; - } - } - - boundingRectHighlighter->highlight(objectList); -} - -QList<QGraphicsItem*> QDeclarativeViewInspectorPrivate::selectableItems( - const QPointF &scenePos) const -{ - QList<QGraphicsItem*> itemlist = view->scene()->items(scenePos); - return filterForSelection(itemlist); -} - -QList<QGraphicsItem*> QDeclarativeViewInspectorPrivate::selectableItems(const QPoint &pos) const -{ - QList<QGraphicsItem*> itemlist = view->items(pos); - return filterForSelection(itemlist); -} - -QList<QGraphicsItem*> QDeclarativeViewInspectorPrivate::selectableItems( - const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const -{ - QList<QGraphicsItem*> itemlist = view->scene()->items(sceneRect, selectionMode); - return filterForSelection(itemlist); -} - -void QDeclarativeViewInspectorPrivate::changeToSingleSelectTool() -{ - selectionTool->setRubberbandSelectionMode(false); - - changeToSelectTool(); - - emit q->selectToolActivated(); - q->sendCurrentTool(Constants::SelectionToolMode); -} - -void QDeclarativeViewInspectorPrivate::changeToSelectTool() -{ - if (q->currentTool() == selectionTool) - return; - - q->currentTool()->clear(); - q->setCurrentTool(selectionTool); - q->currentTool()->clear(); - q->currentTool()->updateSelectedItems(); -} - -void QDeclarativeViewInspectorPrivate::changeToMarqueeSelectTool() -{ - changeToSelectTool(); - selectionTool->setRubberbandSelectionMode(true); - - emit q->marqueeSelectToolActivated(); - q->sendCurrentTool(Constants::MarqueeSelectionToolMode); -} - -void QDeclarativeViewInspectorPrivate::changeToZoomTool() -{ - q->currentTool()->clear(); - q->setCurrentTool(zoomTool); - q->currentTool()->clear(); - - emit q->zoomToolActivated(); - q->sendCurrentTool(Constants::ZoomMode); -} - -void QDeclarativeViewInspectorPrivate::changeToColorPickerTool() -{ - if (q->currentTool() == colorPickerTool) - return; - - q->currentTool()->clear(); - q->setCurrentTool(colorPickerTool); - q->currentTool()->clear(); - - emit q->colorPickerActivated(); - q->sendCurrentTool(Constants::ColorPickerMode); -} - - -static bool isEditorItem(QGraphicsItem *item) -{ - return (item->type() == Constants::EditorItemType - || item->type() == Constants::ResizeHandleItemType - || item->data(Constants::EditorItemDataKey).toBool()); -} - -QList<QGraphicsItem*> QDeclarativeViewInspectorPrivate::filterForSelection( - QList<QGraphicsItem*> &itemlist) const -{ - foreach (QGraphicsItem *item, itemlist) { - if (isEditorItem(item)) - itemlist.removeOne(item); - } - - return itemlist; -} - -void QDeclarativeViewInspectorPrivate::_q_onStatusChanged(QDeclarativeView::Status status) -{ - if (status == QDeclarativeView::Ready) - q->sendReloaded(); -} - -// adjusts bounding boxes on edges of screen to be visible -QRectF QDeclarativeViewInspector::adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace) -{ - int marginFromEdge = 1; - QRectF boundingRect(boundingRectInSceneSpace); - if (qAbs(boundingRect.left()) - 1 < 2) - boundingRect.setLeft(marginFromEdge); - - QRect rect = data->view->rect(); - - if (boundingRect.right() >= rect.right()) - boundingRect.setRight(rect.right() - marginFromEdge); - - if (qAbs(boundingRect.top()) - 1 < 2) - boundingRect.setTop(marginFromEdge); - - if (boundingRect.bottom() >= rect.bottom()) - boundingRect.setBottom(rect.bottom() - marginFromEdge); - - return boundingRect; -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/qdeclarativeviewinspector.h b/src/plugins/qmltooling/qmldbg_qtquick1/qdeclarativeviewinspector.h deleted file mode 100644 index ebaf840b91..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/qdeclarativeviewinspector.h +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 <private/qdeclarativeglobal_p.h> - -#include "abstractviewinspector.h" - -#include <QtCore/QScopedPointer> -#include <QtQuick1/QDeclarativeView> - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class AbstractLiveEditTool; -class QDeclarativeViewInspectorPrivate; - -class QDeclarativeViewInspector : public AbstractViewInspector -{ - Q_OBJECT - -public: - explicit QDeclarativeViewInspector(QDeclarativeView *view, QObject *parent = 0); - ~QDeclarativeViewInspector(); - - // AbstractViewInspector - void changeCurrentObjects(const QList<QObject*> &objects); - void reloadView(); - void reparentQmlObject(QObject *object, QObject *newParent); - void changeTool(InspectorProtocol::Tool tool); - Qt::WindowFlags windowFlags() const; - void setWindowFlags(Qt::WindowFlags flags); - QDeclarativeEngine *declarativeEngine() const; - - void setSelectedItems(QList<QGraphicsItem *> items); - QList<QGraphicsItem *> selectedItems() const; - - QDeclarativeView *declarativeView() const; - - QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace); - -protected: - bool eventFilter(QObject *obj, QEvent *event); - - bool leaveEvent(QEvent *); - bool mouseMoveEvent(QMouseEvent *event); - - AbstractLiveEditTool *currentTool() const; - -private: - Q_DISABLE_COPY(QDeclarativeViewInspector) - - inline QDeclarativeViewInspectorPrivate *d_func() { return data.data(); } - QScopedPointer<QDeclarativeViewInspectorPrivate> data; - friend class QDeclarativeViewInspectorPrivate; - friend class AbstractLiveEditTool; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // QDECLARATIVEVIEWINSPECTOR_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/qdeclarativeviewinspector_p.h b/src/plugins/qmltooling/qmldbg_qtquick1/qdeclarativeviewinspector_p.h deleted file mode 100644 index 4f5c850354..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/qdeclarativeviewinspector_p.h +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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_H -#define QDECLARATIVEVIEWINSPECTOR_P_H - -#include "qdeclarativeviewinspector.h" - -#include <QtCore/QScopedPointer> -#include <QtQuick1/QDeclarativeView> -#include <QtCore/QWeakPointer> -#include <QtCore/QPointF> - -#include "QtDeclarative/private/qdeclarativeinspectorservice_p.h" - -namespace QmlJSDebugger { -namespace QtQuick1 { - -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<QWidget> viewport; - - QList<QWeakPointer<QGraphicsObject> > currentSelection; - - LiveSelectionTool *selectionTool; - ZoomTool *zoomTool; - ColorPickerTool *colorPickerTool; - LiveLayerItem *manipulatorLayer; - - BoundingRectHighlighter *boundingRectHighlighter; - - void setViewport(QWidget *widget); - - void clearEditorItems(); - void changeToSelectTool(); - QList<QGraphicsItem*> filterForSelection(QList<QGraphicsItem*> &itemlist) const; - - QList<QGraphicsItem*> selectableItems(const QPoint &pos) const; - QList<QGraphicsItem*> selectableItems(const QPointF &scenePos) const; - QList<QGraphicsItem*> selectableItems(const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const; - - void setSelectedItemsForTools(const QList<QGraphicsItem *> &items); - void setSelectedItems(const QList<QGraphicsItem *> &items); - QList<QGraphicsItem *> selectedItems() const; - - void clearHighlight(); - void highlight(const QList<QGraphicsObject *> &item); - inline void highlight(QGraphicsObject *item) - { highlight(QList<QGraphicsObject*>() << 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(); } -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // QDECLARATIVEVIEWINSPECTOR_P_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/qmldbg_qtquick1.pro b/src/plugins/qmltooling/qmldbg_qtquick1/qmldbg_qtquick1.pro deleted file mode 100644 index b98f463b5d..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/qmldbg_qtquick1.pro +++ /dev/null @@ -1,50 +0,0 @@ -load(qt_module) - -TARGET = qmldbg_qtquick1 -QT += declarative-private core-private gui-private widgets-private qtquick1 opengl-private - -load(qt_plugin) - -DESTDIR = $$QT.declarative.plugins/qmltooling - -INCLUDEPATH *= $$PWD $$PWD/../shared - -SOURCES += \ - abstractliveedittool.cpp \ - boundingrecthighlighter.cpp \ - colorpickertool.cpp \ - livelayeritem.cpp \ - liverubberbandselectionmanipulator.cpp \ - liveselectionindicator.cpp \ - liveselectionrectangle.cpp \ - liveselectiontool.cpp \ - livesingleselectionmanipulator.cpp \ - qdeclarativeviewinspector.cpp \ - qtquick1plugin.cpp \ - ../shared/abstracttool.cpp \ - ../shared/abstractviewinspector.cpp \ - subcomponentmasklayeritem.cpp \ - zoomtool.cpp - -HEADERS += \ - abstractliveedittool.h \ - boundingrecthighlighter.h \ - colorpickertool.h \ - livelayeritem.h \ - liverubberbandselectionmanipulator.h \ - liveselectionindicator.h \ - liveselectionrectangle.h \ - liveselectiontool.h \ - livesingleselectionmanipulator.h \ - qdeclarativeviewinspector.h \ - qdeclarativeviewinspector_p.h \ - qtquick1plugin.h \ - ../shared/abstracttool.h \ - ../shared/abstractviewinspector.h \ - ../shared/qdeclarativeinspectorprotocol.h \ - ../shared/qmlinspectorconstants.h \ - subcomponentmasklayeritem.h \ - zoomtool.h - -target.path += $$[QT_INSTALL_PLUGINS]/qmltooling -INSTALLS += target diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/qtquick1plugin.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/qtquick1plugin.cpp deleted file mode 100644 index d336d1deae..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/qtquick1plugin.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qtquick1plugin.h" -#include "qdeclarativeviewinspector.h" - -#include <QtCore/qplugin.h> -#include <QtDeclarative/private/qdeclarativeinspectorservice_p.h> -#include <QtQuick1/qdeclarativeview.h> - -namespace QmlJSDebugger { -namespace QtQuick1 { - -QtQuick1Plugin::QtQuick1Plugin() : - m_inspector(0) -{ -} - -QtQuick1Plugin::~QtQuick1Plugin() -{ - delete m_inspector; -} - -bool QtQuick1Plugin::canHandleView(QObject *view) -{ - return qobject_cast<QDeclarativeView*>(view); -} - -void QtQuick1Plugin::activate(QObject *view) -{ - QDeclarativeView *qDeclarativeView = qobject_cast<QDeclarativeView*>(view); - Q_ASSERT(qDeclarativeView); - m_inspector = new QDeclarativeViewInspector(qDeclarativeView, qDeclarativeView); -} - -void QtQuick1Plugin::deactivate() -{ - delete m_inspector; -} - -void QtQuick1Plugin::clientMessage(const QByteArray &message) -{ - if (m_inspector) - m_inspector->handleMessage(message); -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -Q_EXPORT_PLUGIN2(qmldbg_qtquick1, QmlJSDebugger::QtQuick1::QtQuick1Plugin) diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/qtquick1plugin.h b/src/plugins/qmltooling/qmldbg_qtquick1/qtquick1plugin.h deleted file mode 100644 index b974f14b20..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/qtquick1plugin.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEINSPECTORPLUGIN_H -#define QDECLARATIVEINSPECTORPLUGIN_H - -#include <QtCore/QPointer> -#include <QtDeclarative/private/qdeclarativeinspectorinterface_p.h> - -namespace QmlJSDebugger { - -class AbstractViewInspector; - -namespace QtQuick1 { - -class QtQuick1Plugin : public QObject, public QDeclarativeInspectorInterface -{ - Q_OBJECT - Q_DISABLE_COPY(QtQuick1Plugin) - Q_INTERFACES(QDeclarativeInspectorInterface) - -public: - QtQuick1Plugin(); - ~QtQuick1Plugin(); - - // QDeclarativeInspectorInterface - bool canHandleView(QObject *view); - void activate(QObject *view); - void deactivate(); - void clientMessage(const QByteArray &message); - -private: - QPointer<AbstractViewInspector> m_inspector; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // QDECLARATIVEINSPECTORPLUGIN_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/subcomponentmasklayeritem.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/subcomponentmasklayeritem.cpp deleted file mode 100644 index d77fd5b13c..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/subcomponentmasklayeritem.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "subcomponentmasklayeritem.h" - -#include "qmlinspectorconstants.h" -#include "qdeclarativeviewinspector.h" - -#include <QtGui/QPolygonF> - -namespace QmlJSDebugger { -namespace QtQuick1 { - -SubcomponentMaskLayerItem::SubcomponentMaskLayerItem(QDeclarativeViewInspector *inspector, - QGraphicsItem *parentItem) : - QGraphicsPolygonItem(parentItem), - m_inspector(inspector), - m_currentItem(0), - m_borderRect(new QGraphicsRectItem(this)) -{ - m_borderRect->setRect(0,0,0,0); - m_borderRect->setPen(QPen(QColor(60, 60, 60), 1)); - m_borderRect->setData(Constants::EditorItemDataKey, QVariant(true)); - - setBrush(QBrush(QColor(160,160,160))); - setPen(Qt::NoPen); -} - -int SubcomponentMaskLayerItem::type() const -{ - return Constants::EditorItemType; -} - -static QRectF resizeRect(const QRectF &newRect, const QRectF &oldRect) -{ - QRectF result = newRect; - if (oldRect.left() < newRect.left()) - result.setLeft(oldRect.left()); - - if (oldRect.top() < newRect.top()) - result.setTop(oldRect.top()); - - if (oldRect.right() > newRect.right()) - result.setRight(oldRect.right()); - - if (oldRect.bottom() > newRect.bottom()) - result.setBottom(oldRect.bottom()); - - return result; -} - -static QPolygonF regionToPolygon(const QRegion ®ion) -{ - QPainterPath path; - foreach (const QRect &rect, region.rects()) - path.addRect(rect); - return path.toFillPolygon(); -} - -void SubcomponentMaskLayerItem::setCurrentItem(QGraphicsItem *item) -{ - QGraphicsItem *prevItem = m_currentItem; - m_currentItem = item; - - if (!m_currentItem) - return; - - QRect viewRect = m_inspector->declarativeView()->rect(); - viewRect = m_inspector->declarativeView()->mapToScene(viewRect).boundingRect().toRect(); - - QRectF itemRect = item->boundingRect() | item->childrenBoundingRect(); - itemRect = item->mapRectToScene(itemRect); - - // if updating the same item as before, resize the rectangle only bigger, not smaller. - if (prevItem == item && prevItem != 0) { - m_itemPolyRect = resizeRect(itemRect, m_itemPolyRect); - } else { - m_itemPolyRect = itemRect; - } - QRectF borderRect = m_itemPolyRect; - borderRect.adjust(-1, -1, 1, 1); - m_borderRect->setRect(borderRect); - - const QRegion externalRegion = QRegion(viewRect).subtracted(m_itemPolyRect.toRect()); - setPolygon(regionToPolygon(externalRegion)); -} - -QGraphicsItem *SubcomponentMaskLayerItem::currentItem() const -{ - return m_currentItem; -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/subcomponentmasklayeritem.h b/src/plugins/qmltooling/qmldbg_qtquick1/subcomponentmasklayeritem.h deleted file mode 100644 index a76e4ffed7..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/subcomponentmasklayeritem.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 <QtWidgets/QGraphicsPolygonItem> - -namespace QmlJSDebugger { -namespace QtQuick1 { - -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 QtQuick1 -} // namespace QmlJSDebugger - -#endif // SUBCOMPONENTMASKLAYERITEM_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/zoomtool.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/zoomtool.cpp deleted file mode 100644 index 77521a3dbd..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/zoomtool.cpp +++ /dev/null @@ -1,330 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "zoomtool.h" - -#include "qdeclarativeviewinspector_p.h" - -#include <QtGui/QMouseEvent> -#include <QtGui/QWheelEvent> -#include <QtGui/QKeyEvent> -#include <QtWidgets/QMenu> -#include <QtWidgets/QAction> - -#include <QtCore/QRectF> -#include <QtCore/QDebug> - -namespace QmlJSDebugger { -namespace QtQuick1 { - -ZoomTool::ZoomTool(QDeclarativeViewInspector *view) : - AbstractLiveEditTool(view), - m_rubberbandManipulator(), - m_smoothZoomMultiplier(0.05f), - m_currentScale(1.0f) -{ - m_zoomTo100Action = new QAction(tr("Zoom to &100%"), this); - m_zoomInAction = new QAction(tr("Zoom In"), this); - m_zoomOutAction = new QAction(tr("Zoom Out"), this); - m_zoomInAction->setShortcut(QKeySequence(Qt::Key_Plus)); - m_zoomOutAction->setShortcut(QKeySequence(Qt::Key_Minus)); - - - LiveLayerItem *layerItem = QDeclarativeViewInspectorPrivate::get(view)->manipulatorLayer; - QGraphicsObject *layerObject = reinterpret_cast<QGraphicsObject *>(layerItem); - m_rubberbandManipulator = new LiveRubberBandSelectionManipulator(layerObject, view); - - - connect(m_zoomTo100Action, SIGNAL(triggered()), SLOT(zoomTo100())); - connect(m_zoomInAction, SIGNAL(triggered()), SLOT(zoomIn())); - connect(m_zoomOutAction, SIGNAL(triggered()), SLOT(zoomOut())); -} - -ZoomTool::~ZoomTool() -{ - delete m_rubberbandManipulator; -} - -void ZoomTool::mousePressEvent(QMouseEvent *event) -{ - m_mousePos = event->pos(); - - QPointF scenePos = view()->mapToScene(event->pos()); - - if (event->buttons() & Qt::RightButton) { - QMenu contextMenu; - contextMenu.addAction(m_zoomTo100Action); - contextMenu.addSeparator(); - contextMenu.addAction(m_zoomInAction); - contextMenu.addAction(m_zoomOutAction); - contextMenu.exec(event->globalPos()); - } else if (event->buttons() & Qt::LeftButton) { - m_dragBeginPos = scenePos; - m_dragStarted = false; - } -} - -void ZoomTool::mouseMoveEvent(QMouseEvent *event) -{ - m_mousePos = event->pos(); - - QPointF scenePos = view()->mapToScene(event->pos()); - - if (event->buttons() & Qt::LeftButton - && (QPointF(scenePos - m_dragBeginPos).manhattanLength() - > Constants::DragStartDistance / 3) - && !m_dragStarted) - { - m_dragStarted = true; - m_rubberbandManipulator->begin(m_dragBeginPos); - return; - } - - if (m_dragStarted) - m_rubberbandManipulator->update(scenePos); - -} - -void ZoomTool::mouseReleaseEvent(QMouseEvent *event) -{ - m_mousePos = event->pos(); - QPointF scenePos = view()->mapToScene(event->pos()); - - if (m_dragStarted) { - m_rubberbandManipulator->end(); - - int x1 = qMin(scenePos.x(), m_rubberbandManipulator->beginPoint().x()); - int x2 = qMax(scenePos.x(), m_rubberbandManipulator->beginPoint().x()); - int y1 = qMin(scenePos.y(), m_rubberbandManipulator->beginPoint().y()); - int y2 = qMax(scenePos.y(), m_rubberbandManipulator->beginPoint().y()); - - QPointF scenePosTopLeft = QPoint(x1, y1); - QPointF scenePosBottomRight = QPoint(x2, y2); - - QRectF sceneArea(scenePosTopLeft, scenePosBottomRight); - - m_currentScale = qMin(view()->rect().width() / sceneArea.width(), - view()->rect().height() / sceneArea.height()); - - - QTransform transform; - transform.scale(m_currentScale, m_currentScale); - - view()->setTransform(transform); - view()->setSceneRect(sceneArea); - } else { - Qt::KeyboardModifier modifierKey = Qt::ControlModifier; -#ifdef Q_OS_MAC - modifierKey = Qt::AltModifier; -#endif - if (event->modifiers() & modifierKey) { - zoomOut(); - } else { - zoomIn(); - } - } -} - -void ZoomTool::zoomIn() -{ - m_currentScale = nextZoomScale(ZoomIn); - scaleView(view()->mapToScene(m_mousePos)); -} - -void ZoomTool::zoomOut() -{ - m_currentScale = nextZoomScale(ZoomOut); - scaleView(view()->mapToScene(m_mousePos)); -} - -void ZoomTool::mouseDoubleClickEvent(QMouseEvent *event) -{ - m_mousePos = event->pos(); -} - - -void ZoomTool::hoverMoveEvent(QMouseEvent *event) -{ - m_mousePos = event->pos(); -} - - -void ZoomTool::keyPressEvent(QKeyEvent * /*event*/) -{ -} - -void ZoomTool::wheelEvent(QWheelEvent *event) -{ - if (event->orientation() != Qt::Vertical) - return; - - Qt::KeyboardModifier smoothZoomModifier = Qt::ControlModifier; - if (event->modifiers() & smoothZoomModifier) { - int numDegrees = event->delta() / 8; - m_currentScale += m_smoothZoomMultiplier * (numDegrees / 15.0f); - - scaleView(view()->mapToScene(m_mousePos)); - - } else if (!event->modifiers()) { - if (event->delta() > 0) { - m_currentScale = nextZoomScale(ZoomIn); - } else if (event->delta() < 0) { - m_currentScale = nextZoomScale(ZoomOut); - } - scaleView(view()->mapToScene(m_mousePos)); - } -} - -void ZoomTool::keyReleaseEvent(QKeyEvent *event) -{ - switch (event->key()) { - case Qt::Key_Plus: - zoomIn(); - break; - case Qt::Key_Minus: - zoomOut(); - break; - case Qt::Key_1: - case Qt::Key_2: - case Qt::Key_3: - case Qt::Key_4: - case Qt::Key_5: - case Qt::Key_6: - case Qt::Key_7: - case Qt::Key_8: - case Qt::Key_9: - { - m_currentScale = ((event->key() - Qt::Key_0) * 1.0f); - scaleView(view()->mapToScene(m_mousePos)); // view()->mapToScene(view()->rect().center()) - break; - } - - default: - break; - } - -} - -void ZoomTool::clear() -{ - view()->setCursor(Qt::ArrowCursor); -} - -void ZoomTool::scaleView(const QPointF ¢erPos) -{ - - QTransform transform; - transform.scale(m_currentScale, m_currentScale); - view()->setTransform(transform); - - QPointF adjustedCenterPos = centerPos; - QSize rectSize(view()->rect().width() / m_currentScale, - view()->rect().height() / m_currentScale); - - QRectF sceneRect; - if (qAbs(m_currentScale - 1.0f) < Constants::ZoomSnapDelta) { - adjustedCenterPos.rx() = rectSize.width() / 2; - adjustedCenterPos.ry() = rectSize.height() / 2; - } - - if (m_currentScale < 1.0f) { - adjustedCenterPos.rx() = rectSize.width() / 2; - adjustedCenterPos.ry() = rectSize.height() / 2; - sceneRect.setRect(view()->rect().width() / 2 -rectSize.width() / 2, - view()->rect().height() / 2 -rectSize.height() / 2, - rectSize.width(), - rectSize.height()); - } else { - sceneRect.setRect(adjustedCenterPos.x() - rectSize.width() / 2, - adjustedCenterPos.y() - rectSize.height() / 2, - rectSize.width(), - rectSize.height()); - } - - view()->setSceneRect(sceneRect); -} - -void ZoomTool::zoomTo100() -{ - m_currentScale = 1.0f; - scaleView(view()->mapToScene(view()->rect().center())); -} - -qreal ZoomTool::nextZoomScale(ZoomDirection direction) const -{ - static QList<qreal> zoomScales = - QList<qreal>() - << 0.125f - << 1.0f / 6.0f - << 0.25f - << 1.0f / 3.0f - << 0.5f - << 2.0f / 3.0f - << 1.0f - << 2.0f - << 3.0f - << 4.0f - << 5.0f - << 6.0f - << 7.0f - << 8.0f - << 12.0f - << 16.0f - << 32.0f - << 48.0f; - - if (direction == ZoomIn) { - for (int i = 0; i < zoomScales.length(); ++i) { - if (zoomScales[i] > m_currentScale || i == zoomScales.length() - 1) - return zoomScales[i]; - } - } else { - for (int i = zoomScales.length() - 1; i >= 0; --i) { - if (zoomScales[i] < m_currentScale || i == 0) - return zoomScales[i]; - } - } - - return 1.0f; -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/zoomtool.h b/src/plugins/qmltooling/qmldbg_qtquick1/zoomtool.h deleted file mode 100644 index f6855c43f4..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/zoomtool.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 { -namespace QtQuick1 { - -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<QGraphicsItem*> &) {} - - void clear(); - -protected: - void selectedItemsChanged(const QList<QGraphicsItem*> &) {} - -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 QtQuick1 -} // namespace QmlJSDebugger - -#endif // ZOOMTOOL_H diff --git a/src/plugins/qmltooling/qmltooling.pro b/src/plugins/qmltooling/qmltooling.pro index d03ee07fc9..41e1c65a6b 100644 --- a/src/plugins/qmltooling/qmltooling.pro +++ b/src/plugins/qmltooling/qmltooling.pro @@ -2,4 +2,3 @@ TEMPLATE = subdirs SUBDIRS = qmldbg_tcp SUBDIRS += qmldbg_qtquick2 -SUBDIRS += qmldbg_qtquick1 diff --git a/src/qmltest/qmltest.pro b/src/qmltest/qmltest.pro index cc2466639c..39b7dc8a3f 100644 --- a/src/qmltest/qmltest.pro +++ b/src/qmltest/qmltest.pro @@ -7,10 +7,9 @@ CONFIG += module CONFIG += dll warn_on declarative_debug MODULE_PRI += ../../modules/qt_qmltest.pri -QT += testlib-private declarative testlib quick qtquick1 widgets widgets-private gui +QT += testlib-private declarative testlib quick widgets widgets-private gui DEFINES += QT_BUILD_QUICK_TEST_LIB QT_NO_URL_CAST_FROM_STRING - load(qt_module_config) # Install qmltestcase.prf into the Qt mkspecs so that "CONFIG += qmltestcase" diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp index dbc4fc75a1..28033785ba 100644 --- a/src/qmltest/quicktest.cpp +++ b/src/qmltest/quicktest.cpp @@ -45,7 +45,6 @@ #include "qtestoptions_p.h" #include <QApplication> #include <QtDeclarative/qdeclarative.h> -#include <QtQuick1/qdeclarativeview.h> #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativecontext.h> #if defined(QML_VERSION) && QML_VERSION >= 0x020000 @@ -331,47 +330,8 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport } else #endif { - foreach (QString file, files) { - QFileInfo fi(file); - if (!fi.exists()) - continue; - QDeclarativeView view; - QTestRootObject rootobj; - QEventLoop eventLoop; - QObject::connect(view.engine(), SIGNAL(quit()), - &rootobj, SLOT(quit())); - QObject::connect(view.engine(), SIGNAL(quit()), - &eventLoop, SLOT(quit())); - if (createViewport) - view.setViewport((*createViewport)()); - view.rootContext()->setContextProperty - (QLatin1String("qtest"), &rootobj); - foreach (QString path, imports) - view.engine()->addImportPath(path); - QString path = fi.absoluteFilePath(); - if (path.startsWith(QLatin1String(":/"))) - view.setSource(QUrl(QLatin1String("qrc:") + path.mid(2))); - else - view.setSource(QUrl::fromLocalFile(path)); - if (QTest::printAvailableFunctions) - continue; - if (view.status() == QDeclarativeView::Error) { - // Error compiling the test - flag failure in the log and continue. - handleCompileErrors(fi, view); - continue; - } - if (!rootobj.hasQuit) { - // If the test already quit, then it was performed - // synchronously during setSource(). Otherwise it is - // an asynchronous test and we need to show the window - // and wait for the quit indication. - view.show(); - QTest::qWaitForWindowShown(&view); - rootobj.setWindowShown(true); - if (!rootobj.hasQuit) - eventLoop.exec(); - } - } + qWarning("No suitable QtQuick1 implementation is available!"); + return 1; } // Flush the current logging stream. diff --git a/src/qmltest/quicktestevent.cpp b/src/qmltest/quicktestevent.cpp index 6551d2feaa..4dee9bee77 100644 --- a/src/qmltest/quicktestevent.cpp +++ b/src/qmltest/quicktestevent.cpp @@ -42,8 +42,6 @@ #include "quicktestevent_p.h" #include <QtTest/qtestkeyboard.h> #include <QtDeclarative/qdeclarative.h> -#include <QtQuick1/qdeclarativeitem.h> -#include <QtQuick1/qdeclarativeview.h> #if defined(QML_VERSION) && QML_VERSION >= 0x020000 #include <QtQuick/qquickitem.h> #include <QtQuick/qquickcanvas.h> @@ -116,8 +114,6 @@ namespace QtQuickTest } QPoint pos; - QDeclarativeView *view = qobject_cast<QDeclarativeView *>(window); - QWindow *eventWindow = window; #ifdef QUICK_TEST_SCENEGRAPH QQuickItem *sgitem = qobject_cast<QQuickItem *>(item); if (sgitem) { @@ -125,13 +121,7 @@ namespace QtQuickTest } else #endif { - QDeclarativeItem *ditem = qobject_cast<QDeclarativeItem *>(item); - if (!ditem) { - qWarning("Mouse event target is not an Item"); - return; - } - pos = view->mapFromScene(ditem->mapToScene(_pos)); - eventWindow = view->viewport()->windowHandle(); + qWarning("No suitable QtQuick1 implementation is available!"); } QTEST_ASSERT(button == Qt::NoButton || button & Qt::MouseButtonMask); QTEST_ASSERT(stateKey == 0 || stateKey & Qt::KeyboardModifierMask); @@ -158,7 +148,7 @@ namespace QtQuickTest QTEST_ASSERT(false); } QSpontaneKeyEvent::setSpontaneous(&me); - if (!qApp->notify(eventWindow, &me)) { + if (!qApp->notify(window, &me)) { static const char *mouseActionNames[] = { "MousePress", "MouseRelease", "MouseClick", "MouseDoubleClick", "MouseMove" }; QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving window"); @@ -178,8 +168,6 @@ namespace QtQuickTest QTest::qWait(delay); QPoint pos; - QDeclarativeView *view = qobject_cast<QDeclarativeView *>(window); - QWindow *eventWindow = window; #ifdef QUICK_TEST_SCENEGRAPH QQuickItem *sgitem = qobject_cast<QQuickItem *>(item); if (sgitem) { @@ -187,13 +175,7 @@ namespace QtQuickTest } else #endif { - QDeclarativeItem *ditem = qobject_cast<QDeclarativeItem *>(item); - if (!ditem) { - qWarning("Mouse event target is not an Item"); - return; - } - pos = view->mapFromScene(ditem->mapToScene(_pos)); - eventWindow = view->viewport()->windowHandle(); + qWarning("No suitable QtQuick1 implementation is available!"); } QTEST_ASSERT(buttons == Qt::NoButton || buttons & Qt::MouseButtonMask); QTEST_ASSERT(stateKey == 0 || stateKey & Qt::KeyboardModifierMask); @@ -202,7 +184,7 @@ namespace QtQuickTest QWheelEvent we(pos, window->mapToGlobal(pos), delta, buttons, stateKey, orientation); QSpontaneKeyEvent::setSpontaneous(&we); // hmmmm - if (!qApp->notify(eventWindow, &we)) + if (!qApp->notify(window, &we)) QTest::qWarn("Wheel event not accepted by receiving window"); } }; @@ -295,6 +277,8 @@ QWindow *QuickTestEvent::eventWindow() if (sgitem) return sgitem->canvas(); #endif + return 0; + /* QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(parent()); if (!item) return 0; @@ -305,6 +289,7 @@ QWindow *QuickTestEvent::eventWindow() if (views.isEmpty()) return 0; return views.at(0)->windowHandle(); + */ } QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/graphicsitems.pri b/src/qtquick1/graphicsitems/graphicsitems.pri deleted file mode 100644 index d3125d0b66..0000000000 --- a/src/qtquick1/graphicsitems/graphicsitems.pri +++ /dev/null @@ -1,96 +0,0 @@ -INCLUDEPATH += $$PWD - -HEADERS += \ - $$PWD/qdeclarativeitemsmodule_p.h \ - $$PWD/qdeclarativeaccessibleattached_p.h \ - $$PWD/qdeclarativeanchors_p.h \ - $$PWD/qdeclarativeanchors_p_p.h \ - $$PWD/qdeclarativeevents_p_p.h \ - $$PWD/qdeclarativeflickable_p.h \ - $$PWD/qdeclarativeflickable_p_p.h \ - $$PWD/qdeclarativeflipable_p.h \ - $$PWD/qdeclarativegridview_p.h \ - $$PWD/qdeclarativeimage_p.h \ - $$PWD/qdeclarativeimagebase_p.h \ - $$PWD/qdeclarativeborderimage_p.h \ - $$PWD/qdeclarativepainteditem_p.h \ - $$PWD/qdeclarativepainteditem_p_p.h \ - $$PWD/qdeclarativeimage_p_p.h \ - $$PWD/qdeclarativeborderimage_p_p.h \ - $$PWD/qdeclarativeimagebase_p_p.h \ - $$PWD/qdeclarativeanimatedimage_p.h \ - $$PWD/qdeclarativeanimatedimage_p_p.h \ - $$PWD/qdeclarativeitem.h \ - $$PWD/qdeclarativeitem_p.h \ - $$PWD/qdeclarativefocuspanel_p.h \ - $$PWD/qdeclarativefocusscope_p.h \ - $$PWD/qdeclarativepositioners_p.h \ - $$PWD/qdeclarativepositioners_p_p.h \ - $$PWD/qdeclarativeloader_p.h \ - $$PWD/qdeclarativeloader_p_p.h \ - $$PWD/qdeclarativemousearea_p.h \ - $$PWD/qdeclarativemousearea_p_p.h \ - $$PWD/qdeclarativepath_p.h \ - $$PWD/qdeclarativepath_p_p.h \ - $$PWD/qdeclarativepathview_p.h \ - $$PWD/qdeclarativepathview_p_p.h \ - $$PWD/qdeclarativerectangle_p.h \ - $$PWD/qdeclarativerectangle_p_p.h \ - $$PWD/qdeclarativerepeater_p.h \ - $$PWD/qdeclarativerepeater_p_p.h \ - $$PWD/qdeclarativescalegrid_p_p.h \ - $$PWD/qdeclarativetranslate_p.h \ - $$PWD/qdeclarativetextinput_p.h \ - $$PWD/qdeclarativetextinput_p_p.h \ - $$PWD/qdeclarativetextedit_p.h \ - $$PWD/qdeclarativetextedit_p_p.h \ - $$PWD/qdeclarativetext_p.h \ - $$PWD/qdeclarativetext_p_p.h \ - $$PWD/qdeclarativevisualitemmodel_p.h \ - $$PWD/qdeclarativelistview_p.h \ - $$PWD/qdeclarativelayoutitem_p.h \ - $$PWD/qdeclarativeitemchangelistener_p.h \ - $$PWD/qdeclarativegraphicswidget_p.h \ - $$PWD/qdeclarativetextlayout_p.h \ - $$PWD/qdeclarativepincharea_p.h \ - $$PWD/qdeclarativepincharea_p_p.h \ - $$PWD/qdeclarativeimplicitsizeitem_p.h \ - $$PWD/qdeclarativeimplicitsizeitem_p_p.h - - -SOURCES += \ - $$PWD/qdeclarativeitemsmodule.cpp \ - $$PWD/qdeclarativeaccessibleattached.cpp \ - $$PWD/qdeclarativeanchors.cpp \ - $$PWD/qdeclarativeevents.cpp \ - $$PWD/qdeclarativeflickable.cpp \ - $$PWD/qdeclarativeflipable.cpp \ - $$PWD/qdeclarativegridview.cpp \ - $$PWD/qdeclarativeimage.cpp \ - $$PWD/qdeclarativeborderimage.cpp \ - $$PWD/qdeclarativeimagebase.cpp \ - $$PWD/qdeclarativeanimatedimage.cpp \ - $$PWD/qdeclarativepainteditem.cpp \ - $$PWD/qdeclarativeitem.cpp \ - $$PWD/qdeclarativefocuspanel.cpp \ - $$PWD/qdeclarativefocusscope.cpp \ - $$PWD/qdeclarativepositioners.cpp \ - $$PWD/qdeclarativeloader.cpp \ - $$PWD/qdeclarativemousearea.cpp \ - $$PWD/qdeclarativepath.cpp \ - $$PWD/qdeclarativepathview.cpp \ - $$PWD/qdeclarativerectangle.cpp \ - $$PWD/qdeclarativerepeater.cpp \ - $$PWD/qdeclarativescalegrid.cpp \ - $$PWD/qdeclarativetranslate.cpp \ - $$PWD/qdeclarativetextinput.cpp \ - $$PWD/qdeclarativetext.cpp \ - $$PWD/qdeclarativetextedit.cpp \ - $$PWD/qdeclarativevisualitemmodel.cpp \ - $$PWD/qdeclarativelistview.cpp \ - $$PWD/qdeclarativelayoutitem.cpp \ - $$PWD/qdeclarativegraphicswidget.cpp \ - $$PWD/qdeclarativetextlayout.cpp \ - $$PWD/qdeclarativepincharea.cpp \ - $$PWD/qdeclarativeimplicitsizeitem.cpp - diff --git a/src/qtquick1/graphicsitems/qdeclarativeaccessibleattached.cpp b/src/qtquick1/graphicsitems/qdeclarativeaccessibleattached.cpp deleted file mode 100644 index 3a5d09b92f..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeaccessibleattached.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qdeclarativeaccessibleattached_p.h" - -#ifndef QT_NO_ACCESSIBILITY - -#include "private/qdeclarativeitem_p.h" - -QT_BEGIN_NAMESPACE - - -QDeclarativeAccessibleAttached::QDeclarativeAccessibleAttached(QObject *parent) - : QObject(parent) -{ - Q_ASSERT(parent); - QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(parent); - if (!item) - return; - - // Enable accessibility for items with accessible content. This also - // enables accessibility for the ancestors of such items. - item->d_func()->setAccessibleFlagAndListener(); - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ObjectCreated, item, 0)); -} - -QDeclarativeAccessibleAttached::~QDeclarativeAccessibleAttached() -{ -} - -QDeclarativeAccessibleAttached *QDeclarativeAccessibleAttached::qmlAttachedProperties(QObject *obj) -{ - return new QDeclarativeAccessibleAttached(obj); -} - -QT_END_NAMESPACE - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativeaccessibleattached_p.h b/src/qtquick1/graphicsitems/qdeclarativeaccessibleattached_p.h deleted file mode 100644 index 6fccb7948f..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeaccessibleattached_p.h +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QQUICK1ACCESSIBLEATTACHED_H -#define QQUICK1ACCESSIBLEATTACHED_H - -#include <qdeclarativeitem.h> - -#include <QtCore/qobject.h> -#include <QtCore/qstring.h> - -#ifndef QT_NO_ACCESSIBILITY - -#include <private/qdeclarativeglobal_p.h> -#include <QtGui/qaccessible.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class Q_QTQUICK1_EXPORT QDeclarativeAccessibleAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QAccessible::Role role READ role WRITE setRole NOTIFY roleChanged) - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged) - -public: - Q_ENUMS(QAccessible::Role QAccessible::Event QAccessible::State) - - QDeclarativeAccessibleAttached(QObject *parent); - ~QDeclarativeAccessibleAttached(); - - QAccessible::Role role() const { return m_role; } - void setRole(QAccessible::Role role) - { - m_role = role; - emit roleChanged(); - // There is no way to signify role changes at the moment. - // QAccessible::updateAccessibility(parent(), 0, QAccessible::); - } - QString name() const { return m_name; } - void setName(const QString &name) - { - m_name = name; - emit nameChanged(); - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::NameChanged, parent(), 0)); - } - - QString description() const { return m_description; } - void setDescription(const QString &description) - { - m_description = description; - emit descriptionChanged(); - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::DescriptionChanged, parent(), 0)); - } - - // Factory function - static QDeclarativeAccessibleAttached *qmlAttachedProperties(QObject *); - - // Property getter - static QObject *attachedProperties(const QObject *obj) - { - return qmlAttachedPropertiesObject<QDeclarativeAccessibleAttached>(obj, false); - } - - static QVariant property(const QObject *object, const char *propertyName) - { - if (QObject *attachedObject = QDeclarativeAccessibleAttached::attachedProperties(object)) - return attachedObject->property(propertyName); - return QVariant(); - } - - static bool setProperty(QObject *object, const char *propertyName, const QVariant &value) - { - QObject *obj = qmlAttachedPropertiesObject<QDeclarativeAccessibleAttached>(object, true); - if (!obj) { - qWarning("cannot set property Accessible.%s of QObject %s", propertyName, object->metaObject()->className()); - return false; - } - return obj->setProperty(propertyName, value); - } - - -Q_SIGNALS: - void roleChanged(); - void nameChanged(); - void descriptionChanged(); -private: - QAccessible::Role m_role; - QString m_name; - QString m_description; -public: - using QObject::property; -}; - - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeAccessibleAttached) -QML_DECLARE_TYPEINFO(QDeclarativeAccessibleAttached, QML_HAS_ATTACHED_PROPERTIES) - -QT_END_HEADER - -#endif // QT_NO_ACCESSIBILITY - -#endif - diff --git a/src/qtquick1/graphicsitems/qdeclarativeanchors.cpp b/src/qtquick1/graphicsitems/qdeclarativeanchors.cpp deleted file mode 100644 index 821abe1c15..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeanchors.cpp +++ /dev/null @@ -1,1169 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "QtQuick1/private/qdeclarativeanchors_p_p.h" - -#include "QtQuick1/qdeclarativeitem.h" -#include "QtQuick1/private/qdeclarativeitem_p.h" - -#include <QtDeclarative/qdeclarativeinfo.h> - -#include <QDebug> - -QT_BEGIN_NAMESPACE - - - -//TODO: should we cache relationships, so we don't have to check each time (parent-child or sibling)? -//TODO: support non-parent, non-sibling (need to find lowest common ancestor) - -static qreal hcenter(QGraphicsItem *i) -{ - QGraphicsItemPrivate *item = QGraphicsItemPrivate::get(i); - - qreal width = item->width(); - int iw = width; - if (iw % 2) - return (width + 1) / 2; - else - return width / 2; -} - -static qreal vcenter(QGraphicsItem *i) -{ - QGraphicsItemPrivate *item = QGraphicsItemPrivate::get(i); - - qreal height = item->height(); - int ih = height; - if (ih % 2) - return (height + 1) / 2; - else - return height / 2; -} - -//### const item? -//local position -static qreal position(QGraphicsObject *item, QDeclarative1AnchorLine::AnchorLine anchorLine) -{ - qreal ret = 0.0; - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(item); - switch(anchorLine) { - case QDeclarative1AnchorLine::Left: - ret = item->x(); - break; - case QDeclarative1AnchorLine::Right: - ret = item->x() + d->width(); - break; - case QDeclarative1AnchorLine::Top: - ret = item->y(); - break; - case QDeclarative1AnchorLine::Bottom: - ret = item->y() + d->height(); - break; - case QDeclarative1AnchorLine::HCenter: - ret = item->x() + hcenter(item); - break; - case QDeclarative1AnchorLine::VCenter: - ret = item->y() + vcenter(item); - break; - case QDeclarative1AnchorLine::Baseline: - if (d->isDeclarativeItem) - ret = item->y() + static_cast<QDeclarativeItem*>(item)->baselineOffset(); - break; - default: - break; - } - - return ret; -} - -//position when origin is 0,0 -static qreal adjustedPosition(QGraphicsObject *item, QDeclarative1AnchorLine::AnchorLine anchorLine) -{ - qreal ret = 0.0; - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(item); - switch(anchorLine) { - case QDeclarative1AnchorLine::Left: - ret = 0.0; - break; - case QDeclarative1AnchorLine::Right: - ret = d->width(); - break; - case QDeclarative1AnchorLine::Top: - ret = 0.0; - break; - case QDeclarative1AnchorLine::Bottom: - ret = d->height(); - break; - case QDeclarative1AnchorLine::HCenter: - ret = hcenter(item); - break; - case QDeclarative1AnchorLine::VCenter: - ret = vcenter(item); - break; - case QDeclarative1AnchorLine::Baseline: - if (d->isDeclarativeItem) - ret = static_cast<QDeclarativeItem*>(item)->baselineOffset(); - break; - default: - break; - } - - return ret; -} - -QDeclarative1Anchors::QDeclarative1Anchors(QObject *parent) - : QObject(*new QDeclarative1AnchorsPrivate(0), parent) -{ - qFatal("QDeclarative1Anchors::QDeclarative1Anchors(QObject*) called"); -} - -QDeclarative1Anchors::QDeclarative1Anchors(QGraphicsObject *item, QObject *parent) - : QObject(*new QDeclarative1AnchorsPrivate(item), parent) -{ -} - -QDeclarative1Anchors::~QDeclarative1Anchors() -{ - Q_D(QDeclarative1Anchors); - d->remDepend(d->fill); - d->remDepend(d->centerIn); - d->remDepend(d->left.item); - d->remDepend(d->right.item); - d->remDepend(d->top.item); - d->remDepend(d->bottom.item); - d->remDepend(d->vCenter.item); - d->remDepend(d->hCenter.item); - d->remDepend(d->baseline.item); -} - -void QDeclarative1AnchorsPrivate::fillChanged() -{ - Q_Q(QDeclarative1Anchors); - if (!fill || !isItemComplete()) - return; - - if (updatingFill < 2) { - ++updatingFill; - - qreal horizontalMargin = q->mirrored() ? rightMargin : leftMargin; - - if (fill == item->parentItem()) { //child-parent - setItemPos(QPointF(horizontalMargin, topMargin)); - } else if (fill->parentItem() == item->parentItem()) { //siblings - setItemPos(QPointF(fill->x()+horizontalMargin, fill->y()+topMargin)); - } - QGraphicsItemPrivate *fillPrivate = QGraphicsItemPrivate::get(fill); - setItemSize(QSizeF(fillPrivate->width()-leftMargin-rightMargin, fillPrivate->height()-topMargin-bottomMargin)); - - --updatingFill; - } else { - // ### Make this certain :) - qmlInfo(item) << QDeclarative1Anchors::tr("Possible anchor loop detected on fill."); - } - -} - -void QDeclarative1AnchorsPrivate::centerInChanged() -{ - Q_Q(QDeclarative1Anchors); - if (!centerIn || fill || !isItemComplete()) - return; - - if (updatingCenterIn < 2) { - ++updatingCenterIn; - - qreal effectiveHCenterOffset = q->mirrored() ? -hCenterOffset : hCenterOffset; - if (centerIn == item->parentItem()) { - QPointF p(hcenter(item->parentItem()) - hcenter(item) + effectiveHCenterOffset, - vcenter(item->parentItem()) - vcenter(item) + vCenterOffset); - setItemPos(p); - - } else if (centerIn->parentItem() == item->parentItem()) { - QPointF p(centerIn->x() + hcenter(centerIn) - hcenter(item) + effectiveHCenterOffset, - centerIn->y() + vcenter(centerIn) - vcenter(item) + vCenterOffset); - setItemPos(p); - } - - --updatingCenterIn; - } else { - // ### Make this certain :) - qmlInfo(item) << QDeclarative1Anchors::tr("Possible anchor loop detected on centerIn."); - } -} - -void QDeclarative1AnchorsPrivate::clearItem(QGraphicsObject *item) -{ - if (!item) - return; - if (fill == item) - fill = 0; - if (centerIn == item) - centerIn = 0; - if (left.item == item) { - left.item = 0; - usedAnchors &= ~QDeclarative1Anchors::LeftAnchor; - } - if (right.item == item) { - right.item = 0; - usedAnchors &= ~QDeclarative1Anchors::RightAnchor; - } - if (top.item == item) { - top.item = 0; - usedAnchors &= ~QDeclarative1Anchors::TopAnchor; - } - if (bottom.item == item) { - bottom.item = 0; - usedAnchors &= ~QDeclarative1Anchors::BottomAnchor; - } - if (vCenter.item == item) { - vCenter.item = 0; - usedAnchors &= ~QDeclarative1Anchors::VCenterAnchor; - } - if (hCenter.item == item) { - hCenter.item = 0; - usedAnchors &= ~QDeclarative1Anchors::HCenterAnchor; - } - if (baseline.item == item) { - baseline.item = 0; - usedAnchors &= ~QDeclarative1Anchors::BaselineAnchor; - } -} - -void QDeclarative1AnchorsPrivate::addDepend(QGraphicsObject *item) -{ - if (!item) - return; - QGraphicsItemPrivate * itemPrivate = QGraphicsItemPrivate::get(item); - if (itemPrivate->isDeclarativeItem) { - QDeclarativeItemPrivate *p = - static_cast<QDeclarativeItemPrivate *>(QGraphicsItemPrivate::get(item)); - p->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - } else if(itemPrivate->isWidget) { - Q_Q(QDeclarative1Anchors); - QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item); - QObject::connect(widget, SIGNAL(destroyed(QObject*)), q, SLOT(_q_widgetDestroyed(QObject*))); - QObject::connect(widget, SIGNAL(geometryChanged()), q, SLOT(_q_widgetGeometryChanged())); - } -} - -void QDeclarative1AnchorsPrivate::remDepend(QGraphicsObject *item) -{ - if (!item) - return; - QGraphicsItemPrivate * itemPrivate = QGraphicsItemPrivate::get(item); - if (itemPrivate->isDeclarativeItem) { - QDeclarativeItemPrivate *p = - static_cast<QDeclarativeItemPrivate *>(itemPrivate); - p->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - } else if(itemPrivate->isWidget) { - Q_Q(QDeclarative1Anchors); - QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item); - QObject::disconnect(widget, SIGNAL(destroyed(QObject*)), q, SLOT(_q_widgetDestroyed(QObject*))); - QObject::disconnect(widget, SIGNAL(geometryChanged()), q, SLOT(_q_widgetGeometryChanged())); - } -} - -bool QDeclarative1AnchorsPrivate::isItemComplete() const -{ - return componentComplete; -} - -void QDeclarative1Anchors::classBegin() -{ - Q_D(QDeclarative1Anchors); - d->componentComplete = false; -} - -void QDeclarative1Anchors::componentComplete() -{ - Q_D(QDeclarative1Anchors); - d->componentComplete = true; -} - -bool QDeclarative1Anchors::mirrored() -{ - Q_D(QDeclarative1Anchors); - QGraphicsItemPrivate * itemPrivate = QGraphicsItemPrivate::get(d->item); - return itemPrivate->isDeclarativeItem ? static_cast<QDeclarativeItemPrivate *>(itemPrivate)->effectiveLayoutMirror : false; -} - -void QDeclarative1AnchorsPrivate::setItemHeight(qreal v) -{ - updatingMe = true; - QGraphicsItemPrivate::get(item)->setHeight(v); - updatingMe = false; -} - -void QDeclarative1AnchorsPrivate::setItemWidth(qreal v) -{ - updatingMe = true; - QGraphicsItemPrivate::get(item)->setWidth(v); - updatingMe = false; -} - -void QDeclarative1AnchorsPrivate::setItemX(qreal v) -{ - updatingMe = true; - item->setX(v); - updatingMe = false; -} - -void QDeclarative1AnchorsPrivate::setItemY(qreal v) -{ - updatingMe = true; - item->setY(v); - updatingMe = false; -} - -void QDeclarative1AnchorsPrivate::setItemPos(const QPointF &v) -{ - updatingMe = true; - item->setPos(v); - updatingMe = false; -} - -void QDeclarative1AnchorsPrivate::setItemSize(const QSizeF &v) -{ - updatingMe = true; - if(QGraphicsItemPrivate::get(item)->isWidget) - static_cast<QGraphicsWidget *>(item)->resize(v); - else if (QGraphicsItemPrivate::get(item)->isDeclarativeItem) - static_cast<QDeclarativeItem *>(item)->setSize(v); - updatingMe = false; -} - -void QDeclarative1AnchorsPrivate::updateMe() -{ - if (updatingMe) { - updatingMe = false; - return; - } - - fillChanged(); - centerInChanged(); - updateHorizontalAnchors(); - updateVerticalAnchors(); -} - -void QDeclarative1AnchorsPrivate::updateOnComplete() -{ - fillChanged(); - centerInChanged(); - updateHorizontalAnchors(); - updateVerticalAnchors(); -} - -void QDeclarative1AnchorsPrivate::_q_widgetDestroyed(QObject *obj) -{ - clearItem(qobject_cast<QGraphicsObject*>(obj)); -} - -void QDeclarative1AnchorsPrivate::_q_widgetGeometryChanged() -{ - fillChanged(); - centerInChanged(); - updateHorizontalAnchors(); - updateVerticalAnchors(); -} - -void QDeclarative1AnchorsPrivate::itemGeometryChanged(QDeclarativeItem *, const QRectF &newG, const QRectF &oldG) -{ - fillChanged(); - centerInChanged(); - if (newG.x() != oldG.x() || newG.width() != oldG.width()) - updateHorizontalAnchors(); - if (newG.y() != oldG.y() || newG.height() != oldG.height()) - updateVerticalAnchors(); -} - -QGraphicsObject *QDeclarative1Anchors::fill() const -{ - Q_D(const QDeclarative1Anchors); - return d->fill; -} - -void QDeclarative1Anchors::setFill(QGraphicsObject *f) -{ - Q_D(QDeclarative1Anchors); - if (d->fill == f) - return; - - if (!f) { - d->remDepend(d->fill); - d->fill = f; - emit fillChanged(); - return; - } - if (f != d->item->parentItem() && f->parentItem() != d->item->parentItem()){ - qmlInfo(d->item) << tr("Cannot anchor to an item that isn't a parent or sibling."); - return; - } - d->remDepend(d->fill); - d->fill = f; - d->addDepend(d->fill); - emit fillChanged(); - d->fillChanged(); -} - -void QDeclarative1Anchors::resetFill() -{ - setFill(0); -} - -QGraphicsObject *QDeclarative1Anchors::centerIn() const -{ - Q_D(const QDeclarative1Anchors); - return d->centerIn; -} - -void QDeclarative1Anchors::setCenterIn(QGraphicsObject* c) -{ - Q_D(QDeclarative1Anchors); - if (d->centerIn == c) - return; - - if (!c) { - d->remDepend(d->centerIn); - d->centerIn = c; - emit centerInChanged(); - return; - } - if (c != d->item->parentItem() && c->parentItem() != d->item->parentItem()){ - qmlInfo(d->item) << tr("Cannot anchor to an item that isn't a parent or sibling."); - return; - } - - d->remDepend(d->centerIn); - d->centerIn = c; - d->addDepend(d->centerIn); - emit centerInChanged(); - d->centerInChanged(); -} - -void QDeclarative1Anchors::resetCenterIn() -{ - setCenterIn(0); -} - -bool QDeclarative1AnchorsPrivate::calcStretch(const QDeclarative1AnchorLine &edge1, - const QDeclarative1AnchorLine &edge2, - qreal offset1, - qreal offset2, - QDeclarative1AnchorLine::AnchorLine line, - qreal &stretch) -{ - bool edge1IsParent = (edge1.item == item->parentItem()); - bool edge2IsParent = (edge2.item == item->parentItem()); - bool edge1IsSibling = (edge1.item->parentItem() == item->parentItem()); - bool edge2IsSibling = (edge2.item->parentItem() == item->parentItem()); - - bool invalid = false; - if ((edge2IsParent && edge1IsParent) || (edge2IsSibling && edge1IsSibling)) { - stretch = (position(edge2.item, edge2.anchorLine) + offset2) - - (position(edge1.item, edge1.anchorLine) + offset1); - } else if (edge2IsParent && edge1IsSibling) { - stretch = (position(edge2.item, edge2.anchorLine) + offset2) - - (position(item->parentObject(), line) - + position(edge1.item, edge1.anchorLine) + offset1); - } else if (edge2IsSibling && edge1IsParent) { - stretch = (position(item->parentObject(), line) + position(edge2.item, edge2.anchorLine) + offset2) - - (position(edge1.item, edge1.anchorLine) + offset1); - } else - invalid = true; - - return invalid; -} - -void QDeclarative1AnchorsPrivate::updateVerticalAnchors() -{ - if (fill || centerIn || !isItemComplete()) - return; - - if (updatingVerticalAnchor < 2) { - ++updatingVerticalAnchor; - QGraphicsItemPrivate *itemPrivate = QGraphicsItemPrivate::get(item); - if (usedAnchors & QDeclarative1Anchors::TopAnchor) { - //Handle stretching - bool invalid = true; - qreal height = 0.0; - if (usedAnchors & QDeclarative1Anchors::BottomAnchor) { - invalid = calcStretch(top, bottom, topMargin, -bottomMargin, QDeclarative1AnchorLine::Top, height); - } else if (usedAnchors & QDeclarative1Anchors::VCenterAnchor) { - invalid = calcStretch(top, vCenter, topMargin, vCenterOffset, QDeclarative1AnchorLine::Top, height); - height *= 2; - } - if (!invalid) - setItemHeight(height); - - //Handle top - if (top.item == item->parentItem()) { - setItemY(adjustedPosition(top.item, top.anchorLine) + topMargin); - } else if (top.item->parentItem() == item->parentItem()) { - setItemY(position(top.item, top.anchorLine) + topMargin); - } - } else if (usedAnchors & QDeclarative1Anchors::BottomAnchor) { - //Handle stretching (top + bottom case is handled above) - if (usedAnchors & QDeclarative1Anchors::VCenterAnchor) { - qreal height = 0.0; - bool invalid = calcStretch(vCenter, bottom, vCenterOffset, -bottomMargin, - QDeclarative1AnchorLine::Top, height); - if (!invalid) - setItemHeight(height*2); - } - - //Handle bottom - if (bottom.item == item->parentItem()) { - setItemY(adjustedPosition(bottom.item, bottom.anchorLine) - itemPrivate->height() - bottomMargin); - } else if (bottom.item->parentItem() == item->parentItem()) { - setItemY(position(bottom.item, bottom.anchorLine) - itemPrivate->height() - bottomMargin); - } - } else if (usedAnchors & QDeclarative1Anchors::VCenterAnchor) { - //(stetching handled above) - - //Handle vCenter - if (vCenter.item == item->parentItem()) { - setItemY(adjustedPosition(vCenter.item, vCenter.anchorLine) - - vcenter(item) + vCenterOffset); - } else if (vCenter.item->parentItem() == item->parentItem()) { - setItemY(position(vCenter.item, vCenter.anchorLine) - vcenter(item) + vCenterOffset); - } - } else if (usedAnchors & QDeclarative1Anchors::BaselineAnchor) { - //Handle baseline - if (baseline.item == item->parentItem()) { - if (itemPrivate->isDeclarativeItem) - setItemY(adjustedPosition(baseline.item, baseline.anchorLine) - - static_cast<QDeclarativeItem *>(item)->baselineOffset() + baselineOffset); - } else if (baseline.item->parentItem() == item->parentItem()) { - if (itemPrivate->isDeclarativeItem) - setItemY(position(baseline.item, baseline.anchorLine) - - static_cast<QDeclarativeItem *>(item)->baselineOffset() + baselineOffset); - } - } - --updatingVerticalAnchor; - } else { - // ### Make this certain :) - qmlInfo(item) << QDeclarative1Anchors::tr("Possible anchor loop detected on vertical anchor."); - } -} - -inline QDeclarative1AnchorLine::AnchorLine reverseAnchorLine(QDeclarative1AnchorLine::AnchorLine anchorLine) { - if (anchorLine == QDeclarative1AnchorLine::Left) { - return QDeclarative1AnchorLine::Right; - } else if (anchorLine == QDeclarative1AnchorLine::Right) { - return QDeclarative1AnchorLine::Left; - } else { - return anchorLine; - } -} - -void QDeclarative1AnchorsPrivate::updateHorizontalAnchors() -{ - Q_Q(QDeclarative1Anchors); - if (fill || centerIn || !isItemComplete()) - return; - - if (updatingHorizontalAnchor < 3) { - ++updatingHorizontalAnchor; - qreal effectiveRightMargin, effectiveLeftMargin, effectiveHorizontalCenterOffset; - QDeclarative1AnchorLine effectiveLeft, effectiveRight, effectiveHorizontalCenter; - QDeclarative1Anchors::Anchor effectiveLeftAnchor, effectiveRightAnchor; - if (q->mirrored()) { - effectiveLeftAnchor = QDeclarative1Anchors::RightAnchor; - effectiveRightAnchor = QDeclarative1Anchors::LeftAnchor; - effectiveLeft.item = right.item; - effectiveLeft.anchorLine = reverseAnchorLine(right.anchorLine); - effectiveRight.item = left.item; - effectiveRight.anchorLine = reverseAnchorLine(left.anchorLine); - effectiveHorizontalCenter.item = hCenter.item; - effectiveHorizontalCenter.anchorLine = reverseAnchorLine(hCenter.anchorLine); - effectiveLeftMargin = rightMargin; - effectiveRightMargin = leftMargin; - effectiveHorizontalCenterOffset = -hCenterOffset; - } else { - effectiveLeftAnchor = QDeclarative1Anchors::LeftAnchor; - effectiveRightAnchor = QDeclarative1Anchors::RightAnchor; - effectiveLeft = left; - effectiveRight = right; - effectiveHorizontalCenter = hCenter; - effectiveLeftMargin = leftMargin; - effectiveRightMargin = rightMargin; - effectiveHorizontalCenterOffset = hCenterOffset; - } - - QGraphicsItemPrivate *itemPrivate = QGraphicsItemPrivate::get(item); - if (usedAnchors & effectiveLeftAnchor) { - //Handle stretching - bool invalid = true; - qreal width = 0.0; - if (usedAnchors & effectiveRightAnchor) { - invalid = calcStretch(effectiveLeft, effectiveRight, effectiveLeftMargin, -effectiveRightMargin, QDeclarative1AnchorLine::Left, width); - } else if (usedAnchors & QDeclarative1Anchors::HCenterAnchor) { - invalid = calcStretch(effectiveLeft, effectiveHorizontalCenter, effectiveLeftMargin, effectiveHorizontalCenterOffset, QDeclarative1AnchorLine::Left, width); - width *= 2; - } - if (!invalid) - setItemWidth(width); - - //Handle left - if (effectiveLeft.item == item->parentItem()) { - setItemX(adjustedPosition(effectiveLeft.item, effectiveLeft.anchorLine) + effectiveLeftMargin); - } else if (effectiveLeft.item->parentItem() == item->parentItem()) { - setItemX(position(effectiveLeft.item, effectiveLeft.anchorLine) + effectiveLeftMargin); - } - } else if (usedAnchors & effectiveRightAnchor) { - //Handle stretching (left + right case is handled in updateLeftAnchor) - if (usedAnchors & QDeclarative1Anchors::HCenterAnchor) { - qreal width = 0.0; - bool invalid = calcStretch(effectiveHorizontalCenter, effectiveRight, effectiveHorizontalCenterOffset, -effectiveRightMargin, - QDeclarative1AnchorLine::Left, width); - if (!invalid) - setItemWidth(width*2); - } - - //Handle right - if (effectiveRight.item == item->parentItem()) { - setItemX(adjustedPosition(effectiveRight.item, effectiveRight.anchorLine) - itemPrivate->width() - effectiveRightMargin); - } else if (effectiveRight.item->parentItem() == item->parentItem()) { - setItemX(position(effectiveRight.item, effectiveRight.anchorLine) - itemPrivate->width() - effectiveRightMargin); - } - } else if (usedAnchors & QDeclarative1Anchors::HCenterAnchor) { - //Handle hCenter - if (effectiveHorizontalCenter.item == item->parentItem()) { - setItemX(adjustedPosition(effectiveHorizontalCenter.item, effectiveHorizontalCenter.anchorLine) - hcenter(item) + effectiveHorizontalCenterOffset); - } else if (effectiveHorizontalCenter.item->parentItem() == item->parentItem()) { - setItemX(position(effectiveHorizontalCenter.item, effectiveHorizontalCenter.anchorLine) - hcenter(item) + effectiveHorizontalCenterOffset); - } - } - --updatingHorizontalAnchor; - } else { - // ### Make this certain :) - qmlInfo(item) << QDeclarative1Anchors::tr("Possible anchor loop detected on horizontal anchor."); - } -} - -QDeclarative1AnchorLine QDeclarative1Anchors::top() const -{ - Q_D(const QDeclarative1Anchors); - return d->top; -} - -void QDeclarative1Anchors::setTop(const QDeclarative1AnchorLine &edge) -{ - Q_D(QDeclarative1Anchors); - if (!d->checkVAnchorValid(edge) || d->top == edge) - return; - - d->usedAnchors |= TopAnchor; - - if (!d->checkVValid()) { - d->usedAnchors &= ~TopAnchor; - return; - } - - d->remDepend(d->top.item); - d->top = edge; - d->addDepend(d->top.item); - emit topChanged(); - d->updateVerticalAnchors(); -} - -void QDeclarative1Anchors::resetTop() -{ - Q_D(QDeclarative1Anchors); - d->usedAnchors &= ~TopAnchor; - d->remDepend(d->top.item); - d->top = QDeclarative1AnchorLine(); - emit topChanged(); - d->updateVerticalAnchors(); -} - -QDeclarative1AnchorLine QDeclarative1Anchors::bottom() const -{ - Q_D(const QDeclarative1Anchors); - return d->bottom; -} - -void QDeclarative1Anchors::setBottom(const QDeclarative1AnchorLine &edge) -{ - Q_D(QDeclarative1Anchors); - if (!d->checkVAnchorValid(edge) || d->bottom == edge) - return; - - d->usedAnchors |= BottomAnchor; - - if (!d->checkVValid()) { - d->usedAnchors &= ~BottomAnchor; - return; - } - - d->remDepend(d->bottom.item); - d->bottom = edge; - d->addDepend(d->bottom.item); - emit bottomChanged(); - d->updateVerticalAnchors(); -} - -void QDeclarative1Anchors::resetBottom() -{ - Q_D(QDeclarative1Anchors); - d->usedAnchors &= ~BottomAnchor; - d->remDepend(d->bottom.item); - d->bottom = QDeclarative1AnchorLine(); - emit bottomChanged(); - d->updateVerticalAnchors(); -} - -QDeclarative1AnchorLine QDeclarative1Anchors::verticalCenter() const -{ - Q_D(const QDeclarative1Anchors); - return d->vCenter; -} - -void QDeclarative1Anchors::setVerticalCenter(const QDeclarative1AnchorLine &edge) -{ - Q_D(QDeclarative1Anchors); - if (!d->checkVAnchorValid(edge) || d->vCenter == edge) - return; - - d->usedAnchors |= VCenterAnchor; - - if (!d->checkVValid()) { - d->usedAnchors &= ~VCenterAnchor; - return; - } - - d->remDepend(d->vCenter.item); - d->vCenter = edge; - d->addDepend(d->vCenter.item); - emit verticalCenterChanged(); - d->updateVerticalAnchors(); -} - -void QDeclarative1Anchors::resetVerticalCenter() -{ - Q_D(QDeclarative1Anchors); - d->usedAnchors &= ~VCenterAnchor; - d->remDepend(d->vCenter.item); - d->vCenter = QDeclarative1AnchorLine(); - emit verticalCenterChanged(); - d->updateVerticalAnchors(); -} - -QDeclarative1AnchorLine QDeclarative1Anchors::baseline() const -{ - Q_D(const QDeclarative1Anchors); - return d->baseline; -} - -void QDeclarative1Anchors::setBaseline(const QDeclarative1AnchorLine &edge) -{ - Q_D(QDeclarative1Anchors); - if (!d->checkVAnchorValid(edge) || d->baseline == edge) - return; - - d->usedAnchors |= BaselineAnchor; - - if (!d->checkVValid()) { - d->usedAnchors &= ~BaselineAnchor; - return; - } - - d->remDepend(d->baseline.item); - d->baseline = edge; - d->addDepend(d->baseline.item); - emit baselineChanged(); - d->updateVerticalAnchors(); -} - -void QDeclarative1Anchors::resetBaseline() -{ - Q_D(QDeclarative1Anchors); - d->usedAnchors &= ~BaselineAnchor; - d->remDepend(d->baseline.item); - d->baseline = QDeclarative1AnchorLine(); - emit baselineChanged(); - d->updateVerticalAnchors(); -} - -QDeclarative1AnchorLine QDeclarative1Anchors::left() const -{ - Q_D(const QDeclarative1Anchors); - return d->left; -} - -void QDeclarative1Anchors::setLeft(const QDeclarative1AnchorLine &edge) -{ - Q_D(QDeclarative1Anchors); - if (!d->checkHAnchorValid(edge) || d->left == edge) - return; - - d->usedAnchors |= LeftAnchor; - - if (!d->checkHValid()) { - d->usedAnchors &= ~LeftAnchor; - return; - } - - d->remDepend(d->left.item); - d->left = edge; - d->addDepend(d->left.item); - emit leftChanged(); - d->updateHorizontalAnchors(); -} - -void QDeclarative1Anchors::resetLeft() -{ - Q_D(QDeclarative1Anchors); - d->usedAnchors &= ~LeftAnchor; - d->remDepend(d->left.item); - d->left = QDeclarative1AnchorLine(); - emit leftChanged(); - d->updateHorizontalAnchors(); -} - -QDeclarative1AnchorLine QDeclarative1Anchors::right() const -{ - Q_D(const QDeclarative1Anchors); - return d->right; -} - -void QDeclarative1Anchors::setRight(const QDeclarative1AnchorLine &edge) -{ - Q_D(QDeclarative1Anchors); - if (!d->checkHAnchorValid(edge) || d->right == edge) - return; - - d->usedAnchors |= RightAnchor; - - if (!d->checkHValid()) { - d->usedAnchors &= ~RightAnchor; - return; - } - - d->remDepend(d->right.item); - d->right = edge; - d->addDepend(d->right.item); - emit rightChanged(); - d->updateHorizontalAnchors(); -} - -void QDeclarative1Anchors::resetRight() -{ - Q_D(QDeclarative1Anchors); - d->usedAnchors &= ~RightAnchor; - d->remDepend(d->right.item); - d->right = QDeclarative1AnchorLine(); - emit rightChanged(); - d->updateHorizontalAnchors(); -} - -QDeclarative1AnchorLine QDeclarative1Anchors::horizontalCenter() const -{ - Q_D(const QDeclarative1Anchors); - return d->hCenter; -} - -void QDeclarative1Anchors::setHorizontalCenter(const QDeclarative1AnchorLine &edge) -{ - Q_D(QDeclarative1Anchors); - if (!d->checkHAnchorValid(edge) || d->hCenter == edge) - return; - - d->usedAnchors |= HCenterAnchor; - - if (!d->checkHValid()) { - d->usedAnchors &= ~HCenterAnchor; - return; - } - - d->remDepend(d->hCenter.item); - d->hCenter = edge; - d->addDepend(d->hCenter.item); - emit horizontalCenterChanged(); - d->updateHorizontalAnchors(); -} - -void QDeclarative1Anchors::resetHorizontalCenter() -{ - Q_D(QDeclarative1Anchors); - d->usedAnchors &= ~HCenterAnchor; - d->remDepend(d->hCenter.item); - d->hCenter = QDeclarative1AnchorLine(); - emit horizontalCenterChanged(); - d->updateHorizontalAnchors(); -} - -qreal QDeclarative1Anchors::leftMargin() const -{ - Q_D(const QDeclarative1Anchors); - return d->leftMargin; -} - -void QDeclarative1Anchors::setLeftMargin(qreal offset) -{ - Q_D(QDeclarative1Anchors); - if (d->leftMargin == offset) - return; - d->leftMargin = offset; - if(d->fill) - d->fillChanged(); - else - d->updateHorizontalAnchors(); - emit leftMarginChanged(); -} - -qreal QDeclarative1Anchors::rightMargin() const -{ - Q_D(const QDeclarative1Anchors); - return d->rightMargin; -} - -void QDeclarative1Anchors::setRightMargin(qreal offset) -{ - Q_D(QDeclarative1Anchors); - if (d->rightMargin == offset) - return; - d->rightMargin = offset; - if(d->fill) - d->fillChanged(); - else - d->updateHorizontalAnchors(); - emit rightMarginChanged(); -} - -qreal QDeclarative1Anchors::margins() const -{ - Q_D(const QDeclarative1Anchors); - return d->margins; -} - -void QDeclarative1Anchors::setMargins(qreal offset) -{ - Q_D(QDeclarative1Anchors); - if (d->margins == offset) - return; - //###Is it significantly faster to set them directly so we can call fillChanged only once? - if(!d->rightMargin || d->rightMargin == d->margins) - setRightMargin(offset); - if(!d->leftMargin || d->leftMargin == d->margins) - setLeftMargin(offset); - if(!d->topMargin || d->topMargin == d->margins) - setTopMargin(offset); - if(!d->bottomMargin || d->bottomMargin == d->margins) - setBottomMargin(offset); - d->margins = offset; - emit marginsChanged(); - -} - -qreal QDeclarative1Anchors::horizontalCenterOffset() const -{ - Q_D(const QDeclarative1Anchors); - return d->hCenterOffset; -} - -void QDeclarative1Anchors::setHorizontalCenterOffset(qreal offset) -{ - Q_D(QDeclarative1Anchors); - if (d->hCenterOffset == offset) - return; - d->hCenterOffset = offset; - if(d->centerIn) - d->centerInChanged(); - else - d->updateHorizontalAnchors(); - emit horizontalCenterOffsetChanged(); -} - -qreal QDeclarative1Anchors::topMargin() const -{ - Q_D(const QDeclarative1Anchors); - return d->topMargin; -} - -void QDeclarative1Anchors::setTopMargin(qreal offset) -{ - Q_D(QDeclarative1Anchors); - if (d->topMargin == offset) - return; - d->topMargin = offset; - if(d->fill) - d->fillChanged(); - else - d->updateVerticalAnchors(); - emit topMarginChanged(); -} - -qreal QDeclarative1Anchors::bottomMargin() const -{ - Q_D(const QDeclarative1Anchors); - return d->bottomMargin; -} - -void QDeclarative1Anchors::setBottomMargin(qreal offset) -{ - Q_D(QDeclarative1Anchors); - if (d->bottomMargin == offset) - return; - d->bottomMargin = offset; - if(d->fill) - d->fillChanged(); - else - d->updateVerticalAnchors(); - emit bottomMarginChanged(); -} - -qreal QDeclarative1Anchors::verticalCenterOffset() const -{ - Q_D(const QDeclarative1Anchors); - return d->vCenterOffset; -} - -void QDeclarative1Anchors::setVerticalCenterOffset(qreal offset) -{ - Q_D(QDeclarative1Anchors); - if (d->vCenterOffset == offset) - return; - d->vCenterOffset = offset; - if(d->centerIn) - d->centerInChanged(); - else - d->updateVerticalAnchors(); - emit verticalCenterOffsetChanged(); -} - -qreal QDeclarative1Anchors::baselineOffset() const -{ - Q_D(const QDeclarative1Anchors); - return d->baselineOffset; -} - -void QDeclarative1Anchors::setBaselineOffset(qreal offset) -{ - Q_D(QDeclarative1Anchors); - if (d->baselineOffset == offset) - return; - d->baselineOffset = offset; - d->updateVerticalAnchors(); - emit baselineOffsetChanged(); -} - -QDeclarative1Anchors::Anchors QDeclarative1Anchors::usedAnchors() const -{ - Q_D(const QDeclarative1Anchors); - return d->usedAnchors; -} - -bool QDeclarative1AnchorsPrivate::checkHValid() const -{ - if (usedAnchors & QDeclarative1Anchors::LeftAnchor && - usedAnchors & QDeclarative1Anchors::RightAnchor && - usedAnchors & QDeclarative1Anchors::HCenterAnchor) { - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot specify left, right, and hcenter anchors."); - return false; - } - - return true; -} - -bool QDeclarative1AnchorsPrivate::checkHAnchorValid(QDeclarative1AnchorLine anchor) const -{ - if (!anchor.item) { - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor to a null item."); - return false; - } else if (anchor.anchorLine & QDeclarative1AnchorLine::Vertical_Mask) { - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor a horizontal edge to a vertical edge."); - return false; - } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){ - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor to an item that isn't a parent or sibling."); - return false; - } else if (anchor.item == item) { - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor item to self."); - return false; - } - - return true; -} - -bool QDeclarative1AnchorsPrivate::checkVValid() const -{ - if (usedAnchors & QDeclarative1Anchors::TopAnchor && - usedAnchors & QDeclarative1Anchors::BottomAnchor && - usedAnchors & QDeclarative1Anchors::VCenterAnchor) { - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot specify top, bottom, and vcenter anchors."); - return false; - } else if (usedAnchors & QDeclarative1Anchors::BaselineAnchor && - (usedAnchors & QDeclarative1Anchors::TopAnchor || - usedAnchors & QDeclarative1Anchors::BottomAnchor || - usedAnchors & QDeclarative1Anchors::VCenterAnchor)) { - qmlInfo(item) << QDeclarative1Anchors::tr("Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors."); - return false; - } - - return true; -} - -bool QDeclarative1AnchorsPrivate::checkVAnchorValid(QDeclarative1AnchorLine anchor) const -{ - if (!anchor.item) { - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor to a null item."); - return false; - } else if (anchor.anchorLine & QDeclarative1AnchorLine::Horizontal_Mask) { - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor a vertical edge to a horizontal edge."); - return false; - } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){ - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor to an item that isn't a parent or sibling."); - return false; - } else if (anchor.item == item){ - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor item to self."); - return false; - } - - return true; -} - - - -QT_END_NAMESPACE - -#include <moc_qdeclarativeanchors_p.cpp> - diff --git a/src/qtquick1/graphicsitems/qdeclarativeanchors_p.h b/src/qtquick1/graphicsitems/qdeclarativeanchors_p.h deleted file mode 100644 index 4218fd2a67..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeanchors_p.h +++ /dev/null @@ -1,205 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEANCHORS_H -#define QDECLARATIVEANCHORS_H - -#include "qdeclarativeitem.h" - -#include <QtDeclarative/qdeclarative.h> - -#include <QtCore/QObject> - -#include <QtDeclarative/private/qdeclarativeglobal_p.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1AnchorsPrivate; -class QDeclarative1AnchorLine; -class Q_QTQUICK1_EXPORT QDeclarative1Anchors : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QDeclarative1AnchorLine left READ left WRITE setLeft RESET resetLeft NOTIFY leftChanged) - Q_PROPERTY(QDeclarative1AnchorLine right READ right WRITE setRight RESET resetRight NOTIFY rightChanged) - Q_PROPERTY(QDeclarative1AnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter NOTIFY horizontalCenterChanged) - Q_PROPERTY(QDeclarative1AnchorLine top READ top WRITE setTop RESET resetTop NOTIFY topChanged) - Q_PROPERTY(QDeclarative1AnchorLine bottom READ bottom WRITE setBottom RESET resetBottom NOTIFY bottomChanged) - Q_PROPERTY(QDeclarative1AnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter NOTIFY verticalCenterChanged) - Q_PROPERTY(QDeclarative1AnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline NOTIFY baselineChanged) - Q_PROPERTY(qreal margins READ margins WRITE setMargins NOTIFY marginsChanged) - Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged) - Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged) - Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged) - Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged) - Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged) - Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged) - Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged) - Q_PROPERTY(QGraphicsObject *fill READ fill WRITE setFill RESET resetFill NOTIFY fillChanged) - Q_PROPERTY(QGraphicsObject *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn NOTIFY centerInChanged) - Q_PROPERTY(bool mirrored READ mirrored NOTIFY mirroredChanged REVISION 1) - -public: - QDeclarative1Anchors(QObject *parent=0); - QDeclarative1Anchors(QGraphicsObject *item, QObject *parent=0); - virtual ~QDeclarative1Anchors(); - - enum Anchor { - LeftAnchor = 0x01, - RightAnchor = 0x02, - TopAnchor = 0x04, - BottomAnchor = 0x08, - HCenterAnchor = 0x10, - VCenterAnchor = 0x20, - BaselineAnchor = 0x40, - Horizontal_Mask = LeftAnchor | RightAnchor | HCenterAnchor, - Vertical_Mask = TopAnchor | BottomAnchor | VCenterAnchor | BaselineAnchor - }; - Q_DECLARE_FLAGS(Anchors, Anchor) - - QDeclarative1AnchorLine left() const; - void setLeft(const QDeclarative1AnchorLine &edge); - void resetLeft(); - - QDeclarative1AnchorLine right() const; - void setRight(const QDeclarative1AnchorLine &edge); - void resetRight(); - - QDeclarative1AnchorLine horizontalCenter() const; - void setHorizontalCenter(const QDeclarative1AnchorLine &edge); - void resetHorizontalCenter(); - - QDeclarative1AnchorLine top() const; - void setTop(const QDeclarative1AnchorLine &edge); - void resetTop(); - - QDeclarative1AnchorLine bottom() const; - void setBottom(const QDeclarative1AnchorLine &edge); - void resetBottom(); - - QDeclarative1AnchorLine verticalCenter() const; - void setVerticalCenter(const QDeclarative1AnchorLine &edge); - void resetVerticalCenter(); - - QDeclarative1AnchorLine baseline() const; - void setBaseline(const QDeclarative1AnchorLine &edge); - void resetBaseline(); - - qreal leftMargin() const; - void setLeftMargin(qreal); - - qreal rightMargin() const; - void setRightMargin(qreal); - - qreal horizontalCenterOffset() const; - void setHorizontalCenterOffset(qreal); - - qreal topMargin() const; - void setTopMargin(qreal); - - qreal bottomMargin() const; - void setBottomMargin(qreal); - - qreal margins() const; - void setMargins(qreal); - - qreal verticalCenterOffset() const; - void setVerticalCenterOffset(qreal); - - qreal baselineOffset() const; - void setBaselineOffset(qreal); - - QGraphicsObject *fill() const; - void setFill(QGraphicsObject *); - void resetFill(); - - QGraphicsObject *centerIn() const; - void setCenterIn(QGraphicsObject *); - void resetCenterIn(); - - Anchors usedAnchors() const; - - void classBegin(); - void componentComplete(); - - bool mirrored(); - -Q_SIGNALS: - void leftChanged(); - void rightChanged(); - void topChanged(); - void bottomChanged(); - void verticalCenterChanged(); - void horizontalCenterChanged(); - void baselineChanged(); - void fillChanged(); - void centerInChanged(); - void leftMarginChanged(); - void rightMarginChanged(); - void topMarginChanged(); - void bottomMarginChanged(); - void marginsChanged(); - void verticalCenterOffsetChanged(); - void horizontalCenterOffsetChanged(); - void baselineOffsetChanged(); - Q_REVISION(1) void mirroredChanged(); - -private: - friend class QDeclarativeItem; - friend class QDeclarativeItemPrivate; - friend class QDeclarative1GraphicsWidget; - Q_DISABLE_COPY(QDeclarative1Anchors) - Q_DECLARE_PRIVATE(QDeclarative1Anchors) - Q_PRIVATE_SLOT(d_func(), void _q_widgetGeometryChanged()) - Q_PRIVATE_SLOT(d_func(), void _q_widgetDestroyed(QObject *obj)) -}; -Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarative1Anchors::Anchors) - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Anchors) - -QT_END_HEADER - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativeanchors_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeanchors_p_p.h deleted file mode 100644 index a7d769d917..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeanchors_p_p.h +++ /dev/null @@ -1,171 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEANCHORS_P_H -#define QDECLARATIVEANCHORS_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 "QtQuick1/private/qdeclarativeanchors_p.h" -#include "QtQuick1/private/qdeclarativeitemchangelistener_p.h" -#include <private/qobject_p.h> - -QT_BEGIN_NAMESPACE - -// NOTE: if you change this then also update the copy in qdeclarativev4compiler_p_p.h -class QDeclarative1AnchorLine -{ -public: - QDeclarative1AnchorLine() : item(0), anchorLine(Invalid) {} - - enum AnchorLine { - Invalid = 0x0, - Left = 0x01, - Right = 0x02, - Top = 0x04, - Bottom = 0x08, - HCenter = 0x10, - VCenter = 0x20, - Baseline = 0x40, - Horizontal_Mask = Left | Right | HCenter, - Vertical_Mask = Top | Bottom | VCenter | Baseline - }; - - QGraphicsObject *item; - AnchorLine anchorLine; -}; - -inline bool operator==(const QDeclarative1AnchorLine& a, const QDeclarative1AnchorLine& b) -{ - return a.item == b.item && a.anchorLine == b.anchorLine; -} - -class QDeclarative1AnchorsPrivate : public QObjectPrivate, public QDeclarativeItemChangeListener -{ - Q_DECLARE_PUBLIC(QDeclarative1Anchors) -public: - QDeclarative1AnchorsPrivate(QGraphicsObject *i) - : componentComplete(true), updatingMe(false), updatingHorizontalAnchor(0), - updatingVerticalAnchor(0), updatingFill(0), updatingCenterIn(0), item(i), usedAnchors(0), fill(0), - centerIn(0), leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0), - margins(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0) - { - } - - void clearItem(QGraphicsObject *); - - void addDepend(QGraphicsObject *); - void remDepend(QGraphicsObject *); - bool isItemComplete() const; - - bool componentComplete:1; - bool updatingMe:1; - uint updatingHorizontalAnchor:2; - uint updatingVerticalAnchor:2; - uint updatingFill:2; - uint updatingCenterIn:2; - - void setItemHeight(qreal); - void setItemWidth(qreal); - void setItemX(qreal); - void setItemY(qreal); - void setItemPos(const QPointF &); - void setItemSize(const QSizeF &); - - void updateOnComplete(); - void updateMe(); - - // QDeclarativeItemGeometryListener interface - void itemGeometryChanged(QDeclarativeItem *, const QRectF &, const QRectF &); - void _q_widgetDestroyed(QObject *); - void _q_widgetGeometryChanged(); - QDeclarative1AnchorsPrivate *anchorPrivate() { return this; } - - bool checkHValid() const; - bool checkVValid() const; - bool checkHAnchorValid(QDeclarative1AnchorLine anchor) const; - bool checkVAnchorValid(QDeclarative1AnchorLine anchor) const; - bool calcStretch(const QDeclarative1AnchorLine &edge1, const QDeclarative1AnchorLine &edge2, qreal offset1, qreal offset2, QDeclarative1AnchorLine::AnchorLine line, qreal &stretch); - - bool isMirrored() const; - void updateHorizontalAnchors(); - void updateVerticalAnchors(); - void fillChanged(); - void centerInChanged(); - - QGraphicsObject *item; - QDeclarative1Anchors::Anchors usedAnchors; - - QGraphicsObject *fill; - QGraphicsObject *centerIn; - - QDeclarative1AnchorLine left; - QDeclarative1AnchorLine right; - QDeclarative1AnchorLine top; - QDeclarative1AnchorLine bottom; - QDeclarative1AnchorLine vCenter; - QDeclarative1AnchorLine hCenter; - QDeclarative1AnchorLine baseline; - - qreal leftMargin; - qreal rightMargin; - qreal topMargin; - qreal bottomMargin; - qreal margins; - qreal vCenterOffset; - qreal hCenterOffset; - qreal baselineOffset; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QDeclarative1AnchorLine) - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativeanimatedimage.cpp b/src/qtquick1/graphicsitems/qdeclarativeanimatedimage.cpp deleted file mode 100644 index 72bbf13dad..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeanimatedimage.cpp +++ /dev/null @@ -1,402 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "QtQuick1/private/qdeclarativeanimatedimage_p.h" -#include "QtQuick1/private/qdeclarativeanimatedimage_p_p.h" - -#ifndef QT_NO_MOVIE - -#include <QtDeclarative/qdeclarativeinfo.h> -#include <QtDeclarative/private/qdeclarativeengine_p.h> - -#include <QMovie> -#include <QNetworkRequest> -#include <QNetworkReply> - -QT_BEGIN_NAMESPACE - - - -/*! - \qmlclass AnimatedImage QDeclarative1AnimatedImage - \inqmlmodule QtQuick 1 - \inherits Image - \since QtQuick 1.0 - \ingroup basic-visual-elements - - The AnimatedImage element extends the features of the \l Image element, providing - a way to play animations stored as images containing a series of frames, - such as those stored in GIF files. - - Information about the current frame and totla length of the animation can be - obtained using the \l currentFrame and \l frameCount properties. You can - start, pause and stop the animation by changing the values of the \l playing - and \l paused properties. - - The full list of supported formats can be determined with QMovie::supportedFormats(). - - \section1 Example Usage - - \beginfloatleft - \image animatedimageitem.gif - \endfloat - - The following QML shows how to display an animated image and obtain information - about its state, such as the current frame and total number of frames. - The result is an animated image with a simple progress indicator underneath it. - - \bold Note: Unlike images, animated images are not cached or shared internally. - - \clearfloat - \snippet doc/src/snippets/qtquick1/animatedimage.qml document - - \sa BorderImage, Image -*/ - -/*! - \qmlproperty url QtQuick1::AnimatedImage::source - - This property holds the URL that refers to the source image. - - AnimatedImage can handle any image format supported by Qt, loaded from any - URL scheme supported by Qt. - - \sa QDeclarativeImageProvider -*/ - -/*! - \qmlproperty bool QtQuick1::AnimatedImage::asynchronous - - Specifies that images on the local filesystem should be loaded - asynchronously in a separate thread. The default value is - false, causing the user interface thread to block while the - image is loaded. Setting \a asynchronous to true is useful where - maintaining a responsive user interface is more desirable - than having images immediately visible. - - Note that this property is only valid for images read from the - local filesystem. Images loaded via a network resource (e.g. HTTP) - are always loaded asynchonously. -*/ - -/*! - \qmlproperty bool QtQuick1::AnimatedImage::mirror - \since Quick 1.1 - - This property holds whether the image should be horizontally inverted - (effectively displaying a mirrored image). - - The default value is false. -*/ - -QDeclarative1AnimatedImage::QDeclarative1AnimatedImage(QDeclarativeItem *parent) - : QDeclarative1Image(*(new QDeclarative1AnimatedImagePrivate), parent) -{ -} - -QDeclarative1AnimatedImage::~QDeclarative1AnimatedImage() -{ - Q_D(QDeclarative1AnimatedImage); - delete d->_movie; -} - -/*! - \qmlproperty bool QtQuick1::AnimatedImage::paused - This property holds whether the animated image is paused. - - By default, this property is false. Set it to true when you want to pause - the animation. -*/ -bool QDeclarative1AnimatedImage::isPaused() const -{ - Q_D(const QDeclarative1AnimatedImage); - if(!d->_movie) - return false; - return d->_movie->state()==QMovie::Paused; -} - -void QDeclarative1AnimatedImage::setPaused(bool pause) -{ - Q_D(QDeclarative1AnimatedImage); - if(pause == d->paused) - return; - d->paused = pause; - if(!d->_movie) - return; - d->_movie->setPaused(pause); -} -/*! - \qmlproperty bool QtQuick1::AnimatedImage::playing - This property holds whether the animated image is playing. - - By default, this property is true, meaning that the animation - will start playing immediately. -*/ -bool QDeclarative1AnimatedImage::isPlaying() const -{ - Q_D(const QDeclarative1AnimatedImage); - if (!d->_movie) - return false; - return d->_movie->state()!=QMovie::NotRunning; -} - -void QDeclarative1AnimatedImage::setPlaying(bool play) -{ - Q_D(QDeclarative1AnimatedImage); - if(play == d->playing) - return; - d->playing = play; - if (!d->_movie) - return; - if (play) - d->_movie->start(); - else - d->_movie->stop(); -} - -/*! - \qmlproperty int QtQuick1::AnimatedImage::currentFrame - \qmlproperty int QtQuick1::AnimatedImage::frameCount - - currentFrame is the frame that is currently visible. By monitoring this property - for changes, you can animate other items at the same time as the image. - - frameCount is the number of frames in the animation. For some animation formats, - frameCount is unknown and has a value of zero. -*/ -int QDeclarative1AnimatedImage::currentFrame() const -{ - Q_D(const QDeclarative1AnimatedImage); - if (!d->_movie) - return d->preset_currentframe; - return d->_movie->currentFrameNumber(); -} - -void QDeclarative1AnimatedImage::setCurrentFrame(int frame) -{ - Q_D(QDeclarative1AnimatedImage); - if (!d->_movie) { - d->preset_currentframe = frame; - return; - } - d->_movie->jumpToFrame(frame); -} - -int QDeclarative1AnimatedImage::frameCount() const -{ - Q_D(const QDeclarative1AnimatedImage); - if (!d->_movie) - return 0; - return d->_movie->frameCount(); -} - -void QDeclarative1AnimatedImage::setSource(const QUrl &url) -{ - Q_D(QDeclarative1AnimatedImage); - if (url == d->url) - return; - - delete d->_movie; - d->_movie = 0; - - if (d->reply) { - d->reply->deleteLater(); - d->reply = 0; - } - - d->url = url; - emit sourceChanged(d->url); - - if (isComponentComplete()) - load(); -} - -void QDeclarative1AnimatedImage::load() -{ - Q_D(QDeclarative1AnimatedImage); - - QDeclarative1ImageBase::Status oldStatus = d->status; - qreal oldProgress = d->progress; - - if (d->url.isEmpty()) { - delete d->_movie; - d->setPixmap(QPixmap()); - d->progress = 0; - d->status = Null; - if (d->status != oldStatus) - emit statusChanged(d->status); - if (d->progress != oldProgress) - emit progressChanged(d->progress); - } else { -#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML - QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url); - if (!lf.isEmpty()) { - //### should be unified with movieRequestFinished - d->_movie = new QMovie(lf); - if (!d->_movie->isValid()){ - qmlInfo(this) << "Error Reading Animated Image File " << d->url.toString(); - delete d->_movie; - d->_movie = 0; - d->status = Error; - if (d->status != oldStatus) - emit statusChanged(d->status); - return; - } - connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)), - this, SLOT(playingStatusChanged())); - connect(d->_movie, SIGNAL(frameChanged(int)), - this, SLOT(movieUpdate())); - d->_movie->setCacheMode(QMovie::CacheAll); - if(d->playing) - d->_movie->start(); - else - d->_movie->jumpToFrame(0); - if(d->paused) - d->_movie->setPaused(true); - d->setPixmap(d->_movie->currentPixmap()); - d->status = Ready; - d->progress = 1.0; - if (d->status != oldStatus) - emit statusChanged(d->status); - if (d->progress != oldProgress) - emit progressChanged(d->progress); - return; - } -#endif - d->status = Loading; - d->progress = 0; - emit statusChanged(d->status); - emit progressChanged(d->progress); - QNetworkRequest req(d->url); - req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); - d->reply = qmlEngine(this)->networkAccessManager()->get(req); - QObject::connect(d->reply, SIGNAL(finished()), - this, SLOT(movieRequestFinished())); - QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), - this, SLOT(requestProgress(qint64,qint64))); - } -} - -#define ANIMATEDIMAGE_MAXIMUM_REDIRECT_RECURSION 16 - -void QDeclarative1AnimatedImage::movieRequestFinished() -{ - Q_D(QDeclarative1AnimatedImage); - - d->redirectCount++; - if (d->redirectCount < ANIMATEDIMAGE_MAXIMUM_REDIRECT_RECURSION) { - QVariant redirect = d->reply->attribute(QNetworkRequest::RedirectionTargetAttribute); - if (redirect.isValid()) { - QUrl url = d->reply->url().resolved(redirect.toUrl()); - d->reply->deleteLater(); - d->reply = 0; - setSource(url); - return; - } - } - d->redirectCount=0; - - d->_movie = new QMovie(d->reply); - if (!d->_movie->isValid()){ -#ifndef QT_NO_DEBUG_STREAM - qmlInfo(this) << "Error Reading Animated Image File " << d->url; -#endif - delete d->_movie; - d->_movie = 0; - d->status = Error; - emit statusChanged(d->status); - return; - } - connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)), - this, SLOT(playingStatusChanged())); - connect(d->_movie, SIGNAL(frameChanged(int)), - this, SLOT(movieUpdate())); - d->_movie->setCacheMode(QMovie::CacheAll); - if(d->playing) - d->_movie->start(); - if (d->paused || !d->playing) { - d->_movie->jumpToFrame(d->preset_currentframe); - d->preset_currentframe = 0; - } - if(d->paused) - d->_movie->setPaused(true); - d->setPixmap(d->_movie->currentPixmap()); - d->status = Ready; - emit statusChanged(d->status); -} - -void QDeclarative1AnimatedImage::movieUpdate() -{ - Q_D(QDeclarative1AnimatedImage); - d->setPixmap(d->_movie->currentPixmap()); - emit frameChanged(); -} - -void QDeclarative1AnimatedImage::playingStatusChanged() -{ - Q_D(QDeclarative1AnimatedImage); - if((d->_movie->state() != QMovie::NotRunning) != d->playing){ - d->playing = (d->_movie->state() != QMovie::NotRunning); - emit playingChanged(); - } - if((d->_movie->state() == QMovie::Paused) != d->paused){ - d->playing = (d->_movie->state() == QMovie::Paused); - emit pausedChanged(); - } -} - -void QDeclarative1AnimatedImage::componentComplete() -{ - Q_D(QDeclarative1AnimatedImage); - QDeclarativeItem::componentComplete(); // NOT QDeclarative1Image - if (d->url.isValid()) - load(); - if (!d->reply) { - setCurrentFrame(d->preset_currentframe); - d->preset_currentframe = 0; - } -} - - - -QT_END_NAMESPACE - -#endif // QT_NO_MOVIE diff --git a/src/qtquick1/graphicsitems/qdeclarativeanimatedimage_p.h b/src/qtquick1/graphicsitems/qdeclarativeanimatedimage_p.h deleted file mode 100644 index 373af3cc69..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeanimatedimage_p.h +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEANIMATEDIMAGE_H -#define QDECLARATIVEANIMATEDIMAGE_H - -#include "private/qdeclarativeimage_p.h" - -#ifndef QT_NO_MOVIE - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMovie; - - -class QDeclarative1AnimatedImagePrivate; - -class Q_AUTOTEST_EXPORT QDeclarative1AnimatedImage : public QDeclarative1Image -{ - Q_OBJECT - - Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged) - Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged) - Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY frameChanged) - Q_PROPERTY(int frameCount READ frameCount) - - // read-only for AnimatedImage - Q_PROPERTY(QSize sourceSize READ sourceSize NOTIFY sourceSizeChanged) - -public: - QDeclarative1AnimatedImage(QDeclarativeItem *parent=0); - ~QDeclarative1AnimatedImage(); - - bool isPlaying() const; - void setPlaying(bool play); - - bool isPaused() const; - void setPaused(bool pause); - - int currentFrame() const; - void setCurrentFrame(int frame); - - int frameCount() const; - - // Extends QDeclarative1Image's src property*/ - virtual void setSource(const QUrl&); - -Q_SIGNALS: - void playingChanged(); - void pausedChanged(); - void frameChanged(); - void sourceSizeChanged(); - -private Q_SLOTS: - void movieUpdate(); - void movieRequestFinished(); - void playingStatusChanged(); - -protected: - virtual void load(); - void componentComplete(); - -private: - Q_DISABLE_COPY(QDeclarative1AnimatedImage) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1AnimatedImage) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1AnimatedImage) - -QT_END_HEADER - -#endif // QT_NO_MOVIE - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativeanimatedimage_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeanimatedimage_p_p.h deleted file mode 100644 index 8fe6502d99..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeanimatedimage_p_p.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEANIMATEDIMAGE_P_H -#define QDECLARATIVEANIMATEDIMAGE_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 "private/qdeclarativeimage_p_p.h" - -#ifndef QT_NO_MOVIE - -QT_BEGIN_NAMESPACE - -class QMovie; -class QNetworkReply; - -class QDeclarative1AnimatedImagePrivate : public QDeclarative1ImagePrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1AnimatedImage) - -public: - QDeclarative1AnimatedImagePrivate() - : playing(true), paused(false), preset_currentframe(0), _movie(0), reply(0), redirectCount(0) - { - } - - bool playing; - bool paused; - int preset_currentframe; - QMovie *_movie; - QNetworkReply *reply; - int redirectCount; -}; - -QT_END_NAMESPACE - -#endif // QT_NO_MOVIE - -#endif // QDECLARATIVEANIMATEDIMAGE_P_H diff --git a/src/qtquick1/graphicsitems/qdeclarativeborderimage.cpp b/src/qtquick1/graphicsitems/qdeclarativeborderimage.cpp deleted file mode 100644 index 7ef77eabe9..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeborderimage.cpp +++ /dev/null @@ -1,624 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "QtQuick1/private/qdeclarativeborderimage_p.h" -#include "QtQuick1/private/qdeclarativeborderimage_p_p.h" - -#include <QtDeclarative/qdeclarativeinfo.h> -#include <QtDeclarative/private/qdeclarativeengine_p.h> - -#include <QNetworkRequest> -#include <QNetworkReply> -#include <QFile> - -#include <QtWidgets/qdrawutil.h> - -QT_BEGIN_NAMESPACE - - - -/*! - \qmlclass BorderImage QDeclarative1BorderImage - \inqmlmodule QtQuick 1 - \brief The BorderImage element provides an image that can be used as a border. - \inherits Item - \since QtQuick 1.0 - \ingroup qml-basic-visual-elements - - The BorderImage element is used to create borders out of images by scaling or tiling - parts of each image. - - A BorderImage element breaks a source image, specified using the \l url property, - into 9 regions, as shown below: - - \image declarative-scalegrid.png - - When the image is scaled, regions of the source image are scaled or tiled to - create the displayed border image in the following way: - - \list - \i The corners (regions 1, 3, 7, and 9) are not scaled at all. - \i Regions 2 and 8 are scaled according to - \l{BorderImage::horizontalTileMode}{horizontalTileMode}. - \i Regions 4 and 6 are scaled according to - \l{BorderImage::verticalTileMode}{verticalTileMode}. - \i The middle (region 5) is scaled according to both - \l{BorderImage::horizontalTileMode}{horizontalTileMode} and - \l{BorderImage::verticalTileMode}{verticalTileMode}. - \endlist - - The regions of the image are defined using the \l border property group, which - describes the distance from each edge of the source image to use as a border. - - \section1 Example Usage - - The following examples show the effects of the different modes on an image. - Guide lines are overlaid onto the image to show the different regions of the - image as described above. - - \beginfloatleft - \image qml-borderimage-normal-image.png - \endfloat - - An unscaled image is displayed using an Image element. The \l border property is - used to determine the parts of the image that will lie inside the unscaled corner - areas and the parts that will be stretched horizontally and vertically. - - \snippet doc/src/snippets/qtquick1/borderimage/normal-image.qml normal image - - \clearfloat - \beginfloatleft - \image qml-borderimage-scaled.png - \endfloat - - A BorderImage element is used to display the image, and it is given a size that is - larger than the original image. Since the \l horizontalTileMode property is set to - \l{BorderImage::horizontalTileMode}{BorderImage.Stretch}, the parts of image in - regions 2 and 8 are stretched horizontally. Since the \l verticalTileMode property - is set to \l{BorderImage::verticalTileMode}{BorderImage.Stretch}, the parts of image - in regions 4 and 6 are stretched vertically. - - \snippet doc/src/snippets/qtquick1/borderimage/borderimage-scaled.qml scaled border image - - \clearfloat - \beginfloatleft - \image qml-borderimage-tiled.png - \endfloat - - Again, a large BorderImage element is used to display the image. With the - \l horizontalTileMode property set to \l{BorderImage::horizontalTileMode}{BorderImage.Repeat}, - the parts of image in regions 2 and 8 are tiled so that they fill the space at the - top and bottom of the element. Similarly, the \l verticalTileMode property is set to - \l{BorderImage::verticalTileMode}{BorderImage.Repeat}, the parts of image in regions - 4 and 6 are tiled so that they fill the space at the left and right of the element. - - \snippet doc/src/snippets/qtquick1/borderimage/borderimage-tiled.qml tiled border image - - \clearfloat - In some situations, the width of regions 2 and 8 may not be an exact multiple of the width - of the corresponding regions in the source image. Similarly, the height of regions 4 and 6 - may not be an exact multiple of the height of the corresponding regions. It can be useful - to use \l{BorderImage::horizontalTileMode}{BorderImage.Round} instead of - \l{BorderImage::horizontalTileMode}{BorderImage.Repeat} in cases like these. - - The \l{declarative/imageelements/borderimage}{BorderImage example} shows how a BorderImage - can be used to simulate a shadow effect on a rectangular item. - - \section1 Quality and Performance - - By default, any scaled regions of the image are rendered without smoothing to improve - rendering speed. Setting the \l smooth property improves rendering quality of scaled - regions, but may slow down rendering. - - The source image may not be loaded instantaneously, depending on its original location. - Loading progress can be monitored with the \l progress property. - - \sa Image, AnimatedImage - */ - -/*! - \qmlproperty bool QtQuick1::BorderImage::asynchronous - - Specifies that images on the local filesystem should be loaded - asynchronously in a separate thread. The default value is - false, causing the user interface thread to block while the - image is loaded. Setting \a asynchronous to true is useful where - maintaining a responsive user interface is more desirable - than having images immediately visible. - - Note that this property is only valid for images read from the - local filesystem. Images loaded via a network resource (e.g. HTTP) - are always loaded asynchonously. -*/ -QDeclarative1BorderImage::QDeclarative1BorderImage(QDeclarativeItem *parent) - : QDeclarative1ImageBase(*(new QDeclarative1BorderImagePrivate), parent) -{ -} - -QDeclarative1BorderImage::~QDeclarative1BorderImage() -{ - Q_D(QDeclarative1BorderImage); - if (d->sciReply) - d->sciReply->deleteLater(); -} -/*! - \qmlproperty enumeration QtQuick1::BorderImage::status - - This property describes the status of image loading. It can be one of: - - \list - \o BorderImage.Null - no image has been set - \o BorderImage.Ready - the image has been loaded - \o BorderImage.Loading - the image is currently being loaded - \o BorderImage.Error - an error occurred while loading the image - \endlist - - \sa progress -*/ - -/*! - \qmlproperty real QtQuick1::BorderImage::progress - - This property holds the progress of image loading, from 0.0 (nothing loaded) - to 1.0 (finished). - - \sa status -*/ - -/*! - \qmlproperty bool QtQuick1::BorderImage::smooth - - Set this property if you want the image to be smoothly filtered when scaled or - transformed. Smooth filtering gives better visual quality, but is slower. If - the image is displayed at its natural size, this property has no visual or - performance effect. - - By default, this property is set to false. - - \note Generally scaling artifacts are only visible if the image is stationary on - the screen. A common pattern when animating an image is to disable smooth - filtering at the beginning of the animation and enable it at the conclusion. -*/ - -/*! - \qmlproperty bool QtQuick1::BorderImage::cache - \since Quick 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, - to make sure that they aren't cached at the expense of small 'ui element' images. -*/ - -/*! - \qmlproperty bool QtQuick1::BorderImage::mirror - \since Quick 1.1 - - This property holds whether the image should be horizontally inverted - (effectively displaying a mirrored image). - - The default value is false. -*/ - -/*! - \qmlproperty url QtQuick1::BorderImage::source - - This property holds the URL that refers to the source image. - - BorderImage can handle any image format supported by Qt, loaded from any - URL scheme supported by Qt. - - This property can also be used to refer to .sci files, which are - written in a QML-specific, text-based format that specifies the - borders, the image file and the tile rules for a given border image. - - The following .sci file sets the borders to 10 on each side for the - image \c picture.png: - - \code - border.left: 10 - border.top: 10 - border.bottom: 10 - border.right: 10 - source: "picture.png" - \endcode - - The URL may be absolute, or relative to the URL of the component. - - \sa QDeclarativeImageProvider -*/ - -/*! - \qmlproperty QSize QtQuick1::BorderImage::sourceSize - - This property holds the actual width and height of the loaded image. - - In BorderImage, this property is read-only. - - \sa Image::sourceSize -*/ -void QDeclarative1BorderImage::setSource(const QUrl &url) -{ - Q_D(QDeclarative1BorderImage); - //equality is fairly expensive, so we bypass for simple, common case - if ((d->url.isEmpty() == url.isEmpty()) && url == d->url) - return; - - if (d->sciReply) { - d->sciReply->deleteLater(); - d->sciReply = 0; - } - - d->url = url; - d->sciurl = QUrl(); - emit sourceChanged(d->url); - - if (isComponentComplete()) - load(); -} - -void QDeclarative1BorderImage::load() -{ - Q_D(QDeclarative1BorderImage); - if (d->progress != 0.0) { - d->progress = 0.0; - emit progressChanged(d->progress); - } - - if (d->url.isEmpty()) { - d->pix.clear(this); - d->status = Null; - setImplicitWidth(0); - setImplicitHeight(0); - emit statusChanged(d->status); - update(); - } else { - d->status = Loading; - if (d->url.path().endsWith(QLatin1String("sci"))) { -#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML - QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url); - if (!lf.isEmpty()) { - QFile file(lf); - file.open(QIODevice::ReadOnly); - setGridScaledImage(QDeclarative1GridScaledImage(&file)); - } else -#endif - { - QNetworkRequest req(d->url); - d->sciReply = qmlEngine(this)->networkAccessManager()->get(req); - - static int sciReplyFinished = -1; - static int thisSciRequestFinished = -1; - if (sciReplyFinished == -1) { - sciReplyFinished = - QNetworkReply::staticMetaObject.indexOfSignal("finished()"); - thisSciRequestFinished = - QDeclarative1BorderImage::staticMetaObject.indexOfSlot("sciRequestFinished()"); - } - - QMetaObject::connect(d->sciReply, sciReplyFinished, this, - thisSciRequestFinished, Qt::DirectConnection); - } - } else { - - QDeclarative1Pixmap::Options options; - if (d->async) - options |= QDeclarative1Pixmap::Asynchronous; - if (d->cache) - options |= QDeclarative1Pixmap::Cache; - d->pix.clear(this); - d->pix.load(qmlEngine(this), d->url, options); - - if (d->pix.isLoading()) { - d->pix.connectFinished(this, SLOT(requestFinished())); - d->pix.connectDownloadProgress(this, SLOT(requestProgress(qint64,qint64))); - } else { - QSize impsize = d->pix.implicitSize(); - setImplicitWidth(impsize.width()); - setImplicitHeight(impsize.height()); - - if (d->pix.isReady()) { - d->status = Ready; - } else { - d->status = Error; - qmlInfo(this) << d->pix.error(); - } - - d->progress = 1.0; - emit statusChanged(d->status); - emit progressChanged(d->progress); - requestFinished(); - update(); - } - } - } - - emit statusChanged(d->status); -} - -/*! - \qmlproperty int QtQuick1::BorderImage::border.left - \qmlproperty int QtQuick1::BorderImage::border.right - \qmlproperty int QtQuick1::BorderImage::border.top - \qmlproperty int QtQuick1::BorderImage::border.bottom - - The 4 border lines (2 horizontal and 2 vertical) break the image into 9 sections, - as shown below: - - \image declarative-scalegrid.png - - Each border line (left, right, top, and bottom) specifies an offset in pixels - from the respective edge of the source image. By default, each border line has - a value of 0. - - For example, the following definition sets the bottom line 10 pixels up from - the bottom of the image: - - \qml - BorderImage { - border.bottom: 10 - // ... - } - \endqml - - The border lines can also be specified using a - \l {BorderImage::source}{.sci file}. -*/ - -QDeclarative1ScaleGrid *QDeclarative1BorderImage::border() -{ - Q_D(QDeclarative1BorderImage); - return d->getScaleGrid(); -} - -/*! - \qmlproperty enumeration QtQuick1::BorderImage::horizontalTileMode - \qmlproperty enumeration QtQuick1::BorderImage::verticalTileMode - - This property describes how to repeat or stretch the middle parts of the border image. - - \list - \o BorderImage.Stretch - Scales the image to fit to the available area. - \o BorderImage.Repeat - Tile the image until there is no more space. May crop the last image. - \o BorderImage.Round - Like Repeat, but scales the images down to ensure that the last image is not cropped. - \endlist - - The default tile mode for each property is BorderImage.Stretch. -*/ -QDeclarative1BorderImage::TileMode QDeclarative1BorderImage::horizontalTileMode() const -{ - Q_D(const QDeclarative1BorderImage); - return d->horizontalTileMode; -} - -void QDeclarative1BorderImage::setHorizontalTileMode(TileMode t) -{ - Q_D(QDeclarative1BorderImage); - if (t != d->horizontalTileMode) { - d->horizontalTileMode = t; - emit horizontalTileModeChanged(); - update(); - } -} - -QDeclarative1BorderImage::TileMode QDeclarative1BorderImage::verticalTileMode() const -{ - Q_D(const QDeclarative1BorderImage); - return d->verticalTileMode; -} - -void QDeclarative1BorderImage::setVerticalTileMode(TileMode t) -{ - Q_D(QDeclarative1BorderImage); - if (t != d->verticalTileMode) { - d->verticalTileMode = t; - emit verticalTileModeChanged(); - update(); - } -} - -void QDeclarative1BorderImage::setGridScaledImage(const QDeclarative1GridScaledImage& sci) -{ - Q_D(QDeclarative1BorderImage); - if (!sci.isValid()) { - d->status = Error; - emit statusChanged(d->status); - } else { - QDeclarative1ScaleGrid *sg = border(); - sg->setTop(sci.gridTop()); - sg->setBottom(sci.gridBottom()); - sg->setLeft(sci.gridLeft()); - sg->setRight(sci.gridRight()); - d->horizontalTileMode = sci.horizontalTileRule(); - d->verticalTileMode = sci.verticalTileRule(); - - d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl())); - - QDeclarative1Pixmap::Options options; - if (d->async) - options |= QDeclarative1Pixmap::Asynchronous; - if (d->cache) - options |= QDeclarative1Pixmap::Cache; - d->pix.clear(this); - d->pix.load(qmlEngine(this), d->sciurl, options); - - if (d->pix.isLoading()) { - static int thisRequestProgress = -1; - static int thisRequestFinished = -1; - if (thisRequestProgress == -1) { - thisRequestProgress = - QDeclarative1BorderImage::staticMetaObject.indexOfSlot("requestProgress(qint64,qint64)"); - thisRequestFinished = - QDeclarative1BorderImage::staticMetaObject.indexOfSlot("requestFinished()"); - } - - d->pix.connectFinished(this, thisRequestFinished); - d->pix.connectDownloadProgress(this, thisRequestProgress); - - } else { - - QSize impsize = d->pix.implicitSize(); - setImplicitWidth(impsize.width()); - setImplicitHeight(impsize.height()); - - if (d->pix.isReady()) { - d->status = Ready; - } else { - d->status = Error; - qmlInfo(this) << d->pix.error(); - } - - d->progress = 1.0; - emit statusChanged(d->status); - emit progressChanged(1.0); - update(); - - } - } -} - -void QDeclarative1BorderImage::requestFinished() -{ - Q_D(QDeclarative1BorderImage); - - QSize impsize = d->pix.implicitSize(); - if (d->pix.isError()) { - d->status = Error; - qmlInfo(this) << d->pix.error(); - } else { - d->status = Ready; - } - - setImplicitWidth(impsize.width()); - setImplicitHeight(impsize.height()); - - if (d->sourcesize.width() != d->pix.width() || d->sourcesize.height() != d->pix.height()) - emit sourceSizeChanged(); - - d->progress = 1.0; - emit statusChanged(d->status); - emit progressChanged(1.0); - update(); -} - -#define BORDERIMAGE_MAX_REDIRECT 16 - -void QDeclarative1BorderImage::sciRequestFinished() -{ - Q_D(QDeclarative1BorderImage); - - d->redirectCount++; - if (d->redirectCount < BORDERIMAGE_MAX_REDIRECT) { - QVariant redirect = d->sciReply->attribute(QNetworkRequest::RedirectionTargetAttribute); - if (redirect.isValid()) { - QUrl url = d->sciReply->url().resolved(redirect.toUrl()); - setSource(url); - return; - } - } - d->redirectCount=0; - - if (d->sciReply->error() != QNetworkReply::NoError) { - d->status = Error; - d->sciReply->deleteLater(); - d->sciReply = 0; - emit statusChanged(d->status); - } else { - QDeclarative1GridScaledImage sci(d->sciReply); - d->sciReply->deleteLater(); - d->sciReply = 0; - setGridScaledImage(sci); - } -} - -void QDeclarative1BorderImage::doUpdate() -{ - update(); -} - -void QDeclarative1BorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) -{ - Q_D(QDeclarative1BorderImage); - if (d->pix.isNull() || d->width() <= 0.0 || d->height() <= 0.0) - return; - - bool oldAA = p->testRenderHint(QPainter::Antialiasing); - bool oldSmooth = p->testRenderHint(QPainter::SmoothPixmapTransform); - QTransform oldTransform; - if (d->smooth) - p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth); - if (d->mirror) { - oldTransform = p->transform(); - QTransform mirror; - mirror.translate(d->width(), 0).scale(-1, 1.0); - p->setWorldTransform(mirror * oldTransform); - } - - const QDeclarative1ScaleGrid *border = d->getScaleGrid(); - int left = border->left(); - int right = border->right(); - qreal borderWidth = left + right; - if (borderWidth > 0.0 && d->width() < borderWidth) { - qreal diff = borderWidth - d->width() - 1; - left -= qRound(diff * qreal(left) / borderWidth); - right -= qRound(diff * qreal(right) / borderWidth); - } - int top = border->top(); - int bottom = border->bottom(); - qreal borderHeight = top + bottom; - if (borderHeight > 0.0 && d->height() < borderHeight) { - qreal diff = borderHeight - d->height() - 1; - top -= qRound(diff * qreal(top) / borderHeight); - bottom -= qRound(diff * qreal(bottom) / borderHeight); - } - QMargins margins(left, top, right, bottom); - QTileRules rules((Qt::TileRule)d->horizontalTileMode, (Qt::TileRule)d->verticalTileMode); - qDrawBorderPixmap(p, QRect(0, 0, (int)d->width(), (int)d->height()), margins, d->pix, d->pix.rect(), margins, rules); - if (d->smooth) { - p->setRenderHint(QPainter::Antialiasing, oldAA); - p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth); - } - if (d->mirror) - p->setWorldTransform(oldTransform); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativeborderimage_p.h b/src/qtquick1/graphicsitems/qdeclarativeborderimage_p.h deleted file mode 100644 index 4f5cd7e109..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeborderimage_p.h +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEBORDERIMAGE_H -#define QDECLARATIVEBORDERIMAGE_H - -#include "private/qdeclarativeimagebase_p.h" - -#include <QtNetwork/qnetworkreply.h> - -QT_BEGIN_HEADER -QT_BEGIN_NAMESPACE - - -class QDeclarative1ScaleGrid; -class QDeclarative1GridScaledImage; -class QDeclarative1BorderImagePrivate; -class Q_AUTOTEST_EXPORT QDeclarative1BorderImage : public QDeclarative1ImageBase -{ - Q_OBJECT - Q_ENUMS(TileMode) - - Q_PROPERTY(QDeclarative1ScaleGrid *border READ border CONSTANT) - Q_PROPERTY(TileMode horizontalTileMode READ horizontalTileMode WRITE setHorizontalTileMode NOTIFY horizontalTileModeChanged) - Q_PROPERTY(TileMode verticalTileMode READ verticalTileMode WRITE setVerticalTileMode NOTIFY verticalTileModeChanged) - - // read-only for BorderImage - Q_PROPERTY(QSize sourceSize READ sourceSize NOTIFY sourceSizeChanged) - -public: - QDeclarative1BorderImage(QDeclarativeItem *parent=0); - ~QDeclarative1BorderImage(); - - QDeclarative1ScaleGrid *border(); - - enum TileMode { Stretch = Qt::StretchTile, Repeat = Qt::RepeatTile, Round = Qt::RoundTile }; - - TileMode horizontalTileMode() const; - void setHorizontalTileMode(TileMode); - - TileMode verticalTileMode() const; - void setVerticalTileMode(TileMode); - - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); - void setSource(const QUrl &url); - -Q_SIGNALS: - void horizontalTileModeChanged(); - void verticalTileModeChanged(); - void sourceSizeChanged(); - -protected: - virtual void load(); - -private: - void setGridScaledImage(const QDeclarative1GridScaledImage& sci); - -private Q_SLOTS: - void doUpdate(); - void requestFinished(); - void sciRequestFinished(); - -private: - Q_DISABLE_COPY(QDeclarative1BorderImage) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1BorderImage) -}; - -QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarative1BorderImage) -QT_END_HEADER - -#endif // QDECLARATIVEBORDERIMAGE_H diff --git a/src/qtquick1/graphicsitems/qdeclarativeborderimage_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeborderimage_p_p.h deleted file mode 100644 index 4515e62db6..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeborderimage_p_p.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEBORDERIMAGE_P_H -#define QDECLARATIVEBORDERIMAGE_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 "private/qdeclarativeimagebase_p_p.h" -#include "private/qdeclarativescalegrid_p_p.h" - -QT_BEGIN_NAMESPACE - -class QNetworkReply; - -class QDeclarative1BorderImagePrivate : public QDeclarative1ImageBasePrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1BorderImage) - -public: - QDeclarative1BorderImagePrivate() - : border(0), sciReply(0), - horizontalTileMode(QDeclarative1BorderImage::Stretch), - verticalTileMode(QDeclarative1BorderImage::Stretch), - redirectCount(0) - { - } - - ~QDeclarative1BorderImagePrivate() - { - } - - - QDeclarative1ScaleGrid *getScaleGrid() - { - Q_Q(QDeclarative1BorderImage); - if (!border) { - border = new QDeclarative1ScaleGrid(q); - static int borderChangedSignalIdx = -1; - static int doUpdateSlotIdx = -1; - if (borderChangedSignalIdx < 0) - borderChangedSignalIdx = QDeclarative1ScaleGrid::staticMetaObject.indexOfSignal("borderChanged()"); - if (doUpdateSlotIdx < 0) - doUpdateSlotIdx = QDeclarative1BorderImage::staticMetaObject.indexOfSlot("doUpdate()"); - QMetaObject::connect(border, borderChangedSignalIdx, q, doUpdateSlotIdx); - } - return border; - } - - QDeclarative1ScaleGrid *border; - QUrl sciurl; - QNetworkReply *sciReply; - QDeclarative1BorderImage::TileMode horizontalTileMode; - QDeclarative1BorderImage::TileMode verticalTileMode; - int redirectCount; -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVEBORDERIMAGE_P_H diff --git a/src/qtquick1/graphicsitems/qdeclarativeevents.cpp b/src/qtquick1/graphicsitems/qdeclarativeevents.cpp deleted file mode 100644 index 5217aed092..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeevents.cpp +++ /dev/null @@ -1,243 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "QtQuick1/private/qdeclarativeevents_p_p.h" - -QT_BEGIN_NAMESPACE - - -/*! - \qmlclass KeyEvent QDeclarative1KeyEvent - \inqmlmodule QtQuick 1 - \since QtQuick 1.0 - \ingroup qml-event-elements - - \brief The KeyEvent object provides information about a key event. - - For example, the following changes the Item's state property when the Enter - key is pressed: - \qml -Item { - focus: true - Keys.onPressed: { if (event.key == Qt.Key_Enter) state = 'ShowDetails'; } -} - \endqml -*/ - -/*! - \qmlproperty int QtQuick1::KeyEvent::key - - This property holds the code of the key that was pressed or released. - - See \l {Qt::Key}{Qt.Key} for the list of keyboard codes. These codes are - independent of the underlying window system. Note that this - function does not distinguish between capital and non-capital - letters, use the text() function (returning the Unicode text the - key generated) for this purpose. - - A value of either 0 or \l {Qt::Key_unknown}{Qt.Key_Unknown} means that the event is not - the result of a known key; for example, it may be the result of - a compose sequence, a keyboard macro, or due to key event - compression. -*/ - -/*! - \qmlproperty string QtQuick1::KeyEvent::text - - This property holds the Unicode text that the key generated. - The text returned can be an empty string in cases where modifier keys, - such as Shift, Control, Alt, and Meta, are being pressed or released. - In such cases \c key will contain a valid value -*/ - -/*! - \qmlproperty bool QtQuick1::KeyEvent::isAutoRepeat - - This property holds whether this event comes from an auto-repeating key. -*/ - -/*! - \qmlproperty int QtQuick1::KeyEvent::count - - This property holds the number of keys involved in this event. If \l KeyEvent::text - is not empty, this is simply the length of the string. -*/ - -/*! - \qmlproperty bool QtQuick1::KeyEvent::accepted - - Setting \a accepted to true prevents the key event from being - propagated to the item's parent. - - Generally, if the item acts on the key event then it should be accepted - so that ancestor items do not also respond to the same event. -*/ - -/*! - \qmlproperty int QtQuick1::KeyEvent::modifiers - - This property holds the keyboard modifier flags that existed immediately - before the event occurred. - - It contains a bitwise combination of: - \list - \o Qt.NoModifier - No modifier key is pressed. - \o Qt.ShiftModifier - A Shift key on the keyboard is pressed. - \o Qt.ControlModifier - A Ctrl key on the keyboard is pressed. - \o Qt.AltModifier - An Alt key on the keyboard is pressed. - \o Qt.MetaModifier - A Meta key on the keyboard is pressed. - \o Qt.KeypadModifier - A keypad button is pressed. - \endlist - - For example, to react to a Shift key + Enter key combination: - \qml - Item { - focus: true - Keys.onPressed: { - if ((event.key == Qt.Key_Enter) && (event.modifiers & Qt.ShiftModifier)) - doSomething(); - } - } - \endqml -*/ - - -/*! - \qmlclass MouseEvent QDeclarative1MouseEvent - \inqmlmodule QtQuick 1 - \since QtQuick 1.0 - \ingroup qml-event-elements - - \brief The MouseEvent object provides information about a mouse event. - - The position of the mouse can be found via the \l x and \l y properties. - The button that caused the event is available via the \l button property. - - \sa MouseArea -*/ - -/*! - \internal - \class QDeclarative1MouseEvent -*/ - -/*! - \qmlproperty int QtQuick1::MouseEvent::x - \qmlproperty int QtQuick1::MouseEvent::y - - These properties hold the coordinates of the position supplied by the mouse event. -*/ - - -/*! - \qmlproperty bool QtQuick1::MouseEvent::accepted - - Setting \a accepted to true prevents the mouse event from being - propagated to items below this item. - - Generally, if the item acts on the mouse event then it should be accepted - so that items lower in the stacking order do not also respond to the same event. -*/ - -/*! - \qmlproperty enumeration QtQuick1::MouseEvent::button - - This property holds the button that caused the event. It can be one of: - \list - \o Qt.LeftButton - \o Qt.RightButton - \o Qt.MiddleButton - \endlist -*/ - -/*! - \qmlproperty bool QtQuick1::MouseEvent::wasHeld - - This property is true if the mouse button has been held pressed longer the - threshold (800ms). -*/ - -/*! - \qmlproperty int QtQuick1::MouseEvent::buttons - - This property holds the mouse buttons pressed when the event was generated. - For mouse move events, this is all buttons that are pressed down. For mouse - press and double click events this includes the button that caused the event. - For mouse release events this excludes the button that caused the event. - - It contains a bitwise combination of: - \list - \o Qt.LeftButton - \o Qt.RightButton - \o Qt.MiddleButton - \endlist -*/ - -/*! - \qmlproperty int QtQuick1::MouseEvent::modifiers - - This property holds the keyboard modifier flags that existed immediately - before the event occurred. - - It contains a bitwise combination of: - \list - \o Qt.NoModifier - No modifier key is pressed. - \o Qt.ShiftModifier - A Shift key on the keyboard is pressed. - \o Qt.ControlModifier - A Ctrl key on the keyboard is pressed. - \o Qt.AltModifier - An Alt key on the keyboard is pressed. - \o Qt.MetaModifier - A Meta key on the keyboard is pressed. - \o Qt.KeypadModifier - A keypad button is pressed. - \endlist - - For example, to react to a Shift key + Left mouse button click: - \qml - MouseArea { - onClicked: { - if ((mouse.button == Qt.LeftButton) && (mouse.modifiers & Qt.ShiftModifier)) - doSomething(); - } - } - \endqml -*/ - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativeevents_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeevents_p_p.h deleted file mode 100644 index 754579b766..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeevents_p_p.h +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEEVENTS_P_H -#define QDECLARATIVEEVENTS_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 <QtDeclarative/qdeclarative.h> - -#include <QtCore/qobject.h> -#include <QtGui/qevent.h> - -QT_BEGIN_NAMESPACE - -class QDeclarative1KeyEvent : public QObject -{ - Q_OBJECT - Q_PROPERTY(int key READ key) - Q_PROPERTY(QString text READ text) - Q_PROPERTY(int modifiers READ modifiers) - Q_PROPERTY(bool isAutoRepeat READ isAutoRepeat) - Q_PROPERTY(int count READ count) - Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) - -public: - QDeclarative1KeyEvent(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text=QString(), bool autorep=false, ushort count=1) - : event(type, key, modifiers, text, autorep, count) { event.setAccepted(false); } - QDeclarative1KeyEvent(const QKeyEvent &ke) - : event(ke) { event.setAccepted(false); } - - int key() const { return event.key(); } - QString text() const { return event.text(); } - int modifiers() const { return event.modifiers(); } - bool isAutoRepeat() const { return event.isAutoRepeat(); } - int count() const { return event.count(); } - - bool isAccepted() { return event.isAccepted(); } - void setAccepted(bool accepted) { event.setAccepted(accepted); } - -private: - QKeyEvent event; -}; - -class QDeclarative1MouseEvent : public QObject -{ - Q_OBJECT - Q_PROPERTY(int x READ x) - Q_PROPERTY(int y READ y) - Q_PROPERTY(int button READ button) - Q_PROPERTY(int buttons READ buttons) - Q_PROPERTY(int modifiers READ modifiers) - Q_PROPERTY(bool wasHeld READ wasHeld) - Q_PROPERTY(bool isClick READ isClick) - Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) - -public: - QDeclarative1MouseEvent(int x, int y, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers - , bool isClick=false, bool wasHeld=false) - : _x(x), _y(y), _button(button), _buttons(buttons), _modifiers(modifiers) - , _wasHeld(wasHeld), _isClick(isClick), _accepted(true) {} - - int x() const { return _x; } - int y() const { return _y; } - int button() const { return _button; } - int buttons() const { return _buttons; } - int modifiers() const { return _modifiers; } - bool wasHeld() const { return _wasHeld; } - bool isClick() const { return _isClick; } - - // only for internal usage - void setX(int x) { _x = x; } - void setY(int y) { _y = y; } - - bool isAccepted() { return _accepted; } - void setAccepted(bool accepted) { _accepted = accepted; } - -private: - int _x; - int _y; - Qt::MouseButton _button; - Qt::MouseButtons _buttons; - Qt::KeyboardModifiers _modifiers; - bool _wasHeld; - bool _isClick; - bool _accepted; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1KeyEvent) -QML_DECLARE_TYPE(QDeclarative1MouseEvent) - -#endif // QDECLARATIVEEVENTS_P_H diff --git a/src/qtquick1/graphicsitems/qdeclarativeflickable.cpp b/src/qtquick1/graphicsitems/qdeclarativeflickable.cpp deleted file mode 100644 index 39efc3b213..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeflickable.cpp +++ /dev/null @@ -1,1812 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "QtQuick1/private/qdeclarativeflickable_p.h" -#include "QtQuick1/private/qdeclarativeflickable_p_p.h" -#include <QtDeclarative/qdeclarativeinfo.h> -#include <QGraphicsSceneMouseEvent> -#include <QPointer> -#include <QTimer> -#include "qplatformdefs.h" - -QT_BEGIN_NAMESPACE - - - -// The maximum number of pixels a flick can overshoot -#ifndef QML_FLICK_OVERSHOOT -#define QML_FLICK_OVERSHOOT 200 -#endif - -// The number of samples to use in calculating the velocity of a flick -#ifndef QML_FLICK_SAMPLEBUFFER -#define QML_FLICK_SAMPLEBUFFER 3 -#endif - -// The number of samples to discard when calculating the flick velocity. -// Touch panels often produce inaccurate results as the finger is lifted. -#ifndef QML_FLICK_DISCARDSAMPLES -#define QML_FLICK_DISCARDSAMPLES 1 -#endif - -// The default maximum velocity of a flick. -#ifndef QML_FLICK_DEFAULTMAXVELOCITY -#define QML_FLICK_DEFAULTMAXVELOCITY 2500 -#endif - -// The default deceleration of a flick. -#ifndef QML_FLICK_DEFAULTDECELERATION -#define QML_FLICK_DEFAULTDECELERATION 1750 -#endif - -// How much faster to decelerate when overshooting -#ifndef QML_FLICK_OVERSHOOTFRICTION -#define QML_FLICK_OVERSHOOTFRICTION 8 -#endif - -// FlickThreshold determines how far the "mouse" must have moved -// before we perform a flick. -static const int FlickThreshold = 20; - -// RetainGrabVelocity is the maxmimum instantaneous velocity that -// will ensure the Flickable retains the grab on consecutive flicks. -static const int RetainGrabVelocity = 15; - -QDeclarative1FlickableVisibleArea::QDeclarative1FlickableVisibleArea(QDeclarative1Flickable *parent) - : QObject(parent), flickable(parent), m_xPosition(0.), m_widthRatio(0.) - , m_yPosition(0.), m_heightRatio(0.) -{ -} - -qreal QDeclarative1FlickableVisibleArea::widthRatio() const -{ - return m_widthRatio; -} - -qreal QDeclarative1FlickableVisibleArea::xPosition() const -{ - return m_xPosition; -} - -qreal QDeclarative1FlickableVisibleArea::heightRatio() const -{ - return m_heightRatio; -} - -qreal QDeclarative1FlickableVisibleArea::yPosition() const -{ - return m_yPosition; -} - -void QDeclarative1FlickableVisibleArea::updateVisible() -{ - QDeclarative1FlickablePrivate *p = static_cast<QDeclarative1FlickablePrivate *>(QGraphicsItemPrivate::get(flickable)); - - bool changeX = false; - bool changeY = false; - bool changeWidth = false; - bool changeHeight = false; - - // Vertical - const qreal viewheight = flickable->height(); - const qreal maxyextent = -flickable->maxYExtent() + flickable->minYExtent(); - qreal pagePos = (-p->vData.move.value() + flickable->minYExtent()) / (maxyextent + viewheight); - qreal pageSize = viewheight / (maxyextent + viewheight); - - if (pageSize != m_heightRatio) { - m_heightRatio = pageSize; - changeHeight = true; - } - if (pagePos != m_yPosition) { - m_yPosition = pagePos; - changeY = true; - } - - // Horizontal - const qreal viewwidth = flickable->width(); - const qreal maxxextent = -flickable->maxXExtent() + flickable->minXExtent(); - pagePos = (-p->hData.move.value() + flickable->minXExtent()) / (maxxextent + viewwidth); - pageSize = viewwidth / (maxxextent + viewwidth); - - if (pageSize != m_widthRatio) { - m_widthRatio = pageSize; - changeWidth = true; - } - if (pagePos != m_xPosition) { - m_xPosition = pagePos; - changeX = true; - } - - if (changeX) - emit xPositionChanged(m_xPosition); - if (changeY) - emit yPositionChanged(m_yPosition); - if (changeWidth) - emit widthRatioChanged(m_widthRatio); - if (changeHeight) - emit heightRatioChanged(m_heightRatio); -} - - -QDeclarative1FlickablePrivate::QDeclarative1FlickablePrivate() - : contentItem(new QDeclarativeItem) - , hData(this, &QDeclarative1FlickablePrivate::setRoundedViewportX) - , vData(this, &QDeclarative1FlickablePrivate::setRoundedViewportY) - , hMoved(false), vMoved(false) - , stealMouse(false), pressed(false), interactive(true), calcVelocity(false) - , deceleration(QML_FLICK_DEFAULTDECELERATION) - , maxVelocity(QML_FLICK_DEFAULTMAXVELOCITY), reportedVelocitySmoothing(100) - , delayedPressEvent(0), delayedPressTarget(0), pressDelay(0), fixupDuration(400) - , fixupMode(Normal), vTime(0), visibleArea(0) - , flickableDirection(QDeclarative1Flickable::AutoFlickDirection) - , boundsBehavior(QDeclarative1Flickable::DragAndOvershootBounds) -{ -} - -void QDeclarative1FlickablePrivate::init() -{ - Q_Q(QDeclarative1Flickable); - QDeclarative_setParent_noEvent(contentItem, q); - contentItem->setParentItem(q); - static int timelineUpdatedIdx = -1; - static int timelineCompletedIdx = -1; - static int flickableTickedIdx = -1; - static int flickableMovementEndingIdx = -1; - if (timelineUpdatedIdx == -1) { - timelineUpdatedIdx = QDeclarative1TimeLine::staticMetaObject.indexOfSignal("updated()"); - timelineCompletedIdx = QDeclarative1TimeLine::staticMetaObject.indexOfSignal("completed()"); - flickableTickedIdx = QDeclarative1Flickable::staticMetaObject.indexOfSlot("ticked()"); - flickableMovementEndingIdx = QDeclarative1Flickable::staticMetaObject.indexOfSlot("movementEnding()"); - } - QMetaObject::connect(&timeline, timelineUpdatedIdx, - q, flickableTickedIdx, Qt::DirectConnection); - QMetaObject::connect(&timeline, timelineCompletedIdx, - q, flickableMovementEndingIdx, Qt::DirectConnection); - q->setAcceptedMouseButtons(Qt::LeftButton); - q->setFiltersChildEvents(true); - QDeclarativeItemPrivate *viewportPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(contentItem)); - viewportPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - lastPosTime.invalidate(); -} - -/* - Returns the amount to overshoot by given a view size. - Will be up to the lesser of 1/3 of the view size or QML_FLICK_OVERSHOOT -*/ -qreal QDeclarative1FlickablePrivate::overShootDistance(qreal size) -{ - if (maxVelocity <= 0) - return 0.0; - - return qMin(qreal(QML_FLICK_OVERSHOOT), size/3); -} - -void QDeclarative1FlickablePrivate::AxisData::addVelocitySample(qreal v, qreal maxVelocity) -{ - if (v > maxVelocity) - v = maxVelocity; - else if (v < -maxVelocity) - v = -maxVelocity; - velocityBuffer.append(v); - if (velocityBuffer.count() > QML_FLICK_SAMPLEBUFFER) - velocityBuffer.remove(0); -} - -void QDeclarative1FlickablePrivate::AxisData::updateVelocity() -{ - if (velocityBuffer.count() > QML_FLICK_DISCARDSAMPLES) { - velocity = 0; - int count = velocityBuffer.count()-QML_FLICK_DISCARDSAMPLES; - for (int i = 0; i < count; ++i) { - qreal v = velocityBuffer.at(i); - velocity += v; - } - velocity /= count; - } -} - -void QDeclarative1FlickablePrivate::itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeom, const QRectF &oldGeom) -{ - Q_Q(QDeclarative1Flickable); - if (item == contentItem) { - if (newGeom.x() != oldGeom.x()) - emit q->contentXChanged(); - if (newGeom.y() != oldGeom.y()) - emit q->contentYChanged(); - } -} - -void QDeclarative1FlickablePrivate::flickX(qreal velocity) -{ - Q_Q(QDeclarative1Flickable); - flick(hData, q->minXExtent(), q->maxXExtent(), q->width(), fixupX_callback, velocity); -} - -void QDeclarative1FlickablePrivate::flickY(qreal velocity) -{ - Q_Q(QDeclarative1Flickable); - flick(vData, q->minYExtent(), q->maxYExtent(), q->height(), fixupY_callback, velocity); -} - -void QDeclarative1FlickablePrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal, - QDeclarative1TimeLineCallback::Callback fixupCallback, qreal velocity) -{ - Q_Q(QDeclarative1Flickable); - qreal maxDistance = -1; - data.fixingUp = false; - // -ve velocity means list is moving up - if (velocity > 0) { - maxDistance = qAbs(minExtent - data.move.value()); - data.flickTarget = minExtent; - } else { - maxDistance = qAbs(maxExtent - data.move.value()); - data.flickTarget = maxExtent; - } - if (maxDistance > 0) { - qreal v = velocity; - if (maxVelocity != -1 && maxVelocity < qAbs(v)) { - if (v < 0) - v = -maxVelocity; - else - v = maxVelocity; - } - timeline.reset(data.move); - if (boundsBehavior == QDeclarative1Flickable::DragAndOvershootBounds) - timeline.accel(data.move, v, deceleration); - else - timeline.accel(data.move, v, deceleration, maxDistance); - timeline.callback(QDeclarative1TimeLineCallback(&data.move, fixupCallback, this)); - if (!hData.flicking && q->xflick()) { - hData.flicking = true; - emit q->flickingChanged(); - emit q->flickingHorizontallyChanged(); - if (!vData.flicking) - emit q->flickStarted(); - } - if (!vData.flicking && q->yflick()) { - vData.flicking = true; - emit q->flickingChanged(); - emit q->flickingVerticallyChanged(); - if (!hData.flicking) - emit q->flickStarted(); - } - } else { - timeline.reset(data.move); - fixup(data, minExtent, maxExtent); - } -} - -void QDeclarative1FlickablePrivate::fixupY_callback(void *data) -{ - ((QDeclarative1FlickablePrivate *)data)->fixupY(); -} - -void QDeclarative1FlickablePrivate::fixupX_callback(void *data) -{ - ((QDeclarative1FlickablePrivate *)data)->fixupX(); -} - -void QDeclarative1FlickablePrivate::fixupX() -{ - Q_Q(QDeclarative1Flickable); - fixup(hData, q->minXExtent(), q->maxXExtent()); -} - -void QDeclarative1FlickablePrivate::fixupY() -{ - Q_Q(QDeclarative1Flickable); - fixup(vData, q->minYExtent(), q->maxYExtent()); -} - -void QDeclarative1FlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent) -{ - if (data.move.value() > minExtent || maxExtent > minExtent) { - timeline.reset(data.move); - if (data.move.value() != minExtent) { - switch (fixupMode) { - case Immediate: - timeline.set(data.move, minExtent); - break; - case ExtentChanged: - // The target has changed. Don't start from the beginning; just complete the - // second half of the animation using the new extent. - timeline.move(data.move, minExtent, QEasingCurve(QEasingCurve::OutExpo), 3*fixupDuration/4); - data.fixingUp = true; - break; - default: { - qreal dist = minExtent - data.move; - timeline.move(data.move, minExtent - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4); - timeline.move(data.move, minExtent, QEasingCurve(QEasingCurve::OutExpo), 3*fixupDuration/4); - data.fixingUp = true; - } - } - } - } else if (data.move.value() < maxExtent) { - timeline.reset(data.move); - switch (fixupMode) { - case Immediate: - timeline.set(data.move, maxExtent); - break; - case ExtentChanged: - // The target has changed. Don't start from the beginning; just complete the - // second half of the animation using the new extent. - timeline.move(data.move, maxExtent, QEasingCurve(QEasingCurve::OutExpo), 3*fixupDuration/4); - data.fixingUp = true; - break; - default: { - qreal dist = maxExtent - data.move; - timeline.move(data.move, maxExtent - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4); - timeline.move(data.move, maxExtent, QEasingCurve(QEasingCurve::OutExpo), 3*fixupDuration/4); - data.fixingUp = true; - } - } - } - data.inOvershoot = false; - fixupMode = Normal; - vTime = timeline.time(); -} - -void QDeclarative1FlickablePrivate::updateBeginningEnd() -{ - Q_Q(QDeclarative1Flickable); - bool atBoundaryChange = false; - - // Vertical - const int maxyextent = int(-q->maxYExtent()); - const qreal ypos = -vData.move.value(); - bool atBeginning = (ypos <= -q->minYExtent()); - bool atEnd = (maxyextent <= ypos); - - if (atBeginning != vData.atBeginning) { - vData.atBeginning = atBeginning; - atBoundaryChange = true; - } - if (atEnd != vData.atEnd) { - vData.atEnd = atEnd; - atBoundaryChange = true; - } - - // Horizontal - const int maxxextent = int(-q->maxXExtent()); - const qreal xpos = -hData.move.value(); - atBeginning = (xpos <= -q->minXExtent()); - atEnd = (maxxextent <= xpos); - - if (atBeginning != hData.atBeginning) { - hData.atBeginning = atBeginning; - atBoundaryChange = true; - } - if (atEnd != hData.atEnd) { - hData.atEnd = atEnd; - atBoundaryChange = true; - } - - if (atBoundaryChange) - emit q->isAtBoundaryChanged(); - - if (visibleArea) - visibleArea->updateVisible(); -} - -/*! - \qmlclass Flickable QDeclarative1Flickable - \inqmlmodule QtQuick 1 - \since QtQuick 1.0 - \ingroup qml-basic-interaction-elements - - \brief The Flickable item provides a surface that can be "flicked". - \inherits Item - - The Flickable item places its children on a surface that can be dragged - and flicked, causing the view onto the child items to scroll. This - behavior forms the basis of Items that are designed to show large numbers - of child items, such as \l ListView and \l GridView. - - In traditional user interfaces, views can be scrolled using standard - controls, such as scroll bars and arrow buttons. In some situations, it - is also possible to drag the view directly by pressing and holding a - mouse button while moving the cursor. In touch-based user interfaces, - this dragging action is often complemented with a flicking action, where - scrolling continues after the user has stopped touching the view. - - Flickable does not automatically clip its contents. If it is not used as - a full-screen item, you should consider setting the \l{Item::}{clip} property - to true. - - \section1 Example Usage - - \div {class="float-right"} - \inlineimage flickable.gif - \enddiv - - The following example shows a small view onto a large image in which the - user can drag or flick the image in order to view different parts of it. - - \snippet doc/src/snippets/qtquick1/flickable.qml document - - \clearfloat - - Items declared as children of a Flickable are automatically parented to the - Flickable's \l contentItem. This should be taken into account when - operating on the children of the Flickable; it is usually the children of - \c contentItem that are relevant. For example, the bound of Items added - to the Flickable will be available by \c contentItem.childrenRect - - \section1 Limitations - - \note Due to an implementation detail, items placed inside a Flickable cannot anchor to it by - \c id. Use \c parent instead. -*/ - -/*! - \qmlsignal QtQuick1::Flickable::onMovementStarted() - - This handler is called when the view begins moving due to user - interaction. -*/ - -/*! - \qmlsignal QtQuick1::Flickable::onMovementEnded() - - This handler is called when the view stops moving due to user - interaction. If a flick was generated, this handler will - be triggered once the flick stops. If a flick was not - generated, the handler will be triggered when the - user stops dragging - i.e. a mouse or touch release. -*/ - -/*! - \qmlsignal QtQuick1::Flickable::onFlickStarted() - - This handler is called when the view is flicked. A flick - starts from the point that the mouse or touch is released, - while still in motion. -*/ - -/*! - \qmlsignal QtQuick1::Flickable::onFlickEnded() - - This handler is called when the view stops moving due to a flick. -*/ - -/*! - \qmlproperty real QtQuick1::Flickable::visibleArea.xPosition - \qmlproperty real QtQuick1::Flickable::visibleArea.widthRatio - \qmlproperty real QtQuick1::Flickable::visibleArea.yPosition - \qmlproperty real QtQuick1::Flickable::visibleArea.heightRatio - - These properties describe the position and size of the currently viewed area. - The size is defined as the percentage of the full view currently visible, - scaled to 0.0 - 1.0. The page position is usually in the range 0.0 (beginning) to - 1.0 minus size ratio (end), i.e. \c yPosition is in the range 0.0 to 1.0-\c heightRatio. - However, it is possible for the contents to be dragged outside of the normal - range, resulting in the page positions also being outside the normal range. - - These properties are typically used to draw a scrollbar. For example: - - \snippet doc/src/snippets/qtquick1/flickableScrollbar.qml 0 - \dots 8 - \snippet doc/src/snippets/qtquick1/flickableScrollbar.qml 1 - - \sa {declarative/ui-components/scrollbar}{scrollbar example} -*/ - -QDeclarative1Flickable::QDeclarative1Flickable(QDeclarativeItem *parent) - : QDeclarativeItem(*(new QDeclarative1FlickablePrivate), parent) -{ - Q_D(QDeclarative1Flickable); - d->init(); -} - -QDeclarative1Flickable::QDeclarative1Flickable(QDeclarative1FlickablePrivate &dd, QDeclarativeItem *parent) - : QDeclarativeItem(dd, parent) -{ - Q_D(QDeclarative1Flickable); - d->init(); -} - -QDeclarative1Flickable::~QDeclarative1Flickable() -{ -} - -/*! - \qmlproperty real QtQuick1::Flickable::contentX - \qmlproperty real QtQuick1::Flickable::contentY - - These properties hold the surface coordinate currently at the top-left - corner of the Flickable. For example, if you flick an image up 100 pixels, - \c contentY will be 100. -*/ -qreal QDeclarative1Flickable::contentX() const -{ - Q_D(const QDeclarative1Flickable); - return -d->contentItem->x(); -} - -void QDeclarative1Flickable::setContentX(qreal pos) -{ - Q_D(QDeclarative1Flickable); - d->timeline.reset(d->hData.move); - d->vTime = d->timeline.time(); - movementXEnding(); - if (-pos != d->hData.move.value()) { - d->hData.move.setValue(-pos); - viewportMoved(); - } -} - -qreal QDeclarative1Flickable::contentY() const -{ - Q_D(const QDeclarative1Flickable); - return -d->contentItem->y(); -} - -void QDeclarative1Flickable::setContentY(qreal pos) -{ - Q_D(QDeclarative1Flickable); - d->timeline.reset(d->vData.move); - d->vTime = d->timeline.time(); - movementYEnding(); - if (-pos != d->vData.move.value()) { - d->vData.move.setValue(-pos); - viewportMoved(); - } -} - -/*! - \qmlproperty bool QtQuick1::Flickable::interactive - - This property describes whether the user can interact with the Flickable. - A user cannot drag or flick a Flickable that is not interactive. - - By default, this property is true. - - This property is useful for temporarily disabling flicking. This allows - special interaction with Flickable's children; for example, you might want - to freeze a flickable map while scrolling through a pop-up dialog that - is a child of the Flickable. -*/ -bool QDeclarative1Flickable::isInteractive() const -{ - Q_D(const QDeclarative1Flickable); - return d->interactive; -} - -void QDeclarative1Flickable::setInteractive(bool interactive) -{ - Q_D(QDeclarative1Flickable); - if (interactive != d->interactive) { - d->interactive = interactive; - if (!interactive && (d->hData.flicking || d->vData.flicking)) { - d->timeline.clear(); - d->vTime = d->timeline.time(); - d->hData.flicking = false; - d->vData.flicking = false; - emit flickingChanged(); - emit flickingHorizontallyChanged(); - emit flickingVerticallyChanged(); - emit flickEnded(); - } - emit interactiveChanged(); - } -} - -/*! - \qmlproperty real QtQuick1::Flickable::horizontalVelocity - \qmlproperty real QtQuick1::Flickable::verticalVelocity - - The instantaneous velocity of movement along the x and y axes, in pixels/sec. - - The reported velocity is smoothed to avoid erratic output. -*/ -qreal QDeclarative1Flickable::horizontalVelocity() const -{ - Q_D(const QDeclarative1Flickable); - return d->hData.smoothVelocity.value(); -} - -qreal QDeclarative1Flickable::verticalVelocity() const -{ - Q_D(const QDeclarative1Flickable); - return d->vData.smoothVelocity.value(); -} - -/*! - \qmlproperty bool QtQuick1::Flickable::atXBeginning - \qmlproperty bool QtQuick1::Flickable::atXEnd - \qmlproperty bool QtQuick1::Flickable::atYBeginning - \qmlproperty bool QtQuick1::Flickable::atYEnd - - These properties are true if the flickable view is positioned at the beginning, - or end respecively. -*/ -bool QDeclarative1Flickable::isAtXEnd() const -{ - Q_D(const QDeclarative1Flickable); - return d->hData.atEnd; -} - -bool QDeclarative1Flickable::isAtXBeginning() const -{ - Q_D(const QDeclarative1Flickable); - return d->hData.atBeginning; -} - -bool QDeclarative1Flickable::isAtYEnd() const -{ - Q_D(const QDeclarative1Flickable); - return d->vData.atEnd; -} - -bool QDeclarative1Flickable::isAtYBeginning() const -{ - Q_D(const QDeclarative1Flickable); - return d->vData.atBeginning; -} - -void QDeclarative1Flickable::ticked() -{ - viewportMoved(); -} - -/*! - \qmlproperty Item QtQuick1::Flickable::contentItem - - The internal item that contains the Items to be moved in the Flickable. - - Items declared as children of a Flickable are automatically parented to the Flickable's contentItem. - - Items created dynamically need to be explicitly parented to the \e contentItem: - \code - Flickable { - id: myFlickable - function addItem(file) { - var component = Qt.createComponent(file) - component.createObject(myFlickable.contentItem); - } - } - \endcode -*/ -QDeclarativeItem *QDeclarative1Flickable::contentItem() -{ - Q_D(QDeclarative1Flickable); - return d->contentItem; -} - -QDeclarative1FlickableVisibleArea *QDeclarative1Flickable::visibleArea() -{ - Q_D(QDeclarative1Flickable); - if (!d->visibleArea) - d->visibleArea = new QDeclarative1FlickableVisibleArea(this); - return d->visibleArea; -} - -/*! - \qmlproperty enumeration QtQuick1::Flickable::flickableDirection - - This property determines which directions the view can be flicked. - - \list - \o Flickable.AutoFlickDirection (default) - allows flicking vertically if the - \e contentHeight is not equal to the \e height of the Flickable. - Allows flicking horizontally if the \e contentWidth is not equal - to the \e width of the Flickable. - \o Flickable.HorizontalFlick - allows flicking horizontally. - \o Flickable.VerticalFlick - allows flicking vertically. - \o Flickable.HorizontalAndVerticalFlick - allows flicking in both directions. - \endlist -*/ -QDeclarative1Flickable::FlickableDirection QDeclarative1Flickable::flickableDirection() const -{ - Q_D(const QDeclarative1Flickable); - return d->flickableDirection; -} - -void QDeclarative1Flickable::setFlickableDirection(FlickableDirection direction) -{ - Q_D(QDeclarative1Flickable); - if (direction != d->flickableDirection) { - d->flickableDirection = direction; - emit flickableDirectionChanged(); - } -} - -void QDeclarative1FlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event) -{ - Q_Q(QDeclarative1Flickable); - if (interactive && timeline.isActive() - && (qAbs(hData.smoothVelocity.value()) > RetainGrabVelocity || qAbs(vData.smoothVelocity.value()) > RetainGrabVelocity)) - stealMouse = true; // If we've been flicked then steal the click. - else - stealMouse = false; - q->setKeepMouseGrab(stealMouse); - pressed = true; - timeline.clear(); - hData.reset(); - vData.reset(); - hData.dragMinBound = q->minXExtent(); - vData.dragMinBound = q->minYExtent(); - hData.dragMaxBound = q->maxXExtent(); - vData.dragMaxBound = q->maxYExtent(); - fixupMode = Normal; - lastPos = QPoint(); - QDeclarativeItemPrivate::start(lastPosTime); - pressPos = event->pos(); - hData.pressPos = hData.move.value(); - vData.pressPos = vData.move.value(); - hData.flicking = false; - vData.flicking = false; - QDeclarativeItemPrivate::start(pressTime); - QDeclarativeItemPrivate::start(velocityTime); -} - -void QDeclarative1FlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - Q_Q(QDeclarative1Flickable); - if (!interactive || !lastPosTime.isValid()) - return; - bool rejectY = false; - bool rejectX = false; - - bool stealY = stealMouse; - bool stealX = stealMouse; - - if (q->yflick()) { - int dy = int(event->pos().y() - pressPos.y()); - if (qAbs(dy) > QApplication::startDragDistance() || QDeclarativeItemPrivate::elapsed(pressTime) > 200) { - if (!vMoved) - vData.dragStartOffset = dy; - qreal newY = dy + vData.pressPos - vData.dragStartOffset; - const qreal minY = vData.dragMinBound; - const qreal maxY = vData.dragMaxBound; - if (newY > minY) - newY = minY + (newY - minY) / 2; - if (newY < maxY && maxY - minY <= 0) - newY = maxY + (newY - maxY) / 2; - if (boundsBehavior == QDeclarative1Flickable::StopAtBounds && (newY > minY || newY < maxY)) { - rejectY = true; - if (newY < maxY) { - newY = maxY; - rejectY = false; - } - if (newY > minY) { - newY = minY; - rejectY = false; - } - } - if (!rejectY && stealMouse) { - vData.move.setValue(qRound(newY)); - vMoved = true; - } - if (qAbs(dy) > QApplication::startDragDistance()) - stealY = true; - } - } - - if (q->xflick()) { - int dx = int(event->pos().x() - pressPos.x()); - if (qAbs(dx) > QApplication::startDragDistance() || QDeclarativeItemPrivate::elapsed(pressTime) > 200) { - if (!hMoved) - hData.dragStartOffset = dx; - qreal newX = dx + hData.pressPos - hData.dragStartOffset; - const qreal minX = hData.dragMinBound; - const qreal maxX = hData.dragMaxBound; - if (newX > minX) - newX = minX + (newX - minX) / 2; - if (newX < maxX && maxX - minX <= 0) - newX = maxX + (newX - maxX) / 2; - if (boundsBehavior == QDeclarative1Flickable::StopAtBounds && (newX > minX || newX < maxX)) { - rejectX = true; - if (newX < maxX) { - newX = maxX; - rejectX = false; - } - if (newX > minX) { - newX = minX; - rejectX = false; - } - } - if (!rejectX && stealMouse) { - hData.move.setValue(qRound(newX)); - hMoved = true; - } - - if (qAbs(dx) > QApplication::startDragDistance()) - stealX = true; - } - } - - stealMouse = stealX || stealY; - if (stealMouse) - q->setKeepMouseGrab(true); - - if (rejectY) { - vData.velocityBuffer.clear(); - vData.velocity = 0; - } - if (rejectX) { - hData.velocityBuffer.clear(); - hData.velocity = 0; - } - - if (hMoved || vMoved) { - q->movementStarting(); - q->viewportMoved(); - } - - if (!lastPos.isNull()) { - qreal elapsed = qreal(QDeclarativeItemPrivate::elapsed(lastPosTime)) / 1000.; - if (elapsed <= 0) - return; - QDeclarativeItemPrivate::restart(lastPosTime); - qreal dy = event->pos().y()-lastPos.y(); - if (q->yflick() && !rejectY) - vData.addVelocitySample(dy/elapsed, maxVelocity); - qreal dx = event->pos().x()-lastPos.x(); - if (q->xflick() && !rejectX) - hData.addVelocitySample(dx/elapsed, maxVelocity); - } - - lastPos = event->pos(); -} - -void QDeclarative1FlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - Q_Q(QDeclarative1Flickable); - stealMouse = false; - q->setKeepMouseGrab(false); - pressed = false; - if (!lastPosTime.isValid()) - return; - - // if we drag then pause before release we should not cause a flick. - qint64 elapsed = QDeclarativeItemPrivate::elapsed(lastPosTime); - - vData.updateVelocity(); - hData.updateVelocity(); - - vTime = timeline.time(); - - 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) { - velocityTimeline.reset(vData.smoothVelocity); - vData.smoothVelocity.setValue(-velocity); - flickY(velocity); - } else { - fixupY(); - } - - 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) { - velocityTimeline.reset(hData.smoothVelocity); - hData.smoothVelocity.setValue(-velocity); - flickX(velocity); - } else { - fixupX(); - } - - if (!timeline.isActive()) - q->movementEnding(); -} - -void QDeclarative1Flickable::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1Flickable); - if (d->interactive) { - if (!d->pressed) - d->handleMousePressEvent(event); - event->accept(); - } else { - QDeclarativeItem::mousePressEvent(event); - } -} - -void QDeclarative1Flickable::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1Flickable); - if (d->interactive) { - d->handleMouseMoveEvent(event); - event->accept(); - } else { - QDeclarativeItem::mouseMoveEvent(event); - } -} - -void QDeclarative1Flickable::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1Flickable); - if (d->interactive) { - d->clearDelayedPress(); - d->handleMouseReleaseEvent(event); - event->accept(); - ungrabMouse(); - } else { - QDeclarativeItem::mouseReleaseEvent(event); - } -} - -void QDeclarative1Flickable::wheelEvent(QGraphicsSceneWheelEvent *event) -{ - Q_D(QDeclarative1Flickable); - if (!d->interactive) { - QDeclarativeItem::wheelEvent(event); - } else if (yflick() && event->orientation() == Qt::Vertical) { - bool valid = false; - if (event->delta() > 0 && contentY() > -minYExtent()) { - d->vData.velocity = qMax(event->delta()*2 - d->vData.smoothVelocity.value(), qreal(d->maxVelocity/4)); - valid = true; - } else if (event->delta() < 0 && contentY() < -maxYExtent()) { - d->vData.velocity = qMin(event->delta()*2 - d->vData.smoothVelocity.value(), qreal(-d->maxVelocity/4)); - valid = true; - } - if (valid) { - d->vData.flicking = false; - d->flickY(d->vData.velocity); - if (d->vData.flicking) { - d->vMoved = true; - movementStarting(); - } - event->accept(); - } - } else if (xflick() && event->orientation() == Qt::Horizontal) { - bool valid = false; - if (event->delta() > 0 && contentX() > -minXExtent()) { - d->hData.velocity = qMax(event->delta()*2 - d->hData.smoothVelocity.value(), qreal(d->maxVelocity/4)); - valid = true; - } else if (event->delta() < 0 && contentX() < -maxXExtent()) { - d->hData.velocity = qMin(event->delta()*2 - d->hData.smoothVelocity.value(), qreal(-d->maxVelocity/4)); - valid = true; - } - if (valid) { - d->hData.flicking = false; - d->flickX(d->hData.velocity); - if (d->hData.flicking) { - d->hMoved = true; - movementStarting(); - } - event->accept(); - } - } else { - QDeclarativeItem::wheelEvent(event); - } -} - -bool QDeclarative1FlickablePrivate::isOutermostPressDelay() const -{ - Q_Q(const QDeclarative1Flickable); - QDeclarativeItem *item = q->parentItem(); - while (item) { - QDeclarative1Flickable *flick = qobject_cast<QDeclarative1Flickable*>(item); - if (flick && flick->pressDelay() > 0 && flick->isInteractive()) - return false; - item = item->parentItem(); - } - - return true; -} - -void QDeclarative1FlickablePrivate::captureDelayedPress(QGraphicsSceneMouseEvent *event) -{ - Q_Q(QDeclarative1Flickable); - if (!q->scene() || pressDelay <= 0) - return; - if (!isOutermostPressDelay()) - return; - delayedPressTarget = q->scene()->mouseGrabberItem(); - delayedPressEvent = new QGraphicsSceneMouseEvent(event->type()); - delayedPressEvent->setAccepted(false); - for (int i = 0x1; i <= 0x10; i <<= 1) { - if (event->buttons() & i) { - Qt::MouseButton button = Qt::MouseButton(i); - delayedPressEvent->setButtonDownPos(button, event->buttonDownPos(button)); - delayedPressEvent->setButtonDownScenePos(button, event->buttonDownScenePos(button)); - delayedPressEvent->setButtonDownScreenPos(button, event->buttonDownScreenPos(button)); - } - } - delayedPressEvent->setButtons(event->buttons()); - delayedPressEvent->setButton(event->button()); - delayedPressEvent->setPos(event->pos()); - delayedPressEvent->setScenePos(event->scenePos()); - delayedPressEvent->setScreenPos(event->screenPos()); - delayedPressEvent->setLastPos(event->lastPos()); - delayedPressEvent->setLastScenePos(event->lastScenePos()); - delayedPressEvent->setLastScreenPos(event->lastScreenPos()); - delayedPressEvent->setModifiers(event->modifiers()); - delayedPressTimer.start(pressDelay, q); -} - -void QDeclarative1FlickablePrivate::clearDelayedPress() -{ - if (delayedPressEvent) { - delayedPressTimer.stop(); - delete delayedPressEvent; - delayedPressEvent = 0; - } -} - -void QDeclarative1FlickablePrivate::setRoundedViewportX(qreal x) -{ - contentItem->setX(qRound(x)); -} - -void QDeclarative1FlickablePrivate::setRoundedViewportY(qreal y) -{ - contentItem->setY(qRound(y)); -} - -void QDeclarative1Flickable::timerEvent(QTimerEvent *event) -{ - Q_D(QDeclarative1Flickable); - if (event->timerId() == d->delayedPressTimer.timerId()) { - d->delayedPressTimer.stop(); - if (d->delayedPressEvent) { - QDeclarativeItem *grabber = scene() ? qobject_cast<QDeclarativeItem*>(scene()->mouseGrabberItem()) : 0; - if (!grabber || grabber != this) { - // We replay the mouse press but the grabber we had might not be interessted by the event (e.g. overlay) - // so we reset the grabber - if (scene()->mouseGrabberItem() == d->delayedPressTarget) - d->delayedPressTarget->ungrabMouse(); - //Use the event handler that will take care of finding the proper item to propagate the event - QApplication::postEvent(scene(), d->delayedPressEvent); - } else { - delete d->delayedPressEvent; - } - d->delayedPressEvent = 0; - } - } -} - -qreal QDeclarative1Flickable::minYExtent() const -{ - return 0.0; -} - -qreal QDeclarative1Flickable::minXExtent() const -{ - return 0.0; -} - -/* returns -ve */ -qreal QDeclarative1Flickable::maxXExtent() const -{ - return width() - vWidth(); -} -/* returns -ve */ -qreal QDeclarative1Flickable::maxYExtent() const -{ - return height() - vHeight(); -} - -void QDeclarative1Flickable::viewportMoved() -{ - Q_D(QDeclarative1Flickable); - - qreal prevX = d->lastFlickablePosition.x(); - qreal prevY = d->lastFlickablePosition.y(); - 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; - 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); - d->vData.smoothVelocity.setValue(verticalVelocity); - } - } - - 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 - d->vData.inOvershoot = true; - qreal maxDistance = d->overShootDistance(height()); - d->timeline.reset(d->vData.move); - d->timeline.accel(d->vData.move, -d->vData.smoothVelocity.value(), d->deceleration*QML_FLICK_OVERSHOOTFRICTION, maxDistance); - d->timeline.callback(QDeclarative1TimeLineCallback(&d->vData.move, d->fixupY_callback, d)); - } - 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 - d->hData.inOvershoot = true; - qreal maxDistance = d->overShootDistance(width()); - d->timeline.reset(d->hData.move); - d->timeline.accel(d->hData.move, -d->hData.smoothVelocity.value(), d->deceleration*QML_FLICK_OVERSHOOTFRICTION, maxDistance); - d->timeline.callback(QDeclarative1TimeLineCallback(&d->hData.move, d->fixupX_callback, d)); - } - - d->lastFlickablePosition = QPointF(d->hData.move.value(), d->vData.move.value()); - - d->vTime = d->timeline.time(); - d->updateBeginningEnd(); -} - -void QDeclarative1Flickable::geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) -{ - Q_D(QDeclarative1Flickable); - QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); - - bool changed = false; - if (newGeometry.width() != oldGeometry.width()) { - if (xflick()) - changed = true; - if (d->hData.viewSize < 0) { - d->contentItem->setWidth(width()); - emit contentWidthChanged(); - } - // Make sure that we're entirely in view. - if (!d->pressed && !d->hData.moving && !d->vData.moving) { - d->fixupMode = QDeclarative1FlickablePrivate::Immediate; - d->fixupX(); - } - } - if (newGeometry.height() != oldGeometry.height()) { - if (yflick()) - changed = true; - if (d->vData.viewSize < 0) { - d->contentItem->setHeight(height()); - emit contentHeightChanged(); - } - // Make sure that we're entirely in view. - if (!d->pressed && !d->hData.moving && !d->vData.moving) { - d->fixupMode = QDeclarative1FlickablePrivate::Immediate; - d->fixupY(); - } - } - - if (changed) - d->updateBeginningEnd(); -} - -void QDeclarative1Flickable::cancelFlick() -{ - Q_D(QDeclarative1Flickable); - d->timeline.reset(d->hData.move); - d->timeline.reset(d->vData.move); - movementEnding(); -} - -void QDeclarative1FlickablePrivate::data_append(QDeclarativeListProperty<QObject> *prop, QObject *o) -{ - QGraphicsObject *i = qobject_cast<QGraphicsObject *>(o); - if (i) { - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(i); - if (static_cast<QDeclarativeItemPrivate*>(d)->componentComplete) { - i->setParentItem(static_cast<QDeclarative1FlickablePrivate*>(prop->data)->contentItem); - } else { - d->setParentItemHelper(static_cast<QDeclarative1FlickablePrivate*>(prop->data)->contentItem, 0, 0); - } - } else { - o->setParent(prop->object); - } -} - -int QDeclarative1FlickablePrivate::data_count(QDeclarativeListProperty<QObject> *property) -{ - QDeclarativeItem *contentItem= static_cast<QDeclarative1FlickablePrivate*>(property->data)->contentItem; - return contentItem->childItems().count() + contentItem->children().count(); -} - -QObject *QDeclarative1FlickablePrivate::data_at(QDeclarativeListProperty<QObject> *property, int index) -{ - QDeclarativeItem *contentItem = static_cast<QDeclarative1FlickablePrivate*>(property->data)->contentItem; - - int childItemCount = contentItem->childItems().count(); - - if (index < 0) - return 0; - - if (index < childItemCount) { - return contentItem->childItems().at(index)->toGraphicsObject(); - } else { - return contentItem->children().at(index - childItemCount); - } - - return 0; -} - -void QDeclarative1FlickablePrivate::data_clear(QDeclarativeListProperty<QObject> *property) -{ - QDeclarativeItem *contentItem = static_cast<QDeclarative1FlickablePrivate*>(property->data)->contentItem; - - const QList<QGraphicsItem*> graphicsItems = contentItem->childItems(); - for (int i = 0; i < graphicsItems.count(); i++) - contentItem->scene()->removeItem(graphicsItems[i]); - - const QList<QObject*> objects = contentItem->children(); - for (int i = 0; i < objects.count(); i++) - objects[i]->setParent(0); -} - -QDeclarativeListProperty<QObject> QDeclarative1Flickable::flickableData() -{ - Q_D(QDeclarative1Flickable); - return QDeclarativeListProperty<QObject>(this, (void *)d, QDeclarative1FlickablePrivate::data_append, - QDeclarative1FlickablePrivate::data_count, - QDeclarative1FlickablePrivate::data_at, - QDeclarative1FlickablePrivate::data_clear); -} - -QDeclarativeListProperty<QGraphicsObject> QDeclarative1Flickable::flickableChildren() -{ - Q_D(QDeclarative1Flickable); - return QGraphicsItemPrivate::get(d->contentItem)->childrenList(); -} - -/*! - \qmlproperty enumeration QtQuick1::Flickable::boundsBehavior - This property holds whether the surface may be dragged - beyond the Fickable's boundaries, or overshoot the - Flickable's boundaries when flicked. - - This enables the feeling that the edges of the view are soft, - rather than a hard physical boundary. - - The \c boundsBehavior can be one of: - - \list - \o Flickable.StopAtBounds - the contents can not be dragged beyond the boundary - of the flickable, and flicks will not overshoot. - \o Flickable.DragOverBounds - the contents can be dragged beyond the boundary - of the Flickable, but flicks will not overshoot. - \o Flickable.DragAndOvershootBounds (default) - the contents can be dragged - beyond the boundary of the Flickable, and can overshoot the - boundary when flicked. - \endlist -*/ -QDeclarative1Flickable::BoundsBehavior QDeclarative1Flickable::boundsBehavior() const -{ - Q_D(const QDeclarative1Flickable); - return d->boundsBehavior; -} - -void QDeclarative1Flickable::setBoundsBehavior(BoundsBehavior b) -{ - Q_D(QDeclarative1Flickable); - if (b == d->boundsBehavior) - return; - d->boundsBehavior = b; - emit boundsBehaviorChanged(); -} - -/*! - \qmlproperty real QtQuick1::Flickable::contentWidth - \qmlproperty real QtQuick1::Flickable::contentHeight - - The dimensions of the content (the surface controlled by Flickable). - This should typically be set to the combined size of the items placed in the - Flickable. - - The following snippet shows how these properties are used to display - an image that is larger than the Flickable item itself: - - \snippet doc/src/snippets/qtquick1/flickable.qml document - - In some cases, the the content dimensions can be automatically set - using the \l {Item::childrenRect.width}{childrenRect.width} - and \l {Item::childrenRect.height}{childrenRect.height} properties. -*/ -qreal QDeclarative1Flickable::contentWidth() const -{ - Q_D(const QDeclarative1Flickable); - return d->hData.viewSize; -} - -void QDeclarative1Flickable::setContentWidth(qreal w) -{ - Q_D(QDeclarative1Flickable); - if (d->hData.viewSize == w) - return; - d->hData.viewSize = w; - if (w < 0) - d->contentItem->setWidth(width()); - else - d->contentItem->setWidth(w); - // Make sure that we're entirely in view. - if (!d->pressed && !d->hData.moving && !d->vData.moving) { - d->fixupMode = QDeclarative1FlickablePrivate::Immediate; - d->fixupX(); - } else if (!d->pressed && d->hData.fixingUp) { - d->fixupMode = QDeclarative1FlickablePrivate::ExtentChanged; - d->fixupX(); - } - emit contentWidthChanged(); - d->updateBeginningEnd(); -} - -qreal QDeclarative1Flickable::contentHeight() const -{ - Q_D(const QDeclarative1Flickable); - return d->vData.viewSize; -} - -void QDeclarative1Flickable::setContentHeight(qreal h) -{ - Q_D(QDeclarative1Flickable); - if (d->vData.viewSize == h) - return; - d->vData.viewSize = h; - if (h < 0) - d->contentItem->setHeight(height()); - else - d->contentItem->setHeight(h); - // Make sure that we're entirely in view. - if (!d->pressed && !d->hData.moving && !d->vData.moving) { - d->fixupMode = QDeclarative1FlickablePrivate::Immediate; - d->fixupY(); - } else if (!d->pressed && d->vData.fixingUp) { - d->fixupMode = QDeclarative1FlickablePrivate::ExtentChanged; - d->fixupY(); - } - emit contentHeightChanged(); - d->updateBeginningEnd(); -} - -/*! - \qmlmethod QtQuick1::Flickable::resizeContent(real width, real height, QPointF center) - \preliminary - \since Quick 1.1 - - Resizes the content to \a width x \a height about \a center. - - This does not scale the contents of the Flickable - it only resizes the \l contentWidth - and \l contentHeight. - - Resizing the content may result in the content being positioned outside - the bounds of the Flickable. Calling \l returnToBounds() will - move the content back within legal bounds. -*/ -void QDeclarative1Flickable::resizeContent(qreal w, qreal h, QPointF center) -{ - Q_D(QDeclarative1Flickable); - if (w != d->hData.viewSize) { - qreal oldSize = d->hData.viewSize; - d->hData.viewSize = w; - d->contentItem->setWidth(w); - emit contentWidthChanged(); - if (center.x() != 0) { - qreal pos = center.x() * w / oldSize; - setContentX(contentX() + pos - center.x()); - } - } - if (h != d->vData.viewSize) { - qreal oldSize = d->vData.viewSize; - d->vData.viewSize = h; - d->contentItem->setHeight(h); - emit contentHeightChanged(); - if (center.y() != 0) { - qreal pos = center.y() * h / oldSize; - setContentY(contentY() + pos - center.y()); - } - } - d->updateBeginningEnd(); -} - -/*! - \qmlmethod QtQuick1::Flickable::returnToBounds() - \preliminary - \since Quick 1.1 - - Ensures the content is within legal bounds. - - This may be called to ensure that the content is within legal bounds - after manually positioning the content. -*/ -void QDeclarative1Flickable::returnToBounds() -{ - Q_D(QDeclarative1Flickable); - d->fixupX(); - d->fixupY(); -} - -qreal QDeclarative1Flickable::vWidth() const -{ - Q_D(const QDeclarative1Flickable); - if (d->hData.viewSize < 0) - return width(); - else - return d->hData.viewSize; -} - -qreal QDeclarative1Flickable::vHeight() const -{ - Q_D(const QDeclarative1Flickable); - if (d->vData.viewSize < 0) - return height(); - else - return d->vData.viewSize; -} - -bool QDeclarative1Flickable::xflick() const -{ - Q_D(const QDeclarative1Flickable); - if (d->flickableDirection == QDeclarative1Flickable::AutoFlickDirection) - return vWidth() != width(); - return d->flickableDirection & QDeclarative1Flickable::HorizontalFlick; -} - -bool QDeclarative1Flickable::yflick() const -{ - Q_D(const QDeclarative1Flickable); - if (d->flickableDirection == QDeclarative1Flickable::AutoFlickDirection) - return vHeight() != height(); - return d->flickableDirection & QDeclarative1Flickable::VerticalFlick; -} - -bool QDeclarative1Flickable::sceneEvent(QEvent *event) -{ - bool rv = QDeclarativeItem::sceneEvent(event); - if (event->type() == QEvent::UngrabMouse) { - Q_D(QDeclarative1Flickable); - if (d->pressed) { - // if our mouse grab has been removed (probably by another Flickable), - // fix our state - d->pressed = false; - d->stealMouse = false; - setKeepMouseGrab(false); - } - } - return rv; -} - -bool QDeclarative1Flickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1Flickable); - QGraphicsSceneMouseEvent mouseEvent(event->type()); - QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect(); - - QGraphicsScene *s = scene(); - QDeclarativeItem *grabber = s ? qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem()) : 0; - QGraphicsItem *grabberItem = s ? s->mouseGrabberItem() : 0; - bool disabledItem = grabberItem && !grabberItem->isEnabled(); - bool stealThisEvent = d->stealMouse; - if ((stealThisEvent || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab() || disabledItem)) { - mouseEvent.setAccepted(false); - for (int i = 0x1; i <= 0x10; i <<= 1) { - if (event->buttons() & i) { - Qt::MouseButton button = Qt::MouseButton(i); - mouseEvent.setButtonDownPos(button, mapFromScene(event->buttonDownPos(button))); - } - } - mouseEvent.setScenePos(event->scenePos()); - mouseEvent.setLastScenePos(event->lastScenePos()); - mouseEvent.setPos(mapFromScene(event->scenePos())); - mouseEvent.setLastPos(mapFromScene(event->lastScenePos())); - - switch(mouseEvent.type()) { - case QEvent::GraphicsSceneMouseMove: - d->handleMouseMoveEvent(&mouseEvent); - break; - case QEvent::GraphicsSceneMousePress: - if (d->pressed) // we are already pressed - this is a delayed replay - return false; - - d->handleMousePressEvent(&mouseEvent); - d->captureDelayedPress(event); - stealThisEvent = d->stealMouse; // Update stealThisEvent in case changed by function call above - break; - case QEvent::GraphicsSceneMouseRelease: - if (d->delayedPressEvent) { - // We replay the mouse press but the grabber we had might not be interessted by the event (e.g. overlay) - // so we reset the grabber - if (s->mouseGrabberItem() == d->delayedPressTarget) - d->delayedPressTarget->ungrabMouse(); - //Use the event handler that will take care of finding the proper item to propagate the event - QApplication::sendEvent(scene(), d->delayedPressEvent); - d->clearDelayedPress(); - // We send the release - scene()->sendEvent(s->mouseGrabberItem(), event); - // And the event has been consumed - d->stealMouse = false; - d->pressed = false; - return true; - } - d->handleMouseReleaseEvent(&mouseEvent); - break; - default: - break; - } - grabber = qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem()); - if ((grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this) || disabledItem) { - d->clearDelayedPress(); - grabMouse(); - } - - return stealThisEvent || d->delayedPressEvent || disabledItem; - } else if (d->lastPosTime.isValid()) { - d->lastPosTime.invalidate(); - returnToBounds(); - } - if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) { - d->clearDelayedPress(); - d->stealMouse = false; - d->pressed = false; - } - - return false; -} - -bool QDeclarative1Flickable::sceneEventFilter(QGraphicsItem *i, QEvent *e) -{ - Q_D(QDeclarative1Flickable); - if (!isVisible() || !d->interactive || !isEnabled()) - return QDeclarativeItem::sceneEventFilter(i, e); - switch (e->type()) { - case QEvent::GraphicsSceneMousePress: - case QEvent::GraphicsSceneMouseMove: - case QEvent::GraphicsSceneMouseRelease: - return sendMouseEvent(static_cast<QGraphicsSceneMouseEvent *>(e)); - default: - break; - } - - return QDeclarativeItem::sceneEventFilter(i, e); -} - -/*! - \qmlproperty real QtQuick1::Flickable::maximumFlickVelocity - This property holds the maximum velocity that the user can flick the view in pixels/second. - - The default value is platform dependent. -*/ -qreal QDeclarative1Flickable::maximumFlickVelocity() const -{ - Q_D(const QDeclarative1Flickable); - return d->maxVelocity; -} - -void QDeclarative1Flickable::setMaximumFlickVelocity(qreal v) -{ - Q_D(QDeclarative1Flickable); - if (v == d->maxVelocity) - return; - d->maxVelocity = v; - emit maximumFlickVelocityChanged(); -} - -/*! - \qmlproperty real QtQuick1::Flickable::flickDeceleration - This property holds the rate at which a flick will decelerate. - - The default value is platform dependent. -*/ -qreal QDeclarative1Flickable::flickDeceleration() const -{ - Q_D(const QDeclarative1Flickable); - return d->deceleration; -} - -void QDeclarative1Flickable::setFlickDeceleration(qreal deceleration) -{ - Q_D(QDeclarative1Flickable); - if (deceleration == d->deceleration) - return; - d->deceleration = deceleration; - emit flickDecelerationChanged(); -} - -bool QDeclarative1Flickable::isFlicking() const -{ - Q_D(const QDeclarative1Flickable); - return d->hData.flicking || d->vData.flicking; -} - -/*! - \qmlproperty bool QtQuick1::Flickable::flicking - \qmlproperty bool QtQuick1::Flickable::flickingHorizontally - \qmlproperty bool QtQuick1::Flickable::flickingVertically - - These properties describe whether the view is currently moving horizontally, - vertically or in either direction, due to the user flicking the view. -*/ -bool QDeclarative1Flickable::isFlickingHorizontally() const -{ - Q_D(const QDeclarative1Flickable); - return d->hData.flicking; -} - -bool QDeclarative1Flickable::isFlickingVertically() const -{ - Q_D(const QDeclarative1Flickable); - return d->vData.flicking; -} - -/*! - \qmlproperty int QtQuick1::Flickable::pressDelay - - This property holds the time to delay (ms) delivering a press to - children of the Flickable. This can be useful where reacting - to a press before a flicking action has undesirable effects. - - If the flickable is dragged/flicked before the delay times out - the press event will not be delivered. If the button is released - within the timeout, both the press and release will be delivered. - - Note that for nested Flickables with pressDelay set, the pressDelay of - inner Flickables is overridden by the outermost Flickable. -*/ -int QDeclarative1Flickable::pressDelay() const -{ - Q_D(const QDeclarative1Flickable); - return d->pressDelay; -} - -void QDeclarative1Flickable::setPressDelay(int delay) -{ - Q_D(QDeclarative1Flickable); - if (d->pressDelay == delay) - return; - d->pressDelay = delay; - emit pressDelayChanged(); -} - - -bool QDeclarative1Flickable::isMoving() const -{ - Q_D(const QDeclarative1Flickable); - return d->hData.moving || d->vData.moving; -} - -/*! - \qmlproperty bool QtQuick1::Flickable::moving - \qmlproperty bool QtQuick1::Flickable::movingHorizontally - \qmlproperty bool QtQuick1::Flickable::movingVertically - - These properties describe whether the view is currently moving horizontally, - vertically or in either direction, due to the user either dragging or - flicking the view. -*/ -bool QDeclarative1Flickable::isMovingHorizontally() const -{ - Q_D(const QDeclarative1Flickable); - return d->hData.moving; -} - -bool QDeclarative1Flickable::isMovingVertically() const -{ - Q_D(const QDeclarative1Flickable); - return d->vData.moving; -} - -void QDeclarative1Flickable::movementStarting() -{ - Q_D(QDeclarative1Flickable); - if (d->hMoved && !d->hData.moving) { - d->hData.moving = true; - emit movingChanged(); - emit movingHorizontallyChanged(); - if (!d->vData.moving) - emit movementStarted(); - } - else if (d->vMoved && !d->vData.moving) { - d->vData.moving = true; - emit movingChanged(); - emit movingVerticallyChanged(); - if (!d->hData.moving) - emit movementStarted(); - } -} - -void QDeclarative1Flickable::movementEnding() -{ - Q_D(QDeclarative1Flickable); - movementXEnding(); - movementYEnding(); - d->hData.smoothVelocity.setValue(0); - d->vData.smoothVelocity.setValue(0); -} - -void QDeclarative1Flickable::movementXEnding() -{ - Q_D(QDeclarative1Flickable); - if (d->hData.flicking) { - d->hData.flicking = false; - emit flickingChanged(); - emit flickingHorizontallyChanged(); - if (!d->vData.flicking) - emit flickEnded(); - } - if (!d->pressed && !d->stealMouse) { - if (d->hData.moving) { - d->hData.moving = false; - d->hMoved = false; - emit movingChanged(); - emit movingHorizontallyChanged(); - if (!d->vData.moving) - emit movementEnded(); - } - } - d->hData.fixingUp = false; -} - -void QDeclarative1Flickable::movementYEnding() -{ - Q_D(QDeclarative1Flickable); - if (d->vData.flicking) { - d->vData.flicking = false; - emit flickingChanged(); - emit flickingVerticallyChanged(); - if (!d->hData.flicking) - emit flickEnded(); - } - if (!d->pressed && !d->stealMouse) { - if (d->vData.moving) { - d->vData.moving = false; - d->vMoved = false; - emit movingChanged(); - emit movingVerticallyChanged(); - if (!d->hData.moving) - emit movementEnded(); - } - } - d->vData.fixingUp = false; -} - -void QDeclarative1FlickablePrivate::updateVelocity() -{ - Q_Q(QDeclarative1Flickable); - emit q->horizontalVelocityChanged(); - emit q->verticalVelocityChanged(); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativeflickable_p.h b/src/qtquick1/graphicsitems/qdeclarativeflickable_p.h deleted file mode 100644 index 1ac08a6a11..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeflickable_p.h +++ /dev/null @@ -1,228 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEFLICKABLE_H -#define QDECLARATIVEFLICKABLE_H - -#include "qdeclarativeitem.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1FlickablePrivate; -class QDeclarative1FlickableVisibleArea; -class Q_AUTOTEST_EXPORT QDeclarative1Flickable : public QDeclarativeItem -{ - Q_OBJECT - - Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged) - Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged) - Q_PROPERTY(qreal contentX READ contentX WRITE setContentX NOTIFY contentXChanged) - Q_PROPERTY(qreal contentY READ contentY WRITE setContentY NOTIFY contentYChanged) - Q_PROPERTY(QDeclarativeItem *contentItem READ contentItem CONSTANT) - - Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged) - Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged) - - Q_PROPERTY(BoundsBehavior boundsBehavior READ boundsBehavior WRITE setBoundsBehavior NOTIFY boundsBehaviorChanged) - Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged) - Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged) - Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged) - Q_PROPERTY(bool movingHorizontally READ isMovingHorizontally NOTIFY movingHorizontallyChanged) - Q_PROPERTY(bool movingVertically READ isMovingVertically NOTIFY movingVerticallyChanged) - Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged) - Q_PROPERTY(bool flickingHorizontally READ isFlickingHorizontally NOTIFY flickingHorizontallyChanged) - Q_PROPERTY(bool flickingVertically READ isFlickingVertically NOTIFY flickingVerticallyChanged) - Q_PROPERTY(FlickableDirection flickableDirection READ flickableDirection WRITE setFlickableDirection NOTIFY flickableDirectionChanged) - - Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged) - Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay NOTIFY pressDelayChanged) - - Q_PROPERTY(bool atXEnd READ isAtXEnd NOTIFY isAtBoundaryChanged) - Q_PROPERTY(bool atYEnd READ isAtYEnd NOTIFY isAtBoundaryChanged) - Q_PROPERTY(bool atXBeginning READ isAtXBeginning NOTIFY isAtBoundaryChanged) - Q_PROPERTY(bool atYBeginning READ isAtYBeginning NOTIFY isAtBoundaryChanged) - - Q_PROPERTY(QDeclarative1FlickableVisibleArea *visibleArea READ visibleArea CONSTANT) - - Q_PROPERTY(QDeclarativeListProperty<QObject> flickableData READ flickableData) - Q_PROPERTY(QDeclarativeListProperty<QGraphicsObject> flickableChildren READ flickableChildren) - Q_CLASSINFO("DefaultProperty", "flickableData") - - Q_ENUMS(FlickableDirection) - Q_ENUMS(BoundsBehavior) - -public: - QDeclarative1Flickable(QDeclarativeItem *parent=0); - ~QDeclarative1Flickable(); - - QDeclarativeListProperty<QObject> flickableData(); - QDeclarativeListProperty<QGraphicsObject> flickableChildren(); - - enum BoundsBehavior { StopAtBounds, DragOverBounds, DragAndOvershootBounds }; - BoundsBehavior boundsBehavior() const; - void setBoundsBehavior(BoundsBehavior); - - qreal contentWidth() const; - void setContentWidth(qreal); - - qreal contentHeight() const; - void setContentHeight(qreal); - - qreal contentX() const; - virtual void setContentX(qreal pos); - - qreal contentY() const; - virtual void setContentY(qreal pos); - - bool isMoving() const; - bool isMovingHorizontally() const; - bool isMovingVertically() const; - bool isFlicking() const; - bool isFlickingHorizontally() const; - bool isFlickingVertically() const; - - int pressDelay() const; - void setPressDelay(int delay); - - qreal maximumFlickVelocity() const; - void setMaximumFlickVelocity(qreal); - - qreal flickDeceleration() const; - void setFlickDeceleration(qreal); - - bool isInteractive() const; - void setInteractive(bool); - - qreal horizontalVelocity() const; - qreal verticalVelocity() const; - - bool isAtXEnd() const; - bool isAtXBeginning() const; - bool isAtYEnd() const; - bool isAtYBeginning() const; - - QDeclarativeItem *contentItem(); - - enum FlickableDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 }; - FlickableDirection flickableDirection() const; - void setFlickableDirection(FlickableDirection); - - Q_INVOKABLE Q_REVISION(1) void resizeContent(qreal w, qreal h, QPointF center); - Q_INVOKABLE Q_REVISION(1) void returnToBounds(); - -Q_SIGNALS: - void contentWidthChanged(); - void contentHeightChanged(); - void contentXChanged(); - void contentYChanged(); - void movingChanged(); - void movingHorizontallyChanged(); - void movingVerticallyChanged(); - void flickingChanged(); - void flickingHorizontallyChanged(); - void flickingVerticallyChanged(); - void horizontalVelocityChanged(); - void verticalVelocityChanged(); - void isAtBoundaryChanged(); - void flickableDirectionChanged(); - void interactiveChanged(); - void boundsBehaviorChanged(); - void maximumFlickVelocityChanged(); - void flickDecelerationChanged(); - void pressDelayChanged(); - void movementStarted(); - void movementEnded(); - void flickStarted(); - void flickEnded(); - -protected: - virtual bool sceneEventFilter(QGraphicsItem *, QEvent *); - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - void wheelEvent(QGraphicsSceneWheelEvent *event); - void timerEvent(QTimerEvent *event); - - QDeclarative1FlickableVisibleArea *visibleArea(); - -protected Q_SLOTS: - virtual void ticked(); - void movementStarting(); - void movementEnding(); - -protected: - void movementXEnding(); - void movementYEnding(); - virtual qreal minXExtent() const; - virtual qreal minYExtent() const; - virtual qreal maxXExtent() const; - virtual qreal maxYExtent() const; - qreal vWidth() const; - qreal vHeight() const; - virtual void viewportMoved(); - virtual void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry); - bool sceneEvent(QEvent *event); - bool sendMouseEvent(QGraphicsSceneMouseEvent *event); - - bool xflick() const; - bool yflick() const; - void cancelFlick(); - -protected: - QDeclarative1Flickable(QDeclarative1FlickablePrivate &dd, QDeclarativeItem *parent); - -private: - Q_DISABLE_COPY(QDeclarative1Flickable) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Flickable) - friend class QDeclarative1FlickableVisibleArea; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Flickable) - -QT_END_HEADER - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativeflickable_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeflickable_p_p.h deleted file mode 100644 index e6489db70e..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeflickable_p_p.h +++ /dev/null @@ -1,239 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEFLICKABLE_P_H -#define QDECLARATIVEFLICKABLE_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 "private/qdeclarativeflickable_p.h" - -#include "private/qdeclarativeitem_p.h" -#include "private/qdeclarativeitemchangelistener_p.h" - -#include <QtDeclarative/qdeclarative.h> -#include <QtQuick1/private/qdeclarativetimeline_p_p.h> -#include <QtQuick1/private/qdeclarativeanimation_p_p.h> - -#include <qdatetime.h> - -QT_BEGIN_NAMESPACE - -// Really slow flicks can be annoying. -const qreal MinimumFlickVelocity = 75.0; - -class QDeclarative1FlickableVisibleArea; -class QDeclarative1FlickablePrivate : public QDeclarativeItemPrivate, public QDeclarativeItemChangeListener -{ - Q_DECLARE_PUBLIC(QDeclarative1Flickable) - -public: - QDeclarative1FlickablePrivate(); - void init(); - - struct Velocity : public QDeclarative1TimeLineValue - { - Velocity(QDeclarative1FlickablePrivate *p) - : parent(p) {} - virtual void setValue(qreal v) { - if (v != value()) { - QDeclarative1TimeLineValue::setValue(v); - parent->updateVelocity(); - } - } - QDeclarative1FlickablePrivate *parent; - }; - - struct AxisData { - AxisData(QDeclarative1FlickablePrivate *fp, void (QDeclarative1FlickablePrivate::*func)(qreal)) - : move(fp, func), viewSize(-1), smoothVelocity(fp), atEnd(false), atBeginning(true) - , fixingUp(false), inOvershoot(false), moving(false), flicking(false) - {} - - void reset() { - velocityBuffer.clear(); - dragStartOffset = 0; - fixingUp = false; - inOvershoot = false; - } - - void addVelocitySample(qreal v, qreal maxVelocity); - void updateVelocity(); - - QDeclarative1TimeLineValueProxy<QDeclarative1FlickablePrivate> move; - qreal viewSize; - qreal pressPos; - qreal dragStartOffset; - qreal dragMinBound; - qreal dragMaxBound; - qreal velocity; - qreal flickTarget; - QDeclarative1FlickablePrivate::Velocity smoothVelocity; - QPODVector<qreal,10> velocityBuffer; - bool atEnd : 1; - bool atBeginning : 1; - bool fixingUp : 1; - bool inOvershoot : 1; - bool moving : 1; - bool flicking : 1; - }; - - void flickX(qreal velocity); - void flickY(qreal velocity); - virtual void flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, - QDeclarative1TimeLineCallback::Callback fixupCallback, qreal velocity); - - void fixupX(); - void fixupY(); - virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent); - - void updateBeginningEnd(); - - bool isOutermostPressDelay() const; - void captureDelayedPress(QGraphicsSceneMouseEvent *event); - void clearDelayedPress(); - - void setRoundedViewportX(qreal x); - void setRoundedViewportY(qreal y); - - qreal overShootDistance(qreal size); - - void itemGeometryChanged(QDeclarativeItem *, const QRectF &, const QRectF &); - -public: - QDeclarativeItem *contentItem; - - AxisData hData; - AxisData vData; - - QDeclarative1TimeLine timeline; - bool hMoved : 1; - bool vMoved : 1; - bool stealMouse : 1; - bool pressed : 1; - bool interactive : 1; - bool calcVelocity : 1; - QElapsedTimer lastPosTime; - QPointF lastPos; - QPointF pressPos; - QElapsedTimer pressTime; - qreal deceleration; - qreal maxVelocity; - QElapsedTimer velocityTime; - QPointF lastFlickablePosition; - qreal reportedVelocitySmoothing; - QGraphicsSceneMouseEvent *delayedPressEvent; - QGraphicsItem *delayedPressTarget; - QBasicTimer delayedPressTimer; - int pressDelay; - int fixupDuration; - - enum FixupMode { Normal, Immediate, ExtentChanged }; - FixupMode fixupMode; - - static void fixupY_callback(void *); - static void fixupX_callback(void *); - - void updateVelocity(); - int vTime; - QDeclarative1TimeLine velocityTimeline; - QDeclarative1FlickableVisibleArea *visibleArea; - QDeclarative1Flickable::FlickableDirection flickableDirection; - QDeclarative1Flickable::BoundsBehavior boundsBehavior; - - void handleMousePressEvent(QGraphicsSceneMouseEvent *); - void handleMouseMoveEvent(QGraphicsSceneMouseEvent *); - void handleMouseReleaseEvent(QGraphicsSceneMouseEvent *); - - // flickableData property - static void data_append(QDeclarativeListProperty<QObject> *, QObject *); - static int data_count(QDeclarativeListProperty<QObject> *); - static QObject *data_at(QDeclarativeListProperty<QObject> *, int); - static void data_clear(QDeclarativeListProperty<QObject> *); -}; - -class QDeclarative1FlickableVisibleArea : public QObject -{ - Q_OBJECT - - Q_PROPERTY(qreal xPosition READ xPosition NOTIFY xPositionChanged) - Q_PROPERTY(qreal yPosition READ yPosition NOTIFY yPositionChanged) - Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY widthRatioChanged) - Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY heightRatioChanged) - -public: - QDeclarative1FlickableVisibleArea(QDeclarative1Flickable *parent=0); - - qreal xPosition() const; - qreal widthRatio() const; - qreal yPosition() const; - qreal heightRatio() const; - - void updateVisible(); - -signals: - void xPositionChanged(qreal xPosition); - void yPositionChanged(qreal yPosition); - void widthRatioChanged(qreal widthRatio); - void heightRatioChanged(qreal heightRatio); - -private: - QDeclarative1Flickable *flickable; - qreal m_xPosition; - qreal m_widthRatio; - qreal m_yPosition; - qreal m_heightRatio; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1FlickableVisibleArea) - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativeflipable.cpp b/src/qtquick1/graphicsitems/qdeclarativeflipable.cpp deleted file mode 100644 index c36555e1de..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeflipable.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "QtQuick1/private/qdeclarativeflipable_p.h" - -#include "QtQuick1/private/qdeclarativeitem_p.h" -#include "QtDeclarative/private/qdeclarativeguard_p.h" - -#include <QtDeclarative/qdeclarativeinfo.h> - -#include <QtWidgets/qgraphicstransform.h> - -QT_BEGIN_NAMESPACE - - - -class QDeclarative1FlipablePrivate : public QDeclarativeItemPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1Flipable) -public: - QDeclarative1FlipablePrivate() : current(QDeclarative1Flipable::Front), front(0), back(0) {} - - void updateSceneTransformFromParent(); - void setBackTransform(); - - QDeclarative1Flipable::Side current; - QDeclarativeGuard<QGraphicsObject> front; - QDeclarativeGuard<QGraphicsObject> back; - - bool wantBackXFlipped; - bool wantBackYFlipped; -}; - -/*! - \qmlclass Flipable QDeclarative1Flipable - \inqmlmodule QtQuick 1 - \since QtQuick 1.0 - \ingroup qml-basic-interaction-elements - \brief The Flipable item provides a surface that can be flipped. - \inherits Item - - Flipable is an item that can be visibly "flipped" between its front and - back sides, like a card. It is used together with \l Rotation, \l State - and \l Transition elements to produce a flipping effect. - - The \l front and \l back properties are used to hold the items that are - shown respectively on the front and back sides of the flipable item. - - \section1 Example Usage - - The following example shows a Flipable item that flips whenever it is - clicked, rotating about the y-axis. - - This flipable item has a \c flipped boolean property that is toggled - whenever the MouseArea within the flipable is clicked. When - \c flipped is true, the item changes to the "back" state; in this - state, the \c angle of the \l Rotation item is changed to 180 - degrees to produce the flipping effect. When \c flipped is false, the - item reverts to the default state, in which the \c angle value is 0. - - \snippet doc/src/snippets/qtquick1/flipable/flipable.qml 0 - - \image flipable.gif - - The \l Transition creates the animation that changes the angle over - four seconds. When the item changes between its "back" and - default states, the NumberAnimation animates the angle between - its old and new values. - - See \l {QML States} for details on state changes and the default - state, and \l {QML Animation and Transitions} for more information on how - animations work within transitions. - - \sa {declarative/ui-components/flipable}{Flipable example} -*/ - -QDeclarative1Flipable::QDeclarative1Flipable(QDeclarativeItem *parent) -: QDeclarativeItem(*(new QDeclarative1FlipablePrivate), parent) -{ -} - -QDeclarative1Flipable::~QDeclarative1Flipable() -{ -} - -/*! - \qmlproperty Item QtQuick1::Flipable::front - \qmlproperty Item QtQuick1::Flipable::back - - The front and back sides of the flipable. -*/ - -QGraphicsObject *QDeclarative1Flipable::front() -{ - Q_D(const QDeclarative1Flipable); - return d->front; -} - -void QDeclarative1Flipable::setFront(QGraphicsObject *front) -{ - Q_D(QDeclarative1Flipable); - if (d->front) { - qmlInfo(this) << tr("front is a write-once property"); - return; - } - d->front = front; - d->front->setParentItem(this); - if (Back == d->current) - d->front->setOpacity(0.); - emit frontChanged(); -} - -QGraphicsObject *QDeclarative1Flipable::back() -{ - Q_D(const QDeclarative1Flipable); - return d->back; -} - -void QDeclarative1Flipable::setBack(QGraphicsObject *back) -{ - Q_D(QDeclarative1Flipable); - if (d->back) { - qmlInfo(this) << tr("back is a write-once property"); - return; - } - d->back = back; - d->back->setParentItem(this); - if (Front == d->current) - d->back->setOpacity(0.); - connect(back, SIGNAL(widthChanged()), - this, SLOT(retransformBack())); - connect(back, SIGNAL(heightChanged()), - this, SLOT(retransformBack())); - emit backChanged(); -} - -void QDeclarative1Flipable::retransformBack() -{ - Q_D(QDeclarative1Flipable); - if (d->current == QDeclarative1Flipable::Back && d->back) - d->setBackTransform(); -} - -/*! - \qmlproperty enumeration QtQuick1::Flipable::side - - The side of the Flipable currently visible. Possible values are \c - Flipable.Front and \c Flipable.Back. -*/ -QDeclarative1Flipable::Side QDeclarative1Flipable::side() const -{ - Q_D(const QDeclarative1Flipable); - if (d->dirtySceneTransform) - const_cast<QDeclarative1FlipablePrivate *>(d)->ensureSceneTransform(); - - return d->current; -} - -// determination on the currently visible side of the flipable -// has to be done on the complete scene transform to give -// correct results. -void QDeclarative1FlipablePrivate::updateSceneTransformFromParent() -{ - Q_Q(QDeclarative1Flipable); - - QDeclarativeItemPrivate::updateSceneTransformFromParent(); - QPointF p1(0, 0); - QPointF p2(1, 0); - QPointF p3(1, 1); - - QPointF scenep1 = sceneTransform.map(p1); - QPointF scenep2 = sceneTransform.map(p2); - QPointF scenep3 = sceneTransform.map(p3); - p1 = q->mapToParent(p1); - p2 = q->mapToParent(p2); - p3 = q->mapToParent(p3); - - qreal cross = (scenep1.x() - scenep2.x()) * (scenep3.y() - scenep2.y()) - - (scenep1.y() - scenep2.y()) * (scenep3.x() - scenep2.x()); - - wantBackYFlipped = p1.x() >= p2.x(); - wantBackXFlipped = p2.y() >= p3.y(); - - QDeclarative1Flipable::Side newSide; - if (cross > 0) { - newSide = QDeclarative1Flipable::Back; - } else { - newSide = QDeclarative1Flipable::Front; - } - - if (newSide != current) { - current = newSide; - if (current == QDeclarative1Flipable::Back && back) - setBackTransform(); - if (front) - front->setOpacity((current==QDeclarative1Flipable::Front)?1.:0.); - if (back) - back->setOpacity((current==QDeclarative1Flipable::Back)?1.:0.); - emit q->sideChanged(); - } -} - -/* Depends on the width/height of the back item, and so needs reevaulating - if those change. -*/ -void QDeclarative1FlipablePrivate::setBackTransform() -{ - QTransform mat; - QGraphicsItemPrivate *dBack = QGraphicsItemPrivate::get(back); - mat.translate(dBack->width()/2,dBack->height()/2); - if (dBack->width() && wantBackYFlipped) - mat.rotate(180, Qt::YAxis); - if (dBack->height() && wantBackXFlipped) - mat.rotate(180, Qt::XAxis); - mat.translate(-dBack->width()/2,-dBack->height()/2); - back->setTransform(mat); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativeflipable_p.h b/src/qtquick1/graphicsitems/qdeclarativeflipable_p.h deleted file mode 100644 index 3d9f69be84..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeflipable_p.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEFLIPABLE_H -#define QDECLARATIVEFLIPABLE_H - -#include "qdeclarativeitem.h" - -#include <QtCore/QObject> -#include <QtGui/QTransform> -#include <QtGui/qvector3d.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1FlipablePrivate; -class Q_AUTOTEST_EXPORT QDeclarative1Flipable : public QDeclarativeItem -{ - Q_OBJECT - - Q_ENUMS(Side) - Q_PROPERTY(QGraphicsObject *front READ front WRITE setFront NOTIFY frontChanged) - Q_PROPERTY(QGraphicsObject *back READ back WRITE setBack NOTIFY backChanged) - Q_PROPERTY(Side side READ side NOTIFY sideChanged) - //### flipAxis - //### flipRotation -public: - QDeclarative1Flipable(QDeclarativeItem *parent=0); - ~QDeclarative1Flipable(); - - QGraphicsObject *front(); - void setFront(QGraphicsObject *); - - QGraphicsObject *back(); - void setBack(QGraphicsObject *); - - enum Side { Front, Back }; - Side side() const; - -Q_SIGNALS: - void frontChanged(); - void backChanged(); - void sideChanged(); - -private Q_SLOTS: - void retransformBack(); - -private: - Q_DISABLE_COPY(QDeclarative1Flipable) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Flipable) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Flipable) - -QT_END_HEADER - -#endif // QDECLARATIVEFLIPABLE_H diff --git a/src/qtquick1/graphicsitems/qdeclarativefocuspanel.cpp b/src/qtquick1/graphicsitems/qdeclarativefocuspanel.cpp deleted file mode 100644 index 940f7c6f09..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativefocuspanel.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "QtQuick1/private/qdeclarativefocuspanel_p.h" - -#include "QtQuick1/private/qdeclarativeitem_p.h" - -#include <QtWidgets/qgraphicsscene.h> -#include <QEvent> - -QT_BEGIN_NAMESPACE - - - -/*! - \qmlclass FocusPanel QDeclarative1FocusPanel - \inqmlmodule QtQuick 1 - \since QtQuick 1.0 - \ingroup qml-basic-interaction-elements - - \brief The FocusPanel item explicitly creates a focus panel. - \inherits Item - - Focus panels assist in keyboard focus handling when building QML - applications. All the details are covered in the - \l {qmlfocus}{keyboard focus documentation}. -*/ - -QDeclarative1FocusPanel::QDeclarative1FocusPanel(QDeclarativeItem *parent) : - QDeclarativeItem(parent) -{ - Q_D(QDeclarativeItem); - d->flags |= QGraphicsItem::ItemIsPanel; -} - -QDeclarative1FocusPanel::~QDeclarative1FocusPanel() -{ -} - -/*! - \qmlproperty bool QtQuick1::FocusPanel::active - - Sets whether the item is the active focus panel. -*/ - -bool QDeclarative1FocusPanel::sceneEvent(QEvent *event) -{ - if (event->type() == QEvent::WindowActivate || - event->type() == QEvent::WindowDeactivate) - emit activeChanged(); - return QDeclarativeItem::sceneEvent(event); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativefocuspanel_p.h b/src/qtquick1/graphicsitems/qdeclarativefocuspanel_p.h deleted file mode 100644 index 75a7f43173..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativefocuspanel_p.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEFOCUSPANEL_H -#define QDECLARATIVEFOCUSPANEL_H - -#include "qdeclarativeitem.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class Q_AUTOTEST_EXPORT QDeclarative1FocusPanel : public QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) -public: - QDeclarative1FocusPanel(QDeclarativeItem *parent=0); - virtual ~QDeclarative1FocusPanel(); - -Q_SIGNALS: - void activeChanged(); - -protected: - bool sceneEvent(QEvent *event); - -private: - Q_DISABLE_COPY(QDeclarative1FocusPanel) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeItem) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1FocusPanel) - -QT_END_HEADER - -#endif // QDECLARATIVEFOCUSPANEL_H diff --git a/src/qtquick1/graphicsitems/qdeclarativefocusscope.cpp b/src/qtquick1/graphicsitems/qdeclarativefocusscope.cpp deleted file mode 100644 index 97eee708d6..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativefocusscope.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "QtQuick1/private/qdeclarativefocusscope_p.h" - -#include "QtQuick1/private/qdeclarativeitem_p.h" - -QT_BEGIN_NAMESPACE - - - -/*! - \qmlclass FocusScope QDeclarative1FocusScope - \inqmlmodule QtQuick 1 - \since QtQuick 1.0 - \ingroup qml-basic-interaction-elements - - \brief The FocusScope object explicitly creates a focus scope. - \inherits Item - - Focus scopes assist in keyboard focus handling when building reusable QML - components. All the details are covered in the - \l {qmlfocus}{keyboard focus documentation}. - - \sa {declarative/keyinteraction/focus}{Keyboard focus example} -*/ - -QDeclarative1FocusScope::QDeclarative1FocusScope(QDeclarativeItem *parent) : - QDeclarativeItem(parent) -{ - Q_D(QDeclarativeItem); - d->flags |= QGraphicsItem::ItemIsFocusScope; -} - -QDeclarative1FocusScope::~QDeclarative1FocusScope() -{ -} - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativefocusscope_p.h b/src/qtquick1/graphicsitems/qdeclarativefocusscope_p.h deleted file mode 100644 index b61aed4b36..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativefocusscope_p.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEFOCUSSCOPE_H -#define QDECLARATIVEFOCUSSCOPE_H - -#include "qdeclarativeitem.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -//### set component root as focusscope -class Q_AUTOTEST_EXPORT QDeclarative1FocusScope : public QDeclarativeItem -{ - Q_OBJECT - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeItem) -public: - QDeclarative1FocusScope(QDeclarativeItem *parent=0); - virtual ~QDeclarative1FocusScope(); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1FocusScope) - -QT_END_HEADER - -#endif // QDECLARATIVEFOCUSSCOPE_H diff --git a/src/qtquick1/graphicsitems/qdeclarativegraphicswidget.cpp b/src/qtquick1/graphicsitems/qdeclarativegraphicswidget.cpp deleted file mode 100644 index c6a3c4f08b..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativegraphicswidget.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "QtQuick1/private/qdeclarativegraphicswidget_p.h" -#include "QtQuick1/private/qdeclarativeanchors_p.h" -#include "QtQuick1/private/qdeclarativeitem_p.h" -#include "QtQuick1/private/qdeclarativeanchors_p_p.h" - -QT_BEGIN_NAMESPACE - - - -class QDeclarative1GraphicsWidgetPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QDeclarative1GraphicsWidget) -public : - QDeclarative1GraphicsWidgetPrivate() : - _anchors(0), _anchorLines(0) - {} - QDeclarativeItemPrivate::AnchorLines *anchorLines() const; - QDeclarative1Anchors *_anchors; - mutable QDeclarativeItemPrivate::AnchorLines *_anchorLines; -}; - -QDeclarative1GraphicsWidget::QDeclarative1GraphicsWidget(QObject *parent) : - QObject(*new QDeclarative1GraphicsWidgetPrivate, parent) -{ -} -QDeclarative1GraphicsWidget::~QDeclarative1GraphicsWidget() -{ - Q_D(QDeclarative1GraphicsWidget); - delete d->_anchorLines; d->_anchorLines = 0; - delete d->_anchors; d->_anchors = 0; -} - -QDeclarative1Anchors *QDeclarative1GraphicsWidget::anchors() -{ - Q_D(QDeclarative1GraphicsWidget); - if (!d->_anchors) - d->_anchors = new QDeclarative1Anchors(static_cast<QGraphicsObject *>(parent())); - return d->_anchors; -} - -QDeclarativeItemPrivate::AnchorLines *QDeclarative1GraphicsWidgetPrivate::anchorLines() const -{ - Q_Q(const QDeclarative1GraphicsWidget); - if (!_anchorLines) - _anchorLines = new QDeclarativeItemPrivate::AnchorLines(static_cast<QGraphicsObject *>(q->parent())); - return _anchorLines; -} - -QDeclarative1AnchorLine QDeclarative1GraphicsWidget::left() const -{ - Q_D(const QDeclarative1GraphicsWidget); - return d->anchorLines()->left; -} - -QDeclarative1AnchorLine QDeclarative1GraphicsWidget::right() const -{ - Q_D(const QDeclarative1GraphicsWidget); - return d->anchorLines()->right; -} - -QDeclarative1AnchorLine QDeclarative1GraphicsWidget::horizontalCenter() const -{ - Q_D(const QDeclarative1GraphicsWidget); - return d->anchorLines()->hCenter; -} - -QDeclarative1AnchorLine QDeclarative1GraphicsWidget::top() const -{ - Q_D(const QDeclarative1GraphicsWidget); - return d->anchorLines()->top; -} - -QDeclarative1AnchorLine QDeclarative1GraphicsWidget::bottom() const -{ - Q_D(const QDeclarative1GraphicsWidget); - return d->anchorLines()->bottom; -} - -QDeclarative1AnchorLine QDeclarative1GraphicsWidget::verticalCenter() const -{ - Q_D(const QDeclarative1GraphicsWidget); - return d->anchorLines()->vCenter; -} - - - -QT_END_NAMESPACE - -#include <moc_qdeclarativegraphicswidget_p.cpp> diff --git a/src/qtquick1/graphicsitems/qdeclarativegraphicswidget_p.h b/src/qtquick1/graphicsitems/qdeclarativegraphicswidget_p.h deleted file mode 100644 index da1c629d9d..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativegraphicswidget_p.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEGRAPHICSWIDGET_P_H -#define QDECLARATIVEGRAPHICSWIDGET_P_H - -#include <QObject> -#include <QtDeclarative/qdeclarativecomponent.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QGraphicsObject; -class QDeclarative1AnchorLine; -class QDeclarative1Anchors; -class QDeclarative1GraphicsWidgetPrivate; - -// ### TODO can the extension object be the anchor directly? We save one allocation -> awesome. -class QDeclarative1GraphicsWidget : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDeclarative1Anchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL) - Q_PROPERTY(QDeclarative1AnchorLine left READ left CONSTANT FINAL) - Q_PROPERTY(QDeclarative1AnchorLine right READ right CONSTANT FINAL) - Q_PROPERTY(QDeclarative1AnchorLine horizontalCenter READ horizontalCenter CONSTANT FINAL) - Q_PROPERTY(QDeclarative1AnchorLine top READ top CONSTANT FINAL) - Q_PROPERTY(QDeclarative1AnchorLine bottom READ bottom CONSTANT FINAL) - Q_PROPERTY(QDeclarative1AnchorLine verticalCenter READ verticalCenter CONSTANT FINAL) - // ### TODO : QGraphicsWidget don't have a baseline concept yet. - //Q_PROPERTY(QDeclarative1AnchorLine baseline READ baseline CONSTANT FINAL) -public: - QDeclarative1GraphicsWidget(QObject *parent = 0); - ~QDeclarative1GraphicsWidget(); - QDeclarative1Anchors *anchors(); - QDeclarative1AnchorLine left() const; - QDeclarative1AnchorLine right() const; - QDeclarative1AnchorLine horizontalCenter() const; - QDeclarative1AnchorLine top() const; - QDeclarative1AnchorLine bottom() const; - QDeclarative1AnchorLine verticalCenter() const; - Q_DISABLE_COPY(QDeclarative1GraphicsWidget) - Q_DECLARE_PRIVATE(QDeclarative1GraphicsWidget) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEGRAPHICSWIDGET_P_H diff --git a/src/qtquick1/graphicsitems/qdeclarativegridview.cpp b/src/qtquick1/graphicsitems/qdeclarativegridview.cpp deleted file mode 100644 index dd002e5b6c..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativegridview.cpp +++ /dev/null @@ -1,3174 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "QtQuick1/private/qdeclarativegridview_p.h" - -#include "QtQuick1/private/qdeclarativevisualitemmodel_p.h" -#include "QtQuick1/private/qdeclarativeflickable_p_p.h" - -#include "QtQuick1/private/qdeclarativesmoothedanimation_p_p.h" -#include <QtDeclarative/private/qdeclarativeguard_p.h> - -#include <QKeyEvent> - -#include <qmath.h> -#include <math.h> -#include "qplatformdefs.h" - -QT_BEGIN_NAMESPACE - -#ifndef QML_FLICK_SNAPONETHRESHOLD -#define QML_FLICK_SNAPONETHRESHOLD 30 -#endif - -//---------------------------------------------------------------------------- - -class FxGridItem1 -{ -public: - FxGridItem1(QDeclarativeItem *i, QDeclarative1GridView *v) : item(i), view(v) { - attached = static_cast<QDeclarative1GridViewAttached*>(qmlAttachedPropertiesObject<QDeclarative1GridView>(item)); - if (attached) - attached->setView(view); - } - ~FxGridItem1() {} - - qreal rowPos() const { - qreal rowPos = 0; - if (view->flow() == QDeclarative1GridView::LeftToRight) { - rowPos = item->y(); - } else { - if (view->effectiveLayoutDirection() == Qt::RightToLeft) - rowPos = -view->cellWidth()-item->x(); - else - rowPos = item->x(); - } - return rowPos; - } - qreal colPos() const { - qreal colPos = 0; - if (view->flow() == QDeclarative1GridView::LeftToRight) { - if (view->effectiveLayoutDirection() == Qt::RightToLeft) { - int colSize = view->cellWidth(); - int columns = view->width()/colSize; - colPos = colSize * (columns-1) - item->x(); - } else { - colPos = item->x(); - } - } else { - colPos = item->y(); - } - - return colPos; - } - - qreal endRowPos() const { - if (view->flow() == QDeclarative1GridView::LeftToRight) { - return item->y() + view->cellHeight() - 1; - } else { - if (view->effectiveLayoutDirection() == Qt::RightToLeft) - return -item->x() - 1; - else - return item->x() + view->cellWidth() - 1; - } - } - void setPosition(qreal col, qreal row) { - if (view->effectiveLayoutDirection() == Qt::RightToLeft) { - if (view->flow() == QDeclarative1GridView::LeftToRight) { - int columns = view->width()/view->cellWidth(); - item->setPos(QPointF((view->cellWidth() * (columns-1) - col), row)); - } else { - item->setPos(QPointF(-view->cellWidth()-row, col)); - } - } else { - if (view->flow() == QDeclarative1GridView::LeftToRight) - item->setPos(QPointF(col, row)); - else - item->setPos(QPointF(row, col)); - } - - } - bool contains(qreal x, qreal y) const { - return (x >= item->x() && x < item->x() + view->cellWidth() && - y >= item->y() && y < item->y() + view->cellHeight()); - } - - QDeclarativeItem *item; - QDeclarative1GridView *view; - QDeclarative1GridViewAttached *attached; - int index; -}; - -//---------------------------------------------------------------------------- - -class QDeclarative1GridViewPrivate : public QDeclarative1FlickablePrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1GridView) - -public: - QDeclarative1GridViewPrivate() - : currentItem(0), layoutDirection(Qt::LeftToRight), flow(QDeclarative1GridView::LeftToRight) - , visibleIndex(0) , currentIndex(-1) - , cellWidth(100), cellHeight(100), columns(1), requestedIndex(-1), itemCount(0) - , highlightRangeStart(0), highlightRangeEnd(0) - , highlightRangeStartValid(false), highlightRangeEndValid(false) - , highlightRange(QDeclarative1GridView::NoHighlightRange) - , highlightComponent(0), highlight(0), trackedItem(0) - , moveReason(Other), buffer(0), highlightXAnimator(0), highlightYAnimator(0) - , highlightMoveDuration(150) - , footerComponent(0), footer(0), headerComponent(0), header(0) - , bufferMode(BufferBefore | BufferAfter), snapMode(QDeclarative1GridView::NoSnap) - , ownModel(false), wrap(false), autoHighlight(true) - , fixCurrentVisibility(false), lazyRelease(false), layoutScheduled(false) - , deferredRelease(false), haveHighlightRange(false), currentIndexCleared(false) {} - - void init(); - void clear(); - FxGridItem1 *createItem(int modelIndex); - void releaseItem(FxGridItem1 *item); - void refill(qreal from, qreal to, bool doBuffer=false); - - void updateGrid(); - void scheduleLayout(); - void layout(); - void updateUnrequestedIndexes(); - void updateUnrequestedPositions(); - void updateTrackedItem(); - void createHighlight(); - void updateHighlight(); - void updateCurrent(int modelIndex); - void updateHeader(); - void updateFooter(); - void fixupPosition(); - - FxGridItem1 *visibleItem(int modelIndex) const { - if (modelIndex >= visibleIndex && modelIndex < visibleIndex + visibleItems.count()) { - for (int i = modelIndex - visibleIndex; i < visibleItems.count(); ++i) { - FxGridItem1 *item = visibleItems.at(i); - if (item->index == modelIndex) - return item; - } - } - return 0; - } - - bool isRightToLeftTopToBottom() const { - Q_Q(const QDeclarative1GridView); - return flow == QDeclarative1GridView::TopToBottom && q->effectiveLayoutDirection() == Qt::RightToLeft; - } - - void regenerate() { - Q_Q(QDeclarative1GridView); - if (q->isComponentComplete()) { - clear(); - updateGrid(); - setPosition(0); - q->refill(); - updateCurrent(currentIndex); - } - } - - void mirrorChange() { - Q_Q(QDeclarative1GridView); - regenerate(); - emit q->effectiveLayoutDirectionChanged(); - } - - qreal position() const { - Q_Q(const QDeclarative1GridView); - return flow == QDeclarative1GridView::LeftToRight ? q->contentY() : q->contentX(); - } - void setPosition(qreal pos) { - Q_Q(QDeclarative1GridView); - if (flow == QDeclarative1GridView::LeftToRight) { - q->QDeclarative1Flickable::setContentY(pos); - q->QDeclarative1Flickable::setContentX(0); - } else { - if (q->effectiveLayoutDirection() == Qt::LeftToRight) - q->QDeclarative1Flickable::setContentX(pos); - else - q->QDeclarative1Flickable::setContentX(-pos-size()); - q->QDeclarative1Flickable::setContentY(0); - } - } - int size() const { - Q_Q(const QDeclarative1GridView); - return flow == QDeclarative1GridView::LeftToRight ? q->height() : q->width(); - } - qreal originPosition() const { - qreal pos = 0; - if (!visibleItems.isEmpty()) - pos = visibleItems.first()->rowPos() - visibleIndex / columns * rowSize(); - return pos; - } - - qreal lastPosition() const { - qreal pos = 0; - if (model && model->count()) - pos = rowPosAt(model->count() - 1) + rowSize(); - return pos; - } - - qreal startPosition() const { - return isRightToLeftTopToBottom() ? -lastPosition()+1 : originPosition(); - } - - qreal endPosition() const { - return isRightToLeftTopToBottom() ? -originPosition()+1 : lastPosition(); - - } - - bool isValid() const { - return model && model->count() && model->isValid(); - } - - int rowSize() const { - return flow == QDeclarative1GridView::LeftToRight ? cellHeight : cellWidth; - } - int colSize() const { - return flow == QDeclarative1GridView::LeftToRight ? cellWidth : cellHeight; - } - - qreal colPosAt(int modelIndex) const { - if (FxGridItem1 *item = visibleItem(modelIndex)) - return item->colPos(); - if (!visibleItems.isEmpty()) { - if (modelIndex < visibleIndex) { - int count = (visibleIndex - modelIndex) % columns; - int col = visibleItems.first()->colPos() / colSize(); - col = (columns - count + col) % columns; - return col * colSize(); - } else { - int count = columns - 1 - (modelIndex - visibleItems.last()->index - 1) % columns; - return visibleItems.last()->colPos() - count * colSize(); - } - } else { - return (modelIndex % columns) * colSize(); - } - return 0; - } - qreal rowPosAt(int modelIndex) const { - if (FxGridItem1 *item = visibleItem(modelIndex)) - return item->rowPos(); - if (!visibleItems.isEmpty()) { - if (modelIndex < visibleIndex) { - int firstCol = visibleItems.first()->colPos() / colSize(); - int col = visibleIndex - modelIndex + (columns - firstCol - 1); - int rows = col / columns; - return visibleItems.first()->rowPos() - rows * rowSize(); - } else { - int count = modelIndex - visibleItems.last()->index; - int col = visibleItems.last()->colPos() + count * colSize(); - int rows = col / (columns * colSize()); - return visibleItems.last()->rowPos() + rows * rowSize(); - } - } else { - qreal pos = (modelIndex / columns) * rowSize(); - if (header) - pos += headerSize(); - return pos; - } - return 0; - } - - FxGridItem1 *firstVisibleItem() const { - const qreal pos = isRightToLeftTopToBottom() ? -position()-size() : position(); - for (int i = 0; i < visibleItems.count(); ++i) { - FxGridItem1 *item = visibleItems.at(i); - if (item->index != -1 && item->endRowPos() > pos) - return item; - } - return visibleItems.count() ? visibleItems.first() : 0; - } - - int lastVisibleIndex() const { - for (int i = 0; i < visibleItems.count(); ++i) { - FxGridItem1 *item = visibleItems.at(i); - if (item->index != -1) - return item->index; - } - return -1; - } - - // Map a model index to visibleItems list index. - // These may differ if removed items are still present in the visible list, - // e.g. doing a removal animation - int mapFromModel(int modelIndex) const { - if (modelIndex < visibleIndex || modelIndex >= visibleIndex + visibleItems.count()) - return -1; - for (int i = 0; i < visibleItems.count(); ++i) { - FxGridItem1 *listItem = visibleItems.at(i); - if (listItem->index == modelIndex) - return i + visibleIndex; - if (listItem->index > modelIndex) - return -1; - } - return -1; // Not in visibleList - } - - qreal snapPosAt(qreal pos) const { - Q_Q(const QDeclarative1GridView); - 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()) { - maxExtent = q->minXExtent(); - minExtent = q->maxXExtent(); - } else { - maxExtent = flow == QDeclarative1GridView::LeftToRight ? -q->maxYExtent() : -q->maxXExtent(); - minExtent = flow == QDeclarative1GridView::LeftToRight ? -q->minYExtent() : -q->minXExtent(); - } - if (snapPos > maxExtent) - snapPos = maxExtent; - if (snapPos < minExtent) - snapPos = minExtent; - } - return snapPos; - } - - FxGridItem1 *snapItemAt(qreal pos) { - for (int i = 0; i < visibleItems.count(); ++i) { - FxGridItem1 *item = visibleItems[i]; - if (item->index == -1) - continue; - qreal itemTop = item->rowPos(); - if (itemTop+rowSize()/2 >= pos && itemTop - rowSize()/2 <= pos) - return item; - } - return 0; - } - - int snapIndex() { - int index = currentIndex; - for (int i = 0; i < visibleItems.count(); ++i) { - FxGridItem1 *item = visibleItems[i]; - if (item->index == -1) - continue; - qreal itemTop = item->rowPos(); - if (itemTop >= highlight->rowPos()-rowSize()/2 && itemTop < highlight->rowPos()+rowSize()/2) { - index = item->index; - if (item->colPos() >= highlight->colPos()-colSize()/2 && item->colPos() < highlight->colPos()+colSize()/2) - return item->index; - } - } - return index; - } - - qreal headerSize() const { - if (!header) - return 0.0; - - return flow == QDeclarative1GridView::LeftToRight - ? header->item->height() - : header->item->width(); - } - - - virtual void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) { - Q_Q(const QDeclarative1GridView); - QDeclarative1FlickablePrivate::itemGeometryChanged(item, newGeometry, oldGeometry); - if (item == q) { - if (newGeometry.height() != oldGeometry.height() - || newGeometry.width() != oldGeometry.width()) { - if (q->isComponentComplete()) { - updateGrid(); - scheduleLayout(); - } - } - } else if ((header && header->item == item) || (footer && footer->item == item)) { - if (header) - updateHeader(); - if (footer) - updateFooter(); - } - } - - void positionViewAtIndex(int index, int mode); - virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent); - virtual void flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, - QDeclarative1TimeLineCallback::Callback fixupCallback, qreal velocity); - - // for debugging only - void checkVisible() const { - int skip = 0; - for (int i = 0; i < visibleItems.count(); ++i) { - FxGridItem1 *listItem = visibleItems.at(i); - if (listItem->index == -1) { - ++skip; - } else if (listItem->index != visibleIndex + i - skip) { - for (int j = 0; j < visibleItems.count(); j++) - qDebug() << " index" << j << "item index" << visibleItems.at(j)->index; - qFatal("index %d %d %d", visibleIndex, i, listItem->index); - } - } - } - - QDeclarativeGuard<QDeclarative1VisualModel> model; - QVariant modelVariant; - QList<FxGridItem1*> visibleItems; - QHash<QDeclarativeItem*,int> unrequestedItems; - FxGridItem1 *currentItem; - Qt::LayoutDirection layoutDirection; - QDeclarative1GridView::Flow flow; - int visibleIndex; - int currentIndex; - int cellWidth; - int cellHeight; - int columns; - int requestedIndex; - int itemCount; - qreal highlightRangeStart; - qreal highlightRangeEnd; - bool highlightRangeStartValid; - bool highlightRangeEndValid; - QDeclarative1GridView::HighlightRangeMode highlightRange; - QDeclarativeComponent *highlightComponent; - FxGridItem1 *highlight; - FxGridItem1 *trackedItem; - enum MovementReason { Other, SetIndex, Mouse }; - MovementReason moveReason; - int buffer; - QSmoothedAnimation_1 *highlightXAnimator; - QSmoothedAnimation_1 *highlightYAnimator; - int highlightMoveDuration; - QDeclarativeComponent *footerComponent; - FxGridItem1 *footer; - QDeclarativeComponent *headerComponent; - FxGridItem1 *header; - enum BufferMode { NoBuffer = 0x00, BufferBefore = 0x01, BufferAfter = 0x02 }; - int bufferMode; - QDeclarative1GridView::SnapMode snapMode; - - bool ownModel : 1; - bool wrap : 1; - bool autoHighlight : 1; - bool fixCurrentVisibility : 1; - bool lazyRelease : 1; - bool layoutScheduled : 1; - bool deferredRelease : 1; - bool haveHighlightRange : 1; - bool currentIndexCleared : 1; -}; - -void QDeclarative1GridViewPrivate::init() -{ - Q_Q(QDeclarative1GridView); - QObject::connect(q, SIGNAL(movementEnded()), q, SLOT(animStopped())); - q->setFlag(QGraphicsItem::ItemIsFocusScope); - q->setFlickableDirection(QDeclarative1Flickable::VerticalFlick); - addItemChangeListener(this, Geometry); -} - -void QDeclarative1GridViewPrivate::clear() -{ - for (int i = 0; i < visibleItems.count(); ++i) - releaseItem(visibleItems.at(i)); - visibleItems.clear(); - visibleIndex = 0; - releaseItem(currentItem); - currentItem = 0; - createHighlight(); - trackedItem = 0; - itemCount = 0; -} - -FxGridItem1 *QDeclarative1GridViewPrivate::createItem(int modelIndex) -{ - Q_Q(QDeclarative1GridView); - // create object - requestedIndex = modelIndex; - FxGridItem1 *listItem = 0; - if (QDeclarativeItem *item = model->item(modelIndex, false)) { - listItem = new FxGridItem1(item, q); - listItem->index = modelIndex; - if (model->completePending()) { - // complete - listItem->item->setZValue(1); - listItem->item->setParentItem(q->contentItem()); - model->completeItem(); - } else { - listItem->item->setParentItem(q->contentItem()); - } - unrequestedItems.remove(listItem->item); - } - requestedIndex = -1; - return listItem; -} - - -void QDeclarative1GridViewPrivate::releaseItem(FxGridItem1 *item) -{ - Q_Q(QDeclarative1GridView); - if (!item || !model) - return; - if (trackedItem == item) { - QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged())); - QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged())); - trackedItem = 0; - } - if (model->release(item->item) == 0) { - // item was not destroyed, and we no longer reference it. - unrequestedItems.insert(item->item, model->indexOf(item->item, q)); - } - delete item; -} - -void QDeclarative1GridViewPrivate::refill(qreal from, qreal to, bool doBuffer) -{ - Q_Q(QDeclarative1GridView); - if (!isValid() || !q->isComponentComplete()) - return; - itemCount = model->count(); - qreal bufferFrom = from - buffer; - qreal bufferTo = to + buffer; - qreal fillFrom = from; - qreal fillTo = to; - if (doBuffer && (bufferMode & BufferAfter)) - fillTo = bufferTo; - if (doBuffer && (bufferMode & BufferBefore)) - fillFrom = bufferFrom; - - bool changed = false; - - int colPos = colPosAt(visibleIndex); - int rowPos = rowPosAt(visibleIndex); - int modelIndex = visibleIndex; - if (visibleItems.count()) { - rowPos = visibleItems.last()->rowPos(); - colPos = visibleItems.last()->colPos() + colSize(); - if (colPos > colSize() * (columns-1)) { - colPos = 0; - rowPos += rowSize(); - } - int i = visibleItems.count() - 1; - while (i > 0 && visibleItems.at(i)->index == -1) - --i; - modelIndex = visibleItems.at(i)->index + 1; - } - - if (visibleItems.count() && (fillFrom > rowPos + rowSize()*2 - || fillTo < rowPosAt(visibleIndex) - rowSize())) { - // We've jumped more than a page. Estimate which items are now - // visible and fill from there. - int count = (fillFrom - (rowPos + rowSize())) / (rowSize()) * columns; - for (int i = 0; i < visibleItems.count(); ++i) - releaseItem(visibleItems.at(i)); - visibleItems.clear(); - modelIndex += count; - if (modelIndex >= model->count()) - modelIndex = model->count() - 1; - else if (modelIndex < 0) - modelIndex = 0; - modelIndex = modelIndex / columns * columns; - visibleIndex = modelIndex; - colPos = colPosAt(visibleIndex); - rowPos = rowPosAt(visibleIndex); - } - - int colNum = colPos / colSize(); - - FxGridItem1 *item = 0; - - // Item creation and release is staggered in order to avoid - // creating/releasing multiple items in one frame - // while flicking (as much as possible). - while (modelIndex < model->count() && rowPos <= fillTo + rowSize()*(columns - colNum)/(columns+1)) { -// qDebug() << "refill: append item" << modelIndex; - if (!(item = createItem(modelIndex))) - break; - item->setPosition(colPos, rowPos); - visibleItems.append(item); - colPos += colSize(); - colNum++; - if (colPos > colSize() * (columns-1)) { - colPos = 0; - colNum = 0; - rowPos += rowSize(); - } - ++modelIndex; - changed = true; - if (doBuffer) // never buffer more than one item per frame - break; - } - - if (visibleItems.count()) { - rowPos = visibleItems.first()->rowPos(); - colPos = visibleItems.first()->colPos() - colSize(); - if (colPos < 0) { - colPos = colSize() * (columns - 1); - rowPos -= rowSize(); - } - } - colNum = colPos / colSize(); - while (visibleIndex > 0 && rowPos + rowSize() - 1 >= fillFrom - rowSize()*(colNum+1)/(columns+1)){ -// qDebug() << "refill: prepend item" << visibleIndex-1 << "top pos" << rowPos << colPos; - if (!(item = createItem(visibleIndex-1))) - break; - --visibleIndex; - item->setPosition(colPos, rowPos); - visibleItems.prepend(item); - colPos -= colSize(); - colNum--; - if (colPos < 0) { - colPos = colSize() * (columns - 1); - colNum = columns-1; - rowPos -= rowSize(); - } - changed = true; - if (doBuffer) // never buffer more than one item per frame - break; - } - - if (!lazyRelease || !changed || deferredRelease) { // avoid destroying items in the same frame that we create - while (visibleItems.count() > 1 - && (item = visibleItems.first()) - && item->rowPos()+rowSize()-1 < bufferFrom - rowSize()*(item->colPos()/colSize()+1)/(columns+1)) { - if (item->attached->delayRemove()) - break; -// qDebug() << "refill: remove first" << visibleIndex << "top end pos" << item->endRowPos(); - if (item->index != -1) - visibleIndex++; - visibleItems.removeFirst(); - releaseItem(item); - changed = true; - } - while (visibleItems.count() > 1 - && (item = visibleItems.last()) - && item->rowPos() > bufferTo + rowSize()*(columns - item->colPos()/colSize())/(columns+1)) { - if (item->attached->delayRemove()) - break; -// qDebug() << "refill: remove last" << visibleIndex+visibleItems.count()-1; - visibleItems.removeLast(); - releaseItem(item); - changed = true; - } - deferredRelease = false; - } else { - deferredRelease = true; - } - if (changed) { - if (header) - updateHeader(); - if (footer) - updateFooter(); - if (flow == QDeclarative1GridView::LeftToRight) - q->setContentHeight(endPosition() - startPosition()); - else - q->setContentWidth(endPosition() - startPosition()); - } else if (!doBuffer && buffer && bufferMode != NoBuffer) { - refill(from, to, true); - } - lazyRelease = false; -} - -void QDeclarative1GridViewPrivate::updateGrid() -{ - Q_Q(QDeclarative1GridView); - - columns = (int)qMax((flow == QDeclarative1GridView::LeftToRight ? q->width() : q->height()) / colSize(), qreal(1.)); - if (isValid()) { - if (flow == QDeclarative1GridView::LeftToRight) - q->setContentHeight(endPosition() - startPosition()); - else - q->setContentWidth(lastPosition() - originPosition()); - } -} - -void QDeclarative1GridViewPrivate::scheduleLayout() -{ - Q_Q(QDeclarative1GridView); - if (!layoutScheduled) { - layoutScheduled = true; - QCoreApplication::postEvent(q, new QEvent(QEvent::User), Qt::HighEventPriority); - } -} - -void QDeclarative1GridViewPrivate::layout() -{ - Q_Q(QDeclarative1GridView); - layoutScheduled = false; - if (!isValid() && !visibleItems.count()) { - clear(); - return; - } - if (visibleItems.count()) { - qreal rowPos = visibleItems.first()->rowPos(); - qreal colPos = visibleItems.first()->colPos(); - int col = visibleIndex % columns; - if (colPos != col * colSize()) { - colPos = col * colSize(); - visibleItems.first()->setPosition(colPos, rowPos); - } - for (int i = 1; i < visibleItems.count(); ++i) { - FxGridItem1 *item = visibleItems.at(i); - colPos += colSize(); - if (colPos > colSize() * (columns-1)) { - colPos = 0; - rowPos += rowSize(); - } - item->setPosition(colPos, rowPos); - } - } - if (header) - updateHeader(); - if (footer) - updateFooter(); - q->refill(); - updateHighlight(); - moveReason = Other; - if (flow == QDeclarative1GridView::LeftToRight) { - q->setContentHeight(endPosition() - startPosition()); - fixupY(); - } else { - q->setContentWidth(endPosition() - startPosition()); - fixupX(); - } - updateUnrequestedPositions(); -} - -void QDeclarative1GridViewPrivate::updateUnrequestedIndexes() -{ - Q_Q(QDeclarative1GridView); - QHash<QDeclarativeItem*,int>::iterator it; - for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) - *it = model->indexOf(it.key(), q); -} - -void QDeclarative1GridViewPrivate::updateUnrequestedPositions() -{ - QHash<QDeclarativeItem*,int>::const_iterator it; - for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) { - QDeclarativeItem *item = it.key(); - if (flow == QDeclarative1GridView::LeftToRight) { - item->setPos(QPointF(colPosAt(*it), rowPosAt(*it))); - } else { - if (isRightToLeftTopToBottom()) - item->setPos(QPointF(-rowPosAt(*it)-item->width(), colPosAt(*it))); - else - item->setPos(QPointF(rowPosAt(*it), colPosAt(*it))); - } - } -} - -void QDeclarative1GridViewPrivate::updateTrackedItem() -{ - Q_Q(QDeclarative1GridView); - FxGridItem1 *item = currentItem; - if (highlight) - item = highlight; - - if (trackedItem && item != trackedItem) { - QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged())); - QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged())); - trackedItem = 0; - } - - if (!trackedItem && item) { - trackedItem = item; - QObject::connect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged())); - QObject::connect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged())); - } - if (trackedItem) - q->trackedPositionChanged(); -} - -void QDeclarative1GridViewPrivate::createHighlight() -{ - Q_Q(QDeclarative1GridView); - bool changed = false; - if (highlight) { - if (trackedItem == highlight) - trackedItem = 0; - if (highlight->item->scene()) - highlight->item->scene()->removeItem(highlight->item); - highlight->item->deleteLater(); - delete highlight; - highlight = 0; - delete highlightXAnimator; - delete highlightYAnimator; - highlightXAnimator = 0; - highlightYAnimator = 0; - changed = true; - } - - if (currentItem) { - QDeclarativeItem *item = 0; - if (highlightComponent) { - QDeclarativeContext *highlightContext = new QDeclarativeContext(qmlContext(q)); - QObject *nobj = highlightComponent->create(highlightContext); - if (nobj) { - QDeclarative_setParent_noEvent(highlightContext, nobj); - item = qobject_cast<QDeclarativeItem *>(nobj); - if (!item) - delete nobj; - } else { - delete highlightContext; - } - } else { - item = new QDeclarativeItem; - QDeclarative_setParent_noEvent(item, q->contentItem()); - item->setParentItem(q->contentItem()); - } - if (item) { - QDeclarative_setParent_noEvent(item, q->contentItem()); - item->setParentItem(q->contentItem()); - highlight = new FxGridItem1(item, q); - if (currentItem && autoHighlight) - highlight->setPosition(currentItem->colPos(), currentItem->rowPos()); - highlightXAnimator = new QSmoothedAnimation_1(q); - highlightXAnimator->target = QDeclarativeProperty(highlight->item, QLatin1String("x")); - highlightXAnimator->userDuration = highlightMoveDuration; - highlightYAnimator = new QSmoothedAnimation_1(q); - highlightYAnimator->target = QDeclarativeProperty(highlight->item, QLatin1String("y")); - highlightYAnimator->userDuration = highlightMoveDuration; - if (autoHighlight) { - highlightXAnimator->restart(); - highlightYAnimator->restart(); - } - changed = true; - } - } - if (changed) - emit q->highlightItemChanged(); -} - -void QDeclarative1GridViewPrivate::updateHighlight() -{ - if ((!currentItem && highlight) || (currentItem && !highlight)) - createHighlight(); - if (currentItem && autoHighlight && highlight && !hData.moving && !vData.moving) { - // auto-update highlight - highlightXAnimator->to = currentItem->item->x(); - highlightYAnimator->to = currentItem->item->y(); - highlight->item->setWidth(currentItem->item->width()); - highlight->item->setHeight(currentItem->item->height()); - highlightXAnimator->restart(); - highlightYAnimator->restart(); - } - updateTrackedItem(); -} - -void QDeclarative1GridViewPrivate::updateCurrent(int modelIndex) -{ - Q_Q(QDeclarative1GridView); - if (!q->isComponentComplete() || !isValid() || modelIndex < 0 || modelIndex >= model->count()) { - if (currentItem) { - currentItem->attached->setIsCurrentItem(false); - releaseItem(currentItem); - currentItem = 0; - currentIndex = modelIndex; - emit q->currentIndexChanged(); - updateHighlight(); - } else if (currentIndex != modelIndex) { - currentIndex = modelIndex; - emit q->currentIndexChanged(); - } - return; - } - - if (currentItem && currentIndex == modelIndex) { - updateHighlight(); - return; - } - - FxGridItem1 *oldCurrentItem = currentItem; - currentIndex = modelIndex; - currentItem = createItem(modelIndex); - fixCurrentVisibility = true; - if (oldCurrentItem && (!currentItem || oldCurrentItem->item != currentItem->item)) - oldCurrentItem->attached->setIsCurrentItem(false); - if (currentItem) { - currentItem->setPosition(colPosAt(modelIndex), rowPosAt(modelIndex)); - currentItem->item->setFocus(true); - currentItem->attached->setIsCurrentItem(true); - } - updateHighlight(); - emit q->currentIndexChanged(); - releaseItem(oldCurrentItem); -} - -void QDeclarative1GridViewPrivate::updateFooter() -{ - Q_Q(QDeclarative1GridView); - if (!footer && footerComponent) { - QDeclarativeItem *item = 0; - QDeclarativeContext *context = new QDeclarativeContext(qmlContext(q)); - QObject *nobj = footerComponent->create(context); - if (nobj) { - QDeclarative_setParent_noEvent(context, nobj); - item = qobject_cast<QDeclarativeItem *>(nobj); - if (!item) - delete nobj; - } else { - delete context; - } - if (item) { - QDeclarative_setParent_noEvent(item, q->contentItem()); - item->setParentItem(q->contentItem()); - item->setZValue(1); - QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item)); - itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - footer = new FxGridItem1(item, q); - } - } - if (footer) { - qreal colOffset = 0; - qreal rowOffset; - if (isRightToLeftTopToBottom()) { - rowOffset = footer->item->width()-cellWidth; - } else { - rowOffset = 0; - if (q->effectiveLayoutDirection() == Qt::RightToLeft) - colOffset = footer->item->width()-cellWidth; - } - if (visibleItems.count()) { - qreal endPos = lastPosition(); - if (lastVisibleIndex() == model->count()-1) { - footer->setPosition(colOffset, endPos + rowOffset); - } else { - qreal visiblePos = isRightToLeftTopToBottom() ? -position() : position() + size(); - if (endPos <= visiblePos || footer->endRowPos() < endPos + rowOffset) - footer->setPosition(colOffset, endPos + rowOffset); - } - } else { - qreal endPos = 0; - if (header) { - endPos += flow == QDeclarative1GridView::LeftToRight ? header->item->height() : header->item->width(); - } - footer->setPosition(colOffset, endPos); - } - } -} - -void QDeclarative1GridViewPrivate::updateHeader() -{ - Q_Q(QDeclarative1GridView); - if (!header && headerComponent) { - QDeclarativeItem *item = 0; - QDeclarativeContext *context = new QDeclarativeContext(qmlContext(q)); - QObject *nobj = headerComponent->create(context); - if (nobj) { - QDeclarative_setParent_noEvent(context, nobj); - item = qobject_cast<QDeclarativeItem *>(nobj); - if (!item) - delete nobj; - } else { - delete context; - } - if (item) { - QDeclarative_setParent_noEvent(item, q->contentItem()); - item->setParentItem(q->contentItem()); - item->setZValue(1); - QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item)); - itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - header = new FxGridItem1(item, q); - } - } - if (header) { - qreal colOffset = 0; - qreal rowOffset; - if (isRightToLeftTopToBottom()) { - rowOffset = -cellWidth; - } else { - rowOffset = -headerSize(); - if (q->effectiveLayoutDirection() == Qt::RightToLeft) - colOffset = header->item->width()-cellWidth; - } - if (visibleItems.count()) { - qreal startPos = originPosition(); - if (visibleIndex == 0) { - header->setPosition(colOffset, startPos + rowOffset); - } else { - qreal tempPos = isRightToLeftTopToBottom() ? -position()-size() : position(); - qreal headerPos = isRightToLeftTopToBottom() ? header->rowPos() + cellWidth - headerSize() : header->rowPos(); - if (tempPos <= startPos || headerPos > startPos + rowOffset) - header->setPosition(colOffset, startPos + rowOffset); - } - } else { - header->setPosition(colOffset, 0); - } - } -} - -void QDeclarative1GridViewPrivate::fixupPosition() -{ - moveReason = Other; - if (flow == QDeclarative1GridView::LeftToRight) - fixupY(); - else - fixupX(); -} - -void QDeclarative1GridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent) -{ - if ((flow == QDeclarative1GridView::TopToBottom && &data == &vData) - || (flow == QDeclarative1GridView::LeftToRight && &data == &hData)) - return; - - fixupMode = moveReason == Mouse ? fixupMode : Immediate; - - qreal highlightStart; - qreal highlightEnd; - qreal viewPos; - if (isRightToLeftTopToBottom()) { - // Handle Right-To-Left exceptions - viewPos = -position()-size(); - highlightStart = highlightRangeStartValid ? size()-highlightRangeEnd : highlightRangeStart; - highlightEnd = highlightRangeEndValid ? size()-highlightRangeStart : highlightRangeEnd; - } else { - viewPos = position(); - highlightStart = highlightRangeStart; - highlightEnd = highlightRangeEnd; - } - - bool strictHighlightRange = haveHighlightRange && highlightRange == QDeclarative1GridView::StrictlyEnforceRange; - - if (snapMode != QDeclarative1GridView::NoSnap) { - qreal tempPosition = isRightToLeftTopToBottom() ? -position()-size() : position(); - if (snapMode == QDeclarative1GridView::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; - } - FxGridItem1 *topItem = snapItemAt(tempPosition+highlightStart); - if (!topItem && strictHighlightRange && currentItem) { - // StrictlyEnforceRange always keeps an item in range - updateHighlight(); - topItem = currentItem; - } - FxGridItem1 *bottomItem = snapItemAt(tempPosition+highlightEnd); - if (!bottomItem && strictHighlightRange && currentItem) { - // StrictlyEnforceRange always keeps an item in range - updateHighlight(); - bottomItem = currentItem; - } - qreal pos; - bool isInBounds = -position() > maxExtent && -position() <= minExtent; - if (topItem && (isInBounds || strictHighlightRange)) { - if (topItem->index == 0 && header && tempPosition+highlightStart < header->rowPos()+headerSize()/2 && !strictHighlightRange) { - pos = isRightToLeftTopToBottom() ? - header->rowPos() + highlightStart - size() : header->rowPos() - highlightStart; - } else { - if (isRightToLeftTopToBottom()) - pos = qMax(qMin(-topItem->rowPos() + highlightStart - size(), -maxExtent), -minExtent); - else - pos = qMax(qMin(topItem->rowPos() - highlightStart, -maxExtent), -minExtent); - } - } else if (bottomItem && isInBounds) { - if (isRightToLeftTopToBottom()) - pos = qMax(qMin(-bottomItem->rowPos() + highlightEnd - size(), -maxExtent), -minExtent); - else - pos = qMax(qMin(bottomItem->rowPos() - highlightEnd, -maxExtent), -minExtent); - } else { - QDeclarative1FlickablePrivate::fixup(data, minExtent, maxExtent); - return; - } - qreal dist = qAbs(data.move + pos); - if (dist > 0) { - timeline.reset(data.move); - if (fixupMode != Immediate) { - timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); - data.fixingUp = true; - } else { - timeline.set(data.move, -pos); - } - vTime = timeline.time(); - } - } else if (haveHighlightRange && highlightRange == QDeclarative1GridView::StrictlyEnforceRange) { - if (currentItem) { - updateHighlight(); - qreal pos = currentItem->rowPos(); - if (viewPos < pos + rowSize() - highlightEnd) - viewPos = pos + rowSize() - highlightEnd; - if (viewPos > pos - highlightStart) - viewPos = pos - highlightStart; - if (isRightToLeftTopToBottom()) - 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 { - QDeclarative1FlickablePrivate::fixup(data, minExtent, maxExtent); - } - data.inOvershoot = false; - fixupMode = Normal; -} - -void QDeclarative1GridViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, - QDeclarative1TimeLineCallback::Callback fixupCallback, qreal velocity) -{ - Q_Q(QDeclarative1GridView); - data.fixingUp = false; - moveReason = Mouse; - if ((!haveHighlightRange || highlightRange != QDeclarative1GridView::StrictlyEnforceRange) - && snapMode == QDeclarative1GridView::NoSnap) { - QDeclarative1FlickablePrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity); - return; - } - qreal maxDistance = 0; - qreal dataValue = isRightToLeftTopToBottom() ? -data.move.value()+size() : data.move.value(); - // -ve velocity means list is moving up/left - if (velocity > 0) { - if (data.move.value() < minExtent) { - if (snapMode == QDeclarative1GridView::SnapOneRow) { - // 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()); - } - } - if (snapMode == QDeclarative1GridView::NoSnap && highlightRange != QDeclarative1GridView::StrictlyEnforceRange) - data.flickTarget = minExtent; - } else { - if (data.move.value() > maxExtent) { - if (snapMode == QDeclarative1GridView::SnapOneRow) { - // 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()); - } - } - if (snapMode == QDeclarative1GridView::NoSnap && highlightRange != QDeclarative1GridView::StrictlyEnforceRange) - data.flickTarget = maxExtent; - } - - bool overShoot = boundsBehavior == QDeclarative1Flickable::DragAndOvershootBounds; - - if (maxDistance > 0 || overShoot) { - // This mode requires the grid to stop exactly on a row boundary. - qreal v = velocity; - if (maxVelocity != -1 && |