summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-03-10 17:47:25 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-03-10 17:47:25 (GMT)
commita2e78555fe40726c6e3ace09db34ec2afd1cee59 (patch)
tree057fa3fb2fc020e34264097affd26ff2baad068b /src/declarative
parentb80466364fe6c6ca030b884f2d8df94bdfa477b9 (diff)
parente5922ab126f3532483b18720ce893d6be826d50e (diff)
downloadQt-a2e78555fe40726c6e3ace09db34ec2afd1cee59.zip
Qt-a2e78555fe40726c6e3ace09db34ec2afd1cee59.tar.gz
Qt-a2e78555fe40726c6e3ace09db34ec2afd1cee59.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (39 commits) Document - and use - the qmlRegisterXXX template functions when loading debug import plugins on Mac, try with _debug.dylib suffix fix inclusion of qt_targets.pri in qimportbase.pri Use TARGETPATH instead of hardcoding locations Fix location in which webkit import is stored in builddir Oooops --- revert wrong commit Remove accidentally submitted code Ensure currentIndex NOTIFY is emitted when currentIndex changes due to model change. Unify binding optimizer and QtScript binding signal management logic Schedule view relayout after itemsInserted/Removed() Use no-version-specified to mean any version (used to work, fixed again, URL redirection for font loader URL redirection for AnimatedImage Technically, Location can be relative (never is though...) URL redirection for normal images. URL redirection for components resources. URL redirects for border image. Implement URL redirection for types and XmlListModel. Doc Link with the correct library for TCommDbConnPref ...
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp16
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanimatedimage_p_p.h3
-rw-r--r--src/declarative/graphicsitems/qdeclarativeborderimage.cpp16
-rw-r--r--src/declarative/graphicsitems/qdeclarativeborderimage_p_p.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp3
-rw-r--r--src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp8
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp112
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview_p.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp58
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.h27
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem_p.h10
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp134
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp102
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp9
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea.cpp1
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea_p_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativepainteditem.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview_p_p.h5
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners.cpp7
-rw-r--r--src/declarative/graphicsitems/qdeclarativerepeater.cpp56
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp14
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp10
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p_p.h1
-rw-r--r--src/declarative/qml/qdeclarative.h3
-rw-r--r--src/declarative/qml/qdeclarativecompiledbindings.cpp97
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp20
-rw-r--r--src/declarative/qml/qdeclarativecompositetypemanager.cpp50
-rw-r--r--src/declarative/qml/qdeclarativecompositetypemanager_p.h3
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp7
-rw-r--r--src/declarative/qml/qdeclarativecontext_p.h5
-rw-r--r--src/declarative/qml/qdeclarativecustomparser_p.h3
-rw-r--r--src/declarative/qml/qdeclarativedeclarativedata_p.h17
-rw-r--r--src/declarative/qml/qdeclarativedirparser.cpp5
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp75
-rw-r--r--src/declarative/qml/qdeclarativeengine.h4
-rw-r--r--src/declarative/qml/qdeclarativeexpression.cpp153
-rw-r--r--src/declarative/qml/qdeclarativeexpression_p.h19
-rw-r--r--src/declarative/qml/qdeclarativenotifier.cpp109
-rw-r--r--src/declarative/qml/qdeclarativenotifier_p.h272
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass.cpp153
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass_p.h3
-rw-r--r--src/declarative/qml/qdeclarativepropertycache.cpp4
-rw-r--r--src/declarative/qml/qdeclarativepropertycache_p.h12
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp2
-rw-r--r--src/declarative/qml/qdeclarativexmlhttprequest.cpp2
-rw-r--r--src/declarative/qml/qml.pri2
-rw-r--r--src/declarative/util/qdeclarativefontloader.cpp18
-rw-r--r--src/declarative/util/qdeclarativepixmapcache.cpp41
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp7
-rw-r--r--src/declarative/util/qdeclarativeutilmodule.cpp75
-rw-r--r--src/declarative/util/qdeclarativeview.cpp4
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp21
56 files changed, 1212 insertions, 585 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp
index 20b1de3..2c2e034 100644
--- a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp
@@ -247,9 +247,25 @@ void QDeclarativeAnimatedImage::setSource(const QUrl &url)
emit statusChanged(d->status);
}
+#define ANIMATEDIMAGE_MAXIMUM_REDIRECT_RECURSION 16
+
void QDeclarativeAnimatedImage::movieRequestFinished()
{
Q_D(QDeclarativeAnimatedImage);
+
+ d->redirectCount++;
+ if (d->redirectCount < ANIMATEDIMAGE_MAXIMUM_REDIRECT_RECURSION) {
+ QVariant redirect = d->reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ if (redirect.isValid()) {
+ QUrl url = d->reply->url().resolved(redirect.toUrl());
+ d->reply->deleteLater();
+ d->reply = 0;
+ setSource(url);
+ return;
+ }
+ }
+ d->redirectCount=0;
+
d->_movie = new QMovie(d->reply);
if (!d->_movie->isValid()){
qWarning() << "Error Reading Animated Image File " << d->url;
diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage_p_p.h b/src/declarative/graphicsitems/qdeclarativeanimatedimage_p_p.h
index 39bb3e5..273c1d6 100644
--- a/src/declarative/graphicsitems/qdeclarativeanimatedimage_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage_p_p.h
@@ -66,7 +66,7 @@ class QDeclarativeAnimatedImagePrivate : public QDeclarativeImagePrivate
public:
QDeclarativeAnimatedImagePrivate()
- : playing(true), paused(false), preset_currentframe(0), _movie(0), reply(0)
+ : playing(true), paused(false), preset_currentframe(0), _movie(0), reply(0), redirectCount(0)
{
}
@@ -75,6 +75,7 @@ public:
int preset_currentframe;
QMovie *_movie;
QNetworkReply *reply;
+ int redirectCount;
};
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
index de16668..a7534b8 100644
--- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
@@ -191,7 +191,7 @@ void QDeclarativeBorderImage::load()
update();
} else {
d->status = Loading;
- if (d->url.path().endsWith(QLatin1String(".sci"))) {
+ if (d->url.path().endsWith(QLatin1String("sci"))) {
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
QString lf = toLocalFileOrQrc(d->url);
if (!lf.isEmpty()) {
@@ -400,9 +400,23 @@ void QDeclarativeBorderImage::requestFinished()
update();
}
+#define BORDERIMAGE_MAX_REDIRECT 16
+
void QDeclarativeBorderImage::sciRequestFinished()
{
Q_D(QDeclarativeBorderImage);
+
+ d->redirectCount++;
+ if (d->redirectCount < BORDERIMAGE_MAX_REDIRECT) {
+ QVariant redirect = d->sciReply->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ if (redirect.isValid()) {
+ QUrl url = d->sciReply->url().resolved(redirect.toUrl());
+ setSource(url);
+ return;
+ }
+ }
+ d->redirectCount=0;
+
if (d->sciReply->error() != QNetworkReply::NoError) {
d->status = Error;
d->sciReply->deleteLater();
diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage_p_p.h b/src/declarative/graphicsitems/qdeclarativeborderimage_p_p.h
index b9cf73a..82b9ebf 100644
--- a/src/declarative/graphicsitems/qdeclarativeborderimage_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeborderimage_p_p.h
@@ -68,7 +68,8 @@ public:
: border(0), sciReply(0),
sciPendingPixmapCache(false),
horizontalTileMode(QDeclarativeBorderImage::Stretch),
- verticalTileMode(QDeclarativeBorderImage::Stretch)
+ verticalTileMode(QDeclarativeBorderImage::Stretch),
+ redirectCount(0)
{
}
@@ -90,6 +91,7 @@ public:
bool sciPendingPixmapCache;
QDeclarativeBorderImage::TileMode horizontalTileMode;
QDeclarativeBorderImage::TileMode verticalTileMode;
+ int redirectCount;
};
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 67068a0..9ccb3b6 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -264,6 +264,7 @@ void QDeclarativeFlickablePrivate::fixupY()
void QDeclarativeFlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent)
{
+ Q_Q(QDeclarativeFlickable);
if (data.move.value() > minExtent || maxExtent > minExtent) {
timeline.reset(data.move);
if (data.move.value() != minExtent) {
@@ -273,6 +274,7 @@ void QDeclarativeFlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal
timeline.move(data.move, minExtent, QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4);
} else {
data.move.setValue(minExtent);
+ q->viewportMoved();
}
}
//emit flickingChanged();
@@ -284,6 +286,7 @@ void QDeclarativeFlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal
timeline.move(data.move, maxExtent, QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4);
} else {
data.move.setValue(maxExtent);
+ q->viewportMoved();
}
//emit flickingChanged();
} else {
diff --git a/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp b/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp
index 1977817..eb5b6ce 100644
--- a/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegraphicsobjectcontainer.cpp
@@ -65,12 +65,12 @@ public:
if (graphicsObject && graphicsObject->isWidget()) {
if (!on) {
graphicsObject->removeEventFilter(q);
- QObject::disconnect(q, SIGNAL(widthChanged()), q, SLOT(_q_updateSize()));
- QObject::disconnect(q, SIGNAL(heightChanged()), q, SLOT(_q_updateSize()));
+ QObject::disconnect(q, SIGNAL(widthChanged(qreal)), q, SLOT(_q_updateSize()));
+ QObject::disconnect(q, SIGNAL(heightChanged(qreal)), q, SLOT(_q_updateSize()));
} else {
graphicsObject->installEventFilter(q);
- QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(_q_updateSize()));
- QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(_q_updateSize()));
+ QObject::connect(q, SIGNAL(widthChanged(qreal)), q, SLOT(_q_updateSize()));
+ QObject::connect(q, SIGNAL(heightChanged(qreal)), q, SLOT(_q_updateSize()));
}
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 60ffbe2..e66bcf6 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -97,7 +97,7 @@ class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate
public:
QDeclarativeGridViewPrivate()
: currentItem(0), flow(QDeclarativeGridView::LeftToRight)
- , visiblePos(0), visibleIndex(0) , currentIndex(-1)
+ , visibleIndex(0) , currentIndex(-1)
, cellWidth(100), cellHeight(100), columns(1), requestedIndex(-1)
, highlightRangeStart(0), highlightRangeEnd(0), highlightRange(QDeclarativeGridView::NoHighlightRange)
, highlightComponent(0), highlight(0), trackedItem(0)
@@ -305,7 +305,6 @@ public:
QHash<QDeclarativeItem*,int> unrequestedItems;
FxGridItem *currentItem;
QDeclarativeGridView::Flow flow;
- int visiblePos;
int visibleIndex;
int currentIndex;
int cellWidth;
@@ -350,7 +349,6 @@ void QDeclarativeGridViewPrivate::clear()
for (int i = 0; i < visibleItems.count(); ++i)
releaseItem(visibleItems.at(i));
visibleItems.clear();
- visiblePos = 0;
visibleIndex = 0;
releaseItem(currentItem);
currentItem = 0;
@@ -536,7 +534,7 @@ void QDeclarativeGridViewPrivate::scheduleLayout()
Q_Q(QDeclarativeGridView);
if (!layoutScheduled) {
layoutScheduled = true;
- QMetaObject::invokeMethod(q, "layout", Qt::QueuedConnection);
+ QCoreApplication::postEvent(q, new QEvent(QEvent::User), Qt::HighEventPriority);
}
}
@@ -748,21 +746,26 @@ void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m
if (currentItem && currentItem->rowPos() - position() != highlightRangeStart) {
qreal pos = currentItem->rowPos() - highlightRangeStart;
timeline.reset(data.move);
- if (fixupDuration)
+ if (fixupDuration) {
timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
- else
+ } else {
data.move.setValue(-pos);
+ q->viewportMoved();
+ }
vTime = timeline.time();
}
} else if (snapMode != QDeclarativeGridView::NoSnap) {
- qreal pos = qMax(qMin(snapPosAt(position()) - highlightRangeStart, -maxExtent), -minExtent);
- qreal dist = qAbs(data.move + pos);
+ qreal pos = -snapPosAt(-(data.move.value() - highlightRangeStart)) + highlightRangeStart;
+ pos = qMin(qMax(pos, maxExtent), minExtent);
+ qreal dist = qAbs(data.move.value() - pos);
if (dist > 0) {
timeline.reset(data.move);
- if (fixupDuration)
- timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
- else
- data.move.setValue(-pos);
+ if (fixupDuration) {
+ timeline.move(data.move, pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
+ } else {
+ data.move.setValue(pos);
+ q->viewportMoved();
+ }
vTime = timeline.time();
}
} else {
@@ -788,7 +791,7 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
if (FxGridItem *item = firstVisibleItem())
maxDistance = qAbs(item->rowPos() + data.move.value());
} else if (data.move.value() < minExtent) {
- maxDistance = qAbs(minExtent - data.move.value() + (overShoot?overShootDistance(velocity, vSize):0));
+ maxDistance = qAbs(minExtent - data.move.value());
}
if (snapMode != QDeclarativeGridView::SnapToRow && highlightRange != QDeclarativeGridView::StrictlyEnforceRange)
data.flickTarget = minExtent;
@@ -797,7 +800,7 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
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()) + (overShoot?overShootDistance(velocity, vSize):0);
+ maxDistance = qAbs(maxExtent - data.move.value());
}
if (snapMode != QDeclarativeGridView::SnapToRow && highlightRange != QDeclarativeGridView::StrictlyEnforceRange)
data.flickTarget = maxExtent;
@@ -816,7 +819,8 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
qreal maxAccel = v2 / (2.0f * maxDistance);
qreal overshootDist = 0.0;
if (maxAccel < accel) {
- qreal dist = v2 / (accel * 2.0);
+ // + rowSize()/4 to encourage moving at least one item in the flick direction
+ qreal dist = v2 / (accel * 2.0) + rowSize()/4;
if (v > 0)
dist = -dist;
data.flickTarget = -snapPosAt(-(data.move.value() - highlightRangeStart) + dist) + highlightRangeStart;
@@ -1421,6 +1425,17 @@ void QDeclarativeGridView::setSnapMode(SnapMode mode)
}
}
+bool QDeclarativeGridView::event(QEvent *event)
+{
+ Q_D(QDeclarativeGridView);
+ if (event->type() == QEvent::User) {
+ d->layout();
+ return true;
+ }
+
+ return QDeclarativeFlickable::event(event);
+}
+
void QDeclarativeGridView::viewportMoved()
{
Q_D(QDeclarativeGridView);
@@ -1763,7 +1778,7 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count)
{
Q_D(QDeclarativeGridView);
if (!d->visibleItems.count() || d->model->count() <= 1) {
- refill();
+ d->scheduleLayout();
d->updateCurrent(qMax(0, qMin(d->currentIndex, d->model->count()-1)));
emit countChanged();
return;
@@ -1792,8 +1807,9 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count)
d->currentIndex += count;
if (d->currentItem)
d->currentItem->index = d->currentIndex;
+ emit currentIndexChanged();
}
- d->layout();
+ d->scheduleLayout();
emit countChanged();
return;
}
@@ -1823,9 +1839,21 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count)
}
}
+ // Update the indexes of the following visible items.
+ for (int i = 0; i < d->visibleItems.count(); ++i) {
+ FxGridItem *listItem = d->visibleItems.at(i);
+ if (listItem->index != -1 && listItem->index >= modelIndex)
+ listItem->index += count;
+ }
+
+ bool addedVisible = false;
QList<FxGridItem*> added;
int i = 0;
while (i < insertCount && rowPos <= to + d->rowSize()*(d->columns - (colPos/d->colSize()))/qreal(d->columns)) {
+ if (!addedVisible) {
+ d->scheduleLayout();
+ addedVisible = true;
+ }
FxGridItem *item = d->createItem(modelIndex + i);
d->visibleItems.insert(index, item);
item->setPosition(colPos, rowPos);
@@ -1846,6 +1874,15 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count)
}
}
+ // update visibleIndex
+ d->visibleIndex = 0;
+ for (QList<FxGridItem*>::Iterator it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) {
+ if ((*it)->index != -1) {
+ d->visibleIndex = (*it)->index;
+ break;
+ }
+ }
+
if (d->currentIndex >= modelIndex) {
// adjust current item index
d->currentIndex += count;
@@ -1853,18 +1890,13 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count)
d->currentItem->index = d->currentIndex;
d->currentItem->setPosition(d->colPosAt(d->currentIndex), d->rowPosAt(d->currentIndex));
}
- }
- // Update the indexes of the following visible items.
- for (; index < d->visibleItems.count(); ++index) {
- FxGridItem *listItem = d->visibleItems.at(index);
- if (listItem->index != -1)
- listItem->index += count;
+ emit currentIndexChanged();
}
// everything is in order now - emit add() signal
for (int j = 0; j < added.count(); ++j)
added.at(j)->attached->emitAdd();
- d->layout();
+
emit countChanged();
}
@@ -1880,8 +1912,10 @@ void QDeclarativeGridView::itemsRemoved(int modelIndex, int count)
FxGridItem *item = *it;
if (item->index == -1 || item->index < modelIndex) {
// already removed, or before removed items
- if (item->index < modelIndex)
+ if (item->index < modelIndex && !removedVisible) {
+ d->scheduleLayout();
removedVisible = true;
+ }
++it;
} else if (item->index >= modelIndex + count) {
// after removed items
@@ -1889,7 +1923,10 @@ void QDeclarativeGridView::itemsRemoved(int modelIndex, int count)
++it;
} else {
// removed item
- removedVisible = true;
+ if (!removedVisible) {
+ d->scheduleLayout();
+ removedVisible = true;
+ }
item->attached->emitRemove();
if (item->attached->delayRemove()) {
item->index = -1;
@@ -1907,6 +1944,7 @@ void QDeclarativeGridView::itemsRemoved(int modelIndex, int count)
d->currentIndex -= count;
if (d->currentItem)
d->currentItem->index -= count;
+ emit currentIndexChanged();
} else if (currentRemoved) {
// current item has been removed.
d->releaseItem(d->currentItem);
@@ -1916,6 +1954,7 @@ void QDeclarativeGridView::itemsRemoved(int modelIndex, int count)
}
// update visibleIndex
+ d->visibleIndex = 0;
for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) {
if ((*it)->index != -1) {
d->visibleIndex = (*it)->index;
@@ -1923,27 +1962,16 @@ void QDeclarativeGridView::itemsRemoved(int modelIndex, int count)
}
}
- if (removedVisible) {
- if (d->visibleItems.isEmpty()) {
- d->visibleIndex = 0;
- d->setPosition(0);
- refill();
- } else {
- // Correct the positioning of the items
- d->scheduleLayout();
- }
+ if (removedVisible && d->visibleItems.isEmpty()) {
+ d->timeline.clear();
+ d->setPosition(0);
+ if (d->model->count() == 0)
+ update();
}
emit countChanged();
}
-void QDeclarativeGridView::layout()
-{
- Q_D(QDeclarativeGridView);
- if (d->layoutScheduled)
- d->layout();
-}
-
void QDeclarativeGridView::destroyRemoved()
{
Q_D(QDeclarativeGridView);
diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/declarative/graphicsitems/qdeclarativegridview_p.h
index 787c04c..8e253e5 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h
@@ -164,6 +164,7 @@ Q_SIGNALS:
void snapModeChanged();
protected:
+ virtual bool event(QEvent *event);
virtual void viewportMoved();
virtual qreal minYExtent() const;
virtual qreal maxYExtent() const;
@@ -181,7 +182,6 @@ private Q_SLOTS:
void destroyRemoved();
void createdItem(int index, QDeclarativeItem *item);
void destroyingItem(QDeclarativeItem *item);
- void layout();
private:
void refill();
@@ -192,7 +192,7 @@ class QDeclarativeGridViewAttached : public QObject
Q_OBJECT
public:
QDeclarativeGridViewAttached(QObject *parent)
- : QObject(parent), m_isCurrent(false), m_delayRemove(false) {}
+ : QObject(parent), m_view(0), m_isCurrent(false), m_delayRemove(false) {}
~QDeclarativeGridViewAttached() {}
Q_PROPERTY(QDeclarativeGridView *view READ view CONSTANT)
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index c7d7a4c..4ba80ad 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -273,7 +273,7 @@ void QDeclarativeContents::calcHeight()
m_height = qMax(bottom - top, qreal(0.0));
if (m_height != oldheight || m_y != oldy)
- emit rectChanged();
+ emit rectChanged(rectF());
}
//TODO: optimization: only check sender(), if there is one
@@ -301,7 +301,7 @@ void QDeclarativeContents::calcWidth()
m_width = qMax(right - left, qreal(0.0));
if (m_width != oldwidth || m_x != oldx)
- emit rectChanged();
+ emit rectChanged(rectF());
}
void QDeclarativeContents::setItem(QDeclarativeItem *item)
@@ -313,11 +313,11 @@ void QDeclarativeContents::setItem(QDeclarativeItem *item)
QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(i));
if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects?
continue;
- connect(child, SIGNAL(heightChanged()), this, SLOT(calcHeight()));
+ connect(child, SIGNAL(heightChanged(qreal)), this, SLOT(calcHeight()));
connect(child, SIGNAL(yChanged()), this, SLOT(calcHeight()));
- connect(child, SIGNAL(widthChanged()), this, SLOT(calcWidth()));
+ connect(child, SIGNAL(widthChanged(qreal)), this, SLOT(calcWidth()));
connect(child, SIGNAL(xChanged()), this, SLOT(calcWidth()));
- connect(this, SIGNAL(rectChanged()), m_item, SIGNAL(childrenRectChanged()));
+ connect(this, SIGNAL(rectChanged(QRectF)), m_item, SIGNAL(childrenRectChanged(QRectF)));
}
calcHeight();
@@ -1662,7 +1662,7 @@ void QDeclarativeItem::setClip(bool c)
if (clip() == c)
return;
setFlag(ItemClipsChildrenToShape, c);
- emit clipChanged();
+ emit clipChanged(c);
}
/*!
@@ -1802,11 +1802,11 @@ void QDeclarativeItem::geometryChanged(const QRectF &newGeometry,
if (newGeometry.x() != oldGeometry.x())
emit xChanged();
if (newGeometry.width() != oldGeometry.width())
- emit widthChanged();
+ emit widthChanged(newGeometry.width());
if (newGeometry.y() != oldGeometry.y())
emit yChanged();
if (newGeometry.height() != oldGeometry.height())
- emit heightChanged();
+ emit heightChanged(newGeometry.height());
for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
@@ -2068,7 +2068,6 @@ void QDeclarativeItem::setBaselineOffset(qreal offset)
return;
d->_baselineOffset = offset;
- emit baselineOffsetChanged();
for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
@@ -2078,6 +2077,7 @@ void QDeclarativeItem::setBaselineOffset(qreal offset)
anchor->updateVerticalAnchors();
}
}
+ emit baselineOffsetChanged(offset);
}
/*!
@@ -2224,7 +2224,7 @@ void QDeclarativeItem::setKeepMouseGrab(bool keep)
}
/*!
- \qmlmethod object Item::mapFromItem(Item item, int x, int y)
+ \qmlmethod object Item::mapFromItem(Item item, real x, real y)
Maps the point (\a x, \a y), which is in \a item's coordinate system, to
this item's coordinate system, and returns an object with \c x and \c y
@@ -2233,7 +2233,7 @@ void QDeclarativeItem::setKeepMouseGrab(bool keep)
If \a item is a \c null value, this maps the point from the coordinate
system of the root QML view.
*/
-QScriptValue QDeclarativeItem::mapFromItem(const QScriptValue &item, int x, int y) const
+QScriptValue QDeclarativeItem::mapFromItem(const QScriptValue &item, qreal x, qreal y) const
{
QScriptValue sv = QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(this))->newObject();
QDeclarativeItem *itemObj = qobject_cast<QDeclarativeItem*>(item.toQObject());
@@ -2244,13 +2244,13 @@ QScriptValue QDeclarativeItem::mapFromItem(const QScriptValue &item, int x, int
// If QGraphicsItem::mapFromItem() is called with 0, behaves the same as mapFromScene()
QPointF p = qobject_cast<QGraphicsItem*>(this)->mapFromItem(itemObj, x, y);
- sv.setProperty("x", p.x());
- sv.setProperty("y", p.y());
+ sv.setProperty(QLatin1String("x"), p.x());
+ sv.setProperty(QLatin1String("y"), p.y());
return sv;
}
/*!
- \qmlmethod object Item::mapToItem(Item item, int x, int y)
+ \qmlmethod object Item::mapToItem(Item item, real x, real y)
Maps the point (\a x, \a y), which is in this item's coordinate system, to
\a item's coordinate system, and returns an object with \c x and \c y
@@ -2259,7 +2259,7 @@ QScriptValue QDeclarativeItem::mapFromItem(const QScriptValue &item, int x, int
If \a item is a \c null value, this maps \a x and \a y to the coordinate
system of the root QML view.
*/
-QScriptValue QDeclarativeItem::mapToItem(const QScriptValue &item, int x, int y) const
+QScriptValue QDeclarativeItem::mapToItem(const QScriptValue &item, qreal x, qreal y) const
{
QScriptValue sv = QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(this))->newObject();
QDeclarativeItem *itemObj = qobject_cast<QDeclarativeItem*>(item.toQObject());
@@ -2270,23 +2270,15 @@ QScriptValue QDeclarativeItem::mapToItem(const QScriptValue &item, int x, int y)
// If QGraphicsItem::mapToItem() is called with 0, behaves the same as mapToScene()
QPointF p = qobject_cast<QGraphicsItem*>(this)->mapToItem(itemObj, x, y);
- sv.setProperty("x", p.x());
- sv.setProperty("y", p.y());
+ sv.setProperty(QLatin1String("x"), p.x());
+ sv.setProperty(QLatin1String("y"), p.y());
return sv;
}
-/*!
- \internal
-
- This function emits the \e focusChanged signal.
-
- Subclasses overriding this function should call up
- to their base class.
-*/
-void QDeclarativeItem::focusChanged(bool flag)
+void QDeclarativeItemPrivate::focusChanged(bool flag)
{
- Q_UNUSED(flag);
- emit focusChanged();
+ Q_Q(QDeclarativeItem);
+ emit q->focusChanged(flag);
}
/*! \internal */
@@ -2579,14 +2571,16 @@ QPointF QDeclarativeItemPrivate::computeTransformOrigin() const
/*! \internal */
bool QDeclarativeItem::sceneEvent(QEvent *event)
{
+ Q_D(QDeclarativeItem);
if (event->type() == QEvent::KeyPress) {
QKeyEvent *k = static_cast<QKeyEvent *>(event);
-
if ((k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) &&
!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) {
keyPressEvent(static_cast<QKeyEvent *>(event));
if (!event->isAccepted())
return QGraphicsItem::sceneEvent(event);
+ else
+ return true;
} else {
return QGraphicsItem::sceneEvent(event);
}
@@ -2595,7 +2589,7 @@ bool QDeclarativeItem::sceneEvent(QEvent *event)
if (event->type() == QEvent::FocusIn ||
event->type() == QEvent::FocusOut) {
- focusChanged(hasFocus());
+ d->focusChanged(hasFocus());
}
return rv;
}
@@ -2608,7 +2602,7 @@ QVariant QDeclarativeItem::itemChange(GraphicsItemChange change,
Q_D(const QDeclarativeItem);
switch (change) {
case ItemParentHasChanged:
- emit parentChanged();
+ emit parentChanged(parentItem());
break;
case ItemChildAddedChange:
case ItemChildRemovedChange:
@@ -2721,7 +2715,7 @@ void QDeclarativeItem::setSmooth(bool smooth)
if (d->smooth == smooth)
return;
d->smooth = smooth;
- emit smoothChanged();
+ emit smoothChanged(smooth);
update();
}
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h
index 2053eba..9b85ba3 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem.h
@@ -42,8 +42,8 @@
#ifndef QDECLARATIVEITEM_H
#define QDECLARATIVEITEM_H
-#include <qdeclarative.h>
-#include <qdeclarativecomponent.h>
+#include <QtDeclarative/qdeclarative.h>
+#include <QtDeclarative/qdeclarativecomponent.h>
#include <QtCore/QObject>
#include <QtCore/QList>
@@ -161,8 +161,8 @@ public:
bool keepMouseGrab() const;
void setKeepMouseGrab(bool);
- Q_INVOKABLE QScriptValue mapFromItem(const QScriptValue &item, int x, int y) const;
- Q_INVOKABLE QScriptValue mapToItem(const QScriptValue &item, int x, int y) const;
+ Q_INVOKABLE QScriptValue mapFromItem(const QScriptValue &item, qreal x, qreal y) const;
+ Q_INVOKABLE QScriptValue mapToItem(const QScriptValue &item, qreal x, qreal y) const;
QDeclarativeAnchorLine left() const;
QDeclarativeAnchorLine right() const;
@@ -173,18 +173,18 @@ public:
QDeclarativeAnchorLine baseline() const;
Q_SIGNALS:
- void widthChanged();
- void heightChanged();
+ void widthChanged(qreal);
+ void heightChanged(qreal);
void childrenChanged();
- void childrenRectChanged();
- void baselineOffsetChanged();
+ void childrenRectChanged(const QRectF &);
+ void baselineOffsetChanged(qreal);
void stateChanged(const QString &);
- void focusChanged();
- void wantsFocusChanged();
- void parentChanged();
+ void focusChanged(bool);
+ void wantsFocusChanged(bool);
+ void parentChanged(QDeclarativeItem *);
void transformOriginChanged(TransformOrigin);
- void smoothChanged();
- void clipChanged();
+ void smoothChanged(bool);
+ void clipChanged(bool);
protected:
bool isComponentComplete() const;
@@ -199,7 +199,6 @@ protected:
virtual void classBegin();
virtual void componentComplete();
- virtual void focusChanged(bool);
virtual void keyPressEvent(QKeyEvent *event);
virtual void keyReleaseEvent(QKeyEvent *event);
virtual void inputMethodEvent(QInputMethodEvent *);
diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h
index e424970..55df063 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h
@@ -91,7 +91,7 @@ public Q_SLOTS:
void calcWidth();
Q_SIGNALS:
- void rectChanged();
+ void rectChanged(QRectF);
private:
QDeclarativeItem *m_item;
@@ -101,7 +101,7 @@ private:
qreal m_height;
};
-class QDeclarativeItemPrivate : public QGraphicsItemPrivate
+class Q_DECLARATIVE_EXPORT QDeclarativeItemPrivate : public QGraphicsItemPrivate
{
Q_DECLARE_PUBLIC(QDeclarativeItem)
@@ -240,7 +240,7 @@ public:
// Reimplemented from QGraphicsItemPrivate
virtual void subFocusItemChange()
{
- emit q_func()->wantsFocusChanged();
+ emit q_func()->wantsFocusChanged(subFocusItem != 0);
}
// Reimplemented from QGraphicsItemPrivate
@@ -255,9 +255,11 @@ public:
}
}
+ virtual void focusChanged(bool);
+
static int consistentTime;
static QTime currentTime();
- static void Q_DECLARATIVE_EXPORT setConsistentTime(int t);
+ static void setConsistentTime(int t);
static void start(QTime &);
static int elapsed(QTime &);
static int restart(QTime &);
diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
index 25660f8..2d05c7c 100644
--- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
@@ -82,76 +82,76 @@
void QDeclarativeItemModule::defineModule()
{
- QML_REGISTER_TYPE(Qt,4,6,AnimatedImage,QDeclarativeAnimatedImage);
- QML_REGISTER_TYPE(Qt,4,6,Blur,QGraphicsBlurEffect);
- QML_REGISTER_TYPE(Qt,4,6,BorderImage,QDeclarativeBorderImage);
- QML_REGISTER_TYPE(Qt,4,6,Colorize,QGraphicsColorizeEffect);
- QML_REGISTER_TYPE(Qt,4,6,Column,QDeclarativeColumn);
- QML_REGISTER_TYPE(Qt,4,6,Drag,QDeclarativeDrag);
- QML_REGISTER_TYPE(Qt,4,6,DropShadow,QGraphicsDropShadowEffect);
- QML_REGISTER_TYPE(Qt,4,6,Flickable,QDeclarativeFlickable);
- QML_REGISTER_TYPE(Qt,4,6,Flipable,QDeclarativeFlipable);
- QML_REGISTER_TYPE(Qt,4,6,Flow,QDeclarativeFlow);
- QML_REGISTER_TYPE(Qt,4,6,FocusPanel,QDeclarativeFocusPanel);
- QML_REGISTER_TYPE(Qt,4,6,FocusScope,QDeclarativeFocusScope);
- QML_REGISTER_TYPE(Qt,4,6,Gradient,QDeclarativeGradient);
- QML_REGISTER_TYPE(Qt,4,6,GradientStop,QDeclarativeGradientStop);
- QML_REGISTER_TYPE(Qt,4,6,GraphicsObjectContainer,QDeclarativeGraphicsObjectContainer);
- QML_REGISTER_TYPE(Qt,4,6,Grid,QDeclarativeGrid);
- QML_REGISTER_TYPE(Qt,4,6,GridView,QDeclarativeGridView);
- QML_REGISTER_TYPE(Qt,4,6,Image,QDeclarativeImage);
- QML_REGISTER_TYPE(Qt,4,6,Item,QDeclarativeItem);
- QML_REGISTER_TYPE(Qt,4,6,KeyNavigation,QDeclarativeKeyNavigationAttached);
- QML_REGISTER_TYPE(Qt,4,6,Keys,QDeclarativeKeysAttached);
- QML_REGISTER_TYPE(Qt,4,6,LayoutItem,QDeclarativeLayoutItem);
- QML_REGISTER_TYPE(Qt,4,6,ListView,QDeclarativeListView);
- QML_REGISTER_TYPE(Qt,4,6,Loader,QDeclarativeLoader);
- QML_REGISTER_TYPE(Qt,4,6,MouseArea,QDeclarativeMouseArea);
- QML_REGISTER_TYPE(Qt,4,6,Opacity,QGraphicsOpacityEffect);
- QML_REGISTER_TYPE(Qt,4,6,ParticleMotion,QDeclarativeParticleMotion);
- QML_REGISTER_TYPE(Qt,4,6,ParticleMotionGravity,QDeclarativeParticleMotionGravity);
- QML_REGISTER_TYPE(Qt,4,6,ParticleMotionLinear,QDeclarativeParticleMotionLinear);
- QML_REGISTER_TYPE(Qt,4,6,ParticleMotionWander,QDeclarativeParticleMotionWander);
- QML_REGISTER_TYPE(Qt,4,6,Particles,QDeclarativeParticles);
- QML_REGISTER_TYPE(Qt,4,6,Path,QDeclarativePath);
- QML_REGISTER_TYPE(Qt,4,6,PathAttribute,QDeclarativePathAttribute);
- QML_REGISTER_TYPE(Qt,4,6,PathCubic,QDeclarativePathCubic);
- QML_REGISTER_TYPE(Qt,4,6,PathLine,QDeclarativePathLine);
- QML_REGISTER_TYPE(Qt,4,6,PathPercent,QDeclarativePathPercent);
- QML_REGISTER_TYPE(Qt,4,6,PathQuad,QDeclarativePathQuad);
- QML_REGISTER_TYPE(Qt,4,6,PathView,QDeclarativePathView);
- QML_REGISTER_TYPE(Qt,4,6,Pen,QDeclarativePen);
- QML_REGISTER_TYPE(Qt,4,6,QIntValidator,QIntValidator);
+ qmlRegisterType<QDeclarativeAnimatedImage>("Qt",4,6,"AnimatedImage");
+ qmlRegisterType<QGraphicsBlurEffect>("Qt",4,6,"Blur");
+ qmlRegisterType<QDeclarativeBorderImage>("Qt",4,6,"BorderImage");
+ qmlRegisterType<QGraphicsColorizeEffect>("Qt",4,6,"Colorize");
+ qmlRegisterType<QDeclarativeColumn>("Qt",4,6,"Column");
+ qmlRegisterType<QDeclarativeDrag>("Qt",4,6,"Drag");
+ qmlRegisterType<QGraphicsDropShadowEffect>("Qt",4,6,"DropShadow");
+ qmlRegisterType<QDeclarativeFlickable>("Qt",4,6,"Flickable");
+ qmlRegisterType<QDeclarativeFlipable>("Qt",4,6,"Flipable");
+ qmlRegisterType<QDeclarativeFlow>("Qt",4,6,"Flow");
+ qmlRegisterType<QDeclarativeFocusPanel>("Qt",4,6,"FocusPanel");
+ qmlRegisterType<QDeclarativeFocusScope>("Qt",4,6,"FocusScope");
+ qmlRegisterType<QDeclarativeGradient>("Qt",4,6,"Gradient");
+ qmlRegisterType<QDeclarativeGradientStop>("Qt",4,6,"GradientStop");
+ qmlRegisterType<QDeclarativeGraphicsObjectContainer>("Qt",4,6,"GraphicsObjectContainer");
+ qmlRegisterType<QDeclarativeGrid>("Qt",4,6,"Grid");
+ qmlRegisterType<QDeclarativeGridView>("Qt",4,6,"GridView");
+ qmlRegisterType<QDeclarativeImage>("Qt",4,6,"Image");
+ qmlRegisterType<QDeclarativeItem>("Qt",4,6,"Item");
+ qmlRegisterType<QDeclarativeKeyNavigationAttached>("Qt",4,6,"KeyNavigation");
+ qmlRegisterType<QDeclarativeKeysAttached>("Qt",4,6,"Keys");
+ qmlRegisterType<QDeclarativeLayoutItem>("Qt",4,6,"LayoutItem");
+ qmlRegisterType<QDeclarativeListView>("Qt",4,6,"ListView");
+ qmlRegisterType<QDeclarativeLoader>("Qt",4,6,"Loader");
+ qmlRegisterType<QDeclarativeMouseArea>("Qt",4,6,"MouseArea");
+ qmlRegisterType<QGraphicsOpacityEffect>("Qt",4,6,"Opacity");
+ qmlRegisterType<QDeclarativeParticleMotion>("Qt",4,6,"ParticleMotion");
+ qmlRegisterType<QDeclarativeParticleMotionGravity>("Qt",4,6,"ParticleMotionGravity");
+ qmlRegisterType<QDeclarativeParticleMotionLinear>("Qt",4,6,"ParticleMotionLinear");
+ qmlRegisterType<QDeclarativeParticleMotionWander>("Qt",4,6,"ParticleMotionWander");
+ qmlRegisterType<QDeclarativeParticles>("Qt",4,6,"Particles");
+ qmlRegisterType<QDeclarativePath>("Qt",4,6,"Path");
+ qmlRegisterType<QDeclarativePathAttribute>("Qt",4,6,"PathAttribute");
+ qmlRegisterType<QDeclarativePathCubic>("Qt",4,6,"PathCubic");
+ qmlRegisterType<QDeclarativePathLine>("Qt",4,6,"PathLine");
+ qmlRegisterType<QDeclarativePathPercent>("Qt",4,6,"PathPercent");
+ qmlRegisterType<QDeclarativePathQuad>("Qt",4,6,"PathQuad");
+ qmlRegisterType<QDeclarativePathView>("Qt",4,6,"PathView");
+ qmlRegisterType<QDeclarativePen>("Qt",4,6,"Pen");
+ qmlRegisterType<QIntValidator>("Qt",4,6,"QIntValidator");
#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
- QML_REGISTER_TYPE(Qt,4,7,QDoubleValidator,QDoubleValidator);
- QML_REGISTER_TYPE(Qt,4,7,QRegExpValidator,QRegExpValidator);
+ qmlRegisterType<QDoubleValidator>("Qt",4,7,"QDoubleValidator");
+ qmlRegisterType<QRegExpValidator>("Qt",4,7,"QRegExpValidator");
#endif
- QML_REGISTER_TYPE(Qt,4,6,Rectangle,QDeclarativeRectangle);
- QML_REGISTER_TYPE(Qt,4,6,Repeater,QDeclarativeRepeater);
- QML_REGISTER_TYPE(Qt,4,6,Rotation,QGraphicsRotation);
- QML_REGISTER_TYPE(Qt,4,6,Row,QDeclarativeRow);
- QML_REGISTER_TYPE(Qt,4,6,Scale,QGraphicsScale);
- QML_REGISTER_TYPE(Qt,4,6,Text,QDeclarativeText);
- QML_REGISTER_TYPE(Qt,4,6,TextEdit,QDeclarativeTextEdit);
- QML_REGISTER_TYPE(Qt,4,6,TextInput,QDeclarativeTextInput);
- QML_REGISTER_TYPE(Qt,4,6,ViewSection,QDeclarativeViewSection);
- QML_REGISTER_TYPE(Qt,4,6,VisibleArea,QDeclarativeFlickableVisibleArea);
- QML_REGISTER_TYPE(Qt,4,6,VisualDataModel,QDeclarativeVisualDataModel);
- QML_REGISTER_TYPE(Qt,4,6,VisualItemModel,QDeclarativeVisualItemModel);
+ qmlRegisterType<QDeclarativeRectangle>("Qt",4,6,"Rectangle");
+ qmlRegisterType<QDeclarativeRepeater>("Qt",4,6,"Repeater");
+ qmlRegisterType<QGraphicsRotation>("Qt",4,6,"Rotation");
+ qmlRegisterType<QDeclarativeRow>("Qt",4,6,"Row");
+ qmlRegisterType<QGraphicsScale>("Qt",4,6,"Scale");
+ qmlRegisterType<QDeclarativeText>("Qt",4,6,"Text");
+ qmlRegisterType<QDeclarativeTextEdit>("Qt",4,6,"TextEdit");
+ qmlRegisterType<QDeclarativeTextInput>("Qt",4,6,"TextInput");
+ qmlRegisterType<QDeclarativeViewSection>("Qt",4,6,"ViewSection");
+ qmlRegisterType<QDeclarativeFlickableVisibleArea>("Qt",4,6,"VisibleArea");
+ qmlRegisterType<QDeclarativeVisualDataModel>("Qt",4,6,"VisualDataModel");
+ qmlRegisterType<QDeclarativeVisualItemModel>("Qt",4,6,"VisualItemModel");
- QML_REGISTER_NOCREATE_TYPE(QDeclarativeAnchors);
- QML_REGISTER_NOCREATE_TYPE(QGraphicsEffect);
- QML_REGISTER_NOCREATE_TYPE(QDeclarativeKeyEvent);
- QML_REGISTER_NOCREATE_TYPE(QDeclarativeMouseEvent);
- QML_REGISTER_NOCREATE_TYPE(QGraphicsObject);
- QML_REGISTER_NOCREATE_TYPE(QGraphicsTransform);
- QML_REGISTER_NOCREATE_TYPE(QDeclarativePathElement);
- QML_REGISTER_NOCREATE_TYPE(QDeclarativeCurve);
- QML_REGISTER_NOCREATE_TYPE(QDeclarativeScaleGrid);
- QML_REGISTER_NOCREATE_TYPE(QValidator);
- QML_REGISTER_NOCREATE_TYPE(QDeclarativeVisualModel);
- QML_REGISTER_NOCREATE_TYPE(QAction);
+ qmlRegisterType<QDeclarativeAnchors>();
+ qmlRegisterType<QGraphicsEffect>();
+ qmlRegisterType<QDeclarativeKeyEvent>();
+ qmlRegisterType<QDeclarativeMouseEvent>();
+ qmlRegisterType<QGraphicsObject>();
+ qmlRegisterType<QGraphicsTransform>();
+ qmlRegisterType<QDeclarativePathElement>();
+ qmlRegisterType<QDeclarativeCurve>();
+ qmlRegisterType<QDeclarativeScaleGrid>();
+ qmlRegisterType<QValidator>();
+ qmlRegisterType<QDeclarativeVisualModel>();
+ qmlRegisterType<QAction>();
#ifdef QT_WEBKIT_LIB
- QML_REGISTER_NOCREATE_TYPE(QDeclarativeWebSettings);
+ qmlRegisterType<QDeclarativeWebSettings>();
#endif
}
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index d54bb70..b988e6e 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -158,7 +158,7 @@ public:
, bufferMode(NoBuffer)
, ownModel(false), wrap(false), autoHighlight(true), haveHighlightRange(false)
, correctFlick(true), inFlickCorrection(false), lazyRelease(false)
- , deferredRelease(false), minExtentDirty(true), maxExtentDirty(true)
+ , deferredRelease(false), layoutScheduled(false), minExtentDirty(true), maxExtentDirty(true)
{}
void init();
@@ -414,6 +414,7 @@ public:
}
void refill(qreal from, qreal to, bool doBuffer = false);
+ void scheduleLayout();
void layout();
void updateUnrequestedIndexes();
void updateUnrequestedPositions();
@@ -480,6 +481,7 @@ public:
bool inFlickCorrection : 1;
bool lazyRelease : 1;
bool deferredRelease : 1;
+ bool layoutScheduled : 1;
mutable bool minExtentDirty : 1;
mutable bool maxExtentDirty : 1;
};
@@ -557,7 +559,7 @@ void QDeclarativeListViewPrivate::releaseItem(FxListItem *item)
return;
if (trackedItem == item) {
const char *notifier1 = orient == QDeclarativeListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged());
- const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged());
+ const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged(qreal)) : SIGNAL(widthChanged(qreal));
QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged()));
QObject::disconnect(trackedItem->item, notifier2, q, SLOT(trackedPositionChanged()));
trackedItem = 0;
@@ -680,9 +682,19 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer)
lazyRelease = false;
}
+void QDeclarativeListViewPrivate::scheduleLayout()
+{
+ Q_Q(QDeclarativeListView);
+ if (!layoutScheduled) {
+ layoutScheduled = true;
+ QCoreApplication::postEvent(q, new QEvent(QEvent::User), Qt::HighEventPriority);
+ }
+}
+
void QDeclarativeListViewPrivate::layout()
{
Q_Q(QDeclarativeListView);
+ layoutScheduled = false;
updateSections();
if (!visibleItems.isEmpty()) {
int oldEnd = visibleItems.last()->endPosition();
@@ -748,7 +760,7 @@ void QDeclarativeListViewPrivate::updateTrackedItem()
FxListItem *oldTracked = trackedItem;
const char *notifier1 = orient == QDeclarativeListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged());
- const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged());
+ const char *notifier2 = orient == QDeclarativeListView::Vertical ? SIGNAL(heightChanged(qreal)) : SIGNAL(widthChanged(qreal));
if (trackedItem && item != trackedItem) {
QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged()));
@@ -1082,10 +1094,12 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m
if (currentItem && currentItem->position() - position() != highlightRangeStart) {
qreal pos = currentItem->position() - highlightRangeStart;
timeline.reset(data.move);
- if (fixupDuration)
+ if (fixupDuration) {
timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
- else
+ } else {
data.move.setValue(-pos);
+ q->viewportMoved();
+ }
vTime = timeline.time();
}
} else if (snapMode != QDeclarativeListView::NoSnap) {
@@ -1094,10 +1108,12 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m
qreal dist = qAbs(data.move + pos);
if (dist > 0) {
timeline.reset(data.move);
- if (fixupDuration)
+ if (fixupDuration) {
timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
- else
+ } else {
data.move.setValue(-pos);
+ q->viewportMoved();
+ }
vTime = timeline.time();
}
}
@@ -1124,7 +1140,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
if (FxListItem *item = firstVisibleItem())
maxDistance = qAbs(item->position() + data.move.value());
} else if (data.move.value() < minExtent) {
- maxDistance = qAbs(minExtent - data.move.value() + (overShoot?overShootDistance(velocity, vSize):0));
+ maxDistance = qAbs(minExtent - data.move.value());
}
if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
data.flickTarget = minExtent;
@@ -1133,7 +1149,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
if (FxListItem *item = nextVisibleItem())
maxDistance = qAbs(item->position() + data.move.value());
} else if (data.move.value() > maxExtent) {
- maxDistance = qAbs(maxExtent - data.move.value()) + (overShoot?overShootDistance(velocity, vSize):0);
+ maxDistance = qAbs(maxExtent - data.move.value());
}
if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
data.flickTarget = maxExtent;
@@ -1156,7 +1172,8 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
qreal v2 = v * v;
qreal maxAccel = v2 / (2.0f * maxDistance);
if (maxAccel < accel) {
- qreal dist = v2 / (accel * 2.0);
+ // + averageSize/4 to encourage moving at least one item in the flick direction
+ qreal dist = v2 / (accel * 2.0) + averageSize/4;
if (v > 0)
dist = -dist;
data.flickTarget = -snapPosAt(-(data.move.value() - highlightRangeStart) + dist) + highlightRangeStart;
@@ -1944,6 +1961,17 @@ void QDeclarativeListView::setHeader(QDeclarativeComponent *header)
}
}
+bool QDeclarativeListView::event(QEvent *event)
+{
+ Q_D(QDeclarativeListView);
+ if (event->type() == QEvent::User) {
+ d->layout();
+ return true;
+ }
+
+ return QDeclarativeFlickable::event(event);
+}
+
void QDeclarativeListView::viewportMoved()
{
Q_D(QDeclarativeListView);
@@ -1956,10 +1984,11 @@ void QDeclarativeListView::viewportMoved()
if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) {
// reposition highlight
qreal pos = d->highlight->position();
- if (pos > d->position() + d->highlightRangeEnd - 1 - d->highlight->size())
- pos = d->position() + d->highlightRangeEnd - 1 - d->highlight->size();
- if (pos < d->position() + d->highlightRangeStart)
- pos = d->position() + d->highlightRangeStart;
+ qreal viewPos = qRound(d->position());
+ if (pos > viewPos + d->highlightRangeEnd - 1 - d->highlight->size())
+ pos = viewPos + d->highlightRangeEnd - 1 - d->highlight->size();
+ if (pos < viewPos + d->highlightRangeStart)
+ pos = viewPos + d->highlightRangeStart;
d->highlight->setPosition(pos);
// update current index
@@ -2273,7 +2302,7 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count)
d->updateUnrequestedIndexes();
d->moveReason = QDeclarativeListViewPrivate::Other;
if (!d->visibleItems.count() || d->model->count() <= 1) {
- d->layout();
+ d->scheduleLayout();
d->updateCurrent(qMax(0, qMin(d->currentIndex, d->model->count()-1)));
emit countChanged();
return;
@@ -2303,8 +2332,9 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count)
d->currentIndex += count;
if (d->currentItem)
d->currentItem->index = d->currentIndex;
+ emit currentIndexChanged();
}
- d->layout();
+ d->scheduleLayout();
emit countChanged();
return;
}
@@ -2327,7 +2357,10 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count)
int i = 0;
int from = d->position() - d->buffer;
for (i = count-1; i >= 0 && pos > from; --i) {
- addedVisible = true;
+ if (!addedVisible) {
+ d->scheduleLayout();
+ addedVisible = true;
+ }
FxListItem *item = d->createItem(modelIndex + i);
d->visibleItems.insert(insertionIdx, item);
pos -= item->size() + d->spacing;
@@ -2354,7 +2387,10 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count)
int i = 0;
int to = d->buffer+d->position()+d->size()-1;
for (i = 0; i < count && pos <= to; ++i) {
- addedVisible = true;
+ if (!addedVisible) {
+ d->scheduleLayout();
+ addedVisible = true;
+ }
FxListItem *item = d->createItem(modelIndex + i);
d->visibleItems.insert(index, item);
item->setPosition(pos);
@@ -2377,6 +2413,7 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count)
d->currentItem->index = d->currentIndex;
d->currentItem->setPosition(d->currentItem->position() + diff);
}
+ emit currentIndexChanged();
}
// Update the indexes of the following visible items.
for (; index < d->visibleItems.count(); ++index) {
@@ -2390,8 +2427,6 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count)
for (int j = 0; j < added.count(); ++j)
added.at(j)->attached->emitAdd();
- if (addedVisible)
- d->layout();
emit countChanged();
}
@@ -2417,7 +2452,10 @@ void QDeclarativeListView::itemsRemoved(int modelIndex, int count)
++it;
} else {
// removed item
- removedVisible = true;
+ if (!removedVisible) {
+ d->scheduleLayout();
+ removedVisible = true;
+ }
item->attached->emitRemove();
if (item->attached->delayRemove()) {
item->index = -1;
@@ -2442,6 +2480,7 @@ void QDeclarativeListView::itemsRemoved(int modelIndex, int count)
d->currentIndex -= count;
if (d->currentItem)
d->currentItem->index -= count;
+ emit currentIndexChanged();
} else if (d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count) {
// current item has been removed.
d->currentItem->attached->setIsCurrentItem(false);
@@ -2459,20 +2498,13 @@ void QDeclarativeListView::itemsRemoved(int modelIndex, int count)
}
}
- if (removedVisible) {
- if (d->visibleItems.isEmpty()) {
- d->visibleIndex = 0;
- d->visiblePos = d->header ? d->header->size() : 0;
- d->timeline.clear();
- d->setPosition(0);
- if (d->model->count() == 0)
- update();
- else
- refill();
- } else {
- // Correct the positioning of the items
- d->layout();
- }
+ if (removedVisible && d->visibleItems.isEmpty()) {
+ d->visibleIndex = 0;
+ d->visiblePos = d->header ? d->header->size() : 0;
+ d->timeline.clear();
+ d->setPosition(0);
+ if (d->model->count() == 0)
+ update();
}
emit countChanged();
diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/declarative/graphicsitems/qdeclarativelistview_p.h
index d66ac2b..1bf9652 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h
@@ -219,6 +219,7 @@ Q_SIGNALS:
void footerChanged();
protected:
+ virtual bool event(QEvent *event);
virtual void viewportMoved();
virtual qreal minYExtent() const;
virtual qreal maxYExtent() const;
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp
index b0499d7..c9e80ee 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp
@@ -346,12 +346,13 @@ QDeclarativeLoader::Status QDeclarativeLoader::status() const
}
/*!
- \qmlproperty real Loader::progress
+\qmlproperty real Loader::progress
- This property holds the progress of QML data loading, from 0.0 (nothing loaded)
- to 1.0 (finished).
+This property holds the progress of loading QML data from the network, from
+0.0 (nothing loaded) to 1.0 (finished). Most QML files are quite small, so
+this value will rapidly change from 0 to 1.
- \sa status
+\sa status
*/
qreal QDeclarativeLoader::progress() const
{
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
index ec7aa62..13195af 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp
+++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
@@ -383,7 +383,6 @@ void QDeclarativeMouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
d->dragged = false;
setHovered(true);
- d->start = event->pos();
d->startScene = event->scenePos();
// we should only start timer if pressAndHold is connected to.
if (d->isConnected("pressAndHold(QDeclarativeMouseEvent*)"))
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h
index d4871f2..88206cd 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h
@@ -101,7 +101,6 @@ public:
bool dragY : 1;
bool dragged : 1;
QDeclarativeDrag *drag;
- QPointF start;
QPointF startScene;
qreal startX;
qreal startY;
diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
index ab6007a..28a93d2 100644
--- a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
@@ -211,8 +211,8 @@ QDeclarativePaintedItem::~QDeclarativePaintedItem()
*/
void QDeclarativePaintedItem::init()
{
- connect(this,SIGNAL(widthChanged()),this,SLOT(clearCache()));
- connect(this,SIGNAL(heightChanged()),this,SLOT(clearCache()));
+ connect(this,SIGNAL(widthChanged(qreal)),this,SLOT(clearCache()));
+ connect(this,SIGNAL(heightChanged(qreal)),this,SLOT(clearCache()));
connect(this,SIGNAL(visibleChanged()),this,SLOT(clearCache()));
}
diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h
index 4083ab5..62f7d95 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h
@@ -66,11 +66,6 @@
QT_BEGIN_NAMESPACE
-typedef struct PathViewItem{
- int index;
- QDeclarativeItem* item;
-}PathViewItem;
-
class QDeclarativeOpenMetaObjectType;
class QDeclarativePathViewAttached;
class QDeclarativePathViewPrivate : public QDeclarativeItemPrivate
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
index 1212e89..0f59a70 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
@@ -212,19 +212,22 @@ void QDeclarativeBasePositioner::prePositioning()
QList<QGraphicsItem *> children = d->QGraphicsItemPrivate::children;
qSort(children.begin(), children.end(), d->insertionOrder);
+ QPODVector<PositionedItem,8> oldItems;
+ positionedItems.copyAndClear(oldItems);
for (int ii = 0; ii < children.count(); ++ii) {
QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(ii));
if (!child)
continue;
PositionedItem *item = 0;
PositionedItem posItem(child);
- int wIdx = positionedItems.find(posItem);
+ int wIdx = oldItems.find(posItem);
if (wIdx < 0) {
d->watchChanges(child);
positionedItems.append(posItem);
item = &positionedItems[positionedItems.count()-1];
} else {
- item = &positionedItems[wIdx];
+ item = &oldItems[wIdx];
+ positionedItems.append(*item);
}
if (child->opacity() <= 0.0 || !child->isVisible()) {
item->isVisible = false;
diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
index e4cd499..b9696c8 100644
--- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
@@ -296,6 +296,8 @@ void QDeclarativeRepeater::clear()
void QDeclarativeRepeater::regenerate()
{
Q_D(QDeclarativeRepeater);
+ if (!isComponentComplete())
+ return;
clear();
@@ -312,23 +314,65 @@ void QDeclarativeRepeater::regenerate()
}
}
-void QDeclarativeRepeater::itemsInserted(int, int)
+void QDeclarativeRepeater::itemsInserted(int index, int count)
{
- regenerate();
+ Q_D(QDeclarativeRepeater);
+ if (!isComponentComplete())
+ return;
+ for (int i = 0; i < count; ++i) {
+ int modelIndex = index + i;
+ QDeclarativeItem *item = d->model->item(modelIndex);
+ if (item) {
+ item->setParent(parentItem());
+ if (modelIndex < d->deletables.count())
+ item->stackBefore(d->deletables.at(modelIndex));
+ else
+ item->stackBefore(this);
+ d->deletables.insert(modelIndex, item);
+ }
+ }
}
-void QDeclarativeRepeater::itemsRemoved(int, int)
+void QDeclarativeRepeater::itemsRemoved(int index, int count)
{
- regenerate();
+ Q_D(QDeclarativeRepeater);
+ if (!isComponentComplete())
+ return;
+ while (count--) {
+ QDeclarativeItem *item = d->deletables.takeAt(index);
+ if (item) {
+ item->setParentItem(this);
+ d->model->release(item);
+ }
+ }
}
-void QDeclarativeRepeater::itemsMoved(int,int,int)
+void QDeclarativeRepeater::itemsMoved(int from, int to, int count)
{
- regenerate();
+ Q_D(QDeclarativeRepeater);
+ if (!isComponentComplete())
+ return;
+ QList<QDeclarativeItem*> removed;
+ int removedCount = count;
+ while (removedCount--)
+ 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);
+ }
}
void QDeclarativeRepeater::modelReset()
{
+ if (!isComponentComplete())
+ return;
regenerate();
}
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index be73b39..dbae47d 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -760,17 +760,11 @@ void QDeclarativeTextEdit::keyReleaseEvent(QKeyEvent *event)
QDeclarativePaintedItem::keyReleaseEvent(event);
}
-/*!
- \overload
- Handles changing of the focus property. Focus is applied to the control
- even if the edit does not have active focus. This is because things
- like KeyProxy can give the behavior of focus even when hasFocus() isn't
- true.
-*/
-void QDeclarativeTextEdit::focusChanged(bool hasFocus)
+void QDeclarativeTextEditPrivate::focusChanged(bool hasFocus)
{
- setCursorVisible(hasFocus);
- QDeclarativeItem::focusChanged(hasFocus);
+ Q_Q(QDeclarativeTextEdit);
+ q->setCursorVisible(hasFocus);
+ QDeclarativeItemPrivate::focusChanged(hasFocus);
}
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
index 6183b1d..b1682c4 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
@@ -215,8 +215,6 @@ protected:
void keyPressEvent(QKeyEvent *);
void keyReleaseEvent(QKeyEvent *);
- void focusChanged(bool);
-
// mouse filter?
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
index 002fac4..dd2a29d 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
@@ -80,6 +80,7 @@ public:
void updateDefaultTextOption();
void relayoutDocument();
void updateSelection();
+ void focusChanged(bool);
QString text;
QFont font;
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index 3382628..6df3533 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -636,12 +636,12 @@ int QDeclarativeTextInput::xToPos(int x)
return d->control->xToPos(x - d->hscroll);
}
-void QDeclarativeTextInput::focusChanged(bool hasFocus)
+void QDeclarativeTextInputPrivate::focusChanged(bool hasFocus)
{
- Q_D(QDeclarativeTextInput);
- d->focused = hasFocus;
- setCursorVisible(hasFocus);
- QDeclarativeItem::focusChanged(hasFocus);
+ Q_Q(QDeclarativeTextInput);
+ focused = hasFocus;
+ q->setCursorVisible(hasFocus);
+ QDeclarativeItemPrivate::focusChanged(hasFocus);
}
void QDeclarativeTextInput::keyPressEvent(QKeyEvent* ev)
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
index f690ae2..6a61c2d 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
@@ -199,8 +199,6 @@ protected:
void keyPressEvent(QKeyEvent* ev);
bool event(QEvent *e);
- void focusChanged(bool hasFocus);
-
public Q_SLOTS:
void selectAll();
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
index 3d28f40..5d17a55 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
@@ -83,6 +83,7 @@ public:
void init();
void startCreatingCursor();
+ void focusChanged(bool hasFocus);
QLineControl* control;
diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h
index 77b7484..2a7a9cf 100644
--- a/src/declarative/qml/qdeclarative.h
+++ b/src/declarative/qml/qdeclarative.h
@@ -275,6 +275,7 @@ int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
return QDeclarativePrivate::registerType(type);
}
+#if 0
#define QML_REGISTER_INTERFACE(INTERFACE) \
qmlRegisterInterface<INTERFACE>(#INTERFACE)
@@ -287,6 +288,8 @@ int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
#define QML_REGISTER_NOCREATE_TYPE(CLASS) \
qmlRegisterType<CLASS>()
+#endif
+
class QDeclarativeContext;
class QDeclarativeEngine;
Q_DECLARATIVE_EXPORT void qmlExecuteDeferred(QObject *);
diff --git a/src/declarative/qml/qdeclarativecompiledbindings.cpp b/src/declarative/qml/qdeclarativecompiledbindings.cpp
index 17937fd..b35b5b5 100644
--- a/src/declarative/qml/qdeclarativecompiledbindings.cpp
+++ b/src/declarative/qml/qdeclarativecompiledbindings.cpp
@@ -124,24 +124,7 @@ public:
QDeclarativeCompiledBindingsPrivate *parent;
};
- struct Subscription {
- struct Signal {
- QDeclarativeGuard<QObject> source;
- int notifyIndex;
- };
-
- enum { InvalidType, SignalType, IdType } type;
- inline Subscription();
- inline ~Subscription();
- bool isSignal() const { return type == SignalType; }
- bool isId() const { return type == IdType; }
- inline Signal *signal();
- inline QDeclarativeContextPrivate::IdNotifier *id();
- union {
- char signalData[sizeof(Signal)];
- char idData[sizeof(QDeclarativeContextPrivate::IdNotifier)];
- };
- };
+ typedef QDeclarativeNotifierEndpoint Subscription;
Subscription *subscriptions;
QScriptDeclarativeClass::PersistentIdentifier *identifiers;
@@ -190,18 +173,6 @@ QDeclarativeCompiledBindingsPrivate::~QDeclarativeCompiledBindingsPrivate()
delete [] identifiers; identifiers = 0;
}
-QDeclarativeCompiledBindingsPrivate::Subscription::Subscription()
-: type(InvalidType)
-{
-}
-
-QDeclarativeCompiledBindingsPrivate::Subscription::~Subscription()
-{
- if (type == SignalType) ((Signal *)signalData)->~Signal();
- else if (type == IdType) ((QDeclarativeContextPrivate::IdNotifier *)idData)->~IdNotifier();
-}
-
-
int QDeclarativeCompiledBindingsPrivate::methodCount = -1;
QDeclarativeCompiledBindings::QDeclarativeCompiledBindings(const char *program, QDeclarativeContext *context)
@@ -330,22 +301,6 @@ void QDeclarativeCompiledBindingsPrivate::run(Binding *binding)
}
}
-QDeclarativeCompiledBindingsPrivate::Subscription::Signal *QDeclarativeCompiledBindingsPrivate::Subscription::signal()
-{
- if (type == IdType) ((QDeclarativeContextPrivate::IdNotifier *)idData)->~IdNotifier();
- if (type != SignalType) new (signalData) Signal;
- type = SignalType;
- return (Signal *)signalData;
-}
-
-QDeclarativeContextPrivate::IdNotifier *QDeclarativeCompiledBindingsPrivate::Subscription::id()
-{
- if (type == SignalType) ((Signal *)signalData)->~Signal();
- if (type != IdType) new (idData) QDeclarativeContextPrivate::IdNotifier;
- type = IdType;
- return (QDeclarativeContextPrivate::IdNotifier *)idData;
-}
-
namespace {
// This structure is exactly 8-bytes in size
struct Instr {
@@ -656,20 +611,7 @@ void QDeclarativeCompiledBindingsPrivate::unsubscribe(int subIndex)
Q_Q(QDeclarativeCompiledBindings);
QDeclarativeCompiledBindingsPrivate::Subscription *sub = (subscriptions + subIndex);
- if (sub->isSignal()) {
- QDeclarativeCompiledBindingsPrivate::Subscription::Signal *s = sub->signal();
- if (s->source)
-#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2))
- QMetaObject::disconnectOne(s->source, s->notifyIndex,
- q, methodCount + subIndex);
-#else
- // QTBUG-6781
- QMetaObject::disconnect(s->source, s->notifyIndex,
- q, methodCount + subIndex);
-#endif
- } else if (sub->isId()) {
- sub->id()->clear();
- }
+ sub->disconnect();
}
void QDeclarativeCompiledBindingsPrivate::subscribeId(QDeclarativeContextPrivate *p, int idIndex, int subIndex)
@@ -680,15 +622,8 @@ void QDeclarativeCompiledBindingsPrivate::subscribeId(QDeclarativeContextPrivate
if (p->idValues[idIndex]) {
QDeclarativeCompiledBindingsPrivate::Subscription *sub = (subscriptions + subIndex);
- QDeclarativeContextPrivate::IdNotifier *i = sub->id();
-
- i->next = p->idValues[idIndex].bindings;
- i->prev = &p->idValues[idIndex].bindings;
- p->idValues[idIndex].bindings = i;
- if (i->next) i->next->prev = &i->next;
-
- i->target = q;
- i->methodIndex = methodCount + subIndex;
+ sub->target = q;
+ sub->targetMethod = methodCount + subIndex;
}
}
@@ -697,27 +632,9 @@ void QDeclarativeCompiledBindingsPrivate::subscribe(QObject *o, int notifyIndex,
Q_Q(QDeclarativeCompiledBindings);
QDeclarativeCompiledBindingsPrivate::Subscription *sub = (subscriptions + subIndex);
-
- if (sub->isId())
- unsubscribe(subIndex);
-
- QDeclarativeCompiledBindingsPrivate::Subscription::Signal *s = sub->signal();
- if (o != s->source || notifyIndex != s->notifyIndex) {
- if (s->source)
-#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2))
- QMetaObject::disconnectOne(s->source, s->notifyIndex,
- q, methodCount + subIndex);
-#else
- // QTBUG-6781
- QMetaObject::disconnect(s->source, s->notifyIndex,
- q, methodCount + subIndex);
-#endif
- s->source = o;
- s->notifyIndex = notifyIndex;
- if (s->source && s->notifyIndex != -1)
- QMetaObject::connect(s->source, s->notifyIndex, q,
- methodCount + subIndex, Qt::DirectConnection);
- }
+ sub->target = q;
+ sub->targetMethod = methodCount + subIndex;
+ sub->connect(o, notifyIndex);
}
// Conversion functions - these MUST match the QtScript expression path
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index d6bb216..d3608c4 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -512,7 +512,6 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q
{
}
-
/*!
\internal
A version of create which returns a scriptObject, for use in script
@@ -526,7 +525,9 @@ QScriptValue QDeclarativeComponent::createObject()
return QScriptValue();
}
QObject* ret = create(ctxt);
- return QDeclarativeEnginePrivate::qmlScriptObject(ret, d->engine);
+ QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(d->engine);
+ QDeclarativeDeclarativeData::get(ret, true)->setImplicitDestructible();
+ return priv->objectClass->newQObject(ret, QMetaType::QObjectStar);
}
/*!
@@ -541,7 +542,12 @@ QObject *QDeclarativeComponent::create(QDeclarativeContext *context)
{
Q_D(QDeclarativeComponent);
- return d->create(context, QBitField());
+ if (!context)
+ context = d->engine->rootContext();
+
+ QObject *rv = beginCreate(context);
+ completeCreate();
+ return rv;
}
QObject *QDeclarativeComponentPrivate::create(QDeclarativeContext *context,
@@ -586,7 +592,13 @@ QObject *QDeclarativeComponentPrivate::create(QDeclarativeContext *context,
QObject *QDeclarativeComponent::beginCreate(QDeclarativeContext *context)
{
Q_D(QDeclarativeComponent);
- return d->beginCreate(context, QBitField());
+ QObject *rv = d->beginCreate(context, QBitField());
+ if (rv) {
+ QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(rv);
+ Q_ASSERT(ddata);
+ ddata->indestructible = true;
+ }
+ return rv;
}
QObject *
diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
index b90a598..9b3a8b4 100644
--- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp
+++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
@@ -154,7 +154,7 @@ QDeclarativeCompositeTypeData::TypeReference::TypeReference()
}
QDeclarativeCompositeTypeManager::QDeclarativeCompositeTypeManager(QDeclarativeEngine *e)
-: engine(e)
+: engine(e), redirectCount(0)
{
}
@@ -172,6 +172,10 @@ QDeclarativeCompositeTypeManager::~QDeclarativeCompositeTypeManager()
QDeclarativeCompositeTypeData *QDeclarativeCompositeTypeManager::get(const QUrl &url)
{
+ Redirects::Iterator redir = redirects.find(url);
+ if (redir != redirects.end())
+ return get(*redir);
+
QDeclarativeCompositeTypeData *unit = components.value(url);
if (!unit) {
@@ -219,6 +223,8 @@ void QDeclarativeCompositeTypeManager::clearCache()
}
}
+#define TYPEMANAGER_MAXIMUM_REDIRECT_RECURSION 16
+
void QDeclarativeCompositeTypeManager::replyFinished()
{
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
@@ -226,6 +232,26 @@ void QDeclarativeCompositeTypeManager::replyFinished()
QDeclarativeCompositeTypeData *unit = components.value(reply->url());
Q_ASSERT(unit);
+ redirectCount++;
+ if (redirectCount < TYPEMANAGER_MAXIMUM_REDIRECT_RECURSION) {
+ QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ if (redirect.isValid()) {
+ QUrl url = reply->url().resolved(redirect.toUrl());
+ redirects.insert(reply->url(),url);
+ unit->imports.setBaseUrl(url);
+ components.remove(reply->url());
+ components.insert(url, unit);
+ reply->deleteLater();
+ reply = engine->networkAccessManager()->get(QNetworkRequest(url));
+ QObject::connect(reply, SIGNAL(finished()),
+ this, SLOT(replyFinished()));
+ QObject::connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SLOT(requestProgress(qint64,qint64)));
+ return;
+ }
+ }
+ redirectCount = 0;
+
if (reply->error() != QNetworkReply::NoError) {
QString errorDescription;
// ### - Fill in error
@@ -256,6 +282,24 @@ void QDeclarativeCompositeTypeManager::resourceReplyFinished()
QDeclarativeCompositeTypeResource *resource = resources.value(reply->url());
Q_ASSERT(resource);
+ redirectCount++;
+ if (redirectCount < TYPEMANAGER_MAXIMUM_REDIRECT_RECURSION) {
+ QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ if (redirect.isValid()) {
+ QUrl url = reply->url().resolved(redirect.toUrl());
+ redirects.insert(reply->url(),url);
+ resource->url = url.toString();
+ resources.remove(reply->url());
+ resources.insert(url, resource);
+ reply->deleteLater();
+ reply = engine->networkAccessManager()->get(QNetworkRequest(url));
+ QObject::connect(reply, SIGNAL(finished()),
+ this, SLOT(resourceReplyFinished()));
+ return;
+ }
+ }
+ redirectCount = 0;
+
if (reply->error() != QNetworkReply::NoError) {
resource->status = QDeclarativeCompositeTypeResource::Error;
@@ -546,6 +590,10 @@ int QDeclarativeCompositeTypeManager::resolveTypes(QDeclarativeCompositeTypeData
continue;
}
+ Redirects::Iterator redir = redirects.find(url);
+ if (redir != redirects.end())
+ url = *redir;
+
QDeclarativeCompositeTypeData *urlUnit = components.value(url);
if (!urlUnit) {
diff --git a/src/declarative/qml/qdeclarativecompositetypemanager_p.h b/src/declarative/qml/qdeclarativecompositetypemanager_p.h
index 03d16b8..a572e0c 100644
--- a/src/declarative/qml/qdeclarativecompositetypemanager_p.h
+++ b/src/declarative/qml/qdeclarativecompositetypemanager_p.h
@@ -109,6 +109,9 @@ private:
Components components;
typedef QHash<QUrl, QDeclarativeCompositeTypeResource *> Resources;
Resources resources;
+ typedef QHash<QUrl, QUrl> Redirects;
+ Redirects redirects;
+ int redirectCount;
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp
index f70e143..356a4ab 100644
--- a/src/declarative/qml/qdeclarativecontext.cpp
+++ b/src/declarative/qml/qdeclarativecontext.cpp
@@ -109,12 +109,7 @@ void QDeclarativeContextPrivate::destroyed(ContextGuard *guard)
if (parent && QObjectPrivate::get(parent)->wasDeleted)
return;
- while(guard->bindings) {
- QObject *o = guard->bindings->target;
- int mi = guard->bindings->methodIndex;
- guard->bindings->clear();
- if (o) o->qt_metacall(QMetaObject::InvokeMetaMethod, mi, 0);
- }
+ guard->bindings.notify();
for (int ii = 0; ii < idValueCount; ++ii) {
if (&idValues[ii] == guard) {
diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h
index 8297280..5b597fa 100644
--- a/src/declarative/qml/qdeclarativecontext_p.h
+++ b/src/declarative/qml/qdeclarativecontext_p.h
@@ -59,6 +59,7 @@
#include "qdeclarativeengine_p.h"
#include "qdeclarativeintegercache_p.h"
#include "qdeclarativetypenamecache_p.h"
+#include "qdeclarativenotifier_p.h"
#include <QtCore/qhash.h>
#include <QtScript/qscriptvalue.h>
@@ -133,7 +134,7 @@ public:
inline virtual void objectDestroyed(QObject *);
QDeclarativeContextPrivate *priv;
- IdNotifier *bindings;
+ QDeclarativeNotifier bindings;
};
ContextGuard *idValues;
int idValueCount;
@@ -176,7 +177,7 @@ void QDeclarativeContextPrivate::IdNotifier::clear()
}
QDeclarativeContextPrivate::ContextGuard::ContextGuard()
-: priv(0), bindings(0)
+: priv(0)
{
}
diff --git a/src/declarative/qml/qdeclarativecustomparser_p.h b/src/declarative/qml/qdeclarativecustomparser_p.h
index 99587a8..39bd43c 100644
--- a/src/declarative/qml/qdeclarativecustomparser_p.h
+++ b/src/declarative/qml/qdeclarativecustomparser_p.h
@@ -128,9 +128,10 @@ private:
QList<QDeclarativeError> exceptions;
};
+#if 0
#define QML_REGISTER_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, CUSTOMTYPE) \
qmlRegisterCustomType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE, new CUSTOMTYPE)
-
+#endif
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativedeclarativedata_p.h b/src/declarative/qml/qdeclarativedeclarativedata_p.h
index ae40130..ffce9c9 100644
--- a/src/declarative/qml/qdeclarativedeclarativedata_p.h
+++ b/src/declarative/qml/qdeclarativedeclarativedata_p.h
@@ -67,12 +67,21 @@ class Q_AUTOTEST_EXPORT QDeclarativeDeclarativeData : public QDeclarativeData
{
public:
QDeclarativeDeclarativeData(QDeclarativeContext *ctxt = 0)
- : context(ctxt), bindings(0), nextContextObject(0), prevContextObject(0),
- bindingBitsSize(0), bindingBits(0), outerContext(0), lineNumber(0),
- columnNumber(0), deferredComponent(0), deferredIdx(0), attachedProperties(0),
- propertyCache(0), guards(0) {}
+ : indestructible(true), explicitIndestructibleSet(false), context(ctxt),
+ bindings(0), nextContextObject(0), prevContextObject(0), bindingBitsSize(0), bindingBits(0),
+ outerContext(0), lineNumber(0), columnNumber(0), deferredComponent(0), deferredIdx(0),
+ attachedProperties(0), propertyCache(0), guards(0) {}
virtual void destroyed(QObject *);
+ virtual void parentChanged(QObject *, QObject *);
+
+ void setImplicitDestructible() {
+ if (!explicitIndestructibleSet) indestructible = false;
+ }
+
+ quint32 indestructible:1;
+ quint32 explicitIndestructibleSet:1;
+ quint32 dummy:29;
QDeclarativeContext *context;
QDeclarativeAbstractBinding *bindings;
diff --git a/src/declarative/qml/qdeclarativedirparser.cpp b/src/declarative/qml/qdeclarativedirparser.cpp
index e730b92..b6d2115 100644
--- a/src/declarative/qml/qdeclarativedirparser.cpp
+++ b/src/declarative/qml/qdeclarativedirparser.cpp
@@ -151,13 +151,16 @@ bool QDeclarativeDirParser::parse()
_plugins.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);
+ _components.append(entry);
} else if (sectionCount == 3) {
const QString &version = sections[1];
const int dotIndex = version.indexOf(QLatin1Char('.'));
if (dotIndex == -1) {
qWarning() << "expected '.'"; // ### use reportError
-
} else if (version.indexOf(QLatin1Char('.'), dotIndex + 1) != -1) {
qWarning() << "unexpected '.'"; // ### use reportError
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index c23b17c..41c0f5c 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -146,12 +146,12 @@ static bool qt_QmlQtModule_registered = false;
void QDeclarativeEnginePrivate::defineModule()
{
- QML_REGISTER_TYPE(Qt,4,6,Component,QDeclarativeComponent);
- QML_REGISTER_TYPE(Qt,4,6,QtObject,QObject);
- QML_REGISTER_TYPE(Qt,4,6,WorkerScript,QDeclarativeWorkerScript);
- QML_REGISTER_TYPE(Qt,4,6,WorkerListModel,QDeclarativeWorkerListModel);
+ qmlRegisterType<QDeclarativeComponent>("Qt",4,6,"Component");
+ qmlRegisterType<QObject>("Qt",4,6,"QtObject");
+ qmlRegisterType<QDeclarativeWorkerScript>("Qt",4,6,"WorkerScript");
+ qmlRegisterType<QDeclarativeWorkerListModel>("Qt",4,6,"WorkerListModel");
- QML_REGISTER_NOCREATE_TYPE(QDeclarativeBinding);
+ qmlRegisterType<QDeclarativeBinding>();
}
QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e)
@@ -668,6 +668,59 @@ void QDeclarativeEngine::setContextForObject(QObject *object, QDeclarativeContex
context->d_func()->contextObjects = data;
}
+/*!
+\enum QDeclarativeEngine::ObjectOwnership
+
+Ownership controls whether or not QML automatically destroys the QObject when the object
+is garbage collected by the JavaScript engine. The two ownership options are:
+
+\o CppOwnership The object is owned by C++ code, and will never be deleted by QML. The
+JavaScript destroy() method cannot be used on objects with CppOwnership. This option
+is similar to QScriptEngine::QtOwnership.
+
+\o JavaScriptOwnership The object is owned by JavaScript. When the object is returned to QML
+as the return value of a method call or property access, QML will delete the object if there
+are no remaining JavaScript references to it and it has no QObject::parent(). This option
+is similar to QScriptEngine::ScriptOwnership.
+
+Generally an application doesn't need to set an object's ownership explicitly. QML uses
+a heuristic to set the default object ownership. By default, an object that is created by
+QML has JavaScriptOwnership. The exception to this are the root objects created by calling
+QDeclarativeCompnent::create() or QDeclarativeComponent::beginCreate() which have
+CppOwnership by default. The ownership of these root-level objects is considered to have
+been transfered to the C++ caller.
+
+Objects not-created by QML have CppOwnership by default. The exception to this is objects
+returned from a C++ method call. The ownership of these objects is passed to JavaScript.
+
+Calling setObjectOwnership() overrides the default ownership heuristic used by QML.
+*/
+
+/*!
+Sets the \a ownership of \a object.
+*/
+void QDeclarativeEngine::setObjectOwnership(QObject *object, ObjectOwnership ownership)
+{
+ QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(object, true);
+ if (!ddata)
+ return;
+
+ ddata->indestructible = (ownership == CppOwnership)?true:false;
+ ddata->explicitIndestructibleSet = true;
+}
+
+/*!
+Returns the ownership of \a object.
+*/
+QDeclarativeEngine::ObjectOwnership QDeclarativeEngine::objectOwnership(QObject *object)
+{
+ QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(object, false);
+ if (!ddata)
+ return CppOwnership;
+ else
+ return ddata->indestructible?CppOwnership:JavaScriptOwnership;
+}
+
void qmlExecuteDeferred(QObject *object)
{
QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(object);
@@ -778,6 +831,11 @@ void QDeclarativeDeclarativeData::destroyed(QObject *object)
delete this;
}
+void QDeclarativeDeclarativeData::parentChanged(QObject *, QObject *parent)
+{
+ if (!parent && scriptValue.isValid()) scriptValue = QScriptValue();
+}
+
bool QDeclarativeDeclarativeData::hasBindingBit(int bit) const
{
if (bindingBitsSize > bit)
@@ -858,6 +916,7 @@ QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt,
QUrl url = QUrl(context->resolvedUrl(QUrl(arg)));
QDeclarativeComponent *c = new QDeclarativeComponent(activeEngine, url, activeEngine);
c->setCreationContext(context);
+ QDeclarativeDeclarativeData::get(c, true)->setImplicitDestructible();
return activeEnginePriv->objectClass->newQObject(c, qMetaTypeId<QDeclarativeComponent*>());
}
}
@@ -928,7 +987,8 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS
if(gobj && gparent)
gobj->setParentItem(gparent);
- return qmlScriptObject(obj, activeEngine);
+ QDeclarativeDeclarativeData::get(obj, true)->setImplicitDestructible();
+ return activeEnginePriv->objectClass->newQObject(obj, QMetaType::QObjectStar);
}
QScriptValue QDeclarativeEnginePrivate::vector(QScriptContext *ctxt, QScriptEngine *engine)
@@ -1784,6 +1844,9 @@ QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString
return resolvePlugin(dir, baseName,
QStringList()
+# ifdef QT_DEBUG
+ << QLatin1String("_debug.dylib") // try a qmake-style debug build first
+# endif
<< QLatin1String(".dylib")
<< QLatin1String(".so")
<< QLatin1String(".bundle"),
diff --git a/src/declarative/qml/qdeclarativeengine.h b/src/declarative/qml/qdeclarativeengine.h
index fd66358..19e81b6 100644
--- a/src/declarative/qml/qdeclarativeengine.h
+++ b/src/declarative/qml/qdeclarativeengine.h
@@ -98,6 +98,10 @@ public:
static QDeclarativeContext *contextForObject(const QObject *);
static void setContextForObject(QObject *, QDeclarativeContext *);
+ enum ObjectOwnership { CppOwnership, JavaScriptOwnership };
+ static void setObjectOwnership(QObject *, ObjectOwnership);
+ static ObjectOwnership objectOwnership(QObject *);
+
Q_SIGNALS:
void quit ();
diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp
index 899f402..5ff22f7 100644
--- a/src/declarative/qml/qdeclarativeexpression.cpp
+++ b/src/declarative/qml/qdeclarativeexpression.cpp
@@ -622,137 +622,74 @@ void QDeclarativeExpression::__q_notify()
void QDeclarativeExpressionPrivate::clearGuards()
{
- Q_Q(QDeclarativeExpression);
-
- static int notifyIdx = -1;
- if (notifyIdx == -1)
- notifyIdx =
- QDeclarativeExpression::staticMetaObject.indexOfMethod("__q_notify()");
-
- for (int ii = 0; ii < data->guardListLength; ++ii) {
- if (data->guardList[ii].data()) {
-#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2))
- QMetaObject::disconnectOne(data->guardList[ii].data(),
- data->guardList[ii].notifyIndex,
- q, notifyIdx);
-#else
- // QTBUG-6781
- QMetaObject::disconnect(data->guardList[ii].data(),
- data->guardList[ii].notifyIndex,
- q, notifyIdx);
-#endif
- }
- }
-
- delete [] data->guardList; data->guardList = 0;
+ delete [] data->guardList;
+ data->guardList = 0;
data->guardListLength = 0;
}
void QDeclarativeExpressionPrivate::updateGuards(const QPODVector<QDeclarativeEnginePrivate::CapturedProperty> &properties)
{
- //clearGuards();
Q_Q(QDeclarativeExpression);
static int notifyIdx = -1;
if (notifyIdx == -1)
- notifyIdx =
- QDeclarativeExpression::staticMetaObject.indexOfMethod("__q_notify()");
+ notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("__q_notify()");
- QDeclarativeExpressionData::SignalGuard *newGuardList = 0;
-
- if (properties.count() != data->guardListLength)
- newGuardList = new QDeclarativeExpressionData::SignalGuard[properties.count()];
+ if (properties.count() != data->guardListLength) {
+ QDeclarativeNotifierEndpoint *newGuardList =
+ new QDeclarativeNotifierEndpoint[properties.count()];
+
+ for (int ii = 0; ii < qMin(data->guardListLength, properties.count()); ++ii)
+ data->guardList[ii].copyAndClear(newGuardList[ii]);
+
+ delete [] data->guardList;
+ data->guardList = newGuardList;
+ data->guardListLength = properties.count();
+ }
bool outputWarningHeader = false;
- int hit = 0;
+ bool noChanges = true;
for (int ii = 0; ii < properties.count(); ++ii) {
+ QDeclarativeNotifierEndpoint &guard = data->guardList[ii];
const QDeclarativeEnginePrivate::CapturedProperty &property = properties.at(ii);
- bool needGuard = true;
- if (ii >= data->guardListLength) {
- // New guard
- } else if(data->guardList[ii].data() == property.object &&
- data->guardList[ii].notifyIndex == property.notifyIndex) {
- // Cache hit
- if (!data->guardList[ii].isDuplicate ||
- (data->guardList[ii].isDuplicate && hit == ii)) {
- needGuard = false;
- ++hit;
- }
- } else if(data->guardList[ii].data() && !data->guardList[ii].isDuplicate) {
- // Cache miss
-#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2))
- QMetaObject::disconnectOne(data->guardList[ii].data(),
- data->guardList[ii].notifyIndex,
- q, notifyIdx);
-#else
- // QTBUG-6781
- QMetaObject::disconnect(data->guardList[ii].data(),
- data->guardList[ii].notifyIndex,
- q, notifyIdx);
-#endif
- }
- /* else {
- // Cache miss, but nothing to do
- } */
-
- if (needGuard) {
- if (!newGuardList) {
- newGuardList = new QDeclarativeExpressionData::SignalGuard[properties.count()];
- for (int jj = 0; jj < ii; ++jj)
- newGuardList[jj] = data->guardList[jj];
- }
+ guard.target = q;
+ guard.targetMethod = notifyIdx;
+
+ if (property.notifyIndex != -1) {
+
+ if (!noChanges && guard.isConnected(property.object, property.notifyIndex)) {
+ // Nothing to do
+
+ } else {
+ noChanges = false;
- if (property.notifyIndex != -1) {
bool existing = false;
for (int jj = 0; !existing && jj < ii; ++jj)
- existing = newGuardList[jj].data() == property.object &&
- newGuardList[jj].notifyIndex == property.notifyIndex;
-
- newGuardList[ii] = property.object;
- newGuardList[ii].notifyIndex = property.notifyIndex;
- if (existing)
- newGuardList[ii].isDuplicate = true;
- else
- QMetaObject::connect(property.object, property.notifyIndex,
- q, notifyIdx);
- } else {
- if (!outputWarningHeader) {
- outputWarningHeader = true;
- qWarning() << "QDeclarativeExpression: Expression" << q->expression()
- << "depends on non-NOTIFYable properties:";
+ if (data->guardList[jj].isConnected(property.object, property.notifyIndex))
+ existing = true;
+
+ if (existing) {
+ // duplicate
+ guard.disconnect();
+ } else {
+ guard.connect(property.object, property.notifyIndex);
}
+ }
- const QMetaObject *metaObj = property.object->metaObject();
- QMetaProperty metaProp = metaObj->property(property.coreIndex);
-
- qWarning().nospace() << " " << metaObj->className()
- << "::" << metaProp.name();
+ } else {
+ if (!outputWarningHeader) {
+ outputWarningHeader = true;
+ qWarning() << "QDeclarativeExpression: Expression" << q->expression()
+ << "depends on non-NOTIFYable properties:";
}
- } else if (newGuardList) {
- newGuardList[ii] = data->guardList[ii];
- }
- }
- for (int ii = properties.count(); ii < data->guardListLength; ++ii) {
- if (data->guardList[ii].data() && !data->guardList[ii].isDuplicate) {
-#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2))
- QMetaObject::disconnectOne(data->guardList[ii].data(),
- data->guardList[ii].notifyIndex,
- q, notifyIdx);
-#else
- // QTBUG-6781
- QMetaObject::disconnect(data->guardList[ii].data(),
- data->guardList[ii].notifyIndex,
- q, notifyIdx);
-#endif
- }
- }
+ const QMetaObject *metaObj = property.object->metaObject();
+ QMetaProperty metaProp = metaObj->property(property.coreIndex);
- if (newGuardList) {
- if (data->guardList) delete [] data->guardList;
- data->guardList = newGuardList;
- data->guardListLength = properties.count();
+ qWarning().nospace() << " " << metaObj->className()
+ << "::" << metaProp.name();
+ }
}
}
diff --git a/src/declarative/qml/qdeclarativeexpression_p.h b/src/declarative/qml/qdeclarativeexpression_p.h
index cd1729d..d170559 100644
--- a/src/declarative/qml/qdeclarativeexpression_p.h
+++ b/src/declarative/qml/qdeclarativeexpression_p.h
@@ -129,24 +129,7 @@ public:
QString url; // This is a QString for a reason. QUrls are slooooooow...
int line;
- struct SignalGuard : public QDeclarativeGuard<QObject> {
- SignalGuard() : isDuplicate(false), notifyIndex(-1) {}
-
- SignalGuard &operator=(QObject *obj) {
- QDeclarativeGuard<QObject>::operator=(obj);
- return *this;
- }
- SignalGuard &operator=(const SignalGuard &o) {
- QDeclarativeGuard<QObject>::operator=(o);
- isDuplicate = o.isDuplicate;
- notifyIndex = o.notifyIndex;
- return *this;
- }
-
- bool isDuplicate:1;
- int notifyIndex:31;
- };
- SignalGuard *guardList;
+ QDeclarativeNotifierEndpoint *guardList;
int guardListLength;
};
diff --git a/src/declarative/qml/qdeclarativenotifier.cpp b/src/declarative/qml/qdeclarativenotifier.cpp
new file mode 100644
index 0000000..0a8783a
--- /dev/null
+++ b/src/declarative/qml/qdeclarativenotifier.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** 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 "qdeclarativenotifier_p.h"
+
+QT_BEGIN_NAMESPACE
+
+void QDeclarativeNotifier::emitNotify(QDeclarativeNotifierEndpoint *endpoint)
+{
+ QDeclarativeNotifierEndpoint::Notifier *n = endpoint->asNotifier();
+
+ QDeclarativeNotifierEndpoint::Notifier **oldDisconnected = n->disconnected;
+ n->disconnected = &n;
+
+ if (n->next)
+ emitNotify(n->next);
+
+ if (n) {
+ void *args[] = { 0 };
+
+ QMetaObject::metacall(endpoint->target, QMetaObject::InvokeMetaMethod,
+ endpoint->targetMethod, args);
+
+ n->disconnected = oldDisconnected;
+ }
+
+ if (oldDisconnected) *oldDisconnected = n;
+}
+
+void QDeclarativeNotifierEndpoint::copyAndClear(QDeclarativeNotifierEndpoint &other)
+{
+ other.disconnect();
+
+ other.target = target;
+ other.targetMethod = targetMethod;
+
+ if (!isConnected())
+ return;
+
+ if (SignalType == type) {
+ Signal *other_s = other.toSignal();
+ Signal *s = asSignal();
+
+ other_s->source = s->source;
+ other_s->sourceSignal = s->sourceSignal;
+ s->source = 0;
+ } else if(NotifierType == type) {
+ Notifier *other_n = other.toNotifier();
+ Notifier *n = asNotifier();
+
+ other_n->notifier = n->notifier;
+ other_n->disconnected = n->disconnected;
+ if (other_n->disconnected) *other_n->disconnected = other_n;
+
+ if (n->next) {
+ other_n->next = n->next;
+ n->next->asNotifier()->prev = &other_n->next;
+ }
+ other_n->prev = n->prev;
+ *other_n->prev = &other;
+
+ n->prev = 0;
+ n->next = 0;
+ n->disconnected = 0;
+ n->notifier = 0;
+ }
+}
+
+
+QT_END_NAMESPACE
+
diff --git a/src/declarative/qml/qdeclarativenotifier_p.h b/src/declarative/qml/qdeclarativenotifier_p.h
new file mode 100644
index 0000000..a0e6b43
--- /dev/null
+++ b/src/declarative/qml/qdeclarativenotifier_p.h
@@ -0,0 +1,272 @@
+/****************************************************************************
+**
+** 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 QDECLARATIVENOTIFIER_P_H
+#define QDECLARATIVENOTIFIER_P_H
+
+#include "qdeclarativeguard_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeNotifierEndpoint;
+class QDeclarativeNotifier
+{
+public:
+ inline QDeclarativeNotifier();
+ inline ~QDeclarativeNotifier();
+ inline void notify();
+
+private:
+ friend class QDeclarativeNotifierEndpoint;
+
+ static void emitNotify(QDeclarativeNotifierEndpoint *);
+ QDeclarativeNotifierEndpoint *endpoints;
+};
+
+class QDeclarativeNotifierEndpoint
+{
+public:
+ inline QDeclarativeNotifierEndpoint();
+ inline QDeclarativeNotifierEndpoint(QObject *t, int m);
+ inline ~QDeclarativeNotifierEndpoint();
+
+ QObject *target;
+ int targetMethod;
+
+ inline bool isConnected();
+ inline bool isConnected(QObject *source, int sourceSignal);
+ inline bool isConnected(QDeclarativeNotifier *);
+
+ inline void connect(QObject *source, int sourceSignal);
+ inline void connect(QDeclarativeNotifier *);
+ inline void disconnect();
+
+ void copyAndClear(QDeclarativeNotifierEndpoint &other);
+
+private:
+ friend class QDeclarativeNotifier;
+
+ struct Signal {
+ QDeclarativeGuard<QObject> source;
+ int sourceSignal;
+ };
+
+ struct Notifier {
+ QDeclarativeNotifier *notifier;
+ Notifier **disconnected;
+
+ QDeclarativeNotifierEndpoint *next;
+ QDeclarativeNotifierEndpoint **prev;
+ };
+
+ enum { InvalidType, SignalType, NotifierType } type;
+ union {
+ char signalData[sizeof(Signal)];
+ char notifierData[sizeof(Notifier)];
+ };
+
+ inline Notifier *toNotifier();
+ inline Notifier *asNotifier();
+ inline Signal *toSignal();
+ inline Signal *asSignal();
+};
+
+QDeclarativeNotifier::QDeclarativeNotifier()
+: endpoints(0)
+{
+ QDeclarativeNotifierEndpoint *endpoint = endpoints;
+ while (endpoint) {
+ QDeclarativeNotifierEndpoint *next = endpoint->asNotifier()->next;
+ endpoint->asNotifier()->next = 0;
+ endpoint->asNotifier()->prev = 0;
+ endpoint->asNotifier()->notifier = 0;
+ endpoint = next;
+ }
+}
+
+QDeclarativeNotifier::~QDeclarativeNotifier()
+{
+}
+
+void QDeclarativeNotifier::notify()
+{
+ if (endpoints) emitNotify(endpoints);
+}
+
+QDeclarativeNotifierEndpoint::QDeclarativeNotifierEndpoint()
+: target(0), targetMethod(0), type(InvalidType)
+{
+}
+
+QDeclarativeNotifierEndpoint::QDeclarativeNotifierEndpoint(QObject *t, int m)
+: target(t), targetMethod(m), type(InvalidType)
+{
+}
+
+QDeclarativeNotifierEndpoint::~QDeclarativeNotifierEndpoint()
+{
+ disconnect();
+ if (SignalType == type) {
+ Signal *s = asSignal();
+ s->~Signal();
+ }
+}
+
+bool QDeclarativeNotifierEndpoint::isConnected()
+{
+ if (SignalType == type) {
+ return asSignal()->source;
+ } else if (NotifierType == type) {
+ return asNotifier()->notifier;
+ } else {
+ return false;
+ }
+}
+
+bool QDeclarativeNotifierEndpoint::isConnected(QObject *source, int sourceSignal)
+{
+ return SignalType == type && asSignal()->source == source && asSignal()->sourceSignal == sourceSignal;
+}
+
+bool QDeclarativeNotifierEndpoint::isConnected(QDeclarativeNotifier *notifier)
+{
+ return NotifierType == type && asNotifier()->notifier == notifier;
+}
+
+void QDeclarativeNotifierEndpoint::connect(QObject *source, int sourceSignal)
+{
+ Signal *s = toSignal();
+
+ if (s->source == source && s->sourceSignal == sourceSignal)
+ return;
+
+ disconnect();
+
+ QMetaObject::connect(source, sourceSignal, target, targetMethod);
+
+ s->source = source;
+ s->sourceSignal = sourceSignal;
+}
+
+void QDeclarativeNotifierEndpoint::connect(QDeclarativeNotifier *notifier)
+{
+ Notifier *n = toNotifier();
+
+ if (n->notifier == notifier)
+ return;
+
+ disconnect();
+
+ n->next = notifier->endpoints;
+ if (n->next) { n->next->asNotifier()->prev = &n->next; }
+ notifier->endpoints = this;
+ n->prev = &notifier->endpoints;
+ n->notifier = notifier;
+}
+
+void QDeclarativeNotifierEndpoint::disconnect()
+{
+ if (type == SignalType) {
+ Signal *s = (Signal *)&signalData;
+ if (s->source) {
+ QMetaObject::disconnectOne(s->source, s->sourceSignal, target, targetMethod);
+ s->source = 0;
+ }
+ } else if (type == NotifierType) {
+ Notifier *n = asNotifier();
+
+ if (n->next) n->next->asNotifier()->prev = n->prev;
+ if (n->prev) *n->prev = n->next;
+ if (n->disconnected) *n->disconnected = 0;
+ n->next = 0;
+ n->prev = 0;
+ n->disconnected = 0;
+ n->notifier = 0;
+ }
+}
+
+QDeclarativeNotifierEndpoint::Notifier *QDeclarativeNotifierEndpoint::toNotifier()
+{
+ if (NotifierType == type)
+ return asNotifier();
+
+ if (SignalType == type) {
+ disconnect();
+ Signal *s = asSignal();
+ s->~Signal();
+ }
+
+ Notifier *n = asNotifier();
+ n->next = 0;
+ n->prev = 0;
+ n->disconnected = 0;
+ n->notifier = 0;
+ type = NotifierType;
+ return n;
+}
+
+QDeclarativeNotifierEndpoint::Notifier *QDeclarativeNotifierEndpoint::asNotifier()
+{
+ return (Notifier *)(&notifierData);
+}
+
+QDeclarativeNotifierEndpoint::Signal *QDeclarativeNotifierEndpoint::toSignal()
+{
+ if (SignalType == type)
+ return asSignal();
+
+ disconnect();
+ Signal *s = asSignal();
+ new (s) Signal;
+ type = SignalType;
+
+ return s;
+}
+
+QDeclarativeNotifierEndpoint::Signal *QDeclarativeNotifierEndpoint::asSignal()
+{
+ return (Signal *)(&signalData);
+}
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVENOTIFIER_P_H
+
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
index e6f6e5f..dc4a676 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
@@ -59,6 +59,15 @@ QT_BEGIN_NAMESPACE
struct ObjectData : public QScriptDeclarativeClass::Object {
ObjectData(QObject *o, int t) : object(o), type(t) {}
+
+ virtual ~ObjectData() {
+ if (object && !object->parent()) {
+ QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(object, false);
+ if (ddata && !ddata->indestructible)
+ object->deleteLater();
+ }
+ }
+
QDeclarativeGuard<QObject> object;
int type;
};
@@ -87,7 +96,7 @@ QDeclarativeObjectScriptClass::~QDeclarativeObjectScriptClass()
{
}
-QScriptValue QDeclarativeObjectScriptClass::newQObject(QObject *object, int type)
+QScriptValue QDeclarativeObjectScriptClass::newQObject(QObject *object, int type)
{
QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
@@ -96,7 +105,11 @@ QScriptValue QDeclarativeObjectScriptClass::newQObject(QObject *object, int type
QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(object, true);
- if (!ddata->scriptValue.isValid()) {
+ if (!ddata) {
+ return scriptEngine->undefinedValue();
+ } else if (!ddata->indestructible && !object->parent()) {
+ return newObject(scriptEngine, this, new ObjectData(object, type));
+ } else if (!ddata->scriptValue.isValid()) {
ddata->scriptValue = newObject(scriptEngine, this, new ObjectData(object, type));
return ddata->scriptValue;
} else if (ddata->scriptValue.engine() == QDeclarativeEnginePrivate::getScriptEngine(engine)) {
@@ -392,17 +405,30 @@ QScriptValue QDeclarativeObjectScriptClass::tostring(QScriptContext *context, QS
QScriptValue QDeclarativeObjectScriptClass::destroy(QScriptContext *context, QScriptEngine *engine)
{
- QObject* obj = context->thisObject().toQObject();
- if(obj){
- int delay = 0;
- if(context->argumentCount() > 0)
- delay = context->argument(0).toInt32();
- if (delay > 0)
- QTimer::singleShot(delay, obj, SLOT(deleteLater()));
- else
- obj->deleteLater();
- }
- return engine->nullValue();
+ QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine);
+ QScriptValue that = context->thisObject();
+
+ if (scriptClass(that) != p->objectClass)
+ return engine->undefinedValue();
+
+ ObjectData *data = (ObjectData *)p->objectClass->object(that);
+ if (!data->object)
+ return engine->undefinedValue();
+
+ QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(data->object, false);
+ if (!ddata || ddata->indestructible)
+ return engine->currentContext()->throwError(QLatin1String("Invalid attempt to destroy() an indestructible object"));
+
+ QObject *obj = data->object;
+ int delay = 0;
+ if (context->argumentCount() > 0)
+ delay = context->argument(0).toInt32();
+ if (delay > 0)
+ QTimer::singleShot(delay, obj, SLOT(deleteLater()));
+ else
+ obj->deleteLater();
+
+ return engine->undefinedValue();
}
QStringList QDeclarativeObjectScriptClass::propertyNames(Object *object)
@@ -428,6 +454,14 @@ QStringList QDeclarativeObjectScriptClass::propertyNames(Object *object)
return cache->propertyNames();
}
+bool QDeclarativeObjectScriptClass::compare(Object *o1, Object *o2)
+{
+ ObjectData *d1 = (ObjectData *)o1;
+ ObjectData *d2 = (ObjectData *)o2;
+
+ return d1 == d2 || d1->object == d2->object;
+}
+
#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE)
struct MethodData : public QScriptDeclarativeClass::Object {
@@ -441,6 +475,8 @@ QDeclarativeObjectMethodScriptClass::QDeclarativeObjectMethodScriptClass(QDeclar
: QScriptDeclarativeClass(QDeclarativeEnginePrivate::getScriptEngine(bindEngine)),
engine(bindEngine)
{
+ qRegisterMetaType<QList<QObject *> >("QList<QObject *>");
+
setSupportsCall(true);
QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
@@ -551,7 +587,7 @@ private:
inline void cleanup();
- char *data[16];
+ char data[2 * sizeof(void *)];
int type;
};
}
@@ -569,11 +605,13 @@ MetaCallArgument::~MetaCallArgument()
void MetaCallArgument::cleanup()
{
if (type == QMetaType::QString) {
- ((QString *)data)->~QString();
+ ((QString *)&data)->~QString();
} else if (type == -1 || type == qMetaTypeId<QVariant>()) {
- ((QVariant *)data)->~QVariant();
+ ((QVariant *)&data)->~QVariant();
} else if (type == qMetaTypeId<QScriptValue>()) {
- ((QScriptValue *)data)->~QScriptValue();
+ ((QScriptValue *)&data)->~QScriptValue();
+ } else if (type == qMetaTypeId<QList<QObject *> >()) {
+ ((QList<QObject *> *)&data)->~QList<QObject *>();
}
}
@@ -582,7 +620,7 @@ void *MetaCallArgument::dataPtr()
if (type == -1)
return ((QVariant *)data)->data();
else
- return (void *)data;
+ return (void *)&data;
}
void MetaCallArgument::initAsType(int callType, QDeclarativeEngine *e)
@@ -593,7 +631,7 @@ void MetaCallArgument::initAsType(int callType, QDeclarativeEngine *e)
QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(e);
if (callType == qMetaTypeId<QScriptValue>()) {
- new (data) QScriptValue(engine->undefinedValue());
+ new (&data) QScriptValue(engine->undefinedValue());
type = callType;
} else if (callType == QMetaType::Int ||
callType == QMetaType::UInt ||
@@ -602,17 +640,20 @@ void MetaCallArgument::initAsType(int callType, QDeclarativeEngine *e)
callType == QMetaType::Float) {
type = callType;
} else if (callType == QMetaType::QObjectStar) {
- *((QObject **)data) = 0;
+ *((QObject **)&data) = 0;
type = callType;
} else if (callType == QMetaType::QString) {
- new (data) QString();
+ new (&data) QString();
type = callType;
} else if (callType == qMetaTypeId<QVariant>()) {
- type = qMetaTypeId<QVariant>();
- new (data) QVariant();
+ type = callType;
+ new (&data) QVariant();
+ } else if (callType == qMetaTypeId<QList<QObject *> >()) {
+ type = callType;
+ new (&data) QList<QObject *>();
} else {
type = -1;
- new (data) QVariant(callType, (void *)0);
+ new (&data) QVariant(callType, (void *)0);
}
}
@@ -621,47 +662,50 @@ void MetaCallArgument::fromScriptValue(int callType, QDeclarativeEngine *engine,
if (type != 0) { cleanup(); type = 0; }
if (callType == qMetaTypeId<QScriptValue>()) {
- new (data) QScriptValue(value);
+ new (&data) QScriptValue(value);
type = qMetaTypeId<QScriptValue>();
} else if (callType == QMetaType::Int) {
- *((int *)data) = int(value.toInt32());
+ *((int *)&data) = int(value.toInt32());
type = callType;
} else if (callType == QMetaType::UInt) {
- *((uint *)data) = uint(value.toUInt32());
+ *((uint *)&data) = uint(value.toUInt32());
type = callType;
} else if (callType == QMetaType::Bool) {
- *((bool *)data) = value.toBool();
+ *((bool *)&data) = value.toBool();
type = callType;
} else if (callType == QMetaType::Double) {
- *((double *)data) = double(value.toNumber());
+ *((double *)&data) = double(value.toNumber());
type = callType;
} else if (callType == QMetaType::Float) {
- *((float *)data) = float(value.toNumber());
+ *((float *)&data) = float(value.toNumber());
type = callType;
} else if (callType == QMetaType::QString) {
if (value.isNull() || value.isUndefined())
- new (data) QString();
+ new (&data) QString();
else
- new (data) QString(value.toString());
+ new (&data) QString(value.toString());
type = callType;
} else if (callType == QMetaType::QObjectStar) {
- *((QObject **)data) = value.toQObject();
+ *((QObject **)&data) = value.toQObject();
type = callType;
} else if (callType == qMetaTypeId<QVariant>()) {
- new (data) QVariant(QDeclarativeScriptClass::toVariant(engine, value));
+ new (&data) QVariant(QDeclarativeScriptClass::toVariant(engine, value));
+ type = callType;
+ } else if (callType == qMetaTypeId<QList<QObject*> >()) {
+ new (&data) QList<QObject *>(); // We don't support passing in QList<QObject*>
type = callType;
} else {
- new (data) QVariant();
+ new (&data) QVariant();
type = -1;
QVariant v = QDeclarativeScriptClass::toVariant(engine, value);
if (v.userType() == callType) {
- *((QVariant *)data) = v;
+ *((QVariant *)&data) = v;
} else if (v.canConvert((QVariant::Type)callType)) {
- *((QVariant *)data) = v;
- ((QVariant *)data)->convert((QVariant::Type)callType);
+ *((QVariant *)&data) = v;
+ ((QVariant *)&data)->convert((QVariant::Type)callType);
} else {
- *((QVariant *)data) = QVariant(callType, (void *)0);
+ *((QVariant *)&data) = QVariant(callType, (void *)0);
}
}
}
@@ -671,23 +715,36 @@ QScriptDeclarativeClass::Value MetaCallArgument::toValue(QDeclarativeEngine *e)
QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(e);
if (type == qMetaTypeId<QScriptValue>()) {
- return QScriptDeclarativeClass::Value(engine, *((QScriptValue *)data));
+ return QScriptDeclarativeClass::Value(engine, *((QScriptValue *)&data));
} else if (type == QMetaType::Int) {
- return QScriptDeclarativeClass::Value(engine, *((int *)data));
+ return QScriptDeclarativeClass::Value(engine, *((int *)&data));
} else if (type == QMetaType::UInt) {
- return QScriptDeclarativeClass::Value(engine, *((uint *)data));
+ return QScriptDeclarativeClass::Value(engine, *((uint *)&data));
} else if (type == QMetaType::Bool) {
- return QScriptDeclarativeClass::Value(engine, *((bool *)data));
+ return QScriptDeclarativeClass::Value(engine, *((bool *)&data));
} else if (type == QMetaType::Double) {
- return QScriptDeclarativeClass::Value(engine, *((double *)data));
+ return QScriptDeclarativeClass::Value(engine, *((double *)&data));
} else if (type == QMetaType::Float) {
- return QScriptDeclarativeClass::Value(engine, *((float *)data));
+ return QScriptDeclarativeClass::Value(engine, *((float *)&data));
} else if (type == QMetaType::QString) {
- return QScriptDeclarativeClass::Value(engine, *((QString *)data));
+ return QScriptDeclarativeClass::Value(engine, *((QString *)&data));
} else if (type == QMetaType::QObjectStar) {
- return QScriptDeclarativeClass::Value(engine, QDeclarativeEnginePrivate::get(e)->objectClass->newQObject(*((QObject **)data)));
+ QObject *object = *((QObject **)&data);
+ QDeclarativeDeclarativeData::get(object, true)->setImplicitDestructible();
+ QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(e);
+ return QScriptDeclarativeClass::Value(engine, priv->objectClass->newQObject(object));
+ } else if (type == qMetaTypeId<QList<QObject *> >()) {
+ QList<QObject *> &list = *(QList<QObject *>*)&data;
+ QScriptValue rv = engine->newArray(list.count());
+ QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(e);
+ for (int ii = 0; ii < list.count(); ++ii) {
+ QObject *object = list.at(ii);
+ QDeclarativeDeclarativeData::get(object, true)->setImplicitDestructible();
+ rv.setProperty(ii, priv->objectClass->newQObject(object));
+ }
+ return QScriptDeclarativeClass::Value(engine, rv);
} else if (type == -1 || type == qMetaTypeId<QVariant>()) {
- return QScriptDeclarativeClass::Value(engine, QDeclarativeEnginePrivate::get(e)->scriptValueFromVariant(*((QVariant *)data)));
+ return QScriptDeclarativeClass::Value(engine, QDeclarativeEnginePrivate::get(e)->scriptValueFromVariant(*((QVariant *)&data)));
} else {
return QScriptDeclarativeClass::Value();
}
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
index 04e760f..1f7d1c9 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
@@ -57,6 +57,7 @@
#include "qdeclarativetypenamecache_p.h"
#include <private/qdeclarativescriptclass_p.h>
+#include <QtScript/qscriptengine.h>
QT_BEGIN_NAMESPACE
@@ -99,6 +100,7 @@ public:
~QDeclarativeObjectScriptClass();
QScriptValue newQObject(QObject *, int type = QMetaType::QObjectStar);
+
QObject *toQObject(const QScriptValue &) const;
int objectType(const QScriptValue &) const;
@@ -118,6 +120,7 @@ public:
void setProperty(QObject *, const Identifier &name, const QScriptValue &,
QDeclarativeContext *evalContext = 0);
virtual QStringList propertyNames(Object *);
+ virtual bool compare(Object *, Object *);
protected:
virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp
index fea59e5..cbb67e1 100644
--- a/src/declarative/qml/qdeclarativepropertycache.cpp
+++ b/src/declarative/qml/qdeclarativepropertycache.cpp
@@ -420,4 +420,8 @@ QDeclarativePropertyCache::Data *QDeclarativePropertyCache::property(QDeclarativ
return rv;
}
+QDeclarativePropertyCache::Data QDeclarativePropertyCache::property(const QMetaObject *, const char *)
+{
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativepropertycache_p.h b/src/declarative/qml/qdeclarativepropertycache_p.h
index 68e6e6b..db93de3 100644
--- a/src/declarative/qml/qdeclarativepropertycache_p.h
+++ b/src/declarative/qml/qdeclarativepropertycache_p.h
@@ -55,15 +55,16 @@
#include "qdeclarativerefcount_p.h"
#include "qdeclarativecleanup_p.h"
+#include "qdeclarativenotifier_p.h"
#include <QtCore/qvector.h>
#include <QtScript/private/qscriptdeclarativeclass_p.h>
-
QT_BEGIN_NAMESPACE
class QDeclarativeEngine;
class QMetaProperty;
+
class QDeclarativePropertyCache : public QDeclarativeRefCount, public QDeclarativeCleanup
{
public:
@@ -83,9 +84,9 @@ public:
IsResettable = 0x00000004,
// These are mutualy exclusive
- IsFunction = 0x00000008,
- IsQObjectDerived = 0x00000010,
- IsEnumType = 0x00000020,
+ IsFunction = 0x00000010,
+ IsQObjectDerived = 0x00000020,
+ IsEnumType = 0x00000040,
IsQList = 0x00000080,
IsQmlBinding = 0x00000100,
IsQScriptValue = 0x00000200,
@@ -96,7 +97,7 @@ public:
};
Q_DECLARE_FLAGS(Flags, Flag)
-
+
bool isValid() const { return coreIndex != -1; }
Flags flags;
@@ -136,6 +137,7 @@ public:
inline QDeclarativeEngine *qmlEngine() const;
static Data *property(QDeclarativeEngine *, QObject *, const QScriptDeclarativeClass::Identifier &, Data &);
static Data *property(QDeclarativeEngine *, QObject *, const QString &, Data &);
+ static Data property(const QMetaObject *, const char *);
protected:
virtual void clear();
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index 6a08674..d916900 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -197,6 +197,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack, QDeclarati
QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(o);
Q_ASSERT(ddata);
+ ddata->setImplicitDestructible();
ddata->outerContext = ctxt;
ddata->lineNumber = instr.line;
ddata->columnNumber = instr.create.column;
@@ -247,6 +248,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack, QDeclarati
QDeclarativeEngine::setContextForObject(qcomp, ctxt);
QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(qcomp);
Q_ASSERT(ddata);
+ ddata->setImplicitDestructible();
ddata->outerContext = ctxt;
ddata->lineNumber = instr.line;
ddata->columnNumber = instr.create.column;
diff --git a/src/declarative/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
index 87cab85..58e67fa 100644
--- a/src/declarative/qml/qdeclarativexmlhttprequest.cpp
+++ b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
@@ -1245,7 +1245,7 @@ void QDeclarativeXMLHttpRequest::finished()
if (m_redirectCount < XMLHTTPREQUEST_MAXIMUM_REDIRECT_RECURSION) {
QVariant redirect = m_network->attribute(QNetworkRequest::RedirectionTargetAttribute);
if (redirect.isValid()) {
- QUrl url = redirect.toUrl();
+ QUrl url = m_network->url().resolved(redirect.toUrl());
destroyNetwork();
requestFromUrl(url);
return;
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri
index aa1a34b..49888c3 100644
--- a/src/declarative/qml/qml.pri
+++ b/src/declarative/qml/qml.pri
@@ -38,6 +38,7 @@ SOURCES += \
$$PWD/qdeclarativescript.cpp \
$$PWD/qdeclarativecleanup.cpp \
$$PWD/qdeclarativepropertycache.cpp \
+ $$PWD/qdeclarativenotifier.cpp \
$$PWD/qdeclarativeintegercache.cpp \
$$PWD/qdeclarativetypenamecache.cpp \
$$PWD/qdeclarativescriptstring.cpp \
@@ -108,6 +109,7 @@ HEADERS += \
$$PWD/qdeclarativewatcher_p.h \
$$PWD/qdeclarativecleanup_p.h \
$$PWD/qdeclarativepropertycache_p.h \
+ $$PWD/qdeclarativenotifier_p.h \
$$PWD/qdeclarativeintegercache_p.h \
$$PWD/qdeclarativetypenamecache_p.h \
$$PWD/qdeclarativescriptstring.h \
diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp
index 8f5f537..0509242 100644
--- a/src/declarative/util/qdeclarativefontloader.cpp
+++ b/src/declarative/util/qdeclarativefontloader.cpp
@@ -61,7 +61,7 @@ class QDeclarativeFontLoaderPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QDeclarativeFontLoader)
public:
- QDeclarativeFontLoaderPrivate() : reply(0), status(QDeclarativeFontLoader::Null) {}
+ QDeclarativeFontLoaderPrivate() : reply(0), status(QDeclarativeFontLoader::Null), redirectCount(0) {}
void addFontToDatabase(const QByteArray &);
@@ -69,6 +69,7 @@ public:
QString name;
QNetworkReply *reply;
QDeclarativeFontLoader::Status status;
+ int redirectCount;
};
@@ -206,10 +207,25 @@ QDeclarativeFontLoader::Status QDeclarativeFontLoader::status() const
return d->status;
}
+#define FONTLOADER_MAXIMUM_REDIRECT_RECURSION 16
+
void QDeclarativeFontLoader::replyFinished()
{
Q_D(QDeclarativeFontLoader);
if (d->reply) {
+ d->redirectCount++;
+ if (d->redirectCount < FONTLOADER_MAXIMUM_REDIRECT_RECURSION) {
+ QVariant redirect = d->reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ if (redirect.isValid()) {
+ QUrl url = d->reply->url().resolved(redirect.toUrl());
+ d->reply->deleteLater();
+ d->reply = 0;
+ setSource(url);
+ return;
+ }
+ }
+ d->redirectCount=0;
+
if (!d->reply->error()) {
QByteArray ba = d->reply->readAll();
d->addFontToDatabase(ba);
diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp
index cfb25dd..942d5f6 100644
--- a/src/declarative/util/qdeclarativepixmapcache.cpp
+++ b/src/declarative/util/qdeclarativepixmapcache.cpp
@@ -137,7 +137,7 @@ class QDeclarativeImageRequestHandler : public QObject
Q_OBJECT
public:
QDeclarativeImageRequestHandler(QDeclarativeImageReader *read, QDeclarativeEngine *eng)
- : QObject(), accessManager(0), engine(eng), reader(read)
+ : QObject(), accessManager(0), engine(eng), reader(read), redirectCount(0)
{
QCoreApplication::postEvent(this, new QEvent(QEvent::User));
}
@@ -162,18 +162,24 @@ private:
QNetworkAccessManager *accessManager;
QDeclarativeEngine *engine;
QDeclarativeImageReader *reader;
+ int redirectCount;
+
+ static int replyDownloadProgress;
+ static int replyFinished;
+ static int downloadProgress;
+ static int thisNetworkRequestDone;
};
//===========================================================================
+int QDeclarativeImageRequestHandler::replyDownloadProgress = -1;
+int QDeclarativeImageRequestHandler::replyFinished = -1;
+int QDeclarativeImageRequestHandler::downloadProgress = -1;
+int QDeclarativeImageRequestHandler::thisNetworkRequestDone = -1;
+
bool QDeclarativeImageRequestHandler::event(QEvent *event)
{
if (event->type() == QEvent::User) {
- static int replyDownloadProgress = -1;
- static int replyFinished = -1;
- static int downloadProgress = -1;
- static int thisNetworkRequestDone = -1;
-
if (replyDownloadProgress == -1) {
replyDownloadProgress = QNetworkReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)");
replyFinished = QNetworkReply::staticMetaObject.indexOfSignal("finished()");
@@ -264,10 +270,33 @@ bool QDeclarativeImageRequestHandler::event(QEvent *event)
return QObject::event(event);
}
+#define IMAGEREQUESTHANDLER_MAX_REDIRECT_RECURSION 16
+
void QDeclarativeImageRequestHandler::networkRequestDone()
{
QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
QDeclarativePixmapReply *job = replies.take(reply);
+
+ redirectCount++;
+ if (redirectCount < IMAGEREQUESTHANDLER_MAX_REDIRECT_RECURSION) {
+ QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ if (redirect.isValid()) {
+ QUrl url = reply->url().resolved(redirect.toUrl());
+ QNetworkRequest req(url);
+ req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
+
+ reply->deleteLater();
+ reply = networkAccessManager()->get(req);
+
+ QMetaObject::connect(reply, replyDownloadProgress, job, downloadProgress);
+ QMetaObject::connect(reply, replyFinished, this, thisNetworkRequestDone);
+
+ replies.insert(reply, job);
+ return;
+ }
+ }
+ redirectCount=0;
+
if (job) {
QImage image;
QDeclarativeImageReaderEvent::ReadError error;
diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp
index 766d1bc..f13c691 100644
--- a/src/declarative/util/qdeclarativestateoperations.cpp
+++ b/src/declarative/util/qdeclarativestateoperations.cpp
@@ -561,6 +561,13 @@ QString QDeclarativeStateChangeScript::typeName() const
\qmlclass AnchorChanges QDeclarativeAnchorChanges
\brief The AnchorChanges element allows you to change the anchors of an item in a state.
+ In the following example we change the top and bottom anchors of an item:
+ \qml
+ AnchorChanges {
+ target: content; top: window.top; bottom: window.bottom
+ }
+ \endqml
+
AnchorChanges will 'inject' \c x, \c y, \c width, and \c height changes into the transition,
so you can animate them as you would normally changes to these properties:
\qml
diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp
index 65bfdc1..9c3b0aa 100644
--- a/src/declarative/util/qdeclarativeutilmodule.cpp
+++ b/src/declarative/util/qdeclarativeutilmodule.cpp
@@ -75,44 +75,47 @@
void QDeclarativeUtilModule::defineModule()
{
- QML_REGISTER_TYPE(Qt,4,6,AnchorChanges,QDeclarativeAnchorChanges);
- QML_REGISTER_TYPE(Qt,4,6,Behavior,QDeclarativeBehavior);
- QML_REGISTER_TYPE(Qt,4,6,Binding,QDeclarativeBind);
- QML_REGISTER_TYPE(Qt,4,6,ColorAnimation,QDeclarativeColorAnimation);
- QML_REGISTER_TYPE(Qt,4,6,Connections,QDeclarativeConnections);
- QML_REGISTER_TYPE(Qt,4,6,EaseFollow,QDeclarativeEaseFollow);;
- QML_REGISTER_TYPE(Qt,4,6,FontLoader,QDeclarativeFontLoader);
- QML_REGISTER_TYPE(Qt,4,6,ListElement,QDeclarativeListElement);
- QML_REGISTER_TYPE(Qt,4,6,NumberAnimation,QDeclarativeNumberAnimation);
- QML_REGISTER_TYPE(Qt,4,6,Package,QDeclarativePackage);
- QML_REGISTER_TYPE(Qt,4,6,ParallelAnimation,QDeclarativeParallelAnimation);
- QML_REGISTER_TYPE(Qt,4,6,ParentAction,QDeclarativeParentAction);
- QML_REGISTER_TYPE(Qt,4,6,ParentAnimation,QDeclarativeParentAnimation);
- QML_REGISTER_TYPE(Qt,4,6,ParentChange,QDeclarativeParentChange);
- QML_REGISTER_TYPE(Qt,4,6,PauseAnimation,QDeclarativePauseAnimation);
- QML_REGISTER_TYPE(Qt,4,6,PropertyAction,QDeclarativePropertyAction);
- QML_REGISTER_TYPE(Qt,4,6,PropertyAnimation,QDeclarativePropertyAnimation);
- QML_REGISTER_TYPE(Qt,4,6,RotationAnimation,QDeclarativeRotationAnimation);
- QML_REGISTER_TYPE(Qt,4,6,ScriptAction,QDeclarativeScriptAction);
- QML_REGISTER_TYPE(Qt,4,6,SequentialAnimation,QDeclarativeSequentialAnimation);
- QML_REGISTER_TYPE(Qt,4,6,SpringFollow,QDeclarativeSpringFollow);
- QML_REGISTER_TYPE(Qt,4,6,StateChangeScript,QDeclarativeStateChangeScript);
- QML_REGISTER_TYPE(Qt,4,6,StateGroup,QDeclarativeStateGroup);
- QML_REGISTER_TYPE(Qt,4,6,State,QDeclarativeState);
- QML_REGISTER_TYPE(Qt,4,6,SystemPalette,QDeclarativeSystemPalette);
- QML_REGISTER_TYPE(Qt,4,6,Timer,QDeclarativeTimer);
- QML_REGISTER_TYPE(Qt,4,6,Transition,QDeclarativeTransition);
- QML_REGISTER_TYPE(Qt,4,6,Vector3dAnimation,QDeclarativeVector3dAnimation);
+ qmlRegisterType<QDeclarativeAnchorChanges>("Qt",4,6,"AnchorChanges");
+ qmlRegisterType<QDeclarativeBehavior>("Qt",4,6,"Behavior");
+ qmlRegisterType<QDeclarativeBind>("Qt",4,6,"Binding");
+ qmlRegisterType<QDeclarativeColorAnimation>("Qt",4,6,"ColorAnimation");
+ qmlRegisterType<QDeclarativeConnections>("Qt",4,6,"Connections");
+ qmlRegisterType<QDeclarativeEaseFollow>("Qt",4,6,"EaseFollow");
+ qmlRegisterType<QDeclarativeFontLoader>("Qt",4,6,"FontLoader");
+ qmlRegisterType<QDeclarativeListElement>("Qt",4,6,"ListElement");
+ 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");
+ qmlRegisterType<QDeclarativePropertyAction>("Qt",4,6,"PropertyAction");
+ qmlRegisterType<QDeclarativePropertyAnimation>("Qt",4,6,"PropertyAnimation");
+ qmlRegisterType<QDeclarativeRotationAnimation>("Qt",4,6,"RotationAnimation");
+ qmlRegisterType<QDeclarativeScriptAction>("Qt",4,6,"ScriptAction");
+ qmlRegisterType<QDeclarativeSequentialAnimation>("Qt",4,6,"SequentialAnimation");
+ qmlRegisterType<QDeclarativeSpringFollow>("Qt",4,6,"SpringFollow");
+ qmlRegisterType<QDeclarativeStateChangeScript>("Qt",4,6,"StateChangeScript");
+ qmlRegisterType<QDeclarativeStateGroup>("Qt",4,6,"StateGroup");
+ qmlRegisterType<QDeclarativeState>("Qt",4,6,"State");
+ qmlRegisterType<QDeclarativeSystemPalette>("Qt",4,6,"SystemPalette");
+ qmlRegisterType<QDeclarativeTimer>("Qt",4,6,"Timer");
+ qmlRegisterType<QDeclarativeTransition>("Qt",4,6,"Transition");
+ qmlRegisterType<QDeclarativeVector3dAnimation>("Qt",4,6,"Vector3dAnimation");
#ifndef QT_NO_XMLPATTERNS
- QML_REGISTER_TYPE(Qt,4,6,XmlListModel,QDeclarativeXmlListModel);
- QML_REGISTER_TYPE(Qt,4,6,XmlRole,QDeclarativeXmlListModelRole);
+ qmlRegisterType<QDeclarativeXmlListModel>("Qt",4,6,"XmlListModel");
+ qmlRegisterType<QDeclarativeXmlListModelRole>("Qt",4,6,"XmlRole");
#endif
- QML_REGISTER_NOCREATE_TYPE(QDeclarativeAnchors);
- QML_REGISTER_NOCREATE_TYPE(QDeclarativeAbstractAnimation);
- QML_REGISTER_NOCREATE_TYPE(QDeclarativeStateOperation);
+ qmlRegisterType<QDeclarativeAnchors>();
+ qmlRegisterType<QDeclarativeAbstractAnimation>();
+ qmlRegisterType<QDeclarativeStateOperation>();
- QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, ListModel, QDeclarativeListModel, QDeclarativeListModelParser);
- QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, PropertyChanges, QDeclarativePropertyChanges, QDeclarativePropertyChangesParser);
- QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, Connections, QDeclarativeConnections, QDeclarativeConnectionsParser);
+ qmlRegisterCustomType<QDeclarativeListModel>("Qt", 4,6, "ListModel", "QDeclarativeListModel",
+ new QDeclarativeListModelParser);
+ qmlRegisterCustomType<QDeclarativePropertyChanges>("Qt", 4, 6, "PropertyChanges", "QDeclarativePropertyChanges",
+ new QDeclarativePropertyChangesParser);
+ qmlRegisterCustomType<QDeclarativeConnections>("Qt", 4, 6, "Connections", "QDeclarativeConnections",
+ new QDeclarativeConnectionsParser);
}
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
index 735a009..486553a 100644
--- a/src/declarative/util/qdeclarativeview.cpp
+++ b/src/declarative/util/qdeclarativeview.cpp
@@ -458,8 +458,8 @@ void QDeclarativeView::setRootObject(QObject *obj)
QPerformanceLog::clear();
d->root = item;
d->qmlRoot = item;
- connect(item, SIGNAL(widthChanged()), this, SLOT(sizeChanged()));
- connect(item, SIGNAL(heightChanged()), this, SLOT(sizeChanged()));
+ connect(item, SIGNAL(widthChanged(qreal)), this, SLOT(sizeChanged()));
+ connect(item, SIGNAL(heightChanged(qreal)), this, SLOT(sizeChanged()));
if (d->initialSize.height() <= 0 && d->qmlRoot->width() > 0)
d->initialSize.setWidth(d->qmlRoot->width());
if (d->initialSize.height() <= 0 && d->qmlRoot->height() > 0)
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index 49dbb27..249880e 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -396,7 +396,7 @@ public:
QDeclarativeXmlListModelPrivate()
: isComponentComplete(true), size(-1), highestRole(Qt::UserRole)
, reply(0), status(QDeclarativeXmlListModel::Null), progress(0.0)
- , queryId(-1), roleObjects() {}
+ , queryId(-1), roleObjects(), redirectCount(0) {}
bool isComponentComplete;
QUrl src;
@@ -417,6 +417,7 @@ public:
static void removeAt_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list, int i);
static void insert_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list, int i, QDeclarativeXmlListModelRole *role);
QList<QList<QVariant> > data;
+ int redirectCount;
};
@@ -575,8 +576,8 @@ void QDeclarativeXmlListModel::setSource(const QUrl &src)
{
Q_D(QDeclarativeXmlListModel);
if (d->src != src) {
- reload();
d->src = src;
+ reload();
emit sourceChanged();
}
}
@@ -778,9 +779,25 @@ void QDeclarativeXmlListModel::reload()
this, SLOT(requestProgress(qint64,qint64)));
}
+#define XMLLISTMODEL_MAX_REDIRECT 16
+
void QDeclarativeXmlListModel::requestFinished()
{
Q_D(QDeclarativeXmlListModel);
+
+ d->redirectCount++;
+ if (d->redirectCount < XMLLISTMODEL_MAX_REDIRECT) {
+ QVariant redirect = d->reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ if (redirect.isValid()) {
+ QUrl url = d->reply->url().resolved(redirect.toUrl());
+ d->reply->deleteLater();
+ d->reply = 0;
+ setSource(url);
+ return;
+ }
+ }
+ d->redirectCount = 0;
+
if (d->reply->error() != QNetworkReply::NoError) {
disconnect(d->reply, 0, this, 0);
d->reply->deleteLater();