summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-07-22 03:23:39 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2010-07-22 05:04:04 (GMT)
commit0b83a2161261be525f01359397ab1c8c34827749 (patch)
tree96854cca2a179d36983b64d004a0673c6ca756c3
parent266a64d34d775b2ebcf1bffbf751cfe9437ceafe (diff)
downloadQt-0b83a2161261be525f01359397ab1c8c34827749.zip
Qt-0b83a2161261be525f01359397ab1c8c34827749.tar.gz
Qt-0b83a2161261be525f01359397ab1c8c34827749.tar.bz2
Make rootContext and engine pointers in QDeclarativeView API const
Task-number: QTBUG-12322 Reviewed-by: Aaron Kennedy
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp4
-rw-r--r--src/declarative/qml/qdeclarativeengine.h2
-rw-r--r--src/declarative/util/qdeclarativeview.cpp19
-rw-r--r--src/declarative/util/qdeclarativeview.h4
4 files changed, 15 insertions, 14 deletions
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 9dae64d..e3ebca3 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -578,9 +578,9 @@ void QDeclarativeEngine::clearComponentCache()
component instances should be added to sub-contexts parented to the
root context.
*/
-QDeclarativeContext *QDeclarativeEngine::rootContext()
+QDeclarativeContext *QDeclarativeEngine::rootContext() const
{
- Q_D(QDeclarativeEngine);
+ Q_D(const QDeclarativeEngine);
return d->rootContext;
}
diff --git a/src/declarative/qml/qdeclarativeengine.h b/src/declarative/qml/qdeclarativeengine.h
index 01487f5..d971d80 100644
--- a/src/declarative/qml/qdeclarativeengine.h
+++ b/src/declarative/qml/qdeclarativeengine.h
@@ -74,7 +74,7 @@ public:
QDeclarativeEngine(QObject *p = 0);
virtual ~QDeclarativeEngine();
- QDeclarativeContext *rootContext();
+ QDeclarativeContext *rootContext() const;
void clearComponentCache();
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
index 496f2ad..7546a50 100644
--- a/src/declarative/util/qdeclarativeview.cpp
+++ b/src/declarative/util/qdeclarativeview.cpp
@@ -132,7 +132,7 @@ class QDeclarativeViewPrivate : public QGraphicsViewPrivate, public QDeclarative
public:
QDeclarativeViewPrivate()
: root(0), declarativeItemRoot(0), graphicsWidgetRoot(0), component(0), resizeMode(QDeclarativeView::SizeViewToRootObject), initialSize(0,0) {}
- ~QDeclarativeViewPrivate() { delete root; }
+ ~QDeclarativeViewPrivate() { delete root; delete engine; }
void execute();
void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry);
void initResize();
@@ -145,7 +145,7 @@ public:
QUrl source;
- QDeclarativeEngine engine;
+ QDeclarativeEngine* engine;
QDeclarativeComponent *component;
QBasicTimer resizetimer;
@@ -170,7 +170,7 @@ void QDeclarativeViewPrivate::execute()
component = 0;
}
if (!source.isEmpty()) {
- component = new QDeclarativeComponent(&engine, source, q);
+ component = new QDeclarativeComponent(engine, source, q);
if (!component->isLoading()) {
q->continueExecute();
} else {
@@ -275,6 +275,7 @@ QDeclarativeView::QDeclarativeView(const QUrl &source, QWidget *parent)
void QDeclarativeViewPrivate::init()
{
Q_Q(QDeclarativeView);
+ engine = new QDeclarativeEngine();
q->setScene(&scene);
q->setOptimizationFlags(QGraphicsView::DontSavePainterState);
@@ -338,10 +339,10 @@ QUrl QDeclarativeView::source() const
Returns a pointer to the QDeclarativeEngine used for instantiating
QML Components.
*/
-QDeclarativeEngine* QDeclarativeView::engine()
+QDeclarativeEngine* QDeclarativeView::engine() const
{
- Q_D(QDeclarativeView);
- return &d->engine;
+ Q_D(const QDeclarativeView);
+ return d->engine;
}
/*!
@@ -351,10 +352,10 @@ QDeclarativeEngine* QDeclarativeView::engine()
arranged hierarchically and this hierarchy is managed by the
QDeclarativeEngine.
*/
-QDeclarativeContext* QDeclarativeView::rootContext()
+QDeclarativeContext* QDeclarativeView::rootContext() const
{
- Q_D(QDeclarativeView);
- return d->engine.rootContext();
+ Q_D(const QDeclarativeView);
+ return d->engine->rootContext();
}
/*!
diff --git a/src/declarative/util/qdeclarativeview.h b/src/declarative/util/qdeclarativeview.h
index cdcf134..d3e4948 100644
--- a/src/declarative/util/qdeclarativeview.h
+++ b/src/declarative/util/qdeclarativeview.h
@@ -75,8 +75,8 @@ public:
QUrl source() const;
void setSource(const QUrl&);
- QDeclarativeEngine* engine();
- QDeclarativeContext* rootContext();
+ QDeclarativeEngine* engine() const;
+ QDeclarativeContext* rootContext() const;
QGraphicsObject *rootObject() const;