summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-25 11:28:35 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-25 11:28:35 (GMT)
commit6729645b28f6acfeab9bb0bc488ca4143c480f5a (patch)
tree460b440bdaa684f42f0bd8d024829673747cb727 /src
parentea0b7da7f5c206c436999b35bc2b55fb8863ecfe (diff)
parent3eed4c454a58b38c895925b74e47a0b1b747df80 (diff)
downloadQt-6729645b28f6acfeab9bb0bc488ca4143c480f5a.zip
Qt-6729645b28f6acfeab9bb0bc488ca4143c480f5a.tar.gz
Qt-6729645b28f6acfeab9bb0bc488ca4143c480f5a.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7
Conflicts: tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir
Diffstat (limited to 'src')
-rw-r--r--src/corelib/global/qnamespace.h3
-rw-r--r--src/corelib/global/qnamespace.qdoc1
-rw-r--r--src/declarative/QmlChanges.txt41
-rw-r--r--src/declarative/debugger/qdeclarativedebug.cpp14
-rw-r--r--src/declarative/debugger/qdeclarativedebug_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflipable.cpp9
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp62
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp5
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp62
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp21
-rw-r--r--src/declarative/graphicsitems/qdeclarativepath.cpp7
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners.cpp49
-rw-r--r--src/declarative/graphicsitems/qdeclarativerepeater.cpp12
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp8
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp1
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp2
-rw-r--r--src/declarative/qml/parser/qdeclarativejs.g4
-rw-r--r--src/declarative/qml/parser/qdeclarativejsparser.cpp4
-rw-r--r--src/declarative/qml/qdeclarativebinding.cpp5
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp58
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp9
-rw-r--r--src/declarative/qml/qdeclarativecomponent_p.h2
-rw-r--r--src/declarative/qml/qdeclarativecompositetypedata_p.h9
-rw-r--r--src/declarative/qml/qdeclarativecompositetypemanager.cpp58
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp84
-rw-r--r--src/declarative/qml/qdeclarativecontext_p.h16
-rw-r--r--src/declarative/qml/qdeclarativecontextscriptclass.cpp16
-rw-r--r--src/declarative/qml/qdeclarativedirparser.cpp10
-rw-r--r--src/declarative/qml/qdeclarativedirparser_p.h10
-rw-r--r--src/declarative/qml/qdeclarativedom.cpp6
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp122
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h10
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp15
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug_p.h1
-rw-r--r--src/declarative/qml/qdeclarativeexpression.cpp8
-rw-r--r--src/declarative/qml/qdeclarativeinstruction.cpp3
-rw-r--r--src/declarative/qml/qdeclarativeinstruction_p.h1
-rw-r--r--src/declarative/qml/qdeclarativeintegercache.cpp10
-rw-r--r--src/declarative/qml/qdeclarativeintegercache_p.h1
-rw-r--r--src/declarative/qml/qdeclarativemetatype.cpp28
-rw-r--r--src/declarative/qml/qdeclarativemetatype_p.h2
-rw-r--r--src/declarative/qml/qdeclarativeparser.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeparser_p.h9
-rw-r--r--src/declarative/qml/qdeclarativescriptparser.cpp135
-rw-r--r--src/declarative/qml/qdeclarativescriptparser_p.h4
-rw-r--r--src/declarative/qml/qdeclarativetypenamecache.cpp15
-rw-r--r--src/declarative/qml/qdeclarativetypenamecache_p.h4
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp16
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp4
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp344
-rw-r--r--src/declarative/util/qdeclarativeanimation_p.h54
-rw-r--r--src/declarative/util/qdeclarativeanimation_p_p.h29
-rw-r--r--src/declarative/util/qdeclarativebehavior.cpp3
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp18
-rw-r--r--src/declarative/util/qdeclarativepixmapcache.cpp2
-rw-r--r--src/declarative/util/qdeclarativepropertychanges.cpp2
-rw-r--r--src/declarative/util/qdeclarativespringfollow.cpp6
-rw-r--r--src/declarative/util/qdeclarativestate_p_p.h4
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp35
-rw-r--r--src/declarative/util/qdeclarativetransition.cpp14
-rw-r--r--src/declarative/util/qdeclarativetransition_p.h11
-rw-r--r--src/declarative/util/qdeclarativeutilmodule.cpp38
-rw-r--r--src/declarative/util/qdeclarativeview.cpp15
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp191
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel_p.h15
-rw-r--r--src/declarative/util/qfxperf.cpp67
-rw-r--r--src/declarative/util/qfxperf_p_p.h90
-rw-r--r--src/declarative/util/qperformancelog.cpp181
-rw-r--r--src/declarative/util/qperformancelog_p_p.h141
-rw-r--r--src/declarative/util/util.pri4
-rw-r--r--src/gui/dialogs/qfilesystemmodel.cpp7
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp127
-rw-r--r--src/gui/graphicsview/qgraphicsitem.h8
-rw-r--r--src/gui/itemviews/qdirmodel.cpp6
-rw-r--r--src/gui/text/qfontmetrics.cpp4
-rw-r--r--src/gui/widgets/qlabel.cpp5
-rw-r--r--src/imports/particles/qdeclarativeparticles.cpp4
-rw-r--r--src/imports/particles/qdeclarativeparticles_p.h2
-rw-r--r--src/imports/webkit/qdeclarativewebview.cpp87
-rw-r--r--src/imports/webkit/qdeclarativewebview_p.h1
-rw-r--r--src/multimedia/effects/qsoundeffect.cpp10
-rw-r--r--src/multimedia/effects/qsoundeffect_p.h8
83 files changed, 1263 insertions, 1252 deletions
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 89a0c0b..1ef875f 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -146,7 +146,8 @@ public:
NoButton = 0x00000000,
LeftButton = 0x00000001,
RightButton = 0x00000002,
- MidButton = 0x00000004,
+ MidButton = 0x00000004, // ### Qt 5: remove me
+ MiddleButton = MidButton,
XButton1 = 0x00000008,
XButton2 = 0x00000010,
MouseButtonMask = 0x000000ff
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index f8f3c49..8f9902f 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -185,6 +185,7 @@
left-handed mice.)
\value RightButton The right button.
\value MidButton The middle button.
+ \value MiddleButton The middle button.
\value XButton1 The first X button.
\value XButton2 The second X button.
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index 7c584b4d..2a35dda 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -10,6 +10,9 @@ Removed DateTimeFormatter (use Qt.formatDateTime() instead)
Using WebView now requires "import org.webkit 1.0"
Using Particles now requires "import Qt.labs.particles 1.0"
AnchorAnimation must now be used to animate anchor changes (and not NumberAnimation)
+Removed ParentAction (use ParentAnimation instead)
+ScriptAction: renamed stateChangeScriptName -> scriptName
+Animation: replace repeat with loops (loops: Animation.Infinite gives the old repeat behavior)
C++ API
-------
@@ -25,6 +28,44 @@ syntax has been introduced:
Item { Behavior on x {}; NumberAnimation on y {} }
Only the syntax has changed, the behavior is identical.
+Script element removed
+----------------------
+Inline Script{} blocks have been deprecated, and will soon be removed entirely.
+If you used Script to write inline javascript code, it can simply be removed.
+For example
+
+Item {
+ Script {
+ function doSomething() {}
+ }
+}
+
+becomes
+
+Item {
+ function doSomething() {}
+}
+
+If you used Script to include external JavaScript files, you can replace the
+Script element with an “import” line. For example
+
+MouseArea {
+ Script {
+ source: “foo.js”
+ }
+ onClicked: foo()
+}
+
+becomes
+
+Import “foo.js” as Foo
+MouseArea {
+ onClicked: Foo.foo()
+}
+
+The “as” qualifier is mandatory for script imports (as opposed to type
+imports where it is optional).
+
=============================================================================
The changes below are pre Qt 4.7.0 alpha
diff --git a/src/declarative/debugger/qdeclarativedebug.cpp b/src/declarative/debugger/qdeclarativedebug.cpp
index e4b7d4d..677d05f 100644
--- a/src/declarative/debugger/qdeclarativedebug.cpp
+++ b/src/declarative/debugger/qdeclarativedebug.cpp
@@ -151,6 +151,7 @@ void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugOb
ds >> data;
o.m_debugId = data.objectId;
o.m_class = data.objectType;
+ o.m_idString = data.idString;
o.m_name = data.objectName;
o.m_source.m_url = data.url;
o.m_source.m_lineNumber = data.lineNumber;
@@ -750,8 +751,8 @@ QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(int debugId)
}
QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &o)
-: m_debugId(o.m_debugId), m_class(o.m_class), m_name(o.m_name),
- m_source(o.m_source), m_contextDebugId(o.m_contextDebugId),
+: m_debugId(o.m_debugId), m_class(o.m_class), m_idString(o.m_idString),
+ m_name(o.m_name), m_source(o.m_source), m_contextDebugId(o.m_contextDebugId),
m_properties(o.m_properties), m_children(o.m_children)
{
}
@@ -759,8 +760,8 @@ QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(const QDeclar
QDeclarativeDebugObjectReference &
QDeclarativeDebugObjectReference::operator=(const QDeclarativeDebugObjectReference &o)
{
- m_debugId = o.m_debugId; m_class = o.m_class; m_name = o.m_name;
- m_source = o.m_source; m_contextDebugId = o.m_contextDebugId;
+ m_debugId = o.m_debugId; m_class = o.m_class; m_idString = o.m_idString;
+ m_name = o.m_name; m_source = o.m_source; m_contextDebugId = o.m_contextDebugId;
m_properties = o.m_properties; m_children = o.m_children;
return *this;
}
@@ -775,6 +776,11 @@ QString QDeclarativeDebugObjectReference::className() const
return m_class;
}
+QString QDeclarativeDebugObjectReference::idString() const
+{
+ return m_idString;
+}
+
QString QDeclarativeDebugObjectReference::name() const
{
return m_name;
diff --git a/src/declarative/debugger/qdeclarativedebug_p.h b/src/declarative/debugger/qdeclarativedebug_p.h
index f0c7a77..4ead232 100644
--- a/src/declarative/debugger/qdeclarativedebug_p.h
+++ b/src/declarative/debugger/qdeclarativedebug_p.h
@@ -230,6 +230,7 @@ public:
int debugId() const;
QString className() const;
+ QString idString() const;
QString name() const;
QDeclarativeDebugFileReference source() const;
@@ -242,6 +243,7 @@ private:
friend class QDeclarativeEngineDebugPrivate;
int m_debugId;
QString m_class;
+ QString m_idString;
QString m_name;
QDeclarativeDebugFileReference m_source;
int m_contextDebugId;
diff --git a/src/declarative/graphicsitems/qdeclarativeflipable.cpp b/src/declarative/graphicsitems/qdeclarativeflipable.cpp
index 1ebbaee..0e2ae63 100644
--- a/src/declarative/graphicsitems/qdeclarativeflipable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflipable.cpp
@@ -42,6 +42,7 @@
#include "qdeclarativeflipable_p.h"
#include "qdeclarativeitem_p.h"
+#include "qdeclarativeguard_p.h"
#include <qdeclarativeinfo.h>
@@ -58,8 +59,8 @@ public:
void updateSceneTransformFromParent();
QDeclarativeFlipable::Side current;
- QDeclarativeItem *front;
- QDeclarativeItem *back;
+ QDeclarativeGuard<QDeclarativeItem> front;
+ QDeclarativeGuard<QDeclarativeItem> back;
};
/*!
@@ -159,7 +160,7 @@ QDeclarativeFlipable::Side QDeclarativeFlipable::side() const
{
Q_D(const QDeclarativeFlipable);
if (d->dirtySceneTransform)
- const_cast<QDeclarativeFlipablePrivate *>(d)->updateSceneTransformFromParent();
+ const_cast<QDeclarativeFlipablePrivate *>(d)->ensureSceneTransform();
return d->current;
}
@@ -192,7 +193,7 @@ void QDeclarativeFlipablePrivate::updateSceneTransformFromParent()
if (newSide != current) {
current = newSide;
- if (current == QDeclarativeFlipable::Back) {
+ if (current == QDeclarativeFlipable::Back && back) {
QTransform mat;
mat.translate(back->width()/2,back->height()/2);
if (back->width() && p1.x() >= p2.x())
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 93f8d06..de0cb04 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -786,28 +786,32 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
QDeclarativeFlickablePrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity);
return;
}
- qreal maxDistance = -1;
+ qreal maxDistance = 0;
// -ve velocity means list is moving up
if (velocity > 0) {
- if (snapMode == QDeclarativeGridView::SnapOneRow) {
- if (FxGridItem *item = firstVisibleItem())
- maxDistance = qAbs(item->rowPos() + data.move.value());
- } else if (data.move.value() < minExtent) {
- maxDistance = qAbs(minExtent - data.move.value());
+ if (data.move.value() < minExtent) {
+ if (snapMode == QDeclarativeGridView::SnapOneRow) {
+ if (FxGridItem *item = firstVisibleItem())
+ maxDistance = qAbs(item->rowPos() + data.move.value());
+ } else {
+ maxDistance = qAbs(minExtent - data.move.value());
+ }
}
if (snapMode != QDeclarativeGridView::SnapToRow && highlightRange != QDeclarativeGridView::StrictlyEnforceRange)
data.flickTarget = minExtent;
} else {
- if (snapMode == QDeclarativeGridView::SnapOneRow) {
- qreal pos = snapPosAt(-data.move.value()) + rowSize();
- maxDistance = qAbs(pos + data.move.value());
- } else if (data.move.value() > maxExtent) {
- maxDistance = qAbs(maxExtent - data.move.value());
+ if (data.move.value() > maxExtent) {
+ if (snapMode == QDeclarativeGridView::SnapOneRow) {
+ qreal pos = snapPosAt(-data.move.value()) + rowSize();
+ maxDistance = qAbs(pos + data.move.value());
+ } else {
+ maxDistance = qAbs(maxExtent - data.move.value());
+ }
}
if (snapMode != QDeclarativeGridView::SnapToRow && highlightRange != QDeclarativeGridView::StrictlyEnforceRange)
data.flickTarget = maxExtent;
}
- if (maxDistance > 0 && (snapMode != QDeclarativeGridView::NoSnap || highlightRange == QDeclarativeGridView::StrictlyEnforceRange)) {
+ if ((maxDistance > 0 || overShoot) && (snapMode != QDeclarativeGridView::NoSnap || highlightRange == QDeclarativeGridView::StrictlyEnforceRange)) {
// This mode requires the grid to stop exactly on a row boundary.
qreal v = velocity;
if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
@@ -818,9 +822,8 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
}
qreal accel = deceleration;
qreal v2 = v * v;
- qreal maxAccel = v2 / (2.0f * maxDistance);
qreal overshootDist = 0.0;
- if (maxAccel < accel) {
+ if (maxDistance > 0.0 && v2 / (2.0f * maxDistance) < accel) {
// + rowSize()/4 to encourage moving at least one item in the flick direction
qreal dist = v2 / (accel * 2.0) + rowSize()/4;
if (v > 0)
@@ -924,7 +927,7 @@ QDeclarativeGridView::~QDeclarativeGridView()
id: wrapper
SequentialAnimation on GridView.onRemove {
PropertyAction { target: wrapper.GridView; property: "delayRemove"; value: true }
- NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" }
+ NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: "InOutQuad" }
PropertyAction { target: wrapper.GridView; property: "delayRemove"; value: false }
}
}
@@ -1080,8 +1083,9 @@ void QDeclarativeGridView::setCurrentIndex(int index)
d->moveReason = QDeclarativeGridViewPrivate::SetIndex;
cancelFlick();
d->updateCurrent(index);
- } else {
+ } else if (index != d->currentIndex) {
d->currentIndex = index;
+ emit currentIndexChanged();
}
}
@@ -1504,10 +1508,12 @@ qreal QDeclarativeGridView::maxYExtent() const
if (d->flow == QDeclarativeGridView::TopToBottom)
return QDeclarativeFlickable::maxYExtent();
qreal extent;
- if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) {
extent = -(d->endPosition() - d->highlightRangeEnd);
- else
+ extent = qMax(extent, -(d->rowPosAt(d->model->count()-1) - d->highlightRangeStart));
+ } else {
extent = -(d->endPosition() - height());
+ }
const qreal minY = minYExtent();
if (extent > minY)
extent = minY;
@@ -1531,10 +1537,12 @@ qreal QDeclarativeGridView::maxXExtent() const
if (d->flow == QDeclarativeGridView::LeftToRight)
return QDeclarativeFlickable::maxXExtent();
qreal extent;
- if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) {
extent = -(d->endPosition() - d->highlightRangeEnd);
- else
+ extent = qMax(extent, -(d->rowPosAt(d->model->count()-1) - d->highlightRangeStart));
+ } else {
extent = -(d->endPosition() - height());
+ }
const qreal minX = minXExtent();
if (extent > minX)
extent = minX;
@@ -1838,9 +1846,17 @@ void QDeclarativeGridView::trackedPositionChanged()
void QDeclarativeGridView::itemsInserted(int modelIndex, int count)
{
Q_D(QDeclarativeGridView);
+ if (!isComponentComplete())
+ return;
if (!d->visibleItems.count() || d->model->count() <= 1) {
d->scheduleLayout();
- d->updateCurrent(qMax(0, qMin(d->currentIndex, d->model->count()-1)));
+ if (d->currentIndex >= modelIndex) {
+ // adjust current item index
+ d->currentIndex += count;
+ if (d->currentItem)
+ d->currentItem->index = d->currentIndex;
+ emit currentIndexChanged();
+ }
emit countChanged();
return;
}
@@ -1964,6 +1980,8 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count)
void QDeclarativeGridView::itemsRemoved(int modelIndex, int count)
{
Q_D(QDeclarativeGridView);
+ if (!isComponentComplete())
+ return;
bool currentRemoved = d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count;
bool removedVisible = false;
@@ -2054,6 +2072,8 @@ void QDeclarativeGridView::destroyRemoved()
void QDeclarativeGridView::itemsMoved(int from, int to, int count)
{
Q_D(QDeclarativeGridView);
+ if (!isComponentComplete())
+ return;
QHash<int,FxGridItem*> moved;
bool removedBeforeVisible = false;
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 4ba80ad..9b1bdba 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -45,7 +45,6 @@
#include "qdeclarativeevents_p_p.h"
#include <private/qdeclarativeengine_p.h>
-#include <qfxperf_p_p.h>
#include <qdeclarativeengine.h>
#include <qdeclarativeopenmetaobject_p.h>
#include <qdeclarativestate_p.h>
@@ -2491,10 +2490,6 @@ void QDeclarativeItem::classBegin()
*/
void QDeclarativeItem::componentComplete()
{
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QDeclarativePerfTimer<QDeclarativePerf::ItemComponentComplete> cc;
-#endif
-
Q_D(QDeclarativeItem);
d->_componentComplete = true;
if (d->_stateGroup)
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 84281c8..320a2f0 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -1136,28 +1136,32 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
QDeclarativeFlickablePrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity);
return;
}
- qreal maxDistance = -1;
- // -ve velocity means list is moving up
+ qreal maxDistance = 0;
+ // -ve velocity means list is moving up/left
if (velocity > 0) {
- if (snapMode == QDeclarativeListView::SnapOneItem) {
- if (FxListItem *item = firstVisibleItem())
- maxDistance = qAbs(item->position() + data.move.value());
- } else if (data.move.value() < minExtent) {
- maxDistance = qAbs(minExtent - data.move.value());
+ if (data.move.value() < minExtent) {
+ if (snapMode == QDeclarativeListView::SnapOneItem) {
+ if (FxListItem *item = firstVisibleItem())
+ maxDistance = qAbs(item->position() + data.move.value());
+ } else {
+ maxDistance = qAbs(minExtent - data.move.value());
+ }
}
if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
data.flickTarget = minExtent;
} else {
- if (snapMode == QDeclarativeListView::SnapOneItem) {
- if (FxListItem *item = nextVisibleItem())
- maxDistance = qAbs(item->position() + data.move.value());
- } else if (data.move.value() > maxExtent) {
- maxDistance = qAbs(maxExtent - data.move.value());
+ if (data.move.value() > maxExtent) {
+ if (snapMode == QDeclarativeListView::SnapOneItem) {
+ if (FxListItem *item = nextVisibleItem())
+ maxDistance = qAbs(item->position() + data.move.value());
+ } else {
+ maxDistance = qAbs(maxExtent - data.move.value());
+ }
}
if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
data.flickTarget = maxExtent;
}
- if (maxDistance > 0 && (snapMode != QDeclarativeListView::NoSnap || highlightRange == QDeclarativeListView::StrictlyEnforceRange)) {
+ if ((maxDistance > 0 || overShoot) && (snapMode != QDeclarativeListView::NoSnap || highlightRange == QDeclarativeListView::StrictlyEnforceRange)) {
// These modes require the list to stop exactly on an item boundary.
// The initial flick will estimate the boundary to stop on.
// Since list items can have variable sizes, the boundary will be
@@ -1173,8 +1177,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
// the initial flick - estimate boundary
qreal accel = deceleration;
qreal v2 = v * v;
- qreal maxAccel = v2 / (2.0f * maxDistance);
- if (maxAccel < accel) {
+ if (maxDistance > 0.0 && v2 / (2.0f * maxDistance) < accel) {
// + averageSize/4 to encourage moving at least one item in the flick direction
qreal dist = v2 / (accel * 2.0) + averageSize/4;
if (v > 0)
@@ -1328,7 +1331,7 @@ QDeclarativeListView::~QDeclarativeListView()
id: wrapper
SequentialAnimation on ListView.onRemove {
PropertyAction { target: wrapper.ListView; property: "delayRemove"; value: true }
- NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" }
+ NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: "InOutQuad" }
PropertyAction { target: wrapper.ListView; property: "delayRemove"; value: false }
}
}
@@ -1488,8 +1491,9 @@ void QDeclarativeListView::setCurrentIndex(int index)
d->moveReason = QDeclarativeListViewPrivate::SetIndex;
cancelFlick();
d->updateCurrent(index);
- } else {
+ } else if (index != d->currentIndex) {
d->currentIndex = index;
+ emit currentIndexChanged();
}
}
@@ -2063,9 +2067,10 @@ qreal QDeclarativeListView::maxYExtent() const
if (d->orient == QDeclarativeListView::Horizontal)
return height();
if (d->maxExtentDirty) {
- if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) {
d->maxExtent = -(d->endPosition() - d->highlightRangeEnd);
- else
+ d->maxExtent = qMax(d->maxExtent, -(d->positionAt(d->model->count()-1) - d->highlightRangeStart));
+ } else
d->maxExtent = -(d->endPosition() - height() + 1);
if (d->footer)
d->maxExtent -= d->footer->size();
@@ -2100,9 +2105,10 @@ qreal QDeclarativeListView::maxXExtent() const
if (d->orient == QDeclarativeListView::Vertical)
return width();
if (d->maxExtentDirty) {
- if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) {
d->maxExtent = -(d->endPosition() - d->highlightRangeEnd);
- else
+ d->maxExtent = qMax(d->maxExtent, -(d->positionAt(d->model->count()-1) - d->highlightRangeStart));
+ } else
d->maxExtent = -(d->endPosition() - width() + 1);
if (d->footer)
d->maxExtent -= d->footer->size();
@@ -2361,11 +2367,19 @@ void QDeclarativeListView::trackedPositionChanged()
void QDeclarativeListView::itemsInserted(int modelIndex, int count)
{
Q_D(QDeclarativeListView);
+ if (!isComponentComplete())
+ return;
d->updateUnrequestedIndexes();
d->moveReason = QDeclarativeListViewPrivate::Other;
if (!d->visibleItems.count() || d->model->count() <= 1) {
d->scheduleLayout();
- d->updateCurrent(qMax(0, qMin(d->currentIndex, d->model->count()-1)));
+ if (d->currentIndex >= modelIndex) {
+ // adjust current item index
+ d->currentIndex += count;
+ if (d->currentItem)
+ d->currentItem->index = d->currentIndex;
+ emit currentIndexChanged();
+ }
emit countChanged();
return;
}
@@ -2495,6 +2509,8 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count)
void QDeclarativeListView::itemsRemoved(int modelIndex, int count)
{
Q_D(QDeclarativeListView);
+ if (!isComponentComplete())
+ return;
d->moveReason = QDeclarativeListViewPrivate::Other;
d->updateUnrequestedIndexes();
@@ -2593,6 +2609,8 @@ void QDeclarativeListView::destroyRemoved()
void QDeclarativeListView::itemsMoved(int from, int to, int count)
{
Q_D(QDeclarativeListView);
+ if (!isComponentComplete())
+ return;
d->updateUnrequestedIndexes();
if (d->visibleItems.isEmpty()) {
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp
index 6dbcd16..0d62afa 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp
@@ -41,7 +41,9 @@
#include "qdeclarativeloader_p_p.h"
+#include <qdeclarativeinfo.h>
#include <qdeclarativeengine_p.h>
+#include <qdeclarativeglobal_p.h>
QT_BEGIN_NAMESPACE
@@ -66,7 +68,7 @@ void QDeclarativeLoaderPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem
void QDeclarativeLoaderPrivate::clear()
{
if (ownComponent) {
- delete component;
+ component->deleteLater();
component = 0;
ownComponent = false;
}
@@ -285,11 +287,20 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded()
return;
}
+ QDeclarativeComponent *c = component;
QObject *obj = component->create(ctxt);
+ if (component != c) {
+ // component->create could trigger a change in source that causes
+ // component to be set to something else. In that case we just
+ // need to cleanup.
+ delete obj;
+ delete ctxt;
+ return;
+ }
if (obj) {
- ctxt->setParent(obj);
item = qobject_cast<QGraphicsObject *>(obj);
if (item) {
+ QDeclarative_setParent_noEvent(ctxt, obj);
if (QDeclarativeItem* qmlItem = qobject_cast<QDeclarativeItem *>(item)) {
qmlItem->setParentItem(q);
} else {
@@ -298,8 +309,14 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded()
}
// item->setFocus(true);
initResize();
+ } else {
+ qmlInfo(q) << QDeclarativeLoader::tr("Loader does not support loading non-visual elements.");
+ delete obj;
+ delete ctxt;
}
} else {
+ if (!component->errors().isEmpty())
+ qWarning() << component->errors();
delete obj;
delete ctxt;
source = QUrl();
diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/graphicsitems/qdeclarativepath.cpp
index 80586b8..8cd990fc 100644
--- a/src/declarative/graphicsitems/qdeclarativepath.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepath.cpp
@@ -42,9 +42,8 @@
#include "qdeclarativepath_p.h"
#include "qdeclarativepath_p_p.h"
-#include <qfxperf_p_p.h>
-
#include <QSet>
+#include <QTime>
#include <private/qbezier_p.h>
@@ -314,7 +313,6 @@ QStringList QDeclarativePath::attributes() const
Q_D(const QDeclarativePath);
return d->_attributes;
}
-#include <QTime>
static inline QBezier nextBezier(const QPainterPath &path, int *from, qreal *bezLength)
{
@@ -356,9 +354,6 @@ static inline QBezier nextBezier(const QPainterPath &path, int *from, qreal *bez
void QDeclarativePath::createPointCache() const
{
Q_D(const QDeclarativePath);
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QDeclarativePerfTimer<QDeclarativePerf::QDeclarativePathViewPathCache> pc;
-#endif
qreal pathLength = d->_path.length();
const int points = int(pathLength*2);
const int lastElement = d->_path.elementCount() - 1;
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
index 0f59a70..7a0d33a 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
@@ -46,7 +46,6 @@
#include <qdeclarativestate_p.h>
#include <qdeclarativestategroup_p.h>
#include <qdeclarativestateoperations_p.h>
-#include <qfxperf_p_p.h>
#include <QtCore/qmath.h>
#include <QDebug>
@@ -164,9 +163,6 @@ void QDeclarativeBasePositioner::componentComplete()
{
Q_D(QDeclarativeBasePositioner);
QDeclarativeItem::componentComplete();
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QDeclarativePerfTimer<QDeclarativePerf::BasepositionerComponentComplete> cc;
-#endif
positionedItems.reserve(d->QGraphicsItemPrivate::children.count());
prePositioning();
}
@@ -225,20 +221,21 @@ void QDeclarativeBasePositioner::prePositioning()
d->watchChanges(child);
positionedItems.append(posItem);
item = &positionedItems[positionedItems.count()-1];
+ item->isNew = true;
+ if (child->opacity() <= 0.0 || !child->isVisible())
+ item->isVisible = false;
} else {
item = &oldItems[wIdx];
+ if (child->opacity() <= 0.0 || !child->isVisible()) {
+ item->isVisible = false;
+ } else if (!item->isVisible) {
+ item->isVisible = true;
+ item->isNew = true;
+ } else {
+ item->isNew = false;
+ }
positionedItems.append(*item);
}
- if (child->opacity() <= 0.0 || !child->isVisible()) {
- item->isVisible = false;
- continue;
- }
- if (!item->isVisible) {
- item->isVisible = true;
- item->isNew = true;
- } else {
- item->isNew = false;
- }
}
doPositioning();
if(d->addTransition || d->moveTransition)
@@ -261,11 +258,14 @@ void QDeclarativeBasePositioner::positionX(int x, const PositionedItem &target)
{
Q_D(QDeclarativeBasePositioner);
if(d->type == Horizontal || d->type == Both){
- if(!d->addTransition && !d->moveTransition){
- target.item->setX(x);
- }else{
- if(target.isNew)
+ if (target.isNew) {
+ if (!d->addTransition)
+ target.item->setX(x);
+ else
d->addActions << QDeclarativeAction(target.item, QLatin1String("x"), QVariant(x));
+ } else if (x != target.item->x()) {
+ if (!d->moveTransition)
+ target.item->setX(x);
else
d->moveActions << QDeclarativeAction(target.item, QLatin1String("x"), QVariant(x));
}
@@ -276,11 +276,14 @@ void QDeclarativeBasePositioner::positionY(int y, const PositionedItem &target)
{
Q_D(QDeclarativeBasePositioner);
if(d->type == Vertical || d->type == Both){
- if(!d->addTransition && !d->moveTransition){
- target.item->setY(y);
- }else{
- if(target.isNew)
+ if (target.isNew) {
+ if (!d->addTransition)
+ target.item->setY(y);
+ else
d->addActions << QDeclarativeAction(target.item, QLatin1String("y"), QVariant(y));
+ } else if (y != target.item->y()) {
+ if (!d->moveTransition)
+ target.item->setY(y);
else
d->moveActions << QDeclarativeAction(target.item, QLatin1String("y"), QVariant(y));
}
@@ -382,7 +385,7 @@ Column {
move: Transition {
NumberAnimation {
properties: "y"
- easing: "easeOutBounce"
+ easing.type: "OutBounce"
}
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
index b9696c8..e8f9b24 100644
--- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
@@ -358,14 +358,10 @@ void QDeclarativeRepeater::itemsMoved(int from, int to, int count)
removed << d->deletables.takeAt(from);
for (int i = 0; i < count; ++i)
d->deletables.insert(to + i, removed.at(i));
- for (int i = 0; i < d->model->count(); ++i) {
- if (i < from && i < to)
- continue;
- QDeclarativeItem *item = d->deletables.at(i);
- if (i < d->deletables.count()-1)
- item->stackBefore(d->deletables.at(i+1));
- else
- item->stackBefore(this);
+ d->deletables.last()->stackBefore(this);
+ for (int i = d->model->count()-1; i > 0; --i) {
+ QDeclarativeItem *item = d->deletables.at(i-1);
+ item->stackBefore(d->deletables.at(i));
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index 05139f6..b0b5f6d 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -43,8 +43,6 @@
#include "qdeclarativetext_p_p.h"
#include <qdeclarativestyledtext_p.h>
-#include <qfxperf_p_p.h>
-
#include <QTextLayout>
#include <QTextLine>
#include <QTextDocument>
@@ -152,9 +150,6 @@ void QDeclarativeText::setFont(const QFont &font)
void QDeclarativeText::setText(const QString &n)
{
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QDeclarativePerfTimer<QDeclarativePerf::QDeclarativeText_setText> st;
-#endif
Q_D(QDeclarativeText);
if (d->text == n)
return;
@@ -876,9 +871,6 @@ void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid
void QDeclarativeText::componentComplete()
{
Q_D(QDeclarativeText);
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QDeclarativePerfTimer<QDeclarativePerf::TextComponentComplete> cc;
-#endif
QDeclarativeItem::componentComplete();
if (d->dirty) {
d->updateLayout();
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index dbae47d..7dacfbb 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -44,8 +44,6 @@
#include "qdeclarativeevents_p_p.h"
-#include <qfxperf_p_p.h>
-
#include <QTextLayout>
#include <QTextLine>
#include <QTextDocument>
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index 01167dc..b049728 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -220,6 +220,7 @@ void QDeclarativeTextInput::setHAlign(HAlignment align)
if(align == d->hAlign)
return;
d->hAlign = align;
+ updateRect();
emit horizontalAlignmentChanged(d->hAlign);
}
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 6341764..b31bbd0 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -422,6 +422,8 @@ int QDeclarativeVisualDataModelDataMetaObject::createProperty(const char *name,
return -1;
QDeclarativeVisualDataModelPrivate *model = QDeclarativeVisualDataModelPrivate::get(data->m_model);
+ if (data->m_index < 0 || data->m_index >= model->modelCount())
+ return -1;
if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) {
if (model->m_listAccessor->type() == QDeclarativeListAccessor::ListProperty) {
diff --git a/src/declarative/qml/parser/qdeclarativejs.g b/src/declarative/qml/parser/qdeclarativejs.g
index 493ad25..0256c52 100644
--- a/src/declarative/qml/parser/qdeclarativejs.g
+++ b/src/declarative/qml/parser/qdeclarativejs.g
@@ -665,7 +665,9 @@ case $rule_number: {
sym(1).Node = node;
- if (! node) {
+ if (node) {
+ node->importToken = loc(1);
+ } else {
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
QLatin1String("Expected a qualified name id or a string literal")));
diff --git a/src/declarative/qml/parser/qdeclarativejsparser.cpp b/src/declarative/qml/parser/qdeclarativejsparser.cpp
index c86e047..9205ef4 100644
--- a/src/declarative/qml/parser/qdeclarativejsparser.cpp
+++ b/src/declarative/qml/parser/qdeclarativejsparser.cpp
@@ -284,7 +284,9 @@ case 20: {
sym(1).Node = node;
- if (! node) {
+ if (node) {
+ node->importToken = loc(1);
+ } else {
diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1),
QLatin1String("Expected a qualified name id or a string literal")));
diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp
index 090bd5b..a7047ab 100644
--- a/src/declarative/qml/qdeclarativebinding.cpp
+++ b/src/declarative/qml/qdeclarativebinding.cpp
@@ -49,8 +49,6 @@
#include "qdeclarativedeclarativedata_p.h"
#include "qdeclarativestringconverters_p.h"
-#include <qfxperf_p_p.h>
-
#include <QVariant>
#include <QtCore/qdebug.h>
@@ -126,9 +124,6 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags)
{
Q_D(QDeclarativeBinding);
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QDeclarativePerfTimer<QDeclarativePerf::BindableValueUpdate> bu;
-#endif
QDeclarativeBindingData *data = d->bindingData();
if (!data->enabled)
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 2ea7bff..c1f2fe6 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -67,8 +67,6 @@
#include "qdeclarativecompiledbindings_p.h"
#include "qdeclarativeglobalscriptclass_p.h"
-#include <qfxperf_p_p.h>
-
#include <QCoreApplication>
#include <QColor>
#include <QDebug>
@@ -77,6 +75,7 @@
#include <QRectF>
#include <QAtomicInt>
#include <QtCore/qdebug.h>
+#include <QtCore/qdatetime.h>
QT_BEGIN_NAMESPACE
@@ -543,12 +542,9 @@ void QDeclarativeCompiler::reset(QDeclarativeCompiledData *data)
on a successful compiler.
*/
bool QDeclarativeCompiler::compile(QDeclarativeEngine *engine,
- QDeclarativeCompositeTypeData *unit,
- QDeclarativeCompiledData *out)
+ QDeclarativeCompositeTypeData *unit,
+ QDeclarativeCompiledData *out)
{
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QDeclarativePerfTimer<QDeclarativePerf::Compilation> pc;
-#endif
exceptions.clear();
Q_ASSERT(out);
@@ -637,6 +633,37 @@ void QDeclarativeCompiler::compileTree(Object *tree)
init.init.compiledBinding = output->indexForByteArray(compileState.compiledBindingData);
output->bytecode << init;
+ // Build global import scripts
+ QHash<QString, Object::ScriptBlock> importedScripts;
+ QStringList importedScriptIndexes;
+
+ for (int ii = 0; ii < unit->scripts.count(); ++ii) {
+ QString scriptCode = QString::fromUtf8(unit->scripts.at(ii).resource->data);
+ Object::ScriptBlock::Pragmas pragmas = QDeclarativeScriptParser::extractPragmas(scriptCode);
+
+ if (!scriptCode.isEmpty()) {
+ Object::ScriptBlock &scriptBlock = importedScripts[unit->scripts.at(ii).qualifier];
+
+ scriptBlock.codes.append(scriptCode);
+ scriptBlock.lineNumbers.append(1);
+ scriptBlock.files.append(unit->scripts.at(ii).resource->url);
+ scriptBlock.pragmas.append(pragmas);
+ }
+ }
+
+ for (QHash<QString, Object::ScriptBlock>::Iterator iter = importedScripts.begin();
+ iter != importedScripts.end(); ++iter) {
+
+ importedScriptIndexes.append(iter.key());
+
+ QDeclarativeInstruction import;
+ import.type = QDeclarativeInstruction::StoreImportedScript;
+ import.line = 0;
+ import.storeScript.value = output->scripts.count();
+ output->scripts << *iter;
+ output->bytecode << import;
+ }
+
genObject(tree);
QDeclarativeInstruction def;
@@ -645,7 +672,13 @@ void QDeclarativeCompiler::compileTree(Object *tree)
output->bytecode << def;
output->imports = unit->imports;
- output->importCache = output->imports.cache(engine);
+
+ output->importCache = new QDeclarativeTypeNameCache(engine);
+
+ for (int ii = 0; ii < importedScriptIndexes.count(); ++ii)
+ output->importCache->add(importedScriptIndexes.at(ii), ii);
+
+ output->imports.cache(output->importCache, engine);
Q_ASSERT(tree->metatype);
@@ -1157,6 +1190,8 @@ bool QDeclarativeCompiler::buildComponent(QDeclarativeParser::Object *obj,
bool QDeclarativeCompiler::buildScript(QDeclarativeParser::Object *obj, QDeclarativeParser::Object *script)
{
+ qWarning().nospace() << qPrintable(output->url.toString()) << ":" << obj->location.start.line << ":" << obj->location.start.column << ": Script blocks have been deprecated. Support will be removed entirely shortly.";
+
Object::ScriptBlock scriptBlock;
if (script->properties.count() == 1 &&
@@ -1188,6 +1223,7 @@ bool QDeclarativeCompiler::buildScript(QDeclarativeParser::Object *obj, QDeclara
scriptBlock.codes.append(scriptCode);
scriptBlock.files.append(sourceUrl);
scriptBlock.lineNumbers.append(lineNumber);
+ scriptBlock.pragmas.append(Object::ScriptBlock::None);
}
}
@@ -1230,6 +1266,7 @@ bool QDeclarativeCompiler::buildScript(QDeclarativeParser::Object *obj, QDeclara
scriptBlock.codes.append(scriptCode);
scriptBlock.files.append(sourceUrl);
scriptBlock.lineNumbers.append(lineNumber);
+ scriptBlock.pragmas.append(Object::ScriptBlock::None);
}
}
@@ -1331,7 +1368,6 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDecl
const BindingContext &ctxt)
{
Q_ASSERT(obj->metaObject());
- Q_ASSERT(!prop->isEmpty());
QByteArray name = prop->name;
Q_ASSERT(name.startsWith("on"));
@@ -1350,7 +1386,7 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDecl
} else {
if (prop->value || prop->values.count() != 1)
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Incorrectly specified signal"));
+ COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Incorrectly specified signal assignment"));
prop->index = sigIdx;
obj->addSignalProperty(prop);
@@ -2094,7 +2130,7 @@ bool QDeclarativeCompiler::buildPropertyOnAssignment(QDeclarativeParser::Propert
buildDynamicMeta(baseObj, ForceCreation);
v->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor;
} else {
- COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","\"%1\" cannot operate on \"%2\"").arg(QString::fromLatin1(v->object->typeName)).arg(QString::fromLatin1(prop->name.constData())));
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","\"%1\" cannot operate on \"%2\"").arg(QString::fromUtf8(v->object->typeName)).arg(QString::fromUtf8(prop->name)));
}
return true;
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index a280d7e..ec23458 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -54,8 +54,6 @@
#include "qdeclarativeglobal_p.h"
#include "qdeclarativescriptparser_p.h"
-#include <qfxperf_p_p.h>
-
#include <QStack>
#include <QStringList>
#include <QFileInfo>
@@ -511,6 +509,8 @@ QScriptValue QDeclarativeComponent::createObject()
return QScriptValue();
}
QObject* ret = create(ctxt);
+ if (!ret)
+ return QScriptValue();
QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(d->engine);
QDeclarativeDeclarativeData::get(ret, true)->setImplicitDestructible();
return priv->objectClass->newQObject(ret, QMetaType::QObjectStar);
@@ -612,6 +612,11 @@ QDeclarativeComponentPrivate::beginCreate(QDeclarativeContextData *context, cons
ctxt->isInternal = true;
ctxt->url = cc->url;
ctxt->imports = cc->importCache;
+
+ // Nested global imports
+ if (creationContext && start != -1)
+ ctxt->importedScripts = creationContext->importedScripts;
+
cc->importCache->addref();
ctxt->setParent(context);
diff --git a/src/declarative/qml/qdeclarativecomponent_p.h b/src/declarative/qml/qdeclarativecomponent_p.h
index 649fce5..b44aeef 100644
--- a/src/declarative/qml/qdeclarativecomponent_p.h
+++ b/src/declarative/qml/qdeclarativecomponent_p.h
@@ -116,7 +116,7 @@ public:
static void complete(QDeclarativeEnginePrivate *enginePriv, ConstructionState *state);
QDeclarativeEngine *engine;
- QDeclarativeContextData *creationContext;
+ QDeclarativeGuardedContextData creationContext;
void clear();
diff --git a/src/declarative/qml/qdeclarativecompositetypedata_p.h b/src/declarative/qml/qdeclarativecompositetypedata_p.h
index fb26af9..04d0c63 100644
--- a/src/declarative/qml/qdeclarativecompositetypedata_p.h
+++ b/src/declarative/qml/qdeclarativecompositetypedata_p.h
@@ -103,7 +103,16 @@ public:
QDeclarativeCompositeTypeData *unit;
};
+ struct ScriptReference
+ {
+ ScriptReference();
+
+ QString qualifier;
+ QDeclarativeCompositeTypeResource *resource;
+ };
+
QList<TypeReference> types;
+ QList<ScriptReference> scripts;
QList<QDeclarativeCompositeTypeResource *> resources;
// Add or remove p as a waiter. When the QDeclarativeCompositeTypeData becomes
diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
index 5014323..c59e5e2 100644
--- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp
+++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
@@ -126,6 +126,27 @@ QDeclarativeCompositeTypeData::toCompiledComponent(QDeclarativeEngine *engine)
{
if (status == Complete && !compiledComponent) {
+ // Build script imports
+ foreach (const QDeclarativeScriptParser::Import &import, data.imports()) {
+ if (import.type == QDeclarativeScriptParser::Import::Script) {
+ QString url = imports.baseUrl().resolved(QUrl(import.uri)).toString();
+
+ ScriptReference ref;
+ ref.qualifier = import.qualifier;
+
+ for (int ii = 0; ii < resources.count(); ++ii) {
+ if (resources.at(ii)->url == url) {
+ ref.resource = resources.at(ii);
+ break;
+ }
+ }
+
+ Q_ASSERT(ref.resource);
+
+ scripts << ref;
+ }
+ }
+
compiledComponent = new QDeclarativeCompiledData(engine);
compiledComponent->url = imports.baseUrl();
compiledComponent->name = compiledComponent->url.toString();
@@ -153,6 +174,11 @@ QDeclarativeCompositeTypeData::TypeReference::TypeReference()
{
}
+QDeclarativeCompositeTypeData::ScriptReference::ScriptReference()
+: resource(0)
+{
+}
+
QDeclarativeCompositeTypeManager::QDeclarativeCompositeTypeManager(QDeclarativeEngine *e)
: engine(e), redirectCount(0)
{
@@ -513,12 +539,18 @@ int QDeclarativeCompositeTypeManager::resolveTypes(QDeclarativeCompositeTypeData
foreach (QDeclarativeScriptParser::Import imp, unit->data.imports()) {
- QString qmldircontentnetwork;
+ QDeclarativeDirComponents qmldircomponentsnetwork;
+ if (imp.type == QDeclarativeScriptParser::Import::Script)
+ continue;
+
if (imp.type == QDeclarativeScriptParser::Import::File && imp.qualifier.isEmpty()) {
QString importUrl = unit->imports.baseUrl().resolved(QUrl(imp.uri + QLatin1String("/qmldir"))).toString();
for (int ii = 0; ii < unit->resources.count(); ++ii) {
if (unit->resources.at(ii)->url == importUrl) {
- qmldircontentnetwork = QString::fromUtf8(unit->resources.at(ii)->data);
+ QDeclarativeDirParser parser;
+ parser.setSource(QString::fromUtf8(unit->resources.at(ii)->data));
+ parser.parse();
+ qmldircomponentsnetwork = parser.components();
break;
}
}
@@ -538,12 +570,15 @@ int QDeclarativeCompositeTypeManager::resolveTypes(QDeclarativeCompositeTypeData
}
}
+ QString errorString;
if (!QDeclarativeEnginePrivate::get(engine)->
- addToImport(&unit->imports, qmldircontentnetwork, imp.uri, imp.qualifier, vmaj, vmin, imp.type))
+ addToImport(&unit->imports, qmldircomponentsnetwork, imp.uri, imp.qualifier, vmaj, vmin, imp.type, &errorString))
{
QDeclarativeError error;
error.setUrl(unit->imports.baseUrl());
- error.setDescription(tr("Import %1 unavailable").arg(imp.uri));
+ error.setDescription(errorString);
+ error.setLine(imp.location.start.line);
+ error.setColumn(imp.location.start.column);
unit->status = QDeclarativeCompositeTypeData::Error;
unit->errorType = QDeclarativeCompositeTypeData::GeneralError;
unit->errors << error;
@@ -558,18 +593,23 @@ int QDeclarativeCompositeTypeManager::resolveTypes(QDeclarativeCompositeTypeData
*/
{
- QString qmldircontentnetwork;
+ QDeclarativeDirComponents qmldircomponentsnetwork;
if (QDeclarativeCompositeTypeResource *resource
- = resources.value(unit->imports.baseUrl().resolved(QUrl(QLatin1String("./qmldir")))))
- qmldircontentnetwork = QString::fromUtf8(resource->data);
+ = resources.value(unit->imports.baseUrl().resolved(QUrl(QLatin1String("./qmldir"))))) {
+ QDeclarativeDirParser parser;
+ parser.setSource(QString::fromUtf8(resource->data));
+ parser.parse();
+ qmldircomponentsnetwork = parser.components();
+ }
QDeclarativeEnginePrivate::get(engine)->
addToImport(&unit->imports,
- qmldircontentnetwork,
+ qmldircomponentsnetwork,
QLatin1String("."),
QString(),
-1, -1,
- QDeclarativeScriptParser::Import::File);
+ QDeclarativeScriptParser::Import::File,
+ 0); // error ignored (just means no fallback)
}
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp
index 782c0d7..2b8cf70 100644
--- a/src/declarative/qml/qdeclarativecontext.cpp
+++ b/src/declarative/qml/qdeclarativecontext.cpp
@@ -606,6 +606,75 @@ void QDeclarativeContextData::addObject(QObject *o)
contextObjects = data;
}
+void QDeclarativeContextData::addImportedScript(const QDeclarativeParser::Object::ScriptBlock &script)
+{
+ if (!engine)
+ return;
+
+ Q_ASSERT(script.codes.count() == 1);
+
+ QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine);
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ const QString &code = script.codes.at(0);
+ const QString &url = script.files.at(0);
+ const QDeclarativeParser::Object::ScriptBlock::Pragmas &pragmas = script.pragmas.at(0);
+
+ Q_ASSERT(!url.isEmpty());
+
+ if (pragmas & QDeclarativeParser::Object::ScriptBlock::Shared) {
+
+ QHash<QString, QScriptValue>::Iterator iter = enginePriv->m_sharedScriptImports.find(url);
+ if (iter == enginePriv->m_sharedScriptImports.end()) {
+ QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
+
+ scriptContext->pushScope(enginePriv->globalClass->globalObject());
+
+ QScriptValue scope = scriptEngine->newObject();
+ scriptContext->setActivationObject(scope);
+ scriptContext->pushScope(scope);
+
+ scriptEngine->evaluate(code, url, 1);
+
+ if (scriptEngine->hasUncaughtException()) {
+ QDeclarativeError error;
+ QDeclarativeExpressionPrivate::exceptionToError(scriptEngine, error);
+ qWarning().nospace() << qPrintable(error.toString());
+ }
+
+ scriptEngine->popContext();
+
+ iter = enginePriv->m_sharedScriptImports.insert(url, scope);
+ }
+
+ importedScripts.append(*iter);
+
+ } else {
+
+ QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
+
+ scriptContext->pushScope(enginePriv->contextClass->newContext(this, 0));
+ scriptContext->pushScope(enginePriv->globalClass->globalObject());
+
+ QScriptValue scope = scriptEngine->newObject();
+ scriptContext->setActivationObject(scope);
+ scriptContext->pushScope(scope);
+
+ scriptEngine->evaluate(code, url, 1);
+
+ if (scriptEngine->hasUncaughtException()) {
+ QDeclarativeError error;
+ QDeclarativeExpressionPrivate::exceptionToError(scriptEngine, error);
+ qWarning().nospace() << qPrintable(error.toString());
+ }
+
+ scriptEngine->popContext();
+
+ importedScripts.append(scope);
+
+ }
+}
+
void QDeclarativeContextData::addScript(const QDeclarativeParser::Object::ScriptBlock &script,
QObject *scopeObject)
{
@@ -655,6 +724,21 @@ void QDeclarativeContextData::setIdPropertyData(QDeclarativeIntegerCache *data)
idValues = new ContextGuard[idValueCount];
}
+QString QDeclarativeContextData::findObjectId(const QObject *obj) const
+{
+ if (!idValues || !propertyNames)
+ return QString();
+
+ for (int i=0; i<idValueCount; i++) {
+ if (idValues[i] == obj)
+ return propertyNames->findId(i);
+ }
+
+ if (linkedContext)
+ return linkedContext->findObjectId(obj);
+ return QString();
+}
+
QDeclarativeContext *QDeclarativeContextData::asQDeclarativeContext()
{
if (!publicContext)
diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h
index d74aa33..397f37a 100644
--- a/src/declarative/qml/qdeclarativecontext_p.h
+++ b/src/declarative/qml/qdeclarativecontext_p.h
@@ -81,7 +81,7 @@ class QDeclarativeBinding_Id;
class QDeclarativeCompiledBindings;
class QDeclarativeContextData;
-class Q_DECLARATIVE_EXPORT QDeclarativeContextPrivate : public QObjectPrivate
+class QDeclarativeContextPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QDeclarativeContext)
public:
@@ -141,6 +141,8 @@ public:
// Any script blocks that exist on this context
QList<QScriptValue> scripts;
+ QList<QScriptValue> importedScripts;
+ void addImportedScript(const QDeclarativeParser::Object::ScriptBlock &script);
void addScript(const QDeclarativeParser::Object::ScriptBlock &script, QObject *scopeObject);
// Context base url
@@ -188,6 +190,8 @@ public:
// Linked contexts. this owns linkedContext.
QDeclarativeContextData *linkedContext;
+ QString findObjectId(const QObject *obj) const;
+
static QDeclarativeContextData *get(QDeclarativeContext *context) {
return QDeclarativeContextPrivate::get(context)->data;
}
@@ -209,8 +213,11 @@ public:
inline operator QDeclarativeContextData*() const { return m_contextData; }
inline QDeclarativeContextData* operator->() const { return m_contextData; }
+ inline QDeclarativeGuardedContextData &operator=(QDeclarativeContextData *d);
private:
+ QDeclarativeGuardedContextData &operator=(const QDeclarativeGuardedContextData &);
+ QDeclarativeGuardedContextData(const QDeclarativeGuardedContextData &);
friend class QDeclarativeContextData;
inline void clear();
@@ -265,6 +272,13 @@ void QDeclarativeGuardedContextData::clear()
}
}
+QDeclarativeGuardedContextData &
+QDeclarativeGuardedContextData::operator=(QDeclarativeContextData *d)
+{
+ setContextData(d);
+ return *this;
+}
+
QT_END_NAMESPACE
#endif // QDECLARATIVECONTEXT_P_H
diff --git a/src/declarative/qml/qdeclarativecontextscriptclass.cpp b/src/declarative/qml/qdeclarativecontextscriptclass.cpp
index 847d632..2559224 100644
--- a/src/declarative/qml/qdeclarativecontextscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativecontextscriptclass.cpp
@@ -240,10 +240,19 @@ QDeclarativeContextScriptClass::property(Object *object, const Identifier &name)
} else if (lastData) {
- if (lastData->type)
+ if (lastData->type) {
return Value(scriptEngine, ep->typeNameClass->newObject(bindContext->contextObject, lastData->type));
- else
- return Value(scriptEngine, ep->typeNameClass->newObject(bindContext->contextObject, lastData->typeNamespace));
+ } else if (lastData->typeNamespace) {
+ return Value(scriptEngine, ep->typeNameClass->newObject(bindContext->contextObject,
+ lastData->typeNamespace));
+ } else {
+ int index = lastData->importedScriptIndex;
+ if (index < bindContext->importedScripts.count()) {
+ return Value(scriptEngine, bindContext->importedScripts.at(index));
+ } else {
+ return Value();
+ }
+ }
} else if (lastPropertyIndex != -1) {
@@ -266,7 +275,6 @@ QDeclarativeContextScriptClass::property(Object *object, const Identifier &name)
ep->capturedProperties << QDeclarativeEnginePrivate::CapturedProperty(bindContext->asQDeclarativeContext(), -1, lastPropertyIndex + cp->notifyIndex);
}
-
return Value(scriptEngine, rv);
} else {
diff --git a/src/declarative/qml/qdeclarativedirparser.cpp b/src/declarative/qml/qdeclarativedirparser.cpp
index b6d2115..0e82098 100644
--- a/src/declarative/qml/qdeclarativedirparser.cpp
+++ b/src/declarative/qml/qdeclarativedirparser.cpp
@@ -151,6 +151,16 @@ bool QDeclarativeDirParser::parse()
_plugins.append(entry);
+ } else if (sections[0] == QLatin1String("internal")) {
+ if (sectionCount != 3) {
+ reportError(lineNumber, -1,
+ QString::fromUtf8("internal types require 2 arguments, but %1 were provided").arg(sectionCount + 1));
+ continue;
+ }
+ Component entry(sections[1], sections[2], -1, -1);
+ entry.internal = true;
+ _components.append(entry);
+
} else if (sectionCount == 2) {
// No version specified (should only be used for relative qmldir files)
const Component entry(sections[0], sections[1], -1, -1);
diff --git a/src/declarative/qml/qdeclarativedirparser_p.h b/src/declarative/qml/qdeclarativedirparser_p.h
index 5df7117..e4f4ce6 100644
--- a/src/declarative/qml/qdeclarativedirparser_p.h
+++ b/src/declarative/qml/qdeclarativedirparser_p.h
@@ -59,7 +59,6 @@
QT_BEGIN_NAMESPACE
class QDeclarativeError;
-
class QDeclarativeDirParser
{
Q_DISABLE_COPY(QDeclarativeDirParser)
@@ -94,15 +93,17 @@ public:
struct Component
{
Component()
- : majorVersion(0), minorVersion(0) {}
+ : majorVersion(0), minorVersion(0), internal(false) {}
Component(const QString &typeName, const QString &fileName, int majorVersion, int minorVersion)
- : typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion) {}
+ : typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion),
+ internal(false) {}
QString typeName;
QString fileName;
int majorVersion;
int minorVersion;
+ bool internal;
};
QList<Component> components() const;
@@ -120,6 +121,9 @@ private:
unsigned _isParsed: 1;
};
+typedef QList<QDeclarativeDirParser::Component> QDeclarativeDirComponents;
+
+
QT_END_NAMESPACE
#endif // QDECLARATIVEDIRPARSER_P_H
diff --git a/src/declarative/qml/qdeclarativedom.cpp b/src/declarative/qml/qdeclarativedom.cpp
index cb56ead..366750e 100644
--- a/src/declarative/qml/qdeclarativedom.cpp
+++ b/src/declarative/qml/qdeclarativedom.cpp
@@ -1107,8 +1107,7 @@ Rectangle {
x: NumberAnimation {
from: 0
to: 100
- repeat: true
- running: true
+ loops: Animation.Infinite
}
}
\endqml
@@ -1156,8 +1155,7 @@ Rectangle {
x: NumberAnimation {
from: 0
to: 100
- repeat: true
- running: true
+ loops: Animation.Infinite
}
}
\endqml
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 800434a..ddbe433 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -69,8 +69,6 @@
#include "qdeclarativelist_p.h"
#include "qdeclarativetypenamecache_p.h"
-#include <qfxperf_p_p.h>
-
#include <QtCore/qmetaobject.h>
#include <QScriptClass>
#include <QNetworkReply>
@@ -220,7 +218,6 @@ QDeclarativeScriptEngine::QDeclarativeScriptEngine(QDeclarativeEnginePrivate *pr
// XXX When the above a done some better way, that way should also be
// XXX used to add Qt.Sound class.
-
//types
qtObject.setProperty(QLatin1String("rgba"), newFunction(QDeclarativeEnginePrivate::rgba, 4));
qtObject.setProperty(QLatin1String("hsla"), newFunction(QDeclarativeEnginePrivate::hsla, 4));
@@ -1361,9 +1358,10 @@ struct QDeclarativeEnginePrivate::ImportedNamespace {
QList<int> majversions;
QList<int> minversions;
QList<bool> isLibrary;
- QList<QString> qmlDirContent;
+ QList<QDeclarativeDirComponents> qmlDirComponents;
- bool find(const QByteArray& type, int *vmajor, int *vminor, QDeclarativeType** type_return, QUrl* url_return)
+ bool find(const QByteArray& type, int *vmajor, int *vminor, QDeclarativeType** type_return, QUrl* url_return,
+ QUrl *base = 0)
{
for (int i=0; i<urls.count(); ++i) {
int vmaj = majversions.at(i);
@@ -1383,23 +1381,22 @@ struct QDeclarativeEnginePrivate::ImportedNamespace {
}
QUrl url = QUrl(urls.at(i) + QLatin1Char('/') + QString::fromUtf8(type) + QLatin1String(".qml"));
- QString qmldircontent = qmlDirContent.at(i);
+ QDeclarativeDirComponents qmldircomponents = qmlDirComponents.at(i);
bool typeWasDeclaredInQmldir = false;
- if (!qmldircontent.isEmpty()) {
+ if (!qmldircomponents.isEmpty()) {
const QString typeName = QString::fromUtf8(type);
-
- QDeclarativeDirParser qmldirParser;
- qmldirParser.setUrl(url);
- qmldirParser.setSource(qmldircontent);
- qmldirParser.parse();
-
- foreach (const QDeclarativeDirParser::Component &c, qmldirParser.components()) { // ### TODO: cache the components
+ foreach (const QDeclarativeDirParser::Component &c, qmldircomponents) {
if (c.typeName == typeName) {
typeWasDeclaredInQmldir = true;
if (c.majorVersion < vmaj || (c.majorVersion == vmaj && vmin >= c.minorVersion)) {
+ QUrl candidate = url.resolved(QUrl(c.fileName));
+ if (c.internal && base) {
+ if (base->resolved(QUrl(c.fileName)) != candidate)
+ continue; // failed attempt to access an internal type
+ }
if (url_return)
- *url_return = url.resolved(QUrl(c.fileName));
+ *url_return = candidate;
return true;
}
}
@@ -1420,6 +1417,11 @@ struct QDeclarativeEnginePrivate::ImportedNamespace {
}
};
+static bool greaterThan(const QString &s1, const QString &s2)
+{
+ return s1 > s2;
+}
+
class QDeclarativeImportsPrivate {
public:
QDeclarativeImportsPrivate() : ref(1)
@@ -1434,22 +1436,22 @@ public:
QSet<QString> qmlDirFilesForWhichPluginsHaveBeenLoaded;
- QString importExtension(const QString &absoluteFilePath, const QString &uri, QDeclarativeEngine *engine) {
+ QDeclarativeDirComponents importExtension(const QString &absoluteFilePath, const QString &uri, QDeclarativeEngine *engine) {
QFile file(absoluteFilePath);
QString dir = QFileInfo(file).path();
- QString qmldircontent;
+ QString filecontent;
if (file.open(QFile::ReadOnly)) {
- qmldircontent = QString::fromUtf8(file.readAll());
+ filecontent = QString::fromUtf8(file.readAll());
if (qmlImportTrace())
qDebug() << "QDeclarativeEngine::add: loaded" << absoluteFilePath;
}
+ QDeclarativeDirParser qmldirParser;
+ qmldirParser.setSource(filecontent);
+ qmldirParser.parse();
if (! qmlDirFilesForWhichPluginsHaveBeenLoaded.contains(absoluteFilePath)) {
qmlDirFilesForWhichPluginsHaveBeenLoaded.insert(absoluteFilePath);
- QDeclarativeDirParser qmldirParser;
- qmldirParser.setSource(qmldircontent);
- qmldirParser.parse();
foreach (const QDeclarativeDirParser::Plugin &plugin, qmldirParser.plugins()) {
QDir pluginDir(dir + QDir::separator() + plugin.path);
@@ -1465,7 +1467,7 @@ public:
}
}
}
- return qmldircontent;
+ return qmldirParser.components();
}
QString resolvedUri(const QString &dir_arg, QDeclarativeEngine *engine)
@@ -1497,6 +1499,8 @@ public:
// add fileImportPath last, this is *not* search order.
paths += QDeclarativeEnginePrivate::get(engine)->fileImportPath;
+ qSort(paths.begin(), paths.end(), greaterThan); // Ensure subdirs preceed their parents.
+
QString stableRelativePath = dir;
foreach( QString path, paths) {
if (dir.startsWith(path)) {
@@ -1512,9 +1516,9 @@ public:
- bool add(const QUrl& base, const QString &qmldircontentnetwork, const QString& uri_arg, const QString& prefix, int vmaj, int vmin, QDeclarativeScriptParser::Import::Type importType, QDeclarativeEngine *engine)
+ bool add(const QUrl& base, const QDeclarativeDirComponents &qmldircomponentsnetwork, const QString& uri_arg, const QString& prefix, int vmaj, int vmin, QDeclarativeScriptParser::Import::Type importType, QDeclarativeEngine *engine, QString *errorString)
{
- QString qmldircontent = qmldircontentnetwork;
+ QDeclarativeDirComponents qmldircomponents = qmldircomponentsnetwork;
QString uri = uri_arg;
QDeclarativeEnginePrivate::ImportedNamespace *s;
if (prefix.isEmpty()) {
@@ -1547,11 +1551,11 @@ public:
paths += applicationDirPath;
paths += QDeclarativeEnginePrivate::get(engine)->environmentImportPath;
- #if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
QString builtinPath = QLibraryInfo::location(QLibraryInfo::ImportsPath);
- #else
+#else
QString builtinPath;
- #endif
+#endif
if (!builtinPath.isEmpty())
paths += builtinPath;
@@ -1566,24 +1570,57 @@ public:
url = QUrl::fromLocalFile(fi.absolutePath()).toString();
uri = resolvedUri(dir, engine);
- qmldircontent = importExtension(absoluteFilePath, uri, engine);
+ qmldircomponents = importExtension(absoluteFilePath, uri, engine);
break;
}
}
+ if (!found) {
+ found = QDeclarativeMetaType::isModule(uri.toUtf8(), vmaj, vmin);
+ if (!found) {
+ if (errorString) {
+ bool anyversion = QDeclarativeMetaType::isModule(uri.toUtf8(), 0, 0);
+ if (anyversion)
+ *errorString = QDeclarativeEngine::tr("module \"%1\" version %2.%3 is not installed").arg(uri_arg).arg(vmaj).arg(vmin);
+ else
+ *errorString = QDeclarativeEngine::tr("module \"%1\" is not installed").arg(uri_arg);
+ }
+ return false;
+ }
+ }
} else {
- if (importType == QDeclarativeScriptParser::Import::File && qmldircontent.isEmpty()) {
+ if (importType == QDeclarativeScriptParser::Import::File && qmldircomponents.isEmpty()) {
QUrl importUrl = base.resolved(QUrl(uri + QLatin1String("/qmldir")));
QString localFileOrQrc = toLocalFileOrQrc(importUrl);
if (!localFileOrQrc.isEmpty()) {
+ QString dir = toLocalFileOrQrc(base.resolved(QUrl(uri)));
+ if (dir.isEmpty() || !QDir().exists(dir)) {
+ if (errorString)
+ *errorString = QDeclarativeEngine::tr("\"%1\": no such directory").arg(uri_arg);
+ return false; // local import dirs must exist
+ }
uri = resolvedUri(toLocalFileOrQrc(base.resolved(QUrl(uri))), engine);
- qmldircontent = importExtension(localFileOrQrc,
+ qmldircomponents = importExtension(localFileOrQrc,
uri,
engine);
if (uri.endsWith(QLatin1Char('/')))
uri.chop(1);
+ } else {
+ if (prefix.isEmpty()) {
+ // directory must at least exist for valid import
+ QString localFileOrQrc = toLocalFileOrQrc(base.resolved(QUrl(uri)));
+ if (localFileOrQrc.isEmpty() || !QDir().exists(localFileOrQrc)) {
+ if (errorString) {
+ if (localFileOrQrc.isEmpty())
+ *errorString = QDeclarativeEngine::tr("import \"%1\" has no qmldir and no namespace").arg(uri);
+ else
+ *errorString = QDeclarativeEngine::tr("\"%1\": no such directory").arg(uri);
+ }
+ return false;
+ }
+ }
}
}
@@ -1597,7 +1634,7 @@ public:
s->majversions.prepend(vmaj);
s->minversions.prepend(vmin);
s->isLibrary.prepend(importType == QDeclarativeScriptParser::Import::Library);
- s->qmlDirContent.prepend(qmldircontent);
+ s->qmlDirComponents.prepend(qmldircomponents);
return true;
}
@@ -1617,7 +1654,7 @@ public:
}
QByteArray unqualifiedtype = slash < 0 ? type : type.mid(slash+1); // common-case opt (QString::mid works fine, but slower)
if (s) {
- if (s->find(unqualifiedtype,vmajor,vminor,type_return,url_return))
+ if (s->find(unqualifiedtype,vmajor,vminor,type_return,url_return, &base))
return true;
if (s->urls.count() == 1 && !s->isLibrary[0] && url_return && s != &unqualifiedset) {
// qualified, and only 1 url
@@ -1627,16 +1664,7 @@ public:
}
-
- /* now comes really nasty code. It makes "private" types load in the remote case, but
- it does this by breaking the import order. This must go. Instead private types must
- be marked private in the qmldir. */
- if (url_return) {
- *url_return = base.resolved(QUrl(QString::fromUtf8(type + ".qml")));
- return true;
- } else {
- return false;
- }
+ return false;
}
QDeclarativeEnginePrivate::ImportedNamespace *findNamespace(const QString& type)
@@ -1706,12 +1734,10 @@ static QDeclarativeTypeNameCache *cacheForNamespace(QDeclarativeEngine *engine,
return cache;
}
-QDeclarativeTypeNameCache *QDeclarativeEnginePrivate::Imports::cache(QDeclarativeEngine *engine) const
+void QDeclarativeEnginePrivate::Imports::cache(QDeclarativeTypeNameCache *cache, QDeclarativeEngine *engine) const
{
const QDeclarativeEnginePrivate::ImportedNamespace &set = d->unqualifiedset;
- QDeclarativeTypeNameCache *cache = new QDeclarativeTypeNameCache(engine);
-
for (QHash<QString,QDeclarativeEnginePrivate::ImportedNamespace* >::ConstIterator iter = d->set.begin();
iter != d->set.end(); ++iter) {
@@ -1727,8 +1753,6 @@ QDeclarativeTypeNameCache *QDeclarativeEnginePrivate::Imports::cache(QDeclarativ
}
cacheForNamespace(engine, set, cache);
-
- return cache;
}
/*
@@ -1970,12 +1994,12 @@ QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString
The base URL must already have been set with Import::setBaseUrl().
*/
-bool QDeclarativeEnginePrivate::addToImport(Imports* imports, const QString &qmldircontentnetwork, const QString& uri, const QString& prefix, int vmaj, int vmin, QDeclarativeScriptParser::Import::Type importType) const
+bool QDeclarativeEnginePrivate::addToImport(Imports* imports, const QDeclarativeDirComponents &qmldircomponentsnetwork, const QString& uri, const QString& prefix, int vmaj, int vmin, QDeclarativeScriptParser::Import::Type importType, QString *errorString) const
{
QDeclarativeEngine *engine = QDeclarativeEnginePrivate::get(const_cast<QDeclarativeEnginePrivate *>(this));
if (qmlImportTrace())
qDebug().nospace() << "QDeclarativeEngine::addToImport " << imports << " " << uri << " " << vmaj << '.' << vmin << " " << (importType==QDeclarativeScriptParser::Import::Library? "Library" : "File") << " as " << prefix;
- bool ok = imports->d->add(imports->d->base,qmldircontentnetwork, uri,prefix,vmaj,vmin,importType, engine);
+ bool ok = imports->d->add(imports->d->base,qmldircomponentsnetwork, uri,prefix,vmaj,vmin,importType, engine, errorString);
return ok;
}
diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h
index f1b7b0e..06b5027 100644
--- a/src/declarative/qml/qdeclarativeengine_p.h
+++ b/src/declarative/qml/qdeclarativeengine_p.h
@@ -69,6 +69,7 @@
#include "qdeclarativecontextscriptclass_p.h"
#include "qdeclarativevaluetypescriptclass_p.h"
#include "qdeclarativemetatype_p.h"
+#include "qdeclarativedirparser_p.h"
#include <QtScript/QScriptClass>
#include <QtScript/QScriptValue>
@@ -263,7 +264,7 @@ public:
void setBaseUrl(const QUrl& url);
QUrl baseUrl() const;
- QDeclarativeTypeNameCache *cache(QDeclarativeEngine *) const;
+ void cache(QDeclarativeTypeNameCache *cache, QDeclarativeEngine *) const;
private:
friend class QDeclarativeEnginePrivate;
@@ -280,7 +281,10 @@ public:
QString resolvePlugin(const QDir &dir, const QString &baseName);
- bool addToImport(Imports*, const QString& uri, const QString &qmldircontentnetwork, const QString& prefix, int vmaj, int vmin, QDeclarativeScriptParser::Import::Type importType) const;
+ bool addToImport(Imports*, const QDeclarativeDirComponents &qmldircomponentsnetwork,
+ const QString& uri, const QString& prefix, int vmaj, int vmin,
+ QDeclarativeScriptParser::Import::Type importType,
+ QString *errorString) const;
bool resolveType(const Imports&, const QByteArray& type,
QDeclarativeType** type_return, QUrl* url_return,
int *version_major, int *version_minor,
@@ -302,6 +306,8 @@ public:
QHash<int, int> m_qmlLists;
QHash<int, QDeclarativeCompiledData *> m_compositeTypes;
+ QHash<QString, QScriptValue> m_sharedScriptImports;
+
QScriptValue scriptValueFromVariant(const QVariant &);
QVariant scriptValueToVariant(const QScriptValue &);
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp
index a377b35..d30aa8e 100644
--- a/src/declarative/qml/qdeclarativeenginedebug.cpp
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -68,16 +68,16 @@ QDeclarativeEngineDebugServer::QDeclarativeEngineDebugServer(QObject *parent)
QDataStream &operator<<(QDataStream &ds,
const QDeclarativeEngineDebugServer::QDeclarativeObjectData &data)
{
- ds << data.url << data.lineNumber << data.columnNumber << data.objectName
- << data.objectType << data.objectId << data.contextId;
+ ds << data.url << data.lineNumber << data.columnNumber << data.idString
+ << data.objectName << data.objectType << data.objectId << data.contextId;
return ds;
}
QDataStream &operator>>(QDataStream &ds,
QDeclarativeEngineDebugServer::QDeclarativeObjectData &data)
{
- ds >> data.url >> data.lineNumber >> data.columnNumber >> data.objectName
- >> data.objectType >> data.objectId >> data.contextId;
+ ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString
+ >> data.objectName >> data.objectType >> data.objectId >> data.contextId;
return ds;
}
@@ -275,6 +275,13 @@ QDeclarativeEngineDebugServer::objectData(QObject *object)
rv.columnNumber = -1;
}
+ QDeclarativeContext *context = qmlContext(object);
+ if (context) {
+ QDeclarativeContextData *cdata = QDeclarativeContextData::get(context);
+ if (cdata)
+ rv.idString = cdata->findObjectId(object);
+ }
+
rv.objectName = object->objectName();
rv.objectId = QDeclarativeDebugService::idForObject(object);
rv.contextId = QDeclarativeDebugService::idForObject(qmlContext(object));
diff --git a/src/declarative/qml/qdeclarativeenginedebug_p.h b/src/declarative/qml/qdeclarativeenginedebug_p.h
index a95449b..9491411 100644
--- a/src/declarative/qml/qdeclarativeenginedebug_p.h
+++ b/src/declarative/qml/qdeclarativeenginedebug_p.h
@@ -75,6 +75,7 @@ public:
QUrl url;
int lineNumber;
int columnNumber;
+ QString idString;
QString objectName;
QString objectType;
int objectId;
diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp
index 9eed345..b7ee3a4 100644
--- a/src/declarative/qml/qdeclarativeexpression.cpp
+++ b/src/declarative/qml/qdeclarativeexpression.cpp
@@ -353,10 +353,6 @@ void QDeclarativeExpressionPrivate::exceptionToError(QScriptEngine *scriptEngine
QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bool *isUndefined)
{
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QDeclarativePerfTimer<QDeclarativePerf::BindValueQt> perfqt;
-#endif
-
QDeclarativeExpressionData *data = this->data;
QDeclarativeEngine *engine = data->context()->engine;
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
@@ -466,10 +462,6 @@ QVariant QDeclarativeExpressionPrivate::value(QObject *secondaryScope, bool *isU
if (data->expression.isEmpty())
return rv;
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QDeclarativePerfTimer<QDeclarativePerf::BindValue> perf;
-#endif
-
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(q->engine());
QDeclarativeExpression *lastCurrentExpression = ep->currentExpression;
diff --git a/src/declarative/qml/qdeclarativeinstruction.cpp b/src/declarative/qml/qdeclarativeinstruction.cpp
index a23ff75..9083ab3 100644
--- a/src/declarative/qml/qdeclarativeinstruction.cpp
+++ b/src/declarative/qml/qdeclarativeinstruction.cpp
@@ -144,6 +144,9 @@ void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx)
case QDeclarativeInstruction::StoreScript:
qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_SCRIPT\t\t" << instr->storeScript.value;
break;
+ case QDeclarativeInstruction::StoreImportedScript:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_IMPORTED_SCRIPT\t" << instr->storeScript.value;
+ break;
case QDeclarativeInstruction::StoreScriptString:
qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_SCRIPT_STRING\t" << instr->storeScriptString.propertyIndex << "\t" << instr->storeScriptString.value << "\t" << instr->storeScriptString.scope;
break;
diff --git a/src/declarative/qml/qdeclarativeinstruction_p.h b/src/declarative/qml/qdeclarativeinstruction_p.h
index ec32b35..877179d 100644
--- a/src/declarative/qml/qdeclarativeinstruction_p.h
+++ b/src/declarative/qml/qdeclarativeinstruction_p.h
@@ -119,6 +119,7 @@ public:
StoreSignal, /* storeSignal */
StoreScript, /* storeScript */
+ StoreImportedScript, /* storeScript */
StoreScriptString, /* storeScriptString */
//
diff --git a/src/declarative/qml/qdeclarativeintegercache.cpp b/src/declarative/qml/qdeclarativeintegercache.cpp
index 8fa210f..be36471 100644
--- a/src/declarative/qml/qdeclarativeintegercache.cpp
+++ b/src/declarative/qml/qdeclarativeintegercache.cpp
@@ -64,6 +64,16 @@ void QDeclarativeIntegerCache::clear()
engine = 0;
}
+QString QDeclarativeIntegerCache::findId(int value) const
+{
+ for (StringCache::ConstIterator iter = stringCache.begin();
+ iter != stringCache.end(); ++iter) {
+ if (iter.value() && iter.value()->value == value)
+ return iter.key();
+ }
+ return QString();
+}
+
void QDeclarativeIntegerCache::add(const QString &id, int value)
{
Q_ASSERT(!stringCache.contains(id));
diff --git a/src/declarative/qml/qdeclarativeintegercache_p.h b/src/declarative/qml/qdeclarativeintegercache_p.h
index b57565e..5fb5a76 100644
--- a/src/declarative/qml/qdeclarativeintegercache_p.h
+++ b/src/declarative/qml/qdeclarativeintegercache_p.h
@@ -73,6 +73,7 @@ public:
inline int count() const;
void add(const QString &, int);
int value(const QString &);
+ QString findId(int value) const;
inline int value(const QScriptDeclarativeClass::Identifier &id) const;
protected:
diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp
index b32e575..c512d97 100644
--- a/src/declarative/qml/qdeclarativemetatype.cpp
+++ b/src/declarative/qml/qdeclarativemetatype.cpp
@@ -98,6 +98,13 @@ struct QDeclarativeMetaTypeData
typedef QHash<int, QDeclarativeMetaType::StringConverter> StringConverters;
StringConverters stringConverters;
+ struct ModuleInfo {
+ ModuleInfo(int maj, int min) : vmajor(maj), vminor(min) {}
+ int vmajor, vminor;
+ };
+ typedef QHash<QByteArray, ModuleInfo> ModuleInfoHash;
+ ModuleInfoHash modules;
+
QBitArray objects;
QBitArray interfaces;
QBitArray lists;
@@ -441,9 +448,30 @@ int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &t
data->objects.setBit(type.typeId, true);
if (type.listId) data->lists.setBit(type.listId, true);
+ if (type.uri) {
+ QByteArray mod(type.uri);
+ QDeclarativeMetaTypeData::ModuleInfoHash::Iterator it = data->modules.find(mod);
+ if (it == data->modules.end()
+ || ((*it).vmajor < type.versionMajor || ((*it).vmajor == type.versionMajor && (*it).vminor < type.versionMinor))) {
+ data->modules.insert(mod, QDeclarativeMetaTypeData::ModuleInfo(type.versionMajor,type.versionMinor));
+ }
+ }
+
return index;
}
+/*
+ Have any types been registered for \a module with at least versionMajor.versionMinor.
+*/
+bool QDeclarativeMetaType::isModule(const QByteArray &module, int versionMajor, int versionMinor)
+{
+ QDeclarativeMetaTypeData *data = metaTypeData();
+ QDeclarativeMetaTypeData::ModuleInfoHash::Iterator it = data->modules.find(module);
+ return it != data->modules.end()
+ && ((*it).vmajor > versionMajor ||
+ ((*it).vmajor == versionMajor && (*it).vminor >= versionMinor));
+}
+
QObject *QDeclarativeMetaType::toQObject(const QVariant &v, bool *ok)
{
if (!isQObject(v.userType())) {
diff --git a/src/declarative/qml/qdeclarativemetatype_p.h b/src/declarative/qml/qdeclarativemetatype_p.h
index d41323d..b3ec5e3 100644
--- a/src/declarative/qml/qdeclarativemetatype_p.h
+++ b/src/declarative/qml/qdeclarativemetatype_p.h
@@ -97,6 +97,8 @@ public:
typedef QVariant (*StringConverter)(const QString &);
static void registerCustomStringConverter(int, StringConverter);
static StringConverter customStringConverter(int);
+
+ static bool isModule(const QByteArray &module, int versionMajor, int versionMinor);
};
class QDeclarativeTypePrivate;
diff --git a/src/declarative/qml/qdeclarativeparser.cpp b/src/declarative/qml/qdeclarativeparser.cpp
index 51f1660..6e6080e 100644
--- a/src/declarative/qml/qdeclarativeparser.cpp
+++ b/src/declarative/qml/qdeclarativeparser.cpp
@@ -52,8 +52,6 @@
#include "parser/qdeclarativejsast_p.h"
#include "parser/qdeclarativejsengine_p.h"
-#include <qfxperf_p_p.h>
-
#include <QStack>
#include <QColor>
#include <QPointF>
diff --git a/src/declarative/qml/qdeclarativeparser_p.h b/src/declarative/qml/qdeclarativeparser_p.h
index 9dfb86b..476b027 100644
--- a/src/declarative/qml/qdeclarativeparser_p.h
+++ b/src/declarative/qml/qdeclarativeparser_p.h
@@ -179,9 +179,16 @@ namespace QDeclarativeParser
// Script blocks that were nested under this object
struct ScriptBlock {
+ enum Pragma {
+ None = 0x00000000,
+ Shared = 0x00000001
+ };
+ Q_DECLARE_FLAGS(Pragmas, Pragma)
+
QStringList codes;
QStringList files;
QList<int> lineNumbers;
+ QList<Pragmas> pragmas;
};
QList<ScriptBlock> scripts;
@@ -360,6 +367,8 @@ namespace QDeclarativeParser
};
}
+Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeParser::Object::ScriptBlock::Pragmas);
+
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QDeclarativeParser::Variant)
diff --git a/src/declarative/qml/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescriptparser.cpp
index fe516c5..49bd3b7 100644
--- a/src/declarative/qml/qdeclarativescriptparser.cpp
+++ b/src/declarative/qml/qdeclarativescriptparser.cpp
@@ -50,8 +50,6 @@
#include "parser/qdeclarativejsast_p.h"
#include "qdeclarativerewrite_p.h"
-#include <qfxperf_p_p.h>
-
#include <QStack>
#include <QCoreApplication>
#include <QtDebug>
@@ -443,8 +441,14 @@ bool ProcessAST::visit(AST::UiImport *node)
QDeclarativeScriptParser::Import import;
if (node->fileName) {
- import.type = QDeclarativeScriptParser::Import::File;
uri = node->fileName->asString();
+
+ if (uri.endsWith(QLatin1String(".js"))) {
+ import.type = QDeclarativeScriptParser::Import::Script;
+ _parser->_refUrls << QUrl(uri);
+ } else {
+ import.type = QDeclarativeScriptParser::Import::File;
+ }
} else {
import.type = QDeclarativeScriptParser::Import::Library;
uri = asString(node->importUri);
@@ -453,6 +457,7 @@ bool ProcessAST::visit(AST::UiImport *node)
AST::SourceLocation startLoc = node->importToken;
AST::SourceLocation endLoc = node->semicolonToken;
+ // Qualifier
if (node->importId) {
import.qualifier = node->importId->asString();
if (!import.qualifier.at(0).isUpper()) {
@@ -463,17 +468,43 @@ bool ProcessAST::visit(AST::UiImport *node)
_parser->_errors << error;
return false;
}
+
+ // Check for script qualifier clashes
+ bool isScript = import.type == QDeclarativeScriptParser::Import::Script;
+ for (int ii = 0; ii < _parser->_imports.count(); ++ii) {
+ const QDeclarativeScriptParser::Import &other = _parser->_imports.at(ii);
+ bool otherIsScript = other.type == QDeclarativeScriptParser::Import::Script;
+
+ if ((isScript || otherIsScript) && import.qualifier == other.qualifier) {
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","Script import qualifiers must be unique."));
+ error.setLine(node->importIdToken.startLine);
+ error.setColumn(node->importIdToken.startColumn);
+ _parser->_errors << error;
+ return false;
+ }
+ }
+
+ } else if (import.type == QDeclarativeScriptParser::Import::Script) {
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","Script import requires a qualifier"));
+ error.setLine(node->importIdToken.startLine);
+ error.setColumn(node->importIdToken.startColumn);
+ _parser->_errors << error;
+ return false;
}
- if (node->versionToken.isValid())
+
+ if (node->versionToken.isValid()) {
import.version = textAt(node->versionToken);
- else if (import.type == QDeclarativeScriptParser::Import::Library) {
+ } else if (import.type == QDeclarativeScriptParser::Import::Library) {
QDeclarativeError error;
error.setDescription(QCoreApplication::translate("QDeclarativeParser","Library import requires a version"));
error.setLine(node->importIdToken.startLine);
error.setColumn(node->importIdToken.startColumn);
_parser->_errors << error;
return false;
- }
+ }
+
import.location = location(startLoc, endLoc);
import.uri = uri;
@@ -866,9 +897,6 @@ public:
bool QDeclarativeScriptParser::parse(const QByteArray &qmldata, const QUrl &url)
{
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QDeclarativePerfTimer<QDeclarativePerf::QDeclarativeParsing> pt;
-#endif
clear();
const QString fileName = url.toString();
@@ -939,6 +967,95 @@ QList<QDeclarativeError> QDeclarativeScriptParser::errors() const
return _errors;
}
+/*
+Searches for ".pragma <value>" declarations within \a script. Currently supported pragmas
+are:
+ library
+*/
+QDeclarativeParser::Object::ScriptBlock::Pragmas QDeclarativeScriptParser::extractPragmas(QString &script)
+{
+ QDeclarativeParser::Object::ScriptBlock::Pragmas rv = QDeclarativeParser::Object::ScriptBlock::None;
+
+ const QChar forwardSlash(QLatin1Char('/'));
+ const QChar star(QLatin1Char('*'));
+ const QChar newline(QLatin1Char('\n'));
+ const QChar dot(QLatin1Char('.'));
+ const QChar semicolon(QLatin1Char(';'));
+ const QChar space(QLatin1Char(' '));
+ const QString pragma(QLatin1String(".pragma "));
+
+ const QChar *pragmaData = pragma.constData();
+
+ const QChar *data = script.constData();
+ const int length = script.count();
+ for (int ii = 0; ii < length; ++ii) {
+ const QChar &c = data[ii];
+
+ if (c.isSpace())
+ continue;
+
+ if (c == forwardSlash) {
+ ++ii;
+ if (ii >= length)
+ return rv;
+
+ const QChar &c = data[ii];
+ if (c == forwardSlash) {
+ // Find next newline
+ while (ii < length && data[++ii] != newline) {};
+ } else if (c == star) {
+ // Find next star
+ while (true) {
+ while (ii < length && data[++ii] != star) {};
+ if (ii + 1 >= length)
+ return rv;
+
+ if (data[ii + 1] == forwardSlash) {
+ ++ii;
+ break;
+ }
+ }
+ } else {
+ return rv;
+ }
+ } else if (c == dot) {
+ // Could be a pragma!
+ if (ii + pragma.length() >= length ||
+ 0 != ::memcmp(data + ii, pragmaData, sizeof(QChar) * pragma.length()))
+ return rv;
+
+ int pragmaStatementIdx = ii;
+
+ ii += pragma.length();
+
+ while (ii < length && data[ii].isSpace()) { ++ii; }
+
+ int startIdx = ii;
+
+ while (ii < length && data[ii].isLetter()) { ++ii; }
+
+ int endIdx = ii;
+
+ if (ii != length && data[ii] != forwardSlash && !data[ii].isSpace() && data[ii] != semicolon)
+ return rv;
+
+ QString p(data + startIdx, endIdx - startIdx);
+
+ if (p == QLatin1String("library"))
+ rv |= QDeclarativeParser::Object::ScriptBlock::Shared;
+ else
+ return rv;
+
+ for (int jj = pragmaStatementIdx; jj < endIdx; ++jj) script[jj] = space;
+
+ } else {
+ return rv;
+ }
+ }
+
+ return rv;
+}
+
void QDeclarativeScriptParser::clear()
{
if (root) {
diff --git a/src/declarative/qml/qdeclarativescriptparser_p.h b/src/declarative/qml/qdeclarativescriptparser_p.h
index b8f77d1..68f1840 100644
--- a/src/declarative/qml/qdeclarativescriptparser_p.h
+++ b/src/declarative/qml/qdeclarativescriptparser_p.h
@@ -75,7 +75,7 @@ public:
public:
Import() : type(Library) {}
- enum Type { Library, File };
+ enum Type { Library, File, Script };
Type type;
QString uri;
@@ -112,6 +112,8 @@ public:
QList<QDeclarativeError> errors() const;
+ static QDeclarativeParser::Object::ScriptBlock::Pragmas extractPragmas(QString &);
+
// ### private:
TypeReference *findOrCreateType(const QString &name);
void setTree(QDeclarativeParser::Object *tree);
diff --git a/src/declarative/qml/qdeclarativetypenamecache.cpp b/src/declarative/qml/qdeclarativetypenamecache.cpp
index f94f944..c4a8707 100644
--- a/src/declarative/qml/qdeclarativetypenamecache.cpp
+++ b/src/declarative/qml/qdeclarativetypenamecache.cpp
@@ -63,6 +63,21 @@ void QDeclarativeTypeNameCache::clear()
engine = 0;
}
+void QDeclarativeTypeNameCache::add(const QString &name, int importedScriptIndex)
+{
+ if (stringCache.contains(name))
+ return;
+
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+
+ RData *data = new RData;
+ // ### Use typename class
+ data->identifier = ep->objectClass->createPersistentIdentifier(name);
+ data->importedScriptIndex = importedScriptIndex;
+ stringCache.insert(name, data);
+ identifierCache.insert(data->identifier.identifier, data);
+}
+
void QDeclarativeTypeNameCache::add(const QString &name, QDeclarativeType *type)
{
if (stringCache.contains(name))
diff --git a/src/declarative/qml/qdeclarativetypenamecache_p.h b/src/declarative/qml/qdeclarativetypenamecache_p.h
index eee5b77..3e24f5c 100644
--- a/src/declarative/qml/qdeclarativetypenamecache_p.h
+++ b/src/declarative/qml/qdeclarativetypenamecache_p.h
@@ -73,8 +73,10 @@ public:
inline ~Data();
QDeclarativeType *type;
QDeclarativeTypeNameCache *typeNamespace;
+ int importedScriptIndex;
};
+ void add(const QString &, int);
void add(const QString &, QDeclarativeType *);
void add(const QString &, QDeclarativeTypeNameCache *);
@@ -97,7 +99,7 @@ private:
};
QDeclarativeTypeNameCache::Data::Data()
-: type(0), typeNamespace(0)
+: type(0), typeNamespace(0), importedScriptIndex(-1)
{
}
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index 4457404..2338bc3 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -61,8 +61,6 @@
#include "qdeclarativeglobal_p.h"
#include "qdeclarativescriptstring.h"
-#include <qfxperf_p_p.h>
-
#include <QStack>
#include <QWidget>
#include <QColor>
@@ -72,6 +70,7 @@
#include <QtCore/qdebug.h>
#include <QtCore/qvarlengtharray.h>
#include <QtCore/qcoreapplication.h>
+#include <QtCore/qdatetime.h>
QT_BEGIN_NAMESPACE
@@ -260,8 +259,9 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
case QDeclarativeInstruction::CreateComponent:
{
- QObject *qcomp = new QDeclarativeComponent(ctxt->engine, comp, ii + 1, instr.createComponent.count,
- stack.isEmpty() ? 0 : stack.top());
+ QDeclarativeComponent *qcomp =
+ new QDeclarativeComponent(ctxt->engine, comp, ii + 1, instr.createComponent.count,
+ stack.isEmpty() ? 0 : stack.top());
QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(qcomp, true);
Q_ASSERT(ddata);
@@ -276,6 +276,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
ddata->lineNumber = instr.line;
ddata->columnNumber = instr.create.column;
+ QDeclarativeComponentPrivate::get(qcomp)->creationContext = ctxt;
+
stack.push(qcomp);
ii += instr.createComponent.count;
}
@@ -582,6 +584,12 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
}
break;
+ case QDeclarativeInstruction::StoreImportedScript:
+ {
+ ctxt->addImportedScript(scripts.at(instr.storeScript.value));
+ }
+ break;
+
case QDeclarativeInstruction::StoreScriptString:
{
QObject *target = stack.top();
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index 10c0b54..a7ed358 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -201,11 +201,11 @@ QScriptValue QDeclarativeWorkerScriptEnginePrivate::sendMessage(QScriptContext *
if (!script)
return engine->undefinedValue();
- p->m_lock.lock();
+ QMutexLocker(&p->m_lock);
+
if (script->owner)
QCoreApplication::postEvent(script->owner,
new WorkerDataEvent(0, scriptValueToVariant(ctxt->argument(0))));
- p->m_lock.unlock();
return engine->undefinedValue();
}
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index d47dcc5..bad142c 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -190,9 +190,13 @@ void QDeclarativeAbstractAnimation::setRunning(bool r)
d->running = r;
if (d->running) {
- if (d->alwaysRunToEnd && d->repeat
+ if (d->alwaysRunToEnd && d->loopCount != 1
&& qtAnimation()->state() == QAbstractAnimation::Running) {
- qtAnimation()->setLoopCount(-1);
+ //we've restarted before the final loop finished; restore proper loop count
+ if (d->loopCount == -1)
+ qtAnimation()->setLoopCount(d->loopCount);
+ else
+ qtAnimation()->setLoopCount(qtAnimation()->currentLoop() + d->loopCount);
}
if (!d->connectedTimeLine) {
@@ -204,8 +208,8 @@ void QDeclarativeAbstractAnimation::setRunning(bool r)
emit started();
} else {
if (d->alwaysRunToEnd) {
- if (d->repeat)
- qtAnimation()->setLoopCount(qtAnimation()->currentLoop()+1);
+ if (d->loopCount != 1)
+ qtAnimation()->setLoopCount(qtAnimation()->currentLoop()+1); //finish the current loop
} else
qtAnimation()->stop();
@@ -300,10 +304,12 @@ void QDeclarativeAbstractAnimation::setAlwaysRunToEnd(bool f)
}
/*!
- \qmlproperty bool Animation::repeat
- This property holds whether the animation should repeat.
+ \qmlproperty int Animation::loops
+ This property holds the number of times the animation should play.
+
+ By default, \c loops is 1: the animation will play through once and then stop.
- If set, the animation will continuously repeat until it is explicitly
+ If set to Animation.Infinite, the animation will continuously repeat until it is explicitly
stopped - either by setting the \c running property to false, or by calling
the \c stop() method.
@@ -311,28 +317,36 @@ void QDeclarativeAbstractAnimation::setAlwaysRunToEnd(bool f)
\code
Rectangle {
- NumberAnimation on rotation { running: true; repeat: true; from: 0 to: 360 }
+ width: 100; height: 100; color: "green"
+ RotationAnimation on rotation {
+ loops: Animation.Infinite
+ from: 0
+ to: 360
+ }
}
\endcode
*/
-bool QDeclarativeAbstractAnimation::repeat() const
+int QDeclarativeAbstractAnimation::loops() const
{
Q_D(const QDeclarativeAbstractAnimation);
- return d->repeat;
+ return d->loopCount;
}
-void QDeclarativeAbstractAnimation::setRepeat(bool r)
+void QDeclarativeAbstractAnimation::setLoops(int loops)
{
Q_D(QDeclarativeAbstractAnimation);
- if (r == d->repeat)
+ if (loops < 0)
+ loops = -1;
+
+ if (loops == d->loopCount)
return;
- d->repeat = r;
- int lc = r ? -1 : 1;
- qtAnimation()->setLoopCount(lc);
- emit repeatChanged(r);
+ d->loopCount = loops;
+ qtAnimation()->setLoopCount(loops);
+ emit loopCountChanged(loops);
}
+
int QDeclarativeAbstractAnimation::currentTime()
{
return qtAnimation()->currentLoopTime();
@@ -509,8 +523,9 @@ void QDeclarativeAbstractAnimation::timelineComplete()
{
Q_D(QDeclarativeAbstractAnimation);
setRunning(false);
- if (d->alwaysRunToEnd && d->repeat) {
- qtAnimation()->setLoopCount(-1);
+ if (d->alwaysRunToEnd && d->loopCount != 1) {
+ //restore the proper loopCount for the next run
+ qtAnimation()->setLoopCount(d->loopCount);
}
}
@@ -658,6 +673,37 @@ void QDeclarativeColorAnimation::setTo(const QColor &t)
\inherits Animation
\brief The ScriptAction element allows scripts to be run during an animation.
+ ScriptAction can be used to run script at a specific point in an animation.
+
+ \qml
+ SequentialAnimation {
+ NumberAnimation { ... }
+ ScriptAction { script: doSomething(); }
+ NumberAnimation { ... }
+ }
+ \endqml
+
+ When used as part of a Transition, you can also target a specific
+ StateChangeScript to run using the \c scriptName property.
+
+ \qml
+ State {
+ StateChangeScript {
+ name: "myScript"
+ script: doStateStuff();
+ }
+ }
+ ...
+ Transition {
+ SequentialAnimation {
+ NumberAnimation { ... }
+ ScriptAction { scriptName: "myScript" }
+ NumberAnimation { ... }
+ }
+ }
+ \endqml
+
+ \sa StateChangeScript
*/
/*!
\internal
@@ -698,11 +744,14 @@ void QDeclarativeScriptAction::setScript(const QDeclarativeScriptString &script)
}
/*!
- \qmlproperty QString ScriptAction::stateChangeScriptName
+ \qmlproperty QString ScriptAction::scriptName
This property holds the the name of the StateChangeScript to run.
This property is only valid when ScriptAction is used as part of a transition.
- If both script and stateChangeScriptName are set, stateChangeScriptName will be used.
+ If both script and scriptName are set, scriptName will be used.
+
+ \note When using scriptName in a reversible transition, the script will only
+ be run when the transition is being run forwards.
*/
QString QDeclarativeScriptAction::stateChangeScriptName() const
{
@@ -718,6 +767,9 @@ void QDeclarativeScriptAction::setStateChangeScriptName(const QString &name)
void QDeclarativeScriptActionPrivate::execute()
{
+ if (hasRunScriptScript && reversing)
+ return;
+
QDeclarativeScriptString scriptStr = hasRunScriptScript ? runScriptScript : script;
const QString &str = scriptStr.script();
@@ -733,19 +785,18 @@ void QDeclarativeScriptAction::transition(QDeclarativeStateActions &actions,
{
Q_D(QDeclarativeScriptAction);
Q_UNUSED(modified);
- Q_UNUSED(direction);
d->hasRunScriptScript = false;
+ d->reversing = (direction == Backward);
for (int ii = 0; ii < actions.count(); ++ii) {
QDeclarativeAction &action = actions[ii];
if (action.event && action.event->typeName() == QLatin1String("StateChangeScript")
&& static_cast<QDeclarativeStateChangeScript*>(action.event)->name() == d->name) {
- //### how should we handle reverse direction?
d->runScriptScript = static_cast<QDeclarativeStateChangeScript*>(action.event)->script();
d->hasRunScriptScript = true;
action.actionDone = true;
- break; //assumes names are unique
+ break; //only match one (names should be unique)
}
}
}
@@ -1006,212 +1057,6 @@ void QDeclarativePropertyAction::transition(QDeclarativeStateActions &actions,
}
}
-
-
-/*!
- \qmlclass ParentAction QDeclarativeParentAction
- \since 4.7
- \inherits Animation
- \brief The ParentAction element allows parent changes during animation.
-
- ParentAction provides a way to specify at what point in a Transition a ParentChange should
- occur.
- \qml
- State {
- ParentChange {
- target: myItem
- parent: newParent
- }
- }
- Transition {
- SequentialAnimation {
- PropertyAnimation { ... }
- ParentAction {} //reparent myItem now
- PropertyAnimation { ... }
- }
- }
- \endqml
-
- It also provides a way to explicitly reparent an item during an animation.
- \qml
- SequentialAnimation {
- ParentAction { target: myItem; parent: newParent }
- PropertyAnimation {}
- }
- \endqml
-
- The ParentAction is immediate - it is not animated in any way.
-*/
-
-QDeclarativeParentAction::QDeclarativeParentAction(QObject *parent)
-: QDeclarativeAbstractAnimation(*(new QDeclarativeParentActionPrivate), parent)
-{
- Q_D(QDeclarativeParentAction);
- d->init();
-}
-
-QDeclarativeParentAction::~QDeclarativeParentAction()
-{
-}
-
-void QDeclarativeParentActionPrivate::init()
-{
- Q_Q(QDeclarativeParentAction);
- cpa = new QActionAnimation;
- QDeclarative_setParent_noEvent(cpa, q);
-}
-
-/*!
- \qmlproperty Item ParentAction::target
-
- This property holds a target item to reparent.
-
- In the following example, \c myItem will be reparented by the ParentAction, while
- \c myOtherItem will not.
- \qml
- State {
- ParentChange {
- target: myItem
- parent: newParent
- }
- ParentChange {
- target: myOtherItem
- parent: otherNewParent
- }
- }
- Transition {
- SequentialAnimation {
- PropertyAnimation { ... }
- ParentAction { target: myItem }
- PropertyAnimation { ... }
- }
- }
- \endqml
-
- */
-QDeclarativeItem *QDeclarativeParentAction::object() const
-{
- Q_D(const QDeclarativeParentAction);
- return d->pcTarget;
-}
-
-void QDeclarativeParentAction::setObject(QDeclarativeItem *target)
-{
- Q_D(QDeclarativeParentAction);
- d->pcTarget = target;
-}
-
-/*!
- \qmlproperty Item ParentAction::parent
-
- The item to reparent to (i.e. the new parent).
- */
-QDeclarativeItem *QDeclarativeParentAction::parent() const
-{
- Q_D(const QDeclarativeParentAction);
- return d->pcParent;
-}
-
-void QDeclarativeParentAction::setParent(QDeclarativeItem *parent)
-{
- Q_D(QDeclarativeParentAction);
- d->pcParent = parent;
-}
-
-void QDeclarativeParentActionPrivate::doAction()
-{
- QDeclarativeParentChange pc;
- pc.setObject(pcTarget);
- pc.setParent(pcParent);
- pc.execute();
-}
-
-QAbstractAnimation *QDeclarativeParentAction::qtAnimation()
-{
- Q_D(QDeclarativeParentAction);
- return d->cpa;
-}
-
-void QDeclarativeParentAction::transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction)
-{
- Q_D(QDeclarativeParentAction);
- Q_UNUSED(modified);
- Q_UNUSED(direction);
-
- struct QDeclarativeParentActionData : public QAbstractAnimationAction
- {
- QDeclarativeParentActionData(): pc(0) {}
- ~QDeclarativeParentActionData() { delete pc; }
-
- QDeclarativeStateActions actions;
- bool reverse;
- QDeclarativeParentChange *pc;
- virtual void doAction()
- {
- for (int ii = 0; ii < actions.count(); ++ii) {
- const QDeclarativeAction &action = actions.at(ii);
- if (reverse)
- action.event->reverse();
- else
- action.event->execute();
- }
- }
- };
-
- QDeclarativeParentActionData *data = new QDeclarativeParentActionData;
-
- //### need to correctly handle modified/done
-
- bool hasExplicit = false;
- if (d->pcTarget && d->pcParent) {
- data->reverse = false;
- QDeclarativeAction myAction;
- QDeclarativeParentChange *pc = new QDeclarativeParentChange;
- pc->setObject(d->pcTarget);
- pc->setParent(d->pcParent);
- myAction.event = pc;
- data->pc = pc;
- data->actions << myAction;
- hasExplicit = true;
- }
-
- if (!hasExplicit)
- for (int ii = 0; ii < actions.count(); ++ii) {
- QDeclarativeAction &action = actions[ii];
-
- if (action.event && action.event->typeName() == QLatin1String("ParentChange")
- && (!d->pcTarget || static_cast<QDeclarativeParentChange*>(action.event)->object() == d->pcTarget)) {
- QDeclarativeAction myAction = action;
- data->reverse = action.reverseEvent;
- //### this logic differs from PropertyAnimation
- // (probably a result of modified vs. done)
- if (d->pcParent) {
- //### should we disallow this case?
- QDeclarativeParentChange *pc = new QDeclarativeParentChange;
- pc->setObject(d->pcTarget);
- pc->setParent(static_cast<QDeclarativeParentChange*>(action.event)->parent());
- myAction.event = pc;
- data->pc = pc;
- data->actions << myAction;
- break; //only match one
- } else {
- action.actionDone = true;
- data->actions << myAction;
- }
- }
- }
-
- if (data->actions.count()) {
- d->cpa->setAnimAction(data, QAbstractAnimation::DeleteWhenStopped);
- } else {
- delete data;
- }
-}
-
-
-
/*!
\qmlclass NumberAnimation QDeclarativeNumberAnimation
\since 4.7
@@ -1342,9 +1187,10 @@ void QDeclarativeVector3dAnimation::setTo(QVector3D t)
\brief The RotationAnimation element allows you to animate rotations.
RotationAnimation is a specialized PropertyAnimation that gives control
- over the direction of rotation. By default, it will rotate
- via the shortest path; for example, a rotation from 20 to 340 degrees will
- rotation 40 degrees counterclockwise.
+ over the direction of rotation. By default, it will rotate in the direction
+ of the numerical change; a rotation from 0 to 240 will rotate 220 degrees
+ clockwise, while a rotation from 240 to 0 will rotate 220 degrees
+ counterclockwise.
When used in a transition RotationAnimation will rotate all
properties named "rotation" or "angle". You can override this by providing
@@ -1359,7 +1205,7 @@ void QDeclarativeVector3dAnimation::setTo(QVector3D t)
State { name: "-90"; PropertyChanges { target: myItem; rotation: -90 } }
}
transition: Transition {
- RotationAnimation { }
+ RotationAnimation { direction: RotationAnimation.Shortest }
}
\endqml
*/
@@ -1411,7 +1257,7 @@ QDeclarativeRotationAnimation::QDeclarativeRotationAnimation(QObject *parent)
{
Q_D(QDeclarativeRotationAnimation);
d->interpolatorType = QMetaType::QReal;
- d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateShortestRotation);
+ d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
d->defaultProperties = QLatin1String("rotation,angle");
}
@@ -1474,7 +1320,7 @@ void QDeclarativeRotationAnimation::setTo(qreal t)
A rotation from 10 to 350 will rotate 20 degrees counterclockwise.
\endtable
- The default direction is Shortest.
+ The default direction is Numerical.
*/
QDeclarativeRotationAnimation::RotationDirection QDeclarativeRotationAnimation::direction() const
{
@@ -1523,8 +1369,8 @@ void QDeclarativeAnimationGroupPrivate::append_animation(QDeclarativeListPropert
{
QDeclarativeAnimationGroup *q = qobject_cast<QDeclarativeAnimationGroup *>(list->object);
if (q) {
- q->d_func()->animations.append(a);
a->setGroup(q);
+ QDeclarative_setParent_noEvent(a->qtAnimation(), q->d_func()->ag);
q->d_func()->ag->addAnimation(a->qtAnimation());
}
}
@@ -1755,7 +1601,7 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int
\qml
Rectangle {
SequentialAnimation on x {
- repeat: true
+ loops: Animation.Infinite
PropertyAnimation { to: 50 }
PropertyAnimation { to: 0 }
}
@@ -2164,7 +2010,7 @@ void QDeclarativePropertyAnimation::setProperties(const QString &prop)
id: theRect
width: 100; height: 100
color: Qt.rgba(0,0,1)
- NumberAnimation on x { to: 500; repeat: true } //animate theRect's x property
+ NumberAnimation on x { to: 500; loops: Animation.Infinite } //animate theRect's x property
Behavior on y { NumberAnimation {} } //animate theRect's y property
}
\endqml
@@ -2483,7 +2329,11 @@ QDeclarativeItem *QDeclarativeParentAnimation::target() const
void QDeclarativeParentAnimation::setTarget(QDeclarativeItem *target)
{
Q_D(QDeclarativeParentAnimation);
+ if (target == d->target)
+ return;
+
d->target = target;
+ emit targetChanged();
}
/*!
@@ -2501,7 +2351,11 @@ QDeclarativeItem *QDeclarativeParentAnimation::newParent() const
void QDeclarativeParentAnimation::setNewParent(QDeclarativeItem *newParent)
{
Q_D(QDeclarativeParentAnimation);
+ if (newParent == d->newParent)
+ return;
+
d->newParent = newParent;
+ emit newParentChanged();
}
/*!
@@ -2526,7 +2380,11 @@ QDeclarativeItem *QDeclarativeParentAnimation::via() const
void QDeclarativeParentAnimation::setVia(QDeclarativeItem *via)
{
Q_D(QDeclarativeParentAnimation);
+ if (via == d->via)
+ return;
+
d->via = via;
+ emit viaChanged();
}
//### mirrors same-named function in QDeclarativeItem
@@ -2561,10 +2419,10 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions,
{
Q_D(QDeclarativeParentAnimation);
- struct QDeclarativeParentActionData : public QAbstractAnimationAction
+ struct QDeclarativeParentAnimationData : public QAbstractAnimationAction
{
- QDeclarativeParentActionData() {}
- ~QDeclarativeParentActionData() { qDeleteAll(pc); }
+ QDeclarativeParentAnimationData() {}
+ ~QDeclarativeParentAnimationData() { qDeleteAll(pc); }
QDeclarativeStateActions actions;
//### reverse should probably apply on a per-action basis
@@ -2582,8 +2440,8 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions,
}
};
- QDeclarativeParentActionData *data = new QDeclarativeParentActionData;
- QDeclarativeParentActionData *viaData = new QDeclarativeParentActionData;
+ QDeclarativeParentAnimationData *data = new QDeclarativeParentAnimationData;
+ QDeclarativeParentAnimationData *viaData = new QDeclarativeParentAnimationData;
bool hasExplicit = false;
if (d->target && d->newParent) {
diff --git a/src/declarative/util/qdeclarativeanimation_p.h b/src/declarative/util/qdeclarativeanimation_p.h
index eb339f6..816520e 100644
--- a/src/declarative/util/qdeclarativeanimation_p.h
+++ b/src/declarative/util/qdeclarativeanimation_p.h
@@ -70,24 +70,28 @@ class Q_AUTOTEST_EXPORT QDeclarativeAbstractAnimation : public QObject, public Q
Q_INTERFACES(QDeclarativeParserStatus)
Q_INTERFACES(QDeclarativePropertyValueSource)
+ Q_ENUMS(Loops)
Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
- Q_PROPERTY(bool alwaysRunToEnd READ alwaysRunToEnd WRITE setAlwaysRunToEnd NOTIFY alwaysRunToEndChanged())
- Q_PROPERTY(bool repeat READ repeat WRITE setRepeat NOTIFY repeatChanged)
+ Q_PROPERTY(bool alwaysRunToEnd READ alwaysRunToEnd WRITE setAlwaysRunToEnd NOTIFY alwaysRunToEndChanged)
+ Q_PROPERTY(int loops READ loops WRITE setLoops NOTIFY loopsChanged)
Q_CLASSINFO("DefaultMethod", "start()")
public:
QDeclarativeAbstractAnimation(QObject *parent=0);
virtual ~QDeclarativeAbstractAnimation();
+ enum Loops { Infinite = -2 };
+
bool isRunning() const;
void setRunning(bool);
bool isPaused() const;
void setPaused(bool);
bool alwaysRunToEnd() const;
void setAlwaysRunToEnd(bool);
- bool repeat() const;
- void setRepeat(bool);
+
+ int loops() const;
+ void setLoops(int);
int currentTime();
void setCurrentTime(int);
@@ -106,8 +110,8 @@ Q_SIGNALS:
void completed();
void runningChanged(bool);
void pausedChanged(bool);
- void repeatChanged(bool);
void alwaysRunToEndChanged(bool);
+ void loopCountChanged(int);
public Q_SLOTS:
void restart();
@@ -163,7 +167,7 @@ class QDeclarativeScriptAction : public QDeclarativeAbstractAnimation
Q_DECLARE_PRIVATE(QDeclarativeScriptAction)
Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript)
- Q_PROPERTY(QString stateChangeScriptName READ stateChangeScriptName WRITE setStateChangeScriptName)
+ Q_PROPERTY(QString scriptName READ stateChangeScriptName WRITE setStateChangeScriptName)
public:
QDeclarativeScriptAction(QObject *parent=0);
@@ -227,32 +231,6 @@ protected:
};
class QDeclarativeItem;
-class QDeclarativeParentActionPrivate;
-class QDeclarativeParentAction : public QDeclarativeAbstractAnimation
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDeclarativeParentAction)
-
- Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject)
- Q_PROPERTY(QDeclarativeItem *parent READ parent WRITE setParent) //### newParent
-
-public:
- QDeclarativeParentAction(QObject *parent=0);
- virtual ~QDeclarativeParentAction();
-
- QDeclarativeItem *object() const;
- void setObject(QDeclarativeItem *);
-
- QDeclarativeItem *parent() const;
- void setParent(QDeclarativeItem *);
-
-protected:
- virtual void transition(QDeclarativeStateActions &actions,
- QDeclarativeProperties &modified,
- TransitionDirection direction);
- virtual QAbstractAnimation *qtAnimation();
-};
-
class QDeclarativePropertyAnimationPrivate;
class Q_AUTOTEST_EXPORT QDeclarativePropertyAnimation : public QDeclarativeAbstractAnimation
{
@@ -456,9 +434,9 @@ class QDeclarativeParentAnimation : public QDeclarativeAnimationGroup
Q_OBJECT
Q_DECLARE_PRIVATE(QDeclarativeParentAnimation)
- Q_PROPERTY(QDeclarativeItem *target READ target WRITE setTarget)
- Q_PROPERTY(QDeclarativeItem *newParent READ newParent WRITE setNewParent)
- Q_PROPERTY(QDeclarativeItem *via READ via WRITE setVia)
+ Q_PROPERTY(QDeclarativeItem *target READ target WRITE setTarget NOTIFY targetChanged)
+ Q_PROPERTY(QDeclarativeItem *newParent READ newParent WRITE setNewParent NOTIFY newParentChanged)
+ Q_PROPERTY(QDeclarativeItem *via READ via WRITE setVia NOTIFY viaChanged)
public:
QDeclarativeParentAnimation(QObject *parent=0);
@@ -473,6 +451,11 @@ public:
QDeclarativeItem *via() const;
void setVia(QDeclarativeItem *);
+Q_SIGNALS:
+ void targetChanged();
+ void newParentChanged();
+ void viaChanged();
+
protected:
virtual void transition(QDeclarativeStateActions &actions,
QDeclarativeProperties &modified,
@@ -506,7 +489,6 @@ QML_DECLARE_TYPE(QDeclarativeAbstractAnimation)
QML_DECLARE_TYPE(QDeclarativePauseAnimation)
QML_DECLARE_TYPE(QDeclarativeScriptAction)
QML_DECLARE_TYPE(QDeclarativePropertyAction)
-QML_DECLARE_TYPE(QDeclarativeParentAction)
QML_DECLARE_TYPE(QDeclarativePropertyAnimation)
QML_DECLARE_TYPE(QDeclarativeColorAnimation)
QML_DECLARE_TYPE(QDeclarativeNumberAnimation)
diff --git a/src/declarative/util/qdeclarativeanimation_p_p.h b/src/declarative/util/qdeclarativeanimation_p_p.h
index 0460312..3908e50 100644
--- a/src/declarative/util/qdeclarativeanimation_p_p.h
+++ b/src/declarative/util/qdeclarativeanimation_p_p.h
@@ -225,19 +225,21 @@ class QDeclarativeAbstractAnimationPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QDeclarativeAbstractAnimation)
public:
QDeclarativeAbstractAnimationPrivate()
- : running(false), paused(false), alwaysRunToEnd(false), repeat(false),
+ : running(false), paused(false), alwaysRunToEnd(false),
connectedTimeLine(false), componentComplete(true),
- avoidPropertyValueSourceStart(false), disableUserControl(false), group(0) {}
+ avoidPropertyValueSourceStart(false), disableUserControl(false),
+ loopCount(1), group(0) {}
bool running:1;
bool paused:1;
bool alwaysRunToEnd:1;
- bool repeat:1;
bool connectedTimeLine:1;
bool componentComplete:1;
bool avoidPropertyValueSourceStart:1;
bool disableUserControl:1;
+ int loopCount;
+
void commence();
QDeclarativeProperty defaultProperty;
@@ -264,7 +266,7 @@ class QDeclarativeScriptActionPrivate : public QDeclarativeAbstractAnimationPriv
Q_DECLARE_PUBLIC(QDeclarativeScriptAction)
public:
QDeclarativeScriptActionPrivate()
- : QDeclarativeAbstractAnimationPrivate(), hasRunScriptScript(false), proxy(this), rsa(0) {}
+ : QDeclarativeAbstractAnimationPrivate(), hasRunScriptScript(false), reversing(false), proxy(this), rsa(0) {}
void init();
@@ -272,6 +274,7 @@ public:
QString name;
QDeclarativeScriptString runScriptScript;
bool hasRunScriptScript;
+ bool reversing;
void execute();
@@ -300,22 +303,6 @@ public:
QActionAnimation *spa;
};
-class QDeclarativeParentActionPrivate : public QDeclarativeAbstractAnimationPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeParentAction)
-public:
- QDeclarativeParentActionPrivate()
- : QDeclarativeAbstractAnimationPrivate(), pcTarget(0), pcParent(0) {}
-
- void init();
-
- QDeclarativeItem *pcTarget;
- QDeclarativeItem *pcParent;
-
- void doAction();
- QActionAnimation *cpa;
-};
-
class QDeclarativeAnimationGroupPrivate : public QDeclarativeAbstractAnimationPrivate
{
Q_DECLARE_PUBLIC(QDeclarativeAnimationGroup)
@@ -369,7 +356,7 @@ class QDeclarativeRotationAnimationPrivate : public QDeclarativePropertyAnimatio
{
Q_DECLARE_PUBLIC(QDeclarativeRotationAnimation)
public:
- QDeclarativeRotationAnimationPrivate() : direction(QDeclarativeRotationAnimation::Shortest) {}
+ QDeclarativeRotationAnimationPrivate() : direction(QDeclarativeRotationAnimation::Numerical) {}
QDeclarativeRotationAnimation::RotationDirection direction;
};
diff --git a/src/declarative/util/qdeclarativebehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp
index d90ca33..1e000df 100644
--- a/src/declarative/util/qdeclarativebehavior.cpp
+++ b/src/declarative/util/qdeclarativebehavior.cpp
@@ -83,7 +83,8 @@ public:
y: 200 // initial value
Behavior on y {
NumberAnimation {
- easing: "easeOutBounce(amplitude:100)"
+ easing.type: "OutBounce"
+ easing.amplitude: 100
duration: 200
}
}
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp
index 340e9ac..3e25234 100644
--- a/src/declarative/util/qdeclarativelistmodel.cpp
+++ b/src/declarative/util/qdeclarativelistmodel.cpp
@@ -401,7 +401,7 @@ void QDeclarativeListModel::remove(int index)
values in \a dict.
\code
- FruitModel.insert(2, {"cost": 5.95, "name":"Pizza"})
+ fruitModel.insert(2, {"cost": 5.95, "name":"Pizza"})
\endcode
The \a index must be to an existing item in the list, or one past
@@ -437,7 +437,7 @@ void QDeclarativeListModel::insert(int index, const QScriptValue& valuemap)
to the end of the list:
\code
- FruitModel.move(0,FruitModel.count-3,3)
+ fruitModel.move(0,fruitModel.count-3,3)
\endcode
\sa append()
@@ -479,7 +479,7 @@ void QDeclarativeListModel::move(int from, int to, int n)
values in \a dict.
\code
- FruitModel.append({"cost": 5.95, "name":"Pizza"})
+ fruitModel.append({"cost": 5.95, "name":"Pizza"})
\endcode
\sa set() remove()
@@ -500,8 +500,8 @@ void QDeclarativeListModel::append(const QScriptValue& valuemap)
Returns the item at \a index in the list model.
\code
- FruitModel.append({"cost": 5.95, "name":"Jackfruit"})
- FruitModel.get(0).cost
+ fruitModel.append({"cost": 5.95, "name":"Jackfruit"})
+ fruitModel.get(0).cost
\endcode
The \a index must be an element in the list.
@@ -510,10 +510,10 @@ void QDeclarativeListModel::append(const QScriptValue& valuemap)
will also be models, and this get() method is used to access elements:
\code
- FruitModel.append(..., "attributes":
+ fruitModel.append(..., "attributes":
[{"name":"spikes","value":"7mm"},
{"name":"color","value":"green"}]);
- FruitModel.get(0).attributes.get(1).value; // == "green"
+ fruitModel.get(0).attributes.get(1).value; // == "green"
\endcode
\sa append()
@@ -536,7 +536,7 @@ QScriptValue QDeclarativeListModel::get(int index) const
are left unchanged.
\code
- FruitModel.set(3, {"cost": 5.95, "name":"Pizza"})
+ fruitModel.set(3, {"cost": 5.95, "name":"Pizza"})
\endcode
The \a index must be an element in the list.
@@ -574,7 +574,7 @@ void QDeclarativeListModel::set(int index, const QScriptValue& valuemap)
Changes the \a property of the item at \a index in the list model to \a value.
\code
- FruitModel.set(3, "cost", 5.95)
+ fruitModel.set(3, "cost", 5.95)
\endcode
The \a index must be an element in the list.
diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp
index 942d5f6..e78fdf1 100644
--- a/src/declarative/util/qdeclarativepixmapcache.cpp
+++ b/src/declarative/util/qdeclarativepixmapcache.cpp
@@ -43,8 +43,6 @@
#include "qdeclarativenetworkaccessmanagerfactory.h"
#include "qdeclarativeimageprovider.h"
-#include "qfxperf_p_p.h"
-
#include <qdeclarativeengine.h>
#include <private/qdeclarativeglobal_p.h>
#include <private/qdeclarativeengine_p.h>
diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp
index 8865e04..6ceec5d 100644
--- a/src/declarative/util/qdeclarativepropertychanges.cpp
+++ b/src/declarative/util/qdeclarativepropertychanges.cpp
@@ -227,6 +227,8 @@ QDeclarativePropertyChangesParser::compileList(QList<QPair<QByteArray, QVariant>
const QVariant &value = values.at(ii);
if (value.userType() == qMetaTypeId<QDeclarativeCustomParserNode>()) {
+ error(qvariant_cast<QDeclarativeCustomParserNode>(value),
+ QDeclarativePropertyChanges::tr("PropertyChanges does not support creating state-specific objects."));
continue;
} else if(value.userType() == qMetaTypeId<QDeclarativeCustomParserProperty>()) {
diff --git a/src/declarative/util/qdeclarativespringfollow.cpp b/src/declarative/util/qdeclarativespringfollow.cpp
index 1d69dd3..76d7c98 100644
--- a/src/declarative/util/qdeclarativespringfollow.cpp
+++ b/src/declarative/util/qdeclarativespringfollow.cpp
@@ -224,11 +224,11 @@ void QDeclarativeSpringFollowPrivate::stop()
color: "#00ff00"
y: 200 // initial value
SequentialAnimation on y {
- running: true
- repeat: true
+ loops: Animation.Infinite
NumberAnimation {
to: 200
- easing: "easeOutBounce(amplitude:100)"
+ easing.type: "OutBounce"
+ easing.amplitude: 100
duration: 2000
}
PauseAnimation { duration: 1000 }
diff --git a/src/declarative/util/qdeclarativestate_p_p.h b/src/declarative/util/qdeclarativestate_p_p.h
index 6f52219..558c99b 100644
--- a/src/declarative/util/qdeclarativestate_p_p.h
+++ b/src/declarative/util/qdeclarativestate_p_p.h
@@ -58,8 +58,8 @@
#include "qdeclarativeanimation_p_p.h"
#include "qdeclarativetransitionmanager_p_p.h"
-#include <qdeclarativeproperty_p.h>
-#include <qdeclarativeguard_p.h>
+#include <private/qdeclarativeproperty_p.h>
+#include <private/qdeclarativeguard_p.h>
#include <private/qobject_p.h>
diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp
index 6f5bb66..0bc81ee 100644
--- a/src/declarative/util/qdeclarativestateoperations.cpp
+++ b/src/declarative/util/qdeclarativestateoperations.cpp
@@ -168,7 +168,7 @@ void QDeclarativeParentChangePrivate::doChange(QDeclarativeItem *targetParent, Q
for the original and new parent).
You can specify at which point in a transition you want a ParentChange to occur by
- using a ParentAnimation or ParentAction.
+ using a ParentAnimation.
*/
@@ -456,11 +456,10 @@ void QDeclarativeParentChange::saveCurrentValues()
}
d->rewindParent = d->target->parentItem();
+ d->rewindStackBefore = 0;
- if (!d->rewindParent) {
- d->rewindStackBefore = 0;
+ if (!d->rewindParent)
return;
- }
//try to determine the item's original stack position so we can restore it
int siblingIndex = ((AccessibleFxItem*)d->target)->siblingIndex() + 1;
@@ -495,9 +494,31 @@ public:
\qmlclass StateChangeScript QDeclarativeStateChangeScript
\brief The StateChangeScript element allows you to run a script in a state.
- The script specified will be run immediately when the state is made current.
- Alternatively you can use a ScriptAction to specify at which point in the transition
+ StateChangeScripts are run when entering the state. You can use
+ ScriptAction to specify at which point in the transition
you want the StateChangeScript to be run.
+
+ \qml
+ State {
+ name "state1"
+ StateChangeScript {
+ name: "myScript"
+ script: doStateStuff();
+ }
+ ...
+ }
+ ...
+ Transition {
+ to: "state1"
+ SequentialAnimation {
+ NumberAnimation { ... }
+ ScriptAction { scriptName: "myScript" }
+ NumberAnimation { ... }
+ }
+ }
+ \endqml
+
+ \sa ScriptAction
*/
QDeclarativeStateChangeScript::QDeclarativeStateChangeScript(QObject *parent)
@@ -944,7 +965,7 @@ void QDeclarativeAnchorChanges::saveOriginals()
d->origBaseline = d->target->anchors()->baseline();
d->applyOrigLeft = d->applyOrigRight = d->applyOrigHCenter = d->applyOrigTop
- = d->applyOrigBottom = d->applyOrigHCenter = d->applyOrigBaseline = false;
+ = d->applyOrigBottom = d->applyOrigVCenter = d->applyOrigBaseline = false;
saveCurrentValues();
}
diff --git a/src/declarative/util/qdeclarativetransition.cpp b/src/declarative/util/qdeclarativetransition.cpp
index ac07b10..4326a55 100644
--- a/src/declarative/util/qdeclarativetransition.cpp
+++ b/src/declarative/util/qdeclarativetransition.cpp
@@ -67,7 +67,7 @@ QT_BEGIN_NAMESPACE
\ingroup group_states
*/
-//ParallelAnimationWrapperallows us to do a "callback" when the animation finishes, rather than connecting
+//ParallelAnimationWrapper allows us to do a "callback" when the animation finishes, rather than connecting
//and disconnecting signals and slots frequently
class ParallelAnimationWrapper : public QParallelAnimationGroup
{
@@ -195,7 +195,11 @@ QString QDeclarativeTransition::fromState() const
void QDeclarativeTransition::setFromState(const QString &f)
{
Q_D(QDeclarativeTransition);
+ if (f == d->fromState)
+ return;
+
d->fromState = f;
+ emit fromChanged();
}
/*!
@@ -213,7 +217,11 @@ bool QDeclarativeTransition::reversible() const
void QDeclarativeTransition::setReversible(bool r)
{
Q_D(QDeclarativeTransition);
+ if (r == d->reversible)
+ return;
+
d->reversible = r;
+ emit reversibleChanged();
}
QString QDeclarativeTransition::toState() const
@@ -225,7 +233,11 @@ QString QDeclarativeTransition::toState() const
void QDeclarativeTransition::setToState(const QString &t)
{
Q_D(QDeclarativeTransition);
+ if (t == d->toState)
+ return;
+
d->toState = t;
+ emit toChanged();
}
/*!
diff --git a/src/declarative/util/qdeclarativetransition_p.h b/src/declarative/util/qdeclarativetransition_p.h
index 861111a..2f9e7b5 100644
--- a/src/declarative/util/qdeclarativetransition_p.h
+++ b/src/declarative/util/qdeclarativetransition_p.h
@@ -62,9 +62,9 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTransition : public QObject
Q_OBJECT
Q_DECLARE_PRIVATE(QDeclarativeTransition)
- Q_PROPERTY(QString from READ fromState WRITE setFromState)
- Q_PROPERTY(QString to READ toState WRITE setToState)
- Q_PROPERTY(bool reversible READ reversible WRITE setReversible)
+ Q_PROPERTY(QString from READ fromState WRITE setFromState NOTIFY fromChanged)
+ Q_PROPERTY(QString to READ toState WRITE setToState NOTIFY toChanged)
+ Q_PROPERTY(bool reversible READ reversible WRITE setReversible NOTIFY reversibleChanged)
Q_PROPERTY(QDeclarativeListProperty<QDeclarativeAbstractAnimation> animations READ animations)
Q_CLASSINFO("DefaultProperty", "animations")
Q_CLASSINFO("DeferredPropertyNames", "animations")
@@ -90,6 +90,11 @@ public:
void setReversed(bool r);
void stop();
+
+Q_SIGNALS:
+ void fromChanged();
+ void toChanged();
+ void reversibleChanged();
};
QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp
index 4d4678a..d79c6ba 100644
--- a/src/declarative/util/qdeclarativeutilmodule.cpp
+++ b/src/declarative/util/qdeclarativeutilmodule.cpp
@@ -40,7 +40,6 @@
****************************************************************************/
#include "qdeclarativeutilmodule_p.h"
-#include "qfxperf_p_p.h"
#include "qdeclarativeanimation_p.h"
#include "qdeclarativeanimation_p_p.h"
#include "qdeclarativebehavior_p.h"
@@ -71,7 +70,38 @@
#ifndef QT_NO_XMLPATTERNS
#include "qdeclarativexmllistmodel_p.h"
#endif
-#include "qperformancelog_p_p.h"
+
+template<typename T>
+int qmlRegisterTypeEnums(const char *qmlName)
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+ QByteArray listName("QDeclarativeListProperty<" + name + ">");
+
+ QDeclarativePrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()),
+ qRegisterMetaType<QDeclarativeListProperty<T> >(listName.constData()),
+ 0, 0,
+
+ "Qt", 4, 6, qmlName, &T::staticMetaObject,
+
+ QDeclarativePrivate::attachedPropertiesFunc<T>(),
+ QDeclarativePrivate::attachedPropertiesMetaObject<T>(),
+
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativeParserStatus>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueSource>::cast(),
+ QDeclarativePrivate::StaticCastSelector<T,QDeclarativePropertyValueInterceptor>::cast(),
+
+ 0, 0,
+
+ 0
+ };
+
+ return QDeclarativePrivate::registerType(type);
+}
void QDeclarativeUtilModule::defineModule()
{
@@ -87,7 +117,6 @@ void QDeclarativeUtilModule::defineModule()
qmlRegisterType<QDeclarativeNumberAnimation>("Qt",4,6,"NumberAnimation");
qmlRegisterType<QDeclarativePackage>("Qt",4,6,"Package");
qmlRegisterType<QDeclarativeParallelAnimation>("Qt",4,6,"ParallelAnimation");
- qmlRegisterType<QDeclarativeParentAction>("Qt",4,6,"ParentAction");
qmlRegisterType<QDeclarativeParentAnimation>("Qt",4,6,"ParentAnimation");
qmlRegisterType<QDeclarativeParentChange>("Qt",4,6,"ParentChange");
qmlRegisterType<QDeclarativePauseAnimation>("Qt",4,6,"PauseAnimation");
@@ -110,9 +139,10 @@ void QDeclarativeUtilModule::defineModule()
#endif
qmlRegisterType<QDeclarativeAnchors>();
- qmlRegisterType<QDeclarativeAbstractAnimation>();
qmlRegisterType<QDeclarativeStateOperation>();
+ qmlRegisterTypeEnums<QDeclarativeAbstractAnimation>("Animation");
+
qmlRegisterCustomType<QDeclarativeListModel>("Qt", 4,6, "ListModel", "QDeclarativeListModel",
new QDeclarativeListModelParser);
qmlRegisterCustomType<QDeclarativePropertyChanges>("Qt", 4, 6, "PropertyChanges", "QDeclarativePropertyChanges",
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
index 59a062a..d97fb5f 100644
--- a/src/declarative/util/qdeclarativeview.cpp
+++ b/src/declarative/util/qdeclarativeview.cpp
@@ -41,9 +41,6 @@
#include "qdeclarativeview.h"
-#include "qperformancelog_p_p.h"
-#include "qfxperf_p_p.h"
-
#include <qdeclarative.h>
#include <qdeclarativeitem.h>
#include <qdeclarativeengine.h>
@@ -132,6 +129,7 @@ class QDeclarativeViewPrivate
public:
QDeclarativeViewPrivate(QDeclarativeView *view)
: q(view), root(0), component(0), resizeMode(QDeclarativeView::SizeViewToRootObject) {}
+ ~QDeclarativeViewPrivate() { delete root; }
void execute();
@@ -251,13 +249,6 @@ QDeclarativeView::QDeclarativeView(const QUrl &source, QWidget *parent)
void QDeclarativeViewPrivate::init()
{
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- {
- QDeclarativePerfTimer<QDeclarativePerf::FontDatabase> perf;
- QFontDatabase database;
- }
-#endif
-
q->setScene(&scene);
q->setOptimizationFlags(QGraphicsView::DontSavePainterState);
@@ -280,7 +271,7 @@ void QDeclarativeViewPrivate::init()
*/
QDeclarativeView::~QDeclarativeView()
{
- delete d->root;
+ delete d;
}
/*! \property QDeclarativeView::source
@@ -455,8 +446,6 @@ void QDeclarativeView::setRootObject(QObject *obj)
if (QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(obj)) {
d->scene.addItem(item);
- QPerformanceLog::displayData();
- QPerformanceLog::clear();
d->root = item;
d->qmlRoot = item;
connect(item, SIGNAL(widthChanged(qreal)), this, SLOT(sizeChanged()));
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index 01ae2ed..f7beeaa 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -46,6 +46,7 @@
#include <QDebug>
#include <QStringList>
+#include <QQueue>
#include <QApplication>
#include <QThread>
#include <QMutex>
@@ -59,9 +60,9 @@
#include <private/qobject_p.h>
-QT_BEGIN_NAMESPACE
-
+Q_DECLARE_METATYPE(QDeclarativeXmlQueryResult)
+QT_BEGIN_NAMESPACE
typedef QPair<int, int> QDeclarativeXmlListRange;
@@ -109,13 +110,25 @@ typedef QPair<int, int> QDeclarativeXmlListRange;
\sa XmlListModel
*/
+struct XmlQueryJob
+{
+ int queryId;
+ QByteArray data;
+ QString query;
+ QString namespaces;
+ QStringList roleQueries;
+ QStringList keyRoleQueries;
+ QStringList keyRoleResultsCache;
+};
+
class QDeclarativeXmlQuery : public QThread
{
Q_OBJECT
public:
QDeclarativeXmlQuery(QObject *parent=0)
- : QThread(parent), m_quit(false), m_restart(false), m_abort(false), m_queryId(0) {
+ : QThread(parent), m_quit(false), m_abortQueryId(-1), m_queryIds(0) {
+ qRegisterMetaType<QDeclarativeXmlQueryResult>("QDeclarativeXmlQueryResult");
}
~QDeclarativeXmlQuery() {
m_mutex.lock();
@@ -126,27 +139,38 @@ public:
wait();
}
- void abort() {
+ void abort(int id) {
QMutexLocker locker(&m_mutex);
- m_abort = true;
+ m_abortQueryId = id;
}
- int doQuery(QString query, QString namespaces, QByteArray data, QList<QDeclarativeXmlListModelRole *> *roleObjects) {
+ int doQuery(QString query, QString namespaces, QByteArray data, QList<QDeclarativeXmlListModelRole *> *roleObjects, QStringList keyRoleResultsCache) {
QMutexLocker locker(&m_mutex);
- m_size = 0;
- m_data = data;
- m_query = QLatin1String("doc($src)") + query;
- m_namespaces = namespaces;
- m_roleObjects = roleObjects;
- if (!isRunning()) {
- m_abort = false;
+
+ XmlQueryJob job;
+ job.queryId = m_queryIds;
+ job.data = data;
+ job.query = QLatin1String("doc($src)") + query;
+ job.namespaces = namespaces;
+ job.keyRoleResultsCache = keyRoleResultsCache;
+
+ for (int i=0; i<roleObjects->count(); i++) {
+ if (!roleObjects->at(i)->isValid()) {
+ job.roleQueries << "";
+ continue;
+ }
+ job.roleQueries << roleObjects->at(i)->query();
+ if (roleObjects->at(i)->isKey())
+ job.keyRoleQueries << job.roleQueries.last();
+ }
+ m_jobs.enqueue(job);
+ m_queryIds++;
+
+ if (!isRunning())
start();
- } else {
- m_restart = true;
+ else
m_condition.wakeOne();
- }
- m_queryId++;
- return m_queryId;
+ return job.queryId;
}
QList<QList<QVariant> > modelData() {
@@ -164,26 +188,33 @@ public:
return m_removedItemRanges;
}
+
Q_SIGNALS:
- void queryCompleted(int queryId, int size);
+ void queryCompleted(const QDeclarativeXmlQueryResult &);
protected:
void run() {
while (!m_quit) {
m_mutex.lock();
- int queryId = m_queryId;
doQueryJob();
doSubQueryJob();
- m_data.clear(); // no longer needed
m_mutex.unlock();
m_mutex.lock();
- if (!m_abort)
- emit queryCompleted(queryId, m_size);
- if (!m_restart)
+ const XmlQueryJob &job = m_jobs.dequeue();
+ if (m_abortQueryId != job.queryId) {
+ QDeclarativeXmlQueryResult r;
+ r.queryId = job.queryId;
+ r.size = m_size;
+ r.data = m_modelData;
+ r.inserted = m_insertedItemRanges;
+ r.removed = m_removedItemRanges;
+ r.keyRoleResultsCache = job.keyRoleResultsCache;
+ emit queryCompleted(r);
+ }
+ if (m_jobs.isEmpty())
m_condition.wait(&m_mutex);
- m_abort = false;
- m_restart = false;
+ m_abortQueryId = -1;
m_mutex.unlock();
}
}
@@ -197,30 +228,30 @@ private:
private:
QMutex m_mutex;
QWaitCondition m_condition;
+ QQueue<XmlQueryJob> m_jobs;
bool m_quit;
- bool m_restart;
- bool m_abort;
- QByteArray m_data;
- QString m_query;
- QString m_namespaces;
+ int m_abortQueryId;
QString m_prefix;
int m_size;
- int m_queryId;
- const QList<QDeclarativeXmlListModelRole *> *m_roleObjects;
+ int m_queryIds;
QList<QList<QVariant> > m_modelData;
- QStringList m_keysValues;
QList<QDeclarativeXmlListRange> m_insertedItemRanges;
QList<QDeclarativeXmlListRange> m_removedItemRanges;
};
+Q_GLOBAL_STATIC(QDeclarativeXmlQuery, globalXmlQuery)
+
void QDeclarativeXmlQuery::doQueryJob()
{
+ Q_ASSERT(!m_jobs.isEmpty());
+ XmlQueryJob &job = m_jobs.head();
+
QString r;
QXmlQuery query;
- QBuffer buffer(&m_data);
+ QBuffer buffer(&job.data);
buffer.open(QIODevice::ReadOnly);
query.bindVariable(QLatin1String("src"), &buffer);
- query.setQuery(m_namespaces + m_query);
+ query.setQuery(job.namespaces + job.query);
query.evaluateTo(&r);
//qDebug() << r;
@@ -231,9 +262,9 @@ void QDeclarativeXmlQuery::doQueryJob()
b.open(QIODevice::ReadOnly);
//qDebug() << xml;
- QString namespaces = QLatin1String("declare namespace dummy=\"http://qtsotware.com/dummy\";\n") + m_namespaces;
+ QString namespaces = QLatin1String("declare namespace dummy=\"http://qtsotware.com/dummy\";\n") + job.namespaces;
QString prefix = QLatin1String("doc($inputDocument)/dummy:items") +
- m_query.mid(m_query.lastIndexOf(QLatin1Char('/')));
+ job.query.mid(job.query.lastIndexOf(QLatin1Char('/')));
//figure out how many items we are dealing with
int count = -1;
@@ -249,19 +280,18 @@ void QDeclarativeXmlQuery::doQueryJob()
}
//qDebug() << count;
+ job.data = xml;
m_prefix = namespaces + prefix + QLatin1Char('/');
- m_data = xml;
+ m_size = 0;
if (count > 0)
m_size = count;
}
void QDeclarativeXmlQuery::getValuesOfKeyRoles(QStringList *values, QXmlQuery *query) const
{
- QStringList keysQueries;
- for (int i=0; i<m_roleObjects->count(); i++) {
- if (m_roleObjects->at(i)->isKey())
- keysQueries << m_roleObjects->at(i)->query();
- }
+ Q_ASSERT(!m_jobs.isEmpty());
+
+ const QStringList &keysQueries = m_jobs.head().keyRoleQueries;
QString keysQuery;
if (keysQueries.count() == 1)
keysQuery = m_prefix + keysQueries[0];
@@ -291,54 +321,58 @@ void QDeclarativeXmlQuery::addIndexToRangeList(QList<QDeclarativeXmlListRange> *
void QDeclarativeXmlQuery::doSubQueryJob()
{
+ Q_ASSERT(!m_jobs.isEmpty());
+ XmlQueryJob &job = m_jobs.head();
m_modelData.clear();
- QBuffer b(&m_data);
+ QBuffer b(&job.data);
b.open(QIODevice::ReadOnly);
QXmlQuery subquery;
subquery.bindVariable(QLatin1String("inputDocument"), &b);
- QStringList keysValues;
- getValuesOfKeyRoles(&keysValues, &subquery);
+ QStringList keyRoleResults;
+ getValuesOfKeyRoles(&keyRoleResults, &subquery);
// See if any values of key roles have been inserted or removed.
+
m_insertedItemRanges.clear();
m_removedItemRanges.clear();
- if (m_keysValues.isEmpty()) {
+ if (job.keyRoleResultsCache.isEmpty()) {
m_insertedItemRanges << qMakePair(0, m_size);
} else {
- if (keysValues != m_keysValues) {
+ if (keyRoleResults != job.keyRoleResultsCache) {
QStringList temp;
- for (int i=0; i<m_keysValues.count(); i++) {
- if (!keysValues.contains(m_keysValues[i]))
+ for (int i=0; i<job.keyRoleResultsCache.count(); i++) {
+ if (!keyRoleResults.contains(job.keyRoleResultsCache[i]))
addIndexToRangeList(&m_removedItemRanges, i);
else
- temp << m_keysValues[i];
+ temp << job.keyRoleResultsCache[i];
}
- for (int i=0; i<keysValues.count(); i++) {
- if (temp.count() == i || keysValues[i] != temp[i]) {
- temp.insert(i, keysValues[i]);
+ for (int i=0; i<keyRoleResults.count(); i++) {
+ if (temp.count() == i || keyRoleResults[i] != temp[i]) {
+ temp.insert(i, keyRoleResults[i]);
addIndexToRangeList(&m_insertedItemRanges, i);
}
}
}
}
- m_keysValues = keysValues;
+ job.keyRoleResultsCache = keyRoleResults;
+
// Get the new values for each role.
//### we might be able to condense even further (query for everything in one go)
- for (int i = 0; i < m_roleObjects->size(); ++i) {
- QDeclarativeXmlListModelRole *role = m_roleObjects->at(i);
- if (!role->isValid()) {
+ const QStringList &queries = job.roleQueries;
+ for (int i = 0; i < queries.size(); ++i) {
+ if (queries[i].isEmpty()) {
QList<QVariant> resultList;
for (int j = 0; j < m_size; ++j)
resultList << QVariant();
m_modelData << resultList;
continue;
}
- subquery.setQuery(m_prefix + QLatin1String("(let $v := ") + role->query() + QLatin1String(" return if ($v) then ") + role->query() + QLatin1String(" else \"\")"));
+ subquery.setQuery(m_prefix + QLatin1String("(let $v := ") + queries[i] + QLatin1String(" return if ($v) then ") + queries[i] + QLatin1String(" else \"\")"));
QXmlResultItems resultItems;
subquery.evaluateTo(&resultItems);
QXmlItem item(resultItems.next());
@@ -404,8 +438,8 @@ public:
QNetworkReply *reply;
QDeclarativeXmlListModel::Status status;
qreal progress;
- QDeclarativeXmlQuery qmlXmlQuery;
int queryId;
+ QStringList keyRoleResultsCache;
QList<QDeclarativeXmlListModelRole *> roleObjects;
static void append_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list, QDeclarativeXmlListModelRole *role);
static void clear_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list);
@@ -489,9 +523,8 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla
QDeclarativeXmlListModel::QDeclarativeXmlListModel(QObject *parent)
: QListModelInterface(*(new QDeclarativeXmlListModelPrivate), parent)
{
- Q_D(QDeclarativeXmlListModel);
- connect(&d->qmlXmlQuery, SIGNAL(queryCompleted(int,int)),
- this, SLOT(queryCompleted(int,int)));
+ connect(globalXmlQuery(), SIGNAL(queryCompleted(QDeclarativeXmlQueryResult)),
+ this, SLOT(queryCompleted(QDeclarativeXmlQueryResult)));
}
QDeclarativeXmlListModel::~QDeclarativeXmlListModel()
@@ -723,7 +756,7 @@ void QDeclarativeXmlListModel::reload()
if (!d->isComponentComplete)
return;
- d->qmlXmlQuery.abort();
+ globalXmlQuery()->abort(d->queryId);
d->queryId = -1;
int count = d->size;
@@ -755,7 +788,7 @@ void QDeclarativeXmlListModel::reload()
}
if (!d->xml.isEmpty()) {
- d->queryId = d->qmlXmlQuery.doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects);
+ d->queryId = globalXmlQuery()->doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects, d->keyRoleResultsCache);
d->progress = 1.0;
d->status = Ready;
emit progressChanged(d->progress);
@@ -802,7 +835,7 @@ void QDeclarativeXmlListModel::requestFinished()
} else {
d->status = Ready;
QByteArray data = d->reply->readAll();
- d->queryId = d->qmlXmlQuery.doQuery(d->query, d->namespaces, data, &d->roleObjects);
+ d->queryId = globalXmlQuery()->doQuery(d->query, d->namespaces, data, &d->roleObjects, d->keyRoleResultsCache);
disconnect(d->reply, 0, this, 0);
d->reply->deleteLater();
d->reply = 0;
@@ -821,22 +854,20 @@ void QDeclarativeXmlListModel::requestProgress(qint64 received, qint64 total)
}
}
-void QDeclarativeXmlListModel::queryCompleted(int id, int size)
+void QDeclarativeXmlListModel::queryCompleted(const QDeclarativeXmlQueryResult &result)
{
Q_D(QDeclarativeXmlListModel);
- if (id != d->queryId)
+ if (result.queryId != d->queryId)
return;
- bool sizeChanged = size != d->size;
- d->size = size;
- d->data = d->qmlXmlQuery.modelData();
-
- QList<QDeclarativeXmlListRange> removed = d->qmlXmlQuery.removedItemRanges();
- QList<QDeclarativeXmlListRange> inserted = d->qmlXmlQuery.insertedItemRanges();
-
- for (int i=0; i<removed.count(); i++)
- emit itemsRemoved(removed[i].first, removed[i].second);
- for (int i=0; i<inserted.count(); i++)
- emit itemsInserted(inserted[i].first, inserted[i].second);
+ bool sizeChanged = result.size != d->size;
+ d->size = result.size;
+ d->data = result.data;
+ d->keyRoleResultsCache = result.keyRoleResultsCache;
+
+ for (int i=0; i<result.removed.count(); i++)
+ emit itemsRemoved(result.removed[i].first, result.removed[i].second);
+ for (int i=0; i<result.inserted.count(); i++)
+ emit itemsInserted(result.inserted[i].first, result.inserted[i].second);
if (sizeChanged)
emit countChanged();
diff --git a/src/declarative/util/qdeclarativexmllistmodel_p.h b/src/declarative/util/qdeclarativexmllistmodel_p.h
index 23ff7ce..7bb0f0e 100644
--- a/src/declarative/util/qdeclarativexmllistmodel_p.h
+++ b/src/declarative/util/qdeclarativexmllistmodel_p.h
@@ -46,6 +46,7 @@
#include <qdeclarativeinfo.h>
#include <QtCore/qurl.h>
+#include <QtCore/qstringlist.h>
#include <private/qlistmodelinterface_p.h>
@@ -56,10 +57,18 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QDeclarativeContext;
-
class QDeclarativeXmlListModelRole;
-
class QDeclarativeXmlListModelPrivate;
+
+struct QDeclarativeXmlQueryResult {
+ int queryId;
+ int size;
+ QList<QList<QVariant> > data;
+ QList<QPair<int, int> > inserted;
+ QList<QPair<int, int> > removed;
+ QStringList keyRoleResultsCache;
+};
+
class Q_DECLARATIVE_EXPORT QDeclarativeXmlListModel : public QListModelInterface, public QDeclarativeParserStatus
{
Q_OBJECT
@@ -126,7 +135,7 @@ public Q_SLOTS:
private Q_SLOTS:
void requestFinished();
void requestProgress(qint64,qint64);
- void queryCompleted(int,int);
+ void queryCompleted(const QDeclarativeXmlQueryResult &);
private:
Q_DECLARE_PRIVATE(QDeclarativeXmlListModel)
diff --git a/src/declarative/util/qfxperf.cpp b/src/declarative/util/qfxperf.cpp
deleted file mode 100644
index 5611c49..0000000
--- a/src/declarative/util/qfxperf.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfxperf_p_p.h"
-
-QT_BEGIN_NAMESPACE
-
-Q_DEFINE_PERFORMANCE_LOG(QDeclarativePerf, "QDeclarativeGraphics") {
- Q_DEFINE_PERFORMANCE_METRIC(QDeclarativeParsing, "Compilation: QML Parsing")
- Q_DEFINE_PERFORMANCE_METRIC(Compilation, " QML Compilation")
- Q_DEFINE_PERFORMANCE_METRIC(VMEExecution, "Execution: QML VME Execution")
- Q_DEFINE_PERFORMANCE_METRIC(BindInit, "BindValue Initialization")
- Q_DEFINE_PERFORMANCE_METRIC(BindValue, "BindValue execution")
- Q_DEFINE_PERFORMANCE_METRIC(BindValueSSE, "BindValue execution SSE")
- Q_DEFINE_PERFORMANCE_METRIC(BindValueQt, "BindValue execution QtScript")
- Q_DEFINE_PERFORMANCE_METRIC(BindableValueUpdate, "QDeclarativeBinding::update")
- Q_DEFINE_PERFORMANCE_METRIC(PixmapLoad, "Pixmap loading")
- Q_DEFINE_PERFORMANCE_METRIC(FontDatabase, "Font database creation")
- Q_DEFINE_PERFORMANCE_METRIC(QDeclarativePathViewPathCache, "FX Items: QDeclarativePathView: Path cache")
- Q_DEFINE_PERFORMANCE_METRIC(CreateParticle, " QDeclarativeParticles: Particle creation")
- Q_DEFINE_PERFORMANCE_METRIC(ItemComponentComplete, " QDeclarativeItem::componentComplete")
- Q_DEFINE_PERFORMANCE_METRIC(ImageComponentComplete, " QDeclarativeImage::componentComplete")
- Q_DEFINE_PERFORMANCE_METRIC(BaseLayoutComponentComplete, " QDeclarativeBasePositioner::componentComplete")
- Q_DEFINE_PERFORMANCE_METRIC(TextComponentComplete, " QDeclarativeText::componentComplete")
- Q_DEFINE_PERFORMANCE_METRIC(QDeclarativeText_setText, " QDeclarativeText::setText")
- Q_DEFINE_PERFORMANCE_METRIC(AddScript, "QDeclarativeScript::addScriptToEngine")
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qfxperf_p_p.h b/src/declarative/util/qfxperf_p_p.h
deleted file mode 100644
index 8b65821..0000000
--- a/src/declarative/util/qfxperf_p_p.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QFXPERF_H
-#define QFXPERF_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qperformancelog_p_p.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-Q_DECLARE_PERFORMANCE_LOG(QDeclarativePerf) {
- Q_DECLARE_PERFORMANCE_METRIC(QDeclarativeParsing)
-
- Q_DECLARE_PERFORMANCE_METRIC(Compilation)
- Q_DECLARE_PERFORMANCE_METRIC(VMEExecution)
-
- Q_DECLARE_PERFORMANCE_METRIC(BindInit)
- Q_DECLARE_PERFORMANCE_METRIC(BindValue)
- Q_DECLARE_PERFORMANCE_METRIC(BindValueSSE)
- Q_DECLARE_PERFORMANCE_METRIC(BindValueQt)
- Q_DECLARE_PERFORMANCE_METRIC(BindableValueUpdate)
- Q_DECLARE_PERFORMANCE_METRIC(PixmapLoad)
- Q_DECLARE_PERFORMANCE_METRIC(FontDatabase)
- Q_DECLARE_PERFORMANCE_METRIC(QDeclarativePathViewPathCache)
- Q_DECLARE_PERFORMANCE_METRIC(CreateParticle)
- Q_DECLARE_PERFORMANCE_METRIC(ItemComponentComplete)
- Q_DECLARE_PERFORMANCE_METRIC(ImageComponentComplete)
- Q_DECLARE_PERFORMANCE_METRIC(BaseLayoutComponentComplete)
- Q_DECLARE_PERFORMANCE_METRIC(TextComponentComplete)
- Q_DECLARE_PERFORMANCE_METRIC(QDeclarativeText_setText)
- Q_DECLARE_PERFORMANCE_METRIC(AddScript)
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QFXPERF_H
diff --git a/src/declarative/util/qperformancelog.cpp b/src/declarative/util/qperformancelog.cpp
deleted file mode 100644
index 83cc919..0000000
--- a/src/declarative/util/qperformancelog.cpp
+++ /dev/null
@@ -1,181 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qperformancelog_p_p.h"
-
-#include <QHash>
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-#ifdef Q_ENABLE_PERFORMANCE_LOG
-
-struct QPerformanceLogData
-{
- struct Log
- {
- Log()
- : logDescription(0), maxId(-1) {}
-
- QHash<int, const char *> descriptions;
- const char *logDescription;
- int maxId;
- };
-
- typedef QHash<QPerformanceLog::LogData *, Log> Logs;
- Logs logs;
-};
-Q_GLOBAL_STATIC(QPerformanceLogData, performanceLogData);
-
-QPerformanceLog::LogData::LogData(const char *desc)
-: sumTime(0), data(0)
-{
- QPerformanceLogData *logData = performanceLogData();
-
- QPerformanceLogData::Log log;
- log.logDescription = desc;
- logData->logs.insert(this, log);
-
- timer.start();
-}
-
-QPerformanceLog::LogMetric::LogMetric(LogData *l, int id, const char *desc)
-{
- if (id < 0)
- qFatal("QPerformanceLog: Invalid log id %d ('%s')", id, desc);
-
- QPerformanceLogData *logData = performanceLogData();
-
- QPerformanceLogData::Logs::Iterator logIter = logData->logs.find(l);
- if (logIter == logData->logs.end())
- qFatal("QPerformanceLog: Unable to locate log for metric '%s'", desc);
- QPerformanceLogData::Log &log = *logIter;
- if (log.descriptions.contains(id))
- qFatal("QPerformanceLog: Duplicate log metric %d ('%s')", id, desc);
- log.descriptions.insert(id, desc);
-
- if (log.maxId < id) {
- log.maxId = id;
- if (l->data) delete [] l->data;
- l->data = new unsigned int[2 * (log.maxId + 1)];
- ::memset(l->data, 0, 2 * (log.maxId + 1) * sizeof(unsigned int));
- }
-}
-
-static void QPerformanceLog_clear(QPerformanceLog::LogData *l, const QPerformanceLogData::Log *pl)
-{
- ::memset(l->data, 0, 2 * (pl->maxId + 1) * sizeof(unsigned int));
-}
-
-static void QPerformanceLog_displayData(const QPerformanceLog::LogData *l, const QPerformanceLogData::Log *pl)
-{
- qWarning() << pl->logDescription << "performance data";
- unsigned int total = 0;
- for (QHash<int, const char *>::ConstIterator iter = pl->descriptions.begin();
- iter != pl->descriptions.end();
- ++iter) {
-
- int id = iter.key();
- unsigned int ms = l->data[id * 2];
- total += ms;
- unsigned int inst = l->data[id * 2 + 1];
- float pi = float(ms) / float(inst);
- qWarning().nospace() << " " << *iter << ": " << ms << " ms over "
- << inst << " instances (" << pi << " ms/instance)";
- }
- qWarning().nospace() << " TOTAL: " << total;
-}
-
-void QPerformanceLog::displayData()
-{
- QPerformanceLogData *logData = performanceLogData();
-
- for (QPerformanceLogData::Logs::ConstIterator iter = logData->logs.begin();
- iter != logData->logs.end();
- ++iter) {
- QPerformanceLog_displayData(iter.key(), &(*iter));
- }
-}
-
-void QPerformanceLog::clear()
-{
- QPerformanceLogData *logData = performanceLogData();
-
- for (QPerformanceLogData::Logs::ConstIterator iter = logData->logs.begin();
- iter != logData->logs.end();
- ++iter) {
- QPerformanceLog_clear(iter.key(), &(*iter));
- }
-}
-
-void QPerformanceLog::displayData(LogData *l)
-{
- QPerformanceLogData *logData = performanceLogData();
- QPerformanceLogData::Logs::ConstIterator iter = logData->logs.find(l);
- if (iter == logData->logs.end())
- qFatal("QPerformanceLog: Internal corruption - unable to locate log");
-
- QPerformanceLog_displayData(iter.key(), &(*iter));
-}
-
-void QPerformanceLog::clear(LogData *l)
-{
- QPerformanceLogData *logData = performanceLogData();
- QPerformanceLogData::Logs::ConstIterator iter = logData->logs.find(l);
- if (iter == logData->logs.end())
- qFatal("QPerformanceLog: Internal corruption - unable to locate log");
-
- QPerformanceLog_clear(iter.key(), &(*iter));
-}
-
-#else // Q_ENABLE_PERFORMANCE_LOG
-
-void QPerformanceLog::displayData()
-{
-}
-
-void QPerformanceLog::clear()
-{
-}
-
-#endif // Q_ENABLE_PERFORMANCE_LOG
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qperformancelog_p_p.h b/src/declarative/util/qperformancelog_p_p.h
deleted file mode 100644
index a212f28..0000000
--- a/src/declarative/util/qperformancelog_p_p.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPERFORMANCELOG_H
-#define QPERFORMANCELOG_H
-
-#include <QtCore/qdatetime.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace QPerformanceLog
-{
- Q_DECLARATIVE_EXPORT void displayData();
- Q_DECLARATIVE_EXPORT void clear();
-
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- struct LogData {
- LogData(const char *);
- QTime timer;
- int sumTime;
- unsigned int *data;
- };
-
- struct LogMetric {
- LogMetric(LogData *, int, const char *);
- };
-
- // Internal
- void displayData(LogData *);
- void clear(LogData *);
-#endif
-}
-
-#ifdef Q_ENABLE_PERFORMANCE_LOG
-
-#define Q_DECLARE_PERFORMANCE_METRIC(name) \
- enum { name = ValueChoice<0, ValueTracker<0, __LINE__>::value, __LINE__>::value }; \
- template<int L> \
- struct ValueTracker<name, L> \
- { \
- enum { value = name }; \
- }; \
- extern QPerformanceLog::LogMetric metric ## name;
-
-#define Q_DECLARE_PERFORMANCE_LOG(name) \
- namespace name { \
- extern QPerformanceLog::LogData log; \
- inline void displayData() { QPerformanceLog::displayData(&log); } \
- inline void clear() { QPerformanceLog::clear(&log); } \
- } \
- template<int N> \
- class name ## Timer { \
- public: \
- name ## Timer() { \
- lastSum = name::log.sumTime + name::log.timer.restart(); \
- name::log.sumTime = 0; \
- } \
- ~ name ## Timer() { \
- name::log.data[2 * N] += name::log.sumTime + name::log.timer.restart(); \
- ++name::log.data[2 * N + 1]; \
- name::log.sumTime = lastSum; \
- } \
- private: \
- int lastSum; \
- }; \
- namespace name { \
- template<int N, int L> \
- struct ValueTracker \
- { \
- enum { value = -1 }; \
- }; \
- template<int DefNextValue, int NextValue, int L> \
- struct ValueChoice \
- { \
- enum { value = ValueChoice<DefNextValue + 1, ValueTracker<DefNextValue + 1, L>::value, L>::value }; \
- }; \
- template<int DefNextValue, int L> \
- struct ValueChoice<DefNextValue, -1, L> \
- { \
- enum { value = DefNextValue }; \
- }; \
- } \
- namespace name
-
-#define Q_DEFINE_PERFORMANCE_LOG(name, desc) \
- QPerformanceLog::LogData name::log(desc); \
- namespace name
-
-#define Q_DEFINE_PERFORMANCE_METRIC(name, desc) \
- QPerformanceLog::LogMetric metrix ## name(&log, name, desc);
-
-#else // Q_ENABLE_PERFORMANCE_LOG
-
-#define Q_DECLARE_PERFORMANCE_METRIC(name)
-#define Q_DECLARE_PERFORMANCE_LOG(name) namespace name
-#define Q_DEFINE_PERFORMANCE_LOG(name, desc) namespace name
-#define Q_DEFINE_PERFORMANCE_METRIC(name, desc)
-
-#endif // Q_ENABLE_PERFORMANCE_LOG
-
-QT_END_NAMESPACE
-
-#endif // QPERFORMANCELOG_H
diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri
index f455870..f537806 100644
--- a/src/declarative/util/util.pri
+++ b/src/declarative/util/util.pri
@@ -3,8 +3,6 @@ INCLUDEPATH += $$PWD
SOURCES += \
$$PWD/qdeclarativeutilmodule.cpp\
$$PWD/qdeclarativeview.cpp \
- $$PWD/qfxperf.cpp \
- $$PWD/qperformancelog.cpp \
$$PWD/qdeclarativeconnections.cpp \
$$PWD/qdeclarativepackage.cpp \
$$PWD/qdeclarativeanimation.cpp \
@@ -33,8 +31,6 @@ SOURCES += \
HEADERS += \
$$PWD/qdeclarativeutilmodule_p.h\
$$PWD/qdeclarativeview.h \
- $$PWD/qfxperf_p_p.h \
- $$PWD/qperformancelog_p_p.h \
$$PWD/qdeclarativeconnections_p.h \
$$PWD/qdeclarativepackage_p.h \
$$PWD/qdeclarativeanimation_p.h \
diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp
index ba0a560..2f1933c 100644
--- a/src/gui/dialogs/qfilesystemmodel.cpp
+++ b/src/gui/dialogs/qfilesystemmodel.cpp
@@ -1896,6 +1896,13 @@ void QFileSystemModelPrivate::init()
q->connect(&fileInfoGatherer, SIGNAL(directoryLoaded(QString)),
q, SIGNAL(directoryLoaded(QString)));
q->connect(&delayedSortTimer, SIGNAL(timeout()), q, SLOT(_q_performDelayedSort()), Qt::QueuedConnection);
+
+ QHash<int, QByteArray> roles = q->roleNames();
+ roles.insertMulti(QFileSystemModel::FileIconRole, "fileIcon"); // == Qt::decoration
+ roles.insert(QFileSystemModel::FilePathRole, "filePath");
+ roles.insert(QFileSystemModel::FileNameRole, "fileName");
+ roles.insert(QFileSystemModel::FilePermissions, "filePermissions");
+ q->setRoleNames(roles);
}
/*!
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 948ff28..66b262c 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -381,7 +381,9 @@
\value ItemSendsGeometryChanges The item enables itemChange()
notifications for ItemPositionChange, ItemPositionHasChanged,
- ItemMatrixChange, ItemTransformChange, and ItemTransformHasChanged. For
+ ItemMatrixChange, ItemTransformChange, ItemTransformHasChanged,
+ ItemRotationChange, ItemRotationHasChanged, ItemScaleChange, ItemScaleHasChanged,
+ ItemTransformOriginPointChange, and ItemTransformOriginPointHasChanged. For
performance reasons, these notifications are disabled by default. You must
enable this flag to receive notifications for position and transform
changes. This flag was introduced in Qt 4.6.
@@ -475,6 +477,52 @@
(same as transform()), and QGraphicsItem ignores the return value for this
notification (i.e., a read-only notification).
+ \value ItemRotationChange The item's rotation property changes. This
+ notification is sent if the ItemSendsGeometryChanges flag is enabled, and
+ when the item's rotation property changes (i.e., as a result of calling
+ setRotation()). The value argument is the new rotation (i.e., a double);
+ to get the old rotation, call rotation(). Do not call setRotation() in
+ itemChange() as this notification is delivered; instead, you can return
+ the new rotation from itemChange().
+
+ \value ItemRotationHasChanged The item's rotation property has changed.
+ This notification is sent if the ItemSendsGeometryChanges flag is enabled,
+ and after the item's rotation property has changed. The value argument is
+ the new rotation (i.e., a double), and QGraphicsItem ignores the return
+ value for this notification (i.e., a read-only notification). Do not call
+ setRotation() in itemChange() as this notification is delivered.
+
+ \value ItemScaleChange The item's scale property changes. This notification
+ is sent if the ItemSendsGeometryChanges flag is enabled, and when the item's
+ scale property changes (i.e., as a result of calling setScale()). The value
+ argument is the new scale (i.e., a double); to get the old scale, call
+ scale(). Do not call setScale() in itemChange() as this notification is
+ delivered; instead, you can return the new scale from itemChange().
+
+ \value ItemScaleHasChanged The item's scale property has changed. This
+ notification is sent if the ItemSendsGeometryChanges flag is enabled, and
+ after the item's scale property has changed. The value argument is the new
+ scale (i.e., a double), and QGraphicsItem ignores the return value for this
+ notification (i.e., a read-only notification). Do not call setScale() in
+ itemChange() as this notification is delivered.
+
+ \value ItemTransformOriginPointChange The item's transform origin point
+ property changes. This notification is sent if the ItemSendsGeometryChanges
+ flag is enabled, and when the item's transform origin point property changes
+ (i.e., as a result of calling setTransformOriginPoint()). The value argument
+ is the new origin point (i.e., a QPointF); to get the old origin point, call
+ transformOriginPoint(). Do not call setTransformOriginPoint() in itemChange()
+ as this notification is delivered; instead, you can return the new transform
+ origin point from itemChange().
+
+ \value ItemTransformOriginPointHasChanged The item's transform origin point
+ property has changed. This notification is sent if the ItemSendsGeometryChanges
+ flag is enabled, and after the item's transform origin point property has
+ changed. The value argument is the new origin point (i.e., a QPointF), and
+ QGraphicsItem ignores the return value for this notification (i.e., a read-only
+ notification). Do not call setTransformOriginPoint() in itemChange() as this
+ notification is delivered.
+
\value ItemSelectedChange The item's selected state changes. If the item is
presently selected, it will become unselected, and vice verca. The value
argument is the new selected state (i.e., true or false). Do not call
@@ -3722,12 +3770,28 @@ qreal QGraphicsItem::rotation() const
void QGraphicsItem::setRotation(qreal angle)
{
prepareGeometryChange();
+ qreal newRotation = angle;
+
+ if (d_ptr->flags & ItemSendsGeometryChanges) {
+ // Notify the item that the rotation is changing.
+ const QVariant newRotationVariant(itemChange(ItemRotationChange, angle));
+ newRotation = newRotationVariant.toReal();
+ }
+
if (!d_ptr->transformData)
d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
- d_ptr->transformData->rotation = angle;
+
+ if (d_ptr->transformData->rotation == newRotation)
+ return;
+
+ d_ptr->transformData->rotation = newRotation;
d_ptr->transformData->onlyTransform = false;
d_ptr->dirtySceneTransform = 1;
+ // Send post-notification.
+ if (d_ptr->flags & ItemSendsGeometryChanges)
+ itemChange(ItemRotationHasChanged, newRotation);
+
if (d_ptr->isObject)
emit static_cast<QGraphicsObject *>(this)->rotationChanged();
}
@@ -3770,12 +3834,28 @@ qreal QGraphicsItem::scale() const
void QGraphicsItem::setScale(qreal factor)
{
prepareGeometryChange();
+ qreal newScale = factor;
+
+ if (d_ptr->flags & ItemSendsGeometryChanges) {
+ // Notify the item that the scale is changing.
+ const QVariant newScaleVariant(itemChange(ItemScaleChange, factor));
+ newScale = newScaleVariant.toReal();
+ }
+
if (!d_ptr->transformData)
d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
- d_ptr->transformData->scale = factor;
+
+ if (d_ptr->transformData->scale == newScale)
+ return;
+
+ d_ptr->transformData->scale = newScale;
d_ptr->transformData->onlyTransform = false;
d_ptr->dirtySceneTransform = 1;
+ // Send post-notification.
+ if (d_ptr->flags & ItemSendsGeometryChanges)
+ itemChange(ItemScaleHasChanged, newScale);
+
if (d_ptr->isObject)
emit static_cast<QGraphicsObject *>(this)->scaleChanged();
}
@@ -3877,12 +3957,31 @@ QPointF QGraphicsItem::transformOriginPoint() const
void QGraphicsItem::setTransformOriginPoint(const QPointF &origin)
{
prepareGeometryChange();
+ QPointF newOrigin = origin;
+
+ if (d_ptr->flags & ItemSendsGeometryChanges) {
+ // Notify the item that the origin point is changing.
+ const QVariant newOriginVariant(itemChange(ItemTransformOriginPointChange,
+ qVariantFromValue<QPointF>(origin)));
+ newOrigin = newOriginVariant.toPointF();
+ }
+
if (!d_ptr->transformData)
d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
- d_ptr->transformData->xOrigin = origin.x();
- d_ptr->transformData->yOrigin = origin.y();
+
+ if (d_ptr->transformData->xOrigin == newOrigin.x()
+ && d_ptr->transformData->yOrigin == newOrigin.y()) {
+ return;
+ }
+
+ d_ptr->transformData->xOrigin = newOrigin.x();
+ d_ptr->transformData->yOrigin = newOrigin.y();
d_ptr->transformData->onlyTransform = false;
d_ptr->dirtySceneTransform = 1;
+
+ // Send post-notification.
+ if (d_ptr->flags & ItemSendsGeometryChanges)
+ itemChange(ItemTransformOriginPointHasChanged, qVariantFromValue<QPointF>(newOrigin));
}
/*!
@@ -11072,6 +11171,24 @@ QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemChange change)
case QGraphicsItem::ItemScenePositionHasChanged:
str = "ItemScenePositionHasChanged";
break;
+ case QGraphicsItem::ItemRotationChange:
+ str = "ItemRotationChange";
+ break;
+ case QGraphicsItem::ItemRotationHasChanged:
+ str = "ItemRotationHasChanged";
+ break;
+ case QGraphicsItem::ItemScaleChange:
+ str = "ItemScaleChange";
+ break;
+ case QGraphicsItem::ItemScaleHasChanged:
+ str = "ItemScaleHasChanged";
+ break;
+ case QGraphicsItem::ItemTransformOriginPointChange:
+ str = "ItemTransformOriginPointChange";
+ break;
+ case QGraphicsItem::ItemTransformOriginPointHasChanged:
+ str = "ItemTransformOriginPointHasChanged";
+ break;
}
debug << str;
return debug;
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h
index 56f94a2..117113f 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/gui/graphicsview/qgraphicsitem.h
@@ -139,7 +139,13 @@ public:
ItemZValueHasChanged,
ItemOpacityChange,
ItemOpacityHasChanged,
- ItemScenePositionHasChanged
+ ItemScenePositionHasChanged,
+ ItemRotationChange,
+ ItemRotationHasChanged,
+ ItemScaleChange,
+ ItemScaleHasChanged,
+ ItemTransformOriginPointChange,
+ ItemTransformOriginPointHasChanged
};
enum CacheMode {
diff --git a/src/gui/itemviews/qdirmodel.cpp b/src/gui/itemviews/qdirmodel.cpp
index 378a238..48599bc 100644
--- a/src/gui/itemviews/qdirmodel.cpp
+++ b/src/gui/itemviews/qdirmodel.cpp
@@ -1182,12 +1182,18 @@ QFileInfo QDirModel::fileInfo(const QModelIndex &index) const
void QDirModelPrivate::init()
{
+ Q_Q(QDirModel);
filters = QDir::AllEntries | QDir::NoDotAndDotDot;
sort = QDir::Name;
nameFilters << QLatin1String("*");
root.parent = 0;
root.info = QFileInfo();
clear(&root);
+ QHash<int, QByteArray> roles = q->roleNames();
+ roles.insertMulti(QDirModel::FileIconRole, "fileIcon"); // == Qt::decoration
+ roles.insert(QDirModel::FilePathRole, "filePath");
+ roles.insert(QDirModel::FileNameRole, "fileName");
+ q->setRoleNames(roles);
}
QDirModelPrivate::QDirNode *QDirModelPrivate::node(int row, QDirNode *parent) const
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index 13a5704..7f9ae8b 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -328,7 +328,7 @@ int QFontMetrics::height() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
Q_ASSERT(engine != 0);
- return qRound(engine->ascent() + engine->descent()) + 1;
+ return qRound(engine->ascent()) + qRound(engine->descent()) + 1;
}
/*!
@@ -356,7 +356,7 @@ int QFontMetrics::lineSpacing() const
{
QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
Q_ASSERT(engine != 0);
- return qRound(engine->leading() + engine->ascent() + engine->descent()) + 1;
+ return qRound(engine->leading()) + qRound(engine->ascent()) + qRound(engine->descent()) + 1;
}
/*!
diff --git a/src/gui/widgets/qlabel.cpp b/src/gui/widgets/qlabel.cpp
index b81f04f..bdbd0b0 100644
--- a/src/gui/widgets/qlabel.cpp
+++ b/src/gui/widgets/qlabel.cpp
@@ -53,6 +53,7 @@
#include <qurl.h>
#include "qlabel_p.h"
#include "private/qstylesheetstyle_p.h"
+#include <qmath.h>
QT_BEGIN_NAMESPACE
@@ -661,7 +662,9 @@ QSize QLabelPrivate::sizeForWidth(int w) const
} else {
control->setTextWidth(-1);
}
- br = QRect(QPoint(0, 0), control->size().toSize());
+
+ QSizeF controlSize = control->size();
+ br = QRect(QPoint(0, 0), QSize(qCeil(controlSize.width()), qCeil(controlSize.height())));
// restore state
control->setTextWidth(oldTextWidth);
diff --git a/src/imports/particles/qdeclarativeparticles.cpp b/src/imports/particles/qdeclarativeparticles.cpp
index bb6669a..83be59b 100644
--- a/src/imports/particles/qdeclarativeparticles.cpp
+++ b/src/imports/particles/qdeclarativeparticles.cpp
@@ -44,7 +44,6 @@
#include <private/qdeclarativeitem_p.h>
#include <private/qdeclarativepixmapcache_p.h>
-#include <private/qfxperf_p_p.h>
#include <QtCore/QAbstractAnimation>
#include <QPainter>
@@ -567,9 +566,6 @@ void QDeclarativeParticlesPrivate::tick(int time)
void QDeclarativeParticlesPrivate::createParticle(int time)
{
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QDeclarativePerfTimer<QDeclarativePerf::CreateParticle> x;
-#endif
Q_Q(QDeclarativeParticles);
QDeclarativeParticle p(time);
p.x = q->x() + q->width() * qreal(qrand()) / RAND_MAX - image.width()/2.0;
diff --git a/src/imports/particles/qdeclarativeparticles_p.h b/src/imports/particles/qdeclarativeparticles_p.h
index 993796d..9035e3e 100644
--- a/src/imports/particles/qdeclarativeparticles_p.h
+++ b/src/imports/particles/qdeclarativeparticles_p.h
@@ -111,7 +111,7 @@ class QDeclarativeParticleMotionWander : public QDeclarativeParticleMotion
Q_OBJECT
public:
QDeclarativeParticleMotionWander()
- : QDeclarativeParticleMotion(), particles(0), _xvariance(0), _yvariance(0) {}
+ : QDeclarativeParticleMotion(), particles(0), _xvariance(0), _yvariance(0), _pace(100) {}
virtual void advance(QDeclarativeParticle &, int interval);
virtual void created(QDeclarativeParticle &);
diff --git a/src/imports/webkit/qdeclarativewebview.cpp b/src/imports/webkit/qdeclarativewebview.cpp
index f8b2b88..0b85ae4 100644
--- a/src/imports/webkit/qdeclarativewebview.cpp
+++ b/src/imports/webkit/qdeclarativewebview.cpp
@@ -1239,96 +1239,11 @@ bool QDeclarativeWebPage::javaScriptPrompt(QWebFrame *originatingFrame, const QS
}
-/*
- Qt WebKit does not understand non-QWidget plugins, so dummy widgets
- are created, parented to a single dummy tool window.
-
- The requirements for QML object plugins are input to the Qt WebKit
- non-QWidget plugin support, which will obsolete this kludge.
-*/
-class QWidget_Dummy_Plugin : public QWidget
-{
- Q_OBJECT
-public:
- static QWidget *dummy_shared_parent()
- {
- static QWidget *dsp = 0;
- if (!dsp) {
- dsp = new QWidget(0,Qt::Tool);
- dsp->setGeometry(-10000,-10000,0,0);
- dsp->show();
- }
- return dsp;
- }
- QWidget_Dummy_Plugin(const QUrl& url, QDeclarativeWebView *view, const QStringList &paramNames, const QStringList &paramValues) :
- QWidget(dummy_shared_parent()),
- propertyNames(paramNames),
- propertyValues(paramValues),
- webview(view)
- {
- QDeclarativeEngine *engine = qmlEngine(webview);
- component = new QDeclarativeComponent(engine, url, this);
- item = 0;
- if (component->isLoading())
- connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), this, SLOT(qmlLoaded()));
- else
- qmlLoaded();
- }
-
-public Q_SLOTS:
- void qmlLoaded()
- {
- if (component->isError()) {
- // ### Could instead give these errors to the WebView to handle.
- qWarning() << component->errors();
- return;
- }
- item = qobject_cast<QDeclarativeItem*>(component->create(qmlContext(webview)));
- item->setParent(webview);
- QString jsObjName;
- for (int i=0; i<propertyNames.count(); ++i) {
- if (propertyNames[i] != QLatin1String("type") && propertyNames[i] != QLatin1String("data")) {
- item->setProperty(propertyNames[i].toUtf8(),propertyValues[i]);
- if (propertyNames[i] == QLatin1String("objectname"))
- jsObjName = propertyValues[i];
- }
- }
- if (!jsObjName.isNull()) {
- QWebFrame *f = webview->page()->mainFrame();
- f->addToJavaScriptWindowObject(jsObjName, item);
- }
- resizeEvent(0);
- delete component;
- component = 0;
- }
- void resizeEvent(QResizeEvent*)
- {
- if (item) {
- item->setX(x());
- item->setY(y());
- item->setWidth(width());
- item->setHeight(height());
- }
- }
-
-private:
- QDeclarativeComponent *component;
- QDeclarativeItem *item;
- QStringList propertyNames, propertyValues;
- QDeclarativeWebView *webview;
-};
-
QDeclarativeWebView *QDeclarativeWebPage::viewItem()
{
return static_cast<QDeclarativeWebView*>(parent());
}
-QObject *QDeclarativeWebPage::createPlugin(const QString &, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues)
-{
- QUrl comp = qmlContext(viewItem())->resolvedUrl(url);
- return new QWidget_Dummy_Plugin(comp,viewItem(),paramNames,paramValues);
-}
-
QWebPage *QDeclarativeWebPage::createWindow(WebWindowType type)
{
QDeclarativeWebView *newView = viewItem()->createWindow(type);
@@ -1338,5 +1253,3 @@ QWebPage *QDeclarativeWebPage::createWindow(WebWindowType type)
}
QT_END_NAMESPACE
-
-#include <qdeclarativewebview.moc>
diff --git a/src/imports/webkit/qdeclarativewebview_p.h b/src/imports/webkit/qdeclarativewebview_p.h
index 36b18a6..81581d8 100644
--- a/src/imports/webkit/qdeclarativewebview_p.h
+++ b/src/imports/webkit/qdeclarativewebview_p.h
@@ -69,7 +69,6 @@ public:
explicit QDeclarativeWebPage(QDeclarativeWebView *parent);
~QDeclarativeWebPage();
protected:
- QObject *createPlugin(const QString &classid, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);
QWebPage *createWindow(WebWindowType type);
void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID);
QString chooseFile(QWebFrame *originatingFrame, const QString& oldFile);
diff --git a/src/multimedia/effects/qsoundeffect.cpp b/src/multimedia/effects/qsoundeffect.cpp
index 53cad8e..ed9ab3f 100644
--- a/src/multimedia/effects/qsoundeffect.cpp
+++ b/src/multimedia/effects/qsoundeffect.cpp
@@ -80,7 +80,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlproperty int SoundEffect::loopCount
+ \qmlproperty int SoundEffect::loops
This property provides a way to control the number of times to repeat the sound on each play().
*/
@@ -104,7 +104,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlsignal SoundEffect::loopCountChanged()
+ \qmlsignal SoundEffect::loopsChanged()
This handler is called when the number of loops has changes.
*/
@@ -150,18 +150,18 @@ void QSoundEffect::setSource(const QUrl &url)
emit sourceChanged();
}
-int QSoundEffect::loopCount() const
+int QSoundEffect::loops() const
{
return d->loopCount();
}
-void QSoundEffect::setLoopCount(int loopCount)
+void QSoundEffect::setLoops(int loopCount)
{
if (d->loopCount() == loopCount)
return;
d->setLoopCount(loopCount);
- emit loopCountChanged();
+ emit loopsChanged();
}
int QSoundEffect::volume() const
diff --git a/src/multimedia/effects/qsoundeffect_p.h b/src/multimedia/effects/qsoundeffect_p.h
index ec6a2f7..05207a0 100644
--- a/src/multimedia/effects/qsoundeffect_p.h
+++ b/src/multimedia/effects/qsoundeffect_p.h
@@ -67,7 +67,7 @@ class Q_MULTIMEDIA_EXPORT QSoundEffect : public QObject
{
Q_OBJECT
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(int loopCount READ loopCount WRITE setLoopCount NOTIFY loopCountChanged)
+ Q_PROPERTY(int loops READ loops WRITE setLoops NOTIFY loopsChanged)
Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged)
Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
@@ -78,8 +78,8 @@ public:
QUrl source() const;
void setSource(const QUrl &url);
- int loopCount() const;
- void setLoopCount(int loopCount);
+ int loops() const;
+ void setLoops(int loopCount);
int volume() const;
void setVolume(int volume);
@@ -89,7 +89,7 @@ public:
Q_SIGNALS:
void sourceChanged();
- void loopCountChanged();
+ void loopsChanged();
void volumeChanged();
void mutedChanged();