summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-07-23 02:07:35 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-07-23 02:07:35 (GMT)
commitdd61bcbafd669d77a35d2161880ba915f78bf240 (patch)
treee7e3b8cc1725dde557c66e23cfc7be4b996150e8
parent6f43de5c1173277465f13eed9e904928a54bb9fc (diff)
parentaf965934e6dbf8f581b1f9e241a08a9b2128472a (diff)
downloadQt-dd61bcbafd669d77a35d2161880ba915f78bf240.zip
Qt-dd61bcbafd669d77a35d2161880ba915f78bf240.tar.gz
Qt-dd61bcbafd669d77a35d2161880ba915f78bf240.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--demos/declarative/samegame/content/SpinBlock.qml2
-rw-r--r--demos/declarative/samegame/content/samegame.js6
-rw-r--r--examples/declarative/dynamic/dynamic.js4
-rw-r--r--examples/declarative/minehunt/main.cpp1
-rw-r--r--src/corelib/kernel/qabstractitemmodel.cpp10
-rw-r--r--src/corelib/kernel/qabstractitemmodel.h3
-rw-r--r--src/declarative/extra/qfxanimatedimageitem.cpp45
-rw-r--r--src/declarative/extra/qfxanimatedimageitem.h6
-rw-r--r--src/declarative/extra/qfxanimatedimageitem_p.h3
-rw-r--r--src/declarative/extra/qfxflowview.cpp6
-rw-r--r--src/declarative/extra/qfxparticles.cpp6
-rw-r--r--src/declarative/extra/qfxparticles.h2
-rw-r--r--src/declarative/extra/qmlxmllistmodel.cpp2
-rw-r--r--src/declarative/fx/qfxflickable.cpp2
-rw-r--r--src/declarative/fx/qfxgraphicsobjectcontainer.cpp1
-rw-r--r--src/declarative/fx/qfxgraphicsobjectcontainer.h1
-rw-r--r--src/declarative/fx/qfxgridview.cpp2
-rw-r--r--src/declarative/fx/qfximage.cpp6
-rw-r--r--src/declarative/fx/qfximage.h2
-rw-r--r--src/declarative/fx/qfxitem.cpp272
-rw-r--r--src/declarative/fx/qfxitem.h76
-rw-r--r--src/declarative/fx/qfxitem_p.h19
-rw-r--r--src/declarative/fx/qfxlistview.cpp2
-rw-r--r--src/declarative/fx/qfxpainteditem.cpp6
-rw-r--r--src/declarative/fx/qfxpathview.cpp12
-rw-r--r--src/declarative/fx/qfxpixmap.cpp25
-rw-r--r--src/declarative/fx/qfxtext.cpp6
-rw-r--r--src/declarative/fx/qfxtext.h2
-rw-r--r--src/declarative/fx/qfxtextedit.cpp9
-rw-r--r--src/declarative/fx/qfxtextedit.h2
-rw-r--r--src/declarative/fx/qfxvisualitemmodel.cpp7
-rw-r--r--src/declarative/fx/qfxwebview.cpp5
-rw-r--r--src/declarative/fx/qfxwebview.h2
-rw-r--r--src/declarative/qml/qml.pri3
-rw-r--r--src/declarative/qml/qmlbindablecomponent.cpp104
-rw-r--r--src/declarative/qml/qmlbindablecomponent.h91
-rw-r--r--src/declarative/qml/qmlbindablecomponent_p.h77
-rw-r--r--src/declarative/qml/qmlbinding.cpp2
-rw-r--r--src/declarative/qml/qmlbinding.h5
-rw-r--r--src/declarative/qml/qmlcomponent.cpp17
-rw-r--r--src/declarative/qml/qmlcomponent.h9
-rw-r--r--src/declarative/qml/qmlengine.cpp12
-rw-r--r--src/declarative/util/qmlanimation.cpp35
-rw-r--r--src/declarative/util/qmlfollow.cpp3
-rw-r--r--src/declarative/util/qmlstate.cpp47
-rw-r--r--src/declarative/util/qmlstate.h3
-rw-r--r--src/declarative/util/qmlstate_p.h5
-rw-r--r--src/declarative/util/qmlstateoperations.cpp114
-rw-r--r--src/declarative/util/qmlstateoperations.h19
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp11
-rw-r--r--src/gui/graphicsview/qgraphicsitem.h7
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h6
52 files changed, 616 insertions, 509 deletions
diff --git a/demos/declarative/samegame/content/SpinBlock.qml b/demos/declarative/samegame/content/SpinBlock.qml
index 42276d0..2597bfb 100644
--- a/demos/declarative/samegame/content/SpinBlock.qml
+++ b/demos/declarative/samegame/content/SpinBlock.qml
@@ -15,7 +15,7 @@ Item { id:block
} else {
"pics/gnome/greenStone.gif";
}
- playing: selected
+ paused: !selected
}
opacity: 0
y: targetY
diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js
index 1814031..b1b2c50 100644
--- a/demos/declarative/samegame/content/samegame.js
+++ b/demos/declarative/samegame/content/samegame.js
@@ -49,7 +49,7 @@ function initBoard()
var fillFound;
var floodBoard;
-var lastHoveredIdx = -1
+var lastHoveredIdx = -2
function handleHover(x,y, btn)
{
xIdx = Math.floor(x/tileSize);
@@ -201,7 +201,7 @@ var waitTop = -1;
function finishCreatingBlock(xIdx,yIdx){
//TODO: Doc that the 'x', 'y' that were here are hidden properties from the calling QFxItem
- if(component.isReady()){
+ if(component.isReady){
if(xIdx == undefined){
//Called without arguments, create a previously stored (xIdx,yIdx)
if(waitTop == -1)
@@ -226,7 +226,7 @@ function finishCreatingBlock(xIdx,yIdx){
dynamicObject.spawned = true;
board[index(xIdx,yIdx)] = dynamicObject;
return true;
- }else if(component.isError()){
+ }else if(component.isError){
print("error creating block");
print(component.errorsString());
}else{
diff --git a/examples/declarative/dynamic/dynamic.js b/examples/declarative/dynamic/dynamic.js
index 13317df..8f1e138 100644
--- a/examples/declarative/dynamic/dynamic.js
+++ b/examples/declarative/dynamic/dynamic.js
@@ -28,10 +28,10 @@ function instantCreateWithComponent() {//Like create, but assumes instant readyn
}
function finishCreation(){
- if(component.isReady() && dynamicObject == null){
+ if(component.isReady && dynamicObject == null){
dynamicObject = component.createObject();
dynamicObject.parent = targetItem;
- }else if(component.isError()){
+ }else if(component.isError){
dynamicObject = null;
print("error creating component");
print(component.errorsString());
diff --git a/examples/declarative/minehunt/main.cpp b/examples/declarative/minehunt/main.cpp
index d8e60cc..ae850de 100644
--- a/examples/declarative/minehunt/main.cpp
+++ b/examples/declarative/minehunt/main.cpp
@@ -1,4 +1,3 @@
-#include "qmlbindablevalue.h"
#include "qmlengine.h"
#include "qmlcontext.h"
#include "qml.h"
diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp
index aa99b47..6e1d5c4 100644
--- a/src/corelib/kernel/qabstractitemmodel.cpp
+++ b/src/corelib/kernel/qabstractitemmodel.cpp
@@ -1879,6 +1879,13 @@ QSize QAbstractItemModel::span(const QModelIndex &) const
/*!
Sets the model's role names to \a roleNames.
+
+ This function is provided to allow mapping of role identifiers to
+ role property names in Declarative UI. This function must be called
+ before the model is used. Modifying the role names after the model
+ has been set may result in undefined behaviour.
+
+ \sa roleNames()
*/
void QAbstractItemModel::setRoleNames(const QHash<int,QByteArray> &roleNames)
{
@@ -1888,11 +1895,12 @@ void QAbstractItemModel::setRoleNames(const QHash<int,QByteArray> &roleNames)
/*!
Returns the model's role names.
+
+ \sa setRoleNames
*/
const QHash<int,QByteArray> &QAbstractItemModel::roleNames() const
{
Q_D(const QAbstractItemModel);
- qDebug() << "roles" << d->roleNames;
return d->roleNames;
}
diff --git a/src/corelib/kernel/qabstractitemmodel.h b/src/corelib/kernel/qabstractitemmodel.h
index 0a29af6..a6bbff4 100644
--- a/src/corelib/kernel/qabstractitemmodel.h
+++ b/src/corelib/kernel/qabstractitemmodel.h
@@ -220,7 +220,6 @@ public:
Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const;
virtual QSize span(const QModelIndex &index) const;
- void setRoleNames(const QHash<int,QByteArray> &roleNames);
const QHash<int,QByteArray> &roleNames() const;
#ifdef Q_NO_USING_KEYWORD
@@ -285,6 +284,8 @@ protected:
void changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to);
QModelIndexList persistentIndexList() const;
+ void setRoleNames(const QHash<int,QByteArray> &roleNames);
+
private:
Q_DECLARE_PRIVATE(QAbstractItemModel)
Q_DISABLE_COPY(QAbstractItemModel)
diff --git a/src/declarative/extra/qfxanimatedimageitem.cpp b/src/declarative/extra/qfxanimatedimageitem.cpp
index 5516a00..4c74f6f 100644
--- a/src/declarative/extra/qfxanimatedimageitem.cpp
+++ b/src/declarative/extra/qfxanimatedimageitem.cpp
@@ -96,6 +96,30 @@ QFxAnimatedImageItem::~QFxAnimatedImageItem()
}
/*!
+ \qmlproperty bool AnimatedImage::paused
+ This property holds whether the animated image is paused or not
+
+ Defaults to false, and can be set to true when you want to pause.
+*/
+bool QFxAnimatedImageItem::isPaused() const
+{
+ Q_D(const QFxAnimatedImageItem);
+ if(!d->_movie)
+ return false;
+ return d->_movie->state()==QMovie::Paused;
+}
+
+void QFxAnimatedImageItem::setPaused(bool pause)
+{
+ Q_D(QFxAnimatedImageItem);
+ if(pause == d->paused)
+ return;
+ d->paused = pause;
+ if(!d->_movie)
+ return;
+ d->_movie->setPaused(pause);
+}
+/*!
\qmlproperty bool AnimatedImage::playing
This property holds whether the animated image is playing or not
@@ -106,7 +130,7 @@ bool QFxAnimatedImageItem::isPlaying() const
Q_D(const QFxAnimatedImageItem);
if (!d->_movie)
return false;
- return d->_movie->state()==QMovie::Running;
+ return d->_movie->state()!=QMovie::NotRunning;
}
void QFxAnimatedImageItem::setPlaying(bool play)
@@ -120,7 +144,7 @@ void QFxAnimatedImageItem::setPlaying(bool play)
if (play)
d->_movie->start();
else
- d->_movie->setPaused(true);
+ d->_movie->stop();
}
/*!
@@ -197,7 +221,7 @@ void QFxAnimatedImageItem::movieRequestFinished()
return;
}
connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)),
- this, SIGNAL(playingChanged()));
+ this, SLOT(playingStatusChanged()));
connect(d->_movie, SIGNAL(frameChanged(int)),
this, SLOT(movieUpdate()));
d->_movie->setCacheMode(QMovie::CacheAll);
@@ -205,6 +229,8 @@ void QFxAnimatedImageItem::movieRequestFinished()
d->_movie->start();
else
d->_movie->jumpToFrame(0);
+ if(d->paused)
+ d->_movie->setPaused(true);
setPixmap(d->_movie->currentPixmap());
}
@@ -215,4 +241,17 @@ void QFxAnimatedImageItem::movieUpdate()
emit frameChanged();
}
+void QFxAnimatedImageItem::playingStatusChanged()
+{
+ Q_D(QFxAnimatedImageItem);
+ if((d->_movie->state() != QMovie::NotRunning) != d->playing){
+ d->playing = (d->_movie->state() != QMovie::NotRunning);
+ emit playingChanged();
+ }
+ if((d->_movie->state() == QMovie::Paused) != d->paused){
+ d->playing = (d->_movie->state() == QMovie::Paused);
+ emit pausedChanged();
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/extra/qfxanimatedimageitem.h b/src/declarative/extra/qfxanimatedimageitem.h
index 720d187..2d531ee 100644
--- a/src/declarative/extra/qfxanimatedimageitem.h
+++ b/src/declarative/extra/qfxanimatedimageitem.h
@@ -58,6 +58,7 @@ class Q_DECLARATIVE_EXPORT QFxAnimatedImageItem : public QFxImage
Q_OBJECT
Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged)
+ Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY frameChanged)
Q_PROPERTY(int frameCount READ frameCount)
public:
@@ -67,6 +68,9 @@ public:
bool isPlaying() const;
void setPlaying(bool play);
+ bool isPaused() const;
+ void setPaused(bool pause);
+
int currentFrame() const;
void setCurrentFrame(int frame);
@@ -77,11 +81,13 @@ public:
Q_SIGNALS:
void playingChanged();
+ void pausedChanged();
void frameChanged();
private Q_SLOTS:
void movieUpdate();
void movieRequestFinished();
+ void playingStatusChanged();
protected:
QFxAnimatedImageItem(QFxAnimatedImageItemPrivate &dd, QFxItem *parent);
diff --git a/src/declarative/extra/qfxanimatedimageitem_p.h b/src/declarative/extra/qfxanimatedimageitem_p.h
index d743ba4..859f869 100644
--- a/src/declarative/extra/qfxanimatedimageitem_p.h
+++ b/src/declarative/extra/qfxanimatedimageitem_p.h
@@ -65,11 +65,12 @@ class QFxAnimatedImageItemPrivate : public QFxImagePrivate
public:
QFxAnimatedImageItemPrivate()
- : playing(true), _movie(0)
+ : playing(true), paused(false), _movie(0)
{
}
bool playing;
+ bool paused;
QMovie *_movie;
};
diff --git a/src/declarative/extra/qfxflowview.cpp b/src/declarative/extra/qfxflowview.cpp
index 1676512..e1200c7 100644
--- a/src/declarative/extra/qfxflowview.cpp
+++ b/src/declarative/extra/qfxflowview.cpp
@@ -132,7 +132,7 @@ void QFxFlowView::refresh()
for (int ii = 0; ii < m_model->count(); ++ii) {
if (QFxItem *item = m_model->item(ii)) {
item->setParent(this);
- item->setZ(0);
+ item->setZValue(0);
m_items << item;
}
}
@@ -296,7 +296,7 @@ void QFxFlowView::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (r.contains(event->pos())) {
m_dragItem = item;
- m_dragItem->setZ(1);
+ m_dragItem->setZValue(1);
m_dragOffset = r.topLeft() - event->pos();
event->accept();
return;
@@ -316,7 +316,7 @@ void QFxFlowView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event);
if (m_dragItem) {
- m_dragItem->setZ(0);
+ m_dragItem->setZValue(0);
clearTimeLine();
diff --git a/src/declarative/extra/qfxparticles.cpp b/src/declarative/extra/qfxparticles.cpp
index 08d38ba..a7b01dd 100644
--- a/src/declarative/extra/qfxparticles.cpp
+++ b/src/declarative/extra/qfxparticles.cpp
@@ -1041,12 +1041,6 @@ void QFxParticles::setMotion(QFxParticleMotion *motion)
d->motion = motion;
}
-QString QFxParticles::propertyInfo() const
-{
- Q_D(const QFxParticles);
- return d->url.toString();
-}
-
void QFxParticlesPainter::updateSize()
{
const int parentX = parentItem()->x();
diff --git a/src/declarative/extra/qfxparticles.h b/src/declarative/extra/qfxparticles.h
index 9f085cd..2574f7f 100644
--- a/src/declarative/extra/qfxparticles.h
+++ b/src/declarative/extra/qfxparticles.h
@@ -203,8 +203,6 @@ public:
QFxParticleMotion *motion() const;
void setMotion(QFxParticleMotion *);
- virtual QString propertyInfo() const;
-
void paintContents(QPainter &p);
protected:
diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp
index 91ad538..1321f41 100644
--- a/src/declarative/extra/qmlxmllistmodel.cpp
+++ b/src/declarative/extra/qmlxmllistmodel.cpp
@@ -616,6 +616,7 @@ void QmlXmlListModel::requestFinished()
{
Q_D(QmlXmlListModel);
if (d->reply->error() != QNetworkReply::NoError) {
+ disconnect(d->reply, 0, this, 0);
d->reply->deleteLater();
d->reply = 0;
d->status = Error;
@@ -623,6 +624,7 @@ void QmlXmlListModel::requestFinished()
d->status = Idle;
QByteArray data = d->reply->readAll();
d->queryId = d->qmlXmlQuery.doQuery(d->query, d->namespaces, data, &d->roleObjects);
+ disconnect(d->reply, 0, this, 0);
d->reply->deleteLater();
d->reply = 0;
}
diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp
index 24f6d72..1db6e8b 100644
--- a/src/declarative/fx/qfxflickable.cpp
+++ b/src/declarative/fx/qfxflickable.cpp
@@ -1019,7 +1019,7 @@ bool QFxFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QFxFlickable);
QGraphicsSceneMouseEvent mouseEvent(event->type());
- QRectF myRect = mapToScene(QRectF(0, 0, width(), height()));
+ QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect();
QFxItem *grabber = static_cast<QFxItem*>(mouseGrabberItem());
if ((d->stealMouse || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) {
mouseEvent.setAccepted(false);
diff --git a/src/declarative/fx/qfxgraphicsobjectcontainer.cpp b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp
index 479a21d..a82ea3d 100644
--- a/src/declarative/fx/qfxgraphicsobjectcontainer.cpp
+++ b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp
@@ -55,6 +55,7 @@ QT_BEGIN_NAMESPACE
\brief The QFxGraphicsObjectContainer class allows you to add QGraphicsObjects into Fluid UI applications.
*/
+QML_DEFINE_NOCREATE_TYPE(QGraphicsObject)
QML_DEFINE_TYPE(QFxGraphicsObjectContainer, GraphicsObjectContainer)
QFxGraphicsObjectContainer::QFxGraphicsObjectContainer(QFxItem *parent)
diff --git a/src/declarative/fx/qfxgraphicsobjectcontainer.h b/src/declarative/fx/qfxgraphicsobjectcontainer.h
index e118555..165bc48 100644
--- a/src/declarative/fx/qfxgraphicsobjectcontainer.h
+++ b/src/declarative/fx/qfxgraphicsobjectcontainer.h
@@ -75,6 +75,7 @@ private:
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QGraphicsObject)
QML_DECLARE_TYPE(QFxGraphicsObjectContainer)
QT_END_HEADER
diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp
index 3c80e98..9528af7 100644
--- a/src/declarative/fx/qfxgridview.cpp
+++ b/src/declarative/fx/qfxgridview.cpp
@@ -356,7 +356,7 @@ FxGridItem *QFxGridViewPrivate::createItem(int modelIndex)
listItem->index = modelIndex;
// complete
model->completeItem();
- listItem->item->setZ(modelIndex + 1);
+ listItem->item->setZValue(modelIndex + 1);
listItem->item->setParent(q->viewport());
}
requestedIndex = 0;
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp
index 69030d2..7445606 100644
--- a/src/declarative/fx/qfximage.cpp
+++ b/src/declarative/fx/qfximage.cpp
@@ -388,12 +388,6 @@ void QFxImage::paintContents(QPainter &p)
}
}
-QString QFxImage::propertyInfo() const
-{
- Q_D(const QFxImage);
- return d->url.toString();
-}
-
/*!
\qmlproperty enum Image::status
diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h
index 7b3445c..4b6e700 100644
--- a/src/declarative/fx/qfximage.h
+++ b/src/declarative/fx/qfximage.h
@@ -43,6 +43,7 @@
#define QFXIMAGE_H
#include <QtDeclarative/qfxitem.h>
+#include <QtDeclarative/qfxscalegrid.h>
#include <QtNetwork/qnetworkreply.h>
@@ -91,7 +92,6 @@ public:
QUrl source() const;
virtual void setSource(const QUrl &url);
- virtual QString propertyInfo() const;
void paintContents(QPainter &painter);
Q_SIGNALS:
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index 481733b..212496c 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -349,22 +349,6 @@ void QFxContents::setItem(QFxItem *item)
*/
/*!
- \fn void QFxItem::visibleChanged()
-
- This signal is emitted when the visibility of the item changes.
-
- \sa setVisible()
-*/
-
-/*!
- \fn void QFxItem::opacityChanged()
-
- This signal is emitted when the opacity of the item changes.
-
- \sa opacity(), setOpacity()
-*/
-
-/*!
\fn void QFxItem::parentChanged()
This signal is emitted when the parent of the item changes.
@@ -460,70 +444,6 @@ void QFxItem::setItemParent(QFxItem *parent)
}
/*!
- \internal
- \property QFxItem::moveToParent
- Playing around with view2view transitions.
- */
-
-/*!
- \internal
- */
-void QFxItem::moveToParent(QFxItem *parent)
-{
- if (parent && itemParent()) {
- QPointF me = itemParent()->mapToScene(QPointF(0,0));
- QPointF them = parent->mapToScene(QPointF(0,0));
-
- QPointF themx = parent->mapToScene(QPointF(1,0));
- QPointF themy = parent->mapToScene(QPointF(0,1));
-
- themx -= them;
- themy -= them;
-
- setItemParent(parent);
-
- // XXX - this is silly and will only work in a few cases
-
- /*
- xDiff = rx * themx_x + ry * themy_x
- yDiff = rx * themx_y + ry * themy_y
- */
-
- qreal rx = 0;
- qreal ry = 0;
- qreal xDiff = them.x() - me.x();
- qreal yDiff = them.y() - me.y();
-
-
- if (themx.x() == 0.) {
- ry = xDiff / themy.x();
- rx = (yDiff - ry * themy.y()) / themx.y();
- } else if (themy.x() == 0.) {
- rx = xDiff / themx.x();
- ry = (yDiff - rx * themx.y()) / themy.y();
- } else if (themx.y() == 0.) {
- ry = yDiff / themy.y();
- rx = (xDiff - ry * themy.x()) / themx.x();
- } else if (themy.y() == 0.) {
- rx = yDiff / themx.y();
- ry = (xDiff - rx * themx.x()) / themy.x();
- } else {
- qreal div = (themy.x() * themx.y() - themy.y() * themx.x());
-
- if (div != 0.)
- rx = (themx.y() * xDiff - themx.x() * yDiff) / div;
-
- if (themy.y() != 0.) ry = (yDiff - rx * themx.y()) / themy.y();
- }
-
- setX(x() - rx);
- setY(y() - ry);
- } else {
- setItemParent(parent);
- }
-}
-
-/*!
Returns the QFxItem parent of this item.
*/
QFxItem *QFxItem::itemParent() const
@@ -1132,14 +1052,6 @@ void QFxItem::keyReleaseEvent(QKeyEvent *event)
}
/*!
- Returns the bounding rectangle of the item in scene coordinates.
-*/
-QRectF QFxItem::sceneBoundingRect() const
-{
- return QRectF(mapToScene(QPointF(0,0)), QSize(width(), height()));
-}
-
-/*!
\qmlproperty string Item::id
This property holds the identifier for the item.
@@ -1156,34 +1068,6 @@ QRectF QFxItem::sceneBoundingRect() const
*/
/*!
- \property QFxItem::id
- This property holds the identifier for the item.
-
- The identifier can be used in bindings and other expressions to
- refer to the item. For example:
-
- \qml
- Text { id: myText; ... }
- Text { text: myText.text }
- \endqml
-
- The identifier is available throughout the \l {components}{component}
- where it is declared. The identifier must be unique in thecomponent.
-*/
-QString QFxItem::id() const
-{
- Q_D(const QFxItem);
- return d->_id;
-}
-
-void QFxItem::setId(const QString &id)
-{
- Q_D(QFxItem);
- setObjectName(id);
- d->_id = id;
-}
-
-/*!
\internal
*/
QFxAnchorLine QFxItem::left() const
@@ -1567,26 +1451,6 @@ void QFxItem::setRotation(qreal rotation)
*/
/*!
- \property QFxItem::opacity
-
- The opacity of the item. Opacity is specified as a number between 0
- (fully transparent) and 1 (fully opaque). The default is 1.
-
- Opacity is an \e inherited attribute. That is, the opacity is
- also applied individually to child items.
-*/
-
-void QFxItem::setOpacity(qreal v)
-{
- if (v == opacity())
- return;
-
- QGraphicsItem::setOpacity(v);
-
- emit opacityChanged();
-}
-
-/*!
Returns a value indicating whether the mouse should
remain with this item.
*/
@@ -1839,50 +1703,6 @@ QList<QFxTransform *> *QFxItem::transform()
return &(d->_transform);
}
-/*!
- Returns true if the item is visible; otherwise returns false.
-
- An item is considered visible if its opacity is not 0.
-*/
-bool QFxItem::isVisible() const
-{
- Q_D(const QFxItem);
- return d->visible;
-}
-
-/*!
- \property QFxItem::visible
-
- This property specifies whether the item is visible or invisible.
-
- Setting visibility to false sets opacity to 0. Setting the
- visibility to true restores the opacity to its previous value.
-
- \sa isVisible()
-*/
-void QFxItem::setVisible(bool visible)
-{
- Q_D(QFxItem);
- if (visible == d->visible)
- return;
-
- d->visible = visible;
- if (visible)
- setOpacity(d->visibleOp);
- else {
- d->visibleOp = opacity();
- setOpacity(0);
- }
-
- emit visibleChanged();
-}
-
-/*! \internal
-*/
-QString QFxItem::propertyInfo() const
-{
- return QString();
-}
/*!
Creates a new child of the given component \a type. The
@@ -2097,8 +1917,9 @@ void QFxItem::childrenChanged()
void QFxItem::setPaintMargin(qreal margin)
{
Q_D(QFxItem);
- if (margin < d->paintmargin)
- update(); // schedule repaint of old boundingRect
+ if (margin == d->paintmargin)
+ return;
+ prepareGeometryChange();
d->paintmargin = margin;
}
@@ -2118,14 +1939,6 @@ void QFxItem::parentChanged(QFxItem *, QFxItem *)
}
/*!
- Returns the item's (0, 0) point relative to its parent.
- */
-QPointF QFxItem::pos() const
-{
- return QPointF(x(),y());
-}
-
-/*!
Returns the item's (0, 0) point mapped to scene coordinates.
*/
QPointF QFxItem::scenePos() const
@@ -2176,50 +1989,6 @@ QPointF QFxItem::transformOriginPoint() const
return d->transformOrigin();
}
-qreal QFxItem::z() const
-{
- return zValue();
-}
-
-void QFxItem::setX(qreal x)
-{
- if (x == this->x())
- return;
-
- qreal oldX = this->x();
-
- QGraphicsItem::setPos(x, y());
-
- geometryChanged(QRectF(this->x(), y(), width(), height()),
- QRectF(oldX, y(), width(), height()));
-}
-
-void QFxItem::setY(qreal y)
-{
- if (y == this->y())
- return;
-
- qreal oldY = this->y();
-
- QGraphicsItem::setPos(x(), y);
-
- geometryChanged(QRectF(x(), this->y(), width(), height()),
- QRectF(x(), oldY, width(), height()));
-}
-
-void QFxItem::setZ(qreal z)
-{
- if (z == this->z())
- return;
-
- if (z < 0)
- setFlag(QGraphicsItem::ItemStacksBehindParent, true);
- else
- setFlag(QGraphicsItem::ItemStacksBehindParent, false);
-
- setZValue(z);
-}
-
qreal QFxItem::width() const
{
Q_D(const QFxItem);
@@ -2235,6 +2004,7 @@ void QFxItem::setWidth(qreal w)
qreal oldWidth = d->width;
+ prepareGeometryChange();
d->width = w;
update();
@@ -2250,6 +2020,7 @@ void QFxItem::setImplicitWidth(qreal w)
qreal oldWidth = d->width;
+ prepareGeometryChange();
d->width = w;
update();
@@ -2278,6 +2049,7 @@ void QFxItem::setHeight(qreal h)
qreal oldHeight = d->height;
+ prepareGeometryChange();
d->height = h;
update();
@@ -2293,6 +2065,7 @@ void QFxItem::setImplicitHeight(qreal h)
qreal oldHeight = d->height;
+ prepareGeometryChange();
d->height = h;
update();
@@ -2306,17 +2079,6 @@ bool QFxItem::heightValid() const
return d->heightValid;
}
-void QFxItem::setPos(const QPointF &point)
-{
- qreal oldX = x();
- qreal oldY = y();
-
- QGraphicsItem::setPos(point);
-
- geometryChanged(QRectF(x(), y(), width(), height()),
- QRectF(oldX, oldY, width(), height()));
-}
-
qreal QFxItem::scale() const
{
Q_D(const QFxItem);
@@ -2340,26 +2102,6 @@ QRect QFxItem::itemBoundingRect()
return boundingRect().toAlignedRect();
}
-QPointF QFxItem::mapFromScene(const QPointF &p) const
-{
- return QGraphicsItem::mapFromScene(p);
-}
-
-QRectF QFxItem::mapFromScene(const QRectF &r) const
-{
- return QGraphicsItem::mapFromScene(r).boundingRect();
-}
-
-QPointF QFxItem::mapToScene(const QPointF &p) const
-{
- return QGraphicsItem::mapToScene(p);
-}
-
-QRectF QFxItem::mapToScene(const QRectF &r) const
-{
- return QGraphicsItem::mapToScene(r).boundingRect();
-}
-
QTransform QFxItem::transform() const
{
Q_D(const QFxItem);
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index 67b60c1..e3f371e 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -48,9 +48,7 @@
#include <QtDeclarative/qfxanchors.h>
#include <QtDeclarative/qfxglobal.h>
#include <QtDeclarative/qml.h>
-#include <QtDeclarative/qfxscalegrid.h>
#include <QtDeclarative/qmlcomponent.h>
-#include <QtDeclarative/qmlstate.h>
#include <QtGui/qgraphicsitem.h>
#include <QtGui/qfont.h>
@@ -100,8 +98,6 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta
Q_INTERFACES(QmlParserStatus)
Q_PROPERTY(QFxItem * parent READ itemParent WRITE setItemParent NOTIFY parentChanged DESIGNABLE false FINAL)
- Q_PROPERTY(QFxItem * moveToParent READ itemParent WRITE moveToParent NOTIFY parentChanged DESIGNABLE false)
- Q_PROPERTY(QString id READ id WRITE setId)
Q_PROPERTY(QmlList<QFxItem *>* children READ children DESIGNABLE false)
Q_PROPERTY(QmlList<QObject *>* resources READ resources DESIGNABLE false)
Q_PROPERTY(QFxAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL)
@@ -110,11 +106,8 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta
Q_PROPERTY(QmlList<QmlState *>* states READ states DESIGNABLE false)
Q_PROPERTY(QmlList<QmlTransition *>* transitions READ transitions DESIGNABLE false)
Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
- Q_PROPERTY(QUrl qml READ qml WRITE setQml NOTIFY qmlChanged)
- Q_PROPERTY(QFxItem *qmlItem READ qmlItem NOTIFY qmlChanged)
- Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged FINAL)
- Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged FINAL)
- Q_PROPERTY(qreal z READ z WRITE setZ FINAL)
+ Q_PROPERTY(QUrl qml READ qml WRITE setQml NOTIFY qmlChanged) // ### name? Move to own class?
+ Q_PROPERTY(QFxItem *qmlItem READ qmlItem NOTIFY qmlChanged) // ### see above
Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged FINAL)
Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged FINAL)
Q_PROPERTY(QFxAnchorLine left READ left CONSTANT FINAL)
@@ -125,19 +118,17 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta
Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter CONSTANT FINAL)
Q_PROPERTY(QFxAnchorLine baseline READ baseline CONSTANT FINAL)
Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged)
- Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
- Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
- Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged)
- Q_PROPERTY(bool clip READ clip WRITE setClip)
+ Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged) // ## remove me
+ Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) // ### remove me
+ Q_PROPERTY(bool clip READ clip WRITE setClip) // ### move to QGI/QGO, NOTIFY
Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL)
Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged FINAL)
- Q_PROPERTY(QList<QFxTransform *>* transform READ transform)
- Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
- Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin)
+ Q_PROPERTY(QList<QFxTransform *>* transform READ transform) // ## QGI/QGO
+ Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin) // ### move to QGI
Q_ENUMS(TransformOrigin)
Q_CLASSINFO("DefaultProperty", "data")
- typedef QHash<QString, QFxItem *> QmlChildren;
+ typedef QHash<QString, QFxItem *> QmlChildren; // ###
public:
enum Option { NoOption = 0x00000000,
@@ -161,14 +152,9 @@ public:
QFxItem(QFxItem *parent = 0);
virtual ~QFxItem();
- QFxItem *itemParent() const;
+ QFxItem *itemParent() const; // ### remove me
QFxItem *parentItem() const;
- void setItemParent(QFxItem *parent);
-
- void moveToParent(QFxItem *parent);
-
- QString id() const;
- void setId(const QString &);
+ void setItemParent(QFxItem *parent); // ## setParentItem
QmlList<QObject *> *data();
QmlList<QFxItem *> *children();
@@ -202,21 +188,12 @@ public:
qreal scale() const;
void setScale(qreal);
- void setOpacity(qreal);
-
QList<QFxTransform *> *transform();
- bool isVisible() const;
- void setVisible(bool);
-
- virtual QString propertyInfo() const;
-
bool isClassComplete() const;
bool isComponentComplete() const;
- QRectF sceneBoundingRect() const;
-
- void updateTransform();
+ void updateTransform(); // ### private!
bool keepMouseGrab() const;
void setKeepMouseGrab(bool);
@@ -224,23 +201,16 @@ public:
Options options() const;
void setOptions(Options, bool set = true);
- qreal z() const;
- QPointF pos() const;
- void setX(qreal);
- void setY(qreal);
- virtual void setZ(qreal);
- void setPos(const QPointF &);
-
qreal width() const;
void setWidth(qreal);
void setImplicitWidth(qreal);
- bool widthValid() const;
+ bool widthValid() const; // ### better name?
qreal height() const;
void setHeight(qreal);
void setImplicitHeight(qreal);
- bool heightValid() const;
+ bool heightValid() const; // ### better name?
- QPointF scenePos() const;
+ QPointF scenePos() const; // ### remove me
TransformOrigin transformOrigin() const;
void setTransformOrigin(TransformOrigin);
@@ -248,19 +218,14 @@ public:
void setParent(QFxItem *);
- QRect itemBoundingRect();
+ QRect itemBoundingRect(); // ### remove me
void setPaintMargin(qreal margin);
QRectF boundingRect() const;
virtual void paintContents(QPainter &);
- QPointF mapFromScene(const QPointF &) const;
- QRectF mapFromScene(const QRectF &) const;
- QPointF mapToScene(const QPointF &) const;
- QRectF mapToScene(const QRectF &) const;
-
- QTransform transform() const;
- void setTransform(const QTransform &);
+ QTransform transform() const; // ### remove me
+ void setTransform(const QTransform &); // ### remove me
QFxItem *mouseGrabberItem() const;
@@ -271,7 +236,7 @@ public:
bool hasActiveFocus() const;
- static QPixmap string(const QString &, const QColor & = Qt::black, const QFont & = QFont());
+ static QPixmap string(const QString &, const QColor & = Qt::black, const QFont & = QFont()); // ### remove me, make private for now
QVariant inputMethodQuery(Qt::InputMethodQuery query) const; //### for KeyProxy
@@ -292,8 +257,6 @@ Q_SIGNALS:
void keyRelease(QFxKeyEvent *event);
void rotationChanged();
void scaleChanged();
- void opacityChanged();
- void visibleChanged();
void qmlChanged();
void newChildCreated(const QString &url, QScriptValue);
@@ -326,6 +289,7 @@ protected:
QFxItem(QFxItemPrivate &dd, QFxItem *parent = 0);
private:
+ // ### public?
QFxAnchorLine left() const;
QFxAnchorLine right() const;
QFxAnchorLine horizontalCenter() const;
@@ -334,6 +298,7 @@ private:
QFxAnchorLine verticalCenter() const;
QFxAnchorLine baseline() const;
+ // ### move to d-pointer
void init(QFxItem *parent);
friend class QmlStatePrivate;
friend class QFxAnchors;
@@ -343,6 +308,7 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QFxItem::Options)
+// ### move to QGO
template<typename T>
T qobject_cast(QGraphicsItem *item)
{
diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h
index eddeb9b..029b8b0 100644
--- a/src/declarative/fx/qfxitem_p.h
+++ b/src/declarative/fx/qfxitem_p.h
@@ -54,6 +54,7 @@
//
#include <QtDeclarative/qfxitem.h>
+#include <QtDeclarative/qmlstate.h>
#include <private/qmlnullablevalue_p.h>
#include <QtDeclarative/qml.h>
#include <QtDeclarative/qmlcontext.h>
@@ -76,7 +77,7 @@ public:
: _anchors(0), _contents(0), qmlItem(0), _qmlcomp(0),
_baselineOffset(0), _rotation(0.),
_classComplete(true), _componentComplete(true), _keepMouse(false),
- visible(true), _anchorLines(0), visibleOp(1),
+ _anchorLines(0),
_stateGroup(0), canvas(0), origin(QFxItem::TopLeft),
options(QFxItem::NoOption),
widthValid(false), heightValid(false), width(0), height(0),
@@ -93,8 +94,9 @@ public:
q->setItemParent(parent);
_baselineOffset.invalidate();
q->setAcceptedMouseButtons(Qt::NoButton);
- q->setFlag(QGraphicsItem::ItemHasNoContents, true);
- q->setFlag(QGraphicsItem::ItemIsFocusable, true);
+ q->setFlags(QGraphicsItem::ItemHasNoContents |
+ QGraphicsItem::ItemIsFocusable |
+ QGraphicsItem::ItemNegativeZStacksBehindParent);
mouseSetsFocus = false;
}
@@ -151,7 +153,6 @@ public:
bool _classComplete:1;
bool _componentComplete:1;
bool _keepMouse:1;
- bool visible:1;
QmlChildren _qmlChildren;
@@ -173,8 +174,6 @@ public:
return _anchorLines;
}
- float visibleOp;
-
QmlStateGroup *states();
QmlStateGroup *_stateGroup;
@@ -208,6 +207,14 @@ public:
QGraphicsItemPrivate::setFocusItemForArea(b);
q->focusChanged(b);
}
+
+ virtual void setPosHelper(const QPointF &pos)
+ {
+ Q_Q(QFxItem);
+ QRectF oldGeometry(this->pos.x(), this->pos.y(), width, height);
+ QGraphicsItemPrivate::setPosHelper(pos);
+ q->geometryChanged(QRectF(this->pos.x(), this->pos.y(), width, height), oldGeometry);
+ }
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index 50564fb..3515b78 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -423,7 +423,7 @@ FxListItem *QFxListViewPrivate::createItem(int modelIndex)
}
// complete
model->completeItem();
- listItem->item->setZ(modelIndex + 1);
+ listItem->item->setZValue(modelIndex + 1);
listItem->item->setParent(q->viewport());
if (orient == Qt::Vertical)
QObject::connect(listItem->item, SIGNAL(heightChanged()), q, SLOT(itemResized()));
diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp
index 7ff3361..a4055eb 100644
--- a/src/declarative/fx/qfxpainteditem.cpp
+++ b/src/declarative/fx/qfxpainteditem.cpp
@@ -224,11 +224,11 @@ void QFxPaintedItem::paintContents(QPainter &p)
p.setRenderHints(QPainter::SmoothPixmapTransform, true);
QRectF clipf = p.clipRegion().boundingRect();
if (clipf.isEmpty())
- clipf = mapToScene(content); // ### Inefficient: Maps toScene and then fromScene
+ clipf = mapToScene(content).boundingRect(); // ### Inefficient: Maps toScene and then fromScene
else
- clipf = mapToScene(clipf);
+ clipf = mapToScene(clipf).boundingRect();
- const QRect clip = mapFromScene(clipf).toRect();
+ const QRect clip = mapFromScene(clipf).boundingRect().toRect();
QRegion topaint(clip);
topaint &= content;
diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp
index 3c61050..4f6fddd 100644
--- a/src/declarative/fx/qfxpathview.cpp
+++ b/src/declarative/fx/qfxpathview.cpp
@@ -411,7 +411,7 @@ void QFxPathView::mousePressEvent(QGraphicsSceneMouseEvent *event)
int idx = 0;
for (; idx < d->items.count(); ++idx) {
QRectF rect = d->items.at(idx)->boundingRect();
- rect = d->items.at(idx)->mapToScene(rect);
+ rect = d->items.at(idx)->mapToScene(rect).boundingRect();
if (rect.contains(scenePoint))
break;
}
@@ -495,7 +495,7 @@ bool QFxPathView::sendMouseEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QFxPathView);
QGraphicsSceneMouseEvent mouseEvent(event->type());
- QRectF myRect = mapToScene(QRectF(0, 0, width(), height()));
+ QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect();
QFxItem *grabber = static_cast<QFxItem*>(mouseGrabberItem());
if ((d->stealMouse || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) {
mouseEvent.setAccepted(false);
@@ -581,7 +581,7 @@ void QFxPathViewPrivate::regenerate()
return;
}
items.append(item);
- item->setZ(i);
+ item->setZValue(i);
}
q->refill();
}
@@ -639,7 +639,7 @@ void QFxPathView::refill()
d->firstIndex %= d->model->count();
int index = (d->firstIndex + d->items.count())%d->model->count();
d->items << d->getItem(index);
- d->items.last()->setZ(wrapIndex);
+ d->items.last()->setZValue(wrapIndex);
d->pathOffset++;
d->pathOffset=d->pathOffset % d->items.count();
}
@@ -652,7 +652,7 @@ void QFxPathView::refill()
if (d->firstIndex < 0)
d->firstIndex = d->model->count() - 1;
d->items.prepend(d->getItem(d->firstIndex));
- d->items.first()->setZ(d->firstIndex);
+ d->items.first()->setZValue(d->firstIndex);
d->pathOffset--;
if (d->pathOffset < 0)
d->pathOffset = d->items.count() - 1;
@@ -675,7 +675,7 @@ void QFxPathView::itemsInserted(int modelIndex, int count)
if (d->pathItems == -1) {
for (int i = 0; i < count; ++i) {
QFxItem *item = d->getItem(modelIndex + i);
- item->setZ(modelIndex + i);
+ item->setZValue(modelIndex + i);
d->items.insert(modelIndex + i, item);
}
refill();
diff --git a/src/declarative/fx/qfxpixmap.cpp b/src/declarative/fx/qfxpixmap.cpp
index ac8a701..e4d79f4 100644
--- a/src/declarative/fx/qfxpixmap.cpp
+++ b/src/declarative/fx/qfxpixmap.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qfxpixmap.h"
+#include <QImageReader>
#include <QHash>
#include <QNetworkReply>
#include <QPixmapCache>
@@ -124,8 +125,30 @@ QFxPixmap::QFxPixmap(const QUrl &url)
if ((*iter)->reply->error()) {
qWarning() << "Network error loading" << url << (*iter)->reply->errorString();
} else {
+ QImageReader imgio((*iter)->reply);
+
+//#define QT_TEST_SCALED_SIZE
+#ifdef QT_TEST_SCALED_SIZE
+ /*
+ Some mechanism is needed for loading images at a limited size, especially
+ for remote images. Loading only thumbnails of remote progressive JPEG
+ images can be efficient. (Qt jpeg handler does not do so currently)
+ */
+
+ QSize limit(60,60);
+ QSize sz = imgio.size();
+ if (sz.width() > limit.width() || sz.height() > limit.height()) {
+ sz.scale(limit,Qt::KeepAspectRatio);
+ imgio.setScaledSize(sz);
+ }
+#endif
+
QImage img;
- if (img.load((*iter)->reply, 0)) {
+ if (imgio.read(&img)) {
+#ifdef QT_TEST_SCALED_SIZE
+ if (!sz.isValid())
+ img = img.scaled(limit,Qt::KeepAspectRatio);
+#endif
d->pixmap = QPixmap::fromImage(img);
QPixmapCache::insert(key, d->pixmap);
} else {
diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp
index 2bae53f..3d36bf3 100644
--- a/src/declarative/fx/qfxtext.cpp
+++ b/src/declarative/fx/qfxtext.cpp
@@ -575,12 +575,6 @@ void QFxTextPrivate::updateSize()
// ### text layout handling should be profiled and optimized as needed
// what about QStackTextEngine engine(tmp, d->font.font()); QTextLayout textLayout(&engine);
-QString QFxText::propertyInfo() const
-{
- Q_D(const QFxText);
- return QChar(QLatin1Char('\"')) + d->text + QChar(QLatin1Char('\"'));
-}
-
void QFxTextPrivate::drawOutline()
{
QPixmap img = QPixmap(imgCache.size());
diff --git a/src/declarative/fx/qfxtext.h b/src/declarative/fx/qfxtext.h
index b7ec333..a02b76b 100644
--- a/src/declarative/fx/qfxtext.h
+++ b/src/declarative/fx/qfxtext.h
@@ -125,8 +125,6 @@ public:
bool smoothTransform() const;
void setSmoothTransform(bool);
- virtual QString propertyInfo() const;
-
void paintContents(QPainter &p);
virtual void componentComplete();
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index f9cde7c..4a8085b 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -679,15 +679,6 @@ void QFxTextEdit::geometryChanged(const QRectF &newGeometry,
}
/*!
- \internal
-*/
-QString QFxTextEdit::propertyInfo() const
-{
- Q_D(const QFxTextEdit);
- return QChar(QLatin1Char('\"')) + d->text + QChar(QLatin1Char('\"'));
-}
-
-/*!
Ensures any delayed caching or data loading the class
needs to performed is complete.
*/
diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h
index 77fac29..132b474 100644
--- a/src/declarative/fx/qfxtextedit.h
+++ b/src/declarative/fx/qfxtextedit.h
@@ -161,8 +161,6 @@ public:
qreal textMargin() const;
void setTextMargin(qreal margin);
- virtual QString propertyInfo() const;
-
virtual void componentComplete();
/* FROM EDIT */
diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp
index 1b15a48..3d336c5 100644
--- a/src/declarative/fx/qfxvisualitemmodel.cpp
+++ b/src/declarative/fx/qfxvisualitemmodel.cpp
@@ -51,6 +51,7 @@
#include "qmlopenmetaobject.h"
#include "qmllistaccessor.h"
#include "qfxvisualitemmodel.h"
+#include "private/qguard_p.h"
#include <QtCore/qdebug.h>
QML_DECLARE_TYPE(QListModelInterface)
@@ -64,9 +65,9 @@ class QFxVisualItemModelPrivate : public QObjectPrivate
public:
QFxVisualItemModelPrivate(QmlContext *);
- QListModelInterface *m_listModelInterface;
- QAbstractItemModel *m_abstractItemModel;
- QFxVisualItemModel *m_visualItemModel;
+ QGuard<QListModelInterface> m_listModelInterface;
+ QGuard<QAbstractItemModel> m_abstractItemModel;
+ QGuard<QFxVisualItemModel> m_visualItemModel;
QString m_part;
QmlComponent *m_delegate;
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index 42b8d2c..6c23198 100644
--- a/src/declarative/fx/qfxwebview.cpp
+++ b/src/declarative/fx/qfxwebview.cpp
@@ -507,11 +507,6 @@ void QFxWebView::drawContents(QPainter *p, const QRect &r)
page()->mainFrame()->render(p,r);
}
-QString QFxWebView::propertyInfo() const
-{
- return page()->mainFrame()->url().toString();
-}
-
static QMouseEvent *sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *e)
{
QEvent::Type t;
diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h
index ab20281..7f22439 100644
--- a/src/declarative/fx/qfxwebview.h
+++ b/src/declarative/fx/qfxwebview.h
@@ -139,8 +139,6 @@ public:
QAction *forwardAction() const;
QAction *stopAction() const;
- virtual QString propertyInfo() const;
-
QWebPage *page() const;
void setPage(QWebPage *page);
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri
index da3574c..1021dec 100644
--- a/src/declarative/qml/qml.pri
+++ b/src/declarative/qml/qml.pri
@@ -5,6 +5,7 @@ SOURCES += qml/qmlparser.cpp \
qml/qmlexpression.cpp \
qml/qmlbinding.cpp \
qml/qmlmetaproperty.cpp \
+ qml/qmlbindablecomponent.cpp \
qml/qmlcomponent.cpp \
qml/qmlcontext.cpp \
qml/qmlcustomparser.cpp \
@@ -37,6 +38,8 @@ HEADERS += qml/qmlparser_p.h \
qml/qmlbinding.h \
qml/qmlbinding_p.h \
qml/qmlmetaproperty.h \
+ qml/qmlbindablecomponent.h \
+ qml/qmlbindablecomponent_p.h \
qml/qmlcomponent.h \
qml/qmlcomponent_p.h \
qml/qmlcustomparser_p.h \
diff --git a/src/declarative/qml/qmlbindablecomponent.cpp b/src/declarative/qml/qmlbindablecomponent.cpp
new file mode 100644
index 0000000..ed9924a
--- /dev/null
+++ b/src/declarative/qml/qmlbindablecomponent.cpp
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmlbindablecomponent.h"
+#include "qmlbindablecomponent_p.h"
+#include "qmlcomponent.h"
+
+QT_BEGIN_NAMESPACE
+QmlBindableComponent::QmlBindableComponent(QmlEngine *engine, QObject *parent)
+ : QmlComponent(*(new QmlBindableComponentPrivate), parent)
+{
+ Q_D(QmlBindableComponent);
+ d->engine = engine;
+ connect(this, SIGNAL(statusChanged(QmlComponent::Status)),
+ this, SLOT(statusChange(QmlComponent::Status)));
+}
+
+QmlBindableComponent::QmlBindableComponent(QmlEngine *engine, const QUrl &url, QObject *parent)
+ : QmlComponent(*(new QmlBindableComponentPrivate), parent)
+{
+ Q_D(QmlBindableComponent);
+ d->engine = engine;
+ loadUrl(url);
+ connect(this, SIGNAL(statusChanged(QmlComponent::Status)),
+ this, SLOT(statusChange(QmlComponent::Status)));
+}
+
+void QmlBindableComponent::setContext(QmlContext* c)
+{
+ Q_D(QmlBindableComponent);
+ d->ctxt =c;
+}
+/*!
+ Create a script object instance from this component. Returns a null
+ script object if creation failed. It will create the instance in the
+ same context that it was created it. QmlBindableComponent is only
+ meant to be created from with script - C++ developers should just use
+ QmlComponent directly.
+
+ Similar to QmlComponent::create(), but creates an object suitable
+ for usage within scripts.
+*/
+QScriptValue QmlBindableComponent::createObject()
+{
+ Q_D(QmlBindableComponent);
+ QObject* ret = create(d->ctxt);
+ return QmlEngine::qmlScriptObject(ret, d->engine);
+}
+
+void QmlBindableComponent::statusChange(QmlComponent::Status newStatus)
+{
+ Q_D(QmlBindableComponent);
+ if(newStatus == d->prevStatus)
+ return;
+ if(newStatus == QmlComponent::Null || d->prevStatus == QmlComponent::Null)
+ emit isNullChanged();
+ if(newStatus == QmlComponent::Ready || d->prevStatus == QmlComponent::Ready)
+ emit isReadyChanged();
+ if(newStatus == QmlComponent::Loading || d->prevStatus == QmlComponent::Loading)
+ emit isLoadingChanged();
+ if(newStatus == QmlComponent::Error || d->prevStatus == QmlComponent::Error)
+ emit isErrorChanged();
+ d->prevStatus = newStatus;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlbindablecomponent.h b/src/declarative/qml/qmlbindablecomponent.h
new file mode 100644
index 0000000..2b3e0ce
--- /dev/null
+++ b/src/declarative/qml/qmlbindablecomponent.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLBINDABLECOMPONENT_H
+#define QMLBINDABLECOMPONENT_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qstring.h>
+#include <QtDeclarative/qfxglobal.h>
+#include <QtDeclarative/qml.h>
+#include <QtDeclarative/qmlcomponent.h>
+#include <QtDeclarative/qmlerror.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QmlBindableComponentPrivate;
+class QmlEngine;
+class QmlContext;
+class Q_DECLARATIVE_EXPORT QmlBindableComponent : public QmlComponent
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QmlBindableComponent)
+ friend class QmlEngine;
+public:
+ QmlBindableComponent(QmlEngine *, const QUrl &url, QObject *parent = 0);
+ QmlBindableComponent(QmlEngine *, QObject *parent=0);
+ Q_PROPERTY(bool isNull READ isNull NOTIFY isNullChanged);
+ Q_PROPERTY(bool isReady READ isReady NOTIFY isReadyChanged);
+ Q_PROPERTY(bool isError READ isError NOTIFY isErrorChanged);
+ Q_PROPERTY(bool isLoading READ isLoading NOTIFY isLoadingChanged);
+
+ Q_INVOKABLE QScriptValue createObject();
+
+ void setContext(QmlContext* c);
+Q_SIGNALS:
+ void isNullChanged();
+ void isErrorChanged();
+ void isReadyChanged();
+ void isLoadingChanged();
+private slots:
+ void statusChange(QmlComponent::Status newStatus);
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QmlBindableComponent)
+
+QT_END_HEADER
+#endif
diff --git a/src/declarative/qml/qmlbindablecomponent_p.h b/src/declarative/qml/qmlbindablecomponent_p.h
new file mode 100644
index 0000000..79335df
--- /dev/null
+++ b/src/declarative/qml/qmlbindablecomponent_p.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLBINDABLECOMPONENT_P_H
+#define QMLBINDABLECOMPONENT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmlcomponent.h"
+#include "qmlbindablecomponent.h"
+#include "qmlcomponent_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QmlContext;
+class QmlBindableComponentPrivate : public QmlComponentPrivate
+{
+ Q_DECLARE_PUBLIC(QmlBindableComponent)
+public:
+ QmlBindableComponentPrivate() : QmlComponentPrivate(),
+ prevStatus(QmlBindableComponent::Null), ctxt(0)
+ { }
+
+ QmlComponent::Status prevStatus;
+ QmlContext* ctxt;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/declarative/qml/qmlbinding.cpp b/src/declarative/qml/qmlbinding.cpp
index 57c1187..431dd66 100644
--- a/src/declarative/qml/qmlbinding.cpp
+++ b/src/declarative/qml/qmlbinding.cpp
@@ -52,7 +52,7 @@ Q_DECLARE_METATYPE(QList<QObject *>);
QT_BEGIN_NAMESPACE
-DEFINE_BOOL_CONFIG_OPTION(scriptWarnings, QML_SCRIPT_WARNINGS);
+QML_DEFINE_NOCREATE_TYPE(QmlBinding);
QmlBindingPrivate::QmlBindingPrivate()
: inited(false), updating(false), enabled(true), mePtr(0)
diff --git a/src/declarative/qml/qmlbinding.h b/src/declarative/qml/qmlbinding.h
index 5f6d6f4..c2182d5 100644
--- a/src/declarative/qml/qmlbinding.h
+++ b/src/declarative/qml/qmlbinding.h
@@ -54,7 +54,6 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QmlExpression;
class QmlContext;
class QmlBindingPrivate;
class Q_DECLARATIVE_EXPORT QmlBinding : public QmlExpression
@@ -84,10 +83,10 @@ private:
Q_DECLARE_PRIVATE(QmlBinding)
};
-Q_DECLARE_METATYPE(QmlBinding*);
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QmlBinding);
+
QT_END_HEADER
#endif // QMLBINDING_H
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index 4e39d7f..0fdba64 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -431,23 +431,6 @@ QmlComponent::QmlComponent(QmlComponentPrivate &dd, QObject *parent)
{
}
-/*!
- Create a script object instance from this component. Returns a null
- script object if creation failed. It will create the instance in the
- engine's \l {QmlEngine::rootContext()}{root context}.
-
- Similar to QmlComponent::create(), but creates an object suitable
- for usage within scripts.
-*/
-QScriptValue QmlComponent::createObject()
-{
- Q_D(QmlComponent);
- QObject* ret = create();
- if(ret)
- return QmlEngine::qmlScriptObject(ret, d->engine);
- else
- return d->engine->scriptEngine()->nullValue();
-}
/*!
Create an object instance from this component. Returns 0 if creation
diff --git a/src/declarative/qml/qmlcomponent.h b/src/declarative/qml/qmlcomponent.h
index 9c712df..45b26eb 100644
--- a/src/declarative/qml/qmlcomponent.h
+++ b/src/declarative/qml/qmlcomponent.h
@@ -77,17 +77,16 @@ public:
enum Status { Null, Ready, Loading, Error };
Status status() const;
- Q_INVOKABLE bool isNull() const;
- Q_INVOKABLE bool isReady() const;
- Q_INVOKABLE bool isError() const;
- Q_INVOKABLE bool isLoading() const;
+ bool isNull() const;
+ bool isReady() const;
+ bool isError() const;
+ bool isLoading() const;
QList<QmlError> errors() const;
Q_INVOKABLE QString errorsString() const;
QUrl url() const;
- Q_INVOKABLE QScriptValue createObject();
virtual QObject *create(QmlContext *context = 0);
virtual QObject *beginCreate(QmlContext *);
virtual void completeCreate();
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 75ff284..6549e5c 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -71,6 +71,7 @@
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdir.h>
#include <qmlcomponent.h>
+#include <qmlbindablecomponent.h>
#include "private/qmlmetaproperty_p.h"
#include <private/qmlbinding_p.h>
#include <private/qmlvme_p.h>
@@ -601,19 +602,20 @@ QScriptValue QmlEngine::qmlScriptObject(QObject* object, QmlEngine* engine)
*/
QScriptValue QmlEngine::createComponent(QScriptContext *ctxt, QScriptEngine *engine)
{
- QmlComponent* c;
+ QmlBindableComponent* c;
QmlEngine* activeEngine = qobject_cast<QmlEngine*>(
engine->globalObject().property(QLatin1String("qmlEngine")).toQObject());
+ QmlContext* context =activeEngine->d_func()->currentExpression->context();
if(ctxt->argumentCount() != 1 || !activeEngine){
- c = new QmlComponent(activeEngine);
+ c = new QmlBindableComponent(activeEngine);
}else{
- QUrl url = QUrl(activeEngine->d_func()->currentExpression->context()
- ->resolvedUrl(ctxt->argument(0).toString()));
+ QUrl url = QUrl(context->resolvedUrl(ctxt->argument(0).toString()));
if(!url.isValid()){
url = QUrl(ctxt->argument(0).toString());
}
- c = new QmlComponent(activeEngine, url, activeEngine);
+ c = new QmlBindableComponent(activeEngine, url, activeEngine);
}
+ c->setContext(context);
return engine->newQObject(c);
}
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index ff070c1..7d9e30f 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -1128,54 +1128,39 @@ void QmlParentChangeAction::transition(QmlStateActions &actions,
TransitionDirection direction)
{
Q_D(QmlParentChangeAction);
+ Q_UNUSED(modified);
Q_UNUSED(direction);
struct QmlParentChangeActionData : public QAbstractAnimationAction
{
QmlStateActions actions;
+ bool reverse;
virtual void doAction()
{
for (int ii = 0; ii < actions.count(); ++ii) {
const Action &action = actions.at(ii);
- QmlBehaviour::_ignore = true;
- action.property.write(action.toValue);
- QmlBehaviour::_ignore = false;
+ if (reverse)
+ action.event->reverse();
+ else
+ action.event->execute();
}
}
};
QmlParentChangeActionData *data = new QmlParentChangeActionData;
- QSet<QObject *> objs;
for (int ii = 0; ii < actions.count(); ++ii) {
Action &action = actions[ii];
- QObject *obj = action.property.object();
- QString propertyName = action.property.name();
-
- if ((!target() || target() == obj) && propertyName == QString(QLatin1String("moveToParent"))) {
- objs.insert(obj);
+ //### should we still use target to filter?
+ if (action.event /*&& action.event->name() == d->parentChange*/) { //###
Action myAction = action;
-
- /*if (d->value.isValid())
- myAction.toValue = d->value;*/
-
- modified << action.property;
+ data->reverse = action.reverseEvent;
data->actions << myAction;
- action.fromValue = myAction.toValue;
+ action.actionDone = true;
}
}
- /*if (d->value.isValid() && target() && !objs.contains(target())) {
- QObject *obj = target();
- for (int jj = 0; jj < props.count(); ++jj) {
- Action myAction;
- myAction.property = QmlMetaProperty(obj, props.at(jj));
- myAction.toValue = d->value;
- data->actions << myAction;
- }
- }*/
-
if (data->actions.count()) {
d->cpa->setAnimAction(data, QAbstractAnimation::DeleteWhenStopped);
} else {
diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlfollow.cpp
index 1e6fea2..63b6307 100644
--- a/src/declarative/util/qmlfollow.cpp
+++ b/src/declarative/util/qmlfollow.cpp
@@ -345,8 +345,7 @@ void QmlFollow::setDamping(qreal damping)
to 0 to be considered equal to zero. This will depend on the usage of the value.
For pixel positions, 0.25 would suffice. For scale, 0.005 will suffice.
- The default is 0.01. Small performance improvements can result in tuning this
- value.
+ The default is 0.01. Tuning this value can provide small performance improvements.
*/
qreal QmlFollow::epsilon() const
{
diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp
index 73ea9c2..2c44c86 100644
--- a/src/declarative/util/qmlstate.cpp
+++ b/src/declarative/util/qmlstate.cpp
@@ -54,14 +54,14 @@ QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
Action::Action()
-: restore(true), actionDone(false), fromBinding(0), toBinding(0), event(0),
+: restore(true), actionDone(false), reverseEvent(false), fromBinding(0), toBinding(0), event(0),
specifiedObject(0)
{
}
Action::Action(QObject *target, const QString &propertyName,
const QVariant &value)
-: restore(true), actionDone(false), toValue(value), fromBinding(0),
+: restore(true), actionDone(false), reverseEvent(false), toValue(value), fromBinding(0),
toBinding(0), event(0), specifiedObject(target),
specifiedProperty(propertyName)
{
@@ -83,6 +83,15 @@ void ActionEvent::execute()
{
}
+bool ActionEvent::isReversable()
+{
+ return false;
+}
+
+void ActionEvent::reverse()
+{
+}
+
/*!
\internal
*/
@@ -345,23 +354,33 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever
for (int ii = 0; ii < applyList.count(); ++ii) {
Action &action = applyList[ii];
- if (action.event)
- continue;
-
- action.fromBinding = action.property.binding();
-
bool found = false;
+
int jj;
- for (jj = 0; jj < d->revertList.count(); ++jj) {
- if (d->revertList.at(jj).property == action.property) {
- found = true;
- break;
+ if (action.event) {
+ if (!action.event->isReversable())
+ continue;
+ for (jj = 0; jj < d->revertList.count(); ++jj) {
+ ActionEvent *event = d->revertList.at(jj).event;
+ if (event && event->name() == action.event->name()) {
+ found = true;
+ break;
+ }
+ }
+ } else {
+ action.fromBinding = action.property.binding();
+
+ for (jj = 0; jj < d->revertList.count(); ++jj) {
+ if (d->revertList.at(jj).property == action.property) {
+ found = true;
+ break;
+ }
}
}
if (!found) {
if (!action.restore) {
- action.deleteFromBinding();
+ action.deleteFromBinding();
} else {
// Only need to revert the applyList action if the previous
// state doesn't have a higher priority revert already
@@ -394,8 +413,10 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever
a.fromValue = cur;
a.toValue = d->revertList.at(ii).value;
a.toBinding = d->revertList.at(ii).binding;
- a.specifiedObject = d->revertList.at(ii).specifiedObject; //###
+ a.specifiedObject = d->revertList.at(ii).specifiedObject;
a.specifiedProperty = d->revertList.at(ii).specifiedProperty;
+ a.event = d->revertList.at(ii).event;
+ a.reverseEvent = d->revertList.at(ii).reverseEvent;
applyList << a;
// Store these special reverts in the reverting list
d->reverting << d->revertList.at(ii).property;
diff --git a/src/declarative/util/qmlstate.h b/src/declarative/util/qmlstate.h
index 90649a1..1c0d67f 100644
--- a/src/declarative/util/qmlstate.h
+++ b/src/declarative/util/qmlstate.h
@@ -63,6 +63,7 @@ public:
bool restore:1;
bool actionDone:1;
+ bool reverseEvent:1;
QmlMetaProperty property;
QVariant fromValue;
@@ -84,6 +85,8 @@ public:
virtual ~ActionEvent();
virtual QString name() const;
virtual void execute();
+ virtual bool isReversable();
+ virtual void reverse();
};
class QmlStateGroup;
diff --git a/src/declarative/util/qmlstate_p.h b/src/declarative/util/qmlstate_p.h
index 73e2377..b601b57 100644
--- a/src/declarative/util/qmlstate_p.h
+++ b/src/declarative/util/qmlstate_p.h
@@ -69,12 +69,15 @@ public:
property = a.property;
specifiedObject = a.specifiedObject;
specifiedProperty = a.specifiedProperty;
+ event = a.event;
if (state == StartState) {
value = a.fromValue;
binding = property.binding();
+ reverseEvent = true;
} else {
value = a.toValue;
binding = a.toBinding;
+ reverseEvent = false;
}
}
@@ -83,6 +86,8 @@ public:
QmlBinding *binding;
QObject *specifiedObject;
QString specifiedProperty;
+ ActionEvent *event;
+ bool reverseEvent;
};
class QmlStatePrivate : public QObjectPrivate
diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp
index 8d6abe6..dc7fef6 100644
--- a/src/declarative/util/qmlstateoperations.cpp
+++ b/src/declarative/util/qmlstateoperations.cpp
@@ -52,12 +52,70 @@ QT_BEGIN_NAMESPACE
class QmlParentChangePrivate : public QObjectPrivate
{
public:
- QmlParentChangePrivate() : target(0), parent(0) {}
+ QmlParentChangePrivate() : target(0), parent(0), origParent(0) {}
- QObject *target;
- QObject *parent;
+ QFxItem *target;
+ QFxItem *parent;
+ QFxItem *origParent;
+
+ void doChange(QFxItem *targetParent);
};
+void QmlParentChangePrivate::doChange(QFxItem *targetParent)
+{
+ if (targetParent && target && target->itemParent()) {
+ QPointF me = target->itemParent()->mapToScene(QPointF(0,0));
+ QPointF them = targetParent->mapToScene(QPointF(0,0));
+
+ QPointF themx = targetParent->mapToScene(QPointF(1,0));
+ QPointF themy = targetParent->mapToScene(QPointF(0,1));
+
+ themx -= them;
+ themy -= them;
+
+ target->setItemParent(targetParent);
+
+ // XXX - this is silly and will only work in a few cases
+
+ /*
+ xDiff = rx * themx_x + ry * themy_x
+ yDiff = rx * themx_y + ry * themy_y
+ */
+
+ qreal rx = 0;
+ qreal ry = 0;
+ qreal xDiff = them.x() - me.x();
+ qreal yDiff = them.y() - me.y();
+
+
+ if (themx.x() == 0.) {
+ ry = xDiff / themy.x();
+ rx = (yDiff - ry * themy.y()) / themx.y();
+ } else if (themy.x() == 0.) {
+ rx = xDiff / themx.x();
+ ry = (yDiff - rx * themx.y()) / themy.y();
+ } else if (themx.y() == 0.) {
+ ry = yDiff / themy.y();
+ rx = (xDiff - ry * themy.x()) / themx.x();
+ } else if (themy.y() == 0.) {
+ rx = yDiff / themx.y();
+ ry = (xDiff - rx * themx.x()) / themy.x();
+ } else {
+ qreal div = (themy.x() * themx.y() - themy.y() * themx.x());
+
+ if (div != 0.)
+ rx = (themx.y() * xDiff - themx.x() * yDiff) / div;
+
+ if (themy.y() != 0.) ry = (yDiff - rx * themx.y()) / themy.y();
+ }
+
+ target->setX(target->x() - rx);
+ target->setY(target->y() - ry);
+ } else if (target) {
+ target->setItemParent(targetParent);
+ }
+}
+
/*!
\preliminary
\qmlclass ParentChange
@@ -76,32 +134,32 @@ QmlParentChange::~QmlParentChange()
/*!
\qmlproperty Object ParentChange::target
- This property holds the object to be reparented
+ This property holds the item to be reparented
*/
-QObject *QmlParentChange::object() const
+QFxItem *QmlParentChange::object() const
{
Q_D(const QmlParentChange);
return d->target;
}
-void QmlParentChange::setObject(QObject *target)
+void QmlParentChange::setObject(QFxItem *target)
{
Q_D(QmlParentChange);
d->target = target;
}
/*!
- \qmlproperty Object ParentChange::parent
- This property holds the parent for the object in this state
+ \qmlproperty Item ParentChange::parent
+ This property holds the parent for the item in this state
*/
-QObject *QmlParentChange::parent() const
+QFxItem *QmlParentChange::parent() const
{
Q_D(const QmlParentChange);
return d->parent;
}
-void QmlParentChange::setParent(QObject *parent)
+void QmlParentChange::setParent(QFxItem *parent)
{
Q_D(QmlParentChange);
d->parent = parent;
@@ -113,27 +171,31 @@ QmlStateOperation::ActionList QmlParentChange::actions()
if (!d->target || !d->parent)
return ActionList();
- QString propName(QLatin1String("moveToParent"));
- QmlMetaProperty prop(d->target, propName);
- if (!prop.isValid()) {
- qmlInfo(this) << d->target->metaObject()->className()
- << "has no property named" << propName;
- return ActionList();
- }else if (!prop.isWritable()){
- qmlInfo(this) << d->target->metaObject()->className() << propName
- << "is not a writable property and cannot be set.";
- return ActionList();
- }
- QVariant cur = prop.read();
-
Action a;
- a.property = prop;
- a.fromValue = cur;
- a.toValue = qVariantFromValue(d->parent);
+ a.event = this;
return ActionList() << a;
}
+void QmlParentChange::execute()
+{
+ Q_D(QmlParentChange);
+ if (d->target)
+ d->origParent = d->target->itemParent();
+ d->doChange(d->parent);
+}
+
+bool QmlParentChange::isReversable()
+{
+ return true;
+}
+
+void QmlParentChange::reverse()
+{
+ Q_D(QmlParentChange);
+ d->doChange(d->origParent);
+}
+
class QmlRunScriptPrivate : public QObjectPrivate
{
public:
diff --git a/src/declarative/util/qmlstateoperations.h b/src/declarative/util/qmlstateoperations.h
index 221373b..acbe05e 100644
--- a/src/declarative/util/qmlstateoperations.h
+++ b/src/declarative/util/qmlstateoperations.h
@@ -43,6 +43,7 @@
#define QMLSTATEOPERATIONS_H
#include <QtDeclarative/qmlstate.h>
+#include <QtDeclarative/qfxitem.h>
QT_BEGIN_HEADER
@@ -51,24 +52,28 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QmlParentChangePrivate;
-class Q_DECLARATIVE_EXPORT QmlParentChange : public QmlStateOperation
+class Q_DECLARATIVE_EXPORT QmlParentChange : public QmlStateOperation, public ActionEvent
{
Q_OBJECT
Q_DECLARE_PRIVATE(QmlParentChange)
- Q_PROPERTY(QObject *target READ object WRITE setObject)
- Q_PROPERTY(QObject *parent READ parent WRITE setParent)
+ Q_PROPERTY(QFxItem *target READ object WRITE setObject)
+ Q_PROPERTY(QFxItem *parent READ parent WRITE setParent)
public:
QmlParentChange(QObject *parent=0);
~QmlParentChange();
- QObject *object() const;
- void setObject(QObject *);
+ QFxItem *object() const;
+ void setObject(QFxItem *);
- QObject *parent() const;
- void setParent(QObject *);
+ QFxItem *parent() const;
+ void setParent(QFxItem *);
virtual ActionList actions();
+
+ virtual void execute();
+ virtual bool isReversable();
+ virtual void reverse();
};
class QmlRunScriptPrivate;
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 916724c..638f20f 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -327,6 +327,10 @@
\value ItemAcceptsInputMethod The item supports input methods typically
used for Asian languages.
This flag was introduced in Qt 4.6.
+
+ \value ItemNegativeZStacksBehindParent The item automatically stacks
+ it's parent if it's z-value is negative.
+ This flag was introduced in Qt 4.6.
*/
/*!
@@ -3726,6 +3730,13 @@ void QGraphicsItem::setZValue(qreal z)
itemChange(ItemZValueHasChanged, newZVariant);
+ if(d_ptr->flags & ItemNegativeZStacksBehindParent) {
+ if (z < 0)
+ setFlag(QGraphicsItem::ItemStacksBehindParent, true);
+ else
+ setFlag(QGraphicsItem::ItemStacksBehindParent, false);
+ }
+
if (d_ptr->isObject)
emit static_cast<QGraphicsObject *>(this)->zChanged();
}
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h
index 7240eaa..ba7b5ef 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/gui/graphicsview/qgraphicsitem.h
@@ -100,7 +100,8 @@ public:
ItemUsesExtendedStyleOption = 0x200,
ItemHasNoContents = 0x400,
ItemSendsGeometryChanges = 0x800,
- ItemAcceptsInputMethod = 0x1000
+ ItemAcceptsInputMethod = 0x1000,
+ ItemNegativeZStacksBehindParent = 0x2000
// NB! Don't forget to increase the d_ptr->flags bit field by 1 when adding a new flag.
};
Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag)
@@ -510,9 +511,9 @@ class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem
Q_OBJECT
Q_PROPERTY(QGraphicsObject * parent READ parentObject WRITE setParentItem NOTIFY parentChanged DESIGNABLE false)
Q_PROPERTY(QString id READ objectName WRITE setObjectName)
- Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged)
+ Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged FINAL)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
- Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
+ Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged)
Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged)
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index d14ae7f..ba24806 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -199,7 +199,7 @@ public:
virtual QVariant inputMethodQueryHelper(Qt::InputMethodQuery query) const;
static bool movableAncestorIsSelected(const QGraphicsItem *item);
- void setPosHelper(const QPointF &pos);
+ virtual void setPosHelper(const QPointF &pos);
void setTransformHelper(const QTransform &transform);
void setVisibleHelper(bool newVisible, bool explicitly, bool update = true);
void setEnabledHelper(bool newEnabled, bool explicitly, bool update = true);
@@ -449,7 +449,7 @@ public:
// New 32 bits
quint32 fullUpdatePending : 1;
- quint32 flags : 13;
+ quint32 flags : 14;
quint32 dirtyChildrenBoundingRect : 1;
quint32 paintedViewBoundingRectsNeedRepaint : 1;
quint32 dirtySceneTransform : 1;
@@ -466,7 +466,7 @@ public:
quint32 isFocusItemForArea : 1;
quint32 hasActiveFocus : 1;
quint32 mouseSetsFocus : 1;
- quint32 unused : 2; // feel free to use
+ quint32 unused : 1; // feel free to use
// Optional stacking order
int globalStackingOrder;