summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-02-19 19:32:53 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-02-19 19:32:53 (GMT)
commit01498eb9a44f3b15e517e81b309087fbbf1b93bf (patch)
tree24451e4bb7ccf184229499205ed5f832b0f453a9 /src
parentdc0ce606eb848730c1d5047eaad4ec061ffe2dde (diff)
parent6c3acdf906a678158928b76cf047b58fbb9f8969 (diff)
downloadQt-01498eb9a44f3b15e517e81b309087fbbf1b93bf.zip
Qt-01498eb9a44f3b15e517e81b309087fbbf1b93bf.tar.gz
Qt-01498eb9a44f3b15e517e81b309087fbbf1b93bf.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-qml: (81 commits) Revert "Speed up QmlGraphicsItem::setParentItem." Fix dynamic example More strict type checking of ListElement properties. Fix tst_QmlGraphicsLoader::networkRequestUrl autotest. Fix tst_qmlgraphicstextedit::delegateLoading autotest Delete the QmlImageRequestHandler in the correct thread. Fix "AnimatedImage ignores Anchors setting" Remove unused function that breaks build on AIX. doc Add support for startDragDistance in qmlviewer. Add pixmap benchmarks and make cached rounded rect the same as Rectangle. Make QmlDom API internal Compile fix with namepaces Doc: reformulate why we build a button Removed incorrect Q_UNUSED() macro from QmlPropertyAnimation::transition Doc: onExited, onEntered only work when button pressed or hoverEnabled Ensure visibleIndex and currentIndex are updated on itemsMoved(). QmlView API review. See QmlChanges.txt for details. Fix example after introduction of RotationAnimation. Animation doc fix. ...
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/webkit/WebCore/accessibility/qt/AccessibilityObjectQt.cpp4
-rw-r--r--src/corelib/global/qglobal.h3
-rw-r--r--src/corelib/global/qmalloc.cpp1
-rw-r--r--src/declarative/QmlChanges.txt26
-rw-r--r--src/declarative/debugger/qmldebug.cpp7
-rw-r--r--src/declarative/debugger/qmldebug_p.h5
-rw-r--r--src/declarative/debugger/qmldebugservice.cpp33
-rw-r--r--src/declarative/debugger/qmldebugservice_p.h4
-rw-r--r--src/declarative/graphicsitems/graphicsitems.pri3
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanchors.cpp2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h6
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsborderimage.cpp2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicseffects.cpp13
-rw-r--r--src/declarative/graphicsitems/qmlgraphicseffects_p.h65
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsevents.cpp3
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable.cpp45
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable_p.h12
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h32
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsflipable.cpp4
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp3
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgridview.cpp88
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgridview_p.h58
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsimage.cpp2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem.cpp226
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem.h8
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem_p.h201
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp166
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitemsmodule_p.h63
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp9
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview.cpp125
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview_p.h67
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsloader.cpp3
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsloader_p.h4
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp37
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsmouseregion_p.h22
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsparticles.cpp12
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspath.cpp8
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspathview.cpp3
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspositioners.cpp12
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsrectangle.cpp4
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsrepeater.cpp11
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsrepeater_p.h7
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsscalegrid.cpp1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstext.cpp1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextedit.cpp1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextinput.cpp12
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextinput_p.h2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp46
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h39
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview.cpp31
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview_p.h26
-rw-r--r--src/declarative/qml/qml.h4
-rw-r--r--src/declarative/qml/qml.pri4
-rw-r--r--src/declarative/qml/qmlbinding.cpp6
-rw-r--r--src/declarative/qml/qmlbinding.h3
-rw-r--r--src/declarative/qml/qmlcleanup.cpp4
-rw-r--r--src/declarative/qml/qmlcompiledbindings.cpp302
-rw-r--r--src/declarative/qml/qmlcomponent.cpp1
-rw-r--r--src/declarative/qml/qmlcompositetypedata_p.h2
-rw-r--r--src/declarative/qml/qmlcontext.cpp4
-rw-r--r--src/declarative/qml/qmldom.cpp2
-rw-r--r--src/declarative/qml/qmldom.h349
-rw-r--r--src/declarative/qml/qmldom_p.h319
-rw-r--r--src/declarative/qml/qmldom_p_p.h157
-rw-r--r--src/declarative/qml/qmlengine.cpp97
-rw-r--r--src/declarative/qml/qmlengine.h5
-rw-r--r--src/declarative/qml/qmlengine_p.h8
-rw-r--r--src/declarative/qml/qmlguard_p.h4
-rw-r--r--src/declarative/qml/qmlimageprovider.cpp68
-rw-r--r--src/declarative/qml/qmlimageprovider.h64
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp13
-rw-r--r--src/declarative/qml/qmlmetatype.cpp3
-rw-r--r--src/declarative/qml/qmlpropertycache.cpp4
-rw-r--r--src/declarative/qml/qmlscriptstring.h4
-rw-r--r--src/declarative/qml/qmlsqldatabase.cpp3
-rw-r--r--src/declarative/qml/qmlsqldatabase_p.h7
-rw-r--r--src/declarative/qml/qmlstringconverters_p.h4
-rw-r--r--src/declarative/qml/qmlworkerscript.cpp10
-rw-r--r--src/declarative/qml/qmlxmlhttprequest.cpp8
-rw-r--r--src/declarative/qml/qmlxmlhttprequest_p.h7
-rw-r--r--src/declarative/util/qmlanimation.cpp929
-rw-r--r--src/declarative/util/qmlanimation_p.h56
-rw-r--r--src/declarative/util/qmlanimation_p_p.h50
-rw-r--r--src/declarative/util/qmlbehavior.cpp8
-rw-r--r--src/declarative/util/qmllistmodel.cpp42
-rw-r--r--src/declarative/util/qmlpixmapcache.cpp51
-rw-r--r--src/declarative/util/qmlstategroup.cpp4
-rw-r--r--src/declarative/util/qmlstateoperations.cpp2
-rw-r--r--src/declarative/util/qmlstyledtext.cpp4
-rw-r--r--src/declarative/util/qmlstyledtext_p.h5
-rw-r--r--src/declarative/util/qmltimeline_p_p.h8
-rw-r--r--src/declarative/util/qmltransition.cpp9
-rw-r--r--src/declarative/util/qmlview.cpp393
-rw-r--r--src/declarative/util/qmlview.h49
-rw-r--r--src/declarative/util/qmlxmllistmodel.cpp4
-rw-r--r--src/gui/kernel/qapplication.cpp6
-rw-r--r--src/gui/util/qdesktopservices_s60.cpp4
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp4
-rw-r--r--src/plugins/imageformats/ico/qicohandler.cpp4
-rw-r--r--src/plugins/imageformats/ico/qicohandler.h4
103 files changed, 2760 insertions, 1915 deletions
diff --git a/src/3rdparty/webkit/WebCore/accessibility/qt/AccessibilityObjectQt.cpp b/src/3rdparty/webkit/WebCore/accessibility/qt/AccessibilityObjectQt.cpp
index 07f13d4..756ece3 100644
--- a/src/3rdparty/webkit/WebCore/accessibility/qt/AccessibilityObjectQt.cpp
+++ b/src/3rdparty/webkit/WebCore/accessibility/qt/AccessibilityObjectQt.cpp
@@ -20,6 +20,8 @@
#include "config.h"
#include "AccessibilityObject.h"
+QT_BEGIN_NAMESPACE
+
#if HAVE(ACCESSIBILITY)
namespace WebCore {
@@ -37,3 +39,5 @@ AccessibilityObjectPlatformInclusion AccessibilityObject::accessibilityPlatformI
} // namespace WebCore
#endif // HAVE(ACCESSIBILITY)
+
+QT_END_NAMESPACE
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 99bbe42..7e7d7d8 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -864,6 +864,9 @@ typedef quint64 qulonglong;
# endif
#endif
+#define Q_INIT_RESOURCE_EXTERN(name) \
+ extern int QT_MANGLE_NAMESPACE(qInitResources_ ## name) ();
+
#define Q_INIT_RESOURCE(name) \
do { extern int QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); \
QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); } while (0)
diff --git a/src/corelib/global/qmalloc.cpp b/src/corelib/global/qmalloc.cpp
index 43e89e3..090998c 100644
--- a/src/corelib/global/qmalloc.cpp
+++ b/src/corelib/global/qmalloc.cpp
@@ -124,3 +124,4 @@ void qFreeAligned(void *ptr)
}
QT_END_NAMESPACE
+
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index e54ec95..e3aab65 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -1,6 +1,30 @@
+=============================================================================
+The changes below are pre Qt 4.7.0 alpha
+
+QmlView
+-------
+The API of QmlView has been narrowed and its role as a convenience class
+reinforced.
+- remove addItem()
+- remove clearItems() - use 'delete root()'
+- remove reset()
+- resizeContent -> enum ResizeMode { SizeViewToRootObject, SizeRootObjectToView }
+- remove setQml(), qml()
+- rename setUrl(), ur() to setSource(), source()
+- root() -> rootObject(), returns QGraphicsObject rather than QmlGraphicsItem
+- remove quit() signal -> use quit() signal of engine()
+- initialSize() signal removed
+- Added status() to determine status of the internal QmlComponent
+sectionExpression has been replaced by section.property, section.criteria
-Listview: sectionExpression has been replaced by section.property, section.criteria
+ListModel
+---------
+- types are strictly checked (previously, everything was a string)
+ - foo: "bar" continues to work as before
+ - foo: bar is now invalid, use foo: "bar"
+ - foo: true is now a bool (not string "true")
+ - foo: false is now a bool (not string "false" == true!)
=============================================================================
diff --git a/src/declarative/debugger/qmldebug.cpp b/src/declarative/debugger/qmldebug.cpp
index 5e93d50..32d8bbb 100644
--- a/src/declarative/debugger/qmldebug.cpp
+++ b/src/declarative/debugger/qmldebug.cpp
@@ -47,6 +47,8 @@
#include <private/qobject_p.h>
+QT_BEGIN_NAMESPACE
+
class QmlEngineDebugClient : public QmlDebugClient
{
public:
@@ -142,8 +144,6 @@ void QmlEngineDebugPrivate::remove(QmlEngineDebug *c, QmlDebugExpressionQuery *q
}
}
-
-Q_DECLARE_METATYPE(QmlDebugObjectReference);
void QmlEngineDebugPrivate::decode(QDataStream &ds, QmlDebugObjectReference &o,
bool simple)
{
@@ -932,3 +932,6 @@ bool QmlDebugPropertyReference::hasNotifySignal() const
{
return m_hasNotifySignal;
}
+
+QT_END_NAMESPACE
+
diff --git a/src/declarative/debugger/qmldebug_p.h b/src/declarative/debugger/qmldebug_p.h
index 4e9d065..a1371d5 100644
--- a/src/declarative/debugger/qmldebug_p.h
+++ b/src/declarative/debugger/qmldebug_p.h
@@ -361,6 +361,11 @@ private:
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QmlDebugEngineReference)
+Q_DECLARE_METATYPE(QmlDebugObjectReference)
+Q_DECLARE_METATYPE(QmlDebugContextReference)
+Q_DECLARE_METATYPE(QmlDebugPropertyReference)
+
QT_END_HEADER
#endif // QMLDEBUG_H
diff --git a/src/declarative/debugger/qmldebugservice.cpp b/src/declarative/debugger/qmldebugservice.cpp
index 7f28c0c..7b21869 100644
--- a/src/declarative/debugger/qmldebugservice.cpp
+++ b/src/declarative/debugger/qmldebugservice.cpp
@@ -61,9 +61,11 @@ class QmlDebugServer : public QObject
public:
static QmlDebugServer *instance();
void wait();
+ void registerForStartNotification(QObject *object, const char *receiver);
private Q_SLOTS:
void readyRead();
+ void registeredObjectDestroyed(QObject *object);
private:
friend class QmlDebugService;
@@ -83,6 +85,7 @@ public:
QPacketProtocol *protocol;
QHash<QString, QmlDebugService *> plugins;
QStringList enabledPlugins;
+ QList<QPair<QObject*, QByteArray> > notifyClients;
};
class QmlDebugServicePrivate : public QObjectPrivate
@@ -112,6 +115,14 @@ void QmlDebugServerPrivate::wait()
qWarning("QmlDebugServer: Waiting for connection on port %d...", port);
+ for (int i=0; i<notifyClients.count(); i++) {
+ if (!QMetaObject::invokeMethod(notifyClients[i].first, notifyClients[i].second)) {
+ qWarning() << "QmlDebugServer: unable to call method" << notifyClients[i].second
+ << "on object" << notifyClients[i].first << "to notify of debug server start";
+ }
+ }
+ notifyClients.clear();
+
if (!server.waitForNewConnection(-1)) {
qWarning("QmlDebugServer: Connection error");
return;
@@ -165,6 +176,23 @@ void QmlDebugServer::wait()
d->wait();
}
+void QmlDebugServer::registerForStartNotification(QObject *object, const char *methodName)
+{
+ Q_D(QmlDebugServer);
+ connect(object, SIGNAL(destroyed(QObject*)), SLOT(registeredObjectDestroyed(QObject*)));
+ d->notifyClients.append(qMakePair(object, QByteArray(methodName)));
+}
+
+void QmlDebugServer::registeredObjectDestroyed(QObject *object)
+{
+ Q_D(QmlDebugServer);
+ QMutableListIterator<QPair<QObject*, QByteArray> > i(d->notifyClients);
+ while (i.hasNext()) {
+ if (i.next().first == object)
+ i.remove();
+ }
+}
+
QmlDebugServer::QmlDebugServer(int port)
: QObject(*(new QmlDebugServerPrivate))
{
@@ -367,6 +395,11 @@ void QmlDebugService::waitForClients()
QmlDebugServer::instance()->wait();
}
+void QmlDebugService::notifyOnServerStart(QObject *object, const char *receiver)
+{
+ QmlDebugServer::instance()->registerForStartNotification(object, receiver);
+}
+
void QmlDebugService::sendMessage(const QByteArray &message)
{
Q_D(QmlDebugService);
diff --git a/src/declarative/debugger/qmldebugservice_p.h b/src/declarative/debugger/qmldebugservice_p.h
index 55ecf1d..33ddda0 100644
--- a/src/declarative/debugger/qmldebugservice_p.h
+++ b/src/declarative/debugger/qmldebugservice_p.h
@@ -68,17 +68,19 @@ public:
static int idForObject(QObject *);
static QObject *objectForId(int);
-
static bool isDebuggingEnabled();
static QString objectToString(QObject *obj);
static void waitForClients();
+ static void notifyOnServerStart(QObject *object, const char *receiver);
+
protected:
virtual void enabledChanged(bool);
virtual void messageReceived(const QByteArray &);
private:
+ void registerForStartNotification(QObject *object, const char *methodName);
friend class QmlDebugServer;
};
diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/declarative/graphicsitems/graphicsitems.pri
index eb6e0ad..db9c29e 100644
--- a/src/declarative/graphicsitems/graphicsitems.pri
+++ b/src/declarative/graphicsitems/graphicsitems.pri
@@ -1,9 +1,11 @@
INCLUDEPATH += $$PWD
HEADERS += \
+ $$PWD/qmlgraphicsitemsmodule_p.h \
$$PWD/qmlgraphicsanchors_p.h \
$$PWD/qmlgraphicsanchors_p_p.h \
$$PWD/qmlgraphicsevents_p_p.h \
+ $$PWD/qmlgraphicseffects_p.h \
$$PWD/qmlgraphicsflickable_p.h \
$$PWD/qmlgraphicsflickable_p_p.h \
$$PWD/qmlgraphicsflipable_p.h \
@@ -52,6 +54,7 @@ HEADERS += \
$$PWD/qmlgraphicseffects.cpp
SOURCES += \
+ $$PWD/qmlgraphicsitemsmodule.cpp \
$$PWD/qmlgraphicsanchors.cpp \
$$PWD/qmlgraphicsevents.cpp \
$$PWD/qmlgraphicsflickable.cpp \
diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
index 3a6ec48..cde9ec7 100644
--- a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
@@ -50,8 +50,6 @@
QT_BEGIN_NAMESPACE
-QML_DEFINE_NOCREATE_TYPE(QmlGraphicsAnchors)
-
//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)
diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h b/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h
index 12197f0..a2e41d3 100644
--- a/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h
@@ -87,9 +87,6 @@ public:
return item == other.item && anchorLine == other.anchorLine;
}
};
-Q_DECLARE_METATYPE(QmlGraphicsAnchorLine)
-
-
class QmlGraphicsAnchorsPrivate : public QObjectPrivate, public QmlGraphicsItemChangeListener
{
@@ -171,4 +168,7 @@ public:
};
QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QmlGraphicsAnchorLine)
+
#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp b/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp
index eb60495..697be15 100644
--- a/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp
@@ -78,7 +78,6 @@ Item {
\endqml
\endtable
*/
-QML_DEFINE_TYPE(Qt,4,6,AnimatedImage,QmlGraphicsAnimatedImage)
QmlGraphicsAnimatedImage::QmlGraphicsAnimatedImage(QmlGraphicsItem *parent)
: QmlGraphicsImage(*(new QmlGraphicsAnimatedImagePrivate), parent)
@@ -296,6 +295,7 @@ void QmlGraphicsAnimatedImage::playingStatusChanged()
void QmlGraphicsAnimatedImage::componentComplete()
{
Q_D(QmlGraphicsAnimatedImage);
+ QmlGraphicsImage::componentComplete();
if (!d->reply) {
setCurrentFrame(d->preset_currentframe);
d->preset_currentframe = 0;
diff --git a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
index 493b148..f739464 100644
--- a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
@@ -50,8 +50,6 @@
QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(Qt,4,6,BorderImage,QmlGraphicsBorderImage)
-
/*!
\qmlclass BorderImage QmlGraphicsBorderImage
\brief The BorderImage element provides an image that can be used as a border.
diff --git a/src/declarative/graphicsitems/qmlgraphicseffects.cpp b/src/declarative/graphicsitems/qmlgraphicseffects.cpp
index 0160971..6a93b12 100644
--- a/src/declarative/graphicsitems/qmlgraphicseffects.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicseffects.cpp
@@ -43,12 +43,6 @@
#include <QtGui/qgraphicseffect.h>
-QML_DECLARE_TYPE(QGraphicsEffect)
-QML_DEFINE_NOCREATE_TYPE(QGraphicsEffect)
-
-QML_DECLARE_TYPE(QGraphicsBlurEffect)
-QML_DEFINE_TYPE(Qt,4,6,Blur,QGraphicsBlurEffect)
-
/*!
\qmlclass Blur QGraphicsBlurEffect
\brief The Blur object provides a blur effect.
@@ -84,9 +78,6 @@ QML_DEFINE_TYPE(Qt,4,6,Blur,QGraphicsBlurEffect)
The default hint is Qt.PerformanceHint.
*/
-QML_DECLARE_TYPE(QGraphicsColorizeEffect)
-QML_DEFINE_TYPE(Qt,4,6,Colorize,QGraphicsColorizeEffect)
-
/*!
\qmlclass Colorize QGraphicsColorizeEffect
\brief The Colorize object provides a colorize effect.
@@ -112,8 +103,6 @@ QML_DEFINE_TYPE(Qt,4,6,Colorize,QGraphicsColorizeEffect)
while 1.0 means full colorization. By default, the strength is 1.0.
*/
-QML_DECLARE_TYPE(QGraphicsDropShadowEffect)
-QML_DEFINE_TYPE(Qt,4,6,DropShadow,QGraphicsDropShadowEffect)
/*!
\qmlclass DropShadow QGraphicsDropShadowEffect
@@ -155,8 +144,6 @@ QML_DEFINE_TYPE(Qt,4,6,DropShadow,QGraphicsDropShadowEffect)
By default, the drop color is a semi-transparent dark gray.
*/
-QML_DECLARE_TYPE(QGraphicsOpacityEffect)
-QML_DEFINE_TYPE(Qt,4,6,Opacity,QGraphicsOpacityEffect)
/*!
\qmlclass Opacity QGraphicsOpacityEffect
diff --git a/src/declarative/graphicsitems/qmlgraphicseffects_p.h b/src/declarative/graphicsitems/qmlgraphicseffects_p.h
new file mode 100644
index 0000000..4b94a14
--- /dev/null
+++ b/src/declarative/graphicsitems/qmlgraphicseffects_p.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLGRAPHICSEFFECTS_P_H
+#define QMLGRAPHICSEFFECTS_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 <qml.h>
+#include <QtGui/qgraphicseffect.h>
+
+QML_DECLARE_TYPE(QGraphicsEffect)
+QML_DECLARE_TYPE(QGraphicsBlurEffect)
+QML_DECLARE_TYPE(QGraphicsColorizeEffect)
+QML_DECLARE_TYPE(QGraphicsDropShadowEffect)
+QML_DECLARE_TYPE(QGraphicsOpacityEffect)
+
+#endif // QMLGRAPHICSEFFECTS_P_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsevents.cpp b/src/declarative/graphicsitems/qmlgraphicsevents.cpp
index d42708c..1f63218 100644
--- a/src/declarative/graphicsitems/qmlgraphicsevents.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsevents.cpp
@@ -189,7 +189,4 @@ MouseRegion {
\endqml
*/
-QML_DEFINE_NOCREATE_TYPE(QmlGraphicsKeyEvent)
-QML_DEFINE_NOCREATE_TYPE(QmlGraphicsMouseEvent)
-
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
index 2bf11a0..6825f89 100644
--- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp
@@ -56,36 +56,6 @@ static const int FlickThreshold = 20;
// Really slow flicks can be annoying.
static const int minimumFlickVelocity = 200;
-class QmlGraphicsFlickableVisibleArea : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal xPosition READ xPosition NOTIFY pageChanged)
- Q_PROPERTY(qreal yPosition READ yPosition NOTIFY pageChanged)
- Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY pageChanged)
- Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY pageChanged)
-
-public:
- QmlGraphicsFlickableVisibleArea(QmlGraphicsFlickable *parent=0);
-
- qreal xPosition() const;
- qreal widthRatio() const;
- qreal yPosition() const;
- qreal heightRatio() const;
-
- void updateVisible();
-
-signals:
- void pageChanged();
-
-private:
- QmlGraphicsFlickable *flickable;
- qreal m_xPosition;
- qreal m_widthRatio;
- qreal m_yPosition;
- qreal m_heightRatio;
-};
-
QmlGraphicsFlickableVisibleArea::QmlGraphicsFlickableVisibleArea(QmlGraphicsFlickable *parent)
: QObject(parent), flickable(parent), m_xPosition(0.), m_widthRatio(0.)
, m_yPosition(0.), m_heightRatio(0.)
@@ -356,8 +326,6 @@ void QmlGraphicsFlickablePrivate::updateBeginningEnd()
visibleArea->updateVisible();
}
-QML_DEFINE_TYPE(Qt,4,6,Flickable,QmlGraphicsFlickable)
-
/*!
\qmlclass Flickable QmlGraphicsFlickable
\brief The Flickable item provides a surface that can be "flicked".
@@ -1038,7 +1006,10 @@ bool QmlGraphicsFlickable::overShoot() const
void QmlGraphicsFlickable::setOverShoot(bool o)
{
Q_D(QmlGraphicsFlickable);
+ if (d->overShoot == o)
+ return;
d->overShoot = o;
+ emit overShootChanged();
}
/*!
@@ -1247,6 +1218,7 @@ void QmlGraphicsFlickable::setMaximumFlickVelocity(qreal v)
if (v == d->maxVelocity)
return;
d->maxVelocity = v;
+ emit maximumFlickVelocityChanged();
}
/*!
@@ -1264,7 +1236,10 @@ qreal QmlGraphicsFlickable::flickDeceleration() const
void QmlGraphicsFlickable::setFlickDeceleration(qreal deceleration)
{
Q_D(QmlGraphicsFlickable);
+ if (deceleration == d->deceleration)
+ return;
d->deceleration = deceleration;
+ emit flickDecelerationChanged();
}
/*!
@@ -1302,6 +1277,7 @@ void QmlGraphicsFlickable::setPressDelay(int delay)
if (d->pressDelay == delay)
return;
d->pressDelay = delay;
+ emit pressDelayChanged();
}
qreal QmlGraphicsFlickable::reportedVelocitySmoothing() const
@@ -1367,8 +1343,3 @@ void QmlGraphicsFlickablePrivate::updateVelocity()
}
QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QmlGraphicsFlickableVisibleArea)
-QML_DEFINE_TYPE(Qt,4,6,VisibleArea,QmlGraphicsFlickableVisibleArea)
-
-#include <qmlgraphicsflickable.moc>
diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable_p.h b/src/declarative/graphicsitems/qmlgraphicsflickable_p.h
index 5ff8e6f..373815b 100644
--- a/src/declarative/graphicsitems/qmlgraphicsflickable_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsflickable_p.h
@@ -65,15 +65,15 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsFlickable : public QmlGraphicsItem
Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged)
Q_PROPERTY(qreal reportedVelocitySmoothing READ reportedVelocitySmoothing WRITE setReportedVelocitySmoothing NOTIFY reportedVelocitySmoothingChanged)
- Q_PROPERTY(bool overShoot READ overShoot WRITE setOverShoot)
- Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity)
- Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration)
+ Q_PROPERTY(bool overShoot READ overShoot WRITE setOverShoot NOTIFY overShootChanged)
+ 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 flicking READ isFlicking NOTIFY flickingChanged)
Q_PROPERTY(FlickDirection flickDirection READ flickDirection WRITE setFlickDirection NOTIFY flickDirectionChanged)
Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
- Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay)
+ 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)
@@ -160,6 +160,10 @@ Q_SIGNALS:
void pageChanged();
void flickDirectionChanged();
void interactiveChanged();
+ void overShootChanged();
+ void maximumFlickVelocityChanged();
+ void flickDecelerationChanged();
+ void pressDelayChanged();
protected:
virtual bool sceneEventFilter(QGraphicsItem *, QEvent *);
diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h b/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h
index 5eda22c..0c98f7b 100644
--- a/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h
@@ -159,6 +159,38 @@ public:
QML_DECLARE_LIST_PROXY(QmlGraphicsFlickablePrivate, QObject *, data)
};
+class QmlGraphicsFlickableVisibleArea : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal xPosition READ xPosition NOTIFY pageChanged)
+ Q_PROPERTY(qreal yPosition READ yPosition NOTIFY pageChanged)
+ Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY pageChanged)
+ Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY pageChanged)
+
+public:
+ QmlGraphicsFlickableVisibleArea(QmlGraphicsFlickable *parent=0);
+
+ qreal xPosition() const;
+ qreal widthRatio() const;
+ qreal yPosition() const;
+ qreal heightRatio() const;
+
+ void updateVisible();
+
+signals:
+ void pageChanged();
+
+private:
+ QmlGraphicsFlickable *flickable;
+ qreal m_xPosition;
+ qreal m_widthRatio;
+ qreal m_yPosition;
+ qreal m_heightRatio;
+};
+
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QmlGraphicsFlickableVisibleArea)
+
#endif
diff --git a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp
index a30ba6c..be512fc 100644
--- a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp
@@ -49,8 +49,6 @@
QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(Qt,4,6,Flipable,QmlGraphicsFlipable)
-
class QmlGraphicsFlipablePrivate : public QmlGraphicsItemPrivate
{
Q_DECLARE_PUBLIC(QmlGraphicsFlipable)
@@ -96,7 +94,7 @@ public:
}
transitions: Transition {
- NumberAnimation { matchProperties: "angle"; duration: 2000 }
+ NumberAnimation { properties: "angle"; duration: 2000 }
}
MouseRegion {
diff --git a/src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp b/src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp
index 093e9de..d564e86 100644
--- a/src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp
@@ -46,8 +46,6 @@
QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(Qt,4,6,FocusPanel,QmlGraphicsFocusPanel)
-
/*!
\qmlclass FocusPanel QmlGraphicsFocusPanel
\brief The FocusPanel item explicitly creates a focus panel.
diff --git a/src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp b/src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp
index 084e244..9930396 100644
--- a/src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp
@@ -42,7 +42,6 @@
#include "qmlgraphicsfocusscope_p.h"
QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(Qt,4,6,FocusScope,QmlGraphicsFocusScope)
/*!
\qmlclass FocusScope QmlGraphicsFocusScope
diff --git a/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp b/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp
index e7206f1..497d950 100644
--- a/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp
@@ -131,9 +131,6 @@ public:
\brief The QmlGraphicsGraphicsObjectContainer class allows you to add QGraphicsObjects into Fluid UI applications.
*/
-QML_DEFINE_NOCREATE_TYPE(QGraphicsObject)
-QML_DEFINE_TYPE(Qt,4,6,GraphicsObjectContainer,QmlGraphicsGraphicsObjectContainer)
-
QmlGraphicsGraphicsObjectContainer::QmlGraphicsGraphicsObjectContainer(QmlGraphicsItem *parent)
: QmlGraphicsItem(*new QmlGraphicsGraphicsObjectContainerPrivate, parent)
{
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
index 24d9769..bf370ae 100644
--- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
@@ -51,63 +51,6 @@
QT_BEGIN_NAMESPACE
-class QmlGraphicsGridViewAttached : public QObject
-{
- Q_OBJECT
-public:
- QmlGraphicsGridViewAttached(QObject *parent)
- : QObject(parent), m_isCurrent(false), m_delayRemove(false) {}
- ~QmlGraphicsGridViewAttached() {
- attachedProperties.remove(parent());
- }
-
- Q_PROPERTY(QmlGraphicsGridView *view READ view CONSTANT)
- QmlGraphicsGridView *view() { return m_view; }
-
- Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged)
- bool isCurrentItem() const { return m_isCurrent; }
- void setIsCurrentItem(bool c) {
- if (m_isCurrent != c) {
- m_isCurrent = c;
- emit currentItemChanged();
- }
- }
-
- Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged)
- bool delayRemove() const { return m_delayRemove; }
- void setDelayRemove(bool delay) {
- if (m_delayRemove != delay) {
- m_delayRemove = delay;
- emit delayRemoveChanged();
- }
- }
-
- static QmlGraphicsGridViewAttached *properties(QObject *obj) {
- QmlGraphicsGridViewAttached *rv = attachedProperties.value(obj);
- if (!rv) {
- rv = new QmlGraphicsGridViewAttached(obj);
- attachedProperties.insert(obj, rv);
- }
- return rv;
- }
-
- void emitAdd() { emit add(); }
- void emitRemove() { emit remove(); }
-
-Q_SIGNALS:
- void currentItemChanged();
- void delayRemoveChanged();
- void add();
- void remove();
-
-public:
- QmlGraphicsGridView *m_view;
- bool m_isCurrent;
- bool m_delayRemove;
-
- static QHash<QObject*, QmlGraphicsGridViewAttached*> attachedProperties;
-};
-
QHash<QObject*, QmlGraphicsGridViewAttached*> QmlGraphicsGridViewAttached::attachedProperties;
@@ -1713,9 +1656,32 @@ void QmlGraphicsGridView::itemsMoved(int from, int to, int count)
++endIndex;
}
+ // update visibleIndex
+ for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) {
+ if ((*it)->index != -1) {
+ d->visibleIndex = (*it)->index;
+ break;
+ }
+ }
+
+ // Fix current index
+ if (d->currentIndex >= 0 && d->currentItem) {
+ int oldCurrent = d->currentIndex;
+ d->currentIndex = d->model->indexOf(d->currentItem->item, this);
+ if (oldCurrent != d->currentIndex) {
+ d->currentItem->index = d->currentIndex;
+ emit currentIndexChanged();
+ }
+ }
+
// Whatever moved items remain are no longer visible items.
- while (moved.count())
- d->releaseItem(moved.take(moved.begin().key()));
+ while (moved.count()) {
+ int idx = moved.begin().key();
+ FxGridItem *item = moved.take(idx);
+ if (item->item == d->currentItem->item)
+ item->setPosition(d->colPosAt(idx), d->rowPosAt(idx));
+ d->releaseItem(item);
+ }
d->layout(removedBeforeVisible);
}
@@ -1754,8 +1720,4 @@ QmlGraphicsGridViewAttached *QmlGraphicsGridView::qmlAttachedProperties(QObject
return QmlGraphicsGridViewAttached::properties(obj);
}
-QML_DEFINE_TYPE(Qt, 4,6, GridView, QmlGraphicsGridView)
-
QT_END_NAMESPACE
-
-#include <qmlgraphicsgridview.moc>
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview_p.h b/src/declarative/graphicsitems/qmlgraphicsgridview_p.h
index 11dd3f2..bd18daf 100644
--- a/src/declarative/graphicsitems/qmlgraphicsgridview_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsgridview_p.h
@@ -154,6 +154,64 @@ private:
void refill();
};
+class QmlGraphicsGridViewAttached : public QObject
+{
+ Q_OBJECT
+public:
+ QmlGraphicsGridViewAttached(QObject *parent)
+ : QObject(parent), m_isCurrent(false), m_delayRemove(false) {}
+ ~QmlGraphicsGridViewAttached() {
+ attachedProperties.remove(parent());
+ }
+
+ Q_PROPERTY(QmlGraphicsGridView *view READ view CONSTANT)
+ QmlGraphicsGridView *view() { return m_view; }
+
+ Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged)
+ bool isCurrentItem() const { return m_isCurrent; }
+ void setIsCurrentItem(bool c) {
+ if (m_isCurrent != c) {
+ m_isCurrent = c;
+ emit currentItemChanged();
+ }
+ }
+
+ Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged)
+ bool delayRemove() const { return m_delayRemove; }
+ void setDelayRemove(bool delay) {
+ if (m_delayRemove != delay) {
+ m_delayRemove = delay;
+ emit delayRemoveChanged();
+ }
+ }
+
+ static QmlGraphicsGridViewAttached *properties(QObject *obj) {
+ QmlGraphicsGridViewAttached *rv = attachedProperties.value(obj);
+ if (!rv) {
+ rv = new QmlGraphicsGridViewAttached(obj);
+ attachedProperties.insert(obj, rv);
+ }
+ return rv;
+ }
+
+ void emitAdd() { emit add(); }
+ void emitRemove() { emit remove(); }
+
+Q_SIGNALS:
+ void currentItemChanged();
+ void delayRemoveChanged();
+ void add();
+ void remove();
+
+public:
+ QmlGraphicsGridView *m_view;
+ bool m_isCurrent;
+ bool m_delayRemove;
+
+ static QHash<QObject*, QmlGraphicsGridViewAttached*> attachedProperties;
+};
+
+
QT_END_NAMESPACE
QML_DECLARE_TYPE(QmlGraphicsGridView)
diff --git a/src/declarative/graphicsitems/qmlgraphicsimage.cpp b/src/declarative/graphicsitems/qmlgraphicsimage.cpp
index d4ad3c8..c586452 100644
--- a/src/declarative/graphicsitems/qmlgraphicsimage.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsimage.cpp
@@ -48,8 +48,6 @@
QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(Qt,4,6,Image,QmlGraphicsImage)
-
/*!
\qmlclass Image QmlGraphicsImage
\brief The Image element allows you to add bitmaps to a scene.
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
index 17362d0..22beb12 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
@@ -69,12 +69,6 @@ QT_BEGIN_NAMESPACE
#define FLT_MAX 1E+37
#endif
-QML_DEFINE_TYPE(Qt,4,6,Item,QmlGraphicsItem)
-
-QML_DEFINE_NOCREATE_TYPE(QGraphicsTransform);
-QML_DEFINE_TYPE(Qt,4,6,Scale,QGraphicsScale)
-QML_DEFINE_TYPE(Qt,4,6,Rotation,QGraphicsRotation)
-
#include "qmlgraphicseffects.cpp"
/*!
@@ -325,28 +319,6 @@ void QmlGraphicsContents::setItem(QmlGraphicsItem *item)
calcWidth();
}
-/*
- Key filters can be installed on a QmlGraphicsItem, but not removed. Currently they
- are only used by attached objects (which are only destroyed on Item
- destruction), so this isn't a problem. If in future this becomes any form
- of public API, they will have to support removal too.
-*/
-class QmlGraphicsItemKeyFilter
-{
-public:
- QmlGraphicsItemKeyFilter(QmlGraphicsItem * = 0);
- virtual ~QmlGraphicsItemKeyFilter();
-
- virtual void keyPressed(QKeyEvent *event);
- virtual void keyReleased(QKeyEvent *event);
- virtual void inputMethodEvent(QInputMethodEvent *event);
- virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
- virtual void componentComplete();
-
-private:
- QmlGraphicsItemKeyFilter *m_next;
-};
-
QmlGraphicsItemKeyFilter::QmlGraphicsItemKeyFilter(QmlGraphicsItem *item)
: m_next(0)
{
@@ -458,49 +430,6 @@ void QmlGraphicsItemKeyFilter::componentComplete()
pressed.
*/
-class QmlGraphicsKeyNavigationAttachedPrivate : public QObjectPrivate
-{
-public:
- QmlGraphicsKeyNavigationAttachedPrivate()
- : QObjectPrivate(), left(0), right(0), up(0), down(0) {}
-
- QmlGraphicsItem *left;
- QmlGraphicsItem *right;
- QmlGraphicsItem *up;
- QmlGraphicsItem *down;
-};
-
-class QmlGraphicsKeyNavigationAttached : public QObject, public QmlGraphicsItemKeyFilter
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlGraphicsKeyNavigationAttached)
-
- Q_PROPERTY(QmlGraphicsItem *left READ left WRITE setLeft NOTIFY changed)
- Q_PROPERTY(QmlGraphicsItem *right READ right WRITE setRight NOTIFY changed)
- Q_PROPERTY(QmlGraphicsItem *up READ up WRITE setUp NOTIFY changed)
- Q_PROPERTY(QmlGraphicsItem *down READ down WRITE setDown NOTIFY changed)
-public:
- QmlGraphicsKeyNavigationAttached(QObject * = 0);
-
- QmlGraphicsItem *left() const;
- void setLeft(QmlGraphicsItem *);
- QmlGraphicsItem *right() const;
- void setRight(QmlGraphicsItem *);
- QmlGraphicsItem *up() const;
- void setUp(QmlGraphicsItem *);
- QmlGraphicsItem *down() const;
- void setDown(QmlGraphicsItem *);
-
- static QmlGraphicsKeyNavigationAttached *qmlAttachedProperties(QObject *);
-
-Q_SIGNALS:
- void changed();
-
-private:
- virtual void keyPressed(QKeyEvent *event);
- virtual void keyReleased(QKeyEvent *event);
-};
-
QmlGraphicsKeyNavigationAttached::QmlGraphicsKeyNavigationAttached(QObject *parent)
: QObject(*(new QmlGraphicsKeyNavigationAttachedPrivate), parent),
QmlGraphicsItemKeyFilter(qobject_cast<QmlGraphicsItem*>(parent))
@@ -964,137 +893,6 @@ void QmlGraphicsKeyNavigationAttached::keyReleased(QKeyEvent *event)
*/
-class QmlGraphicsKeysAttachedPrivate : public QObjectPrivate
-{
-public:
- QmlGraphicsKeysAttachedPrivate()
- : QObjectPrivate(), inPress(false), inRelease(false)
- , inIM(false), enabled(true), imeItem(0), item(0)
- {}
-
- bool isConnected(const char *signalName);
-
- QGraphicsItem *finalFocusProxy(QGraphicsItem *item) const
- {
- QGraphicsItem *fp;
- while ((fp = item->focusProxy()))
- item = fp;
- return item;
- }
-
- //loop detection
- bool inPress:1;
- bool inRelease:1;
- bool inIM:1;
-
- bool enabled : 1;
-
- QGraphicsItem *imeItem;
- QList<QmlGraphicsItem *> targets;
- QmlGraphicsItem *item;
-};
-
-class QmlGraphicsKeysAttached : public QObject, public QmlGraphicsItemKeyFilter
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QmlGraphicsKeysAttached)
-
- Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
- Q_PROPERTY(QList<QmlGraphicsItem *> *forwardTo READ forwardTo)
-
-public:
- QmlGraphicsKeysAttached(QObject *parent=0);
- ~QmlGraphicsKeysAttached();
-
- bool enabled() const { Q_D(const QmlGraphicsKeysAttached); return d->enabled; }
- void setEnabled(bool enabled) {
- Q_D(QmlGraphicsKeysAttached);
- if (enabled != d->enabled) {
- d->enabled = enabled;
- emit enabledChanged();
- }
- }
-
- QList<QmlGraphicsItem *> *forwardTo() {
- Q_D(QmlGraphicsKeysAttached);
- return &d->targets;
- }
-
- virtual void componentComplete();
-
- static QmlGraphicsKeysAttached *qmlAttachedProperties(QObject *);
-
-Q_SIGNALS:
- void enabledChanged();
- void pressed(QmlGraphicsKeyEvent *event);
- void released(QmlGraphicsKeyEvent *event);
- void digit0Pressed(QmlGraphicsKeyEvent *event);
- void digit1Pressed(QmlGraphicsKeyEvent *event);
- void digit2Pressed(QmlGraphicsKeyEvent *event);
- void digit3Pressed(QmlGraphicsKeyEvent *event);
- void digit4Pressed(QmlGraphicsKeyEvent *event);
- void digit5Pressed(QmlGraphicsKeyEvent *event);
- void digit6Pressed(QmlGraphicsKeyEvent *event);
- void digit7Pressed(QmlGraphicsKeyEvent *event);
- void digit8Pressed(QmlGraphicsKeyEvent *event);
- void digit9Pressed(QmlGraphicsKeyEvent *event);
-
- void leftPressed(QmlGraphicsKeyEvent *event);
- void rightPressed(QmlGraphicsKeyEvent *event);
- void upPressed(QmlGraphicsKeyEvent *event);
- void downPressed(QmlGraphicsKeyEvent *event);
-
- void asteriskPressed(QmlGraphicsKeyEvent *event);
- void numberSignPressed(QmlGraphicsKeyEvent *event);
- void escapePressed(QmlGraphicsKeyEvent *event);
- void returnPressed(QmlGraphicsKeyEvent *event);
- void enterPressed(QmlGraphicsKeyEvent *event);
- void deletePressed(QmlGraphicsKeyEvent *event);
- void spacePressed(QmlGraphicsKeyEvent *event);
- void backPressed(QmlGraphicsKeyEvent *event);
- void cancelPressed(QmlGraphicsKeyEvent *event);
- void selectPressed(QmlGraphicsKeyEvent *event);
- void yesPressed(QmlGraphicsKeyEvent *event);
- void noPressed(QmlGraphicsKeyEvent *event);
- void context1Pressed(QmlGraphicsKeyEvent *event);
- void context2Pressed(QmlGraphicsKeyEvent *event);
- void context3Pressed(QmlGraphicsKeyEvent *event);
- void context4Pressed(QmlGraphicsKeyEvent *event);
- void callPressed(QmlGraphicsKeyEvent *event);
- void hangupPressed(QmlGraphicsKeyEvent *event);
- void flipPressed(QmlGraphicsKeyEvent *event);
- void menuPressed(QmlGraphicsKeyEvent *event);
- void volumeUpPressed(QmlGraphicsKeyEvent *event);
- void volumeDownPressed(QmlGraphicsKeyEvent *event);
-
-private:
- virtual void keyPressed(QKeyEvent *event);
- virtual void keyReleased(QKeyEvent *event);
- virtual void inputMethodEvent(QInputMethodEvent *);
- virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
-
- const QByteArray keyToSignal(int key) {
- QByteArray keySignal;
- if (key >= Qt::Key_0 && key <= Qt::Key_9) {
- keySignal = "digit0Pressed";
- keySignal[5] = '0' + (key - Qt::Key_0);
- } else {
- int i = 0;
- while (sigMap[i].key && sigMap[i].key != key)
- ++i;
- keySignal = sigMap[i].sig;
- }
- return keySignal;
- }
-
- struct SigMap {
- int key;
- const char *sig;
- };
-
- static const SigMap sigMap[];
-};
-
const QmlGraphicsKeysAttached::SigMap QmlGraphicsKeysAttached::sigMap[] = {
{ Qt::Key_Left, "leftPressed" },
{ Qt::Key_Right, "rightPressed" },
@@ -1538,12 +1336,8 @@ void QmlGraphicsItem::setParentItem(QmlGraphicsItem *parent)
QmlGraphicsItem *oldParent = parentItem();
if (parent == oldParent || !parent) return;
- Q_D(QmlGraphicsItem);
QObject::setParent(parent);
- d->setParentItemHelper(parent, /*newParentVariant=*/0, /*thisPointerVariant=*/0);
- if (oldParent)
- emit oldParent->childrenChanged();
- emit parentChanged();
+ QGraphicsObject::setParentItem(parent);
}
/*!
@@ -1846,7 +1640,10 @@ bool QmlGraphicsItem::clip() const
void QmlGraphicsItem::setClip(bool c)
{
+ if (clip() == c)
+ return;
setFlag(ItemClipsChildrenToShape, c);
+ emit clipChanged();
}
/*!
@@ -2276,10 +2073,6 @@ void QmlGraphicsItem::setBaselineOffset(qreal offset)
color: "blue"
width: 100; height: 100
Rectangle {
- color: "green"
- width: 25; height: 25
- }
- Rectangle {
color: "red"
x: 25; y: 25; width: 50; height: 50
rotation: 30
@@ -2838,6 +2631,7 @@ void QmlGraphicsItem::setSmooth(bool smooth)
if (d->smooth == smooth)
return;
d->smooth = smooth;
+ emit smoothChanged();
update();
}
@@ -3090,14 +2884,6 @@ int QmlGraphicsItemPrivate::restart(QTime &t)
return n;
}
-#include <qmlgraphicsitem.moc>
-#include <moc_qmlgraphicsitem.cpp>
-
QT_END_NAMESPACE
-QML_DECLARE_TYPE(QmlGraphicsKeysAttached)
-QML_DECLARE_TYPEINFO(QmlGraphicsKeysAttached, QML_HAS_ATTACHED_PROPERTIES)
-QML_DEFINE_TYPE(Qt,4,6,Keys,QmlGraphicsKeysAttached)
-QML_DECLARE_TYPE(QmlGraphicsKeyNavigationAttached)
-QML_DECLARE_TYPEINFO(QmlGraphicsKeyNavigationAttached, QML_HAS_ATTACHED_PROPERTIES)
-QML_DEFINE_TYPE(Qt,4,6,KeyNavigation,QmlGraphicsKeyNavigationAttached)
+#include <moc_qmlgraphicsitem.cpp>
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.h b/src/declarative/graphicsitems/qmlgraphicsitem.h
index 606cc56..e1cf035 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitem.h
+++ b/src/declarative/graphicsitems/qmlgraphicsitem.h
@@ -50,6 +50,7 @@
#include <QtGui/qgraphicsitem.h>
#include <QtGui/qgraphicstransform.h>
#include <QtGui/qfont.h>
+#include <QtGui/qaction.h>
QT_BEGIN_HEADER
@@ -87,12 +88,12 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsItem : public QGraphicsObject, public QmlP
Q_PROPERTY(QmlGraphicsAnchorLine verticalCenter READ verticalCenter CONSTANT FINAL)
Q_PROPERTY(QmlGraphicsAnchorLine baseline READ baseline CONSTANT FINAL)
Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged)
- Q_PROPERTY(bool clip READ clip WRITE setClip) // ### move to QGI/QGO, NOTIFY
+ Q_PROPERTY(bool clip READ clip WRITE setClip NOTIFY clipChanged) // ### move to QGI/QGO, NOTIFY
Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL)
Q_PROPERTY(bool wantsFocus READ wantsFocus NOTIFY wantsFocusChanged)
Q_PROPERTY(QmlList<QGraphicsTransform *>* transform READ transform DESIGNABLE false FINAL)
Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin NOTIFY transformOriginChanged)
- Q_PROPERTY(bool smooth READ smooth WRITE setSmooth)
+ Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
Q_PROPERTY(QGraphicsEffect *effect READ graphicsEffect WRITE setGraphicsEffect)
Q_ENUMS(TransformOrigin)
Q_CLASSINFO("DefaultProperty", "data")
@@ -177,6 +178,8 @@ Q_SIGNALS:
void wantsFocusChanged();
void parentChanged();
void transformOriginChanged(TransformOrigin);
+ void smoothChanged();
+ void clipChanged();
protected:
bool isComponentComplete() const;
@@ -233,6 +236,7 @@ QML_DECLARE_TYPE(QmlGraphicsItem)
QML_DECLARE_TYPE(QGraphicsTransform)
QML_DECLARE_TYPE(QGraphicsScale)
QML_DECLARE_TYPE(QGraphicsRotation)
+QML_DECLARE_TYPE(QAction)
QT_END_HEADER
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem_p.h b/src/declarative/graphicsitems/qmlgraphicsitem_p.h
index 5ef07e3..7662a3b 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitem_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsitem_p.h
@@ -280,8 +280,209 @@ public:
static int restart(QTime &);
};
+/*
+ Key filters can be installed on a QmlGraphicsItem, but not removed. Currently they
+ are only used by attached objects (which are only destroyed on Item
+ destruction), so this isn't a problem. If in future this becomes any form
+ of public API, they will have to support removal too.
+*/
+class QmlGraphicsItemKeyFilter
+{
+public:
+ QmlGraphicsItemKeyFilter(QmlGraphicsItem * = 0);
+ virtual ~QmlGraphicsItemKeyFilter();
+
+ virtual void keyPressed(QKeyEvent *event);
+ virtual void keyReleased(QKeyEvent *event);
+ virtual void inputMethodEvent(QInputMethodEvent *event);
+ virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
+ virtual void componentComplete();
+
+private:
+ QmlGraphicsItemKeyFilter *m_next;
+};
+
+class QmlGraphicsKeyNavigationAttachedPrivate : public QObjectPrivate
+{
+public:
+ QmlGraphicsKeyNavigationAttachedPrivate()
+ : QObjectPrivate(), left(0), right(0), up(0), down(0) {}
+
+ QmlGraphicsItem *left;
+ QmlGraphicsItem *right;
+ QmlGraphicsItem *up;
+ QmlGraphicsItem *down;
+};
+
+class QmlGraphicsKeyNavigationAttached : public QObject, public QmlGraphicsItemKeyFilter
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QmlGraphicsKeyNavigationAttached)
+
+ Q_PROPERTY(QmlGraphicsItem *left READ left WRITE setLeft NOTIFY changed)
+ Q_PROPERTY(QmlGraphicsItem *right READ right WRITE setRight NOTIFY changed)
+ Q_PROPERTY(QmlGraphicsItem *up READ up WRITE setUp NOTIFY changed)
+ Q_PROPERTY(QmlGraphicsItem *down READ down WRITE setDown NOTIFY changed)
+public:
+ QmlGraphicsKeyNavigationAttached(QObject * = 0);
+
+ QmlGraphicsItem *left() const;
+ void setLeft(QmlGraphicsItem *);
+ QmlGraphicsItem *right() const;
+ void setRight(QmlGraphicsItem *);
+ QmlGraphicsItem *up() const;
+ void setUp(QmlGraphicsItem *);
+ QmlGraphicsItem *down() const;
+ void setDown(QmlGraphicsItem *);
+
+ static QmlGraphicsKeyNavigationAttached *qmlAttachedProperties(QObject *);
+
+Q_SIGNALS:
+ void changed();
+
+private:
+ virtual void keyPressed(QKeyEvent *event);
+ virtual void keyReleased(QKeyEvent *event);
+};
+
+class QmlGraphicsKeysAttachedPrivate : public QObjectPrivate
+{
+public:
+ QmlGraphicsKeysAttachedPrivate()
+ : QObjectPrivate(), inPress(false), inRelease(false)
+ , inIM(false), enabled(true), imeItem(0), item(0)
+ {}
+
+ bool isConnected(const char *signalName);
+
+ QGraphicsItem *finalFocusProxy(QGraphicsItem *item) const
+ {
+ QGraphicsItem *fp;
+ while ((fp = item->focusProxy()))
+ item = fp;
+ return item;
+ }
+
+ //loop detection
+ bool inPress:1;
+ bool inRelease:1;
+ bool inIM:1;
+
+ bool enabled : 1;
+
+ QGraphicsItem *imeItem;
+ QList<QmlGraphicsItem *> targets;
+ QmlGraphicsItem *item;
+};
+
+class QmlGraphicsKeysAttached : public QObject, public QmlGraphicsItemKeyFilter
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QmlGraphicsKeysAttached)
+
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
+ Q_PROPERTY(QList<QmlGraphicsItem *> *forwardTo READ forwardTo)
+
+public:
+ QmlGraphicsKeysAttached(QObject *parent=0);
+ ~QmlGraphicsKeysAttached();
+
+ bool enabled() const { Q_D(const QmlGraphicsKeysAttached); return d->enabled; }
+ void setEnabled(bool enabled) {
+ Q_D(QmlGraphicsKeysAttached);
+ if (enabled != d->enabled) {
+ d->enabled = enabled;
+ emit enabledChanged();
+ }
+ }
+
+ QList<QmlGraphicsItem *> *forwardTo() {
+ Q_D(QmlGraphicsKeysAttached);
+ return &d->targets;
+ }
+
+ virtual void componentComplete();
+
+ static QmlGraphicsKeysAttached *qmlAttachedProperties(QObject *);
+
+Q_SIGNALS:
+ void enabledChanged();
+ void pressed(QmlGraphicsKeyEvent *event);
+ void released(QmlGraphicsKeyEvent *event);
+ void digit0Pressed(QmlGraphicsKeyEvent *event);
+ void digit1Pressed(QmlGraphicsKeyEvent *event);
+ void digit2Pressed(QmlGraphicsKeyEvent *event);
+ void digit3Pressed(QmlGraphicsKeyEvent *event);
+ void digit4Pressed(QmlGraphicsKeyEvent *event);
+ void digit5Pressed(QmlGraphicsKeyEvent *event);
+ void digit6Pressed(QmlGraphicsKeyEvent *event);
+ void digit7Pressed(QmlGraphicsKeyEvent *event);
+ void digit8Pressed(QmlGraphicsKeyEvent *event);
+ void digit9Pressed(QmlGraphicsKeyEvent *event);
+
+ void leftPressed(QmlGraphicsKeyEvent *event);
+ void rightPressed(QmlGraphicsKeyEvent *event);
+ void upPressed(QmlGraphicsKeyEvent *event);
+ void downPressed(QmlGraphicsKeyEvent *event);
+
+ void asteriskPressed(QmlGraphicsKeyEvent *event);
+ void numberSignPressed(QmlGraphicsKeyEvent *event);
+ void escapePressed(QmlGraphicsKeyEvent *event);
+ void returnPressed(QmlGraphicsKeyEvent *event);
+ void enterPressed(QmlGraphicsKeyEvent *event);
+ void deletePressed(QmlGraphicsKeyEvent *event);
+ void spacePressed(QmlGraphicsKeyEvent *event);
+ void backPressed(QmlGraphicsKeyEvent *event);
+ void cancelPressed(QmlGraphicsKeyEvent *event);
+ void selectPressed(QmlGraphicsKeyEvent *event);
+ void yesPressed(QmlGraphicsKeyEvent *event);
+ void noPressed(QmlGraphicsKeyEvent *event);
+ void context1Pressed(QmlGraphicsKeyEvent *event);
+ void context2Pressed(QmlGraphicsKeyEvent *event);
+ void context3Pressed(QmlGraphicsKeyEvent *event);
+ void context4Pressed(QmlGraphicsKeyEvent *event);
+ void callPressed(QmlGraphicsKeyEvent *event);
+ void hangupPressed(QmlGraphicsKeyEvent *event);
+ void flipPressed(QmlGraphicsKeyEvent *event);
+ void menuPressed(QmlGraphicsKeyEvent *event);
+ void volumeUpPressed(QmlGraphicsKeyEvent *event);
+ void volumeDownPressed(QmlGraphicsKeyEvent *event);
+
+private:
+ virtual void keyPressed(QKeyEvent *event);
+ virtual void keyReleased(QKeyEvent *event);
+ virtual void inputMethodEvent(QInputMethodEvent *);
+ virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
+
+ const QByteArray keyToSignal(int key) {
+ QByteArray keySignal;
+ if (key >= Qt::Key_0 && key <= Qt::Key_9) {
+ keySignal = "digit0Pressed";
+ keySignal[5] = '0' + (key - Qt::Key_0);
+ } else {
+ int i = 0;
+ while (sigMap[i].key && sigMap[i].key != key)
+ ++i;
+ keySignal = sigMap[i].sig;
+ }
+ return keySignal;
+ }
+
+ struct SigMap {
+ int key;
+ const char *sig;
+ };
+
+ static const SigMap sigMap[];
+};
+
Q_DECLARE_OPERATORS_FOR_FLAGS(QmlGraphicsItemPrivate::ChangeTypes);
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QmlGraphicsKeysAttached)
+QML_DECLARE_TYPEINFO(QmlGraphicsKeysAttached, QML_HAS_ATTACHED_PROPERTIES)
+QML_DECLARE_TYPE(QmlGraphicsKeyNavigationAttached)
+QML_DECLARE_TYPEINFO(QmlGraphicsKeyNavigationAttached, QML_HAS_ATTACHED_PROPERTIES)
+
#endif // QMLGRAPHICSITEM_P_H
diff --git a/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp b/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp
new file mode 100644
index 0000000..66d62f0
--- /dev/null
+++ b/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp
@@ -0,0 +1,166 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmlgraphicsitemsmodule_p.h"
+
+#include <QtGui/qaction.h>
+#include <QtGui/qvalidator.h>
+#include <QtGui/qgraphicseffect.h>
+
+#include "qmlgraphicsevents_p_p.h"
+#include "qmlgraphicseffects_p.h"
+#include "qmlgraphicsscalegrid_p_p.h"
+#include "qmlgraphicsanimatedimage_p.h"
+#include "qmlgraphicsborderimage_p.h"
+#include "qmlgraphicspositioners_p.h"
+#include "qmlgraphicsmouseregion_p.h"
+#include "qmlgraphicsflickable_p.h"
+#include "qmlgraphicsflickable_p_p.h"
+#include "qmlgraphicsflipable_p.h"
+#include "qmlgraphicsfocuspanel_p.h"
+#include "qmlgraphicsfocusscope_p.h"
+#include "qmlgraphicsgraphicsobjectcontainer_p.h"
+#include "qmlgraphicsgridview_p.h"
+#include "qmlgraphicsimage_p.h"
+#include "qmlgraphicsitem_p.h"
+#include "qmlgraphicslayoutitem_p.h"
+#include "qmlgraphicslistview_p.h"
+#include "qmlgraphicsloader_p.h"
+#include "qmlgraphicsmouseregion_p.h"
+#include "qmlgraphicsparticles_p.h"
+#include "qmlgraphicspath_p.h"
+#include "qmlgraphicspathview_p.h"
+#include "qmlgraphicsrectangle_p.h"
+#include "qmlgraphicsrepeater_p.h"
+#include "qmlgraphicstext_p.h"
+#include "qmlgraphicstextedit_p.h"
+#include "qmlgraphicstextinput_p.h"
+#include "qmlgraphicsvisualitemmodel_p.h"
+#ifdef QT_WEBKIT_LIB
+#include "qmlgraphicswebview_p.h"
+#include "qmlgraphicswebview_p_p.h"
+#endif
+#include "qmlgraphicsanchors_p.h"
+
+#define QML_REGISTER_TYPE(URI,VMAJ,VMIN,TYPE,CLASS) \
+ qmlRegisterType<CLASS>(#URI, VMAJ, VMIN, #TYPE, #CLASS)
+
+#define QML_REGISTER_NOCREATE_TYPE(CLASS) \
+ qmlRegisterType<CLASS>(#CLASS)
+
+void QmlGraphicsItemModule::defineModule()
+{
+ QML_REGISTER_TYPE(Qt,4,6,AnimatedImage,QmlGraphicsAnimatedImage);
+ QML_REGISTER_TYPE(Qt,4,6,Blur,QGraphicsBlurEffect);
+ QML_REGISTER_TYPE(Qt,4,6,BorderImage,QmlGraphicsBorderImage);
+ QML_REGISTER_TYPE(Qt,4,6,Colorize,QGraphicsColorizeEffect);
+ QML_REGISTER_TYPE(Qt,4,6,Column,QmlGraphicsColumn);
+ QML_REGISTER_TYPE(Qt,4,6,Drag,QmlGraphicsDrag);
+ QML_REGISTER_TYPE(Qt,4,6,DropShadow,QGraphicsDropShadowEffect);
+ QML_REGISTER_TYPE(Qt,4,6,Flickable,QmlGraphicsFlickable);
+ QML_REGISTER_TYPE(Qt,4,6,Flipable,QmlGraphicsFlipable);
+ QML_REGISTER_TYPE(Qt,4,6,Flow,QmlGraphicsFlow);
+ QML_REGISTER_TYPE(Qt,4,6,FocusPanel,QmlGraphicsFocusPanel);
+ QML_REGISTER_TYPE(Qt,4,6,FocusScope,QmlGraphicsFocusScope);
+ QML_REGISTER_TYPE(Qt,4,6,Gradient,QmlGraphicsGradient);
+ QML_REGISTER_TYPE(Qt,4,6,GradientStop,QmlGraphicsGradientStop);
+ QML_REGISTER_TYPE(Qt,4,6,GraphicsObjectContainer,QmlGraphicsGraphicsObjectContainer);
+ QML_REGISTER_TYPE(Qt,4,6,Grid,QmlGraphicsGrid);
+ QML_REGISTER_TYPE(Qt,4,6,GridView,QmlGraphicsGridView);
+ QML_REGISTER_TYPE(Qt,4,6,Image,QmlGraphicsImage);
+ QML_REGISTER_TYPE(Qt,4,6,Item,QmlGraphicsItem);
+ QML_REGISTER_TYPE(Qt,4,6,KeyNavigation,QmlGraphicsKeyNavigationAttached);
+ QML_REGISTER_TYPE(Qt,4,6,Keys,QmlGraphicsKeysAttached);
+ QML_REGISTER_TYPE(Qt,4,6,LayoutItem,QmlGraphicsLayoutItem);
+ QML_REGISTER_TYPE(Qt,4,6,ListView,QmlGraphicsListView);
+ QML_REGISTER_TYPE(Qt,4,6,Loader,QmlGraphicsLoader);
+ QML_REGISTER_TYPE(Qt,4,6,MouseRegion,QmlGraphicsMouseRegion);
+ QML_REGISTER_TYPE(Qt,4,6,Opacity,QGraphicsOpacityEffect);
+ QML_REGISTER_TYPE(Qt,4,6,ParticleMotion,QmlGraphicsParticleMotion);
+ QML_REGISTER_TYPE(Qt,4,6,ParticleMotionGravity,QmlGraphicsParticleMotionGravity);
+ QML_REGISTER_TYPE(Qt,4,6,ParticleMotionLinear,QmlGraphicsParticleMotionLinear);
+ QML_REGISTER_TYPE(Qt,4,6,ParticleMotionWander,QmlGraphicsParticleMotionWander);
+ QML_REGISTER_TYPE(Qt,4,6,Particles,QmlGraphicsParticles);
+ QML_REGISTER_TYPE(Qt,4,6,Path,QmlGraphicsPath);
+ QML_REGISTER_TYPE(Qt,4,6,PathAttribute,QmlGraphicsPathAttribute);
+ QML_REGISTER_TYPE(Qt,4,6,PathCubic,QmlGraphicsPathCubic);
+ QML_REGISTER_TYPE(Qt,4,6,PathLine,QmlGraphicsPathLine);
+ QML_REGISTER_TYPE(Qt,4,6,PathPercent,QmlGraphicsPathPercent);
+ QML_REGISTER_TYPE(Qt,4,6,PathQuad,QmlGraphicsPathQuad);
+ QML_REGISTER_TYPE(Qt,4,6,PathView,QmlGraphicsPathView);
+ QML_REGISTER_TYPE(Qt,4,6,Pen,QmlGraphicsPen);
+ QML_REGISTER_TYPE(Qt,4,6,QIntValidator,QIntValidator);
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
+ QML_REGISTER_TYPE(Qt,4,7,QDoubleValidator,QDoubleValidator);
+ QML_REGISTER_TYPE(Qt,4,7,QRegExpValidator,QRegExpValidator);
+#endif
+ QML_REGISTER_TYPE(Qt,4,6,Rectangle,QmlGraphicsRectangle);
+ QML_REGISTER_TYPE(Qt,4,6,Repeater,QmlGraphicsRepeater);
+ QML_REGISTER_TYPE(Qt,4,6,Rotation,QGraphicsRotation);
+ QML_REGISTER_TYPE(Qt,4,6,Row,QmlGraphicsRow);
+ QML_REGISTER_TYPE(Qt,4,6,Scale,QGraphicsScale);
+ QML_REGISTER_TYPE(Qt,4,6,Text,QmlGraphicsText);
+ QML_REGISTER_TYPE(Qt,4,6,TextEdit,QmlGraphicsTextEdit);
+ QML_REGISTER_TYPE(Qt,4,6,TextInput,QmlGraphicsTextInput);
+ QML_REGISTER_TYPE(Qt,4,6,ViewSection,QmlGraphicsViewSection);
+ QML_REGISTER_TYPE(Qt,4,6,VisibleArea,QmlGraphicsFlickableVisibleArea);
+ QML_REGISTER_TYPE(Qt,4,6,VisualDataModel,QmlGraphicsVisualDataModel);
+ QML_REGISTER_TYPE(Qt,4,6,VisualItemModel,QmlGraphicsVisualItemModel);
+#ifdef QT_WEBKIT_LIB
+ QML_REGISTER_TYPE(Qt,4,6,WebView,QmlGraphicsWebView);
+#endif
+
+ QML_REGISTER_NOCREATE_TYPE(QmlGraphicsAnchors);
+ QML_REGISTER_NOCREATE_TYPE(QGraphicsEffect);
+ QML_REGISTER_NOCREATE_TYPE(QmlGraphicsKeyEvent);
+ QML_REGISTER_NOCREATE_TYPE(QmlGraphicsMouseEvent);
+ QML_REGISTER_NOCREATE_TYPE(QGraphicsObject);
+ QML_REGISTER_NOCREATE_TYPE(QGraphicsTransform);
+ QML_REGISTER_NOCREATE_TYPE(QmlGraphicsPathElement);
+ QML_REGISTER_NOCREATE_TYPE(QmlGraphicsCurve);
+ QML_REGISTER_NOCREATE_TYPE(QmlGraphicsScaleGrid);
+ QML_REGISTER_NOCREATE_TYPE(QValidator);
+ QML_REGISTER_NOCREATE_TYPE(QmlGraphicsVisualModel);
+ QML_REGISTER_NOCREATE_TYPE(QAction);
+#ifdef QT_WEBKIT_LIB
+ QML_REGISTER_NOCREATE_TYPE(QmlGraphicsWebSettings);
+#endif
+}
diff --git a/src/declarative/graphicsitems/qmlgraphicsitemsmodule_p.h b/src/declarative/graphicsitems/qmlgraphicsitemsmodule_p.h
new file mode 100644
index 0000000..76fea7e
--- /dev/null
+++ b/src/declarative/graphicsitems/qmlgraphicsitemsmodule_p.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLGRAPHICSITEMMODULE_H
+#define QMLGRAPHICSITEMMODULE_H
+
+#include <qml.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QmlGraphicsItemModule
+{
+public:
+ static void defineModule();
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QMLGRAPHICSITEMMODULE_H
diff --git a/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp b/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp
index b054ced..961065e 100644
--- a/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp
@@ -47,11 +47,16 @@
QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(Qt,4,6,LayoutItem,QmlGraphicsLayoutItem)
-
/*!
\qmlclass LayoutItem QmlGraphicsLayoutItem
\brief The LayoutItem element allows you to place your Fluid UI elements inside a classical Qt layout.
+
+ LayoutItem is a variant of Item with a couple of additional properties. These properties provide the size hints
+ needed for items to work in conjunction with Qt Layouts. The Qt Layout will resize the LayoutItem as appropriate,
+ taking its size hints into account, and you can propagate this to the other elements in your UI via anchors and bindings.
+
+ This is a QGraphicsLayoutItem subclass, and the properties merely expose the QGraphicsLayoutItem functionality to QML.
+ See the QGraphicsLayoutItem documentation for further details.
*/
/*!
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
index 1e2698c..c646d49 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
@@ -85,72 +85,6 @@ QString QmlGraphicsViewSection::sectionString(const QString &value)
return value;
}
-class QmlGraphicsListViewAttached : public QObject
-{
- Q_OBJECT
-public:
- QmlGraphicsListViewAttached(QObject *parent)
- : QObject(parent), m_view(0), m_isCurrent(false), m_delayRemove(false) {}
- ~QmlGraphicsListViewAttached() {}
-
- Q_PROPERTY(QmlGraphicsListView *view READ view CONSTANT)
- QmlGraphicsListView *view() { return m_view; }
-
- Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged)
- bool isCurrentItem() const { return m_isCurrent; }
- void setIsCurrentItem(bool c) {
- if (m_isCurrent != c) {
- m_isCurrent = c;
- emit currentItemChanged();
- }
- }
-
- Q_PROPERTY(QString prevSection READ prevSection NOTIFY prevSectionChanged)
- QString prevSection() const { return m_prevSection; }
- void setPrevSection(const QString &sect) {
- if (m_prevSection != sect) {
- m_prevSection = sect;
- emit prevSectionChanged();
- }
- }
-
- Q_PROPERTY(QString section READ section NOTIFY sectionChanged)
- QString section() const { return m_section; }
- void setSection(const QString &sect) {
- if (m_section != sect) {
- m_section = sect;
- emit sectionChanged();
- }
- }
-
- Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged)
- bool delayRemove() const { return m_delayRemove; }
- void setDelayRemove(bool delay) {
- if (m_delayRemove != delay) {
- m_delayRemove = delay;
- emit delayRemoveChanged();
- }
- }
-
- void emitAdd() { emit add(); }
- void emitRemove() { emit remove(); }
-
-Q_SIGNALS:
- void currentItemChanged();
- void sectionChanged();
- void prevSectionChanged();
- void delayRemoveChanged();
- void add();
- void remove();
-
-public:
- QmlGraphicsListView *m_view;
- bool m_isCurrent;
- mutable QString m_section;
- QString m_prevSection;
- bool m_delayRemove;
-};
-
//----------------------------------------------------------------------------
class FxListItem
@@ -1135,9 +1069,13 @@ void QmlGraphicsListViewPrivate::fixupY()
fixupDuration = moveReason == Mouse ? fixupDuration : 0;
if (haveHighlightRange && highlightRange == QmlGraphicsListView::StrictlyEnforceRange) {
- if (currentItem && highlight && currentItem->position() != highlight->position()) {
+ if (currentItem && currentItem->position() - position() != highlightRangeStart) {
+ qreal pos = currentItem->position() - highlightRangeStart;
timeline.reset(_moveY);
- timeline.move(_moveY, -(currentItem->position() - highlightRangeStart), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ if (fixupDuration)
+ timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ else
+ _moveY.setValue(-pos);
vTime = timeline.time();
}
} else if (snapMode != QmlGraphicsListView::NoSnap) {
@@ -1146,7 +1084,10 @@ void QmlGraphicsListViewPrivate::fixupY()
qreal dist = qAbs(_moveY + pos);
if (dist > 0) {
timeline.reset(_moveY);
- timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ if (fixupDuration)
+ timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ else
+ _moveY.setValue(-pos);
vTime = timeline.time();
}
}
@@ -1168,9 +1109,13 @@ void QmlGraphicsListViewPrivate::fixupX()
fixupDuration = moveReason == Mouse ? fixupDuration : 0;
if (haveHighlightRange && highlightRange == QmlGraphicsListView::StrictlyEnforceRange) {
- if (currentItem && highlight && currentItem->position() != highlight->position()) {
+ if (currentItem && currentItem->position() - position() != highlightRangeStart) {
+ qreal pos = currentItem->position() - highlightRangeStart;
timeline.reset(_moveX);
- timeline.move(_moveX, -(currentItem->position() - highlightRangeStart), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ if (fixupDuration)
+ timeline.move(_moveX, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ else
+ _moveX.setValue(-pos);
vTime = timeline.time();
}
} else if (snapMode != QmlGraphicsListView::NoSnap) {
@@ -1179,7 +1124,10 @@ void QmlGraphicsListViewPrivate::fixupX()
qreal dist = qAbs(_moveX + pos);
if (dist > 0) {
timeline.reset(_moveX);
- timeline.move(_moveX, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ if (fixupDuration)
+ timeline.move(_moveX, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ else
+ _moveX.setValue(-pos);
vTime = timeline.time();
}
}
@@ -2327,6 +2275,7 @@ void QmlGraphicsListView::positionViewAtIndex(int index)
for (int i = 0; i < oldVisible.count(); ++i)
d->releaseItem(oldVisible.at(i));
}
+ d->fixupPosition();
}
@@ -2699,9 +2648,32 @@ void QmlGraphicsListView::itemsMoved(int from, int to, int count)
++endIndex;
}
+ // update visibleIndex
+ for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) {
+ if ((*it)->index != -1) {
+ d->visibleIndex = (*it)->index;
+ break;
+ }
+ }
+
+ // Fix current index
+ if (d->currentIndex >= 0 && d->currentItem) {
+ int oldCurrent = d->currentIndex;
+ d->currentIndex = d->model->indexOf(d->currentItem->item, this);
+ if (oldCurrent != d->currentIndex) {
+ d->currentItem->index = d->currentIndex;
+ emit currentIndexChanged();
+ }
+ }
+
// Whatever moved items remain are no longer visible items.
- while (moved.count())
- d->releaseItem(moved.take(moved.begin().key()));
+ while (moved.count()) {
+ int idx = moved.begin().key();
+ FxListItem *item = moved.take(idx);
+ if (item->item == d->currentItem->item)
+ item->setPosition(d->positionAt(idx));
+ d->releaseItem(item);
+ }
// Ensure we don't cause an ugly list scroll.
d->visibleItems.first()->setPosition(d->visibleItems.first()->position() + moveBy);
@@ -2740,9 +2712,4 @@ QmlGraphicsListViewAttached *QmlGraphicsListView::qmlAttachedProperties(QObject
return new QmlGraphicsListViewAttached(obj);
}
-QML_DEFINE_TYPE(Qt,4,6,ListView,QmlGraphicsListView)
-QML_DEFINE_TYPE(Qt,4,6,ViewSection,QmlGraphicsViewSection)
-
QT_END_NAMESPACE
-
-#include <qmlgraphicslistview.moc>
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview_p.h b/src/declarative/graphicsitems/qmlgraphicslistview_p.h
index 5a8ac9c..c5b4aab 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicslistview_p.h
@@ -227,6 +227,73 @@ private Q_SLOTS:
void animStopped();
};
+class QmlGraphicsListViewAttached : public QObject
+{
+ Q_OBJECT
+public:
+ QmlGraphicsListViewAttached(QObject *parent)
+ : QObject(parent), m_view(0), m_isCurrent(false), m_delayRemove(false) {}
+ ~QmlGraphicsListViewAttached() {}
+
+ Q_PROPERTY(QmlGraphicsListView *view READ view CONSTANT)
+ QmlGraphicsListView *view() { return m_view; }
+
+ Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged)
+ bool isCurrentItem() const { return m_isCurrent; }
+ void setIsCurrentItem(bool c) {
+ if (m_isCurrent != c) {
+ m_isCurrent = c;
+ emit currentItemChanged();
+ }
+ }
+
+ Q_PROPERTY(QString prevSection READ prevSection NOTIFY prevSectionChanged)
+ QString prevSection() const { return m_prevSection; }
+ void setPrevSection(const QString &sect) {
+ if (m_prevSection != sect) {
+ m_prevSection = sect;
+ emit prevSectionChanged();
+ }
+ }
+
+ Q_PROPERTY(QString section READ section NOTIFY sectionChanged)
+ QString section() const { return m_section; }
+ void setSection(const QString &sect) {
+ if (m_section != sect) {
+ m_section = sect;
+ emit sectionChanged();
+ }
+ }
+
+ Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged)
+ bool delayRemove() const { return m_delayRemove; }
+ void setDelayRemove(bool delay) {
+ if (m_delayRemove != delay) {
+ m_delayRemove = delay;
+ emit delayRemoveChanged();
+ }
+ }
+
+ void emitAdd() { emit add(); }
+ void emitRemove() { emit remove(); }
+
+Q_SIGNALS:
+ void currentItemChanged();
+ void sectionChanged();
+ void prevSectionChanged();
+ void delayRemoveChanged();
+ void add();
+ void remove();
+
+public:
+ QmlGraphicsListView *m_view;
+ bool m_isCurrent;
+ mutable QString m_section;
+ QString m_prevSection;
+ bool m_delayRemove;
+};
+
+
QT_END_NAMESPACE
QML_DECLARE_TYPEINFO(QmlGraphicsListView, QML_HAS_ATTACHED_PROPERTIES)
diff --git a/src/declarative/graphicsitems/qmlgraphicsloader.cpp b/src/declarative/graphicsitems/qmlgraphicsloader.cpp
index 44932a2..159ddc3 100644
--- a/src/declarative/graphicsitems/qmlgraphicsloader.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsloader.cpp
@@ -108,8 +108,6 @@ void QmlGraphicsLoaderPrivate::initResize()
_q_updateSize();
}
-QML_DEFINE_TYPE(Qt,4,6,Loader,QmlGraphicsLoader)
-
/*!
\qmlclass Loader QmlGraphicsLoader
\inherits Item
@@ -400,6 +398,7 @@ void QmlGraphicsLoader::setResizeMode(ResizeMode mode)
}
d->resizeMode = mode;
+ emit resizeModeChanged();
d->initResize();
}
diff --git a/src/declarative/graphicsitems/qmlgraphicsloader_p.h b/src/declarative/graphicsitems/qmlgraphicsloader_p.h
index bfc011d..0ab67ac 100644
--- a/src/declarative/graphicsitems/qmlgraphicsloader_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsloader_p.h
@@ -59,7 +59,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsLoader : public QmlGraphicsItem
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
Q_PROPERTY(QmlComponent *sourceComponent READ sourceComponent WRITE setSourceComponent NOTIFY sourceChanged)
- Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
+ Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode NOTIFY resizeModeChanged)
Q_PROPERTY(QGraphicsObject *item READ item NOTIFY itemChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
@@ -89,6 +89,8 @@ Q_SIGNALS:
void sourceChanged();
void statusChanged();
void progressChanged();
+ void resizeModeChanged();
+
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
index 1f8435e..3470d37 100644
--- a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
@@ -49,7 +49,6 @@
QT_BEGIN_NAMESPACE
static const int PressAndHoldDelay = 800;
-QML_DEFINE_TYPE(Qt,4,6,Drag,QmlGraphicsDrag)
QmlGraphicsDrag::QmlGraphicsDrag(QObject *parent)
: QObject(parent), _target(0), _axis(XandYAxis), _xmin(0), _xmax(0), _ymin(0), _ymax(0)
{
@@ -66,7 +65,10 @@ QmlGraphicsItem *QmlGraphicsDrag::target() const
void QmlGraphicsDrag::setTarget(QmlGraphicsItem *t)
{
+ if (_target == t)
+ return;
_target = t;
+ emit targetChanged();
}
QmlGraphicsDrag::Axis QmlGraphicsDrag::axis() const
@@ -76,7 +78,10 @@ QmlGraphicsDrag::Axis QmlGraphicsDrag::axis() const
void QmlGraphicsDrag::setAxis(QmlGraphicsDrag::Axis a)
{
+ if (_axis == a)
+ return;
_axis = a;
+ emit axisChanged();
}
qreal QmlGraphicsDrag::xmin() const
@@ -86,7 +91,10 @@ qreal QmlGraphicsDrag::xmin() const
void QmlGraphicsDrag::setXmin(qreal m)
{
+ if (_xmin == m)
+ return;
_xmin = m;
+ emit minimumXChanged();
}
qreal QmlGraphicsDrag::xmax() const
@@ -96,7 +104,10 @@ qreal QmlGraphicsDrag::xmax() const
void QmlGraphicsDrag::setXmax(qreal m)
{
+ if (_xmax == m)
+ return;
_xmax = m;
+ emit maximumXChanged();
}
qreal QmlGraphicsDrag::ymin() const
@@ -106,7 +117,10 @@ qreal QmlGraphicsDrag::ymin() const
void QmlGraphicsDrag::setYmin(qreal m)
{
+ if (_ymin == m)
+ return;
_ymin = m;
+ emit minimumYChanged();
}
qreal QmlGraphicsDrag::ymax() const
@@ -116,7 +130,10 @@ qreal QmlGraphicsDrag::ymax() const
void QmlGraphicsDrag::setYmax(qreal m)
{
+ if (_ymax == m)
+ return;
_ymax = m;
+ emit maximumYChanged();
}
QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate()
@@ -155,12 +172,24 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate()
\qmlsignal MouseRegion::onEntered()
This handler is called when the mouse enters the mouse region.
+
+ By default the onEntered handler is only called while a button is
+ pressed. Setting hoverEnabled to true enables handling of
+ onExited when no mouse button is pressed.
+
+ \sa hoverEnabled
*/
/*!
\qmlsignal MouseRegion::onExited()
This handler is called when the mouse exists the mouse region.
+
+ By default the onExited handler is only called while a button is
+ pressed. Setting hoverEnabled to true enables handling of
+ onExited when no mouse button is pressed.
+
+ \sa hoverEnabled
*/
/*!
@@ -172,6 +201,10 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate()
position, and any buttons currently pressed.
The \e accepted property of the MouseEvent parameter is ignored in this handler.
+
+ By default the onPositionChanged handler is only called while a button is
+ pressed. Setting hoverEnabled to true enables handling of
+ onPositionChanged when no mouse button is pressed.
*/
/*!
@@ -231,8 +264,6 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate()
The \e accepted property of the MouseEvent parameter is ignored in this handler.
*/
-QML_DEFINE_TYPE(Qt,4,6,MouseRegion,QmlGraphicsMouseRegion)
-
/*!
\internal
\class QmlGraphicsMouseRegion
diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion_p.h b/src/declarative/graphicsitems/qmlgraphicsmouseregion_p.h
index e01831e..cccf90c 100644
--- a/src/declarative/graphicsitems/qmlgraphicsmouseregion_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsmouseregion_p.h
@@ -55,12 +55,12 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsDrag : public QObject
Q_OBJECT
Q_ENUMS(Axis)
- Q_PROPERTY(QmlGraphicsItem *target READ target WRITE setTarget)
- Q_PROPERTY(Axis axis READ axis WRITE setAxis)
- Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin)
- Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax)
- Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin)
- Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax)
+ Q_PROPERTY(QmlGraphicsItem *target READ target WRITE setTarget NOTIFY targetChanged)
+ Q_PROPERTY(Axis axis READ axis WRITE setAxis NOTIFY axisChanged)
+ Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged)
+ Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged)
+ Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged)
+ Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged)
//### consider drag and drop
public:
@@ -83,6 +83,14 @@ public:
qreal ymax() const;
void setYmax(qreal);
+Q_SIGNALS:
+ void targetChanged();
+ void axisChanged();
+ void minimumXChanged();
+ void maximumXChanged();
+ void minimumYChanged();
+ void maximumYChanged();
+
private:
QmlGraphicsItem *_target;
Axis _axis;
@@ -107,7 +115,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsMouseRegion : public QmlGraphicsItem
Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedChanged)
Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
Q_PROPERTY(bool hoverEnabled READ acceptHoverEvents WRITE setAcceptHoverEvents)
- Q_PROPERTY(QmlGraphicsDrag *drag READ drag) //### add flicking to QmlGraphicsDrag or add a QmlGraphicsFlick ???
+ Q_PROPERTY(QmlGraphicsDrag *drag READ drag CONSTANT) //### add flicking to QmlGraphicsDrag or add a QmlGraphicsFlick ???
public:
QmlGraphicsMouseRegion(QmlGraphicsItem *parent=0);
diff --git a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
index 95d4844..08fce74 100644
--- a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
@@ -108,8 +108,6 @@ public:
//---------------------------------------------------------------------------
-QML_DEFINE_TYPE(Qt,4,6,ParticleMotion,QmlGraphicsParticleMotion)
-
/*!
\class QmlGraphicsParticleMotion
\ingroup group_effects
@@ -169,8 +167,6 @@ void QmlGraphicsParticleMotion::destroy(QmlGraphicsParticle &particle)
\brief The QmlGraphicsParticleMotionLinear class moves the particles linearly.
*/
-QML_DEFINE_TYPE(Qt,4,6,ParticleMotionLinear,QmlGraphicsParticleMotionLinear)
-
void QmlGraphicsParticleMotionLinear::advance(QmlGraphicsParticle &p, int interval)
{
p.x += interval * p.x_velocity;
@@ -191,8 +187,6 @@ void QmlGraphicsParticleMotionLinear::advance(QmlGraphicsParticle &p, int interv
\brief The QmlGraphicsParticleMotionGravity class moves the particles towards a point.
*/
-QML_DEFINE_TYPE(Qt,4,6,ParticleMotionGravity,QmlGraphicsParticleMotionGravity)
-
/*!
\qmlproperty int ParticleMotionGravity::xattractor
\qmlproperty int ParticleMotionGravity::yattractor
@@ -293,8 +287,6 @@ Rectangle {
This property holds how quickly the paricles will move from side to side.
*/
-QML_DEFINE_TYPE(Qt,4,6,ParticleMotionWander,QmlGraphicsParticleMotionWander)
-
void QmlGraphicsParticleMotionWander::advance(QmlGraphicsParticle &p, int interval)
{
if (!particles)
@@ -561,8 +553,6 @@ void QmlGraphicsParticlesPrivate::updateOpacity(QmlGraphicsParticle &p, int age)
}
}
-QML_DEFINE_TYPE(Qt,4,6,Particles,QmlGraphicsParticles)
-
/*!
\qmlclass Particles
\brief The Particles object generates and moves particles.
@@ -645,7 +635,7 @@ QmlGraphicsParticles::~QmlGraphicsParticles()
}
/*!
- \qmlproperty string Particles::src
+ \qmlproperty string Particles::source
This property holds the URL of the particle image.
*/
diff --git a/src/declarative/graphicsitems/qmlgraphicspath.cpp b/src/declarative/graphicsitems/qmlgraphicspath.cpp
index 6f04b75..7916bd3 100644
--- a/src/declarative/graphicsitems/qmlgraphicspath.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicspath.cpp
@@ -49,14 +49,6 @@
#include <private/qbezier_p.h>
QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(Qt,4,6,Path,QmlGraphicsPath)
-QML_DEFINE_NOCREATE_TYPE(QmlGraphicsPathElement)
-QML_DEFINE_NOCREATE_TYPE(QmlGraphicsCurve)
-QML_DEFINE_TYPE(Qt,4,6,PathAttribute,QmlGraphicsPathAttribute)
-QML_DEFINE_TYPE(Qt,4,6,PathPercent,QmlGraphicsPathPercent)
-QML_DEFINE_TYPE(Qt,4,6,PathLine,QmlGraphicsPathLine)
-QML_DEFINE_TYPE(Qt,4,6,PathQuad,QmlGraphicsPathQuad)
-QML_DEFINE_TYPE(Qt,4,6,PathCubic,QmlGraphicsPathCubic)
/*!
\qmlclass PathElement QmlGraphicsPathElement
diff --git a/src/declarative/graphicsitems/qmlgraphicspathview.cpp b/src/declarative/graphicsitems/qmlgraphicspathview.cpp
index 4511820..f862555 100644
--- a/src/declarative/graphicsitems/qmlgraphicspathview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicspathview.cpp
@@ -54,9 +54,6 @@
QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(Qt,4,6,PathView,QmlGraphicsPathView)
-
-
inline qreal qmlMod(qreal x, qreal y)
{
#ifdef QT_USE_MATH_H_FLOATS
diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
index ba26f62..8adf239 100644
--- a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
@@ -288,7 +288,6 @@ void QmlGraphicsBasePositioner::finishApplyTransitions()
d->moveActions.clear();
}
-QML_DEFINE_TYPE(Qt,4,6,Column,QmlGraphicsColumn)
/*!
\qmlclass Column QmlGraphicsColumn
\brief The Column item lines up its children vertically.
@@ -362,7 +361,7 @@ Column {
Column {
move: Transition {
NumberAnimation {
- matchProperties: "y"
+ properties: "y"
ease: "easeOutBounce"
}
}
@@ -418,7 +417,6 @@ void QmlGraphicsColumn::doPositioning()
}
}
-QML_DEFINE_TYPE(Qt,4,6,Row,QmlGraphicsRow)
/*!
\qmlclass Row QmlGraphicsRow
\brief The Row item lines up its children horizontally.
@@ -472,7 +470,7 @@ Row {
id: positioner
move: Transition {
NumberAnimation {
- matchProperties: "x"
+ properties: "x"
ease: "easeOutBounce"
}
}
@@ -523,7 +521,6 @@ void QmlGraphicsRow::doPositioning()
}
}
-QML_DEFINE_TYPE(Qt,4,6,Grid,QmlGraphicsGrid)
/*!
\qmlclass Grid QmlGraphicsGrid
@@ -595,7 +592,7 @@ Grid {
Grid {
move: Transition {
NumberAnimation {
- matchProperties: "x,y"
+ properties: "x,y"
ease: "easeOutBounce"
}
}
@@ -711,7 +708,6 @@ void QmlGraphicsGrid::doPositioning()
}
-QML_DEFINE_TYPE(Qt,4,6,Flow,QmlGraphicsFlow)
/*!
\qmlclass Flow QmlGraphicsFlow
\brief The Flow item lines up its children side by side, wrapping as necessary.
@@ -741,7 +737,7 @@ Flow {
id: positioner
move: Transition {
NumberAnimation {
- matchProperties: "x,y"
+ properties: "x,y"
ease: "easeOutBounce"
}
}
diff --git a/src/declarative/graphicsitems/qmlgraphicsrectangle.cpp b/src/declarative/graphicsitems/qmlgraphicsrectangle.cpp
index 1fa63e0..f357ed0 100644
--- a/src/declarative/graphicsitems/qmlgraphicsrectangle.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsrectangle.cpp
@@ -46,9 +46,6 @@
#include <QtCore/qmath.h>
QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(Qt,4,6,Pen,QmlGraphicsPen)
-QML_DEFINE_TYPE(Qt,4,6,GradientStop,QmlGraphicsGradientStop)
-QML_DEFINE_TYPE(Qt,4,6,Gradient,QmlGraphicsGradient)
/*!
\internal
@@ -149,7 +146,6 @@ void QmlGraphicsGradient::doUpdate()
emit updated();
}
-QML_DEFINE_TYPE(Qt,4,6,Rectangle,QmlGraphicsRectangle)
/*!
\qmlclass Rectangle QmlGraphicsRectangle
diff --git a/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp b/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp
index 0c27f4c..fc78ef8 100644
--- a/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp
@@ -60,8 +60,6 @@ QmlGraphicsRepeaterPrivate::~QmlGraphicsRepeaterPrivate()
delete model;
}
-QML_DEFINE_TYPE(Qt,4,6,Repeater,QmlGraphicsRepeater)
-
/*!
\qmlclass Repeater QmlGraphicsRepeater
\inherits Item
@@ -159,6 +157,9 @@ QVariant QmlGraphicsRepeater::model() const
void QmlGraphicsRepeater::setModel(const QVariant &model)
{
Q_D(QmlGraphicsRepeater);
+ if (d->dataSource == model)
+ return;
+
clear();
if (d->model) {
disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
@@ -170,6 +171,7 @@ void QmlGraphicsRepeater::setModel(const QVariant &model)
*/
}
d->dataSource = model;
+ emit modelChanged();
QObject *object = qvariant_cast<QObject*>(model);
QmlGraphicsVisualModel *vim = 0;
if (object && (vim = qobject_cast<QmlGraphicsVisualModel *>(object))) {
@@ -221,6 +223,10 @@ QmlComponent *QmlGraphicsRepeater::delegate() const
void QmlGraphicsRepeater::setDelegate(QmlComponent *delegate)
{
Q_D(QmlGraphicsRepeater);
+ if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model))
+ if (delegate == dataModel->delegate())
+ return;
+
if (!d->ownModel) {
d->model = new QmlGraphicsVisualDataModel(qmlContext(this));
d->ownModel = true;
@@ -228,6 +234,7 @@ void QmlGraphicsRepeater::setDelegate(QmlComponent *delegate)
if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model)) {
dataModel->setDelegate(delegate);
regenerate();
+ emit delegateChanged();
}
}
diff --git a/src/declarative/graphicsitems/qmlgraphicsrepeater_p.h b/src/declarative/graphicsitems/qmlgraphicsrepeater_p.h
index f7a6b09..2324916 100644
--- a/src/declarative/graphicsitems/qmlgraphicsrepeater_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsrepeater_p.h
@@ -55,8 +55,8 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsRepeater : public QmlGraphicsItem
{
Q_OBJECT
- Q_PROPERTY(QVariant model READ model WRITE setModel)
- Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate)
+ Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
+ Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_CLASSINFO("DefaultProperty", "delegate")
@@ -73,8 +73,9 @@ public:
int count() const;
Q_SIGNALS:
+ void modelChanged();
+ void delegateChanged();
void countChanged();
-
private:
void clear();
void regenerate();
diff --git a/src/declarative/graphicsitems/qmlgraphicsscalegrid.cpp b/src/declarative/graphicsitems/qmlgraphicsscalegrid.cpp
index 58d6ab8..1956939 100644
--- a/src/declarative/graphicsitems/qmlgraphicsscalegrid.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsscalegrid.cpp
@@ -52,7 +52,6 @@ QT_BEGIN_NAMESPACE
\class QmlGraphicsScaleGrid
\brief The QmlGraphicsScaleGrid class allows you to specify a 3x3 grid to use in scaling an image.
*/
-QML_DEFINE_NOCREATE_TYPE(QmlGraphicsScaleGrid)
QmlGraphicsScaleGrid::QmlGraphicsScaleGrid(QObject *parent) : QObject(parent), _left(0), _top(0), _right(0), _bottom(0)
{
diff --git a/src/declarative/graphicsitems/qmlgraphicstext.cpp b/src/declarative/graphicsitems/qmlgraphicstext.cpp
index e9e5924..ab2f9a3 100644
--- a/src/declarative/graphicsitems/qmlgraphicstext.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicstext.cpp
@@ -55,7 +55,6 @@
#include <qmath.h>
QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(Qt,4,6,Text,QmlGraphicsText)
/*!
\qmlclass Text QmlGraphicsText
diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp
index e8cde10..3dadbe0 100644
--- a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp
@@ -56,7 +56,6 @@
#include <private/qtextcontrol_p.h>
QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(Qt,4,6,TextEdit,QmlGraphicsTextEdit)
/*!
\qmlclass TextEdit QmlGraphicsTextEdit
diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp
index a7b25c5..6b4407f 100644
--- a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp
@@ -51,12 +51,6 @@
QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(Qt,4,6,TextInput,QmlGraphicsTextInput);
-QML_DEFINE_NOCREATE_TYPE(QValidator);
-QML_DEFINE_TYPE(Qt,4,6,QIntValidator,QIntValidator);
-QML_DEFINE_TYPE(Qt,4,6,QDoubleValidator,QDoubleValidator);
-QML_DEFINE_TYPE(Qt,4,6,QRegExpValidator,QRegExpValidator);
-
/*!
\qmlclass TextInput QmlGraphicsTextInput
The TextInput item allows you to add an editable line of text to a scene.
@@ -652,10 +646,12 @@ void QmlGraphicsTextInput::focusChanged(bool hasFocus)
void QmlGraphicsTextInput::keyPressEvent(QKeyEvent* ev)
{
Q_D(QmlGraphicsTextInput);
- if((d->control->cursor() == 0 && ev->key() == Qt::Key_Left)
+ if(((d->control->cursor() == 0 && ev->key() == Qt::Key_Left)
|| (d->control->cursor() == d->control->text().length()
- && ev->key() == Qt::Key_Right)){
+ && ev->key() == Qt::Key_Right))
+ && (d->lastSelectionStart == d->lastSelectionEnd)){
//ignore when moving off the end
+ //unless there is a selection, because then moving will do something (deselect)
ev->ignore();
}else{
d->control->processKeyEvent(ev);
diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput_p.h b/src/declarative/graphicsitems/qmlgraphicstextinput_p.h
index 794661c..2b37b78 100644
--- a/src/declarative/graphicsitems/qmlgraphicstextinput_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicstextinput_p.h
@@ -222,8 +222,10 @@ QT_END_NAMESPACE
QML_DECLARE_TYPE(QmlGraphicsTextInput)
QML_DECLARE_TYPE(QValidator)
QML_DECLARE_TYPE(QIntValidator)
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
QML_DECLARE_TYPE(QDoubleValidator)
QML_DECLARE_TYPE(QRegExpValidator)
+#endif
QT_END_HEADER
diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
index f9ebef9..4ced2c3 100644
--- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
@@ -62,48 +62,8 @@
#include <private/qobject_p.h>
-QML_DECLARE_TYPE(QListModelInterface)
-
QT_BEGIN_NAMESPACE
-class QmlGraphicsVisualItemModelAttached : public QObject
-{
- Q_OBJECT
-
-public:
- QmlGraphicsVisualItemModelAttached(QObject *parent)
- : QObject(parent), m_index(0) {}
- ~QmlGraphicsVisualItemModelAttached() {
- attachedProperties.remove(parent());
- }
-
- Q_PROPERTY(int index READ index NOTIFY indexChanged)
- int index() const { return m_index; }
- void setIndex(int idx) {
- if (m_index != idx) {
- m_index = idx;
- emit indexChanged();
- }
- }
-
- static QmlGraphicsVisualItemModelAttached *properties(QObject *obj) {
- QmlGraphicsVisualItemModelAttached *rv = attachedProperties.value(obj);
- if (!rv) {
- rv = new QmlGraphicsVisualItemModelAttached(obj);
- attachedProperties.insert(obj, rv);
- }
- return rv;
- }
-
-Q_SIGNALS:
- void indexChanged();
-
-public:
- int m_index;
-
- static QHash<QObject*, QmlGraphicsVisualItemModelAttached*> attachedProperties;
-};
-
QHash<QObject*, QmlGraphicsVisualItemModelAttached*> QmlGraphicsVisualItemModelAttached::attachedProperties;
@@ -1146,10 +1106,8 @@ void QmlGraphicsVisualDataModel::_q_destroyingPackage(QmlPackage *package)
emit destroyingItem(qobject_cast<QmlGraphicsItem*>(package->part(d->m_part)));
}
-QML_DEFINE_NOCREATE_TYPE(QmlGraphicsVisualModel);
-QML_DEFINE_TYPE(Qt,4,6,VisualItemModel,QmlGraphicsVisualItemModel)
-QML_DEFINE_TYPE(Qt,4,6,VisualDataModel,QmlGraphicsVisualDataModel)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QListModelInterface)
+
#include <qmlgraphicsvisualitemmodel.moc>
diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h
index 3321472..c0ea499 100644
--- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h
@@ -195,6 +195,45 @@ private:
Q_DISABLE_COPY(QmlGraphicsVisualDataModel)
};
+class QmlGraphicsVisualItemModelAttached : public QObject
+{
+ Q_OBJECT
+
+public:
+ QmlGraphicsVisualItemModelAttached(QObject *parent)
+ : QObject(parent), m_index(0) {}
+ ~QmlGraphicsVisualItemModelAttached() {
+ attachedProperties.remove(parent());
+ }
+
+ Q_PROPERTY(int index READ index NOTIFY indexChanged)
+ int index() const { return m_index; }
+ void setIndex(int idx) {
+ if (m_index != idx) {
+ m_index = idx;
+ emit indexChanged();
+ }
+ }
+
+ static QmlGraphicsVisualItemModelAttached *properties(QObject *obj) {
+ QmlGraphicsVisualItemModelAttached *rv = attachedProperties.value(obj);
+ if (!rv) {
+ rv = new QmlGraphicsVisualItemModelAttached(obj);
+ attachedProperties.insert(obj, rv);
+ }
+ return rv;
+ }
+
+Q_SIGNALS:
+ void indexChanged();
+
+public:
+ int m_index;
+
+ static QHash<QObject*, QmlGraphicsVisualItemModelAttached*> attachedProperties;
+};
+
+
QT_END_NAMESPACE
QML_DECLARE_TYPE(QmlGraphicsVisualModel)
diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp
index a811506..515f896 100644
--- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicswebview.cpp
@@ -64,13 +64,9 @@
#include <qlistmodelinterface_p.h>
QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(Qt,4,6,WebView,QmlGraphicsWebView)
-QML_DEFINE_NOCREATE_TYPE(QAction)
static const int MAX_DOUBLECLICK_TIME=500; // XXX need better gesture system
-QML_DEFINE_NOCREATE_TYPE(QmlGraphicsWebSettings)
-
class QmlGraphicsWebViewPrivate : public QmlGraphicsPaintedItemPrivate
{
Q_DECLARE_PUBLIC(QmlGraphicsWebView)
@@ -461,30 +457,6 @@ QmlList<QObject *> *QmlGraphicsWebView::javaScriptWindowObjects()
return &d->windowObjects;
}
-class QmlGraphicsWebViewAttached : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QString windowObjectName READ windowObjectName WRITE setWindowObjectName)
-public:
- QmlGraphicsWebViewAttached(QObject *parent)
- : QObject(parent)
- {
- }
-
- QString windowObjectName() const
- {
- return m_windowObjectName;
- }
-
- void setWindowObjectName(const QString &n)
- {
- m_windowObjectName = n;
- }
-
-private:
- QString m_windowObjectName;
-};
-
QmlGraphicsWebViewAttached *QmlGraphicsWebView::qmlAttachedProperties(QObject *o)
{
return new QmlGraphicsWebViewAttached(o);
@@ -1111,7 +1083,8 @@ QmlGraphicsWebView *QmlGraphicsWebView::createWindow(QWebPage::WebWindowType typ
if (!webview) {
delete item;
} else {
- item->setParent(d->newWindowParent);
+ nobj->setParent(d->newWindowParent);
+ static_cast<QGraphicsObject*>(item)->setParentItem(d->newWindowParent);
}
}
} else {
diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p.h
index 2162716..1822ddb 100644
--- a/src/declarative/graphicsitems/qmlgraphicswebview_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicswebview_p.h
@@ -246,11 +246,35 @@ private:
friend class QmlGraphicsWebPage;
};
+class QmlGraphicsWebViewAttached : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString windowObjectName READ windowObjectName WRITE setWindowObjectName)
+public:
+ QmlGraphicsWebViewAttached(QObject *parent)
+ : QObject(parent)
+ {
+ }
+
+ QString windowObjectName() const
+ {
+ return m_windowObjectName;
+ }
+
+ void setWindowObjectName(const QString &n)
+ {
+ m_windowObjectName = n;
+ }
+
+private:
+ QString m_windowObjectName;
+};
+
+
QT_END_NAMESPACE
QML_DECLARE_TYPE(QmlGraphicsWebView)
QML_DECLARE_TYPEINFO(QmlGraphicsWebView, QML_HAS_ATTACHED_PROPERTIES)
-QML_DECLARE_TYPE(QAction)
QT_END_HEADER
diff --git a/src/declarative/qml/qml.h b/src/declarative/qml/qml.h
index 46eec67..e5e7c59 100644
--- a/src/declarative/qml/qml.h
+++ b/src/declarative/qml/qml.h
@@ -77,6 +77,7 @@ enum { /* TYPEINFO flags */
};
#define QML_DECLARE_TYPEINFO(TYPE, FLAGS) \
+QT_BEGIN_NAMESPACE \
template <> \
class QmlTypeInfo<TYPE > \
{ \
@@ -84,7 +85,8 @@ public: \
enum { \
hasAttachedProperties = (((FLAGS) & QML_HAS_ATTACHED_PROPERTIES) == QML_HAS_ATTACHED_PROPERTIES) \
}; \
-};
+}; \
+QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri
index cd2fbff..a8df61e 100644
--- a/src/declarative/qml/qml.pri
+++ b/src/declarative/qml/qml.pri
@@ -50,6 +50,7 @@ SOURCES += \
$$PWD/qmltypenamescriptclass.cpp \
$$PWD/qmllistscriptclass.cpp \
$$PWD/qmlworkerscript.cpp \
+ $$PWD/qmlimageprovider.cpp \
$$PWD/qmlnetworkaccessmanagerfactory.cpp
HEADERS += \
$$PWD/qmlparser_p.h \
@@ -75,8 +76,8 @@ HEADERS += \
$$PWD/qmlengine_p.h \
$$PWD/qmlexpression_p.h \
$$PWD/qmlprivate.h \
- $$PWD/qmldom.h \
$$PWD/qmldom_p.h \
+ $$PWD/qmldom_p_p.h \
$$PWD/qmlrefcount_p.h \
$$PWD/qmlmetatype.h \
$$PWD/qmlengine.h \
@@ -117,6 +118,7 @@ HEADERS += \
$$PWD/qmlworkerscript_p.h \
$$PWD/qmlscriptclass_p.h \
$$PWD/qmlguard_p.h \
+ $$PWD/qmlimageprovider.h \
$$PWD/qmlnetworkaccessmanagerfactory.h
QT += sql
include(parser/parser.pri)
diff --git a/src/declarative/qml/qmlbinding.cpp b/src/declarative/qml/qmlbinding.cpp
index c4be39e..0dbe63b 100644
--- a/src/declarative/qml/qmlbinding.cpp
+++ b/src/declarative/qml/qmlbinding.cpp
@@ -291,6 +291,12 @@ void QmlAbstractBinding::removeFromObject()
}
}
+void QmlAbstractBinding::clear()
+{
+ if (m_mePtr)
+ *m_mePtr = 0;
+}
+
QString QmlAbstractBinding::expression() const
{
return QLatin1String("<Unknown>");
diff --git a/src/declarative/qml/qmlbinding.h b/src/declarative/qml/qmlbinding.h
index 2b09414..151b71c 100644
--- a/src/declarative/qml/qmlbinding.h
+++ b/src/declarative/qml/qmlbinding.h
@@ -75,6 +75,9 @@ public:
void addToObject(QObject *);
void removeFromObject();
+protected:
+ void clear();
+
private:
friend class QmlDeclarativeData;
friend class QmlMetaProperty;
diff --git a/src/declarative/qml/qmlcleanup.cpp b/src/declarative/qml/qmlcleanup.cpp
index fc01a90..581d4a3 100644
--- a/src/declarative/qml/qmlcleanup.cpp
+++ b/src/declarative/qml/qmlcleanup.cpp
@@ -43,6 +43,8 @@
#include "qmlengine_p.h"
+QT_BEGIN_NAMESPACE
+
/*!
\internal
\class QmlCleanup
@@ -82,4 +84,4 @@ QmlCleanup::~QmlCleanup()
prev = 0;
next = 0;
}
-
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlcompiledbindings.cpp b/src/declarative/qml/qmlcompiledbindings.cpp
index fbf714d..7a8cf0e 100644
--- a/src/declarative/qml/qmlcompiledbindings.cpp
+++ b/src/declarative/qml/qmlcompiledbindings.cpp
@@ -39,6 +39,8 @@
**
****************************************************************************/
+// #define COMPILEDBINDINGS_DEBUG
+
#include "qmlcompiledbindings_p.h"
#include <QtDeclarative/qmlinfo.h>
@@ -275,6 +277,7 @@ void QmlCompiledBindingsPrivate::Binding::destroy()
enabled = false;
removeFromObject();
parent->q_func()->release();
+ clear();
}
int QmlCompiledBindings::qt_metacall(QMetaObject::Call c, int id, void **)
@@ -975,6 +978,147 @@ static void throwException(int id, QmlDelayedError *error,
qWarning() << error->error;
}
+static void dumpInstruction(const Instr *instr)
+{
+ switch (instr->common.type) {
+ case Instr::Noop:
+ qWarning().nospace() << "Noop";
+ break;
+ case Instr::Subscribe:
+ qWarning().nospace() << "Subscribe" << "\t\t" << instr->subscribe.offset << "\t" << instr->subscribe.reg << "\t" << instr->subscribe.index;
+ break;
+ case Instr::SubscribeId:
+ qWarning().nospace() << "SubscribeId" << "\t\t" << instr->subscribe.offset << "\t" << instr->subscribe.reg << "\t" << instr->subscribe.index;
+ break;
+ case Instr::LoadId:
+ qWarning().nospace() << "LoadId" << "\t\t\t" << instr->load.index << "\t" << instr->load.reg;
+ break;
+ case Instr::LoadScope:
+ qWarning().nospace() << "LoadScope" << "\t\t" << instr->load.index << "\t" << instr->load.reg;
+ break;
+ case Instr::LoadRoot:
+ qWarning().nospace() << "LoadRoot" << "\t\t" << instr->load.index << "\t" << instr->load.reg;
+ break;
+ case Instr::LoadAttached:
+ qWarning().nospace() << "LoadAttached" << "\t\t" << instr->attached.output << "\t" << instr->attached.reg << "\t" << instr->attached.index;
+ break;
+ case Instr::ConvertIntToReal:
+ qWarning().nospace() << "ConvertIntToReal" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
+ break;
+ case Instr::ConvertRealToInt:
+ qWarning().nospace() << "ConvertRealToInt" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
+ break;
+ case Instr::Real:
+ qWarning().nospace() << "Real" << "\t\t\t" << instr->real_value.reg << "\t" << instr->real_value.value;
+ break;
+ case Instr::Int:
+ qWarning().nospace() << "Int" << "\t\t\t" << instr->int_value.reg << "\t" << instr->int_value.value;
+ break;
+ case Instr::Bool:
+ qWarning().nospace() << "Bool" << "\t\t\t" << instr->bool_value.reg << "\t" << instr->bool_value.value;
+ break;
+ case Instr::String:
+ qWarning().nospace() << "String" << "\t\t\t" << instr->string_value.reg << "\t" << instr->string_value.offset << "\t" << instr->string_value.length;
+ break;
+ case Instr::AddReal:
+ qWarning().nospace() << "AddReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::AddInt:
+ qWarning().nospace() << "AddInt" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::AddString:
+ qWarning().nospace() << "AddString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::MinusReal:
+ qWarning().nospace() << "MinusReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::MinusInt:
+ qWarning().nospace() << "MinusInt" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::CompareReal:
+ qWarning().nospace() << "CompareReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::CompareString:
+ qWarning().nospace() << "CompareString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::NotCompareReal:
+ qWarning().nospace() << "NotCompareReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::NotCompareString:
+ qWarning().nospace() << "NotCompareString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::GreaterThanReal:
+ qWarning().nospace() << "GreaterThanReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::MaxReal:
+ qWarning().nospace() << "MaxReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::MinReal:
+ qWarning().nospace() << "MinReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
+ break;
+ case Instr::NewString:
+ qWarning().nospace() << "NewString" << "\t\t" << instr->construct.reg;
+ break;
+ case Instr::NewUrl:
+ qWarning().nospace() << "NewUrl" << "\t\t\t" << instr->construct.reg;
+ break;
+ case Instr::CleanupString:
+ qWarning().nospace() << "CleanupString" << "\t\t" << instr->cleanup.reg;
+ break;
+ case Instr::CleanupUrl:
+ qWarning().nospace() << "CleanupUrl" << "\t\t" << instr->cleanup.reg;
+ break;
+ case Instr::Fetch:
+ qWarning().nospace() << "Fetch" << "\t\t\t" << instr->fetch.output << "\t" << instr->fetch.index << "\t" << instr->fetch.objectReg;
+ break;
+ case Instr::Store:
+ qWarning().nospace() << "Store" << "\t\t\t" << instr->store.output << "\t" << instr->store.index << "\t" << instr->store.reg;
+ break;
+ case Instr::Copy:
+ qWarning().nospace() << "Copy" << "\t\t\t" << instr->copy.reg << "\t" << instr->copy.src;
+ break;
+ case Instr::Skip:
+ qWarning().nospace() << "Skip" << "\t\t\t" << instr->skip.reg << "\t" << instr->skip.count;
+ break;
+ case Instr::Done:
+ qWarning().nospace() << "Done";
+ break;
+ case Instr::InitString:
+ qWarning().nospace() << "InitString" << "\t\t" << instr->initstring.offset << "\t" << instr->initstring.dataIdx;
+ break;
+ case Instr::FindGeneric:
+ qWarning().nospace() << "FindGeneric" << "\t\t" << instr->find.reg << "\t" << instr->find.name;
+ break;
+ case Instr::FindGenericTerminal:
+ qWarning().nospace() << "FindGenericTerminal" << "\t" << instr->find.reg << "\t" << instr->find.name;
+ break;
+ case Instr::FindProperty:
+ qWarning().nospace() << "FindProperty" << "\t\t" << instr->find.reg << "\t" << instr->find.src << "\t" << instr->find.name;
+ break;
+ case Instr::FindPropertyTerminal:
+ qWarning().nospace() << "FindPropertyTerminal" << "\t" << instr->find.reg << "\t" << instr->find.src << "\t" << instr->find.name;
+ break;
+ case Instr::CleanupGeneric:
+ qWarning().nospace() << "CleanupGeneric" << "\t\t" << instr->cleanup.reg;
+ break;
+ case Instr::ConvertGenericToReal:
+ qWarning().nospace() << "ConvertGenericToReal" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
+ break;
+ case Instr::ConvertGenericToBool:
+ qWarning().nospace() << "ConvertGenericToBool" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
+ break;
+ case Instr::ConvertGenericToString:
+ qWarning().nospace() << "ConvertGenericToString" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
+ break;
+ case Instr::ConvertGenericToUrl:
+ qWarning().nospace() << "ConvertGenericToUrl" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
+ break;
+ default:
+ qWarning().nospace() << "Unknown";
+ break;
+ }
+}
+
void QmlCompiledBindingsPrivate::run(int instrIndex,
QmlContextPrivate *context, QmlDelayedError *error,
QObject *scope, QObject *output)
@@ -990,7 +1134,14 @@ void QmlCompiledBindingsPrivate::run(int instrIndex,
instr += instrIndex;
const char *data = program->data();
+#ifdef COMPILEDBINDINGS_DEBUG
+ qWarning().nospace() << "Begin binding run";
+#endif
+
while (instr) {
+#ifdef COMPILEDBINDINGS_DEBUG
+ dumpInstruction(instr);
+#endif
switch (instr->common.type) {
case Instr::Noop:
@@ -1403,144 +1554,7 @@ void QmlBindingCompiler::dump(const QByteArray &programData)
while (count--) {
- switch (instr->common.type) {
- case Instr::Noop:
- qWarning().nospace() << "Noop";
- break;
- case Instr::Subscribe:
- qWarning().nospace() << "Subscribe" << "\t\t" << instr->subscribe.offset << "\t" << instr->subscribe.reg << "\t" << instr->subscribe.index;
- break;
- case Instr::SubscribeId:
- qWarning().nospace() << "SubscribeId" << "\t\t" << instr->subscribe.offset << "\t" << instr->subscribe.reg << "\t" << instr->subscribe.index;
- break;
- case Instr::LoadId:
- qWarning().nospace() << "LoadId" << "\t\t\t" << instr->load.index << "\t" << instr->load.reg;
- break;
- case Instr::LoadScope:
- qWarning().nospace() << "LoadScope" << "\t\t" << instr->load.index << "\t" << instr->load.reg;
- break;
- case Instr::LoadRoot:
- qWarning().nospace() << "LoadRoot" << "\t\t" << instr->load.index << "\t" << instr->load.reg;
- break;
- case Instr::LoadAttached:
- qWarning().nospace() << "LoadAttached" << "\t\t" << instr->attached.output << "\t" << instr->attached.reg << "\t" << instr->attached.index;
- break;
- case Instr::ConvertIntToReal:
- qWarning().nospace() << "ConvertIntToReal" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
- break;
- case Instr::ConvertRealToInt:
- qWarning().nospace() << "ConvertRealToInt" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
- break;
- case Instr::Real:
- qWarning().nospace() << "Real" << "\t\t\t" << instr->real_value.reg << "\t" << instr->real_value.value;
- break;
- case Instr::Int:
- qWarning().nospace() << "Int" << "\t\t\t" << instr->int_value.reg << "\t" << instr->int_value.value;
- break;
- case Instr::Bool:
- qWarning().nospace() << "Bool" << "\t\t\t" << instr->bool_value.reg << "\t" << instr->bool_value.value;
- break;
- case Instr::String:
- qWarning().nospace() << "String" << "\t\t\t" << instr->string_value.reg << "\t" << instr->string_value.offset << "\t" << instr->string_value.length;
- break;
- case Instr::AddReal:
- qWarning().nospace() << "AddReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::AddInt:
- qWarning().nospace() << "AddInt" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::AddString:
- qWarning().nospace() << "AddString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::MinusReal:
- qWarning().nospace() << "MinusReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::MinusInt:
- qWarning().nospace() << "MinusInt" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::CompareReal:
- qWarning().nospace() << "CompareReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::CompareString:
- qWarning().nospace() << "CompareString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::NotCompareReal:
- qWarning().nospace() << "NotCompareReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::NotCompareString:
- qWarning().nospace() << "NotCompareString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::GreaterThanReal:
- qWarning().nospace() << "GreaterThanReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::MaxReal:
- qWarning().nospace() << "MaxReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::MinReal:
- qWarning().nospace() << "MinReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2;
- break;
- case Instr::NewString:
- qWarning().nospace() << "NewString" << "\t\t" << instr->construct.reg;
- break;
- case Instr::NewUrl:
- qWarning().nospace() << "NewUrl" << "\t\t\t" << instr->construct.reg;
- break;
- case Instr::CleanupString:
- qWarning().nospace() << "CleanupString" << "\t\t" << instr->cleanup.reg;
- break;
- case Instr::CleanupUrl:
- qWarning().nospace() << "CleanupUrl" << "\t\t" << instr->cleanup.reg;
- break;
- case Instr::Fetch:
- qWarning().nospace() << "Fetch" << "\t\t\t" << instr->fetch.output << "\t" << instr->fetch.index << "\t" << instr->fetch.objectReg;
- break;
- case Instr::Store:
- qWarning().nospace() << "Store" << "\t\t\t" << instr->store.output << "\t" << instr->store.index << "\t" << instr->store.reg;
- break;
- case Instr::Copy:
- qWarning().nospace() << "Copy" << "\t\t\t" << instr->copy.reg << "\t" << instr->copy.src;
- break;
- case Instr::Skip:
- qWarning().nospace() << "Skip" << "\t\t\t" << instr->skip.reg << "\t" << instr->skip.count;
- break;
- case Instr::Done:
- qWarning().nospace() << "Done";
- break;
- case Instr::InitString:
- qWarning().nospace() << "InitString" << "\t\t" << instr->initstring.offset << "\t" << instr->initstring.dataIdx;
- break;
- case Instr::FindGeneric:
- qWarning().nospace() << "FindGeneric" << "\t\t" << instr->find.reg << "\t" << instr->find.name;
- break;
- case Instr::FindGenericTerminal:
- qWarning().nospace() << "FindGenericTerminal" << "\t" << instr->find.reg << "\t" << instr->find.name;
- break;
- case Instr::FindProperty:
- qWarning().nospace() << "FindProperty" << "\t\t" << instr->find.reg << "\t" << instr->find.src << "\t" << instr->find.name;
- break;
- case Instr::FindPropertyTerminal:
- qWarning().nospace() << "FindPropertyTerminal" << "\t" << instr->find.reg << "\t" << instr->find.src << "\t" << instr->find.name;
- break;
- case Instr::CleanupGeneric:
- qWarning().nospace() << "CleanupGeneric" << "\t\t" << instr->cleanup.reg;
- break;
- case Instr::ConvertGenericToReal:
- qWarning().nospace() << "ConvertGenericToReal" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
- break;
- case Instr::ConvertGenericToBool:
- qWarning().nospace() << "ConvertGenericToBool" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
- break;
- case Instr::ConvertGenericToString:
- qWarning().nospace() << "ConvertGenericToString" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
- break;
- case Instr::ConvertGenericToUrl:
- qWarning().nospace() << "ConvertGenericToUrl" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src;
- break;
- default:
- qWarning().nospace() << "Unknown";
- break;
- }
-
+ dumpInstruction(instr);
++instr;
}
}
@@ -1585,6 +1599,9 @@ bool QmlBindingCompilerPrivate::compile(QmlJS::AST::Node *node)
{
resetInstanceState();
+ if (destination->type == -1)
+ return false;
+
Result type;
if (!parseExpression(node, type))
@@ -1864,7 +1881,8 @@ bool QmlBindingCompilerPrivate::parseName(AST::Node *node, Result &type)
subscribeName << contextName();
subscribeName << name;
- fetch(type, context->metaObject(), reg, d0Idx, subscribeName, nameNodes.at(ii));
+ if (!fetch(type, context->metaObject(), reg, d0Idx, subscribeName, nameNodes.at(ii)))
+ return false;
} else if(d1Idx != -1) {
Instr instr;
instr.common.type = Instr::LoadRoot;
@@ -1875,7 +1893,8 @@ bool QmlBindingCompilerPrivate::parseName(AST::Node *node, Result &type)
subscribeName << QLatin1String("$$$ROOT");
subscribeName << name;
- fetch(type, component->metaObject(), reg, d1Idx, subscribeName, nameNodes.at(ii));
+ if (!fetch(type, component->metaObject(), reg, d1Idx, subscribeName, nameNodes.at(ii)))
+ return false;
} else {
Instr find;
if (nameParts.count() == 1)
@@ -1935,8 +1954,7 @@ bool QmlBindingCompilerPrivate::parseName(AST::Node *node, Result &type)
if (absType || (wasAttachedObject && idx != -1) || (mo && mo->property(idx).isFinal())) {
absType = 0;
- fetch(type, mo, reg, idx, subscribeName, nameNodes.at(ii));
- if (type.type == -1)
+ if (!fetch(type, mo, reg, idx, subscribeName, nameNodes.at(ii)))
return false;
} else {
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index f15c364..87ecb8a 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -539,7 +539,6 @@ QObject *QmlComponent::create(QmlContext *context)
QObject *QmlComponentPrivate::create(QmlContext *context,
const QBitField &bindings)
{
- QObject *create(QmlContext *context, const QBitField &);
if (!context)
context = engine->rootContext();
diff --git a/src/declarative/qml/qmlcompositetypedata_p.h b/src/declarative/qml/qmlcompositetypedata_p.h
index e4e8007..342c88a 100644
--- a/src/declarative/qml/qmlcompositetypedata_p.h
+++ b/src/declarative/qml/qmlcompositetypedata_p.h
@@ -146,5 +146,7 @@ public:
QByteArray data;
};
+QT_END_NAMESPACE
+
#endif // QMLCOMPOSITETYPEDATA_P_H
diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp
index 4011d8d..303af42 100644
--- a/src/declarative/qml/qmlcontext.cpp
+++ b/src/declarative/qml/qmlcontext.cpp
@@ -300,8 +300,6 @@ QmlContext::~QmlContext()
co->prevContextObject = 0;
}
- delete [] d->idValues;
-
if (d->propertyNames)
d->propertyNames->release();
@@ -310,6 +308,8 @@ QmlContext::~QmlContext()
if (d->optimizedBindings)
d->optimizedBindings->release();
+
+ delete [] d->idValues;
}
void QmlContextPrivate::invalidateEngines()
diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp
index c4eb062..01061ee 100644
--- a/src/declarative/qml/qmldom.cpp
+++ b/src/declarative/qml/qmldom.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#include "qmldom.h"
#include "qmldom_p.h"
+#include "qmldom_p_p.h"
#include "qmlcompositetypedata_p.h"
#include "qmlcompiler_p.h"
diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h
deleted file mode 100644
index 98c5eb8..0000000
--- a/src/declarative/qml/qmldom.h
+++ /dev/null
@@ -1,349 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMLDOM_H
-#define QMLDOM_H
-
-#include "qmlerror.h"
-
-#include <QtCore/qlist.h>
-#include <QtCore/qshareddata.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QString;
-class QByteArray;
-class QmlDomObject;
-class QmlDomList;
-class QmlDomValue;
-class QmlEngine;
-class QmlDomComponent;
-class QmlDomImport;
-class QIODevice;
-
-class QmlDomDocumentPrivate;
-
-class Q_DECLARATIVE_EXPORT QmlDomDocument
-{
-public:
- QmlDomDocument();
- QmlDomDocument(const QmlDomDocument &);
- ~QmlDomDocument();
- QmlDomDocument &operator=(const QmlDomDocument &);
-
- QList<QmlDomImport> imports() const;
-
- QList<QmlError> errors() const;
- bool load(QmlEngine *, const QByteArray &, const QUrl & = QUrl());
-
- QmlDomObject rootObject() const;
-
-private:
- QSharedDataPointer<QmlDomDocumentPrivate> d;
-};
-
-class QmlDomPropertyPrivate;
-class Q_DECLARATIVE_EXPORT QmlDomProperty
-{
-public:
- QmlDomProperty();
- QmlDomProperty(const QmlDomProperty &);
- ~QmlDomProperty();
- QmlDomProperty &operator=(const QmlDomProperty &);
-
- bool isValid() const;
-
- QByteArray propertyName() const;
- QList<QByteArray> propertyNameParts() const;
-
- bool isDefaultProperty() const;
-
- QmlDomValue value() const;
-
- int position() const;
- int length() const;
-
-private:
- friend class QmlDomObject;
- friend class QmlDomDynamicProperty;
- QSharedDataPointer<QmlDomPropertyPrivate> d;
-};
-
-class QmlDomDynamicPropertyPrivate;
-class Q_DECLARATIVE_EXPORT QmlDomDynamicProperty
-{
-public:
- QmlDomDynamicProperty();
- QmlDomDynamicProperty(const QmlDomDynamicProperty &);
- ~QmlDomDynamicProperty();
- QmlDomDynamicProperty &operator=(const QmlDomDynamicProperty &);
-
- bool isValid() const;
-
- QByteArray propertyName() const;
- int propertyType() const;
- QByteArray propertyTypeName() const;
-
- bool isDefaultProperty() const;
- QmlDomProperty defaultValue() const;
-
- bool isAlias() const;
-
- int position() const;
- int length() const;
-
-private:
- friend class QmlDomObject;
- QSharedDataPointer<QmlDomDynamicPropertyPrivate> d;
-};
-
-class QmlDomObjectPrivate;
-class Q_DECLARATIVE_EXPORT QmlDomObject
-{
-public:
- QmlDomObject();
- QmlDomObject(const QmlDomObject &);
- ~QmlDomObject();
- QmlDomObject &operator=(const QmlDomObject &);
-
- bool isValid() const;
-
- QByteArray objectType() const;
- QByteArray objectClassName() const;
-
- int objectTypeMajorVersion() const;
- int objectTypeMinorVersion() const;
-
- QString objectId() const;
-
- QList<QmlDomProperty> properties() const;
- QmlDomProperty property(const QByteArray &) const;
-
- QList<QmlDomDynamicProperty> dynamicProperties() const;
- QmlDomDynamicProperty dynamicProperty(const QByteArray &) const;
-
- bool isCustomType() const;
- QByteArray customTypeData() const;
-
- bool isComponent() const;
- QmlDomComponent toComponent() const;
-
- int position() const;
- int length() const;
-
- QUrl url() const;
-private:
- friend class QmlDomDocument;
- friend class QmlDomComponent;
- friend class QmlDomValue;
- friend class QmlDomValueValueSource;
- friend class QmlDomValueValueInterceptor;
- QSharedDataPointer<QmlDomObjectPrivate> d;
-};
-
-class QmlDomValuePrivate;
-class QmlDomBasicValuePrivate;
-class Q_DECLARATIVE_EXPORT QmlDomValueLiteral
-{
-public:
- QmlDomValueLiteral();
- QmlDomValueLiteral(const QmlDomValueLiteral &);
- ~QmlDomValueLiteral();
- QmlDomValueLiteral &operator=(const QmlDomValueLiteral &);
-
- QString literal() const;
-
-private:
- friend class QmlDomValue;
- QSharedDataPointer<QmlDomBasicValuePrivate> d;
-};
-
-class Q_DECLARATIVE_EXPORT QmlDomValueBinding
-{
-public:
- QmlDomValueBinding();
- QmlDomValueBinding(const QmlDomValueBinding &);
- ~QmlDomValueBinding();
- QmlDomValueBinding &operator=(const QmlDomValueBinding &);
-
- QString binding() const;
-
-private:
- friend class QmlDomValue;
- QSharedDataPointer<QmlDomBasicValuePrivate> d;
-};
-
-class Q_DECLARATIVE_EXPORT QmlDomValueValueSource
-{
-public:
- QmlDomValueValueSource();
- QmlDomValueValueSource(const QmlDomValueValueSource &);
- ~QmlDomValueValueSource();
- QmlDomValueValueSource &operator=(const QmlDomValueValueSource &);
-
- QmlDomObject object() const;
-
-private:
- friend class QmlDomValue;
- QSharedDataPointer<QmlDomBasicValuePrivate> d;
-};
-
-class Q_DECLARATIVE_EXPORT QmlDomValueValueInterceptor
-{
-public:
- QmlDomValueValueInterceptor();
- QmlDomValueValueInterceptor(const QmlDomValueValueInterceptor &);
- ~QmlDomValueValueInterceptor();
- QmlDomValueValueInterceptor &operator=(const QmlDomValueValueInterceptor &);
-
- QmlDomObject object() const;
-
-private:
- friend class QmlDomValue;
- QSharedDataPointer<QmlDomBasicValuePrivate> d;
-};
-
-
-class Q_DECLARATIVE_EXPORT QmlDomComponent : public QmlDomObject
-{
-public:
- QmlDomComponent();
- QmlDomComponent(const QmlDomComponent &);
- ~QmlDomComponent();
- QmlDomComponent &operator=(const QmlDomComponent &);
-
- QmlDomObject componentRoot() const;
-};
-
-class Q_DECLARATIVE_EXPORT QmlDomValue
-{
-public:
- enum Type {
- Invalid,
- Literal,
- PropertyBinding,
- ValueSource,
- ValueInterceptor,
- Object,
- List
- };
-
- QmlDomValue();
- QmlDomValue(const QmlDomValue &);
- ~QmlDomValue();
- QmlDomValue &operator=(const QmlDomValue &);
-
- Type type() const;
-
- bool isInvalid() const;
- bool isLiteral() const;
- bool isBinding() const;
- bool isValueSource() const;
- bool isValueInterceptor() const;
- bool isObject() const;
- bool isList() const;
-
- QmlDomValueLiteral toLiteral() const;
- QmlDomValueBinding toBinding() const;
- QmlDomValueValueSource toValueSource() const;
- QmlDomValueValueInterceptor toValueInterceptor() const;
- QmlDomObject toObject() const;
- QmlDomList toList() const;
-
- int position() const;
- int length() const;
-
-private:
- friend class QmlDomProperty;
- friend class QmlDomList;
- QSharedDataPointer<QmlDomValuePrivate> d;
-};
-
-class Q_DECLARATIVE_EXPORT QmlDomList
-{
-public:
- QmlDomList();
- QmlDomList(const QmlDomList &);
- ~QmlDomList();
- QmlDomList &operator=(const QmlDomList &);
-
- QList<QmlDomValue> values() const;
-
- int position() const;
- int length() const;
-
- QList<int> commaPositions() const;
-
-private:
- friend class QmlDomValue;
- QSharedDataPointer<QmlDomValuePrivate> d;
-};
-
-class QmlDomImportPrivate;
-class Q_DECLARATIVE_EXPORT QmlDomImport
-{
-public:
- enum Type { Library, File };
-
- QmlDomImport();
- QmlDomImport(const QmlDomImport &);
- ~QmlDomImport();
- QmlDomImport &operator=(const QmlDomImport &);
-
- Type type() const;
- QString uri() const;
- QString version() const;
- QString qualifier() const;
-
-private:
- friend class QmlDomDocument;
- QSharedDataPointer<QmlDomImportPrivate> d;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMLDOM_H
diff --git a/src/declarative/qml/qmldom_p.h b/src/declarative/qml/qmldom_p.h
index 4ddb9b0..8c7288e 100644
--- a/src/declarative/qml/qmldom_p.h
+++ b/src/declarative/qml/qmldom_p.h
@@ -53,105 +53,308 @@
// We mean it.
//
-#include "qmlparser_p.h"
+#include "qmlerror.h"
-#include <QtCore/QtGlobal>
+#include <QtCore/qlist.h>
+#include <QtCore/qshareddata.h>
+
+QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-class QmlDomDocumentPrivate : public QSharedData
+QT_MODULE(Declarative)
+
+class QString;
+class QByteArray;
+class QmlDomObject;
+class QmlDomList;
+class QmlDomValue;
+class QmlEngine;
+class QmlDomComponent;
+class QmlDomImport;
+class QIODevice;
+
+class QmlDomDocumentPrivate;
+
+class Q_DECLARATIVE_EXPORT QmlDomDocument
{
public:
- QmlDomDocumentPrivate();
- QmlDomDocumentPrivate(const QmlDomDocumentPrivate &o)
- : QSharedData(o) { qFatal("Not impl"); }
- ~QmlDomDocumentPrivate();
-
- QList<QmlError> errors;
- QList<QmlDomImport> imports;
- QmlParser::Object *root;
- QList<int> automaticSemicolonOffsets;
+ QmlDomDocument();
+ QmlDomDocument(const QmlDomDocument &);
+ ~QmlDomDocument();
+ QmlDomDocument &operator=(const QmlDomDocument &);
+
+ QList<QmlDomImport> imports() const;
+
+ QList<QmlError> errors() const;
+ bool load(QmlEngine *, const QByteArray &, const QUrl & = QUrl());
+
+ QmlDomObject rootObject() const;
+
+private:
+ QSharedDataPointer<QmlDomDocumentPrivate> d;
+};
+
+class QmlDomPropertyPrivate;
+class Q_DECLARATIVE_EXPORT QmlDomProperty
+{
+public:
+ QmlDomProperty();
+ QmlDomProperty(const QmlDomProperty &);
+ ~QmlDomProperty();
+ QmlDomProperty &operator=(const QmlDomProperty &);
+
+ bool isValid() const;
+
+ QByteArray propertyName() const;
+ QList<QByteArray> propertyNameParts() const;
+
+ bool isDefaultProperty() const;
+
+ QmlDomValue value() const;
+
+ int position() const;
+ int length() const;
+
+private:
+ friend class QmlDomObject;
+ friend class QmlDomDynamicProperty;
+ QSharedDataPointer<QmlDomPropertyPrivate> d;
};
-class QmlDomObjectPrivate : public QSharedData
+class QmlDomDynamicPropertyPrivate;
+class Q_DECLARATIVE_EXPORT QmlDomDynamicProperty
{
public:
- QmlDomObjectPrivate();
- QmlDomObjectPrivate(const QmlDomObjectPrivate &o)
- : QSharedData(o) { qFatal("Not impl"); }
- ~QmlDomObjectPrivate();
+ QmlDomDynamicProperty();
+ QmlDomDynamicProperty(const QmlDomDynamicProperty &);
+ ~QmlDomDynamicProperty();
+ QmlDomDynamicProperty &operator=(const QmlDomDynamicProperty &);
+
+ bool isValid() const;
+
+ QByteArray propertyName() const;
+ int propertyType() const;
+ QByteArray propertyTypeName() const;
+
+ bool isDefaultProperty() const;
+ QmlDomProperty defaultValue() const;
+
+ bool isAlias() const;
- typedef QList<QPair<QmlParser::Property *, QByteArray> > Properties;
- Properties properties() const;
- Properties properties(QmlParser::Property *) const;
+ int position() const;
+ int length() const;
- QmlParser::Object *object;
+private:
+ friend class QmlDomObject;
+ QSharedDataPointer<QmlDomDynamicPropertyPrivate> d;
};
-class QmlDomPropertyPrivate : public QSharedData
+class QmlDomObjectPrivate;
+class Q_DECLARATIVE_EXPORT QmlDomObject
{
public:
- QmlDomPropertyPrivate();
- QmlDomPropertyPrivate(const QmlDomPropertyPrivate &o)
- : QSharedData(o) { qFatal("Not impl"); }
- ~QmlDomPropertyPrivate();
+ QmlDomObject();
+ QmlDomObject(const QmlDomObject &);
+ ~QmlDomObject();
+ QmlDomObject &operator=(const QmlDomObject &);
+
+ bool isValid() const;
+
+ QByteArray objectType() const;
+ QByteArray objectClassName() const;
+
+ int objectTypeMajorVersion() const;
+ int objectTypeMinorVersion() const;
+
+ QString objectId() const;
- QByteArray propertyName;
- QmlParser::Property *property;
+ QList<QmlDomProperty> properties() const;
+ QmlDomProperty property(const QByteArray &) const;
+
+ QList<QmlDomDynamicProperty> dynamicProperties() const;
+ QmlDomDynamicProperty dynamicProperty(const QByteArray &) const;
+
+ bool isCustomType() const;
+ QByteArray customTypeData() const;
+
+ bool isComponent() const;
+ QmlDomComponent toComponent() const;
+
+ int position() const;
+ int length() const;
+
+ QUrl url() const;
+private:
+ friend class QmlDomDocument;
+ friend class QmlDomComponent;
+ friend class QmlDomValue;
+ friend class QmlDomValueValueSource;
+ friend class QmlDomValueValueInterceptor;
+ QSharedDataPointer<QmlDomObjectPrivate> d;
};
-class QmlDomDynamicPropertyPrivate : public QSharedData
+class QmlDomValuePrivate;
+class QmlDomBasicValuePrivate;
+class Q_DECLARATIVE_EXPORT QmlDomValueLiteral
{
public:
- QmlDomDynamicPropertyPrivate();
- QmlDomDynamicPropertyPrivate(const QmlDomDynamicPropertyPrivate &o)
- : QSharedData(o) { qFatal("Not impl"); }
- ~QmlDomDynamicPropertyPrivate();
+ QmlDomValueLiteral();
+ QmlDomValueLiteral(const QmlDomValueLiteral &);
+ ~QmlDomValueLiteral();
+ QmlDomValueLiteral &operator=(const QmlDomValueLiteral &);
+
+ QString literal() const;
- bool valid;
- QmlParser::Object::DynamicProperty property;
+private:
+ friend class QmlDomValue;
+ QSharedDataPointer<QmlDomBasicValuePrivate> d;
};
-class QmlDomValuePrivate : public QSharedData
+class Q_DECLARATIVE_EXPORT QmlDomValueBinding
{
public:
- QmlDomValuePrivate();
- QmlDomValuePrivate(const QmlDomValuePrivate &o)
- : QSharedData(o) { qFatal("Not impl"); }
- ~QmlDomValuePrivate();
+ QmlDomValueBinding();
+ QmlDomValueBinding(const QmlDomValueBinding &);
+ ~QmlDomValueBinding();
+ QmlDomValueBinding &operator=(const QmlDomValueBinding &);
- QmlParser::Property *property;
- QmlParser::Value *value;
+ QString binding() const;
+
+private:
+ friend class QmlDomValue;
+ QSharedDataPointer<QmlDomBasicValuePrivate> d;
};
-class QmlDomBasicValuePrivate : public QSharedData
+class Q_DECLARATIVE_EXPORT QmlDomValueValueSource
{
public:
- QmlDomBasicValuePrivate();
- QmlDomBasicValuePrivate(const QmlDomBasicValuePrivate &o)
- : QSharedData(o) { qFatal("Not impl"); }
- ~QmlDomBasicValuePrivate();
+ QmlDomValueValueSource();
+ QmlDomValueValueSource(const QmlDomValueValueSource &);
+ ~QmlDomValueValueSource();
+ QmlDomValueValueSource &operator=(const QmlDomValueValueSource &);
+
+ QmlDomObject object() const;
- QmlParser::Value *value;
+private:
+ friend class QmlDomValue;
+ QSharedDataPointer<QmlDomBasicValuePrivate> d;
};
-class QmlDomImportPrivate : public QSharedData
+class Q_DECLARATIVE_EXPORT QmlDomValueValueInterceptor
{
public:
- QmlDomImportPrivate();
- QmlDomImportPrivate(const QmlDomImportPrivate &o)
- : QSharedData(o) { qFatal("Not impl"); }
- ~QmlDomImportPrivate();
+ QmlDomValueValueInterceptor();
+ QmlDomValueValueInterceptor(const QmlDomValueValueInterceptor &);
+ ~QmlDomValueValueInterceptor();
+ QmlDomValueValueInterceptor &operator=(const QmlDomValueValueInterceptor &);
+ QmlDomObject object() const;
+
+private:
+ friend class QmlDomValue;
+ QSharedDataPointer<QmlDomBasicValuePrivate> d;
+};
+
+
+class Q_DECLARATIVE_EXPORT QmlDomComponent : public QmlDomObject
+{
+public:
+ QmlDomComponent();
+ QmlDomComponent(const QmlDomComponent &);
+ ~QmlDomComponent();
+ QmlDomComponent &operator=(const QmlDomComponent &);
+
+ QmlDomObject componentRoot() const;
+};
+
+class Q_DECLARATIVE_EXPORT QmlDomValue
+{
+public:
+ enum Type {
+ Invalid,
+ Literal,
+ PropertyBinding,
+ ValueSource,
+ ValueInterceptor,
+ Object,
+ List
+ };
+
+ QmlDomValue();
+ QmlDomValue(const QmlDomValue &);
+ ~QmlDomValue();
+ QmlDomValue &operator=(const QmlDomValue &);
+
+ Type type() const;
+
+ bool isInvalid() const;
+ bool isLiteral() const;
+ bool isBinding() const;
+ bool isValueSource() const;
+ bool isValueInterceptor() const;
+ bool isObject() const;
+ bool isList() const;
+
+ QmlDomValueLiteral toLiteral() const;
+ QmlDomValueBinding toBinding() const;
+ QmlDomValueValueSource toValueSource() const;
+ QmlDomValueValueInterceptor toValueInterceptor() const;
+ QmlDomObject toObject() const;
+ QmlDomList toList() const;
+
+ int position() const;
+ int length() const;
+
+private:
+ friend class QmlDomProperty;
+ friend class QmlDomList;
+ QSharedDataPointer<QmlDomValuePrivate> d;
+};
+
+class Q_DECLARATIVE_EXPORT QmlDomList
+{
+public:
+ QmlDomList();
+ QmlDomList(const QmlDomList &);
+ ~QmlDomList();
+ QmlDomList &operator=(const QmlDomList &);
+
+ QList<QmlDomValue> values() const;
+
+ int position() const;
+ int length() const;
+
+ QList<int> commaPositions() const;
+
+private:
+ friend class QmlDomValue;
+ QSharedDataPointer<QmlDomValuePrivate> d;
+};
+
+class QmlDomImportPrivate;
+class Q_DECLARATIVE_EXPORT QmlDomImport
+{
+public:
enum Type { Library, File };
- Type type;
- QString uri;
- QString version;
- QString qualifier;
+ QmlDomImport();
+ QmlDomImport(const QmlDomImport &);
+ ~QmlDomImport();
+ QmlDomImport &operator=(const QmlDomImport &);
+
+ Type type() const;
+ QString uri() const;
+ QString version() const;
+ QString qualifier() const;
+
+private:
+ friend class QmlDomDocument;
+ QSharedDataPointer<QmlDomImportPrivate> d;
};
QT_END_NAMESPACE
-#endif // QMLDOM_P_H
+QT_END_HEADER
+#endif // QMLDOM_P_H
diff --git a/src/declarative/qml/qmldom_p_p.h b/src/declarative/qml/qmldom_p_p.h
new file mode 100644
index 0000000..9d955b0
--- /dev/null
+++ b/src/declarative/qml/qmldom_p_p.h
@@ -0,0 +1,157 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLDOM_P_P_H
+#define QMLDOM_P_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 "qmlparser_p.h"
+
+#include <QtCore/QtGlobal>
+
+QT_BEGIN_NAMESPACE
+
+class QmlDomDocumentPrivate : public QSharedData
+{
+public:
+ QmlDomDocumentPrivate();
+ QmlDomDocumentPrivate(const QmlDomDocumentPrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
+ ~QmlDomDocumentPrivate();
+
+ QList<QmlError> errors;
+ QList<QmlDomImport> imports;
+ QmlParser::Object *root;
+ QList<int> automaticSemicolonOffsets;
+};
+
+class QmlDomObjectPrivate : public QSharedData
+{
+public:
+ QmlDomObjectPrivate();
+ QmlDomObjectPrivate(const QmlDomObjectPrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
+ ~QmlDomObjectPrivate();
+
+ typedef QList<QPair<QmlParser::Property *, QByteArray> > Properties;
+ Properties properties() const;
+ Properties properties(QmlParser::Property *) const;
+
+ QmlParser::Object *object;
+};
+
+class QmlDomPropertyPrivate : public QSharedData
+{
+public:
+ QmlDomPropertyPrivate();
+ QmlDomPropertyPrivate(const QmlDomPropertyPrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
+ ~QmlDomPropertyPrivate();
+
+ QByteArray propertyName;
+ QmlParser::Property *property;
+};
+
+class QmlDomDynamicPropertyPrivate : public QSharedData
+{
+public:
+ QmlDomDynamicPropertyPrivate();
+ QmlDomDynamicPropertyPrivate(const QmlDomDynamicPropertyPrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
+ ~QmlDomDynamicPropertyPrivate();
+
+ bool valid;
+ QmlParser::Object::DynamicProperty property;
+};
+
+class QmlDomValuePrivate : public QSharedData
+{
+public:
+ QmlDomValuePrivate();
+ QmlDomValuePrivate(const QmlDomValuePrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
+ ~QmlDomValuePrivate();
+
+ QmlParser::Property *property;
+ QmlParser::Value *value;
+};
+
+class QmlDomBasicValuePrivate : public QSharedData
+{
+public:
+ QmlDomBasicValuePrivate();
+ QmlDomBasicValuePrivate(const QmlDomBasicValuePrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
+ ~QmlDomBasicValuePrivate();
+
+ QmlParser::Value *value;
+};
+
+class QmlDomImportPrivate : public QSharedData
+{
+public:
+ QmlDomImportPrivate();
+ QmlDomImportPrivate(const QmlDomImportPrivate &o)
+ : QSharedData(o) { qFatal("Not impl"); }
+ ~QmlDomImportPrivate();
+
+ enum Type { Library, File };
+
+ Type type;
+ QString uri;
+ QString version;
+ QString qualifier;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMLDOM_P_P_H
+
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index bb36035..cf26f58 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -65,6 +65,7 @@
#include "qmlcomponent_p.h"
#include "qmlscriptclass_p.h"
#include "qmlnetworkaccessmanagerfactory.h"
+#include "qmlimageprovider.h"
#include <qfxperf_p_p.h>
@@ -85,6 +86,7 @@
#include <QtCore/qthread.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdir.h>
+#include <QtCore/qmutex.h>
#include <QtGui/qcolor.h>
#include <QtGui/qvector3d.h>
#include <QtGui/qsound.h>
@@ -95,6 +97,8 @@
#include <private/qobject_p.h>
#include <private/qscriptdeclarativeclass_p.h>
+#include <private/qmlgraphicsitemsmodule_p.h>
+
#ifdef Q_OS_WIN // for %APPDATA%
#include <qt_windows.h>
#include <qlibrary.h>
@@ -136,6 +140,8 @@ struct StaticQtMetaObject : public QObject
{ return &static_cast<StaticQtMetaObject*> (0)->staticQtMetaObject; }
};
+static bool qt_QmlQtModule_registered = false;
+
QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e)
: captureProperties(false), rootContext(0), currentExpression(0), isDebugging(false),
contextClass(0), sharedContext(0), sharedScope(0), objectClass(0), valueTypeClass(0),
@@ -144,6 +150,10 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e)
networkAccessManager(0), networkAccessManagerFactory(0),
typeManager(e), uniqueId(1)
{
+ if (!qt_QmlQtModule_registered) {
+ qt_QmlQtModule_registered = true;
+ QmlGraphicsItemModule::defineModule();
+ }
globalClass = new QmlGlobalScriptClass(&scriptEngine);
fileImportPath.append(QLibraryInfo::location(QLibraryInfo::DataPath)+QDir::separator()+QLatin1String("qml"));
}
@@ -428,6 +438,7 @@ QmlContext *QmlEngine::rootContext()
void QmlEngine::setNetworkAccessManagerFactory(QmlNetworkAccessManagerFactory *factory)
{
Q_D(QmlEngine);
+ QMutexLocker locker(&d->mutex);
d->networkAccessManagerFactory = factory;
}
@@ -442,17 +453,24 @@ QmlNetworkAccessManagerFactory *QmlEngine::networkAccessManagerFactory() const
return d->networkAccessManagerFactory;
}
+QNetworkAccessManager *QmlEnginePrivate::createNetworkAccessManager(QObject *parent) const
+{
+ QMutexLocker locker(&mutex);
+ QNetworkAccessManager *nam;
+ if (networkAccessManagerFactory) {
+ nam = networkAccessManagerFactory->create(parent);
+ } else {
+ nam = new QNetworkAccessManager(parent);
+ }
+
+ return nam;
+}
+
QNetworkAccessManager *QmlEnginePrivate::getNetworkAccessManager() const
{
Q_Q(const QmlEngine);
-
- if (!networkAccessManager) {
- if (networkAccessManagerFactory) {
- networkAccessManager = networkAccessManagerFactory->create(const_cast<QmlEngine*>(q));
- } else {
- networkAccessManager = new QNetworkAccessManager(const_cast<QmlEngine*>(q));
- }
- }
+ if (!networkAccessManager)
+ networkAccessManager = createNetworkAccessManager(const_cast<QmlEngine*>(q));
return networkAccessManager;
}
@@ -474,6 +492,69 @@ QNetworkAccessManager *QmlEngine::networkAccessManager() const
}
/*!
+ Sets the \a provider to use for images requested via the \e image: url
+ scheme, with host \a providerId.
+
+ QmlImageProvider allows images to be provided to QML asynchronously.
+ The image request will be run in a low priority thread. This allows
+ potentially costly image loading to be done in the background, without
+ affecting the performance of the UI.
+
+ Note that images loaded from a QmlImageProvider are cached by
+ QPixmapCache, similar to any image loaded by QML.
+
+ The QmlEngine assumes ownership of the provider.
+
+ This example creates a provider with id \e colors:
+
+ \snippet examples/declarative/imageprovider/main.cpp 0
+
+ \snippet examples/declarative/imageprovider/view.qml 0
+
+ \sa removeImageProvider()
+*/
+void QmlEngine::addImageProvider(const QString &providerId, QmlImageProvider *provider)
+{
+ Q_D(QmlEngine);
+ QMutexLocker locker(&d->mutex);
+ d->imageProviders.insert(providerId, provider);
+}
+
+/*!
+ Returns the QmlImageProvider set for \a providerId.
+*/
+QmlImageProvider *QmlEngine::imageProvider(const QString &providerId) const
+{
+ Q_D(const QmlEngine);
+ QMutexLocker locker(&d->mutex);
+ return d->imageProviders.value(providerId);
+}
+
+/*!
+ Removes the QmlImageProvider for \a providerId.
+
+ Returns the provider if it was found; otherwise returns 0.
+
+ \sa addImageProvider()
+*/
+void QmlEngine::removeImageProvider(const QString &providerId)
+{
+ Q_D(QmlEngine);
+ QMutexLocker locker(&d->mutex);
+ delete d->imageProviders.take(providerId);
+}
+
+QImage QmlEnginePrivate::getImageFromProvider(const QUrl &url)
+{
+ QMutexLocker locker(&mutex);
+ QImage image;
+ QmlImageProvider *provider = imageProviders.value(url.host());
+ if (provider)
+ image = provider->request(url.path().mid(1));
+ return image;
+}
+
+/*!
Return the base URL for this engine. The base URL is only used to resolve
components when a relative URL is passed to the QmlComponent constructor.
diff --git a/src/declarative/qml/qmlengine.h b/src/declarative/qml/qmlengine.h
index 8916013..64d0b9d 100644
--- a/src/declarative/qml/qmlengine.h
+++ b/src/declarative/qml/qmlengine.h
@@ -62,6 +62,7 @@ class QmlType;
class QUrl;
class QScriptEngine;
class QScriptContext;
+class QmlImageProvider;
class QNetworkAccessManager;
class QmlNetworkAccessManagerFactory;
class Q_DECLARATIVE_EXPORT QmlEngine : public QObject
@@ -83,6 +84,10 @@ public:
QNetworkAccessManager *networkAccessManager() const;
+ void addImageProvider(const QString &id, QmlImageProvider *);
+ QmlImageProvider *imageProvider(const QString &id) const;
+ void removeImageProvider(const QString &id);
+
void setOfflineStoragePath(const QString& dir);
QString offlineStoragePath() const;
diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h
index ce99e7c..7ec6dd6 100644
--- a/src/declarative/qml/qmlengine_p.h
+++ b/src/declarative/qml/qmlengine_p.h
@@ -75,6 +75,7 @@
#include <QtCore/qlist.h>
#include <QtCore/qpair.h>
#include <QtCore/qstack.h>
+#include <QtCore/qmutex.h>
#include <QtScript/qscriptengine.h>
#include <private/qobject_p.h>
@@ -211,10 +212,16 @@ public:
bool inBeginCreate;
+ QNetworkAccessManager *createNetworkAccessManager(QObject *parent) const;
QNetworkAccessManager *getNetworkAccessManager() const;
mutable QNetworkAccessManager *networkAccessManager;
mutable QmlNetworkAccessManagerFactory *networkAccessManagerFactory;
+ QHash<QString,QmlImageProvider*> imageProviders;
+ QImage getImageFromProvider(const QUrl &url);
+
+ mutable QMutex mutex;
+
QmlCompositeTypeManager typeManager;
QStringList fileImportPath;
QString offlineStoragePath;
@@ -309,6 +316,7 @@ public:
static QScriptEngine *getScriptEngine(QmlEngine *e) { return &e->d_func()->scriptEngine; }
static QmlEngine *getEngine(QScriptEngine *e) { return static_cast<QmlScriptEngine*>(e)->p->q_func(); }
static QmlEnginePrivate *get(QmlEngine *e) { return e->d_func(); }
+ static QmlEnginePrivate *get(QmlContext *c) { return (c && c->engine()) ? QmlEnginePrivate::get(c->engine()) : 0; }
static QmlEnginePrivate *get(QScriptEngine *e) { return static_cast<QmlScriptEngine*>(e)->p; }
static QmlEngine *get(QmlEnginePrivate *p) { return p->q_func(); }
QmlContext *getContext(QScriptContext *);
diff --git a/src/declarative/qml/qmlguard_p.h b/src/declarative/qml/qmlguard_p.h
index dae7d05..0e90f79 100644
--- a/src/declarative/qml/qmlguard_p.h
+++ b/src/declarative/qml/qmlguard_p.h
@@ -94,10 +94,10 @@ private:
inline void remGuard();
};
-Q_DECLARE_METATYPE(QmlGuard<QObject>);
-
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QmlGuard<QObject>);
+
#include "qmldeclarativedata_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/qml/qmlimageprovider.cpp b/src/declarative/qml/qmlimageprovider.cpp
new file mode 100644
index 0000000..7f15d08
--- /dev/null
+++ b/src/declarative/qml/qmlimageprovider.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmlimageprovider.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QmlImageProvider
+ \brief The QmlImageProvider class provides an interface for threaded image requests.
+
+ Note: the request() method may be called by multiple threads, so ensure the
+ implementation of this method is reentrant.
+
+ \sa QmlEngine::addImageProvider()
+*/
+QmlImageProvider::~QmlImageProvider()
+{
+}
+
+/*!
+ \fn QImage QmlImageProvider::request(const QString &id)
+
+ Implement this method to return the image with \a id.
+
+ Note: this method may be called by multiple threads, so ensure the
+ implementation of this method is reentrant.
+*/
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlimageprovider.h b/src/declarative/qml/qmlimageprovider.h
new file mode 100644
index 0000000..52fe066
--- /dev/null
+++ b/src/declarative/qml/qmlimageprovider.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLIMAGEPROVIDER_H
+#define QMLIMAGEPROVIDER_H
+
+#include <QtGui/qimage.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class Q_DECLARATIVE_EXPORT QmlImageProvider
+{
+public:
+ virtual ~QmlImageProvider();
+ virtual QImage request(const QString &id) = 0;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QMLIMAGEPROVIDER
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index 5938384..d7d4a07 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -276,7 +276,7 @@ const char *QmlMetaProperty::propertyTypeName() const
{
if (type() & ValueTypeProperty) {
- QmlEnginePrivate *ep = d->context?QmlEnginePrivate::get(d->context->engine()):0;
+ QmlEnginePrivate *ep = QmlEnginePrivate::get(d->context);
QmlValueType *valueType = 0;
if (ep) valueType = ep->valueTypes[d->core.propType];
else valueType = QmlValueTypeFactory::valueType(d->core.propType);
@@ -689,7 +689,7 @@ QVariant QmlMetaPropertyPrivate::readValueProperty()
} else if(type & QmlMetaProperty::ValueTypeProperty) {
- QmlEnginePrivate *ep = context?QmlEnginePrivate::get(context->engine()):0;
+ QmlEnginePrivate *ep = QmlEnginePrivate::get(context);
QmlValueType *valueType = 0;
if (ep) valueType = ep->valueTypes[core.propType];
else valueType = QmlValueTypeFactory::valueType(core.propType);
@@ -754,14 +754,15 @@ bool QmlMetaPropertyPrivate::writeValueProperty(const QVariant &value,
QmlMetaProperty::WriteFlags flags)
{
// Remove any existing bindings on this property
- if (!(flags & QmlMetaProperty::DontRemoveBinding))
- delete q->setBinding(0);
+ if (!(flags & QmlMetaProperty::DontRemoveBinding)) {
+ QmlAbstractBinding *binding = q->setBinding(0);
+ if (binding) binding->destroy();
+ }
bool rv = false;
uint type = q->type();
if (type & QmlMetaProperty::ValueTypeProperty) {
- QmlEnginePrivate *ep =
- context?static_cast<QmlEnginePrivate *>(QObjectPrivate::get(context->engine())):0;
+ QmlEnginePrivate *ep = QmlEnginePrivate::get(context);
QmlValueType *writeBack = 0;
if (ep) {
diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp
index 50a19e4..b94a815 100644
--- a/src/declarative/qml/qmlmetatype.cpp
+++ b/src/declarative/qml/qmlmetatype.cpp
@@ -840,6 +840,8 @@ QList<QmlType*> QmlMetaType::qmlTypes()
return data->nameToType.values();
}
+QT_END_NAMESPACE
+
#include <QtGui/qfont.h>
#include <QtGui/qpixmap.h>
#include <QtGui/qbrush.h>
@@ -867,6 +869,7 @@ QList<QmlType*> QmlMetaType::qmlTypes()
Q_DECLARE_METATYPE(QScriptValue);
+QT_BEGIN_NAMESPACE
/*!
Copies \a copy into \a data, assuming they both are of type \a type. If
\a copy is zero, a default type is copied. Returns true if the copy was
diff --git a/src/declarative/qml/qmlpropertycache.cpp b/src/declarative/qml/qmlpropertycache.cpp
index 2c79ceb..e567fd2 100644
--- a/src/declarative/qml/qmlpropertycache.cpp
+++ b/src/declarative/qml/qmlpropertycache.cpp
@@ -45,10 +45,10 @@
#include "qmlbinding.h"
#include "qdebug.h"
-QT_BEGIN_NAMESPACE
-
Q_DECLARE_METATYPE(QScriptValue);
+QT_BEGIN_NAMESPACE
+
void QmlPropertyCache::Data::load(const QMetaProperty &p, QmlEngine *engine)
{
propType = p.userType();
diff --git a/src/declarative/qml/qmlscriptstring.h b/src/declarative/qml/qmlscriptstring.h
index 3f61f5d..1789eb5 100644
--- a/src/declarative/qml/qmlscriptstring.h
+++ b/src/declarative/qml/qmlscriptstring.h
@@ -77,10 +77,10 @@ private:
QSharedDataPointer<QmlScriptStringPrivate> d;
};
-Q_DECLARE_METATYPE(QmlScriptString);
-
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QmlScriptString);
+
QT_END_HEADER
#endif // QMLSCRIPTSTRING_H
diff --git a/src/declarative/qml/qmlsqldatabase.cpp b/src/declarative/qml/qmlsqldatabase.cpp
index 4b132af..4e0e0fb 100644
--- a/src/declarative/qml/qmlsqldatabase.cpp
+++ b/src/declarative/qml/qmlsqldatabase.cpp
@@ -65,6 +65,8 @@
Q_DECLARE_METATYPE(QSqlDatabase)
Q_DECLARE_METATYPE(QSqlQuery)
+QT_BEGIN_NAMESPACE
+
class QmlSqlQueryScriptClass: public QScriptClass {
public:
QmlSqlQueryScriptClass(QScriptEngine *engine) : QScriptClass(engine)
@@ -423,3 +425,4 @@ We add a "forwardOnly" property that stops Qt caching results (code promises to
through the data.
*/
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlsqldatabase_p.h b/src/declarative/qml/qmlsqldatabase_p.h
index 95eb5ea..0fd275b 100644
--- a/src/declarative/qml/qmlsqldatabase_p.h
+++ b/src/declarative/qml/qmlsqldatabase_p.h
@@ -42,6 +42,7 @@
#ifndef QMLSQLDATABASE_P_H
#define QMLSQLDATABASE_P_H
+#include <QtScript/qscriptengine.h>
//
// W A R N I N G
// -------------
@@ -53,8 +54,14 @@
// We mean it.
//
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
class QScriptEngine;
void qt_add_qmlsqldatabase(QScriptEngine *engine);
+QT_END_NAMESPACE
+
#endif // QMLSQLDATABASE_P_H
diff --git a/src/declarative/qml/qmlstringconverters_p.h b/src/declarative/qml/qmlstringconverters_p.h
index 5156b7d..c83a1de 100644
--- a/src/declarative/qml/qmlstringconverters_p.h
+++ b/src/declarative/qml/qmlstringconverters_p.h
@@ -56,6 +56,8 @@
#include <QtCore/qglobal.h>
#include <QtCore/qvariant.h>
+QT_BEGIN_NAMESPACE
+
class QColor;
class QPointF;
class QSizeF;
@@ -64,8 +66,6 @@ class QString;
class QByteArray;
class QVector3D;
-QT_BEGIN_NAMESPACE
-
// XXX - Bauhaus currently uses these methods which is why they're exported
namespace QmlStringConverters
{
diff --git a/src/declarative/qml/qmlworkerscript.cpp b/src/declarative/qml/qmlworkerscript.cpp
index 4e6bd4f..a2e8c7a 100644
--- a/src/declarative/qml/qmlworkerscript.cpp
+++ b/src/declarative/qml/qmlworkerscript.cpp
@@ -55,6 +55,7 @@
#include <QtDeclarative/qmlinfo.h>
#include "qmlnetworkaccessmanagerfactory.h"
+
QT_BEGIN_NAMESPACE
class WorkerDataEvent : public QEvent
@@ -238,8 +239,13 @@ private:
QAtomicInt m_ref;
QmlWorkerListModel *m_model;
};
+
+QT_END_NAMESPACE
+
Q_DECLARE_METATYPE(QmlWorkerListModelAgent::VariantRef);
+QT_BEGIN_NAMESPACE
+
QmlWorkerScriptEnginePrivate::QmlWorkerScriptEnginePrivate(QmlEngine *engine)
: workerEngine(0), qmlengine(engine), m_nextId(0)
{
@@ -1030,8 +1036,10 @@ QVariant QmlWorkerListModel::data(int index, int role) const
return m_values.at(index).value(role);
}
+QT_END_NAMESPACE
+
QML_DEFINE_TYPE(Qt,4,6,WorkerListModel,QmlWorkerListModel)
#include "qmlworkerscript.moc"
-QT_END_NAMESPACE
+
diff --git a/src/declarative/qml/qmlxmlhttprequest.cpp b/src/declarative/qml/qmlxmlhttprequest.cpp
index 8bee751..eda2d9e 100644
--- a/src/declarative/qml/qmlxmlhttprequest.cpp
+++ b/src/declarative/qml/qmlxmlhttprequest.cpp
@@ -91,7 +91,7 @@
#define D(arg) (arg)->release()
#define A(arg) (arg)->addref()
-namespace {
+QT_BEGIN_NAMESPACE
class DocumentImpl;
class NodeImpl
@@ -315,12 +315,14 @@ public:
static QScriptValue load(QScriptEngine *engine, const QString &data);
};
-}; // namespace
+QT_END_NAMESPACE
Q_DECLARE_METATYPE(Node);
Q_DECLARE_METATYPE(NodeList);
Q_DECLARE_METATYPE(NamedNodeMap);
+QT_BEGIN_NAMESPACE
+
void NodeImpl::addref()
{
A(document);
@@ -1624,4 +1626,6 @@ void qt_add_qmlxmlhttprequest(QScriptEngine *engine)
engine->globalObject().setProperty(QLatin1String("DOMException"), domExceptionPrototype);
}
+QT_END_NAMESPACE
+
#include <qmlxmlhttprequest.moc>
diff --git a/src/declarative/qml/qmlxmlhttprequest_p.h b/src/declarative/qml/qmlxmlhttprequest_p.h
index 733cc03..59cb211 100644
--- a/src/declarative/qml/qmlxmlhttprequest_p.h
+++ b/src/declarative/qml/qmlxmlhttprequest_p.h
@@ -42,6 +42,7 @@
#ifndef QMLXMLHTTPREQUEST_P_H
#define QMLXMLHTTPREQUEST_P_H
+#include <QtScript/qscriptengine.h>
//
// W A R N I N G
// -------------
@@ -53,8 +54,14 @@
// We mean it.
//
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
class QScriptEngine;
void qt_add_qmlxmlhttprequest(QScriptEngine *engine);
+QT_END_NAMESPACE
+
#endif // QMLXMLHTTPREQUEST_P_H
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index 103a50f..82bd33e 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -210,11 +210,16 @@ bool QmlAbstractAnimation::isRunning() const
return d->running;
}
+//commence is called to start an animation when it is used as a
+//simple animation, and not as part of a transition
void QmlAbstractAnimationPrivate::commence()
{
Q_Q(QmlAbstractAnimation);
- q->prepare(userProperty.value);
+ QmlStateActions actions;
+ QmlMetaProperties properties;
+ q->transition(actions, properties, QmlAbstractAnimation::Forward);
+
q->qtAnimation()->start();
if (q->qtAnimation()->state() != QAbstractAnimation::Running) {
running = false;
@@ -238,14 +243,17 @@ QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const
void QmlAbstractAnimation::setRunning(bool r)
{
Q_D(QmlAbstractAnimation);
-
- if (r == false)
- d->avoidPropertyValueSourceStart = true;
+ if (!d->componentComplete) {
+ d->running = r;
+ if (r == false)
+ d->avoidPropertyValueSourceStart = true;
+ return;
+ }
if (d->running == r)
return;
- if (d->group) {
+ if (d->group || d->disableUserControl) {
qWarning("QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes");
return;
}
@@ -262,10 +270,7 @@ void QmlAbstractAnimation::setRunning(bool r)
this, SLOT(timelineComplete()));
d->connectedTimeLine = true;
}
- if (d->componentComplete)
- d->commence();
- else
- d->startOnCompletion = true;
+ d->commence();
emit started();
} else {
if (d->alwaysRunToEnd) {
@@ -304,7 +309,7 @@ void QmlAbstractAnimation::setPaused(bool p)
if (d->paused == p)
return;
- if (d->group) {
+ if (d->group || d->disableUserControl) {
qWarning("QmlAbstractAnimation: setPaused() cannot be used on non-root animation nodes");
return;
}
@@ -315,7 +320,7 @@ void QmlAbstractAnimation::setPaused(bool p)
else
qtAnimation()->resume();
- emit pausedChanged(d->running);
+ emit pausedChanged(d->paused);
}
void QmlAbstractAnimation::classBegin()
@@ -327,9 +332,11 @@ void QmlAbstractAnimation::classBegin()
void QmlAbstractAnimation::componentComplete()
{
Q_D(QmlAbstractAnimation);
- if (d->startOnCompletion)
- d->commence();
d->componentComplete = true;
+ if (d->running) {
+ d->running = false;
+ setRunning(true);
+ }
}
/*!
@@ -534,17 +541,32 @@ void QmlAbstractAnimation::complete()
void QmlAbstractAnimation::setTarget(const QmlMetaProperty &p)
{
Q_D(QmlAbstractAnimation);
- if (d->userProperty.isNull)
- d->userProperty = p;
+ d->defaultProperty = p;
if (!d->avoidPropertyValueSourceStart)
setRunning(true);
}
-//prepare is called before an animation begins
-//(when an animation is used as a simple animation, and not as part of a transition)
-void QmlAbstractAnimation::prepare(QmlMetaProperty &)
+/*
+ we rely on setTarget only being called when used as a value source
+ so this function allows us to do the same thing as setTarget without
+ that assumption
+*/
+void QmlAbstractAnimation::setDefaultTarget(const QmlMetaProperty &p)
+{
+ Q_D(QmlAbstractAnimation);
+ d->defaultProperty = p;
+}
+
+/*
+ don't allow start/stop/pause/resume to be manually invoked,
+ because something else (like a Behavior) already has control
+ over the animation.
+*/
+void QmlAbstractAnimation::setDisableUserControl()
{
+ Q_D(QmlAbstractAnimation);
+ d->disableUserControl = true;
}
void QmlAbstractAnimation::transition(QmlStateActions &actions,
@@ -685,7 +707,7 @@ void QmlColorAnimation::setFrom(const QColor &f)
}
/*!
- \qmlproperty color ColorAnimation::from
+ \qmlproperty color ColorAnimation::to
This property holds the ending color.
*/
QColor QmlColorAnimation::to() const
@@ -819,7 +841,7 @@ QML_DEFINE_TYPE(Qt,4,6,ScriptAction,QmlScriptAction)
Set \c thewebview.url to the value set for the destination state:
\code
- PropertyAction { matchTargets: thewebview; matchProperties: "url" }
+ PropertyAction { target: thewebview; property: "url" }
\endcode
The PropertyAction is immediate -
@@ -866,25 +888,10 @@ void QmlPropertyAction::setTarget(QObject *o)
Q_D(QmlPropertyAction);
if (d->target == o)
return;
-
d->target = o;
- if (d->target && !d->propertyName.isEmpty()) {
- d->userProperty = d->createProperty(d->target, d->propertyName, this);
- } else {
- d->userProperty.invalidate();
- }
-
emit targetChanged(d->target, d->propertyName);
}
-/*!
- \qmlproperty string PropertyAction::property
- This property holds an explicit property to animated.
-
- The exact effect of the \c property property depends on how the animation
- is being used. Refer to the \l animation documentation for details.
-*/
-
QString QmlPropertyAction::property() const
{
Q_D(const QmlPropertyAction);
@@ -896,29 +903,24 @@ void QmlPropertyAction::setProperty(const QString &n)
Q_D(QmlPropertyAction);
if (d->propertyName == n)
return;
-
d->propertyName = n;
- if (d->target && !d->propertyName.isEmpty()) {
- d->userProperty = d->createProperty(d->target, d->propertyName, this);
- } else {
- d->userProperty.invalidate();
- }
-
emit targetChanged(d->target, d->propertyName);
}
/*!
- \qmlproperty string PropertyAction::matchProperties
- This property holds a comma-separated list of property names this action
- will match against. These names are used in conjunction with matchTargets
- to create a list of properties that the action will set, assuming those
- properties have changed.
+ \qmlproperty string PropertyAction::property
+ \qmlproperty string PropertyAction::properties
+ \qmlproperty Object PropertyAction::target
+ \qmlproperty list<Object> PropertyAction::targets
- This property is typically used for an action appearing as part of a Transition.
+ These properties are used as a set to determine which properties should be
+ affected by this action.
- By default, no property names will be matched.
+ The details of how these properties are interpreted in different situations
+ is covered in the \l{PropertyAnimation::properties}{corresponding} PropertyAnimation
+ documentation.
- \sa matchTargets PropertyAnimation::matchProperties
+ \sa exclude
*/
QString QmlPropertyAction::properties() const
{
@@ -935,18 +937,6 @@ void QmlPropertyAction::setProperties(const QString &p)
emit propertiesChanged(p);
}
-/*!
- \qmlproperty list<Object> PropertyAction::matchTargets
- This property holds a list of objects this action will match against.
- These objects are used in conjunction with matchProperties to create a list of properties
- that the action will set, assuming those properties have changed.
-
- This property is typically used for an action appearing as part of a Transition.
-
- By default, all changing targets will be matched.
-
- \sa exclude matchProperties PropertyAnimation::matchTargets
-*/
QList<QObject *> *QmlPropertyAction::targets()
{
Q_D(QmlPropertyAction);
@@ -956,7 +946,7 @@ QList<QObject *> *QmlPropertyAction::targets()
/*!
\qmlproperty list<Object> PropertyAction::exclude
This property holds the objects not to be affected by this animation.
- \sa matchTargets
+ \sa targets
*/
QList<QObject *> *QmlPropertyAction::exclude()
{
@@ -984,29 +974,12 @@ void QmlPropertyAction::setValue(const QVariant &v)
}
}
-void QmlPropertyActionPrivate::doAction()
-{
- property.write(value, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
-}
-
QAbstractAnimation *QmlPropertyAction::qtAnimation()
{
Q_D(QmlPropertyAction);
return d->spa;
}
-void QmlPropertyAction::prepare(QmlMetaProperty &p)
-{
- Q_D(QmlPropertyAction);
-
- if (d->userProperty.isNull)
- d->property = p;
- else
- d->property = d->userProperty;
-
- d->spa->setAnimAction(&d->proxy, QAbstractAnimation::KeepWhenStopped);
-}
-
void QmlPropertyAction::transition(QmlStateActions &actions,
QmlMetaProperties &modified,
TransitionDirection direction)
@@ -1029,31 +1002,42 @@ void QmlPropertyAction::transition(QmlStateActions &actions,
QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(','));
for (int ii = 0; ii < props.count(); ++ii)
props[ii] = props.at(ii).trimmed();
+ if (!d->propertyName.isEmpty())
+ props << d->propertyName;
- bool hasSelectors = !props.isEmpty() || !d->targets.isEmpty() || !d->exclude.isEmpty();
- bool hasTarget = !d->propertyName.isEmpty() || d->target;
+ QList<QObject*> targets = d->targets;
+ if (d->target)
+ targets.append(d->target);
- if (hasSelectors && hasTarget) {
- qmlInfo(this) << tr("matchTargets/matchProperties/exclude and target/property are mutually exclusive.");
- return;
+ bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty();
+
+ if (d->defaultProperty.isValid() && !hasSelectors) {
+ props << d->defaultProperty.name();
+ targets << d->defaultProperty.object();
}
QmlSetPropertyAnimationAction *data = new QmlSetPropertyAnimationAction;
bool hasExplicit = false;
- if (hasTarget && d->value.isValid()) {
- QmlAction myAction;
- myAction.property = d->createProperty(target(), d->propertyName, this);
- if (myAction.property.isValid()) {
- myAction.toValue = d->value;
- data->actions << myAction;
- hasExplicit = true;
- for (int ii = 0; ii < actions.count(); ++ii) {
- QmlAction &action = actions[ii];
- if (action.property.object() == myAction.property.object() &&
- myAction.property.name() == action.property.name()) {
- modified << action.property;
- break; //### any chance there could be multiples?
+ //an explicit animation has been specified
+ if (d->value.isValid()) {
+ for (int i = 0; i < props.count(); ++i) {
+ for (int j = 0; j < targets.count(); ++j) {
+ QmlAction myAction;
+ myAction.property = d->createProperty(targets.at(j), props.at(i), this);
+ if (myAction.property.isValid()) {
+ myAction.toValue = d->value;
+ QmlPropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType());
+ data->actions << myAction;
+ hasExplicit = true;
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QmlAction &action = actions[ii];
+ if (action.property.object() == myAction.property.object() &&
+ myAction.property.name() == action.property.name()) {
+ modified << action.property;
+ break; //### any chance there could be multiples?
+ }
+ }
}
}
}
@@ -1069,31 +1053,18 @@ void QmlPropertyAction::transition(QmlStateActions &actions,
QString sPropertyName = action.specifiedProperty;
bool same = (obj == sObj);
- if ((d->targets.isEmpty() || d->targets.contains(obj) || (!same && d->targets.contains(sObj))) &&
+ if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) &&
(!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
(props.contains(propertyName) || (!same && props.contains(sPropertyName)))) {
QmlAction myAction = action;
if (d->value.isValid())
myAction.toValue = d->value;
+ QmlPropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType());
modified << action.property;
data->actions << myAction;
action.fromValue = myAction.toValue;
- } else if (d->userProperty.isValid() &&
- !hasSelectors && !hasTarget) {
- if ((d->userProperty.value.object() == obj || (!same && d->userProperty.value.object() == sObj)) &&
- (d->userProperty.value.name() == propertyName || (!same && d->userProperty.value.name() == sPropertyName))) {
- //### same as above. merge
- QmlAction myAction = action;
-
- if (d->value.isValid())
- myAction.toValue = d->value;
-
- modified << action.property;
- data->actions << myAction;
- action.fromValue = myAction.toValue;
- }
}
}
@@ -1161,24 +1132,7 @@ void QmlParentActionPrivate::init()
/*!
\qmlproperty Item ParentAction::target
- This property holds an explicit target item to reparent.
- */
-QmlGraphicsItem *QmlParentAction::object() const
-{
- Q_D(const QmlParentAction);
- return d->pcTarget;
-}
-
-void QmlParentAction::setObject(QmlGraphicsItem *target)
-{
- Q_D(QmlParentAction);
- d->pcTarget = target;
-}
-
-/*!
- \qmlproperty Item ParentAction::matchTarget
- This property holds the item this action will match against -- the item
- that the action will reparent, assuming its parent has changed.
+ This property holds a target item to reparent.
In the following example, \c myItem will be reparented by the ParentAction, while
\c myOtherItem will not.
@@ -1196,24 +1150,23 @@ void QmlParentAction::setObject(QmlGraphicsItem *target)
Transition {
SequentialAnimation {
PropertyAnimation { ... }
- ParentAction { matchTargets: myItem }
+ ParentAction { target: myItem }
PropertyAnimation { ... }
}
}
\endqml
- This property is typically used for an action appearing as part of a Transition.
*/
-QmlGraphicsItem *QmlParentAction::matchTarget() const
+QmlGraphicsItem *QmlParentAction::object() const
{
Q_D(const QmlParentAction);
return d->pcTarget;
}
-void QmlParentAction::setMatchTarget(QmlGraphicsItem *target)
+void QmlParentAction::setObject(QmlGraphicsItem *target)
{
Q_D(QmlParentAction);
- d->pcMatchTarget = target;
+ d->pcTarget = target;
}
/*!
@@ -1277,17 +1230,27 @@ void QmlParentAction::transition(QmlStateActions &actions,
QmlParentActionData *data = new QmlParentActionData;
- if (d->pcTarget && d->pcMatchTarget) {
- qmlInfo(this) << tr("matchTarget and target are mutually exclusive.");
- return;
+ //### need to correctly handle modified/done
+
+ bool hasExplicit = false;
+ if (d->pcTarget && d->pcParent) {
+ data->reverse = false;
+ QmlAction myAction;
+ QmlParentChange *pc = new QmlParentChange;
+ pc->setObject(d->pcTarget);
+ pc->setParent(d->pcParent);
+ myAction.event = pc;
+ data->pc = pc;
+ data->actions << myAction;
+ hasExplicit = true;
}
+ if (!hasExplicit)
for (int ii = 0; ii < actions.count(); ++ii) {
QmlAction &action = actions[ii];
if (action.event && action.event->typeName() == QLatin1String("ParentChange")
- && !d->pcTarget
- && (!d->pcMatchTarget || static_cast<QmlParentChange*>(action.event)->object() == d->pcMatchTarget)) {
+ && (!d->pcTarget || static_cast<QmlParentChange*>(action.event)->object() == d->pcTarget)) {
QmlAction myAction = action;
data->reverse = action.reverseEvent;
//### this logic differs from PropertyAnimation
@@ -1308,17 +1271,6 @@ void QmlParentAction::transition(QmlStateActions &actions,
}
}
- if (d->pcTarget && d->pcParent) {
- data->reverse = false;
- QmlAction myAction;
- QmlParentChange *pc = new QmlParentChange;
- pc->setObject(d->pcTarget);
- pc->setParent(d->pcParent);
- myAction.event = pc;
- data->pc = pc;
- data->actions << myAction;
- }
-
if (data->actions.count()) {
d->cpa->setAnimAction(data, QAbstractAnimation::DeleteWhenStopped);
} else {
@@ -1336,7 +1288,7 @@ QML_DEFINE_TYPE(Qt,4,6,ParentAction,QmlParentAction)
Animate a set of properties over 200ms, from their values in the start state to
their values in the end state of the transition:
\code
- NumberAnimation { matchProperties: "x,y,scale"; duration: 200 }
+ NumberAnimation { properties: "x,y,scale"; duration: 200 }
\endcode
*/
@@ -1376,7 +1328,7 @@ void QmlNumberAnimation::setFrom(qreal f)
/*!
\qmlproperty real NumberAnimation::to
This property holds the ending value.
- If not set, then the value defined in the end state of the transition.
+ If not set, then the value defined in the end state of the transition or Behavior.
*/
qreal QmlNumberAnimation::to() const
{
@@ -1434,7 +1386,7 @@ void QmlVector3dAnimation::setFrom(QVector3D f)
/*!
\qmlproperty real Vector3dAnimation::to
This property holds the ending value.
- If not set, then the value defined in the end state of the transition.
+ If not set, then the value defined in the end state of the transition or Behavior.
*/
QVector3D QmlVector3dAnimation::to() const
{
@@ -1449,6 +1401,177 @@ void QmlVector3dAnimation::setTo(QVector3D t)
QML_DEFINE_TYPE(Qt,4,6,Vector3dAnimation,QmlVector3dAnimation)
+/*!
+ \qmlclass RotationAnimation QmlRotationAnimation
+ \inherits PropertyAnimation
+ \brief The RotationAnimation element allows you to animate rotations.
+
+ RotationAnimation is a specialized PropertyAnimation that gives control
+ over the direction of rotation.
+
+ The RotationAnimation in the following example ensures that we always take
+ the shortest rotation path when switching between our states.
+ \qml
+ states: {
+ State { name: "180"; PropertyChanges { target: myItem; rotation: 180 } }
+ State { name: "-180"; PropertyChanges { target: myItem; rotation: -180 } }
+ State { name: "180"; PropertyChanges { target: myItem; rotation: 270 } }
+ }
+ transition: Transition {
+ RotationAnimation { direction: RotationAnimation.Shortest }
+ }
+ \endqml
+
+ By default, when used in a transition RotationAnimation will rotate all
+ properties named "rotation" or "angle". You can override this by providing
+ your own properties via \c properties or \c property.
+*/
+
+/*!
+ \internal
+ \class QmlRotationAnimation
+*/
+
+QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress)
+{
+ qreal newt = t;
+ qreal diff = t-f;
+ while(diff > 180.0){
+ newt -= 360.0;
+ diff -= 360.0;
+ }
+ while(diff < -180.0){
+ newt += 360.0;
+ diff += 360.0;
+ }
+ return QVariant(f + (newt - f) * progress);
+}
+
+QVariant _q_interpolateClockwiseRotation(qreal &f, qreal &t, qreal progress)
+{
+ qreal newt = t;
+ qreal diff = t-f;
+ while(diff < 0.0){
+ newt += 360.0;
+ diff += 360.0;
+ }
+ return QVariant(f + (newt - f) * progress);
+}
+
+QVariant _q_interpolateCounterclockwiseRotation(qreal &f, qreal &t, qreal progress)
+{
+ qreal newt = t;
+ qreal diff = t-f;
+ while(diff > 0.0){
+ newt -= 360.0;
+ diff -= 360.0;
+ }
+ return QVariant(f + (newt - f) * progress);
+}
+
+QmlRotationAnimation::QmlRotationAnimation(QObject *parent)
+: QmlPropertyAnimation(*(new QmlRotationAnimationPrivate), parent)
+{
+ Q_D(QmlRotationAnimation);
+ d->interpolatorType = QMetaType::QReal;
+ d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateShortestRotation);
+ d->defaultProperties = QLatin1String("rotation,angle");
+}
+
+QmlRotationAnimation::~QmlRotationAnimation()
+{
+}
+
+/*!
+ \qmlproperty real RotationAnimation::from
+ This property holds the starting value.
+ If not set, then the value defined in the start state of the transition.
+*/
+qreal QmlRotationAnimation::from() const
+{
+ Q_D(const QmlRotationAnimation);
+ return d->from.toReal();
+}
+
+void QmlRotationAnimation::setFrom(qreal f)
+{
+ QmlPropertyAnimation::setFrom(f);
+}
+
+/*!
+ \qmlproperty real RotationAnimation::to
+ This property holds the ending value.
+ If not set, then the value defined in the end state of the transition or Behavior.
+*/
+qreal QmlRotationAnimation::to() const
+{
+ Q_D(const QmlRotationAnimation);
+ return d->to.toReal();
+}
+
+void QmlRotationAnimation::setTo(qreal t)
+{
+ QmlPropertyAnimation::setTo(t);
+}
+
+/*!
+ \qmlproperty enum RotationAnimation::direction
+ The direction in which to rotate.
+ Possible values are Numerical, Clockwise, Counterclockwise,
+ or Shortest.
+
+ \list
+ \row
+ \o Numerical
+ \o Rotate by linearly interpolating between the two numbers.
+ A rotation from 10 to 350 will rotate 340 degrees clockwise.
+ \row
+ \o Clockwise
+ \o Rotate clockwise between the two values
+ \row
+ \o Counterclockwise
+ \o Rotate counterclockwise between the two values
+ \row
+ \o Shortest
+ \o Rotate in the direction that produces the shortest animation path.
+ A rotation from 10 to 350 will rotate 20 degrees counterclockwise.
+ \list
+
+ The default direction is Shortest.
+*/
+QmlRotationAnimation::RotationDirection QmlRotationAnimation::direction() const
+{
+ Q_D(const QmlRotationAnimation);
+ return d->direction;
+}
+
+void QmlRotationAnimation::setDirection(QmlRotationAnimation::RotationDirection direction)
+{
+ Q_D(QmlRotationAnimation);
+ if (d->direction == direction)
+ return;
+
+ d->direction = direction;
+ switch(d->direction) {
+ case Clockwise:
+ d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateClockwiseRotation);
+ break;
+ case Counterclockwise:
+ d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateCounterclockwiseRotation);
+ break;
+ case Shortest:
+ d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateShortestRotation);
+ break;
+ default:
+ d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
+ break;
+ }
+
+ emit directionChanged();
+}
+
+QML_DEFINE_TYPE(Qt,4,6,RotationAnimation,QmlRotationAnimation)
+
QmlAnimationGroup::QmlAnimationGroup(QObject *parent)
: QmlAbstractAnimation(*(new QmlAnimationGroupPrivate), parent)
{
@@ -1495,18 +1618,6 @@ QmlSequentialAnimation::~QmlSequentialAnimation()
{
}
-void QmlSequentialAnimation::prepare(QmlMetaProperty &p)
-{
- Q_D(QmlAnimationGroup);
- if (d->userProperty.isNull)
- d->property = p;
- else
- d->property = d->userProperty;
-
- for (int i = 0; i < d->animations.size(); ++i)
- d->animations.at(i)->prepare(d->property);
-}
-
QAbstractAnimation *QmlSequentialAnimation::qtAnimation()
{
Q_D(QmlAnimationGroup);
@@ -1526,13 +1637,10 @@ void QmlSequentialAnimation::transition(QmlStateActions &actions,
from = d->animations.count() - 1;
}
- //needed for Behavior
- if (d->userProperty.isValid()) {
- for (int i = 0; i < d->animations.count(); ++i)
- d->animations.at(i)->setTarget(d->userProperty);
- }
-
+ bool valid = d->defaultProperty.isValid();
for (int ii = from; ii < d->animations.count() && ii >= 0; ii += inc) {
+ if (valid)
+ d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
d->animations.at(ii)->transition(actions, modified, direction);
}
}
@@ -1574,18 +1682,6 @@ QmlParallelAnimation::~QmlParallelAnimation()
{
}
-void QmlParallelAnimation::prepare(QmlMetaProperty &p)
-{
- Q_D(QmlAnimationGroup);
- if (d->userProperty.isNull)
- d->property = p;
- else
- d->property = d->userProperty;
-
- for (int i = 0; i < d->animations.size(); ++i)
- d->animations.at(i)->prepare(d->property);
-}
-
QAbstractAnimation *QmlParallelAnimation::qtAnimation()
{
Q_D(QmlAnimationGroup);
@@ -1597,14 +1693,10 @@ void QmlParallelAnimation::transition(QmlStateActions &actions,
TransitionDirection direction)
{
Q_D(QmlAnimationGroup);
-
- //needed for Behavior
- if (d->userProperty.isValid()) {
- for (int i = 0; i < d->animations.count(); ++i)
- d->animations.at(i)->setTarget(d->userProperty);
- }
-
+ bool valid = d->defaultProperty.isValid();
for (int ii = 0; ii < d->animations.count(); ++ii) {
+ if (valid)
+ d->animations.at(ii)->setDefaultTarget(d->defaultProperty);
d->animations.at(ii)->transition(actions, modified, direction);
}
}
@@ -1668,12 +1760,56 @@ void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type)
\inherits Animation
\brief The PropertyAnimation element allows you to animate property changes.
- Animate theObject's size property over 200ms, from its current size to 20-by-20:
- \code
+ PropertyAnimation provides a way to animate changes to a property's value. It can
+ be used in many different situations:
+ \list
+ \o In a Transition
+
+ Animate any objects that have changed their x or y properties in the target state using
+ an InOutQuad easing curve:
+ \qml
+ Transition { PropertyAnimation { properties: "x,y"; easing: "InOutQuad" } }
+ \endqml
+ \o In a Behavior
+
+ Animate all changes to a rectangle's x property.
+ \qml
+ Rectangle {
+ x: Behavior { PropertyAnimation {} }
+ }
+ \endqml
+ \o As a property value source
+
+ Repeatedly animate the rectangle's x property.
+ \qml
+ Rectangle {
+ x: SequentialAnimation {
+ repeat: true
+ PropertyAnimation { to: 50 }
+ PropertyAnimation { to: 0 }
+ }
+ }
+ \endqml
+ \o In a signal handler
+
+ Fade out \c theObject when clicked:
+ \qml
+ MouseRegion {
+ anchors.fill: theObject
+ onClicked: PropertyAnimation { target: theObject; property: "opacity"; to: 0 }
+ }
+ \endqml
+ \o Standalone
+
+ Animate \c theObject's size property over 200ms, from its current size to 20-by-20:
+ \qml
PropertyAnimation { target: theObject; property: "size"; to: "20x20"; duration: 200 }
- \endcode
+ \endqml
+ \endlist
- For an introduction to animation in QML, see \l{QML Animation}.
+ Depending on how the animation is used, the set of properties normally used will be
+ different. For more information see the individual property documentation, as well
+ as the \l{QML Animation} introduction.
*/
QmlPropertyAnimation::QmlPropertyAnimation(QObject *parent)
@@ -1683,6 +1819,13 @@ QmlPropertyAnimation::QmlPropertyAnimation(QObject *parent)
d->init();
}
+QmlPropertyAnimation::QmlPropertyAnimation(QmlPropertyAnimationPrivate &dd, QObject *parent)
+: QmlAbstractAnimation(dd, parent)
+{
+ Q_D(QmlPropertyAnimation);
+ d->init();
+}
+
QmlPropertyAnimation::~QmlPropertyAnimation()
{
}
@@ -1744,7 +1887,7 @@ void QmlPropertyAnimation::setFrom(const QVariant &f)
/*!
\qmlproperty real PropertyAnimation::to
This property holds the ending value.
- If not set, then the value defined in the end state of the transition.
+ If not set, then the value defined in the end state of the transition or Behavior.
*/
QVariant QmlPropertyAnimation::to() const
{
@@ -1955,16 +2098,6 @@ void QmlPropertyAnimation::setEasing(const QString &e)
emit easingChanged(e);
}
-/*!
- \qmlproperty Object PropertyAnimation::target
- This property holds an explicit target object to animate.
-
- target is used in conjunction with property to determine
- what property should be animated.
-
- \sa property matchTargets
-*/
-
QObject *QmlPropertyAnimation::target() const
{
Q_D(const QmlPropertyAnimation);
@@ -1976,27 +2109,10 @@ void QmlPropertyAnimation::setTarget(QObject *o)
Q_D(QmlPropertyAnimation);
if (d->target == o)
return;
-
d->target = o;
- if (d->target && !d->propertyName.isEmpty()) {
- d->userProperty = d->createProperty(d->target, d->propertyName, this);
- } else {
- d->userProperty.invalidate();
- }
-
emit targetChanged(d->target, d->propertyName);
}
-/*!
- \qmlproperty string PropertyAnimation::property
- This property holds an explicit property name to animate.
-
- property is used in conjunction with target to determine
- what property should be animated.
-
- \sa target matchProperties
-*/
-
QString QmlPropertyAnimation::property() const
{
Q_D(const QmlPropertyAnimation);
@@ -2008,46 +2124,10 @@ void QmlPropertyAnimation::setProperty(const QString &n)
Q_D(QmlPropertyAnimation);
if (d->propertyName == n)
return;
-
d->propertyName = n;
- if (d->target && !d->propertyName.isEmpty()) {
- d->userProperty = d->createProperty(d->target, d->propertyName, this);
- } else {
- d->userProperty.invalidate();
- }
-
emit targetChanged(d->target, d->propertyName);
}
-/*!
- \qmlproperty string PropertyAnimation::matchProperties
- This property holds a comma-separated list of property names this animation
- will match against. These names are used in conjunction with matchTargets
- to create a list of properties that the animation will animate, assuming those
- properties have changed.
-
- In the following example, the change in 'x' will be animated by the transition, while
- the change in 'y' will not.
- \qml
- State {
- PropertyChanges {
- target: myItem
- x: 15; y: 15
- }
- }
- Transition {
- PropertyAnimation {
- matchProperties: "x"
- }
- }
- \endqml
-
- This property is typically used for an animation appearing as part of a Transition.
-
- By default, no property names will be matched.
-
- \sa matchTargets PropertyAction::matchTargets
-*/
QString QmlPropertyAnimation::properties() const
{
Q_D(const QmlPropertyAnimation);
@@ -2065,37 +2145,86 @@ void QmlPropertyAnimation::setProperties(const QString &prop)
}
/*!
- \qmlproperty list<Object> PropertyAnimation::matchTargets
- This property holds a list of objects this animation will match against.
- These objects are used in conjunction with matchProperties to create a list of properties
- that the animation will animate, assuming those properties have changed.
+ \qmlproperty string PropertyAnimation::property
+ \qmlproperty string PropertyAnimation::properties
+ \qmlproperty Object PropertyAnimation::target
+ \qmlproperty list<Object> PropertyAnimation::targets
- In the following example, the changes to \c myItem will be animated by the transition, while
- the changes to \c myOtherItem will not.
+ These properties are used as a set to determine which properties should be animated.
+ The singular and plural forms are functionally identical, e.g.
\qml
- State {
- PropertyChanges {
- target: myItem
- x: 15; y: 15
- }
- PropertyChanges {
- target: myOtherItem
- x: 30; y: 30
- }
- }
- Transition {
- PropertyAnimation {
- matchTargets: myItem
- matchProperties: "x,y"
- }
- }
+ NumberAnimation { target: theItem; property: "x"; to: 500 }
+ \endqml
+ has the same meaning as
+ \qml
+ NumberAnimation { targets: theItem; properties: "x"; to: 500 }
\endqml
+ The singular forms are slightly optimized, so if you do have only a single target/property
+ to animate you should try to use them.
- This property is typically used for an animation appearing as part of a Transition.
+ In many cases these properties do not need to be explicitly specified -- they can be
+ inferred from the animation framework.
+ \table 80%
+ \row
+ \o Value Source / Behavior
+ \o When an animation is used as a value source or in a Behavior, the default target and property
+ name to be animated can both be inferred.
+ \qml
+ Rectangle {
+ id: theRect
+ width: 100; height: 100
+ color: Qt.rgba(0,0,1)
+ x: NumberAnimation { to: 500; repeat: true } //animate theRect's x property
+ y: Behavior { NumberAnimation {} } //animate theRect's y property
+ }
+ \endqml
+ \row
+ \o Transition
+ \o When used in a transition, a property animation is assumed to match \e all targets
+ but \e no properties. In practice, that means you need to specify at least the properties
+ in order for the animation to do anything.
+ \qml
+ Rectangle {
+ id: theRect
+ width: 100; height: 100
+ color: Qt.rgba(0,0,1)
+ Item { id: uselessItem }
+ states: State {
+ name: "state1"
+ PropertyChanges { target: theRect; x: 200; y: 200; z: 4 }
+ PropertyChanges { target: uselessItem; x: 10; y: 10; z: 2 }
+ }
+ transitions: Transition {
+ //animate both theRect's and uselessItem's x and y to their final values
+ NumberAnimation { properties: "x,y" }
- By default, all changing targets will be matched.
-
- \sa exclude matchProperties
+ //animate theRect's z to its final value
+ NumberAnimation { target: theRect; property: "z" }
+ }
+ }
+ \endqml
+ \row
+ \o Standalone
+ \o When an animation is used standalone, both the target and property need to be
+ explicitly specified.
+ \qml
+ Rectangle {
+ id: theRect
+ width: 100; height: 100
+ color: Qt.rgba(0,0,1)
+ //need to explicitly specify target and property
+ NumberAnimation { id: theAnim; target: theRect; property: "x" to: 500 }
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: theAnim.start()
+ }
+ }
+ \endqml
+ \endtable
+
+ As seen in the above example, properties is specified as a comma-separated string of property names to animate.
+
+ \sa exclude
*/
QList<QObject *> *QmlPropertyAnimation::targets()
{
@@ -2106,7 +2235,7 @@ QList<QObject *> *QmlPropertyAnimation::targets()
/*!
\qmlproperty list<Object> PropertyAnimation::exclude
This property holds the items not to be affected by this animation.
- \sa matchTargets
+ \sa targets
*/
QList<QObject *> *QmlPropertyAnimation::exclude()
{
@@ -2114,152 +2243,119 @@ QList<QObject *> *QmlPropertyAnimation::exclude()
return &d->exclude;
}
-void QmlPropertyAnimationPrivate::valueChanged(qreal r)
-{
- if (!fromSourced) {
- if (!fromIsDefined) {
- from = property.read();
- convertVariant(from, interpolatorType ? interpolatorType : property.propertyType());
- //### check for invalid variant if using property type
- }
- fromSourced = true;
- }
-
- if (r == 1.) {
- property.write(to, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
- } else {
- if (interpolator)
- property.write(interpolator(from.constData(), to.constData(), r), QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
- }
-}
-
QAbstractAnimation *QmlPropertyAnimation::qtAnimation()
{
Q_D(QmlPropertyAnimation);
return d->va;
}
-void QmlPropertyAnimation::prepare(QmlMetaProperty &p)
+struct PropertyUpdater : public QmlTimeLineValue
{
- Q_D(QmlPropertyAnimation);
- if (d->userProperty.isNull)
- d->property = p;
- else
- d->property = d->userProperty;
-
- if (!d->rangeIsSet) {
- d->va->setStartValue(qreal(0));
- d->va->setEndValue(qreal(1));
- d->rangeIsSet = true;
- }
-
- int propType = d->property.propertyType();
- d->convertVariant(d->to, d->interpolatorType ? d->interpolatorType : propType);
- if (d->fromIsDefined)
- d->convertVariant(d->from, d->interpolatorType ? d->interpolatorType : propType);
-
- if (!d->interpolatorType) {
- //### check for invalid variants
- d->interpolator = QVariantAnimationPrivate::getInterpolator(propType);
+ QmlStateActions actions;
+ int interpolatorType; //for Number/ColorAnimation
+ int prevInterpolatorType; //for generic
+ QVariantAnimation::Interpolator interpolator;
+ bool reverse;
+ bool fromSourced;
+ bool fromDefined;
+ bool *wasDeleted;
+ PropertyUpdater() : wasDeleted(0) {}
+ ~PropertyUpdater() { if (wasDeleted) *wasDeleted = true; }
+ void setValue(qreal v)
+ {
+ bool deleted = false;
+ wasDeleted = &deleted;
+ if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1
+ v = 1 - v;
+ QmlTimeLineValue::setValue(v);
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QmlAction &action = actions[ii];
+
+ if (v == 1.)
+ action.property.write(action.toValue, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
+ else {
+ if (!fromSourced && !fromDefined) {
+ action.fromValue = action.property.read();
+ if (interpolatorType)
+ QmlPropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType);
+ }
+ if (!interpolatorType) {
+ int propType = action.property.propertyType();
+ if (!prevInterpolatorType || prevInterpolatorType != propType) {
+ prevInterpolatorType = propType;
+ interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType);
+ }
+ }
+ if (interpolator)
+ action.property.write(interpolator(action.fromValue.constData(), action.toValue.constData(), v), QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
+ }
+ if (deleted)
+ return;
+ }
+ wasDeleted = 0;
+ fromSourced = true;
}
-
- d->fromSourced = false;
- d->value.QmlTimeLineValue::setValue(0.);
- d->va->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped);
- d->va->setFromSourcedValue(&d->fromSourced);
-}
+};
void QmlPropertyAnimation::transition(QmlStateActions &actions,
QmlMetaProperties &modified,
TransitionDirection direction)
{
Q_D(QmlPropertyAnimation);
- Q_UNUSED(direction);
-
- struct PropertyUpdater : public QmlTimeLineValue
- {
- QmlStateActions actions;
- int interpolatorType; //for Number/ColorAnimation
- int prevInterpolatorType; //for generic
- QVariantAnimation::Interpolator interpolator;
- bool reverse;
- bool *wasDeleted;
- PropertyUpdater() : wasDeleted(0) {}
- ~PropertyUpdater() { if (wasDeleted) *wasDeleted = true; }
- void setValue(qreal v)
- {
- bool deleted = false;
- wasDeleted = &deleted;
- if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1
- v = 1 - v;
- QmlTimeLineValue::setValue(v);
- for (int ii = 0; ii < actions.count(); ++ii) {
- QmlAction &action = actions[ii];
-
- if (v == 1.)
- action.property.write(action.toValue, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
- else {
- if (action.fromValue.isNull()) {
- action.fromValue = action.property.read();
- if (interpolatorType)
- QmlPropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType);
- }
- if (!interpolatorType) {
- int propType = action.property.propertyType();
- if (!prevInterpolatorType || prevInterpolatorType != propType) {
- prevInterpolatorType = propType;
- interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType);
- }
- }
- if (interpolator)
- action.property.write(interpolator(action.fromValue.constData(), action.toValue.constData(), v), QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding);
- }
- if (deleted)
- return;
- }
- wasDeleted = 0;
- }
- };
QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(','));
for (int ii = 0; ii < props.count(); ++ii)
props[ii] = props.at(ii).trimmed();
+ if (!d->propertyName.isEmpty())
+ props << d->propertyName;
- bool hasSelectors = !props.isEmpty() || !d->targets.isEmpty() || !d->exclude.isEmpty();
- bool hasTarget = !d->propertyName.isEmpty() || d->target;
+ QList<QObject*> targets = d->targets;
+ if (d->target)
+ targets.append(d->target);
- if (hasSelectors && hasTarget) {
- qmlInfo(this) << tr("matchTargets/matchProperties/exclude and target/property are mutually exclusive.");
- return;
+ bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty();
+ bool useType = (props.isEmpty() && d->defaultToInterpolatorType) ? true : false;
+
+ if (d->defaultProperty.isValid() && !hasSelectors) {
+ props << d->defaultProperty.name();
+ targets << d->defaultProperty.object();
}
- bool useType = (props.isEmpty() && d->propertyName.isEmpty() && d->defaultToInterpolatorType) ? true : false;
+ if (props.isEmpty() && !d->defaultProperties.isEmpty()) {
+ props << d->defaultProperties.split(QLatin1Char(','));
+ }
PropertyUpdater *data = new PropertyUpdater;
data->interpolatorType = d->interpolatorType;
data->interpolator = d->interpolator;
data->reverse = direction == Backward ? true : false;
+ data->fromSourced = false;
+ data->fromDefined = d->fromIsDefined;
bool hasExplicit = false;
//an explicit animation has been specified
- if (hasTarget && d->toIsDefined) {
- QmlAction myAction;
- myAction.property = d->createProperty(target(), d->propertyName, this);
- if (myAction.property.isValid()) {
- if (d->fromIsDefined) {
- d->convertVariant(d->from, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
- myAction.fromValue = d->from;
- }
- d->convertVariant(d->to, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
- myAction.toValue = d->to;
- data->actions << myAction;
- hasExplicit = true;
- for (int ii = 0; ii < actions.count(); ++ii) {
- QmlAction &action = actions[ii];
- if (action.property.object() == myAction.property.object() &&
- myAction.property.name() == action.property.name()) {
- modified << action.property;
- break; //### any chance there could be multiples?
+ if (d->toIsDefined) {
+ for (int i = 0; i < props.count(); ++i) {
+ for (int j = 0; j < targets.count(); ++j) {
+ QmlAction myAction;
+ myAction.property = d->createProperty(targets.at(j), props.at(i), this);
+ if (myAction.property.isValid()) {
+ if (d->fromIsDefined) {
+ myAction.fromValue = d->from;
+ d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
+ }
+ myAction.toValue = d->to;
+ d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
+ data->actions << myAction;
+ hasExplicit = true;
+ for (int ii = 0; ii < actions.count(); ++ii) {
+ QmlAction &action = actions[ii];
+ if (action.property.object() == myAction.property.object() &&
+ myAction.property.name() == action.property.name()) {
+ modified << action.property;
+ break; //### any chance there could be multiples?
+ }
+ }
}
}
}
@@ -2275,7 +2371,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions,
QString sPropertyName = action.specifiedProperty;
bool same = (obj == sObj);
- if ((d->targets.isEmpty() || d->targets.contains(obj) || (!same && d->targets.contains(sObj))) &&
+ if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) &&
(!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) &&
(props.contains(propertyName) || (!same && props.contains(sPropertyName))
|| (useType && action.property.propertyType() == d->interpolatorType))) {
@@ -2295,29 +2391,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions,
data->actions << myAction;
action.fromValue = myAction.toValue;
- } else if (d->userProperty.isValid() &&
- !hasSelectors && !hasTarget) {
- if ((d->userProperty.value.object() == obj || (!same && d->userProperty.value.object() == sObj)) &&
- (d->userProperty.value.name() == propertyName || (!same && d->userProperty.value.name() == sPropertyName))) {
- //### same as above. merge
- QmlAction myAction = action;
-
- if (d->fromIsDefined)
- myAction.fromValue = d->from;
- else
- myAction.fromValue = QVariant();
- if (d->toIsDefined)
- myAction.toValue = d->to;
-
- d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
- d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType());
-
- modified << action.property;
-
- data->actions << myAction;
- action.fromValue = myAction.toValue;
- }
- }
+ }
}
if (data->actions.count()) {
@@ -2327,6 +2401,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions,
d->rangeIsSet = true;
}
d->va->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped);
+ d->va->setFromSourcedValue(&data->fromSourced);
} else {
delete data;
}
diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h
index f9bbdf9..50eb577 100644
--- a/src/declarative/util/qmlanimation_p.h
+++ b/src/declarative/util/qmlanimation_p.h
@@ -94,7 +94,8 @@ public:
QmlAnimationGroup *group() const;
void setGroup(QmlAnimationGroup *);
- virtual void setTarget(const QmlMetaProperty &);
+ void setDefaultTarget(const QmlMetaProperty &);
+ void setDisableUserControl();
void classBegin();
void componentComplete();
@@ -123,11 +124,13 @@ public:
virtual void transition(QmlStateActions &actions,
QmlMetaProperties &modified,
TransitionDirection direction);
- virtual void prepare(QmlMetaProperty &);
virtual QAbstractAnimation *qtAnimation() = 0;
private Q_SLOTS:
void timelineComplete();
+
+private:
+ virtual void setTarget(const QmlMetaProperty &);
};
class QmlPauseAnimationPrivate;
@@ -186,8 +189,8 @@ class QmlPropertyAction : public QmlAbstractAnimation
Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged)
- Q_PROPERTY(QString matchProperties READ properties WRITE setProperties NOTIFY propertiesChanged)
- Q_PROPERTY(QList<QObject *>* matchTargets READ targets)
+ Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
+ Q_PROPERTY(QList<QObject *>* targets READ targets)
Q_PROPERTY(QList<QObject *>* exclude READ exclude)
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
@@ -220,7 +223,6 @@ protected:
QmlMetaProperties &modified,
TransitionDirection direction);
virtual QAbstractAnimation *qtAnimation();
- virtual void prepare(QmlMetaProperty &);
};
class QmlGraphicsItem;
@@ -231,8 +233,7 @@ class QmlParentAction : public QmlAbstractAnimation
Q_DECLARE_PRIVATE(QmlParentAction)
Q_PROPERTY(QmlGraphicsItem *target READ object WRITE setObject)
- Q_PROPERTY(QmlGraphicsItem *matchTarget READ matchTarget WRITE setMatchTarget)
- Q_PROPERTY(QmlGraphicsItem *parent READ parent WRITE setParent)
+ Q_PROPERTY(QmlGraphicsItem *parent READ parent WRITE setParent) //### newParent
public:
QmlParentAction(QObject *parent=0);
@@ -241,9 +242,6 @@ public:
QmlGraphicsItem *object() const;
void setObject(QmlGraphicsItem *);
- QmlGraphicsItem *matchTarget() const;
- void setMatchTarget(QmlGraphicsItem *);
-
QmlGraphicsItem *parent() const;
void setParent(QmlGraphicsItem *);
@@ -266,8 +264,8 @@ class Q_AUTOTEST_EXPORT QmlPropertyAnimation : public QmlAbstractAnimation
Q_PROPERTY(QString easing READ easing WRITE setEasing NOTIFY easingChanged)
Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged)
- Q_PROPERTY(QString matchProperties READ properties WRITE setProperties NOTIFY propertiesChanged)
- Q_PROPERTY(QList<QObject *>* matchTargets READ targets)
+ Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
+ Q_PROPERTY(QList<QObject *>* targets READ targets)
Q_PROPERTY(QList<QObject *>* exclude READ exclude)
public:
@@ -299,11 +297,11 @@ public:
QList<QObject *> *exclude();
protected:
+ QmlPropertyAnimation(QmlPropertyAnimationPrivate &dd, QObject *parent);
virtual void transition(QmlStateActions &actions,
QmlMetaProperties &modified,
TransitionDirection direction);
virtual QAbstractAnimation *qtAnimation();
- virtual void prepare(QmlMetaProperty &);
Q_SIGNALS:
void durationChanged(int);
@@ -370,6 +368,35 @@ public:
void setTo(QVector3D);
};
+class QmlRotationAnimationPrivate;
+class Q_AUTOTEST_EXPORT QmlRotationAnimation : public QmlPropertyAnimation
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QmlRotationAnimation)
+ Q_ENUMS(RotationDirection)
+
+ Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged)
+ Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged)
+ Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
+
+public:
+ QmlRotationAnimation(QObject *parent=0);
+ virtual ~QmlRotationAnimation();
+
+ qreal from() const;
+ void setFrom(qreal);
+
+ qreal to() const;
+ void setTo(qreal);
+
+ enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise };
+ RotationDirection direction() const;
+ void setDirection(RotationDirection direction);
+
+Q_SIGNALS:
+ void directionChanged();
+};
+
class QmlAnimationGroupPrivate;
class QmlAnimationGroup : public QmlAbstractAnimation
{
@@ -401,7 +428,6 @@ protected:
QmlMetaProperties &modified,
TransitionDirection direction);
virtual QAbstractAnimation *qtAnimation();
- virtual void prepare(QmlMetaProperty &);
};
class QmlParallelAnimation : public QmlAnimationGroup
@@ -418,7 +444,6 @@ protected:
QmlMetaProperties &modified,
TransitionDirection direction);
virtual QAbstractAnimation *qtAnimation();
- virtual void prepare(QmlMetaProperty &);
};
QT_END_NAMESPACE
@@ -434,6 +459,7 @@ QML_DECLARE_TYPE(QmlNumberAnimation)
QML_DECLARE_TYPE(QmlSequentialAnimation)
QML_DECLARE_TYPE(QmlParallelAnimation)
QML_DECLARE_TYPE(QmlVector3dAnimation)
+QML_DECLARE_TYPE(QmlRotationAnimation)
QT_END_HEADER
diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h
index 1fe0375..b2ce297 100644
--- a/src/declarative/util/qmlanimation_p_p.h
+++ b/src/declarative/util/qmlanimation_p_p.h
@@ -108,6 +108,8 @@ public:
{
if (state() == Running)
stop();
+ if (policy == DeleteWhenStopped)
+ delete animAction;
animAction = action;
policy = p;
}
@@ -126,12 +128,12 @@ protected:
animAction = 0;
}
}
- } else if (newState == Stopped && policy == DeleteWhenStopped) {
+ } /*else if (newState == Stopped && policy == DeleteWhenStopped) {
if (!running) {
delete animAction;
animAction = 0;
}
- }
+ }*/
}
private:
@@ -151,6 +153,8 @@ public:
{
if (state() == Running)
stop();
+ if (policy == DeleteWhenStopped)
+ delete animValue;
animValue = value;
policy = p;
}
@@ -165,16 +169,17 @@ protected:
animValue->setValue(value.toReal());
}
virtual void updateState(State newState, State oldState)
- {
+ {
QVariantAnimation::updateState(newState, oldState);
if (newState == Running) {
//check for new from every loop
if (fromSourced)
*fromSourced = false;
- } else if (newState == Stopped && policy == DeleteWhenStopped) {
+ } /*else if (newState == Stopped && policy == DeleteWhenStopped) {
delete animValue;
animValue = 0;
- }
+ }*/ //### we get a stop each loop if we are in a group
+ //### top-level animation is the only reliable one for this
}
private:
@@ -204,24 +209,22 @@ class QmlAbstractAnimationPrivate : public QObjectPrivate
public:
QmlAbstractAnimationPrivate()
: running(false), paused(false), alwaysRunToEnd(false), repeat(false),
- connectedTimeLine(false), componentComplete(true), startOnCompletion(false),
- avoidPropertyValueSourceStart(false), group(0) {}
+ connectedTimeLine(false), componentComplete(true),
+ avoidPropertyValueSourceStart(false), disableUserControl(false), group(0) {}
bool running:1;
bool paused:1;
bool alwaysRunToEnd:1;
bool repeat:1;
bool connectedTimeLine:1;
-
bool componentComplete:1;
- bool startOnCompletion:1;
bool avoidPropertyValueSourceStart:1;
+ bool disableUserControl:1;
void commence();
- QmlNullableValue<QmlMetaProperty> userProperty;
+ QmlMetaProperty defaultProperty;
- QmlMetaProperty property;
QmlAnimationGroup *group;
static QmlMetaProperty createProperty(QObject *obj, const QString &str, QObject *infoObj);
@@ -265,7 +268,7 @@ class QmlPropertyActionPrivate : public QmlAbstractAnimationPrivate
Q_DECLARE_PUBLIC(QmlPropertyAction)
public:
QmlPropertyActionPrivate()
- : QmlAbstractAnimationPrivate(), target(0), proxy(this), spa(0) {}
+ : QmlAbstractAnimationPrivate(), target(0), spa(0) {}
void init();
@@ -277,10 +280,6 @@ public:
QmlNullableValue<QVariant> value;
- void doAction();
-
- QAnimationActionProxy<QmlPropertyActionPrivate,
- &QmlPropertyActionPrivate::doAction> proxy;
QActionAnimation *spa;
};
@@ -289,12 +288,11 @@ class QmlParentActionPrivate : public QmlAbstractAnimationPrivate
Q_DECLARE_PUBLIC(QmlParentAction)
public:
QmlParentActionPrivate()
- : QmlAbstractAnimationPrivate(), pcTarget(0), pcMatchTarget(0), pcParent(0) {}
+ : QmlAbstractAnimationPrivate(), pcTarget(0), pcParent(0) {}
void init();
QmlGraphicsItem *pcTarget;
- QmlGraphicsItem *pcMatchTarget;
QmlGraphicsItem *pcParent;
void doAction();
@@ -346,8 +344,7 @@ class QmlPropertyAnimationPrivate : public QmlAbstractAnimationPrivate
public:
QmlPropertyAnimationPrivate()
: QmlAbstractAnimationPrivate(), target(0), fromSourced(false), fromIsDefined(false), toIsDefined(false),
- rangeIsSet(false), defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0),
- value(this, &QmlPropertyAnimationPrivate::valueChanged) {}
+ rangeIsSet(false), defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0) {}
void init();
@@ -361,6 +358,7 @@ public:
QString properties;
QList<QObject *> targets;
QList<QObject *> exclude;
+ QString defaultProperties;
bool fromSourced;
bool fromIsDefined:1;
@@ -371,14 +369,20 @@ public:
QVariantAnimation::Interpolator interpolator;
QmlTimeLineValueAnimator *va;
- virtual void valueChanged(qreal);
-
- QmlTimeLineValueProxy<QmlPropertyAnimationPrivate> value;
static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress);
static void convertVariant(QVariant &variant, int type);
};
+class QmlRotationAnimationPrivate : public QmlPropertyAnimationPrivate
+{
+ Q_DECLARE_PUBLIC(QmlRotationAnimation)
+public:
+ QmlRotationAnimationPrivate() : direction(QmlRotationAnimation::Shortest) {}
+
+ QmlRotationAnimation::RotationDirection direction;
+};
+
QT_END_NAMESPACE
#endif // QMLANIMATION_P_H
diff --git a/src/declarative/util/qmlbehavior.cpp b/src/declarative/util/qmlbehavior.cpp
index 2367694..d65d8cd 100644
--- a/src/declarative/util/qmlbehavior.cpp
+++ b/src/declarative/util/qmlbehavior.cpp
@@ -124,8 +124,10 @@ void QmlBehavior::setAnimation(QmlAbstractAnimation *animation)
}
d->animation = animation;
- if (d->animation)
- d->animation->setTarget(d->property);
+ if (d->animation) {
+ d->animation->setDefaultTarget(d->property);
+ d->animation->setDisableUserControl();
+ }
}
/*!
@@ -183,7 +185,7 @@ void QmlBehavior::setTarget(const QmlMetaProperty &property)
d->property = property;
d->currentValue = property.read();
if (d->animation)
- d->animation->setTarget(property);
+ d->animation->setDefaultTarget(property);
}
QT_END_NAMESPACE
diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp
index ee35d2e..af41dfd 100644
--- a/src/declarative/util/qmllistmodel.cpp
+++ b/src/declarative/util/qmllistmodel.cpp
@@ -806,7 +806,23 @@ bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QL
qvariant_cast<QmlParser::Variant>(value);
int ref = data.count();
- QByteArray d = variant.asScript().toUtf8();
+
+ QByteArray d;
+ d += char(variant.type()); // type tag
+ if (variant.isString()) {
+ d += variant.asString().toUtf8();
+ } else if (variant.isNumber()) {
+ d += QByteArray::number(variant.asNumber(),'g',20);
+ } else if (variant.isBoolean()) {
+ d += char(variant.asBoolean());
+ } else if (variant.isScript()) {
+ if (definesEmptyList(variant.asScript())) {
+ d[0] = 0; // QmlParser::Variant::Invalid - marks empty list
+ } else {
+ error(prop, QmlListModel::tr("ListElement: cannot use script for property value"));
+ return false;
+ }
+ }
d.append('\0');
data.append(d);
@@ -814,7 +830,6 @@ bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QL
li.type = ListInstruction::Value;
li.dataIdx = ref;
instr << li;
-
}
}
@@ -892,15 +907,22 @@ void QmlListModelParser::setCustomData(QObject *obj, const QByteArray &d)
case ListInstruction::Value:
{
ModelNode *n = nodes.top();
- QString s = QString::fromUtf8(QByteArray(data + instr.dataIdx));
-
- bool isEmptyList = false;
- if (!n->isArray)
- isEmptyList = definesEmptyList(s);
- if (isEmptyList)
+ switch (QmlParser::Variant::Type(data[instr.dataIdx])) {
+ case QmlParser::Variant::Invalid:
n->isArray = true;
- else
- n->values.append(s);
+ break;
+ case QmlParser::Variant::Boolean:
+ n->values.append(bool(data[1 + instr.dataIdx]));
+ break;
+ case QmlParser::Variant::Number:
+ n->values.append(QByteArray(data + 1 + instr.dataIdx).toDouble());
+ break;
+ case QmlParser::Variant::String:
+ n->values.append(QString::fromUtf8(data + 1 + instr.dataIdx));
+ break;
+ default:
+ Q_ASSERT("Format error in ListInstruction");
+ }
processingSet = false;
}
diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp
index f833501..56903ce 100644
--- a/src/declarative/util/qmlpixmapcache.cpp
+++ b/src/declarative/util/qmlpixmapcache.cpp
@@ -41,11 +41,13 @@
#include "qmlpixmapcache_p.h"
#include "qmlnetworkaccessmanagerfactory.h"
+#include "qmlimageprovider.h"
#include "qfxperf_p_p.h"
#include <qmlengine.h>
#include <private/qmlglobal_p.h>
+#include <private/qmlengine_p.h>
#include <QCoreApplication>
#include <QImageReader>
@@ -82,7 +84,7 @@ class QmlImageReaderEvent : public QEvent
public:
enum ReadError { NoError, Loading, Decoding };
- QmlImageReaderEvent(QmlImageReaderEvent::ReadError err, const QString &errStr, QImage &img)
+ QmlImageReaderEvent(QmlImageReaderEvent::ReadError err, const QString &errStr, const QImage &img)
: QEvent(QEvent::User), error(err), errorString(errStr), image(img) {}
ReadError error;
@@ -143,13 +145,8 @@ private slots:
private:
QNetworkAccessManager *networkAccessManager() {
- if (!accessManager) {
- if (engine && engine->networkAccessManagerFactory()) {
- accessManager = engine->networkAccessManagerFactory()->create(this);
- } else {
- accessManager = new QNetworkAccessManager(this);
- }
- }
+ if (!accessManager)
+ accessManager = QmlEnginePrivate::get(engine)->createNetworkAccessManager(this);
return accessManager;
}
@@ -197,21 +194,32 @@ bool QmlImageRequestHandler::event(QEvent *event)
break;
}
- QmlPixmapReply *runningJob = reader->jobs.takeFirst();
+ QmlPixmapReply *runningJob = reader->jobs.takeLast();
runningJob->addRef();
runningJob->setLoading();
QUrl url = runningJob->url();
reader->mutex.unlock();
// fetch
- QNetworkRequest req(url);
- req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
- QNetworkReply *reply = networkAccessManager()->get(req);
+ if (url.scheme() == QLatin1String("image")) {
+ QImage image = QmlEnginePrivate::get(engine)->getImageFromProvider(url);
+ QmlImageReaderEvent::ReadError errorCode = QmlImageReaderEvent::NoError;
+ QString errorStr;
+ if (image.isNull()) {
+ errorCode = QmlImageReaderEvent::Loading;
+ errorStr = QLatin1String("Failed to get image from provider: ") + url.toString();
+ }
+ QCoreApplication::postEvent(runningJob, new QmlImageReaderEvent(errorCode, errorStr, image));
+ } else {
+ QNetworkRequest req(url);
+ req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
+ QNetworkReply *reply = networkAccessManager()->get(req);
- QMetaObject::connect(reply, replyDownloadProgress, runningJob, downloadProgress);
- QMetaObject::connect(reply, replyFinished, this, thisNetworkRequestDone);
+ QMetaObject::connect(reply, replyDownloadProgress, runningJob, downloadProgress);
+ QMetaObject::connect(reply, replyFinished, this, thisNetworkRequestDone);
- replies.insert(reply, runningJob);
+ replies.insert(reply, runningJob);
+ }
}
return true;
}
@@ -259,12 +267,12 @@ QmlImageReader::QmlImageReader(QmlEngine *eng)
QmlImageReader::~QmlImageReader()
{
- quit();
- wait();
readerMutex.lock();
readers.remove(engine);
readerMutex.unlock();
- delete handler;
+
+ quit();
+ wait();
}
QmlImageReader *QmlImageReader::instance(QmlEngine *engine)
@@ -327,6 +335,9 @@ void QmlImageReader::run()
handler = new QmlImageRequestHandler(this, engine);
exec();
+
+ delete handler;
+ handler = 0;
}
//===========================================================================
@@ -600,6 +611,6 @@ int QmlPixmapCache::pendingRequests()
return qmlActivePixmapReplies()->count();
}
-#include <qmlpixmapcache.moc>
-
QT_END_NAMESPACE
+
+#include <qmlpixmapcache.moc>
diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp
index c53b0e5..d289e17 100644
--- a/src/declarative/util/qmlstategroup.cpp
+++ b/src/declarative/util/qmlstategroup.cpp
@@ -55,8 +55,6 @@ QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
-QML_DEFINE_TYPE(Qt,4,6,StateGroup,QmlStateGroup)
-
class QmlStateGroupPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QmlStateGroup)
@@ -421,3 +419,5 @@ void QmlStateGroup::removeState(QmlState *state)
}
QT_END_NAMESPACE
+
+QML_DEFINE_TYPE(Qt,4,6,StateGroup,QmlStateGroup)
diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp
index d1b2339..bd1f5f0 100644
--- a/src/declarative/util/qmlstateoperations.cpp
+++ b/src/declarative/util/qmlstateoperations.cpp
@@ -403,7 +403,7 @@ QString QmlStateChangeScript::typeName() const
so you can animate them as you would normally changes to these properties:
\qml
//animate our anchor changes
- NumberAnimation { matchTargets: content; matchProperties: "x,y,width,height" }
+ NumberAnimation { targets: content; properties: "x,y,width,height" }
\endqml
For more information on anchors see \l {anchor-layout}{Anchor Layouts}.
diff --git a/src/declarative/util/qmlstyledtext.cpp b/src/declarative/util/qmlstyledtext.cpp
index 1dc7bce..1f31214 100644
--- a/src/declarative/util/qmlstyledtext.cpp
+++ b/src/declarative/util/qmlstyledtext.cpp
@@ -58,6 +58,8 @@
The opening and closing tags must be correctly nested.
*/
+QT_BEGIN_NAMESPACE
+
class QmlStyledTextPrivate
{
public:
@@ -341,3 +343,5 @@ QStringRef QmlStyledTextPrivate::parseValue(const QChar *&ch, const QString &tex
return QStringRef(&textIn, valStart, valLength);
}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/util/qmlstyledtext_p.h b/src/declarative/util/qmlstyledtext_p.h
index a746594..4698279 100644
--- a/src/declarative/util/qmlstyledtext_p.h
+++ b/src/declarative/util/qmlstyledtext_p.h
@@ -44,10 +44,13 @@
#include <QSizeF>
+QT_BEGIN_NAMESPACE
+
class QPainter;
class QPointF;
class QString;
class QmlStyledTextPrivate;
+
class Q_DECLARATIVE_EXPORT QmlStyledText
{
public:
@@ -60,4 +63,6 @@ private:
QmlStyledTextPrivate *d;
};
+QT_END_NAMESPACE
+
#endif
diff --git a/src/declarative/util/qmltimeline_p_p.h b/src/declarative/util/qmltimeline_p_p.h
index f335e7d..f271a3f 100644
--- a/src/declarative/util/qmltimeline_p_p.h
+++ b/src/declarative/util/qmltimeline_p_p.h
@@ -154,14 +154,6 @@ public:
QmlTimeLineEvent(const QmlTimeLineEvent &o);
template<class T, void (T::*method)()>
- QmlTimeLineEvent(QmlTimeLineObject *b, T *c)
- {
- d0 = &callFunc<T, method>;
- d1 = (void *)c;
- d2 = b;
- }
-
- template<class T, void (T::*method)()>
static QmlTimeLineEvent timeLineEvent(QmlTimeLineObject *b, T *c)
{
QmlTimeLineEvent rv;
diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp
index 22826ce..e4e53d6 100644
--- a/src/declarative/util/qmltransition.cpp
+++ b/src/declarative/util/qmltransition.cpp
@@ -86,6 +86,7 @@ public:
, reversed(false), reversible(false), endState(0)
{
animations.parent = this;
+ group.trans = this;
}
QString fromState;
@@ -95,11 +96,6 @@ public:
ParallelAnimationWrapper group;
QmlTransitionManager *endState;
- void init()
- {
- group.trans = this;
- }
-
void complete()
{
endState->complete();
@@ -121,6 +117,7 @@ void QmlTransitionPrivate::AnimationList::append(QmlAbstractAnimation *a)
{
QmlConcreteList<QmlAbstractAnimation *>::append(a);
parent->group.addAnimation(a->qtAnimation());
+ a->setDisableUserControl();
}
void ParallelAnimationWrapper::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
@@ -139,8 +136,6 @@ QML_DEFINE_TYPE(Qt,4,6,Transition,QmlTransition)
QmlTransition::QmlTransition(QObject *parent)
: QObject(*(new QmlTransitionPrivate), parent)
{
- Q_D(QmlTransition);
- d->init();
}
QmlTransition::~QmlTransition()
diff --git a/src/declarative/util/qmlview.cpp b/src/declarative/util/qmlview.cpp
index 702b054..4a6d697 100644
--- a/src/declarative/util/qmlview.cpp
+++ b/src/declarative/util/qmlview.cpp
@@ -64,6 +64,7 @@
#include <qboxlayout.h>
#include <qbasictimer.h>
#include <QtCore/qabstractanimation.h>
+#include <private/qgraphicsview_p.h>
QT_BEGIN_NAMESPACE
@@ -125,24 +126,24 @@ void FrameBreakAnimation::updateCurrentTime(int msecs)
server->frameBreak();
}
-class QmlViewPrivate
+class QmlViewPrivate : public QGraphicsViewPrivate
{
+ Q_DECLARE_PUBLIC(QmlView)
public:
- QmlViewPrivate(QmlView *w)
- : q(w), root(0), component(0), resizable(false) {}
+ QmlViewPrivate()
+ : root(0), component(0), resizeMode(QmlView::SizeViewToRootObject) {}
- QmlView *q;
- QmlGraphicsItem *root;
+ QGuard<QGraphicsObject> root;
+ QGuard<QmlGraphicsItem> qmlRoot;
QUrl source;
- QString qml;
QmlEngine engine;
QmlComponent *component;
QBasicTimer resizetimer;
- QSize initialSize;
- bool resizable;
+ mutable QSize initialSize;
+ QmlView::ResizeMode resizeMode;
QTime frameTimer;
void init();
@@ -154,9 +155,30 @@ public:
\class QmlView
\brief The QmlView class provides a widget for displaying a Qt Declarative user interface.
- QmlView currently provides a minimal interface for displaying QML
+ Any QGraphicsObject or QmlGraphicsItem
+ created via QML can be placed on a standard QGraphicsScene and viewed with a standard
+ QGraphicsView.
+
+ QmlView is a QGraphicsView subclass provided as a convenience for displaying QML
files, and connecting between QML and C++ Qt objects.
+ QmlView performs the following functions:
+
+ \list
+ \o Manages QmlComponent loading and object creation.
+ \o Initializes QGraphicsView for optimal performance with QML:
+ \list
+ \o QGraphicsView::setOptimizationFlags(QGraphicsView::DontSavePainterState);
+ \o QGraphicsView::setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
+ \o QGraphicsScene::setItemIndexMethod(QGraphicsScene::NoIndex);
+ \endlist
+ \o Initializes QGraphicsView for QML key handling:
+ \list
+ \o QGraphicsView::viewport()->setFocusPolicy(Qt::NoFocus);
+ \o QGraphicsScene::setStickyFocus(true);
+ \endlist
+ \endlist
+
Typical usage:
\code
...
@@ -164,7 +186,7 @@ public:
vbox->addWidget(view);
QUrl url(fileName);
- view->setUrl(url);
+ view->setSource(url);
...
view->execute();
...
@@ -172,7 +194,17 @@ public:
\endcode
To receive errors related to loading and executing QML with QmlView,
- you can connect to the errors() signal.
+ you can connect to the statusChanged() signal and monitor for QmlView::Error.
+ The errors are available via QmlView::errors().
+*/
+
+
+/*! \fn void QmlView::sceneResized(QSize size)
+ This signal is emitted when the view is resized to \a size.
+*/
+
+/*! \fn void QmlView::statusChanged(QmlView::Status status)
+ This signal is emitted when the component's current \l{QmlView::Status} {status} changes.
*/
/*!
@@ -181,14 +213,16 @@ public:
Constructs a QmlView with the given \a parent.
*/
QmlView::QmlView(QWidget *parent)
-: QGraphicsView(parent), d(new QmlViewPrivate(this))
+: QGraphicsView(*(new QmlViewPrivate), parent)
{
+ Q_D(QmlView);
setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
d->init();
}
void QmlViewPrivate::init()
{
+ Q_Q(QmlView);
#ifdef Q_ENABLE_PERFORMANCE_LOG
{
QmlPerfTimer<QmlPerf::FontDatabase> perf;
@@ -212,61 +246,46 @@ void QmlViewPrivate::init()
}
/*!
- The destructor clears the view's \l {QmlGraphicsItem} {items} and
+ The destructor clears the view's \l {QGraphicsObject} {items} and
deletes the internal representation.
-
- \sa clearItems()
*/
QmlView::~QmlView()
{
- clearItems();
- delete d; d = 0;
+ Q_D(QmlView);
+ delete d->root;
}
/*!
- Sets the source to the \a url. The QML string is set to
- empty.
+ Sets the source to the \a url.
+
+ Call \l execute() to load the QML and instantiate the component.
+
+ \sa execute()
*/
-void QmlView::setUrl(const QUrl& url)
+void QmlView::setSource(const QUrl& url)
{
+ Q_D(QmlView);
d->source = url;
- d->qml = QString();
}
/*!
Returns the source URL, if set.
- \sa setUrl()
+ \sa setSource()
*/
-QUrl QmlView::url() const
+QUrl QmlView::source() const
{
+ Q_D(const QmlView);
return d->source;
}
/*!
- Sets the source to the URL from the \a filename, and sets
- the QML string to \a qml.
- */
-void QmlView::setQml(const QString &qml, const QString &filename)
-{
- d->source = QUrl::fromLocalFile(filename);
- d->qml = qml;
-}
-
-/*!
- Returns the QML string.
- */
-QString QmlView::qml() const
-{
- return d->qml;
-}
-
-/*!
Returns a pointer to the QmlEngine used for instantiating
QML Components.
*/
QmlEngine* QmlView::engine()
{
+ Q_D(QmlView);
return &d->engine;
}
@@ -279,21 +298,21 @@ QmlEngine* QmlView::engine()
*/
QmlContext* QmlView::rootContext()
{
+ Q_D(QmlView);
return d->engine.rootContext();
}
/*!
- Displays the Qt Declarative user interface.
+ Loads and instantiates the QML component set by the \l setSource() method.
+
+ \sa setSource()
*/
void QmlView::execute()
{
- if (d->qml.isEmpty()) {
- d->component = new QmlComponent(&d->engine, d->source, this);
- } else {
- d->component = new QmlComponent(&d->engine, this);
- d->component->setData(d->qml.toUtf8(), d->source);
- }
- connect (&d->engine, SIGNAL (quit ()), this, SIGNAL (quit ()));
+ Q_D(QmlView);
+ delete d->root;
+ delete d->component;
+ d->component = new QmlComponent(&d->engine, d->source, this);
if (!d->component->isLoading()) {
continueExecute();
@@ -302,26 +321,100 @@ void QmlView::execute()
}
}
+/*!
+ \enum QmlView::Status
+
+ Specifies the loading status of the QmlView.
+
+ \value Null This QmlView has no source set.
+ \value Ready This QmlView has loaded and created the QML component.
+ \value Loading This QmlView is loading network data.
+ \value Error An error has occured. Calling errorDescription() to retrieve a description.
+*/
+
+/*!
+ \property QmlView::status
+ The component's current \l{QmlView::Status} {status}.
+*/
+
+QmlView::Status QmlView::status() const
+{
+ Q_D(const QmlView);
+ if (!d->component)
+ return QmlView::Null;
+
+ return QmlView::Status(d->component->status());
+}
+
+/*!
+ Return the list of errors that occured during the last compile or create
+ operation. An empty list is returned if isError() is not set.
+*/
+QList<QmlError> QmlView::errors() const
+{
+ Q_D(const QmlView);
+ if (d->component)
+ return d->component->errors();
+ return QList<QmlError>();
+}
+
+
+/*!
+ \property QmlView::resizeMode
+ \brief whether the view should resize the canvas contents
+
+ If this property is set to SizeViewToRootObject (the default), the view
+ resizes with the root item in the QML.
+
+ If this property is set to SizeRootObjectToView, the view will
+ automatically resize the root item.
+
+ Regardless of this property, the sizeHint of the view
+ is the initial size of the root item. Note though that
+ since QML may load dynamically, that size may change.
+
+ \sa initialSize()
+*/
+
+void QmlView::setResizeMode(ResizeMode mode)
+{
+ Q_D(QmlView);
+ if (d->resizeMode == mode)
+ return;
+
+ d->resizeMode = mode;
+ if (d->qmlRoot) {
+ if (d->resizeMode == SizeRootObjectToView) {
+ d->qmlRoot->setWidth(width());
+ d->qmlRoot->setHeight(height());
+ } else {
+ d->qmlRoot->setWidth(d->initialSize.width());
+ d->qmlRoot->setHeight(d->initialSize.height());
+ }
+ }
+}
+
+QmlView::ResizeMode QmlView::resizeMode() const
+{
+ Q_D(const QmlView);
+ return d->resizeMode;
+}
/*!
\internal
*/
void QmlView::continueExecute()
{
- disconnect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute()));
+ Q_D(QmlView);
- if (!d->component) {
- qWarning() << "Error in loading" << d->source;
- return;
- }
+ disconnect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute()));
- if(d->component->isError()) {
+ if (d->component->isError()) {
QList<QmlError> errorList = d->component->errors();
foreach (const QmlError &error, errorList) {
qWarning() << error;
}
- emit errors(errorList);
-
+ emit statusChanged(status());
return;
}
@@ -332,8 +425,7 @@ void QmlView::continueExecute()
foreach (const QmlError &error, errorList) {
qWarning() << error;
}
- emit errors(errorList);
-
+ emit statusChanged(status());
return;
}
@@ -345,24 +437,27 @@ void QmlView::continueExecute()
QPerformanceLog::displayData();
QPerformanceLog::clear();
d->root = item;
+ d->qmlRoot = item;
connect(item, SIGNAL(widthChanged()), this, SLOT(sizeChanged()));
connect(item, SIGNAL(heightChanged()), this, SLOT(sizeChanged()));
- if (d->initialSize.height() <= 0 && d->root->width() > 0)
- d->initialSize.setWidth(d->root->width());
- if (d->initialSize.height() <= 0 && d->root->height() > 0)
- d->initialSize.setHeight(d->root->height());
+ if (d->initialSize.height() <= 0 && d->qmlRoot->width() > 0)
+ d->initialSize.setWidth(d->qmlRoot->width());
+ if (d->initialSize.height() <= 0 && d->qmlRoot->height() > 0)
+ d->initialSize.setHeight(d->qmlRoot->height());
resize(d->initialSize);
- if (d->resizable) {
- d->root->setWidth(width());
- d->root->setHeight(height());
+ if (d->resizeMode == SizeRootObjectToView) {
+ d->qmlRoot->setWidth(width());
+ d->qmlRoot->setHeight(height());
} else {
- QSize sz(d->root->width(),d->root->height());
+ QSize sz(d->qmlRoot->width(),d->qmlRoot->height());
emit sceneResized(sz);
resize(sz);
}
updateGeometry();
- emit initialSize(d->initialSize);
+ } else if (QGraphicsObject *item = qobject_cast<QGraphicsObject *>(obj)) {
+ d->scene.addItem(item);
+ qWarning() << "QmlView::resizeMode is not honored for components of type QGraphicsObject";
} else if (QWidget *wid = qobject_cast<QWidget *>(obj)) {
window()->setAttribute(Qt::WA_OpaquePaintEvent, false);
window()->setAttribute(Qt::WA_NoSystemBackground, false);
@@ -377,45 +472,32 @@ void QmlView::continueExecute()
}
layout()->addWidget(wid);
emit sceneResized(wid->size());
- emit initialSize(wid->size());
}
}
+ emit statusChanged(status());
}
-/*! \fn void QmlView::sceneResized(QSize size)
- This signal is emitted when the view is resized to \a size.
- */
-
-/*! \fn void QmlView::initialSize(QSize size)
- This signal is emitted when the initial \a size of the root item is known.
- */
-
-/*! \fn void QmlView::errors(const QList<QmlError> &errors)
- This signal is emitted when the qml loaded contains \a errors.
- */
-
-/*! \fn void QmlView::quit()
- \internal
- */
-
/*!
\internal
*/
void QmlView::sizeChanged()
{
+ Q_D(QmlView);
// delay, so we catch both width and height changing.
d->resizetimer.start(0,this);
}
/*!
+ \internal
If the \l {QTimerEvent} {timer event} \a e is this
view's resize timer, sceneResized() is emitted.
*/
void QmlView::timerEvent(QTimerEvent* e)
{
+ Q_D(QmlView);
if (!e || e->timerId() == d->resizetimer.timerId()) {
- if (d->root) {
- QSize sz(d->root->width(),d->root->height());
+ if (d->qmlRoot) {
+ QSize sz(d->qmlRoot->width(),d->qmlRoot->height());
emit sceneResized(sz);
//if (!d->resizable)
//resize(sz);
@@ -425,147 +507,47 @@ void QmlView::timerEvent(QTimerEvent* e)
}
}
-// modelled on QScrollArea::widgetResizable
-/*!
- \property QmlView::contentResizable
- \brief whether the view should resize the canvas contents
-
- If this property is set to false (the default), the view
- resizes with the root item in the QML.
-
- If this property is set to true, the view will
- automatically resize the root item.
-
- Regardless of this property, the sizeHint of the view
- is the initial size of the root item. Note though that
- since QML may load dynamically, that size may change.
-
- \sa initialSize()
-*/
-
-void QmlView::setContentResizable(bool on)
-{
- if (d->resizable != on) {
- d->resizable = on;
- if (d->root) {
- if (on) {
- d->root->setWidth(width());
- d->root->setHeight(height());
- } else {
- d->root->setWidth(d->initialSize.width());
- d->root->setHeight(d->initialSize.height());
- }
- }
- }
-}
-
-bool QmlView::contentResizable() const
-{
- return d->resizable;
-}
-
-
/*!
+ \internal
The size hint is the size of the root item.
*/
QSize QmlView::sizeHint() const
{
- if (d->root) {
+ Q_D(const QmlView);
+ if (d->qmlRoot) {
if (d->initialSize.width() <= 0)
- d->initialSize.setWidth(d->root->width());
+ d->initialSize.setWidth(d->qmlRoot->width());
if (d->initialSize.height() <= 0)
- d->initialSize.setHeight(d->root->height());
+ d->initialSize.setHeight(d->qmlRoot->height());
}
return d->initialSize;
}
/*!
- Creates a \l{QmlComponent} {component} from the \a qml
- string, and returns it as an \l {QmlGraphicsItem} {item}. If the
- \a parent item is provided, it becomes the new item's
- parent. \a parent should be in this view's item hierarchy.
+ Returns the view's root \l {QGraphicsObject} {item}.
*/
-QmlGraphicsItem* QmlView::addItem(const QString &qml, QmlGraphicsItem* parent)
-{
- if (!d->root)
- return 0;
-
- QmlComponent component(&d->engine);
- component.setData(qml.toUtf8(), QUrl());
- if(d->component->isError()) {
- QList<QmlError> errorList = d->component->errors();
- foreach (const QmlError &error, errorList) {
- qWarning() << error;
- }
- emit errors(errorList);
-
- return 0;
- }
-
- QObject *obj = component.create();
- if(d->component->isError()) {
- QList<QmlError> errorList = d->component->errors();
- foreach (const QmlError &error, errorList) {
- qWarning() << error;
- }
- emit errors(errorList);
-
- return 0;
- }
-
- if (obj){
- QmlGraphicsItem *item = static_cast<QmlGraphicsItem *>(obj);
- if (!parent)
- parent = d->root;
-
- item->setParentItem(parent);
- return item;
- }
- return 0;
-}
-
-/*!
- Deletes the view's \l {QmlGraphicsItem} {items} and clears the \l {QmlEngine}
- {QML engine's} Component cache.
- */
-void QmlView::reset()
-{
- clearItems();
- d->engine.clearComponentCache();
- d->initialSize = QSize();
-}
-
-/*!
- Deletes the view's \l {QmlGraphicsItem} {items}.
- */
-void QmlView::clearItems()
-{
- if (!d->root)
- return;
- delete d->root;
- d->root = 0;
-}
-
-/*!
- Returns the view's root \l {QmlGraphicsItem} {item}.
- */
-QmlGraphicsItem *QmlView::root() const
+QGraphicsObject *QmlView::rootObject() const
{
+ Q_D(const QmlView);
return d->root;
}
/*!
+ \internal
This function handles the \l {QResizeEvent} {resize event}
\a e.
*/
void QmlView::resizeEvent(QResizeEvent *e)
{
- if (d->resizable && d->root) {
- d->root->setWidth(width());
- d->root->setHeight(height());
+ Q_D(QmlView);
+ if (d->resizeMode == SizeRootObjectToView && d->qmlRoot) {
+ d->qmlRoot->setWidth(width());
+ d->qmlRoot->setHeight(height());
}
- if (d->root) {
- setSceneRect(QRectF(0, 0, d->root->width(), d->root->height()));
+ if (d->qmlRoot) {
+ setSceneRect(QRectF(0, 0, d->qmlRoot->width(), d->qmlRoot->height()));
+ } else if (d->root) {
+ setSceneRect(d->root->boundingRect());
} else {
setSceneRect(rect());
}
@@ -573,10 +555,11 @@ void QmlView::resizeEvent(QResizeEvent *e)
}
/*!
- \reimp
+ \internal
*/
void QmlView::paintEvent(QPaintEvent *event)
{
+ Q_D(QmlView);
int time = 0;
if (frameRateDebug() || QmlViewDebugServer::isDebuggingEnabled())
time = d->frameTimer.restart();
diff --git a/src/declarative/util/qmlview.h b/src/declarative/util/qmlview.h
index 3fa9d37..1c6d865 100644
--- a/src/declarative/util/qmlview.h
+++ b/src/declarative/util/qmlview.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QFXVIEW_H
-#define QFXVIEW_H
+#ifndef QMLVIEW_H
+#define QMLVIEW_H
#include <QtCore/qdatetime.h>
#include <QtGui/qgraphicssceneevent.h>
@@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QmlGraphicsItem;
+class QGraphicsObject;
class QmlEngine;
class QmlContext;
class QmlError;
@@ -62,35 +62,38 @@ class QmlViewPrivate;
class Q_DECLARATIVE_EXPORT QmlView : public QGraphicsView
{
Q_OBJECT
- Q_PROPERTY(bool contentResizable READ contentResizable WRITE setContentResizable)
+ Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+
+ Q_DECLARE_PRIVATE(QmlView)
+
public:
explicit QmlView(QWidget *parent = 0);
-
virtual ~QmlView();
- void setUrl(const QUrl&);
- QUrl url() const;
- void setQml(const QString &qml, const QString &filename=QString());
- QString qml() const;
+ QUrl source() const;
+ void setSource(const QUrl&);
+
QmlEngine* engine();
QmlContext* rootContext();
- virtual void execute();
- virtual void reset();
+ void execute();
- virtual QmlGraphicsItem* addItem(const QString &qml, QmlGraphicsItem* parent=0);
- virtual void clearItems();
+ QGraphicsObject *rootObject() const;
- virtual QmlGraphicsItem *root() const;
+ enum ResizeMode { SizeViewToRootObject, SizeRootObjectToView };
+ ResizeMode resizeMode() const;
+ void setResizeMode(ResizeMode);
+
+ enum Status { Null, Ready, Loading, Error };
+ Status status() const;
+
+ QList<QmlError> errors() const;
- void setContentResizable(bool);
- bool contentResizable() const;
QSize sizeHint() const;
Q_SIGNALS:
- void initialSize(QSize size);
- void sceneResized(QSize size);
- void errors(const QList<QmlError> &error);
- void quit();
+ void sceneResized(QSize size); // ???
+ void statusChanged(QmlView::Status);
private Q_SLOTS:
void continueExecute();
@@ -100,14 +103,10 @@ protected:
virtual void resizeEvent(QResizeEvent *);
virtual void paintEvent(QPaintEvent *event);
void timerEvent(QTimerEvent*);
-
-private:
- friend class QmlViewPrivate;
- QmlViewPrivate *d;
};
QT_END_NAMESPACE
QT_END_HEADER
-#endif // QFXVIEW_H
+#endif // QMLVIEW_H
diff --git a/src/declarative/util/qmlxmllistmodel.cpp b/src/declarative/util/qmlxmllistmodel.cpp
index 7975959..0e939bf 100644
--- a/src/declarative/util/qmlxmllistmodel.cpp
+++ b/src/declarative/util/qmlxmllistmodel.cpp
@@ -125,8 +125,10 @@ private:
QString m_name;
QString m_query;
};
-
+QT_END_NAMESPACE
QML_DECLARE_TYPE(QmlXmlListModelRole)
+QT_BEGIN_NAMESPACE
+
class QmlXmlListModelPrivate;
struct QmlXmlRoleList : public QmlConcreteList<QmlXmlListModelRole *>
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 336be91..4ec2ae2 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -122,15 +122,19 @@ extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp
static void initResources()
{
#if defined(Q_WS_WINCE)
+ Q_INIT_RESOURCE_EXTERN(qstyle_wince)
Q_INIT_RESOURCE(qstyle_wince);
#elif defined(Q_OS_SYMBIAN)
+ Q_INIT_RESOURCE_EXTERN(qstyle_s60)
Q_INIT_RESOURCE(qstyle_s60);
#else
+ Q_INIT_RESOURCE_EXTERN(qstyle)
Q_INIT_RESOURCE(qstyle);
#endif
-
+ Q_INIT_RESOURCE_EXTERN(qmessagebox)
Q_INIT_RESOURCE(qmessagebox);
#if !defined(QT_NO_PRINTDIALOG)
+ Q_INIT_RESOURCE_EXTERN(qprintdialog)
Q_INIT_RESOURCE(qprintdialog);
#endif
diff --git a/src/gui/util/qdesktopservices_s60.cpp b/src/gui/util/qdesktopservices_s60.cpp
index 319c4b0..0f5792f 100644
--- a/src/gui/util/qdesktopservices_s60.cpp
+++ b/src/gui/util/qdesktopservices_s60.cpp
@@ -413,11 +413,11 @@ QString QDesktopServices::storageLocation(StandardLocation type)
//return QDir::homePath(); break;
break;
case DataLocation:
- CEikonEnv::Static()->FsSession().PrivatePath(path);
+ qt_s60GetRFs().PrivatePath(path);
path.Insert(0, writableExeDrive().Name());
break;
case CacheLocation:
- CEikonEnv::Static()->FsSession().PrivatePath(path);
+ qt_s60GetRFs().PrivatePath(path);
path.Insert(0, writableExeDrive().Name());
path.Append(KCacheSubDir);
break;
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index d6ddbfe..c34cf89 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -91,6 +91,9 @@
QT_BEGIN_NAMESPACE
//#define QT_GL_NO_SCISSOR_TEST
+#ifdef Q_WS_WIN
+extern Q_GUI_EXPORT bool qt_cleartype_enabled;
+#endif
extern QImage qt_imageForBrush(int brushStyle, bool invert);
@@ -1822,7 +1825,6 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
#if !defined(QT_OPENGL_ES_2)
#if defined(Q_WS_WIN)
- extern Q_GUI_EXPORT bool qt_cleartype_enabled;
if (qt_cleartype_enabled)
#endif
d->glyphCacheType = QFontEngineGlyphCache::Raster_RGBMask;
diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp
index 4edb87a..032ff85 100644
--- a/src/plugins/imageformats/ico/qicohandler.cpp
+++ b/src/plugins/imageformats/ico/qicohandler.cpp
@@ -54,6 +54,9 @@
#include <QtCore/QFile>
#include <QtCore/QBuffer>
#include <qvariant.h>
+
+QT_BEGIN_NAMESPACE
+
// These next two structs represent how the icon information is stored
// in an ICO file.
typedef struct
@@ -891,3 +894,4 @@ bool QtIcoHandler::jumpToNextImage()
return jumpToImage(m_currentIconIndex + 1);
}
+QT_END_NAMESPACE
diff --git a/src/plugins/imageformats/ico/qicohandler.h b/src/plugins/imageformats/ico/qicohandler.h
index 394a5eb..4334ad9 100644
--- a/src/plugins/imageformats/ico/qicohandler.h
+++ b/src/plugins/imageformats/ico/qicohandler.h
@@ -43,6 +43,8 @@
#include <QtGui/QImageIOHandler>
+QT_BEGIN_NAMESPACE
+
class ICOReader;
class QtIcoHandler: public QImageIOHandler
{
@@ -71,5 +73,7 @@ private:
};
+QT_END_NAMESPACE
+
#endif /* QTICOHANDLER_H */