summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-04-27 05:56:06 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-04-27 05:56:06 (GMT)
commit7e94543a9b013b6b1140137ba64406b74a363afc (patch)
tree565db03ed0c733d8b6472a8b8bdb7f2cdba3b17e
parentcd8542ca836b175377f3b3471725b86f8739e91a (diff)
downloadQt-7e94543a9b013b6b1140137ba64406b74a363afc.zip
Qt-7e94543a9b013b6b1140137ba64406b74a363afc.tar.gz
Qt-7e94543a9b013b6b1140137ba64406b74a363afc.tar.bz2
Remove QFxItem::itemContext() method.
Use qmlContext(object) instead. This makes everything consistent.
-rw-r--r--src/declarative/fx/qfxanimatedimageitem.cpp4
-rw-r--r--src/declarative/fx/qfxblendedimage.cpp8
-rw-r--r--src/declarative/fx/qfxcomponentinstance.cpp2
-rw-r--r--src/declarative/fx/qfxgridview.cpp6
-rw-r--r--src/declarative/fx/qfximage.cpp8
-rw-r--r--src/declarative/fx/qfxitem.cpp22
-rw-r--r--src/declarative/fx/qfxitem.h2
-rw-r--r--src/declarative/fx/qfxkeyactions.cpp3
-rw-r--r--src/declarative/fx/qfxlistview.cpp8
-rw-r--r--src/declarative/fx/qfxmouseregion.cpp3
-rw-r--r--src/declarative/fx/qfxparticles.cpp4
-rw-r--r--src/declarative/fx/qfxrepeater.cpp10
-rw-r--r--src/declarative/fx/qfxvisualitemmodel.cpp2
-rw-r--r--src/declarative/fx/qfxwebview.cpp11
14 files changed, 42 insertions, 51 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 b5b7bb3..ec2b9cc 100644
--- a/src/declarative/fx/qfxblendedimage.cpp
+++ b/src/declarative/fx/qfxblendedimage.cpp
@@ -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()));
}
/*!
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/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/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 6e8a07d..0ed46bc 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -816,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()) {
@@ -831,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
@@ -852,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);
}
@@ -870,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);
@@ -1885,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();
@@ -1982,14 +1982,6 @@ void QFxItem::transformChanged(const QSimpleCanvas::Matrix &)
{
}
-/*!
- Returns the current QML context for this item.
-*/
-QmlContext *QFxItem::itemContext() const
-{
- return QmlEngine::contextForObject(this);
-}
-
QmlStateGroup *QFxItemPrivate::states()
{
Q_Q(QFxItem);
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index bfd493f..e2a2ebd 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -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/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 f25470b..e03ec47 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -394,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) {
@@ -580,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);
@@ -899,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);
@@ -944,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 54e3778..8b16098 100644
--- a/src/declarative/fx/qfxparticles.cpp
+++ b/src/declarative/fx/qfxparticles.cpp
@@ -613,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/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 dc68026..e851bad 100644
--- a/src/declarative/fx/qfxvisualitemmodel.cpp
+++ b/src/declarative/fx/qfxvisualitemmodel.cpp
@@ -542,7 +542,7 @@ 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();
}
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index 05e2f65..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);
@@ -1030,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()));
@@ -1039,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")) {
@@ -1074,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);
}