summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/declarative/QmlChanges.txt11
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp213
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p.h43
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p_p.h10
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp46
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp193
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp45
-rw-r--r--src/declarative/graphicsitems/qdeclarativepath.cpp11
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp42
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativerepeater.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp11
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p_p.h3
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp22
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p_p.h3
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp63
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h6
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp4
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp11
-rw-r--r--src/declarative/qml/qdeclarativeinstruction.cpp3
-rw-r--r--src/declarative/qml/qdeclarativeinstruction_p.h1
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp10
-rw-r--r--src/declarative/util/qdeclarativebehavior.cpp6
-rw-r--r--src/declarative/util/qdeclarativepixmapcache.cpp6
-rw-r--r--src/declarative/util/qdeclarativepropertychanges.cpp11
-rw-r--r--src/declarative/util/qdeclarativeview.cpp45
-rw-r--r--src/declarative/util/qdeclarativeview.h3
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp91
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp8
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp2
-rw-r--r--src/gui/image/qpixmapcache.cpp43
-rw-r--r--src/gui/image/qpixmapcache.h10
-rw-r--r--src/gui/image/qpixmapcache_p.h2
-rw-r--r--src/plugins/imageformats/gif/qgifhandler.cpp7
35 files changed, 650 insertions, 340 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index dfc4244..9ab3f08 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -1,13 +1,18 @@
=============================================================================
The changes below are pre Qt 4.7.0 RC
-Flickable: overShoot is replaced by boundsBehavior enumeration.
+Flickable:
+ - overShoot is replaced by boundsBehavior enumeration
+ - flicking is replaced by flickingHorizontally and flickingVertically
+ - moving is replaced by movingHorizontally and movingVertically
+ - flickDirection is renamed flickableDirection
+ - onMovementStarted, onMovementEnded, onFlickStarted and onFlickEnded signals removed
Component: isReady, isLoading, isError and isNull properties removed, use
status property instead
QList<QObject*> models no longer provide properties in model object. The
properties are now updated when the object changes. An object's property
"foo" may now be accessed as "foo", modelData.foo" or model.modelData.foo"
-
+component.createObject has gained a mandatory "parent" argument
C++ API
-------
@@ -15,7 +20,7 @@ QDeclarativeExpression::value() has been renamed to
QDeclarativeExpression::evaluate()
=============================================================================
-The changes below are pre Qt 4.7.0 beta
+The changes below are pre Qt 4.7.0 beta 1
TextEdit: wrap property is replaced by wrapMode enumeration.
Text: wrap property is replaced by wrapMode enumeration.
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 34b0606..a7a8983 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -125,12 +125,14 @@ QDeclarativeFlickablePrivate::QDeclarativeFlickablePrivate()
: viewport(new QDeclarativeItem)
, hData(this, &QDeclarativeFlickablePrivate::setRoundedViewportX)
, vData(this, &QDeclarativeFlickablePrivate::setRoundedViewportY)
- , flicked(false), moving(false), stealMouse(false)
- , pressed(false)
+ , flickingHorizontally(false), flickingVertically(false)
+ , hMoved(false), vMoved(false)
+ , movingHorizontally(false), movingVertically(false)
+ , stealMouse(false), pressed(false)
, interactive(true), deceleration(500), maxVelocity(2000), reportedVelocitySmoothing(100)
, delayedPressEvent(0), delayedPressTarget(0), pressDelay(0), fixupDuration(600)
, vTime(0), visibleArea(0)
- , flickDirection(QDeclarativeFlickable::AutoFlickDirection)
+ , flickableDirection(QDeclarativeFlickable::AutoFlickDirection)
, boundsBehavior(QDeclarativeFlickable::DragAndOvershootBounds)
{
}
@@ -226,10 +228,15 @@ void QDeclarativeFlickablePrivate::flick(AxisData &data, qreal minExtent, qreal
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();
+ if (!flickingHorizontally && q->xflick()) {
+ flickingHorizontally = true;
+ emit q->flickingChanged(); // deprecated
+ emit q->flickingHorizontallyChanged();
+ }
+ if (!flickingVertically && q->yflick()) {
+ flickingVertically = true;
+ emit q->flickingChanged(); // deprecated
+ emit q->flickingVerticallyChanged();
}
} else {
timeline.reset(data.move);
@@ -274,7 +281,6 @@ void QDeclarativeFlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal
q->viewportMoved();
}
}
- //emit flickingChanged();
} else if (data.move.value() < maxExtent) {
timeline.reset(data.move);
if (fixupDuration) {
@@ -285,11 +291,7 @@ void QDeclarativeFlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal
data.move.setValue(maxExtent);
q->viewportMoved();
}
- //emit flickingChanged();
- } else {
- flicked = false;
}
-
vTime = timeline.time();
}
@@ -363,37 +365,6 @@ void QDeclarativeFlickablePrivate::updateBeginningEnd()
*/
/*!
- \qmlsignal Flickable::onMovementStarted()
-
- This handler is called when the view begins moving due to user
- interaction.
-*/
-
-/*!
- \qmlsignal Flickable::onMovementEnded()
-
- This handler is called when the view stops moving due to user
- interaction. If a flick was generated, this handler will
- be triggered once the flick stops. If a flick was not
- generated, the handler will be triggered when the
- user stops dragging - i.e. a mouse or touch release.
-*/
-
-/*!
- \qmlsignal Flickable::onFlickStarted()
-
- This handler is called when the view is flicked. A flick
- starts from the point that the mouse or touch is released,
- while still in motion.
-*/
-
-/*!
- \qmlsignal Flickable::onFlickEnded()
-
- This handler is called when the view stops moving due to a flick.
-*/
-
-/*!
\qmlproperty real Flickable::visibleArea.xPosition
\qmlproperty real Flickable::visibleArea.widthRatio
\qmlproperty real Flickable::visibleArea.yPosition
@@ -498,12 +469,14 @@ void QDeclarativeFlickable::setInteractive(bool interactive)
Q_D(QDeclarativeFlickable);
if (interactive != d->interactive) {
d->interactive = interactive;
- if (!interactive && d->flicked) {
+ if (!interactive && (d->flickingHorizontally || d->flickingVertically)) {
d->timeline.clear();
d->vTime = d->timeline.time();
- d->flicked = false;
- emit flickingChanged();
- emit flickEnded();
+ d->flickingHorizontally = false;
+ d->flickingVertically = false;
+ emit flickingChanged(); // deprecated
+ emit flickingHorizontallyChanged();
+ emit flickingVerticallyChanged();
}
emit interactiveChanged();
}
@@ -582,7 +555,7 @@ QDeclarativeFlickableVisibleArea *QDeclarativeFlickable::visibleArea()
}
/*!
- \qmlproperty enumeration Flickable::flickDirection
+ \qmlproperty enumeration Flickable::flickableDirection
This property determines which directions the view can be flicked.
@@ -596,21 +569,33 @@ QDeclarativeFlickableVisibleArea *QDeclarativeFlickable::visibleArea()
\o Flickable.HorizontalAndVerticalFlick - allows flicking in both directions.
\endlist
*/
-QDeclarativeFlickable::FlickDirection QDeclarativeFlickable::flickDirection() const
+QDeclarativeFlickable::FlickableDirection QDeclarativeFlickable::flickableDirection() const
{
Q_D(const QDeclarativeFlickable);
- return d->flickDirection;
+ return d->flickableDirection;
}
-void QDeclarativeFlickable::setFlickDirection(FlickDirection direction)
+void QDeclarativeFlickable::setFlickableDirection(FlickableDirection direction)
{
Q_D(QDeclarativeFlickable);
- if (direction != d->flickDirection) {
- d->flickDirection = direction;
- emit flickDirectionChanged();
+ if (direction != d->flickableDirection) {
+ d->flickableDirection = direction;
+ emit flickableDirectionChanged();
}
}
+QDeclarativeFlickable::FlickableDirection QDeclarativeFlickable::flickDirection() const
+{
+ qmlInfo(this) << "'flickDirection' is deprecated. Please use 'flickableDirection' instead.";
+ return flickableDirection();
+}
+
+void QDeclarativeFlickable::setFlickDirection(FlickableDirection direction)
+{
+ qmlInfo(this) << "'flickDirection' is deprecated. Please use 'flickableDirection' instead.";
+ setFlickableDirection(direction);
+}
+
void QDeclarativeFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (interactive && timeline.isActive() && (qAbs(hData.velocity) > 10 || qAbs(vData.velocity) > 10))
@@ -626,7 +611,8 @@ void QDeclarativeFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEven
pressPos = event->pos();
hData.pressPos = hData.move.value();
vData.pressPos = vData.move.value();
- flicked = false;
+ flickingHorizontally = false;
+ flickingVertically = false;
QDeclarativeItemPrivate::start(pressTime);
QDeclarativeItemPrivate::start(velocityTime);
}
@@ -638,7 +624,6 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
return;
bool rejectY = false;
bool rejectX = false;
- bool moved = false;
if (q->yflick()) {
int dy = int(event->pos().y() - pressPos.y());
@@ -660,7 +645,7 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
}
if (!rejectY && stealMouse) {
vData.move.setValue(qRound(newY));
- moved = true;
+ vMoved = true;
}
if (qAbs(dy) > QApplication::startDragDistance())
stealMouse = true;
@@ -687,7 +672,7 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
}
if (!rejectX && stealMouse) {
hData.move.setValue(qRound(newX));
- moved = true;
+ hMoved = true;
}
if (qAbs(dx) > QApplication::startDragDistance())
@@ -717,7 +702,7 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent
if (rejectY) vData.velocity = 0;
if (rejectX) hData.velocity = 0;
- if (moved) {
+ if (hMoved || vMoved) {
q->movementStarting();
q->viewportMoved();
}
@@ -812,9 +797,9 @@ void QDeclarativeFlickable::wheelEvent(QGraphicsSceneWheelEvent *event)
d->vData.velocity = qMax(event->delta() - d->vData.smoothVelocity.value(), qreal(250.0));
else
d->vData.velocity = qMin(event->delta() - d->vData.smoothVelocity.value(), qreal(-250.0));
- d->flicked = false;
+ d->flickingVertically = false;
d->flickY(d->vData.velocity);
- if (d->flicked)
+ if (d->flickingVertically)
movementStarting();
event->accept();
} else if (xflick()) {
@@ -822,9 +807,9 @@ void QDeclarativeFlickable::wheelEvent(QGraphicsSceneWheelEvent *event)
d->hData.velocity = qMax(event->delta() - d->hData.smoothVelocity.value(), qreal(250.0));
else
d->hData.velocity = qMin(event->delta() - d->hData.smoothVelocity.value(), qreal(-250.0));
- d->flicked = false;
+ d->flickingHorizontally = false;
d->flickX(d->hData.velocity);
- if (d->flicked)
+ if (d->flickingHorizontally)
movementStarting();
event->accept();
} else {
@@ -1091,7 +1076,7 @@ void QDeclarativeFlickable::setContentWidth(qreal w)
else
d->viewport->setWidth(w);
// Make sure that we're entirely in view.
- if (!d->pressed && !d->moving) {
+ if (!d->pressed && !d->movingHorizontally && !d->movingVertically) {
int oldDuration = d->fixupDuration;
d->fixupDuration = 0;
d->fixupX();
@@ -1118,7 +1103,7 @@ void QDeclarativeFlickable::setContentHeight(qreal h)
else
d->viewport->setHeight(h);
// Make sure that we're entirely in view.
- if (!d->pressed && !d->moving) {
+ if (!d->pressed && !d->movingHorizontally && !d->movingVertically) {
int oldDuration = d->fixupDuration;
d->fixupDuration = 0;
d->fixupY();
@@ -1149,17 +1134,17 @@ qreal QDeclarativeFlickable::vHeight() const
bool QDeclarativeFlickable::xflick() const
{
Q_D(const QDeclarativeFlickable);
- if (d->flickDirection == QDeclarativeFlickable::AutoFlickDirection)
+ if (d->flickableDirection == QDeclarativeFlickable::AutoFlickDirection)
return vWidth() != width();
- return d->flickDirection & QDeclarativeFlickable::HorizontalFlick;
+ return d->flickableDirection & QDeclarativeFlickable::HorizontalFlick;
}
bool QDeclarativeFlickable::yflick() const
{
Q_D(const QDeclarativeFlickable);
- if (d->flickDirection == QDeclarativeFlickable::AutoFlickDirection)
+ if (d->flickableDirection == QDeclarativeFlickable::AutoFlickDirection)
return vHeight() != height();
- return d->flickDirection & QDeclarativeFlickable::VerticalFlick;
+ return d->flickableDirection & QDeclarativeFlickable::VerticalFlick;
}
bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event)
@@ -1281,16 +1266,30 @@ void QDeclarativeFlickable::setFlickDeceleration(qreal deceleration)
emit flickDecelerationChanged();
}
+bool QDeclarativeFlickable::isFlicking() const
+{
+ Q_D(const QDeclarativeFlickable);
+ qmlInfo(this) << "'flicking' is deprecated. Please use 'flickingHorizontally' and 'flickingVertically' instead.";
+ return d->flickingHorizontally || d->flickingVertically;
+}
+
/*!
- \qmlproperty bool Flickable::flicking
+ \qmlproperty bool Flickable::flickingHorizontally
+ \qmlproperty bool Flickable::flickingVertically
- This property holds whether the view is currently moving due to
- the user flicking the view.
+ These properties hold whether the view is currently moving horizontally
+ or vertically due to the user flicking the view.
*/
-bool QDeclarativeFlickable::isFlicking() const
+bool QDeclarativeFlickable::isFlickingHorizontally() const
{
Q_D(const QDeclarativeFlickable);
- return d->flicked;
+ return d->flickingHorizontally;
+}
+
+bool QDeclarativeFlickable::isFlickingVertically() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->flickingVertically;
}
/*!
@@ -1319,40 +1318,72 @@ void QDeclarativeFlickable::setPressDelay(int delay)
emit pressDelayChanged();
}
+
+bool QDeclarativeFlickable::isMoving() const
+{
+ Q_D(const QDeclarativeFlickable);
+ qmlInfo(this) << "'moving' is deprecated. Please use 'movingHorizontally' or 'movingVertically' instead.";
+ return d->movingHorizontally || d->movingVertically;
+}
+
/*!
- \qmlproperty bool Flickable::moving
+ \qmlproperty bool Flickable::movingHorizontally
+ \qmlproperty bool Flickable::movingVertically
- This property holds whether the view is currently moving due to
- the user either dragging or flicking the view.
+ These properties hold whether the view is currently moving horizontally
+ or vertically due to the user either dragging or flicking the view.
*/
-bool QDeclarativeFlickable::isMoving() const
+bool QDeclarativeFlickable::isMovingHorizontally() const
+{
+ Q_D(const QDeclarativeFlickable);
+ return d->movingHorizontally;
+}
+
+bool QDeclarativeFlickable::isMovingVertically() const
{
Q_D(const QDeclarativeFlickable);
- return d->moving;
+ return d->movingVertically;
}
void QDeclarativeFlickable::movementStarting()
{
Q_D(QDeclarativeFlickable);
- if (!d->moving) {
- d->moving = true;
- emit movingChanged();
- emit movementStarted();
+ if (d->hMoved && !d->movingHorizontally) {
+ d->movingHorizontally = true;
+ emit movingChanged(); // deprecated
+ emit movingHorizontallyChanged();
+ }
+ if (d->vMoved && !d->movingVertically) {
+ d->movingVertically = true;
+ emit movingChanged(); // deprecated
+ emit movingVerticallyChanged();
}
}
void QDeclarativeFlickable::movementEnding()
{
Q_D(QDeclarativeFlickable);
- if (d->moving) {
- d->moving = false;
- emit movingChanged();
- emit movementEnded();
+ if (d->flickingHorizontally) {
+ d->flickingHorizontally = false;
+ emit flickingChanged(); // deprecated
+ emit flickingHorizontallyChanged();
+ }
+ if (d->flickingVertically) {
+ d->flickingVertically = false;
+ emit flickingChanged(); // deprecated
+ emit flickingVerticallyChanged();
+ }
+ if (d->movingHorizontally) {
+ d->movingHorizontally = false;
+ d->hMoved = false;
+ emit movingChanged(); // deprecated
+ emit movingHorizontallyChanged();
}
- if (d->flicked) {
- d->flicked = false;
- emit flickingChanged();
- emit flickEnded();
+ if (d->movingVertically) {
+ d->movingVertically = false;
+ d->vMoved = false;
+ emit movingChanged(); // deprecated
+ emit movingVerticallyChanged();
}
d->hData.smoothVelocity.setValue(0);
d->vData.smoothVelocity.setValue(0);
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p.h
index f031a24..7944e2b 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p.h
@@ -68,9 +68,14 @@ class Q_DECLARATIVE_EXPORT QDeclarativeFlickable : public QDeclarativeItem
Q_PROPERTY(BoundsBehavior boundsBehavior READ boundsBehavior WRITE setBoundsBehavior NOTIFY boundsBehaviorChanged)
Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged)
Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
- Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
- Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
- Q_PROPERTY(FlickDirection flickDirection READ flickDirection WRITE setFlickDirection NOTIFY flickDirectionChanged)
+ Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged) // deprecated
+ Q_PROPERTY(bool movingHorizontally READ isMovingHorizontally NOTIFY movingHorizontallyChanged)
+ Q_PROPERTY(bool movingVertically READ isMovingVertically NOTIFY movingVerticallyChanged)
+ Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged) // deprecated
+ Q_PROPERTY(bool flickingHorizontally READ isFlickingHorizontally NOTIFY flickingHorizontallyChanged)
+ Q_PROPERTY(bool flickingVertically READ isFlickingVertically NOTIFY flickingVerticallyChanged)
+ Q_PROPERTY(FlickableDirection flickDirection READ flickDirection WRITE setFlickDirection NOTIFY flickableDirectionChanged) // deprecated
+ Q_PROPERTY(FlickableDirection flickableDirection READ flickableDirection WRITE setFlickableDirection NOTIFY flickableDirectionChanged)
Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay NOTIFY pressDelayChanged)
@@ -86,7 +91,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeFlickable : public QDeclarativeItem
Q_PROPERTY(QDeclarativeListProperty<QGraphicsObject> flickableChildren READ flickableChildren)
Q_CLASSINFO("DefaultProperty", "flickableData")
- Q_ENUMS(FlickDirection)
+ Q_ENUMS(FlickableDirection)
Q_ENUMS(BoundsBehavior)
public:
@@ -115,8 +120,12 @@ public:
qreal contentY() const;
void setContentY(qreal pos);
- bool isMoving() const;
- bool isFlicking() const;
+ bool isMoving() const; // deprecated
+ bool isMovingHorizontally() const;
+ bool isMovingVertically() const;
+ bool isFlicking() const; // deprecated
+ bool isFlickingHorizontally() const;
+ bool isFlickingVertically() const;
int pressDelay() const;
void setPressDelay(int delay);
@@ -140,26 +149,28 @@ public:
QDeclarativeItem *viewport();
- enum FlickDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 };
- FlickDirection flickDirection() const;
- void setFlickDirection(FlickDirection);
+ enum FlickableDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 };
+ FlickableDirection flickDirection() const; // deprecated
+ void setFlickDirection(FlickableDirection); // deprecated
+ FlickableDirection flickableDirection() const;
+ void setFlickableDirection(FlickableDirection);
Q_SIGNALS:
void contentWidthChanged();
void contentHeightChanged();
void contentXChanged();
void contentYChanged();
- void movingChanged();
- void flickingChanged();
- void movementStarted();
- void movementEnded();
- void flickStarted();
- void flickEnded();
+ void movingChanged(); // deprecated
+ void movingHorizontallyChanged();
+ void movingVerticallyChanged();
+ void flickingChanged(); // deprecated
+ void flickingHorizontallyChanged();
+ void flickingVerticallyChanged();
void horizontalVelocityChanged();
void verticalVelocityChanged();
void isAtBoundaryChanged();
void pageChanged();
- void flickDirectionChanged();
+ void flickableDirectionChanged();
void interactiveChanged();
void overShootChanged();
void boundsBehaviorChanged();
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
index 01cfb18..b467ed2 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
@@ -131,8 +131,12 @@ public:
AxisData vData;
QDeclarativeTimeLine timeline;
- bool flicked : 1;
- bool moving : 1;
+ bool flickingHorizontally : 1;
+ bool flickingVertically : 1;
+ bool hMoved : 1;
+ bool vMoved : 1;
+ bool movingHorizontally : 1;
+ bool movingVertically : 1;
bool stealMouse : 1;
bool pressed : 1;
bool interactive : 1;
@@ -158,7 +162,7 @@ public:
int vTime;
QDeclarativeTimeLine velocityTimeline;
QDeclarativeFlickableVisibleArea *visibleArea;
- QDeclarativeFlickable::FlickDirection flickDirection;
+ QDeclarativeFlickable::FlickableDirection flickableDirection;
QDeclarativeFlickable::BoundsBehavior boundsBehavior;
void handleMousePressEvent(QGraphicsSceneMouseEvent *);
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 7b413fb..396acd0 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -347,9 +347,10 @@ public:
void QDeclarativeGridViewPrivate::init()
{
Q_Q(QDeclarativeGridView);
- QObject::connect(q, SIGNAL(movementEnded()), q, SLOT(animStopped()));
+ QObject::connect(q, SIGNAL(movingHorizontallyChanged()), q, SLOT(animStopped()));
+ QObject::connect(q, SIGNAL(movingVerticallyChanged()), q, SLOT(animStopped()));
q->setFlag(QGraphicsItem::ItemIsFocusScope);
- q->setFlickDirection(QDeclarativeFlickable::VerticalFlick);
+ q->setFlickableDirection(QDeclarativeFlickable::VerticalFlick);
addItemChangeListener(this, Geometry);
}
@@ -692,7 +693,7 @@ void QDeclarativeGridViewPrivate::updateHighlight()
{
if ((!currentItem && highlight) || (currentItem && !highlight))
createHighlight();
- if (currentItem && autoHighlight && highlight && !moving) {
+ if (currentItem && autoHighlight && highlight && !movingHorizontally && !movingVertically) {
// auto-update highlight
highlightXAnimator->to = currentItem->item->x();
highlightYAnimator->to = currentItem->item->y();
@@ -806,7 +807,8 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
Q_Q(QDeclarativeGridView);
moveReason = Mouse;
- if ((!haveHighlightRange || highlightRange != QDeclarativeGridView::StrictlyEnforceRange) && snapMode == QDeclarativeGridView::NoSnap) {
+ if ((!haveHighlightRange || highlightRange != QDeclarativeGridView::StrictlyEnforceRange)
+ && snapMode == QDeclarativeGridView::NoSnap) {
QDeclarativeFlickablePrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity);
return;
}
@@ -874,9 +876,16 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
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();
+ if (!flickingHorizontally && q->xflick()) {
+ flickingHorizontally = true;
+ emit q->flickingChanged(); // deprecated
+ emit q->flickingHorizontallyChanged();
+ }
+ if (!flickingVertically && q->yflick()) {
+ flickingVertically = true;
+ emit q->flickingChanged(); // deprecated
+ emit q->flickingVerticallyChanged();
+ }
} else {
timeline.reset(data.move);
fixup(data, minExtent, maxExtent);
@@ -1027,7 +1036,7 @@ void QDeclarativeGridView::setModel(const QVariant &model)
d->model = vim;
} else {
if (!d->ownModel) {
- d->model = new QDeclarativeVisualDataModel(qmlContext(this));
+ d->model = new QDeclarativeVisualDataModel(qmlContext(this), this);
d->ownModel = true;
}
if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model))
@@ -1371,10 +1380,10 @@ void QDeclarativeGridView::setFlow(Flow flow)
d->flow = flow;
if (d->flow == LeftToRight) {
setContentWidth(-1);
- setFlickDirection(QDeclarativeFlickable::VerticalFlick);
+ setFlickableDirection(QDeclarativeFlickable::VerticalFlick);
} else {
setContentHeight(-1);
- setFlickDirection(QDeclarativeFlickable::HorizontalFlick);
+ setFlickableDirection(QDeclarativeFlickable::HorizontalFlick);
}
d->clear();
d->updateGrid();
@@ -1530,7 +1539,7 @@ void QDeclarativeGridView::viewportMoved()
Q_D(QDeclarativeGridView);
QDeclarativeFlickable::viewportMoved();
d->lazyRelease = true;
- if (d->flicked) {
+ if (d->flickingHorizontally || d->flickingVertically) {
if (yflick()) {
if (d->vData.velocity > 0)
d->bufferMode = QDeclarativeGridViewPrivate::BufferBefore;
@@ -1546,7 +1555,7 @@ void QDeclarativeGridView::viewportMoved()
}
}
refill();
- if (isFlicking() || d->moving)
+ if (d->flickingHorizontally || d->flickingVertically || d->movingHorizontally || d->movingVertically)
d->moveReason = QDeclarativeGridViewPrivate::Mouse;
if (d->moveReason != QDeclarativeGridViewPrivate::SetIndex) {
if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) {
@@ -1885,7 +1894,8 @@ void QDeclarativeGridView::trackedPositionChanged()
Q_D(QDeclarativeGridView);
if (!d->trackedItem || !d->currentItem)
return;
- if (!isFlicking() && !d->moving && d->moveReason == QDeclarativeGridViewPrivate::SetIndex) {
+ if (!d->flickingHorizontally && !d->flickingVertically && !d->movingHorizontally && !d->movingVertically
+ && d->moveReason == QDeclarativeGridViewPrivate::SetIndex) {
const qreal trackedPos = d->trackedItem->rowPos();
const qreal viewPos = d->position();
if (d->haveHighlightRange) {
@@ -2301,9 +2311,13 @@ void QDeclarativeGridView::destroyingItem(QDeclarativeItem *item)
void QDeclarativeGridView::animStopped()
{
Q_D(QDeclarativeGridView);
- d->bufferMode = QDeclarativeGridViewPrivate::NoBuffer;
- if (d->haveHighlightRange && d->highlightRange == QDeclarativeGridView::StrictlyEnforceRange)
- d->updateHighlight();
+ if ((!d->movingVertically && d->flow == QDeclarativeGridView::LeftToRight)
+ || (!d->movingHorizontally && d->flow == QDeclarativeGridView::TopToBottom))
+ {
+ d->bufferMode = QDeclarativeGridViewPrivate::NoBuffer;
+ if (d->haveHighlightRange && d->highlightRange == QDeclarativeGridView::StrictlyEnforceRange)
+ d->updateHighlight();
+ }
}
void QDeclarativeGridView::refill()
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
index aeddb15..88e8520 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -54,79 +54,36 @@ QT_BEGIN_NAMESPACE
\brief The Image element allows you to add bitmaps to a scene.
\inherits Item
- Displays the image from the specified \l source. If a size is not specified explicitly,
- the Image element will be sized to the loaded image.
+ An Image element displays a specified \l source image:
- If the source resolves to a network resource, the image will be loaded asynchronously,
- updating the \l progress and \l status properties appropriately.
+ \table
+ \o
+ \image declarative-qtlogo.png
+ \o
+ \qml
+ import Qt 4.7
+
+ Image { source: "qtlogo.png" }
+ \endqml
+ \endtable
+
+ If a size is not specified explicitly, the Image element is sized to the loaded image.
+ Image elements can be stretched and tiled using the \l fillMode property.
- Images which are available locally
- will be loaded immediately, blocking the user interface. This is typically the
- correct behavior for user interface elements. For large local images, which do not need
- to be visible immediately, it may be preferable to enable \l asynchronous loading.
- This will load the image in the background using a low priority thread.
+ If the image \l source is a network resource, the image is loaded asynchronous and the
+ \l progress and \l status properties are updated appropriately. Otherwise, if the image is
+ available locally, it is loaded immediately and the user interface is blocked until loading is
+ complete. (This is typically the correct behavior for user interface elements.)
+ For large local images, which do not need to be visible immediately, it may be preferable to
+ enable \l asynchronous loading. This loads the image in the background using a low priority thread.
Images are cached and shared internally, so if several Image elements have the same source
only one copy of the image will be loaded.
- \bold Note: Images are often the greatest user of memory in QML UIs. It is recommended
+ \bold Note: Images are often the greatest user of memory in QML user interfaces. It is recommended
that images which do not form part of the user interface have their
size bounded via the \l sourceSize property. This is especially important for content
that is loaded from external sources or provided by the user.
-
- The Image element supports untransformed, stretched and tiled images.
-
- For an explanation of stretching and tiling, see the fillMode property description.
-
- Examples:
- \table
- \row
- \o \image declarative-qtlogo1.png
- \o Untransformed
- \qml
- Image { source: "pics/qtlogo.png" }
- \endqml
- \row
- \o \image declarative-qtlogo2.png
- \o fillMode: Stretch (default)
- \qml
- Image {
- width: 160
- height: 160
- source: "pics/qtlogo.png"
- }
- \endqml
- \row
- \o \image declarative-qtlogo3.png
- \o fillMode: Tile
- \qml
- Image {
- fillMode: Image.Tile
- width: 160; height: 160
- source: "pics/qtlogo.png"
- }
- \endqml
- \row
- \o \image declarative-qtlogo6.png
- \o fillMode: TileVertically
- \qml
- Image {
- fillMode: Image.TileVertically
- width: 160; height: 160
- source: "pics/qtlogo.png"
- }
- \endqml
- \row
- \o \image declarative-qtlogo5.png
- \o fillMode: TileHorizontally
- \qml
- Image {
- fillMode: Image.TileHorizontally
- width: 160; height: 160
- source: "pics/qtlogo.png"
- }
- \endqml
- \endtable
*/
/*!
@@ -207,7 +164,77 @@ void QDeclarativeImagePrivate::setPixmap(const QPixmap &pixmap)
\o Image.TileHorizontally - the image is stretched vertically and tiled horizontally
\endlist
- \image declarative-image_fillMode.gif
+ \table
+
+ \row
+ \o \image declarative-qtlogo-stretch.png
+ \o Stretch (default)
+ \qml
+ Image {
+ width: 130; height: 100
+ smooth: true
+ source: "qtlogo.png"
+ }
+ \endqml
+
+ \row
+ \o \image declarative-qtlogo-preserveaspectfit.png
+ \o PreserveAspectFit
+ \qml
+ Image {
+ width: 130; height: 100
+ fillMode: Image.PreserveAspectFit
+ smooth: true
+ source: "qtlogo.png"
+ }
+ \endqml
+
+ \row
+ \o \image declarative-qtlogo-preserveaspectcrop.png
+ \o PreserveAspectCrop
+ \qml
+ Image {
+ width: 130; height: 100
+ fillMode: Image.PreserveAspectCrop
+ smooth: true
+ source: "qtlogo.png"
+ }
+ \endqml
+
+ \row
+ \o \image declarative-qtlogo-tile.png
+ \o Tile
+ \qml
+ Image {
+ width: 120; height: 120
+ fillMode: Image.Tile
+ source: "qtlogo.png"
+ }
+ \endqml
+
+ \row
+ \o \image declarative-qtlogo-tilevertically.png
+ \o TileVertically
+ \qml
+ Image {
+ width: 120; height: 120
+ fillMode: Image.TileVertically
+ source: "qtlogo.png"
+ }
+ \endqml
+
+ \row
+ \o \image declarative-qtlogo-tilehorizontally.png
+ \o TileHorizontally
+ \qml
+ Image {
+ width: 120; height: 120
+ fillMode: Image.TileHorizontally
+ source: "qtlogo.png"
+ }
+ \endqml
+
+ \endtable
*/
QDeclarativeImage::FillMode QDeclarativeImage::fillMode() const
{
@@ -290,32 +317,30 @@ qreal QDeclarativeImage::paintedHeight() const
/*!
\qmlproperty QSize Image::sourceSize
- This properties is the size of the loaded image, in pixels.
+ This property holds the size of the loaded image, in pixels.
- If you set this property explicitly, you can to control the storage
- used by a loaded image. The image will be scaled down if its intrinsic size
- is greater than this value.
-
- If only one dimension of the size is set (and the other left at 0), the
- unset dimension will be set in proportion to the set dimension to preserve
- the source image aspect ratio. The fillMode is independent of this.
-
- Unlike setting the width and height properties, which merely scale the painting
- of the image, this property affects the number of pixels stored.
-
- \e{Changing this property dynamically will lead to the image source being reloaded,
- potentially even from the network if it is not in the disk cache.}
+ This is used to control the storage used by a loaded image. Unlike
+ the width and height properties, which scale the painting of the image, this property
+ affects the number of pixels stored.
+ If the image's actual size is larger than the sourceSize, the image is scaled down.
+ If only one dimension of the size is set to greater than 0, the
+ other dimension is set in proportion to preserve the source image's aspect ratio.
+ (The \l fillMode is independent of this.)
+
If the source is an instrinsically scalable image (eg. SVG), this property
- determines the size of the loaded image regardless of intrinsic size. You should
- avoid changing this property dynamically - rendering an SVG is \e slow compared
+ determines the size of the loaded image regardless of intrinsic size.
+ Avoid changing this property dynamically; rendering an SVG is \e slow compared
to an image.
If the source is a non-scalable image (eg. JPEG), the loaded image will
be no greater than this property specifies. For some formats (currently only JPEG),
the whole image will never actually be loaded into memory.
+
+ \note \e{Changing this property dynamically will lead to the image source being reloaded,
+ potentially even from the network if it is not in the disk cache.}
- The example below will ensure that the size of the image in memory is
+ Here is an example that ensures the size of the image in memory is
no larger than 1024x1024 pixels, regardless of the size of the Image element.
\code
@@ -327,8 +352,8 @@ qreal QDeclarativeImage::paintedHeight() const
}
\endcode
- The example below will ensure that the memory used by the image is
- no more than necessary to display the image at the size of the Image element.
+ The example below ensures the memory used by the image is no more than necessary
+ to display the image at the size of the Image element.
Of course if the Image element is resized a costly reload will be required, so
use this technique \e only when the Image size is fixed.
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 416e0a8..20106cb 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -48,6 +48,7 @@
#include <qdeclarativeexpression.h>
#include <qdeclarativeengine.h>
#include <qdeclarativeguard_p.h>
+#include <qdeclarativeinfo.h>
#include <qlistmodelinterface_p.h>
#include <qmath.h>
@@ -524,8 +525,9 @@ void QDeclarativeListViewPrivate::init()
Q_Q(QDeclarativeListView);
q->setFlag(QGraphicsItem::ItemIsFocusScope);
addItemChangeListener(this, Geometry);
- QObject::connect(q, SIGNAL(movementEnded()), q, SLOT(animStopped()));
- q->setFlickDirection(QDeclarativeFlickable::VerticalFlick);
+ QObject::connect(q, SIGNAL(movingHorizontallyChanged()), q, SLOT(animStopped()));
+ QObject::connect(q, SIGNAL(movingVerticallyChanged()), q, SLOT(animStopped()));
+ q->setFlickableDirection(QDeclarativeFlickable::VerticalFlick);
::memset(sectionCache, 0, sizeof(QDeclarativeItem*) * sectionCacheSize);
}
@@ -868,7 +870,7 @@ void QDeclarativeListViewPrivate::updateHighlight()
{
if ((!currentItem && highlight) || (currentItem && !highlight))
createHighlight();
- if (currentItem && autoHighlight && highlight && !moving) {
+ if (currentItem && autoHighlight && highlight && !movingHorizontally && !movingVertically) {
// auto-update highlight
highlightPosAnimator->to = currentItem->position();
highlightSizeAnimator->to = currentItem->size();
@@ -1208,7 +1210,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
else
v = maxVelocity;
}
- if (!flicked) {
+ if (!flickingHorizontally && !flickingVertically) {
// the initial flick - estimate boundary
qreal accel = deceleration;
qreal v2 = v * v;
@@ -1256,9 +1258,16 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
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();
+ if (!flickingHorizontally && q->xflick()) {
+ flickingHorizontally = true;
+ emit q->flickingChanged(); // deprecated
+ emit q->flickingHorizontallyChanged();
+ }
+ if (!flickingVertically && q->yflick()) {
+ flickingVertically = true;
+ emit q->flickingChanged(); // deprecated
+ emit q->flickingVerticallyChanged();
+ }
correctFlick = true;
} else {
// reevaluate the target boundary.
@@ -1461,7 +1470,7 @@ void QDeclarativeListView::setModel(const QVariant &model)
d->model = vim;
} else {
if (!d->ownModel) {
- d->model = new QDeclarativeVisualDataModel(qmlContext(this));
+ d->model = new QDeclarativeVisualDataModel(qmlContext(this), this);
d->ownModel = true;
}
if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model))
@@ -1804,10 +1813,10 @@ void QDeclarativeListView::setOrientation(QDeclarativeListView::Orientation orie
d->orient = orientation;
if (d->orient == QDeclarativeListView::Vertical) {
setContentWidth(-1);
- setFlickDirection(VerticalFlick);
+ setFlickableDirection(VerticalFlick);
} else {
setContentHeight(-1);
- setFlickDirection(HorizontalFlick);
+ setFlickableDirection(HorizontalFlick);
}
d->clear();
d->setPosition(0);
@@ -2106,7 +2115,7 @@ void QDeclarativeListView::viewportMoved()
QDeclarativeFlickable::viewportMoved();
d->lazyRelease = true;
refill();
- if (isFlicking() || d->moving)
+ if (d->flickingHorizontally || d->flickingVertically || d->movingHorizontally || d->movingVertically)
d->moveReason = QDeclarativeListViewPrivate::Mouse;
if (d->moveReason != QDeclarativeListViewPrivate::SetIndex) {
if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) {
@@ -2126,7 +2135,7 @@ void QDeclarativeListView::viewportMoved()
}
}
- if (d->flicked && d->correctFlick && !d->inFlickCorrection) {
+ if ((d->flickingHorizontally || d->flickingVertically) && d->correctFlick && !d->inFlickCorrection) {
d->inFlickCorrection = true;
// 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.
@@ -2446,7 +2455,8 @@ void QDeclarativeListView::trackedPositionChanged()
Q_D(QDeclarativeListView);
if (!d->trackedItem || !d->currentItem)
return;
- if (!isFlicking() && !d->moving && d->moveReason == QDeclarativeListViewPrivate::SetIndex) {
+ if (!d->flickingHorizontally && !d->flickingVertically && !d->movingHorizontally && !d->movingVertically
+ && d->moveReason == QDeclarativeListViewPrivate::SetIndex) {
const qreal trackedPos = qCeil(d->trackedItem->position());
const qreal viewPos = d->position();
if (d->haveHighlightRange) {
@@ -2880,9 +2890,12 @@ void QDeclarativeListView::destroyingItem(QDeclarativeItem *item)
void QDeclarativeListView::animStopped()
{
Q_D(QDeclarativeListView);
- d->bufferMode = QDeclarativeListViewPrivate::NoBuffer;
- if (d->haveHighlightRange && d->highlightRange == QDeclarativeListView::StrictlyEnforceRange)
- d->updateHighlight();
+ if ((!d->movingVertically && d->orient == QDeclarativeListView::Vertical) || (!d->movingHorizontally && d->orient == QDeclarativeListView::Horizontal))
+ {
+ d->bufferMode = QDeclarativeListViewPrivate::NoBuffer;
+ if (d->haveHighlightRange && d->highlightRange == QDeclarativeListView::StrictlyEnforceRange)
+ d->updateHighlight();
+ }
}
QDeclarativeListViewAttached *QDeclarativeListView::qmlAttachedProperties(QObject *obj)
diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/graphicsitems/qdeclarativepath.cpp
index 4d8b619..3d0df87 100644
--- a/src/declarative/graphicsitems/qdeclarativepath.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepath.cpp
@@ -322,6 +322,17 @@ QPainterPath QDeclarativePath::path() const
QStringList QDeclarativePath::attributes() const
{
Q_D(const QDeclarativePath);
+ if (!d->componentComplete) {
+ QSet<QString> attrs;
+
+ // First gather up all the attributes
+ foreach (QDeclarativePathElement *pathElement, d->_pathElements) {
+ if (QDeclarativePathAttribute *attribute =
+ qobject_cast<QDeclarativePathAttribute *>(pathElement))
+ attrs.insert(attribute->name());
+ }
+ return attrs.toList();
+ }
return d->_attributes;
}
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index 040fc98..503d096 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -98,9 +98,8 @@ QDeclarativeItem *QDeclarativePathViewPrivate::getItem(int modelIndex)
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()) {
+ foreach(const QString &attr, path->attributes())
attType->createProperty(attr.toUtf8());
- }
}
qPathViewAttachedType = attType;
QDeclarativePathViewAttached *att = static_cast<QDeclarativePathViewAttached *>(qmlAttachedPropertiesObject<QDeclarativePathView>(item));
@@ -418,7 +417,7 @@ void QDeclarativePathView::setModel(const QVariant &model)
d->model = vim;
} else {
if (!d->ownModel) {
- d->model = new QDeclarativeVisualDataModel(qmlContext(this));
+ d->model = new QDeclarativeVisualDataModel(qmlContext(this), this);
d->ownModel = true;
}
if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model))
@@ -471,12 +470,14 @@ void QDeclarativePathView::setPath(QDeclarativePath *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;
+ if (d->isValid() && isComponentComplete()) {
+ d->clear();
+ if (d->attType) {
+ d->attType->release();
+ d->attType = 0;
+ }
+ d->regenerate();
}
- d->regenerate();
emit pathChanged();
}
@@ -1119,7 +1120,8 @@ void QDeclarativePathView::refill()
while ((pos > startPos || !d->items.count()) && d->items.count() < count) {
// qDebug() << "append" << idx;
QDeclarativeItem *item = d->getItem(idx);
- item->setZValue(idx+1);
+ if (d->model->completePending())
+ item->setZValue(idx+1);
if (d->currentIndex == idx) {
item->setFocus(true);
if (QDeclarativePathViewAttached *att = d->attached(item))
@@ -1132,7 +1134,8 @@ void QDeclarativePathView::refill()
d->firstIndex = idx;
d->items.append(item);
d->updateItem(item, pos);
- d->model->completeItem();
+ if (d->model->completePending())
+ d->model->completeItem();
++idx;
if (idx >= d->model->count())
idx = 0;
@@ -1146,7 +1149,8 @@ void QDeclarativePathView::refill()
while (pos >= 0.0 && pos < startPos) {
// qDebug() << "prepend" << idx;
QDeclarativeItem *item = d->getItem(idx);
- item->setZValue(idx+1);
+ if (d->model->completePending())
+ item->setZValue(idx+1);
if (d->currentIndex == idx) {
item->setFocus(true);
if (QDeclarativePathViewAttached *att = d->attached(item))
@@ -1157,7 +1161,8 @@ void QDeclarativePathView::refill()
}
d->items.prepend(item);
d->updateItem(item, pos);
- d->model->completeItem();
+ if (d->model->completePending())
+ d->model->completeItem();
d->firstIndex = idx;
idx = d->firstIndex - 1;
if (idx < 0)
@@ -1269,6 +1274,19 @@ void QDeclarativePathView::createdItem(int index, QDeclarativeItem *item)
{
Q_D(QDeclarativePathView);
if (d->requestedIndex != index) {
+ if (!d->attType) {
+ // pre-create one metatype to share with all attached objects
+ d->attType = new QDeclarativeOpenMetaObjectType(&QDeclarativePathViewAttached::staticMetaObject, qmlEngine(this));
+ foreach(const QString &attr, d->path->attributes())
+ d->attType->createProperty(attr.toUtf8());
+ }
+ qPathViewAttachedType = d->attType;
+ QDeclarativePathViewAttached *att = static_cast<QDeclarativePathViewAttached *>(qmlAttachedPropertiesObject<QDeclarativePathView>(item));
+ qPathViewAttachedType = 0;
+ if (att) {
+ att->m_view = this;
+ att->setOnPath(false);
+ }
item->setParentItem(this);
d->updateItem(item, index < d->firstIndex ? 0.0 : 1.0);
}
diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p.h
index 7240578..85f47fd 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepathview_p.h
@@ -215,6 +215,7 @@ Q_SIGNALS:
private:
friend class QDeclarativePathViewPrivate;
+ friend class QDeclarativePathView;
QDeclarativePathView *m_view;
QDeclarativeOpenMetaObject *m_metaobject;
bool m_onPath : 1;
diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
index ca0b8c6..04076f8 100644
--- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
@@ -193,7 +193,7 @@ void QDeclarativeRepeater::setModel(const QVariant &model)
d->model = vim;
} else {
if (!d->ownModel) {
- d->model = new QDeclarativeVisualDataModel(qmlContext(this));
+ d->model = new QDeclarativeVisualDataModel(qmlContext(this), this);
d->ownModel = true;
}
if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model))
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index 6d86e58..db20da8 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -899,6 +899,7 @@ Handles the given mouse \a event.
void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextEdit);
+ bool hadFocus = hasFocus();
if (d->focusOnPress){
QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope?
while(p) {
@@ -910,6 +911,8 @@ void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
setFocus(true);
}
+ if (!hadFocus && hasFocus())
+ d->clickCausedFocus = true;
d->control->processEvent(event, QPointF(0, 0));
if (!event->isAccepted())
QDeclarativePaintedItem::mousePressEvent(event);
@@ -924,11 +927,12 @@ void QDeclarativeTextEdit::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Q_D(QDeclarativeTextEdit);
QWidget *widget = event->widget();
if (widget && (d->control->textInteractionFlags() & Qt::TextEditable) && boundingRect().contains(event->pos()))
- qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->focusOnPress);
+ qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->clickCausedFocus);
+ d->clickCausedFocus = false;
d->control->processEvent(event, QPointF(0, 0));
if (!event->isAccepted())
- QDeclarativePaintedItem::mousePressEvent(event);
+ QDeclarativePaintedItem::mouseReleaseEvent(event);
}
/*!
@@ -952,7 +956,8 @@ void QDeclarativeTextEdit::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Q_D(QDeclarativeTextEdit);
d->control->processEvent(event, QPointF(0, 0));
if (!event->isAccepted())
- QDeclarativePaintedItem::mousePressEvent(event);
+ QDeclarativePaintedItem::mouseMoveEvent(event);
+ event->setAccepted(true);
}
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
index 8d4b611..5e19c3d 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h
@@ -70,7 +70,7 @@ public:
QDeclarativeTextEditPrivate()
: color("black"), hAlign(QDeclarativeTextEdit::AlignLeft), vAlign(QDeclarativeTextEdit::AlignTop),
imgDirty(true), dirty(false), richText(false), cursorVisible(false), focusOnPress(true),
- persistentSelection(true), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0),
+ persistentSelection(true), clickCausedFocus(false), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0),
cursorComponent(0), cursor(0), format(QDeclarativeTextEdit::AutoText), document(0),
wrapMode(QDeclarativeTextEdit::NoWrap)
{
@@ -100,6 +100,7 @@ public:
bool cursorVisible : 1;
bool focusOnPress : 1;
bool persistentSelection : 1;
+ bool clickCausedFocus : 1;
qreal textMargin;
int lastSelectionStart;
int lastSelectionEnd;
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index 604f508..afbaaac 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -882,6 +882,7 @@ void QDeclarativeTextInput::keyPressEvent(QKeyEvent* ev)
void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextInput);
+ bool hadFocus = hasFocus();
if(d->focusOnPress){
QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope?
while(p) {
@@ -893,15 +894,20 @@ void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
setFocus(true);
}
+ if (!hadFocus && hasFocus())
+ d->clickCausedFocus = true;
+
bool mark = event->modifiers() & Qt::ShiftModifier;
int cursor = d->xToPos(event->pos().x());
d->control->moveCursor(cursor, mark);
+ event->setAccepted(true);
}
void QDeclarativeTextInput::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextInput);
d->control->moveCursor(d->xToPos(event->pos().x()), true);
+ event->setAccepted(true);
}
/*!
@@ -913,8 +919,10 @@ void QDeclarativeTextInput::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Q_D(QDeclarativeTextInput);
QWidget *widget = event->widget();
if (widget && !d->control->isReadOnly() && boundingRect().contains(event->pos()))
- qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->focusOnPress);
- d->control->processEvent(event);
+ qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->clickCausedFocus);
+ d->clickCausedFocus = false;
+ if (!event->isAccepted())
+ QDeclarativePaintedItem::mouseReleaseEvent(event);
}
bool QDeclarativeTextInput::event(QEvent* ev)
@@ -935,8 +943,8 @@ bool QDeclarativeTextInput::event(QEvent* ev)
updateSize();
}
if(!handled)
- return QDeclarativePaintedItem::event(ev);
- return true;
+ handled = QDeclarativePaintedItem::event(ev);
+ return handled;
}
void QDeclarativeTextInput::geometryChanged(const QRectF &newGeometry,
@@ -1018,6 +1026,8 @@ QVariant QDeclarativeTextInput::inputMethodQuery(Qt::InputMethodQuery property)
{
Q_D(const QDeclarativeTextInput);
switch(property) {
+ case Qt::ImMicroFocus:
+ return d->control->cursorRect();
case Qt::ImFont:
return font();
case Qt::ImCursorPosition:
@@ -1233,9 +1243,7 @@ void QDeclarativeTextInput::updateSize(bool needsRedraw)
int cursorWidth = d->control->cursorWidth();
if(d->cursorItem)
cursorWidth = d->cursorItem->width();
- //### Is QFontMetrics too slow?
- QFontMetricsF fm(d->font);
- setImplicitWidth(fm.width(d->control->displayText())+cursorWidth);
+ setImplicitWidth(d->control->naturalTextWidth() + cursorWidth);
setContentsSize(QSize(width(), height()));//Repaints if changed
if(w==width() && h==height() && needsRedraw){
clearCache();
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
index 26cf78c..99866b8 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h
@@ -72,7 +72,7 @@ public:
color((QRgb)0), style(QDeclarativeText::Normal),
styleColor((QRgb)0), hAlign(QDeclarativeTextInput::AlignLeft),
hscroll(0), oldScroll(0), focused(false), focusOnPress(true),
- cursorVisible(false), autoScroll(true)
+ cursorVisible(false), autoScroll(true), clickCausedFocus(false)
{
}
@@ -116,6 +116,7 @@ public:
bool focusOnPress;
bool cursorVisible;
bool autoScroll;
+ bool clickCausedFocus;
};
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 1038c83..0e4217e 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -138,8 +138,8 @@ public:
}
\endcode
*/
-QDeclarativeVisualItemModel::QDeclarativeVisualItemModel()
- : QDeclarativeVisualModel(*(new QDeclarativeVisualItemModelPrivate))
+QDeclarativeVisualItemModel::QDeclarativeVisualItemModel(QObject *parent)
+ : QDeclarativeVisualModel(*(new QDeclarativeVisualItemModelPrivate), parent)
{
}
@@ -269,7 +269,8 @@ public:
}
if (m_roles.count() == 1)
m_roleNames.insert("modelData", m_roles.at(0));
- m_roleNames.insert("hasModelChildren", 0);
+ if (m_roles.count())
+ m_roleNames.insert("hasModelChildren", 0);
} else if (m_listAccessor) {
m_roleNames.insert("modelData", 0);
if (m_listAccessor->type() == QDeclarativeListAccessor::Instance) {
@@ -285,15 +286,19 @@ public:
}
}
+ QHash<int,int> roleToPropId;
void createMetaData() {
if (!m_metaDataCreated) {
ensureRoles();
- QHash<QByteArray, int>::const_iterator it = m_roleNames.begin();
- while (it != m_roleNames.end()) {
- m_delegateDataType->createProperty(it.key());
- ++it;
+ if (m_roleNames.count()) {
+ QHash<QByteArray, int>::const_iterator it = m_roleNames.begin();
+ while (it != m_roleNames.end()) {
+ int propId = m_delegateDataType->createProperty(it.key()) - m_delegateDataType->propertyOffset();
+ roleToPropId.insert(*it, propId);
+ ++it;
+ }
+ m_metaDataCreated = true;
}
- m_metaDataCreated = true;
}
}
@@ -383,7 +388,6 @@ public:
private:
friend class QDeclarativeVisualDataModelData;
- QHash<int,int> roleToProp;
};
class QDeclarativeVisualDataModelData : public QObject
@@ -400,6 +404,8 @@ public:
int propForRole(int) const;
void setValue(int, const QVariant &);
+ void ensureProperties();
+
Q_SIGNALS:
void indexChanged();
@@ -412,9 +418,11 @@ private:
int QDeclarativeVisualDataModelData::propForRole(int id) const
{
- QHash<int,int>::const_iterator it = m_meta->roleToProp.find(id);
- if (it != m_meta->roleToProp.end())
- return m_meta->roleToProp[id];
+ QDeclarativeVisualDataModelPrivate *model = QDeclarativeVisualDataModelPrivate::get(m_model);
+ QHash<int,int>::const_iterator it = model->roleToPropId.find(id);
+ if (it != model->roleToPropId.end())
+ return *it;
+
return -1;
}
@@ -470,12 +478,10 @@ QVariant QDeclarativeVisualDataModelDataMetaObject::initialValue(int propId)
model->ensureRoles();
QHash<QByteArray,int>::const_iterator it = model->m_roleNames.find(propName);
if (it != model->m_roleNames.end()) {
- roleToProp.insert(*it, propId);
QVariant value = model->m_listModelInterface->data(data->m_index, *it);
return value;
} else if (model->m_roles.count() == 1 && propName == "modelData") {
//for compatability with other lists, assign modelData if there is only a single role
- roleToProp.insert(model->m_roles.first(), propId);
QVariant value = model->m_listModelInterface->data(data->m_index, model->m_roles.first());
return value;
}
@@ -487,7 +493,6 @@ QVariant QDeclarativeVisualDataModelDataMetaObject::initialValue(int propId)
} else {
QHash<QByteArray,int>::const_iterator it = model->m_roleNames.find(propName);
if (it != model->m_roleNames.end()) {
- roleToProp.insert(*it, propId);
QModelIndex index = model->m_abstractItemModel->index(data->m_index, 0, model->m_root);
return model->m_abstractItemModel->data(index, *it);
}
@@ -502,18 +507,23 @@ QDeclarativeVisualDataModelData::QDeclarativeVisualDataModelData(int index,
: m_index(index), m_model(model),
m_meta(new QDeclarativeVisualDataModelDataMetaObject(this, QDeclarativeVisualDataModelPrivate::get(model)->m_delegateDataType))
{
- QDeclarativeVisualDataModelPrivate *modelPriv = QDeclarativeVisualDataModelPrivate::get(model);
- if (modelPriv->m_metaDataCacheable) {
- if (!modelPriv->m_metaDataCreated)
- modelPriv->createMetaData();
- m_meta->setCached(true);
- }
+ ensureProperties();
}
QDeclarativeVisualDataModelData::~QDeclarativeVisualDataModelData()
{
}
+void QDeclarativeVisualDataModelData::ensureProperties()
+{
+ QDeclarativeVisualDataModelPrivate *modelPriv = QDeclarativeVisualDataModelPrivate::get(m_model);
+ if (modelPriv->m_metaDataCacheable && !modelPriv->m_metaDataCreated) {
+ modelPriv->createMetaData();
+ if (modelPriv->m_metaDataCreated)
+ m_meta->setCached(true);
+ }
+}
+
int QDeclarativeVisualDataModelData::index() const
{
return m_index;
@@ -626,8 +636,8 @@ QDeclarativeVisualDataModel::QDeclarativeVisualDataModel()
{
}
-QDeclarativeVisualDataModel::QDeclarativeVisualDataModel(QDeclarativeContext *ctxt)
-: QDeclarativeVisualModel(*(new QDeclarativeVisualDataModelPrivate(ctxt)))
+QDeclarativeVisualDataModel::QDeclarativeVisualDataModel(QDeclarativeContext *ctxt, QObject *parent)
+: QDeclarativeVisualModel(*(new QDeclarativeVisualDataModelPrivate(ctxt)), parent)
{
}
@@ -1212,6 +1222,13 @@ void QDeclarativeVisualDataModel::_q_itemsChanged(int index, int count,
QModelIndex index = d->m_abstractItemModel->index(idx, 0, d->m_root);
data->setValue(propId, d->m_abstractItemModel->data(index, role));
}
+ } else {
+ QString roleName;
+ if (d->m_listModelInterface)
+ roleName = d->m_listModelInterface->toString(role);
+ else if (d->m_abstractItemModel)
+ roleName = d->m_abstractItemModel->roleNames().value(role);
+ qmlInfo(this) << "Changing role not present in item: " << roleName;
}
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
index edfd387..0bdbbcf 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
@@ -72,7 +72,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeVisualModel : public QObject
Q_PROPERTY(int count READ count NOTIFY countChanged)
public:
- QDeclarativeVisualModel() {}
+ QDeclarativeVisualModel(QObject *parent=0) : QObject(parent) {}
virtual ~QDeclarativeVisualModel() {}
enum ReleaseFlag { Referenced = 0x01, Destroyed = 0x02 };
@@ -117,7 +117,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeVisualItemModel : public QDeclarativeVisu
Q_CLASSINFO("DefaultProperty", "children")
public:
- QDeclarativeVisualItemModel();
+ QDeclarativeVisualItemModel(QObject *parent=0);
virtual ~QDeclarativeVisualItemModel() {}
virtual int count() const;
@@ -156,7 +156,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeVisualDataModel : public QDeclarativeVisu
Q_CLASSINFO("DefaultProperty", "delegate")
public:
QDeclarativeVisualDataModel();
- QDeclarativeVisualDataModel(QDeclarativeContext *);
+ QDeclarativeVisualDataModel(QDeclarativeContext *, QObject *parent=0);
virtual ~QDeclarativeVisualDataModel();
QVariant model() const;
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 6d420a7..a43b9ac 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -352,6 +352,10 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
instr.storeDouble.propertyIndex = prop.propertyIndex();
instr.storeDouble.value = n;
}
+ } else if(v->value.isBoolean()) {
+ instr.type = QDeclarativeInstruction::StoreVariantBool;
+ instr.storeBool.propertyIndex = prop.propertyIndex();
+ instr.storeBool.value = v->value.asBoolean();
} else {
instr.type = QDeclarativeInstruction::StoreVariant;
instr.storeString.propertyIndex = prop.propertyIndex();
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index afdaee8..e757675 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -545,7 +545,7 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q
}
/*!
- \qmlmethod object Component::createObject()
+ \qmlmethod object Component::createObject(parent)
Returns an object instance from this component, or null if object creation fails.
The object will be created in the same context as the one in which the component
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 9f5cafe..94e6771 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -327,11 +327,12 @@ Q_GLOBAL_STATIC(QDeclarativeEngineDebugServer, qmlEngineDebugServer);
void QDeclarativePrivate::qdeclarativeelement_destructor(QObject *o)
{
QObjectPrivate *p = QObjectPrivate::get(o);
- Q_ASSERT(p->declarativeData);
- QDeclarativeData *d = static_cast<QDeclarativeData*>(p->declarativeData);
- if (d->ownContext && d->context) {
- d->context->destroy();
- d->context = 0;
+ if (p->declarativeData) {
+ QDeclarativeData *d = static_cast<QDeclarativeData*>(p->declarativeData);
+ if (d->ownContext && d->context) {
+ d->context->destroy();
+ d->context = 0;
+ }
}
}
diff --git a/src/declarative/qml/qdeclarativeinstruction.cpp b/src/declarative/qml/qdeclarativeinstruction.cpp
index 99f1cc8..0236950 100644
--- a/src/declarative/qml/qdeclarativeinstruction.cpp
+++ b/src/declarative/qml/qdeclarativeinstruction.cpp
@@ -136,6 +136,9 @@ void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx)
case QDeclarativeInstruction::StoreVariantDouble:
qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VARIANT_DOUBLE\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
break;
+ case QDeclarativeInstruction::StoreVariantBool:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VARIANT_BOOL\t\t" << instr->storeBool.propertyIndex << "\t" << instr->storeBool.value;
+ break;
case QDeclarativeInstruction::StoreObject:
qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_OBJECT\t\t" << instr->storeObject.propertyIndex;
break;
diff --git a/src/declarative/qml/qdeclarativeinstruction_p.h b/src/declarative/qml/qdeclarativeinstruction_p.h
index c09b157..dc5f2f8 100644
--- a/src/declarative/qml/qdeclarativeinstruction_p.h
+++ b/src/declarative/qml/qdeclarativeinstruction_p.h
@@ -116,6 +116,7 @@ public:
StoreVariant, /* storeString */
StoreVariantInteger, /* storeInteger */
StoreVariantDouble, /* storeDouble */
+ StoreVariantBool, /* storeBool */
StoreObject, /* storeObject */
StoreVariantObject, /* storeObject */
StoreInterface, /* storeObject */
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index 3e63e24..8ba79a6 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -360,6 +360,16 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
}
break;
+ case QDeclarativeInstruction::StoreVariantBool:
+ {
+ QObject *target = stack.top();
+ QVariant v(instr.storeBool.value);
+ void *a[] = { &v, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeString.propertyIndex, a);
+ }
+ break;
+
case QDeclarativeInstruction::StoreString:
{
QObject *target = stack.top();
diff --git a/src/declarative/util/qdeclarativebehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp
index ba90007..90e0ca3 100644
--- a/src/declarative/util/qdeclarativebehavior.cpp
+++ b/src/declarative/util/qdeclarativebehavior.cpp
@@ -62,6 +62,7 @@ public:
QDeclarativeProperty property;
QVariant currentValue;
+ QVariant targetValue;
QDeclarativeGuard<QDeclarativeAbstractAnimation> animation;
bool enabled;
bool finalized;
@@ -162,10 +163,15 @@ void QDeclarativeBehavior::write(const QVariant &value)
qmlExecuteDeferred(this);
if (!d->animation || !d->enabled || !d->finalized) {
QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
+ d->targetValue = value;
return;
}
+ if (value == d->targetValue)
+ return;
+
d->currentValue = d->property.read();
+ d->targetValue = value;
if (d->animation->qtAnimation()->duration() != -1)
d->animation->qtAnimation()->stop();
diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp
index dbca326..d9ce42c 100644
--- a/src/declarative/util/qdeclarativepixmapcache.cpp
+++ b/src/declarative/util/qdeclarativepixmapcache.cpp
@@ -55,6 +55,7 @@
#include <QFile>
#include <QThread>
#include <QMutex>
+#include <QBuffer>
#include <QWaitCondition>
#include <QtCore/qdebug.h>
#include <private/qobject_p.h>
@@ -342,7 +343,10 @@ void QDeclarativeImageRequestHandler::networkRequestDone()
errorString = reply->errorString();
} else {
QSize read_impsize;
- if (readImage(reply->url(), reply, &image, &errorString, &read_impsize, job->forcedWidth(), job->forcedHeight())) {
+ QByteArray all = reply->readAll();
+ QBuffer buff(&all);
+ buff.open(QIODevice::ReadOnly);
+ if (readImage(reply->url(), &buff, &image, &errorString, &read_impsize, job->forcedWidth(), job->forcedHeight())) {
qmlOriginalSizes()->insert(reply->url(), read_impsize);
error = QDeclarativeImageReaderEvent::NoError;
} else {
diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp
index 94780c4..a22c756 100644
--- a/src/declarative/util/qdeclarativepropertychanges.cpp
+++ b/src/declarative/util/qdeclarativepropertychanges.cpp
@@ -161,20 +161,15 @@ public:
QDeclarativeExpression *rewindExpression;
QDeclarativeGuard<QDeclarativeExpression> ownedExpression;
- virtual bool changesBindings() { return true; }
- virtual void clearBindings() {
- ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, 0);
- }
-
virtual void execute(Reason) {
- QDeclarativePropertyPrivate::setSignalExpression(property, expression);
+ ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, expression);
if (ownedExpression == expression)
ownedExpression = 0;
}
virtual bool isReversable() { return true; }
virtual void reverse(Reason) {
- QDeclarativePropertyPrivate::setSignalExpression(property, reverseExpression);
+ ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, reverseExpression);
if (ownedExpression == reverseExpression)
ownedExpression = 0;
}
@@ -198,7 +193,7 @@ public:
}
virtual void rewind() {
- QDeclarativePropertyPrivate::setSignalExpression(property, rewindExpression);
+ ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, rewindExpression);
if (ownedExpression == rewindExpression)
ownedExpression = 0;
}
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
index 833e284..e68ef94 100644
--- a/src/declarative/util/qdeclarativeview.cpp
+++ b/src/declarative/util/qdeclarativeview.cpp
@@ -128,19 +128,18 @@ void FrameBreakAnimation::updateCurrentTime(int msecs)
server->frameBreak();
}
-class QDeclarativeViewPrivate : public QDeclarativeItemChangeListener
+class QDeclarativeViewPrivate : public QGraphicsViewPrivate, public QDeclarativeItemChangeListener
{
+ Q_DECLARE_PUBLIC(QDeclarativeView)
public:
- QDeclarativeViewPrivate(QDeclarativeView *view)
- : q(view), root(0), declarativeItemRoot(0), graphicsWidgetRoot(0), component(0), resizeMode(QDeclarativeView::SizeViewToRootObject) {}
+ QDeclarativeViewPrivate()
+ : root(0), declarativeItemRoot(0), graphicsWidgetRoot(0), component(0), resizeMode(QDeclarativeView::SizeViewToRootObject) {}
~QDeclarativeViewPrivate() { delete root; }
void execute();
void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry);
void initResize();
void updateSize();
- inline QSize rootObjectSize();
-
- QDeclarativeView *q;
+ inline QSize rootObjectSize() const;
QDeclarativeGuard<QGraphicsObject> root;
QDeclarativeGuard<QDeclarativeItem> declarativeItemRoot;
@@ -162,6 +161,7 @@ public:
void QDeclarativeViewPrivate::execute()
{
+ Q_Q(QDeclarativeView);
if (root) {
delete root;
root = 0;
@@ -182,6 +182,7 @@ void QDeclarativeViewPrivate::execute()
void QDeclarativeViewPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem, const QRectF &newGeometry, const QRectF &oldGeometry)
{
+ Q_Q(QDeclarativeView);
if (resizeItem == root && resizeMode == QDeclarativeView::SizeViewToRootObject) {
// wait for both width and height to be changed
resizetimer.start(0,q);
@@ -250,8 +251,9 @@ void QDeclarativeViewPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem,
Constructs a QDeclarativeView with the given \a parent.
*/
QDeclarativeView::QDeclarativeView(QWidget *parent)
-: QGraphicsView(parent), d(new QDeclarativeViewPrivate(this))
+ : QGraphicsView(*(new QDeclarativeViewPrivate), parent)
{
+ Q_D(QDeclarativeView);
setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
d->init();
}
@@ -262,8 +264,9 @@ QDeclarativeView::QDeclarativeView(QWidget *parent)
Constructs a QDeclarativeView with the given QML \a source and \a parent.
*/
QDeclarativeView::QDeclarativeView(const QUrl &source, QWidget *parent)
-: QGraphicsView(parent), d(new QDeclarativeViewPrivate(this))
+ : QGraphicsView(*(new QDeclarativeViewPrivate), parent)
{
+ Q_D(QDeclarativeView);
setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
d->init();
setSource(source);
@@ -271,6 +274,7 @@ QDeclarativeView::QDeclarativeView(const QUrl &source, QWidget *parent)
void QDeclarativeViewPrivate::init()
{
+ Q_Q(QDeclarativeView);
q->setScene(&scene);
q->setOptimizationFlags(QGraphicsView::DontSavePainterState);
@@ -288,12 +292,10 @@ void QDeclarativeViewPrivate::init()
}
/*!
- The destructor clears the view's \l {QGraphicsObject} {items} and
- deletes the internal representation.
+ Destroys the view.
*/
QDeclarativeView::~QDeclarativeView()
{
- delete d;
}
/*! \property QDeclarativeView::source
@@ -316,6 +318,7 @@ QDeclarativeView::~QDeclarativeView()
*/
void QDeclarativeView::setSource(const QUrl& url)
{
+ Q_D(QDeclarativeView);
d->source = url;
d->execute();
}
@@ -327,6 +330,7 @@ void QDeclarativeView::setSource(const QUrl& url)
*/
QUrl QDeclarativeView::source() const
{
+ Q_D(const QDeclarativeView);
return d->source;
}
@@ -336,6 +340,7 @@ QUrl QDeclarativeView::source() const
*/
QDeclarativeEngine* QDeclarativeView::engine()
{
+ Q_D(QDeclarativeView);
return &d->engine;
}
@@ -348,6 +353,7 @@ QDeclarativeEngine* QDeclarativeView::engine()
*/
QDeclarativeContext* QDeclarativeView::rootContext()
{
+ Q_D(QDeclarativeView);
return d->engine.rootContext();
}
@@ -376,6 +382,7 @@ QDeclarativeContext* QDeclarativeView::rootContext()
QDeclarativeView::Status QDeclarativeView::status() const
{
+ Q_D(const QDeclarativeView);
if (!d->component)
return QDeclarativeView::Null;
@@ -388,6 +395,7 @@ QDeclarativeView::Status QDeclarativeView::status() const
*/
QList<QDeclarativeError> QDeclarativeView::errors() const
{
+ Q_D(const QDeclarativeView);
if (d->component)
return d->component->errors();
return QList<QDeclarativeError>();
@@ -410,6 +418,7 @@ QList<QDeclarativeError> QDeclarativeView::errors() const
void QDeclarativeView::setResizeMode(ResizeMode mode)
{
+ Q_D(QDeclarativeView);
if (d->resizeMode == mode)
return;
@@ -433,6 +442,7 @@ void QDeclarativeView::setResizeMode(ResizeMode mode)
void QDeclarativeViewPrivate::initResize()
{
+ Q_Q(QDeclarativeView);
if (declarativeItemRoot) {
if (resizeMode == QDeclarativeView::SizeViewToRootObject) {
QDeclarativeItemPrivate *p =
@@ -449,6 +459,7 @@ void QDeclarativeViewPrivate::initResize()
void QDeclarativeViewPrivate::updateSize()
{
+ Q_Q(QDeclarativeView);
if (!root)
return;
if (declarativeItemRoot) {
@@ -479,7 +490,7 @@ void QDeclarativeViewPrivate::updateSize()
q->updateGeometry();
}
-QSize QDeclarativeViewPrivate::rootObjectSize()
+QSize QDeclarativeViewPrivate::rootObjectSize() const
{
QSize rootObjectSize(0,0);
int widthCandidate = -1;
@@ -500,6 +511,7 @@ QSize QDeclarativeViewPrivate::rootObjectSize()
QDeclarativeView::ResizeMode QDeclarativeView::resizeMode() const
{
+ Q_D(const QDeclarativeView);
return d->resizeMode;
}
@@ -508,7 +520,7 @@ QDeclarativeView::ResizeMode QDeclarativeView::resizeMode() const
*/
void QDeclarativeView::continueExecute()
{
-
+ Q_D(QDeclarativeView);
disconnect(d->component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), this, SLOT(continueExecute()));
if (d->component->isError()) {
@@ -541,6 +553,7 @@ void QDeclarativeView::continueExecute()
*/
void QDeclarativeView::setRootObject(QObject *obj)
{
+ Q_D(QDeclarativeView);
if (d->root == obj)
return;
if (QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem *>(obj)) {
@@ -590,6 +603,7 @@ void QDeclarativeView::setRootObject(QObject *obj)
*/
void QDeclarativeView::timerEvent(QTimerEvent* e)
{
+ Q_D(QDeclarativeView);
if (!e || e->timerId() == d->resizetimer.timerId()) {
d->updateSize();
d->resizetimer.stop();
@@ -599,6 +613,7 @@ void QDeclarativeView::timerEvent(QTimerEvent* e)
/*! \reimp */
bool QDeclarativeView::eventFilter(QObject *watched, QEvent *e)
{
+ Q_D(QDeclarativeView);
if (watched == d->root && d->resizeMode == SizeViewToRootObject) {
if (d->graphicsWidgetRoot) {
if (e->type() == QEvent::GraphicsSceneResize) {
@@ -615,6 +630,7 @@ bool QDeclarativeView::eventFilter(QObject *watched, QEvent *e)
*/
QSize QDeclarativeView::sizeHint() const
{
+ Q_D(const QDeclarativeView);
QSize rootObjectSize = d->rootObjectSize();
if (rootObjectSize.isEmpty()) {
return size();
@@ -628,6 +644,7 @@ QSize QDeclarativeView::sizeHint() const
*/
QGraphicsObject *QDeclarativeView::rootObject() const
{
+ Q_D(const QDeclarativeView);
return d->root;
}
@@ -638,6 +655,7 @@ QGraphicsObject *QDeclarativeView::rootObject() const
*/
void QDeclarativeView::resizeEvent(QResizeEvent *e)
{
+ Q_D(QDeclarativeView);
if (d->resizeMode == SizeRootObjectToView) {
d->updateSize();
}
@@ -657,6 +675,7 @@ void QDeclarativeView::resizeEvent(QResizeEvent *e)
*/
void QDeclarativeView::paintEvent(QPaintEvent *event)
{
+ Q_D(QDeclarativeView);
int time = 0;
if (frameRateDebug() || QDeclarativeViewDebugServer::isDebuggingEnabled())
time = d->frameTimer.restart();
diff --git a/src/declarative/util/qdeclarativeview.h b/src/declarative/util/qdeclarativeview.h
index 3513c04..e9cff32 100644
--- a/src/declarative/util/qdeclarativeview.h
+++ b/src/declarative/util/qdeclarativeview.h
@@ -106,9 +106,8 @@ protected:
virtual bool eventFilter(QObject *watched, QEvent *e);
private:
- friend class QDeclarativeViewPrivate;
- QDeclarativeViewPrivate *d;
Q_DISABLE_COPY(QDeclarativeView)
+ Q_DECLARE_PRIVATE(QDeclarativeView)
};
QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index ae3b5d7..f1a00989 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -472,40 +472,71 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla
\since 4.7
\brief The XmlListModel element is used to specify a model using XPath expressions.
- XmlListModel is used to create a model from XML data that can be used as a data source
+ XmlListModel is used to create a model from XML data. XmlListModel can be used as a data source
for the view classes (such as ListView, PathView, GridView) and other classes that interact with model
- data (such as Repeater).
+ data (such as \l Repeater).
+
+ For example, if there is a XML document at http://www.mysite.com/feed.xml like this:
+
+ \code
+ <?xml version="1.0" encoding="utf-8"?>
+ <rss version="2.0">
+ ...
+ <channel>
+ <item>
+ <title>Item A</title>
+ <pubDate>Sat, 07 Sep 2010 10:00:01 GMT</pubDate>
+ </item>
+ <item>
+ <title>Item B</title>
+ <pubDate>Sat, 07 Sep 2010 15:35:01 GMT</pubDate>
+ </item>
+ </channel>
+ </rss>
+ \endcode
+
+ Then it could be used to create the following model:
- Here is an example of a model containing news from a Yahoo RSS feed:
\qml
XmlListModel {
- id: feedModel
- source: "http://rss.news.yahoo.com/rss/oceania"
+ source: "http://www.mysite.com/feed.xml"
query: "/rss/channel/item"
XmlRole { name: "title"; query: "title/string()" }
XmlRole { name: "pubDate"; query: "pubDate/string()" }
- XmlRole { name: "description"; query: "description/string()" }
}
\endqml
- You can also define certain roles as "keys" so that the model only adds data
- that contains new values for these keys when reload() is called.
+ The \l {XmlListModel::query}{query} value of "/rss/channel/item" specifies that the XmlListModel should generate
+ a model item for each \c <item> in the XML document. The XmlRole objects define the
+ model item attributes; here, each model item will have \c title and \c pubDate
+ attributes that match the \c title and \c pubDate values of its corresponding \c <item>.
- For example, if the roles above were defined like this:
+
+ \section2 Using key XML roles
+
+ You can define certain roles as "keys" so that when reload() is called,
+ the model will only add and refresh data that contains new values for
+ these keys.
+
+ For example, if above role for "pubDate" was defined like this instead:
\qml
- XmlRole { name: "title"; query: "title/string()"; isKey: true }
XmlRole { name: "pubDate"; query: "pubDate/string()"; isKey: true }
\endqml
- Then when reload() is called, the model will only add new items with a
- "title" and "pubDate" value combination that is not already present in
- the model.
+ Then when reload() is called, the model will only add and reload
+ items with a "pubDate" value that is not already
+ present in the model.
- This is useful to provide incremental updates and avoid repainting an
- entire model in a view.
+ This is useful when displaying the contents of XML documents that
+ are incrementally updated (such as RSS feeds) to avoid repainting the
+ entire contents of a model in a view.
- \sa {QtDeclarative}
+ If multiple key roles are specified, the model only adds and reload items
+ with a combined value of all key roles that is not already present in
+ the model.
+
+ \sa {declarative/xmldata}{XML data example}
*/
QDeclarativeXmlListModel::QDeclarativeXmlListModel(QObject *parent)
@@ -626,8 +657,8 @@ void QDeclarativeXmlListModel::setXml(const QString &xml)
/*!
\qmlproperty string XmlListModel::query
- An absolute XPath query representing the base query for the model items. The query should start with
- '/' or '//'.
+ An absolute XPath query representing the base query for creating model items
+ from this model's XmlRole objects. The query should start with '/' or '//'.
*/
QString QDeclarativeXmlListModel::query() const
{
@@ -652,7 +683,20 @@ void QDeclarativeXmlListModel::setQuery(const QString &query)
/*!
\qmlproperty string XmlListModel::namespaceDeclarations
- A set of declarations for the namespaces used in the query.
+ The namespace declarations to be used in the XPath queries.
+
+ The namespaces should be declared as in XQuery. For example, if a requested document
+ at http://mysite.com/feed.xml uses the namespace "http://www.w3.org/2005/Atom",
+ this can be declared as the default namespace:
+
+ \qml
+ XmlListModel {
+ source: "http://mysite.com/feed.xml"
+ query: "/feed/entry"
+ namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';"
+ XmlRole { name: "title"; query: "title/string()" }
+ }
+ \endqml
*/
QString QDeclarativeXmlListModel::namespaceDeclarations() const
{
@@ -735,7 +779,7 @@ void QDeclarativeXmlListModel::componentComplete()
Otherwise, items are only added if the model does not already
contain items with matching key role values.
- \sa XmlRole::isKey
+ \sa {Using key XML roles}, XmlRole::isKey
*/
void QDeclarativeXmlListModel::reload()
{
@@ -752,8 +796,11 @@ void QDeclarativeXmlListModel::reload()
if (d->reply) {
d->reply->abort();
- d->reply->deleteLater();
- d->reply = 0;
+ if (d->reply) {
+ // abort will generally have already done this (and more)
+ d->reply->deleteLater();
+ d->reply = 0;
+ }
}
if (!d->xml.isEmpty()) {
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 0d4e48a..7abd5f6 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -690,6 +690,10 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
if (item == lastMouseGrabberItem)
lastMouseGrabberItem = 0;
+ // Reset the current drop item
+ if (item == dragDropItem)
+ dragDropItem = 0;
+
// Reenable selectionChanged() for individual items
--selectionChanging;
if (!selectionChanging && selectedItems.size() != oldSelectedItemsSize)
@@ -1316,10 +1320,10 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou
setFocus = true;
break;
}
- if (item->isEnabled() && ((item->flags() & QGraphicsItem::ItemIsFocusable) && item->d_ptr->mouseSetsFocus)) {
+ if (item->isEnabled() && ((item->flags() & QGraphicsItem::ItemIsFocusable))) {
if (!item->isWidget() || ((QGraphicsWidget *)item)->focusPolicy() & Qt::ClickFocus) {
setFocus = true;
- if (item != q->focusItem())
+ if (item != q->focusItem() && item->d_ptr->mouseSetsFocus)
q->setFocusItem(item, Qt::MouseFocusReason);
break;
}
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index 0bba7e9..9519ca0 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -1819,8 +1819,6 @@ void QGraphicsView::centerOn(const QGraphicsItem *item)
void QGraphicsView::ensureVisible(const QRectF &rect, int xmargin, int ymargin)
{
Q_D(QGraphicsView);
- Q_UNUSED(xmargin);
- Q_UNUSED(ymargin);
qreal width = viewport()->width();
qreal height = viewport()->height();
QRectF viewRect = d->matrix.mapRect(rect);
diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp
index 5fc605a..7a6a73f 100644
--- a/src/gui/image/qpixmapcache.cpp
+++ b/src/gui/image/qpixmapcache.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
+#define Q_TEST_QPIXMAPCACHE
#include "qpixmapcache.h"
#include "qobject.h"
#include "qdebug.h"
@@ -194,6 +195,9 @@ public:
static QPixmapCache::KeyData* getKeyData(QPixmapCache::Key *key);
+ QList< QPair<QString,QPixmap> > allPixmaps() const;
+ void flushDetachedPixmaps(bool nt);
+
private:
int *keyArray;
int theid;
@@ -235,10 +239,9 @@ QPMCache::~QPMCache()
When the last pixmap has been deleted from the cache, kill the
timer so Qt won't keep the CPU from going into sleep mode.
*/
-void QPMCache::timerEvent(QTimerEvent *)
+void QPMCache::flushDetachedPixmaps(bool nt)
{
int mc = maxCost();
- bool nt = totalCost() == ps;
setMaxCost(nt ? totalCost() * 3 / 4 : totalCost() -1);
setMaxCost(mc);
ps = totalCost();
@@ -252,6 +255,12 @@ void QPMCache::timerEvent(QTimerEvent *)
++it;
}
}
+}
+
+void QPMCache::timerEvent(QTimerEvent *)
+{
+ bool nt = totalCost() == ps;
+ flushDetachedPixmaps(nt);
if (!size()) {
killTimer(theid);
@@ -263,6 +272,7 @@ void QPMCache::timerEvent(QTimerEvent *)
}
}
+
QPixmap *QPMCache::object(const QString &key) const
{
QPixmapCache::Key cacheKey = cacheKeys.value(key);
@@ -422,6 +432,20 @@ QPixmapCache::KeyData* QPMCache::getKeyData(QPixmapCache::Key *key)
return key->d;
}
+QList< QPair<QString,QPixmap> > QPMCache::allPixmaps() const
+{
+ QList< QPair<QString,QPixmap> > r;
+ QHash<QString, QPixmapCache::Key>::const_iterator it = cacheKeys.begin();
+ while (it != cacheKeys.end()) {
+ QPixmap *ptr = QCache<QPixmapCache::Key, QPixmapCacheEntry>::object(it.value());
+ if (ptr)
+ r.append(QPair<QString,QPixmap>(it.key(),*ptr));
+ ++it;
+ }
+ return r;
+}
+
+
Q_GLOBAL_STATIC(QPMCache, pm_cache)
int Q_AUTOTEST_EXPORT q_QPixmapCache_keyHashSize()
@@ -633,4 +657,19 @@ void QPixmapCache::clear()
}
}
+void QPixmapCache::flushDetachedPixmaps()
+{
+ pm_cache()->flushDetachedPixmaps(true);
+}
+
+int QPixmapCache::totalUsed()
+{
+ return (pm_cache()->totalCost()+1023) / 1024;
+}
+
+QList< QPair<QString,QPixmap> > QPixmapCache::allPixmaps()
+{
+ return pm_cache()->allPixmaps();
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmapcache.h b/src/gui/image/qpixmapcache.h
index 50a9369..e9c8c15 100644
--- a/src/gui/image/qpixmapcache.h
+++ b/src/gui/image/qpixmapcache.h
@@ -44,6 +44,10 @@
#include <QtGui/qpixmap.h>
+#ifdef Q_TEST_QPIXMAPCACHE
+#include <QtCore/qpair.h>
+#endif
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -83,6 +87,12 @@ public:
static void remove(const QString &key);
static void remove(const Key &key);
static void clear();
+
+#ifdef Q_TEST_QPIXMAPCACHE
+ static void flushDetachedPixmaps();
+ static int totalUsed();
+ static QList< QPair<QString,QPixmap> > allPixmaps();
+#endif
};
QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmapcache_p.h b/src/gui/image/qpixmapcache_p.h
index 86a1b78..825f272 100644
--- a/src/gui/image/qpixmapcache_p.h
+++ b/src/gui/image/qpixmapcache_p.h
@@ -95,6 +95,8 @@ public:
QPixmapCache::Key key;
};
+inline bool qIsDetached(QPixmapCacheEntry &t) { return t.isDetached(); }
+
QT_END_NAMESPACE
#endif // QPIXMAPCACHE_P_H
diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp
index 25d3dfa..8abc2d1 100644
--- a/src/plugins/imageformats/gif/qgifhandler.cpp
+++ b/src/plugins/imageformats/gif/qgifhandler.cpp
@@ -1119,8 +1119,11 @@ bool QGifHandler::write(const QImage &image)
bool QGifHandler::supportsOption(ImageOption option) const
{
- return option == Size
- || option == Animation;
+ if (!device() || device()->isSequential())
+ return option == Animation;
+ else
+ return option == Size
+ || option == Animation;
}
QVariant QGifHandler::option(ImageOption option) const