summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/debugger/qdeclarativedebugclient.cpp2
-rw-r--r--src/declarative/debugger/qdeclarativedebughelper.cpp8
-rw-r--r--src/declarative/debugger/qdeclarativedebughelper_p.h6
-rw-r--r--src/declarative/debugger/qdeclarativedebugservice.cpp19
-rw-r--r--src/declarative/graphicsitems/qdeclarativeborderimage.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp44
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p_p.h3
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp43
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp63
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp19
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea.cpp3
-rw-r--r--src/declarative/graphicsitems/qdeclarativerectangle.cpp3
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp37
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp23
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextlayout.cpp17
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextlayout_p.h1
-rw-r--r--src/declarative/qml/parser/qdeclarativejs.g4
-rw-r--r--src/declarative/qml/parser/qdeclarativejsparser.cpp4
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp37
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp21
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp3
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h2
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp3
-rw-r--r--src/declarative/qml/qdeclarativeparser_p.h2
-rw-r--r--src/declarative/qml/qdeclarativeprivate.h5
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp30
-rw-r--r--src/declarative/qml/qmetaobjectbuilder.cpp12
-rw-r--r--src/declarative/util/qdeclarativefontloader.cpp16
-rw-r--r--src/declarative/util/qdeclarativestate.cpp12
-rw-r--r--src/declarative/util/qdeclarativestate_p.h7
-rw-r--r--src/declarative/util/qdeclarativestate_p_p.h2
-rw-r--r--src/declarative/util/qdeclarativestategroup_p.h2
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp2
-rw-r--r--src/declarative/util/qdeclarativetransition.cpp6
-rw-r--r--src/declarative/util/qdeclarativetransition_p.h2
-rw-r--r--src/declarative/util/qdeclarativetransitionmanager.cpp16
-rw-r--r--src/declarative/util/qdeclarativeview.cpp8
39 files changed, 325 insertions, 169 deletions
diff --git a/src/declarative/debugger/qdeclarativedebugclient.cpp b/src/declarative/debugger/qdeclarativedebugclient.cpp
index 977e58e227..f5c57511af 100644
--- a/src/declarative/debugger/qdeclarativedebugclient.cpp
+++ b/src/declarative/debugger/qdeclarativedebugclient.cpp
@@ -93,7 +93,7 @@ QDeclarativeDebugConnectionPrivate::QDeclarativeDebugConnectionPrivate(QDeclarat
void QDeclarativeDebugConnectionPrivate::advertisePlugins()
{
- if (!q->isConnected() || !gotHello)
+ if (!q->isConnected())
return;
QPacket pack;
diff --git a/src/declarative/debugger/qdeclarativedebughelper.cpp b/src/declarative/debugger/qdeclarativedebughelper.cpp
index 207ad2bc7f..b003c12324 100644
--- a/src/declarative/debugger/qdeclarativedebughelper.cpp
+++ b/src/declarative/debugger/qdeclarativedebughelper.cpp
@@ -48,6 +48,7 @@
#include <private/qdeclarativeengine_p.h>
#include <private/qabstractanimation_p.h>
+#include <private/qdeclarativeengine_p.h>
QT_BEGIN_NAMESPACE
@@ -63,4 +64,11 @@ void QDeclarativeDebugHelper::setAnimationSlowDownFactor(qreal factor)
timer->setSlowdownFactor(factor);
}
+void QDeclarativeDebugHelper::enableDebugging() {
+ if (!QDeclarativeEnginePrivate::qml_debugging_enabled) {
+ qWarning("Qml debugging is enabled. Only use this in a safe environment!");
+ }
+ QDeclarativeEnginePrivate::qml_debugging_enabled = true;
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qdeclarativedebughelper_p.h b/src/declarative/debugger/qdeclarativedebughelper_p.h
index 5689dff252..fcd71151cd 100644
--- a/src/declarative/debugger/qdeclarativedebughelper_p.h
+++ b/src/declarative/debugger/qdeclarativedebughelper_p.h
@@ -55,11 +55,15 @@ class QDeclarativeEngine;
// Helper methods to access private API through a stable interface
// This is used in the qmljsdebugger library of QtCreator.
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugHelper
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugHelper
{
public:
static QScriptEngine *getScriptEngine(QDeclarativeEngine *engine);
static void setAnimationSlowDownFactor(qreal factor);
+
+ // Enables remote debugging functionality
+ // Only use this for debugging in a safe environment!
+ static void enableDebugging();
};
QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qdeclarativedebugservice.cpp b/src/declarative/debugger/qdeclarativedebugservice.cpp
index b98cd5dab3..8c86ae820e 100644
--- a/src/declarative/debugger/qdeclarativedebugservice.cpp
+++ b/src/declarative/debugger/qdeclarativedebugservice.cpp
@@ -42,6 +42,7 @@
#include "private/qdeclarativedebugservice_p.h"
#include "private/qpacketprotocol_p.h"
+#include "private/qdeclarativeengine_p.h"
#include <QtCore/qdebug.h>
#include <QtNetwork/qtcpserver.h>
@@ -204,13 +205,19 @@ QDeclarativeDebugServer *QDeclarativeDebugServer::instance()
bool ok = false;
// format: qmljsdebugger=port:3768[,block]
- if (!appD->qmljsDebugArguments.isEmpty()) {
+ if (!appD->qmljsDebugArgumentsString().isEmpty()) {
+ if (!QDeclarativeEnginePrivate::qml_debugging_enabled) {
+ qWarning() << QString::fromLatin1("QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
+ "Debugging has not been enabled.").arg(
+ appD->qmljsDebugArgumentsString()).toAscii().constData();
+ return 0;
+ }
- if (appD->qmljsDebugArguments.indexOf(QLatin1String("port:")) == 0) {
- int separatorIndex = appD->qmljsDebugArguments.indexOf(QLatin1Char(','));
- port = appD->qmljsDebugArguments.mid(5, separatorIndex - 5).toInt(&ok);
+ if (appD->qmljsDebugArgumentsString().indexOf(QLatin1String("port:")) == 0) {
+ int separatorIndex = appD->qmljsDebugArgumentsString().indexOf(QLatin1Char(','));
+ port = appD->qmljsDebugArgumentsString().mid(5, separatorIndex - 5).toInt(&ok);
}
- block = appD->qmljsDebugArguments.contains(QLatin1String("block"));
+ block = appD->qmljsDebugArgumentsString().contains(QLatin1String("block"));
if (ok) {
server = new QDeclarativeDebugServer(port);
@@ -221,7 +228,7 @@ QDeclarativeDebugServer *QDeclarativeDebugServer::instance()
} else {
qWarning(QString::fromAscii("QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
"Format is -qmljsdebugger=port:<port>[,block]").arg(
- appD->qmljsDebugArguments).toAscii().constData());
+ appD->qmljsDebugArgumentsString()).toAscii().constData());
}
}
#endif
diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
index c58a08ddd5..649c8fb074 100644
--- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp
@@ -361,6 +361,8 @@ QDeclarativeScaleGrid *QDeclarativeBorderImage::border()
\o BorderImage.Repeat - Tile the image until there is no more space. May crop the last image.
\o BorderImage.Round - Like Repeat, but scales the images down to ensure that the last image is not cropped.
\endlist
+
+ The default tile mode for each property is BorderImage.Stretch.
*/
QDeclarativeBorderImage::TileMode QDeclarativeBorderImage::horizontalTileMode() const
{
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 6fe152251d..0f786e35f8 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -53,9 +53,6 @@ QT_BEGIN_NAMESPACE
// before we perform a flick.
static const int FlickThreshold = 20;
-// Really slow flicks can be annoying.
-static const int MinimumFlickVelocity = 75;
-
QDeclarativeFlickableVisibleArea::QDeclarativeFlickableVisibleArea(QDeclarativeFlickable *parent)
: QObject(parent), flickable(parent), m_xPosition(0.), m_widthRatio(0.)
, m_yPosition(0.), m_heightRatio(0.)
@@ -990,8 +987,8 @@ void QDeclarativeFlickable::viewportMoved()
{
Q_D(QDeclarativeFlickable);
- qreal prevY = d->lastFlickablePosition.x();
- qreal prevX = d->lastFlickablePosition.y();
+ qreal prevX = d->lastFlickablePosition.x();
+ qreal prevY = d->lastFlickablePosition.y();
d->velocityTimeline.clear();
if (d->pressed || d->calcVelocity) {
int elapsed = QDeclarativeItemPrivate::restart(d->velocityTime);
@@ -1012,7 +1009,7 @@ void QDeclarativeFlickable::viewportMoved()
}
}
- d->lastFlickablePosition = QPointF(d->vData.move.value(), d->hData.move.value());
+ d->lastFlickablePosition = QPointF(d->hData.move.value(), d->vData.move.value());
d->vTime = d->timeline.time();
d->updateBeginningEnd();
@@ -1032,6 +1029,13 @@ void QDeclarativeFlickable::geometryChanged(const QRectF &newGeometry,
d->contentItem->setWidth(width());
emit contentWidthChanged();
}
+ // Make sure that we're entirely in view.
+ if (!d->pressed && !d->movingHorizontally && !d->movingVertically) {
+ int oldDuration = d->fixupDuration;
+ d->fixupDuration = 0;
+ d->fixupX();
+ d->fixupDuration = oldDuration;
+ }
}
if (newGeometry.height() != oldGeometry.height()) {
if (yflick())
@@ -1040,6 +1044,13 @@ void QDeclarativeFlickable::geometryChanged(const QRectF &newGeometry,
d->contentItem->setHeight(height());
emit contentHeightChanged();
}
+ // Make sure that we're entirely in view.
+ if (!d->pressed && !d->movingHorizontally && !d->movingVertically) {
+ int oldDuration = d->fixupDuration;
+ d->fixupDuration = 0;
+ d->fixupY();
+ d->fixupDuration = oldDuration;
+ }
}
if (changed)
@@ -1161,19 +1172,18 @@ void QDeclarativeFlickable::setBoundsBehavior(BoundsBehavior b)
\qmlproperty real Flickable::contentWidth
\qmlproperty real Flickable::contentHeight
- The dimensions of the content (the surface controlled by Flickable). Typically this
- should be set to the combined size of the items placed in the Flickable. Note this
- can be set automatically using \l {Item::childrenRect.width}{childrenRect.width}
- and \l {Item::childrenRect.height}{childrenRect.height}. For example:
+ The dimensions of the content (the surface controlled by Flickable).
+ This should typically be set to the combined size of the items placed in the
+ Flickable.
- \code
- Flickable {
- width: 320; height: 480
- contentWidth: childrenRect.width; contentHeight: childrenRect.height
+ The following snippet shows how these properties are used to display
+ an image that is larger than the Flickable item itself:
- Image { id: image; source: "bigImage.png" }
- }
- \endcode
+ \snippet doc/src/snippets/declarative/flickable.qml document
+
+ In some cases, the the content dimensions can be automatically set
+ using the \l {Item::childrenRect.width}{childrenRect.width}
+ and \l {Item::childrenRect.height}{childrenRect.height} properties.
*/
qreal QDeclarativeFlickable::contentWidth() const
{
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
index afefde22bf..92cf74874b 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
@@ -66,6 +66,9 @@
QT_BEGIN_NAMESPACE
+// Really slow flicks can be annoying.
+const qreal MinimumFlickVelocity = 75.0;
+
class QDeclarativeFlickableVisibleArea;
class QDeclarativeFlickablePrivate : public QDeclarativeItemPrivate, public QDeclarativeItemChangeListener
{
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
index 08d237f265..3b08a9bcb3 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -259,8 +259,10 @@ void QDeclarativeImage::setFillMode(FillMode mode)
\qmlproperty real Image::paintedHeight
These properties hold the size of the image that is actually painted.
- In most cases it is the same as \c width and \c height, but when using a \c fillMode like
- \c PreserveAspectFit \c paintedWidth or \c paintedHeight can be smaller than \c width and \c height.
+ In most cases it is the same as \c width and \c height, but when using a
+ \c fillMode \c PreserveAspectFit or \c fillMode \c PreserveAspectCrop
+ \c paintedWidth or \c paintedHeight can be smaller or larger than
+ \c width and \c height of the Image element.
*/
qreal QDeclarativeImage::paintedWidth() const
{
@@ -288,23 +290,25 @@ qreal QDeclarativeImage::paintedHeight() const
Use this status to provide an update or respond to the status change in some way.
For example, you could:
- \e {Trigger a state change:}
- \qml
- State { name: 'loaded'; when: image.status = Image.Ready }
+ \list
+ \o Trigger a state change:
+ \qml
+ State { name: 'loaded'; when: image.status == Image.Ready }
\endqml
- \e {Implement an \c onStatusChanged signal handler:}
- \qml
+ \o Implement an \c onStatusChanged signal handler:
+ \qml
Image {
id: image
onStatusChanged: if (image.status == Image.Ready) console.log('Loaded')
}
\endqml
- \e {Bind to the status value:}
+ \o Bind to the status value:
\qml
- Text { text: image.status != Image.Ready ? 'Not Loaded' : 'Loaded' }
+ Text { text: image.status == Image.Ready ? 'Loaded' : 'Not loaded' }
\endqml
+ \endlist
\sa progress
*/
@@ -397,6 +401,19 @@ void QDeclarativeImage::updatePaintedGeometry()
if (heightValid() && !widthValid()) {
setImplicitWidth(d->paintedWidth);
}
+ } else if (d->fillMode == PreserveAspectCrop) {
+ if (!d->pix.width() || !d->pix.height())
+ return;
+ qreal widthScale = width() / qreal(d->pix.width());
+ qreal heightScale = height() / qreal(d->pix.height());
+ if (widthScale < heightScale) {
+ widthScale = heightScale;
+ } else if(heightScale < widthScale) {
+ heightScale = widthScale;
+ }
+
+ d->paintedHeight = heightScale * qreal(d->pix.height());
+ d->paintedWidth = widthScale * qreal(d->pix.width());
} else {
d->paintedWidth = width();
d->paintedHeight = height();
@@ -410,6 +427,12 @@ void QDeclarativeImage::geometryChanged(const QRectF &newGeometry, const QRectF
updatePaintedGeometry();
}
+QRectF QDeclarativeImage::boundingRect() const
+{
+ Q_D(const QDeclarativeImage);
+ return QRectF(0, 0, qMax(d->mWidth, d->paintedWidth), qMax(d->mHeight, d->paintedHeight));
+}
+
/*!
\qmlproperty url Image::source
@@ -494,7 +517,7 @@ void QDeclarativeImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWi
}
if (clip()) {
p->save();
- p->setClipRect(boundingRect(), Qt::IntersectClip);
+ p->setClipRect(QRectF(0, 0, d->mWidth, d->mHeight), Qt::IntersectClip);
}
scale.scale(widthScale, heightScale);
QTransform old = p->transform();
diff --git a/src/declarative/graphicsitems/qdeclarativeimage_p.h b/src/declarative/graphicsitems/qdeclarativeimage_p.h
index c8bb30be8f..0e8034e743 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeimage_p.h
@@ -76,6 +76,7 @@ public:
qreal paintedHeight() const;
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+ QRectF boundingRect() const;
Q_SIGNALS:
void fillModeChanged();
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 95a4fd65c0..e0df75195b 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -1955,12 +1955,8 @@ void QDeclarativeItem::geometryChanged(const QRectF &newGeometry,
change.listener->itemGeometryChanged(this, newGeometry, oldGeometry);
}
- if (newGeometry.x() != oldGeometry.x())
- emit xChanged();
if (newGeometry.width() != oldGeometry.width())
emit widthChanged();
- if (newGeometry.y() != oldGeometry.y())
- emit yChanged();
if (newGeometry.height() != oldGeometry.height())
emit heightChanged();
}
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 38a4839502..94b1cb368c 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -334,28 +334,9 @@ public:
return model && model->count() && model->isValid();
}
- int snapIndex() {
- int index = currentIndex;
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxListItem *item = visibleItems[i];
- if (item->index == -1)
- continue;
- qreal itemTop = item->position();
- if (itemTop >= highlight->position()-item->size()/2 && itemTop < highlight->position()+item->size()/2)
- return item->index;
- }
- return index;
- }
-
qreal snapPosAt(qreal pos) {
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxListItem *item = visibleItems[i];
- if (item->index == -1)
- continue;
- qreal itemTop = item->position();
- if (itemTop+item->size()/2 >= pos && itemTop <= pos)
- return item->position();
- }
+ if (FxListItem *snapItem = snapItemAt(pos))
+ return snapItem->position();
if (visibleItems.count()) {
qreal firstPos = visibleItems.first()->position();
qreal endPos = visibleItems.last()->position();
@@ -368,17 +349,18 @@ public:
}
FxListItem *snapItemAt(qreal pos) {
+ FxListItem *snapItem = 0;
for (int i = 0; i < visibleItems.count(); ++i) {
FxListItem *item = visibleItems[i];
if (item->index == -1)
continue;
qreal itemTop = item->position();
- if (item->index == model->count()-1 || (itemTop+item->size()/2 >= pos))
+ if (highlight && itemTop >= pos && item->endPosition() <= pos + highlight->size() - 1)
return item;
+ if (itemTop+item->size()/2 >= pos && itemTop-item->size()/2 < pos)
+ snapItem = item;
}
- if (visibleItems.count() && visibleItems.first()->position() <= pos)
- return visibleItems.first();
- return 0;
+ return snapItem;
}
int lastVisibleIndex() const {
@@ -768,8 +750,10 @@ void QDeclarativeListViewPrivate::layout()
minExtentDirty = true;
maxExtentDirty = true;
updateHighlight();
- fixupPosition();
- q->refill();
+ if (!q->isMoving() && !q->isFlicking()) {
+ fixupPosition();
+ q->refill();
+ }
if (header)
updateHeader();
if (footer)
@@ -1173,6 +1157,7 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m
|| (orient == QDeclarativeListView::Vertical && &data == &hData))
return;
+ correctFlick = false;
int oldDuration = fixupDuration;
fixupDuration = moveReason == Mouse ? fixupDuration : 0;
@@ -1350,12 +1335,15 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
qreal newtarget = data.flickTarget;
if (snapMode != QDeclarativeListView::NoSnap || highlightRange == QDeclarativeListView::StrictlyEnforceRange)
newtarget = -snapPosAt(-(data.flickTarget - highlightRangeStart)) + highlightRangeStart;
- if (velocity < 0 && newtarget < maxExtent)
- newtarget = maxExtent;
- else if (velocity > 0 && newtarget > minExtent)
- newtarget = minExtent;
- if (newtarget == data.flickTarget) // boundary unchanged - nothing to do
+ if (velocity < 0 && newtarget <= maxExtent)
+ newtarget = maxExtent - overshootDist;
+ else if (velocity > 0 && newtarget >= minExtent)
+ newtarget = minExtent + overshootDist;
+ if (newtarget == data.flickTarget) { // boundary unchanged - nothing to do
+ if (qAbs(velocity) < MinimumFlickVelocity)
+ correctFlick = false;
return;
+ }
data.flickTarget = newtarget;
qreal dist = -newtarget + data.move.value();
if ((v < 0 && dist < 0) || (v > 0 && dist > 0)) {
@@ -1365,7 +1353,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
return;
}
timeline.reset(data.move);
- timeline.accelDistance(data.move, v, -dist + (v < 0 ? -overshootDist : overshootDist));
+ timeline.accelDistance(data.move, v, -dist);
timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this));
}
} else {
@@ -1696,7 +1684,7 @@ void QDeclarativeListView::setCurrentIndex(int index)
if (isComponentComplete() && d->isValid()) {
d->moveReason = QDeclarativeListViewPrivate::SetIndex;
d->updateCurrent(index);
- } else {
+ } else if (d->currentIndex != index) {
d->currentIndex = index;
emit currentIndexChanged();
}
@@ -2323,9 +2311,10 @@ void QDeclarativeListView::viewportMoved()
d->highlight->setPosition(qRound(pos));
// update current index
- int idx = d->snapIndex();
- if (idx >= 0 && idx != d->currentIndex)
- d->updateCurrent(idx);
+ if (FxListItem *snapItem = d->snapItemAt(d->highlight->position())) {
+ if (snapItem->index >= 0 && snapItem->index != d->currentIndex)
+ d->updateCurrent(snapItem->index);
+ }
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp
index 5647b14568..109fbbbbd5 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp
@@ -216,7 +216,8 @@ QDeclarativeLoader::~QDeclarativeLoader()
cannot load non-visual components.
To unload the currently loaded item, set this property to an empty string,
- or set \l sourceComponent to \c undefined.
+ or set \l sourceComponent to \c undefined. Setting \c source to a
+ new URL will also cause the item created by the previous URL to be unloaded.
\sa sourceComponent, status, progress
*/
@@ -394,23 +395,25 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded()
Use this status to provide an update or respond to the status change in some way.
For example, you could:
- \e {Trigger a state change:}
- \qml
- State { name: 'loaded'; when: loader.status = Loader.Ready }
+ \list
+ \o Trigger a state change:
+ \qml
+ State { name: 'loaded'; when: loader.status == Loader.Ready }
\endqml
- \e {Implement an \c onStatusChanged signal handler:}
- \qml
+ \o Implement an \c onStatusChanged signal handler:
+ \qml
Loader {
id: loader
onStatusChanged: if (loader.status == Loader.Ready) console.log('Loaded')
}
\endqml
- \e {Bind to the status value:}
+ \o Bind to the status value:
\qml
- Text { text: loader.status != Loader.Ready ? 'Not Loaded' : 'Loaded' }
+ Text { text: loader.status == Loader.Ready ? 'Loaded' : 'Not loaded' }
\endqml
+ \endlist
Note that if the source is a local file, the status will initially be Ready (or Error). While
there will be no onStatusChanged signal in that case, the onLoaded will still be invoked.
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
index 1b7dce04d9..d9edd11171 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp
+++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
@@ -566,7 +566,8 @@ void QDeclarativeMouseArea::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *even
if (!d->absorb) {
QDeclarativeItem::mouseDoubleClickEvent(event);
} else {
- d->doubleClick = true;
+ if (d->isDoubleClickConnected())
+ d->doubleClick = true;
d->saveEvent(event);
QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, true, false);
me.setAccepted(d->isDoubleClickConnected());
diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
index 1ffd3bdc25..fc3954f042 100644
--- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
@@ -477,7 +477,8 @@ void QDeclarativeRectangle::drawRect(QPainter &p)
{
Q_D(QDeclarativeRectangle);
if ((d->gradient && d->gradient->gradient())
- || d->radius > width()/2 || d->radius > height()/2) {
+ || d->radius > width()/2 || d->radius > height()/2
+ || width() < 3 || height() < 3) {
// XXX This path is still slower than the image path
// Image path won't work for gradients or invalid radius though
bool oldAA = p.testRenderHint(QPainter::Antialiasing);
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index 0717b78b23..82c444e04f 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -219,8 +219,10 @@ void QDeclarativeTextPrivate::updateSize()
QFontMetrics fm(font);
if (text.isEmpty()) {
+ q->setImplicitWidth(0);
q->setImplicitHeight(fm.height());
emit q->paintedSizeChanged();
+ q->update();
return;
}
@@ -283,11 +285,10 @@ QSize QDeclarativeTextPrivate::setupTextLayout()
{
// ### text layout handling should be profiled and optimized as needed
// what about QStackTextEngine engine(tmp, d->font.font()); QTextLayout textLayout(&engine);
-
Q_Q(QDeclarativeText);
layout.setCacheEnabled(true);
- int height = 0;
+ qreal height = 0;
qreal widthUsed = 0;
qreal lineWidth = 0;
@@ -300,12 +301,12 @@ QSize QDeclarativeTextPrivate::setupTextLayout()
layout.setTextOption(textOption);
layout.beginLayout();
- while (1) {
+ forever {
QTextLine line = layout.createLine();
if (!line.isValid())
break;
- if ((wrapMode != QDeclarativeText::NoWrap || elideMode != QDeclarativeText::ElideNone) && q->widthValid())
+ if (lineWidth)
line.setLineWidth(lineWidth);
}
layout.endLayout();
@@ -315,27 +316,27 @@ QSize QDeclarativeTextPrivate::setupTextLayout()
widthUsed = qMax(widthUsed, line.naturalTextWidth());
}
- qreal layoutWidth = q->widthValid()?q->width():widthUsed;
+ qreal layoutWidth = q->widthValid() ? q->width() : widthUsed;
- int x = 0;
+ qreal x = 0;
for (int i = 0; i < layout.lineCount(); ++i) {
QTextLine line = layout.lineAt(i);
line.setPosition(QPointF(0, height));
- height += int(line.height());
+ height += line.height();
if (!cacheAllTextAsImage) {
if (hAlign == QDeclarativeText::AlignLeft) {
x = 0;
} else if (hAlign == QDeclarativeText::AlignRight) {
- x = layoutWidth - (int)line.naturalTextWidth();
+ x = layoutWidth - line.naturalTextWidth();
} else if (hAlign == QDeclarativeText::AlignHCenter) {
- x = (layoutWidth - (int)line.naturalTextWidth()) / 2;
+ x = (layoutWidth - line.naturalTextWidth()) / 2;
}
- line.setPosition(QPoint(x, (int)line.y()));
+ line.setPosition(QPointF(x, line.y()));
}
}
- return QSize(qCeil(widthUsed), height);
+ return layout.boundingRect().toAlignedRect().size();
}
/*!
@@ -347,17 +348,17 @@ QPixmap QDeclarativeTextPrivate::textLayoutImage(bool drawStyle)
//do layout
QSize size = layedOutTextSize;
- int x = 0;
+ qreal x = 0;
for (int i = 0; i < layout.lineCount(); ++i) {
QTextLine line = layout.lineAt(i);
if (hAlign == QDeclarativeText::AlignLeft) {
x = 0;
} else if (hAlign == QDeclarativeText::AlignRight) {
- x = size.width() - (int)line.naturalTextWidth();
+ x = size.width() - line.naturalTextWidth();
} else if (hAlign == QDeclarativeText::AlignHCenter) {
- x = (size.width() - (int)line.naturalTextWidth()) / 2;
+ x = (size.width() - line.naturalTextWidth()) / 2;
}
- line.setPosition(QPoint(x, (int)line.y()));
+ line.setPosition(QPointF(x, line.y()));
}
//paint text
@@ -901,7 +902,7 @@ void QDeclarativeText::setStyleColor(const QColor &color)
and \c Text.AlignVCenter.
Note that for a single line of text, the size of the text is the area of the text. In this common case,
- all alignments are equivalent. If you want the text to be, say, centered in it parent, then you will
+ all alignments are equivalent. If you want the text to be, say, centered in its parent, then you will
need to either modify the Item::anchors, or set horizontalAlignment to Text.AlignHCenter and bind the width to
that of the parent.
*/
@@ -1062,7 +1063,7 @@ void QDeclarativeText::setTextFormat(TextFormat format)
Set this property to elide parts of the text fit to the Text item's width.
The text will only elide if an explicit width has been set.
- This property cannot be used with wrapping enabled or with rich text.
+ This property cannot be used with multi-line text or with rich text.
Eliding can be:
\list
@@ -1147,7 +1148,7 @@ void QDeclarativeText::geometryChanged(const QRectF &newGeometry, const QRectF &
if ((!d->internalWidthUpdate && newGeometry.width() != oldGeometry.width())
&& (d->wrapMode != QDeclarativeText::NoWrap
|| d->elideMode != QDeclarativeText::ElideNone
- || d->hAlign != Qt::AlignLeft)) {
+ || d->hAlign != QDeclarativeText::AlignLeft)) {
if (d->singleline && d->elideMode != QDeclarativeText::ElideNone && widthValid()) {
// We need to re-elide
d->updateLayout();
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index 2348478657..0deacf889b 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -460,10 +460,9 @@ QRect QDeclarativeTextInput::cursorRectangle() const
text edit.
Note that if selectionStart == selectionEnd then there is no current
- selection. If you attempt to set selectionStart to a value outside of
- the current text, selectionStart will not be changed.
+ selection.
- \sa selectionEnd, cursorPosition, selectedText
+ \sa selectionEnd, cursorPosition, selectedText, select()
*/
int QDeclarativeTextInput::selectionStart() const
{
@@ -479,10 +478,9 @@ int QDeclarativeTextInput::selectionStart() const
text edit.
Note that if selectionStart == selectionEnd then there is no current
- selection. If you attempt to set selectionEnd to a value outside of
- the current text, selectionEnd will not be changed.
+ selection.
- \sa selectionStart, cursorPosition, selectedText
+ \sa selectionStart, cursorPosition, selectedText, select()
*/
int QDeclarativeTextInput::selectionEnd() const
{
@@ -490,6 +488,19 @@ int QDeclarativeTextInput::selectionEnd() const
return d->lastSelectionEnd;
}
+/*!
+ \qmlmethod void TextInput::select(int start, int end)
+
+ Causes the text from \a start to \a end to be selected.
+
+ If either start or end is out of range, the selection is not changed.
+
+ After calling this, selectionStart will become the lesser
+ and selectionEnd will become the greater (regardless of the order passed
+ to this method).
+
+ \sa selectionStart, selectionEnd
+*/
void QDeclarativeTextInput::select(int start, int end)
{
Q_D(QDeclarativeTextInput);
diff --git a/src/declarative/graphicsitems/qdeclarativetextlayout.cpp b/src/declarative/graphicsitems/qdeclarativetextlayout.cpp
index 89a2158c6d..e8da3676c4 100644
--- a/src/declarative/graphicsitems/qdeclarativetextlayout.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextlayout.cpp
@@ -94,7 +94,7 @@ class DrawTextItemRecorder: public QPaintEngine
if (!m_inertText->items.isEmpty()) {
QStaticTextItem &last = m_inertText->items[m_inertText->items.count() - 1];
- if (last.fontEngine == ti.fontEngine && last.font == ti.font() &&
+ if (last.fontEngine() == ti.fontEngine && last.font == ti.font() &&
(!m_dirtyPen || last.color == state->pen().color())) {
needFreshCurrentItem = false;
@@ -107,7 +107,7 @@ class DrawTextItemRecorder: public QPaintEngine
if (needFreshCurrentItem) {
QStaticTextItem currentItem;
- currentItem.fontEngine = ti.fontEngine;
+ currentItem.setFontEngine(ti.fontEngine);
currentItem.font = ti.font();
currentItem.charOffset = charOffset;
currentItem.numChars = ti.num_chars;
@@ -285,6 +285,19 @@ void QDeclarativeTextLayout::beginLayout()
QTextLayout::beginLayout();
}
+void QDeclarativeTextLayout::clearLayout()
+{
+ if (d && d->cached) {
+ d->cached = false;
+ d->items.clear();
+ d->positions.clear();
+ d->glyphs.clear();
+ d->chars.clear();
+ d->position = QPointF();
+ }
+ QTextLayout::clearLayout();
+}
+
void QDeclarativeTextLayout::prepare()
{
if (!d || !d->cached) {
diff --git a/src/declarative/graphicsitems/qdeclarativetextlayout_p.h b/src/declarative/graphicsitems/qdeclarativetextlayout_p.h
index 90bf0e0979..8b81db3536 100644
--- a/src/declarative/graphicsitems/qdeclarativetextlayout_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextlayout_p.h
@@ -59,6 +59,7 @@ public:
~QDeclarativeTextLayout();
void beginLayout();
+ void clearLayout();
void prepare();
void draw(QPainter *, const QPointF & = QPointF());
diff --git a/src/declarative/qml/parser/qdeclarativejs.g b/src/declarative/qml/parser/qdeclarativejs.g
index 1b66ba0427..c84f0b30ba 100644
--- a/src/declarative/qml/parser/qdeclarativejs.g
+++ b/src/declarative/qml/parser/qdeclarativejs.g
@@ -1254,7 +1254,7 @@ case $rule_number: {
else
node = makeAstNode<AST::ObjectLiteral> (driver->nodePool());
node->lbraceToken = loc(1);
- node->lbraceToken = loc(3);
+ node->rbraceToken = loc(3);
sym(1).Node = node;
} break;
./
@@ -1265,7 +1265,7 @@ case $rule_number: {
AST::ObjectLiteral *node = makeAstNode<AST::ObjectLiteral> (driver->nodePool(),
sym(2).PropertyNameAndValueList->finish ());
node->lbraceToken = loc(1);
- node->lbraceToken = loc(4);
+ node->rbraceToken = loc(4);
sym(1).Node = node;
} break;
./
diff --git a/src/declarative/qml/parser/qdeclarativejsparser.cpp b/src/declarative/qml/parser/qdeclarativejsparser.cpp
index 8afb93d5ba..28ef17d5ae 100644
--- a/src/declarative/qml/parser/qdeclarativejsparser.cpp
+++ b/src/declarative/qml/parser/qdeclarativejsparser.cpp
@@ -679,7 +679,7 @@ case 85: {
else
node = makeAstNode<AST::ObjectLiteral> (driver->nodePool());
node->lbraceToken = loc(1);
- node->lbraceToken = loc(3);
+ node->rbraceToken = loc(3);
sym(1).Node = node;
} break;
@@ -687,7 +687,7 @@ case 86: {
AST::ObjectLiteral *node = makeAstNode<AST::ObjectLiteral> (driver->nodePool(),
sym(2).PropertyNameAndValueList->finish ());
node->lbraceToken = loc(1);
- node->lbraceToken = loc(4);
+ node->rbraceToken = loc(4);
sym(1).Node = node;
} break;
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index 0a2a6dbc51..2686ce3d52 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -98,6 +98,43 @@ class QByteArray;
int width = item->width(); // width = 200
\endcode
+
+ \section2 Network Components
+
+ If the URL passed to QDeclarativeComponent is a network resource, or if the QML document references a
+ network resource, the QDeclarativeComponent has to fetch the network data before it is able to create
+ objects. In this case, the QDeclarativeComponent will have a \l {QDeclarativeComponent::Loading}{Loading}
+ \l {QDeclarativeComponent::status()}{status}. An application will have to wait until the component
+ is \l {QDeclarativeComponent::Ready}{Ready} before calling \l {QDeclarativeComponent::create()}.
+
+ The following example shows how to load a QML file from a network resource. After creating
+ the QDeclarativeComponent, it tests whether the component is loading. If it is, it connects to the
+ QDeclarativeComponent::statusChanged() signal and otherwise calls the \c {continueLoading()} method
+ directly. Note that QDeclarativeComponent::isLoading() may be false for a network component if the
+ component has been cached and is ready immediately.
+
+ \code
+ MyApplication::MyApplication()
+ {
+ // ...
+ component = new QDeclarativeComponent(engine, QUrl("http://www.example.com/main.qml"));
+ if (component->isLoading())
+ QObject::connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)),
+ this, SLOT(continueLoading()));
+ else
+ continueLoading();
+ }
+
+ void MyApplication::continueLoading()
+ {
+ if (component->isError()) {
+ qWarning() << component->errors();
+ } else {
+ QObject *myObject = component->create();
+ }
+ }
+ \endcode
+
\sa {Using QML in C++ Applications}, {Integrating QML with existing Qt UI code}
*/
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp
index 59d5cfa692..1e58a71d1e 100644
--- a/src/declarative/qml/qdeclarativecontext.cpp
+++ b/src/declarative/qml/qdeclarativecontext.cpp
@@ -86,9 +86,14 @@ QDeclarativeContextPrivate::QDeclarativeContextPrivate()
QDeclarativeComponent component(&engine);
component.setData("import QtQuick 1.0\nListView { model: myModel }", QUrl());
- component.create(context);
+ QObject *window = component.create(context);
\endcode
+ Note it is the responsibility of the creator to delete any QDeclarativeContext it
+ constructs. If the \c context object in the example is no longer needed when the
+ \c window component instance is destroyed, the \c context must be destroyed explicitly.
+ The simplest way to ensure this is to set \c window as the parent of \c context.
+
To simplify binding and maintaining larger data sets, a context object can be set
on a QDeclarativeContext. All the properties of the context object are available
by name in the context, as though they were all individually added through calls
@@ -119,11 +124,13 @@ QDeclarativeContextPrivate::QDeclarativeContextPrivate()
All properties added explicitly by QDeclarativeContext::setContextProperty() take
precedence over the context object's properties.
- Contexts form a hierarchy. The root of this hierarchy is the QDeclarativeEngine's
- \l {QDeclarativeEngine::rootContext()}{root context}. A component instance can
- access the data in its own context, as well as all its ancestor contexts. Data
- can be made available to all instances by modifying the
- \l {QDeclarativeEngine::rootContext()}{root context}.
+ \section2 The Context Hierarchy
+
+ Contexts form a hierarchy. The root of this hierarchy is the QML engine's
+ \l {QDeclarativeEngine::rootContext()}{root context}. Child contexts inherit
+ the context properties of their parents; if a child context sets a context property
+ that already exists in its parent, the new context property overrides that of the
+ parent.
The following example defines two contexts - \c context1 and \c context2. The
second context overrides the "b" context property inherited from the first with a
@@ -144,7 +151,7 @@ QDeclarativeContextPrivate::QDeclarativeContextPrivate()
context, their bindings are. If a context is destroyed, the property bindings of
outstanding QML objects will stop evaluating.
- \note Setting the context object or adding new context properties after an object
+ \warning Setting the context object or adding new context properties after an object
has been created in that context is an expensive operation (essentially forcing all bindings
to reevaluate). Thus whenever possible you should complete "setup" of the context
before using it to create any objects.
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index caea6d8b34..cd113361b1 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -176,6 +176,7 @@ struct StaticQtMetaObject : public QObject
};
static bool qt_QmlQtModule_registered = false;
+bool QDeclarativeEnginePrivate::qml_debugging_enabled = false;
void QDeclarativeEnginePrivate::defineModule()
{
@@ -608,7 +609,7 @@ QDeclarativeContext *QDeclarativeEngine::rootContext() const
QNetworkAccessManager with specialized caching, proxy and cookie
support.
- The factory must be set before exceuting the engine.
+ The factory must be set before executing the engine.
*/
void QDeclarativeEngine::setNetworkAccessManagerFactory(QDeclarativeNetworkAccessManagerFactory *factory)
{
diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h
index 8539fbf2d9..deb4a77ee8 100644
--- a/src/declarative/qml/qdeclarativeengine_p.h
+++ b/src/declarative/qml/qdeclarativeengine_p.h
@@ -321,6 +321,8 @@ public:
static QString urlToLocalFileOrQrc(const QUrl& url);
static void defineModule();
+
+ static bool qml_debugging_enabled;
};
/*!
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp
index ed281857d2..bffe681470 100644
--- a/src/declarative/qml/qdeclarativeenginedebug.cpp
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -502,7 +502,8 @@ void QDeclarativeEngineDebugServer::setBinding(int objectId,
property.write(expression);
} else if (hasValidSignal(object, propertyName)) {
QDeclarativeExpression *declarativeExpression = new QDeclarativeExpression(context, object, expression.toString());
- QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression);
+ QDeclarativeExpression *oldExpression = QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression);
+ declarativeExpression->setSourceLocation(oldExpression->sourceFile(), oldExpression->lineNumber());
} else if (property.isProperty()) {
QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context);
binding->setTarget(property);
diff --git a/src/declarative/qml/qdeclarativeparser_p.h b/src/declarative/qml/qdeclarativeparser_p.h
index b4753df6b0..77184c2ddb 100644
--- a/src/declarative/qml/qdeclarativeparser_p.h
+++ b/src/declarative/qml/qdeclarativeparser_p.h
@@ -356,7 +356,7 @@ namespace QDeclarativeParser
// True if the setting of this property will be deferred. Set by the
// QDeclarativeCompiler
bool isDeferred;
- // True if this property is a value-type psuedo-property
+ // True if this property is a value-type pseudo-property
bool isValueTypeSubProperty;
LocationSpan location;
diff --git a/src/declarative/qml/qdeclarativeprivate.h b/src/declarative/qml/qdeclarativeprivate.h
index d45ddbcbaf..388c92e15c 100644
--- a/src/declarative/qml/qdeclarativeprivate.h
+++ b/src/declarative/qml/qdeclarativeprivate.h
@@ -55,9 +55,6 @@
#include <QtCore/qglobal.h>
#include <QtCore/qvariant.h>
-#ifndef Q_OS_WIN
-#include <stdint.h>
-#endif
QT_BEGIN_HEADER
@@ -105,7 +102,7 @@ namespace QDeclarativePrivate
template<class From, class To>
struct StaticCastSelectorClass<From, To, sizeof(int)>
{
- static inline int cast() { return int(reinterpret_cast<intptr_t>(static_cast<To *>(reinterpret_cast<From *>(0x10000000)))) - 0x10000000; }
+ static inline int cast() { return int(reinterpret_cast<quintptr>(static_cast<To *>(reinterpret_cast<From *>(0x10000000)))) - 0x10000000; }
};
template<class From, class To>
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index 509ca6bb5f..ae7a80d139 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -514,7 +514,7 @@ void QDeclarativeWorkerScriptEngine::run()
/*!
\qmlclass WorkerScript QDeclarativeWorkerScript
- \ingroup qml-utility-elements
+ \ingroup qml-utility-elements
\brief The WorkerScript element enables the use of threads in QML.
Use WorkerScript to run operations in a new thread.
@@ -528,7 +528,7 @@ void QDeclarativeWorkerScriptEngine::run()
\snippet doc/src/snippets/declarative/workerscript.qml 0
- The above worker script specifies a javascript file, "script.js", that handles
+ The above worker script specifies a JavaScript file, "script.js", that handles
the operations to be performed in the new thread. Here is \c script.js:
\qml
@@ -543,6 +543,19 @@ void QDeclarativeWorkerScriptEngine::run()
\tt script.js. This in turn sends a reply message that is then received
by the \tt onMessage() handler of \tt myWorker.
+
+ \section3 Restrictions
+
+ Since the \c WorkerScript.onMessage() function is run in a separate thread, the
+ JavaScript file is evaluated in a context separate from the main QML engine. This means
+ that unlike an ordinary JavaScript file that is imported into QML, the \c script.js
+ in the above example cannot access the properties, methods or other attributes
+ of the QML item, nor can it access any context properties set on the QML object
+ through QDeclarativeContext.
+
+ Additionally, there are restrictions on the types of values that can be passed to and
+ from the worker script. See the sendMessage() documentation for details.
+
\sa {declarative/threading/workerscript}{WorkerScript example},
{declarative/threading/threadedlistmodel}{Threaded ListModel example}
*/
@@ -586,6 +599,19 @@ void QDeclarativeWorkerScript::setSource(const QUrl &source)
Sends the given \a message to a worker script handler in another
thread. The other worker script handler can receive this message
through the onMessage() handler.
+
+ The \c message object may only contain values of the following
+ types:
+
+ \list
+ \o boolean, number, string
+ \o JavaScript objects and arrays
+ \o ListModel objects (any other type of QObject* is not allowed)
+ \endlist
+
+ All objects and arrays are copied to the \c message. With the exception
+ of ListModel objects, any modifications by the other thread to an object
+ passed in \c message will not be reflected in the original object.
*/
void QDeclarativeWorkerScript::sendMessage(const QScriptValue &message)
{
diff --git a/src/declarative/qml/qmetaobjectbuilder.cpp b/src/declarative/qml/qmetaobjectbuilder.cpp
index 58f8811567..dfe89f843b 100644
--- a/src/declarative/qml/qmetaobjectbuilder.cpp
+++ b/src/declarative/qml/qmetaobjectbuilder.cpp
@@ -41,10 +41,6 @@
#include "private/qmetaobjectbuilder_p.h"
-#ifndef Q_OS_WIN
-#include <stdint.h>
-#endif
-
QT_BEGIN_NAMESPACE
/*!
@@ -1264,8 +1260,8 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
char *str = reinterpret_cast<char *>(buf + size);
if (buf) {
if (relocatable) {
- meta->d.stringdata = reinterpret_cast<const char *>((intptr_t)size);
- meta->d.data = reinterpret_cast<uint *>((intptr_t)pmetaSize);
+ meta->d.stringdata = reinterpret_cast<const char *>((quintptr)size);
+ meta->d.data = reinterpret_cast<uint *>((quintptr)pmetaSize);
} else {
meta->d.stringdata = str;
meta->d.data = reinterpret_cast<uint *>(data);
@@ -1502,8 +1498,8 @@ void QMetaObjectBuilder::fromRelocatableData(QMetaObject *output,
const char *buf = data.constData();
const QMetaObject *dataMo = reinterpret_cast<const QMetaObject *>(buf);
- intptr_t stringdataOffset = (intptr_t)dataMo->d.stringdata;
- intptr_t dataOffset = (intptr_t)dataMo->d.data;
+ quintptr stringdataOffset = (quintptr)dataMo->d.stringdata;
+ quintptr dataOffset = (quintptr)dataMo->d.data;
output->d.superdata = superclass;
output->d.stringdata = buf + stringdataOffset;
diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp
index 9fee2575e7..03a0561fbf 100644
--- a/src/declarative/util/qdeclarativefontloader.cpp
+++ b/src/declarative/util/qdeclarativefontloader.cpp
@@ -297,23 +297,25 @@ void QDeclarativeFontLoader::setName(const QString &name)
Use this status to provide an update or respond to the status change in some way.
For example, you could:
- \e {Trigger a state change:}
- \qml
- State { name: 'loaded'; when: loader.status = FontLoader.Ready }
+ \list
+ \o Trigger a state change:
+ \qml
+ State { name: 'loaded'; when: loader.status == FontLoader.Ready }
\endqml
- \e {Implement an \c onStatusChanged signal handler:}
- \qml
+ \o Implement an \c onStatusChanged signal handler:
+ \qml
FontLoader {
id: loader
onStatusChanged: if (loader.status == FontLoader.Ready) console.log('Loaded')
}
\endqml
- \e {Bind to the status value:}
+ \o Bind to the status value:
\qml
- Text { text: loader.status != FontLoader.Ready ? 'Not Loaded' : 'Loaded' }
+ Text { text: loader.status == FontLoader.Ready ? 'Loaded' : 'Not loaded' }
\endqml
+ \endlist
*/
QDeclarativeFontLoader::Status QDeclarativeFontLoader::status() const
{
diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp
index 0f5413ec46..391548538d 100644
--- a/src/declarative/util/qdeclarativestate.cpp
+++ b/src/declarative/util/qdeclarativestate.cpp
@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
QDeclarativeAction::QDeclarativeAction()
-: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), fromBinding(0), toBinding(0), event(0),
+: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), fromBinding(0), event(0),
specifiedObject(0)
{
}
@@ -67,7 +67,7 @@ QDeclarativeAction::QDeclarativeAction(QObject *target, const QString &propertyN
const QVariant &value)
: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false),
property(target, propertyName), toValue(value),
- fromBinding(0), toBinding(0), event(0),
+ fromBinding(0), event(0),
specifiedObject(target), specifiedProperty(propertyName)
{
if (property.isValid())
@@ -78,7 +78,7 @@ QDeclarativeAction::QDeclarativeAction(QObject *target, const QString &propertyN
QDeclarativeContext *context, const QVariant &value)
: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false),
property(target, propertyName, context), toValue(value),
- fromBinding(0), toBinding(0), event(0),
+ fromBinding(0), event(0),
specifiedObject(target), specifiedProperty(propertyName)
{
if (property.isValid())
@@ -503,11 +503,11 @@ void QDeclarativeState::addEntriesToRevertList(const QList<QDeclarativeAction> &
const QDeclarativeAction &action = actionListIterator.next();
QDeclarativeSimpleAction simpleAction(action);
action.property.write(action.toValue);
- if (action.toBinding) {
+ if (!action.toBinding.isNull()) {
QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(simpleAction.property());
if (oldBinding)
QDeclarativePropertyPrivate::setBinding(simpleAction.property(), 0);
- QDeclarativePropertyPrivate::setBinding(simpleAction.property(), action.toBinding, QDeclarativePropertyPrivate::DontRemoveBinding);
+ QDeclarativePropertyPrivate::setBinding(simpleAction.property(), action.toBinding.data(), QDeclarativePropertyPrivate::DontRemoveBinding);
}
simpleActionList.append(simpleAction);
@@ -675,7 +675,7 @@ void QDeclarativeState::apply(QDeclarativeStateGroup *group, QDeclarativeTransit
a.property = d->revertList.at(ii).property();
a.fromValue = cur;
a.toValue = d->revertList.at(ii).value();
- a.toBinding = d->revertList.at(ii).binding();
+ a.toBinding = QDeclarativeAbstractBinding::getPointer(d->revertList.at(ii).binding());
a.specifiedObject = d->revertList.at(ii).specifiedObject();
a.specifiedProperty = d->revertList.at(ii).specifiedProperty();
a.event = d->revertList.at(ii).event();
diff --git a/src/declarative/util/qdeclarativestate_p.h b/src/declarative/util/qdeclarativestate_p.h
index d01af4e4f5..7b9c18a323 100644
--- a/src/declarative/util/qdeclarativestate_p.h
+++ b/src/declarative/util/qdeclarativestate_p.h
@@ -45,6 +45,7 @@
#include <qdeclarative.h>
#include <qdeclarativeproperty.h>
#include <QtCore/qobject.h>
+#include <private/qdeclarativebinding_p.h>
#include <private/qdeclarativeglobal_p.h>
QT_BEGIN_HEADER
@@ -75,7 +76,7 @@ public:
QVariant toValue;
QDeclarativeAbstractBinding *fromBinding;
- QDeclarativeAbstractBinding *toBinding;
+ QDeclarativeAbstractBinding::Pointer toBinding;
QDeclarativeActionEvent *event;
//strictly for matching
@@ -114,7 +115,7 @@ public:
class QDeclarativeStateGroup;
class QDeclarativeState;
class QDeclarativeStateOperationPrivate;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeStateOperation : public QObject
+class Q_DECLARATIVE_EXPORT QDeclarativeStateOperation : public QObject
{
Q_OBJECT
public:
@@ -139,7 +140,7 @@ typedef QDeclarativeStateOperation::ActionList QDeclarativeStateActions;
class QDeclarativeTransition;
class QDeclarativeStatePrivate;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeState : public QObject
+class Q_DECLARATIVE_EXPORT QDeclarativeState : public QObject
{
Q_OBJECT
diff --git a/src/declarative/util/qdeclarativestate_p_p.h b/src/declarative/util/qdeclarativestate_p_p.h
index 4fd8f217c9..98c3f7b222 100644
--- a/src/declarative/util/qdeclarativestate_p_p.h
+++ b/src/declarative/util/qdeclarativestate_p_p.h
@@ -85,7 +85,7 @@ public:
m_reverseEvent = true;
} else {
m_value = a.toValue;
- m_binding = QDeclarativeAbstractBinding::getPointer(a.toBinding);
+ m_binding = a.toBinding;
m_reverseEvent = false;
}
}
diff --git a/src/declarative/util/qdeclarativestategroup_p.h b/src/declarative/util/qdeclarativestategroup_p.h
index 0222cf24c3..cac23f49a4 100644
--- a/src/declarative/util/qdeclarativestategroup_p.h
+++ b/src/declarative/util/qdeclarativestategroup_p.h
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QDeclarativeStateGroupPrivate;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeStateGroup : public QObject, public QDeclarativeParserStatus
+class Q_DECLARATIVE_EXPORT QDeclarativeStateGroup : public QObject, public QDeclarativeParserStatus
{
Q_OBJECT
Q_INTERFACES(QDeclarativeParserStatus)
diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp
index 8cb813c675..d1d7822077 100644
--- a/src/declarative/util/qdeclarativestateoperations.cpp
+++ b/src/declarative/util/qdeclarativestateoperations.cpp
@@ -648,7 +648,7 @@ void QDeclarativeStateChangeScript::setScript(const QDeclarativeScriptString &s)
}
/*!
- \qmlproperty script StateChangeScript::script
+ \qmlproperty string StateChangeScript::name
This property holds the name of the script. This name can be used by a
ScriptAction to target a specific script.
diff --git a/src/declarative/util/qdeclarativetransition.cpp b/src/declarative/util/qdeclarativetransition.cpp
index 478c7f45ae..c8bc7b3f03 100644
--- a/src/declarative/util/qdeclarativetransition.cpp
+++ b/src/declarative/util/qdeclarativetransition.cpp
@@ -86,12 +86,16 @@ QT_BEGIN_NAMESPACE
Item {
...
transitions: [
- Transition { ... },
+ Transition { to: "state1" ... },
Transition { ... }
]
}
\endqml
+ If multiple Transitions are specified, only a single (best-matching) Transition will be applied for any particular
+ state change. In the example above, when changing to \c state1, the first transition will be used, rather
+ than the more generic second transition.
+
If a state change has a Transition that matches the same property as a
\l Behavior, the Transition animation overrides the \l Behavior for that
state change.
diff --git a/src/declarative/util/qdeclarativetransition_p.h b/src/declarative/util/qdeclarativetransition_p.h
index 5b20cb2374..fc7a5772b1 100644
--- a/src/declarative/util/qdeclarativetransition_p.h
+++ b/src/declarative/util/qdeclarativetransition_p.h
@@ -57,7 +57,7 @@ QT_MODULE(Declarative)
class QDeclarativeAbstractAnimation;
class QDeclarativeTransitionPrivate;
class QDeclarativeTransitionManager;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeTransition : public QObject
+class Q_DECLARATIVE_EXPORT QDeclarativeTransition : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QDeclarativeTransition)
diff --git a/src/declarative/util/qdeclarativetransitionmanager.cpp b/src/declarative/util/qdeclarativetransitionmanager.cpp
index 89b00440a0..d19e6f2799 100644
--- a/src/declarative/util/qdeclarativetransitionmanager.cpp
+++ b/src/declarative/util/qdeclarativetransitionmanager.cpp
@@ -99,8 +99,8 @@ void QDeclarativeTransitionManager::complete()
void QDeclarativeTransitionManagerPrivate::applyBindings()
{
foreach(const QDeclarativeAction &action, bindingsList) {
- if (action.toBinding) {
- QDeclarativePropertyPrivate::setBinding(action.property, action.toBinding);
+ if (!action.toBinding.isNull()) {
+ QDeclarativePropertyPrivate::setBinding(action.property, action.toBinding.data());
} else if (action.event) {
if (action.reverseEvent)
action.event->reverse();
@@ -145,8 +145,8 @@ void QDeclarativeTransitionManager::transition(const QList<QDeclarativeAction> &
// Apply all the property and binding changes
for (int ii = 0; ii < applyList.size(); ++ii) {
const QDeclarativeAction &action = applyList.at(ii);
- if (action.toBinding) {
- QDeclarativePropertyPrivate::setBinding(action.property, action.toBinding, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
+ if (!action.toBinding.isNull()) {
+ QDeclarativePropertyPrivate::setBinding(action.property, action.toBinding.data(), QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
} else if (!action.event) {
QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
} else if (action.event->isReversable()) {
@@ -165,7 +165,7 @@ void QDeclarativeTransitionManager::transition(const QList<QDeclarativeAction> &
continue;
}
const QDeclarativeProperty &prop = action->property;
- if (action->toBinding || !action->toValue.isValid()) {
+ if (!action->toBinding.isNull() || !action->toValue.isValid()) {
action->toValue = prop.read();
}
}
@@ -259,10 +259,10 @@ void QDeclarativeTransitionManager::cancel()
for(int i = 0; i < d->bindingsList.count(); ++i) {
QDeclarativeAction action = d->bindingsList[i];
- if (action.toBinding && action.deletableToBinding) {
+ if (!action.toBinding.isNull() && action.deletableToBinding) {
QDeclarativePropertyPrivate::setBinding(action.property, 0);
- action.toBinding->destroy();
- action.toBinding = 0;
+ action.toBinding.data()->destroy();
+ action.toBinding.clear();
action.deletableToBinding = false;
} else if (action.event) {
//### what do we do here?
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
index 163f6261d2..c4d8dde8f2 100644
--- a/src/declarative/util/qdeclarativeview.cpp
+++ b/src/declarative/util/qdeclarativeview.cpp
@@ -72,6 +72,7 @@
QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(frameRateDebug, QML_SHOW_FRAMERATE)
+extern Q_GUI_EXPORT bool qt_applefontsmoothing_enabled;
class QDeclarativeScene : public QGraphicsScene
{
@@ -696,7 +697,14 @@ void QDeclarativeView::paintEvent(QPaintEvent *event)
if (frameRateDebug())
time = d->frameTimer.restart();
+#ifdef Q_WS_MAC
+ bool oldSmooth = qt_applefontsmoothing_enabled;
+ qt_applefontsmoothing_enabled = false;
+#endif
QGraphicsView::paintEvent(event);
+#ifdef Q_WS_MAC
+ qt_applefontsmoothing_enabled = oldSmooth;
+#endif
QDeclarativeDebugTrace::endRange(QDeclarativeDebugTrace::Painting);