summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/QmlChanges.txt14
-rw-r--r--src/declarative/graphicsitems/graphicsitems.pri7
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanchors.cpp10
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanchors_p_p.h40
-rw-r--r--src/declarative/graphicsitems/qdeclarativeeffects.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeevents.cpp1
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp407
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p_p.h77
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflipable.cpp51
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp448
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview_p.h67
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp19
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase.cpp21
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp173
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.h7
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem_p.h17
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp351
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview_p.h42
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp9
-rw-r--r--src/declarative/graphicsitems/qdeclarativeparticles.cpp26
-rw-r--r--src/declarative/graphicsitems/qdeclarativepath.cpp11
-rw-r--r--src/declarative/graphicsitems/qdeclarativepath_p.h11
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp228
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview_p.h69
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview_p_p.h10
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativerectangle.cpp28
-rw-r--r--src/declarative/graphicsitems/qdeclarativerectangle_p_p.h15
-rw-r--r--src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext_p_p.h10
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp5
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp29
-rw-r--r--src/declarative/graphicsitems/qdeclarativewebview.cpp1338
-rw-r--r--src/declarative/graphicsitems/qdeclarativewebview_p.h286
-rw-r--r--src/declarative/graphicsitems/qdeclarativewebview_p_p.h151
-rw-r--r--src/declarative/qml/parser/qdeclarativejs.g2
-rw-r--r--src/declarative/qml/parser/qdeclarativejsgrammar.cpp2
-rw-r--r--src/declarative/qml/parser/qdeclarativejsgrammar_p.h4
-rw-r--r--src/declarative/qml/parser/qdeclarativejsparser.cpp2
-rw-r--r--src/declarative/qml/qdeclarativebinding_p.h7
-rw-r--r--src/declarative/qml/qdeclarativeboundsignal.cpp4
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp315
-rw-r--r--src/declarative/qml/qdeclarativecompiler_p.h8
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp9
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp9
-rw-r--r--src/declarative/qml/qdeclarativecontextscriptclass.cpp35
-rw-r--r--src/declarative/qml/qdeclarativecontextscriptclass_p.h1
-rw-r--r--src/declarative/qml/qdeclarativedeclarativedata_p.h10
-rw-r--r--src/declarative/qml/qdeclarativedom.cpp20
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp139
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h8
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp4
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug_p.h2
-rw-r--r--src/declarative/qml/qdeclarativeexpression.cpp46
-rw-r--r--src/declarative/qml/qdeclarativeexpression_p.h5
-rw-r--r--src/declarative/qml/qdeclarativeglobal_p.h2
-rw-r--r--src/declarative/qml/qdeclarativeglobalscriptclass.cpp15
-rw-r--r--src/declarative/qml/qdeclarativeglobalscriptclass_p.h7
-rw-r--r--src/declarative/qml/qdeclarativeinstruction_p.h320
-rw-r--r--src/declarative/qml/qdeclarativelist.h2
-rw-r--r--src/declarative/qml/qdeclarativemetatype.cpp9
-rw-r--r--src/declarative/qml/qdeclarativemetatype_p.h2
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass.cpp83
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass_p.h12
-rw-r--r--src/declarative/qml/qdeclarativeparser.cpp13
-rw-r--r--src/declarative/qml/qdeclarativeparser_p.h10
-rw-r--r--src/declarative/qml/qdeclarativeproperty.cpp17
-rw-r--r--src/declarative/qml/qdeclarativeproperty_p.h2
-rw-r--r--src/declarative/qml/qdeclarativepropertycache.cpp4
-rw-r--r--src/declarative/qml/qdeclarativescript.cpp1
-rw-r--r--src/declarative/qml/qdeclarativescriptparser.cpp70
-rw-r--r--src/declarative/qml/qdeclarativevaluetype.cpp75
-rw-r--r--src/declarative/qml/qdeclarativevaluetype_p.h11
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp10
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp220
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript_p.h11
-rw-r--r--src/declarative/qml/qdeclarativexmlhttprequest.cpp19
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp240
-rw-r--r--src/declarative/util/qdeclarativeanimation_p.h2
-rw-r--r--src/declarative/util/qdeclarativeanimation_p_p.h21
-rw-r--r--src/declarative/util/qdeclarativebehavior.cpp8
-rw-r--r--src/declarative/util/qdeclarativebehavior_p.h1
-rw-r--r--src/declarative/util/qdeclarativebind.cpp15
-rw-r--r--src/declarative/util/qdeclarativedatetimeformatter.cpp373
-rw-r--r--src/declarative/util/qdeclarativedatetimeformatter_p.h117
-rw-r--r--src/declarative/util/qdeclarativeeasefollow.cpp35
-rw-r--r--src/declarative/util/qdeclarativefontloader.cpp11
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp2
-rw-r--r--src/declarative/util/qdeclarativelistmodel_p.h2
-rw-r--r--src/declarative/util/qdeclarativenumberformatter.cpp261
-rw-r--r--src/declarative/util/qdeclarativenumberformatter_p.h93
-rw-r--r--src/declarative/util/qdeclarativepackage.cpp2
-rw-r--r--src/declarative/util/qdeclarativespringfollow.cpp7
-rw-r--r--src/declarative/util/qdeclarativestategroup.cpp3
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp22
-rw-r--r--src/declarative/util/qdeclarativestateoperations_p.h2
-rw-r--r--src/declarative/util/qdeclarativesystempalette.cpp1
-rw-r--r--src/declarative/util/qdeclarativetimeline_p_p.h2
-rw-r--r--src/declarative/util/qdeclarativetimer.cpp4
-rw-r--r--src/declarative/util/qdeclarativetimer_p.h9
-rw-r--r--src/declarative/util/qdeclarativeutilmodule.cpp8
-rw-r--r--src/declarative/util/qdeclarativeview.cpp16
-rw-r--r--src/declarative/util/qdeclarativeview.h4
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp79
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel_p.h43
-rw-r--r--src/declarative/util/qnumberformat.cpp224
-rw-r--r--src/declarative/util/qnumberformat_p.h174
-rw-r--r--src/declarative/util/util.pri6
115 files changed, 2972 insertions, 4365 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index 34e4834..591fb3d 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -6,12 +6,16 @@ Flickable: renamed viewportHeight -> contentHeight
Flickable: renamed viewportX -> contentX
Flickable: renamed viewportY -> contentY
Removed Flickable.reportedVelocitySmoothing
+Removed Qt.playSound (replaced by SoundEffect element)
+Removed NumberFormatter
+Removed DateTimeFormatter (use Qt.formatDateTime() instead)
Renamed MouseRegion -> MouseArea
Connection: syntax and rename:
Connection { sender: a; signal: foo(); script: xxx }
Connection { sender: a; signal: bar(); script: yyy }
becomes:
Connections { target: a; onFoo: xxx; onBar: yyy }
+Using WebView now requires "import org.webkit 1.0"
QmlView
-------
@@ -52,6 +56,16 @@ matchProperties and matchTargets have been renamed back to properties and target
The semantics are explained in the PropertyAnimation::properties documentation
and the animation overview documentation.
+Behavior and Animation syntax
+-----------------------------
+
+Previously animations and behaviors could be "assigned" to properties like this:
+ Item { x: Behavior {}; y: NumberAnimation {} }
+To make it more obvious that these are not regular value assignments a new "on"
+syntax has been introduced:
+ Item { Behavior on x {}; NumberAnimation on y {} }
+Only the syntax has changed, the behavior is identical.
+
=============================================================================
The changes below are pre-4.6.0 release.
diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/declarative/graphicsitems/graphicsitems.pri
index 7a85f00..3ff92b1 100644
--- a/src/declarative/graphicsitems/graphicsitems.pri
+++ b/src/declarative/graphicsitems/graphicsitems.pri
@@ -84,10 +84,3 @@ SOURCES += \
$$PWD/qdeclarativegraphicsobjectcontainer.cpp \
$$PWD/qdeclarativeparticles.cpp \
$$PWD/qdeclarativelayoutitem.cpp \
-
-contains(QT_CONFIG, webkit) {
- QT+=webkit
- SOURCES += $$PWD/qdeclarativewebview.cpp
- HEADERS += $$PWD/qdeclarativewebview_p.h
- HEADERS += $$PWD/qdeclarativewebview_p_p.h
-}
diff --git a/src/declarative/graphicsitems/qdeclarativeanchors.cpp b/src/declarative/graphicsitems/qdeclarativeanchors.cpp
index 274d778..dc1f09d 100644
--- a/src/declarative/graphicsitems/qdeclarativeanchors.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeanchors.cpp
@@ -168,8 +168,7 @@ void QDeclarativeAnchorsPrivate::fillChanged()
} else if (fill->parentItem() == item->parentItem()) { //siblings
setItemPos(QPointF(fill->x()+leftMargin, fill->y()+topMargin));
}
- setItemWidth(fill->width()-leftMargin-rightMargin);
- setItemHeight(fill->height()-topMargin-bottomMargin);
+ setItemSize(QSizeF(fill->width()-leftMargin-rightMargin, fill->height()-topMargin-bottomMargin));
--updatingFill;
} else {
@@ -314,6 +313,13 @@ void QDeclarativeAnchorsPrivate::setItemPos(const QPointF &v)
updatingMe = false;
}
+void QDeclarativeAnchorsPrivate::setItemSize(const QSizeF &v)
+{
+ updatingMe = true;
+ item->setSize(v);
+ updatingMe = false;
+}
+
void QDeclarativeAnchorsPrivate::updateMe()
{
if (updatingMe) {
diff --git a/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h b/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
index d9d7ffa..5840868 100644
--- a/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
@@ -59,12 +59,9 @@
QT_BEGIN_NAMESPACE
-class QDeclarativeAnchorLine
+struct QDeclarativeAnchorLine
{
-public:
- QDeclarativeAnchorLine() : item(0), anchorLine(Invalid)
- {
- }
+ QDeclarativeAnchorLine() : item(0), anchorLine(Invalid) {}
enum AnchorLine {
Invalid = 0x0,
@@ -81,27 +78,22 @@ public:
QDeclarativeItem *item;
AnchorLine anchorLine;
-
- bool operator==(const QDeclarativeAnchorLine& other) const
- {
- return item == other.item && anchorLine == other.anchorLine;
- }
};
+inline bool operator==(const QDeclarativeAnchorLine& a, const QDeclarativeAnchorLine& b)
+{
+ return a.item == b.item && a.anchorLine == b.anchorLine;
+}
+
class QDeclarativeAnchorsPrivate : public QObjectPrivate, public QDeclarativeItemChangeListener
{
Q_DECLARE_PUBLIC(QDeclarativeAnchors)
public:
QDeclarativeAnchorsPrivate(QDeclarativeItem *i)
- : updatingMe(false), updatingHorizontalAnchor(0),
+ : componentComplete(true), updatingMe(false), updatingHorizontalAnchor(0),
updatingVerticalAnchor(0), updatingFill(0), updatingCenterIn(0), item(i), usedAnchors(0), fill(0),
centerIn(0), leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0),
- margins(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0),
- componentComplete(true)
- {
- }
-
- void init()
+ margins(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0)
{
}
@@ -111,17 +103,19 @@ public:
void remDepend(QDeclarativeItem *);
bool isItemComplete() const;
- bool updatingMe;
- int updatingHorizontalAnchor;
- int updatingVerticalAnchor;
- int updatingFill;
- int updatingCenterIn;
+ bool componentComplete:1;
+ bool updatingMe:1;
+ uint updatingHorizontalAnchor:2;
+ uint updatingVerticalAnchor:2;
+ uint updatingFill:2;
+ uint updatingCenterIn:2;
void setItemHeight(qreal);
void setItemWidth(qreal);
void setItemX(qreal);
void setItemY(qreal);
void setItemPos(const QPointF &);
+ void setItemSize(const QSizeF &);
void updateOnComplete();
void updateMe();
@@ -163,8 +157,6 @@ public:
qreal vCenterOffset;
qreal hCenterOffset;
qreal baselineOffset;
-
- bool componentComplete;
};
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeeffects.cpp b/src/declarative/graphicsitems/qdeclarativeeffects.cpp
index efab24e..ea1f9cc 100644
--- a/src/declarative/graphicsitems/qdeclarativeeffects.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeeffects.cpp
@@ -45,6 +45,7 @@
/*!
\qmlclass Blur QGraphicsBlurEffect
+ \since 4.7
\brief The Blur object provides a blur effect.
A blur effect blurs the source item. This effect is useful for reducing details;
@@ -80,6 +81,7 @@
/*!
\qmlclass Colorize QGraphicsColorizeEffect
+ \since 4.7
\brief The Colorize object provides a colorize effect.
A colorize effect renders the source item with a tint of its color.
@@ -106,6 +108,7 @@
/*!
\qmlclass DropShadow QGraphicsDropShadowEffect
+ \since 4.7
\brief The DropShadow object provides a drop shadow effect.
A drop shadow effect renders the source item with a drop shadow. The color of
@@ -147,6 +150,7 @@
/*!
\qmlclass Opacity QGraphicsOpacityEffect
+ \since 4.7
\brief The Opacity object provides an opacity effect.
An opacity effect renders the source with an opacity. This effect is useful
diff --git a/src/declarative/graphicsitems/qdeclarativeevents.cpp b/src/declarative/graphicsitems/qdeclarativeevents.cpp
index d2cbb54..8be2f40 100644
--- a/src/declarative/graphicsitems/qdeclarativeevents.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeevents.cpp
@@ -114,6 +114,7 @@ Item {
/*!
\qmlclass MouseEvent QDeclarativeMouseEvent
+ \since 4.7
\brief The MouseEvent object provides information about a mouse event.
The position of the mouse can be found via the x and y properties.
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 3f4a9ce..67068a0 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -90,7 +90,7 @@ void QDeclarativeFlickableVisibleArea::updateVisible()
// Vertical
const qreal viewheight = flickable->height();
const qreal maxyextent = -flickable->maxYExtent() + flickable->minYExtent();
- qreal pagePos = (-p->_moveY.value() + flickable->minYExtent()) / (maxyextent + viewheight);
+ qreal pagePos = (-p->vData.move.value() + flickable->minYExtent()) / (maxyextent + viewheight);
qreal pageSize = viewheight / (maxyextent + viewheight);
if (pageSize != m_heightRatio) {
@@ -105,7 +105,7 @@ void QDeclarativeFlickableVisibleArea::updateVisible()
// Horizontal
const qreal viewwidth = flickable->width();
const qreal maxxextent = -flickable->maxXExtent() + flickable->minXExtent();
- pagePos = (-p->_moveX.value() + flickable->minXExtent()) / (maxxextent + viewwidth);
+ pagePos = (-p->hData.move.value() + flickable->minXExtent()) / (maxxextent + viewwidth);
pageSize = viewwidth / (maxxextent + viewwidth);
if (pageSize != m_widthRatio) {
@@ -123,13 +123,13 @@ void QDeclarativeFlickableVisibleArea::updateVisible()
QDeclarativeFlickablePrivate::QDeclarativeFlickablePrivate()
: viewport(new QDeclarativeItem)
- , _moveX(this, &QDeclarativeFlickablePrivate::setRoundedViewportX)
- , _moveY(this, &QDeclarativeFlickablePrivate::setRoundedViewportY)
- , vWidth(-1), vHeight(-1), overShoot(true), flicked(false), moving(false), stealMouse(false)
- , pressed(false), atXEnd(false), atXBeginning(true), atYEnd(false), atYBeginning(true)
+ , hData(this, &QDeclarativeFlickablePrivate::setRoundedViewportX)
+ , vData(this, &QDeclarativeFlickablePrivate::setRoundedViewportY)
+ , overShoot(true), flicked(false), moving(false), stealMouse(false)
+ , pressed(false)
, interactive(true), deceleration(500), maxVelocity(2000), reportedVelocitySmoothing(100)
, delayedPressEvent(0), delayedPressTarget(0), pressDelay(0), fixupDuration(600)
- , horizontalVelocity(this), verticalVelocity(this), vTime(0), visibleArea(0)
+ , vTime(0), visibleArea(0)
, flickDirection(QDeclarativeFlickable::AutoFlickDirection)
{
}
@@ -138,14 +138,24 @@ void QDeclarativeFlickablePrivate::init()
{
Q_Q(QDeclarativeFlickable);
viewport->setParent(q);
- QObject::connect(&timeline, SIGNAL(updated()), q, SLOT(ticked()));
- QObject::connect(&timeline, SIGNAL(completed()), q, SLOT(movementEnding()));
+ static int timelineUpdatedIdx = -1;
+ static int timelineCompletedIdx = -1;
+ static int flickableTickedIdx = -1;
+ static int flickableMovementEndingIdx = -1;
+ if (timelineUpdatedIdx == -1) {
+ timelineUpdatedIdx = QDeclarativeTimeLine::staticMetaObject.indexOfSignal("updated()");
+ timelineCompletedIdx = QDeclarativeTimeLine::staticMetaObject.indexOfSignal("completed()");
+ flickableTickedIdx = QDeclarativeFlickable::staticMetaObject.indexOfSlot("ticked()");
+ flickableMovementEndingIdx = QDeclarativeFlickable::staticMetaObject.indexOfSlot("movementEnding()");
+ }
+ QMetaObject::connect(&timeline, timelineUpdatedIdx,
+ q, flickableTickedIdx, Qt::DirectConnection);
+ QMetaObject::connect(&timeline, timelineCompletedIdx,
+ q, flickableMovementEndingIdx, Qt::DirectConnection);
q->setAcceptedMouseButtons(Qt::LeftButton);
q->setFiltersChildEvents(true);
- QObject::connect(viewport, SIGNAL(xChanged()), q, SIGNAL(contentXChanged()));
- QObject::connect(viewport, SIGNAL(yChanged()), q, SIGNAL(contentYChanged()));
- QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(heightChange()));
- QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(widthChange()));
+ QDeclarativeItemPrivate *viewportPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(viewport));
+ viewportPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
}
/*
@@ -154,7 +164,6 @@ void QDeclarativeFlickablePrivate::init()
*/
qreal QDeclarativeFlickablePrivate::overShootDistance(qreal velocity, qreal size)
{
- Q_Q(QDeclarativeFlickable);
if (maxVelocity <= 0)
return 0.0;
@@ -165,59 +174,43 @@ qreal QDeclarativeFlickablePrivate::overShootDistance(qreal velocity, qreal size
return dist;
}
-void QDeclarativeFlickablePrivate::flickX(qreal velocity)
+void QDeclarativeFlickablePrivate::itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeom, const QRectF &oldGeom)
{
Q_Q(QDeclarativeFlickable);
- qreal maxDistance = -1;
- // -ve velocity means list is moving up
- if (velocity > 0) {
- const qreal minX = q->minXExtent();
- if (_moveX.value() < minX)
- maxDistance = qAbs(minX -_moveX.value() + (overShoot?overShootDistance(velocity,q->width()):0));
- flickTargetX = minX;
- } else {
- const qreal maxX = q->maxXExtent();
- if (_moveX.value() > maxX)
- maxDistance = qAbs(maxX - _moveX.value()) + (overShoot?overShootDistance(velocity,q->width()):0);
- flickTargetX = maxX;
- }
- if (maxDistance > 0) {
- qreal v = velocity;
- if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
- if (v < 0)
- v = -maxVelocity;
- else
- v = maxVelocity;
- }
- timeline.reset(_moveX);
- timeline.accel(_moveX, v, deceleration, maxDistance);
- timeline.callback(QDeclarativeTimeLineCallback(&_moveX, fixupX_callback, this));
- if (!flicked) {
- flicked = true;
- emit q->flickingChanged();
- emit q->flickStarted();
- }
- } else {
- timeline.reset(_moveX);
- fixupX();
+ if (item == viewport) {
+ if (newGeom.x() != oldGeom.x())
+ emit q->contentXChanged();
+ if (newGeom.y() != oldGeom.y())
+ emit q->contentYChanged();
}
}
+void QDeclarativeFlickablePrivate::flickX(qreal velocity)
+{
+ Q_Q(QDeclarativeFlickable);
+ flick(hData, q->minXExtent(), q->maxXExtent(), q->width(), fixupX_callback, velocity);
+}
+
void QDeclarativeFlickablePrivate::flickY(qreal velocity)
{
Q_Q(QDeclarativeFlickable);
+ flick(vData, q->minYExtent(), q->maxYExtent(), q->height(), fixupY_callback, velocity);
+}
+
+void QDeclarativeFlickablePrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
+ QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity)
+{
+ Q_Q(QDeclarativeFlickable);
qreal maxDistance = -1;
// -ve velocity means list is moving up
if (velocity > 0) {
- const qreal minY = q->minYExtent();
- if (_moveY.value() < minY)
- maxDistance = qAbs(minY -_moveY.value() + (overShoot?overShootDistance(velocity,q->height()):0));
- flickTargetY = minY;
+ if (data.move.value() < minExtent)
+ maxDistance = qAbs(minExtent - data.move.value() + (overShoot?overShootDistance(velocity,vSize):0));
+ data.flickTarget = minExtent;
} else {
- const qreal maxY = q->maxYExtent();
- if (_moveY.value() > maxY)
- maxDistance = qAbs(maxY - _moveY.value()) + (overShoot?overShootDistance(velocity,q->height()):0);
- flickTargetY = maxY;
+ if (data.move.value() > maxExtent)
+ maxDistance = qAbs(maxExtent - data.move.value()) + (overShoot?overShootDistance(velocity,vSize):0);
+ data.flickTarget = maxExtent;
}
if (maxDistance > 0) {
qreal v = velocity;
@@ -227,55 +220,20 @@ void QDeclarativeFlickablePrivate::flickY(qreal velocity)
else
v = maxVelocity;
}
- timeline.reset(_moveY);
- timeline.accel(_moveY, v, deceleration, maxDistance);
- timeline.callback(QDeclarativeTimeLineCallback(&_moveY, fixupY_callback, this));
+ timeline.reset(data.move);
+ timeline.accel(data.move, v, deceleration, maxDistance);
+ timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this));
if (!flicked) {
flicked = true;
emit q->flickingChanged();
emit q->flickStarted();
}
} else {
- timeline.reset(_moveY);
- fixupY();
+ timeline.reset(data.move);
+ fixup(data, minExtent, maxExtent);
}
}
-void QDeclarativeFlickablePrivate::fixupX()
-{
- Q_Q(QDeclarativeFlickable);
- if (!q->xflick() || _moveX.timeLine())
- return;
-
- if (_moveX.value() > q->minXExtent() || (q->maxXExtent() > q->minXExtent())) {
- timeline.reset(_moveX);
- if (_moveX.value() != q->minXExtent()) {
- if (fixupDuration) {
- qreal dist = q->minXExtent() - _moveX;
- timeline.move(_moveX, q->minXExtent() - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4);
- timeline.move(_moveX, q->minXExtent(), QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4);
- } else {
- _moveX.setValue(q->minXExtent());
- }
- }
- //emit flickingChanged();
- } else if (_moveX.value() < q->maxXExtent()) {
- timeline.reset(_moveX);
- if (fixupDuration) {
- qreal dist = q->maxXExtent() - _moveX;
- timeline.move(_moveX, q->maxXExtent() - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4);
- timeline.move(_moveX, q->maxXExtent(), QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4);
- } else {
- _moveX.setValue(q->maxXExtent());
- }
- //emit flickingChanged();
- } else {
- flicked = false;
- }
-
- vTime = timeline.time();
-}
-
void QDeclarativeFlickablePrivate::fixupY_callback(void *data)
{
((QDeclarativeFlickablePrivate *)data)->fixupY();
@@ -286,32 +244,46 @@ void QDeclarativeFlickablePrivate::fixupX_callback(void *data)
((QDeclarativeFlickablePrivate *)data)->fixupX();
}
+void QDeclarativeFlickablePrivate::fixupX()
+{
+ Q_Q(QDeclarativeFlickable);
+ if (!q->xflick() || hData.move.timeLine())
+ return;
+
+ fixup(hData, q->minXExtent(), q->maxXExtent());
+}
+
void QDeclarativeFlickablePrivate::fixupY()
{
Q_Q(QDeclarativeFlickable);
- if (!q->yflick() || _moveY.timeLine())
+ if (!q->yflick() || vData.move.timeLine())
return;
- if (_moveY.value() > q->minYExtent() || (q->maxYExtent() > q->minYExtent())) {
- timeline.reset(_moveY);
- if (_moveY.value() != q->minYExtent()) {
+ fixup(vData, q->minYExtent(), q->maxYExtent());
+}
+
+void QDeclarativeFlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent)
+{
+ if (data.move.value() > minExtent || maxExtent > minExtent) {
+ timeline.reset(data.move);
+ if (data.move.value() != minExtent) {
if (fixupDuration) {
- qreal dist = q->minYExtent() - _moveY;
- timeline.move(_moveY, q->minYExtent() - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4);
- timeline.move(_moveY, q->minYExtent(), QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4);
+ qreal dist = minExtent - data.move;
+ timeline.move(data.move, minExtent - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4);
+ timeline.move(data.move, minExtent, QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4);
} else {
- _moveY.setValue(q->minYExtent());
+ data.move.setValue(minExtent);
}
}
//emit flickingChanged();
- } else if (_moveY.value() < q->maxYExtent()) {
- timeline.reset(_moveY);
+ } else if (data.move.value() < maxExtent) {
+ timeline.reset(data.move);
if (fixupDuration) {
- qreal dist = q->maxYExtent() - _moveY;
- timeline.move(_moveY, q->maxYExtent() - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4);
- timeline.move(_moveY, q->maxYExtent(), QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4);
+ qreal dist = maxExtent - data.move;
+ timeline.move(data.move, maxExtent - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4);
+ timeline.move(data.move, maxExtent, QEasingCurve(QEasingCurve::OutQuint), 3*fixupDuration/4);
} else {
- _moveY.setValue(q->maxYExtent());
+ data.move.setValue(maxExtent);
}
//emit flickingChanged();
} else {
@@ -328,31 +300,31 @@ void QDeclarativeFlickablePrivate::updateBeginningEnd()
// Vertical
const int maxyextent = int(-q->maxYExtent());
- const qreal ypos = -_moveY.value();
+ const qreal ypos = -vData.move.value();
bool atBeginning = (ypos <= -q->minYExtent());
bool atEnd = (maxyextent <= ypos);
- if (atBeginning != atYBeginning) {
- atYBeginning = atBeginning;
+ if (atBeginning != vData.atBeginning) {
+ vData.atBeginning = atBeginning;
atBoundaryChange = true;
}
- if (atEnd != atYEnd) {
- atYEnd = atEnd;
+ if (atEnd != vData.atEnd) {
+ vData.atEnd = atEnd;
atBoundaryChange = true;
}
// Horizontal
const int maxxextent = int(-q->maxXExtent());
- const qreal xpos = -_moveX.value();
+ const qreal xpos = -hData.move.value();
atBeginning = (xpos <= -q->minXExtent());
atEnd = (maxxextent <= xpos);
- if (atBeginning != atXBeginning) {
- atXBeginning = atBeginning;
+ if (atBeginning != hData.atBeginning) {
+ hData.atBeginning = atBeginning;
atBoundaryChange = true;
}
- if (atEnd != atXEnd) {
- atXEnd = atEnd;
+ if (atEnd != hData.atEnd) {
+ hData.atEnd = atEnd;
atBoundaryChange = true;
}
@@ -365,6 +337,7 @@ void QDeclarativeFlickablePrivate::updateBeginningEnd()
/*!
\qmlclass Flickable QDeclarativeFlickable
+ \since 4.7
\brief The Flickable item provides a surface that can be "flicked".
\inherits Item
@@ -468,17 +441,17 @@ QDeclarativeFlickable::~QDeclarativeFlickable()
qreal QDeclarativeFlickable::contentX() const
{
Q_D(const QDeclarativeFlickable);
- return -d->_moveX.value();
+ return -d->hData.move.value();
}
void QDeclarativeFlickable::setContentX(qreal pos)
{
Q_D(QDeclarativeFlickable);
pos = qRound(pos);
- d->timeline.reset(d->_moveX);
+ d->timeline.reset(d->hData.move);
d->vTime = d->timeline.time();
- if (-pos != d->_moveX.value()) {
- d->_moveX.setValue(-pos);
+ if (-pos != d->hData.move.value()) {
+ d->hData.move.setValue(-pos);
viewportMoved();
}
}
@@ -486,17 +459,17 @@ void QDeclarativeFlickable::setContentX(qreal pos)
qreal QDeclarativeFlickable::contentY() const
{
Q_D(const QDeclarativeFlickable);
- return -d->_moveY.value();
+ return -d->vData.move.value();
}
void QDeclarativeFlickable::setContentY(qreal pos)
{
Q_D(QDeclarativeFlickable);
pos = qRound(pos);
- d->timeline.reset(d->_moveY);
+ d->timeline.reset(d->vData.move);
d->vTime = d->timeline.time();
- if (-pos != d->_moveY.value()) {
- d->_moveY.setValue(-pos);
+ if (-pos != d->vData.move.value()) {
+ d->vData.move.setValue(-pos);
viewportMoved();
}
}
@@ -543,13 +516,13 @@ void QDeclarativeFlickable::setInteractive(bool interactive)
qreal QDeclarativeFlickable::horizontalVelocity() const
{
Q_D(const QDeclarativeFlickable);
- return d->horizontalVelocity.value();
+ return d->hData.smoothVelocity.value();
}
qreal QDeclarativeFlickable::verticalVelocity() const
{
Q_D(const QDeclarativeFlickable);
- return d->verticalVelocity.value();
+ return d->vData.smoothVelocity.value();
}
/*!
@@ -564,25 +537,25 @@ qreal QDeclarativeFlickable::verticalVelocity() const
bool QDeclarativeFlickable::isAtXEnd() const
{
Q_D(const QDeclarativeFlickable);
- return d->atXEnd;
+ return d->hData.atEnd;
}
bool QDeclarativeFlickable::isAtXBeginning() const
{
Q_D(const QDeclarativeFlickable);
- return d->atXBeginning;
+ return d->hData.atBeginning;
}
bool QDeclarativeFlickable::isAtYEnd() const
{
Q_D(const QDeclarativeFlickable);
- return d->atYEnd;
+ return d->vData.atEnd;
}
bool QDeclarativeFlickable::isAtYBeginning() const
{
Q_D(const QDeclarativeFlickable);
- return d->atYBeginning;
+ return d->vData.atBeginning;
}
void QDeclarativeFlickable::ticked()
@@ -636,19 +609,19 @@ void QDeclarativeFlickable::setFlickDirection(FlickDirection direction)
void QDeclarativeFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event)
{
- if (interactive && timeline.isActive() && (qAbs(velocityX) > 10 || qAbs(velocityY) > 10))
+ if (interactive && timeline.isActive() && (qAbs(hData.velocity) > 10 || qAbs(vData.velocity) > 10))
stealMouse = true; // If we've been flicked then steal the click.
else
stealMouse = false;
pressed = true;
timeline.clear();
- velocityX = 0;
- velocityY = 0;
+ hData.velocity = 0;
+ vData.velocity = 0;
lastPos = QPoint();
QDeclarativeItemPrivate::start(lastPosTime);
pressPos = event->pos();
- pressX = _moveX.value();
- pressY = _moveY.value();
+ hData.pressPos = hData.move.value();
+ vData.pressPos = vData.move.value();
flicked = false;
QDeclarativeItemPrivate::start(pressTime);
QDeclarativeItemPrivate::start(velocityTime);
@@ -666,7 +639,7 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
if (q->yflick()) {
int dy = int(event->pos().y() - pressPos.y());
if (qAbs(dy) > QApplication::startDragDistance() || QDeclarativeItemPrivate::elapsed(pressTime) > 200) {
- qreal newY = dy + pressY;
+ qreal newY = dy + vData.pressPos;
const qreal minY = q->minYExtent();
const qreal maxY = q->maxYExtent();
if (newY > minY)
@@ -681,8 +654,8 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
else
rejectY = true;
}
- if (!rejectY) {
- _moveY.setValue(newY);
+ if (!rejectY && stealMouse) {
+ vData.move.setValue(newY);
moved = true;
}
if (qAbs(dy) > QApplication::startDragDistance())
@@ -693,7 +666,7 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
if (q->xflick()) {
int dx = int(event->pos().x() - pressPos.x());
if (qAbs(dx) > QApplication::startDragDistance() || QDeclarativeItemPrivate::elapsed(pressTime) > 200) {
- qreal newX = dx + pressX;
+ qreal newX = dx + hData.pressPos;
const qreal minX = q->minXExtent();
const qreal maxX = q->maxXExtent();
if (newX > minX)
@@ -708,8 +681,8 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
else
rejectX = true;
}
- if (!rejectX) {
- _moveX.setValue(newX);
+ if (!rejectX && stealMouse) {
+ hData.move.setValue(newX);
moved = true;
}
@@ -725,20 +698,20 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
if (q->yflick()) {
qreal diff = event->pos().y() - lastPos.y();
// average to reduce the effect of spurious moves
- velocityY += diff / elapsed;
- velocityY /= 2;
+ vData.velocity += diff / elapsed;
+ vData.velocity /= 2;
}
if (q->xflick()) {
qreal diff = event->pos().x() - lastPos.x();
// average to reduce the effect of spurious moves
- velocityX += diff / elapsed;
- velocityX /= 2;
+ hData.velocity += diff / elapsed;
+ hData.velocity /= 2;
}
}
- if (rejectY) velocityY = 0;
- if (rejectX) velocityX = 0;
+ if (rejectY) vData.velocity = 0;
+ if (rejectX) hData.velocity = 0;
if (moved) {
q->movementStarting();
@@ -751,19 +724,21 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
void QDeclarativeFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
Q_Q(QDeclarativeFlickable);
+ stealMouse = false;
+ q->setKeepMouseGrab(false);
pressed = false;
if (lastPosTime.isNull())
return;
if (QDeclarativeItemPrivate::elapsed(lastPosTime) > 100) {
// if we drag then pause before release we should not cause a flick.
- velocityX = 0.0;
- velocityY = 0.0;
+ hData.velocity = 0.0;
+ vData.velocity = 0.0;
}
vTime = timeline.time();
- if (qAbs(velocityY) > 10 && qAbs(event->pos().y() - pressPos.y()) > FlickThreshold) {
- qreal velocity = velocityY;
+ if (qAbs(vData.velocity) > 10 && qAbs(event->pos().y() - pressPos.y()) > FlickThreshold) {
+ qreal velocity = vData.velocity;
if (qAbs(velocity) < minimumFlickVelocity) // Minimum velocity to avoid annoyingly slow flicks.
velocity = velocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity;
flickY(velocity);
@@ -771,8 +746,8 @@ void QDeclarativeFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEv
fixupY();
}
- if (qAbs(velocityX) > 10 && qAbs(event->pos().x() - pressPos.x()) > FlickThreshold) {
- qreal velocity = velocityX;
+ if (qAbs(hData.velocity) > 10 && qAbs(event->pos().x() - pressPos.x()) > FlickThreshold) {
+ qreal velocity = hData.velocity;
if (qAbs(velocity) < minimumFlickVelocity) // Minimum velocity to avoid annoyingly slow flicks.
velocity = velocity < 0 ? -minimumFlickVelocity : minimumFlickVelocity;
flickX(velocity);
@@ -780,7 +755,6 @@ void QDeclarativeFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEv
fixupX();
}
- stealMouse = false;
lastPosTime = QTime();
if (!timeline.isActive())
@@ -803,6 +777,8 @@ void QDeclarativeFlickable::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Q_D(QDeclarativeFlickable);
if (d->interactive) {
d->handleMouseMoveEvent(event);
+ if (d->stealMouse)
+ setKeepMouseGrab(true);
event->accept();
} else {
QDeclarativeItem::mouseMoveEvent(event);
@@ -829,19 +805,19 @@ void QDeclarativeFlickable::wheelEvent(QGraphicsSceneWheelEvent *event)
QDeclarativeItem::wheelEvent(event);
} else if (yflick()) {
if (event->delta() > 0)
- d->velocityY = qMax(event->delta() - d->verticalVelocity.value(), qreal(250.0));
+ d->vData.velocity = qMax(event->delta() - d->vData.smoothVelocity.value(), qreal(250.0));
else
- d->velocityY = qMin(event->delta() - d->verticalVelocity.value(), qreal(-250.0));
+ d->vData.velocity = qMin(event->delta() - d->vData.smoothVelocity.value(), qreal(-250.0));
d->flicked = false;
- d->flickY(d->velocityY);
+ d->flickY(d->vData.velocity);
event->accept();
} else if (xflick()) {
if (event->delta() > 0)
- d->velocityX = qMax(event->delta() - d->horizontalVelocity.value(), qreal(250.0));
+ d->hData.velocity = qMax(event->delta() - d->hData.smoothVelocity.value(), qreal(250.0));
else
- d->velocityX = qMin(event->delta() - d->horizontalVelocity.value(), qreal(-250.0));
+ d->hData.velocity = qMin(event->delta() - d->hData.smoothVelocity.value(), qreal(-250.0));
d->flicked = false;
- d->flickX(d->velocityX);
+ d->flickX(d->hData.velocity);
event->accept();
} else {
QDeclarativeItem::wheelEvent(event);
@@ -943,32 +919,56 @@ void QDeclarativeFlickable::viewportMoved()
qreal prevX = d->lastFlickablePosition.y();
d->velocityTimeline.clear();
if (d->pressed) {
- qreal horizontalVelocity = (prevX - d->_moveX.value()) * 1000 / elapsed;
- qreal verticalVelocity = (prevY - d->_moveY.value()) * 1000 / elapsed;
- d->velocityTimeline.move(d->horizontalVelocity, horizontalVelocity, d->reportedVelocitySmoothing);
- d->velocityTimeline.move(d->horizontalVelocity, 0, d->reportedVelocitySmoothing);
- d->velocityTimeline.move(d->verticalVelocity, verticalVelocity, d->reportedVelocitySmoothing);
- d->velocityTimeline.move(d->verticalVelocity, 0, d->reportedVelocitySmoothing);
+ qreal horizontalVelocity = (prevX - d->hData.move.value()) * 1000 / elapsed;
+ qreal verticalVelocity = (prevY - d->vData.move.value()) * 1000 / elapsed;
+ d->velocityTimeline.move(d->hData.smoothVelocity, horizontalVelocity, d->reportedVelocitySmoothing);
+ d->velocityTimeline.move(d->hData.smoothVelocity, 0, d->reportedVelocitySmoothing);
+ d->velocityTimeline.move(d->vData.smoothVelocity, verticalVelocity, d->reportedVelocitySmoothing);
+ d->velocityTimeline.move(d->vData.smoothVelocity, 0, d->reportedVelocitySmoothing);
} else {
if (d->timeline.time() > d->vTime) {
- qreal horizontalVelocity = (prevX - d->_moveX.value()) * 1000 / (d->timeline.time() - d->vTime);
- qreal verticalVelocity = (prevY - d->_moveY.value()) * 1000 / (d->timeline.time() - d->vTime);
- d->horizontalVelocity.setValue(horizontalVelocity);
- d->verticalVelocity.setValue(verticalVelocity);
+ qreal horizontalVelocity = (prevX - d->hData.move.value()) * 1000 / (d->timeline.time() - d->vTime);
+ qreal verticalVelocity = (prevY - d->vData.move.value()) * 1000 / (d->timeline.time() - d->vTime);
+ d->hData.smoothVelocity.setValue(horizontalVelocity);
+ d->vData.smoothVelocity.setValue(verticalVelocity);
}
}
- d->lastFlickablePosition = QPointF(d->_moveY.value(), d->_moveX.value());
+ d->lastFlickablePosition = QPointF(d->vData.move.value(), d->hData.move.value());
d->vTime = d->timeline.time();
d->updateBeginningEnd();
}
+void QDeclarativeFlickable::geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry)
+{
+ Q_D(QDeclarativeFlickable);
+ QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
+
+ bool changed = false;
+ if (newGeometry.width() != oldGeometry.width()) {
+ if (d->hData.viewSize < 0) {
+ d->viewport->setWidth(width());
+ emit contentWidthChanged();
+ }
+ }
+ if (newGeometry.height() != oldGeometry.height()) {
+ if (d->vData.viewSize < 0) {
+ d->viewport->setHeight(height());
+ emit contentHeightChanged();
+ }
+ }
+
+ if (changed)
+ d->updateBeginningEnd();
+}
+
void QDeclarativeFlickable::cancelFlick()
{
Q_D(QDeclarativeFlickable);
- d->timeline.reset(d->_moveX);
- d->timeline.reset(d->_moveY);
+ d->timeline.reset(d->hData.move);
+ d->timeline.reset(d->vData.move);
movementEnding();
}
@@ -1035,15 +1035,15 @@ void QDeclarativeFlickable::setOverShoot(bool o)
qreal QDeclarativeFlickable::contentWidth() const
{
Q_D(const QDeclarativeFlickable);
- return d->vWidth;
+ return d->hData.viewSize;
}
void QDeclarativeFlickable::setContentWidth(qreal w)
{
Q_D(QDeclarativeFlickable);
- if (d->vWidth == w)
+ if (d->hData.viewSize == w)
return;
- d->vWidth = w;
+ d->hData.viewSize = w;
if (w < 0)
d->viewport->setWidth(width());
else
@@ -1055,38 +1055,18 @@ void QDeclarativeFlickable::setContentWidth(qreal w)
d->updateBeginningEnd();
}
-void QDeclarativeFlickable::widthChange()
-{
- Q_D(QDeclarativeFlickable);
- if (d->vWidth < 0) {
- d->viewport->setWidth(width());
- emit contentWidthChanged();
- }
- d->updateBeginningEnd();
-}
-
-void QDeclarativeFlickable::heightChange()
-{
- Q_D(QDeclarativeFlickable);
- if (d->vHeight < 0) {
- d->viewport->setHeight(height());
- emit contentHeightChanged();
- }
- d->updateBeginningEnd();
-}
-
qreal QDeclarativeFlickable::contentHeight() const
{
Q_D(const QDeclarativeFlickable);
- return d->vHeight;
+ return d->vData.viewSize;
}
void QDeclarativeFlickable::setContentHeight(qreal h)
{
Q_D(QDeclarativeFlickable);
- if (d->vHeight == h)
+ if (d->vData.viewSize == h)
return;
- d->vHeight = h;
+ d->vData.viewSize = h;
if (h < 0)
d->viewport->setHeight(height());
else
@@ -1101,19 +1081,19 @@ void QDeclarativeFlickable::setContentHeight(qreal h)
qreal QDeclarativeFlickable::vWidth() const
{
Q_D(const QDeclarativeFlickable);
- if (d->vWidth < 0)
+ if (d->hData.viewSize < 0)
return width();
else
- return d->vWidth;
+ return d->hData.viewSize;
}
qreal QDeclarativeFlickable::vHeight() const
{
Q_D(const QDeclarativeFlickable);
- if (d->vHeight < 0)
+ if (d->vData.viewSize < 0)
return height();
else
- return d->vHeight;
+ return d->vData.viewSize;
}
bool QDeclarativeFlickable::xflick() const
@@ -1140,7 +1120,8 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event)
QGraphicsScene *s = scene();
QDeclarativeItem *grabber = s ? qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem()) : 0;
- if ((d->stealMouse || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) {
+ bool stealThisEvent = d->stealMouse;
+ if ((stealThisEvent || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) {
mouseEvent.setAccepted(false);
for (int i = 0x1; i <= 0x10; i <<= 1) {
if (event->buttons() & i) {
@@ -1175,17 +1156,19 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event)
break;
}
grabber = qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem());
- if (grabber && d->stealMouse && !grabber->keepMouseGrab() && grabber != this) {
+ if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this) {
d->clearDelayedPress();
grabMouse();
}
- return d->stealMouse || d->delayedPressEvent;
+ return stealThisEvent || d->delayedPressEvent;
} else if (!d->lastPosTime.isNull()) {
d->lastPosTime = QTime();
}
- if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease)
+ if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) {
d->clearDelayedPress();
+ d->stealMouse = false;
+ }
return false;
}
@@ -1321,8 +1304,8 @@ void QDeclarativeFlickable::movementEnding()
emit flickingChanged();
emit flickEnded();
}
- d->horizontalVelocity.setValue(0);
- d->verticalVelocity.setValue(0);
+ d->hData.smoothVelocity.setValue(0);
+ d->vData.smoothVelocity.setValue(0);
}
void QDeclarativeFlickablePrivate::updateVelocity()
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p.h
index 4617688..7dcab98 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p.h
@@ -174,8 +174,6 @@ protected Q_SLOTS:
virtual void ticked();
void movementStarting();
void movementEnding();
- void heightChange();
- void widthChange();
protected:
virtual qreal minXExtent() const;
@@ -185,6 +183,8 @@ protected:
qreal vWidth() const;
qreal vHeight() const;
virtual void viewportMoved();
+ virtual void geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry);
bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
bool xflick() const;
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
index 1ff4f92..c963c2b 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
@@ -56,6 +56,7 @@
#include "qdeclarativeflickable_p.h"
#include "qdeclarativeitem_p.h"
+#include "qdeclarativeitemchangelistener_p.h"
#include <qdeclarative.h>
#include <qdeclarativetimeline_p_p.h>
@@ -66,17 +67,51 @@
QT_BEGIN_NAMESPACE
class QDeclarativeFlickableVisibleArea;
-class QDeclarativeFlickablePrivate : public QDeclarativeItemPrivate
+class QDeclarativeFlickablePrivate : public QDeclarativeItemPrivate, public QDeclarativeItemChangeListener
{
Q_DECLARE_PUBLIC(QDeclarativeFlickable)
public:
QDeclarativeFlickablePrivate();
void init();
- virtual void flickX(qreal velocity);
- virtual void flickY(qreal velocity);
- virtual void fixupX();
- virtual void fixupY();
+
+ struct Velocity : public QDeclarativeTimeLineValue
+ {
+ Velocity(QDeclarativeFlickablePrivate *p)
+ : parent(p) {}
+ virtual void setValue(qreal v) {
+ if (v != value()) {
+ QDeclarativeTimeLineValue::setValue(v);
+ parent->updateVelocity();
+ }
+ }
+ QDeclarativeFlickablePrivate *parent;
+ };
+
+ struct AxisData {
+ AxisData(QDeclarativeFlickablePrivate *fp, void (QDeclarativeFlickablePrivate::*func)(qreal))
+ : move(fp, func), viewSize(-1), smoothVelocity(fp), atEnd(false), atBeginning(true)
+ {}
+
+ QDeclarativeTimeLineValueProxy<QDeclarativeFlickablePrivate> move;
+ qreal viewSize;
+ qreal pressPos;
+ qreal velocity;
+ qreal flickTarget;
+ QDeclarativeFlickablePrivate::Velocity smoothVelocity;
+ bool atEnd : 1;
+ bool atBeginning : 1;
+ };
+
+ void flickX(qreal velocity);
+ void flickY(qreal velocity);
+ virtual void flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
+ QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity);
+
+ void fixupX();
+ void fixupY();
+ virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent);
+
void updateBeginningEnd();
void captureDelayedPress(QGraphicsSceneMouseEvent *event);
@@ -87,38 +122,30 @@ public:
qreal overShootDistance(qreal velocity, qreal size);
+ void itemGeometryChanged(QDeclarativeItem *, const QRectF &, const QRectF &);
+
public:
QDeclarativeItem *viewport;
- QDeclarativeTimeLineValueProxy<QDeclarativeFlickablePrivate> _moveX;
- QDeclarativeTimeLineValueProxy<QDeclarativeFlickablePrivate> _moveY;
+
+ AxisData hData;
+ AxisData vData;
+
QDeclarativeTimeLine timeline;
- qreal vWidth;
- qreal vHeight;
bool overShoot : 1;
bool flicked : 1;
bool moving : 1;
bool stealMouse : 1;
bool pressed : 1;
- bool atXEnd : 1;
- bool atXBeginning : 1;
- bool atYEnd : 1;
- bool atYBeginning : 1;
bool interactive : 1;
QTime lastPosTime;
QPointF lastPos;
QPointF pressPos;
- qreal pressX;
- qreal pressY;
- qreal velocityX;
- qreal velocityY;
QTime pressTime;
qreal deceleration;
qreal maxVelocity;
QTime velocityTime;
QPointF lastFlickablePosition;
qreal reportedVelocitySmoothing;
- qreal flickTargetX;
- qreal flickTargetY;
QGraphicsSceneMouseEvent *delayedPressEvent;
QGraphicsItem *delayedPressTarget;
QBasicTimer delayedPressTimer;
@@ -129,18 +156,6 @@ public:
static void fixupX_callback(void *);
void updateVelocity();
- struct Velocity : public QDeclarativeTimeLineValue
- {
- Velocity(QDeclarativeFlickablePrivate *p)
- : parent(p) {}
- virtual void setValue(qreal v) {
- QDeclarativeTimeLineValue::setValue(v);
- parent->updateVelocity();
- }
- QDeclarativeFlickablePrivate *parent;
- };
- Velocity horizontalVelocity;
- Velocity verticalVelocity;
int vTime;
QDeclarativeTimeLine velocityTimeline;
QDeclarativeFlickableVisibleArea *visibleArea;
diff --git a/src/declarative/graphicsitems/qdeclarativeflipable.cpp b/src/declarative/graphicsitems/qdeclarativeflipable.cpp
index b36127f..1ebbaee 100644
--- a/src/declarative/graphicsitems/qdeclarativeflipable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflipable.cpp
@@ -68,56 +68,31 @@ public:
\brief The Flipable item provides a surface that can be flipped.
\inherits Item
- Flipable allows you to specify a front and a back and then flip between those sides.
+ Flipable is an item that can be visibly "flipped" between its front and
+ back sides. It is used together with Rotation and State/Transition to
+ produce a flipping effect.
- Here's an example that flips between the front and back sides when clicked:
+ Here is a Flipable that flips whenever it is clicked:
- \qml
-
- Flipable {
- id: flipable
- width: 250; height: 250
- property int angle: 0
-
- transform: Rotation {
- id: rotation
- origin.x: flipable.width/2; origin.y: flipable.height/2
- axis.x: 0; axis.y: 1; axis.z: 0 // rotate around y-axis
- angle: flipable.angle
- }
-
- front: Image { source: "front.png" }
- back: Image { source: "back.png" }
-
- states: State {
- name: "back"
- PropertyChanges { target: flipable; angle: 180 }
- }
-
- transitions: Transition {
- NumberAnimation { properties: "angle"; duration: 2000 }
- }
-
- MouseArea {
- // change between default and 'back' states
- onClicked: flipable.state = (flipable.state == 'back' ? '' : 'back')
- anchors.fill: parent
- }
- }
- \endqml
+ \snippet examples/declarative/flipable/flipable.qml 0
\image flipable.gif
+
+ The Rotation element is used to specify the angle and axis of the flip,
+ and the State defines the changes in angle which produce the flipping
+ effect. Finally, the Transition creates the animation that changes the
+ angle over one second.
*/
/*!
\internal
\class QDeclarativeFlipable
- \brief The QDeclarativeFlipable class provides a flipable surface.
+ \brief The Flipable item provides a surface that can be flipped.
\ingroup group_widgets
- QDeclarativeFlipable allows you to specify a front and a back, as well as an
- axis for the flip.
+ Flipable is an item that can be visibly "flipped" between its front and
+ back sides.
*/
QDeclarativeFlipable::QDeclarativeFlipable(QDeclarativeItem *parent)
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 0a103f3..60ffbe2 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -45,13 +45,14 @@
#include "qdeclarativeflickable_p_p.h"
#include <qdeclarativeeasefollow_p.h>
+#include <qdeclarativeguard_p.h>
#include <qlistmodelinterface_p.h>
#include <QKeyEvent>
-QT_BEGIN_NAMESPACE
+#include <math.h>
-QHash<QObject*, QDeclarativeGridViewAttached*> QDeclarativeGridViewAttached::attachedProperties;
+QT_BEGIN_NAMESPACE
//----------------------------------------------------------------------------
@@ -60,8 +61,9 @@ class FxGridItem
{
public:
FxGridItem(QDeclarativeItem *i, QDeclarativeGridView *v) : item(i), view(v) {
- attached = QDeclarativeGridViewAttached::properties(item);
- attached->m_view = view;
+ attached = static_cast<QDeclarativeGridViewAttached*>(qmlAttachedPropertiesObject<QDeclarativeGridView>(item));
+ if (attached)
+ attached->m_view = view;
}
~FxGridItem() {}
@@ -97,12 +99,13 @@ public:
: currentItem(0), flow(QDeclarativeGridView::LeftToRight)
, visiblePos(0), 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)
, moveReason(Other), buffer(0), highlightXAnimator(0), highlightYAnimator(0)
- , bufferMode(NoBuffer)
+ , bufferMode(NoBuffer), snapMode(QDeclarativeGridView::NoSnap)
, ownModel(false), wrap(false), autoHighlight(true)
, fixCurrentVisibility(false), lazyRelease(false), layoutScheduled(false)
- , deferredRelease(false) {}
+ , deferredRelease(false), haveHighlightRange(false) {}
void init();
void clear();
@@ -119,6 +122,7 @@ public:
void createHighlight();
void updateHighlight();
void updateCurrent(int modelIndex);
+ void fixupPosition();
FxGridItem *visibleItem(int modelIndex) const {
if (modelIndex >= visibleIndex && modelIndex < visibleIndex + visibleItems.count()) {
@@ -236,6 +240,50 @@ public:
return -1; // Not in visibleList
}
+ qreal snapPosAt(qreal pos) {
+ qreal snapPos = 0;
+ if (!visibleItems.isEmpty()) {
+ pos += rowSize()/2;
+ snapPos = visibleItems.first()->rowPos() - visibleIndex / columns * rowSize();
+ snapPos = pos - fmodf(pos - snapPos, qreal(rowSize()));
+ }
+ return snapPos;
+ }
+
+ int snapIndex() {
+ int index = currentIndex;
+ for (int i = 0; i < visibleItems.count(); ++i) {
+ FxGridItem *item = visibleItems[i];
+ if (item->index == -1)
+ continue;
+ qreal itemTop = item->rowPos();
+ if (itemTop >= highlight->rowPos()-rowSize()/2 && itemTop < highlight->rowPos()+rowSize()/2) {
+ index = item->index;
+ if (item->colPos() >= highlight->colPos()-colSize()/2 && item->colPos() < highlight->colPos()+colSize()/2)
+ return item->index;
+ }
+ }
+ return index;
+ }
+
+ virtual void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) {
+ Q_Q(const QDeclarativeGridView);
+ QDeclarativeFlickablePrivate::itemGeometryChanged(item, newGeometry, oldGeometry);
+ if (item == q) {
+ if (newGeometry.height() != oldGeometry.height()
+ || newGeometry.width() != oldGeometry.width()) {
+ if (q->isComponentComplete()) {
+ updateGrid();
+ layout();
+ }
+ }
+ }
+ }
+
+ virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent);
+ virtual void flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
+ QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity);
+
// for debugging only
void checkVisible() const {
int skip = 0;
@@ -251,7 +299,7 @@ public:
}
}
- QGuard<QDeclarativeVisualModel> model;
+ QDeclarativeGuard<QDeclarativeVisualModel> model;
QVariant modelVariant;
QList<FxGridItem*> visibleItems;
QHash<QDeclarativeItem*,int> unrequestedItems;
@@ -264,6 +312,9 @@ public:
int cellHeight;
int columns;
int requestedIndex;
+ qreal highlightRangeStart;
+ qreal highlightRangeEnd;
+ QDeclarativeGridView::HighlightRangeMode highlightRange;
QDeclarativeComponent *highlightComponent;
FxGridItem *highlight;
FxGridItem *trackedItem;
@@ -274,6 +325,7 @@ public:
QDeclarativeEaseFollow *highlightYAnimator;
enum BufferMode { NoBuffer = 0x00, BufferBefore = 0x01, BufferAfter = 0x02 };
BufferMode bufferMode;
+ QDeclarativeGridView::SnapMode snapMode;
bool ownModel : 1;
bool wrap : 1;
@@ -282,15 +334,15 @@ public:
bool lazyRelease : 1;
bool layoutScheduled : 1;
bool deferredRelease : 1;
+ bool haveHighlightRange : 1;
};
void QDeclarativeGridViewPrivate::init()
{
Q_Q(QDeclarativeGridView);
q->setFlag(QGraphicsItem::ItemIsFocusScope);
- QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(sizeChange()));
- QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(sizeChange()));
q->setFlickDirection(QDeclarativeFlickable::VerticalFlick);
+ addItemChangeListener(this, Geometry);
}
void QDeclarativeGridViewPrivate::clear()
@@ -315,9 +367,9 @@ FxGridItem *QDeclarativeGridViewPrivate::createItem(int modelIndex)
if (QDeclarativeItem *item = model->item(modelIndex, false)) {
listItem = new FxGridItem(item, q);
listItem->index = modelIndex;
+ listItem->item->setZValue(1);
// complete
model->completeItem();
- listItem->item->setZValue(1);
listItem->item->setParent(q->viewport());
unrequestedItems.remove(listItem->item);
}
@@ -618,7 +670,7 @@ void QDeclarativeGridViewPrivate::createHighlight()
}
}
if (changed)
- emit q->highlightChanged();
+ emit q->highlightItemChanged();
}
void QDeclarativeGridViewPrivate::updateHighlight()
@@ -671,10 +723,127 @@ void QDeclarativeGridViewPrivate::updateCurrent(int modelIndex)
releaseItem(oldCurrentItem);
}
+void QDeclarativeGridViewPrivate::fixupPosition()
+{
+ moveReason = Other;
+ if (flow == QDeclarativeGridView::LeftToRight)
+ fixupY();
+ else
+ fixupX();
+}
+
+void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent)
+{
+ Q_Q(QDeclarativeGridView);
+
+ if ((&data == &vData && !q->yflick())
+ || (&data == &hData && !q->xflick())
+ || data.move.timeLine())
+ return;
+
+ int oldDuration = fixupDuration;
+ fixupDuration = moveReason == Mouse ? fixupDuration : 0;
+
+ if (haveHighlightRange && highlightRange == QDeclarativeGridView::StrictlyEnforceRange) {
+ if (currentItem && currentItem->rowPos() - position() != highlightRangeStart) {
+ qreal pos = currentItem->rowPos() - highlightRangeStart;
+ timeline.reset(data.move);
+ if (fixupDuration)
+ timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
+ else
+ data.move.setValue(-pos);
+ vTime = timeline.time();
+ }
+ } else if (snapMode != QDeclarativeGridView::NoSnap) {
+ qreal pos = qMax(qMin(snapPosAt(position()) - highlightRangeStart, -maxExtent), -minExtent);
+ qreal dist = qAbs(data.move + 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);
+ vTime = timeline.time();
+ }
+ } else {
+ QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent);
+ }
+ fixupDuration = oldDuration;
+}
+
+void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
+ QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity)
+{
+ Q_Q(QDeclarativeGridView);
+
+ moveReason = Mouse;
+ if ((!haveHighlightRange || highlightRange != QDeclarativeGridView::StrictlyEnforceRange) && snapMode == QDeclarativeGridView::NoSnap) {
+ QDeclarativeFlickablePrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity);
+ return;
+ }
+ qreal maxDistance = -1;
+ // -ve velocity means list is moving up
+ if (velocity > 0) {
+ if (snapMode == QDeclarativeGridView::SnapOneRow) {
+ if (FxGridItem *item = firstVisibleItem())
+ maxDistance = qAbs(item->rowPos() + data.move.value());
+ } else if (data.move.value() < minExtent) {
+ maxDistance = qAbs(minExtent - data.move.value() + (overShoot?overShootDistance(velocity, vSize):0));
+ }
+ if (snapMode != QDeclarativeGridView::SnapToRow && highlightRange != QDeclarativeGridView::StrictlyEnforceRange)
+ data.flickTarget = minExtent;
+ } else {
+ if (snapMode == QDeclarativeGridView::SnapOneRow) {
+ qreal pos = snapPosAt(-data.move.value()) + rowSize();
+ maxDistance = qAbs(pos + data.move.value());
+ } else if (data.move.value() > maxExtent) {
+ maxDistance = qAbs(maxExtent - data.move.value()) + (overShoot?overShootDistance(velocity, vSize):0);
+ }
+ if (snapMode != QDeclarativeGridView::SnapToRow && highlightRange != QDeclarativeGridView::StrictlyEnforceRange)
+ data.flickTarget = maxExtent;
+ }
+ if (maxDistance > 0 && (snapMode != QDeclarativeGridView::NoSnap || highlightRange == QDeclarativeGridView::StrictlyEnforceRange)) {
+ // This mode requires the grid to stop exactly on a row boundary.
+ qreal v = velocity;
+ if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
+ if (v < 0)
+ v = -maxVelocity;
+ else
+ v = maxVelocity;
+ }
+ qreal accel = deceleration;
+ qreal v2 = v * v;
+ qreal maxAccel = v2 / (2.0f * maxDistance);
+ qreal overshootDist = 0.0;
+ if (maxAccel < accel) {
+ qreal dist = v2 / (accel * 2.0);
+ if (v > 0)
+ dist = -dist;
+ data.flickTarget = -snapPosAt(-(data.move.value() - highlightRangeStart) + dist) + highlightRangeStart;
+ dist = -data.flickTarget + data.move.value();
+ accel = v2 / (2.0f * qAbs(dist));
+ } else {
+ data.flickTarget = velocity > 0 ? minExtent : maxExtent;
+ overshootDist = overShoot ? overShootDistance(v, vSize) : 0;
+ }
+ timeline.reset(data.move);
+ timeline.accel(data.move, v, accel, maxDistance + overshootDist);
+ timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this));
+ flicked = true;
+ emit q->flickingChanged();
+ emit q->flickStarted();
+ } else {
+ timeline.reset(data.move);
+ fixup(data, minExtent, maxExtent);
+ }
+}
+
+
//----------------------------------------------------------------------------
/*!
\qmlclass GridView QDeclarativeGridView
+ \since 4.7
\inherits Flickable
\brief The GridView item provides a grid view of items provided by a model.
@@ -695,6 +864,11 @@ void QDeclarativeGridViewPrivate::updateCurrent(int modelIndex)
In this case ListModel is a handy way for us to test our UI. In practice
the model would be implemented in C++, or perhaps via a SQL data source.
+
+ Note that views do not enable \e clip automatically. If the view
+ is not clipped by another item or the screen, it will be necessary
+ to set \e {clip: true} in order to have the out of view items clipped
+ nicely.
*/
QDeclarativeGridView::QDeclarativeGridView(QDeclarativeItem *parent)
: QDeclarativeFlickable(*(new QDeclarativeGridViewPrivate), parent)
@@ -742,7 +916,7 @@ QDeclarativeGridView::~QDeclarativeGridView()
id: myDelegate
Item {
id: wrapper
- GridView.onRemove: SequentialAnimation {
+ SequentialAnimation on GridView.onRemove {
PropertyAction { target: wrapper.GridView; property: "delayRemove"; value: true }
NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" }
PropertyAction { target: wrapper.GridView; property: "delayRemove"; value: false }
@@ -783,6 +957,8 @@ QVariant QDeclarativeGridView::model() const
void QDeclarativeGridView::setModel(const QVariant &model)
{
Q_D(QDeclarativeGridView);
+ if (d->modelVariant == model)
+ return;
if (d->model) {
disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
@@ -827,6 +1003,7 @@ void QDeclarativeGridView::setModel(const QVariant &model)
connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*)));
emit countChanged();
}
+ emit modelChanged();
}
/*!
@@ -870,6 +1047,7 @@ void QDeclarativeGridView::setDelegate(QDeclarativeComponent *delegate)
d->moveReason = QDeclarativeGridViewPrivate::SetIndex;
d->updateCurrent(d->currentIndex);
}
+ emit delegateChanged();
}
}
@@ -965,6 +1143,7 @@ void QDeclarativeGridView::setHighlight(QDeclarativeComponent *highlight)
if (highlight != d->highlightComponent) {
d->highlightComponent = highlight;
d->updateCurrent(d->currentIndex);
+ emit highlightChanged();
}
}
@@ -982,8 +1161,8 @@ void QDeclarativeGridView::setHighlight(QDeclarativeComponent *highlight)
id: myHighlight
Rectangle {
id: wrapper; color: "lightsteelblue"; radius: 4; width: 320; height: 60
- y: SpringFollow { source: Wrapper.GridView.view.currentItem.y; spring: 3; damping: 0.2 }
- x: SpringFollow { source: Wrapper.GridView.view.currentItem.x; spring: 3; damping: 0.2 }
+ SpringFollow on y { source: Wrapper.GridView.view.currentItem.y; spring: 3; damping: 0.2 }
+ SpringFollow on x { source: Wrapper.GridView.view.currentItem.x; spring: 3; damping: 0.2 }
}
}
\endcode
@@ -1008,6 +1187,87 @@ void QDeclarativeGridView::setHighlightFollowsCurrentItem(bool autoHighlight)
}
/*!
+ \qmlproperty real GridView::preferredHighlightBegin
+ \qmlproperty real GridView::preferredHighlightEnd
+ \qmlproperty enumeration GridView::highlightRangeMode
+
+ These properties set the preferred range of the highlight (current item)
+ within the view.
+
+ Note that this is the correct way to influence where the
+ current item ends up when the view scrolls. For example, if you want the
+ currently selected item to be in the middle of the list, then set the
+ highlight range to be where the middle item would go. Then, when the view scrolls,
+ the currently selected item will be the item at that spot. This also applies to
+ when the currently selected item changes - it will scroll to within the preferred
+ highlight range. Furthermore, the behaviour of the current item index will occur
+ whether or not a highlight exists.
+
+ If highlightRangeMode is set to \e ApplyRange the view will
+ attempt to maintain the highlight within the range, however
+ the highlight can move outside of the range at the ends of the list
+ or due to a mouse interaction.
+
+ If highlightRangeMode is set to \e StrictlyEnforceRange the highlight will never
+ move outside of the range. This means that the current item will change
+ if a keyboard or mouse action would cause the highlight to move
+ outside of the range.
+
+ The default value is \e NoHighlightRange.
+
+ Note that a valid range requires preferredHighlightEnd to be greater
+ than or equal to preferredHighlightBegin.
+*/
+qreal QDeclarativeGridView::preferredHighlightBegin() const
+{
+ Q_D(const QDeclarativeGridView);
+ return d->highlightRangeStart;
+}
+
+void QDeclarativeGridView::setPreferredHighlightBegin(qreal start)
+{
+ Q_D(QDeclarativeGridView);
+ if (d->highlightRangeStart == start)
+ return;
+ d->highlightRangeStart = start;
+ d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
+ emit preferredHighlightBeginChanged();
+}
+
+qreal QDeclarativeGridView::preferredHighlightEnd() const
+{
+ Q_D(const QDeclarativeGridView);
+ return d->highlightRangeEnd;
+}
+
+void QDeclarativeGridView::setPreferredHighlightEnd(qreal end)
+{
+ Q_D(QDeclarativeGridView);
+ if (d->highlightRangeEnd == end)
+ return;
+ d->highlightRangeEnd = end;
+ d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
+ emit preferredHighlightEndChanged();
+}
+
+QDeclarativeGridView::HighlightRangeMode QDeclarativeGridView::highlightRangeMode() const
+{
+ Q_D(const QDeclarativeGridView);
+ return d->highlightRange;
+}
+
+void QDeclarativeGridView::setHighlightRangeMode(HighlightRangeMode mode)
+{
+ Q_D(QDeclarativeGridView);
+ if (d->highlightRange == mode)
+ return;
+ d->highlightRange = mode;
+ d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
+ emit highlightRangeModeChanged();
+}
+
+
+/*!
\qmlproperty enumeration GridView::flow
This property holds the flow of the grid.
@@ -1038,6 +1298,7 @@ void QDeclarativeGridView::setFlow(Flow flow)
d->updateGrid();
refill();
d->updateCurrent(d->currentIndex);
+ emit flowChanged();
}
}
@@ -1057,7 +1318,10 @@ bool QDeclarativeGridView::isWrapEnabled() const
void QDeclarativeGridView::setWrapEnabled(bool wrap)
{
Q_D(QDeclarativeGridView);
+ if (d->wrap == wrap)
+ return;
d->wrap = wrap;
+ emit keyNavigationWrapsChanged();
}
/*!
@@ -1081,6 +1345,7 @@ void QDeclarativeGridView::setCacheBuffer(int buffer)
d->buffer = buffer;
if (isComponentComplete())
refill();
+ emit cacheBufferChanged();
}
}
@@ -1125,13 +1390,34 @@ void QDeclarativeGridView::setCellHeight(int cellHeight)
d->layout();
}
}
+/*!
+ \qmlproperty enumeration GridView::snapMode
+
+ This property determines where the view will settle following a drag or flick.
+ The allowed values are:
+
+ \list
+ \o NoSnap (default) - the view will stop anywhere within the visible area.
+ \o SnapToRow - the view will settle with a row (or column for TopToBottom flow)
+ aligned with the start of the view.
+ \o SnapOneRow - the view will settle no more than one row (or column for TopToBottom flow)
+ away from the first visible row at the time the mouse button is released.
+ This mode is particularly useful for moving one page at a time.
+ \endlist
+
+*/
+QDeclarativeGridView::SnapMode QDeclarativeGridView::snapMode() const
+{
+ Q_D(const QDeclarativeGridView);
+ return d->snapMode;
+}
-void QDeclarativeGridView::sizeChange()
+void QDeclarativeGridView::setSnapMode(SnapMode mode)
{
Q_D(QDeclarativeGridView);
- if (isComponentComplete()) {
- d->updateGrid();
- d->layout();
+ if (d->snapMode != mode) {
+ d->snapMode = mode;
+ emit snapModeChanged();
}
}
@@ -1142,20 +1428,46 @@ void QDeclarativeGridView::viewportMoved()
d->lazyRelease = true;
if (d->flicked) {
if (yflick()) {
- if (d->velocityY > 0)
+ if (d->vData.velocity > 0)
d->bufferMode = QDeclarativeGridViewPrivate::BufferBefore;
- else if (d->velocityY < 0)
+ else if (d->vData.velocity < 0)
d->bufferMode = QDeclarativeGridViewPrivate::BufferAfter;
}
if (xflick()) {
- if (d->velocityX > 0)
+ if (d->hData.velocity > 0)
d->bufferMode = QDeclarativeGridViewPrivate::BufferBefore;
- else if (d->velocityX < 0)
+ else if (d->hData.velocity < 0)
d->bufferMode = QDeclarativeGridViewPrivate::BufferAfter;
}
}
refill();
+ if (isFlicking() || d->moving)
+ d->moveReason = QDeclarativeGridViewPrivate::Mouse;
+ if (d->moveReason != QDeclarativeGridViewPrivate::SetIndex) {
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) {
+ // reposition highlight
+ qreal pos = d->highlight->rowPos();
+ qreal viewPos = qRound(d->position());
+ if (pos > viewPos + d->highlightRangeEnd - 1 - d->rowSize())
+ pos = viewPos + d->highlightRangeEnd - 1 - d->rowSize();
+ if (pos < viewPos + d->highlightRangeStart)
+ pos = viewPos + d->highlightRangeStart;
+ d->highlight->setPosition(d->highlight->colPos(), pos);
+
+ // update current index
+ int idx = d->snapIndex();
+ if (idx >= 0 && idx != d->currentIndex) {
+ d->updateCurrent(idx);
+ if (d->currentItem && d->currentItem->colPos() != d->highlight->colPos() && d->autoHighlight) {
+ if (d->flow == LeftToRight)
+ d->highlightXAnimator->setSourceValue(d->currentItem->item->x());
+ else
+ d->highlightYAnimator->setSourceValue(d->currentItem->item->y());
+ }
+ }
+ }
+ }
}
qreal QDeclarativeGridView::minYExtent() const
@@ -1163,7 +1475,10 @@ qreal QDeclarativeGridView::minYExtent() const
Q_D(const QDeclarativeGridView);
if (d->flow == QDeclarativeGridView::TopToBottom)
return QDeclarativeFlickable::minYExtent();
- return -d->startPosition();
+ qreal extent = -d->startPosition();
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
+ extent += d->highlightRangeStart;
+ return extent;
}
qreal QDeclarativeGridView::maxYExtent() const
@@ -1171,7 +1486,11 @@ qreal QDeclarativeGridView::maxYExtent() const
Q_D(const QDeclarativeGridView);
if (d->flow == QDeclarativeGridView::TopToBottom)
return QDeclarativeFlickable::maxYExtent();
- qreal extent = -(d->endPosition() - height());
+ qreal extent;
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
+ extent = -(d->rowPosAt(count()-1) - d->highlightRangeEnd);
+ else
+ extent = -(d->endPosition() - height());
const qreal minY = minYExtent();
if (extent > minY)
extent = minY;
@@ -1183,7 +1502,10 @@ qreal QDeclarativeGridView::minXExtent() const
Q_D(const QDeclarativeGridView);
if (d->flow == QDeclarativeGridView::LeftToRight)
return QDeclarativeFlickable::minXExtent();
- return -d->startPosition();
+ qreal extent = -d->startPosition();
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
+ extent += d->highlightRangeStart;
+ return extent;
}
qreal QDeclarativeGridView::maxXExtent() const
@@ -1191,7 +1513,11 @@ qreal QDeclarativeGridView::maxXExtent() const
Q_D(const QDeclarativeGridView);
if (d->flow == QDeclarativeGridView::LeftToRight)
return QDeclarativeFlickable::maxXExtent();
- qreal extent = -(d->endPosition() - width());
+ qreal extent;
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
+ extent = -(d->rowPosAt(count()-1) - d->highlightRangeEnd);
+ else
+ extent = -(d->endPosition() - height());
const qreal minX = minXExtent();
if (extent > minX)
extent = minX;
@@ -1324,6 +1650,18 @@ void QDeclarativeGridView::moveCurrentIndexRight()
}
}
+/*!
+ \qmlmethod GridView::positionViewAtIndex(int index)
+
+ Positions the view such that the \a index is at the top (or left for horizontal orientation) of the view.
+ If positioning the view at the index would cause empty space to be displayed at
+ the end of the view, the view will be positioned at the end.
+
+ It is not recommended to use contentX or contentY to position the view
+ at a particular index. This is unreliable since removing items from the start
+ of the list does not cause all other items to be repositioned.
+ The correct way to bring an item into view is with positionViewAtIndex.
+*/
void QDeclarativeGridView::positionViewAtIndex(int index)
{
Q_D(QDeclarativeGridView);
@@ -1350,6 +1688,7 @@ void QDeclarativeGridView::positionViewAtIndex(int index)
for (int i = 0; i < oldVisible.count(); ++i)
d->releaseItem(oldVisible.at(i));
}
+ d->fixupPosition();
}
@@ -1363,6 +1702,7 @@ void QDeclarativeGridView::componentComplete()
d->updateCurrent(0);
else
d->updateCurrent(d->currentIndex);
+ d->fixupPosition();
}
void QDeclarativeGridView::trackedPositionChanged()
@@ -1371,22 +1711,50 @@ void QDeclarativeGridView::trackedPositionChanged()
if (!d->trackedItem || !d->currentItem)
return;
if (!isFlicking() && !d->moving && d->moveReason == QDeclarativeGridViewPrivate::SetIndex) {
+ const qreal trackedPos = d->trackedItem->rowPos();
const qreal viewPos = d->position();
- if (d->trackedItem->rowPos() < viewPos && d->currentItem->rowPos() < viewPos) {
- d->setPosition(d->currentItem->rowPos() < d->trackedItem->rowPos() ? d->trackedItem->rowPos() : d->currentItem->rowPos());
- } else if (d->trackedItem->endRowPos() > viewPos + d->size()
- && d->currentItem->endRowPos() > viewPos + d->size()) {
- qreal pos;
- if (d->trackedItem->endRowPos() < d->currentItem->endRowPos()) {
- pos = d->trackedItem->endRowPos() - d->size();
- if (d->rowSize() > d->size())
- pos = d->trackedItem->rowPos();
+ if (d->haveHighlightRange) {
+ if (d->highlightRange == StrictlyEnforceRange) {
+ qreal pos = viewPos;
+ if (trackedPos > pos + d->highlightRangeEnd - d->rowSize())
+ pos = trackedPos - d->highlightRangeEnd + d->rowSize();
+ if (trackedPos < pos + d->highlightRangeStart)
+ pos = trackedPos - d->highlightRangeStart;
+ d->setPosition(pos);
} else {
- pos = d->currentItem->endRowPos() - d->size();
- if (d->rowSize() > d->size())
- pos = d->currentItem->rowPos();
+ qreal pos = viewPos;
+ if (trackedPos < d->startPosition() + d->highlightRangeStart) {
+ pos = d->startPosition();
+ } else if (d->trackedItem->endRowPos() > d->endPosition() - d->size() + d->highlightRangeEnd) {
+ pos = d->endPosition() - d->size();
+ if (pos < d->startPosition())
+ pos = d->startPosition();
+ } else {
+ if (trackedPos < viewPos + d->highlightRangeStart) {
+ pos = trackedPos - d->highlightRangeStart;
+ } else if (trackedPos > viewPos + d->highlightRangeEnd - d->rowSize()) {
+ pos = trackedPos - d->highlightRangeEnd + d->rowSize();
+ }
+ }
+ d->setPosition(pos);
+ }
+ } else {
+ if (trackedPos < viewPos && d->currentItem->rowPos() < viewPos) {
+ d->setPosition(d->currentItem->rowPos() < trackedPos ? trackedPos : d->currentItem->rowPos());
+ } else if (d->trackedItem->endRowPos() > viewPos + d->size()
+ && d->currentItem->endRowPos() > viewPos + d->size()) {
+ qreal pos;
+ if (d->trackedItem->endRowPos() < d->currentItem->endRowPos()) {
+ pos = d->trackedItem->endRowPos() - d->size();
+ if (d->rowSize() > d->size())
+ pos = trackedPos;
+ } else {
+ pos = d->currentItem->endRowPos() - d->size();
+ if (d->rowSize() > d->size())
+ pos = d->currentItem->rowPos();
+ }
+ d->setPosition(pos);
}
- d->setPosition(pos);
}
}
}
@@ -1731,7 +2099,7 @@ void QDeclarativeGridView::refill()
QDeclarativeGridViewAttached *QDeclarativeGridView::qmlAttachedProperties(QObject *obj)
{
- return QDeclarativeGridViewAttached::properties(obj);
+ return new QDeclarativeGridViewAttached(obj);
}
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/declarative/graphicsitems/qdeclarativegridview_p.h
index b488475..787c04c 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h
@@ -57,21 +57,30 @@ class Q_DECLARATIVE_EXPORT QDeclarativeGridView : public QDeclarativeFlickable
Q_OBJECT
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeGridView)
- Q_PROPERTY(QVariant model READ model WRITE setModel)
- Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate)
+ Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
+ Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
Q_PROPERTY(QDeclarativeItem *currentItem READ currentItem NOTIFY currentIndexChanged)
Q_PROPERTY(int count READ count NOTIFY countChanged)
- Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight)
- Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightChanged)
+ Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged)
+ Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightItemChanged)
Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem)
- Q_PROPERTY(Flow flow READ flow WRITE setFlow)
- Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled)
- Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer)
+ Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin NOTIFY preferredHighlightBeginChanged)
+ Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged)
+ Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode NOTIFY highlightRangeModeChanged)
+
+ Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
+ Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled NOTIFY keyNavigationWrapsChanged)
+ Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged)
Q_PROPERTY(int cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellWidthChanged)
Q_PROPERTY(int cellHeight READ cellHeight WRITE setCellHeight NOTIFY cellHeightChanged)
+
+ Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged)
+
+ Q_ENUMS(HighlightRangeMode)
+ Q_ENUMS(SnapMode)
Q_CLASSINFO("DefaultProperty", "data")
public:
@@ -97,6 +106,16 @@ public:
bool highlightFollowsCurrentItem() const;
void setHighlightFollowsCurrentItem(bool);
+ enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange };
+ HighlightRangeMode highlightRangeMode() const;
+ void setHighlightRangeMode(HighlightRangeMode mode);
+
+ qreal preferredHighlightBegin() const;
+ void setPreferredHighlightBegin(qreal);
+
+ qreal preferredHighlightEnd() const;
+ void setPreferredHighlightEnd(qreal);
+
Q_ENUMS(Flow)
enum Flow { LeftToRight, TopToBottom };
Flow flow() const;
@@ -114,6 +133,10 @@ public:
int cellHeight() const;
void setCellHeight(int);
+ enum SnapMode { NoSnap, SnapToRow, SnapOneRow };
+ SnapMode snapMode() const;
+ void setSnapMode(SnapMode mode);
+
static QDeclarativeGridViewAttached *qmlAttachedProperties(QObject *);
public Q_SLOTS:
@@ -129,6 +152,16 @@ Q_SIGNALS:
void cellWidthChanged();
void cellHeightChanged();
void highlightChanged();
+ void highlightItemChanged();
+ void preferredHighlightBeginChanged();
+ void preferredHighlightEndChanged();
+ void highlightRangeModeChanged();
+ void modelChanged();
+ void delegateChanged();
+ void flowChanged();
+ void keyNavigationWrapsChanged();
+ void cacheBufferChanged();
+ void snapModeChanged();
protected:
virtual void viewportMoved();
@@ -148,7 +181,6 @@ private Q_SLOTS:
void destroyRemoved();
void createdItem(int index, QDeclarativeItem *item);
void destroyingItem(QDeclarativeItem *item);
- void sizeChange();
void layout();
private:
@@ -161,9 +193,7 @@ class QDeclarativeGridViewAttached : public QObject
public:
QDeclarativeGridViewAttached(QObject *parent)
: QObject(parent), m_isCurrent(false), m_delayRemove(false) {}
- ~QDeclarativeGridViewAttached() {
- attachedProperties.remove(parent());
- }
+ ~QDeclarativeGridViewAttached() {}
Q_PROPERTY(QDeclarativeGridView *view READ view CONSTANT)
QDeclarativeGridView *view() { return m_view; }
@@ -186,15 +216,6 @@ public:
}
}
- static QDeclarativeGridViewAttached *properties(QObject *obj) {
- QDeclarativeGridViewAttached *rv = attachedProperties.value(obj);
- if (!rv) {
- rv = new QDeclarativeGridViewAttached(obj);
- attachedProperties.insert(obj, rv);
- }
- return rv;
- }
-
void emitAdd() { emit add(); }
void emitRemove() { emit remove(); }
@@ -206,10 +227,8 @@ Q_SIGNALS:
public:
QDeclarativeGridView *m_view;
- bool m_isCurrent;
- bool m_delayRemove;
-
- static QHash<QObject*, QDeclarativeGridViewAttached*> attachedProperties;
+ bool m_isCurrent : 1;
+ bool m_delayRemove : 1;
};
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
index 99ab053..425976f 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -127,7 +127,6 @@ QT_BEGIN_NAMESPACE
QDeclarativeImage::QDeclarativeImage(QDeclarativeItem *parent)
: QDeclarativeImageBase(*(new QDeclarativeImagePrivate), parent)
{
- connect(this, SIGNAL(pixmapChanged()), this, SLOT(updatePaintedGeometry()));
}
QDeclarativeImage::QDeclarativeImage(QDeclarativeImagePrivate &dd, QDeclarativeItem *parent)
@@ -172,7 +171,7 @@ void QDeclarativeImagePrivate::setPixmap(const QPixmap &pixmap)
status = pix.isNull() ? QDeclarativeImageBase::Null : QDeclarativeImageBase::Ready;
q->update();
- emit q->pixmapChanged();
+ q->pixmapChange();
}
/*!
@@ -232,6 +231,16 @@ qreal QDeclarativeImage::paintedHeight() const
\o Error - an error occurred while loading the image
\endlist
+ Note that a change in the status property does not cause anything to happen
+ (although it reflects what has happened with the image internally). If you wish
+ to react to the change in status you need to do it yourself, for example in one
+ of the following ways:
+ \list
+ \o Create a state, so that a state change occurs, e.g. State{name: 'loaded'; when: image.status = Image.Ready;}
+ \o Do something inside the onStatusChanged signal handler, e.g. Image{id: image; onStatusChanged: if(image.status == Image.Ready) console.log('Loaded');}
+ \o Bind to the status variable somewhere, e.g. Text{text: if(image.status!=Image.Ready){'Not Loaded';}else{'Loaded';}}
+ \endlist
+
\sa progress
*/
@@ -374,4 +383,10 @@ void QDeclarativeImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWi
}
}
+void QDeclarativeImage::pixmapChange()
+{
+ updatePaintedGeometry();
+ emit pixmapChanged();
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeimage_p.h b/src/declarative/graphicsitems/qdeclarativeimage_p.h
index fb77ac9..da6cbd5 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeimage_p.h
@@ -79,12 +79,14 @@ public:
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
Q_SIGNALS:
+ void pixmapChanged();
void fillModeChanged();
void paintedGeometryChanged();
protected:
QDeclarativeImage(QDeclarativeImagePrivate &dd, QDeclarativeItem *parent);
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
+ void pixmapChange();
protected Q_SLOTS:
void updatePaintedGeometry();
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
index a8cce3f..e65c9d1 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
@@ -52,7 +52,6 @@ QT_BEGIN_NAMESPACE
QDeclarativeImageBase::QDeclarativeImageBase(QDeclarativeImageBasePrivate &dd, QDeclarativeItem *parent)
: QDeclarativeItem(dd, parent)
{
- setFlag(QGraphicsItem::ItemHasNoContents, false);
}
QDeclarativeImageBase::~QDeclarativeImageBase()
@@ -131,7 +130,7 @@ void QDeclarativeImageBase::load()
setImplicitWidth(0);
setImplicitHeight(0);
emit statusChanged(d->status);
- emit pixmapChanged();
+ pixmapChange();
update();
} else {
d->status = Loading;
@@ -145,19 +144,19 @@ void QDeclarativeImageBase::load()
static int thisRequestProgress = -1;
static int thisRequestFinished = -1;
if (replyDownloadProgress == -1) {
- replyDownloadProgress =
+ replyDownloadProgress =
QDeclarativePixmapReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)");
- replyFinished =
+ replyFinished =
QDeclarativePixmapReply::staticMetaObject.indexOfSignal("finished()");
- thisRequestProgress =
+ thisRequestProgress =
QDeclarativeImageBase::staticMetaObject.indexOfSlot("requestProgress(qint64,qint64)");
thisRequestFinished =
QDeclarativeImageBase::staticMetaObject.indexOfSlot("requestFinished()");
}
- QMetaObject::connect(reply, replyFinished, this,
+ QMetaObject::connect(reply, replyFinished, this,
thisRequestFinished, Qt::DirectConnection);
- QMetaObject::connect(reply, replyDownloadProgress, this,
+ QMetaObject::connect(reply, replyDownloadProgress, this,
thisRequestProgress, Qt::DirectConnection);
} else {
//### should be unified with requestFinished
@@ -173,7 +172,7 @@ void QDeclarativeImageBase::load()
d->progress = 1.0;
emit statusChanged(d->status);
emit progressChanged(d->progress);
- emit pixmapChanged();
+ pixmapChange();
update();
}
}
@@ -197,7 +196,7 @@ void QDeclarativeImageBase::requestFinished()
d->progress = 1.0;
emit statusChanged(d->status);
emit progressChanged(1.0);
- emit pixmapChanged();
+ pixmapChange();
update();
}
@@ -218,4 +217,8 @@ void QDeclarativeImageBase::componentComplete()
load();
}
+void QDeclarativeImageBase::pixmapChange()
+{
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
index c8c50ac..b215193 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
@@ -75,12 +75,12 @@ Q_SIGNALS:
void sourceChanged(const QUrl &);
void statusChanged(Status);
void progressChanged(qreal progress);
- void pixmapChanged();
void asynchronousChanged();
protected:
virtual void load();
virtual void componentComplete();
+ virtual void pixmapChange();
QDeclarativeImageBase(QDeclarativeImageBasePrivate &dd, QDeclarativeItem *parent);
private Q_SLOTS:
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h
index 2e062a8..c4a61f3 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h
@@ -71,6 +71,7 @@ public:
pendingPixmapCache(false),
async(false)
{
+ QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents;
}
QPixmap pix;
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index c282808..9d6b2a0 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -43,6 +43,7 @@
#include "qdeclarativeitem.h"
#include "qdeclarativeevents_p_p.h"
+#include <private/qdeclarativeengine_p.h>
#include <qfxperf_p_p.h>
#include <qdeclarativeengine.h>
@@ -51,6 +52,7 @@
#include <qdeclarativeview.h>
#include <qdeclarativestategroup_p.h>
#include <qdeclarativecomponent.h>
+#include <qdeclarativeinfo.h>
#include <QDebug>
#include <QPen>
@@ -498,6 +500,32 @@ void QDeclarativeKeyNavigationAttached::setDown(QDeclarativeItem *i)
emit changed();
}
+QDeclarativeItem *QDeclarativeKeyNavigationAttached::tab() const
+{
+ Q_D(const QDeclarativeKeyNavigationAttached);
+ return d->tab;
+}
+
+void QDeclarativeKeyNavigationAttached::setTab(QDeclarativeItem *i)
+{
+ Q_D(QDeclarativeKeyNavigationAttached);
+ d->tab = i;
+ emit changed();
+}
+
+QDeclarativeItem *QDeclarativeKeyNavigationAttached::backtab() const
+{
+ Q_D(const QDeclarativeKeyNavigationAttached);
+ return d->backtab;
+}
+
+void QDeclarativeKeyNavigationAttached::setBacktab(QDeclarativeItem *i)
+{
+ Q_D(QDeclarativeKeyNavigationAttached);
+ d->backtab = i;
+ emit changed();
+}
+
void QDeclarativeKeyNavigationAttached::keyPressed(QKeyEvent *event)
{
Q_D(QDeclarativeKeyNavigationAttached);
@@ -529,6 +557,18 @@ void QDeclarativeKeyNavigationAttached::keyPressed(QKeyEvent *event)
event->accept();
}
break;
+ case Qt::Key_Tab:
+ if (d->tab) {
+ d->tab->setFocus(true);
+ event->accept();
+ }
+ break;
+ case Qt::Key_Backtab:
+ if (d->backtab) {
+ d->backtab->setFocus(true);
+ event->accept();
+ }
+ break;
default:
break;
}
@@ -563,6 +603,16 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event)
event->accept();
}
break;
+ case Qt::Key_Tab:
+ if (d->tab) {
+ event->accept();
+ }
+ break;
+ case Qt::Key_Backtab:
+ if (d->backtab) {
+ event->accept();
+ }
+ break;
default:
break;
}
@@ -902,6 +952,8 @@ const QDeclarativeKeysAttached::SigMap QDeclarativeKeysAttached::sigMap[] = {
{ Qt::Key_Right, "rightPressed" },
{ Qt::Key_Up, "upPressed" },
{ Qt::Key_Down, "downPressed" },
+ { Qt::Key_Tab, "tabPressed" },
+ { Qt::Key_Backtab, "backtabPressed" },
{ Qt::Key_Asterisk, "asteriskPressed" },
{ Qt::Key_NumberSign, "numberSignPressed" },
{ Qt::Key_Escape, "escapePressed" },
@@ -1172,7 +1224,7 @@ QDeclarativeKeysAttached *QDeclarativeKeysAttached::qmlAttachedProperties(QObjec
See the \l {Keys}{Keys} attached property for detailed documentation.
- \section 1 Property Change Signals
+ \section1 Property Change Signals
Most properties on Item and Item derivatives have a signal
emitted when they change. By convention, the signals are
@@ -1440,7 +1492,7 @@ QDeclarativeAnchors *QDeclarativeItem::anchors()
void QDeclarativeItemPrivate::data_append(QDeclarativeListProperty<QObject> *prop, QObject *o)
{
QDeclarativeItem *i = qobject_cast<QDeclarativeItem *>(o);
- if (i)
+ if (i)
i->setParentItem(static_cast<QDeclarativeItem *>(prop->object));
else
o->setParent(static_cast<QDeclarativeItem *>(prop->object));
@@ -1568,7 +1620,7 @@ void QDeclarativeItemPrivate::transform_clear(QDeclarativeListProperty<QGraphics
*/
/*! \internal */
-QDeclarativeListProperty<QObject> QDeclarativeItem::data()
+QDeclarativeListProperty<QObject> QDeclarativeItem::data()
{
return QDeclarativeListProperty<QObject>(this, 0, QDeclarativeItemPrivate::data_append);
}
@@ -1730,8 +1782,12 @@ void QDeclarativeItem::geometryChanged(const QRectF &newGeometry,
if (d->_anchors)
d->_anchors->d_func()->updateMe();
- if (transformOrigin() != QDeclarativeItem::TopLeft)
- setTransformOriginPoint(d->computeTransformOrigin());
+ if (transformOrigin() != QDeclarativeItem::TopLeft
+ && (newGeometry.width() != oldGeometry.width() || newGeometry.height() != oldGeometry.height())) {
+ QPointF origin = d->computeTransformOrigin();
+ if (transformOriginPoint() != origin)
+ setTransformOriginPoint(origin);
+ }
if (newGeometry.x() != oldGeometry.x())
emit xChanged();
@@ -2158,6 +2214,58 @@ void QDeclarativeItem::setKeepMouseGrab(bool keep)
}
/*!
+ \qmlmethod object Item::mapFromItem(Item item, int x, int 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
+ properties matching the mapped cooordinate.
+
+ 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 sv = QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(this))->newObject();
+ QDeclarativeItem *itemObj = qobject_cast<QDeclarativeItem*>(item.toQObject());
+ if (!itemObj && !item.isNull()) {
+ qWarning().nospace() << "mapFromItem() given argument " << item.toString() << " which is neither null nor an Item";
+ return 0;
+ }
+
+ // 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());
+ return sv;
+}
+
+/*!
+ \qmlmethod object Item::mapToItem(Item item, int x, int 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
+ properties matching the mapped cooordinate.
+
+ 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 sv = QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(this))->newObject();
+ QDeclarativeItem *itemObj = qobject_cast<QDeclarativeItem*>(item.toQObject());
+ if (!itemObj && !item.isNull()) {
+ qWarning().nospace() << "mapToItem() given argument " << item.toString() << " which is neither null nor an Item";
+ return 0;
+ }
+
+ // 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());
+ return sv;
+}
+
+/*!
\internal
This function emits the \e focusChanged signal.
@@ -2175,16 +2283,16 @@ void QDeclarativeItem::focusChanged(bool flag)
QDeclarativeListProperty<QDeclarativeItem> QDeclarativeItem::fxChildren()
{
return QDeclarativeListProperty<QDeclarativeItem>(this, 0, QDeclarativeItemPrivate::children_append,
- QDeclarativeItemPrivate::children_count,
- QDeclarativeItemPrivate::children_at);
+ QDeclarativeItemPrivate::children_count,
+ QDeclarativeItemPrivate::children_at);
}
/*! \internal */
QDeclarativeListProperty<QObject> QDeclarativeItem::resources()
{
- return QDeclarativeListProperty<QObject>(this, 0, QDeclarativeItemPrivate::resources_append,
- QDeclarativeItemPrivate::resources_count,
- QDeclarativeItemPrivate::resources_at);
+ return QDeclarativeListProperty<QObject>(this, 0, QDeclarativeItemPrivate::resources_append,
+ QDeclarativeItemPrivate::resources_count,
+ QDeclarativeItemPrivate::resources_at);
}
/*!
@@ -2461,14 +2569,26 @@ QPointF QDeclarativeItemPrivate::computeTransformOrigin() const
/*! \internal */
bool QDeclarativeItem::sceneEvent(QEvent *event)
{
- bool rv = QGraphicsItem::sceneEvent(event);
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent *k = static_cast<QKeyEvent *>(event);
- if (event->type() == QEvent::FocusIn ||
- event->type() == QEvent::FocusOut) {
- focusChanged(hasFocus());
- }
+ if ((k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) &&
+ !(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) {
+ keyPressEvent(static_cast<QKeyEvent *>(event));
+ if (!event->isAccepted())
+ return QGraphicsItem::sceneEvent(event);
+ } else {
+ return QGraphicsItem::sceneEvent(event);
+ }
+ } else {
+ bool rv = QGraphicsItem::sceneEvent(event);
- return rv;
+ if (event->type() == QEvent::FocusIn ||
+ event->type() == QEvent::FocusOut) {
+ focusChanged(hasFocus());
+ }
+ return rv;
+ }
}
/*! \internal */
@@ -2735,6 +2855,27 @@ bool QDeclarativeItem::heightValid() const
return d->heightValid;
}
+/*! \internal */
+void QDeclarativeItem::setSize(const QSizeF &size)
+{
+ Q_D(QDeclarativeItem);
+ d->heightValid = true;
+ d->widthValid = true;
+
+ if (d->height == size.height() && d->width == size.width())
+ return;
+
+ qreal oldHeight = d->height;
+ qreal oldWidth = d->width;
+
+ prepareGeometryChange();
+ d->height = size.height();
+ d->width = size.width();
+
+ geometryChanged(QRectF(x(), y(), width(), height()),
+ QRectF(x(), y(), oldWidth, oldHeight));
+}
+
/*!
\qmlproperty bool Item::wantsFocus
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h
index 3ae404d..2053eba 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem.h
@@ -143,6 +143,8 @@ public:
void resetHeight();
qreal implicitHeight() const;
+ void setSize(const QSizeF &size);
+
TransformOrigin transformOrigin() const;
void setTransformOrigin(TransformOrigin);
@@ -159,6 +161,9 @@ 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;
+
QDeclarativeAnchorLine left() const;
QDeclarativeAnchorLine right() const;
QDeclarativeAnchorLine horizontalCenter() const;
@@ -206,8 +211,6 @@ protected:
QDeclarativeItem(QDeclarativeItemPrivate &dd, QDeclarativeItem *parent = 0);
private:
- friend class QDeclarativeStatePrivate;
- friend class QDeclarativeAnchors;
Q_DISABLE_COPY(QDeclarativeItem)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeItem)
};
diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h
index 81c5688..e424970 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h
@@ -60,8 +60,8 @@
#include "qdeclarativeitemchangelistener_p.h"
#include <private/qpodvector_p.h>
-#include "../util/qdeclarativestate_p.h"
-#include "../util/qdeclarativenullablevalue_p_p.h"
+#include <private/qdeclarativestate_p.h>
+#include <private/qdeclarativenullablevalue_p_p.h>
#include <qdeclarative.h>
#include <qdeclarativecontext.h>
@@ -289,12 +289,14 @@ class QDeclarativeKeyNavigationAttachedPrivate : public QObjectPrivate
{
public:
QDeclarativeKeyNavigationAttachedPrivate()
- : QObjectPrivate(), left(0), right(0), up(0), down(0) {}
+ : QObjectPrivate(), left(0), right(0), up(0), down(0), tab(0), backtab(0) {}
QDeclarativeItem *left;
QDeclarativeItem *right;
QDeclarativeItem *up;
QDeclarativeItem *down;
+ QDeclarativeItem *tab;
+ QDeclarativeItem *backtab;
};
class QDeclarativeKeyNavigationAttached : public QObject, public QDeclarativeItemKeyFilter
@@ -306,6 +308,9 @@ class QDeclarativeKeyNavigationAttached : public QObject, public QDeclarativeIte
Q_PROPERTY(QDeclarativeItem *right READ right WRITE setRight NOTIFY changed)
Q_PROPERTY(QDeclarativeItem *up READ up WRITE setUp NOTIFY changed)
Q_PROPERTY(QDeclarativeItem *down READ down WRITE setDown NOTIFY changed)
+ Q_PROPERTY(QDeclarativeItem *tab READ tab WRITE setTab NOTIFY changed)
+ Q_PROPERTY(QDeclarativeItem *backtab READ backtab WRITE setBacktab NOTIFY changed)
+
public:
QDeclarativeKeyNavigationAttached(QObject * = 0);
@@ -317,6 +322,10 @@ public:
void setUp(QDeclarativeItem *);
QDeclarativeItem *down() const;
void setDown(QDeclarativeItem *);
+ QDeclarativeItem *tab() const;
+ void setTab(QDeclarativeItem *);
+ QDeclarativeItem *backtab() const;
+ void setBacktab(QDeclarativeItem *);
static QDeclarativeKeyNavigationAttached *qmlAttachedProperties(QObject *);
@@ -407,6 +416,8 @@ Q_SIGNALS:
void rightPressed(QDeclarativeKeyEvent *event);
void upPressed(QDeclarativeKeyEvent *event);
void downPressed(QDeclarativeKeyEvent *event);
+ void tabPressed(QDeclarativeKeyEvent *event);
+ void backtabPressed(QDeclarativeKeyEvent *event);
void asteriskPressed(QDeclarativeKeyEvent *event);
void numberSignPressed(QDeclarativeKeyEvent *event);
diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
index f3b9385..25660f8 100644
--- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
@@ -106,7 +106,6 @@ void QDeclarativeItemModule::defineModule()
QML_REGISTER_TYPE(Qt,4,6,LayoutItem,QDeclarativeLayoutItem);
QML_REGISTER_TYPE(Qt,4,6,ListView,QDeclarativeListView);
QML_REGISTER_TYPE(Qt,4,6,Loader,QDeclarativeLoader);
- QML_REGISTER_TYPE(Qt,4,6,MouseRegion,QDeclarativeMouseArea);
QML_REGISTER_TYPE(Qt,4,6,MouseArea,QDeclarativeMouseArea);
QML_REGISTER_TYPE(Qt,4,6,Opacity,QGraphicsOpacityEffect);
QML_REGISTER_TYPE(Qt,4,6,ParticleMotion,QDeclarativeParticleMotion);
@@ -139,9 +138,6 @@ void QDeclarativeItemModule::defineModule()
QML_REGISTER_TYPE(Qt,4,6,VisibleArea,QDeclarativeFlickableVisibleArea);
QML_REGISTER_TYPE(Qt,4,6,VisualDataModel,QDeclarativeVisualDataModel);
QML_REGISTER_TYPE(Qt,4,6,VisualItemModel,QDeclarativeVisualItemModel);
-#ifdef QT_WEBKIT_LIB
- QML_REGISTER_TYPE(Qt,4,6,WebView,QDeclarativeWebView);
-#endif
QML_REGISTER_NOCREATE_TYPE(QDeclarativeAnchors);
QML_REGISTER_NOCREATE_TYPE(QGraphicsEffect);
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index c496c97..d54bb70 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -47,6 +47,7 @@
#include <qdeclarativeeasefollow_p.h>
#include <qdeclarativeexpression.h>
#include <qdeclarativeengine.h>
+#include <qdeclarativeguard_p.h>
#include <qlistmodelinterface_p.h>
#include <QKeyEvent>
@@ -138,7 +139,7 @@ public:
//----------------------------------------------------------------------------
-class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate, private QDeclarativeItemChangeListener
+class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate
{
Q_DECLARE_PUBLIC(QDeclarativeListView)
@@ -222,7 +223,7 @@ public:
if (!visibleItems.isEmpty()) {
pos = (*visibleItems.constBegin())->position();
if (visibleIndex > 0)
- pos -= visibleIndex * (averageSize + spacing) - spacing;
+ pos -= visibleIndex * (averageSize + spacing);
}
return pos;
}
@@ -388,11 +389,14 @@ public:
}
}
- void itemGeometryChanged(QDeclarativeItem *, const QRectF &newGeometry, const QRectF &oldGeometry) {
- if ((orient == QDeclarativeListView::Vertical && newGeometry.height() != oldGeometry.height())
- || newGeometry.width() != oldGeometry.width()) {
- layout();
- fixupPosition();
+ void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) {
+ QDeclarativeFlickablePrivate::itemGeometryChanged(item, newGeometry, oldGeometry);
+ if (item != viewport) {
+ if ((orient == QDeclarativeListView::Vertical && newGeometry.height() != oldGeometry.height())
+ || newGeometry.width() != oldGeometry.width()) {
+ layout();
+ fixupPosition();
+ }
}
}
@@ -424,12 +428,11 @@ public:
void updateHeader();
void updateFooter();
void fixupPosition();
- virtual void fixupY();
- virtual void fixupX();
- virtual void flickX(qreal velocity);
- virtual void flickY(qreal velocity);
+ virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent);
+ virtual void flick(QDeclarativeFlickablePrivate::AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
+ QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity);
- QGuard<QDeclarativeVisualModel> model;
+ QDeclarativeGuard<QDeclarativeVisualModel> model;
QVariant modelVariant;
QList<FxListItem*> visibleItems;
QHash<QDeclarativeItem*,int> unrequestedItems;
@@ -530,9 +533,9 @@ FxListItem *QDeclarativeListViewPrivate::createItem(int modelIndex)
listItem->attached->m_prevSection = sectionAt(modelIndex-1);
}
}
+ listItem->item->setZValue(1);
// complete
model->completeItem();
- listItem->item->setZValue(1);
listItem->item->setParent(q->viewport());
QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item));
itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
@@ -798,10 +801,13 @@ void QDeclarativeListViewPrivate::createHighlight()
if (item) {
item->setParent(q->viewport());
highlight = new FxListItem(item, q);
- if (orient == QDeclarativeListView::Vertical)
- highlight->item->setHeight(currentItem->item->height());
- else
- highlight->item->setWidth(currentItem->item->width());
+ if (currentItem && autoHighlight) {
+ if (orient == QDeclarativeListView::Vertical) {
+ highlight->item->setHeight(currentItem->item->height());
+ } else {
+ highlight->item->setWidth(currentItem->item->width());
+ }
+ }
const QLatin1String posProp(orient == QDeclarativeListView::Vertical ? "y" : "x");
highlightPosAnimator = new QDeclarativeEaseFollow(q);
highlightPosAnimator->setTarget(QDeclarativeProperty(highlight->item, posProp));
@@ -816,7 +822,7 @@ void QDeclarativeListViewPrivate::createHighlight()
}
}
if (changed)
- emit q->highlightChanged();
+ emit q->highlightItemChanged();
}
void QDeclarativeListViewPrivate::updateHighlight()
@@ -1057,52 +1063,16 @@ void QDeclarativeListViewPrivate::fixupPosition()
fixupX();
}
-void QDeclarativeListViewPrivate::fixupY()
+void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent)
{
Q_Q(QDeclarativeListView);
- if (orient == QDeclarativeListView::Horizontal)
+ if ((orient == QDeclarativeListView::Horizontal && &data == &vData)
+ || (orient == QDeclarativeListView::Vertical && &data == &hData))
return;
- if (!q->yflick() || _moveY.timeLine())
- return;
-
- int oldDuration = fixupDuration;
- fixupDuration = moveReason == Mouse ? fixupDuration : 0;
-
- if (haveHighlightRange && highlightRange == QDeclarativeListView::StrictlyEnforceRange) {
- if (currentItem && currentItem->position() - position() != highlightRangeStart) {
- qreal pos = currentItem->position() - highlightRangeStart;
- timeline.reset(_moveY);
- if (fixupDuration)
- timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
- else
- _moveY.setValue(-pos);
- vTime = timeline.time();
- }
- } else if (snapMode != QDeclarativeListView::NoSnap) {
- if (FxListItem *item = snapItemAt(position())) {
- qreal pos = qMin(item->position() - highlightRangeStart, -q->maxYExtent());
- qreal dist = qAbs(_moveY + pos);
- if (dist > 0) {
- timeline.reset(_moveY);
- if (fixupDuration)
- timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
- else
- _moveY.setValue(-pos);
- vTime = timeline.time();
- }
- }
- } else {
- QDeclarativeFlickablePrivate::fixupY();
- }
- fixupDuration = oldDuration;
-}
-void QDeclarativeListViewPrivate::fixupX()
-{
- Q_Q(QDeclarativeListView);
- if (orient == QDeclarativeListView::Vertical)
- return;
- if (!q->xflick() || _moveX.timeLine())
+ if ((&data == &vData && !q->yflick())
+ || (&data == &hData && !q->xflick())
+ || data.move.timeLine())
return;
int oldDuration = fixupDuration;
@@ -1111,63 +1081,62 @@ void QDeclarativeListViewPrivate::fixupX()
if (haveHighlightRange && highlightRange == QDeclarativeListView::StrictlyEnforceRange) {
if (currentItem && currentItem->position() - position() != highlightRangeStart) {
qreal pos = currentItem->position() - highlightRangeStart;
- timeline.reset(_moveX);
+ timeline.reset(data.move);
if (fixupDuration)
- timeline.move(_moveX, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
else
- _moveX.setValue(-pos);
+ data.move.setValue(-pos);
vTime = timeline.time();
}
} else if (snapMode != QDeclarativeListView::NoSnap) {
if (FxListItem *item = snapItemAt(position())) {
- qreal pos = qMin(item->position() - highlightRangeStart, -q->maxXExtent());
- qreal dist = qAbs(_moveX + pos);
+ qreal pos = qMin(item->position() - highlightRangeStart, -maxExtent);
+ qreal dist = qAbs(data.move + pos);
if (dist > 0) {
- timeline.reset(_moveX);
+ timeline.reset(data.move);
if (fixupDuration)
- timeline.move(_moveX, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration);
+ timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
else
- _moveX.setValue(-pos);
+ data.move.setValue(-pos);
vTime = timeline.time();
}
}
} else {
- QDeclarativeFlickablePrivate::fixupX();
+ QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent);
}
fixupDuration = oldDuration;
}
-void QDeclarativeListViewPrivate::flickX(qreal velocity)
+void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
+ QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity)
{
Q_Q(QDeclarativeListView);
moveReason = Mouse;
if ((!haveHighlightRange || highlightRange != QDeclarativeListView::StrictlyEnforceRange) && snapMode == QDeclarativeListView::NoSnap) {
- QDeclarativeFlickablePrivate::flickX(velocity);
+ QDeclarativeFlickablePrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity);
return;
}
qreal maxDistance = -1;
- const qreal maxX = q->maxXExtent();
- const qreal minX = q->minXExtent();
// -ve velocity means list is moving up
if (velocity > 0) {
if (snapMode == QDeclarativeListView::SnapOneItem) {
if (FxListItem *item = firstVisibleItem())
- maxDistance = qAbs(item->position() + _moveX.value());
- } else if (_moveX.value() < minX) {
- maxDistance = qAbs(minX -_moveX.value() + (overShoot?overShootDistance(velocity, q->width()):0));
+ maxDistance = qAbs(item->position() + data.move.value());
+ } else if (data.move.value() < minExtent) {
+ maxDistance = qAbs(minExtent - data.move.value() + (overShoot?overShootDistance(velocity, vSize):0));
}
if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
- flickTargetX = minX;
+ data.flickTarget = minExtent;
} else {
if (snapMode == QDeclarativeListView::SnapOneItem) {
if (FxListItem *item = nextVisibleItem())
- maxDistance = qAbs(item->position() + _moveX.value());
- } else if (_moveX.value() > maxX) {
- maxDistance = qAbs(maxX - _moveX.value()) + (overShoot?overShootDistance(velocity, q->width()):0);
+ maxDistance = qAbs(item->position() + data.move.value());
+ } else if (data.move.value() > maxExtent) {
+ maxDistance = qAbs(maxExtent - data.move.value()) + (overShoot?overShootDistance(velocity, vSize):0);
}
if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
- flickTargetX = maxX;
+ data.flickTarget = maxExtent;
}
if (maxDistance > 0 && (snapMode != QDeclarativeListView::NoSnap || highlightRange == QDeclarativeListView::StrictlyEnforceRange)) {
// These modes require the list to stop exactly on an item boundary.
@@ -1190,146 +1159,48 @@ void QDeclarativeListViewPrivate::flickX(qreal velocity)
qreal dist = v2 / (accel * 2.0);
if (v > 0)
dist = -dist;
- flickTargetX = -snapPosAt(-(_moveX.value() - highlightRangeStart) + dist) + highlightRangeStart;
- dist = -flickTargetX + _moveX.value();
+ data.flickTarget = -snapPosAt(-(data.move.value() - highlightRangeStart) + dist) + highlightRangeStart;
+ dist = -data.flickTarget + data.move.value();
accel = v2 / (2.0f * qAbs(dist));
overshootDist = 0.0;
} else {
- flickTargetX = velocity > 0 ? minX : maxX;
- overshootDist = overShoot ? overShootDistance(v, q->width()) : 0;
+ data.flickTarget = velocity > 0 ? minExtent : maxExtent;
+ overshootDist = overShoot ? overShootDistance(v, vSize) : 0;
}
- timeline.reset(_moveX);
- timeline.accel(_moveX, v, accel, maxDistance + overshootDist);
- timeline.callback(QDeclarativeTimeLineCallback(&_moveX, fixupX_callback, this));
+ timeline.reset(data.move);
+ timeline.accel(data.move, v, accel, maxDistance + overshootDist);
+ timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this));
flicked = true;
emit q->flickingChanged();
emit q->flickStarted();
correctFlick = true;
} else {
// reevaluate the target boundary.
- qreal newtarget = flickTargetX;
+ qreal newtarget = data.flickTarget;
if (snapMode != QDeclarativeListView::NoSnap || highlightRange == QDeclarativeListView::StrictlyEnforceRange)
- newtarget = -snapPosAt(-(flickTargetX - highlightRangeStart)) + highlightRangeStart;
- if (velocity < 0 && newtarget < maxX)
- newtarget = maxX;
- else if (velocity > 0 && newtarget > minX)
- newtarget = minX;
- if (newtarget == flickTargetX) // boundary unchanged - nothing to do
+ 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
return;
- flickTargetX = newtarget;
- qreal dist = -newtarget + _moveX.value();
+ data.flickTarget = newtarget;
+ qreal dist = -newtarget + data.move.value();
if ((v < 0 && dist < 0) || (v > 0 && dist > 0)) {
correctFlick = false;
- timeline.reset(_moveX);
- fixupX();
+ timeline.reset(data.move);
+ fixup(data, minExtent, maxExtent);
return;
}
- timeline.reset(_moveX);
- timeline.accelDistance(_moveX, v, -dist + (v < 0 ? -overshootDist : overshootDist));
- timeline.callback(QDeclarativeTimeLineCallback(&_moveX, fixupX_callback, this));
+ timeline.reset(data.move);
+ timeline.accelDistance(data.move, v, -dist + (v < 0 ? -overshootDist : overshootDist));
+ timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this));
}
} else {
correctFlick = false;
- timeline.reset(_moveX);
- fixupX();
- }
-}
-
-void QDeclarativeListViewPrivate::flickY(qreal velocity)
-{
- Q_Q(QDeclarativeListView);
-
- moveReason = Mouse;
- if ((!haveHighlightRange || highlightRange != QDeclarativeListView::StrictlyEnforceRange) && snapMode == QDeclarativeListView::NoSnap) {
- QDeclarativeFlickablePrivate::flickY(velocity);
- return;
- }
- qreal maxDistance = -1;
- const qreal maxY = q->maxYExtent();
- const qreal minY = q->minYExtent();
- // -ve velocity means list is moving up
- if (velocity > 0) {
- if (snapMode == QDeclarativeListView::SnapOneItem) {
- if (FxListItem *item = firstVisibleItem())
- maxDistance = qAbs(item->position() + _moveY.value());
- } else if (_moveY.value() < minY) {
- maxDistance = qAbs(minY -_moveY.value() + (overShoot?overShootDistance(velocity, q->height()):0));
- }
- if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
- flickTargetY = minY;
- } else {
- if (snapMode == QDeclarativeListView::SnapOneItem) {
- if (FxListItem *item = nextVisibleItem())
- maxDistance = qAbs(item->position() + _moveY.value());
- } else if (_moveY.value() > maxY) {
- maxDistance = qAbs(maxY - _moveY.value()) + (overShoot?overShootDistance(velocity, q->height()):0);
- }
- if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
- flickTargetY = maxY;
- }
- if (maxDistance > 0 && (snapMode != QDeclarativeListView::NoSnap || highlightRange == QDeclarativeListView::StrictlyEnforceRange)) {
- // These modes require the list to stop exactly on an item boundary.
- // The initial flick will estimate the boundary to stop on.
- // Since list items can have variable sizes, the boundary will be
- // reevaluated and adjusted as we approach the boundary.
- qreal v = velocity;
- if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
- if (v < 0)
- v = -maxVelocity;
- else
- v = maxVelocity;
- }
- if (!flicked) {
- // the initial flick - estimate boundary
- qreal accel = deceleration;
- qreal v2 = v * v;
- qreal maxAccel = v2 / (2.0f * maxDistance);
- if (maxAccel < accel) {
- qreal dist = v2 / (accel * 2.0);
- if (v > 0)
- dist = -dist;
- flickTargetY = -snapPosAt(-(_moveY.value() - highlightRangeStart) + dist) + highlightRangeStart;
- dist = -flickTargetY + _moveY.value();
- accel = v2 / (2.0f * qAbs(dist));
- overshootDist = 0.0;
- } else {
- flickTargetY = velocity > 0 ? minY : maxY;
- overshootDist = overShoot ? overShootDistance(v, q->height()) : 0;
- }
- timeline.reset(_moveY);
- timeline.accel(_moveY, v, accel, maxDistance + overshootDist);
- timeline.callback(QDeclarativeTimeLineCallback(&_moveY, fixupY_callback, this));
- flicked = true;
- emit q->flickingChanged();
- emit q->flickStarted();
- correctFlick = true;
- } else {
- // reevaluate the target boundary.
- qreal newtarget = flickTargetY;
- if (snapMode != QDeclarativeListView::NoSnap || highlightRange == QDeclarativeListView::StrictlyEnforceRange)
- newtarget = -snapPosAt(-(flickTargetY - highlightRangeStart)) + highlightRangeStart;
- if (velocity < 0 && newtarget < maxY)
- newtarget = maxY;
- else if (velocity > 0 && newtarget > minY)
- newtarget = minY;
- if (newtarget == flickTargetY) // boundary unchanged - nothing to do
- return;
- flickTargetY = newtarget;
- qreal dist = -newtarget + _moveY.value();
- if ((v < 0 && dist < 0) || (v > 0 && dist > 0)) {
- correctFlick = false;
- timeline.reset(_moveY);
- fixupY();
- return;
- }
- timeline.reset(_moveY);
- timeline.accelDistance(_moveY, v, -dist + (v < 0 ? -overshootDist : overshootDist));
- timeline.callback(QDeclarativeTimeLineCallback(&_moveY, fixupY_callback, this));
- }
- } else {
- correctFlick = false;
- timeline.reset(_moveY);
- fixupY();
+ timeline.reset(data.move);
+ fixup(data, minExtent, maxExtent);
}
}
@@ -1358,6 +1229,11 @@ void QDeclarativeListViewPrivate::flickY(qreal velocity)
In this case ListModel is a handy way for us to test our UI. In practice
the model would be implemented in C++, or perhaps via a SQL data source.
+
+ Note that views do not enable \e clip automatically. If the view
+ is not clipped by another item or the screen, it will be necessary
+ to set \e {clip: true} in order to have the out of view items clipped
+ nicely.
*/
QDeclarativeListView::QDeclarativeListView(QDeclarativeItem *parent)
@@ -1430,7 +1306,7 @@ QDeclarativeListView::~QDeclarativeListView()
id: myDelegate
Item {
id: wrapper
- ListView.onRemove: SequentialAnimation {
+ SequentialAnimation on ListView.onRemove {
PropertyAction { target: wrapper.ListView; property: "delayRemove"; value: true }
NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" }
PropertyAction { target: wrapper.ListView; property: "delayRemove"; value: false }
@@ -1473,6 +1349,8 @@ QVariant QDeclarativeListView::model() const
void QDeclarativeListView::setModel(const QVariant &model)
{
Q_D(QDeclarativeListView);
+ if (d->modelVariant == model)
+ return;
if (d->model) {
disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
@@ -1517,6 +1395,7 @@ void QDeclarativeListView::setModel(const QVariant &model)
connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*)));
emit countChanged();
}
+ emit modelChanged();
}
/*!
@@ -1563,6 +1442,7 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate)
d->updateCurrent(d->currentIndex);
}
}
+ emit delegateChanged();
}
/*!
@@ -1663,6 +1543,7 @@ void QDeclarativeListView::setHighlight(QDeclarativeComponent *highlight)
d->createHighlight();
if (d->currentItem)
d->updateHighlight();
+ emit highlightChanged();
}
}
@@ -1700,6 +1581,7 @@ void QDeclarativeListView::setHighlightFollowsCurrentItem(bool autoHighlight)
d->highlightSizeAnimator->setEnabled(d->autoHighlight);
}
d->updateHighlight();
+ emit highlightFollowsCurrentItemChanged();
}
}
@@ -1745,8 +1627,11 @@ qreal QDeclarativeListView::preferredHighlightBegin() const
void QDeclarativeListView::setPreferredHighlightBegin(qreal start)
{
Q_D(QDeclarativeListView);
+ if (d->highlightRangeStart == start)
+ return;
d->highlightRangeStart = start;
d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
+ emit preferredHighlightBeginChanged();
}
qreal QDeclarativeListView::preferredHighlightEnd() const
@@ -1758,8 +1643,11 @@ qreal QDeclarativeListView::preferredHighlightEnd() const
void QDeclarativeListView::setPreferredHighlightEnd(qreal end)
{
Q_D(QDeclarativeListView);
+ if (d->highlightRangeEnd == end)
+ return;
d->highlightRangeEnd = end;
d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
+ emit preferredHighlightEndChanged();
}
QDeclarativeListView::HighlightRangeMode QDeclarativeListView::highlightRangeMode() const
@@ -1771,8 +1659,11 @@ QDeclarativeListView::HighlightRangeMode QDeclarativeListView::highlightRangeMod
void QDeclarativeListView::setHighlightRangeMode(HighlightRangeMode mode)
{
Q_D(QDeclarativeListView);
+ if (d->highlightRange == mode)
+ return;
d->highlightRange = mode;
d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
+ emit highlightRangeModeChanged();
}
/*!
@@ -1848,7 +1739,10 @@ bool QDeclarativeListView::isWrapEnabled() const
void QDeclarativeListView::setWrapEnabled(bool wrap)
{
Q_D(QDeclarativeListView);
+ if (d->wrap == wrap)
+ return;
d->wrap = wrap;
+ emit keyNavigationWrapsChanged();
}
/*!
@@ -1874,6 +1768,7 @@ void QDeclarativeListView::setCacheBuffer(int b)
d->bufferMode = QDeclarativeListViewPrivate::BufferBefore | QDeclarativeListViewPrivate::BufferAfter;
refill();
}
+ emit cacheBufferChanged();
}
}
@@ -1980,6 +1875,12 @@ void QDeclarativeListView::setHighlightResizeSpeed(qreal speed)
visible item at the time the mouse button is released. This mode is particularly
useful for moving one page at a time.
\endlist
+
+ snapMode does not affect the currentIndex. To update the
+ currentIndex as the list is moved set \e highlightRangeMode
+ to \e StrictlyEnforceRange.
+
+ \sa highlightRangeMode
*/
QDeclarativeListView::SnapMode QDeclarativeListView::snapMode() const
{
@@ -1992,6 +1893,7 @@ void QDeclarativeListView::setSnapMode(SnapMode mode)
Q_D(QDeclarativeListView);
if (d->snapMode != mode) {
d->snapMode = mode;
+ emit snapModeChanged();
}
}
@@ -2014,6 +1916,7 @@ void QDeclarativeListView::setFooter(QDeclarativeComponent *footer)
d->maxExtentDirty = true;
d->updateFooter();
d->updateViewport();
+ emit footerChanged();
}
}
@@ -2037,6 +1940,7 @@ void QDeclarativeListView::setHeader(QDeclarativeComponent *header)
d->updateHeader();
d->updateFooter();
d->updateViewport();
+ emit headerChanged();
}
}
@@ -2070,33 +1974,33 @@ void QDeclarativeListView::viewportMoved()
// Near an end and it seems that the extent has changed?
// Recalculate the flick so that we don't end up in an odd position.
if (yflick()) {
- if (d->velocityY > 0) {
+ if (d->vData.velocity > 0) {
const qreal minY = minYExtent();
- if ((minY - d->_moveY.value() < height()/2 || d->flickTargetY - d->_moveY.value() < height()/2)
- && minY != d->flickTargetY)
- d->flickY(-d->verticalVelocity.value());
+ if ((minY - d->vData.move.value() < height()/2 || d->vData.flickTarget - d->vData.move.value() < height()/2)
+ && minY != d->vData.flickTarget)
+ d->flickY(-d->vData.smoothVelocity.value());
d->bufferMode = QDeclarativeListViewPrivate::BufferBefore;
- } else if (d->velocityY < 0) {
+ } else if (d->vData.velocity < 0) {
const qreal maxY = maxYExtent();
- if ((d->_moveY.value() - maxY < height()/2 || d->_moveY.value() - d->flickTargetY < height()/2)
- && maxY != d->flickTargetY)
- d->flickY(-d->verticalVelocity.value());
+ if ((d->vData.move.value() - maxY < height()/2 || d->vData.move.value() - d->vData.flickTarget < height()/2)
+ && maxY != d->vData.flickTarget)
+ d->flickY(-d->vData.smoothVelocity.value());
d->bufferMode = QDeclarativeListViewPrivate::BufferAfter;
}
}
if (xflick()) {
- if (d->velocityX > 0) {
+ if (d->hData.velocity > 0) {
const qreal minX = minXExtent();
- if ((minX - d->_moveX.value() < height()/2 || d->flickTargetX - d->_moveX.value() < height()/2)
- && minX != d->flickTargetX)
- d->flickX(-d->horizontalVelocity.value());
+ if ((minX - d->hData.move.value() < width()/2 || d->hData.flickTarget - d->hData.move.value() < width()/2)
+ && minX != d->hData.flickTarget)
+ d->flickX(-d->hData.smoothVelocity.value());
d->bufferMode = QDeclarativeListViewPrivate::BufferBefore;
- } else if (d->velocityX < 0) {
+ } else if (d->hData.velocity < 0) {
const qreal maxX = maxXExtent();
- if ((d->_moveX.value() - maxX < height()/2 || d->_moveX.value() - d->flickTargetX < height()/2)
- && maxX != d->flickTargetX)
- d->flickX(-d->horizontalVelocity.value());
+ if ((d->hData.move.value() - maxX < width()/2 || d->hData.move.value() - d->hData.flickTarget < width()/2)
+ && maxX != d->hData.flickTarget)
+ d->flickX(-d->hData.smoothVelocity.value());
d->bufferMode = QDeclarativeListViewPrivate::BufferAfter;
}
}
@@ -2252,6 +2156,12 @@ void QDeclarativeListView::decrementCurrentIndex()
Positions the view such that the \a index is at the top (or left for horizontal orientation) of the view.
If positioning the view at the index would cause empty space to be displayed at
the end of the view, the view will be positioned at the end.
+
+ It is not recommended to use contentX or contentY to position the view
+ at a particular index. This is unreliable since removing items from the start
+ of the list does not cause all other items to be repositioned, and because
+ the actual start of the view can vary based on the size of the delegates.
+ The correct way to bring an item into view is with positionViewAtIndex.
*/
void QDeclarativeListView::positionViewAtIndex(int index)
{
@@ -2374,7 +2284,8 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count)
int i = d->visibleItems.count() - 1;
while (i > 0 && d->visibleItems.at(i)->index == -1)
--i;
- if (d->visibleItems.at(i)->index + 1 == modelIndex) {
+ if (d->visibleItems.at(i)->index + 1 == modelIndex
+ && d->visibleItems.at(i)->endPosition() < d->buffer+d->position()+d->size()-1) {
// Special case of appending an item to the model.
modelIndex = d->visibleIndex + d->visibleItems.count();
} else {
diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/declarative/graphicsitems/qdeclarativelistview_p.h
index 5e3edb0..d66ac2b 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h
@@ -91,33 +91,33 @@ class Q_DECLARATIVE_EXPORT QDeclarativeListView : public QDeclarativeFlickable
Q_OBJECT
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeListView)
- Q_PROPERTY(QVariant model READ model WRITE setModel)
- Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate)
+ Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
+ Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
Q_PROPERTY(QDeclarativeItem *currentItem READ currentItem NOTIFY currentIndexChanged)
Q_PROPERTY(int count READ count NOTIFY countChanged)
- Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight)
- Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightChanged)
- Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem)
+ Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged)
+ Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightItemChanged)
+ Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem NOTIFY highlightFollowsCurrentItemChanged)
Q_PROPERTY(qreal highlightMoveSpeed READ highlightMoveSpeed WRITE setHighlightMoveSpeed NOTIFY highlightMoveSpeedChanged)
Q_PROPERTY(qreal highlightResizeSpeed READ highlightResizeSpeed WRITE setHighlightResizeSpeed NOTIFY highlightResizeSpeedChanged)
- Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin)
- Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd)
- Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode)
+ Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin NOTIFY preferredHighlightBeginChanged)
+ Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged)
+ Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode NOTIFY highlightRangeModeChanged)
Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
- Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled)
- Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer)
+ Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled NOTIFY keyNavigationWrapsChanged)
+ Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged)
Q_PROPERTY(QDeclarativeViewSection *section READ sectionCriteria CONSTANT)
Q_PROPERTY(QString currentSection READ currentSection NOTIFY currentSectionChanged)
- Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode)
+ Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged)
- Q_PROPERTY(QDeclarativeComponent *header READ header WRITE setHeader)
- Q_PROPERTY(QDeclarativeComponent *footer READ footer WRITE setFooter)
+ Q_PROPERTY(QDeclarativeComponent *header READ header WRITE setHeader NOTIFY headerChanged)
+ Q_PROPERTY(QDeclarativeComponent *footer READ footer WRITE setFooter NOTIFY footerChanged)
Q_ENUMS(HighlightRangeMode)
Q_ENUMS(Orientation)
@@ -205,6 +205,18 @@ Q_SIGNALS:
void highlightMoveSpeedChanged();
void highlightResizeSpeedChanged();
void highlightChanged();
+ void highlightItemChanged();
+ void modelChanged();
+ void delegateChanged();
+ void highlightFollowsCurrentItemChanged();
+ void preferredHighlightBeginChanged();
+ void preferredHighlightEndChanged();
+ void highlightRangeModeChanged();
+ void keyNavigationWrapsChanged();
+ void cacheBufferChanged();
+ void snapModeChanged();
+ void headerChanged();
+ void footerChanged();
protected:
virtual void viewportMoved();
@@ -288,10 +300,10 @@ Q_SIGNALS:
public:
QDeclarativeListView *m_view;
- bool m_isCurrent;
mutable QString m_section;
QString m_prevSection;
- bool m_delayRemove;
+ bool m_isCurrent : 1;
+ bool m_delayRemove : 1;
};
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp
index bd89321..b0499d7 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp
@@ -320,6 +320,15 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded()
\o Error - an error occurred while loading the QML source
\endlist
+ Note that a change in the status property does not cause anything to happen
+ (although it reflects what has happened to the loader internally). If you wish
+ to react to the change in status you need to do it yourself, for example in one
+ of the following ways:
+ \list
+ \o Create a state, so that a state change occurs, e.g. State{name: 'loaded'; when: loader.status = Loader.Ready;}
+ \o Do something inside the onStatusChanged signal handler, e.g. Loader{id: loader; onStatusChanged: if(loader.status == Loader.Ready) console.log('Loaded');}
+ \o Bind to the status variable somewhere, e.g. Text{text: if(loader.status!=Loader.Ready){'Not Loaded';}else{'Loaded';}}
+ \endlist
\sa progress
*/
diff --git a/src/declarative/graphicsitems/qdeclarativeparticles.cpp b/src/declarative/graphicsitems/qdeclarativeparticles.cpp
index 1a58d3f..593c80a 100644
--- a/src/declarative/graphicsitems/qdeclarativeparticles.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeparticles.cpp
@@ -758,11 +758,13 @@ void QDeclarativeParticles::setSource(const QUrl &name)
The particles element emits particles until it has count active
particles. When this number is reached, new particles are not emitted until
- some of the current particles reach theend of their lifespan.
+ some of the current particles reach the end of their lifespan.
If count is -1 then there is no maximum number of active particles, and
particles will be constantly emitted at the rate specified by emissionRate.
+ The default value for count is 1.
+
If both count and emissionRate are set to -1, nothing will be emitted.
*/
@@ -1219,7 +1221,7 @@ void QDeclarativeParticles::burst(int count, int emissionRate)
void QDeclarativeParticlesPainter::updateSize()
{
- if (!isComponentComplete())
+ if (!d->_componentComplete)
return;
const int parentX = parentItem()->x();
@@ -1260,7 +1262,11 @@ void QDeclarativeParticlesPainter::paint(QPainter *p, const QStyleOptionGraphics
const int myX = x() + parentItem()->x();
const int myY = y() + parentItem()->y();
- QVarLengthArray<QPainter::Fragment, 256> pixmapData;
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
+ QVarLengthArray<QPainter::PixmapFragment, 256> pixmapData;
+#else
+ QVarLengthArray<QDrawPixmaps::Data, 256> pixmapData;
+#endif
pixmapData.resize(d->particles.count());
const QRectF sourceRect = d->image.rect();
@@ -1268,27 +1274,39 @@ void QDeclarativeParticlesPainter::paint(QPainter *p, const QStyleOptionGraphics
qreal halfPHeight = sourceRect.height()/2.;
for (int i = 0; i < d->particles.count(); ++i) {
const QDeclarativeParticle &particle = d->particles.at(i);
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
pixmapData[i].x = particle.x - myX + halfPWidth;
pixmapData[i].y = particle.y - myY + halfPHeight;
+#else
+ pixmapData[i].point = QPointF(particle.x - myX + halfPWidth, particle.y - myY + halfPHeight);
+#endif
pixmapData[i].opacity = particle.opacity;
//these never change
pixmapData[i].rotation = 0;
pixmapData[i].scaleX = 1;
pixmapData[i].scaleY = 1;
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
pixmapData[i].sourceLeft = sourceRect.left();
pixmapData[i].sourceTop = sourceRect.top();
pixmapData[i].width = sourceRect.width();
pixmapData[i].height = sourceRect.height();
+#else
+ pixmapData[i].source = sourceRect;
+#endif
}
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
p->drawPixmapFragments(pixmapData.data(), d->particles.count(), d->image);
+#else
+ qDrawPixmaps(p, pixmapData.data(), d->particles.count(), d->image);
+#endif
}
void QDeclarativeParticles::componentComplete()
{
Q_D(QDeclarativeParticles);
QDeclarativeItem::componentComplete();
- if (d->count) {
+ if (d->count && d->emissionRate) {
d->paintItem->updateSize();
d->clock.start();
}
diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/graphicsitems/qdeclarativepath.cpp
index 48f112a..80586b8 100644
--- a/src/declarative/graphicsitems/qdeclarativepath.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepath.cpp
@@ -114,7 +114,10 @@ qreal QDeclarativePath::startX() const
void QDeclarativePath::setStartX(qreal x)
{
Q_D(QDeclarativePath);
+ if (qFuzzyCompare(x, d->startX))
+ return;
d->startX = x;
+ emit startXChanged();
}
qreal QDeclarativePath::startY() const
@@ -126,7 +129,10 @@ qreal QDeclarativePath::startY() const
void QDeclarativePath::setStartY(qreal y)
{
Q_D(QDeclarativePath);
+ if (qFuzzyCompare(y, d->startY))
+ return;
d->startY = y;
+ emit startYChanged();
}
/*!
@@ -522,7 +528,10 @@ QString QDeclarativePathAttribute::name() const
void QDeclarativePathAttribute::setName(const QString &name)
{
- _name = name;
+ if (_name == name)
+ return;
+ _name = name;
+ emit nameChanged();
}
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativepath_p.h b/src/declarative/graphicsitems/qdeclarativepath_p.h
index b3139f8..d7cfca1 100644
--- a/src/declarative/graphicsitems/qdeclarativepath_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepath_p.h
@@ -67,7 +67,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativePathAttribute : public QDeclarativePathEl
{
Q_OBJECT
- Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY changed)
public:
QDeclarativePathAttribute(QObject *parent=0) : QDeclarativePathElement(parent), _value(0) {}
@@ -79,6 +79,9 @@ public:
qreal value() const;
void setValue(qreal value);
+Q_SIGNALS:
+ void nameChanged();
+
private:
QString _name;
qreal _value;
@@ -190,8 +193,8 @@ class Q_DECLARATIVE_EXPORT QDeclarativePath : public QObject, public QDeclarativ
Q_INTERFACES(QDeclarativeParserStatus)
Q_PROPERTY(QDeclarativeListProperty<QDeclarativePathElement> pathElements READ pathElements)
- Q_PROPERTY(qreal startX READ startX WRITE setStartX)
- Q_PROPERTY(qreal startY READ startY WRITE setStartY)
+ Q_PROPERTY(qreal startX READ startX WRITE setStartX NOTIFY startXChanged)
+ Q_PROPERTY(qreal startY READ startY WRITE setStartY NOTIFY startYChanged)
Q_PROPERTY(bool closed READ isClosed NOTIFY changed)
Q_CLASSINFO("DefaultProperty", "pathElements")
Q_INTERFACES(QDeclarativeParserStatus)
@@ -216,6 +219,8 @@ public:
Q_SIGNALS:
void changed();
+ void startXChanged();
+ void startYChanged();
protected:
virtual void componentComplete();
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index c131f4c..cc17157 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -44,7 +44,6 @@
#include <qdeclarativestate_p.h>
#include <qdeclarativeopenmetaobject_p.h>
-
#include <QDebug>
#include <QEvent>
#include <qlistmodelinterface_p.h>
@@ -64,57 +63,52 @@ inline qreal qmlMod(qreal x, qreal y)
return fmod(x, y);
}
+static QDeclarativeOpenMetaObjectType *qPathViewAttachedType = 0;
-class QDeclarativePathViewAttached : public QObject
+QDeclarativePathViewAttached::QDeclarativePathViewAttached(QObject *parent)
+: QObject(parent), m_view(0), m_onPath(false), m_isCurrent(false)
{
- Q_OBJECT
-
- Q_PROPERTY(bool onPath READ isOnPath NOTIFY onPathChanged)
-public:
- QDeclarativePathViewAttached(QObject *parent)
- : QObject(parent), mo(new QDeclarativeOpenMetaObject(this)), onPath(false)
- {
- }
-
- ~QDeclarativePathViewAttached()
- {
- QDeclarativePathView::attachedProperties.remove(parent());
- }
-
- QVariant value(const QByteArray &name) const
- {
- return mo->value(name);
- }
- void setValue(const QByteArray &name, const QVariant &val)
- {
- mo->setValue(name, val);
- }
-
- bool isOnPath() const { return onPath; }
- void setOnPath(bool on) {
- if (on != onPath) {
- onPath = on;
- emit onPathChanged();
- }
+ if (qPathViewAttachedType) {
+ m_metaobject = new QDeclarativeOpenMetaObject(this, qPathViewAttachedType);
+ m_metaobject->setCached(true);
+ } else {
+ m_metaobject = new QDeclarativeOpenMetaObject(this);
}
+}
-Q_SIGNALS:
- void onPathChanged();
-
-private:
- QDeclarativeOpenMetaObject *mo;
- bool onPath;
-};
+QDeclarativePathViewAttached::~QDeclarativePathViewAttached()
+{
+}
+QVariant QDeclarativePathViewAttached::value(const QByteArray &name) const
+{
+ return m_metaobject->value(name);
+}
+void QDeclarativePathViewAttached::setValue(const QByteArray &name, const QVariant &val)
+{
+ m_metaobject->setValue(name, val);
+}
QDeclarativeItem *QDeclarativePathViewPrivate::getItem(int modelIndex)
{
Q_Q(QDeclarativePathView);
requestedIndex = modelIndex;
- QDeclarativeItem *item = model->item(modelIndex);
+ QDeclarativeItem *item = model->item(modelIndex, false);
if (item) {
- if (QObject *obj = QDeclarativePathView::qmlAttachedProperties(item))
- static_cast<QDeclarativePathViewAttached *>(obj)->setOnPath(true);
+ if (!attType) {
+ // pre-create one metatype to share with all attached objects
+ attType = new QDeclarativeOpenMetaObjectType(&QDeclarativePathViewAttached::staticMetaObject, qmlEngine(q));
+ foreach(const QString &attr, path->attributes()) {
+ attType->createProperty(attr.toUtf8());
+ }
+ }
+ qPathViewAttachedType = attType;
+ QDeclarativePathViewAttached *att = static_cast<QDeclarativePathViewAttached *>(qmlAttachedPropertiesObject<QDeclarativePathView>(item));
+ qPathViewAttachedType = 0;
+ if (att) {
+ att->m_view = q;
+ att->setOnPath(true);
+ }
item->setParentItem(q);
}
requestedIndex = -1;
@@ -125,14 +119,26 @@ void QDeclarativePathViewPrivate::releaseItem(QDeclarativeItem *item)
{
if (!item || !model)
return;
- if (QObject *obj = QDeclarativePathView::qmlAttachedProperties(item))
- static_cast<QDeclarativePathViewAttached *>(obj)->setOnPath(false);
- if (model->release(item) == 0) {
- if (QObject *obj = QDeclarativePathView::qmlAttachedProperties(item))
- static_cast<QDeclarativePathViewAttached *>(obj)->setOnPath(false);
+ if (QDeclarativePathViewAttached *att = attached(item))
+ att->setOnPath(false);
+ model->release(item);
+}
+
+QDeclarativePathViewAttached *QDeclarativePathViewPrivate::attached(QDeclarativeItem *item)
+{
+ return static_cast<QDeclarativePathViewAttached *>(qmlAttachedPropertiesObject<QDeclarativePathView>(item, false));
+}
+
+void QDeclarativePathViewPrivate::clear()
+{
+ for (int i=0; i<items.count(); i++){
+ QDeclarativeItem *p = items[i];
+ releaseItem(p);
}
+ items.clear();
}
+
/*!
\qmlclass PathView QDeclarativePathView
\since 4.7
@@ -147,6 +153,11 @@ void QDeclarativePathViewPrivate::releaseItem(QDeclarativeItem *item)
\image pathview.gif
+ Note that views do not enable \e clip automatically. If the view
+ is not clipped by another item or the screen, it will be necessary
+ to set \e {clip: true} in order to have the out of view items clipped
+ nicely.
+
\sa Path
*/
@@ -160,6 +171,9 @@ QDeclarativePathView::QDeclarativePathView(QDeclarativeItem *parent)
QDeclarativePathView::~QDeclarativePathView()
{
Q_D(QDeclarativePathView);
+ d->clear();
+ if (d->attType)
+ d->attType->release();
if (d->ownModel)
delete d->model;
}
@@ -185,6 +199,15 @@ QDeclarativePathView::~QDeclarativePathView()
*/
/*!
+ \qmlattachedproperty bool PathView::isCurrentItem
+ This attached property is true if this delegate is the current item; otherwise false.
+
+ It is attached to each instance of the delegate.
+
+ This property may be used to adjust the appearance of the current item.
+*/
+
+/*!
\qmlproperty model PathView::model
This property holds the model providing data for the view.
@@ -203,6 +226,9 @@ QVariant QDeclarativePathView::model() const
void QDeclarativePathView::setModel(const QVariant &model)
{
Q_D(QDeclarativePathView);
+ if (d->modelVariant == model)
+ return;
+
if (d->model) {
disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
@@ -242,6 +268,7 @@ void QDeclarativePathView::setModel(const QVariant &model)
d->pathOffset = 0;
d->regenerate();
d->fixOffset();
+ emit modelChanged();
}
/*!
@@ -269,9 +296,19 @@ QDeclarativePath *QDeclarativePathView::path() const
void QDeclarativePathView::setPath(QDeclarativePath *path)
{
Q_D(QDeclarativePathView);
+ if (d->path == path)
+ return;
+ if (d->path)
+ disconnect(d->path, SIGNAL(changed()), this, SLOT(refill()));
d->path = path;
connect(d->path, SIGNAL(changed()), this, SLOT(refill()));
+ d->clear();
+ if (d->attType) {
+ d->attType->release();
+ d->attType = 0;
+ }
d->regenerate();
+ emit pathChanged();
}
/*!
@@ -290,12 +327,25 @@ void QDeclarativePathView::setCurrentIndex(int idx)
if (d->model && d->model->count())
idx = qAbs(idx % d->model->count());
if (d->model && idx != d->currentIndex) {
+ if (d->model->count()) {
+ int itemIndex = (d->currentIndex - d->firstIndex + d->model->count()) % d->model->count();
+ if (itemIndex < d->items.count()) {
+ if (QDeclarativeItem *item = d->items.at(d->currentIndex)) {
+ if (QDeclarativePathViewAttached *att = d->attached(item))
+ att->setIsCurrentItem(false);
+ }
+ }
+ }
d->currentIndex = idx;
if (d->model->count()) {
d->snapToCurrent();
int itemIndex = (idx - d->firstIndex + d->model->count()) % d->model->count();
- if (itemIndex < d->items.count())
- d->items.at(itemIndex)->setFocus(true);
+ if (itemIndex < d->items.count()) {
+ QDeclarativeItem *item = d->items.at(itemIndex);
+ item->setFocus(true);
+ if (QDeclarativePathViewAttached *att = d->attached(item))
+ att->setIsCurrentItem(true);
+ }
}
emit currentIndexChanged();
}
@@ -333,7 +383,7 @@ void QDeclarativePathViewPrivate::setOffset(qreal o)
/*!
\qmlproperty real PathView::snapPosition
- This property determines the position (0-100) the nearest item will snap to.
+ This property determines the position (0.0-1.0) the nearest item will snap to.
*/
qreal QDeclarativePathView::snapPosition() const
{
@@ -344,8 +394,12 @@ qreal QDeclarativePathView::snapPosition() const
void QDeclarativePathView::setSnapPosition(qreal pos)
{
Q_D(QDeclarativePathView);
- d->snapPos = pos/100;
+ qreal normalizedPos = pos - int(pos);
+ if (qFuzzyCompare(normalizedPos, d->snapPos))
+ return;
+ d->snapPos = normalizedPos;
d->fixOffset();
+ emit snapPositionChanged();
}
/*!
@@ -365,7 +419,10 @@ qreal QDeclarativePathView::dragMargin() const
void QDeclarativePathView::setDragMargin(qreal dragMargin)
{
Q_D(QDeclarativePathView);
+ if (d->dragMargin == dragMargin)
+ return;
d->dragMargin = dragMargin;
+ emit dragMarginChanged();
}
/*!
@@ -392,16 +449,19 @@ QDeclarativeComponent *QDeclarativePathView::delegate() const
return 0;
}
-void QDeclarativePathView::setDelegate(QDeclarativeComponent *c)
+void QDeclarativePathView::setDelegate(QDeclarativeComponent *delegate)
{
Q_D(QDeclarativePathView);
+ if (delegate == this->delegate())
+ return;
if (!d->ownModel) {
d->model = new QDeclarativeVisualDataModel(qmlContext(this));
d->ownModel = true;
}
if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) {
- dataModel->setDelegate(c);
+ dataModel->setDelegate(delegate);
d->regenerate();
+ emit delegateChanged();
}
}
@@ -422,6 +482,7 @@ void QDeclarativePathView::setPathItemCount(int i)
return;
d->pathItems = i;
d->regenerate();
+ pathItemCountChanged();
}
QPointF QDeclarativePathViewPrivate::pointNear(const QPointF &point, qreal *nearPercent) const
@@ -631,11 +692,7 @@ void QDeclarativePathViewPrivate::regenerate()
if (!q->isComponentComplete())
return;
- for (int i=0; i<items.count(); i++){
- QDeclarativeItem *p = items[i];
- releaseItem(p);
- }
- items.clear();
+ clear();
if (!isValid())
return;
@@ -655,17 +712,25 @@ void QDeclarativePathViewPrivate::regenerate()
}
items.append(item);
item->setZValue(i);
- if (currentIndex == index)
+ qreal percent = i * (100. / numItems) + _offset;
+ percent = qAbs(qmlMod(percent, qreal(100.0))/100.0);
+ updateItem(item, percent);
+ model->completeItem();
+ if (currentIndex == index) {
item->setFocus(true);
+ if (QDeclarativePathViewAttached *att = attached(item))
+ att->setIsCurrentItem(true);
+ }
}
- q->refill();
+ if (pathItems != -1)
+ q->refill();
}
void QDeclarativePathViewPrivate::updateItem(QDeclarativeItem *item, qreal percent)
{
- if (QObject *obj = QDeclarativePathView::qmlAttachedProperties(item)) {
+ if (QDeclarativePathViewAttached *att = attached(item)) {
foreach(const QString &attr, path->attributes())
- static_cast<QDeclarativePathViewAttached *>(obj)->setValue(attr.toUtf8(), path->attributeAt(attr, percent));
+ att->setValue(attr.toUtf8(), path->attributeAt(attr, percent));
}
QPointF pf = path->pointAt(percent);
item->setX(pf.x() - item->width()*item->scale()/2);
@@ -715,8 +780,12 @@ void QDeclarativePathView::refill()
int index = (d->firstIndex + d->items.count())%d->model->count();
QDeclarativeItem *item = d->getItem(index);
item->setZValue(wrapIndex);
- if (d->currentIndex == index)
+ d->model->completeItem();
+ if (d->currentIndex == index) {
item->setFocus(true);
+ if (QDeclarativePathViewAttached *att = d->attached(item))
+ att->setIsCurrentItem(true);
+ }
d->items << item;
d->pathOffset++;
d->pathOffset=d->pathOffset % d->items.count();
@@ -731,8 +800,12 @@ void QDeclarativePathView::refill()
d->firstIndex = d->model->count() - 1;
QDeclarativeItem *item = d->getItem(d->firstIndex);
item->setZValue(d->firstIndex);
- if (d->currentIndex == d->firstIndex)
+ d->model->completeItem();
+ if (d->currentIndex == d->firstIndex) {
item->setFocus(true);
+ if (QDeclarativePathViewAttached *att = d->attached(item))
+ att->setIsCurrentItem(true);
+ }
d->items.prepend(item);
d->pathOffset--;
if (d->pathOffset < 0)
@@ -757,6 +830,7 @@ void QDeclarativePathView::itemsInserted(int modelIndex, int count)
for (int i = 0; i < count; ++i) {
QDeclarativeItem *item = d->getItem(modelIndex + i);
item->setZValue(modelIndex + i);
+ d->model->completeItem();
d->items.insert(modelIndex + i, item);
}
refill();
@@ -887,10 +961,21 @@ void QDeclarativePathViewPrivate::updateCurrent()
return;
int idx = calcCurrentIndex();
if (model && idx != currentIndex) {
+ int itemIndex = (currentIndex - firstIndex + model->count()) % model->count();
+ if (itemIndex < items.count()) {
+ if (QDeclarativeItem *item = items.at(itemIndex)) {
+ if (QDeclarativePathViewAttached *att = attached(item))
+ att->setIsCurrentItem(false);
+ }
+ }
currentIndex = idx;
- int itemIndex = (idx - firstIndex + model->count()) % model->count();
- if (itemIndex < items.count())
- items.at(itemIndex)->setFocus(true);
+ itemIndex = (idx - firstIndex + model->count()) % model->count();
+ if (itemIndex < items.count()) {
+ QDeclarativeItem *item = items.at(itemIndex);
+ item->setFocus(true);
+ if (QDeclarativePathViewAttached *att = attached(item))
+ att->setIsCurrentItem(true);
+ }
emit q->currentIndexChanged();
}
}
@@ -971,17 +1056,10 @@ void QDeclarativePathViewPrivate::snapToCurrent()
}
}
-QHash<QObject*, QObject*> QDeclarativePathView::attachedProperties;
-QObject *QDeclarativePathView::qmlAttachedProperties(QObject *obj)
+QDeclarativePathViewAttached *QDeclarativePathView::qmlAttachedProperties(QObject *obj)
{
- QObject *rv = attachedProperties.value(obj);
- if (!rv) {
- rv = new QDeclarativePathViewAttached(obj);
- attachedProperties.insert(obj, rv);
- }
- return rv;
+ return new QDeclarativePathViewAttached(obj);
}
QT_END_NAMESPACE
-#include <qdeclarativepathview.moc>
diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p.h
index 709a4fc..6dbd044 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepathview_p.h
@@ -52,19 +52,20 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QDeclarativePathViewPrivate;
+class QDeclarativePathViewAttached;
class Q_DECLARATIVE_EXPORT QDeclarativePathView : public QDeclarativeItem
{
Q_OBJECT
- Q_PROPERTY(QVariant model READ model WRITE setModel)
- Q_PROPERTY(QDeclarativePath *path READ path WRITE setPath)
+ Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
+ Q_PROPERTY(QDeclarativePath *path READ path WRITE setPath NOTIFY pathChanged)
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
Q_PROPERTY(qreal offset READ offset WRITE setOffset NOTIFY offsetChanged)
- Q_PROPERTY(qreal snapPosition READ snapPosition WRITE setSnapPosition)
- Q_PROPERTY(qreal dragMargin READ dragMargin WRITE setDragMargin)
+ Q_PROPERTY(qreal snapPosition READ snapPosition WRITE setSnapPosition NOTIFY snapPositionChanged)
+ Q_PROPERTY(qreal dragMargin READ dragMargin WRITE setDragMargin NOTIFY dragMarginChanged)
Q_PROPERTY(int count READ count)
- Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate)
- Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount)
+ Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
+ Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount NOTIFY pathItemCountChanged)
public:
QDeclarativePathView(QDeclarativeItem *parent=0);
@@ -96,11 +97,17 @@ public:
int pathItemCount() const;
void setPathItemCount(int);
- static QObject *qmlAttachedProperties(QObject *);
+ static QDeclarativePathViewAttached *qmlAttachedProperties(QObject *);
Q_SIGNALS:
void currentIndexChanged();
void offsetChanged();
+ void modelChanged();
+ void pathChanged();
+ void dragMarginChanged();
+ void snapPositionChanged();
+ void delegateChanged();
+ void pathItemCountChanged();
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
@@ -121,11 +128,57 @@ private Q_SLOTS:
private:
friend class QDeclarativePathViewAttached;
- static QHash<QObject*, QObject*> attachedProperties;
Q_DISABLE_COPY(QDeclarativePathView)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativePathView)
};
+class QDeclarativeOpenMetaObject;
+class QDeclarativePathViewAttached : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QDeclarativePathView *view READ view CONSTANT)
+ Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged)
+ Q_PROPERTY(bool onPath READ isOnPath NOTIFY pathChanged)
+
+public:
+ QDeclarativePathViewAttached(QObject *parent);
+ ~QDeclarativePathViewAttached();
+
+ QDeclarativePathView *view() { return m_view; }
+
+ bool isCurrentItem() const { return m_isCurrent; }
+ void setIsCurrentItem(bool c) {
+ if (m_isCurrent != c) {
+ m_isCurrent = c;
+ emit currentItemChanged();
+ }
+ }
+
+ QVariant value(const QByteArray &name) const;
+ void setValue(const QByteArray &name, const QVariant &val);
+
+ bool isOnPath() const { return m_onPath; }
+ void setOnPath(bool on) {
+ if (on != m_onPath) {
+ m_onPath = on;
+ emit pathChanged();
+ }
+ }
+
+Q_SIGNALS:
+ void currentItemChanged();
+ void pathChanged();
+
+private:
+ friend class QDeclarativePathViewPrivate;
+ QDeclarativePathView *m_view;
+ QDeclarativeOpenMetaObject *m_metaobject;
+ bool m_onPath : 1;
+ bool m_isCurrent : 1;
+};
+
+
QT_END_NAMESPACE
QML_DECLARE_TYPE(QDeclarativePathView)
diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h
index ca50910..4083ab5 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h
@@ -60,6 +60,7 @@
#include <qdeclarative.h>
#include <qdeclarativeanimation_p_p.h>
+#include <qdeclarativeguard_p.h>
#include <qdatetime.h>
@@ -70,6 +71,8 @@ typedef struct PathViewItem{
QDeclarativeItem* item;
}PathViewItem;
+class QDeclarativeOpenMetaObjectType;
+class QDeclarativePathViewAttached;
class QDeclarativePathViewPrivate : public QDeclarativeItemPrivate
{
Q_DECLARE_PUBLIC(QDeclarativePathView)
@@ -80,7 +83,7 @@ public:
, lastElapsed(0), stealMouse(false), ownModel(false), activeItem(0)
, snapPos(0), dragMargin(0), moveOffset(this, &QDeclarativePathViewPrivate::setOffset)
, firstIndex(0), pathItems(-1), pathOffset(0), requestedIndex(-1)
- , moveReason(Other)
+ , moveReason(Other), attType(0)
{
}
@@ -96,6 +99,8 @@ public:
QDeclarativeItem *getItem(int modelIndex);
void releaseItem(QDeclarativeItem *item);
+ QDeclarativePathViewAttached *attached(QDeclarativeItem *item);
+ void clear();
bool isValid() const {
return model && model->count() > 0 && model->isValid() && path;
@@ -132,10 +137,11 @@ public:
int pathOffset;
int requestedIndex;
QList<QDeclarativeItem *> items;
- QGuard<QDeclarativeVisualModel> model;
+ QDeclarativeGuard<QDeclarativeVisualModel> model;
QVariant modelVariant;
enum MovementReason { Other, Key, Mouse };
MovementReason moveReason;
+ QDeclarativeOpenMetaObjectType *attType;
};
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p.h
index ff6fc4b..f38847c 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepositioners_p.h
@@ -44,7 +44,7 @@
#include "qdeclarativeitem.h"
-#include "../util/qdeclarativestate_p.h"
+#include <private/qdeclarativestate_p.h>
#include <private/qpodvector_p.h>
#include <QtCore/QObject>
diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
index d534f21..207d05e 100644
--- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
@@ -180,9 +180,6 @@ void QDeclarativeGradient::doUpdate()
QDeclarativeRectangle::QDeclarativeRectangle(QDeclarativeItem *parent)
: QDeclarativeItem(*(new QDeclarativeRectanglePrivate), parent)
{
- Q_D(QDeclarativeRectangle);
- d->init();
- setFlag(QGraphicsItem::ItemHasNoContents, false);
}
void QDeclarativeRectangle::doUpdate()
@@ -393,9 +390,10 @@ void QDeclarativeRectangle::paint(QPainter *p, const QStyleOptionGraphicsItem *,
void QDeclarativeRectangle::drawRect(QPainter &p)
{
Q_D(QDeclarativeRectangle);
- if (d->gradient && d->gradient->gradient()) {
+ if ((d->gradient && d->gradient->gradient())
+ || d->radius > width()/2 || d->radius > height()/2) {
// XXX This path is still slower than the image path
- // Image path won't work for gradients though
+ // Image path won't work for gradients or invalid radius though
bool oldAA = p.testRenderHint(QPainter::Antialiasing);
if (d->smooth)
p.setRenderHint(QPainter::Antialiasing);
@@ -405,11 +403,23 @@ void QDeclarativeRectangle::drawRect(QPainter &p)
} else {
p.setPen(Qt::NoPen);
}
- p.setBrush(*d->gradient->gradient());
- if (d->radius > 0.)
- p.drawRoundedRect(0, 0, width(), height(), d->radius, d->radius);
+ if (d->gradient && d->gradient->gradient())
+ p.setBrush(*d->gradient->gradient());
+ else
+ p.setBrush(d->color);
+ const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0;
+ QRectF rect;
+ if (pw%2)
+ rect = QRectF(0.5, 0.5, width()-1, height()-1);
+ else
+ rect = QRectF(0, 0, width(), height());
+ qreal radius = d->radius;
+ if (radius > width()/2 || radius > height()/2)
+ radius = qMin(width()/2, height()/2);
+ if (radius > 0.)
+ p.drawRoundedRect(rect, radius, radius);
else
- p.drawRect(0, 0, width(), height());
+ p.drawRect(rect);
if (d->smooth)
p.setRenderHint(QPainter::Antialiasing, oldAA);
} else {
diff --git a/src/declarative/graphicsitems/qdeclarativerectangle_p_p.h b/src/declarative/graphicsitems/qdeclarativerectangle_p_p.h
index b87c57f..6bae219 100644
--- a/src/declarative/graphicsitems/qdeclarativerectangle_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativerectangle_p_p.h
@@ -67,6 +67,7 @@ public:
QDeclarativeRectanglePrivate() :
color(Qt::white), gradient(0), pen(0), radius(0), paintmargin(0)
{
+ QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents;
}
~QDeclarativeRectanglePrivate()
@@ -74,13 +75,13 @@ public:
delete pen;
}
- void init()
- {
- }
-
- QColor getColor();
QColor color;
QDeclarativeGradient *gradient;
+ QDeclarativePen *pen;
+ qreal radius;
+ qreal paintmargin;
+ QPixmap rectImage;
+
QDeclarativePen *getPen() {
if (!pen) {
Q_Q(QDeclarativeRectangle);
@@ -89,10 +90,6 @@ public:
}
return pen;
}
- QDeclarativePen *pen;
- qreal radius;
- qreal paintmargin;
- QPixmap rectImage;
void setPaintMargin(qreal margin)
{
diff --git a/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h b/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h
index 92b3f91..fbf9040 100644
--- a/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h
@@ -44,7 +44,7 @@
#include "qdeclarativeborderimage_p.h"
-#include "../util/qdeclarativepixmapcache_p.h"
+#include <private/qdeclarativepixmapcache_p.h>
#include <qdeclarative.h>
#include <QtCore/QString>
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index ca253df..05139f6 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -110,8 +110,6 @@ QT_BEGIN_NAMESPACE
QDeclarativeText::QDeclarativeText(QDeclarativeItem *parent)
: QDeclarativeItem(*(new QDeclarativeTextPrivate), parent)
{
- setAcceptedMouseButtons(Qt::LeftButton);
- setFlag(QGraphicsItem::ItemHasNoContents, false);
}
QDeclarativeText::~QDeclarativeText()
diff --git a/src/declarative/graphicsitems/qdeclarativetext_p_p.h b/src/declarative/graphicsitems/qdeclarativetext_p_p.h
index a0c8abe..0d9a0a6 100644
--- a/src/declarative/graphicsitems/qdeclarativetext_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetext_p_p.h
@@ -70,14 +70,16 @@ class QDeclarativeTextPrivate : public QDeclarativeItemPrivate
Q_DECLARE_PUBLIC(QDeclarativeText)
public:
QDeclarativeTextPrivate()
- : color((QRgb)0), style(QDeclarativeText::Normal), imgDirty(true),
+ : color((QRgb)0), style(QDeclarativeText::Normal),
hAlign(QDeclarativeText::AlignLeft), vAlign(QDeclarativeText::AlignTop), elideMode(QDeclarativeText::ElideNone),
- dirty(true), wrap(false), richText(false), singleline(false), cache(true), doc(0),
+ imgDirty(true), dirty(true), wrap(false), richText(false), singleline(false), cache(true), doc(0),
format(QDeclarativeText::AutoText)
{
#if defined(QML_NO_TEXT_CACHE)
cache = false;
#endif
+ QGraphicsItemPrivate::acceptedMouseButtons = Qt::LeftButton;
+ QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents;
}
~QDeclarativeTextPrivate();
@@ -106,12 +108,12 @@ public:
QDeclarativeText::TextStyle style;
QColor styleColor;
QString activeLink;
- bool imgDirty;
QPixmap imgCache;
QPixmap imgStyleCache;
QDeclarativeText::HAlignment hAlign;
QDeclarativeText::VAlignment vAlign;
- QDeclarativeText::TextElideMode elideMode;
+ QDeclarativeText::TextElideMode elideMode;
+ bool imgDirty:1;
bool dirty:1;
bool wrap:1;
bool richText:1;
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index 8e44b26..be73b39 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -613,6 +613,11 @@ void QDeclarativeTextEdit::setPersistentSelection(bool on)
emit persistentSelectionChanged(d->persistentSelection);
}
+/*
+ \qmlproperty number TextEdit::textMargin
+
+ The margin, in pixels, around the text in the TextEdit.
+*/
qreal QDeclarativeTextEdit::textMargin() const
{
Q_D(const QDeclarativeTextEdit);
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index 9919904..3382628 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -704,6 +704,8 @@ bool QDeclarativeTextInput::event(QEvent* ev)
break;
default:
handled = d->control->processEvent(ev);
+ if (ev->type() == QEvent::InputMethod)
+ updateSize();
}
if(!handled)
return QDeclarativePaintedItem::event(ev);
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 2402648..6bad4da 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -53,6 +53,7 @@
#include <qdeclarativedeclarativedata_p.h>
#include <qdeclarativepropertycache_p.h>
#include <qdeclarativeguard_p.h>
+#include <qdeclarativeglobal_p.h>
#include <qlistmodelinterface_p.h>
#include <qhash.h>
@@ -80,6 +81,14 @@ public:
static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->emitChildrenChanged();
}
+ static int children_count(QDeclarativeListProperty<QDeclarativeItem> *prop) {
+ return static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->children.count();
+ }
+
+ static QDeclarativeItem *children_at(QDeclarativeListProperty<QDeclarativeItem> *prop, int index) {
+ return static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->children.at(index);
+ }
+
void itemAppended() {
Q_Q(QDeclarativeVisualItemModel);
QDeclarativeVisualItemModelAttached *attached = QDeclarativeVisualItemModelAttached::properties(children.last());
@@ -135,7 +144,8 @@ QDeclarativeVisualItemModel::QDeclarativeVisualItemModel()
QDeclarativeListProperty<QDeclarativeItem> QDeclarativeVisualItemModel::children()
{
Q_D(QDeclarativeVisualItemModel);
- return QDeclarativeListProperty<QDeclarativeItem>(this, d, QDeclarativeVisualItemModelPrivate::children_append);
+ return QDeclarativeListProperty<QDeclarativeItem>(this, d, d->children_append,
+ d->children_count, d->children_at);
}
/*!
@@ -473,7 +483,7 @@ QVariant QDeclarativeVisualDataModelDataMetaObject::initialValue(int propId)
QDeclarativeVisualDataModelData::QDeclarativeVisualDataModelData(int index,
QDeclarativeVisualDataModel *model)
-: m_index(index), m_model(model),
+: m_index(index), m_model(model),
m_meta(new QDeclarativeVisualDataModelDataMetaObject(this, QDeclarativeVisualDataModelPrivate::get(model)->m_delegateDataType))
{
QDeclarativeVisualDataModelPrivate *modelPriv = QDeclarativeVisualDataModelPrivate::get(model);
@@ -540,7 +550,7 @@ QVariant QDeclarativeVisualDataModelPartsMetaObject::initialValue(int id)
}
QDeclarativeVisualDataModelParts::QDeclarativeVisualDataModelParts(QDeclarativeVisualDataModel *parent)
-: QObject(parent), model(parent)
+: QObject(parent), model(parent)
{
new QDeclarativeVisualDataModelPartsMetaObject(this);
}
@@ -830,7 +840,7 @@ void QDeclarativeVisualDataModel::setDelegate(QDeclarativeComponent *delegate)
Rectangle {
height: 25; width: 100
Text { text: path }
- MouseRegion {
+ MouseArea {
anchors.fill: parent;
onClicked: myModel.setRoot(path)
}
@@ -917,7 +927,9 @@ QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(Q
if (inPackage) {
emit destroyingPackage(qobject_cast<QDeclarativePackage*>(obj));
} else {
- item->setVisible(false);
+ if (item->hasFocus())
+ item->clearFocus();
+ item->setOpacity(0.0);
static_cast<QGraphicsItem*>(item)->setParentItem(0);
}
stat |= Destroyed;
@@ -959,7 +971,7 @@ QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(Q
QObject *QDeclarativeVisualDataModel::parts()
{
Q_D(QDeclarativeVisualDataModel);
- if (!d->m_parts)
+ if (!d->m_parts)
d->m_parts = new QDeclarativeVisualDataModelParts(this);
return d->m_parts;
}
@@ -984,8 +996,8 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray
if (complete)
d->m_delegate->completeCreate();
if (nobj) {
- ctxt->setParent(nobj);
- data->setParent(nobj);
+ QDeclarative_setParent_noEvent(ctxt, nobj);
+ QDeclarative_setParent_noEvent(data, nobj);
d->m_cache.insertItem(index, nobj);
if (QDeclarativePackage *package = qobject_cast<QDeclarativePackage *>(nobj))
emit createdPackage(index, package);
@@ -1268,7 +1280,6 @@ void QDeclarativeVisualDataModel::_q_dataChanged(const QModelIndex &begin, const
void QDeclarativeVisualDataModel::_q_modelReset()
{
- Q_D(QDeclarativeVisualDataModel);
emit modelReset();
}
diff --git a/src/declarative/graphicsitems/qdeclarativewebview.cpp b/src/declarative/graphicsitems/qdeclarativewebview.cpp
deleted file mode 100644
index a2b16ba..0000000
--- a/src/declarative/graphicsitems/qdeclarativewebview.cpp
+++ /dev/null
@@ -1,1338 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativewebview_p.h"
-#include "qdeclarativewebview_p_p.h"
-
-#include "qdeclarativepainteditem_p_p.h"
-
-#include <qdeclarative.h>
-#include <qdeclarativeengine.h>
-#include <qdeclarativestate_p.h>
-
-#include <QDebug>
-#include <QPen>
-#include <QFile>
-#include <QEvent>
-#include <QMouseEvent>
-#include <QKeyEvent>
-#include <QBasicTimer>
-#include <QApplication>
-#include <QGraphicsSceneMouseEvent>
-#include <QtWebKit/QWebPage>
-#include <QtWebKit/QWebFrame>
-#include <QtWebKit/QWebElement>
-#include <QtWebKit/QWebSettings>
-#include <qlistmodelinterface_p.h>
-
-QT_BEGIN_NAMESPACE
-
-static const int MAX_DOUBLECLICK_TIME=500; // XXX need better gesture system
-
-class QDeclarativeWebViewPrivate : public QDeclarativePaintedItemPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeWebView)
-
-public:
- QDeclarativeWebViewPrivate()
- : QDeclarativePaintedItemPrivate(), page(0), preferredwidth(0), preferredheight(0),
- progress(1.0), status(QDeclarativeWebView::Null), pending(PendingNone),
- newWindowComponent(0), newWindowParent(0),
- pressTime(400),
- rendering(true)
- {
- }
-
- QUrl url; // page url might be different if it has not loaded yet
- QWebPage *page;
-
- int preferredwidth, preferredheight;
- qreal progress;
- QDeclarativeWebView::Status status;
- QString statusText;
- enum { PendingNone, PendingUrl, PendingHtml, PendingContent } pending;
- QUrl pending_url;
- QString pending_string;
- QByteArray pending_data;
- mutable QDeclarativeWebSettings settings;
- QDeclarativeComponent *newWindowComponent;
- QDeclarativeItem *newWindowParent;
-
- QBasicTimer pressTimer;
- QPoint pressPoint;
- int pressTime; // milliseconds before it's a "hold"
-
-
- static void windowObjects_append(QDeclarativeListProperty<QObject> *prop, QObject *o) {
- static_cast<QDeclarativeWebViewPrivate *>(prop->data)->windowObjects.append(o);
- static_cast<QDeclarativeWebViewPrivate *>(prop->data)->updateWindowObjects();
- }
-
- void updateWindowObjects();
- QObjectList windowObjects;
-
- bool rendering;
-};
-
-/*!
- \qmlclass WebView QDeclarativeWebView
- \since 4.7
- \brief The WebView item allows you to add web content to a canvas.
- \inherits Item
-
- A WebView renders web content based on a URL.
-
- If the width and height of the item is not set, they will
- dynamically adjust to a size appropriate for the content.
- This width may be large for typical online web pages.
-
- If the preferredWidth is set, the width will be this amount or larger,
- usually laying out the web content to fit the preferredWidth.
-
- \qml
- WebView {
- url: "http://www.nokia.com"
- width: 490
- height: 400
- scale: 0.5
- smooth: false
- smoothCache: true
- }
- \endqml
-
- \image webview.png
-
- The item includes no scrolling, scaling,
- toolbars, etc., those must be implemented around WebView. See the WebBrowser example
- for a demonstration of this.
-*/
-
-/*!
- \internal
- \class QDeclarativeWebView
- \brief The QDeclarativeWebView class allows you to add web content to a QDeclarativeView.
-
- A WebView renders web content base on a URL.
-
- \image webview.png
-
- The item includes no scrolling, scaling,
- toolbars, etc., those must be implemented around WebView. See the WebBrowser example
- for a demonstration of this.
-
- A QDeclarativeWebView object can be instantiated in Qml using the tag \l WebView.
-*/
-
-QDeclarativeWebView::QDeclarativeWebView(QDeclarativeItem *parent)
- : QDeclarativePaintedItem(*(new QDeclarativeWebViewPrivate), parent)
-{
- init();
-}
-
-QDeclarativeWebView::~QDeclarativeWebView()
-{
- Q_D(QDeclarativeWebView);
- delete d->page;
-}
-
-void QDeclarativeWebView::init()
-{
- Q_D(QDeclarativeWebView);
-
- QWebSettings::enablePersistentStorage();
-
- setAcceptHoverEvents(true);
- setAcceptedMouseButtons(Qt::LeftButton);
- setFlag(QGraphicsItem::ItemHasNoContents, false);
-
- d->page = 0;
-}
-
-void QDeclarativeWebView::componentComplete()
-{
- QDeclarativePaintedItem::componentComplete();
- Q_D(QDeclarativeWebView);
- switch (d->pending) {
- case QDeclarativeWebViewPrivate::PendingUrl:
- setUrl(d->pending_url);
- break;
- case QDeclarativeWebViewPrivate::PendingHtml:
- setHtml(d->pending_string, d->pending_url);
- break;
- case QDeclarativeWebViewPrivate::PendingContent:
- setContent(d->pending_data, d->pending_string, d->pending_url);
- break;
- default:
- break;
- }
- d->pending = QDeclarativeWebViewPrivate::PendingNone;
- d->updateWindowObjects();
-}
-
-QDeclarativeWebView::Status QDeclarativeWebView::status() const
-{
- Q_D(const QDeclarativeWebView);
- return d->status;
-}
-
-
-/*!
- \qmlproperty real WebView::progress
- This property holds the progress of loading the current URL, from 0 to 1.
-
- If you just want to know when progress gets to 1, use
- WebView::onLoadFinished() or WebView::onLoadFailed() instead.
-*/
-qreal QDeclarativeWebView::progress() const
-{
- Q_D(const QDeclarativeWebView);
- return d->progress;
-}
-
-void QDeclarativeWebView::doLoadStarted()
-{
- Q_D(QDeclarativeWebView);
-
- if (!d->url.isEmpty()) {
- d->status = Loading;
- emit statusChanged(d->status);
- }
- emit loadStarted();
-}
-
-void QDeclarativeWebView::doLoadProgress(int p)
-{
- Q_D(QDeclarativeWebView);
- if (d->progress == p/100.0)
- return;
- d->progress = p/100.0;
- emit progressChanged();
-}
-
-void QDeclarativeWebView::pageUrlChanged()
-{
- Q_D(QDeclarativeWebView);
-
- page()->setViewportSize(QSize(
- d->preferredwidth>0 ? d->preferredwidth : width(),
- d->preferredheight>0 ? d->preferredheight : height()));
- expandToWebPage();
-
- if ((d->url.isEmpty() && page()->mainFrame()->url() != QUrl(QLatin1String("about:blank")))
- || (d->url != page()->mainFrame()->url() && !page()->mainFrame()->url().isEmpty()))
- {
- d->url = page()->mainFrame()->url();
- if (d->url == QUrl(QLatin1String("about:blank")))
- d->url = QUrl();
- emit urlChanged();
- }
-}
-
-void QDeclarativeWebView::doLoadFinished(bool ok)
-{
- Q_D(QDeclarativeWebView);
-
- if (title().isEmpty())
- pageUrlChanged(); // XXX bug 232556 - pages with no title never get urlChanged()
-
- if (ok) {
- d->status = d->url.isEmpty() ? Null : Ready;
- emit loadFinished();
- } else {
- d->status = Error;
- emit loadFailed();
- }
- emit statusChanged(d->status);
-}
-
-/*!
- \qmlproperty url WebView::url
- This property holds the URL to the page displayed in this item. It can be set,
- but also can change spontaneously (eg. because of network redirection).
-
- If the url is empty, the page is blank.
-
- The url is always absolute (QML will resolve relative URL strings in the context
- of the containing QML document).
-*/
-QUrl QDeclarativeWebView::url() const
-{
- Q_D(const QDeclarativeWebView);
- return d->url;
-}
-
-void QDeclarativeWebView::setUrl(const QUrl &url)
-{
- Q_D(QDeclarativeWebView);
- if (url == d->url)
- return;
-
- if (isComponentComplete()) {
- d->url = url;
- page()->setViewportSize(QSize(
- d->preferredwidth>0 ? d->preferredwidth : width(),
- d->preferredheight>0 ? d->preferredheight : height()));
- QUrl seturl = url;
- if (seturl.isEmpty())
- seturl = QUrl(QLatin1String("about:blank"));
-
- Q_ASSERT(!seturl.isRelative());
-
- page()->mainFrame()->load(seturl);
-
- emit urlChanged();
- } else {
- d->pending = d->PendingUrl;
- d->pending_url = url;
- }
-}
-
-/*!
- \qmlproperty int WebView::preferredWidth
- This property holds the ideal width for displaying the current URL.
-*/
-int QDeclarativeWebView::preferredWidth() const
-{
- Q_D(const QDeclarativeWebView);
- return d->preferredwidth;
-}
-
-void QDeclarativeWebView::setPreferredWidth(int iw)
-{
- Q_D(QDeclarativeWebView);
- if (d->preferredwidth == iw) return;
- d->preferredwidth = iw;
- //expandToWebPage();
- emit preferredWidthChanged();
-}
-
-/*!
- \qmlproperty int WebView::preferredHeight
- This property holds the ideal height for displaying the current URL.
- This only affects the area zoomed by heuristicZoom().
-*/
-int QDeclarativeWebView::preferredHeight() const
-{
- Q_D(const QDeclarativeWebView);
- return d->preferredheight;
-}
-void QDeclarativeWebView::setPreferredHeight(int ih)
-{
- Q_D(QDeclarativeWebView);
- if (d->preferredheight == ih) return;
- d->preferredheight = ih;
- emit preferredHeightChanged();
-}
-
-/*!
- \qmlmethod bool WebView::evaluateJavaScript(string)
-
- Evaluates the \a scriptSource JavaScript inside the context of the
- main web frame, and returns the result of the last executed statement.
-
- Note that this JavaScript does \e not have any access to QML objects
- except as made available as windowObjects.
-*/
-QVariant QDeclarativeWebView::evaluateJavaScript(const QString &scriptSource)
-{
- return this->page()->mainFrame()->evaluateJavaScript(scriptSource);
-}
-
-void QDeclarativeWebView::focusChanged(bool hasFocus)
-{
- QFocusEvent e(hasFocus ? QEvent::FocusIn : QEvent::FocusOut);
- page()->event(&e);
- QDeclarativeItem::focusChanged(hasFocus);
-}
-
-void QDeclarativeWebView::initialLayout()
-{
- // nothing useful to do at this point
-}
-
-void QDeclarativeWebView::noteContentsSizeChanged(const QSize&)
-{
- expandToWebPage();
-}
-
-void QDeclarativeWebView::expandToWebPage()
-{
- Q_D(QDeclarativeWebView);
- QSize cs = page()->mainFrame()->contentsSize();
- if (cs.width() < d->preferredwidth)
- cs.setWidth(d->preferredwidth);
- if (cs.height() < d->preferredheight)
- cs.setHeight(d->preferredheight);
- if (widthValid())
- cs.setWidth(width());
- if (heightValid())
- cs.setHeight(height());
- if (cs != page()->viewportSize()) {
- page()->setViewportSize(cs);
- }
- if (cs != contentsSize())
- setContentsSize(cs);
-}
-
-void QDeclarativeWebView::geometryChanged(const QRectF &newGeometry,
- const QRectF &oldGeometry)
-{
- if (newGeometry.size() != oldGeometry.size())
- expandToWebPage();
- QDeclarativePaintedItem::geometryChanged(newGeometry, oldGeometry);
-}
-
-void QDeclarativeWebView::paintPage(const QRect& r)
-{
- dirtyCache(r);
- update();
-}
-
-/*!
- \qmlproperty list<object> WebView::javaScriptWindowObjects
-
- This property is a list of object that are available from within
- the webview's JavaScript context.
-
- The \a object will be inserted as a child of the frame's window
- object, under the name given by the attached property \c WebView.windowObjectName.
-
- \qml
- WebView {
- javaScriptWindowObjects: Object {
- WebView.windowObjectName: "coordinates"
- }
- }
- \endqml
-
- Properties of the object will be exposed as JavaScript properties and slots as
- JavaScript methods.
-
- If Javascript is not enabled for this page, then this property does nothing.
-*/
-QDeclarativeListProperty<QObject> QDeclarativeWebView::javaScriptWindowObjects()
-{
- Q_D(QDeclarativeWebView);
- return QDeclarativeListProperty<QObject>(this, d, &QDeclarativeWebViewPrivate::windowObjects_append);
-}
-
-QDeclarativeWebViewAttached *QDeclarativeWebView::qmlAttachedProperties(QObject *o)
-{
- return new QDeclarativeWebViewAttached(o);
-}
-
-void QDeclarativeWebViewPrivate::updateWindowObjects()
-{
- Q_Q(QDeclarativeWebView);
- if (!q->isComponentComplete() || !page)
- return;
-
- for (int ii = 0; ii < windowObjects.count(); ++ii) {
- QObject *object = windowObjects.at(ii);
- QDeclarativeWebViewAttached *attached = static_cast<QDeclarativeWebViewAttached *>(qmlAttachedPropertiesObject<QDeclarativeWebView>(object));
- if (attached && !attached->windowObjectName().isEmpty()) {
- page->mainFrame()->addToJavaScriptWindowObject(attached->windowObjectName(), object);
- }
- }
-}
-
-bool QDeclarativeWebView::renderingEnabled() const
-{
- Q_D(const QDeclarativeWebView);
- return d->rendering;
-}
-
-void QDeclarativeWebView::setRenderingEnabled(bool enabled)
-{
- Q_D(QDeclarativeWebView);
- if (d->rendering == enabled)
- return;
- d->rendering = enabled;
- emit renderingEnabledChanged();
-
- setCacheFrozen(!enabled);
- if (enabled)
- clearCache();
-}
-
-
-void QDeclarativeWebView::drawContents(QPainter *p, const QRect &r)
-{
- Q_D(QDeclarativeWebView);
- if (d->rendering)
- page()->mainFrame()->render(p,r);
-}
-
-QMouseEvent *QDeclarativeWebView::sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *e)
-{
- QEvent::Type t;
- switch(e->type()) {
- default:
- case QEvent::GraphicsSceneMousePress:
- t = QEvent::MouseButtonPress;
- break;
- case QEvent::GraphicsSceneMouseRelease:
- t = QEvent::MouseButtonRelease;
- break;
- case QEvent::GraphicsSceneMouseMove:
- t = QEvent::MouseMove;
- break;
- case QGraphicsSceneEvent::GraphicsSceneMouseDoubleClick:
- t = QEvent::MouseButtonDblClick;
- break;
- }
-
- QMouseEvent *me = new QMouseEvent(t, (e->pos()/contentsScale()).toPoint(), e->button(), e->buttons(), 0);
- return me;
-}
-
-QMouseEvent *QDeclarativeWebView::sceneHoverMoveEventToMouseEvent(QGraphicsSceneHoverEvent *e)
-{
- QEvent::Type t = QEvent::MouseMove;
-
- QMouseEvent *me = new QMouseEvent(t, (e->pos()/contentsScale()).toPoint(), Qt::NoButton, Qt::NoButton, 0);
-
- return me;
-}
-
-
-/*!
- \qmlsignal WebView::onDoubleClick(clickx,clicky)
-
- The WebView does not pass double-click events to the web engine, but rather
- emits this signals.
-*/
-
-void QDeclarativeWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
-{
- QMouseEvent *me = sceneMouseEventToMouseEvent(event);
- emit doubleClick(me->x(),me->y());
- delete me;
-}
-
-/*!
- \qmlmethod bool WebView::heuristicZoom(clickX,clickY,maxzoom)
-
- Finds a zoom that:
- \list
- \i shows a whole item
- \i includes (\a clickX, \a clickY)
- \i fits into the preferredWidth and preferredHeight
- \i zooms by no more than \a maxzoom
- \i is more than 10% above the current zoom
- \endlist
-
- If such a zoom exists, emits zoomTo(zoom,centerX,centerY) and returns true; otherwise,
- no signal is emitted and returns false.
-*/
-bool QDeclarativeWebView::heuristicZoom(int clickX, int clickY, qreal maxzoom)
-{
- Q_D(QDeclarativeWebView);
- if (contentsScale() >= maxzoom/zoomFactor())
- return false;
- qreal ozf = contentsScale();
- QRect showarea = elementAreaAt(clickX, clickY, d->preferredwidth/maxzoom, d->preferredheight/maxzoom);
- qreal z = qMin(qreal(d->preferredwidth)/showarea.width(),qreal(d->preferredheight)/showarea.height());
- if (z > maxzoom/zoomFactor())
- z = maxzoom/zoomFactor();
- if (z/ozf > 1.2) {
- QRectF r(showarea.left()*z, showarea.top()*z, showarea.width()*z, showarea.height()*z);
- emit zoomTo(z,r.x()+r.width()/2, r.y()+r.height()/2);
- return true;
- } else {
- return false;
- }
-}
-
-/*!
- \qmlproperty int WebView::pressGrabTime
-
- The number of milliseconds the user must press before the WebView
- starts passing move events through to the web engine (rather than
- letting other QML elements such as a Flickable take them).
-
- Defaults to 400ms. Set to 0 to always grab and pass move events to
- the web engine.
-*/
-int QDeclarativeWebView::pressGrabTime() const
-{
- Q_D(const QDeclarativeWebView);
- return d->pressTime;
-}
-
-void QDeclarativeWebView::setPressGrabTime(int ms)
-{
- Q_D(QDeclarativeWebView);
- if (d->pressTime == ms)
- return;
- d->pressTime = ms;
- emit pressGrabTimeChanged();
-}
-
-void QDeclarativeWebView::mousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QDeclarativeWebView);
-
- setFocus (true);
- QMouseEvent *me = sceneMouseEventToMouseEvent(event);
-
- d->pressPoint = me->pos();
- if (d->pressTime) {
- d->pressTimer.start(d->pressTime,this);
- setKeepMouseGrab(false);
- } else {
- grabMouse();
- setKeepMouseGrab(true);
- }
-
- page()->event(me);
- event->setAccepted(
-/*
- It is not correct to send the press event upwards, if it is not accepted by WebKit
- e.g. push button does not work, if done so as QGraphicsScene will not send the release event at all to WebKit
- Might be a bug in WebKit, though
- */
-#if 1 //QT_VERSION <= 0x040500 // XXX see bug 230835
- true
-#else
- me->isAccepted()
-#endif
- );
- delete me;
- if (!event->isAccepted()) {
- QDeclarativePaintedItem::mousePressEvent(event);
- }
-}
-
-void QDeclarativeWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QDeclarativeWebView);
-
- QMouseEvent *me = sceneMouseEventToMouseEvent(event);
- page()->event(me);
- d->pressTimer.stop();
- event->setAccepted(
-/*
- It is not correct to send the press event upwards, if it is not accepted by WebKit
- e.g. push button does not work, if done so as QGraphicsScene will not send all the events to WebKit
- */
-#if 1 //QT_VERSION <= 0x040500 // XXX see bug 230835
- true
-#else
- me->isAccepted()
-#endif
- );
- delete me;
- if (!event->isAccepted()) {
- QDeclarativePaintedItem::mouseReleaseEvent(event);
- }
- setKeepMouseGrab(false);
- ungrabMouse();
-}
-
-void QDeclarativeWebView::timerEvent(QTimerEvent *event)
-{
- Q_D(QDeclarativeWebView);
- if (event->timerId() == d->pressTimer.timerId()) {
- d->pressTimer.stop();
- grabMouse();
- setKeepMouseGrab(true);
- }
-}
-
-void QDeclarativeWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QDeclarativeWebView);
-
- QMouseEvent *me = sceneMouseEventToMouseEvent(event);
- if (d->pressTimer.isActive()) {
- if ((me->pos() - d->pressPoint).manhattanLength() > QApplication::startDragDistance()) {
- d->pressTimer.stop();
- }
- }
- if (keepMouseGrab()) {
- page()->event(me);
- event->setAccepted(
-/*
- It is not correct to send the press event upwards, if it is not accepted by WebKit
- e.g. push button does not work, if done so as QGraphicsScene will not send the release event at all to WebKit
- Might be a bug in WebKit, though
- */
-#if 1 // QT_VERSION <= 0x040500 // XXX see bug 230835
- true
-#else
- me->isAccepted()
-#endif
- );
- }
- delete me;
- if (!event->isAccepted())
- QDeclarativePaintedItem::mouseMoveEvent(event);
-
-}
-void QDeclarativeWebView::hoverMoveEvent (QGraphicsSceneHoverEvent * event)
-{
- QMouseEvent *me = sceneHoverMoveEventToMouseEvent(event);
- page()->event(me);
- event->setAccepted(
-#if QT_VERSION <= 0x040500 // XXX see bug 230835
- true
-#else
- me->isAccepted()
-#endif
- );
- delete me;
- if (!event->isAccepted())
- QDeclarativePaintedItem::hoverMoveEvent(event);
-}
-
-void QDeclarativeWebView::keyPressEvent(QKeyEvent* event)
-{
- page()->event(event);
- if (!event->isAccepted())
- QDeclarativePaintedItem::keyPressEvent(event);
-}
-
-void QDeclarativeWebView::keyReleaseEvent(QKeyEvent* event)
-{
- page()->event(event);
- if (!event->isAccepted())
- QDeclarativePaintedItem::keyReleaseEvent(event);
-}
-
-bool QDeclarativeWebView::sceneEvent(QEvent *event)
-{
- if (event->type() == QEvent::KeyPress) {
- QKeyEvent *k = static_cast<QKeyEvent *>(event);
- if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) {
- if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
- page()->event(event);
- if (event->isAccepted())
- return true;
- }
- }
- }
- return QDeclarativePaintedItem::sceneEvent(event);
-}
-
-
-/*!
- \qmlproperty action WebView::back
- This property holds the action for causing the previous URL in the history to be displayed.
-*/
-QAction *QDeclarativeWebView::backAction() const
-{
- return page()->action(QWebPage::Back);
-}
-
-/*!
- \qmlproperty action WebView::forward
- This property holds the action for causing the next URL in the history to be displayed.
-*/
-QAction *QDeclarativeWebView::forwardAction() const
-{
- return page()->action(QWebPage::Forward);
-}
-
-/*!
- \qmlproperty action WebView::reload
- This property holds the action for reloading with the current URL
-*/
-QAction *QDeclarativeWebView::reloadAction() const
-{
- return page()->action(QWebPage::Reload);
-}
-
-/*!
- \qmlproperty action WebView::stop
- This property holds the action for stopping loading with the current URL
-*/
-QAction *QDeclarativeWebView::stopAction() const
-{
- return page()->action(QWebPage::Stop);
-}
-
-/*!
- \qmlproperty real WebView::title
- This property holds the title of the web page currently viewed
-
- By default, this property contains an empty string.
-*/
-QString QDeclarativeWebView::title() const
-{
- return page()->mainFrame()->title();
-}
-
-
-
-/*!
- \qmlproperty pixmap WebView::icon
- This property holds the icon associated with the web page currently viewed
-*/
-QPixmap QDeclarativeWebView::icon() const
-{
- return page()->mainFrame()->icon().pixmap(QSize(256,256));
-}
-
-
-/*!
- \qmlproperty real WebView::zoomFactor
- This property holds the multiplier used to scale the contents of a Web page.
-*/
-void QDeclarativeWebView::setZoomFactor(qreal factor)
-{
- Q_D(QDeclarativeWebView);
- if (factor == page()->mainFrame()->zoomFactor())
- return;
-
- page()->mainFrame()->setZoomFactor(factor);
- page()->setViewportSize(QSize(
- d->preferredwidth>0 ? d->preferredwidth*factor : width()*factor,
- d->preferredheight>0 ? d->preferredheight*factor : height()*factor));
- expandToWebPage();
-
- emit zoomFactorChanged();
-}
-
-qreal QDeclarativeWebView::zoomFactor() const
-{
- return page()->mainFrame()->zoomFactor();
-}
-
-/*!
- \qmlproperty string WebView::statusText
-
- This property is the current status suggested by the current web page. In a web browser,
- such status is often shown in some kind of status bar.
-*/
-void QDeclarativeWebView::setStatusText(const QString& s)
-{
- Q_D(QDeclarativeWebView);
- d->statusText = s;
- emit statusTextChanged();
-}
-
-void QDeclarativeWebView::windowObjectCleared()
-{
- Q_D(QDeclarativeWebView);
- d->updateWindowObjects();
-}
-
-QString QDeclarativeWebView::statusText() const
-{
- Q_D(const QDeclarativeWebView);
- return d->statusText;
-}
-
-QWebPage *QDeclarativeWebView::page() const
-{
- Q_D(const QDeclarativeWebView);
-
- if (!d->page) {
- QDeclarativeWebView *self = const_cast<QDeclarativeWebView*>(this);
- QWebPage *wp = new QDeclarativeWebPage(self);
-
- // QML items don't default to having a background,
- // even though most we pages will set one anyway.
- QPalette pal = QApplication::palette();
- pal.setBrush(QPalette::Base, QColor::fromRgbF(0, 0, 0, 0));
- wp->setPalette(pal);
-
- wp->setNetworkAccessManager(qmlEngine(this)->networkAccessManager());
-
- self->setPage(wp);
-
- return wp;
- }
-
- return d->page;
-}
-
-
-// The QObject interface to settings().
-/*!
- \qmlproperty string WebView::settings.standardFontFamily
- \qmlproperty string WebView::settings.fixedFontFamily
- \qmlproperty string WebView::settings.serifFontFamily
- \qmlproperty string WebView::settings.sansSerifFontFamily
- \qmlproperty string WebView::settings.cursiveFontFamily
- \qmlproperty string WebView::settings.fantasyFontFamily
-
- \qmlproperty int WebView::settings.minimumFontSize
- \qmlproperty int WebView::settings.minimumLogicalFontSize
- \qmlproperty int WebView::settings.defaultFontSize
- \qmlproperty int WebView::settings.defaultFixedFontSize
-
- \qmlproperty bool WebView::settings.autoLoadImages
- \qmlproperty bool WebView::settings.javascriptEnabled
- \qmlproperty bool WebView::settings.javaEnabled
- \qmlproperty bool WebView::settings.pluginsEnabled
- \qmlproperty bool WebView::settings.privateBrowsingEnabled
- \qmlproperty bool WebView::settings.javascriptCanOpenWindows
- \qmlproperty bool WebView::settings.javascriptCanAccessClipboard
- \qmlproperty bool WebView::settings.developerExtrasEnabled
- \qmlproperty bool WebView::settings.linksIncludedInFocusChain
- \qmlproperty bool WebView::settings.zoomTextOnly
- \qmlproperty bool WebView::settings.printElementBackgrounds
- \qmlproperty bool WebView::settings.offlineStorageDatabaseEnabled
- \qmlproperty bool WebView::settings.offlineWebApplicationCacheEnabled
- \qmlproperty bool WebView::settings.localStorageDatabaseEnabled
- \qmlproperty bool WebView::settings.localContentCanAccessRemoteUrls
-
- These properties give access to the settings controlling the web view.
-
- See QWebSettings for details of these properties.
-
- \qml
- WebView {
- settings.pluginsEnabled: true
- settings.standardFontFamily: "Arial"
- ...
- }
- \endqml
-*/
-QDeclarativeWebSettings *QDeclarativeWebView::settingsObject() const
-{
- Q_D(const QDeclarativeWebView);
- d->settings.s = page()->settings();
- return &d->settings;
-}
-
-void QDeclarativeWebView::setPage(QWebPage *page)
-{
- Q_D(QDeclarativeWebView);
- if (d->page == page)
- return;
- if (d->page) {
- if (d->page->parent() == this) {
- delete d->page;
- } else {
- d->page->disconnect(this);
- }
- }
- d->page = page;
- d->page->setViewportSize(QSize(
- d->preferredwidth>0 ? d->preferredwidth : width(),
- d->preferredheight>0 ? d->preferredheight : height()));
- d->page->mainFrame()->setScrollBarPolicy(Qt::Horizontal,Qt::ScrollBarAlwaysOff);
- d->page->mainFrame()->setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff);
- connect(d->page,SIGNAL(repaintRequested(QRect)),this,SLOT(paintPage(QRect)));
- connect(d->page->mainFrame(),SIGNAL(urlChanged(QUrl)),this,SLOT(pageUrlChanged()));
- connect(d->page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString)));
- connect(d->page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(iconChanged()));
- connect(d->page->mainFrame(), SIGNAL(iconChanged()), this, SIGNAL(iconChanged()));
- connect(d->page->mainFrame(), SIGNAL(contentsSizeChanged(QSize)), this, SLOT(noteContentsSizeChanged(QSize)));
- connect(d->page->mainFrame(), SIGNAL(initialLayoutCompleted()), this, SLOT(initialLayout()));
-
- connect(d->page,SIGNAL(loadStarted()),this,SLOT(doLoadStarted()));
- connect(d->page,SIGNAL(loadProgress(int)),this,SLOT(doLoadProgress(int)));
- connect(d->page,SIGNAL(loadFinished(bool)),this,SLOT(doLoadFinished(bool)));
- connect(d->page,SIGNAL(statusBarMessage(QString)),this,SLOT(setStatusText(QString)));
-
- connect(d->page->mainFrame(),SIGNAL(javaScriptWindowObjectCleared()),this,SLOT(windowObjectCleared()));
-}
-
-/*!
- \qmlsignal WebView::onLoadStarted()
-
- This handler is called when the web engine begins loading
- a page. Later, WebView::onLoadFinished() or WebView::onLoadFailed()
- will be emitted.
-*/
-
-/*!
- \qmlsignal WebView::onLoadFinished()
-
- This handler is called when the web engine \e successfully
- finishes loading a page, including any component content
- (WebView::onLoadFailed() will be emitted otherwise).
-
- \sa progress
-*/
-
-/*!
- \qmlsignal WebView::onLoadFailed()
-
- This handler is called when the web engine fails loading
- a page or any component content
- (WebView::onLoadFinished() will be emitted on success).
-*/
-
-void QDeclarativeWebView::load(const QNetworkRequest &request,
- QNetworkAccessManager::Operation operation,
- const QByteArray &body)
-{
- page()->mainFrame()->load(request, operation, body);
-}
-
-QString QDeclarativeWebView::html() const
-{
- return page()->mainFrame()->toHtml();
-}
-
-/*!
- \qmlproperty string WebView::html
- This property holds HTML text set directly
-
- The html property can be set as a string.
-
- \qml
- WebView {
- html: "<p>This is <b>HTML</b>."
- }
- \endqml
-*/
-void QDeclarativeWebView::setHtml(const QString &html, const QUrl &baseUrl)
-{
- Q_D(QDeclarativeWebView);
- page()->setViewportSize(QSize(
- d->preferredwidth>0 ? d->preferredwidth : width(),
- d->preferredheight>0 ? d->preferredheight : height()));
- if (isComponentComplete())
- page()->mainFrame()->setHtml(html, baseUrl);
- else {
- d->pending = d->PendingHtml;
- d->pending_url = baseUrl;
- d->pending_string = html;
- }
- emit htmlChanged();
-}
-
-void QDeclarativeWebView::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
-{
- Q_D(QDeclarativeWebView);
- page()->setViewportSize(QSize(
- d->preferredwidth>0 ? d->preferredwidth : width(),
- d->preferredheight>0 ? d->preferredheight : height()));
-
- if (isComponentComplete())
- page()->mainFrame()->setContent(data,mimeType,qmlContext(this)->resolvedUrl(baseUrl));
- else {
- d->pending = d->PendingContent;
- d->pending_url = baseUrl;
- d->pending_string = mimeType;
- d->pending_data = data;
- }
-}
-
-QWebHistory *QDeclarativeWebView::history() const
-{
- return page()->history();
-}
-
-QWebSettings *QDeclarativeWebView::settings() const
-{
- return page()->settings();
-}
-
-QDeclarativeWebView *QDeclarativeWebView::createWindow(QWebPage::WebWindowType type)
-{
- Q_D(QDeclarativeWebView);
- switch (type) {
- case QWebPage::WebBrowserWindow: {
- if (!d->newWindowComponent && d->newWindowParent)
- qWarning("WebView::newWindowComponent not set - WebView::newWindowParent ignored");
- else if (d->newWindowComponent && !d->newWindowParent)
- qWarning("WebView::newWindowParent not set - WebView::newWindowComponent ignored");
- else if (d->newWindowComponent && d->newWindowParent) {
- QDeclarativeWebView *webview = 0;
- QDeclarativeContext *windowContext = new QDeclarativeContext(qmlContext(this));
-
- QObject *nobj = d->newWindowComponent->create(windowContext);
- if (nobj) {
- windowContext->setParent(nobj);
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(nobj);
- if (!item) {
- delete nobj;
- } else {
- webview = item->findChild<QDeclarativeWebView*>();
- if (!webview) {
- delete item;
- } else {
- nobj->setParent(d->newWindowParent);
- static_cast<QGraphicsObject*>(item)->setParentItem(d->newWindowParent);
- }
- }
- } else {
- delete windowContext;
- }
-
- return webview;
- }
- }
- break;
- case QWebPage::WebModalDialog: {
- // Not supported
- }
- }
- return 0;
-}
-
-/*!
- \qmlproperty component WebView::newWindowComponent
-
- This property holds the component to use for new windows.
- The component must have a WebView somewhere in its structure.
-
- When the web engine requests a new window, it will be an instance of
- this component.
-
- The parent of the new window is set by newWindowParent. It must be set.
-*/
-QDeclarativeComponent *QDeclarativeWebView::newWindowComponent() const
-{
- Q_D(const QDeclarativeWebView);
- return d->newWindowComponent;
-}
-
-void QDeclarativeWebView::setNewWindowComponent(QDeclarativeComponent *newWindow)
-{
- Q_D(QDeclarativeWebView);
- if (newWindow == d->newWindowComponent)
- return;
- d->newWindowComponent = newWindow;
- emit newWindowComponentChanged();
-}
-
-
-/*!
- \qmlproperty item WebView::newWindowParent
-
- The parent item for new windows.
-
- \sa newWindowComponent
-*/
-QDeclarativeItem *QDeclarativeWebView::newWindowParent() const
-{
- Q_D(const QDeclarativeWebView);
- return d->newWindowParent;
-}
-
-void QDeclarativeWebView::setNewWindowParent(QDeclarativeItem *parent)
-{
- Q_D(QDeclarativeWebView);
- if (parent == d->newWindowParent)
- return;
- if (d->newWindowParent && parent) {
- QList<QGraphicsItem *> children = d->newWindowParent->childItems();
- for (int i = 0; i < children.count(); ++i) {
- children.at(i)->setParentItem(parent);
- }
- }
- d->newWindowParent = parent;
- emit newWindowParentChanged();
-}
-
-/*!
- Returns the area of the largest element at position (\a x,\a y) that is no larger
- than \a maxwidth by \a maxheight pixels.
-
- May return an area larger in the case when no smaller element is at the position.
-*/
-QRect QDeclarativeWebView::elementAreaAt(int x, int y, int maxwidth, int maxheight) const
-{
- QWebHitTestResult hit = page()->mainFrame()->hitTestContent(QPoint(x,y));
- QRect rv = hit.boundingRect();
- QWebElement element = hit.enclosingBlockElement();
- if (maxwidth<=0) maxwidth = INT_MAX;
- if (maxheight<=0) maxheight = INT_MAX;
- while (!element.parent().isNull() && element.geometry().width() <= maxwidth && element.geometry().height() <= maxheight) {
- rv = element.geometry();
- element = element.parent();
- }
- return rv;
-}
-
-/*!
- \internal
- \class QDeclarativeWebPage
- \brief The QDeclarativeWebPage class is a QWebPage that can create QML plugins.
-
- \sa QDeclarativeWebView
-*/
-QDeclarativeWebPage::QDeclarativeWebPage(QDeclarativeWebView *parent) :
- QWebPage(parent)
-{
-}
-
-QDeclarativeWebPage::~QDeclarativeWebPage()
-{
-}
-
-void QDeclarativeWebPage::javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID)
-{
- qWarning() << sourceID << ':' << lineNumber << ':' << message;
-}
-
-QString QDeclarativeWebPage::chooseFile(QWebFrame *originatingFrame, const QString& oldFile)
-{
- // Not supported (it's modal)
- Q_UNUSED(originatingFrame)
- Q_UNUSED(oldFile)
- return oldFile;
-}
-
-void QDeclarativeWebPage::javaScriptAlert(QWebFrame *originatingFrame, const QString& msg)
-{
- Q_UNUSED(originatingFrame)
- emit viewItem()->alert(msg);
-}
-
-bool QDeclarativeWebPage::javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg)
-{
- // Not supported (it's modal)
- Q_UNUSED(originatingFrame)
- Q_UNUSED(msg)
- return false;
-}
-
-bool QDeclarativeWebPage::javaScriptPrompt(QWebFrame *originatingFrame, const QString& msg, const QString& defaultValue, QString* result)
-{
- // Not supported (it's modal)
- Q_UNUSED(originatingFrame)
- Q_UNUSED(msg)
- Q_UNUSED(defaultValue)
- Q_UNUSED(result)
- return false;
-}
-
-
-/*
- Qt WebKit does not understand non-QWidget plugins, so dummy widgets
- are created, parented to a single dummy tool window.
-
- The requirements for QML object plugins are input to the Qt WebKit
- non-QWidget plugin support, which will obsolete this kludge.
-*/
-class QWidget_Dummy_Plugin : public QWidget
-{
- Q_OBJECT
-public:
- static QWidget *dummy_shared_parent()
- {
- static QWidget *dsp = 0;
- if (!dsp) {
- dsp = new QWidget(0,Qt::Tool);
- dsp->setGeometry(-10000,-10000,0,0);
- dsp->show();
- }
- return dsp;
- }
- QWidget_Dummy_Plugin(const QUrl& url, QDeclarativeWebView *view, const QStringList &paramNames, const QStringList &paramValues) :
- QWidget(dummy_shared_parent()),
- propertyNames(paramNames),
- propertyValues(paramValues),
- webview(view)
- {
- QDeclarativeEngine *engine = qmlEngine(webview);
- component = new QDeclarativeComponent(engine, url, this);
- item = 0;
- if (component->isLoading())
- connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), this, SLOT(qmlLoaded()));
- else
- qmlLoaded();
- }
-
-public Q_SLOTS:
- void qmlLoaded()
- {
- if (component->isError()) {
- // ### Could instead give these errors to the WebView to handle.
- qWarning() << component->errors();
- return;
- }
- item = qobject_cast<QDeclarativeItem*>(component->create(qmlContext(webview)));
- item->setParent(webview);
- QString jsObjName;
- for (int i=0; i<propertyNames.count(); ++i) {
- if (propertyNames[i] != QLatin1String("type") && propertyNames[i] != QLatin1String("data")) {
- item->setProperty(propertyNames[i].toUtf8(),propertyValues[i]);
- if (propertyNames[i] == QLatin1String("objectname"))
- jsObjName = propertyValues[i];
- }
- }
- if (!jsObjName.isNull()) {
- QWebFrame *f = webview->page()->mainFrame();
- f->addToJavaScriptWindowObject(jsObjName, item);
- }
- resizeEvent(0);
- delete component;
- component = 0;
- }
- void resizeEvent(QResizeEvent*)
- {
- if (item) {
- item->setX(x());
- item->setY(y());
- item->setWidth(width());
- item->setHeight(height());
- }
- }
-
-private:
- QDeclarativeComponent *component;
- QDeclarativeItem *item;
- QStringList propertyNames, propertyValues;
- QDeclarativeWebView *webview;
-};
-
-QDeclarativeWebView *QDeclarativeWebPage::viewItem()
-{
- return static_cast<QDeclarativeWebView*>(parent());
-}
-
-QObject *QDeclarativeWebPage::createPlugin(const QString &, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues)
-{
- QUrl comp = qmlContext(viewItem())->resolvedUrl(url);
- return new QWidget_Dummy_Plugin(comp,viewItem(),paramNames,paramValues);
-}
-
-QWebPage *QDeclarativeWebPage::createWindow(WebWindowType type)
-{
- QDeclarativeWebView *newView = viewItem()->createWindow(type);
- if (newView)
- return newView->page();
- return 0;
-}
-
-QT_END_NAMESPACE
-
-#include <qdeclarativewebview.moc>
diff --git a/src/declarative/graphicsitems/qdeclarativewebview_p.h b/src/declarative/graphicsitems/qdeclarativewebview_p.h
deleted file mode 100644
index a65aab3..0000000
--- a/src/declarative/graphicsitems/qdeclarativewebview_p.h
+++ /dev/null
@@ -1,286 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEWEBVIEW_H
-#define QDECLARATIVEWEBVIEW_H
-
-#include "qdeclarativepainteditem_p.h"
-
-#include <QtGui/QAction>
-#include <QtCore/QUrl>
-#include <QtNetwork/qnetworkaccessmanager.h>
-#include <QtWebKit/QWebPage>
-
-QT_BEGIN_HEADER
-
-class QWebHistory;
-class QWebSettings;
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QDeclarativeWebViewPrivate;
-class QNetworkRequest;
-class QDeclarativeWebView;
-
-class Q_DECLARATIVE_EXPORT QDeclarativeWebPage : public QWebPage
-{
- Q_OBJECT
-public:
- explicit QDeclarativeWebPage(QDeclarativeWebView *parent);
- ~QDeclarativeWebPage();
-protected:
- QObject *createPlugin(const QString &classid, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);
- QWebPage *createWindow(WebWindowType type);
- void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID);
- QString chooseFile(QWebFrame *originatingFrame, const QString& oldFile);
- void javaScriptAlert(QWebFrame *originatingFrame, const QString& msg);
- bool javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg);
- bool javaScriptPrompt(QWebFrame *originatingFrame, const QString& msg, const QString& defaultValue, QString* result);
-
-private:
- QDeclarativeWebView *viewItem();
-};
-
-
-class QDeclarativeWebViewAttached;
-class QDeclarativeWebSettings;
-
-//### TODO: browser plugins
-
-class Q_DECLARATIVE_EXPORT QDeclarativeWebView : public QDeclarativePaintedItem
-{
- Q_OBJECT
-
- Q_ENUMS(Status SelectionMode)
-
- Q_PROPERTY(QString title READ title NOTIFY titleChanged)
- Q_PROPERTY(QPixmap icon READ icon NOTIFY iconChanged)
- Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged)
- Q_PROPERTY(QString statusText READ statusText NOTIFY statusTextChanged)
-
- Q_PROPERTY(QString html READ html WRITE setHtml NOTIFY htmlChanged)
-
- Q_PROPERTY(int pressGrabTime READ pressGrabTime WRITE setPressGrabTime NOTIFY pressGrabTimeChanged)
-
- Q_PROPERTY(int preferredWidth READ preferredWidth WRITE setPreferredWidth NOTIFY preferredWidthChanged)
- Q_PROPERTY(int preferredHeight READ preferredHeight WRITE setPreferredHeight NOTIFY preferredHeightChanged)
- Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
- Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
- Q_PROPERTY(Status status READ status NOTIFY statusChanged)
-
- Q_PROPERTY(QAction* reload READ reloadAction CONSTANT)
- Q_PROPERTY(QAction* back READ backAction CONSTANT)
- Q_PROPERTY(QAction* forward READ forwardAction CONSTANT)
- Q_PROPERTY(QAction* stop READ stopAction CONSTANT)
-
- Q_PROPERTY(QDeclarativeWebSettings* settings READ settingsObject CONSTANT)
-
- Q_PROPERTY(QDeclarativeListProperty<QObject> javaScriptWindowObjects READ javaScriptWindowObjects CONSTANT)
-
- Q_PROPERTY(QDeclarativeComponent* newWindowComponent READ newWindowComponent WRITE setNewWindowComponent NOTIFY newWindowComponentChanged)
- Q_PROPERTY(QDeclarativeItem* newWindowParent READ newWindowParent WRITE setNewWindowParent NOTIFY newWindowParentChanged)
-
- Q_PROPERTY(bool renderingEnabled READ renderingEnabled WRITE setRenderingEnabled NOTIFY renderingEnabledChanged)
-
-public:
- QDeclarativeWebView(QDeclarativeItem *parent=0);
- ~QDeclarativeWebView();
-
- QUrl url() const;
- void setUrl(const QUrl &);
-
- QString title() const;
-
- QPixmap icon() const;
-
- qreal zoomFactor() const;
- void setZoomFactor(qreal);
- Q_INVOKABLE bool heuristicZoom(int clickX, int clickY, qreal maxzoom);
- QRect elementAreaAt(int x, int y, int minwidth, int minheight) const;
-
- int pressGrabTime() const;
- void setPressGrabTime(int);
-
- int preferredWidth() const;
- void setPreferredWidth(int);
- int preferredHeight() const;
- void setPreferredHeight(int);
-
- enum Status { Null, Ready, Loading, Error };
- Status status() const;
- qreal progress() const;
- QString statusText() const;
-
- QAction *reloadAction() const;
- QAction *backAction() const;
- QAction *forwardAction() const;
- QAction *stopAction() const;
-
- QWebPage *page() const;
- void setPage(QWebPage *page);
-
- void load(const QNetworkRequest &request,
- QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation,
- const QByteArray &body = QByteArray());
-
- QString html() const;
-
- void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
- void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl());
-
- QWebHistory *history() const;
- QWebSettings *settings() const;
- QDeclarativeWebSettings *settingsObject() const;
-
- bool renderingEnabled() const;
- void setRenderingEnabled(bool);
-
- QDeclarativeListProperty<QObject> javaScriptWindowObjects();
-
- static QDeclarativeWebViewAttached *qmlAttachedProperties(QObject *);
-
- QDeclarativeComponent *newWindowComponent() const;
- void setNewWindowComponent(QDeclarativeComponent *newWindow);
- QDeclarativeItem *newWindowParent() const;
- void setNewWindowParent(QDeclarativeItem *newWindow);
-
-Q_SIGNALS:
- void preferredWidthChanged();
- void preferredHeightChanged();
- void urlChanged();
- void progressChanged();
- void statusChanged(Status);
- void titleChanged(const QString&);
- void iconChanged();
- void statusTextChanged();
- void htmlChanged();
- void pressGrabTimeChanged();
- void zoomFactorChanged();
- void newWindowComponentChanged();
- void newWindowParentChanged();
- void renderingEnabledChanged();
-
- void loadStarted();
- void loadFinished();
- void loadFailed();
-
- void doubleClick(int clickX, int clickY);
-
- void zoomTo(qreal zoom, int centerX, int centerY);
-
- void alert(const QString& message);
-
-public Q_SLOTS:
- QVariant evaluateJavaScript(const QString&);
-
-private Q_SLOTS:
- void expandToWebPage();
- void paintPage(const QRect&);
- void doLoadStarted();
- void doLoadProgress(int p);
- void doLoadFinished(bool ok);
- void setStatusText(const QString&);
- void windowObjectCleared();
- void pageUrlChanged();
- void noteContentsSizeChanged(const QSize&);
- void initialLayout();
-
-protected:
- void drawContents(QPainter *, const QRect &);
-
- void mousePressEvent(QGraphicsSceneMouseEvent *event);
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
- void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
- void timerEvent(QTimerEvent *event);
- void hoverMoveEvent (QGraphicsSceneHoverEvent * event);
- void keyPressEvent(QKeyEvent* event);
- void keyReleaseEvent(QKeyEvent* event);
- virtual void geometryChanged(const QRectF &newGeometry,
- const QRectF &oldGeometry);
- virtual void focusChanged(bool);
- virtual bool sceneEvent(QEvent *event);
- QDeclarativeWebView *createWindow(QWebPage::WebWindowType type);
-
-private:
- void init();
- virtual void componentComplete();
- Q_DISABLE_COPY(QDeclarativeWebView)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeWebView)
- QMouseEvent *sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *);
- QMouseEvent *sceneHoverMoveEventToMouseEvent(QGraphicsSceneHoverEvent *);
- friend class QDeclarativeWebPage;
-};
-
-class QDeclarativeWebViewAttached : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QString windowObjectName READ windowObjectName WRITE setWindowObjectName)
-public:
- QDeclarativeWebViewAttached(QObject *parent)
- : QObject(parent)
- {
- }
-
- QString windowObjectName() const
- {
- return m_windowObjectName;
- }
-
- void setWindowObjectName(const QString &n)
- {
- m_windowObjectName = n;
- }
-
-private:
- QString m_windowObjectName;
-};
-
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeWebView)
-QML_DECLARE_TYPEINFO(QDeclarativeWebView, QML_HAS_ATTACHED_PROPERTIES)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/graphicsitems/qdeclarativewebview_p_p.h b/src/declarative/graphicsitems/qdeclarativewebview_p_p.h
deleted file mode 100644
index 258b472..0000000
--- a/src/declarative/graphicsitems/qdeclarativewebview_p_p.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEWEBVIEW_P_H
-#define QDECLARATIVEWEBVIEW_P_H
-
-#include <qdeclarative.h>
-
-#include <QtWebKit/QWebPage>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QDeclarativeWebSettings : public QObject {
- Q_OBJECT
-
- Q_PROPERTY(QString standardFontFamily READ standardFontFamily WRITE setStandardFontFamily)
- Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily WRITE setFixedFontFamily)
- Q_PROPERTY(QString serifFontFamily READ serifFontFamily WRITE setSerifFontFamily)
- Q_PROPERTY(QString sansSerifFontFamily READ sansSerifFontFamily WRITE setSansSerifFontFamily)
- Q_PROPERTY(QString cursiveFontFamily READ cursiveFontFamily WRITE setCursiveFontFamily)
- Q_PROPERTY(QString fantasyFontFamily READ fantasyFontFamily WRITE setFantasyFontFamily)
-
- Q_PROPERTY(int minimumFontSize READ minimumFontSize WRITE setMinimumFontSize)
- Q_PROPERTY(int minimumLogicalFontSize READ minimumLogicalFontSize WRITE setMinimumLogicalFontSize)
- Q_PROPERTY(int defaultFontSize READ defaultFontSize WRITE setDefaultFontSize)
- Q_PROPERTY(int defaultFixedFontSize READ defaultFixedFontSize WRITE setDefaultFixedFontSize)
-
- Q_PROPERTY(bool autoLoadImages READ autoLoadImages WRITE setAutoLoadImages)
- Q_PROPERTY(bool javascriptEnabled READ javascriptEnabled WRITE setJavascriptEnabled)
- Q_PROPERTY(bool javaEnabled READ javaEnabled WRITE setJavaEnabled)
- Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled)
- Q_PROPERTY(bool privateBrowsingEnabled READ privateBrowsingEnabled WRITE setPrivateBrowsingEnabled)
- Q_PROPERTY(bool javascriptCanOpenWindows READ javascriptCanOpenWindows WRITE setJavascriptCanOpenWindows)
- Q_PROPERTY(bool javascriptCanAccessClipboard READ javascriptCanAccessClipboard WRITE setJavascriptCanAccessClipboard)
- Q_PROPERTY(bool developerExtrasEnabled READ developerExtrasEnabled WRITE setDeveloperExtrasEnabled)
- Q_PROPERTY(bool linksIncludedInFocusChain READ linksIncludedInFocusChain WRITE setLinksIncludedInFocusChain)
- Q_PROPERTY(bool zoomTextOnly READ zoomTextOnly WRITE setZoomTextOnly)
- Q_PROPERTY(bool printElementBackgrounds READ printElementBackgrounds WRITE setPrintElementBackgrounds)
- Q_PROPERTY(bool offlineStorageDatabaseEnabled READ offlineStorageDatabaseEnabled WRITE setOfflineStorageDatabaseEnabled)
- Q_PROPERTY(bool offlineWebApplicationCacheEnabled READ offlineWebApplicationCacheEnabled WRITE setOfflineWebApplicationCacheEnabled)
- Q_PROPERTY(bool localStorageDatabaseEnabled READ localStorageDatabaseEnabled WRITE setLocalStorageDatabaseEnabled)
- Q_PROPERTY(bool localContentCanAccessRemoteUrls READ localContentCanAccessRemoteUrls WRITE setLocalContentCanAccessRemoteUrls)
-
-public:
- QDeclarativeWebSettings() {}
-
- QString standardFontFamily() const { return s->fontFamily(QWebSettings::StandardFont); }
- void setStandardFontFamily(const QString& f) { s->setFontFamily(QWebSettings::StandardFont,f); }
- QString fixedFontFamily() const { return s->fontFamily(QWebSettings::FixedFont); }
- void setFixedFontFamily(const QString& f) { s->setFontFamily(QWebSettings::FixedFont,f); }
- QString serifFontFamily() const { return s->fontFamily(QWebSettings::SerifFont); }
- void setSerifFontFamily(const QString& f) { s->setFontFamily(QWebSettings::SerifFont,f); }
- QString sansSerifFontFamily() const { return s->fontFamily(QWebSettings::SansSerifFont); }
- void setSansSerifFontFamily(const QString& f) { s->setFontFamily(QWebSettings::SansSerifFont,f); }
- QString cursiveFontFamily() const { return s->fontFamily(QWebSettings::CursiveFont); }
- void setCursiveFontFamily(const QString& f) { s->setFontFamily(QWebSettings::CursiveFont,f); }
- QString fantasyFontFamily() const { return s->fontFamily(QWebSettings::FantasyFont); }
- void setFantasyFontFamily(const QString& f) { s->setFontFamily(QWebSettings::FantasyFont,f); }
-
- int minimumFontSize() const { return s->fontSize(QWebSettings::MinimumFontSize); }
- void setMinimumFontSize(int size) { s->setFontSize(QWebSettings::MinimumFontSize,size); }
- int minimumLogicalFontSize() const { return s->fontSize(QWebSettings::MinimumLogicalFontSize); }
- void setMinimumLogicalFontSize(int size) { s->setFontSize(QWebSettings::MinimumLogicalFontSize,size); }
- int defaultFontSize() const { return s->fontSize(QWebSettings::DefaultFontSize); }
- void setDefaultFontSize(int size) { s->setFontSize(QWebSettings::DefaultFontSize,size); }
- int defaultFixedFontSize() const { return s->fontSize(QWebSettings::DefaultFixedFontSize); }
- void setDefaultFixedFontSize(int size) { s->setFontSize(QWebSettings::DefaultFixedFontSize,size); }
-
- bool autoLoadImages() const { return s->testAttribute(QWebSettings::AutoLoadImages); }
- void setAutoLoadImages(bool on) { s->setAttribute(QWebSettings::AutoLoadImages, on); }
- bool javascriptEnabled() const { return s->testAttribute(QWebSettings::JavascriptEnabled); }
- void setJavascriptEnabled(bool on) { s->setAttribute(QWebSettings::JavascriptEnabled, on); }
- bool javaEnabled() const { return s->testAttribute(QWebSettings::JavaEnabled); }
- void setJavaEnabled(bool on) { s->setAttribute(QWebSettings::JavaEnabled, on); }
- bool pluginsEnabled() const { return s->testAttribute(QWebSettings::PluginsEnabled); }
- void setPluginsEnabled(bool on) { s->setAttribute(QWebSettings::PluginsEnabled, on); }
- bool privateBrowsingEnabled() const { return s->testAttribute(QWebSettings::PrivateBrowsingEnabled); }
- void setPrivateBrowsingEnabled(bool on) { s->setAttribute(QWebSettings::PrivateBrowsingEnabled, on); }
- bool javascriptCanOpenWindows() const { return s->testAttribute(QWebSettings::JavascriptCanOpenWindows); }
- void setJavascriptCanOpenWindows(bool on) { s->setAttribute(QWebSettings::JavascriptCanOpenWindows, on); }
- bool javascriptCanAccessClipboard() const { return s->testAttribute(QWebSettings::JavascriptCanAccessClipboard); }
- void setJavascriptCanAccessClipboard(bool on) { s->setAttribute(QWebSettings::JavascriptCanAccessClipboard, on); }
- bool developerExtrasEnabled() const { return s->testAttribute(QWebSettings::DeveloperExtrasEnabled); }
- void setDeveloperExtrasEnabled(bool on) { s->setAttribute(QWebSettings::DeveloperExtrasEnabled, on); }
- bool linksIncludedInFocusChain() const { return s->testAttribute(QWebSettings::LinksIncludedInFocusChain); }
- void setLinksIncludedInFocusChain(bool on) { s->setAttribute(QWebSettings::LinksIncludedInFocusChain, on); }
- bool zoomTextOnly() const { return s->testAttribute(QWebSettings::ZoomTextOnly); }
- void setZoomTextOnly(bool on) { s->setAttribute(QWebSettings::ZoomTextOnly, on); }
- bool printElementBackgrounds() const { return s->testAttribute(QWebSettings::PrintElementBackgrounds); }
- void setPrintElementBackgrounds(bool on) { s->setAttribute(QWebSettings::PrintElementBackgrounds, on); }
- bool offlineStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::OfflineStorageDatabaseEnabled); }
- void setOfflineStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, on); }
- bool offlineWebApplicationCacheEnabled() const { return s->testAttribute(QWebSettings::OfflineWebApplicationCacheEnabled); }
- void setOfflineWebApplicationCacheEnabled(bool on) { s->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, on); }
- bool localStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::LocalStorageDatabaseEnabled); }
- void setLocalStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, on); }
- bool localContentCanAccessRemoteUrls() const { return s->testAttribute(QWebSettings::LocalContentCanAccessRemoteUrls); }
- void setLocalContentCanAccessRemoteUrls(bool on) { s->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, on); }
-
- QWebSettings *s;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeWebSettings)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/qml/parser/qdeclarativejs.g b/src/declarative/qml/parser/qdeclarativejs.g
index 7cf81b2..493ad25 100644
--- a/src/declarative/qml/parser/qdeclarativejs.g
+++ b/src/declarative/qml/parser/qdeclarativejs.g
@@ -1020,7 +1020,7 @@ case $rule_number: {
JsIdentifier: T_ON ;
/.
case $rule_number: {
- QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_READONLY]);
+ QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_ON]);
sym(1).sval = driver->intern(s.constData(), s.length());
break;
}
diff --git a/src/declarative/qml/parser/qdeclarativejsgrammar.cpp b/src/declarative/qml/parser/qdeclarativejsgrammar.cpp
index 0677bc5..89493ff 100644
--- a/src/declarative/qml/parser/qdeclarativejsgrammar.cpp
+++ b/src/declarative/qml/parser/qdeclarativejsgrammar.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
diff --git a/src/declarative/qml/parser/qdeclarativejsgrammar_p.h b/src/declarative/qml/parser/qdeclarativejsgrammar_p.h
index 2b2e3d1..32bb12b 100644
--- a/src/declarative/qml/parser/qdeclarativejsgrammar_p.h
+++ b/src/declarative/qml/parser/qdeclarativejsgrammar_p.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE
class QDeclarativeJSGrammar
{
public:
- enum {
+ enum VariousConstants {
EOF_SYMBOL = 0,
REDUCE_HERE = 100,
SHIFT_THERE = 99,
diff --git a/src/declarative/qml/parser/qdeclarativejsparser.cpp b/src/declarative/qml/parser/qdeclarativejsparser.cpp
index fd9e690..c86e047 100644
--- a/src/declarative/qml/parser/qdeclarativejsparser.cpp
+++ b/src/declarative/qml/parser/qdeclarativejsparser.cpp
@@ -516,7 +516,7 @@ case 66: {
}
case 67: {
- QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_READONLY]);
+ QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_ON]);
sym(1).sval = driver->intern(s.constData(), s.length());
break;
}
diff --git a/src/declarative/qml/qdeclarativebinding_p.h b/src/declarative/qml/qdeclarativebinding_p.h
index f66b9c7..1a714f0 100644
--- a/src/declarative/qml/qdeclarativebinding_p.h
+++ b/src/declarative/qml/qdeclarativebinding_p.h
@@ -64,7 +64,7 @@
QT_BEGIN_NAMESPACE
-class Q_AUTOTEST_EXPORT QDeclarativeAbstractBinding
+class Q_DECLARATIVE_EXPORT QDeclarativeAbstractBinding
{
public:
QDeclarativeAbstractBinding();
@@ -101,7 +101,7 @@ private:
class QDeclarativeContext;
class QDeclarativeBindingPrivate;
-class Q_AUTOTEST_EXPORT QDeclarativeBinding : public QDeclarativeExpression, public QDeclarativeAbstractBinding
+class Q_DECLARATIVE_EXPORT QDeclarativeBinding : public QDeclarativeExpression, public QDeclarativeAbstractBinding
{
Q_OBJECT
public:
@@ -130,8 +130,9 @@ protected:
private:
Q_DECLARE_PRIVATE(QDeclarativeBinding)
};
-Q_DECLARE_METATYPE(QDeclarativeBinding*);
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QDeclarativeBinding*);
+
#endif // QDECLARATIVEBINDING_P_H
diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp
index ce396fd..6a5a102 100644
--- a/src/declarative/qml/qdeclarativeboundsignal.cpp
+++ b/src/declarative/qml/qdeclarativeboundsignal.cpp
@@ -104,7 +104,7 @@ QDeclarativeBoundSignal::QDeclarativeBoundSignal(QObject *scope, const QMetaMeth
// is that they both do the work to figure it out. Boo hoo.
if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount();
- QDeclarativeGraphics_setParent_noEvent(this, parent);
+ QDeclarative_setParent_noEvent(this, parent);
QMetaObject::connect(scope, m_signal.methodIndex(), this, evaluateIdx);
}
@@ -120,7 +120,7 @@ QDeclarativeBoundSignal::QDeclarativeBoundSignal(QDeclarativeContext *ctxt, cons
// is that they both do the work to figure it out. Boo hoo.
if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount();
- QDeclarativeGraphics_setParent_noEvent(this, parent);
+ QDeclarative_setParent_noEvent(this, parent);
QMetaObject::connect(scope, m_signal.methodIndex(), this, evaluateIdx);
m_expression = new QDeclarativeExpression(ctxt, val, scope);
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 5da207d..ef1032b 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -65,6 +65,7 @@
#include "qdeclarativescriptparser_p.h"
#include "qdeclarativebinding_p.h"
#include "qdeclarativecompiledbindings_p.h"
+#include "qdeclarativeglobalscriptclass_p.h"
#include <qfxperf_p_p.h>
@@ -113,32 +114,6 @@ QList<QDeclarativeError> QDeclarativeCompiler::errors() const
}
/*!
- Returns true if \a val is a legal object id, false otherwise.
-
- Legal ids must start with a lower-case letter or underscore, and contain only
- letters, numbers and underscores.
-*/
-bool QDeclarativeCompiler::isValidId(const QString &val)
-{
- if (val.isEmpty())
- return false;
-
- if (val.at(0).isLetter() && !val.at(0).isLower()) {
- qWarning().nospace() << "id " << val << " is invalid: ids cannot start with uppercase letters";
- return false;
- }
-
- QChar u(QLatin1Char('_'));
- for (int ii = 0; ii < val.count(); ++ii)
- if (val.at(ii) != u &&
- ((ii == 0 && !val.at(ii).isLetter()) ||
- (ii != 0 && !val.at(ii).isLetterOrNumber())) )
- return false;
-
- return true;
-}
-
-/*!
Returns true if \a name refers to an attached property, false otherwise.
Attached property names are those that start with a capital letter.
@@ -586,9 +561,11 @@ bool QDeclarativeCompiler::compile(QDeclarativeEngine *engine,
QDeclarativeCompositeTypeData::TypeReference &tref = unit->types[ii];
QDeclarativeCompiledData::TypeReference ref;
QDeclarativeScriptParser::TypeReference *parserRef = unit->data.referencedTypes().at(ii);
- if (tref.type)
+ if (tref.type) {
ref.type = tref.type;
- else if (tref.unit) {
+ if (!ref.type->isCreatable())
+ COMPILE_EXCEPTION(parserRef->refObjects.first(), QCoreApplication::translate("QDeclarativeCompiler", "Element is not creatable."));
+ } else if (tref.unit) {
ref.component = tref.unit->toComponent(engine);
if (ref.component->isError()) {
@@ -718,6 +695,7 @@ bool QDeclarativeCompiler::buildObject(Object *obj, const BindingContext &ctxt)
BindingContext objCtxt(obj);
// Create the synthesized meta object, ignoring aliases
+ COMPILE_CHECK(checkDynamicMeta(obj));
COMPILE_CHECK(mergeDynamicMetaProperties(obj));
COMPILE_CHECK(buildDynamicMeta(obj, IgnoreAliases));
@@ -1007,12 +985,15 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj)
} else if (v->type == Value::SignalExpression) {
+ BindingContext ctxt = compileState.signalExpressions.value(v);
+
QDeclarativeInstruction store;
store.type = QDeclarativeInstruction::StoreSignal;
store.line = v->location.start.line;
store.storeSignal.signalIndex = prop->index;
store.storeSignal.value =
output->indexForString(v->value.asScript().trimmed());
+ store.storeSignal.context = ctxt.stack;
output->bytecode << store;
}
@@ -1139,10 +1120,11 @@ bool QDeclarativeCompiler::buildComponent(QDeclarativeParser::Object *obj,
if (obj->properties.count())
idProp = *obj->properties.begin();
- if (idProp && (idProp->value || idProp->values.count() > 1 || !isValidId(idProp->values.first()->primitive())))
- COMPILE_EXCEPTION(idProp, QCoreApplication::translate("QDeclarativeCompiler","Invalid component id specification"));
-
if (idProp) {
+ if (idProp->value || idProp->values.count() > 1 || idProp->values.at(0)->object)
+ COMPILE_EXCEPTION(idProp, QCoreApplication::translate("QDeclarativeCompiler","Invalid component id specification"));
+ COMPILE_CHECK(checkValidId(idProp->values.first(), idProp->values.first()->primitive()));
+
QString idVal = idProp->values.first()->primitive();
if (compileState.ids.contains(idVal))
@@ -1344,7 +1326,7 @@ QMetaMethod QDeclarativeCompiler::findSignalByName(const QMetaObject *mo, const
}
bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj,
- const BindingContext &ctxt)
+ const BindingContext &ctxt)
{
Q_ASSERT(obj->metaObject());
Q_ASSERT(!prop->isEmpty());
@@ -1365,7 +1347,7 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDecl
} else {
- if (prop->value || prop->values.count() > 1)
+ if (prop->value || prop->values.count() != 1)
COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Incorrectly specified signal"));
prop->index = sigIdx;
@@ -1380,6 +1362,8 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDecl
QString script = prop->values.at(0)->value.asScript().trimmed();
if (script.isEmpty())
COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Empty signal assignment"));
+
+ compileState.signalExpressions.insert(prop->values.at(0), ctxt);
}
}
@@ -1623,6 +1607,10 @@ void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeParser::Property *p
for (int ii = 0; ii < prop->values.count(); ++ii) {
QDeclarativeParser::Value *v = prop->values.at(ii);
+ Q_ASSERT(v->type == Value::CreatedObject ||
+ v->type == Value::PropertyBinding ||
+ v->type == Value::Literal);
+
if (v->type == Value::CreatedObject) {
genObject(v->object);
@@ -1652,7 +1640,27 @@ void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeParser::Property *p
output->bytecode << store;
}
- } else if (v->type == Value::ValueSource) {
+ } else if (v->type == Value::PropertyBinding) {
+
+ genBindingAssignment(v, prop, obj, valueTypeProperty);
+
+ } else if (v->type == Value::Literal) {
+
+ QMetaProperty mp = obj->metaObject()->property(prop->index);
+ genLiteralAssignment(mp, v);
+
+ }
+
+ }
+
+ for (int ii = 0; ii < prop->onValues.count(); ++ii) {
+
+ QDeclarativeParser::Value *v = prop->onValues.at(ii);
+
+ Q_ASSERT(v->type == Value::ValueSource ||
+ v->type == Value::ValueInterceptor);
+
+ if (v->type == Value::ValueSource) {
genObject(v->object);
QDeclarativeInstruction store;
@@ -1685,16 +1693,6 @@ void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeParser::Property *p
QDeclarativeType *valueType = toQmlType(v->object);
store.assignValueInterceptor.castValue = valueType->propertyValueInterceptorCast();
output->bytecode << store;
-
- } else if (v->type == Value::PropertyBinding) {
-
- genBindingAssignment(v, prop, obj, valueTypeProperty);
-
- } else if (v->type == Value::Literal) {
-
- QMetaProperty mp = obj->metaObject()->property(prop->index);
- genLiteralAssignment(mp, v);
-
}
}
@@ -1711,8 +1709,7 @@ bool QDeclarativeCompiler::buildIdProperty(QDeclarativeParser::Property *prop,
QDeclarativeParser::Value *idValue = prop->values.at(0);
QString val = idValue->primitive();
- if (!isValidId(val))
- COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","\"%1\" is not a valid object id").arg(val));
+ COMPILE_CHECK(checkValidId(idValue, val));
// We disallow id's that conflict with import prefixes and types
QDeclarativeEnginePrivate::ImportedNamespace *ns = 0;
@@ -1793,19 +1790,25 @@ bool QDeclarativeCompiler::buildAttachedProperty(QDeclarativeParser::Property *p
// }
// font is a nested property. pointSize and family are not.
bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
- const BindingContext &ctxt)
+ QDeclarativeParser::Object *obj,
+ const BindingContext &ctxt)
{
Q_ASSERT(prop->type != 0);
Q_ASSERT(prop->index != -1);
- if (prop->values.count())
- COMPILE_EXCEPTION(prop->values.first(), QCoreApplication::translate("QDeclarativeCompiler", "Invalid value in grouped property"));
-
- if (prop->type < (int)QVariant::UserType) {
+ if (QDeclarativeValueTypeFactory::isValueType(prop->type)) {
QDeclarativeEnginePrivate *ep =
static_cast<QDeclarativeEnginePrivate *>(QObjectPrivate::get(engine));
if (prop->type >= 0 /* QVariant == -1 */ && ep->valueTypes[prop->type]) {
+
+ if (prop->values.count()) {
+ if (prop->values.at(0)->location < prop->value->location) {
+ COMPILE_EXCEPTION(prop->value, QCoreApplication::translate("QDeclarativeCompiler", "Property has already been assigned a value"));
+ } else {
+ COMPILE_EXCEPTION(prop->values.at(0), QCoreApplication::translate("QDeclarativeCompiler", "Property has already been assigned a value"));
+ }
+ }
+
COMPILE_CHECK(buildValueTypeProperty(ep->valueTypes[prop->type],
prop->value, obj, ctxt.incr()));
obj->addValueTypeProperty(prop);
@@ -1820,6 +1823,9 @@ bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeParser::Property *pr
if (!prop->value->metatype)
COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Invalid grouped property access"));
+ if (prop->values.count())
+ COMPILE_EXCEPTION(prop->values.at(0), QCoreApplication::translate("QDeclarativeCompiler", "Cannot assign a value directly to a grouped property"));
+
obj->addGroupedProperty(prop);
COMPILE_CHECK(buildSubObject(prop->value, ctxt.incr()));
@@ -1829,9 +1835,9 @@ bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeParser::Property *pr
}
bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Object *baseObj,
- const BindingContext &ctxt)
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Object *baseObj,
+ const BindingContext &ctxt)
{
if (obj->defaultProperty)
COMPILE_EXCEPTION(obj, QCoreApplication::translate("QDeclarativeCompiler","Invalid property use"));
@@ -1848,37 +1854,36 @@ bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type,
if (prop->value)
COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Property assignment expected"));
- if (prop->values.count() != 1)
+ if (prop->values.count() > 1) {
COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Single property assignment expected"));
+ } else if (prop->values.count()) {
+ Value *value = prop->values.at(0);
- Value *value = prop->values.at(0);
-
- if (value->object) {
- bool isPropertyValue = output->types.at(value->object->type).type->propertyValueSourceCast() != -1;
- bool isPropertyInterceptor = output->types.at(value->object->type).type->propertyValueInterceptorCast() != -1;
- if (!isPropertyValue && !isPropertyInterceptor) {
+ if (value->object) {
COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Unexpected object assignment"));
- } else {
- COMPILE_CHECK(buildObject(value->object, ctxt));
-
- if (isPropertyInterceptor && baseObj->synthdata.isEmpty())
- buildDynamicMeta(baseObj, ForceCreation);
- value->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor;
+ } else if (value->value.isScript()) {
+ // ### Check for writability
+ BindingReference reference;
+ reference.expression = value->value;
+ reference.property = prop;
+ reference.value = value;
+ reference.bindingContext = ctxt;
+ reference.bindingContext.owner++;
+ addBindingReference(reference);
+ value->type = Value::PropertyBinding;
+ } else {
+ COMPILE_CHECK(testLiteralAssignment(p, value));
+ value->type = Value::Literal;
}
- } else if (value->value.isScript()) {
- // ### Check for writability
- BindingReference reference;
- reference.expression = value->value;
- reference.property = prop;
- reference.value = value;
- reference.bindingContext = ctxt;
- reference.bindingContext.owner++;
- addBindingReference(reference);
- value->type = Value::PropertyBinding;
- } else {
- COMPILE_CHECK(testLiteralAssignment(p, value));
- value->type = Value::Literal;
}
+
+ for (int ii = 0; ii < prop->onValues.count(); ++ii) {
+ Value *v = prop->onValues.at(ii);
+ Q_ASSERT(v->object);
+
+ COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, baseObj, v, ctxt));
+ }
+
obj->addValueProperty(prop);
}
@@ -1886,13 +1891,11 @@ bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type,
}
// Build assignments to QML lists. QML lists are properties of type
-// QList<T *> * and QDeclarativeList<T *> *.
-//
-// QList<T *> * types can accept a list of objects, or a single binding
-// QDeclarativeList<T *> * types can accept a list of objects
+// QDeclarativeListProperty<T>. List properties can accept a list of
+// objects, or a single binding.
bool QDeclarativeCompiler::buildListProperty(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
- const BindingContext &ctxt)
+ QDeclarativeParser::Object *obj,
+ const BindingContext &ctxt)
{
Q_ASSERT(QDeclarativeEnginePrivate::get(engine)->isList(prop->type));
@@ -1950,20 +1953,6 @@ bool QDeclarativeCompiler::buildScriptStringProperty(QDeclarativeParser::Propert
}
// Compile regular property assignments of the form "property: <value>"
-//
-// ### The following problems exist
-//
-// There is no distinction between how "lists" of values are specified. This
-// Item {
-// children: Item {}
-// children: Item {}
-// }
-// is identical to
-// Item {
-// children: [ Item {}, Item {} ]
-// }
-//
-// We allow assignming multiple values to single value properties
bool QDeclarativeCompiler::buildPropertyAssignment(QDeclarativeParser::Property *prop,
QDeclarativeParser::Object *obj,
const BindingContext &ctxt)
@@ -1983,14 +1972,21 @@ bool QDeclarativeCompiler::buildPropertyAssignment(QDeclarativeParser::Property
}
}
+ for (int ii = 0; ii < prop->onValues.count(); ++ii) {
+ Value *v = prop->onValues.at(ii);
+
+ Q_ASSERT(v->object);
+ COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, obj, v, ctxt));
+ }
+
return true;
}
// Compile assigning a single object instance to a regular property
bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Value *v,
- const BindingContext &ctxt)
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Value *v,
+ const BindingContext &ctxt)
{
Q_ASSERT(prop->index != -1);
Q_ASSERT(v->object->type != -1);
@@ -2019,15 +2015,6 @@ bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeParser::Pro
v->object->metatype = output->types.at(v->object->type).metaObject();
Q_ASSERT(v->object->metaObject());
- // Will be true if the assigned type inherits QDeclarativePropertyValueSource
- bool isPropertyValue = false;
- // Will be true if the assigned type inherits QDeclarativePropertyValueInterceptor
- bool isPropertyInterceptor = false;
- if (QDeclarativeType *valueType = toQmlType(v->object)) {
- isPropertyValue = valueType->propertyValueSourceCast() != -1;
- isPropertyInterceptor = valueType->propertyValueInterceptorCast() != -1;
- }
-
// We want to raw metaObject here as the raw metaobject is the
// actual property type before we applied any extensions that might
// effect the properties on the type, but don't effect assignability
@@ -2063,13 +2050,6 @@ bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeParser::Pro
component->getDefaultProperty()->addValue(componentValue);
v->object = component;
COMPILE_CHECK(buildPropertyObjectAssignment(prop, obj, v, ctxt));
- } else if (isPropertyValue || isPropertyInterceptor) {
- // Assign as a property value source
- COMPILE_CHECK(buildObject(v->object, ctxt));
-
- if (isPropertyInterceptor && prop->parent->synthdata.isEmpty())
- buildDynamicMeta(prop->parent, ForceCreation);
- v->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor;
} else {
COMPILE_EXCEPTION(v->object, QCoreApplication::translate("QDeclarativeCompiler","Cannot assign object to property"));
}
@@ -2078,6 +2058,55 @@ bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeParser::Pro
return true;
}
+// Compile assigning a single object instance to a regular property using the "on" syntax.
+//
+// For example:
+// Item {
+// NumberAnimation on x { }
+// }
+bool QDeclarativeCompiler::buildPropertyOnAssignment(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Object *baseObj,
+ QDeclarativeParser::Value *v,
+ const BindingContext &ctxt)
+{
+ Q_ASSERT(prop->index != -1);
+ Q_ASSERT(v->object->type != -1);
+
+ if (!obj->metaObject()->property(prop->index).isWritable())
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop->name)));
+
+
+ // Normally buildObject() will set this up, but we need the static
+ // meta object earlier to test for assignability. It doesn't matter
+ // that there may still be outstanding synthesized meta object changes
+ // on this type, as they are not relevant for assignability testing
+ v->object->metatype = output->types.at(v->object->type).metaObject();
+ Q_ASSERT(v->object->metaObject());
+
+ // Will be true if the assigned type inherits QDeclarativePropertyValueSource
+ bool isPropertyValue = false;
+ // Will be true if the assigned type inherits QDeclarativePropertyValueInterceptor
+ bool isPropertyInterceptor = false;
+ if (QDeclarativeType *valueType = toQmlType(v->object)) {
+ isPropertyValue = valueType->propertyValueSourceCast() != -1;
+ isPropertyInterceptor = valueType->propertyValueInterceptorCast() != -1;
+ }
+
+ if (isPropertyValue || isPropertyInterceptor) {
+ // Assign as a property value source
+ COMPILE_CHECK(buildObject(v->object, ctxt));
+
+ if (isPropertyInterceptor && prop->parent->synthdata.isEmpty())
+ buildDynamicMeta(baseObj, ForceCreation);
+ v->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor;
+ } else {
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","\"%1\" cannot operate on \"%2\"").arg(v->object->typeName.constData()).arg(prop->name.constData()));
+ }
+
+ return true;
+}
+
// Compile assigning a literal or binding to a regular property
bool QDeclarativeCompiler::buildPropertyLiteralAssignment(QDeclarativeParser::Property *prop,
QDeclarativeParser::Object *obj,
@@ -2175,6 +2204,8 @@ bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj)
if (propNames.contains(prop.name))
COMPILE_EXCEPTION(&prop, QCoreApplication::translate("QDeclarativeCompiler","Duplicate property name"));
+ if (QString::fromUtf8(prop.name).at(0).isUpper())
+ COMPILE_EXCEPTION(&prop, QCoreApplication::translate("QDeclarativeCompiler","Property names cannot begin with an upper case letter"));
propNames.insert(prop.name);
}
@@ -2182,12 +2213,16 @@ bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj)
QByteArray name = obj->dynamicSignals.at(ii).name;
if (methodNames.contains(name))
COMPILE_EXCEPTION(obj, QCoreApplication::translate("QDeclarativeCompiler","Duplicate signal name"));
+ if (QString::fromUtf8(name).at(0).isUpper())
+ COMPILE_EXCEPTION(obj, QCoreApplication::translate("QDeclarativeCompiler","Signal names cannot begin with an upper case letter"));
methodNames.insert(name);
}
for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) {
QByteArray name = obj->dynamicSlots.at(ii).name;
if (methodNames.contains(name))
COMPILE_EXCEPTION(obj, QCoreApplication::translate("QDeclarativeCompiler","Duplicate method name"));
+ if (QString::fromUtf8(name).at(0).isUpper())
+ COMPILE_EXCEPTION(obj, QCoreApplication::translate("QDeclarativeCompiler","Method names cannot begin with an upper case letter"));
methodNames.insert(name);
}
@@ -2203,10 +2238,13 @@ bool QDeclarativeCompiler::mergeDynamicMetaProperties(QDeclarativeParser::Object
continue;
Property *property = 0;
- if (p.isDefaultProperty)
+ if (p.isDefaultProperty) {
property = obj->getDefaultProperty();
- else
+ } else {
property = obj->getProperty(p.name);
+ if (!property->values.isEmpty())
+ COMPILE_EXCEPTION(property, QCoreApplication::translate("QDeclarativeCompiler","Property value set multiple times"));
+ }
if (property->value)
COMPILE_EXCEPTION(property, QCoreApplication::translate("QDeclarativeCompiler","Invalid property nesting"));
@@ -2233,8 +2271,6 @@ bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeParser::Object *obj, Dyn
obj->dynamicSlots.isEmpty())
return true;
- COMPILE_CHECK(checkDynamicMeta(obj));
-
QByteArray dynamicData(sizeof(QDeclarativeVMEMetaData), (char)0);
QByteArray newClassName = obj->metatype->className();
@@ -2437,6 +2473,31 @@ bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeParser::Object *obj, Dyn
return true;
}
+bool QDeclarativeCompiler::checkValidId(QDeclarativeParser::Value *v, const QString &val)
+{
+ if (val.isEmpty())
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "Invalid empty ID"));
+
+ if (val.at(0).isLetter() && !val.at(0).isLower())
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "IDs cannot start with an uppercase letter"));
+
+ QChar u(QLatin1Char('_'));
+ for (int ii = 0; ii < val.count(); ++ii) {
+
+ if (ii == 0 && !val.at(ii).isLetter() && val.at(ii) != u) {
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "IDs must start with a letter or underscore"));
+ } else if (ii != 0 && !val.at(ii).isLetterOrNumber() && val.at(ii) != u) {
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "IDs must contain only letters, numbers, and underscores"));
+ }
+
+ }
+
+ if (QDeclarativeEnginePrivate::get(engine)->globalClass->illegalNames().contains(val))
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "ID illegally masks global JavaScript property"));
+
+ return true;
+}
+
#include <qdeclarativejsparser_p.h>
static QStringList astNodeToStringList(QDeclarativeJS::AST::Node *node)
@@ -2560,9 +2621,9 @@ bool QDeclarativeCompiler::buildBinding(QDeclarativeParser::Value *value,
}
void QDeclarativeCompiler::genBindingAssignment(QDeclarativeParser::Value *binding,
- QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj,
- QDeclarativeParser::Property *valueTypeProperty)
+ QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Property *valueTypeProperty)
{
Q_UNUSED(obj);
Q_ASSERT(compileState.bindings.contains(binding));
diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h
index 2ea3366..cca42e2 100644
--- a/src/declarative/qml/qdeclarativecompiler_p.h
+++ b/src/declarative/qml/qdeclarativecompiler_p.h
@@ -155,7 +155,6 @@ public:
bool isError() const;
QList<QDeclarativeError> errors() const;
- static bool isValidId(const QString &);
static bool isAttachedPropertyName(const QByteArray &);
static bool isSignalPropertyName(const QByteArray &);
@@ -219,6 +218,11 @@ private:
QDeclarativeParser::Object *obj,
QDeclarativeParser::Value *value,
const BindingContext &ctxt);
+ bool buildPropertyOnAssignment(QDeclarativeParser::Property *prop,
+ QDeclarativeParser::Object *obj,
+ QDeclarativeParser::Object *baseObj,
+ QDeclarativeParser::Value *value,
+ const BindingContext &ctxt);
bool buildPropertyLiteralAssignment(QDeclarativeParser::Property *prop,
QDeclarativeParser::Object *obj,
QDeclarativeParser::Value *value,
@@ -242,6 +246,7 @@ private:
QDeclarativeParser::Object *obj,
const QDeclarativeParser::Object::DynamicProperty &);
bool completeComponentBuild();
+ bool checkValidId(QDeclarativeParser::Value *, const QString &);
void genObject(QDeclarativeParser::Object *obj);
@@ -302,6 +307,7 @@ private:
QByteArray compiledBindingData;
QHash<QDeclarativeParser::Value *, BindingReference> bindings;
+ QHash<QDeclarativeParser::Value *, BindingContext> signalExpressions;
QList<QDeclarativeParser::Object *> aliasingObjects;
QDeclarativeParser::Object *root;
};
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index fe63ad2..d6bb216 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -437,6 +437,13 @@ void QDeclarativeComponent::loadUrl(const QUrl &url)
else
d->url = url;
+ if (url.isEmpty()) {
+ QDeclarativeError error;
+ error.setDescription(tr("Invalid empty URL"));
+ d->state.errors << error;
+ return;
+ }
+
QDeclarativeCompositeTypeData *data =
QDeclarativeEnginePrivate::get(d->engine)->typeManager.get(d->url);
@@ -618,7 +625,7 @@ QDeclarativeComponentPrivate::beginCreate(QDeclarativeContext *context, const QB
QObject *rv = begin(ctxt, ep, cc, start, count, &state, bindings);
if (rv) {
- QDeclarativeGraphics_setParent_noEvent(ctxt, rv);
+ QDeclarative_setParent_noEvent(ctxt, rv);
} else {
delete ctxt;
}
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp
index b244cd8..f70e143 100644
--- a/src/declarative/qml/qdeclarativecontext.cpp
+++ b/src/declarative/qml/qdeclarativecontext.cpp
@@ -47,6 +47,7 @@
#include "qdeclarativeengine.h"
#include "qdeclarativecompiledbindings_p.h"
#include "qdeclarativeinfo.h"
+#include "qdeclarativeglobalscriptclass_p.h"
#include <qscriptengine.h>
#include <QtCore/qvarlengtharray.h>
@@ -74,10 +75,13 @@ void QDeclarativeContextPrivate::addScript(const QDeclarativeParser::Object::Scr
QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
+
scriptContext->pushScope(enginePriv->contextClass->newContext(q, scopeObject));
+ scriptContext->pushScope(enginePriv->globalClass->globalObject());
QScriptValue scope = scriptEngine->newObject();
scriptContext->setActivationObject(scope);
+ scriptContext->pushScope(scope);
for (int ii = 0; ii < script.codes.count(); ++ii) {
scriptEngine->evaluate(script.codes.at(ii), script.files.at(ii), script.lineNumbers.at(ii));
@@ -480,7 +484,10 @@ QVariant QDeclarativeContext::contextProperty(const QString &name) const
if (!value.isValid() && parentContext())
value = parentContext()->contextProperty(name);
} else {
- value = d->propertyValues[idx];
+ if (idx >= d->propertyValues.count())
+ value = QVariant::fromValue(d->idValues[idx - d->propertyValues.count()].data());
+ else
+ value = d->propertyValues[idx];
}
return value;
diff --git a/src/declarative/qml/qdeclarativecontextscriptclass.cpp b/src/declarative/qml/qdeclarativecontextscriptclass.cpp
index 7deed0b..5fcf4e2 100644
--- a/src/declarative/qml/qdeclarativecontextscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativecontextscriptclass.cpp
@@ -50,10 +50,11 @@
QT_BEGIN_NAMESPACE
struct ContextData : public QScriptDeclarativeClass::Object {
- ContextData() : isSharedContext(true) {}
- ContextData(QDeclarativeContext *c, QObject *o) : context(c), scopeObject(o), isSharedContext(false) {}
+ ContextData() : overrideObject(0), isSharedContext(true) {}
+ ContextData(QDeclarativeContext *c, QObject *o) : context(c), scopeObject(o), overrideObject(0), isSharedContext(false) {}
QDeclarativeGuard<QDeclarativeContext> context;
QDeclarativeGuard<QObject> scopeObject;
+ QObject *overrideObject;
bool isSharedContext;
QDeclarativeContext *getContext(QDeclarativeEngine *engine) {
@@ -110,6 +111,17 @@ QDeclarativeContext *QDeclarativeContextScriptClass::contextFromValue(const QScr
return data->getContext(engine);
}
+QObject *QDeclarativeContextScriptClass::setOverrideObject(QScriptValue &v, QObject *override)
+{
+ if (scriptClass(v) != this)
+ return 0;
+
+ ContextData *data = (ContextData *)object(v);
+ QObject *rv = data->overrideObject;
+ data->overrideObject = override;
+ return rv;
+}
+
QScriptClass::QueryFlags
QDeclarativeContextScriptClass::queryProperty(Object *object, const Identifier &name,
QScriptClass::QueryFlags flags)
@@ -127,6 +139,20 @@ QDeclarativeContextScriptClass::queryProperty(Object *object, const Identifier &
if (!bindContext)
return 0;
+ QObject *overrideObject = ((ContextData *)object)->overrideObject;
+ if (overrideObject) {
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+ QScriptClass::QueryFlags rv =
+ ep->objectClass->queryProperty(overrideObject, name, flags, bindContext,
+ QDeclarativeObjectScriptClass::ImplicitObject |
+ QDeclarativeObjectScriptClass::SkipAttachedProperties);
+ if (rv) {
+ lastScopeObject = overrideObject;
+ lastContext = bindContext;
+ return rv;
+ }
+ }
+
bool includeTypes = true;
while (bindContext) {
QScriptClass::QueryFlags rv =
@@ -236,8 +262,9 @@ QDeclarativeContextScriptClass::property(Object *object, const Identifier &name)
}
}
- ep->capturedProperties <<
- QDeclarativeEnginePrivate::CapturedProperty(bindContext, -1, lastPropertyIndex + cp->notifyIndex);
+ if (ep->captureProperties)
+ ep->capturedProperties << QDeclarativeEnginePrivate::CapturedProperty(bindContext, -1, lastPropertyIndex + cp->notifyIndex);
+
return Value(scriptEngine, rv);
} else if(lastDefaultObject != -1) {
diff --git a/src/declarative/qml/qdeclarativecontextscriptclass_p.h b/src/declarative/qml/qdeclarativecontextscriptclass_p.h
index 26086ec..4b0dca0 100644
--- a/src/declarative/qml/qdeclarativecontextscriptclass_p.h
+++ b/src/declarative/qml/qdeclarativecontextscriptclass_p.h
@@ -70,6 +70,7 @@ public:
QScriptValue newSharedContext();
QDeclarativeContext *contextFromValue(const QScriptValue &);
+ QObject *setOverrideObject(QScriptValue &, QObject *);
protected:
virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &,
diff --git a/src/declarative/qml/qdeclarativedeclarativedata_p.h b/src/declarative/qml/qdeclarativedeclarativedata_p.h
index 2c92419..ae40130 100644
--- a/src/declarative/qml/qdeclarativedeclarativedata_p.h
+++ b/src/declarative/qml/qdeclarativedeclarativedata_p.h
@@ -103,7 +103,10 @@ public:
static QDeclarativeDeclarativeData *get(const QObject *object, bool create = false) {
QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object));
- if (priv->declarativeData) {
+ if (priv->wasDeleted) {
+ Q_ASSERT(!create);
+ return 0;
+ } else if (priv->declarativeData) {
return static_cast<QDeclarativeDeclarativeData *>(priv->declarativeData);
} else if (create) {
priv->declarativeData = new QDeclarativeDeclarativeData;
@@ -117,6 +120,11 @@ public:
template<class T>
void QDeclarativeGuard<T>::addGuard()
{
+ if (QObjectPrivate::get(o)->wasDeleted) {
+ if (prev) remGuard();
+ return;
+ }
+
QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(o, true);
next = data->guards;
if (next) reinterpret_cast<QDeclarativeGuard<T> *>(next)->prev = &next;
diff --git a/src/declarative/qml/qdeclarativedom.cpp b/src/declarative/qml/qdeclarativedom.cpp
index 6c81f34..cb56ead 100644
--- a/src/declarative/qml/qdeclarativedom.cpp
+++ b/src/declarative/qml/qdeclarativedom.cpp
@@ -374,7 +374,10 @@ QDeclarativeDomValue QDeclarativeDomProperty::value() const
QDeclarativeDomValue rv;
if (d->property) {
rv.d->property = d->property;
- rv.d->value = d->property->values.at(0);
+ if (d->property->values.count())
+ rv.d->value = d->property->values.at(0);
+ else
+ rv.d->value = d->property->onValues.at(0);
rv.d->property->addref();
rv.d->value->addref();
}
@@ -505,7 +508,7 @@ int QDeclarativeDomDynamicProperty::propertyType() const
QByteArray QDeclarativeDomDynamicProperty::propertyTypeName() const
{
- if (isValid())
+ if (isValid())
return d->property.customType;
return QByteArray();
@@ -1181,7 +1184,7 @@ QDeclarativeDomObject QDeclarativeDomValueValueSource::object() const
\qml
Rectangle {
- x: Behavior { NumberAnimation { duration: 500 } }
+ Behavior on x { NumberAnimation { duration: 500 } }
}
\endqml
*/
@@ -1225,7 +1228,7 @@ QDeclarativeDomValueValueInterceptor &QDeclarativeDomValueValueInterceptor::oper
returned.
\qml
Rectangle {
- x: Behavior { NumberAnimation { duration: 500 } }
+ Behavior on x { NumberAnimation { duration: 500 } }
}
\endqml
*/
@@ -1346,7 +1349,7 @@ QDeclarativeDomValue::Type QDeclarativeDomValue::type() const
{
if (d->property)
if (QDeclarativeMetaType::isList(d->property->type) ||
- (d->property && d->property->values.count() > 1))
+ (d->property && (d->property->values.count() + d->property->onValues.count()) > 1))
return List;
QDeclarativeParser::Value *value = d->value;
@@ -1628,6 +1631,13 @@ QList<QDeclarativeDomValue> QDeclarativeDomList::values() const
rv << v;
}
+ for (int ii = 0; ii < d->property->onValues.count(); ++ii) {
+ QDeclarativeDomValue v;
+ v.d->value = d->property->onValues.at(ii);
+ v.d->value->addref();
+ rv << v;
+ }
+
return rv;
}
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index af75e98..41d55d7 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -167,6 +167,7 @@ QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e)
QDeclarativeItemModule::defineModule();
QDeclarativeUtilModule::defineModule();
QDeclarativeEnginePrivate::defineModule();
+ QDeclarativeValueTypeFactory::registerValueTypes();
}
globalClass = new QDeclarativeGlobalScriptClass(&scriptEngine);
@@ -236,9 +237,13 @@ QDeclarativeScriptEngine::QDeclarativeScriptEngine(QDeclarativeEnginePrivate *pr
qtObject.setProperty(QLatin1String("tint"), newFunction(QDeclarativeEnginePrivate::tint, 2));
}
+ //date/time formatting
+ qtObject.setProperty(QLatin1String("formatDate"),newFunction(QDeclarativeEnginePrivate::formatDate, 2));
+ qtObject.setProperty(QLatin1String("formatTime"),newFunction(QDeclarativeEnginePrivate::formatTime, 2));
+ qtObject.setProperty(QLatin1String("formatDateTime"),newFunction(QDeclarativeEnginePrivate::formatDateTime, 2));
+
//misc methods
qtObject.setProperty(QLatin1String("closestAngle"), newFunction(QDeclarativeEnginePrivate::closestAngle, 2));
- qtObject.setProperty(QLatin1String("playSound"), newFunction(QDeclarativeEnginePrivate::playSound, 1));
qtObject.setProperty(QLatin1String("openUrlExternally"),newFunction(QDeclarativeEnginePrivate::desktopOpenUrl, 1));
qtObject.setProperty(QLatin1String("md5"),newFunction(QDeclarativeEnginePrivate::md5, 1));
qtObject.setProperty(QLatin1String("btoa"),newFunction(QDeclarativeEnginePrivate::btoa, 1));
@@ -936,6 +941,66 @@ QScriptValue QDeclarativeEnginePrivate::vector(QScriptContext *ctxt, QScriptEngi
return engine->newVariant(qVariantFromValue(QVector3D(x, y, z)));
}
+QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptEngine*engine)
+{
+ int argCount = ctxt->argumentCount();
+ if(argCount == 0 || argCount > 2)
+ return engine->nullValue();
+
+ QDate date = ctxt->argument(0).toDateTime().date();
+ Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
+ if (argCount == 2) {
+ if (ctxt->argument(1).isString()) {
+ QString format = ctxt->argument(1).toString();
+ return engine->newVariant(qVariantFromValue(date.toString(format)));
+ } else if (ctxt->argument(1).isNumber()) {
+ enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32());
+ } else
+ return engine->nullValue();
+ }
+ return engine->newVariant(qVariantFromValue(date.toString(enumFormat)));
+}
+
+QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptEngine*engine)
+{
+ int argCount = ctxt->argumentCount();
+ if(argCount == 0 || argCount > 2)
+ return engine->nullValue();
+
+ QTime date = ctxt->argument(0).toDateTime().time();
+ Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
+ if (argCount == 2) {
+ if (ctxt->argument(1).isString()) {
+ QString format = ctxt->argument(1).toString();
+ return engine->newVariant(qVariantFromValue(date.toString(format)));
+ } else if (ctxt->argument(1).isNumber()) {
+ enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32());
+ } else
+ return engine->nullValue();
+ }
+ return engine->newVariant(qVariantFromValue(date.toString(enumFormat)));
+}
+
+QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScriptEngine*engine)
+{
+ int argCount = ctxt->argumentCount();
+ if(argCount == 0 || argCount > 2)
+ return engine->nullValue();
+
+ QDateTime date = ctxt->argument(0).toDateTime();
+ Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
+ if (argCount == 2) {
+ if (ctxt->argument(1).isString()) {
+ QString format = ctxt->argument(1).toString();
+ return engine->newVariant(qVariantFromValue(date.toString(format)));
+ } else if (ctxt->argument(1).isNumber()) {
+ enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32());
+ } else
+ return engine->nullValue();
+ }
+ return engine->newVariant(qVariantFromValue(date.toString(enumFormat)));
+}
+
QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine *engine)
{
int argCount = ctxt->argumentCount();
@@ -1040,30 +1105,6 @@ QScriptValue QDeclarativeEnginePrivate::darker(QScriptContext *ctxt, QScriptEngi
return qScriptValueFromValue(engine, qVariantFromValue(color));
}
-QScriptValue QDeclarativeEnginePrivate::playSound(QScriptContext *ctxt, QScriptEngine *engine)
-{
- if (ctxt->argumentCount() != 1)
- return engine->undefinedValue();
-
- QUrl url(ctxt->argument(0).toString());
-
- QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine);
- if (url.isRelative()) {
- QDeclarativeContext *context = enginePriv->getContext(ctxt);
- if (!context)
- return engine->undefinedValue();
-
- url = context->resolvedUrl(url);
- }
-
- if (url.scheme() == QLatin1String("file")) {
-
- QSound::play(url.toLocalFile());
-
- }
- return engine->undefinedValue();
-}
-
QScriptValue QDeclarativeEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QScriptEngine *e)
{
if(ctxt->argumentCount() < 1)
@@ -1193,17 +1234,13 @@ QScriptValue QDeclarativeEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine
else if (a == 0x00)
finalColor = color;
else {
- uint src = tintColor.rgba();
- uint dest = color.rgba();
+ qreal a = tintColor.alphaF();
+ qreal inv_a = 1.0 - a;
- uint res = (((a * (src & 0xFF00FF)) +
- ((0xFF - a) * (dest & 0xFF00FF))) >> 8) & 0xFF00FF;
- res |= (((a * ((src >> 8) & 0xFF00FF)) +
- ((0xFF - a) * ((dest >> 8) & 0xFF00FF)))) & 0xFF00FF00;
- if ((src & 0xFF000000) == 0xFF000000)
- res |= 0xFF000000;
-
- finalColor = QColor::fromRgba(res);
+ finalColor.setRgbF(tintColor.redF() * a + color.redF() * inv_a,
+ tintColor.greenF() * a + color.greenF() * inv_a,
+ tintColor.blueF() * a + color.blueF() * inv_a,
+ a + inv_a * color.alphaF());
}
return qScriptValueFromValue(engine, qVariantFromValue(finalColor));
@@ -1383,7 +1420,11 @@ public:
paths += QFileInfo(base.toLocalFile()).path();
paths += importPath;
paths += QDeclarativeEnginePrivate::get(engine)->environmentImportPath;
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
QString builtinPath = QLibraryInfo::location(QLibraryInfo::ImportsPath);
+#else
+ QString builtinPath;
+#endif
if (!builtinPath.isEmpty())
paths += builtinPath;
@@ -1687,6 +1728,7 @@ QString QDeclarativeEngine::offlineStoragePath() const
\internal
Returns the result of the merge of \a baseName with \a dir, \a suffixes, and \a prefix.
+ The \a prefix must contain the dot.
*/
QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString &baseName,
const QStringList &suffixes,
@@ -1696,7 +1738,6 @@ QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString
QString pluginFileName = prefix;
pluginFileName += baseName;
- pluginFileName += QLatin1Char('.');
pluginFileName += suffix;
QFileInfo fileInfo(dir, pluginFileName);
@@ -1728,14 +1769,26 @@ QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString
QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString &baseName)
{
#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
- return resolvePlugin(dir, baseName, QStringList(QLatin1String("dll")));
+ return resolvePlugin(dir, baseName,
+ QStringList()
+# ifdef QT_DEBUG
+ << QLatin1String("d.dll") // try a qmake-style debug build first
+# endif
+ << QLatin1String(".dll"));
#elif defined(Q_OS_SYMBIAN)
- return resolvePlugin(dir, baseName, QStringList() << QLatin1String("dll") << QLatin1String("qtplugin"));
+ return resolvePlugin(dir, baseName,
+ QStringList()
+ << QLatin1String(".dll")
+ << QLatin1String(".qtplugin"));
#else
# if defined(Q_OS_DARWIN)
- return resolvePlugin(dir, baseName, QStringList() << QLatin1String("dylib") << QLatin1String("so") << QLatin1String("bundle"),
+ return resolvePlugin(dir, baseName,
+ QStringList()
+ << QLatin1String(".dylib")
+ << QLatin1String(".so")
+ << QLatin1String(".bundle"),
QLatin1String("lib"));
# else // Generic Unix
QStringList validSuffixList;
@@ -1746,14 +1799,14 @@ QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString
"In PA-RISC (PA-32 and PA-64) shared libraries are suffixed with .sl. In IPF (32-bit and 64-bit),
the shared libraries are suffixed with .so. For compatibility, the IPF linker also supports the .sl suffix."
*/
- validSuffixList << QLatin1String("sl");
+ validSuffixList << QLatin1String(".sl");
# if defined __ia64
- validSuffixList << QLatin1String("so");
+ validSuffixList << QLatin1String(".so");
# endif
# elif defined(Q_OS_AIX)
- validSuffixList << QLatin1String("a") << QLatin1String("so");
+ validSuffixList << QLatin1String(".a") << QLatin1String(".so");
# elif defined(Q_OS_UNIX)
- validSuffixList << QLatin1String("so");
+ validSuffixList << QLatin1String(".so");
# endif
// Examples of valid library names:
diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h
index 0359f98..459a325 100644
--- a/src/declarative/qml/qdeclarativeengine_p.h
+++ b/src/declarative/qml/qdeclarativeengine_p.h
@@ -238,7 +238,8 @@ public:
QHash<const QMetaObject *, QDeclarativePropertyCache *> propertyCache;
QDeclarativePropertyCache *cache(QObject *obj) {
Q_Q(QDeclarativeEngine);
- if (!obj || QObjectPrivate::get(obj)->metaObject) return 0;
+ if (!obj || QObjectPrivate::get(obj)->metaObject ||
+ QObjectPrivate::get(obj)->wasDeleted) return 0;
const QMetaObject *mo = obj->metaObject();
QDeclarativePropertyCache *rv = propertyCache.value(mo);
if (!rv) {
@@ -318,7 +319,6 @@ public:
static QScriptValue tint(QScriptContext*, QScriptEngine*);
static QScriptValue closestAngle(QScriptContext*, QScriptEngine*);
- static QScriptValue playSound(QScriptContext*, QScriptEngine*);
static QScriptValue desktopOpenUrl(QScriptContext*, QScriptEngine*);
static QScriptValue md5(QScriptContext*, QScriptEngine*);
static QScriptValue btoa(QScriptContext*, QScriptEngine*);
@@ -326,6 +326,10 @@ public:
static QScriptValue consoleLog(QScriptContext*, QScriptEngine*);
static QScriptValue quit(QScriptContext*, QScriptEngine*);
+ static QScriptValue formatDate(QScriptContext*, QScriptEngine*);
+ static QScriptValue formatTime(QScriptContext*, QScriptEngine*);
+ static QScriptValue formatDateTime(QScriptContext*, QScriptEngine*);
+
static QScriptEngine *getScriptEngine(QDeclarativeEngine *e) { return &e->d_func()->scriptEngine; }
static QDeclarativeEngine *getEngine(QScriptEngine *e) { return static_cast<QDeclarativeScriptEngine*>(e)->p->q_func(); }
static QDeclarativeEnginePrivate *get(QDeclarativeEngine *e) { return e->d_func(); }
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp
index 09882cb..3e4acbe 100644
--- a/src/declarative/qml/qdeclarativeenginedebug.cpp
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -117,7 +117,7 @@ QDeclarativeEngineDebugServer::propertyData(QObject *obj, int propIdx)
QVariant value = prop.read(obj);
rv.value = valueContents(value);
- if (QVariant::Type(prop.userType()) < QVariant::UserType) {
+ if (QDeclarativeValueTypeFactory::isValueType(prop.userType())) {
rv.type = QDeclarativeObjectProperty::Basic;
} else if (QDeclarativeMetaType::isQObject(prop.userType())) {
rv.type = QDeclarativeObjectProperty::Object;
@@ -131,7 +131,7 @@ QDeclarativeEngineDebugServer::propertyData(QObject *obj, int propIdx)
QVariant QDeclarativeEngineDebugServer::valueContents(const QVariant &value) const
{
int userType = value.userType();
- if (QVariant::Type(userType) < QVariant::UserType)
+ if (QDeclarativeValueTypeFactory::isValueType(userType))
return value;
/*
diff --git a/src/declarative/qml/qdeclarativeenginedebug_p.h b/src/declarative/qml/qdeclarativeenginedebug_p.h
index 89da399..a95449b 100644
--- a/src/declarative/qml/qdeclarativeenginedebug_p.h
+++ b/src/declarative/qml/qdeclarativeenginedebug_p.h
@@ -53,7 +53,7 @@
// We mean it.
//
-#include "../debugger/qdeclarativedebugservice_p.h"
+#include <private/qdeclarativedebugservice_p.h>
#include <QtCore/qurl.h>
#include <QtCore/qvariant.h>
diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp
index ae1e790..e528e9e 100644
--- a/src/declarative/qml/qdeclarativeexpression.cpp
+++ b/src/declarative/qml/qdeclarativeexpression.cpp
@@ -46,6 +46,7 @@
#include "qdeclarativecontext_p.h"
#include "qdeclarativerewrite_p.h"
#include "qdeclarativecompiler_p.h"
+#include "qdeclarativeglobalscriptclass_p.h"
#include <QtCore/qdebug.h>
#include <QtScript/qscriptprogram.h>
@@ -135,6 +136,7 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContext *ctxt, void *expr,
if (!dd->cachedClosures.at(progIdx)) {
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
scriptContext->pushScope(ep->contextClass->newSharedContext());
+ scriptContext->pushScope(ep->globalClass->globalObject());
dd->cachedClosures[progIdx] = new QScriptValue(scriptEngine->evaluate(data->expression, data->url, data->line));
scriptEngine->popContext();
}
@@ -151,9 +153,11 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContext *ctxt, void *expr,
new QScriptProgram(data->expression, data->url, data->line);
}
- data->expressionFunction = evalInObjectScope(ctxt, me, *dd->cachedPrograms.at(progIdx));
+ data->expressionFunction = evalInObjectScope(ctxt, me, *dd->cachedPrograms.at(progIdx),
+ &data->expressionContext);
#else
- data->expressionFunction = evalInObjectScope(ctxt, me, data->expression);
+ data->expressionFunction = evalInObjectScope(ctxt, me, data->expression,
+ &data->expressionContext);
#endif
data->expressionFunctionValid = true;
@@ -164,22 +168,34 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContext *ctxt, void *expr,
}
QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContext *context, QObject *object,
- const QString &program)
+ const QString &program, QScriptValue *contextObject)
{
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine());
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(&ep->scriptEngine);
- scriptContext->pushScope(ep->contextClass->newContext(context, object));
+ if (contextObject) {
+ *contextObject = ep->contextClass->newContext(context, object);
+ scriptContext->pushScope(*contextObject);
+ } else {
+ scriptContext->pushScope(ep->contextClass->newContext(context, object));
+ }
+ scriptContext->pushScope(ep->globalClass->globalObject());
QScriptValue rv = ep->scriptEngine.evaluate(program);
ep->scriptEngine.popContext();
return rv;
}
QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContext *context, QObject *object,
- const QScriptProgram &program)
+ const QScriptProgram &program, QScriptValue *contextObject)
{
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine());
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(&ep->scriptEngine);
- scriptContext->pushScope(ep->contextClass->newContext(context, object));
+ if (contextObject) {
+ *contextObject = ep->contextClass->newContext(context, object);
+ scriptContext->pushScope(*contextObject);
+ } else {
+ scriptContext->pushScope(ep->contextClass->newContext(context, object));
+ }
+ scriptContext->pushScope(ep->globalClass->globalObject());
QScriptValue rv = ep->scriptEngine.evaluate(program);
ep->scriptEngine.popContext();
return rv;
@@ -326,15 +342,14 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo
QDeclarativeEngine *engine = data->context()->engine();
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
- if (secondaryScope)
- ctxtPriv->defaultObjects.append(secondaryScope);
-
QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
if (!data->expressionFunctionValid) {
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
- scriptContext->pushScope(ep->contextClass->newContext(data->context(), data->me));
+ data->expressionContext = ep->contextClass->newContext(data->context(), data->me);
+ scriptContext->pushScope(data->expressionContext);
+ scriptContext->pushScope(ep->globalClass->globalObject());
if (data->expressionRewritten) {
data->expressionFunction = scriptEngine->evaluate(data->expression,
@@ -357,11 +372,14 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo
QDeclarativeContext *oldSharedContext = 0;
QObject *oldSharedScope = 0;
+ QObject *oldOverride = 0;
if (data->isShared) {
oldSharedContext = ep->sharedContext;
oldSharedScope = ep->sharedScope;
ep->sharedContext = data->context();
ep->sharedScope = data->me;
+ } else {
+ oldOverride = ep->contextClass->setOverrideObject(data->expressionContext, secondaryScope);
}
QScriptValue svalue = data->expressionFunction.call();
@@ -369,6 +387,8 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo
if (data->isShared) {
ep->sharedContext = oldSharedContext;
ep->sharedScope = oldSharedScope;
+ } else {
+ ep->contextClass->setOverrideObject(data->expressionContext, oldOverride);
}
if (isUndefined)
@@ -383,12 +403,6 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo
data->error = QDeclarativeError();
}
- if (secondaryScope) {
- QObject *last = ctxtPriv->defaultObjects.takeLast();
- Q_ASSERT(last == secondaryScope);
- Q_UNUSED(last);
- }
-
QVariant rv;
if (svalue.isArray()) {
diff --git a/src/declarative/qml/qdeclarativeexpression_p.h b/src/declarative/qml/qdeclarativeexpression_p.h
index 91ac4c0..cd1729d 100644
--- a/src/declarative/qml/qdeclarativeexpression_p.h
+++ b/src/declarative/qml/qdeclarativeexpression_p.h
@@ -119,6 +119,7 @@ public:
bool expressionFunctionValid:1;
bool expressionRewritten:1;
QScriptValue expressionFunction;
+ QScriptValue expressionContext;
QObject *me;
bool trackChange;
@@ -180,8 +181,8 @@ public:
virtual void emitValueChanged();
static void exceptionToError(QScriptEngine *, QDeclarativeError &);
- static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QString &);
- static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QScriptProgram &);
+ static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QString &, QScriptValue * = 0);
+ static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QScriptProgram &, QScriptValue * = 0);
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeglobal_p.h b/src/declarative/qml/qdeclarativeglobal_p.h
index bbdc91c..1041992 100644
--- a/src/declarative/qml/qdeclarativeglobal_p.h
+++ b/src/declarative/qml/qdeclarativeglobal_p.h
@@ -79,7 +79,7 @@ struct QDeclarativeGraphics_DerivedObject : public QObject
neither \a parent nor the object's previous parent (if it had one) will
receive ChildRemoved or ChildAdded events.
*/
-inline void QDeclarativeGraphics_setParent_noEvent(QObject *object, QObject *parent)
+inline void QDeclarative_setParent_noEvent(QObject *object, QObject *parent)
{
static_cast<QDeclarativeGraphics_DerivedObject *>(object)->setParent_noEvent(parent);
}
diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
index 5b06b42..9ee2fe5 100644
--- a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
@@ -53,15 +53,17 @@ QT_BEGIN_NAMESPACE
QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass(QScriptEngine *engine)
: QScriptClass(engine)
{
- QScriptValue v = engine->newObject();
- globalObject = engine->globalObject();
+ QScriptValue globalObject = engine->globalObject();
+ m_globalObject = engine->newObject();
QScriptValueIterator iter(globalObject);
while (iter.hasNext()) {
iter.next();
- v.setProperty(iter.scriptName(), iter.value());
+ m_globalObject.setProperty(iter.scriptName(), iter.value());
+ m_illegalNames.insert(iter.name());
}
+ QScriptValue v = engine->newObject();
v.setScriptClass(this);
engine->setGlobalObject(v);
}
@@ -101,12 +103,14 @@ void QDeclarativeGlobalScriptClass::setProperty(QScriptValue &object,
engine()->currentContext()->throwError(error);
}
+/* This method is for the use of tst_qdeclarativeecmascript::callQtInvokables() only */
void QDeclarativeGlobalScriptClass::explicitSetProperty(const QString &name, const QScriptValue &value)
{
+ QScriptValue globalObject = engine()->globalObject();
+
QScriptValue v = engine()->newObject();
- globalObject = engine()->globalObject();
- QScriptValueIterator iter(globalObject);
+ QScriptValueIterator iter(v);
while (iter.hasNext()) {
iter.next();
v.setProperty(iter.scriptName(), iter.value());
@@ -114,6 +118,7 @@ void QDeclarativeGlobalScriptClass::explicitSetProperty(const QString &name, con
v.setProperty(name, value);
v.setScriptClass(this);
+
engine()->setGlobalObject(v);
}
diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
index a33cf5e..1b34aee 100644
--- a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
+++ b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
@@ -54,6 +54,7 @@
//
#include <QtScript/qscriptclass.h>
+#include <QtCore/qset.h>
QT_BEGIN_NAMESPACE
@@ -74,8 +75,12 @@ public:
void explicitSetProperty(const QString &, const QScriptValue &);
+ const QScriptValue &globalObject() const { return m_globalObject; }
+ const QSet<QString> &illegalNames() const { return m_illegalNames; }
+
private:
- QScriptValue globalObject;
+ QSet<QString> m_illegalNames;
+ QScriptValue m_globalObject;
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeinstruction_p.h b/src/declarative/qml/qdeclarativeinstruction_p.h
index d8af6a7..ec32b35 100644
--- a/src/declarative/qml/qdeclarativeinstruction_p.h
+++ b/src/declarative/qml/qdeclarativeinstruction_p.h
@@ -161,154 +161,180 @@ public:
Type type;
unsigned short line;
+
+ struct InitInstruction {
+ int bindingsSize;
+ int parserStatusSize;
+ int contextCache;
+ int compiledBinding;
+ };
+ struct CreateInstruction {
+ int type;
+ int data;
+ int bindingBits;
+ ushort column;
+ };
+ struct StoreMetaInstruction {
+ int data;
+ int aliasData;
+ int propertyCache;
+ };
+ struct SetIdInstruction {
+ int value;
+ int index;
+ };
+ struct AssignValueSourceInstruction {
+ int property;
+ int owner;
+ int castValue;
+ };
+ struct AssignValueInterceptorInstruction {
+ int property;
+ int owner;
+ int castValue;
+ };
+ struct AssignBindingInstruction {
+ unsigned int property;
+ int value;
+ short context;
+ short owner;
+ };
+ struct FetchInstruction {
+ int property;
+ };
+ struct FetchValueInstruction {
+ int property;
+ int type;
+ };
+ struct FetchQmlListInstruction {
+ int property;
+ int type;
+ };
+ struct BeginInstruction {
+ int castValue;
+ };
+ struct StoreFloatInstruction {
+ int propertyIndex;
+ float value;
+ };
+ struct StoreDoubleInstruction {
+ int propertyIndex;
+ double value;
+ };
+ struct StoreIntegerInstruction {
+ int propertyIndex;
+ int value;
+ };
+ struct StoreBoolInstruction {
+ int propertyIndex;
+ bool value;
+ };
+ struct StoreStringInstruction {
+ int propertyIndex;
+ int value;
+ };
+ struct StoreScriptStringInstruction {
+ int propertyIndex;
+ int value;
+ int scope;
+ };
+ struct StoreScriptInstruction {
+ int value;
+ };
+ struct StoreUrlInstruction {
+ int propertyIndex;
+ int value;
+ };
+ struct StoreColorInstruction {
+ int propertyIndex;
+ unsigned int value;
+ };
+ struct StoreDateInstruction {
+ int propertyIndex;
+ int value;
+ };
+ struct StoreTimeInstruction {
+ int propertyIndex;
+ int valueIndex;
+ };
+ struct StoreDateTimeInstruction {
+ int propertyIndex;
+ int valueIndex;
+ };
+ struct StoreRealPairInstruction {
+ int propertyIndex;
+ int valueIndex;
+ };
+ struct StoreRectInstruction {
+ int propertyIndex;
+ int valueIndex;
+ };
+ struct StoreVector3DInstruction {
+ int propertyIndex;
+ int valueIndex;
+ };
+ struct StoreObjectInstruction {
+ int propertyIndex;
+ };
+ struct AssignCustomTypeInstruction {
+ int propertyIndex;
+ int valueIndex;
+ };
+ struct StoreSignalInstruction {
+ int signalIndex;
+ int value;
+ int context;
+ };
+ struct AssignSignalObjectInstruction {
+ int signal;
+ };
+ struct CreateComponentInstruction {
+ int count;
+ ushort column;
+ int endLine;
+ int metaObject;
+ };
+ struct FetchAttachedInstruction {
+ int id;
+ };
+ struct DeferInstruction {
+ int deferCount;
+ };
+
union {
- struct {
- int bindingsSize;
- int parserStatusSize;
- int contextCache;
- int compiledBinding;
- } init;
- struct {
- int type;
- int data;
- int bindingBits;
- ushort column;
- } create;
- struct {
- int data;
- int aliasData;
- int propertyCache;
- } storeMeta;
- struct {
- int value;
- int index;
- } setId;
- struct {
- int property;
- int owner;
- int castValue;
- } assignValueSource;
- struct {
- int property;
- int owner;
- int castValue;
- } assignValueInterceptor;
- struct {
- unsigned int property;
- int value;
- short context;
- short owner;
- } assignBinding;
- struct {
- int property;
- int id;
- } assignIdOptBinding;
- struct {
- int property;
- int contextIdx;
- short context;
- short notifyIdx;
- } assignObjPropBinding;
- struct {
- int property;
- } fetch;
- struct {
- int property;
- int type;
- } fetchValue;
- struct {
- int property;
- int type;
- } fetchQmlList;
- struct {
- int castValue;
- } begin;
- struct {
- int propertyIndex;
- float value;
- } storeFloat;
- struct {
- int propertyIndex;
- double value;
- } storeDouble;
- struct {
- int propertyIndex;
- int value;
- } storeInteger;
- struct {
- int propertyIndex;
- bool value;
- } storeBool;
- struct {
- int propertyIndex;
- int value;
- } storeString;
- struct {
- int propertyIndex;
- int value;
- int scope;
- } storeScriptString;
- struct {
- int value;
- } storeScript;
- struct {
- int propertyIndex;
- int value;
- } storeUrl;
- struct {
- int propertyIndex;
- unsigned int value;
- } storeColor;
- struct {
- int propertyIndex;
- int value;
- } storeDate;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeTime;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeDateTime;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeRealPair;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeRect;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeVector3D;
- struct {
- int propertyIndex;
- } storeObject;
- struct {
- int propertyIndex;
- int valueIndex;
- } assignCustomType;
- struct {
- int signalIndex;
- int value;
- } storeSignal;
- struct {
- int signal;
- } assignSignalObject;
- struct {
- int count;
- ushort column;
- int endLine;
- int metaObject;
- } createComponent;
- struct {
- int id;
- } fetchAttached;
- struct {
- int deferCount;
- } defer;
+ InitInstruction init;
+ CreateInstruction create;
+ StoreMetaInstruction storeMeta;
+ SetIdInstruction setId;
+ AssignValueSourceInstruction assignValueSource;
+ AssignValueInterceptorInstruction assignValueInterceptor;
+ AssignBindingInstruction assignBinding;
+ FetchInstruction fetch;
+ FetchValueInstruction fetchValue;
+ FetchQmlListInstruction fetchQmlList;
+ BeginInstruction begin;
+ StoreFloatInstruction storeFloat;
+ StoreDoubleInstruction storeDouble;
+ StoreIntegerInstruction storeInteger;
+ StoreBoolInstruction storeBool;
+ StoreStringInstruction storeString;
+ StoreScriptStringInstruction storeScriptString;
+ StoreScriptInstruction storeScript;
+ StoreUrlInstruction storeUrl;
+ StoreColorInstruction storeColor;
+ StoreDateInstruction storeDate;
+ StoreTimeInstruction storeTime;
+ StoreDateTimeInstruction storeDateTime;
+ StoreRealPairInstruction storeRealPair;
+ StoreRectInstruction storeRect;
+ StoreVector3DInstruction storeVector3D;
+ StoreObjectInstruction storeObject;
+ AssignCustomTypeInstruction assignCustomType;
+ StoreSignalInstruction storeSignal;
+ AssignSignalObjectInstruction assignSignalObject;
+ CreateComponentInstruction createComponent;
+ FetchAttachedInstruction fetchAttached;
+ DeferInstruction defer;
};
void dump(QDeclarativeCompiledData *);
diff --git a/src/declarative/qml/qdeclarativelist.h b/src/declarative/qml/qdeclarativelist.h
index 8d59384..eac4967 100644
--- a/src/declarative/qml/qdeclarativelist.h
+++ b/src/declarative/qml/qdeclarativelist.h
@@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QObject;
-class QMetaObject;
+struct QMetaObject;
template<typename T>
struct QDeclarativeListProperty {
typedef void (*AppendFunction)(QDeclarativeListProperty<T> *, T*);
diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp
index abbb9d6..50ab56b 100644
--- a/src/declarative/qml/qdeclarativemetatype.cpp
+++ b/src/declarative/qml/qdeclarativemetatype.cpp
@@ -286,6 +286,11 @@ QDeclarativeCustomParser *QDeclarativeType::customParser() const
return d->m_customParser;
}
+bool QDeclarativeType::isCreatable() const
+{
+ return d->m_newFunc != 0;
+}
+
bool QDeclarativeType::isInterface() const
{
return d->m_isInterface;
@@ -402,7 +407,7 @@ int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &t
data->types.append(dtype);
data->idToType.insert(dtype->typeId(), dtype);
- data->idToType.insert(dtype->qListTypeId(), dtype);
+ if (dtype->qListTypeId()) data->idToType.insert(dtype->qListTypeId(), dtype);
if (!dtype->qmlTypeName().isEmpty())
data->nameToType.insertMulti(dtype->qmlTypeName(), dtype);
@@ -414,7 +419,7 @@ int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &t
if (data->lists.size() <= type.listId)
data->lists.resize(type.listId + 16);
data->objects.setBit(type.typeId, true);
- data->lists.setBit(type.listId, true);
+ if (type.listId) data->lists.setBit(type.listId, true);
return index;
}
diff --git a/src/declarative/qml/qdeclarativemetatype_p.h b/src/declarative/qml/qdeclarativemetatype_p.h
index ec5c045..cf8946d 100644
--- a/src/declarative/qml/qdeclarativemetatype_p.h
+++ b/src/declarative/qml/qdeclarativemetatype_p.h
@@ -114,6 +114,8 @@ public:
QDeclarativeCustomParser *customParser() const;
+ bool isCreatable() const;
+
bool isInterface() const;
int typeId() const;
int qListTypeId() const;
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
index 542f417..e6f6e5f 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
@@ -232,7 +232,7 @@ QDeclarativeObjectScriptClass::property(QObject *obj, const Identifier &name)
QDeclarativeEnginePrivate::CapturedProperty(obj, lastData->coreIndex, lastData->notifyIndex);
}
- if ((uint)lastData->propType < QVariant::UserType) {
+ if (QDeclarativeValueTypeFactory::isValueType((uint)lastData->propType)) {
QDeclarativeValueType *valueType = enginePriv->valueTypes[lastData->propType];
if (valueType)
return Value(scriptEngine, enginePriv->valueTypeClass->newObject(obj, lastData->coreIndex, valueType));
@@ -442,6 +442,13 @@ QDeclarativeObjectMethodScriptClass::QDeclarativeObjectMethodScriptClass(QDeclar
engine(bindEngine)
{
setSupportsCall(true);
+
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ m_connect = scriptEngine->newFunction(connect);
+ m_connectId = createPersistentIdentifier(QLatin1String("connect"));
+ m_disconnect = scriptEngine->newFunction(disconnect);
+ m_disconnectId = createPersistentIdentifier(QLatin1String("disconnect"));
}
QDeclarativeObjectMethodScriptClass::~QDeclarativeObjectMethodScriptClass()
@@ -455,6 +462,80 @@ QScriptValue QDeclarativeObjectMethodScriptClass::newMethod(QObject *object, con
return newObject(scriptEngine, this, new MethodData(object, *method));
}
+QScriptValue QDeclarativeObjectMethodScriptClass::connect(QScriptContext *context, QScriptEngine *engine)
+{
+ QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine);
+
+ QScriptValue that = context->thisObject();
+ if (&p->objectClass->methods != scriptClass(that))
+ return engine->undefinedValue();
+
+ MethodData *data = (MethodData *)object(that);
+
+ if (!data->object || context->argumentCount() == 0)
+ return engine->undefinedValue();
+
+ QByteArray signal("2");
+ signal.append(data->object->metaObject()->method(data->data.coreIndex).signature());
+
+ if (context->argumentCount() == 1) {
+ qScriptConnect(data->object, signal.constData(), QScriptValue(), context->argument(0));
+ } else {
+ qScriptConnect(data->object, signal.constData(), context->argument(0), context->argument(1));
+ }
+
+ return engine->undefinedValue();
+}
+
+QScriptValue QDeclarativeObjectMethodScriptClass::disconnect(QScriptContext *context, QScriptEngine *engine)
+{
+ QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine);
+
+ QScriptValue that = context->thisObject();
+ if (&p->objectClass->methods != scriptClass(that))
+ return engine->undefinedValue();
+
+ MethodData *data = (MethodData *)object(that);
+
+ if (!data->object || context->argumentCount() == 0)
+ return engine->undefinedValue();
+
+ QByteArray signal("2");
+ signal.append(data->object->metaObject()->method(data->data.coreIndex).signature());
+
+ if (context->argumentCount() == 1) {
+ qScriptDisconnect(data->object, signal.constData(), QScriptValue(), context->argument(0));
+ } else {
+ qScriptDisconnect(data->object, signal.constData(), context->argument(0), context->argument(1));
+ }
+
+ return engine->undefinedValue();
+}
+
+QScriptClass::QueryFlags
+QDeclarativeObjectMethodScriptClass::queryProperty(Object *, const Identifier &name,
+ QScriptClass::QueryFlags flags)
+{
+ if (name == m_connectId.identifier || name == m_disconnectId.identifier)
+ return QScriptClass::HandlesReadAccess;
+ else
+ return 0;
+
+}
+
+QDeclarativeObjectScriptClass::ScriptValue
+QDeclarativeObjectMethodScriptClass::property(Object *, const Identifier &name)
+{
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ if (name == m_connectId.identifier)
+ return Value(scriptEngine, m_connect);
+ else if (name == m_disconnectId.identifier)
+ return Value(scriptEngine, m_disconnect);
+ else
+ return Value();
+}
+
namespace {
struct MetaCallArgument {
inline MetaCallArgument();
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
index 8023756..04e760f 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
@@ -73,10 +73,21 @@ public:
~QDeclarativeObjectMethodScriptClass();
QScriptValue newMethod(QObject *, const QDeclarativePropertyCache::Data *);
+
protected:
virtual Value call(Object *, QScriptContext *);
+ virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags);
+ virtual Value property(Object *, const Identifier &);
private:
+ PersistentIdentifier m_connectId;
+ PersistentIdentifier m_disconnectId;
+ QScriptValue m_connect;
+ QScriptValue m_disconnect;
+
+ static QScriptValue connect(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue disconnect(QScriptContext *context, QScriptEngine *engine);
+
QDeclarativeEngine *engine;
};
#endif
@@ -119,6 +130,7 @@ protected:
private:
#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE)
+ friend class QDeclarativeObjectMethodScriptClass;
QDeclarativeObjectMethodScriptClass methods;
#endif
diff --git a/src/declarative/qml/qdeclarativeparser.cpp b/src/declarative/qml/qdeclarativeparser.cpp
index 5ac49d5..b0599ad 100644
--- a/src/declarative/qml/qdeclarativeparser.cpp
+++ b/src/declarative/qml/qdeclarativeparser.cpp
@@ -221,12 +221,14 @@ QDeclarativeParser::Property::~Property()
{
foreach(Value *value, values)
value->release();
+ foreach(Value *value, onValues)
+ value->release();
if (value) value->release();
}
-Object *QDeclarativeParser::Property::getValue()
+Object *QDeclarativeParser::Property::getValue(const LocationSpan &l)
{
- if (!value) value = new Object;
+ if (!value) { value = new Object; value->location = l; }
return value;
}
@@ -235,9 +237,14 @@ void QDeclarativeParser::Property::addValue(Value *v)
values << v;
}
+void QDeclarativeParser::Property::addOnValue(Value *v)
+{
+ onValues << v;
+}
+
bool QDeclarativeParser::Property::isEmpty() const
{
- return !value && values.isEmpty();
+ return !value && values.isEmpty() && onValues.isEmpty();
}
QDeclarativeParser::Value::Value()
diff --git a/src/declarative/qml/qdeclarativeparser_p.h b/src/declarative/qml/qdeclarativeparser_p.h
index aae507e..5bf4b68 100644
--- a/src/declarative/qml/qdeclarativeparser_p.h
+++ b/src/declarative/qml/qdeclarativeparser_p.h
@@ -104,6 +104,11 @@ namespace QDeclarativeParser
Location start;
Location end;
LocationRange range;
+
+ bool operator<(LocationSpan &o) const {
+ return (start.line < o.start.line) ||
+ (start.line == o.start.line && start.column < o.start.column);
+ }
};
class Property;
@@ -318,8 +323,9 @@ namespace QDeclarativeParser
// The Object to which this property is attached
Object *parent;
- Object *getValue();
+ Object *getValue(const LocationSpan &);
void addValue(Value *v);
+ void addOnValue(Value *v);
// The QVariant::Type of the property, or 0 (QVariant::Invalid) if
// unknown.
@@ -333,6 +339,8 @@ namespace QDeclarativeParser
// The list of values assigned to this property. Content in values
// and value are mutually exclusive
QList<Value *> values;
+ // The list of values assigned to this property using the "on" syntax
+ QList<Value *> onValues;
// The accessed property. This is used to represent dot properties.
// Content in value and values are mutually exclusive.
Object *value;
diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp
index e1ec2cd..4f73b89 100644
--- a/src/declarative/qml/qdeclarativeproperty.cpp
+++ b/src/declarative/qml/qdeclarativeproperty.cpp
@@ -238,10 +238,10 @@ void QDeclarativePropertyPrivate::initProperty(QObject *obj, const QString &name
if (property->flags & QDeclarativePropertyCache::Data::IsFunction)
return; // Not an object property
- if (ii == (path.count() - 2) && property->propType < (int)QVariant::UserType) {
+ if (ii == (path.count() - 2) && QDeclarativeValueTypeFactory::isValueType(property->propType)) {
// We're now at a value type property. We can use a global valuetypes array as we
// never actually use the objects, just look up their properties.
- QObject *typeObject = qmlValueTypes()->valueTypes[property->propType];
+ QObject *typeObject = (*qmlValueTypes())[property->propType];
if (!typeObject) return; // Not a value type
int idx = typeObject->metaObject()->indexOfProperty(path.last().toUtf8().constData());
@@ -346,7 +346,7 @@ QDeclarativePropertyPrivate::propertyTypeCategory() const
int type = propertyType();
if (type == QVariant::Invalid)
return QDeclarativeProperty::InvalidCategory;
- else if ((uint)type < QVariant::UserType)
+ else if (QDeclarativeValueTypeFactory::isValueType((uint)type))
return QDeclarativeProperty::Normal;
else if (core.flags & QDeclarativePropertyCache::Data::IsQObjectDerived)
return QDeclarativeProperty::Object;
@@ -793,7 +793,7 @@ QVariant QDeclarativeProperty::read(QObject *object, const QString &name, QDecla
QVariant QDeclarativePropertyPrivate::readValueProperty()
{
- if(isValueType()) {
+ if (isValueType()) {
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context);
QDeclarativeValueType *valueType = 0;
@@ -809,13 +809,20 @@ QVariant QDeclarativePropertyPrivate::readValueProperty()
if (!ep) delete valueType;
return rv;
- } else if(core.flags & QDeclarativePropertyCache::Data::IsQList) {
+ } else if (core.flags & QDeclarativePropertyCache::Data::IsQList) {
QDeclarativeListProperty<QObject> prop;
void *args[] = { &prop, 0 };
QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args);
return QVariant::fromValue(QDeclarativeListReferencePrivate::init(prop, core.propType, engine));
+ } else if (core.flags & QDeclarativePropertyCache::Data::IsQObjectDerived) {
+
+ QObject *rv = 0;
+ void *args[] = { &rv, 0 };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args);
+ return QVariant::fromValue(rv);
+
} else {
return object->metaObject()->property(core.coreIndex).read(object.data());
diff --git a/src/declarative/qml/qdeclarativeproperty_p.h b/src/declarative/qml/qdeclarativeproperty_p.h
index 1fda7f4..c31e2d3 100644
--- a/src/declarative/qml/qdeclarativeproperty_p.h
+++ b/src/declarative/qml/qdeclarativeproperty_p.h
@@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE
class QDeclarativeContext;
class QDeclarativeEnginePrivate;
class QDeclarativeExpression;
-class Q_AUTOTEST_EXPORT QDeclarativePropertyPrivate
+class Q_DECLARATIVE_EXPORT QDeclarativePropertyPrivate
{
public:
enum WriteFlag { BypassInterceptor = 0x01, DontRemoveBinding = 0x02 };
diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp
index 08b47b7..fea59e5 100644
--- a/src/declarative/qml/qdeclarativepropertycache.cpp
+++ b/src/declarative/qml/qdeclarativepropertycache.cpp
@@ -155,9 +155,9 @@ QDeclarativePropertyCache::Data QDeclarativePropertyCache::create(const QMetaObj
int parenIdx = methodName.indexOf(QLatin1Char('('));
Q_ASSERT(parenIdx != -1);
- methodName = methodName.left(parenIdx);
+ QStringRef methodNameRef = methodName.leftRef(parenIdx);
- if (methodName == property) {
+ if (methodNameRef == property) {
rv.load(m);
return rv;
}
diff --git a/src/declarative/qml/qdeclarativescript.cpp b/src/declarative/qml/qdeclarativescript.cpp
index acfb9e1..ac4b2c1 100644
--- a/src/declarative/qml/qdeclarativescript.cpp
+++ b/src/declarative/qml/qdeclarativescript.cpp
@@ -43,6 +43,7 @@
/*!
\qmlclass Script QDeclarativeScript
+ \since 4.7
\brief The Script element provides a way to add JavaScript code snippets in QML.
\ingroup group_utility
diff --git a/src/declarative/qml/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescriptparser.cpp
index f4c9cdd..fe516c5 100644
--- a/src/declarative/qml/qdeclarativescriptparser.cpp
+++ b/src/declarative/qml/qdeclarativescriptparser.cpp
@@ -85,8 +85,8 @@ class ProcessAST: protected AST::Visitor
{
const State &state = top();
if (state.property) {
- State s(state.property->getValue(),
- state.property->getValue()->getProperty(name.toUtf8()));
+ State s(state.property->getValue(location),
+ state.property->getValue(location)->getProperty(name.toUtf8()));
s.property->location = location;
push(s);
} else {
@@ -106,12 +106,12 @@ public:
void operator()(const QString &code, AST::Node *node);
protected:
- Object *defineObjectBinding(AST::UiQualifiedId *propertyName,
+ Object *defineObjectBinding(AST::UiQualifiedId *propertyName, bool onAssignment,
AST::UiQualifiedId *objectTypeName,
LocationSpan location,
AST::UiObjectInitializer *initializer = 0);
- Object *defineObjectBinding_helper(AST::UiQualifiedId *propertyName,
+ Object *defineObjectBinding_helper(AST::UiQualifiedId *propertyName, bool onAssignment,
const QString &objectType,
AST::SourceLocation typeLocation,
LocationSpan location,
@@ -243,6 +243,7 @@ QString ProcessAST::asString(AST::UiQualifiedId *node) const
Object *
ProcessAST::defineObjectBinding_helper(AST::UiQualifiedId *propertyName,
+ bool onAssignment,
const QString &objectType,
AST::SourceLocation typeLocation,
LocationSpan location,
@@ -254,10 +255,19 @@ ProcessAST::defineObjectBinding_helper(AST::UiQualifiedId *propertyName,
(lastTypeDot >= 0 && objectType.at(lastTypeDot+1).isUpper()));
int propertyCount = 0;
- for (; propertyName; propertyName = propertyName->next){
+ for (AST::UiQualifiedId *name = propertyName; name; name = name->next){
++propertyCount;
- _stateStack.pushProperty(propertyName->name->asString(),
- this->location(propertyName));
+ _stateStack.pushProperty(name->name->asString(),
+ this->location(name));
+ }
+
+ if (!onAssignment && propertyCount && currentProperty() && currentProperty()->values.count()) {
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","Property value set multiple times"));
+ error.setLine(this->location(propertyName).start.line);
+ error.setColumn(this->location(propertyName).start.column);
+ _parser->_errors << error;
+ return 0;
}
if (!isType) {
@@ -327,7 +337,10 @@ ProcessAST::defineObjectBinding_helper(AST::UiQualifiedId *propertyName,
Value *v = new Value;
v->object = obj;
v->location = obj->location;
- prop->addValue(v);
+ if (onAssignment)
+ prop->addOnValue(v);
+ else
+ prop->addValue(v);
while (propertyCount--)
_stateStack.pop();
@@ -363,7 +376,7 @@ ProcessAST::defineObjectBinding_helper(AST::UiQualifiedId *propertyName,
}
}
-Object *ProcessAST::defineObjectBinding(AST::UiQualifiedId *qualifiedId,
+Object *ProcessAST::defineObjectBinding(AST::UiQualifiedId *qualifiedId, bool onAssignment,
AST::UiQualifiedId *objectTypeName,
LocationSpan location,
AST::UiObjectInitializer *initializer)
@@ -395,7 +408,7 @@ Object *ProcessAST::defineObjectBinding(AST::UiQualifiedId *qualifiedId,
}
- return defineObjectBinding_helper(qualifiedId, objectType, typeLocation, location, initializer);
+ return defineObjectBinding_helper(qualifiedId, onAssignment, objectType, typeLocation, location, initializer);
}
LocationSpan ProcessAST::location(AST::UiQualifiedId *id)
@@ -623,7 +636,7 @@ bool ProcessAST::visit(AST::UiObjectDefinition *node)
LocationSpan l = location(node->firstSourceLocation(),
node->lastSourceLocation());
- defineObjectBinding(/*propertyName = */ 0,
+ defineObjectBinding(/*propertyName = */ 0, false,
node->qualifiedTypeNameId,
l,
node->initializer);
@@ -638,7 +651,7 @@ bool ProcessAST::visit(AST::UiObjectBinding *node)
LocationSpan l = location(node->qualifiedTypeNameId->identifierToken,
node->initializer->rbraceToken);
- defineObjectBinding(node->qualifiedId,
+ defineObjectBinding(node->qualifiedId, node->hasOnToken,
node->qualifiedTypeNameId,
l,
node->initializer);
@@ -674,14 +687,23 @@ bool ProcessAST::visit(AST::UiScriptBinding *node)
{
int propertyCount = 0;
AST::UiQualifiedId *propertyName = node->qualifiedId;
- for (; propertyName; propertyName = propertyName->next){
+ for (AST::UiQualifiedId *name = propertyName; name; name = name->next){
++propertyCount;
- _stateStack.pushProperty(propertyName->name->asString(),
- location(propertyName));
+ _stateStack.pushProperty(name->name->asString(),
+ location(name));
}
Property *prop = currentProperty();
+ if (prop->values.count()) {
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","Property value set multiple times"));
+ error.setLine(this->location(propertyName).start.line);
+ error.setColumn(this->location(propertyName).start.column);
+ _parser->_errors << error;
+ return 0;
+ }
+
QDeclarativeParser::Variant primitive;
if (AST::ExpressionStatement *stmt = AST::cast<AST::ExpressionStatement *>(node->statement)) {
@@ -724,16 +746,26 @@ bool ProcessAST::visit(AST::UiArrayBinding *node)
{
int propertyCount = 0;
AST::UiQualifiedId *propertyName = node->qualifiedId;
- for (; propertyName; propertyName = propertyName->next){
+ for (AST::UiQualifiedId *name = propertyName; name; name = name->next){
++propertyCount;
- _stateStack.pushProperty(propertyName->name->asString(),
- location(propertyName));
+ _stateStack.pushProperty(name->name->asString(),
+ location(name));
+ }
+
+ Property* prop = currentProperty();
+
+ if (prop->values.count()) {
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","Property value set multiple times"));
+ error.setLine(this->location(propertyName).start.line);
+ error.setColumn(this->location(propertyName).start.column);
+ _parser->_errors << error;
+ return 0;
}
accept(node->members);
// For the DOM, store the position of the T_LBRACKET upto the T_RBRACKET as the range:
- Property* prop = currentProperty();
prop->listValueRange.offset = node->lbracketToken.offset;
prop->listValueRange.length = node->rbracketToken.offset + node->rbracketToken.length - node->lbracketToken.offset;
diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp
index 01fa214..c070123 100644
--- a/src/declarative/qml/qdeclarativevaluetype.cpp
+++ b/src/declarative/qml/qdeclarativevaluetype.cpp
@@ -41,23 +41,88 @@
#include "qdeclarativevaluetype_p.h"
+#include "qdeclarativemetatype_p.h"
+
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
+#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
+Q_DECLARE_METATYPE(QEasingCurve);
+#endif
+
+template<typename T>
+int qmlRegisterValueTypeEnums(const char *qmlName)
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+
+ QDeclarativePrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()), 0, 0,
+
+ "Qt", 4, 6, qmlName, &T::staticMetaObject,
+
+ 0, 0,
+
+ 0, 0, 0,
+
+ 0, 0,
+
+ 0
+ };
+
+ return QDeclarativePrivate::registerType(type);
+}
+
QDeclarativeValueTypeFactory::QDeclarativeValueTypeFactory()
{
// ### Optimize
for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii)
valueTypes[ii] = valueType(ii);
+#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
+ easingType = qMetaTypeId<QEasingCurve>();
+ easingValueType = valueType(easingType);
+#endif
}
QDeclarativeValueTypeFactory::~QDeclarativeValueTypeFactory()
{
for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii)
delete valueTypes[ii];
+#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
+ delete easingValueType;
+#endif
+}
+
+bool QDeclarativeValueTypeFactory::isValueType(int idx)
+{
+ if ((uint)idx < QVariant::UserType)
+ return true;
+#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
+ if (idx == qMetaTypeId<QEasingCurve>())
+ return true;
+#endif
+ return false;
+}
+
+void QDeclarativeValueTypeFactory::registerValueTypes()
+{
+ qmlRegisterValueTypeEnums<QDeclarativeEasingValueType>("Easing");
+ qmlRegisterValueTypeEnums<QDeclarativeFontValueType>("Font");
+}
+
+QDeclarativeValueType *QDeclarativeValueTypeFactory::operator[](int idx) const
+{
+#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
+ if (idx == easingType) return easingValueType;
+#endif
+ return valueTypes[idx];
}
+
QDeclarativeValueType *QDeclarativeValueTypeFactory::valueType(int t)
{
switch (t) {
@@ -75,11 +140,17 @@ QDeclarativeValueType *QDeclarativeValueTypeFactory::valueType(int t)
return new QDeclarativeRectFValueType;
case QVariant::Vector3D:
return new QDeclarativeVector3DValueType;
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
case QVariant::EasingCurve:
return new QDeclarativeEasingValueType;
+#endif
case QVariant::Font:
return new QDeclarativeFontValueType;
default:
+#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
+ if (t == qMetaTypeId<QEasingCurve>())
+ return new QDeclarativeEasingValueType;
+#endif
return 0;
}
}
@@ -495,7 +566,11 @@ void QDeclarativeEasingValueType::write(QObject *obj, int idx, QDeclarativePrope
QVariant QDeclarativeEasingValueType::value()
{
+#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
return QVariant(easing);
+#else
+ return QVariant::fromValue<QEasingCurve>(easing);
+#endif
}
void QDeclarativeEasingValueType::setValue(QVariant value)
diff --git a/src/declarative/qml/qdeclarativevaluetype_p.h b/src/declarative/qml/qdeclarativevaluetype_p.h
index cb153be..ad2f6c4 100644
--- a/src/declarative/qml/qdeclarativevaluetype_p.h
+++ b/src/declarative/qml/qdeclarativevaluetype_p.h
@@ -81,10 +81,19 @@ class Q_DECLARATIVE_EXPORT QDeclarativeValueTypeFactory
public:
QDeclarativeValueTypeFactory();
~QDeclarativeValueTypeFactory();
+ static bool isValueType(int);
static QDeclarativeValueType *valueType(int);
+ static void registerValueTypes();
+
+ QDeclarativeValueType *operator[](int idx) const;
+
+private:
QDeclarativeValueType *valueTypes[QVariant::UserType - 1];
- QDeclarativeValueType *operator[](int idx) const { return valueTypes[idx]; }
+#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
+ int easingType;
+ QDeclarativeValueType *easingValueType;
+#endif
};
class Q_AUTOTEST_EXPORT QDeclarativePointFValueType : public QDeclarativeValueType
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index 720b496..6a08674 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -217,7 +217,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack, QDeclarati
// TODO: parent might be a layout
}
} else {
- QDeclarativeGraphics_setParent_noEvent(o, parent);
+ QDeclarative_setParent_noEvent(o, parent);
// o->setParent(parent);
}
}
@@ -538,13 +538,13 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack, QDeclarati
case QDeclarativeInstruction::StoreSignal:
{
QObject *target = stack.top();
- // XXX scope
- QMetaMethod signal =
- target->metaObject()->method(instr.storeSignal.signalIndex);
+ QObject *context = stack.at(stack.count() - 1 - instr.assignBinding.context);
+
+ QMetaMethod signal = target->metaObject()->method(instr.storeSignal.signalIndex);
QDeclarativeBoundSignal *bs = new QDeclarativeBoundSignal(target, signal, target);
QDeclarativeExpression *expr =
- new QDeclarativeExpression(ctxt, primitives.at(instr.storeSignal.value), target);
+ new QDeclarativeExpression(ctxt, primitives.at(instr.storeSignal.value), context);
expr->setSourceLocation(comp->name, instr.line);
bs->setExpression(expr);
}
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index 03151e4..784353a 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -365,6 +365,8 @@ void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
workerEngine->evaluate(script);
workerEngine->popContext();
+ } else {
+ qWarning().nospace() << "WorkerScript: Cannot find source file " << url.toString();
}
}
@@ -382,7 +384,7 @@ QVariant QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(const QScri
quint32 length = (quint32)value.property(QLatin1String("length")).toNumber();
for (quint32 ii = 0; ii < length; ++ii) {
- QVariant v = scriptValueToVariant(ii);
+ QVariant v = scriptValueToVariant(value.property(ii));
list << v;
}
@@ -561,6 +563,65 @@ void QDeclarativeWorkerScriptEngine::run()
delete d->workerEngine; d->workerEngine = 0;
}
+
+/*!
+ \qmlclass WorkerScript QDeclarativeWorkerScript
+ \brief The WorkerScript element enables the use of threads in QML.
+
+ Use WorkerScript to run operations in a new thread.
+ This is useful for running operations in the background so
+ that the main GUI thread is not blocked.
+
+ Messages can be passed between the new thread and the parent thread
+ using sendMessage() and the onMessage() handler.
+
+ Here is an example:
+
+ \qml
+ import Qt 4.6
+
+ Rectangle {
+ width: 300
+ height: 300
+
+ Text {
+ id: myText
+ text: 'Click anywhere'
+ }
+
+ WorkerScript {
+ id: myWorker
+ source: "script.js"
+
+ onMessage: {
+ myText.text = messageObject.reply
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: myWorker.sendMessage( {'x': mouse.x, 'y': mouse.y} );
+ }
+ }
+ \endqml
+
+ The above worker script specifies a javascript file, "script.js", that handles
+ the operations to be performed in the new thread:
+
+ \qml
+ WorkerScript.onMessage = function(message) {
+ // ... long-running operations and calculations are done here
+ WorkerScript.sendMessage( {'reply': 'Mouse is at ' + message.x + ',' + message.y} );
+ }
+ \endqml
+
+ When the user clicks anywhere within the rectangle, \c sendMessage() is
+ called, triggering the \tt WorkerScript.onMessage() handler in
+ \tt source.js. This in turn sends a reply message that is then received
+ by the \tt onMessage() handler of \tt myWorker.
+
+ \sa WorkerListModel
+*/
QDeclarativeWorkerScript::QDeclarativeWorkerScript(QObject *parent)
: QObject(parent), m_engine(0), m_scriptId(-1)
{
@@ -571,6 +632,12 @@ QDeclarativeWorkerScript::~QDeclarativeWorkerScript()
if (m_scriptId != -1) m_engine->removeWorkerScript(m_scriptId);
}
+/*!
+ \qmlproperty url WorkerScript::source
+
+ This holds the url of the javascript file that implements the
+ \tt WorkerScript.onMessage() handler for threaded operations.
+*/
QUrl QDeclarativeWorkerScript::source() const
{
return m_source;
@@ -589,6 +656,13 @@ void QDeclarativeWorkerScript::setSource(const QUrl &source)
emit sourceChanged();
}
+/*
+ \qmlmethod WorkerScript::sendMessage(jsobject message)
+
+ Sends the given \a message to a worker script handler in another
+ thread. The other worker script handler can receive this message
+ through the onMessage() handler.
+*/
void QDeclarativeWorkerScript::sendMessage(const QScriptValue &message)
{
if (!m_engine) {
@@ -616,6 +690,13 @@ void QDeclarativeWorkerScript::componentComplete()
}
}
+/*!
+ \qmlsignal WorkerScript::onMessage(jsobject msg)
+
+ This handler is called when a message \a msg is received from a worker
+ script in another thread through a call to sendMessage().
+*/
+
bool QDeclarativeWorkerScript::event(QEvent *event)
{
if (event->type() == (QEvent::Type)WorkerDataEvent::WorkerData) {
@@ -841,6 +922,41 @@ bool QDeclarativeWorkerListModelAgent::event(QEvent *e)
return QObject::event(e);
}
+/*!
+ \qmlclass WorkerListModel QDeclarativeWorkerListModel
+ \brief The WorkerListModel element provides a threaded list model.
+
+ Use WorkerListModel together with WorkerScript to define a list model
+ that is controlled by a separate thread. This is useful if list modification
+ operations are synchronous and take some time: using WorkerListModel
+ moves these operations to a different thread and avoids blocking of the
+ main GUI thread.
+
+ The thread that creates the WorkerListModel can modify the model for any
+ initial set-up requirements. However, once the model has been modified by
+ the associated WorkerScript, the model can only be modified by that worker
+ script and becomes read-only to all other threads.
+
+ Here is an example application that uses WorkerScript to append the
+ current time to a WorkerListModel:
+
+ \snippet examples/declarative/workerlistmodel/timedisplay.qml 0
+
+ The included file, \tt dataloader.js, looks like this:
+
+ \snippet examples/declarative/workerlistmodel/dataloader.js 0
+
+ The application's \tt Timer object periodically sends a message to the
+ worker script by calling \tt WorkerScript::sendMessage(). When this message
+ is received, \tt WorkerScript.onMessage() is invoked in
+ \tt dataloader.js, which appends the current time to the worker list
+ model.
+
+ Note that unlike ListModel, WorkerListModel does not have \tt move() and
+ \tt setProperty() methods.
+
+ \sa WorkerScript, ListModel
+*/
QDeclarativeWorkerListModel::QDeclarativeWorkerListModel(QObject *parent)
: QListModelInterface(parent), m_agent(0)
{
@@ -854,6 +970,14 @@ QDeclarativeWorkerListModel::~QDeclarativeWorkerListModel()
}
}
+/*!
+ \qmlmethod WorkerListModel::clear()
+
+ Deletes all content from the model. The properties are cleared such that
+ different properties may be set on subsequent additions.
+
+ \sa append() remove()
+*/
void QDeclarativeWorkerListModel::clear()
{
if (m_agent) {
@@ -869,6 +993,13 @@ void QDeclarativeWorkerListModel::clear()
}
}
+/*!
+ \qmlmethod WorkerListModel::remove(int index)
+
+ Deletes the content at \a index from the model.
+
+ \sa clear()
+*/
void QDeclarativeWorkerListModel::remove(int index)
{
if (m_agent) {
@@ -884,6 +1015,18 @@ void QDeclarativeWorkerListModel::remove(int index)
emit countChanged();
}
+/*!
+ \qmlmethod WorkerListModel::append(jsobject dict)
+
+ Adds a new item to the end of the list model, with the
+ values in \a dict.
+
+ \code
+ FruitModel.append({"cost": 5.95, "name":"Pizza"})
+ \endcode
+
+ \sa set() remove()
+*/
void QDeclarativeWorkerListModel::append(const QScriptValue &value)
{
if (m_agent) {
@@ -914,6 +1057,21 @@ void QDeclarativeWorkerListModel::append(const QScriptValue &value)
emit countChanged();
}
+/*!
+ \qmlmethod WorkerListModel::insert(int index, jsobject dict)
+
+ Adds a new item to the list model at position \a index, with the
+ values in \a dict.
+
+ \code
+ FruitModel.insert(2, {"cost": 5.95, "name":"Pizza"})
+ \endcode
+
+ The \a index must be to an existing item in the list, or one past
+ the end of the list (equivalent to append).
+
+ \sa set() append()
+*/
void QDeclarativeWorkerListModel::insert(int index, const QScriptValue &value)
{
if (m_agent) {
@@ -946,6 +1104,30 @@ void QDeclarativeWorkerListModel::insert(int index, const QScriptValue &value)
emit countChanged();
}
+/*!
+ \qmlmethod object ListModel::get(int index)
+
+ Returns the item at \a index in the list model.
+
+ \code
+ FruitModel.append({"cost": 5.95, "name":"Jackfruit"})
+ FruitModel.get(0).cost
+ \endcode
+
+ The \a index must be an element in the list.
+
+ Note that properties of the returned object that are themselves objects
+ will also be models, and this get() method is used to access elements:
+
+ \code
+ FruitModel.append(..., "attributes":
+ [{"name":"spikes","value":"7mm"},
+ {"name":"color","value":"green"}]);
+ FruitModel.get(0).attributes.get(1).value; // == "green"
+ \endcode
+
+ \sa append()
+*/
QScriptValue QDeclarativeWorkerListModel::get(int index) const
{
QDeclarativeEngine *engine = qmlEngine(this);
@@ -962,6 +1144,21 @@ QScriptValue QDeclarativeWorkerListModel::get(int index) const
return rv;
}
+/*!
+ \qmlmethod WorkerListModel::set(int index, jsobject dict)
+
+ Changes the item at \a index in the list model with the
+ values in \a dict. Properties not appearing in \a valuemap
+ are left unchanged.
+
+ \code
+ FruitModel.set(3, {"cost": 5.95, "name":"Pizza"})
+ \endcode
+
+ The \a index must be an element in the list.
+
+ \sa append()
+*/
void QDeclarativeWorkerListModel::set(int index, const QScriptValue &value)
{
if (m_agent) {
@@ -995,6 +1192,22 @@ void QDeclarativeWorkerListModel::set(int index, const QScriptValue &value)
}
}
+/*!
+ \qmlmethod WorkerListModel::sync()
+
+ Writes any unsaved changes to the list model. This must be called after
+ changes have been made to the list model in the worker script.
+
+ Note that this method can only be called from the associated worker script.
+*/
+void QDeclarativeWorkerListModel::sync()
+{
+ // This is really a dummy method to make it look like sync() exists in
+ // WorkerListModel (and not QDeclarativeWorkerListModelAgent) and to let
+ // us document sync().
+ qmlInfo(this) << "sync() can only be called from a WorkerScript";
+}
+
QDeclarativeWorkerListModelAgent *QDeclarativeWorkerListModel::agent()
{
if (!m_agent)
@@ -1013,6 +1226,10 @@ QString QDeclarativeWorkerListModel::toString(int role) const
return m_roles.value(role);
}
+/*!
+ \qmlproperty int ListModel::count
+ The number of data entries in the model.
+*/
int QDeclarativeWorkerListModel::count() const
{
return m_values.count();
@@ -1038,4 +1255,3 @@ QT_END_NAMESPACE
#include "qdeclarativeworkerscript.moc"
-
diff --git a/src/declarative/qml/qdeclarativeworkerscript_p.h b/src/declarative/qml/qdeclarativeworkerscript_p.h
index 8ebd2c1..912eac9 100644
--- a/src/declarative/qml/qdeclarativeworkerscript_p.h
+++ b/src/declarative/qml/qdeclarativeworkerscript_p.h
@@ -61,8 +61,12 @@
#include <QtScript/qscriptvalue.h>
#include <QtCore/qurl.h>
+QT_BEGIN_HEADER
+
QT_BEGIN_NAMESPACE
+QT_MODULE(Declarative)
+
class QDeclarativeWorkerScript;
class QDeclarativeWorkerScriptEnginePrivate;
class QDeclarativeWorkerScriptEngine : public QThread
@@ -84,7 +88,7 @@ private:
QDeclarativeWorkerScriptEnginePrivate *d;
};
-class QDeclarativeWorkerScript : public QObject, public QDeclarativeParserStatus
+class Q_DECLARATIVE_EXPORT QDeclarativeWorkerScript : public QObject, public QDeclarativeParserStatus
{
Q_OBJECT
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
@@ -115,7 +119,7 @@ private:
};
class QDeclarativeWorkerListModelAgent;
-class QDeclarativeWorkerListModel : public QListModelInterface
+class Q_DECLARATIVE_EXPORT QDeclarativeWorkerListModel : public QListModelInterface
{
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY countChanged)
@@ -130,6 +134,7 @@ public:
Q_INVOKABLE void insert(int index, const QScriptValue&);
Q_INVOKABLE QScriptValue get(int index) const;
Q_INVOKABLE void set(int index, const QScriptValue &);
+ Q_INVOKABLE void sync();
QDeclarativeWorkerListModelAgent *agent();
@@ -157,4 +162,6 @@ QT_END_NAMESPACE
QML_DECLARE_TYPE(QDeclarativeWorkerScript);
QML_DECLARE_TYPE(QDeclarativeWorkerListModel);
+QT_END_HEADER
+
#endif // QDECLARATIVEWORKERSCRIPT_P_H
diff --git a/src/declarative/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
index 3ba53f0..87cab85 100644
--- a/src/declarative/qml/qdeclarativexmlhttprequest.cpp
+++ b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
@@ -52,6 +52,7 @@
#include <QtScript/qscriptcontext.h>
#include <QtScript/qscriptengine.h>
#include <QtNetwork/qnetworkreply.h>
+#include <QtCore/qtextcodec.h>
#include <QtCore/qxmlstream.h>
#include <QtCore/qstack.h>
#include <QtCore/qdebug.h>
@@ -312,7 +313,7 @@ public:
// C++ API
static QScriptValue prototype(QScriptEngine *);
- static QScriptValue load(QScriptEngine *engine, const QString &data);
+ static QScriptValue load(QScriptEngine *engine, const QByteArray &data);
};
QT_END_NAMESPACE
@@ -619,7 +620,7 @@ QScriptValue Document::prototype(QScriptEngine *engine)
return proto;
}
-QScriptValue Document::load(QScriptEngine *engine, const QString &data)
+QScriptValue Document::load(QScriptEngine *engine, const QByteArray &data)
{
Q_ASSERT(engine);
@@ -960,6 +961,7 @@ public:
QScriptValue abort(QScriptValue *me);
QString responseBody() const;
+ const QByteArray & rawResponseBody() const;
private slots:
void downloadProgress(qint64);
void error(QNetworkReply::NetworkError);
@@ -1279,9 +1281,20 @@ void QDeclarativeXMLHttpRequest::finished()
QString QDeclarativeXMLHttpRequest::responseBody() const
{
+ QXmlStreamReader reader(m_responseEntityBody);
+ reader.readNext();
+ QTextCodec *codec = QTextCodec::codecForName(reader.documentEncoding().toString().toUtf8());
+ if (codec)
+ return codec->toUnicode(m_responseEntityBody);
+
return QString::fromUtf8(m_responseEntityBody);
}
+const QByteArray &QDeclarativeXMLHttpRequest::rawResponseBody() const
+{
+ return m_responseEntityBody;
+}
+
QScriptValue QDeclarativeXMLHttpRequest::dispatchCallback(QScriptValue *me)
{
QScriptValue v = me->property(QLatin1String("callback"));
@@ -1538,7 +1551,7 @@ static QScriptValue qmlxmlhttprequest_responseXML(QScriptContext *context, QScri
request->readyState() != QDeclarativeXMLHttpRequest::Done)
return engine->nullValue();
else
- return Document::load(engine, request->responseBody());
+ return Document::load(engine, request->rawResponseBody());
}
static QScriptValue qmlxmlhttprequest_onreadystatechange(QScriptContext *context, QScriptEngine *engine)
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index 181ef0a..8c8dd95 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -52,6 +52,7 @@
#include <qdeclarativestringconverters_p.h>
#include <qdeclarativeglobal_p.h>
#include <qdeclarativemetatype_p.h>
+#include <qdeclarativevaluetype_p.h>
#include <qdeclarativeproperty_p.h>
#include <qvariant.h>
@@ -71,7 +72,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass Animation QDeclarativeAbstractAnimation
- \since 4.7
+ \since 4.7
\brief The Animation element is the base of all QML animations.
The Animation element cannot be used directly in a QML file. It exists
@@ -110,7 +111,7 @@ QDeclarativeAbstractAnimation::QDeclarativeAbstractAnimation(QDeclarativeAbstrac
\code
Rectangle {
width: 100; height: 100
- x: NumberAnimation {
+ NumberAnimation on x {
running: myMouse.pressed
from: 0; to: 100
}
@@ -310,7 +311,7 @@ void QDeclarativeAbstractAnimation::setAlwaysRunToEnd(bool f)
\code
Rectangle {
- rotation: NumberAnimation { running: true; repeat: true; from: 0 to: 360 }
+ NumberAnimation on rotation { running: true; repeat: true; from: 0 to: 360 }
}
\endcode
*/
@@ -412,7 +413,7 @@ void QDeclarativeAbstractAnimation::resume()
no further influence on property values. In this example animation
\code
Rectangle {
- x: NumberAnimation { from: 0; to: 100; duration: 500 }
+ NumberAnimation on x { from: 0; to: 100; duration: 500 }
}
\endcode
was stopped at time 250ms, the \c x property will have a value of 50.
@@ -450,7 +451,7 @@ void QDeclarativeAbstractAnimation::restart()
its end. In the following example,
\code
Rectangle {
- x: NumberAnimation { from: 0; to: 100; duration: 500 }
+ NumberAnimation on x { from: 0; to: 100; duration: 500 }
}
\endcode
calling \c stop() at time 250ms will result in the \c x property having
@@ -515,7 +516,7 @@ void QDeclarativeAbstractAnimation::timelineComplete()
/*!
\qmlclass PauseAnimation QDeclarativePauseAnimation
- \since 4.7
+ \since 4.7
\inherits Animation
\brief The PauseAnimation element provides a pause for an animation.
@@ -552,7 +553,7 @@ void QDeclarativePauseAnimationPrivate::init()
{
Q_Q(QDeclarativePauseAnimation);
pa = new QPauseAnimation;
- QDeclarativeGraphics_setParent_noEvent(pa, q);
+ QDeclarative_setParent_noEvent(pa, q);
}
/*!
@@ -589,7 +590,7 @@ QAbstractAnimation *QDeclarativePauseAnimation::qtAnimation()
/*!
\qmlclass ColorAnimation QDeclarativeColorAnimation
- \since 4.7
+ \since 4.7
\inherits PropertyAnimation
\brief The ColorAnimation element allows you to animate color changes.
@@ -653,7 +654,7 @@ void QDeclarativeColorAnimation::setTo(const QColor &t)
/*!
\qmlclass ScriptAction QDeclarativeScriptAction
- \since 4.7
+ \since 4.7
\inherits Animation
\brief The ScriptAction element allows scripts to be run during an animation.
@@ -677,7 +678,7 @@ void QDeclarativeScriptActionPrivate::init()
{
Q_Q(QDeclarativeScriptAction);
rsa = new QActionAnimation(&proxy);
- QDeclarativeGraphics_setParent_noEvent(rsa, q);
+ QDeclarative_setParent_noEvent(rsa, q);
}
/*!
@@ -759,7 +760,7 @@ QAbstractAnimation *QDeclarativeScriptAction::qtAnimation()
/*!
\qmlclass PropertyAction QDeclarativePropertyAction
- \since 4.7
+ \since 4.7
\inherits Animation
\brief The PropertyAction element allows immediate property changes during animation.
@@ -795,7 +796,7 @@ void QDeclarativePropertyActionPrivate::init()
{
Q_Q(QDeclarativePropertyAction);
spa = new QActionAnimation;
- QDeclarativeGraphics_setParent_noEvent(spa, q);
+ QDeclarative_setParent_noEvent(spa, q);
}
/*!
@@ -1008,7 +1009,7 @@ void QDeclarativePropertyAction::transition(QDeclarativeStateActions &actions,
/*!
\qmlclass ParentAction QDeclarativeParentAction
- \since 4.7
+ \since 4.7
\inherits Animation
\brief The ParentAction element allows parent changes during animation.
@@ -1056,7 +1057,7 @@ void QDeclarativeParentActionPrivate::init()
{
Q_Q(QDeclarativeParentAction);
cpa = new QActionAnimation;
- QDeclarativeGraphics_setParent_noEvent(cpa, q);
+ QDeclarative_setParent_noEvent(cpa, q);
}
/*!
@@ -1212,7 +1213,7 @@ void QDeclarativeParentAction::transition(QDeclarativeStateActions &actions,
/*!
\qmlclass NumberAnimation QDeclarativeNumberAnimation
- \since 4.7
+ \since 4.7
\inherits PropertyAnimation
\brief The NumberAnimation element allows you to animate changes in properties of type qreal.
@@ -1276,7 +1277,7 @@ void QDeclarativeNumberAnimation::setTo(qreal t)
/*!
\qmlclass Vector3dAnimation QDeclarativeVector3dAnimation
- \since 4.7
+ \since 4.7
\inherits PropertyAnimation
\brief The Vector3dAnimation element allows you to animate changes in properties of type QVector3d.
*/
@@ -1292,7 +1293,7 @@ QDeclarativeVector3dAnimation::QDeclarativeVector3dAnimation(QObject *parent)
Q_D(QDeclarativePropertyAnimation);
d->interpolatorType = QMetaType::QVector3D;
d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
- d->defaultToInterpolatorType = true;
+ d->defaultToInterpolatorType = true;
}
QDeclarativeVector3dAnimation::~QDeclarativeVector3dAnimation()
@@ -1335,28 +1336,31 @@ void QDeclarativeVector3dAnimation::setTo(QVector3D t)
/*!
\qmlclass RotationAnimation QDeclarativeRotationAnimation
+ \since 4.7
\inherits PropertyAnimation
\brief The RotationAnimation element allows you to animate rotations.
RotationAnimation is a specialized PropertyAnimation that gives control
- over the direction of rotation.
+ over the direction of rotation. By default, it will rotate
+ via the shortest path; for example, a rotation from 20 to 340 degrees will
+ rotation 40 degrees counterclockwise.
- The RotationAnimation in the following example ensures that we always take
- the shortest rotation path when switching between our states.
+ When used in a transition RotationAnimation will rotate all
+ properties named "rotation" or "angle". You can override this by providing
+ your own properties via \c properties or \c property.
+
+ In the following example we use RotationAnimation to animate the rotation
+ between states via the shortest path.
\qml
states: {
State { name: "180"; PropertyChanges { target: myItem; rotation: 180 } }
- State { name: "-180"; PropertyChanges { target: myItem; rotation: -180 } }
- State { name: "180"; PropertyChanges { target: myItem; rotation: 270 } }
+ State { name: "90"; PropertyChanges { target: myItem; rotation: 90 } }
+ State { name: "-90"; PropertyChanges { target: myItem; rotation: -90 } }
}
transition: Transition {
- RotationAnimation { direction: RotationAnimation.Shortest }
+ RotationAnimation { }
}
\endqml
-
- By default, when used in a transition RotationAnimation will rotate all
- properties named "rotation" or "angle". You can override this by providing
- your own properties via \c properties or \c property.
*/
/*!
@@ -1549,7 +1553,7 @@ QDeclarativeListProperty<QDeclarativeAbstractAnimation> QDeclarativeAnimationGro
/*!
\qmlclass SequentialAnimation QDeclarativeSequentialAnimation
- \since 4.7
+ \since 4.7
\inherits Animation
\brief The SequentialAnimation element allows you to run animations sequentially.
@@ -1572,7 +1576,8 @@ QDeclarativeSequentialAnimation::QDeclarativeSequentialAnimation(QObject *parent
QDeclarativeAnimationGroup(parent)
{
Q_D(QDeclarativeAnimationGroup);
- d->ag = new QSequentialAnimationGroup(this);
+ d->ag = new QSequentialAnimationGroup;
+ QDeclarative_setParent_noEvent(d->ag, this);
}
QDeclarativeSequentialAnimation::~QDeclarativeSequentialAnimation()
@@ -1610,7 +1615,7 @@ void QDeclarativeSequentialAnimation::transition(QDeclarativeStateActions &actio
/*!
\qmlclass ParallelAnimation QDeclarativeParallelAnimation
- \since 4.7
+ \since 4.7
\inherits Animation
\brief The ParallelAnimation element allows you to run animations in parallel.
@@ -1637,7 +1642,8 @@ QDeclarativeParallelAnimation::QDeclarativeParallelAnimation(QObject *parent) :
QDeclarativeAnimationGroup(parent)
{
Q_D(QDeclarativeAnimationGroup);
- d->ag = new QParallelAnimationGroup(this);
+ d->ag = new QParallelAnimationGroup;
+ QDeclarative_setParent_noEvent(d->ag, this);
}
QDeclarativeParallelAnimation::~QDeclarativeParallelAnimation()
@@ -1707,19 +1713,20 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int
break;
}
default:
- if ((uint)type >= QVariant::UserType) {
+ if (QDeclarativeValueTypeFactory::isValueType((uint)type)) {
+ variant.convert((QVariant::Type)type);
+ } else {
QDeclarativeMetaType::StringConverter converter = QDeclarativeMetaType::customStringConverter(type);
if (converter)
variant = converter(variant.toString());
- } else
- variant.convert((QVariant::Type)type);
+ }
break;
}
}
/*!
\qmlclass PropertyAnimation QDeclarativePropertyAnimation
- \since 4.7
+ \since 4.7
\inherits Animation
\brief The PropertyAnimation element allows you to animate property changes.
@@ -1731,14 +1738,14 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int
Animate any objects that have changed their x or y properties in the target state using
an InOutQuad easing curve:
\qml
- Transition { PropertyAnimation { properties: "x,y"; easing: "InOutQuad" } }
+ Transition { PropertyAnimation { properties: "x,y"; easing.type: "InOutQuad" } }
\endqml
\o In a Behavior
Animate all changes to a rectangle's x property.
\qml
Rectangle {
- x: Behavior { PropertyAnimation {} }
+ Behavior on x { PropertyAnimation {} }
}
\endqml
\o As a property value source
@@ -1746,7 +1753,7 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int
Repeatedly animate the rectangle's x property.
\qml
Rectangle {
- x: SequentialAnimation {
+ SequentialAnimation on x {
repeat: true
PropertyAnimation { to: 50 }
PropertyAnimation { to: 0 }
@@ -1796,8 +1803,8 @@ QDeclarativePropertyAnimation::~QDeclarativePropertyAnimation()
void QDeclarativePropertyAnimationPrivate::init()
{
Q_Q(QDeclarativePropertyAnimation);
- va = new QDeclarativeTimeLineValueAnimator;
- QDeclarativeGraphics_setParent_noEvent(va, q);
+ va = new QDeclarativeBulkValueAnimator;
+ QDeclarative_setParent_noEvent(va, q);
}
/*!
@@ -1872,7 +1879,13 @@ void QDeclarativePropertyAnimation::setTo(const QVariant &t)
\qmlproperty QEasingCurve PropertyAnimation::easing
\brief the easing curve used for the transition.
- Available values are:
+ For the easing you can specify the following parameters: type, amplitude, period and overshoot.
+
+ \qml
+ PropertyAnimation { properties: "y"; easing.type: "InOutElastc"; easing.amplitude: 2.0; easing.period: 1.5 }
+ \endqml
+
+ Available types are:
\table
\row
@@ -2043,6 +2056,15 @@ void QDeclarativePropertyAnimation::setTo(const QVariant &t)
\o \inlineimage qeasingcurve-outinbounce.png
\endtable
+ easing.amplitude is not applicable for all curve types. It is only applicable for bounce and elastic curves (curves of type
+ QEasingCurve::InBounce, QEasingCurve::OutBounce, QEasingCurve::InOutBounce, QEasingCurve::OutInBounce, QEasingCurve::InElastic,
+ QEasingCurve::OutElastic, QEasingCurve::InOutElastic or QEasingCurve::OutInElastic).
+
+ easing.overshoot is not applicable for all curve types. It is only applicable if type is: QEasingCurve::InBack, QEasingCurve::OutBack,
+ QEasingCurve::InOutBack or QEasingCurve::OutInBack.
+
+ easing.period is not applicable for all curve types. It is only applicable if type is: QEasingCurve::InElastic, QEasingCurve::OutElastic,
+ QEasingCurve::InOutElastic or QEasingCurve::OutInElastic.
*/
QEasingCurve QDeclarativePropertyAnimation::easing() const
{
@@ -2137,8 +2159,8 @@ void QDeclarativePropertyAnimation::setProperties(const QString &prop)
id: theRect
width: 100; height: 100
color: Qt.rgba(0,0,1)
- x: NumberAnimation { to: 500; repeat: true } //animate theRect's x property
- y: Behavior { NumberAnimation {} } //animate theRect's y property
+ NumberAnimation on x { to: 500; repeat: true } //animate theRect's x property
+ Behavior on y { NumberAnimation {} } //animate theRect's y property
}
\endqml
\row
@@ -2212,7 +2234,7 @@ QAbstractAnimation *QDeclarativePropertyAnimation::qtAnimation()
return d->va;
}
-struct PropertyUpdater : public QDeclarativeTimeLineValue
+struct PropertyUpdater : public QDeclarativeBulkValueUpdater
{
QDeclarativeStateActions actions;
int interpolatorType; //for Number/ColorAnimation
@@ -2222,7 +2244,7 @@ struct PropertyUpdater : public QDeclarativeTimeLineValue
bool fromSourced;
bool fromDefined;
bool *wasDeleted;
- PropertyUpdater() : wasDeleted(0) {}
+ PropertyUpdater() : prevInterpolatorType(0), wasDeleted(0) {}
~PropertyUpdater() { if (wasDeleted) *wasDeleted = true; }
void setValue(qreal v)
{
@@ -2230,7 +2252,6 @@ struct PropertyUpdater : public QDeclarativeTimeLineValue
wasDeleted = &deleted;
if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1
v = 1 - v;
- QDeclarativeTimeLineValue::setValue(v);
for (int ii = 0; ii < actions.count(); ++ii) {
QDeclarativeAction &action = actions[ii];
@@ -2370,12 +2391,58 @@ void QDeclarativePropertyAnimation::transition(QDeclarativeStateActions &actions
}
}
+/*!
+ \qmlclass ParentAnimation QDeclarativeParentAnimation
+ \since 4.7
+ \inherits Animation
+ \brief The ParentAnimation element allows you to animate parent changes.
+
+ ParentAnimation is used in conjunction with NumberAnimation to smoothly
+ animate changing an item's parent. In the following example,
+ ParentAnimation wraps a NumberAnimation which animates from the
+ current position in the old parent to the new position in the new
+ parent.
+
+ \qml
+ ...
+ State {
+ //reparent myItem to newParent. myItem's final location
+ //should be 10,10 in newParent.
+ ParentChange {
+ target: myItem
+ parent: newParent
+ x: 10; y: 10
+ }
+ }
+ ...
+ Transition {
+ //smoothly reparent myItem and move into new position
+ ParentAnimation {
+ target: theItem
+ NumberAnimation { properties: "x,y" }
+ }
+ }
+ \endqml
+
+ ParentAnimation can wrap any number of animations -- those animations will
+ be run in parallel (like those in a ParallelAnimation group).
+
+ In some cases, such as reparenting between items with clipping, it's useful
+ to animate the parent change \i via another item with no clipping.
+
+ When used in a transition, ParentAnimation will by default animate
+ all ParentChanges.
+*/
+/*!
+ \internal
+ \class QDeclarativeParentAnimation
+*/
QDeclarativeParentAnimation::QDeclarativeParentAnimation(QObject *parent)
: QDeclarativeAnimationGroup(*(new QDeclarativeParentAnimationPrivate), parent)
{
Q_D(QDeclarativeParentAnimation);
d->topLevelGroup = new QSequentialAnimationGroup;
- QDeclarativeGraphics_setParent_noEvent(d->topLevelGroup, this);
+ QDeclarative_setParent_noEvent(d->topLevelGroup, this);
d->startAction = new QActionAnimation;
d->topLevelGroup->addAnimation(d->startAction);
@@ -2391,6 +2458,13 @@ QDeclarativeParentAnimation::~QDeclarativeParentAnimation()
{
}
+/*!
+ \qmlproperty item ParentAnimation::target
+ The item to reparent.
+
+ When used in a transition, if no target is specified all
+ ParentChanges will be animated by the ParentAnimation.
+*/
QDeclarativeItem *QDeclarativeParentAnimation::target() const
{
Q_D(const QDeclarativeParentAnimation);
@@ -2403,6 +2477,12 @@ void QDeclarativeParentAnimation::setTarget(QDeclarativeItem *target)
d->target = target;
}
+/*!
+ \qmlproperty item ParentAnimation::newParent
+ The new parent to animate to.
+
+ If not set, then the parent defined in the end state of the transition.
+*/
QDeclarativeItem *QDeclarativeParentAnimation::newParent() const
{
Q_D(const QDeclarativeParentAnimation);
@@ -2415,6 +2495,19 @@ void QDeclarativeParentAnimation::setNewParent(QDeclarativeItem *newParent)
d->newParent = newParent;
}
+/*!
+ \qmlproperty item ParentAnimation::via
+ The item to reparent via. This provides a way to do an unclipped animation
+ when both the old parent and new parent are clipped
+
+ \qml
+ ParentAnimation {
+ target: myItem
+ via: topLevelItem
+ ...
+ }
+ \endqml
+*/
QDeclarativeItem *QDeclarativeParentAnimation::via() const
{
Q_D(const QDeclarativeParentAnimation);
@@ -2461,12 +2554,13 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions,
struct QDeclarativeParentActionData : public QAbstractAnimationAction
{
- QDeclarativeParentActionData(): pc(0) {}
- ~QDeclarativeParentActionData() { delete pc; }
+ QDeclarativeParentActionData() {}
+ ~QDeclarativeParentActionData() { qDeleteAll(pc); }
QDeclarativeStateActions actions;
+ //### reverse should probably apply on a per-action basis
bool reverse;
- QDeclarativeParentChange *pc;
+ QList<QDeclarativeParentChange *> pc;
virtual void doAction()
{
for (int ii = 0; ii < actions.count(); ++ii) {
@@ -2481,6 +2575,33 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions,
QDeclarativeParentActionData *data = new QDeclarativeParentActionData;
QDeclarativeParentActionData *viaData = new QDeclarativeParentActionData;
+
+ bool hasExplicit = false;
+ if (d->target && d->newParent) {
+ data->reverse = false;
+ QDeclarativeAction myAction;
+ QDeclarativeParentChange *pc = new QDeclarativeParentChange;
+ pc->setObject(d->target);
+ pc->setParent(d->newParent);
+ myAction.event = pc;
+ data->pc << pc;
+ data->actions << myAction;
+ hasExplicit = true;
+ if (d->via) {
+ viaData->reverse = false;
+ QDeclarativeAction myVAction;
+ QDeclarativeParentChange *vpc = new QDeclarativeParentChange;
+ vpc->setObject(d->target);
+ vpc->setParent(d->via);
+ myVAction.event = vpc;
+ viaData->pc << vpc;
+ viaData->actions << myVAction;
+ }
+ //### once actions have concept of modified,
+ // loop to match appropriate ParentChanges and mark as modified
+ }
+
+ if (!hasExplicit)
for (int i = 0; i < actions.size(); ++i) {
QDeclarativeAction &action = actions[i];
if (action.event && action.event->typeName() == QLatin1String("ParentChange")
@@ -2489,8 +2610,21 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions,
QDeclarativeParentChange *pc = static_cast<QDeclarativeParentChange*>(action.event);
QDeclarativeAction myAction = action;
data->reverse = action.reverseEvent;
- action.actionDone = true;
- data->actions << myAction;
+
+ //### this logic differs from PropertyAnimation
+ // (probably a result of modified vs. done)
+ if (d->newParent) {
+ QDeclarativeParentChange *epc = new QDeclarativeParentChange;
+ epc->setObject(static_cast<QDeclarativeParentChange*>(action.event)->object());
+ epc->setParent(d->newParent);
+ myAction.event = epc;
+ data->pc << epc;
+ data->actions << myAction;
+ pc = epc;
+ } else {
+ action.actionDone = true;
+ data->actions << myAction;
+ }
if (d->via) {
viaData->reverse = false;
@@ -2499,7 +2633,7 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions,
vpc->setObject(pc->object());
vpc->setParent(d->via);
myAction.event = vpc;
- viaData->pc = vpc;
+ viaData->pc << vpc;
viaData->actions << myAction;
QDeclarativeAction dummyAction;
QDeclarativeAction &xAction = pc->xIsSet() ? actions[++i] : dummyAction;
diff --git a/src/declarative/util/qdeclarativeanimation_p.h b/src/declarative/util/qdeclarativeanimation_p.h
index 0f23f5c..af48309 100644
--- a/src/declarative/util/qdeclarativeanimation_p.h
+++ b/src/declarative/util/qdeclarativeanimation_p.h
@@ -457,7 +457,7 @@ class QDeclarativeParentAnimation : public QDeclarativeAnimationGroup
Q_DECLARE_PRIVATE(QDeclarativeParentAnimation)
Q_PROPERTY(QDeclarativeItem *target READ target WRITE setTarget)
- //Q_PROPERTY(QDeclarativeItem *newParent READ newParent WRITE setNewParent)
+ Q_PROPERTY(QDeclarativeItem *newParent READ newParent WRITE setNewParent)
Q_PROPERTY(QDeclarativeItem *via READ via WRITE setVia)
public:
diff --git a/src/declarative/util/qdeclarativeanimation_p_p.h b/src/declarative/util/qdeclarativeanimation_p_p.h
index e582066..ae82a90 100644
--- a/src/declarative/util/qdeclarativeanimation_p_p.h
+++ b/src/declarative/util/qdeclarativeanimation_p_p.h
@@ -149,14 +149,21 @@ private:
bool running;
};
-//animates QDeclarativeTimeLineValue (assumes start and end values will be reals or compatible)
-class QDeclarativeTimeLineValueAnimator : public QVariantAnimation
+class QDeclarativeBulkValueUpdater
+{
+public:
+ virtual ~QDeclarativeBulkValueUpdater() {}
+ virtual void setValue(qreal value) = 0;
+};
+
+//animates QDeclarativeBulkValueUpdater (assumes start and end values will be reals or compatible)
+class QDeclarativeBulkValueAnimator : public QVariantAnimation
{
Q_OBJECT
public:
- QDeclarativeTimeLineValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), fromSourced(0), policy(KeepWhenStopped) {}
- ~QDeclarativeTimeLineValueAnimator() { if (policy == DeleteWhenStopped) { delete animValue; animValue = 0; } }
- void setAnimValue(QDeclarativeTimeLineValue *value, DeletionPolicy p)
+ QDeclarativeBulkValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), fromSourced(0), policy(KeepWhenStopped) {}
+ ~QDeclarativeBulkValueAnimator() { if (policy == DeleteWhenStopped) { delete animValue; animValue = 0; } }
+ void setAnimValue(QDeclarativeBulkValueUpdater *value, DeletionPolicy p)
{
if (state() == Running)
stop();
@@ -193,7 +200,7 @@ protected:
}
private:
- QDeclarativeTimeLineValue *animValue;
+ QDeclarativeBulkValueUpdater *animValue;
bool *fromSourced;
DeletionPolicy policy;
};
@@ -352,7 +359,7 @@ public:
int interpolatorType;
QVariantAnimation::Interpolator interpolator;
- QDeclarativeTimeLineValueAnimator *va;
+ QDeclarativeBulkValueAnimator *va;
static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress);
static void convertVariant(QVariant &variant, int type);
diff --git a/src/declarative/util/qdeclarativebehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp
index e0189dc..d90ca33 100644
--- a/src/declarative/util/qdeclarativebehavior.cpp
+++ b/src/declarative/util/qdeclarativebehavior.cpp
@@ -70,17 +70,18 @@ public:
/*!
\qmlclass Behavior QDeclarativeBehavior
+ \since 4.7
\brief The Behavior element allows you to specify a default animation for a property change.
Behaviors provide one way to specify \l{qdeclarativeanimation.html}{animations} in QML.
- In the example below, the rect will use a bounce easing curve over 200 millisecond for any changes to its y property:
+ In the example below, the rectangle will use a bounce easing curve over 200 millisecond for any changes to its y property:
\code
Rectangle {
width: 20; height: 20
color: "#00ff00"
- y: 200 //initial value
- y: Behavior {
+ y: 200 // initial value
+ Behavior on y {
NumberAnimation {
easing: "easeOutBounce(amplitude:100)"
duration: 200
@@ -156,6 +157,7 @@ void QDeclarativeBehavior::setEnabled(bool enabled)
void QDeclarativeBehavior::write(const QVariant &value)
{
Q_D(QDeclarativeBehavior);
+ qmlExecuteDeferred(this);
if (!d->animation || !d->enabled) {
QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
return;
diff --git a/src/declarative/util/qdeclarativebehavior_p.h b/src/declarative/util/qdeclarativebehavior_p.h
index a633b55..ff58210 100644
--- a/src/declarative/util/qdeclarativebehavior_p.h
+++ b/src/declarative/util/qdeclarativebehavior_p.h
@@ -65,6 +65,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeBehavior : public QObject, public QDeclar
Q_CLASSINFO("DefaultProperty", "animation")
Q_PROPERTY(QDeclarativeAbstractAnimation *animation READ animation WRITE setAnimation)
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
+ Q_CLASSINFO("DeferredPropertyNames", "animation")
public:
QDeclarativeBehavior(QObject *parent=0);
diff --git a/src/declarative/util/qdeclarativebind.cpp b/src/declarative/util/qdeclarativebind.cpp
index e95a03e..26baa38 100644
--- a/src/declarative/util/qdeclarativebind.cpp
+++ b/src/declarative/util/qdeclarativebind.cpp
@@ -72,7 +72,7 @@ public:
/*!
\qmlclass Binding QDeclarativeBind
- \since 4.7
+ \since 4.7
\brief The Binding element allows arbitrary property bindings to be created.
Sometimes it is necessary to bind to a property of an object that wasn't
@@ -114,6 +114,19 @@ QDeclarativeBind::~QDeclarativeBind()
{
}
+/*!
+ \qmlproperty bool Binding::when
+
+ This property holds when the binding is active.
+ This should be set to an expression that evaluates to true when you want the binding to be active.
+
+ \code
+ Binding {
+ target: contactName; property: 'text'
+ value: name; when: list.ListView.isCurrentItem
+ }
+ \endcode
+*/
bool QDeclarativeBind::when() const
{
Q_D(const QDeclarativeBind);
diff --git a/src/declarative/util/qdeclarativedatetimeformatter.cpp b/src/declarative/util/qdeclarativedatetimeformatter.cpp
deleted file mode 100644
index 4087091..0000000
--- a/src/declarative/util/qdeclarativedatetimeformatter.cpp
+++ /dev/null
@@ -1,373 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativedatetimeformatter_p.h"
-
-#include <QtCore/qlocale.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-//TODO: may need optimisation as the QDateTime member may not be needed?
-// be able to set a locale?
-
-class QDeclarativeDateTimeFormatterPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeDateTimeFormatter)
-public:
- QDeclarativeDateTimeFormatterPrivate() : locale(QLocale::system()), longStyle(false), componentComplete(true) {}
-
- void updateText();
-
- QDateTime dateTime;
- QDate date;
- QTime time;
- QLocale locale;
- QString dateTimeText;
- QString dateText;
- QString timeText;
- QString dateTimeFormat; //set for convienience?
- QString dateFormat;
- QString timeFormat;
- bool longStyle;
- bool componentComplete;
-};
-
-/*!
- \qmlclass DateTimeFormatter QDeclarativeDateTimeFormatter
- \since 4.7
- \brief The DateTimeFormatter allows you to control the format of a date string.
-
- \code
- DateTimeFormatter { id: formatter; date: System.date }
- Text { text: formatter.dateText }
- \endcode
-
- By default, the text properties (dateText, timeText, and dateTimeText) will return the
- date and time using the current system locale's format.
-*/
-
-/*!
- \internal
- \class QDeclarativeDateTimeFormatter
- \ingroup group_utility
- \brief The QDeclarativeDateTimeFormatter class allows you to format a date string.
-*/
-
-QDeclarativeDateTimeFormatter::QDeclarativeDateTimeFormatter(QObject *parent)
-: QObject(*(new QDeclarativeDateTimeFormatterPrivate), parent)
-{
-}
-
-QDeclarativeDateTimeFormatter::~QDeclarativeDateTimeFormatter()
-{
-}
-
-/*!
- \qmlproperty string DateTimeFormatter::dateText
- \qmlproperty string DateTimeFormatter::timeText
- \qmlproperty string DateTimeFormatter::dateTimeText
-
- Formatted text representations of the \c date, \c time,
- and \c {date and time}, respectively.
-
- If there is no explictly specified format the DateTimeFormatter
- will use the system locale's default 'short' setting.
-
- \code
- // specify source date (assuming today is February 19, 2009)
- DateTimeFormatter { id: formatter; dateTime: Today.date }
-
- // display the full date and time
- Text { text: formatter.dateText }
- \endcode
-
- Would be equivalent to the following for a US English locale:
-
- \code
- // display the date
- Text { text: "2/19/09" }
- \endcode
-*/
-QString QDeclarativeDateTimeFormatter::dateTimeText() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->dateTimeText;
-}
-
-QString QDeclarativeDateTimeFormatter::dateText() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->dateText;
-}
-
-QString QDeclarativeDateTimeFormatter::timeText() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->timeText;
-}
-
-/*!
- \qmlproperty date DateTimeFormatter::date
- \qmlproperty time DateTimeFormatter::time
- \qmlproperty datetime DateTimeFormatter::dateTime
-
- The source date and time to be used by the formatter.
-
- \code
- // setting the date and time
- DateTimeFormatter { date: System.date; time: System.time }
- \endcode
-
- For convienience it is possible to set the datetime property to set both the date and the time.
- \code
- // setting the datetime
- DateTimeFormatter { dateTime: System.dateTime }
- \endcode
-
- There can only be one instance of date and time per formatter; if date, time, and dateTime are all
- set the actual date and time used is not guaranteed.
-
- \note If no date is set, dateTimeText will be just the date;
- If no time is set, the dateTimeText will be just the time.
-
-*/
-QDate QDeclarativeDateTimeFormatter::date() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->date;
-}
-
-QTime QDeclarativeDateTimeFormatter::time() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->time;
-}
-
-QDateTime QDeclarativeDateTimeFormatter::dateTime() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->dateTime;
-}
-
-/*!
- \qmlproperty string DateTimeFormatter::dateFormat
- \qmlproperty string DateTimeFormatter::timeFormat
- \qmlproperty string DateTimeFormatter::dateTimeFormat
-
- Specifies a custom format which the DateTime Formatter can use.
-
- If there is no explictly specified format the DateTimeFormatter
- will use the system locale's default 'short' setting.
-
- The text's format may be modified by setting:
- \list
- \i \c dateFormat
- \i \c timeFormat
- \i \c dateTimeFormat
- \endlist
-
- If only the format for date is defined, the time and dateTime formats will be defined
- as the system locale default and likewise for the others.
-
- Syntax for the format is based on the QDateTime::toString() formatting options.
-
- \code
- // Format the date such that the dateText is: '1997-12-12'
- DateTimeFormatter { id: formatter; dateTime: Today.dateTime; formatDate: "yyyy-MM-d" }
- \endcode
-
- Assigning an empty string to a particular format will reset it.
-*/
-QString QDeclarativeDateTimeFormatter::dateTimeFormat() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->dateTimeFormat;
-}
-
-QString QDeclarativeDateTimeFormatter::dateFormat() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->dateFormat;
-}
-
-QString QDeclarativeDateTimeFormatter::timeFormat() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->timeFormat;
-}
-
-/*!
- \qmlproperty bool DateTimeFormatter::longStyle
-
- This property causes the formatter to use the system locale's long format rather than short format
- by default.
-
- This setting is off by default.
-*/
-bool QDeclarativeDateTimeFormatter::longStyle() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->longStyle;
-}
-
-void QDeclarativeDateTimeFormatter::setDateTime(const QDateTime &dateTime)
-{
- Q_D(QDeclarativeDateTimeFormatter);
- if (d->dateTime == dateTime)
- return;
- d->dateTime = dateTime;
- d->date = d->dateTime.date();
- d->time = d->dateTime.time();
- d->updateText();
-}
-
-void QDeclarativeDateTimeFormatter::setTime(const QTime &time)
-{
- Q_D(QDeclarativeDateTimeFormatter);
- if (d->dateTime.time() == time)
- return;
- d->time = time;
- d->dateTime.setTime(time);
- d->updateText();
-}
-
-void QDeclarativeDateTimeFormatter::setDate(const QDate &date)
-{
- Q_D(QDeclarativeDateTimeFormatter);
- if (d->dateTime.date() == date)
- return;
- d->date = date;
- bool clearTime = d->dateTime.time().isValid() ? false : true; //because setting date generates default time
- d->dateTime.setDate(date);
- if (clearTime)
- d->dateTime.setTime(QTime());
- d->updateText();
-}
-
-//DateTime formatting may be a combination of date and time?
-void QDeclarativeDateTimeFormatter::setDateTimeFormat(const QString &format)
-{
- Q_D(QDeclarativeDateTimeFormatter);
- //no format checking
- d->dateTimeFormat = format;
- d->updateText();
-}
-
-void QDeclarativeDateTimeFormatter::setDateFormat(const QString &format)
-{
- Q_D(QDeclarativeDateTimeFormatter);
- //no format checking
- d->dateFormat = format;
- d->updateText();
-}
-
-void QDeclarativeDateTimeFormatter::setTimeFormat(const QString &format)
-{
- Q_D(QDeclarativeDateTimeFormatter);
- //no format checking
- d->timeFormat = format;
- d->updateText();
-}
-
-void QDeclarativeDateTimeFormatter::setLongStyle(bool longStyle)
-{
- Q_D(QDeclarativeDateTimeFormatter);
- d->longStyle = longStyle;
- d->updateText();
-}
-
-void QDeclarativeDateTimeFormatterPrivate::updateText()
-{
- Q_Q(QDeclarativeDateTimeFormatter);
- if (!componentComplete)
- return;
-
- QString str;
- QString str1;
- QString str2;
-
- Qt::DateFormat defaultFormat = longStyle ? Qt::SystemLocaleLongDate : Qt::SystemLocaleShortDate;
-
- if (dateFormat.isEmpty())
- str1 = date.toString(defaultFormat);
- else
- str1 = date.toString(dateFormat);
-
- if (timeFormat.isEmpty())
- str2 = time.toString(defaultFormat);
- else
- str2 = time.toString(timeFormat);
-
- if (dateTimeFormat.isEmpty())
- str = dateTime.toString(defaultFormat);
- //else if (!formatTime.isEmpty() && !formatDate.isEmpty())
- // str = str1 + QLatin1Char(' ') + str2;
- else
- str = dateTime.toString(dateTimeFormat);
-
- if (dateTimeText == str && dateText == str1 && timeText == str2)
- return;
-
- dateTimeText = str;
- dateText = str1;
- timeText = str2;
-
- emit q->textChanged();
-}
-
-void QDeclarativeDateTimeFormatter::classBegin()
-{
- Q_D(QDeclarativeDateTimeFormatter);
- d->componentComplete = false;
-}
-
-void QDeclarativeDateTimeFormatter::componentComplete()
-{
- Q_D(QDeclarativeDateTimeFormatter);
- d->componentComplete = true;
- d->updateText();
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativedatetimeformatter_p.h b/src/declarative/util/qdeclarativedatetimeformatter_p.h
deleted file mode 100644
index da900be..0000000
--- a/src/declarative/util/qdeclarativedatetimeformatter_p.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEDATETIMEFORMATTER_H
-#define QDECLARATIVEDATETIMEFORMATTER_H
-
-#include <qdeclarative.h>
-
-#include <QtCore/qdatetime.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QDeclarativeDateTimeFormatterPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeDateTimeFormatter : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
-
- Q_PROPERTY(QString dateText READ dateText NOTIFY textChanged)
- Q_PROPERTY(QString timeText READ timeText NOTIFY textChanged)
- Q_PROPERTY(QString dateTimeText READ dateTimeText NOTIFY textChanged)
- Q_PROPERTY(QDate date READ date WRITE setDate)
- Q_PROPERTY(QTime time READ time WRITE setTime)
- Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime)
- Q_PROPERTY(QString dateFormat READ dateFormat WRITE setDateFormat)
- Q_PROPERTY(QString timeFormat READ timeFormat WRITE setTimeFormat)
- Q_PROPERTY(QString dateTimeFormat READ dateTimeFormat WRITE setDateTimeFormat)
- Q_PROPERTY(bool longStyle READ longStyle WRITE setLongStyle)
-public:
- QDeclarativeDateTimeFormatter(QObject *parent=0);
- ~QDeclarativeDateTimeFormatter();
-
- QString dateTimeText() const;
- QString dateText() const;
- QString timeText() const;
-
- QDate date() const;
- void setDate(const QDate &);
-
- QTime time() const;
- void setTime(const QTime &);
-
- QDateTime dateTime() const;
- void setDateTime(const QDateTime &);
-
- QString dateTimeFormat() const;
- void setDateTimeFormat(const QString &);
-
- QString dateFormat() const;
- void setDateFormat(const QString &);
-
- QString timeFormat() const;
- void setTimeFormat(const QString &);
-
- bool longStyle() const;
- void setLongStyle(bool);
-
- virtual void classBegin();
- virtual void componentComplete();
-
-Q_SIGNALS:
- void textChanged();
-
-private:
- Q_DISABLE_COPY(QDeclarativeDateTimeFormatter)
- Q_DECLARE_PRIVATE(QDeclarativeDateTimeFormatter)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeDateTimeFormatter)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/util/qdeclarativeeasefollow.cpp b/src/declarative/util/qdeclarativeeasefollow.cpp
index 232dc90..ee181dd 100644
--- a/src/declarative/util/qdeclarativeeasefollow.cpp
+++ b/src/declarative/util/qdeclarativeeasefollow.cpp
@@ -59,10 +59,10 @@ class QDeclarativeEaseFollowPrivate : public QObjectPrivate
public:
QDeclarativeEaseFollowPrivate()
: source(0), velocity(200), duration(-1), maximumEasingTime(-1),
- reversingMode(QDeclarativeEaseFollow::Eased), initialVelocity(0),
+ reversingMode(QDeclarativeEaseFollow::Eased), initialVelocity(0),
initialValue(0), invert(false), enabled(true), trackVelocity(0), clockOffset(0),
lastTick(0), clock(this)
- {}
+ {}
qreal source;
qreal velocity;
@@ -173,7 +173,7 @@ bool QDeclarativeEaseFollowPrivate::recalc()
}
/*
- qWarning() << "a:" << a << "tf:" << tf << "tp:" << tp << "vp:"
+ qWarning() << "a:" << a << "tf:" << tf << "tp:" << tp << "vp:"
<< vp << "sp:" << sp << "vi:" << vi << "invert:" << invert;
*/
return true;
@@ -251,21 +251,22 @@ void QDeclarativeEaseFollowPrivate::tick(int t)
/*!
\qmlclass EaseFollow QDeclarativeEaseFollow
+ \since 4.7
\brief The EaseFollow element allows a property to smoothly track a value.
- The EaseFollow smoothly animates a property's value to a set target value
+ The EaseFollow smoothly animates a property's value to a set target value
using an ease in/out quad easing curve. If the target value changes while
- the animation is in progress, the easing curves used to animate to the old
+ the animation is in progress, the easing curves used to animate to the old
and the new target values are spliced together to avoid any obvious visual
glitches.
The property animation is configured by setting the velocity at which the
- animation should occur, or the duration that the animation should take.
+ animation should occur, or the duration that the animation should take.
If both a velocity and a duration are specified, the one that results in
the quickest animation is chosen for each change in the target value.
For example, animating from 0 to 800 will take 4 seconds if a velocity
- of 200 is set, will take 8 seconds with a duration of 8000 set, and will
+ of 200 is set, will take 8 seconds with a duration of 8000 set, and will
take 4 seconds with both a velocity of 200 and a duration of 8000 set.
Animating from 0 to 20000 will take 10 seconds if a velocity of 200 is set,
will take 8 seconds with a duration of 8000 set, and will take 8 seconds
@@ -282,8 +283,8 @@ Rectangle {
color: "green"
width: 60; height: 60;
x: -5; y: -5;
- x: EaseFollow { source: rect1.x - 5; velocity: 200 }
- y: EaseFollow { source: rect1.y - 5; velocity: 200 }
+ EaseFollow on x { source: rect1.x - 5; velocity: 200 }
+ EaseFollow on y { source: rect1.y - 5; velocity: 200 }
}
Rectangle {
@@ -337,8 +338,8 @@ qreal QDeclarativeEaseFollow::sourceValue() const
Sets how the EaseFollow behaves if an animation direction is reversed.
If reversing mode is \c Eased, the animation will smoothly decelerate, and
- then reverse direction. If the reversing mode is \c Immediate, the
- animation will immediately begin accelerating in the reverse direction,
+ then reverse direction. If the reversing mode is \c Immediate, the
+ animation will immediately begin accelerating in the reverse direction,
begining with a velocity of 0. If the reversing mode is \c Sync, the
property is immediately set to the target value.
*/
@@ -372,7 +373,7 @@ void QDeclarativeEaseFollowPrivate::restart()
return;
}
- bool hasReversed = trackVelocity != 0. &&
+ bool hasReversed = trackVelocity != 0. &&
((trackVelocity > 0) == ((initialValue - source) > 0));
if (hasReversed) {
@@ -439,7 +440,7 @@ void QDeclarativeEaseFollow::setDuration(qreal v)
d->duration = v;
d->trackVelocity = 0;
- if (d->clock.state() == QAbstractAnimation::Running)
+ if (d->clock.state() == QAbstractAnimation::Running)
d->restart();
emit durationChanged();
@@ -469,7 +470,7 @@ void QDeclarativeEaseFollow::setVelocity(qreal v)
d->velocity = v;
d->trackVelocity = 0;
- if (d->clock.state() == QAbstractAnimation::Running)
+ if (d->clock.state() == QAbstractAnimation::Running)
d->restart();
emit velocityChanged();
@@ -510,8 +511,8 @@ void QDeclarativeEaseFollow::setTarget(const QDeclarativeProperty &t)
\qmlproperty qreal EaseFollow::maximumEasingTime
This property specifies the maximum time an "eases" during the follow should take.
-Setting this property causes the velocity to "level out" after at a time. Setting
-a negative value reverts to the normal mode of easing over the entire animation
+Setting this property causes the velocity to "level out" after at a time. Setting
+a negative value reverts to the normal mode of easing over the entire animation
duration.
The default value is -1.
@@ -527,7 +528,7 @@ void QDeclarativeEaseFollow::setMaximumEasingTime(qreal v)
Q_D(QDeclarativeEaseFollow);
d->maximumEasingTime = v;
- if (d->clock.state() == QAbstractAnimation::Running)
+ if (d->clock.state() == QAbstractAnimation::Running)
d->restart();
emit maximumEasingTimeChanged();
diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp
index ac30384..8f5f537 100644
--- a/src/declarative/util/qdeclarativefontloader.cpp
+++ b/src/declarative/util/qdeclarativefontloader.cpp
@@ -75,6 +75,7 @@ public:
/*!
\qmlclass FontLoader QDeclarativeFontLoader
+ \since 4.7
\ingroup group_utility
\brief This item allows using fonts by name or url.
@@ -188,6 +189,16 @@ void QDeclarativeFontLoader::setName(const QString &name)
\o Loading - the font is currently being loaded
\o Error - an error occurred while loading the font
\endlist
+
+ Note that a change in the status property does not cause anything to happen
+ (although it reflects what has happened to the font loader internally). If you wish
+ to react to the change in status you need to do it yourself, for example in one
+ of the following ways:
+ \list
+ \o Create a state, so that a state change occurs, e.g. State{name: 'loaded'; when: loader.status = FontLoader.Ready;}
+ \o Do something inside the onStatusChanged signal handler, e.g. FontLoader{id: loader; onStatusChanged: if(loader.status == FontLoader.Ready) console.log('Loaded');}
+ \o Bind to the status variable somewhere, e.g. Text{text: if(loader.status!=FontLoader.Ready){'Not Loaded';}else{'Loaded';}}
+ \endlist
*/
QDeclarativeFontLoader::Status QDeclarativeFontLoader::status() const
{
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp
index e78e0e1..e3f26d7 100644
--- a/src/declarative/util/qdeclarativelistmodel.cpp
+++ b/src/declarative/util/qdeclarativelistmodel.cpp
@@ -70,6 +70,7 @@ static void dump(ModelNode *node, int ind);
/*!
\qmlclass ListModel QDeclarativeListModel
+ \since 4.7
\brief The ListModel element defines a free-form list data source.
The ListModel is a simple hierarchy of elements containing data roles. The contents can
@@ -936,6 +937,7 @@ bool QDeclarativeListModelParser::definesEmptyList(const QString &s)
/*!
\qmlclass ListElement
+ \since 4.7
\brief The ListElement element defines a data item in a ListModel.
\sa ListModel
diff --git a/src/declarative/util/qdeclarativelistmodel_p.h b/src/declarative/util/qdeclarativelistmodel_p.h
index 251a31f..8eb6583 100644
--- a/src/declarative/util/qdeclarativelistmodel_p.h
+++ b/src/declarative/util/qdeclarativelistmodel_p.h
@@ -50,7 +50,7 @@
#include <QtCore/QHash>
#include <QtCore/QList>
#include <QtCore/QVariant>
-#include "../3rdparty/qlistmodelinterface_p.h"
+#include <private/qlistmodelinterface_p.h>
#include <QtScript/qscriptvalue.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/util/qdeclarativenumberformatter.cpp b/src/declarative/util/qdeclarativenumberformatter.cpp
deleted file mode 100644
index 5d81958..0000000
--- a/src/declarative/util/qdeclarativenumberformatter.cpp
+++ /dev/null
@@ -1,261 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativenumberformatter_p.h"
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-//TODO: set locale
-// docs
-// this is a wrapper around qnumberformat (test integration)
-// if number or format haven't been explictly set, text should be an empty string
-
-class QDeclarativeNumberFormatterPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeNumberFormatter)
-public:
- QDeclarativeNumberFormatterPrivate() : locale(QLocale::system()), number(0), componentComplete(true) {}
-
- void updateText();
-
- QLocale locale;
- QString format;
- QNumberFormat numberFormat;
- QString text;
- qreal number;
- bool componentComplete;
-};
-/*!
- \qmlclass NumberFormatter
- \since 4.7
- \brief The NumberFormatter allows you to control the format of a number string.
-
- The format property documentation has more details on how the format can be manipulated.
-
- In the following example, the text element will display the text "1,234.57".
- \code
- NumberFormatter { id: formatter; number: 1234.5678; format: "##,##0.##" }
- Text { text: formatter.text }
- \endcode
-
- */
-/*!
- \internal
- \class QDeclarativeNumberFormatter
- \ingroup group_utility
- \brief The QDeclarativeNumberFormatter class allows you to format a number to a particular string format/locale specific number format.
-*/
-
-QDeclarativeNumberFormatter::QDeclarativeNumberFormatter(QObject *parent)
-: QObject(*(new QDeclarativeNumberFormatterPrivate), parent)
-{
-}
-
-QDeclarativeNumberFormatter::~QDeclarativeNumberFormatter()
-{
-}
-
-/*!
- \qmlproperty string NumberFormatter::text
-
- The number in the specified format.
-
- If no format is specified the text will be empty.
-*/
-
-QString QDeclarativeNumberFormatter::text() const
-{
- Q_D(const QDeclarativeNumberFormatter);
- return d->text;
-}
-
-/*!
- \qmlproperty real NumberFormatter::number
-
- A single point precision number. (Doubles are not yet supported)
-
-*/
-qreal QDeclarativeNumberFormatter::number() const
-{
- Q_D(const QDeclarativeNumberFormatter);
- return d->number;
-}
-
-/*!
- \qmlproperty string NumberFormatter::format
-
- The particular format the number will adhere to during the conversion to text.
-
- The format syntax follows a style similar to the Unicode Standard (UTS35).
-
- The table below shows the characters, patterns that can be used in the format.
-
- \table
- \header
- \o Character
- \o Meaning
- \row
- \o #
- \o Any digit(s), zero shows as absent (for leading/trailing zeroes).
- \row
- \o 0
- \o Implicit digit. Zero will show in the case that the input number is too small.
- \row
- \o .
- \o Decimal separator. Output decimal seperator will be dependant on system locale.
- \row
- \o ,
- \o Grouping separator. The number of digits (either #, or 0) between the grouping separator and the decimal (or the rightmost digit) will determine the groupingSize).
- \row
- \o other
- \o Any other character will be taken as a string literal and placed directly into the output string.
- \endtable
-
- Invalid formats will not guarantee a meaningful text output.
-
- \note Input numbers that are too long for the given format will be rounded dependent on precison based on the position of the decimal point.
-
- The following table illustrates the output text created by applying some examples of numeric formats to the formatter.
-
- \table
- \header
- \o Format
- \o Number
- \o Output
- \row
- \o ###
- \o 123456
- \o 123456
- \row
- \o 000
- \o 123456
- \o 123456
- \row
- \o ######
- \o 1234
- \o 1234
- \row
- \o 000000
- \o 1234
- \o 001234
- \row
- \o ##,##0.##
- \o 1234.456
- \o 1,234.46 (for US locale)
- \codeline 1 234,46 (for FR locale)
- \row
- \o 000000,000.#
- \o 123456
- \o 000,123,456 (for US locale)
- \codeline 000 123 456 (for FR locale)
- \row
- \o 0.0###
- \o 0.999997
- \o 1.0
- \row
- \o (000) 000 - 000
- \o 12345678
- \o (012) 345 - 678
- \row
- \o #A
- \o 12
- \o 12A
- \endtable
-
-*/
-QString QDeclarativeNumberFormatter::format() const
-{
- Q_D(const QDeclarativeNumberFormatter);
- return d->format;
-}
-
-void QDeclarativeNumberFormatter::setNumber(const qreal &number)
-{
- Q_D(QDeclarativeNumberFormatter);
- if (d->number == number)
- return;
- d->number = number;
- d->updateText();
-}
-
-void QDeclarativeNumberFormatter::setFormat(const QString &format)
-{
- Q_D(QDeclarativeNumberFormatter);
- //no format checking
- if (format.isEmpty())
- d->format = QString::null;
- else
- d->format = format;
- d->updateText();
-}
-
-void QDeclarativeNumberFormatterPrivate::updateText()
-{
- Q_Q(QDeclarativeNumberFormatter);
- if (!componentComplete)
- return;
-
- QNumberFormat tempFormat;
- tempFormat.setFormat(format);
- tempFormat.setNumber(number);
-
- text = tempFormat.text();
-
- emit q->textChanged();
-}
-
-void QDeclarativeNumberFormatter::classBegin()
-{
- Q_D(QDeclarativeNumberFormatter);
- d->componentComplete = false;
-}
-
-void QDeclarativeNumberFormatter::componentComplete()
-{
- Q_D(QDeclarativeNumberFormatter);
- d->componentComplete = true;
- d->updateText();
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativenumberformatter_p.h b/src/declarative/util/qdeclarativenumberformatter_p.h
deleted file mode 100644
index 3b8c7e1..0000000
--- a/src/declarative/util/qdeclarativenumberformatter_p.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVENUMBERFORMATTER_H
-#define QDECLARATIVENUMBERFORMATTER_H
-
-#include "qnumberformat_p.h"
-
-#include <qdeclarative.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QDeclarativeNumberFormatterPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeNumberFormatter : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
-
- Q_PROPERTY(QString text READ text NOTIFY textChanged)
- Q_PROPERTY(QString format READ format WRITE setFormat)
- Q_PROPERTY(qreal number READ number WRITE setNumber)
-public:
- QDeclarativeNumberFormatter(QObject *parent=0);
- ~QDeclarativeNumberFormatter();
-
- QString text() const;
-
- qreal number() const;
- void setNumber(const qreal &);
-
- QString format() const;
- void setFormat(const QString &);
-
- virtual void classBegin();
- virtual void componentComplete();
-
-Q_SIGNALS:
- void textChanged();
-
-private:
- Q_DISABLE_COPY(QDeclarativeNumberFormatter)
- Q_DECLARE_PRIVATE(QDeclarativeNumberFormatter)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeNumberFormatter)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/util/qdeclarativepackage.cpp b/src/declarative/util/qdeclarativepackage.cpp
index 34ae466..d144777 100644
--- a/src/declarative/util/qdeclarativepackage.cpp
+++ b/src/declarative/util/qdeclarativepackage.cpp
@@ -42,7 +42,7 @@
#include "qdeclarativepackage_p.h"
#include <private/qobject_p.h>
-#include "private/qdeclarativeguard_p.h"
+#include <private/qdeclarativeguard_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/util/qdeclarativespringfollow.cpp b/src/declarative/util/qdeclarativespringfollow.cpp
index 012e6a0..1d69dd3 100644
--- a/src/declarative/util/qdeclarativespringfollow.cpp
+++ b/src/declarative/util/qdeclarativespringfollow.cpp
@@ -213,6 +213,7 @@ void QDeclarativeSpringFollowPrivate::stop()
/*!
\qmlclass SpringFollow QDeclarativeSpringFollow
+ \since 4.7
\brief The SpringFollow element allows a property to track a value.
In example below, \e rect2 will follow \e rect1 moving with a velocity of up to 200:
@@ -221,8 +222,8 @@ void QDeclarativeSpringFollowPrivate::stop()
id: rect1
width: 20; height: 20
color: "#00ff00"
- y: 200 //initial value
- y: SequentialAnimation {
+ y: 200 // initial value
+ SequentialAnimation on y {
running: true
repeat: true
NumberAnimation {
@@ -238,7 +239,7 @@ void QDeclarativeSpringFollowPrivate::stop()
x: rect1.width
width: 20; height: 20
color: "#ff0000"
- y: SpringFollow { source: rect1.y; velocity: 200 }
+ SpringFollow on y { source: rect1.y; velocity: 200 }
}
\endcode
diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp
index 1a7c256..083e87d 100644
--- a/src/declarative/util/qdeclarativestategroup.cpp
+++ b/src/declarative/util/qdeclarativestategroup.cpp
@@ -84,6 +84,7 @@ public:
/*!
\qmlclass StateGroup QDeclarativeStateGroup
+ \since 4.7
\brief The StateGroup element provides state support for non-Item elements.
Item (and all dervied elements) provides built in support for states and transitions
@@ -406,7 +407,7 @@ void QDeclarativeStateGroupPrivate::setCurrentStateInternal(const QString &state
}
if (oldState == 0 || newState == 0) {
- if (!nullState) { nullState = new QDeclarativeState; QDeclarativeGraphics_setParent_noEvent(nullState, q); }
+ if (!nullState) { nullState = new QDeclarativeState; QDeclarative_setParent_noEvent(nullState, q); }
if (!oldState) oldState = nullState;
if (!newState) newState = nullState;
}
diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp
index cea9ad7..cd06380 100644
--- a/src/declarative/util/qdeclarativestateoperations.cpp
+++ b/src/declarative/util/qdeclarativestateoperations.cpp
@@ -158,17 +158,17 @@ void QDeclarativeParentChangePrivate::doChange(QDeclarativeItem *targetParent, Q
\qmlclass ParentChange QDeclarativeParentChange
\brief The ParentChange element allows you to reparent an Item in a state change.
- ParentChange reparents an Item while preserving its visual appearance (position, rotation,
- and scale) on screen. You can then specify a transition to move/rotate/scale the Item to
- its final intended appearance.
+ ParentChange reparents an item while preserving its visual appearance (position, size,
+ rotation, and scale) on screen. You can then specify a transition to move/resize/rotate/scale
+ the item to its final intended appearance.
ParentChange can only preserve visual appearance if no complex transforms are involved.
More specifically, it will not work if the transform property has been set for any
- Items involved in the reparenting (defined as any Items in the common ancestor tree
+ items involved in the reparenting (i.e. items in the common ancestor tree
for the original and new parent).
You can specify at which point in a transition you want a ParentChange to occur by
- using a ParentAction.
+ using a ParentAnimation or ParentAction.
*/
@@ -181,6 +181,16 @@ QDeclarativeParentChange::~QDeclarativeParentChange()
{
}
+/*!
+ \qmlproperty real ParentChange::x
+ \qmlproperty real ParentChange::y
+ \qmlproperty real ParentChange::width
+ \qmlproperty real ParentChange::height
+ \qmlproperty real ParentChange::scale
+ \qmlproperty real ParentChange::rotation
+ These properties hold the new position, size, scale, and rotation
+ for the item in this state.
+*/
qreal QDeclarativeParentChange::x() const
{
Q_D(const QDeclarativeParentChange);
@@ -314,7 +324,7 @@ void QDeclarativeParentChange::setObject(QDeclarativeItem *target)
/*!
\qmlproperty Item ParentChange::parent
- This property holds the parent for the item in this state
+ This property holds the new parent for the item in this state.
*/
QDeclarativeItem *QDeclarativeParentChange::parent() const
diff --git a/src/declarative/util/qdeclarativestateoperations_p.h b/src/declarative/util/qdeclarativestateoperations_p.h
index 026a64d..dd4248023 100644
--- a/src/declarative/util/qdeclarativestateoperations_p.h
+++ b/src/declarative/util/qdeclarativestateoperations_p.h
@@ -45,7 +45,7 @@
#include "qdeclarativestate_p.h"
#include <qdeclarativeitem.h>
-#include "private/qdeclarativeanchors_p.h"
+#include <private/qdeclarativeanchors_p.h>
#include <qdeclarativescriptstring.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/util/qdeclarativesystempalette.cpp b/src/declarative/util/qdeclarativesystempalette.cpp
index 1e00f22..d819c27 100644
--- a/src/declarative/util/qdeclarativesystempalette.cpp
+++ b/src/declarative/util/qdeclarativesystempalette.cpp
@@ -58,6 +58,7 @@ public:
/*!
\qmlclass SystemPalette QDeclarativeSystemPalette
+ \since 4.7
\ingroup group_utility
\brief The SystemPalette item gives access to the Qt palettes.
\sa QPalette
diff --git a/src/declarative/util/qdeclarativetimeline_p_p.h b/src/declarative/util/qdeclarativetimeline_p_p.h
index c08c07c..598c897 100644
--- a/src/declarative/util/qdeclarativetimeline_p_p.h
+++ b/src/declarative/util/qdeclarativetimeline_p_p.h
@@ -160,7 +160,7 @@ public:
QDeclarativeTimeLineObject *callbackObject() const;
private:
- friend class QDeclarativeTimeLinePrivate;
+ friend struct QDeclarativeTimeLinePrivate;
Callback d0;
void *d1;
QDeclarativeTimeLineObject *d2;
diff --git a/src/declarative/util/qdeclarativetimer.cpp b/src/declarative/util/qdeclarativetimer.cpp
index 89c461b..104e3ae 100644
--- a/src/declarative/util/qdeclarativetimer.cpp
+++ b/src/declarative/util/qdeclarativetimer.cpp
@@ -70,6 +70,7 @@ public:
/*!
\qmlclass Timer QDeclarativeTimer
+ \since 4.7
\brief The Timer item triggers a handler at a specified interval.
A timer can be used to trigger an action either once, or repeatedly
@@ -122,6 +123,7 @@ void QDeclarativeTimer::setInterval(int interval)
if (interval != d->interval) {
d->interval = interval;
update();
+ emit intervalChanged();
}
}
@@ -182,6 +184,7 @@ void QDeclarativeTimer::setRepeating(bool repeating)
if (repeating != d->repeating) {
d->repeating = repeating;
update();
+ emit repeatChanged();
}
}
@@ -214,6 +217,7 @@ void QDeclarativeTimer::setTriggeredOnStart(bool triggeredOnStart)
if (d->triggeredOnStart != triggeredOnStart) {
d->triggeredOnStart = triggeredOnStart;
update();
+ emit triggeredOnStartChanged();
}
}
diff --git a/src/declarative/util/qdeclarativetimer_p.h b/src/declarative/util/qdeclarativetimer_p.h
index e063657..d1e6630 100644
--- a/src/declarative/util/qdeclarativetimer_p.h
+++ b/src/declarative/util/qdeclarativetimer_p.h
@@ -59,10 +59,10 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTimer : public QObject, public QDeclarati
Q_OBJECT
Q_DECLARE_PRIVATE(QDeclarativeTimer)
Q_INTERFACES(QDeclarativeParserStatus)
- Q_PROPERTY(int interval READ interval WRITE setInterval)
+ Q_PROPERTY(int interval READ interval WRITE setInterval NOTIFY intervalChanged)
Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
- Q_PROPERTY(bool repeat READ isRepeating WRITE setRepeating)
- Q_PROPERTY(bool triggeredOnStart READ triggeredOnStart WRITE setTriggeredOnStart)
+ Q_PROPERTY(bool repeat READ isRepeating WRITE setRepeating NOTIFY repeatChanged)
+ Q_PROPERTY(bool triggeredOnStart READ triggeredOnStart WRITE setTriggeredOnStart NOTIFY triggeredOnStartChanged)
public:
QDeclarativeTimer(QObject *parent=0);
@@ -91,6 +91,9 @@ public Q_SLOTS:
Q_SIGNALS:
void triggered();
void runningChanged();
+ void intervalChanged();
+ void repeatChanged();
+ void triggeredOnStartChanged();
private:
void update();
diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp
index 2b8c7de..65bfdc1 100644
--- a/src/declarative/util/qdeclarativeutilmodule.cpp
+++ b/src/declarative/util/qdeclarativeutilmodule.cpp
@@ -46,13 +46,11 @@
#include "qdeclarativebehavior_p.h"
#include "qdeclarativebind_p.h"
#include "qdeclarativeconnections_p.h"
-#include "qdeclarativedatetimeformatter_p.h"
#include "qdeclarativeeasefollow_p.h"
#include "qdeclarativefontloader_p.h"
#include "qdeclarativelistaccessor_p.h"
#include "qdeclarativelistmodel_p.h"
#include "qdeclarativenullablevalue_p_p.h"
-#include "qdeclarativenumberformatter_p.h"
#include "qdeclarativeopenmetaobject_p.h"
#include "qdeclarativepackage_p.h"
#include "qdeclarativepixmapcache_p.h"
@@ -70,8 +68,9 @@
#include "qdeclarativetransitionmanager_p_p.h"
#include "qdeclarativetransition_p.h"
#include "qdeclarativeview.h"
+#ifndef QT_NO_XMLPATTERNS
#include "qdeclarativexmllistmodel_p.h"
-#include "qnumberformat_p.h"
+#endif
#include "qperformancelog_p_p.h"
void QDeclarativeUtilModule::defineModule()
@@ -81,12 +80,10 @@ void QDeclarativeUtilModule::defineModule()
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,DateTimeFormatter,QDeclarativeDateTimeFormatter);
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,NumberFormatter,QDeclarativeNumberFormatter);;
QML_REGISTER_TYPE(Qt,4,6,Package,QDeclarativePackage);
QML_REGISTER_TYPE(Qt,4,6,ParallelAnimation,QDeclarativeParallelAnimation);
QML_REGISTER_TYPE(Qt,4,6,ParentAction,QDeclarativeParentAction);
@@ -114,7 +111,6 @@ void QDeclarativeUtilModule::defineModule()
QML_REGISTER_NOCREATE_TYPE(QDeclarativeAnchors);
QML_REGISTER_NOCREATE_TYPE(QDeclarativeAbstractAnimation);
QML_REGISTER_NOCREATE_TYPE(QDeclarativeStateOperation);
- QML_REGISTER_NOCREATE_TYPE(QNumberFormat);
QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, ListModel, QDeclarativeListModel, QDeclarativeListModelParser);
QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, PropertyChanges, QDeclarativePropertyChanges, QDeclarativePropertyChangesParser);
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
index 6fe5bf3..cd67aeb 100644
--- a/src/declarative/util/qdeclarativeview.cpp
+++ b/src/declarative/util/qdeclarativeview.cpp
@@ -51,6 +51,7 @@
#include <qdeclarativedebug_p.h>
#include <qdeclarativedebugservice_p.h>
#include <qdeclarativeglobal_p.h>
+#include <qdeclarativeguard_p.h>
#include <qscriptvalueiterator.h>
#include <qdebug.h>
@@ -136,8 +137,8 @@ public:
QDeclarativeView *q;
- QGuard<QGraphicsObject> root;
- QGuard<QDeclarativeItem> qmlRoot;
+ QDeclarativeGuard<QGraphicsObject> root;
+ QDeclarativeGuard<QDeclarativeItem> qmlRoot;
QUrl source;
@@ -193,6 +194,7 @@ void QDeclarativeViewPrivate::execute()
\o Initializes QGraphicsView for QML key handling:
\list
\o QGraphicsView::viewport()->setFocusPolicy(Qt::NoFocus);
+ \o QGraphicsView::setFocusPolicy(Qt::StrongFocus);
\o QGraphicsScene::setStickyFocus(true);
\endlist
\endlist
@@ -267,6 +269,7 @@ void QDeclarativeViewPrivate::init()
q->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
scene.setItemIndexMethod(QGraphicsScene::NoIndex);
q->viewport()->setFocusPolicy(Qt::NoFocus);
+ q->setFocusPolicy(Qt::StrongFocus);
scene.setStickyFocus(true); //### needed for correct focus handling
}
@@ -282,13 +285,14 @@ QDeclarativeView::~QDeclarativeView()
/*!
Sets the source to the \a url, loads the QML component and instantiates it.
+
+ Calling this methods multiple times with the same url will result
+ in the QML being reloaded.
*/
void QDeclarativeView::setSource(const QUrl& url)
{
- if (url != d->source) {
- d->source = url;
- d->execute();
- }
+ d->source = url;
+ d->execute();
}
/*!
diff --git a/src/declarative/util/qdeclarativeview.h b/src/declarative/util/qdeclarativeview.h
index 03d8db3..107f3f9 100644
--- a/src/declarative/util/qdeclarativeview.h
+++ b/src/declarative/util/qdeclarativeview.h
@@ -43,6 +43,7 @@
#define QDECLARATIVEVIEW_H
#include <QtCore/qdatetime.h>
+#include <QtCore/qurl.h>
#include <QtGui/qgraphicssceneevent.h>
#include <QtGui/qgraphicsview.h>
#include <QtGui/qwidget.h>
@@ -64,7 +65,8 @@ class Q_DECLARATIVE_EXPORT QDeclarativeView : public QGraphicsView
Q_OBJECT
Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
-
+ Q_PROPERTY(QUrl source READ source WRITE setSource DESIGNABLE true)
+ Q_ENUMS(ResizeMode Status)
public:
explicit QDeclarativeView(QWidget *parent = 0);
QDeclarativeView(const QUrl &source, QWidget *parent = 0);
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index 386df46..49dbb27 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -61,9 +61,6 @@
QT_BEGIN_NAMESPACE
-
-
-
typedef QPair<int, int> QDeclarativeXmlListRange;
/*!
@@ -114,9 +111,6 @@ class QDeclarativeXmlQuery : public QThread
{
Q_OBJECT
public:
- QDeclarativeXmlQuery(QObject *parent=0)
- : QThread(parent), m_quit(false), m_restart(false), m_abort(false), m_queryId(0) {
- }
~QDeclarativeXmlQuery() {
m_mutex.lock();
m_quit = true;
@@ -126,6 +120,11 @@ public:
wait();
}
+ static QDeclarativeXmlQuery *instance() {
+ static QDeclarativeXmlQuery *query = new QDeclarativeXmlQuery;
+ return query;
+ }
+
void abort() {
QMutexLocker locker(&m_mutex);
m_abort = true;
@@ -164,6 +163,11 @@ public:
return m_removedItemRanges;
}
+private:
+ QDeclarativeXmlQuery(QObject *parent=0)
+ : QThread(parent), m_quit(false), m_restart(false), m_abort(false), m_queryId(0) {
+ }
+
Q_SIGNALS:
void queryCompleted(int queryId, int size);
@@ -213,6 +217,8 @@ private:
QList<QDeclarativeXmlListRange> m_removedItemRanges;
};
+//Q_GLOBAL_STATIC(QDeclarativeXmlQuery, QDeclarativeXmlQuery::instance());
+
void QDeclarativeXmlQuery::doQueryJob()
{
QString r;
@@ -404,7 +410,6 @@ public:
QNetworkReply *reply;
QDeclarativeXmlListModel::Status status;
qreal progress;
- QDeclarativeXmlQuery qmlXmlQuery;
int queryId;
QList<QDeclarativeXmlListModelRole *> roleObjects;
static void append_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list, QDeclarativeXmlListModelRole *role);
@@ -488,8 +493,7 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla
QDeclarativeXmlListModel::QDeclarativeXmlListModel(QObject *parent)
: QListModelInterface(*(new QDeclarativeXmlListModelPrivate), parent)
{
- Q_D(QDeclarativeXmlListModel);
- connect(&d->qmlXmlQuery, SIGNAL(queryCompleted(int,int)),
+ connect(QDeclarativeXmlQuery::instance(), SIGNAL(queryCompleted(int,int)),
this, SLOT(queryCompleted(int,int)));
}
@@ -571,9 +575,10 @@ void QDeclarativeXmlListModel::setSource(const QUrl &src)
{
Q_D(QDeclarativeXmlListModel);
if (d->src != src) {
- d->src = src;
reload();
- }
+ d->src = src;
+ emit sourceChanged();
+ }
}
/*!
@@ -593,8 +598,11 @@ QString QDeclarativeXmlListModel::xml() const
void QDeclarativeXmlListModel::setXml(const QString &xml)
{
Q_D(QDeclarativeXmlListModel);
- d->xml = xml;
- reload();
+ if (d->xml != xml) {
+ d->xml = xml;
+ reload();
+ emit xmlChanged();
+ }
}
/*!
@@ -619,6 +627,7 @@ void QDeclarativeXmlListModel::setQuery(const QString &query)
if (d->query != query) {
d->query = query;
reload();
+ emit queryChanged();
}
}
@@ -638,6 +647,7 @@ void QDeclarativeXmlListModel::setNamespaceDeclarations(const QString &declarati
if (d->namespaces != declarations) {
d->namespaces = declarations;
reload();
+ emit namespaceDeclarationsChanged();
}
}
@@ -647,11 +657,21 @@ void QDeclarativeXmlListModel::setNamespaceDeclarations(const QString &declarati
This property holds the status of data source loading. It can be one of:
\list
\o Null - no data source has been set
- \o Ready - nthe data source has been loaded
+ \o Ready - the data source has been loaded
\o Loading - the data source is currently being loaded
\o Error - an error occurred while loading the data source
\endlist
+ Note that a change in the status property does not cause anything to happen
+ (although it reflects what has happened to the XmlListModel internally). If you wish
+ to react to the change in status you need to do it yourself, for example in one
+ of the following ways:
+ \list
+ \o Create a state, so that a state change occurs, e.g. State{name: 'loaded'; when: xmlListModel.status = XmlListModel.Ready;}
+ \o Do something inside the onStatusChanged signal handler, e.g. XmlListModel{id: xmlListModel; onStatusChanged: if(xmlListModel.status == XmlListModel.Ready) console.log('Loaded');}
+ \o Bind to the status variable somewhere, e.g. Text{text: if(xmlListModel.status!=XmlListModel.Ready){'Not Loaded';}else{'Loaded';}}
+ \endlist
+
\sa progress
*/
@@ -706,11 +726,27 @@ void QDeclarativeXmlListModel::reload()
if (!d->isComponentComplete)
return;
- d->qmlXmlQuery.abort();
+ QDeclarativeXmlQuery::instance()->abort();
d->queryId = -1;
- if (d->size < 0)
+ int count = d->size;
+ if (count < 0)
+ d->size = 0;
+ bool hasKeys = false;
+ for (int i=0; i<d->roleObjects.count(); i++) {
+ if (d->roleObjects[i]->isKey()) {
+ hasKeys = true;
+ break;
+ }
+ }
+ if (!hasKeys) {
+ d->data.clear();
d->size = 0;
+ if (count > 0) {
+ emit itemsRemoved(0, count);
+ emit countChanged();
+ }
+ }
if (d->src.isEmpty() && d->xml.isEmpty())
return;
@@ -722,7 +758,7 @@ void QDeclarativeXmlListModel::reload()
}
if (!d->xml.isEmpty()) {
- d->queryId = d->qmlXmlQuery.doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects);
+ d->queryId = QDeclarativeXmlQuery::instance()->doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects);
d->progress = 1.0;
d->status = Ready;
emit progressChanged(d->progress);
@@ -753,7 +789,7 @@ void QDeclarativeXmlListModel::requestFinished()
} else {
d->status = Ready;
QByteArray data = d->reply->readAll();
- d->queryId = d->qmlXmlQuery.doQuery(d->query, d->namespaces, data, &d->roleObjects);
+ d->queryId = QDeclarativeXmlQuery::instance()->doQuery(d->query, d->namespaces, data, &d->roleObjects);
disconnect(d->reply, 0, this, 0);
d->reply->deleteLater();
d->reply = 0;
@@ -779,12 +815,13 @@ void QDeclarativeXmlListModel::queryCompleted(int id, int size)
return;
bool sizeChanged = size != d->size;
d->size = size;
- d->data = d->qmlXmlQuery.modelData();
+ d->data = QDeclarativeXmlQuery::instance()->modelData();
+
+ QList<QDeclarativeXmlListRange> removed = QDeclarativeXmlQuery::instance()->removedItemRanges();
+ QList<QDeclarativeXmlListRange> inserted = QDeclarativeXmlQuery::instance()->insertedItemRanges();
- QList<QDeclarativeXmlListRange> removed = d->qmlXmlQuery.removedItemRanges();
for (int i=0; i<removed.count(); i++)
emit itemsRemoved(removed[i].first, removed[i].second);
- QList<QDeclarativeXmlListRange> inserted = d->qmlXmlQuery.insertedItemRanges();
for (int i=0; i<inserted.count(); i++)
emit itemsInserted(inserted[i].first, inserted[i].second);
diff --git a/src/declarative/util/qdeclarativexmllistmodel_p.h b/src/declarative/util/qdeclarativexmllistmodel_p.h
index 132a53c..23ff7ce 100644
--- a/src/declarative/util/qdeclarativexmllistmodel_p.h
+++ b/src/declarative/util/qdeclarativexmllistmodel_p.h
@@ -47,7 +47,7 @@
#include <QtCore/qurl.h>
-#include "../3rdparty/qlistmodelinterface_p.h"
+#include <private/qlistmodelinterface_p.h>
QT_BEGIN_HEADER
@@ -68,10 +68,10 @@ class Q_DECLARATIVE_EXPORT QDeclarativeXmlListModel : public QListModelInterface
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
- Q_PROPERTY(QUrl source READ source WRITE setSource)
- Q_PROPERTY(QString xml READ xml WRITE setXml)
- Q_PROPERTY(QString query READ query WRITE setQuery)
- Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations)
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(QString xml READ xml WRITE setXml NOTIFY xmlChanged)
+ Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged)
+ Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations NOTIFY namespaceDeclarationsChanged)
Q_PROPERTY(QDeclarativeListProperty<QDeclarativeXmlListModelRole> roles READ roleObjects)
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_CLASSINFO("DefaultProperty", "roles")
@@ -111,6 +111,10 @@ Q_SIGNALS:
void statusChanged(Status);
void progressChanged(qreal progress);
void countChanged();
+ void sourceChanged();
+ void xmlChanged();
+ void queryChanged();
+ void namespaceDeclarationsChanged();
public Q_SLOTS:
// ### need to use/expose Expiry to guess when to call this?
@@ -132,16 +136,20 @@ private:
class Q_DECLARATIVE_EXPORT QDeclarativeXmlListModelRole : public QObject
{
Q_OBJECT
- Q_PROPERTY(QString name READ name WRITE setName)
- Q_PROPERTY(QString query READ query WRITE setQuery)
- Q_PROPERTY(bool isKey READ isKey WRITE setIsKey)
-
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged)
+ Q_PROPERTY(bool isKey READ isKey WRITE setIsKey NOTIFY isKeyChanged)
public:
QDeclarativeXmlListModelRole() : m_isKey(false) {}
~QDeclarativeXmlListModelRole() {}
QString name() const { return m_name; }
- void setName(const QString &name) { m_name = name; }
+ void setName(const QString &name) {
+ if (name == m_name)
+ return;
+ m_name = name;
+ emit nameChanged();
+ }
QString query() const { return m_query; }
void setQuery(const QString &query)
@@ -150,16 +158,29 @@ public:
qmlInfo(this) << tr("An XmlRole query must not start with '/'");
return;
}
+ if (m_query == query)
+ return;
m_query = query;
+ emit queryChanged();
}
bool isKey() const { return m_isKey; }
- void setIsKey(bool b) { m_isKey = b; }
+ void setIsKey(bool b) {
+ if (m_isKey == b)
+ return;
+ m_isKey = b;
+ emit isKeyChanged();
+ }
bool isValid() {
return !m_name.isEmpty() && !m_query.isEmpty();
}
+Q_SIGNALS:
+ void nameChanged();
+ void queryChanged();
+ void isKeyChanged();
+
private:
QString m_name;
QString m_query;
diff --git a/src/declarative/util/qnumberformat.cpp b/src/declarative/util/qnumberformat.cpp
deleted file mode 100644
index 81d0b90..0000000
--- a/src/declarative/util/qnumberformat.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qnumberformat_p.h"
-#include <QtCore/qstringlist.h>
-
-QT_BEGIN_NAMESPACE
-
-QNumberFormat::QNumberFormat(QObject *parent) : QObject(parent), _number(0), _type(Decimal),
- _groupingSize(0)
-{
- _locale = QLocale::system();
- _groupingSeparator = _locale.groupSeparator();
- _decimalSeparator = _locale.decimalPoint();
- _currencySymbol = QLatin1Char('$');
-}
-
-QNumberFormat::~QNumberFormat()
-{
-
-}
-
-void QNumberFormat::updateText()
-{
- QTime t;
- t.start();
- static int totalTime;
-
- handleFormat();
-
- totalTime += t.elapsed();
- emit textChanged();
-}
-
-void QNumberFormat::handleFormat()
-{
- // ### is extremely messy
- if (_format.isEmpty()) {
- _text = QString::number(_number, 'f', -1);
- return;
- }
-
- QString inputString;
-
- // ### possible to use the following parsed data in the future
-
- int remainingLength = _format.size();
- int currentIndex = _format.size()-1;
-
- int maxDigits = 0;
- int minDigits = 0;
- int decimalLength = 0;
-
- while (remainingLength > 0) {
- switch(_format.at(currentIndex).unicode()) {
- case ',':
- if (decimalLength && !_groupingSize)
- setGroupingSize(maxDigits - decimalLength);
- else if (!_groupingSize)
- setGroupingSize(maxDigits);
- break;
- case '.':
- if (!decimalLength)
- decimalLength = maxDigits;
- break;
- case '0':
- minDigits++;
- case '#':
- maxDigits++;
- break;
- default:
- break;
- }
- currentIndex--;
- remainingLength--;
- }
-
- // round given the decimal length/precision
- inputString = QString::number(_number, 'f', decimalLength);
-
- QStringList parts = inputString.split(QLatin1Char('.'));
- QStringList formatParts = _format.split(QLatin1Char('.'));
-
- if (formatParts.size() > 2 || parts.size() > 2 )
- return;
-
- QString formatInt = formatParts.at(0);
-
- QString formatDec;
- if (formatParts.size() == 2)
- formatDec = formatParts.at(1);
-
- QString integer = parts.at(0);
-
- QString decimal;
- if (parts.size() == 2)
- decimal = parts.at(1);
-
- QString outputDecimal = formatDecimal(formatDec, decimal);
- QString outputInteger = formatInteger(formatInt, integer);
-
- // insert separators
- if (_groupingSize) {
- unsigned int count = 0;
- for (int i = outputInteger.size()-1; i > 0; i--) {
- if (outputInteger.at(i).digitValue() >= 0) {
- if (count == _groupingSize - 1) {
- count = 0;
- outputInteger.insert(i, _groupingSeparator);
- }
- else
- count++;
- }
- }
- }
- if (!outputDecimal.isEmpty())
- _text = outputInteger + _decimalSeparator + outputDecimal;
- else
- _text = outputInteger;
-}
-
-QString QNumberFormat::formatInteger(const QString &formatInt, const QString &integer)
-{
- if (formatInt.isEmpty() || integer.isEmpty())
- return QString();
-
- QString outputInteger;
- int formatIndex = formatInt.size()-1;
-
- //easier for carry?
- for (int index= integer.size()-1; index >= 0; index--) {
- if (formatIndex < 0) {
- outputInteger.push_front(integer.at(index));
- }
- else {
- switch(formatInt.at(formatIndex).unicode()) {
- case '0':
- if (index > integer.size()-1) {
- outputInteger.push_front(QLatin1Char('0'));
- break;
- }
- case '#':
- outputInteger.push_front(integer.at(index));
- break;
- case ',':
- index++;
- break;
- default:
- outputInteger.push_front(formatInt.at(formatIndex));
- index++;
- break;
- }
- formatIndex--;
- }
- }
- while (formatIndex >= 0) {
- if (formatInt.at(formatIndex).unicode() != '#' && formatInt.at(formatIndex).unicode() != ',')
- outputInteger.push_front(formatInt.at(formatIndex));
- formatIndex--;
- }
- return outputInteger;
-}
-
-QString QNumberFormat::formatDecimal(const QString &formatDec, const QString &decimal)
-{
- QString outputDecimal;
-
- // up to max 6 decimal places
- for (int index=formatDec.size()-1; index >= 0; index--) {
- switch(formatDec.at(index).unicode()) {
- case '0':
- outputDecimal.push_front(decimal.at(index));
- break;
- case '#':
- if (decimal.at(index) != QLatin1Char('0') || outputDecimal.size() > 0)
- outputDecimal.push_front(decimal.at(index));
- break;
- default:
- outputDecimal.push_front(formatDec.at(index));
- break;
- }
- }
- return outputDecimal;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qnumberformat_p.h b/src/declarative/util/qnumberformat_p.h
deleted file mode 100644
index ced4442..0000000
--- a/src/declarative/util/qnumberformat_p.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef NUMBERFORMAT_H
-#define NUMBERFORMAT_H
-
-#include <qdeclarative.h>
-
-#include <QtCore/QLocale>
-#include <QtCore/QTime>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-// TODO
-// be able to set Locale, instead of default system for dynamic formatting
-// add currency support
-// add additional syntax, extend to format scientific, percentiles, significant digits etc
-
-
-class QNumberFormat : public QObject
-{
- Q_OBJECT
- Q_ENUMS(NumberType)
-public:
- QNumberFormat(QObject *parent=0);
- ~QNumberFormat();
-
- enum NumberType {
- Percent,
- Scientific,
- Currency,
- Decimal
- };
-
- //external property, only visible
- Q_PROPERTY(QString text READ text NOTIFY textChanged)
-
- //mutatable properties to modify the output (text)
- Q_PROPERTY(qreal number READ number WRITE setNumber)
- Q_PROPERTY(QString format READ format WRITE setFormat)
- Q_PROPERTY(QLocale locale READ locale WRITE setLocale)
-
- //Format specific settings
- Q_PROPERTY(unsigned short groupingSeparator READ groupingSeparator WRITE setGroupingSeparator)
- Q_PROPERTY(unsigned short decimalSeperator READ decimalSeparator WRITE setDecimalSeparator)
- Q_PROPERTY(unsigned int groupingSize READ groupingSize WRITE setGroupingSize)
- Q_PROPERTY(unsigned short currencySymbol READ currencySymbol WRITE setCurrencySymbol)
-
-
- QString text() const { return _text; }
-
- qreal number() const { return _number; }
- void setNumber(qreal n) {
- if (_number == n)
- return;
- _number = n;
- updateText();
- }
-
- QString format() const { return _format; }
- void setFormat(const QString &format) {
- if (format.isEmpty())
- _format = QString::null;
- else if (_format == format)
- return;
-
- _format = format;
- updateText();
- }
-
- QLocale locale() const { return _locale; }
- void setLocale(const QLocale &locale) { _locale = locale; updateText(); }
-
- //Do we deal with unicode standard? or create our own
- // ### since this is the backend for the number conversions, we will use the unicode
- // the front-end will handle the QChar/QString -> short int
-
- unsigned short groupingSeparator() { return _groupingSeparator.unicode(); }
- void setGroupingSeparator(unsigned short unicodeSymbol)
- {
- _groupingSeparator = QChar(unicodeSymbol);
- }
-
- unsigned short decimalSeparator() { return _decimalSeparator.unicode(); }
- void setDecimalSeparator(unsigned short unicodeSymbol)
- {
- _decimalSeparator = QChar(unicodeSymbol);
- }
-
- unsigned short currencySymbol() { return _currencySymbol.unicode(); }
- void setCurrencySymbol(unsigned short unicodeSymbol)
- {
- _currencySymbol = QChar(unicodeSymbol);
- }
-
- unsigned int groupingSize() { return _groupingSize; }
- void setGroupingSize(unsigned int size)
- {
- _groupingSize = size;
- }
-
-Q_SIGNALS:
- void textChanged();
-
-private:
- void updateText();
- void handleFormat();
- QString formatInteger(const QString &formatInt, const QString &integer);
- QString formatDecimal(const QString &formatDec, const QString &decimal);
-
- qreal _number;
- NumberType _type;
- QChar _groupingSeparator;
- QChar _decimalSeparator;
- QChar _currencySymbol;
- unsigned int _groupingSize;
-
- QLocale _locale;
- QString _format;
-
- // only hooked member at the moment
- QString _text;
-
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QNumberFormat)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri
index 198e9e5..26edecc 100644
--- a/src/declarative/util/util.pri
+++ b/src/declarative/util/util.pri
@@ -25,9 +25,6 @@ SOURCES += \
$$PWD/qdeclarativebind.cpp \
$$PWD/qdeclarativepropertymap.cpp \
$$PWD/qdeclarativepixmapcache.cpp \
- $$PWD/qnumberformat.cpp \
- $$PWD/qdeclarativenumberformatter.cpp \
- $$PWD/qdeclarativedatetimeformatter.cpp \
$$PWD/qdeclarativebehavior.cpp \
$$PWD/qdeclarativefontloader.cpp \
$$PWD/qdeclarativestyledtext.cpp
@@ -60,9 +57,6 @@ HEADERS += \
$$PWD/qdeclarativebind_p.h \
$$PWD/qdeclarativepropertymap.h \
$$PWD/qdeclarativepixmapcache_p.h \
- $$PWD/qnumberformat_p.h \
- $$PWD/qdeclarativenumberformatter_p.h \
- $$PWD/qdeclarativedatetimeformatter_p.h \
$$PWD/qdeclarativebehavior_p.h \
$$PWD/qdeclarativefontloader_p.h \
$$PWD/qdeclarativestyledtext_p.h