diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-05-01 06:31:14 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-05-01 06:31:14 (GMT) |
commit | 20e0828d3dcb806a67e29f31447621af1a3d8ea9 (patch) | |
tree | 6104f3cde6046157232f9fdf302d9b608623d63b | |
parent | 569389e7ab3d052da8bf549827776ffb4d154dba (diff) | |
download | Qt-20e0828d3dcb806a67e29f31447621af1a3d8ea9.zip Qt-20e0828d3dcb806a67e29f31447621af1a3d8ea9.tar.gz Qt-20e0828d3dcb806a67e29f31447621af1a3d8ea9.tar.bz2 |
Rename QFxView::setXml to QFxView::setQml.
-rw-r--r-- | doc/src/declarative/binding.qdoc | 8 | ||||
-rw-r--r-- | examples/declarative/contacts/main.cpp | 6 | ||||
-rw-r--r-- | examples/declarative/minehunt/main.cpp | 4 | ||||
-rw-r--r-- | src/declarative/test/qfxtestview.cpp | 4 | ||||
-rw-r--r-- | src/declarative/util/qfxview.cpp | 41 | ||||
-rw-r--r-- | src/declarative/util/qfxview.h | 16 |
6 files changed, 37 insertions, 42 deletions
diff --git a/doc/src/declarative/binding.qdoc b/doc/src/declarative/binding.qdoc index b711a08..1d4f9a1 100644 --- a/doc/src/declarative/binding.qdoc +++ b/doc/src/declarative/binding.qdoc @@ -87,16 +87,16 @@ void setBrightness(int b) Next, make an instance of this class visible to the Qml bind engine: \code QFxView *view = new QFxView; -view->setXml("MyUI.qml"); +view->setUrl("MyUI.qml"); MyScreen *screen = new MyScreen; -QmlBindContext *ctxt = view->bindContext(); -ctxt->setProperty("screen", screen); +QmlBindContext *ctxt = view->rootContext(); +ctxt->setContextProperty("screen", screen); view->execute(); \endcode -\note Bindings must be made after setXml() but before execute(). +\note Bindings must be made after setUrl() but before execute(). Finally, in Qml you can make the appropriate bindings, so in \c "MyUI.qml": diff --git a/examples/declarative/contacts/main.cpp b/examples/declarative/contacts/main.cpp index 6bf9daf..bda6565 100644 --- a/examples/declarative/contacts/main.cpp +++ b/examples/declarative/contacts/main.cpp @@ -7,7 +7,7 @@ #include <QTime> #include <QVBoxLayout> -const char *defaultFileName("contacts.xml"); +const char *defaultFileName("contacts.qml"); class Contacts : public QWidget { @@ -43,8 +43,8 @@ Contacts::Contacts(const QString &fileName, int width, int height, QWidget *pare QFile file(fileName); file.open(QFile::ReadOnly); - QString xml = file.readAll(); - canvas->setXml(xml, fileName); + QString qml = file.readAll(); + canvas->setQml(qml, fileName); canvas->execute(); } diff --git a/examples/declarative/minehunt/main.cpp b/examples/declarative/minehunt/main.cpp index 9db717b..7f10757 100644 --- a/examples/declarative/minehunt/main.cpp +++ b/examples/declarative/minehunt/main.cpp @@ -130,8 +130,8 @@ MyWidget::MyWidget(int width, int height, QWidget *parent, Qt::WindowFlags flags QFile file(fileName); file.open(QFile::ReadOnly); - QString xml = file.readAll(); - canvas->setXml(xml, fileName); + QString qml = file.readAll(); + canvas->setQml(qml, fileName); QmlContext *ctxt = canvas->rootContext(); ctxt->activate(); diff --git a/src/declarative/test/qfxtestview.cpp b/src/declarative/test/qfxtestview.cpp index 67b6c15..94bcb30 100644 --- a/src/declarative/test/qfxtestview.cpp +++ b/src/declarative/test/qfxtestview.cpp @@ -59,8 +59,8 @@ QFxTestView::QFxTestView(const QString &filename, const QString &testdir) QFile file(filename); file.open(QFile::ReadOnly); - QString xml = QString::fromUtf8(file.readAll()); - setXml(xml, filename); + QString qml = QString::fromUtf8(file.readAll()); + setQml(qml, filename); execute(); } diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp index aefe3e4..cac73a0 100644 --- a/src/declarative/util/qfxview.cpp +++ b/src/declarative/util/qfxview.cpp @@ -97,7 +97,7 @@ public: QFxItem *root; QUrl source; - QString xml; + QString qml; QmlEngine engine; QmlComponent *component; @@ -113,20 +113,15 @@ public: QFxView currently provides a minimal interface for displaying QML files, and connecting between QML and C++ Qt objects. - Typcial usage: + Typical usage: \code ... QFxView *view = new QFxView(this); vbox->addWidget(view); - QFile file(fileName); - file.open(QFile::ReadOnly); - QString xml = file.readAll(); - view->setXml(xml, fileName); - - QFileInfo fi(file); - view->setPath(fi.path()); - + QUrl url(fileName); + view->setUrl(url); + ... view->execute(); ... \endcode @@ -185,31 +180,31 @@ QFxView::~QFxView() } /*! - Sets the source to the \a url. The XML string is set to + Sets the source to the \a url. The QML string is set to empty. */ void QFxView::setUrl(const QUrl& url) { d->source = url; - d->xml = QString(); + d->qml = QString(); } /*! Sets the source to the URL from the \a filename, and sets - the XML string to \a xml. + the QML string to \a qml. */ -void QFxView::setXml(const QString &xml, const QString &filename) +void QFxView::setQml(const QString &qml, const QString &filename) { d->source = QUrl::fromLocalFile(filename); - d->xml = xml; + d->qml = qml; } /*! - Returns the XML string. + Returns the QML string. */ -QString QFxView::xml() const +QString QFxView::qml() const { - return d->xml; + return d->qml; } /*! @@ -240,10 +235,10 @@ void QFxView::execute() { rootContext()->activate(); - if (d->xml.isEmpty()) { + if (d->qml.isEmpty()) { d->component = new QmlComponent(&d->engine, d->source, this); } else { - d->component = new QmlComponent(&d->engine, d->xml.toUtf8(), d->source); + d->component = new QmlComponent(&d->engine, d->qml.toUtf8(), d->source); } if (!d->component->isLoading()) { @@ -324,17 +319,17 @@ void QFxView::timerEvent(QTimerEvent* e) } /*! - Creates a \l{QmlComponent} {component} from the \a xml + Creates a \l{QmlComponent} {component} from the \a qml string, and returns it as an \l {QFxItem} {item}. If the \a parent item is provided, it becomes the new item's parent. \a parent should be in this view's item hierarchy. */ -QFxItem* QFxView::addItem(const QString &xml, QFxItem* parent) +QFxItem* QFxView::addItem(const QString &qml, QFxItem* parent) { if (!d->root) return 0; - QmlComponent component(&d->engine, xml.toUtf8(), QUrl()); + QmlComponent component(&d->engine, qml.toUtf8(), QUrl()); QObject *obj = component.create(); if (obj){ QFxItem *item = static_cast<QFxItem *>(obj); diff --git a/src/declarative/util/qfxview.h b/src/declarative/util/qfxview.h index c658f07..d2cacf4 100644 --- a/src/declarative/util/qfxview.h +++ b/src/declarative/util/qfxview.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef _QFXVIEW_H_ -#define _QFXVIEW_H_ +#ifndef QFXVIEW_H +#define QFXVIEW_H #include <qfxglobal.h> #include <QtCore/qdatetime.h> @@ -48,12 +48,12 @@ #include <QtGui/qwidget.h> #include <qsimplecanvas.h> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxItem; class QmlEngine; class QmlContext; @@ -70,14 +70,14 @@ public: virtual ~QFxView(); void setUrl(const QUrl&); - void setXml(const QString &xml, const QString &filename=QString()); - QString xml() const; + void setQml(const QString &qml, const QString &filename=QString()); + QString qml() const; QmlEngine* engine(); QmlContext* rootContext(); virtual void execute(); virtual void reset(); - virtual QFxItem* addItem(const QString &xml, QFxItem* parent=0); + virtual QFxItem* addItem(const QString &qml, QFxItem* parent=0); virtual void clearItems(); virtual QFxItem *root() const; @@ -102,8 +102,8 @@ private: QFxViewPrivate *d; }; - QT_END_NAMESPACE QT_END_HEADER -#endif // _QFXVIEW_H_ + +#endif // QFXVIEW_H |