summaryrefslogtreecommitdiffstats
path: root/src/declarative/extra
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-04-27 05:36:11 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-04-27 05:36:11 (GMT)
commit9f941fd65083ae6d3f2f5441bf60346821932218 (patch)
tree4ccd25dd9de4835a551534de37a931e2105fa4d3 /src/declarative/extra
parentf75b524b060682a896ac7a3951ac677d29e15727 (diff)
downloadQt-9f941fd65083ae6d3f2f5441bf60346821932218.zip
Qt-9f941fd65083ae6d3f2f5441bf60346821932218.tar.gz
Qt-9f941fd65083ae6d3f2f5441bf60346821932218.tar.bz2
Add a declarative data ptr to QObjectPrivate
This data ptr does not increase the size of the QObject, as we take advantage of space only used during destruction. Currently this data is only used to store an object's QmlContext, but it will be used for more later.
Diffstat (limited to 'src/declarative/extra')
-rw-r--r--src/declarative/extra/qmlsqlconnection.cpp8
-rw-r--r--src/declarative/extra/qmlxmllistmodel.cpp6
2 files changed, 5 insertions, 9 deletions
diff --git a/src/declarative/extra/qmlsqlconnection.cpp b/src/declarative/extra/qmlsqlconnection.cpp
index 3e2032c..7f1fec2 100644
--- a/src/declarative/extra/qmlsqlconnection.cpp
+++ b/src/declarative/extra/qmlsqlconnection.cpp
@@ -62,7 +62,6 @@ public:
int port;
QString name, databaseName, connectionOptions;
QString hostName, userName, password, driver;
- QmlContext *context;
};
/*!
@@ -177,8 +176,6 @@ public:
QmlSqlConnection::QmlSqlConnection(QObject *parent)
: QObject(*(new QmlSqlConnectionPrivate), parent)
{
- Q_D(QmlSqlConnection);
- d->context = QmlContext::activeContext();
}
/*!
@@ -416,10 +413,11 @@ QSqlDatabase QmlSqlConnection::database() const
}
if (db.isOpen())
return db;
- if ((d->driver.isEmpty() || d->driver == QLatin1String("QSQLITE")) && d->context) {
+ if ((d->driver.isEmpty() || d->driver == QLatin1String("QSQLITE")) &&
+ qmlContext(this)) {
// SQLITE uses files for databases, hence use relative pathing
// if possible.
- QUrl url = d->context->resolvedUrl(d->databaseName);
+ QUrl url = qmlContext(this)->resolvedUrl(d->databaseName);
if (url.isRelative() || url.scheme() == QLatin1String("file"))
db.setDatabaseName(url.toLocalFile());
else
diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp
index 13faab2..44787b5 100644
--- a/src/declarative/extra/qmlxmllistmodel.cpp
+++ b/src/declarative/extra/qmlxmllistmodel.cpp
@@ -87,7 +87,7 @@ class QmlXmlListModelPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QmlXmlListModel)
public:
- QmlXmlListModelPrivate() : size(-1), highestRole(Qt::UserRole), reply(0), context(0), roleObjects(this) {}
+ QmlXmlListModelPrivate() : size(-1), highestRole(Qt::UserRole), reply(0), roleObjects(this) {}
QString src;
QString query;
@@ -100,7 +100,6 @@ public:
QNetworkReply *reply;
mutable QByteArray xml;
QString prefix;
- QmlContext *context;
struct RoleList : public QmlConcreteList<XmlListModelRole *>
{
@@ -144,7 +143,6 @@ QmlXmlListModel::QmlXmlListModel(QObject *parent)
: QListModelInterface(*(new QmlXmlListModelPrivate), parent)
{
Q_D(QmlXmlListModel);
- d->context = QmlContext::activeContext();
}
QmlXmlListModel::~QmlXmlListModel()
@@ -249,7 +247,7 @@ void QmlXmlListModel::fetch()
QNetworkRequest req((QUrl(d->src)));
req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
- d->reply = d->context->engine()->networkAccessManager()->get(req);
+ d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req);
QObject::connect(d->reply, SIGNAL(finished()),
this, SLOT(requestFinished()));
}