diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-02-23 06:46:44 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-02-23 06:46:44 (GMT) |
commit | 5ffd6c0fba0ecc709551e414ed0649de15ac3754 (patch) | |
tree | 7db7006ef6349b48a75729766362e44d06999442 /src/declarative/util/qmlview.cpp | |
parent | 113e350e36c0ff31824bc238160094814dc3fb4f (diff) | |
download | Qt-5ffd6c0fba0ecc709551e414ed0649de15ac3754.zip Qt-5ffd6c0fba0ecc709551e414ed0649de15ac3754.tar.gz Qt-5ffd6c0fba0ecc709551e414ed0649de15ac3754.tar.bz2 |
Remove QmlView::execute(). QmlView::setSource() does it all now.
Task-number: QT-2538
Diffstat (limited to 'src/declarative/util/qmlview.cpp')
-rw-r--r-- | src/declarative/util/qmlview.cpp | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/src/declarative/util/qmlview.cpp b/src/declarative/util/qmlview.cpp index 400ae52..05c6460 100644 --- a/src/declarative/util/qmlview.cpp +++ b/src/declarative/util/qmlview.cpp @@ -132,6 +132,8 @@ public: QmlViewPrivate(QmlView *view) : q(view), root(0), component(0), resizeMode(QmlView::SizeViewToRootObject) {} + void execute(); + QmlView *q; QGuard<QGraphicsObject> root; @@ -152,6 +154,20 @@ public: QGraphicsScene scene; }; +void QmlViewPrivate::execute() +{ + delete root; + delete component; + component = new QmlComponent(&engine, source, q); + + if (!component->isLoading()) { + q->continueExecute(); + } else { + QObject::connect(component, SIGNAL(statusChanged(QmlComponent::Status)), q, SLOT(continueExecute())); + } +} + + /*! \class QmlView \brief The QmlView class provides a widget for displaying a Qt Declarative user interface. @@ -188,9 +204,6 @@ public: QUrl url(fileName); view->setSource(url); - ... - view->execute(); - ... view->show(); \endcode @@ -220,6 +233,19 @@ QmlView::QmlView(QWidget *parent) d->init(); } +/*! + \fn QmlView::QmlView(const QUrl &source, QWidget *parent) + + Constructs a QmlView with the given QML \a source and \a parent. +*/ +QmlView::QmlView(const QUrl &source, QWidget *parent) +: QGraphicsView(parent), d(new QmlViewPrivate(this)) +{ + setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); + d->init(); + setSource(source); +} + void QmlViewPrivate::init() { #ifdef Q_ENABLE_PERFORMANCE_LOG @@ -254,15 +280,14 @@ QmlView::~QmlView() } /*! - Sets the source to the \a url. - - Call \l execute() to load the QML and instantiate the component. - - \sa execute() + Sets the source to the \a url, loads the QML component and instantiates it. */ void QmlView::setSource(const QUrl& url) { - d->source = url; + if (url != d->source) { + d->source = url; + d->execute(); + } } /*! @@ -296,23 +321,6 @@ QmlContext* QmlView::rootContext() return d->engine.rootContext(); } -/*! - Loads and instantiates the QML component set by the \l setSource() method. - - \sa setSource() -*/ -void QmlView::execute() -{ - delete d->root; - delete d->component; - d->component = new QmlComponent(&d->engine, d->source, this); - - if (!d->component->isLoading()) { - continueExecute(); - } else { - connect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute())); - } -} /*! \enum QmlView::Status |