summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2009-04-27 06:52:38 (GMT)
committerRoberto Raggi <roberto.raggi@nokia.com>2009-04-27 06:52:38 (GMT)
commit6ed9a0b6344cfd0fd9c27f6a69f15b4e709f97eb (patch)
tree68d6c4928dbd91d50e08b5b9d09a1178dffad092 /src/declarative/fx
parent5d8ce4c43c3c2816cd5dca03ddd429f26b96d34d (diff)
parent7e94543a9b013b6b1140137ba64406b74a363afc (diff)
downloadQt-6ed9a0b6344cfd0fd9c27f6a69f15b4e709f97eb.zip
Qt-6ed9a0b6344cfd0fd9c27f6a69f15b4e709f97eb.tar.gz
Qt-6ed9a0b6344cfd0fd9c27f6a69f15b4e709f97eb.tar.bz2
Merge branch 'kinetic-declarativeui' of git://scm.dev.nokia.troll.no/qt/kinetic into kinetic-declarativeui-qfx
Diffstat (limited to 'src/declarative/fx')
-rw-r--r--src/declarative/fx/qfxanimatedimageitem.cpp4
-rw-r--r--src/declarative/fx/qfxblendedimage.cpp45
-rw-r--r--src/declarative/fx/qfxblendedimage.h6
-rw-r--r--src/declarative/fx/qfxcomponentinstance.cpp2
-rw-r--r--src/declarative/fx/qfxflickable.cpp15
-rw-r--r--src/declarative/fx/qfxflickable_p.h18
-rw-r--r--src/declarative/fx/qfxgridview.cpp6
-rw-r--r--src/declarative/fx/qfxhighlightfilter.cpp8
-rw-r--r--src/declarative/fx/qfximage.cpp8
-rw-r--r--src/declarative/fx/qfxitem.cpp313
-rw-r--r--src/declarative/fx/qfxitem.h4
-rw-r--r--src/declarative/fx/qfxitem_p.h2
-rw-r--r--src/declarative/fx/qfxkeyactions.cpp3
-rw-r--r--src/declarative/fx/qfxlistview.cpp17
-rw-r--r--src/declarative/fx/qfxmouseregion.cpp3
-rw-r--r--src/declarative/fx/qfxparticles.cpp5
-rw-r--r--src/declarative/fx/qfxpathview.cpp15
-rw-r--r--src/declarative/fx/qfxpathview.h1
-rw-r--r--src/declarative/fx/qfxpathview_p.h7
-rw-r--r--src/declarative/fx/qfxrepeater.cpp10
-rw-r--r--src/declarative/fx/qfxvisualitemmodel.cpp12
-rw-r--r--src/declarative/fx/qfxwebview.cpp41
-rw-r--r--src/declarative/fx/qfxwebview.h4
23 files changed, 424 insertions, 125 deletions
diff --git a/src/declarative/fx/qfxanimatedimageitem.cpp b/src/declarative/fx/qfxanimatedimageitem.cpp
index cc11b56..b5f0cc4 100644
--- a/src/declarative/fx/qfxanimatedimageitem.cpp
+++ b/src/declarative/fx/qfxanimatedimageitem.cpp
@@ -165,7 +165,7 @@ void QFxAnimatedImageItem::setSource(const QString &url)
}
d->source = url;
- d->url = itemContext()->resolvedUrl(url);
+ d->url = qmlContext(this)->resolvedUrl(url);
if(url.isEmpty()) {
delete d->_movie;
@@ -174,7 +174,7 @@ void QFxAnimatedImageItem::setSource(const QString &url)
d->status = Loading;
QNetworkRequest req(d->url);
req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
- d->reply = itemContext()->engine()->networkAccessManager()->get(req);
+ d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req);
QObject::connect(d->reply, SIGNAL(finished()),
this, SLOT(movieRequestFinished()));
}
diff --git a/src/declarative/fx/qfxblendedimage.cpp b/src/declarative/fx/qfxblendedimage.cpp
index b5d9a9a..ec2b9cc 100644
--- a/src/declarative/fx/qfxblendedimage.cpp
+++ b/src/declarative/fx/qfxblendedimage.cpp
@@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE
secondary image.
*/
QFxBlendedImage::QFxBlendedImage(QFxItem *parent)
-: QFxItem(parent), _blend(0), dirty(false)
+: QFxItem(parent), _blend(0), _smooth(false), dirty(false)
{
#if defined(QFX_RENDER_OPENGL2)
setOptions(HasContents);
@@ -103,9 +103,9 @@ void QFxBlendedImage::setPrimaryUrl(const QString &url)
if (!primSrc.isEmpty())
QFxPixmap::cancelGet(primUrl,this,SLOT(primaryLoaded()));
primSrc = url;
- primUrl = itemContext()->resolvedUrl(url);
+ primUrl = qmlContext(this)->resolvedUrl(url);
if (!primSrc.isEmpty())
- QFxPixmap::get(itemContext()->engine(), primUrl,this,SLOT(primaryLoaded()));
+ QFxPixmap::get(qmlEngine(this), primUrl,this,SLOT(primaryLoaded()));
}
/*!
@@ -131,9 +131,9 @@ void QFxBlendedImage::setSecondaryUrl(const QString &url)
if (!secSrc.isEmpty())
QFxPixmap::cancelGet(secUrl,this,SLOT(secondaryLoaded()));
secSrc = url;
- secUrl = itemContext()->resolvedUrl(url);
+ secUrl = qmlContext(this)->resolvedUrl(url);
if (!secSrc.isEmpty())
- QFxPixmap::get(itemContext()->engine(), secUrl,this,SLOT(secondaryLoaded()));
+ QFxPixmap::get(qmlEngine(this), secUrl,this,SLOT(secondaryLoaded()));
}
/*!
@@ -154,16 +154,51 @@ void QFxBlendedImage::setBlend(qreal b)
update();
}
+/*!
+ \qmlproperty bool BlendedImage::smooth
+
+ Set this property if you want the image to be smoothly filtered when scaled or
+ transformed. Smooth filtering gives better visual quality, but is slower. If
+ the BlendedImage is displayed at its natural size, this property has no visual or
+ performance effect.
+
+ \note Generally scaling artifacts are only visible if the image is stationary on
+ the screen. A common pattern when animating an image is to disable smooth
+ filtering at the beginning of the animation and reenable it at the conclusion.
+ */
+bool QFxBlendedImage::smoothTransform() const
+{
+ return _smooth;
+}
+
+void QFxBlendedImage::setSmoothTransform(bool s)
+{
+ if(_smooth == s)
+ return;
+ _smooth = s;
+ update();
+}
+
#if defined(QFX_RENDER_QPAINTER)
void QFxBlendedImage::paintContents(QPainter &p)
{
if (primSrc.isNull() && secSrc.isNull())
return;
+
+ if(_smooth) {
+ p.save();
+ p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, _smooth);
+ }
+
if (_blend < 0.75)
p.drawImage(0, 0, primPix);
else
p.drawImage(0, 0, secPix);
+
+ if(_smooth) {
+ p.restore();
+ }
}
#elif defined(QFX_RENDER_OPENGL2)
diff --git a/src/declarative/fx/qfxblendedimage.h b/src/declarative/fx/qfxblendedimage.h
index 96d3135..5cc0238 100644
--- a/src/declarative/fx/qfxblendedimage.h
+++ b/src/declarative/fx/qfxblendedimage.h
@@ -60,17 +60,22 @@ class QFxBlendedImage : public QFxItem
Q_PROPERTY(QString primaryUrl READ primaryUrl WRITE setPrimaryUrl)
Q_PROPERTY(QString secondaryUrl READ secondaryUrl WRITE setSecondaryUrl)
Q_PROPERTY(qreal blend READ blend WRITE setBlend)
+ Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform)
public:
QFxBlendedImage(QFxItem *parent=0);
QString primaryUrl() const;
void setPrimaryUrl(const QString &);
+
QString secondaryUrl() const;
void setSecondaryUrl(const QString &);
qreal blend() const;
void setBlend(qreal);
+ bool smoothTransform() const;
+ void setSmoothTransform(bool);
+
#if defined(QFX_RENDER_QPAINTER)
void paintContents(QPainter &painter);
#elif defined(QFX_RENDER_OPENGL2)
@@ -88,6 +93,7 @@ private:
QUrl secUrl;
qreal _blend;
+ bool _smooth;
bool dirty;
#if defined(QFX_RENDER_OPENGL2)
GLTexture prim;
diff --git a/src/declarative/fx/qfxcomponentinstance.cpp b/src/declarative/fx/qfxcomponentinstance.cpp
index b456716..02a6c86 100644
--- a/src/declarative/fx/qfxcomponentinstance.cpp
+++ b/src/declarative/fx/qfxcomponentinstance.cpp
@@ -109,7 +109,7 @@ void QFxComponentInstance::create()
{
Q_D(QFxComponentInstance);
if(d->component) {
- QObject *obj= d->component->create(itemContext());
+ QObject *obj= d->component->create(qmlContext(this));
if(obj) {
QFxItem *objitem = qobject_cast<QFxItem *>(obj);
if(objitem) {
diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp
index 5715116..04b4a3d 100644
--- a/src/declarative/fx/qfxflickable.cpp
+++ b/src/declarative/fx/qfxflickable.cpp
@@ -43,13 +43,12 @@
#include "qfxflickable_p.h"
#include <QGraphicsSceneMouseEvent>
-#include <gfxeasing.h>
#include <QPointer>
#include <QTimer>
QT_BEGIN_NAMESPACE
-ElasticValue::ElasticValue(GfxValue &val)
+ElasticValue::ElasticValue(QmlTimeLineValue &val)
: _value(val)
{
_to = _value.value();
@@ -101,8 +100,8 @@ QFxFlickablePrivate::QFxFlickablePrivate()
, vTime(0), atXEnd(false), atXBeginning(true), pageXPosition(0.), pageWidth(0.)
, atYEnd(false), atYBeginning(true), pageYPosition(0.), pageHeight(0.)
{
- fixupXEvent = GfxEvent::gfxEvent<QFxFlickablePrivate, &QFxFlickablePrivate::fixupX>(&_moveX, this);
- fixupYEvent = GfxEvent::gfxEvent<QFxFlickablePrivate, &QFxFlickablePrivate::fixupY>(&_moveY, this);
+ fixupXEvent = QmlTimeLineEvent::timeLineEvent<QFxFlickablePrivate, &QFxFlickablePrivate::fixupX>(&_moveX, this);
+ fixupYEvent = QmlTimeLineEvent::timeLineEvent<QFxFlickablePrivate, &QFxFlickablePrivate::fixupY>(&_moveY, this);
}
void QFxFlickablePrivate::init()
@@ -128,11 +127,11 @@ void QFxFlickablePrivate::fixupX()
vTime = _tl.time();
if(_moveX.value() > q->minXExtent() || q->maxXExtent() > 0) {
- _tl.move(_moveX, q->minXExtent(), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveX, q->minXExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
flicked = false;
//emit flickingChanged();
} else if(_moveX.value() < q->maxXExtent()) {
- _tl.move(_moveX, q->maxXExtent(), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveX, q->maxXExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
flicked = false;
//emit flickingChanged();
}
@@ -147,10 +146,10 @@ void QFxFlickablePrivate::fixupY()
vTime = _tl.time();
if(_moveY.value() > q->minYExtent() || (q->maxYExtent() > q->minYExtent())) {
- _tl.move(_moveY, q->minYExtent(), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveY, q->minYExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
//emit flickingChanged();
} else if(_moveY.value() < q->maxYExtent()) {
- _tl.move(_moveY, q->maxYExtent(), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveY, q->maxYExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
//emit flickingChanged();
} else {
flicked = false;
diff --git a/src/declarative/fx/qfxflickable_p.h b/src/declarative/fx/qfxflickable_p.h
index 59450e0..ebd0327 100644
--- a/src/declarative/fx/qfxflickable_p.h
+++ b/src/declarative/fx/qfxflickable_p.h
@@ -57,7 +57,7 @@
#include "qfxflickable.h"
#include "qfxitem_p.h"
#include "qml.h"
-#include "gfxvalueproxy.h"
+#include "qmltimelinevalueproxy.h"
#include "private/qmlanimation_p.h"
QT_BEGIN_NAMESPACE
@@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE
class ElasticValue : public QAbstractAnimation {
Q_OBJECT
public:
- ElasticValue(GfxValue &);
+ ElasticValue(QmlTimeLineValue &);
void setValue(qreal to);
void clear();
@@ -81,7 +81,7 @@ private:
qreal _to;
qreal _myValue;
qreal _velocity;
- GfxValue &_value;
+ QmlTimeLineValue &_value;
QTime _startTime;
};
@@ -98,8 +98,8 @@ public:
public:
QFxItem *_flick;
- GfxValueProxy<QFxItem> _moveX;
- GfxValueProxy<QFxItem> _moveY;
+ QmlTimeLineValueProxy<QFxItem> _moveX;
+ QmlTimeLineValueProxy<QFxItem> _moveY;
QmlTimeLine _tl;
int vWidth;
int vHeight;
@@ -116,8 +116,8 @@ public:
qreal velocityX;
qreal velocityY;
QTime pressTime;
- GfxEvent fixupXEvent;
- GfxEvent fixupYEvent;
+ QmlTimeLineEvent fixupXEvent;
+ QmlTimeLineEvent fixupYEvent;
int maxVelocity;
bool locked;
QFxFlickable::DragMode dragMode;
@@ -128,12 +128,12 @@ public:
int velocityDecay;
void updateVelocity();
- struct Velocity : public GfxValue
+ struct Velocity : public QmlTimeLineValue
{
Velocity(QFxFlickablePrivate *p)
: parent(p) {}
virtual void setValue(qreal v) {
- GfxValue::setValue(v);
+ QmlTimeLineValue::setValue(v);
parent->updateVelocity();
}
QFxFlickablePrivate *parent;
diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp
index f9a9f8c..5e4baac 100644
--- a/src/declarative/fx/qfxgridview.cpp
+++ b/src/declarative/fx/qfxgridview.cpp
@@ -558,7 +558,7 @@ void QFxGridViewPrivate::createHighlight()
return;
if (currentItem) {
- QmlContext *highlightContext = new QmlContext(q->itemContext());
+ QmlContext *highlightContext = new QmlContext(qmlContext(q));
QObject *nobj = highlightComponent->create(highlightContext);
if (nobj) {
highlightContext->setParent(nobj);
@@ -751,7 +751,7 @@ void QFxGridView::setModel(const QVariant &model)
d->model = vim;
} else {
if (!d->ownModel) {
- d->model = new QFxVisualItemModel(itemContext());
+ d->model = new QFxVisualItemModel(qmlContext(this));
d->ownModel = true;
}
d->model->setModel(model);
@@ -796,7 +796,7 @@ void QFxGridView::setDelegate(QmlComponent *delegate)
{
Q_D(QFxGridView);
if (!d->ownModel) {
- d->model = new QFxVisualItemModel(itemContext());
+ d->model = new QFxVisualItemModel(qmlContext(this));
d->ownModel = true;
}
d->model->setDelegate(delegate);
diff --git a/src/declarative/fx/qfxhighlightfilter.cpp b/src/declarative/fx/qfxhighlightfilter.cpp
index d1ff3d3..d99b9e5 100644
--- a/src/declarative/fx/qfxhighlightfilter.cpp
+++ b/src/declarative/fx/qfxhighlightfilter.cpp
@@ -56,10 +56,8 @@ class QFxHighlightFilterPrivate
{
public:
QFxHighlightFilterPrivate()
- : ctxt(QmlContext::activeContext()),
- xOffset(0), yOffset(0), tiled(false) {}
+ : xOffset(0), yOffset(0), tiled(false) {}
- QmlContext *ctxt;
QString source;
QUrl url;
int xOffset;
@@ -147,12 +145,12 @@ void QFxHighlightFilter::setSource(const QString &f)
if(!d->source.isEmpty())
QFxPixmap::cancelGet(d->url, this, SLOT(imageLoaded()));
d->source = f;
- d->url = QmlContext::activeContext()->resolvedUrl(f);
+ d->url = qmlContext(this)->resolvedUrl(f);
#if defined(QFX_RENDER_OPENGL2)
d->tex.clear();
#endif
if(!f.isEmpty())
- QFxPixmap::get(d->ctxt->engine(), d->url, this, SLOT(imageLoaded()));
+ QFxPixmap::get(qmlEngine(this), d->url, this, SLOT(imageLoaded()));
else
emit sourceChanged(d->source);
}
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp
index 9fe491c..2d0dbc7 100644
--- a/src/declarative/fx/qfximage.cpp
+++ b/src/declarative/fx/qfximage.cpp
@@ -842,7 +842,7 @@ void QFxImage::setSource(const QString &url)
QFxPixmap::cancelGet(d->sciurl, this, SLOT(requestFinished()));
d->source = url;
- d->url = itemContext()->resolvedUrl(url);
+ d->url = qmlContext(this)->resolvedUrl(url);
d->sciurl = QUrl();
if(url.isEmpty()) {
@@ -861,12 +861,12 @@ void QFxImage::setSource(const QString &url)
{
QNetworkRequest req(d->url);
req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
- d->reply = itemContext()->engine()->networkAccessManager()->get(req);
+ d->reply = qmlEngine(this)->networkAccessManager()->get(req);
QObject::connect(d->reply, SIGNAL(finished()),
this, SLOT(sciRequestFinished()));
}
} else {
- QFxPixmap::get(itemContext()->engine(), d->url, this, SLOT(requestFinished()));
+ QFxPixmap::get(qmlEngine(this), d->url, this, SLOT(requestFinished()));
}
}
@@ -921,7 +921,7 @@ void QFxImage::setGridScaledImage(const QFxGridScaledImage& sci)
emit statusChanged(d->status);
} else {
d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl()));
- QFxPixmap::get(itemContext()->engine(), d->sciurl, this, SLOT(requestFinished()));
+ QFxPixmap::get(qmlEngine(this), d->sciurl, this, SLOT(requestFinished()));
QFxScaleGrid *sg = scaleGrid();
sg->setTop(sci.gridTop());
sg->setBottom(sci.gridBottom());
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index 6b4c504..0ed46bc 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -227,6 +227,11 @@ void QFxContents::setItem(QFxItem *item)
*/
/*!
+ \property QFxItem::activeFocus
+ This property indicates whether the item has the active focus.
+ */
+
+/*!
\fn void QFxItem::activeFocusChanged()
This signal is emitted when this item gains active focus.
@@ -433,17 +438,25 @@ QFxItem::~QFxItem()
The default transform origin is \c TopLeft.
*/
+
/*!
\qmlproperty Item Item::parent
This property holds the parent of the item.
*/
+
+/*!
+ \property QFxItem::parent
+ This property holds the parent of the item.
+*/
void QFxItem::setItemParent(QFxItem *parent)
{
setParent(parent);
}
/*!
- XXX Playing around with view2view transitions.
+ \internal
+ \property QFxItem::moveToParent
+ Playing around with view2view transitions.
*/
void QFxItem::moveToParent(QFxItem *parent)
{
@@ -535,6 +548,19 @@ QFxItem *QFxItem::itemParent() const
*/
/*!
+ \property QFxItem::children
+
+ This property contains the list of visual children of this item.
+*/
+
+/*!
+ \property QFxItem::resources
+
+ This property contains non-visual resources that you want to
+ reference by name.
+*/
+
+/*!
Returns true if all of the attributes set via QML have been set;
otherwise returns false.
@@ -707,6 +733,18 @@ void QFxItemPrivate::children_clear()
data is a behind-the-scenes property: you should never need to explicitly
specify it.
*/
+
+/*!
+ \property QFxItem::data
+
+ The data property is allows you to freely mix the visual children
+ and the non-visual resources of an item. If you assign a visual
+ item to the data list it becomes a child and if you assign any
+ other object type, it is added as a resource.
+
+ data is a behind-the-scenes property: you should never need to
+ explicitly specify it.
+ */
QmlList<QObject *> *QFxItem::data()
{
Q_D(QFxItem);
@@ -731,6 +769,11 @@ QFxContents *QFxItem::contents()
return d->_contents;
}
+/*!
+ \internal
+ \property QFxItem::qmlItem
+*/
+
QFxItem *QFxItem::qmlItem() const
{
Q_D(const QFxItem);
@@ -745,6 +788,15 @@ QFxItem *QFxItem::qmlItem() const
item. Querying for the QML only has meaning if the QML has been
dynamically set; otherwise an empty string is returned.
*/
+
+/*!
+ \property QFxItem::qml
+ This property holds the dynamic QML for the item.
+
+ This property is used for dynamically loading QML into the
+ item. Querying for the QML only has meaning if the QML has been
+ dynamically set; otherwise an empty string is returned.
+*/
QString QFxItem::qml() const
{
Q_D(const QFxItem);
@@ -764,7 +816,7 @@ void QFxItem::setQml(const QString &qml)
}
d->_qml = qml;
- d->_qmlurl = itemContext()->resolvedUri(qml);
+ d->_qmlurl = qmlContext(this)->resolvedUri(qml);
d->qmlItem = 0;
if(d->_qml.isEmpty()) {
@@ -779,7 +831,7 @@ void QFxItem::setQml(const QString &qml)
emit qmlChanged();
} else {
d->_qmlcomp =
- new QmlComponent(itemContext()->engine(), d->_qmlurl, this);
+ new QmlComponent(qmlEngine(this), d->_qmlurl, this);
if(!d->_qmlcomp->isLoading())
qmlLoaded();
else
@@ -800,12 +852,12 @@ void QFxItem::qmlLoaded()
if(c->isLoading())
continue;
- QmlContext *ctxt = new QmlContext(itemContext());
+ QmlContext *ctxt = new QmlContext(qmlContext(this));
QObject* o = c ? c->create(ctxt):0;
QFxItem* ret = qobject_cast<QFxItem*>(o);
if (ret) {
ret->setItemParent(this);
- QScriptValue v = itemContext()->engine()->scriptEngine()->newQObject(ret);
+ QScriptValue v = qmlEngine(this)->scriptEngine()->newQObject(ret);
emit newChildCreated(d->_qmlnewloading.at(i).toString(),v);
}
@@ -818,7 +870,7 @@ void QFxItem::qmlLoaded()
// setQml...
if (d->_qmlcomp) {
- QmlContext *ctxt = new QmlContext(itemContext());
+ QmlContext *ctxt = new QmlContext(qmlContext(this));
ctxt->addDefaultObject(this);
QObject *obj = d->_qmlcomp->create(ctxt);
@@ -851,6 +903,39 @@ void QFxItem::qmlLoaded()
*/
/*!
+ \property QFxItem::width
+
+ Defines the item's width relative to its parent.
+ */
+
+/*!
+ \property QFxItem::height
+
+ Defines the item's height relative to its parent.
+ */
+
+/*!
+ \property QFxItem::x
+
+ The x coordinate of the item relative to its parent.
+*/
+
+/*!
+ \property QFxItem::y
+
+ The y coordinate of the item relative to its parent.
+*/
+
+/*!
+ \property QFxItem::z
+
+ The z coordinate of the item relative to its parent.
+
+ A negative z coordinate means the item will be painted below its parent.
+*/
+
+
+/*!
\qmlproperty real Item::z
Sets the stacking order of the item. By default the stacking order is 0.
@@ -903,12 +988,6 @@ void QFxItem::qmlLoaded()
\endqml
\endtable
*/
-/*!
- \property QFxItem::z
- \brief The z coordinate of the item relative to its parent.
-
- A negative z coordinate means the item will be painted below its parent.
-*/
void QFxItem::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry)
@@ -1002,6 +1081,13 @@ void QFxItemPrivate::handleHeightChange(int yoffset)
When set, the item will be displayed flipped horizontally or vertically
about its center.
*/
+
+/*!
+ \property QFxItem::flipVertically
+
+ When set, the item will be displayed flipped horizontally or vertically
+ about its center.
+ */
bool QFxItem::flipVertically() const
{
return flip() & VerticalFlip;
@@ -1015,6 +1101,12 @@ void QFxItem::setFlipVertically(bool v)
setFlip((QSimpleCanvasItem::Flip)(flip() & ~VerticalFlip));
}
+/*!
+ \property QFxItem::flipHorizontally
+
+ When set, the item will be displayed flipped horizontally or vertically
+ about its center.
+ */
bool QFxItem::flipHorizontally() const
{
return flip() & HorizontalFlip;
@@ -1095,8 +1187,23 @@ QRectF QFxItem::sceneBoundingRect() const
\endqml
The identifier is available throughout to the \l {components}{component}
- where it is declared. Two items in the same component
- with the same identifier is invalid.
+ where it is declared. The identifier must be unique in thecomponent.
+*/
+
+/*!
+ \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
{
@@ -1148,6 +1255,54 @@ QFxAnchorLine QFxItem::verticalCenter() const
}
/*!
+ \property QFxItem::top
+
+ One of the anchor lines of the item.
+
+ For more information see \l {anchor-layout}{Anchor Layouts}.
+*/
+
+/*!
+ \property QFxItem::bottom
+
+ One of the anchor lines of the item.
+
+ For more information see \l {anchor-layout}{Anchor Layouts}.
+*/
+
+/*!
+ \property QFxItem::left
+
+ One of the anchor lines of the item.
+
+ For more information see \l {anchor-layout}{Anchor Layouts}.
+*/
+
+/*!
+ \property QFxItem::right
+
+ One of the anchor lines of the item.
+
+ For more information see \l {anchor-layout}{Anchor Layouts}.
+*/
+
+/*!
+ \property QFxItem::horizontalCenter
+
+ One of the anchor lines of the item.
+
+ For more information see \l {anchor-layout}{Anchor Layouts}.
+*/
+
+/*!
+ \property QFxItem::verticalCenter
+
+ One of the anchor lines of the item.
+
+ For more information see \l {anchor-layout}{Anchor Layouts}.
+*/
+
+/*!
\qmlproperty AnchorLine Item::top
\qmlproperty AnchorLine Item::bottom
\qmlproperty AnchorLine Item::left
@@ -1216,8 +1371,8 @@ QFxAnchorLine QFxItem::verticalCenter() const
For more information see \l {anchor-layout}{Anchor Layouts}.
*/
-/*
- \property QFxItem::baseline
+/*!
+ \property QFxItem::baselineOffset
\brief The position of the item's baseline in global (scene) coordinates.
The baseline of a Text item is the imaginary line on which the text
@@ -1267,6 +1422,14 @@ void QFxItem::setBaselineOffset(int offset)
\endqml
\endtable
*/
+
+/*!
+ \property QFxItem::rotation
+ This property holds the rotation of the item in degrees.
+
+ This specifies how many degrees to rotate the item around its origin (0,0).
+ The default rotation is 0 degrees (i.e. not rotated at all).
+*/
qreal QFxItem::rotation() const
{
Q_D(const QFxItem);
@@ -1322,6 +1485,21 @@ void QFxItem::setRotation(qreal rotation)
\endqml
\endtable
*/
+
+/*!
+ \property QFxItem::scale
+ This property holds the scale of the item.
+
+ A scale of less than 1 means the item will be displayed smaller than
+ normal, and a scale of greater than 1 means the item will be
+ displayed larger than normal. A negative scale means the item will
+ be mirrored.
+
+ By default, items are displayed at a scale of 1 (i.e. at their
+ normal size).
+
+ Scaling is from the item's origin (0,0).
+*/
qreal QFxItem::scale() const
{
return QSimpleCanvasItem::scale();
@@ -1370,6 +1548,16 @@ void QFxItem::setScale(qreal s)
\endtable
*/
+/*!
+ \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.
+*/
+
qreal QFxItem::opacity() const
{
return QSimpleCanvasItem::visible();
@@ -1437,6 +1625,13 @@ QmlList<QObject *> *QFxItem::resources()
\sa {states-transitions}{States and Transitions}
*/
+
+/*!
+ \property QFxItem::states
+ This property holds a list of states defined by the item.
+
+ \sa {states-transitions}{States and Transitions}
+*/
QmlList<QmlState *>* QFxItem::states()
{
Q_D(QFxItem);
@@ -1459,6 +1654,13 @@ QmlList<QmlState *>* QFxItem::states()
\sa {states-transitions}{States and Transitions}
*/
+
+/*!
+ \property QFxItem::transitions
+ This property holds a list of transitions defined by the item.
+
+ \sa {states-transitions}{States and Transitions}
+*/
QmlList<QmlTransition *>* QFxItem::transitions()
{
Q_D(QFxItem);
@@ -1466,6 +1668,11 @@ QmlList<QmlTransition *>* QFxItem::transitions()
}
/*!
+ \internal
+ \property QFxItem::filter
+*/
+
+/*!
\qmlproperty list<Filter> Item::filter
This property holds a list of graphical filters to be applied to the item.
@@ -1497,6 +1704,16 @@ QmlList<QmlTransition *>* QFxItem::transitions()
*/
/*!
+ \property QFxItem::clip
+ This property holds whether clipping is enabled.
+
+ if clipping is enabled, an item will clip its own painting, as well
+ as the painting of its children, to its bounding rectangle.
+
+ Non-rectangular clipping regions are not supported for performance reasons.
+*/
+
+/*!
Returns the state with \a name. Returns 0 if no matching state is found.
*/
QmlState *QFxItem::findState(const QString &name) const
@@ -1533,6 +1750,32 @@ QmlState *QFxItem::findState(const QString &name) const
\sa {states-transitions}{States and Transitions}
*/
+
+/*!
+ \property QFxItem::state
+
+ This property holds the name of the current state of the item.
+
+ This property is often used in scripts to change between states. For
+ example:
+
+ \qml
+ <Script>
+ function toggle() {
+ if (button.state == 'On')
+ button.state = 'Off';
+ else
+ button.state = 'On';
+ }
+ </Script>
+ \endqml
+
+ If the item is in its base state (i.e. no explicit state has been
+ set), \c state will be a blank string. Likewise, you can return an
+ item to its base state by setting its current state to \c ''.
+
+ \sa {states-transitions}{States and Transitions}
+*/
QString QFxItem::state() const
{
Q_D(const QFxItem);
@@ -1554,6 +1797,13 @@ void QFxItem::setState(const QString &state)
For more information see \l Transform.
*/
+
+/*!
+ \property QFxItem::transform
+ This property holds the list of transformations to apply.
+
+ For more information see \l Transform.
+*/
QList<QFxTransform *> *QFxItem::transform()
{
Q_D(QFxItem);
@@ -1561,6 +1811,16 @@ QList<QFxTransform *> *QFxItem::transform()
}
/*!
+ \property QFxItem::focus
+ This property holds the item's focus state.
+*/
+
+/*!
+ \property QFxItem::focusable
+ This property holds whether the item has focus state.
+*/
+
+/*!
Returns true if the item is visible; otherwise returns false.
An item is considered visible if its opacity is not 0.
@@ -1571,11 +1831,15 @@ bool QFxItem::isVisible() const
return d->visible;
}
-/*!
- Sets the visibility of the item to \a 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)
{
@@ -1621,12 +1885,12 @@ void QFxItem::newChild(const QString &type)
{
Q_D(QFxItem);
- QUrl url = itemContext()->resolvedUri(type);
+ QUrl url = qmlContext(this)->resolvedUri(type);
if (url.isEmpty())
return;
d->_qmlnewloading.append(url);
- d->_qmlnewcomp.append(new QmlComponent(itemContext()->engine(), url, this));
+ d->_qmlnewcomp.append(new QmlComponent(qmlEngine(this), url, this));
if(!d->_qmlnewcomp.last()->isLoading())
qmlLoaded();
@@ -1718,15 +1982,6 @@ void QFxItem::transformChanged(const QSimpleCanvas::Matrix &)
{
}
-/*!
- Returns the current QML context for this item.
-*/
-QmlContext *QFxItem::itemContext() const
-{
- Q_D(const QFxItem);
- return d->_ctxt;
-}
-
QmlStateGroup *QFxItemPrivate::states()
{
Q_Q(QFxItem);
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index c47a1e1..e2a2ebd 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -120,7 +120,7 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QSimpleCanvasItem, public QmlParserS
Q_PROPERTY(bool flipVertically READ flipVertically WRITE setFlipVertically)
Q_PROPERTY(bool flipHorizontally READ flipHorizontally WRITE setFlipHorizontally)
Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
- Q_PROPERTY(int baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged )
+ Q_PROPERTY(int baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged)
Q_PROPERTY(QFxAnchorLine left READ left)
Q_PROPERTY(QFxAnchorLine right READ right)
Q_PROPERTY(QFxAnchorLine horizontalCenter READ horizontalCenter)
@@ -215,8 +215,6 @@ public:
bool keepMouseGrab() const;
void setKeepMouseGrab(bool);
- QmlContext *itemContext() const;
-
public Q_SLOTS:
void newChild(const QString &url);
diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h
index 1266711..71fc912 100644
--- a/src/declarative/fx/qfxitem_p.h
+++ b/src/declarative/fx/qfxitem_p.h
@@ -84,7 +84,6 @@ public:
void init(QFxItem *parent)
{
Q_Q(QFxItem);
- _ctxt = QmlContext::activeContext();
if(parent)
q->setItemParent(parent);
@@ -92,7 +91,6 @@ public:
q->setAcceptedMouseButtons(Qt::NoButton);
}
- QmlContext *_ctxt;
QString _id;
// data property
diff --git a/src/declarative/fx/qfxkeyactions.cpp b/src/declarative/fx/qfxkeyactions.cpp
index c4ae3e3..d16c305 100644
--- a/src/declarative/fx/qfxkeyactions.cpp
+++ b/src/declarative/fx/qfxkeyactions.cpp
@@ -908,8 +908,7 @@ void QFxKeyActions::keyPressEvent(QKeyEvent *event)
{
Qt::Key key = (Qt::Key)event->key();
if(d->enabled && d->key(key)) {
- QmlExpression b(itemContext(), d->action(key),
- this, false);
+ QmlExpression b(qmlContext(this), d->action(key), this, false);
b.value();
event->accept();
} else {
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index 3c8c12c..e03ec47 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -43,7 +43,6 @@
#include "qmlfollow.h"
#include "qlistmodelinterface.h"
#include "qfxvisualitemmodel.h"
-#include "gfxeasing.h"
#include "qfxlistview.h"
#include <qmlexpression.h>
@@ -395,7 +394,7 @@ FxListItem *QFxListViewPrivate::createItem(int modelIndex)
listItem->index = modelIndex;
// initialise attached properties
if (!sectionExpression.isEmpty()) {
- QmlExpression e(listItem->item->itemContext(), sectionExpression, q);
+ QmlExpression e(qmlContext(listItem->item), sectionExpression, q);
e.setTrackChange(false);
listItem->attached->m_section = e.value().toString();
if (modelIndex > 0) {
@@ -581,7 +580,7 @@ void QFxListViewPrivate::createHighlight()
if (currentItem) {
QFxItem *item = 0;
if (highlightComponent) {
- QmlContext *highlightContext = new QmlContext(q->itemContext());
+ QmlContext *highlightContext = new QmlContext(qmlContext(q));
QObject *nobj = highlightComponent->create(highlightContext);
if (nobj) {
highlightContext->setParent(nobj);
@@ -749,7 +748,7 @@ void QFxListViewPrivate::fixupY()
if (currentItem) {
moveReason = Mouse;
_tl.clear();
- _tl.move(_moveY, -(currentItem->position() - snapPos), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveY, -(currentItem->position() - snapPos), QEasingCurve(QEasingCurve::InOutQuad), 200);
}
} else if (currItemMode == QFxListView::Snap) {
moveReason = Mouse;
@@ -761,7 +760,7 @@ void QFxListViewPrivate::fixupY()
else if (pos < -q->minYExtent())
pos = -q->minYExtent();
_tl.clear();
- _tl.move(_moveY, -(pos), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveY, -(pos), QEasingCurve(QEasingCurve::InOutQuad), 200);
}
}
}
@@ -775,7 +774,7 @@ void QFxListViewPrivate::fixupX()
if (currItemMode == QFxListView::SnapAuto) {
moveReason = Mouse;
_tl.clear();
- _tl.move(_moveX, -(currentItem->position() - snapPos), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveX, -(currentItem->position() - snapPos), QEasingCurve(QEasingCurve::InOutQuad), 200);
} else if (currItemMode == QFxListView::Snap) {
moveReason = Mouse;
int idx = snapIndex();
@@ -786,7 +785,7 @@ void QFxListViewPrivate::fixupX()
else if (pos < -q->minXExtent())
pos = -q->minXExtent();
_tl.clear();
- _tl.move(_moveX, -(pos), GfxEasing(GfxEasing::InOutQuad), 200);
+ _tl.move(_moveX, -(pos), QEasingCurve(QEasingCurve::InOutQuad), 200);
}
}
}
@@ -900,7 +899,7 @@ void QFxListView::setModel(const QVariant &model)
d->model = vim;
} else {
if (!d->ownModel) {
- d->model = new QFxVisualItemModel(itemContext());
+ d->model = new QFxVisualItemModel(qmlContext(this));
d->ownModel = true;
}
d->model->setModel(model);
@@ -945,7 +944,7 @@ void QFxListView::setDelegate(QmlComponent *delegate)
{
Q_D(QFxListView);
if (!d->ownModel) {
- d->model = new QFxVisualItemModel(itemContext());
+ d->model = new QFxVisualItemModel(qmlContext(this));
d->ownModel = true;
}
d->model->setDelegate(delegate);
diff --git a/src/declarative/fx/qfxmouseregion.cpp b/src/declarative/fx/qfxmouseregion.cpp
index c6a7f96..0af3cea 100644
--- a/src/declarative/fx/qfxmouseregion.cpp
+++ b/src/declarative/fx/qfxmouseregion.cpp
@@ -315,7 +315,8 @@ void QFxMouseRegionPrivate::bindButtonValue(Qt::MouseButton b)
default:
bString = QLatin1String("None"); break;
}
- q->itemContext()->setContextProperty(QLatin1String("mouseButton"), bString);
+ // ### is this needed anymore?
+ qmlContext(q)->setContextProperty(QLatin1String("mouseButton"), bString);
}
void QFxMouseRegion::mousePressEvent(QGraphicsSceneMouseEvent *event)
diff --git a/src/declarative/fx/qfxparticles.cpp b/src/declarative/fx/qfxparticles.cpp
index 9319c46..8b16098 100644
--- a/src/declarative/fx/qfxparticles.cpp
+++ b/src/declarative/fx/qfxparticles.cpp
@@ -39,7 +39,6 @@
**
****************************************************************************/
-#include "gfxtimeline.h"
#include "qfxitem_p.h"
#if defined(QFX_RENDER_OPENGL)
#include "gltexture.h"
@@ -614,8 +613,8 @@ void QFxParticles::setUrl(const QString &name)
update();
} else {
d->source = name;
- d->url = itemContext()->resolvedUrl(name);
- QFxPixmap::get(itemContext()->engine(), d->url, this, SLOT(imageLoaded()));
+ d->url = qmlContext(this)->resolvedUrl(name);
+ QFxPixmap::get(qmlEngine(this), d->url, this, SLOT(imageLoaded()));
}
}
diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp
index 99f6e86..b1cfaa5 100644
--- a/src/declarative/fx/qfxpathview.cpp
+++ b/src/declarative/fx/qfxpathview.cpp
@@ -43,7 +43,6 @@
#include <QDebug>
#include <QPen>
#include <QEvent>
-#include <gfxeasing.h>
#include "qmlbindablevalue.h"
#include "qmlstate.h"
#include "qlistmodelinterface.h"
@@ -595,6 +594,8 @@ void QFxPathViewPrivate::regenerate()
int minI = -1;
for(int i=0; i<numItems; i++){
QFxItem *item = model->item(i);
+ if (!item)
+ return;
items.append(item);
item->setZ(i);
item->setParent(q);
@@ -805,7 +806,7 @@ void QFxPathViewPrivate::snapToCurrent()
rounds--;
if(distance > 50)
rounds++;
- tl.move(moveOffset, targetOffset + 100.0*(-rounds), GfxEasing(GfxEasing::InOutQuad),
+ tl.move(moveOffset, targetOffset + 100.0*(-rounds), QEasingCurve(QEasingCurve::InOutQuad),
int(100*items.count()*qMax((qreal)(2.0/items.count()),(qreal)qAbs(rounds))));
tl.execute(fixupOffsetEvent);
return;
@@ -813,16 +814,16 @@ void QFxPathViewPrivate::snapToCurrent()
if (targetOffset - _offset > 50.0) {
qreal distance = 100 - targetOffset + _offset;
- tl.move(moveOffset, 0.0, GfxEasing(GfxEasing::OutQuad), int(200 * _offset / distance));
+ tl.move(moveOffset, 0.0, QEasingCurve(QEasingCurve::OutQuad), int(200 * _offset / distance));
tl.set(moveOffset, 100.0);
- tl.move(moveOffset, targetOffset, GfxEasing(GfxEasing::InQuad), int(200 * (100-targetOffset) / distance));
+ tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InQuad), int(200 * (100-targetOffset) / distance));
} else if (targetOffset - _offset <= -50.0) {
qreal distance = 100 - _offset + targetOffset;
- tl.move(moveOffset, 100.0, GfxEasing(GfxEasing::OutQuad), int(200 * (100-_offset) / distance));
+ tl.move(moveOffset, 100.0, QEasingCurve(QEasingCurve::OutQuad), int(200 * (100-_offset) / distance));
tl.set(moveOffset, 0.0);
- tl.move(moveOffset, targetOffset, GfxEasing(GfxEasing::InQuad), int(200 * targetOffset / distance));
+ tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InQuad), int(200 * targetOffset / distance));
} else {
- tl.move(moveOffset, targetOffset, GfxEasing(GfxEasing::InOutQuad), 200);
+ tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), 200);
}
}
diff --git a/src/declarative/fx/qfxpathview.h b/src/declarative/fx/qfxpathview.h
index 6d4280d..2cc0769 100644
--- a/src/declarative/fx/qfxpathview.h
+++ b/src/declarative/fx/qfxpathview.h
@@ -44,7 +44,6 @@
#include <qfxitem.h>
#include <qfxpath.h>
-#include <gfxvalueproxy.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxpathview_p.h b/src/declarative/fx/qfxpathview_p.h
index 31933c0..a19d778 100644
--- a/src/declarative/fx/qfxpathview_p.h
+++ b/src/declarative/fx/qfxpathview_p.h
@@ -58,6 +58,7 @@
#include "qfxitem_p.h"
#include "qfxvisualitemmodel.h"
#include "qml.h"
+#include "qmltimelinevalueproxy.h"
#include "private/qmlanimation_p.h"
QT_BEGIN_NAMESPACE
@@ -79,7 +80,7 @@ public:
, firstIndex(0), pathItems(-1), pathOffset(0), model(0)
, moveReason(Other)
{
- fixupOffsetEvent = GfxEvent::gfxEvent<QFxPathViewPrivate, &QFxPathViewPrivate::fixOffset>(&moveOffset, this);
+ fixupOffsetEvent = QmlTimeLineEvent::timeLineEvent<QFxPathViewPrivate, &QFxPathViewPrivate::fixOffset>(&moveOffset, this);
}
void init()
@@ -115,8 +116,8 @@ public:
qreal snapPos;
qreal dragMargin;
QmlTimeLine tl;
- GfxValueProxy<QFxPathViewPrivate> moveOffset;
- GfxEvent fixupOffsetEvent;
+ QmlTimeLineValueProxy<QFxPathViewPrivate> moveOffset;
+ QmlTimeLineEvent fixupOffsetEvent;
int firstIndex;
int pathItems;
int pathOffset;
diff --git a/src/declarative/fx/qfxrepeater.cpp b/src/declarative/fx/qfxrepeater.cpp
index 570d54d..ad4081b 100644
--- a/src/declarative/fx/qfxrepeater.cpp
+++ b/src/declarative/fx/qfxrepeater.cpp
@@ -259,7 +259,7 @@ void QFxRepeater::regenerate()
QStringList sl = qvariant_cast<QStringList>(d->dataSource);
for(int ii = 0; ii < sl.size(); ++ii) {
- QmlContext *ctxt = new QmlContext(itemContext(), this);
+ QmlContext *ctxt = new QmlContext(qmlContext(this), this);
d->deletables << ctxt;
ctxt->setContextProperty(QLatin1String("index"), ii);
@@ -277,7 +277,7 @@ void QFxRepeater::regenerate()
QVariant v = QmlMetaType::listAt(d->dataSource, ii);
QObject *o = QmlMetaType::toQObject(v);
- QmlContext *ctxt = new QmlContext(itemContext(), this);
+ QmlContext *ctxt = new QmlContext(qmlContext(this), this);
d->deletables << ctxt;
ctxt->setContextProperty(QLatin1String("index"), ii);
@@ -292,7 +292,7 @@ void QFxRepeater::regenerate()
return;
for(int ii = 0; ii < cnt; ++ii) {
- QmlContext *ctxt = new QmlContext(itemContext(), this);
+ QmlContext *ctxt = new QmlContext(qmlContext(this), this);
d->deletables << ctxt;
ctxt->setContextProperty(QLatin1String("index"), ii);
@@ -313,7 +313,7 @@ void QFxRepeater::regenerate()
} else if (QObject *object = d->dataSource.value<QObject*>()) {
// A single object (i.e. list of size 1).
// Properties are the roles (excluding objectName).
- QmlContext *ctxt = new QmlContext(itemContext(), this);
+ QmlContext *ctxt = new QmlContext(qmlContext(this), this);
d->deletables << ctxt;
ctxt->setContextProperty(QLatin1String("index"), QVariant(0));
@@ -335,7 +335,7 @@ void QFxRepeater::regenerate()
int count = qvariant_cast<int>(d->dataSource);
for(int ii = 0; ii < count; ++ii) {
- QmlContext *ctxt = new QmlContext(itemContext(), this);
+ QmlContext *ctxt = new QmlContext(qmlContext(this), this);
d->deletables << ctxt;
ctxt->setContextProperty(QLatin1String("index"), ii);
diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp
index 145e750..e851bad 100644
--- a/src/declarative/fx/qfxvisualitemmodel.cpp
+++ b/src/declarative/fx/qfxvisualitemmodel.cpp
@@ -285,7 +285,7 @@ QFxVisualItemModelData *QFxVisualItemModelPrivate::data(QObject *item)
}
QFxVisualItemModel::QFxVisualItemModel()
-: QObject(*(new QFxVisualItemModelPrivate(QmlContext::activeContext())))
+: QObject(*(new QFxVisualItemModelPrivate(0)))
{
}
@@ -489,7 +489,9 @@ QFxItem *QFxVisualItemModel::item(int index, const QByteArray &viewId, bool comp
if(d->m_cache.contains(index)) {
nobj = d->m_cache[index];
} else {
- QmlContext *ctxt = new QmlContext(d->m_context);
+ QmlContext *ccontext = d->m_context;
+ if(!ccontext) ccontext = qmlContext(this);
+ QmlContext *ctxt = new QmlContext(ccontext);
QFxVisualItemModelData *data = new QFxVisualItemModelData(index, d);
ctxt->setContextProperty(QLatin1String("model"), data);
ctxt->addDefaultObject(data);
@@ -540,12 +542,14 @@ QVariant QFxVisualItemModel::evaluate(int index, const QString &expression, QObj
QObject *nobj = d->m_cache[index];
QFxItem *item = qobject_cast<QFxItem *>(nobj);
if (item) {
- QmlExpression e(item->itemContext(), expression, objectContext);
+ QmlExpression e(qmlContext(item), expression, objectContext);
e.setTrackChange(false);
value = e.value();
}
} else {
- QmlContext *ctxt = new QmlContext(d->m_context);
+ QmlContext *ccontext = d->m_context;
+ if(!ccontext) ccontext = qmlContext(this);
+ QmlContext *ctxt = new QmlContext(ccontext);
QFxVisualItemModelData *data = new QFxVisualItemModelData(index, d);
ctxt->addDefaultObject(data);
QmlExpression e(ctxt, expression, objectContext);
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index a5d2ac3..147415d 100644
--- a/src/declarative/fx/qfxwebview.cpp
+++ b/src/declarative/fx/qfxwebview.cpp
@@ -211,7 +211,8 @@ void QFxWebView::init()
pal.setBrush(QPalette::Base, QColor::fromRgbF(0, 0, 0, 0));
wp->setPalette(pal);
- wp->setNetworkAccessManager(itemContext()->engine()->networkAccessManager());
+ // ### Need to delay this as qmlEngine() is not set yet
+ wp->setNetworkAccessManager(qmlEngine(this)->networkAccessManager());
setPage(wp);
// XXX settable from QML?
@@ -313,7 +314,7 @@ void QFxWebView::setUrl(const QString &n)
QUrl url(n);
if (url.isRelative())
- url = itemContext()->resolvedUrl(n);
+ url = qmlContext(this)->resolvedUrl(n);
if (isComponentComplete())
d->page->mainFrame()->load(url);
@@ -372,12 +373,16 @@ void QFxWebView::setIdealHeight(int ih)
}
/*!
- \qmlproperty bool WebView::interactive
- This property holds controls whether the item responds to mouse and key events.
+ \qmlproperty bool WebView::interactive
+
+ This property holds controls whether the item responds to mouse and
+ key events.
*/
+
/*!
- \property QFxWebView::interactive
- \brief controls whether the item responds to mouse and key events.
+ \property QFxWebView::interactive
+
+ \brief controls whether the item responds to mouse and key events.
*/
bool QFxWebView::interactive() const
{
@@ -458,19 +463,19 @@ void QFxWebView::paintPage(const QRect& r)
}
/*!
- \qmlproperty int WebView::cacheSize
- This property holds the maximum number of pixels of image cache to allow
+ \qmlproperty int WebView::cacheSize
- The default is 0.1 megapixels.
-
- The cache will not be larger than the (unscaled) size of the WebView.
+ This property holds the maximum number of pixels of image cache to
+ allow. The default is 0.1 megapixels. The cache will not be larger
+ than the (unscaled) size of the WebView.
*/
+
/*!
- \property QFxWebView::cacheSize
- \brief the maximum number of pixels of image cache to allow
- The default is 0.1 megapixels.
+ \property QFxWebView::cacheSize
- The cache will not be larger than the (unscaled) size of the QFxWebView.
+ The maximum number of pixels of image cache to allow. The default
+ is 0.1 megapixels. The cache will not be larger than the (unscaled)
+ size of the QFxWebView.
*/
int QFxWebView::cacheSize() const
{
@@ -1026,7 +1031,7 @@ public:
propertyValues(paramValues),
webview(view)
{
- QmlEngine *engine = webview->itemContext()->engine();
+ QmlEngine *engine = qmlEngine(webview);
component = new QmlComponent(engine, url, this);
item = 0;
connect(engine, SIGNAL(statusChanged(Status)), this, SLOT(qmlLoaded()));
@@ -1035,7 +1040,7 @@ public:
public Q_SLOTS:
void qmlLoaded()
{
- item = qobject_cast<QFxItem*>(component->create(webview->itemContext()));
+ item = qobject_cast<QFxItem*>(component->create(qmlContext(webview)));
item->setParent(webview);
for (int i=0; i<propertyNames.count(); ++i) {
if (propertyNames[i] != QLatin1String("type") && propertyNames[i] != QLatin1String("data")) {
@@ -1070,7 +1075,7 @@ QFxWebView *QFxWebPage::view()
QObject *QFxWebPage::createPlugin(const QString &, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues)
{
- QUrl comp = view()->itemContext()->resolvedUri(url.toString());
+ QUrl comp = qmlContext(view())->resolvedUri(url.toString());
return new QWidget_Dummy_Plugin(comp,view(),paramNames,paramValues);
}
diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h
index 463d0c4..1eede52 100644
--- a/src/declarative/fx/qfxwebview.h
+++ b/src/declarative/fx/qfxwebview.h
@@ -92,8 +92,10 @@ class Q_DECLARATIVE_EXPORT QFxWebView : public QFxItem
Q_PROPERTY(int idealHeight READ idealHeight WRITE setIdealHeight NOTIFY idealHeightChanged)
Q_PROPERTY(QString url READ url WRITE setUrl NOTIFY urlChanged)
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth)
- Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged())
+ Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
+
Q_PROPERTY(bool interactive READ interactive WRITE setInteractive NOTIFY interactiveChanged)
+
Q_PROPERTY(int cacheSize READ cacheSize WRITE setCacheSize)
Q_PROPERTY(QObject* reload READ reloadAction)