summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/declarative/QmlChanges.txt12
-rw-r--r--src/declarative/graphicsitems/graphicsitems.pri7
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp20
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp47
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview_p.h39
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp10
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp88
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem_p.h13
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp56
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview_p.h38
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp9
-rw-r--r--src/declarative/graphicsitems/qdeclarativeparticles.cpp16
-rw-r--r--src/declarative/graphicsitems/qdeclarativepath.cpp11
-rw-r--r--src/declarative/graphicsitems/qdeclarativepath_p.h11
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp26
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview_p.h18
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview_p_p.h3
-rw-r--r--src/declarative/graphicsitems/qdeclarativerectangle.cpp25
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp5
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp25
-rw-r--r--src/declarative/qml/parser/qdeclarativejs.g2
-rw-r--r--src/declarative/qml/parser/qdeclarativejsgrammar.cpp2
-rw-r--r--src/declarative/qml/parser/qdeclarativejsgrammar_p.h4
-rw-r--r--src/declarative/qml/parser/qdeclarativejsparser.cpp2
-rw-r--r--src/declarative/qml/qdeclarativebinding_p.h4
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp303
-rw-r--r--src/declarative/qml/qdeclarativecompiler_p.h8
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp7
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp9
-rw-r--r--src/declarative/qml/qdeclarativecontextscriptclass.cpp30
-rw-r--r--src/declarative/qml/qdeclarativecontextscriptclass_p.h1
-rw-r--r--src/declarative/qml/qdeclarativedeclarativedata_p.h10
-rw-r--r--src/declarative/qml/qdeclarativedom.cpp20
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp122
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h8
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp4
-rw-r--r--src/declarative/qml/qdeclarativeexpression.cpp46
-rw-r--r--src/declarative/qml/qdeclarativeexpression_p.h5
-rw-r--r--src/declarative/qml/qdeclarativeglobalscriptclass.cpp15
-rw-r--r--src/declarative/qml/qdeclarativeglobalscriptclass_p.h7
-rw-r--r--src/declarative/qml/qdeclarativeinstruction_p.h1
-rw-r--r--src/declarative/qml/qdeclarativelist.h2
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeparser.cpp13
-rw-r--r--src/declarative/qml/qdeclarativeparser_p.h10
-rw-r--r--src/declarative/qml/qdeclarativeproperty.cpp17
-rw-r--r--src/declarative/qml/qdeclarativeproperty_p.h2
-rw-r--r--src/declarative/qml/qdeclarativepropertycache.cpp4
-rw-r--r--src/declarative/qml/qdeclarativescriptparser.cpp70
-rw-r--r--src/declarative/qml/qdeclarativevaluetype.cpp41
-rw-r--r--src/declarative/qml/qdeclarativevaluetype_p.h9
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp8
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp220
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript_p.h11
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp58
-rw-r--r--src/declarative/util/qdeclarativeanimation_p_p.h21
-rw-r--r--src/declarative/util/qdeclarativebehavior.cpp6
-rw-r--r--src/declarative/util/qdeclarativebind.cpp15
-rw-r--r--src/declarative/util/qdeclarativeeasefollow.cpp34
-rw-r--r--src/declarative/util/qdeclarativefontloader.cpp10
-rw-r--r--src/declarative/util/qdeclarativespringfollow.cpp6
-rw-r--r--src/declarative/util/qdeclarativeview.cpp16
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp12
-rw-r--r--src/gui/graphicsview/qgraphicsitem.h8
-rw-r--r--src/imports/imports.pro (renamed from src/plugins/qdeclarativemodules/qdeclarativemodules.pro)1
-rw-r--r--src/imports/multimedia/multimedia.cpp (renamed from src/plugins/qdeclarativemodules/multimedia/multimedia.cpp)0
-rw-r--r--src/imports/multimedia/multimedia.pro (renamed from src/plugins/qdeclarativemodules/multimedia/multimedia.pro)8
-rw-r--r--src/imports/multimedia/qdeclarativeaudio.cpp (renamed from src/plugins/qdeclarativemodules/multimedia/qdeclarativeaudio.cpp)0
-rw-r--r--src/imports/multimedia/qdeclarativeaudio_p.h (renamed from src/plugins/qdeclarativemodules/multimedia/qdeclarativeaudio_p.h)0
-rw-r--r--src/imports/multimedia/qdeclarativemediabase.cpp (renamed from src/plugins/qdeclarativemodules/multimedia/qdeclarativemediabase.cpp)0
-rw-r--r--src/imports/multimedia/qdeclarativemediabase_p.h (renamed from src/plugins/qdeclarativemodules/multimedia/qdeclarativemediabase_p.h)0
-rw-r--r--src/imports/multimedia/qdeclarativevideo.cpp (renamed from src/plugins/qdeclarativemodules/multimedia/qdeclarativevideo.cpp)0
-rw-r--r--src/imports/multimedia/qdeclarativevideo_p.h (renamed from src/plugins/qdeclarativemodules/multimedia/qdeclarativevideo_p.h)0
-rw-r--r--src/imports/multimedia/qmetadatacontrolmetaobject.cpp (renamed from src/plugins/qdeclarativemodules/multimedia/qmetadatacontrolmetaobject.cpp)0
-rw-r--r--src/imports/multimedia/qmetadatacontrolmetaobject_p.h (renamed from src/plugins/qdeclarativemodules/multimedia/qmetadatacontrolmetaobject_p.h)0
-rw-r--r--src/imports/multimedia/qmldir1
-rw-r--r--src/imports/qimportbase.pri33
-rw-r--r--src/imports/webkit/plugin.cpp67
-rw-r--r--src/imports/webkit/qdeclarativewebview.cpp (renamed from src/declarative/graphicsitems/qdeclarativewebview.cpp)8
-rw-r--r--src/imports/webkit/qdeclarativewebview_p.h (renamed from src/declarative/graphicsitems/qdeclarativewebview_p.h)10
-rw-r--r--src/imports/webkit/qdeclarativewebview_p_p.h (renamed from src/declarative/graphicsitems/qdeclarativewebview_p_p.h)4
-rw-r--r--src/imports/webkit/qmldir1
-rw-r--r--src/imports/webkit/webkit.pro19
-rw-r--r--src/imports/webkit/webkitqmlplugin_export.h53
-rw-r--r--src/imports/widgets/graphicslayouts.cpp (renamed from src/plugins/qdeclarativemodules/widgets/graphicslayouts.cpp)0
-rw-r--r--src/imports/widgets/graphicslayouts_p.h (renamed from src/plugins/qdeclarativemodules/widgets/graphicslayouts_p.h)0
-rw-r--r--src/imports/widgets/graphicswidgets.cpp (renamed from src/plugins/qdeclarativemodules/widgets/graphicswidgets.cpp)0
-rw-r--r--src/imports/widgets/graphicswidgets_p.h (renamed from src/plugins/qdeclarativemodules/widgets/graphicswidgets_p.h)0
-rw-r--r--src/imports/widgets/qmldir1
-rw-r--r--src/imports/widgets/widgets.cpp (renamed from src/plugins/qdeclarativemodules/widgets/widgets.cpp)0
-rw-r--r--src/imports/widgets/widgets.pro (renamed from src/plugins/qdeclarativemodules/widgets/widgets.pro)10
-rw-r--r--src/multimedia/effects/qsoundeffect.cpp2
-rw-r--r--src/plugins/plugins.pro1
-rw-r--r--src/src.pro5
95 files changed, 1471 insertions, 441 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index 34e4834..6e77abf 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -6,12 +6,14 @@ Flickable: renamed viewportHeight -> contentHeight
Flickable: renamed viewportX -> contentX
Flickable: renamed viewportY -> contentY
Removed Flickable.reportedVelocitySmoothing
+Removed Qt.playSound (replaced by SoundEffect element)
Renamed MouseRegion -> MouseArea
Connection: syntax and rename:
Connection { sender: a; signal: foo(); script: xxx }
Connection { sender: a; signal: bar(); script: yyy }
becomes:
Connections { target: a; onFoo: xxx; onBar: yyy }
+Using WebView now requires "import org.webkit 1.0"
QmlView
-------
@@ -52,6 +54,16 @@ matchProperties and matchTargets have been renamed back to properties and target
The semantics are explained in the PropertyAnimation::properties documentation
and the animation overview documentation.
+Behavior and Animation syntax
+-----------------------------
+
+Previously animations and behaviors could be "assigned" to properties like this:
+ Item { x: Behavior {}; y: NumberAnimation {} }
+To make it more obvious that these are not regular value assignments a new "on"
+syntax has been introduced:
+ Item { Behavior on x {}; NumberAnimation on y {} }
+Only the syntax has changed, the behavior is identical.
+
=============================================================================
The changes below are pre-4.6.0 release.
diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/declarative/graphicsitems/graphicsitems.pri
index 7a85f00..3ff92b1 100644
--- a/src/declarative/graphicsitems/graphicsitems.pri
+++ b/src/declarative/graphicsitems/graphicsitems.pri
@@ -84,10 +84,3 @@ SOURCES += \
$$PWD/qdeclarativegraphicsobjectcontainer.cpp \
$$PWD/qdeclarativeparticles.cpp \
$$PWD/qdeclarativelayoutitem.cpp \
-
-contains(QT_CONFIG, webkit) {
- QT+=webkit
- SOURCES += $$PWD/qdeclarativewebview.cpp
- HEADERS += $$PWD/qdeclarativewebview_p.h
- HEADERS += $$PWD/qdeclarativewebview_p_p.h
-}
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index c54ddd0..2fdd720 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -682,7 +682,7 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
else
rejectY = true;
}
- if (!rejectY) {
+ if (!rejectY && stealMouse) {
_moveY.setValue(newY);
moved = true;
}
@@ -709,7 +709,7 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
else
rejectX = true;
}
- if (!rejectX) {
+ if (!rejectX && stealMouse) {
_moveX.setValue(newX);
moved = true;
}
@@ -752,6 +752,8 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
void QDeclarativeFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
Q_Q(QDeclarativeFlickable);
+ stealMouse = false;
+ q->setKeepMouseGrab(false);
pressed = false;
if (lastPosTime.isNull())
return;
@@ -781,7 +783,6 @@ void QDeclarativeFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEv
fixupX();
}
- stealMouse = false;
lastPosTime = QTime();
if (!timeline.isActive())
@@ -804,6 +805,8 @@ void QDeclarativeFlickable::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Q_D(QDeclarativeFlickable);
if (d->interactive) {
d->handleMouseMoveEvent(event);
+ if (d->stealMouse)
+ setKeepMouseGrab(true);
event->accept();
} else {
QDeclarativeItem::mouseMoveEvent(event);
@@ -1141,7 +1144,8 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event)
QGraphicsScene *s = scene();
QDeclarativeItem *grabber = s ? qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem()) : 0;
- if ((d->stealMouse || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) {
+ bool stealThisEvent = d->stealMouse;
+ if ((stealThisEvent || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) {
mouseEvent.setAccepted(false);
for (int i = 0x1; i <= 0x10; i <<= 1) {
if (event->buttons() & i) {
@@ -1176,17 +1180,19 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event)
break;
}
grabber = qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem());
- if (grabber && d->stealMouse && !grabber->keepMouseGrab() && grabber != this) {
+ if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this) {
d->clearDelayedPress();
grabMouse();
}
- return d->stealMouse || d->delayedPressEvent;
+ return stealThisEvent || d->delayedPressEvent;
} else if (!d->lastPosTime.isNull()) {
d->lastPosTime = QTime();
}
- if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease)
+ if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) {
d->clearDelayedPress();
+ d->stealMouse = false;
+ }
return false;
}
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index b43b30b..463b238 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -45,14 +45,13 @@
#include "qdeclarativeflickable_p_p.h"
#include <qdeclarativeeasefollow_p.h>
+#include <qdeclarativeguard_p.h>
#include <qlistmodelinterface_p.h>
#include <QKeyEvent>
QT_BEGIN_NAMESPACE
-QHash<QObject*, QDeclarativeGridViewAttached*> QDeclarativeGridViewAttached::attachedProperties;
-
//----------------------------------------------------------------------------
@@ -60,8 +59,9 @@ class FxGridItem
{
public:
FxGridItem(QDeclarativeItem *i, QDeclarativeGridView *v) : item(i), view(v) {
- attached = QDeclarativeGridViewAttached::properties(item);
- attached->m_view = view;
+ attached = static_cast<QDeclarativeGridViewAttached*>(qmlAttachedPropertiesObject<QDeclarativeGridView>(item));
+ if (attached)
+ attached->m_view = view;
}
~FxGridItem() {}
@@ -251,7 +251,7 @@ public:
}
}
- QGuard<QDeclarativeVisualModel> model;
+ QDeclarativeGuard<QDeclarativeVisualModel> model;
QVariant modelVariant;
QList<FxGridItem*> visibleItems;
QHash<QDeclarativeItem*,int> unrequestedItems;
@@ -618,7 +618,7 @@ void QDeclarativeGridViewPrivate::createHighlight()
}
}
if (changed)
- emit q->highlightChanged();
+ emit q->highlightItemChanged();
}
void QDeclarativeGridViewPrivate::updateHighlight()
@@ -696,6 +696,11 @@ void QDeclarativeGridViewPrivate::updateCurrent(int modelIndex)
In this case ListModel is a handy way for us to test our UI. In practice
the model would be implemented in C++, or perhaps via a SQL data source.
+
+ Note that views do not enable \e clip automatically. If the view
+ is not clipped by another item or the screen, it will be necessary
+ to set \e {clip: true} in order to have the out of view items clipped
+ nicely.
*/
QDeclarativeGridView::QDeclarativeGridView(QDeclarativeItem *parent)
: QDeclarativeFlickable(*(new QDeclarativeGridViewPrivate), parent)
@@ -743,7 +748,7 @@ QDeclarativeGridView::~QDeclarativeGridView()
id: myDelegate
Item {
id: wrapper
- GridView.onRemove: SequentialAnimation {
+ SequentialAnimation on GridView.onRemove {
PropertyAction { target: wrapper.GridView; property: "delayRemove"; value: true }
NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" }
PropertyAction { target: wrapper.GridView; property: "delayRemove"; value: false }
@@ -784,6 +789,8 @@ QVariant QDeclarativeGridView::model() const
void QDeclarativeGridView::setModel(const QVariant &model)
{
Q_D(QDeclarativeGridView);
+ if (d->modelVariant == model)
+ return;
if (d->model) {
disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
@@ -828,6 +835,7 @@ void QDeclarativeGridView::setModel(const QVariant &model)
connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*)));
emit countChanged();
}
+ emit modelChanged();
}
/*!
@@ -871,6 +879,7 @@ void QDeclarativeGridView::setDelegate(QDeclarativeComponent *delegate)
d->moveReason = QDeclarativeGridViewPrivate::SetIndex;
d->updateCurrent(d->currentIndex);
}
+ emit delegateChanged();
}
}
@@ -966,6 +975,7 @@ void QDeclarativeGridView::setHighlight(QDeclarativeComponent *highlight)
if (highlight != d->highlightComponent) {
d->highlightComponent = highlight;
d->updateCurrent(d->currentIndex);
+ emit highlightChanged();
}
}
@@ -983,8 +993,8 @@ void QDeclarativeGridView::setHighlight(QDeclarativeComponent *highlight)
id: myHighlight
Rectangle {
id: wrapper; color: "lightsteelblue"; radius: 4; width: 320; height: 60
- y: SpringFollow { source: Wrapper.GridView.view.currentItem.y; spring: 3; damping: 0.2 }
- x: SpringFollow { source: Wrapper.GridView.view.currentItem.x; spring: 3; damping: 0.2 }
+ SpringFollow on y { source: Wrapper.GridView.view.currentItem.y; spring: 3; damping: 0.2 }
+ SpringFollow on x { source: Wrapper.GridView.view.currentItem.x; spring: 3; damping: 0.2 }
}
}
\endcode
@@ -1039,6 +1049,7 @@ void QDeclarativeGridView::setFlow(Flow flow)
d->updateGrid();
refill();
d->updateCurrent(d->currentIndex);
+ emit flowChanged();
}
}
@@ -1058,7 +1069,10 @@ bool QDeclarativeGridView::isWrapEnabled() const
void QDeclarativeGridView::setWrapEnabled(bool wrap)
{
Q_D(QDeclarativeGridView);
+ if (d->wrap == wrap)
+ return;
d->wrap = wrap;
+ emit keyNavigationWrapsChanged();
}
/*!
@@ -1082,6 +1096,7 @@ void QDeclarativeGridView::setCacheBuffer(int buffer)
d->buffer = buffer;
if (isComponentComplete())
refill();
+ emit cacheBufferChanged();
}
}
@@ -1325,6 +1340,18 @@ void QDeclarativeGridView::moveCurrentIndexRight()
}
}
+/*!
+ \qmlmethod GridView::positionViewAtIndex(int index)
+
+ Positions the view such that the \a index is at the top (or left for horizontal orientation) of the view.
+ If positioning the view at the index would cause empty space to be displayed at
+ the end of the view, the view will be positioned at the end.
+
+ It is not recommended to use contentX or contentY to position the view
+ at a particular index. This is unreliable since removing items from the start
+ of the list does not cause all other items to be repositioned.
+ The correct way to bring an item into view is with positionViewAtIndex.
+*/
void QDeclarativeGridView::positionViewAtIndex(int index)
{
Q_D(QDeclarativeGridView);
@@ -1732,7 +1759,7 @@ void QDeclarativeGridView::refill()
QDeclarativeGridViewAttached *QDeclarativeGridView::qmlAttachedProperties(QObject *obj)
{
- return QDeclarativeGridViewAttached::properties(obj);
+ return new QDeclarativeGridViewAttached(obj);
}
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/declarative/graphicsitems/qdeclarativegridview_p.h
index b488475..22fcef6 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h
@@ -57,19 +57,19 @@ class Q_DECLARATIVE_EXPORT QDeclarativeGridView : public QDeclarativeFlickable
Q_OBJECT
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeGridView)
- Q_PROPERTY(QVariant model READ model WRITE setModel)
- Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate)
+ Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
+ Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
Q_PROPERTY(QDeclarativeItem *currentItem READ currentItem NOTIFY currentIndexChanged)
Q_PROPERTY(int count READ count NOTIFY countChanged)
- Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight)
- Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightChanged)
+ Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged)
+ Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightItemChanged)
Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem)
- Q_PROPERTY(Flow flow READ flow WRITE setFlow)
- Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled)
- Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer)
+ Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
+ Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled NOTIFY keyNavigationWrapsChanged)
+ Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged)
Q_PROPERTY(int cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellWidthChanged)
Q_PROPERTY(int cellHeight READ cellHeight WRITE setCellHeight NOTIFY cellHeightChanged)
Q_CLASSINFO("DefaultProperty", "data")
@@ -129,6 +129,12 @@ Q_SIGNALS:
void cellWidthChanged();
void cellHeightChanged();
void highlightChanged();
+ void highlightItemChanged();
+ void modelChanged();
+ void delegateChanged();
+ void flowChanged();
+ void keyNavigationWrapsChanged();
+ void cacheBufferChanged();
protected:
virtual void viewportMoved();
@@ -161,9 +167,7 @@ class QDeclarativeGridViewAttached : public QObject
public:
QDeclarativeGridViewAttached(QObject *parent)
: QObject(parent), m_isCurrent(false), m_delayRemove(false) {}
- ~QDeclarativeGridViewAttached() {
- attachedProperties.remove(parent());
- }
+ ~QDeclarativeGridViewAttached() {}
Q_PROPERTY(QDeclarativeGridView *view READ view CONSTANT)
QDeclarativeGridView *view() { return m_view; }
@@ -186,15 +190,6 @@ public:
}
}
- static QDeclarativeGridViewAttached *properties(QObject *obj) {
- QDeclarativeGridViewAttached *rv = attachedProperties.value(obj);
- if (!rv) {
- rv = new QDeclarativeGridViewAttached(obj);
- attachedProperties.insert(obj, rv);
- }
- return rv;
- }
-
void emitAdd() { emit add(); }
void emitRemove() { emit remove(); }
@@ -206,10 +201,8 @@ Q_SIGNALS:
public:
QDeclarativeGridView *m_view;
- bool m_isCurrent;
- bool m_delayRemove;
-
- static QHash<QObject*, QDeclarativeGridViewAttached*> attachedProperties;
+ bool m_isCurrent : 1;
+ bool m_delayRemove : 1;
};
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
index 99ab053..2739ab8 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -232,6 +232,16 @@ qreal QDeclarativeImage::paintedHeight() const
\o Error - an error occurred while loading the image
\endlist
+ Note that a change in the status property does not cause anything to happen
+ (although it reflects what has happened with the image internally). If you wish
+ to react to the change in status you need to do it yourself, for example in one
+ of the following ways:
+ \list
+ \o Create a state, so that a state change occurs, e.g. State{name: 'loaded'; when: image.status = Image.Ready;}
+ \o Do something inside the onStatusChanged signal handler, e.g. Image{id: image; onStatusChanged: if(image.status == Image.Ready) console.log('Loaded');}
+ \o Bind to the status variable somewhere, e.g. Text{text: if(image.status!=Image.Ready){'Not Loaded';}else{'Loaded';}}
+ \endlist
+
\sa progress
*/
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 5014fd8..3bee5b8 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -498,6 +498,32 @@ void QDeclarativeKeyNavigationAttached::setDown(QDeclarativeItem *i)
emit changed();
}
+QDeclarativeItem *QDeclarativeKeyNavigationAttached::tab() const
+{
+ Q_D(const QDeclarativeKeyNavigationAttached);
+ return d->tab;
+}
+
+void QDeclarativeKeyNavigationAttached::setTab(QDeclarativeItem *i)
+{
+ Q_D(QDeclarativeKeyNavigationAttached);
+ d->tab = i;
+ emit changed();
+}
+
+QDeclarativeItem *QDeclarativeKeyNavigationAttached::backtab() const
+{
+ Q_D(const QDeclarativeKeyNavigationAttached);
+ return d->backtab;
+}
+
+void QDeclarativeKeyNavigationAttached::setBacktab(QDeclarativeItem *i)
+{
+ Q_D(QDeclarativeKeyNavigationAttached);
+ d->backtab = i;
+ emit changed();
+}
+
void QDeclarativeKeyNavigationAttached::keyPressed(QKeyEvent *event)
{
Q_D(QDeclarativeKeyNavigationAttached);
@@ -529,6 +555,18 @@ void QDeclarativeKeyNavigationAttached::keyPressed(QKeyEvent *event)
event->accept();
}
break;
+ case Qt::Key_Tab:
+ if (d->tab) {
+ d->tab->setFocus(true);
+ event->accept();
+ }
+ break;
+ case Qt::Key_Backtab:
+ if (d->backtab) {
+ d->backtab->setFocus(true);
+ event->accept();
+ }
+ break;
default:
break;
}
@@ -563,6 +601,16 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event)
event->accept();
}
break;
+ case Qt::Key_Tab:
+ if (d->tab) {
+ event->accept();
+ }
+ break;
+ case Qt::Key_Backtab:
+ if (d->backtab) {
+ event->accept();
+ }
+ break;
default:
break;
}
@@ -902,6 +950,8 @@ const QDeclarativeKeysAttached::SigMap QDeclarativeKeysAttached::sigMap[] = {
{ Qt::Key_Right, "rightPressed" },
{ Qt::Key_Up, "upPressed" },
{ Qt::Key_Down, "downPressed" },
+ { Qt::Key_Tab, "tabPressed" },
+ { Qt::Key_Backtab, "backtabPressed" },
{ Qt::Key_Asterisk, "asteriskPressed" },
{ Qt::Key_NumberSign, "numberSignPressed" },
{ Qt::Key_Escape, "escapePressed" },
@@ -1440,7 +1490,7 @@ QDeclarativeAnchors *QDeclarativeItem::anchors()
void QDeclarativeItemPrivate::data_append(QDeclarativeListProperty<QObject> *prop, QObject *o)
{
QDeclarativeItem *i = qobject_cast<QDeclarativeItem *>(o);
- if (i)
+ if (i)
i->setParentItem(static_cast<QDeclarativeItem *>(prop->object));
else
o->setParent(static_cast<QDeclarativeItem *>(prop->object));
@@ -1568,7 +1618,7 @@ void QDeclarativeItemPrivate::transform_clear(QDeclarativeListProperty<QGraphics
*/
/*! \internal */
-QDeclarativeListProperty<QObject> QDeclarativeItem::data()
+QDeclarativeListProperty<QObject> QDeclarativeItem::data()
{
return QDeclarativeListProperty<QObject>(this, 0, QDeclarativeItemPrivate::data_append);
}
@@ -2179,16 +2229,16 @@ void QDeclarativeItem::focusChanged(bool flag)
QDeclarativeListProperty<QDeclarativeItem> QDeclarativeItem::fxChildren()
{
return QDeclarativeListProperty<QDeclarativeItem>(this, 0, QDeclarativeItemPrivate::children_append,
- QDeclarativeItemPrivate::children_count,
- QDeclarativeItemPrivate::children_at);
+ QDeclarativeItemPrivate::children_count,
+ QDeclarativeItemPrivate::children_at);
}
/*! \internal */
QDeclarativeListProperty<QObject> QDeclarativeItem::resources()
{
- return QDeclarativeListProperty<QObject>(this, 0, QDeclarativeItemPrivate::resources_append,
- QDeclarativeItemPrivate::resources_count,
- QDeclarativeItemPrivate::resources_at);
+ return QDeclarativeListProperty<QObject>(this, 0, QDeclarativeItemPrivate::resources_append,
+ QDeclarativeItemPrivate::resources_count,
+ QDeclarativeItemPrivate::resources_at);
}
/*!
@@ -2465,14 +2515,26 @@ QPointF QDeclarativeItemPrivate::computeTransformOrigin() const
/*! \internal */
bool QDeclarativeItem::sceneEvent(QEvent *event)
{
- bool rv = QGraphicsItem::sceneEvent(event);
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent *k = static_cast<QKeyEvent *>(event);
- if (event->type() == QEvent::FocusIn ||
- event->type() == QEvent::FocusOut) {
- focusChanged(hasFocus());
- }
+ if ((k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) &&
+ !(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) {
+ keyPressEvent(static_cast<QKeyEvent *>(event));
+ if (!event->isAccepted())
+ QGraphicsItem::sceneEvent(event);
+ } else {
+ QGraphicsItem::sceneEvent(event);
+ }
+ } else {
+ bool rv = QGraphicsItem::sceneEvent(event);
- return rv;
+ if (event->type() == QEvent::FocusIn ||
+ event->type() == QEvent::FocusOut) {
+ focusChanged(hasFocus());
+ }
+ return rv;
+ }
}
/*! \internal */
diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h
index 4b4917e..e424970 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h
@@ -289,12 +289,14 @@ class QDeclarativeKeyNavigationAttachedPrivate : public QObjectPrivate
{
public:
QDeclarativeKeyNavigationAttachedPrivate()
- : QObjectPrivate(), left(0), right(0), up(0), down(0) {}
+ : QObjectPrivate(), left(0), right(0), up(0), down(0), tab(0), backtab(0) {}
QDeclarativeItem *left;
QDeclarativeItem *right;
QDeclarativeItem *up;
QDeclarativeItem *down;
+ QDeclarativeItem *tab;
+ QDeclarativeItem *backtab;
};
class QDeclarativeKeyNavigationAttached : public QObject, public QDeclarativeItemKeyFilter
@@ -306,6 +308,9 @@ class QDeclarativeKeyNavigationAttached : public QObject, public QDeclarativeIte
Q_PROPERTY(QDeclarativeItem *right READ right WRITE setRight NOTIFY changed)
Q_PROPERTY(QDeclarativeItem *up READ up WRITE setUp NOTIFY changed)
Q_PROPERTY(QDeclarativeItem *down READ down WRITE setDown NOTIFY changed)
+ Q_PROPERTY(QDeclarativeItem *tab READ tab WRITE setTab NOTIFY changed)
+ Q_PROPERTY(QDeclarativeItem *backtab READ backtab WRITE setBacktab NOTIFY changed)
+
public:
QDeclarativeKeyNavigationAttached(QObject * = 0);
@@ -317,6 +322,10 @@ public:
void setUp(QDeclarativeItem *);
QDeclarativeItem *down() const;
void setDown(QDeclarativeItem *);
+ QDeclarativeItem *tab() const;
+ void setTab(QDeclarativeItem *);
+ QDeclarativeItem *backtab() const;
+ void setBacktab(QDeclarativeItem *);
static QDeclarativeKeyNavigationAttached *qmlAttachedProperties(QObject *);
@@ -407,6 +416,8 @@ Q_SIGNALS:
void rightPressed(QDeclarativeKeyEvent *event);
void upPressed(QDeclarativeKeyEvent *event);
void downPressed(QDeclarativeKeyEvent *event);
+ void tabPressed(QDeclarativeKeyEvent *event);
+ void backtabPressed(QDeclarativeKeyEvent *event);
void asteriskPressed(QDeclarativeKeyEvent *event);
void numberSignPressed(QDeclarativeKeyEvent *event);
diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
index f3b9385..25660f8 100644
--- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
@@ -106,7 +106,6 @@ void QDeclarativeItemModule::defineModule()
QML_REGISTER_TYPE(Qt,4,6,LayoutItem,QDeclarativeLayoutItem);
QML_REGISTER_TYPE(Qt,4,6,ListView,QDeclarativeListView);
QML_REGISTER_TYPE(Qt,4,6,Loader,QDeclarativeLoader);
- QML_REGISTER_TYPE(Qt,4,6,MouseRegion,QDeclarativeMouseArea);
QML_REGISTER_TYPE(Qt,4,6,MouseArea,QDeclarativeMouseArea);
QML_REGISTER_TYPE(Qt,4,6,Opacity,QGraphicsOpacityEffect);
QML_REGISTER_TYPE(Qt,4,6,ParticleMotion,QDeclarativeParticleMotion);
@@ -139,9 +138,6 @@ void QDeclarativeItemModule::defineModule()
QML_REGISTER_TYPE(Qt,4,6,VisibleArea,QDeclarativeFlickableVisibleArea);
QML_REGISTER_TYPE(Qt,4,6,VisualDataModel,QDeclarativeVisualDataModel);
QML_REGISTER_TYPE(Qt,4,6,VisualItemModel,QDeclarativeVisualItemModel);
-#ifdef QT_WEBKIT_LIB
- QML_REGISTER_TYPE(Qt,4,6,WebView,QDeclarativeWebView);
-#endif
QML_REGISTER_NOCREATE_TYPE(QDeclarativeAnchors);
QML_REGISTER_NOCREATE_TYPE(QGraphicsEffect);
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 03303a0..cd8d143 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -47,6 +47,7 @@
#include <qdeclarativeeasefollow_p.h>
#include <qdeclarativeexpression.h>
#include <qdeclarativeengine.h>
+#include <qdeclarativeguard_p.h>
#include <qlistmodelinterface_p.h>
#include <QKeyEvent>
@@ -222,7 +223,7 @@ public:
if (!visibleItems.isEmpty()) {
pos = (*visibleItems.constBegin())->position();
if (visibleIndex > 0)
- pos -= visibleIndex * (averageSize + spacing) - spacing;
+ pos -= visibleIndex * (averageSize + spacing);
}
return pos;
}
@@ -429,7 +430,7 @@ public:
virtual void flickX(qreal velocity);
virtual void flickY(qreal velocity);
- QGuard<QDeclarativeVisualModel> model;
+ QDeclarativeGuard<QDeclarativeVisualModel> model;
QVariant modelVariant;
QList<FxListItem*> visibleItems;
QHash<QDeclarativeItem*,int> unrequestedItems;
@@ -798,10 +799,13 @@ void QDeclarativeListViewPrivate::createHighlight()
if (item) {
item->setParent(q->viewport());
highlight = new FxListItem(item, q);
- if (orient == QDeclarativeListView::Vertical)
- highlight->item->setHeight(currentItem->item->height());
- else
- highlight->item->setWidth(currentItem->item->width());
+ if (currentItem && autoHighlight) {
+ if (orient == QDeclarativeListView::Vertical) {
+ highlight->item->setHeight(currentItem->item->height());
+ } else {
+ highlight->item->setWidth(currentItem->item->width());
+ }
+ }
const QLatin1String posProp(orient == QDeclarativeListView::Vertical ? "y" : "x");
highlightPosAnimator = new QDeclarativeEaseFollow(q);
highlightPosAnimator->setTarget(QDeclarativeProperty(highlight->item, posProp));
@@ -816,7 +820,7 @@ void QDeclarativeListViewPrivate::createHighlight()
}
}
if (changed)
- emit q->highlightChanged();
+ emit q->highlightItemChanged();
}
void QDeclarativeListViewPrivate::updateHighlight()
@@ -1358,6 +1362,11 @@ void QDeclarativeListViewPrivate::flickY(qreal velocity)
In this case ListModel is a handy way for us to test our UI. In practice
the model would be implemented in C++, or perhaps via a SQL data source.
+
+ Note that views do not enable \e clip automatically. If the view
+ is not clipped by another item or the screen, it will be necessary
+ to set \e {clip: true} in order to have the out of view items clipped
+ nicely.
*/
QDeclarativeListView::QDeclarativeListView(QDeclarativeItem *parent)
@@ -1430,7 +1439,7 @@ QDeclarativeListView::~QDeclarativeListView()
id: myDelegate
Item {
id: wrapper
- ListView.onRemove: SequentialAnimation {
+ SequentialAnimation on ListView.onRemove {
PropertyAction { target: wrapper.ListView; property: "delayRemove"; value: true }
NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" }
PropertyAction { target: wrapper.ListView; property: "delayRemove"; value: false }
@@ -1473,6 +1482,8 @@ QVariant QDeclarativeListView::model() const
void QDeclarativeListView::setModel(const QVariant &model)
{
Q_D(QDeclarativeListView);
+ if (d->modelVariant == model)
+ return;
if (d->model) {
disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
@@ -1517,6 +1528,7 @@ void QDeclarativeListView::setModel(const QVariant &model)
connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*)));
emit countChanged();
}
+ emit modelChanged();
}
/*!
@@ -1563,6 +1575,7 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate)
d->updateCurrent(d->currentIndex);
}
}
+ emit delegateChanged();
}
/*!
@@ -1663,6 +1676,7 @@ void QDeclarativeListView::setHighlight(QDeclarativeComponent *highlight)
d->createHighlight();
if (d->currentItem)
d->updateHighlight();
+ emit highlightChanged();
}
}
@@ -1700,6 +1714,7 @@ void QDeclarativeListView::setHighlightFollowsCurrentItem(bool autoHighlight)
d->highlightSizeAnimator->setEnabled(d->autoHighlight);
}
d->updateHighlight();
+ emit highlightFollowsCurrentItemChanged();
}
}
@@ -1745,8 +1760,11 @@ qreal QDeclarativeListView::preferredHighlightBegin() const
void QDeclarativeListView::setPreferredHighlightBegin(qreal start)
{
Q_D(QDeclarativeListView);
+ if (d->highlightRangeStart == start)
+ return;
d->highlightRangeStart = start;
d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
+ emit preferredHighlightBeginChanged();
}
qreal QDeclarativeListView::preferredHighlightEnd() const
@@ -1758,8 +1776,11 @@ qreal QDeclarativeListView::preferredHighlightEnd() const
void QDeclarativeListView::setPreferredHighlightEnd(qreal end)
{
Q_D(QDeclarativeListView);
+ if (d->highlightRangeEnd == end)
+ return;
d->highlightRangeEnd = end;
d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
+ emit preferredHighlightEndChanged();
}
QDeclarativeListView::HighlightRangeMode QDeclarativeListView::highlightRangeMode() const
@@ -1771,8 +1792,11 @@ QDeclarativeListView::HighlightRangeMode QDeclarativeListView::highlightRangeMod
void QDeclarativeListView::setHighlightRangeMode(HighlightRangeMode mode)
{
Q_D(QDeclarativeListView);
+ if (d->highlightRange == mode)
+ return;
d->highlightRange = mode;
d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
+ emit highlightRangeModeChanged();
}
/*!
@@ -1848,7 +1872,10 @@ bool QDeclarativeListView::isWrapEnabled() const
void QDeclarativeListView::setWrapEnabled(bool wrap)
{
Q_D(QDeclarativeListView);
+ if (d->wrap == wrap)
+ return;
d->wrap = wrap;
+ emit keyNavigationWrapsChanged();
}
/*!
@@ -1874,6 +1901,7 @@ void QDeclarativeListView::setCacheBuffer(int b)
d->bufferMode = QDeclarativeListViewPrivate::BufferBefore | QDeclarativeListViewPrivate::BufferAfter;
refill();
}
+ emit cacheBufferChanged();
}
}
@@ -1998,6 +2026,7 @@ void QDeclarativeListView::setSnapMode(SnapMode mode)
Q_D(QDeclarativeListView);
if (d->snapMode != mode) {
d->snapMode = mode;
+ emit snapModeChanged();
}
}
@@ -2020,6 +2049,7 @@ void QDeclarativeListView::setFooter(QDeclarativeComponent *footer)
d->maxExtentDirty = true;
d->updateFooter();
d->updateViewport();
+ emit footerChanged();
}
}
@@ -2043,6 +2073,7 @@ void QDeclarativeListView::setHeader(QDeclarativeComponent *header)
d->updateHeader();
d->updateFooter();
d->updateViewport();
+ emit headerChanged();
}
}
@@ -2258,6 +2289,12 @@ void QDeclarativeListView::decrementCurrentIndex()
Positions the view such that the \a index is at the top (or left for horizontal orientation) of the view.
If positioning the view at the index would cause empty space to be displayed at
the end of the view, the view will be positioned at the end.
+
+ It is not recommended to use contentX or contentY to position the view
+ at a particular index. This is unreliable since removing items from the start
+ of the list does not cause all other items to be repositioned, and because
+ the actual start of the view can vary based on the size of the delegates.
+ The correct way to bring an item into view is with positionViewAtIndex.
*/
void QDeclarativeListView::positionViewAtIndex(int index)
{
@@ -2380,7 +2417,8 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count)
int i = d->visibleItems.count() - 1;
while (i > 0 && d->visibleItems.at(i)->index == -1)
--i;
- if (d->visibleItems.at(i)->index + 1 == modelIndex) {
+ if (d->visibleItems.at(i)->index + 1 == modelIndex
+ && d->visibleItems.at(i)->endPosition() < d->buffer+d->position()+d->size()-1) {
// Special case of appending an item to the model.
modelIndex = d->visibleIndex + d->visibleItems.count();
} else {
diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/declarative/graphicsitems/qdeclarativelistview_p.h
index 5e3edb0..f9b7b50 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h
@@ -91,33 +91,33 @@ class Q_DECLARATIVE_EXPORT QDeclarativeListView : public QDeclarativeFlickable
Q_OBJECT
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeListView)
- Q_PROPERTY(QVariant model READ model WRITE setModel)
- Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate)
+ Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
+ Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
Q_PROPERTY(QDeclarativeItem *currentItem READ currentItem NOTIFY currentIndexChanged)
Q_PROPERTY(int count READ count NOTIFY countChanged)
- Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight)
- Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightChanged)
- Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem)
+ Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged)
+ Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightItemChanged)
+ Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem NOTIFY highlightFollowsCurrentItemChanged)
Q_PROPERTY(qreal highlightMoveSpeed READ highlightMoveSpeed WRITE setHighlightMoveSpeed NOTIFY highlightMoveSpeedChanged)
Q_PROPERTY(qreal highlightResizeSpeed READ highlightResizeSpeed WRITE setHighlightResizeSpeed NOTIFY highlightResizeSpeedChanged)
- Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin)
- Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd)
- Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode)
+ Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin NOTIFY preferredHighlightBeginChanged)
+ Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged)
+ Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode NOTIFY highlightRangeModeChanged)
Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
- Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled)
- Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer)
+ Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled NOTIFY keyNavigationWrapsChanged)
+ Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged)
Q_PROPERTY(QDeclarativeViewSection *section READ sectionCriteria CONSTANT)
Q_PROPERTY(QString currentSection READ currentSection NOTIFY currentSectionChanged)
- Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode)
+ Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged)
- Q_PROPERTY(QDeclarativeComponent *header READ header WRITE setHeader)
- Q_PROPERTY(QDeclarativeComponent *footer READ footer WRITE setFooter)
+ Q_PROPERTY(QDeclarativeComponent *header READ header WRITE setHeader NOTIFY headerChanged)
+ Q_PROPERTY(QDeclarativeComponent *footer READ footer WRITE setFooter NOTIFY footerChanged)
Q_ENUMS(HighlightRangeMode)
Q_ENUMS(Orientation)
@@ -205,6 +205,18 @@ Q_SIGNALS:
void highlightMoveSpeedChanged();
void highlightResizeSpeedChanged();
void highlightChanged();
+ void highlightItemChanged();
+ void modelChanged();
+ void delegateChanged();
+ void highlightFollowsCurrentItemChanged();
+ void preferredHighlightBeginChanged();
+ void preferredHighlightEndChanged();
+ void highlightRangeModeChanged();
+ void keyNavigationWrapsChanged();
+ void cacheBufferChanged();
+ void snapModeChanged();
+ void headerChanged();
+ void footerChanged();
protected:
virtual void viewportMoved();
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp
index bd89321..b0499d7 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp
@@ -320,6 +320,15 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded()
\o Error - an error occurred while loading the QML source
\endlist
+ Note that a change in the status property does not cause anything to happen
+ (although it reflects what has happened to the loader internally). If you wish
+ to react to the change in status you need to do it yourself, for example in one
+ of the following ways:
+ \list
+ \o Create a state, so that a state change occurs, e.g. State{name: 'loaded'; when: loader.status = Loader.Ready;}
+ \o Do something inside the onStatusChanged signal handler, e.g. Loader{id: loader; onStatusChanged: if(loader.status == Loader.Ready) console.log('Loaded');}
+ \o Bind to the status variable somewhere, e.g. Text{text: if(loader.status!=Loader.Ready){'Not Loaded';}else{'Loaded';}}
+ \endlist
\sa progress
*/
diff --git a/src/declarative/graphicsitems/qdeclarativeparticles.cpp b/src/declarative/graphicsitems/qdeclarativeparticles.cpp
index 1a58d3f..deabdd6 100644
--- a/src/declarative/graphicsitems/qdeclarativeparticles.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeparticles.cpp
@@ -1260,7 +1260,11 @@ void QDeclarativeParticlesPainter::paint(QPainter *p, const QStyleOptionGraphics
const int myX = x() + parentItem()->x();
const int myY = y() + parentItem()->y();
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
QVarLengthArray<QPainter::Fragment, 256> pixmapData;
+#else
+ QVarLengthArray<QDrawPixmaps::Data, 256> pixmapData;
+#endif
pixmapData.resize(d->particles.count());
const QRectF sourceRect = d->image.rect();
@@ -1268,20 +1272,32 @@ void QDeclarativeParticlesPainter::paint(QPainter *p, const QStyleOptionGraphics
qreal halfPHeight = sourceRect.height()/2.;
for (int i = 0; i < d->particles.count(); ++i) {
const QDeclarativeParticle &particle = d->particles.at(i);
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
pixmapData[i].x = particle.x - myX + halfPWidth;
pixmapData[i].y = particle.y - myY + halfPHeight;
+#else
+ pixmapData[i].point = QPointF(particle.x - myX + halfPWidth, particle.y - myY + halfPHeight);
+#endif
pixmapData[i].opacity = particle.opacity;
//these never change
pixmapData[i].rotation = 0;
pixmapData[i].scaleX = 1;
pixmapData[i].scaleY = 1;
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
pixmapData[i].sourceLeft = sourceRect.left();
pixmapData[i].sourceTop = sourceRect.top();
pixmapData[i].width = sourceRect.width();
pixmapData[i].height = sourceRect.height();
+#else
+ pixmapData[i].source = sourceRect;
+#endif
}
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
p->drawPixmapFragments(pixmapData.data(), d->particles.count(), d->image);
+#else
+ qDrawPixmaps(p, pixmapData.data(), d->particles.count(), d->image);
+#endif
}
void QDeclarativeParticles::componentComplete()
diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/graphicsitems/qdeclarativepath.cpp
index 48f112a..80586b8 100644
--- a/src/declarative/graphicsitems/qdeclarativepath.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepath.cpp
@@ -114,7 +114,10 @@ qreal QDeclarativePath::startX() const
void QDeclarativePath::setStartX(qreal x)
{
Q_D(QDeclarativePath);
+ if (qFuzzyCompare(x, d->startX))
+ return;
d->startX = x;
+ emit startXChanged();
}
qreal QDeclarativePath::startY() const
@@ -126,7 +129,10 @@ qreal QDeclarativePath::startY() const
void QDeclarativePath::setStartY(qreal y)
{
Q_D(QDeclarativePath);
+ if (qFuzzyCompare(y, d->startY))
+ return;
d->startY = y;
+ emit startYChanged();
}
/*!
@@ -522,7 +528,10 @@ QString QDeclarativePathAttribute::name() const
void QDeclarativePathAttribute::setName(const QString &name)
{
- _name = name;
+ if (_name == name)
+ return;
+ _name = name;
+ emit nameChanged();
}
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativepath_p.h b/src/declarative/graphicsitems/qdeclarativepath_p.h
index b3139f8..d7cfca1 100644
--- a/src/declarative/graphicsitems/qdeclarativepath_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepath_p.h
@@ -67,7 +67,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativePathAttribute : public QDeclarativePathEl
{
Q_OBJECT
- Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY changed)
public:
QDeclarativePathAttribute(QObject *parent=0) : QDeclarativePathElement(parent), _value(0) {}
@@ -79,6 +79,9 @@ public:
qreal value() const;
void setValue(qreal value);
+Q_SIGNALS:
+ void nameChanged();
+
private:
QString _name;
qreal _value;
@@ -190,8 +193,8 @@ class Q_DECLARATIVE_EXPORT QDeclarativePath : public QObject, public QDeclarativ
Q_INTERFACES(QDeclarativeParserStatus)
Q_PROPERTY(QDeclarativeListProperty<QDeclarativePathElement> pathElements READ pathElements)
- Q_PROPERTY(qreal startX READ startX WRITE setStartX)
- Q_PROPERTY(qreal startY READ startY WRITE setStartY)
+ Q_PROPERTY(qreal startX READ startX WRITE setStartX NOTIFY startXChanged)
+ Q_PROPERTY(qreal startY READ startY WRITE setStartY NOTIFY startYChanged)
Q_PROPERTY(bool closed READ isClosed NOTIFY changed)
Q_CLASSINFO("DefaultProperty", "pathElements")
Q_INTERFACES(QDeclarativeParserStatus)
@@ -216,6 +219,8 @@ public:
Q_SIGNALS:
void changed();
+ void startXChanged();
+ void startYChanged();
protected:
virtual void componentComplete();
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index f1b0213..50aa9ef 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -203,6 +203,9 @@ QVariant QDeclarativePathView::model() const
void QDeclarativePathView::setModel(const QVariant &model)
{
Q_D(QDeclarativePathView);
+ if (d->modelVariant == model)
+ return;
+
if (d->model) {
disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
@@ -242,6 +245,7 @@ void QDeclarativePathView::setModel(const QVariant &model)
d->pathOffset = 0;
d->regenerate();
d->fixOffset();
+ emit modelChanged();
}
/*!
@@ -269,9 +273,12 @@ QDeclarativePath *QDeclarativePathView::path() const
void QDeclarativePathView::setPath(QDeclarativePath *path)
{
Q_D(QDeclarativePathView);
+ if (d->path == path)
+ return;
d->path = path;
connect(d->path, SIGNAL(changed()), this, SLOT(refill()));
d->regenerate();
+ emit pathChanged();
}
/*!
@@ -333,7 +340,7 @@ void QDeclarativePathViewPrivate::setOffset(qreal o)
/*!
\qmlproperty real PathView::snapPosition
- This property determines the position (0-100) the nearest item will snap to.
+ This property determines the position (0.0-1.0) the nearest item will snap to.
*/
qreal QDeclarativePathView::snapPosition() const
{
@@ -344,8 +351,12 @@ qreal QDeclarativePathView::snapPosition() const
void QDeclarativePathView::setSnapPosition(qreal pos)
{
Q_D(QDeclarativePathView);
- d->snapPos = pos/100;
+ qreal normalizedPos = pos - int(pos);
+ if (qFuzzyCompare(normalizedPos, d->snapPos))
+ return;
+ d->snapPos = normalizedPos;
d->fixOffset();
+ emit snapPositionChanged();
}
/*!
@@ -365,7 +376,10 @@ qreal QDeclarativePathView::dragMargin() const
void QDeclarativePathView::setDragMargin(qreal dragMargin)
{
Q_D(QDeclarativePathView);
+ if (d->dragMargin == dragMargin)
+ return;
d->dragMargin = dragMargin;
+ emit dragMarginChanged();
}
/*!
@@ -392,16 +406,19 @@ QDeclarativeComponent *QDeclarativePathView::delegate() const
return 0;
}
-void QDeclarativePathView::setDelegate(QDeclarativeComponent *c)
+void QDeclarativePathView::setDelegate(QDeclarativeComponent *delegate)
{
Q_D(QDeclarativePathView);
+ if (delegate == this->delegate())
+ return;
if (!d->ownModel) {
d->model = new QDeclarativeVisualDataModel(qmlContext(this));
d->ownModel = true;
}
if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) {
- dataModel->setDelegate(c);
+ dataModel->setDelegate(delegate);
d->regenerate();
+ emit delegateChanged();
}
}
@@ -422,6 +439,7 @@ void QDeclarativePathView::setPathItemCount(int i)
return;
d->pathItems = i;
d->regenerate();
+ pathItemCountChanged();
}
QPointF QDeclarativePathViewPrivate::pointNear(const QPointF &point, qreal *nearPercent) const
diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p.h
index 709a4fc..df9c6ae 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepathview_p.h
@@ -56,15 +56,15 @@ class Q_DECLARATIVE_EXPORT QDeclarativePathView : public QDeclarativeItem
{
Q_OBJECT
- Q_PROPERTY(QVariant model READ model WRITE setModel)
- Q_PROPERTY(QDeclarativePath *path READ path WRITE setPath)
+ Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
+ Q_PROPERTY(QDeclarativePath *path READ path WRITE setPath NOTIFY pathChanged)
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
Q_PROPERTY(qreal offset READ offset WRITE setOffset NOTIFY offsetChanged)
- Q_PROPERTY(qreal snapPosition READ snapPosition WRITE setSnapPosition)
- Q_PROPERTY(qreal dragMargin READ dragMargin WRITE setDragMargin)
+ Q_PROPERTY(qreal snapPosition READ snapPosition WRITE setSnapPosition NOTIFY snapPositionChanged)
+ Q_PROPERTY(qreal dragMargin READ dragMargin WRITE setDragMargin NOTIFY dragMarginChanged)
Q_PROPERTY(int count READ count)
- Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate)
- Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount)
+ Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
+ Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount NOTIFY pathItemCountChanged)
public:
QDeclarativePathView(QDeclarativeItem *parent=0);
@@ -101,6 +101,12 @@ public:
Q_SIGNALS:
void currentIndexChanged();
void offsetChanged();
+ void modelChanged();
+ void pathChanged();
+ void dragMarginChanged();
+ void snapPositionChanged();
+ void delegateChanged();
+ void pathItemCountChanged();
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h
index ca50910..6344a8a 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h
@@ -60,6 +60,7 @@
#include <qdeclarative.h>
#include <qdeclarativeanimation_p_p.h>
+#include <qdeclarativeguard_p.h>
#include <qdatetime.h>
@@ -132,7 +133,7 @@ public:
int pathOffset;
int requestedIndex;
QList<QDeclarativeItem *> items;
- QGuard<QDeclarativeVisualModel> model;
+ QDeclarativeGuard<QDeclarativeVisualModel> model;
QVariant modelVariant;
enum MovementReason { Other, Key, Mouse };
MovementReason moveReason;
diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
index d534f21..05fe0f7 100644
--- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
@@ -393,9 +393,10 @@ void QDeclarativeRectangle::paint(QPainter *p, const QStyleOptionGraphicsItem *,
void QDeclarativeRectangle::drawRect(QPainter &p)
{
Q_D(QDeclarativeRectangle);
- if (d->gradient && d->gradient->gradient()) {
+ if ((d->gradient && d->gradient->gradient())
+ || d->radius > width()/2 || d->radius > height()/2) {
// XXX This path is still slower than the image path
- // Image path won't work for gradients though
+ // Image path won't work for gradients or invalid radius though
bool oldAA = p.testRenderHint(QPainter::Antialiasing);
if (d->smooth)
p.setRenderHint(QPainter::Antialiasing);
@@ -405,11 +406,23 @@ void QDeclarativeRectangle::drawRect(QPainter &p)
} else {
p.setPen(Qt::NoPen);
}
- p.setBrush(*d->gradient->gradient());
- if (d->radius > 0.)
- p.drawRoundedRect(0, 0, width(), height(), d->radius, d->radius);
+ if (d->gradient && d->gradient->gradient())
+ p.setBrush(*d->gradient->gradient());
else
- p.drawRect(0, 0, width(), height());
+ p.setBrush(d->color);
+ const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0;
+ QRectF rect;
+ if (pw%2)
+ rect = QRectF(0.5, 0.5, width()-1, height()-1);
+ else
+ rect = QRectF(0, 0, width(), height());
+ qreal radius = d->radius;
+ if (radius > width()/2 || radius > height()/2)
+ radius = qMin(width()/2, height()/2);
+ if (radius > 0.)
+ p.drawRoundedRect(rect, radius, radius);
+ else
+ p.drawRect(rect);
if (d->smooth)
p.setRenderHint(QPainter::Antialiasing, oldAA);
} else {
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index 8e44b26..be73b39 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -613,6 +613,11 @@ void QDeclarativeTextEdit::setPersistentSelection(bool on)
emit persistentSelectionChanged(d->persistentSelection);
}
+/*
+ \qmlproperty number TextEdit::textMargin
+
+ The margin, in pixels, around the text in the TextEdit.
+*/
qreal QDeclarativeTextEdit::textMargin() const
{
Q_D(const QDeclarativeTextEdit);
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index cd72ef9..55f1c89 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -53,6 +53,7 @@
#include <qdeclarativedeclarativedata_p.h>
#include <qdeclarativepropertycache_p.h>
#include <qdeclarativeguard_p.h>
+#include <qdeclarativeglobal_p.h>
#include <qlistmodelinterface_p.h>
#include <qhash.h>
@@ -80,6 +81,14 @@ public:
static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->emitChildrenChanged();
}
+ static int children_count(QDeclarativeListProperty<QDeclarativeItem> *prop) {
+ return static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->children.count();
+ }
+
+ static QDeclarativeItem *children_at(QDeclarativeListProperty<QDeclarativeItem> *prop, int index) {
+ return static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->children.at(index);
+ }
+
void itemAppended() {
Q_Q(QDeclarativeVisualItemModel);
QDeclarativeVisualItemModelAttached *attached = QDeclarativeVisualItemModelAttached::properties(children.last());
@@ -135,7 +144,8 @@ QDeclarativeVisualItemModel::QDeclarativeVisualItemModel()
QDeclarativeListProperty<QDeclarativeItem> QDeclarativeVisualItemModel::children()
{
Q_D(QDeclarativeVisualItemModel);
- return QDeclarativeListProperty<QDeclarativeItem>(this, d, QDeclarativeVisualItemModelPrivate::children_append);
+ return QDeclarativeListProperty<QDeclarativeItem>(this, d, d->children_append,
+ d->children_count, d->children_at);
}
/*!
@@ -473,7 +483,7 @@ QVariant QDeclarativeVisualDataModelDataMetaObject::initialValue(int propId)
QDeclarativeVisualDataModelData::QDeclarativeVisualDataModelData(int index,
QDeclarativeVisualDataModel *model)
-: m_index(index), m_model(model),
+: m_index(index), m_model(model),
m_meta(new QDeclarativeVisualDataModelDataMetaObject(this, QDeclarativeVisualDataModelPrivate::get(model)->m_delegateDataType))
{
QDeclarativeVisualDataModelPrivate *modelPriv = QDeclarativeVisualDataModelPrivate::get(model);
@@ -540,7 +550,7 @@ QVariant QDeclarativeVisualDataModelPartsMetaObject::initialValue(int id)
}
QDeclarativeVisualDataModelParts::QDeclarativeVisualDataModelParts(QDeclarativeVisualDataModel *parent)
-: QObject(parent), model(parent)
+: QObject(parent), model(parent)
{
new QDeclarativeVisualDataModelPartsMetaObject(this);
}
@@ -830,7 +840,7 @@ void QDeclarativeVisualDataModel::setDelegate(QDeclarativeComponent *delegate)
Rectangle {
height: 25; width: 100
Text { text: path }
- MouseRegion {
+ MouseArea {
anchors.fill: parent;
onClicked: myModel.setRoot(path)
}
@@ -959,7 +969,7 @@ QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(Q
QObject *QDeclarativeVisualDataModel::parts()
{
Q_D(QDeclarativeVisualDataModel);
- if (!d->m_parts)
+ if (!d->m_parts)
d->m_parts = new QDeclarativeVisualDataModelParts(this);
return d->m_parts;
}
@@ -984,8 +994,8 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray
if (complete)
d->m_delegate->completeCreate();
if (nobj) {
- ctxt->setParent(nobj);
- data->setParent(nobj);
+ QDeclarative_setParent_noEvent(ctxt, nobj);
+ QDeclarative_setParent_noEvent(data, nobj);
d->m_cache.insertItem(index, nobj);
if (QDeclarativePackage *package = qobject_cast<QDeclarativePackage *>(nobj))
emit createdPackage(index, package);
@@ -1268,7 +1278,6 @@ void QDeclarativeVisualDataModel::_q_dataChanged(const QModelIndex &begin, const
void QDeclarativeVisualDataModel::_q_modelReset()
{
- Q_D(QDeclarativeVisualDataModel);
emit modelReset();
}
diff --git a/src/declarative/qml/parser/qdeclarativejs.g b/src/declarative/qml/parser/qdeclarativejs.g
index 7cf81b2..493ad25 100644
--- a/src/declarative/qml/parser/qdeclarativejs.g
+++ b/src/declarative/qml/parser/qdeclarativejs.g
@@ -1020,7 +1020,7 @@ case $rule_number: {
JsIdentifier: T_ON ;
/.
case $rule_number: {
- QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_READONLY]);
+ QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_ON]);
sym(1).sval = driver->intern(s.constData(), s.length());
break;
}
diff --git a/src/declarative/qml/parser/qdeclarativejsgrammar.cpp b/src/declarative/qml/parser/qdeclarativejsgrammar.cpp
index 0677bc5..89493ff 100644
--- a/src/declarative/qml/parser/qdeclarativejsgrammar.cpp
+++ b/src/declarative/qml/parser/qdeclarativejsgrammar.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
diff --git a/src/declarative/qml/parser/qdeclarativejsgrammar_p.h b/src/declarative/qml/parser/qdeclarativejsgrammar_p.h
index 2b2e3d1..32bb12b 100644
--- a/src/declarative/qml/parser/qdeclarativejsgrammar_p.h
+++ b/src/declarative/qml/parser/qdeclarativejsgrammar_p.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE
class QDeclarativeJSGrammar
{
public:
- enum {
+ enum VariousConstants {
EOF_SYMBOL = 0,
REDUCE_HERE = 100,
SHIFT_THERE = 99,
diff --git a/src/declarative/qml/parser/qdeclarativejsparser.cpp b/src/declarative/qml/parser/qdeclarativejsparser.cpp
index fd9e690..c86e047 100644
--- a/src/declarative/qml/parser/qdeclarativejsparser.cpp
+++ b/src/declarative/qml/parser/qdeclarativejsparser.cpp
@@ -516,7 +516,7 @@ case 66: {
}
case 67: {
- QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_READONLY]);
+ QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_ON]);
sym(1).sval = driver->intern(s.constData(), s.length());
break;
}
diff --git a/src/declarative/qml/qdeclarativebinding_p.h b/src/declarative/qml/qdeclarativebinding_p.h
index ec5809d..1a714f0 100644
--- a/src/declarative/qml/qdeclarativebinding_p.h
+++ b/src/declarative/qml/qdeclarativebinding_p.h
@@ -64,7 +64,7 @@
QT_BEGIN_NAMESPACE
-class Q_AUTOTEST_EXPORT QDeclarativeAbstractBinding
+class Q_DECLARATIVE_EXPORT QDeclarativeAbstractBinding
{
public:
QDeclarativeAbstractBinding();
@@ -101,7 +101,7 @@ private:
class QDeclarativeContext;
class QDeclarativeBindingPrivate;
-class Q_AUTOTEST_EXPORT QDeclarativeBinding : public QDeclarativeExpression, public QDeclarativeAbstractBinding
+class Q_DECLARATIVE_EXPORT QDeclarativeBinding : public QDeclarativeExpression, public QDeclarativeAbstractBinding
{
Q_OBJECT
public:
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 5da207d..5a2f3b5 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -65,6 +65,7 @@
#include "qdeclarativescriptparser_p.h"
#include "qdeclarativebinding_p.h"
#include "qdeclarativecompiledbindings_p.h"
+#include "qdeclarativeglobalscriptclass_p.h"
#include <qfxperf_p_p.h>
@@ -113,32 +114,6 @@ QList<QDeclarativeError> QDeclarativeCompiler::errors() const
}
/*!
- Returns true if \a val is a legal object id, false otherwise.
-
- Legal ids must start with a lower-case letter or underscore, and contain only
- letters, numbers and underscores.
-*/
-bool QDeclarativeCompiler::isValidId(const QString &val)
-{
- if (val.isEmpty())
- return false;
-
- if (val.at(0).isLetter() && !val.at(0).isLower()) {
- qWarning().nospace() << "id " << val << " is invalid: ids cannot start with uppercase letters";
- return false;
- }
-
- QChar u(QLatin1Char('_'));
- for (int ii = 0; ii < val.count(); ++ii)
- if (val.at(ii) != u &&
- ((ii == 0 && !val.at(ii).isLetter()) ||
- (ii != 0 && !val.at(ii).isLetterOrNumber())) )
- return false;
-
- return true;
-}
-
-/*!
Returns true if \a name refers to an attached property, false otherwise.
Attached property names are those that start with a capital letter.
@@ -718,6 +693,7 @@ bool QDeclarativeCompiler::buildObject(Object *obj, const BindingContext &ctxt)
BindingContext objCtxt(obj);
// Create the synthesized meta object, ignoring aliases
+ COMPILE_CHECK(checkDynamicMeta(obj));
COMPILE_CHECK(mergeDynamicMetaProperties(obj));
COMPILE_CHECK(buildDynamicMeta(obj, IgnoreAliases));
@@ -1007,12 +983,15 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj)
} else if (v->type == Value::SignalExpression) {
+ BindingContext ctxt = compileState.signalExpressions.value(v);
+
QDeclarativeInstruction store;
store.type = QDeclarativeInstruction::StoreSignal;
store.line = v->location.start.line;
store.storeSignal.signalIndex = prop->index;
store.storeSignal.value =
output->indexForString(v->value.asScript().trimmed());
+ store.storeSignal.context = ctxt.stack;
output->bytecode << store;
}
@@ -1139,10 +1118,11 @@ bool QDeclarativeCompiler::buildComponent(QDeclarativeParser::Object *obj,
if (obj->properties.count())
idProp = *obj->properties.begin();
- if (idProp && (idProp->value || idProp->values.count() > 1 || !isValidId(idProp->values.first()->primitive())))
- COMPILE_EXCEPTION(idProp, QCoreApplication::translate("QDeclarativeCompiler","Invalid component id specification"));
-
if (idProp) {
+ if (idProp->value || idProp->values.count() > 1 || idProp->values.at(0)->object)
+ COMPILE_EXCEPTION(idProp, QCoreApplication::translate("QDeclarativeCompiler","Invalid component id specification"));
+ COMPILE_CHECK(checkValidId(idProp->values.first(), idProp->values.first()->primitive()));
+
QString idVal = idProp->values.first()->primitive();
if (compileState.ids.contains(idVal))
@@ -1344,7 +1324,7 @@ QMetaMethod QDeclarativeCompiler::findSignalByName(const QMetaObject *mo, const
}
bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj,
- const BindingContext &ctxt)
+ const BindingContext &ctxt)
{
Q_ASSERT(obj->metaObject());
Q_ASSERT(!prop->isEmpty());
@@ -1365,7 +1345,7 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDecl
} else {
- if (prop->value || prop->values.count() > 1)
+ if (prop->value || prop->values.count() != 1)
COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Incorrectly specified signal"));
prop->index = sigIdx;
@@ -1380,6 +1360,8 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDecl
QString script = prop->values.at(0)->value.asScript().trimmed();
if (script.isEmpty())
COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Empty signal assignment"));
+
+ compileState.signalExpressions.insert(prop->values.at(0), ctxt);
}
}
@@ -1623,6 +1605,10 @@ void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeParser::Property *p
for (int ii = 0; ii < prop->values.count(); ++ii) {
QDeclarativeParser::Value *v = prop->values.at(ii);
+ Q_ASSERT(v->type == Value::CreatedObject ||
+ v->type == Value::PropertyBinding ||
+ v->type == Value::Literal);
+
if (v->type == Value::CreatedObject) {
genObject(v->object);
@@ -1652,7 +1638,27 @@ void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeParser::Property *p
output->bytecode << store;
}
- } else if (v->type == Value::ValueSource) {
+ } else if (v->type == Value::PropertyBinding) {
+
+ genBindingAssignment(v, prop, obj, valueTypeProperty);
+
+ } else if (v->type == Value::Literal) {
+
+ QMetaProperty mp = obj->metaObject()->property(prop->index);
+ genLiteralAssignment(mp, v);
+
+ }
+
+ }
+
+ for (int ii = 0; ii < prop->onValues.count(); ++ii) {
+
+ QDeclarativeParser::Value *v = prop->onValues.at(ii);
+
+ Q_ASSERT(v->type == Value::ValueSource ||
+ v->type == Value::ValueInterceptor);
+
+ if (v->type == Value::ValueSource) {
genObject(v->object);
QDeclarativeInstruction store;
@@ -1685,16 +1691,6 @@ void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeParser::Property *p
QDeclarativeType *valueType = toQmlType(v->object);
store.assignValueInterceptor.castValue = valueType->propertyValueInterceptorCast();
output->bytecode << store;
-
- } else if (v->type == Value::PropertyBinding) {
-
- genBindingAssignment(v, prop, obj, valueTypeProperty);
-
- } else if (v->type == Value::Literal) {
-
- QMetaProperty mp = obj->metaObject()->property(prop->index);
- genLiteralAssignment(mp, v);
-
}
}
@@ -1711,8 +1707,7 @@ bool QDeclarativeCompiler::buildIdProperty(QDeclarativeParser::Property *prop,
QDeclarativeParser::Value *idValue = prop->values.at(0);
QString val = idValue->primitive();
- if (!isValidId(val))
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","\"%1\" is not a valid object id").arg(val));
+ COMPILE_CHECK(checkValidId(idValue, val));
// We disallow id's that conflict with import prefixes and types
QDeclarativeEnginePrivate::ImportedNamespace *ns = 0;
@@ -1793,19 +1788,25 @@ bool QDeclarativeCompiler::buildAttachedProperty(QDeclarativeParser::Property *p
// }
// font is a nested property. pointSize and family are not.
bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
- const BindingContext &ctxt)
+ QDeclarativeParser::Object *obj,
+ const BindingContext &ctxt)
{
Q_ASSERT(prop->type != 0);
Q_ASSERT(prop->index != -1);
- if (prop->values.count())
- COMPILE_EXCEPTION(prop->values.first(), QCoreApplication::translate("QDeclarativeCompiler", "Invalid value in grouped property"));
-
- if (prop->type < (int)QVariant::UserType) {
+ if (QDeclarativeValueTypeFactory::isValueType(prop->type)) {
QDeclarativeEnginePrivate *ep =
static_cast<QDeclarativeEnginePrivate *>(QObjectPrivate::get(engine));
if (prop->type >= 0 /* QVariant == -1 */ && ep->valueTypes[prop->type]) {
+
+ if (prop->values.count()) {
+ if (prop->values.at(0)->location < prop->value->location) {
+ COMPILE_EXCEPTION(prop->value, QCoreApplication::translate("QDeclarativeCompiler", "Property has already been assigned a value"));
+ } else {
+ COMPILE_EXCEPTION(prop->values.at(0), QCoreApplication::translate("QDeclarativeCompiler", "Property has already been assigned a value"));
+ }
+ }
+
COMPILE_CHECK(buildValueTypeProperty(ep->valueTypes[prop->type],
prop->value, obj, ctxt.incr()));
obj->addValueTypeProperty(prop);
@@ -1820,6 +1821,9 @@ bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeParser::Property *pr
if (!prop->value->metatype)
COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Invalid grouped property access"));
+ if (prop->values.count())
+ COMPILE_EXCEPTION(prop->values.at(0), QCoreApplication::translate("QDeclarativeCompiler", "Cannot assign a value directly to a grouped property"));
+
obj->addGroupedProperty(prop);
COMPILE_CHECK(buildSubObject(prop->value, ctxt.incr()));
@@ -1829,9 +1833,9 @@ bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeParser::Property *pr
}
bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Object *baseObj,
- const BindingContext &ctxt)
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Object *baseObj,
+ const BindingContext &ctxt)
{
if (obj->defaultProperty)
COMPILE_EXCEPTION(obj, QCoreApplication::translate("QDeclarativeCompiler","Invalid property use"));
@@ -1848,37 +1852,36 @@ bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type,
if (prop->value)
COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Property assignment expected"));
- if (prop->values.count() != 1)
+ if (prop->values.count() > 1) {
COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Single property assignment expected"));
+ } else if (prop->values.count()) {
+ Value *value = prop->values.at(0);
- Value *value = prop->values.at(0);
-
- if (value->object) {
- bool isPropertyValue = output->types.at(value->object->type).type->propertyValueSourceCast() != -1;
- bool isPropertyInterceptor = output->types.at(value->object->type).type->propertyValueInterceptorCast() != -1;
- if (!isPropertyValue && !isPropertyInterceptor) {
+ if (value->object) {
COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Unexpected object assignment"));
- } else {
- COMPILE_CHECK(buildObject(value->object, ctxt));
-
- if (isPropertyInterceptor && baseObj->synthdata.isEmpty())
- buildDynamicMeta(baseObj, ForceCreation);
- value->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor;
+ } else if (value->value.isScript()) {
+ // ### Check for writability
+ BindingReference reference;
+ reference.expression = value->value;
+ reference.property = prop;
+ reference.value = value;
+ reference.bindingContext = ctxt;
+ reference.bindingContext.owner++;
+ addBindingReference(reference);
+ value->type = Value::PropertyBinding;
+ } else {
+ COMPILE_CHECK(testLiteralAssignment(p, value));
+ value->type = Value::Literal;
}
- } else if (value->value.isScript()) {
- // ### Check for writability
- BindingReference reference;
- reference.expression = value->value;
- reference.property = prop;
- reference.value = value;
- reference.bindingContext = ctxt;
- reference.bindingContext.owner++;
- addBindingReference(reference);
- value->type = Value::PropertyBinding;
- } else {
- COMPILE_CHECK(testLiteralAssignment(p, value));
- value->type = Value::Literal;
}
+
+ for (int ii = 0; ii < prop->onValues.count(); ++ii) {
+ Value *v = prop->onValues.at(ii);
+ Q_ASSERT(v->object);
+
+ COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, baseObj, v, ctxt));
+ }
+
obj->addValueProperty(prop);
}
@@ -1886,13 +1889,11 @@ bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type,
}
// Build assignments to QML lists. QML lists are properties of type
-// QList<T *> * and QDeclarativeList<T *> *.
-//
-// QList<T *> * types can accept a list of objects, or a single binding
-// QDeclarativeList<T *> * types can accept a list of objects
+// QDeclarativeListProperty<T>. List properties can accept a list of
+// objects, or a single binding.
bool QDeclarativeCompiler::buildListProperty(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
- const BindingContext &ctxt)
+ QDeclarativeParser::Object *obj,
+ const BindingContext &ctxt)
{
Q_ASSERT(QDeclarativeEnginePrivate::get(engine)->isList(prop->type));
@@ -1950,20 +1951,6 @@ bool QDeclarativeCompiler::buildScriptStringProperty(QDeclarativeParser::Propert
}
// Compile regular property assignments of the form "property: <value>"
-//
-// ### The following problems exist
-//
-// There is no distinction between how "lists" of values are specified. This
-// Item {
-// children: Item {}
-// children: Item {}
-// }
-// is identical to
-// Item {
-// children: [ Item {}, Item {} ]
-// }
-//
-// We allow assignming multiple values to single value properties
bool QDeclarativeCompiler::buildPropertyAssignment(QDeclarativeParser::Property *prop,
QDeclarativeParser::Object *obj,
const BindingContext &ctxt)
@@ -1983,14 +1970,21 @@ bool QDeclarativeCompiler::buildPropertyAssignment(QDeclarativeParser::Property
}
}
+ for (int ii = 0; ii < prop->onValues.count(); ++ii) {
+ Value *v = prop->onValues.at(ii);
+
+ Q_ASSERT(v->object);
+ COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, obj, v, ctxt));
+ }
+
return true;
}
// Compile assigning a single object instance to a regular property
bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Value *v,
- const BindingContext &ctxt)
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Value *v,
+ const BindingContext &ctxt)
{
Q_ASSERT(prop->index != -1);
Q_ASSERT(v->object->type != -1);
@@ -2019,15 +2013,6 @@ bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeParser::Pro
v->object->metatype = output->types.at(v->object->type).metaObject();
Q_ASSERT(v->object->metaObject());
- // Will be true if the assigned type inherits QDeclarativePropertyValueSource
- bool isPropertyValue = false;
- // Will be true if the assigned type inherits QDeclarativePropertyValueInterceptor
- bool isPropertyInterceptor = false;
- if (QDeclarativeType *valueType = toQmlType(v->object)) {
- isPropertyValue = valueType->propertyValueSourceCast() != -1;
- isPropertyInterceptor = valueType->propertyValueInterceptorCast() != -1;
- }
-
// We want to raw metaObject here as the raw metaobject is the
// actual property type before we applied any extensions that might
// effect the properties on the type, but don't effect assignability
@@ -2063,13 +2048,6 @@ bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeParser::Pro
component->getDefaultProperty()->addValue(componentValue);
v->object = component;
COMPILE_CHECK(buildPropertyObjectAssignment(prop, obj, v, ctxt));
- } else if (isPropertyValue || isPropertyInterceptor) {
- // Assign as a property value source
- COMPILE_CHECK(buildObject(v->object, ctxt));
-
- if (isPropertyInterceptor && prop->parent->synthdata.isEmpty())
- buildDynamicMeta(prop->parent, ForceCreation);
- v->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor;
} else {
COMPILE_EXCEPTION(v->object, QCoreApplication::translate("QDeclarativeCompiler","Cannot assign object to property"));
}
@@ -2078,6 +2056,55 @@ bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeParser::Pro
return true;
}
+// Compile assigning a single object instance to a regular property using the "on" syntax.
+//
+// For example:
+// Item {
+// NumberAnimation on x { }
+// }
+bool QDeclarativeCompiler::buildPropertyOnAssignment(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Object *baseObj,
+ QDeclarativeParser::Value *v,
+ const BindingContext &ctxt)
+{
+ Q_ASSERT(prop->index != -1);
+ Q_ASSERT(v->object->type != -1);
+
+ if (!obj->metaObject()->property(prop->index).isWritable())
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop->name)));
+
+
+ // Normally buildObject() will set this up, but we need the static
+ // meta object earlier to test for assignability. It doesn't matter
+ // that there may still be outstanding synthesized meta object changes
+ // on this type, as they are not relevant for assignability testing
+ v->object->metatype = output->types.at(v->object->type).metaObject();
+ Q_ASSERT(v->object->metaObject());
+
+ // Will be true if the assigned type inherits QDeclarativePropertyValueSource
+ bool isPropertyValue = false;
+ // Will be true if the assigned type inherits QDeclarativePropertyValueInterceptor
+ bool isPropertyInterceptor = false;
+ if (QDeclarativeType *valueType = toQmlType(v->object)) {
+ isPropertyValue = valueType->propertyValueSourceCast() != -1;
+ isPropertyInterceptor = valueType->propertyValueInterceptorCast() != -1;
+ }
+
+ if (isPropertyValue || isPropertyInterceptor) {
+ // Assign as a property value source
+ COMPILE_CHECK(buildObject(v->object, ctxt));
+
+ if (isPropertyInterceptor && prop->parent->synthdata.isEmpty())
+ buildDynamicMeta(baseObj, ForceCreation);
+ v->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor;
+ } else {
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","\"%1\" cannot operate on \"%2\"").arg(v->object->typeName.constData()).arg(prop->name.constData()));
+ }
+
+ return true;
+}
+
// Compile assigning a literal or binding to a regular property
bool QDeclarativeCompiler::buildPropertyLiteralAssignment(QDeclarativeParser::Property *prop,
QDeclarativeParser::Object *obj,
@@ -2203,10 +2230,13 @@ bool QDeclarativeCompiler::mergeDynamicMetaProperties(QDeclarativeParser::Object
continue;
Property *property = 0;
- if (p.isDefaultProperty)
+ if (p.isDefaultProperty) {
property = obj->getDefaultProperty();
- else
+ } else {
property = obj->getProperty(p.name);
+ if (!property->values.isEmpty())
+ COMPILE_EXCEPTION(property, QCoreApplication::translate("QDeclarativeCompiler","Property value set multiple times"));
+ }
if (property->value)
COMPILE_EXCEPTION(property, QCoreApplication::translate("QDeclarativeCompiler","Invalid property nesting"));
@@ -2233,8 +2263,6 @@ bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeParser::Object *obj, Dyn
obj->dynamicSlots.isEmpty())
return true;
- COMPILE_CHECK(checkDynamicMeta(obj));
-
QByteArray dynamicData(sizeof(QDeclarativeVMEMetaData), (char)0);
QByteArray newClassName = obj->metatype->className();
@@ -2437,6 +2465,31 @@ bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeParser::Object *obj, Dyn
return true;
}
+bool QDeclarativeCompiler::checkValidId(QDeclarativeParser::Value *v, const QString &val)
+{
+ if (val.isEmpty())
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "Invalid empty ID"));
+
+ if (val.at(0).isLetter() && !val.at(0).isLower())
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "IDs cannot start with an uppercase letter"));
+
+ QChar u(QLatin1Char('_'));
+ for (int ii = 0; ii < val.count(); ++ii) {
+
+ if (ii == 0 && !val.at(ii).isLetter() && val.at(ii) != u) {
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "IDs must start with a letter or underscore"));
+ } else if (ii != 0 && !val.at(ii).isLetterOrNumber() && val.at(ii) != u) {
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "IDs must contain only letters, numbers, and underscores"));
+ }
+
+ }
+
+ if (QDeclarativeEnginePrivate::get(engine)->globalClass->illegalNames().contains(val))
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "ID illegally masks global JavaScript property"));
+
+ return true;
+}
+
#include <qdeclarativejsparser_p.h>
static QStringList astNodeToStringList(QDeclarativeJS::AST::Node *node)
@@ -2560,9 +2613,9 @@ bool QDeclarativeCompiler::buildBinding(QDeclarativeParser::Value *value,
}
void QDeclarativeCompiler::genBindingAssignment(QDeclarativeParser::Value *binding,
- QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Property *valueTypeProperty)
+ QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Property *valueTypeProperty)
{
Q_UNUSED(obj);
Q_ASSERT(compileState.bindings.contains(binding));
diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h
index 2ea3366..cca42e2 100644
--- a/src/declarative/qml/qdeclarativecompiler_p.h
+++ b/src/declarative/qml/qdeclarativecompiler_p.h
@@ -155,7 +155,6 @@ public:
bool isError() const;
QList<QDeclarativeError> errors() const;
- static bool isValidId(const QString &);
static bool isAttachedPropertyName(const QByteArray &);
static bool isSignalPropertyName(const QByteArray &);
@@ -219,6 +218,11 @@ private:
QDeclarativeParser::Object *obj,
QDeclarativeParser::Value *value,
const BindingContext &ctxt);
+ bool buildPropertyOnAssignment(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Object *baseObj,
+ QDeclarativeParser::Value *value,
+ const BindingContext &ctxt);
bool buildPropertyLiteralAssignment(QDeclarativeParser::Property *prop,
QDeclarativeParser::Object *obj,
QDeclarativeParser::Value *value,
@@ -242,6 +246,7 @@ private:
QDeclarativeParser::Object *obj,
const QDeclarativeParser::Object::DynamicProperty &);
bool completeComponentBuild();
+ bool checkValidId(QDeclarativeParser::Value *, const QString &);
void genObject(QDeclarativeParser::Object *obj);
@@ -302,6 +307,7 @@ private:
QByteArray compiledBindingData;
QHash<QDeclarativeParser::Value *, BindingReference> bindings;
+ QHash<QDeclarativeParser::Value *, BindingContext> signalExpressions;
QList<QDeclarativeParser::Object *> aliasingObjects;
QDeclarativeParser::Object *root;
};
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index 6a2d2d1..d6bb216 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -437,6 +437,13 @@ void QDeclarativeComponent::loadUrl(const QUrl &url)
else
d->url = url;
+ if (url.isEmpty()) {
+ QDeclarativeError error;
+ error.setDescription(tr("Invalid empty URL"));
+ d->state.errors << error;
+ return;
+ }
+
QDeclarativeCompositeTypeData *data =
QDeclarativeEnginePrivate::get(d->engine)->typeManager.get(d->url);
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp
index b244cd8..f70e143 100644
--- a/src/declarative/qml/qdeclarativecontext.cpp
+++ b/src/declarative/qml/qdeclarativecontext.cpp
@@ -47,6 +47,7 @@
#include "qdeclarativeengine.h"
#include "qdeclarativecompiledbindings_p.h"
#include "qdeclarativeinfo.h"
+#include "qdeclarativeglobalscriptclass_p.h"
#include <qscriptengine.h>
#include <QtCore/qvarlengtharray.h>
@@ -74,10 +75,13 @@ void QDeclarativeContextPrivate::addScript(const QDeclarativeParser::Object::Scr
QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
+
scriptContext->pushScope(enginePriv->contextClass->newContext(q, scopeObject));
+ scriptContext->pushScope(enginePriv->globalClass->globalObject());
QScriptValue scope = scriptEngine->newObject();
scriptContext->setActivationObject(scope);
+ scriptContext->pushScope(scope);
for (int ii = 0; ii < script.codes.count(); ++ii) {
scriptEngine->evaluate(script.codes.at(ii), script.files.at(ii), script.lineNumbers.at(ii));
@@ -480,7 +484,10 @@ QVariant QDeclarativeContext::contextProperty(const QString &name) const
if (!value.isValid() && parentContext())
value = parentContext()->contextProperty(name);
} else {
- value = d->propertyValues[idx];
+ if (idx >= d->propertyValues.count())
+ value = QVariant::fromValue(d->idValues[idx - d->propertyValues.count()].data());
+ else
+ value = d->propertyValues[idx];
}
return value;
diff --git a/src/declarative/qml/qdeclarativecontextscriptclass.cpp b/src/declarative/qml/qdeclarativecontextscriptclass.cpp
index 7deed0b..d6305d8 100644
--- a/src/declarative/qml/qdeclarativecontextscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativecontextscriptclass.cpp
@@ -50,10 +50,11 @@
QT_BEGIN_NAMESPACE
struct ContextData : public QScriptDeclarativeClass::Object {
- ContextData() : isSharedContext(true) {}
- ContextData(QDeclarativeContext *c, QObject *o) : context(c), scopeObject(o), isSharedContext(false) {}
+ ContextData() : overrideObject(0), isSharedContext(true) {}
+ ContextData(QDeclarativeContext *c, QObject *o) : context(c), scopeObject(o), overrideObject(0), isSharedContext(false) {}
QDeclarativeGuard<QDeclarativeContext> context;
QDeclarativeGuard<QObject> scopeObject;
+ QObject *overrideObject;
bool isSharedContext;
QDeclarativeContext *getContext(QDeclarativeEngine *engine) {
@@ -110,6 +111,17 @@ QDeclarativeContext *QDeclarativeContextScriptClass::contextFromValue(const QScr
return data->getContext(engine);
}
+QObject *QDeclarativeContextScriptClass::setOverrideObject(QScriptValue &v, QObject *override)
+{
+ if (scriptClass(v) != this)
+ return 0;
+
+ ContextData *data = (ContextData *)object(v);
+ QObject *rv = data->overrideObject;
+ data->overrideObject = override;
+ return rv;
+}
+
QScriptClass::QueryFlags
QDeclarativeContextScriptClass::queryProperty(Object *object, const Identifier &name,
QScriptClass::QueryFlags flags)
@@ -127,6 +139,20 @@ QDeclarativeContextScriptClass::queryProperty(Object *object, const Identifier &
if (!bindContext)
return 0;
+ QObject *overrideObject = ((ContextData *)object)->overrideObject;
+ if (overrideObject) {
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+ QScriptClass::QueryFlags rv =
+ ep->objectClass->queryProperty(overrideObject, name, flags, bindContext,
+ QDeclarativeObjectScriptClass::ImplicitObject |
+ QDeclarativeObjectScriptClass::SkipAttachedProperties);
+ if (rv) {
+ lastScopeObject = overrideObject;
+ lastContext = bindContext;
+ return rv;
+ }
+ }
+
bool includeTypes = true;
while (bindContext) {
QScriptClass::QueryFlags rv =
diff --git a/src/declarative/qml/qdeclarativecontextscriptclass_p.h b/src/declarative/qml/qdeclarativecontextscriptclass_p.h
index 26086ec..4b0dca0 100644
--- a/src/declarative/qml/qdeclarativecontextscriptclass_p.h
+++ b/src/declarative/qml/qdeclarativecontextscriptclass_p.h
@@ -70,6 +70,7 @@ public:
QScriptValue newSharedContext();
QDeclarativeContext *contextFromValue(const QScriptValue &);
+ QObject *setOverrideObject(QScriptValue &, QObject *);
protected:
virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
diff --git a/src/declarative/qml/qdeclarativedeclarativedata_p.h b/src/declarative/qml/qdeclarativedeclarativedata_p.h
index 2c92419..ae40130 100644
--- a/src/declarative/qml/qdeclarativedeclarativedata_p.h
+++ b/src/declarative/qml/qdeclarativedeclarativedata_p.h
@@ -103,7 +103,10 @@ public:
static QDeclarativeDeclarativeData *get(const QObject *object, bool create = false) {
QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
- if (priv->declarativeData) {
+ if (priv->wasDeleted) {
+ Q_ASSERT(!create);
+ return 0;
+ } else if (priv->declarativeData) {
return static_cast<QDeclarativeDeclarativeData *>(priv->declarativeData);
} else if (create) {
priv->declarativeData = new QDeclarativeDeclarativeData;
@@ -117,6 +120,11 @@ public:
template<class T>
void QDeclarativeGuard<T>::addGuard()
{
+ if (QObjectPrivate::get(o)->wasDeleted) {
+ if (prev) remGuard();
+ return;
+ }
+
QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(o, true);
next = data->guards;
if (next) reinterpret_cast<QDeclarativeGuard<T> *>(next)->prev = &next;
diff --git a/src/declarative/qml/qdeclarativedom.cpp b/src/declarative/qml/qdeclarativedom.cpp
index 6c81f34..cb56ead 100644
--- a/src/declarative/qml/qdeclarativedom.cpp
+++ b/src/declarative/qml/qdeclarativedom.cpp
@@ -374,7 +374,10 @@ QDeclarativeDomValue QDeclarativeDomProperty::value() const
QDeclarativeDomValue rv;
if (d->property) {
rv.d->property = d->property;
- rv.d->value = d->property->values.at(0);
+ if (d->property->values.count())
+ rv.d->value = d->property->values.at(0);
+ else
+ rv.d->value = d->property->onValues.at(0);
rv.d->property->addref();
rv.d->value->addref();
}
@@ -505,7 +508,7 @@ int QDeclarativeDomDynamicProperty::propertyType() const
QByteArray QDeclarativeDomDynamicProperty::propertyTypeName() const
{
- if (isValid())
+ if (isValid())
return d->property.customType;
return QByteArray();
@@ -1181,7 +1184,7 @@ QDeclarativeDomObject QDeclarativeDomValueValueSource::object() const
\qml
Rectangle {
- x: Behavior { NumberAnimation { duration: 500 } }
+ Behavior on x { NumberAnimation { duration: 500 } }
}
\endqml
*/
@@ -1225,7 +1228,7 @@ QDeclarativeDomValueValueInterceptor &QDeclarativeDomValueValueInterceptor::oper
returned.
\qml
Rectangle {
- x: Behavior { NumberAnimation { duration: 500 } }
+ Behavior on x { NumberAnimation { duration: 500 } }
}
\endqml
*/
@@ -1346,7 +1349,7 @@ QDeclarativeDomValue::Type QDeclarativeDomValue::type() const
{
if (d->property)
if (QDeclarativeMetaType::isList(d->property->type) ||
- (d->property && d->property->values.count() > 1))
+ (d->property && (d->property->values.count() + d->property->onValues.count()) > 1))
return List;
QDeclarativeParser::Value *value = d->value;
@@ -1628,6 +1631,13 @@ QList<QDeclarativeDomValue> QDeclarativeDomList::values() const
rv << v;
}
+ for (int ii = 0; ii < d->property->onValues.count(); ++ii) {
+ QDeclarativeDomValue v;
+ v.d->value = d->property->onValues.at(ii);
+ v.d->value->addref();
+ rv << v;
+ }
+
return rv;
}
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index af75e98..7ce2d0b 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -236,9 +236,13 @@ QDeclarativeScriptEngine::QDeclarativeScriptEngine(QDeclarativeEnginePrivate *pr
qtObject.setProperty(QLatin1String("tint"), newFunction(QDeclarativeEnginePrivate::tint, 2));
}
+ //date/time formatting
+ qtObject.setProperty(QLatin1String("formatDate"),newFunction(QDeclarativeEnginePrivate::formatDate, 2));
+ qtObject.setProperty(QLatin1String("formatTime"),newFunction(QDeclarativeEnginePrivate::formatTime, 2));
+ qtObject.setProperty(QLatin1String("formatDateTime"),newFunction(QDeclarativeEnginePrivate::formatDateTime, 2));
+
//misc methods
qtObject.setProperty(QLatin1String("closestAngle"), newFunction(QDeclarativeEnginePrivate::closestAngle, 2));
- qtObject.setProperty(QLatin1String("playSound"), newFunction(QDeclarativeEnginePrivate::playSound, 1));
qtObject.setProperty(QLatin1String("openUrlExternally"),newFunction(QDeclarativeEnginePrivate::desktopOpenUrl, 1));
qtObject.setProperty(QLatin1String("md5"),newFunction(QDeclarativeEnginePrivate::md5, 1));
qtObject.setProperty(QLatin1String("btoa"),newFunction(QDeclarativeEnginePrivate::btoa, 1));
@@ -936,6 +940,66 @@ QScriptValue QDeclarativeEnginePrivate::vector(QScriptContext *ctxt, QScriptEngi
return engine->newVariant(qVariantFromValue(QVector3D(x, y, z)));
}
+QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptEngine*engine)
+{
+ int argCount = ctxt->argumentCount();
+ if(argCount == 0 || argCount > 2)
+ return engine->nullValue();
+
+ QDate date = ctxt->argument(0).toDateTime().date();
+ Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
+ if (argCount == 2) {
+ if (ctxt->argument(1).isString()) {
+ QString format = ctxt->argument(1).toString();
+ return engine->newVariant(qVariantFromValue(date.toString(format)));
+ } else if (ctxt->argument(1).isNumber()) {
+ enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32());
+ } else
+ return engine->nullValue();
+ }
+ return engine->newVariant(qVariantFromValue(date.toString(enumFormat)));
+}
+
+QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptEngine*engine)
+{
+ int argCount = ctxt->argumentCount();
+ if(argCount == 0 || argCount > 2)
+ return engine->nullValue();
+
+ QTime date = ctxt->argument(0).toDateTime().time();
+ Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
+ if (argCount == 2) {
+ if (ctxt->argument(1).isString()) {
+ QString format = ctxt->argument(1).toString();
+ return engine->newVariant(qVariantFromValue(date.toString(format)));
+ } else if (ctxt->argument(1).isNumber()) {
+ enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32());
+ } else
+ return engine->nullValue();
+ }
+ return engine->newVariant(qVariantFromValue(date.toString(enumFormat)));
+}
+
+QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScriptEngine*engine)
+{
+ int argCount = ctxt->argumentCount();
+ if(argCount == 0 || argCount > 2)
+ return engine->nullValue();
+
+ QDateTime date = ctxt->argument(0).toDateTime();
+ Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
+ if (argCount == 2) {
+ if (ctxt->argument(1).isString()) {
+ QString format = ctxt->argument(1).toString();
+ return engine->newVariant(qVariantFromValue(date.toString(format)));
+ } else if (ctxt->argument(1).isNumber()) {
+ enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32());
+ } else
+ return engine->nullValue();
+ }
+ return engine->newVariant(qVariantFromValue(date.toString(enumFormat)));
+}
+
QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine *engine)
{
int argCount = ctxt->argumentCount();
@@ -1040,30 +1104,6 @@ QScriptValue QDeclarativeEnginePrivate::darker(QScriptContext *ctxt, QScriptEngi
return qScriptValueFromValue(engine, qVariantFromValue(color));
}
-QScriptValue QDeclarativeEnginePrivate::playSound(QScriptContext *ctxt, QScriptEngine *engine)
-{
- if (ctxt->argumentCount() != 1)
- return engine->undefinedValue();
-
- QUrl url(ctxt->argument(0).toString());
-
- QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine);
- if (url.isRelative()) {
- QDeclarativeContext *context = enginePriv->getContext(ctxt);
- if (!context)
- return engine->undefinedValue();
-
- url = context->resolvedUrl(url);
- }
-
- if (url.scheme() == QLatin1String("file")) {
-
- QSound::play(url.toLocalFile());
-
- }
- return engine->undefinedValue();
-}
-
QScriptValue QDeclarativeEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QScriptEngine *e)
{
if(ctxt->argumentCount() < 1)
@@ -1383,7 +1423,11 @@ public:
paths += QFileInfo(base.toLocalFile()).path();
paths += importPath;
paths += QDeclarativeEnginePrivate::get(engine)->environmentImportPath;
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
QString builtinPath = QLibraryInfo::location(QLibraryInfo::ImportsPath);
+#else
+ QString builtinPath;
+#endif
if (!builtinPath.isEmpty())
paths += builtinPath;
@@ -1687,6 +1731,7 @@ QString QDeclarativeEngine::offlineStoragePath() const
\internal
Returns the result of the merge of \a baseName with \a dir, \a suffixes, and \a prefix.
+ The \a prefix must contain the dot.
*/
QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString &baseName,
const QStringList &suffixes,
@@ -1696,7 +1741,6 @@ QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString
QString pluginFileName = prefix;
pluginFileName += baseName;
- pluginFileName += QLatin1Char('.');
pluginFileName += suffix;
QFileInfo fileInfo(dir, pluginFileName);
@@ -1728,14 +1772,26 @@ QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString
QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString &baseName)
{
#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
- return resolvePlugin(dir, baseName, QStringList(QLatin1String("dll")));
+ return resolvePlugin(dir, baseName,
+ QStringList()
+# ifdef QT_DEBUG
+ << QLatin1String("d.dll") // try a qmake-style debug build first
+# endif
+ << QLatin1String(".dll"));
#elif defined(Q_OS_SYMBIAN)
- return resolvePlugin(dir, baseName, QStringList() << QLatin1String("dll") << QLatin1String("qtplugin"));
+ return resolvePlugin(dir, baseName,
+ QStringList()
+ << QLatin1String(".dll")
+ << QLatin1String(".qtplugin"));
#else
# if defined(Q_OS_DARWIN)
- return resolvePlugin(dir, baseName, QStringList() << QLatin1String("dylib") << QLatin1String("so") << QLatin1String("bundle"),
+ return resolvePlugin(dir, baseName,
+ QStringList()
+ << QLatin1String(".dylib")
+ << QLatin1String(".so")
+ << QLatin1String(".bundle"),
QLatin1String("lib"));
# else // Generic Unix
QStringList validSuffixList;
@@ -1746,14 +1802,14 @@ QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString
"In PA-RISC (PA-32 and PA-64) shared libraries are suffixed with .sl. In IPF (32-bit and 64-bit),
the shared libraries are suffixed with .so. For compatibility, the IPF linker also supports the .sl suffix."
*/
- validSuffixList << QLatin1String("sl");
+ validSuffixList << QLatin1String(".sl");
# if defined __ia64
- validSuffixList << QLatin1String("so");
+ validSuffixList << QLatin1String(".so");
# endif
# elif defined(Q_OS_AIX)
- validSuffixList << QLatin1String("a") << QLatin1String("so");
+ validSuffixList << QLatin1String(".a") << QLatin1String(".so");
# elif defined(Q_OS_UNIX)
- validSuffixList << QLatin1String("so");
+ validSuffixList << QLatin1String(".so");
# endif
// Examples of valid library names:
diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h
index 0359f98..459a325 100644
--- a/src/declarative/qml/qdeclarativeengine_p.h
+++ b/src/declarative/qml/qdeclarativeengine_p.h
@@ -238,7 +238,8 @@ public:
QHash<const QMetaObject *, QDeclarativePropertyCache *> propertyCache;
QDeclarativePropertyCache *cache(QObject *obj) {
Q_Q(QDeclarativeEngine);
- if (!obj || QObjectPrivate::get(obj)->metaObject) return 0;
+ if (!obj || QObjectPrivate::get(obj)->metaObject ||
+ QObjectPrivate::get(obj)->wasDeleted) return 0;
const QMetaObject *mo = obj->metaObject();
QDeclarativePropertyCache *rv = propertyCache.value(mo);
if (!rv) {
@@ -318,7 +319,6 @@ public:
static QScriptValue tint(QScriptContext*, QScriptEngine*);
static QScriptValue closestAngle(QScriptContext*, QScriptEngine*);
- static QScriptValue playSound(QScriptContext*, QScriptEngine*);
static QScriptValue desktopOpenUrl(QScriptContext*, QScriptEngine*);
static QScriptValue md5(QScriptContext*, QScriptEngine*);
static QScriptValue btoa(QScriptContext*, QScriptEngine*);
@@ -326,6 +326,10 @@ public:
static QScriptValue consoleLog(QScriptContext*, QScriptEngine*);
static QScriptValue quit(QScriptContext*, QScriptEngine*);
+ static QScriptValue formatDate(QScriptContext*, QScriptEngine*);
+ static QScriptValue formatTime(QScriptContext*, QScriptEngine*);
+ static QScriptValue formatDateTime(QScriptContext*, QScriptEngine*);
+
static QScriptEngine *getScriptEngine(QDeclarativeEngine *e) { return &e->d_func()->scriptEngine; }
static QDeclarativeEngine *getEngine(QScriptEngine *e) { return static_cast<QDeclarativeScriptEngine*>(e)->p->q_func(); }
static QDeclarativeEnginePrivate *get(QDeclarativeEngine *e) { return e->d_func(); }
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp
index 09882cb..3e4acbe 100644
--- a/src/declarative/qml/qdeclarativeenginedebug.cpp
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -117,7 +117,7 @@ QDeclarativeEngineDebugServer::propertyData(QObject *obj, int propIdx)
QVariant value = prop.read(obj);
rv.value = valueContents(value);
- if (QVariant::Type(prop.userType()) < QVariant::UserType) {
+ if (QDeclarativeValueTypeFactory::isValueType(prop.userType())) {
rv.type = QDeclarativeObjectProperty::Basic;
} else if (QDeclarativeMetaType::isQObject(prop.userType())) {
rv.type = QDeclarativeObjectProperty::Object;
@@ -131,7 +131,7 @@ QDeclarativeEngineDebugServer::propertyData(QObject *obj, int propIdx)
QVariant QDeclarativeEngineDebugServer::valueContents(const QVariant &value) const
{
int userType = value.userType();
- if (QVariant::Type(userType) < QVariant::UserType)
+ if (QDeclarativeValueTypeFactory::isValueType(userType))
return value;
/*
diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp
index ae1e790..e528e9e 100644
--- a/src/declarative/qml/qdeclarativeexpression.cpp
+++ b/src/declarative/qml/qdeclarativeexpression.cpp
@@ -46,6 +46,7 @@
#include "qdeclarativecontext_p.h"
#include "qdeclarativerewrite_p.h"
#include "qdeclarativecompiler_p.h"
+#include "qdeclarativeglobalscriptclass_p.h"
#include <QtCore/qdebug.h>
#include <QtScript/qscriptprogram.h>
@@ -135,6 +136,7 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContext *ctxt, void *expr,
if (!dd->cachedClosures.at(progIdx)) {
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
scriptContext->pushScope(ep->contextClass->newSharedContext());
+ scriptContext->pushScope(ep->globalClass->globalObject());
dd->cachedClosures[progIdx] = new QScriptValue(scriptEngine->evaluate(data->expression, data->url, data->line));
scriptEngine->popContext();
}
@@ -151,9 +153,11 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContext *ctxt, void *expr,
new QScriptProgram(data->expression, data->url, data->line);
}
- data->expressionFunction = evalInObjectScope(ctxt, me, *dd->cachedPrograms.at(progIdx));
+ data->expressionFunction = evalInObjectScope(ctxt, me, *dd->cachedPrograms.at(progIdx),
+ &data->expressionContext);
#else
- data->expressionFunction = evalInObjectScope(ctxt, me, data->expression);
+ data->expressionFunction = evalInObjectScope(ctxt, me, data->expression,
+ &data->expressionContext);
#endif
data->expressionFunctionValid = true;
@@ -164,22 +168,34 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContext *ctxt, void *expr,
}
QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContext *context, QObject *object,
- const QString &program)
+ const QString &program, QScriptValue *contextObject)
{
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine());
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(&ep->scriptEngine);
- scriptContext->pushScope(ep->contextClass->newContext(context, object));
+ if (contextObject) {
+ *contextObject = ep->contextClass->newContext(context, object);
+ scriptContext->pushScope(*contextObject);
+ } else {
+ scriptContext->pushScope(ep->contextClass->newContext(context, object));
+ }
+ scriptContext->pushScope(ep->globalClass->globalObject());
QScriptValue rv = ep->scriptEngine.evaluate(program);
ep->scriptEngine.popContext();
return rv;
}
QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContext *context, QObject *object,
- const QScriptProgram &program)
+ const QScriptProgram &program, QScriptValue *contextObject)
{
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine());
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(&ep->scriptEngine);
- scriptContext->pushScope(ep->contextClass->newContext(context, object));
+ if (contextObject) {
+ *contextObject = ep->contextClass->newContext(context, object);
+ scriptContext->pushScope(*contextObject);
+ } else {
+ scriptContext->pushScope(ep->contextClass->newContext(context, object));
+ }
+ scriptContext->pushScope(ep->globalClass->globalObject());
QScriptValue rv = ep->scriptEngine.evaluate(program);
ep->scriptEngine.popContext();
return rv;
@@ -326,15 +342,14 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo
QDeclarativeEngine *engine = data->context()->engine();
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
- if (secondaryScope)
- ctxtPriv->defaultObjects.append(secondaryScope);
-
QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
if (!data->expressionFunctionValid) {
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
- scriptContext->pushScope(ep->contextClass->newContext(data->context(), data->me));
+ data->expressionContext = ep->contextClass->newContext(data->context(), data->me);
+ scriptContext->pushScope(data->expressionContext);
+ scriptContext->pushScope(ep->globalClass->globalObject());
if (data->expressionRewritten) {
data->expressionFunction = scriptEngine->evaluate(data->expression,
@@ -357,11 +372,14 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo
QDeclarativeContext *oldSharedContext = 0;
QObject *oldSharedScope = 0;
+ QObject *oldOverride = 0;
if (data->isShared) {
oldSharedContext = ep->sharedContext;
oldSharedScope = ep->sharedScope;
ep->sharedContext = data->context();
ep->sharedScope = data->me;
+ } else {
+ oldOverride = ep->contextClass->setOverrideObject(data->expressionContext, secondaryScope);
}
QScriptValue svalue = data->expressionFunction.call();
@@ -369,6 +387,8 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo
if (data->isShared) {
ep->sharedContext = oldSharedContext;
ep->sharedScope = oldSharedScope;
+ } else {
+ ep->contextClass->setOverrideObject(data->expressionContext, oldOverride);
}
if (isUndefined)
@@ -383,12 +403,6 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo
data->error = QDeclarativeError();
}
- if (secondaryScope) {
- QObject *last = ctxtPriv->defaultObjects.takeLast();
- Q_ASSERT(last == secondaryScope);
- Q_UNUSED(last);
- }
-
QVariant rv;
if (svalue.isArray()) {
diff --git a/src/declarative/qml/qdeclarativeexpression_p.h b/src/declarative/qml/qdeclarativeexpression_p.h
index 91ac4c0..cd1729d 100644
--- a/src/declarative/qml/qdeclarativeexpression_p.h
+++ b/src/declarative/qml/qdeclarativeexpression_p.h
@@ -119,6 +119,7 @@ public:
bool expressionFunctionValid:1;
bool expressionRewritten:1;
QScriptValue expressionFunction;
+ QScriptValue expressionContext;
QObject *me;
bool trackChange;
@@ -180,8 +181,8 @@ public:
virtual void emitValueChanged();
static void exceptionToError(QScriptEngine *, QDeclarativeError &);
- static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QString &);
- static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QScriptProgram &);
+ static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QString &, QScriptValue * = 0);
+ static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QScriptProgram &, QScriptValue * = 0);
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
index 5b06b42..9ee2fe5 100644
--- a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
@@ -53,15 +53,17 @@ QT_BEGIN_NAMESPACE
QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass(QScriptEngine *engine)
: QScriptClass(engine)
{
- QScriptValue v = engine->newObject();
- globalObject = engine->globalObject();
+ QScriptValue globalObject = engine->globalObject();
+ m_globalObject = engine->newObject();
QScriptValueIterator iter(globalObject);
while (iter.hasNext()) {
iter.next();
- v.setProperty(iter.scriptName(), iter.value());
+ m_globalObject.setProperty(iter.scriptName(), iter.value());
+ m_illegalNames.insert(iter.name());
}
+ QScriptValue v = engine->newObject();
v.setScriptClass(this);
engine->setGlobalObject(v);
}
@@ -101,12 +103,14 @@ void QDeclarativeGlobalScriptClass::setProperty(QScriptValue &object,
engine()->currentContext()->throwError(error);
}
+/* This method is for the use of tst_qdeclarativeecmascript::callQtInvokables() only */
void QDeclarativeGlobalScriptClass::explicitSetProperty(const QString &name, const QScriptValue &value)
{
+ QScriptValue globalObject = engine()->globalObject();
+
QScriptValue v = engine()->newObject();
- globalObject = engine()->globalObject();
- QScriptValueIterator iter(globalObject);
+ QScriptValueIterator iter(v);
while (iter.hasNext()) {
iter.next();
v.setProperty(iter.scriptName(), iter.value());
@@ -114,6 +118,7 @@ void QDeclarativeGlobalScriptClass::explicitSetProperty(const QString &name, con
v.setProperty(name, value);
v.setScriptClass(this);
+
engine()->setGlobalObject(v);
}
diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
index a33cf5e..1b34aee 100644
--- a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
+++ b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
@@ -54,6 +54,7 @@
//
#include <QtScript/qscriptclass.h>
+#include <QtCore/qset.h>
QT_BEGIN_NAMESPACE
@@ -74,8 +75,12 @@ public:
void explicitSetProperty(const QString &, const QScriptValue &);
+ const QScriptValue &globalObject() const { return m_globalObject; }
+ const QSet<QString> &illegalNames() const { return m_illegalNames; }
+
private:
- QScriptValue globalObject;
+ QSet<QString> m_illegalNames;
+ QScriptValue m_globalObject;
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeinstruction_p.h b/src/declarative/qml/qdeclarativeinstruction_p.h
index d8af6a7..c41b14f 100644
--- a/src/declarative/qml/qdeclarativeinstruction_p.h
+++ b/src/declarative/qml/qdeclarativeinstruction_p.h
@@ -293,6 +293,7 @@ public:
struct {
int signalIndex;
int value;
+ int context;
} storeSignal;
struct {
int signal;
diff --git a/src/declarative/qml/qdeclarativelist.h b/src/declarative/qml/qdeclarativelist.h
index 8d59384..eac4967 100644
--- a/src/declarative/qml/qdeclarativelist.h
+++ b/src/declarative/qml/qdeclarativelist.h
@@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QObject;
-class QMetaObject;
+struct QMetaObject;
template<typename T>
struct QDeclarativeListProperty {
typedef void (*AppendFunction)(QDeclarativeListProperty<T> *, T*);
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
index 542f417..2e4ffa7 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
@@ -232,7 +232,7 @@ QDeclarativeObjectScriptClass::property(QObject *obj, const Identifier &name)
QDeclarativeEnginePrivate::CapturedProperty(obj, lastData->coreIndex, lastData->notifyIndex);
}
- if ((uint)lastData->propType < QVariant::UserType) {
+ if (QDeclarativeValueTypeFactory::isValueType((uint)lastData->propType)) {
QDeclarativeValueType *valueType = enginePriv->valueTypes[lastData->propType];
if (valueType)
return Value(scriptEngine, enginePriv->valueTypeClass->newObject(obj, lastData->coreIndex, valueType));
diff --git a/src/declarative/qml/qdeclarativeparser.cpp b/src/declarative/qml/qdeclarativeparser.cpp
index 5ac49d5..b0599ad 100644
--- a/src/declarative/qml/qdeclarativeparser.cpp
+++ b/src/declarative/qml/qdeclarativeparser.cpp
@@ -221,12 +221,14 @@ QDeclarativeParser::Property::~Property()
{
foreach(Value *value, values)
value->release();
+ foreach(Value *value, onValues)
+ value->release();
if (value) value->release();
}
-Object *QDeclarativeParser::Property::getValue()
+Object *QDeclarativeParser::Property::getValue(const LocationSpan &l)
{
- if (!value) value = new Object;
+ if (!value) { value = new Object; value->location = l; }
return value;
}
@@ -235,9 +237,14 @@ void QDeclarativeParser::Property::addValue(Value *v)
values << v;
}
+void QDeclarativeParser::Property::addOnValue(Value *v)
+{
+ onValues << v;
+}
+
bool QDeclarativeParser::Property::isEmpty() const
{
- return !value && values.isEmpty();
+ return !value && values.isEmpty() && onValues.isEmpty();
}
QDeclarativeParser::Value::Value()
diff --git a/src/declarative/qml/qdeclarativeparser_p.h b/src/declarative/qml/qdeclarativeparser_p.h
index aae507e..5bf4b68 100644
--- a/src/declarative/qml/qdeclarativeparser_p.h
+++ b/src/declarative/qml/qdeclarativeparser_p.h
@@ -104,6 +104,11 @@ namespace QDeclarativeParser
Location start;
Location end;
LocationRange range;
+
+ bool operator<(LocationSpan &o) const {
+ return (start.line < o.start.line) ||
+ (start.line == o.start.line && start.column < o.start.column);
+ }
};
class Property;
@@ -318,8 +323,9 @@ namespace QDeclarativeParser
// The Object to which this property is attached
Object *parent;
- Object *getValue();
+ Object *getValue(const LocationSpan &);
void addValue(Value *v);
+ void addOnValue(Value *v);
// The QVariant::Type of the property, or 0 (QVariant::Invalid) if
// unknown.
@@ -333,6 +339,8 @@ namespace QDeclarativeParser
// The list of values assigned to this property. Content in values
// and value are mutually exclusive
QList<Value *> values;
+ // The list of values assigned to this property using the "on" syntax
+ QList<Value *> onValues;
// The accessed property. This is used to represent dot properties.
// Content in value and values are mutually exclusive.
Object *value;
diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp
index e1ec2cd..4f73b89 100644
--- a/src/declarative/qml/qdeclarativeproperty.cpp
+++ b/src/declarative/qml/qdeclarativeproperty.cpp
@@ -238,10 +238,10 @@ void QDeclarativePropertyPrivate::initProperty(QObject *obj, const QString &name
if (property->flags & QDeclarativePropertyCache::Data::IsFunction)
return; // Not an object property
- if (ii == (path.count() - 2) && property->propType < (int)QVariant::UserType) {
+ if (ii == (path.count() - 2) && QDeclarativeValueTypeFactory::isValueType(property->propType)) {
// We're now at a value type property. We can use a global valuetypes array as we
// never actually use the objects, just look up their properties.
- QObject *typeObject = qmlValueTypes()->valueTypes[property->propType];
+ QObject *typeObject = (*qmlValueTypes())[property->propType];
if (!typeObject) return; // Not a value type
int idx = typeObject->metaObject()->indexOfProperty(path.last().toUtf8().constData());
@@ -346,7 +346,7 @@ QDeclarativePropertyPrivate::propertyTypeCategory() const
int type = propertyType();
if (type == QVariant::Invalid)
return QDeclarativeProperty::InvalidCategory;
- else if ((uint)type < QVariant::UserType)
+ else if (QDeclarativeValueTypeFactory::isValueType((uint)type))
return QDeclarativeProperty::Normal;
else if (core.flags & QDeclarativePropertyCache::Data::IsQObjectDerived)
return QDeclarativeProperty::Object;
@@ -793,7 +793,7 @@ QVariant QDeclarativeProperty::read(QObject *object, const QString &name, QDecla
QVariant QDeclarativePropertyPrivate::readValueProperty()
{
- if(isValueType()) {
+ if (isValueType()) {
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context);
QDeclarativeValueType *valueType = 0;
@@ -809,13 +809,20 @@ QVariant QDeclarativePropertyPrivate::readValueProperty()
if (!ep) delete valueType;
return rv;
- } else if(core.flags & QDeclarativePropertyCache::Data::IsQList) {
+ } else if (core.flags & QDeclarativePropertyCache::Data::IsQList) {
QDeclarativeListProperty<QObject> prop;
void *args[] = { &prop, 0 };
QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args);
return QVariant::fromValue(QDeclarativeListReferencePrivate::init(prop, core.propType, engine));
+ } else if (core.flags & QDeclarativePropertyCache::Data::IsQObjectDerived) {
+
+ QObject *rv = 0;
+ void *args[] = { &rv, 0 };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args);
+ return QVariant::fromValue(rv);
+
} else {
return object->metaObject()->property(core.coreIndex).read(object.data());
diff --git a/src/declarative/qml/qdeclarativeproperty_p.h b/src/declarative/qml/qdeclarativeproperty_p.h
index 1fda7f4..c31e2d3 100644
--- a/src/declarative/qml/qdeclarativeproperty_p.h
+++ b/src/declarative/qml/qdeclarativeproperty_p.h
@@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE
class QDeclarativeContext;
class QDeclarativeEnginePrivate;
class QDeclarativeExpression;
-class Q_AUTOTEST_EXPORT QDeclarativePropertyPrivate
+class Q_DECLARATIVE_EXPORT QDeclarativePropertyPrivate
{
public:
enum WriteFlag { BypassInterceptor = 0x01, DontRemoveBinding = 0x02 };
diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp
index 08b47b7..fea59e5 100644
--- a/src/declarative/qml/qdeclarativepropertycache.cpp
+++ b/src/declarative/qml/qdeclarativepropertycache.cpp
@@ -155,9 +155,9 @@ QDeclarativePropertyCache::Data QDeclarativePropertyCache::create(const QMetaObj
int parenIdx = methodName.indexOf(QLatin1Char('('));
Q_ASSERT(parenIdx != -1);
- methodName = methodName.left(parenIdx);
+ QStringRef methodNameRef = methodName.leftRef(parenIdx);
- if (methodName == property) {
+ if (methodNameRef == property) {
rv.load(m);
return rv;
}
diff --git a/src/declarative/qml/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescriptparser.cpp
index f4c9cdd..fe516c5 100644
--- a/src/declarative/qml/qdeclarativescriptparser.cpp
+++ b/src/declarative/qml/qdeclarativescriptparser.cpp
@@ -85,8 +85,8 @@ class ProcessAST: protected AST::Visitor
{
const State &state = top();
if (state.property) {
- State s(state.property->getValue(),
- state.property->getValue()->getProperty(name.toUtf8()));
+ State s(state.property->getValue(location),
+ state.property->getValue(location)->getProperty(name.toUtf8()));
s.property->location = location;
push(s);
} else {
@@ -106,12 +106,12 @@ public:
void operator()(const QString &code, AST::Node *node);
protected:
- Object *defineObjectBinding(AST::UiQualifiedId *propertyName,
+ Object *defineObjectBinding(AST::UiQualifiedId *propertyName, bool onAssignment,
AST::UiQualifiedId *objectTypeName,
LocationSpan location,
AST::UiObjectInitializer *initializer = 0);
- Object *defineObjectBinding_helper(AST::UiQualifiedId *propertyName,
+ Object *defineObjectBinding_helper(AST::UiQualifiedId *propertyName, bool onAssignment,
const QString &objectType,
AST::SourceLocation typeLocation,
LocationSpan location,
@@ -243,6 +243,7 @@ QString ProcessAST::asString(AST::UiQualifiedId *node) const
Object *
ProcessAST::defineObjectBinding_helper(AST::UiQualifiedId *propertyName,
+ bool onAssignment,
const QString &objectType,
AST::SourceLocation typeLocation,
LocationSpan location,
@@ -254,10 +255,19 @@ ProcessAST::defineObjectBinding_helper(AST::UiQualifiedId *propertyName,
(lastTypeDot >= 0 && objectType.at(lastTypeDot+1).isUpper()));
int propertyCount = 0;
- for (; propertyName; propertyName = propertyName->next){
+ for (AST::UiQualifiedId *name = propertyName; name; name = name->next){
++propertyCount;
- _stateStack.pushProperty(propertyName->name->asString(),
- this->location(propertyName));
+ _stateStack.pushProperty(name->name->asString(),
+ this->location(name));
+ }
+
+ if (!onAssignment && propertyCount && currentProperty() && currentProperty()->values.count()) {
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","Property value set multiple times"));
+ error.setLine(this->location(propertyName).start.line);
+ error.setColumn(this->location(propertyName).start.column);
+ _parser->_errors << error;
+ return 0;
}
if (!isType) {
@@ -327,7 +337,10 @@ ProcessAST::defineObjectBinding_helper(AST::UiQualifiedId *propertyName,
Value *v = new Value;
v->object = obj;
v->location = obj->location;
- prop->addValue(v);
+ if (onAssignment)
+ prop->addOnValue(v);
+ else
+ prop->addValue(v);
while (propertyCount--)
_stateStack.pop();
@@ -363,7 +376,7 @@ ProcessAST::defineObjectBinding_helper(AST::UiQualifiedId *propertyName,
}
}
-Object *ProcessAST::defineObjectBinding(AST::UiQualifiedId *qualifiedId,
+Object *ProcessAST::defineObjectBinding(AST::UiQualifiedId *qualifiedId, bool onAssignment,
AST::UiQualifiedId *objectTypeName,
LocationSpan location,
AST::UiObjectInitializer *initializer)
@@ -395,7 +408,7 @@ Object *ProcessAST::defineObjectBinding(AST::UiQualifiedId *qualifiedId,
}
- return defineObjectBinding_helper(qualifiedId, objectType, typeLocation, location, initializer);
+ return defineObjectBinding_helper(qualifiedId, onAssignment, objectType, typeLocation, location, initializer);
}
LocationSpan ProcessAST::location(AST::UiQualifiedId *id)
@@ -623,7 +636,7 @@ bool ProcessAST::visit(AST::UiObjectDefinition *node)
LocationSpan l = location(node->firstSourceLocation(),
node->lastSourceLocation());
- defineObjectBinding(/*propertyName = */ 0,
+ defineObjectBinding(/*propertyName = */ 0, false,
node->qualifiedTypeNameId,
l,
node->initializer);
@@ -638,7 +651,7 @@ bool ProcessAST::visit(AST::UiObjectBinding *node)
LocationSpan l = location(node->qualifiedTypeNameId->identifierToken,
node->initializer->rbraceToken);
- defineObjectBinding(node->qualifiedId,
+ defineObjectBinding(node->qualifiedId, node->hasOnToken,
node->qualifiedTypeNameId,
l,
node->initializer);
@@ -674,14 +687,23 @@ bool ProcessAST::visit(AST::UiScriptBinding *node)
{
int propertyCount = 0;
AST::UiQualifiedId *propertyName = node->qualifiedId;
- for (; propertyName; propertyName = propertyName->next){
+ for (AST::UiQualifiedId *name = propertyName; name; name = name->next){
++propertyCount;
- _stateStack.pushProperty(propertyName->name->asString(),
- location(propertyName));
+ _stateStack.pushProperty(name->name->asString(),
+ location(name));
}
Property *prop = currentProperty();
+ if (prop->values.count()) {
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","Property value set multiple times"));
+ error.setLine(this->location(propertyName).start.line);
+ error.setColumn(this->location(propertyName).start.column);
+ _parser->_errors << error;
+ return 0;
+ }
+
QDeclarativeParser::Variant primitive;
if (AST::ExpressionStatement *stmt = AST::cast<AST::ExpressionStatement *>(node->statement)) {
@@ -724,16 +746,26 @@ bool ProcessAST::visit(AST::UiArrayBinding *node)
{
int propertyCount = 0;
AST::UiQualifiedId *propertyName = node->qualifiedId;
- for (; propertyName; propertyName = propertyName->next){
+ for (AST::UiQualifiedId *name = propertyName; name; name = name->next){
++propertyCount;
- _stateStack.pushProperty(propertyName->name->asString(),
- location(propertyName));
+ _stateStack.pushProperty(name->name->asString(),
+ location(name));
+ }
+
+ Property* prop = currentProperty();
+
+ if (prop->values.count()) {
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","Property value set multiple times"));
+ error.setLine(this->location(propertyName).start.line);
+ error.setColumn(this->location(propertyName).start.column);
+ _parser->_errors << error;
+ return 0;
}
accept(node->members);
// For the DOM, store the position of the T_LBRACKET upto the T_RBRACKET as the range:
- Property* prop = currentProperty();
prop->listValueRange.offset = node->lbracketToken.offset;
prop->listValueRange.length = node->rbracketToken.offset + node->rbracketToken.length - node->lbracketToken.offset;
diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp
index 01fa214..34d3795 100644
--- a/src/declarative/qml/qdeclarativevaluetype.cpp
+++ b/src/declarative/qml/qdeclarativevaluetype.cpp
@@ -45,19 +45,50 @@
QT_BEGIN_NAMESPACE
+#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
+Q_DECLARE_METATYPE(QEasingCurve);
+#endif
+
QDeclarativeValueTypeFactory::QDeclarativeValueTypeFactory()
{
// ### Optimize
for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii)
valueTypes[ii] = valueType(ii);
+#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
+ easingType = qMetaTypeId<QEasingCurve>();
+ easingValueType = valueType(easingType);
+#endif
}
QDeclarativeValueTypeFactory::~QDeclarativeValueTypeFactory()
{
for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii)
delete valueTypes[ii];
+#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
+ delete easingValueType;
+#endif
+}
+
+bool QDeclarativeValueTypeFactory::isValueType(int idx)
+{
+ if ((uint)idx < QVariant::UserType)
+ return true;
+#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
+ if (idx == qMetaTypeId<QEasingCurve>())
+ return true;
+#endif
+ return false;
}
+QDeclarativeValueType *QDeclarativeValueTypeFactory::operator[](int idx) const
+{
+#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
+ if (idx == easingType) return easingValueType;
+#endif
+ return valueTypes[idx];
+}
+
+
QDeclarativeValueType *QDeclarativeValueTypeFactory::valueType(int t)
{
switch (t) {
@@ -75,11 +106,17 @@ QDeclarativeValueType *QDeclarativeValueTypeFactory::valueType(int t)
return new QDeclarativeRectFValueType;
case QVariant::Vector3D:
return new QDeclarativeVector3DValueType;
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
case QVariant::EasingCurve:
return new QDeclarativeEasingValueType;
+#endif
case QVariant::Font:
return new QDeclarativeFontValueType;
default:
+#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
+ if (t == qMetaTypeId<QEasingCurve>())
+ return new QDeclarativeEasingValueType;
+#endif
return 0;
}
}
@@ -495,7 +532,11 @@ void QDeclarativeEasingValueType::write(QObject *obj, int idx, QDeclarativePrope
QVariant QDeclarativeEasingValueType::value()
{
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
return QVariant(easing);
+#else
+ return QVariant::fromValue<QEasingCurve>(easing);
+#endif
}
void QDeclarativeEasingValueType::setValue(QVariant value)
diff --git a/src/declarative/qml/qdeclarativevaluetype_p.h b/src/declarative/qml/qdeclarativevaluetype_p.h
index cb153be..e69f161 100644
--- a/src/declarative/qml/qdeclarativevaluetype_p.h
+++ b/src/declarative/qml/qdeclarativevaluetype_p.h
@@ -81,10 +81,17 @@ class Q_DECLARATIVE_EXPORT QDeclarativeValueTypeFactory
public:
QDeclarativeValueTypeFactory();
~QDeclarativeValueTypeFactory();
+ static bool isValueType(int);
static QDeclarativeValueType *valueType(int);
+ QDeclarativeValueType *operator[](int idx) const;
+
+private:
QDeclarativeValueType *valueTypes[QVariant::UserType - 1];
- QDeclarativeValueType *operator[](int idx) const { return valueTypes[idx]; }
+#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
+ int easingType;
+ QDeclarativeValueType *easingValueType;
+#endif
};
class Q_AUTOTEST_EXPORT QDeclarativePointFValueType : public QDeclarativeValueType
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index fc3722d..6a08674 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -538,13 +538,13 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack, QDeclarati
case QDeclarativeInstruction::StoreSignal:
{
QObject *target = stack.top();
- // XXX scope
- QMetaMethod signal =
- target->metaObject()->method(instr.storeSignal.signalIndex);
+ QObject *context = stack.at(stack.count() - 1 - instr.assignBinding.context);
+
+ QMetaMethod signal = target->metaObject()->method(instr.storeSignal.signalIndex);
QDeclarativeBoundSignal *bs = new QDeclarativeBoundSignal(target, signal, target);
QDeclarativeExpression *expr =
- new QDeclarativeExpression(ctxt, primitives.at(instr.storeSignal.value), target);
+ new QDeclarativeExpression(ctxt, primitives.at(instr.storeSignal.value), context);
expr->setSourceLocation(comp->name, instr.line);
bs->setExpression(expr);
}
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index 03151e4..784353a 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -365,6 +365,8 @@ void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
workerEngine->evaluate(script);
workerEngine->popContext();
+ } else {
+ qWarning().nospace() << "WorkerScript: Cannot find source file " << url.toString();
}
}
@@ -382,7 +384,7 @@ QVariant QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(const QScri
quint32 length = (quint32)value.property(QLatin1String("length")).toNumber();
for (quint32 ii = 0; ii < length; ++ii) {
- QVariant v = scriptValueToVariant(ii);
+ QVariant v = scriptValueToVariant(value.property(ii));
list << v;
}
@@ -561,6 +563,65 @@ void QDeclarativeWorkerScriptEngine::run()
delete d->workerEngine; d->workerEngine = 0;
}
+
+/*!
+ \qmlclass WorkerScript QDeclarativeWorkerScript
+ \brief The WorkerScript element enables the use of threads in QML.
+
+ Use WorkerScript to run operations in a new thread.
+ This is useful for running operations in the background so
+ that the main GUI thread is not blocked.
+
+ Messages can be passed between the new thread and the parent thread
+ using sendMessage() and the onMessage() handler.
+
+ Here is an example:
+
+ \qml
+ import Qt 4.6
+
+ Rectangle {
+ width: 300
+ height: 300
+
+ Text {
+ id: myText
+ text: 'Click anywhere'
+ }
+
+ WorkerScript {
+ id: myWorker
+ source: "script.js"
+
+ onMessage: {
+ myText.text = messageObject.reply
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: myWorker.sendMessage( {'x': mouse.x, 'y': mouse.y} );
+ }
+ }
+ \endqml
+
+ The above worker script specifies a javascript file, "script.js", that handles
+ the operations to be performed in the new thread:
+
+ \qml
+ WorkerScript.onMessage = function(message) {
+ // ... long-running operations and calculations are done here
+ WorkerScript.sendMessage( {'reply': 'Mouse is at ' + message.x + ',' + message.y} );
+ }
+ \endqml
+
+ When the user clicks anywhere within the rectangle, \c sendMessage() is
+ called, triggering the \tt WorkerScript.onMessage() handler in
+ \tt source.js. This in turn sends a reply message that is then received
+ by the \tt onMessage() handler of \tt myWorker.
+
+ \sa WorkerListModel
+*/
QDeclarativeWorkerScript::QDeclarativeWorkerScript(QObject *parent)
: QObject(parent), m_engine(0), m_scriptId(-1)
{
@@ -571,6 +632,12 @@ QDeclarativeWorkerScript::~QDeclarativeWorkerScript()
if (m_scriptId != -1) m_engine->removeWorkerScript(m_scriptId);
}
+/*!
+ \qmlproperty url WorkerScript::source
+
+ This holds the url of the javascript file that implements the
+ \tt WorkerScript.onMessage() handler for threaded operations.
+*/
QUrl QDeclarativeWorkerScript::source() const
{
return m_source;
@@ -589,6 +656,13 @@ void QDeclarativeWorkerScript::setSource(const QUrl &source)
emit sourceChanged();
}
+/*
+ \qmlmethod WorkerScript::sendMessage(jsobject message)
+
+ Sends the given \a message to a worker script handler in another
+ thread. The other worker script handler can receive this message
+ through the onMessage() handler.
+*/
void QDeclarativeWorkerScript::sendMessage(const QScriptValue &message)
{
if (!m_engine) {
@@ -616,6 +690,13 @@ void QDeclarativeWorkerScript::componentComplete()
}
}
+/*!
+ \qmlsignal WorkerScript::onMessage(jsobject msg)
+
+ This handler is called when a message \a msg is received from a worker
+ script in another thread through a call to sendMessage().
+*/
+
bool QDeclarativeWorkerScript::event(QEvent *event)
{
if (event->type() == (QEvent::Type)WorkerDataEvent::WorkerData) {
@@ -841,6 +922,41 @@ bool QDeclarativeWorkerListModelAgent::event(QEvent *e)
return QObject::event(e);
}
+/*!
+ \qmlclass WorkerListModel QDeclarativeWorkerListModel
+ \brief The WorkerListModel element provides a threaded list model.
+
+ Use WorkerListModel together with WorkerScript to define a list model
+ that is controlled by a separate thread. This is useful if list modification
+ operations are synchronous and take some time: using WorkerListModel
+ moves these operations to a different thread and avoids blocking of the
+ main GUI thread.
+
+ The thread that creates the WorkerListModel can modify the model for any
+ initial set-up requirements. However, once the model has been modified by
+ the associated WorkerScript, the model can only be modified by that worker
+ script and becomes read-only to all other threads.
+
+ Here is an example application that uses WorkerScript to append the
+ current time to a WorkerListModel:
+
+ \snippet examples/declarative/workerlistmodel/timedisplay.qml 0
+
+ The included file, \tt dataloader.js, looks like this:
+
+ \snippet examples/declarative/workerlistmodel/dataloader.js 0
+
+ The application's \tt Timer object periodically sends a message to the
+ worker script by calling \tt WorkerScript::sendMessage(). When this message
+ is received, \tt WorkerScript.onMessage() is invoked in
+ \tt dataloader.js, which appends the current time to the worker list
+ model.
+
+ Note that unlike ListModel, WorkerListModel does not have \tt move() and
+ \tt setProperty() methods.
+
+ \sa WorkerScript, ListModel
+*/
QDeclarativeWorkerListModel::QDeclarativeWorkerListModel(QObject *parent)
: QListModelInterface(parent), m_agent(0)
{
@@ -854,6 +970,14 @@ QDeclarativeWorkerListModel::~QDeclarativeWorkerListModel()
}
}
+/*!
+ \qmlmethod WorkerListModel::clear()
+
+ Deletes all content from the model. The properties are cleared such that
+ different properties may be set on subsequent additions.
+
+ \sa append() remove()
+*/
void QDeclarativeWorkerListModel::clear()
{
if (m_agent) {
@@ -869,6 +993,13 @@ void QDeclarativeWorkerListModel::clear()
}
}
+/*!
+ \qmlmethod WorkerListModel::remove(int index)
+
+ Deletes the content at \a index from the model.
+
+ \sa clear()
+*/
void QDeclarativeWorkerListModel::remove(int index)
{
if (m_agent) {
@@ -884,6 +1015,18 @@ void QDeclarativeWorkerListModel::remove(int index)
emit countChanged();
}
+/*!
+ \qmlmethod WorkerListModel::append(jsobject dict)
+
+ Adds a new item to the end of the list model, with the
+ values in \a dict.
+
+ \code
+ FruitModel.append({"cost": 5.95, "name":"Pizza"})
+ \endcode
+
+ \sa set() remove()
+*/
void QDeclarativeWorkerListModel::append(const QScriptValue &value)
{
if (m_agent) {
@@ -914,6 +1057,21 @@ void QDeclarativeWorkerListModel::append(const QScriptValue &value)
emit countChanged();
}
+/*!
+ \qmlmethod WorkerListModel::insert(int index, jsobject dict)
+
+ Adds a new item to the list model at position \a index, with the
+ values in \a dict.
+
+ \code
+ FruitModel.insert(2, {"cost": 5.95, "name":"Pizza"})
+ \endcode
+
+ The \a index must be to an existing item in the list, or one past
+ the end of the list (equivalent to append).
+
+ \sa set() append()
+*/
void QDeclarativeWorkerListModel::insert(int index, const QScriptValue &value)
{
if (m_agent) {
@@ -946,6 +1104,30 @@ void QDeclarativeWorkerListModel::insert(int index, const QScriptValue &value)
emit countChanged();
}
+/*!
+ \qmlmethod object ListModel::get(int index)
+
+ Returns the item at \a index in the list model.
+
+ \code
+ FruitModel.append({"cost": 5.95, "name":"Jackfruit"})
+ FruitModel.get(0).cost
+ \endcode
+
+ The \a index must be an element in the list.
+
+ Note that properties of the returned object that are themselves objects
+ will also be models, and this get() method is used to access elements:
+
+ \code
+ FruitModel.append(..., "attributes":
+ [{"name":"spikes","value":"7mm"},
+ {"name":"color","value":"green"}]);
+ FruitModel.get(0).attributes.get(1).value; // == "green"
+ \endcode
+
+ \sa append()
+*/
QScriptValue QDeclarativeWorkerListModel::get(int index) const
{
QDeclarativeEngine *engine = qmlEngine(this);
@@ -962,6 +1144,21 @@ QScriptValue QDeclarativeWorkerListModel::get(int index) const
return rv;
}
+/*!
+ \qmlmethod WorkerListModel::set(int index, jsobject dict)
+
+ Changes the item at \a index in the list model with the
+ values in \a dict. Properties not appearing in \a valuemap
+ are left unchanged.
+
+ \code
+ FruitModel.set(3, {"cost": 5.95, "name":"Pizza"})
+ \endcode
+
+ The \a index must be an element in the list.
+
+ \sa append()
+*/
void QDeclarativeWorkerListModel::set(int index, const QScriptValue &value)
{
if (m_agent) {
@@ -995,6 +1192,22 @@ void QDeclarativeWorkerListModel::set(int index, const QScriptValue &value)
}
}
+/*!
+ \qmlmethod WorkerListModel::sync()
+
+ Writes any unsaved changes to the list model. This must be called after
+ changes have been made to the list model in the worker script.
+
+ Note that this method can only be called from the associated worker script.
+*/
+void QDeclarativeWorkerListModel::sync()
+{
+ // This is really a dummy method to make it look like sync() exists in
+ // WorkerListModel (and not QDeclarativeWorkerListModelAgent) and to let
+ // us document sync().
+ qmlInfo(this) << "sync() can only be called from a WorkerScript";
+}
+
QDeclarativeWorkerListModelAgent *QDeclarativeWorkerListModel::agent()
{
if (!m_agent)
@@ -1013,6 +1226,10 @@ QString QDeclarativeWorkerListModel::toString(int role) const
return m_roles.value(role);
}
+/*!
+ \qmlproperty int ListModel::count
+ The number of data entries in the model.
+*/
int QDeclarativeWorkerListModel::count() const
{
return m_values.count();
@@ -1038,4 +1255,3 @@ QT_END_NAMESPACE
#include "qdeclarativeworkerscript.moc"
-
diff --git a/src/declarative/qml/qdeclarativeworkerscript_p.h b/src/declarative/qml/qdeclarativeworkerscript_p.h
index 8ebd2c1..912eac9 100644
--- a/src/declarative/qml/qdeclarativeworkerscript_p.h
+++ b/src/declarative/qml/qdeclarativeworkerscript_p.h
@@ -61,8 +61,12 @@
#include <QtScript/qscriptvalue.h>
#include <QtCore/qurl.h>
+QT_BEGIN_HEADER
+
QT_BEGIN_NAMESPACE
+QT_MODULE(Declarative)
+
class QDeclarativeWorkerScript;
class QDeclarativeWorkerScriptEnginePrivate;
class QDeclarativeWorkerScriptEngine : public QThread
@@ -84,7 +88,7 @@ private:
QDeclarativeWorkerScriptEnginePrivate *d;
};
-class QDeclarativeWorkerScript : public QObject, public QDeclarativeParserStatus
+class Q_DECLARATIVE_EXPORT QDeclarativeWorkerScript : public QObject, public QDeclarativeParserStatus
{
Q_OBJECT
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
@@ -115,7 +119,7 @@ private:
};
class QDeclarativeWorkerListModelAgent;
-class QDeclarativeWorkerListModel : public QListModelInterface
+class Q_DECLARATIVE_EXPORT QDeclarativeWorkerListModel : public QListModelInterface
{
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY countChanged)
@@ -130,6 +134,7 @@ public:
Q_INVOKABLE void insert(int index, const QScriptValue&);
Q_INVOKABLE QScriptValue get(int index) const;
Q_INVOKABLE void set(int index, const QScriptValue &);
+ Q_INVOKABLE void sync();
QDeclarativeWorkerListModelAgent *agent();
@@ -157,4 +162,6 @@ QT_END_NAMESPACE
QML_DECLARE_TYPE(QDeclarativeWorkerScript);
QML_DECLARE_TYPE(QDeclarativeWorkerListModel);
+QT_END_HEADER
+
#endif // QDECLARATIVEWORKERSCRIPT_P_H
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index 10230d3..76b6a58 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -52,6 +52,7 @@
#include <qdeclarativestringconverters_p.h>
#include <qdeclarativeglobal_p.h>
#include <qdeclarativemetatype_p.h>
+#include <qdeclarativevaluetype_p.h>
#include <qdeclarativeproperty_p.h>
#include <qvariant.h>
@@ -110,7 +111,7 @@ QDeclarativeAbstractAnimation::QDeclarativeAbstractAnimation(QDeclarativeAbstrac
\code
Rectangle {
width: 100; height: 100
- x: NumberAnimation {
+ NumberAnimation on x {
running: myMouse.pressed
from: 0; to: 100
}
@@ -310,7 +311,7 @@ void QDeclarativeAbstractAnimation::setAlwaysRunToEnd(bool f)
\code
Rectangle {
- rotation: NumberAnimation { running: true; repeat: true; from: 0 to: 360 }
+ NumberAnimation on rotation { running: true; repeat: true; from: 0 to: 360 }
}
\endcode
*/
@@ -412,7 +413,7 @@ void QDeclarativeAbstractAnimation::resume()
no further influence on property values. In this example animation
\code
Rectangle {
- x: NumberAnimation { from: 0; to: 100; duration: 500 }
+ NumberAnimation on x { from: 0; to: 100; duration: 500 }
}
\endcode
was stopped at time 250ms, the \c x property will have a value of 50.
@@ -450,7 +451,7 @@ void QDeclarativeAbstractAnimation::restart()
its end. In the following example,
\code
Rectangle {
- x: NumberAnimation { from: 0; to: 100; duration: 500 }
+ NumberAnimation on x { from: 0; to: 100; duration: 500 }
}
\endcode
calling \c stop() at time 250ms will result in the \c x property having
@@ -1292,7 +1293,7 @@ QDeclarativeVector3dAnimation::QDeclarativeVector3dAnimation(QObject *parent)
Q_D(QDeclarativePropertyAnimation);
d->interpolatorType = QMetaType::QVector3D;
d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
- d->defaultToInterpolatorType = true;
+ d->defaultToInterpolatorType = true;
}
QDeclarativeVector3dAnimation::~QDeclarativeVector3dAnimation()
@@ -1573,7 +1574,8 @@ QDeclarativeSequentialAnimation::QDeclarativeSequentialAnimation(QObject *parent
QDeclarativeAnimationGroup(parent)
{
Q_D(QDeclarativeAnimationGroup);
- d->ag = new QSequentialAnimationGroup(this);
+ d->ag = new QSequentialAnimationGroup;
+ QDeclarative_setParent_noEvent(d->ag, this);
}
QDeclarativeSequentialAnimation::~QDeclarativeSequentialAnimation()
@@ -1638,7 +1640,8 @@ QDeclarativeParallelAnimation::QDeclarativeParallelAnimation(QObject *parent) :
QDeclarativeAnimationGroup(parent)
{
Q_D(QDeclarativeAnimationGroup);
- d->ag = new QParallelAnimationGroup(this);
+ d->ag = new QParallelAnimationGroup;
+ QDeclarative_setParent_noEvent(d->ag, this);
}
QDeclarativeParallelAnimation::~QDeclarativeParallelAnimation()
@@ -1708,12 +1711,13 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int
break;
}
default:
- if ((uint)type >= QVariant::UserType) {
+ if (QDeclarativeValueTypeFactory::isValueType((uint)type)) {
+ variant.convert((QVariant::Type)type);
+ } else {
QDeclarativeMetaType::StringConverter converter = QDeclarativeMetaType::customStringConverter(type);
if (converter)
variant = converter(variant.toString());
- } else
- variant.convert((QVariant::Type)type);
+ }
break;
}
}
@@ -1732,14 +1736,14 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int
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" } }
+ Transition { PropertyAnimation { properties: "x,y"; easing.type: "InOutQuad" } }
\endqml
\o In a Behavior
Animate all changes to a rectangle's x property.
\qml
Rectangle {
- x: Behavior { PropertyAnimation {} }
+ Behavior on x { PropertyAnimation {} }
}
\endqml
\o As a property value source
@@ -1747,7 +1751,7 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int
Repeatedly animate the rectangle's x property.
\qml
Rectangle {
- x: SequentialAnimation {
+ SequentialAnimation on x {
repeat: true
PropertyAnimation { to: 50 }
PropertyAnimation { to: 0 }
@@ -1797,7 +1801,7 @@ QDeclarativePropertyAnimation::~QDeclarativePropertyAnimation()
void QDeclarativePropertyAnimationPrivate::init()
{
Q_Q(QDeclarativePropertyAnimation);
- va = new QDeclarativeTimeLineValueAnimator;
+ va = new QDeclarativeBulkValueAnimator;
QDeclarative_setParent_noEvent(va, q);
}
@@ -1873,7 +1877,13 @@ void QDeclarativePropertyAnimation::setTo(const QVariant &t)
\qmlproperty QEasingCurve PropertyAnimation::easing
\brief the easing curve used for the transition.
- Available values are:
+ For the easing you can specify the following parameters: type, amplitude, period and overshoot.
+
+ \qml
+ PropertyAnimation { properties: "y"; easing.type: "InOutElastc"; easing.amplitude: 2.0; easing.period: 1.5 }
+ \endqml
+
+ Available types are:
\table
\row
@@ -2044,6 +2054,15 @@ void QDeclarativePropertyAnimation::setTo(const QVariant &t)
\o \inlineimage qeasingcurve-outinbounce.png
\endtable
+ easing.amplitude is not applicable for all curve types. It is only applicable for bounce and elastic curves (curves of type
+ QEasingCurve::InBounce, QEasingCurve::OutBounce, QEasingCurve::InOutBounce, QEasingCurve::OutInBounce, QEasingCurve::InElastic,
+ QEasingCurve::OutElastic, QEasingCurve::InOutElastic or QEasingCurve::OutInElastic).
+
+ easing.overshoot is not applicable for all curve types. It is only applicable if type is: QEasingCurve::InBack, QEasingCurve::OutBack,
+ QEasingCurve::InOutBack or QEasingCurve::OutInBack.
+
+ easing.period is not applicable for all curve types. It is only applicable if type is: QEasingCurve::InElastic, QEasingCurve::OutElastic,
+ QEasingCurve::InOutElastic or QEasingCurve::OutInElastic.
*/
QEasingCurve QDeclarativePropertyAnimation::easing() const
{
@@ -2138,8 +2157,8 @@ void QDeclarativePropertyAnimation::setProperties(const QString &prop)
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
+ NumberAnimation on x { to: 500; repeat: true } //animate theRect's x property
+ Behavior on y { NumberAnimation {} } //animate theRect's y property
}
\endqml
\row
@@ -2213,7 +2232,7 @@ QAbstractAnimation *QDeclarativePropertyAnimation::qtAnimation()
return d->va;
}
-struct PropertyUpdater : public QDeclarativeTimeLineValue
+struct PropertyUpdater : public QDeclarativeBulkValueUpdater
{
QDeclarativeStateActions actions;
int interpolatorType; //for Number/ColorAnimation
@@ -2223,7 +2242,7 @@ struct PropertyUpdater : public QDeclarativeTimeLineValue
bool fromSourced;
bool fromDefined;
bool *wasDeleted;
- PropertyUpdater() : wasDeleted(0) {}
+ PropertyUpdater() : prevInterpolatorType(0), wasDeleted(0) {}
~PropertyUpdater() { if (wasDeleted) *wasDeleted = true; }
void setValue(qreal v)
{
@@ -2231,7 +2250,6 @@ struct PropertyUpdater : public QDeclarativeTimeLineValue
wasDeleted = &deleted;
if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1
v = 1 - v;
- QDeclarativeTimeLineValue::setValue(v);
for (int ii = 0; ii < actions.count(); ++ii) {
QDeclarativeAction &action = actions[ii];
diff --git a/src/declarative/util/qdeclarativeanimation_p_p.h b/src/declarative/util/qdeclarativeanimation_p_p.h
index e582066..ae82a90 100644
--- a/src/declarative/util/qdeclarativeanimation_p_p.h
+++ b/src/declarative/util/qdeclarativeanimation_p_p.h
@@ -149,14 +149,21 @@ private:
bool running;
};
-//animates QDeclarativeTimeLineValue (assumes start and end values will be reals or compatible)
-class QDeclarativeTimeLineValueAnimator : public QVariantAnimation
+class QDeclarativeBulkValueUpdater
+{
+public:
+ virtual ~QDeclarativeBulkValueUpdater() {}
+ virtual void setValue(qreal value) = 0;
+};
+
+//animates QDeclarativeBulkValueUpdater (assumes start and end values will be reals or compatible)
+class QDeclarativeBulkValueAnimator : public QVariantAnimation
{
Q_OBJECT
public:
- QDeclarativeTimeLineValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), fromSourced(0), policy(KeepWhenStopped) {}
- ~QDeclarativeTimeLineValueAnimator() { if (policy == DeleteWhenStopped) { delete animValue; animValue = 0; } }
- void setAnimValue(QDeclarativeTimeLineValue *value, DeletionPolicy p)
+ QDeclarativeBulkValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), fromSourced(0), policy(KeepWhenStopped) {}
+ ~QDeclarativeBulkValueAnimator() { if (policy == DeleteWhenStopped) { delete animValue; animValue = 0; } }
+ void setAnimValue(QDeclarativeBulkValueUpdater *value, DeletionPolicy p)
{
if (state() == Running)
stop();
@@ -193,7 +200,7 @@ protected:
}
private:
- QDeclarativeTimeLineValue *animValue;
+ QDeclarativeBulkValueUpdater *animValue;
bool *fromSourced;
DeletionPolicy policy;
};
@@ -352,7 +359,7 @@ public:
int interpolatorType;
QVariantAnimation::Interpolator interpolator;
- QDeclarativeTimeLineValueAnimator *va;
+ QDeclarativeBulkValueAnimator *va;
static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress);
static void convertVariant(QVariant &variant, int type);
diff --git a/src/declarative/util/qdeclarativebehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp
index 5352341..dea2c02 100644
--- a/src/declarative/util/qdeclarativebehavior.cpp
+++ b/src/declarative/util/qdeclarativebehavior.cpp
@@ -75,13 +75,13 @@ public:
Behaviors provide one way to specify \l{qdeclarativeanimation.html}{animations} in QML.
- In the example below, the rect will use a bounce easing curve over 200 millisecond for any changes to its y property:
+ In the example below, the rectangle will use a bounce easing curve over 200 millisecond for any changes to its y property:
\code
Rectangle {
width: 20; height: 20
color: "#00ff00"
- y: 200 //initial value
- y: Behavior {
+ y: 200 // initial value
+ Behavior on y {
NumberAnimation {
easing: "easeOutBounce(amplitude:100)"
duration: 200
diff --git a/src/declarative/util/qdeclarativebind.cpp b/src/declarative/util/qdeclarativebind.cpp
index e95a03e..26baa38 100644
--- a/src/declarative/util/qdeclarativebind.cpp
+++ b/src/declarative/util/qdeclarativebind.cpp
@@ -72,7 +72,7 @@ public:
/*!
\qmlclass Binding QDeclarativeBind
- \since 4.7
+ \since 4.7
\brief The Binding element allows arbitrary property bindings to be created.
Sometimes it is necessary to bind to a property of an object that wasn't
@@ -114,6 +114,19 @@ QDeclarativeBind::~QDeclarativeBind()
{
}
+/*!
+ \qmlproperty bool Binding::when
+
+ This property holds when the binding is active.
+ This should be set to an expression that evaluates to true when you want the binding to be active.
+
+ \code
+ Binding {
+ target: contactName; property: 'text'
+ value: name; when: list.ListView.isCurrentItem
+ }
+ \endcode
+*/
bool QDeclarativeBind::when() const
{
Q_D(const QDeclarativeBind);
diff --git a/src/declarative/util/qdeclarativeeasefollow.cpp b/src/declarative/util/qdeclarativeeasefollow.cpp
index 3fa9866..ee181dd 100644
--- a/src/declarative/util/qdeclarativeeasefollow.cpp
+++ b/src/declarative/util/qdeclarativeeasefollow.cpp
@@ -59,10 +59,10 @@ class QDeclarativeEaseFollowPrivate : public QObjectPrivate
public:
QDeclarativeEaseFollowPrivate()
: source(0), velocity(200), duration(-1), maximumEasingTime(-1),
- reversingMode(QDeclarativeEaseFollow::Eased), initialVelocity(0),
+ reversingMode(QDeclarativeEaseFollow::Eased), initialVelocity(0),
initialValue(0), invert(false), enabled(true), trackVelocity(0), clockOffset(0),
lastTick(0), clock(this)
- {}
+ {}
qreal source;
qreal velocity;
@@ -173,7 +173,7 @@ bool QDeclarativeEaseFollowPrivate::recalc()
}
/*
- qWarning() << "a:" << a << "tf:" << tf << "tp:" << tp << "vp:"
+ qWarning() << "a:" << a << "tf:" << tf << "tp:" << tp << "vp:"
<< vp << "sp:" << sp << "vi:" << vi << "invert:" << invert;
*/
return true;
@@ -254,19 +254,19 @@ void QDeclarativeEaseFollowPrivate::tick(int t)
\since 4.7
\brief The EaseFollow element allows a property to smoothly track a value.
- The EaseFollow smoothly animates a property's value to a set target value
+ The EaseFollow smoothly animates a property's value to a set target value
using an ease in/out quad easing curve. If the target value changes while
- the animation is in progress, the easing curves used to animate to the old
+ the animation is in progress, the easing curves used to animate to the old
and the new target values are spliced together to avoid any obvious visual
glitches.
The property animation is configured by setting the velocity at which the
- animation should occur, or the duration that the animation should take.
+ animation should occur, or the duration that the animation should take.
If both a velocity and a duration are specified, the one that results in
the quickest animation is chosen for each change in the target value.
For example, animating from 0 to 800 will take 4 seconds if a velocity
- of 200 is set, will take 8 seconds with a duration of 8000 set, and will
+ of 200 is set, will take 8 seconds with a duration of 8000 set, and will
take 4 seconds with both a velocity of 200 and a duration of 8000 set.
Animating from 0 to 20000 will take 10 seconds if a velocity of 200 is set,
will take 8 seconds with a duration of 8000 set, and will take 8 seconds
@@ -283,8 +283,8 @@ Rectangle {
color: "green"
width: 60; height: 60;
x: -5; y: -5;
- x: EaseFollow { source: rect1.x - 5; velocity: 200 }
- y: EaseFollow { source: rect1.y - 5; velocity: 200 }
+ EaseFollow on x { source: rect1.x - 5; velocity: 200 }
+ EaseFollow on y { source: rect1.y - 5; velocity: 200 }
}
Rectangle {
@@ -338,8 +338,8 @@ qreal QDeclarativeEaseFollow::sourceValue() const
Sets how the EaseFollow behaves if an animation direction is reversed.
If reversing mode is \c Eased, the animation will smoothly decelerate, and
- then reverse direction. If the reversing mode is \c Immediate, the
- animation will immediately begin accelerating in the reverse direction,
+ then reverse direction. If the reversing mode is \c Immediate, the
+ animation will immediately begin accelerating in the reverse direction,
begining with a velocity of 0. If the reversing mode is \c Sync, the
property is immediately set to the target value.
*/
@@ -373,7 +373,7 @@ void QDeclarativeEaseFollowPrivate::restart()
return;
}
- bool hasReversed = trackVelocity != 0. &&
+ bool hasReversed = trackVelocity != 0. &&
((trackVelocity > 0) == ((initialValue - source) > 0));
if (hasReversed) {
@@ -440,7 +440,7 @@ void QDeclarativeEaseFollow::setDuration(qreal v)
d->duration = v;
d->trackVelocity = 0;
- if (d->clock.state() == QAbstractAnimation::Running)
+ if (d->clock.state() == QAbstractAnimation::Running)
d->restart();
emit durationChanged();
@@ -470,7 +470,7 @@ void QDeclarativeEaseFollow::setVelocity(qreal v)
d->velocity = v;
d->trackVelocity = 0;
- if (d->clock.state() == QAbstractAnimation::Running)
+ if (d->clock.state() == QAbstractAnimation::Running)
d->restart();
emit velocityChanged();
@@ -511,8 +511,8 @@ void QDeclarativeEaseFollow::setTarget(const QDeclarativeProperty &t)
\qmlproperty qreal EaseFollow::maximumEasingTime
This property specifies the maximum time an "eases" during the follow should take.
-Setting this property causes the velocity to "level out" after at a time. Setting
-a negative value reverts to the normal mode of easing over the entire animation
+Setting this property causes the velocity to "level out" after at a time. Setting
+a negative value reverts to the normal mode of easing over the entire animation
duration.
The default value is -1.
@@ -528,7 +528,7 @@ void QDeclarativeEaseFollow::setMaximumEasingTime(qreal v)
Q_D(QDeclarativeEaseFollow);
d->maximumEasingTime = v;
- if (d->clock.state() == QAbstractAnimation::Running)
+ if (d->clock.state() == QAbstractAnimation::Running)
d->restart();
emit maximumEasingTimeChanged();
diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp
index 4d12ae1..8f5f537 100644
--- a/src/declarative/util/qdeclarativefontloader.cpp
+++ b/src/declarative/util/qdeclarativefontloader.cpp
@@ -189,6 +189,16 @@ void QDeclarativeFontLoader::setName(const QString &name)
\o Loading - the font is currently being loaded
\o Error - an error occurred while loading the font
\endlist
+
+ Note that a change in the status property does not cause anything to happen
+ (although it reflects what has happened to the font loader internally). If you wish
+ to react to the change in status you need to do it yourself, for example in one
+ of the following ways:
+ \list
+ \o Create a state, so that a state change occurs, e.g. State{name: 'loaded'; when: loader.status = FontLoader.Ready;}
+ \o Do something inside the onStatusChanged signal handler, e.g. FontLoader{id: loader; onStatusChanged: if(loader.status == FontLoader.Ready) console.log('Loaded');}
+ \o Bind to the status variable somewhere, e.g. Text{text: if(loader.status!=FontLoader.Ready){'Not Loaded';}else{'Loaded';}}
+ \endlist
*/
QDeclarativeFontLoader::Status QDeclarativeFontLoader::status() const
{
diff --git a/src/declarative/util/qdeclarativespringfollow.cpp b/src/declarative/util/qdeclarativespringfollow.cpp
index 6205ab9..1d69dd3 100644
--- a/src/declarative/util/qdeclarativespringfollow.cpp
+++ b/src/declarative/util/qdeclarativespringfollow.cpp
@@ -222,8 +222,8 @@ void QDeclarativeSpringFollowPrivate::stop()
id: rect1
width: 20; height: 20
color: "#00ff00"
- y: 200 //initial value
- y: SequentialAnimation {
+ y: 200 // initial value
+ SequentialAnimation on y {
running: true
repeat: true
NumberAnimation {
@@ -239,7 +239,7 @@ void QDeclarativeSpringFollowPrivate::stop()
x: rect1.width
width: 20; height: 20
color: "#ff0000"
- y: SpringFollow { source: rect1.y; velocity: 200 }
+ SpringFollow on y { source: rect1.y; velocity: 200 }
}
\endcode
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
index 6fe5bf3..cd67aeb 100644
--- a/src/declarative/util/qdeclarativeview.cpp
+++ b/src/declarative/util/qdeclarativeview.cpp
@@ -51,6 +51,7 @@
#include <qdeclarativedebug_p.h>
#include <qdeclarativedebugservice_p.h>
#include <qdeclarativeglobal_p.h>
+#include <qdeclarativeguard_p.h>
#include <qscriptvalueiterator.h>
#include <qdebug.h>
@@ -136,8 +137,8 @@ public:
QDeclarativeView *q;
- QGuard<QGraphicsObject> root;
- QGuard<QDeclarativeItem> qmlRoot;
+ QDeclarativeGuard<QGraphicsObject> root;
+ QDeclarativeGuard<QDeclarativeItem> qmlRoot;
QUrl source;
@@ -193,6 +194,7 @@ void QDeclarativeViewPrivate::execute()
\o Initializes QGraphicsView for QML key handling:
\list
\o QGraphicsView::viewport()->setFocusPolicy(Qt::NoFocus);
+ \o QGraphicsView::setFocusPolicy(Qt::StrongFocus);
\o QGraphicsScene::setStickyFocus(true);
\endlist
\endlist
@@ -267,6 +269,7 @@ void QDeclarativeViewPrivate::init()
q->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
scene.setItemIndexMethod(QGraphicsScene::NoIndex);
q->viewport()->setFocusPolicy(Qt::NoFocus);
+ q->setFocusPolicy(Qt::StrongFocus);
scene.setStickyFocus(true); //### needed for correct focus handling
}
@@ -282,13 +285,14 @@ QDeclarativeView::~QDeclarativeView()
/*!
Sets the source to the \a url, loads the QML component and instantiates it.
+
+ Calling this methods multiple times with the same url will result
+ in the QML being reloaded.
*/
void QDeclarativeView::setSource(const QUrl& url)
{
- if (url != d->source) {
- d->source = url;
- d->execute();
- }
+ d->source = url;
+ d->execute();
}
/*!
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index 162a669..d260ada 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -647,11 +647,21 @@ void QDeclarativeXmlListModel::setNamespaceDeclarations(const QString &declarati
This property holds the status of data source loading. It can be one of:
\list
\o Null - no data source has been set
- \o Ready - nthe data source has been loaded
+ \o Ready - the data source has been loaded
\o Loading - the data source is currently being loaded
\o Error - an error occurred while loading the data source
\endlist
+ Note that a change in the status property does not cause anything to happen
+ (although it reflects what has happened to the XmlListModel internally). If you wish
+ to react to the change in status you need to do it yourself, for example in one
+ of the following ways:
+ \list
+ \o Create a state, so that a state change occurs, e.g. State{name: 'loaded'; when: xmlListModel.status = XmlListModel.Ready;}
+ \o Do something inside the onStatusChanged signal handler, e.g. XmlListModel{id: xmlListModel; onStatusChanged: if(xmlListModel.status == XmlListModel.Ready) console.log('Loaded');}
+ \o Bind to the status variable somewhere, e.g. Text{text: if(xmlListModel.status!=XmlListModel.Ready){'Not Loaded';}else{'Loaded';}}
+ \endlist
+
\sa progress
*/
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h
index d72833b..56f94a2 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/gui/graphicsview/qgraphicsitem.h
@@ -540,10 +540,10 @@ class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged FINAL)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
- Q_PROPERTY(QPointF pos READ pos WRITE setPos)
- Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged)
- Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged)
- Q_PROPERTY(qreal z READ zValue WRITE setZValue NOTIFY zChanged)
+ Q_PROPERTY(QPointF pos READ pos WRITE setPos FINAL)
+ Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged FINAL)
+ Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged FINAL)
+ Q_PROPERTY(qreal z READ zValue WRITE setZValue NOTIFY zChanged FINAL)
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint WRITE setTransformOriginPoint)
diff --git a/src/plugins/qdeclarativemodules/qdeclarativemodules.pro b/src/imports/imports.pro
index 0a6f444..8b47043 100644
--- a/src/plugins/qdeclarativemodules/qdeclarativemodules.pro
+++ b/src/imports/imports.pro
@@ -2,5 +2,6 @@ TEMPLATE = subdirs
SUBDIRS += widgets
+contains(QT_CONFIG, webkit): SUBDIRS += webkit
contains(QT_CONFIG, multimedia): SUBDIRS += multimedia
diff --git a/src/plugins/qdeclarativemodules/multimedia/multimedia.cpp b/src/imports/multimedia/multimedia.cpp
index a2e74f4..a2e74f4 100644
--- a/src/plugins/qdeclarativemodules/multimedia/multimedia.cpp
+++ b/src/imports/multimedia/multimedia.cpp
diff --git a/src/plugins/qdeclarativemodules/multimedia/multimedia.pro b/src/imports/multimedia/multimedia.pro
index 7b63e7c..117aa9b 100644
--- a/src/plugins/qdeclarativemodules/multimedia/multimedia.pro
+++ b/src/imports/multimedia/multimedia.pro
@@ -1,5 +1,6 @@
TARGET = multimedia
-include(../../qpluginbase.pri)
+TARGETPATH = $$[QT_INSTALL_IMPORTS]/Qt/multimedia
+include(../qimportbase.pri)
QT += multimedia declarative
@@ -17,10 +18,9 @@ SOURCES += \
qmetadatacontrolmetaobject.cpp
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/Qt/multimedia
-target.path = $$[QT_INSTALL_IMPORTS]/Qt/multimedia
+target.path = $$TARGETPATH
qmldir.files += $$QT_BUILD_TREE/imports/Qt/multimedia/qmldir
-qmldir.path += $$[QT_INSTALL_IMPORTS]/Qt/multimedia
+qmldir.path += $$TARGETPATH
INSTALLS += target qmldir
-
diff --git a/src/plugins/qdeclarativemodules/multimedia/qdeclarativeaudio.cpp b/src/imports/multimedia/qdeclarativeaudio.cpp
index df2888c..df2888c 100644
--- a/src/plugins/qdeclarativemodules/multimedia/qdeclarativeaudio.cpp
+++ b/src/imports/multimedia/qdeclarativeaudio.cpp
diff --git a/src/plugins/qdeclarativemodules/multimedia/qdeclarativeaudio_p.h b/src/imports/multimedia/qdeclarativeaudio_p.h
index 9881dbc..9881dbc 100644
--- a/src/plugins/qdeclarativemodules/multimedia/qdeclarativeaudio_p.h
+++ b/src/imports/multimedia/qdeclarativeaudio_p.h
diff --git a/src/plugins/qdeclarativemodules/multimedia/qdeclarativemediabase.cpp b/src/imports/multimedia/qdeclarativemediabase.cpp
index 8e87e44..8e87e44 100644
--- a/src/plugins/qdeclarativemodules/multimedia/qdeclarativemediabase.cpp
+++ b/src/imports/multimedia/qdeclarativemediabase.cpp
diff --git a/src/plugins/qdeclarativemodules/multimedia/qdeclarativemediabase_p.h b/src/imports/multimedia/qdeclarativemediabase_p.h
index b40e84e..b40e84e 100644
--- a/src/plugins/qdeclarativemodules/multimedia/qdeclarativemediabase_p.h
+++ b/src/imports/multimedia/qdeclarativemediabase_p.h
diff --git a/src/plugins/qdeclarativemodules/multimedia/qdeclarativevideo.cpp b/src/imports/multimedia/qdeclarativevideo.cpp
index 064f242..064f242 100644
--- a/src/plugins/qdeclarativemodules/multimedia/qdeclarativevideo.cpp
+++ b/src/imports/multimedia/qdeclarativevideo.cpp
diff --git a/src/plugins/qdeclarativemodules/multimedia/qdeclarativevideo_p.h b/src/imports/multimedia/qdeclarativevideo_p.h
index fb13519..fb13519 100644
--- a/src/plugins/qdeclarativemodules/multimedia/qdeclarativevideo_p.h
+++ b/src/imports/multimedia/qdeclarativevideo_p.h
diff --git a/src/plugins/qdeclarativemodules/multimedia/qmetadatacontrolmetaobject.cpp b/src/imports/multimedia/qmetadatacontrolmetaobject.cpp
index e90cbd6..e90cbd6 100644
--- a/src/plugins/qdeclarativemodules/multimedia/qmetadatacontrolmetaobject.cpp
+++ b/src/imports/multimedia/qmetadatacontrolmetaobject.cpp
diff --git a/src/plugins/qdeclarativemodules/multimedia/qmetadatacontrolmetaobject_p.h b/src/imports/multimedia/qmetadatacontrolmetaobject_p.h
index c381f2d..c381f2d 100644
--- a/src/plugins/qdeclarativemodules/multimedia/qmetadatacontrolmetaobject_p.h
+++ b/src/imports/multimedia/qmetadatacontrolmetaobject_p.h
diff --git a/src/imports/multimedia/qmldir b/src/imports/multimedia/qmldir
new file mode 100644
index 0000000..0e6f656
--- /dev/null
+++ b/src/imports/multimedia/qmldir
@@ -0,0 +1 @@
+plugin multimedia
diff --git a/src/imports/qimportbase.pri b/src/imports/qimportbase.pri
new file mode 100644
index 0000000..363dd88
--- /dev/null
+++ b/src/imports/qimportbase.pri
@@ -0,0 +1,33 @@
+TEMPLATE = lib
+CONFIG += qt plugin
+
+win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release
+
+isEmpty(TARGETPATH) {
+ error("qimportbase.pri: You must provide a TARGETPATH!")
+}
+isEmpty(TARGET) {
+ error("qimportbase.pri: You must provide a TARGET!")
+}
+
+QMLDIRFILE = $${_PRO_FILE_PWD_}/qmldir
+copy2build.input = QMLDIRFILE
+copy2build.output = $$TARGETPATH/qmldir
+isEmpty(vcproj):copy2build.variable_out = PRE_TARGETDEPS
+copy2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
+copy2build.name = COPY ${QMAKE_FILE_IN}
+copy2build.CONFIG += no_link
+QMAKE_EXTRA_COMPILERS += copy2build
+
+TARGET = $$qtLibraryTarget($$TARGET)
+contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
+
+include(../../qt_targets.pri)
+
+wince*:LIBS += $$QMAKE_LIBS_GUI
+
+symbian: {
+ TARGET.EPOCALLOWDLLDATA=1
+ TARGET.CAPABILITY = All -Tcb
+ load(armcc_warnings)
+}
diff --git a/src/imports/webkit/plugin.cpp b/src/imports/webkit/plugin.cpp
new file mode 100644
index 0000000..799fe9e
--- /dev/null
+++ b/src/imports/webkit/plugin.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** 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 plugins 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 <QtDeclarative/qdeclarativeextensionplugin.h>
+#include <QtDeclarative/qdeclarative.h>
+
+#include "qdeclarativewebview_p.h"
+#include "qdeclarativewebview_p_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class WebKitQmlPlugin : public QDeclarativeExtensionPlugin
+{
+ Q_OBJECT
+public:
+ virtual void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("org.webkit"));
+ QML_REGISTER_NOCREATE_TYPE(QDeclarativeWebSettings);
+ qmlRegisterType<QDeclarativeWebView>(uri,1,0,"WebView");
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "plugin.moc"
+
+Q_EXPORT_PLUGIN2(webkitqmlplugin, QT_PREPEND_NAMESPACE(WebKitQmlPlugin));
+
diff --git a/src/declarative/graphicsitems/qdeclarativewebview.cpp b/src/imports/webkit/qdeclarativewebview.cpp
index a2b16ba..d78ba28 100644
--- a/src/declarative/graphicsitems/qdeclarativewebview.cpp
+++ b/src/imports/webkit/qdeclarativewebview.cpp
@@ -42,11 +42,11 @@
#include "qdeclarativewebview_p.h"
#include "qdeclarativewebview_p_p.h"
-#include "qdeclarativepainteditem_p_p.h"
+#include <private/qdeclarativepainteditem_p_p.h>
#include <qdeclarative.h>
#include <qdeclarativeengine.h>
-#include <qdeclarativestate_p.h>
+#include <private/qdeclarativestate_p.h>
#include <QDebug>
#include <QPen>
@@ -61,7 +61,7 @@
#include <QtWebKit/QWebFrame>
#include <QtWebKit/QWebElement>
#include <QtWebKit/QWebSettings>
-#include <qlistmodelinterface_p.h>
+#include <private/qlistmodelinterface_p.h>
QT_BEGIN_NAMESPACE
@@ -128,6 +128,8 @@ public:
usually laying out the web content to fit the preferredWidth.
\qml
+ import org.webkit 1.0
+
WebView {
url: "http://www.nokia.com"
width: 490
diff --git a/src/declarative/graphicsitems/qdeclarativewebview_p.h b/src/imports/webkit/qdeclarativewebview_p.h
index a65aab3..145e74b 100644
--- a/src/declarative/graphicsitems/qdeclarativewebview_p.h
+++ b/src/imports/webkit/qdeclarativewebview_p.h
@@ -42,7 +42,9 @@
#ifndef QDECLARATIVEWEBVIEW_H
#define QDECLARATIVEWEBVIEW_H
-#include "qdeclarativepainteditem_p.h"
+#include "webkitqmlplugin_export.h"
+
+#include <private/qdeclarativepainteditem_p.h>
#include <QtGui/QAction>
#include <QtCore/QUrl>
@@ -57,11 +59,12 @@ class QWebSettings;
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+class QDeclarativeWebSettings;
class QDeclarativeWebViewPrivate;
class QNetworkRequest;
class QDeclarativeWebView;
-class Q_DECLARATIVE_EXPORT QDeclarativeWebPage : public QWebPage
+class WEBKITQMLPLUGIN_EXPORT QDeclarativeWebPage : public QWebPage
{
Q_OBJECT
public:
@@ -82,11 +85,10 @@ private:
class QDeclarativeWebViewAttached;
-class QDeclarativeWebSettings;
//### TODO: browser plugins
-class Q_DECLARATIVE_EXPORT QDeclarativeWebView : public QDeclarativePaintedItem
+class WEBKITQMLPLUGIN_EXPORT QDeclarativeWebView : public QDeclarativePaintedItem
{
Q_OBJECT
diff --git a/src/declarative/graphicsitems/qdeclarativewebview_p_p.h b/src/imports/webkit/qdeclarativewebview_p_p.h
index 258b472..3ad9e9a 100644
--- a/src/declarative/graphicsitems/qdeclarativewebview_p_p.h
+++ b/src/imports/webkit/qdeclarativewebview_p_p.h
@@ -42,6 +42,8 @@
#ifndef QDECLARATIVEWEBVIEW_P_H
#define QDECLARATIVEWEBVIEW_P_H
+#include "webkitqmlplugin_export.h"
+
#include <qdeclarative.h>
#include <QtWebKit/QWebPage>
@@ -52,7 +54,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QDeclarativeWebSettings : public QObject {
+class WEBKITQMLPLUGIN_EXPORT QDeclarativeWebSettings : public QObject {
Q_OBJECT
Q_PROPERTY(QString standardFontFamily READ standardFontFamily WRITE setStandardFontFamily)
diff --git a/src/imports/webkit/qmldir b/src/imports/webkit/qmldir
new file mode 100644
index 0000000..258aa2c
--- /dev/null
+++ b/src/imports/webkit/qmldir
@@ -0,0 +1 @@
+plugin webkitqmlplugin
diff --git a/src/imports/webkit/webkit.pro b/src/imports/webkit/webkit.pro
new file mode 100644
index 0000000..76b46f1
--- /dev/null
+++ b/src/imports/webkit/webkit.pro
@@ -0,0 +1,19 @@
+TARGET = webkitqmlplugin
+TARGETPATH = $$[QT_INSTALL_IMPORTS]/org/webkit
+include(../qimportbase.pri)
+
+QT += webkit declarative
+DEFINES += WEBKITQMLPLUGIN_EXPORTS
+
+SOURCES += qdeclarativewebview.cpp plugin.cpp
+HEADERS += qdeclarativewebview_p.h \
+ qdeclarativewebview_p_p.h \
+ webkitqmlplugin_export.h
+
+QTDIR_build:DESTDIR = $$TARGETPATH
+target.path = $$TARGETPATH
+
+qmldir.files += $$QT_BUILD_TREE/imports/org/webkit/qmldir
+qmldir.path += $$TARGETPATH
+
+INSTALLS += target qmldir
diff --git a/src/imports/webkit/webkitqmlplugin_export.h b/src/imports/webkit/webkitqmlplugin_export.h
new file mode 100644
index 0000000..974fd24
--- /dev/null
+++ b/src/imports/webkit/webkitqmlplugin_export.h
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** 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 WEBKITQMLPLUGIN_EXPORT_H
+#define WEBKITQMLPLUGIN_EXPORT_H
+
+#include <QtCore/QtGlobal>
+
+#if defined WEBKITQMLPLUGIN_EXPORTS
+# define WEBKITQMLPLUGIN_EXPORT Q_DECL_EXPORT
+#else
+# define WEBKITQMLPLUGIN_EXPORT Q_DECL_IMPORT
+#endif
+
+#endif // WEBKITQMLPLUGIN_EXPORT_H
diff --git a/src/plugins/qdeclarativemodules/widgets/graphicslayouts.cpp b/src/imports/widgets/graphicslayouts.cpp
index fc15ad2..fc15ad2 100644
--- a/src/plugins/qdeclarativemodules/widgets/graphicslayouts.cpp
+++ b/src/imports/widgets/graphicslayouts.cpp
diff --git a/src/plugins/qdeclarativemodules/widgets/graphicslayouts_p.h b/src/imports/widgets/graphicslayouts_p.h
index f9b9ae8..f9b9ae8 100644
--- a/src/plugins/qdeclarativemodules/widgets/graphicslayouts_p.h
+++ b/src/imports/widgets/graphicslayouts_p.h
diff --git a/src/plugins/qdeclarativemodules/widgets/graphicswidgets.cpp b/src/imports/widgets/graphicswidgets.cpp
index 062e516..062e516 100644
--- a/src/plugins/qdeclarativemodules/widgets/graphicswidgets.cpp
+++ b/src/imports/widgets/graphicswidgets.cpp
diff --git a/src/plugins/qdeclarativemodules/widgets/graphicswidgets_p.h b/src/imports/widgets/graphicswidgets_p.h
index 2c2b707..2c2b707 100644
--- a/src/plugins/qdeclarativemodules/widgets/graphicswidgets_p.h
+++ b/src/imports/widgets/graphicswidgets_p.h
diff --git a/src/imports/widgets/qmldir b/src/imports/widgets/qmldir
new file mode 100644
index 0000000..6f19878
--- /dev/null
+++ b/src/imports/widgets/qmldir
@@ -0,0 +1 @@
+plugin widgets
diff --git a/src/plugins/qdeclarativemodules/widgets/widgets.cpp b/src/imports/widgets/widgets.cpp
index ec21cc4..ec21cc4 100644
--- a/src/plugins/qdeclarativemodules/widgets/widgets.cpp
+++ b/src/imports/widgets/widgets.cpp
diff --git a/src/plugins/qdeclarativemodules/widgets/widgets.pro b/src/imports/widgets/widgets.pro
index 3ec38da..b98be59 100644
--- a/src/plugins/qdeclarativemodules/widgets/widgets.pro
+++ b/src/imports/widgets/widgets.pro
@@ -1,5 +1,6 @@
TARGET = widgets
-include(../../qpluginbase.pri)
+TARGETPATH = $$[QT_INSTALL_IMPORTS]/Qt/widgets
+include(../qimportbase.pri)
QT += declarative
@@ -12,9 +13,10 @@ HEADERS += \
graphicslayouts_p.h
QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/Qt/widgets
-target.path = $$[QT_INSTALL_IMPORTS]/Qt/widgets
+target.path = $$TARGETPATH
-qmldir.files += $$QT_BUILD_TREE/imports/Qt/widgets/qmldir
-qmldir.path += $$[QT_INSTALL_IMPORTS]/Qt/widgets
+# install qmldir file
+qmldir.files += qmldir
+qmldir.path = $$TARGETPATH
INSTALLS += target qmldir
diff --git a/src/multimedia/effects/qsoundeffect.cpp b/src/multimedia/effects/qsoundeffect.cpp
index 541e6c9..2694023 100644
--- a/src/multimedia/effects/qsoundeffect.cpp
+++ b/src/multimedia/effects/qsoundeffect.cpp
@@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE
id: playSound
source: "test.wav"
}
- MouseRegion {
+ MouseArea {
id: playArea
anchors.fill: parent
onPressed: {
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 418fd81..730fdc5 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -12,6 +12,5 @@ embedded:SUBDIRS *= gfxdrivers decorations mousedrivers kbddrivers
symbian:SUBDIRS += s60
contains(QT_CONFIG, phonon): SUBDIRS *= phonon
contains(QT_CONFIG, multimedia): SUBDIRS *= audio mediaservices
-contains(QT_CONFIG, declarative): SUBDIRS *= qdeclarativemodules
diff --git a/src/src.pro b/src/src.pro
index ebfd44b..8c21ef7 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -29,6 +29,7 @@ contains(QT_CONFIG, scripttools): SRC_SUBDIRS += src_scripttools
contains(QT_CONFIG, declarative): SRC_SUBDIRS += src_declarative
contains(QT_CONFIG, multimedia): SRC_SUBDIRS += src_multimedia
SRC_SUBDIRS += src_plugins
+contains(QT_CONFIG, declarative): SRC_SUBDIRS += src_imports
src_s60main.subdir = $$QT_SOURCE_TREE/src/s60main
src_s60main.target = sub-s60main
@@ -70,6 +71,8 @@ src_activeqt.subdir = $$QT_SOURCE_TREE/src/activeqt
src_activeqt.target = sub-activeqt
src_plugins.subdir = $$QT_SOURCE_TREE/src/plugins
src_plugins.target = sub-plugins
+src_imports.subdir = $$QT_SOURCE_TREE/src/imports
+src_imports.target = sub-imports
src_testlib.subdir = $$QT_SOURCE_TREE/src/testlib
src_testlib.target = sub-testlib
src_javascriptcore.subdir = $$QT_SOURCE_TREE/src/3rdparty/webkit/JavaScriptCore
@@ -103,11 +106,13 @@ src_declarative.target = sub-declarative
src_tools_activeqt.depends = src_tools_idc src_gui
src_declarative.depends = src_xml src_gui src_script src_network src_svg
src_plugins.depends = src_gui src_sql src_svg src_multimedia
+ src_imports.depends = src_gui src_declarative
contains(QT_CONFIG, webkit) {
src_webkit.depends = src_gui src_sql src_network src_xml
contains(QT_CONFIG, phonon):src_webkit.depends += src_phonon
contains(QT_CONFIG, xmlpatterns): src_webkit.depends += src_xmlpatterns
contains(QT_CONFIG, declarative):src_declarative.depends += src_webkit
+ src_imports.depends += webkit
#exists($$QT_SOURCE_TREE/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro): src_webkit.depends += src_javascriptcore
}
contains(QT_CONFIG, qt3support): src_plugins.depends += src_qt3support