summaryrefslogtreecommitdiffstats
path: root/src/declarative/util/qfxview.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-04-30 03:09:22 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-04-30 03:09:22 (GMT)
commit0282ea19722c247157c652ef9122379f0e715497 (patch)
tree9773641d150774bd8e66e87e33e5e8899a6a4a9c /src/declarative/util/qfxview.cpp
parentd85c0c07b72476d801db3f1cb622cb32ab50dcc4 (diff)
parente3c91e87a06b73a06c86f93c69951768874bbaf6 (diff)
downloadQt-0282ea19722c247157c652ef9122379f0e715497.zip
Qt-0282ea19722c247157c652ef9122379f0e715497.tar.gz
Qt-0282ea19722c247157c652ef9122379f0e715497.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Conflicts: src/declarative/qml/parser/javascriptgrammar.cpp src/declarative/qml/parser/javascriptgrammar_p.h
Diffstat (limited to 'src/declarative/util/qfxview.cpp')
-rw-r--r--src/declarative/util/qfxview.cpp54
1 files changed, 49 insertions, 5 deletions
diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp
index 1e9d5a4..42047b6 100644
--- a/src/declarative/util/qfxview.cpp
+++ b/src/declarative/util/qfxview.cpp
@@ -49,6 +49,7 @@
#include "qicon.h"
#include "qurl.h"
#include "qboxlayout.h"
+#include "qbasictimer.h"
#include "qmlbindablevalue.h"
#include "qml.h"
@@ -100,6 +101,8 @@ public:
QmlEngine engine;
QmlComponent *component;
+ QBasicTimer resizetimer;
+
void init();
};
@@ -107,10 +110,10 @@ public:
\class QFxView
\brief The QFxView class provides a widget for displaying a Qt Declarative user interface.
- QFxView currently provides a minimal interface for displaying Qml files, and
- connecting between QML and C++ Qt objects.
+ QFxView currently provides a minimal interface for displaying QML
+ files, and connecting between QML and C++ Qt objects.
- Typcial usage looks something like this:
+ Typcial usage:
\code
...
QFxView *view = new QFxView(this);
@@ -129,12 +132,24 @@ public:
\endcode
*/
+/*!
+ \fn QFxView::QFxView(QWidget *parent)
+
+ Constructs a QFxView with the given \a parent.
+*/
QFxView::QFxView(QWidget *parent)
: QSimpleCanvas(parent), d(new QFxViewPrivate(this))
{
d->init();
}
+/*!
+ \fn QFxView::QFxView(QSimpleCanvas::CanvasMode mode, QWidget *parent)
+
+ Constructs a QFxView with the given \a parent. The canvas
+ \a mode can be QSimpleCanvas::GraphicsView or
+ QSimpleCanvas::SimpleCanvas.
+*/
QFxView::QFxView(QSimpleCanvas::CanvasMode mode, QWidget *parent)
: QSimpleCanvas(mode, parent), d(new QFxViewPrivate(this))
{
@@ -157,29 +172,49 @@ void QFxViewPrivate::init()
QFontDatabase database;
}
+/*!
+ The destructor clears the instance and deletes the internal
+ representation.
+
+ \sa clearItems()
+ */
QFxView::~QFxView()
{
clearItems();
delete d; d = 0;
}
+/*!
+ Sets the source to the \a url. The XML string is set to
+ empty.
+ */
void QFxView::setUrl(const QUrl& url)
{
d->source = url;
d->xml = QString();
}
+/*!
+ Sets the source to the URL from the \a filename, and sets
+ the XML string to \a xml.
+ */
void QFxView::setXml(const QString &xml, const QString &filename)
{
d->source = QUrl::fromLocalFile(filename);
d->xml = xml;
}
+/*!
+ Returns the XML string.
+ */
QString QFxView::xml() const
{
return d->xml;
}
+/*!
+ Returns a pointer to the QmlEngine.
+ */
QmlEngine* QFxView::engine()
{
return &d->engine;
@@ -250,8 +285,17 @@ void QFxView::continueExecute()
void QFxView::sizeChanged()
{
- if (d->root)
- emit sceneResized(QSize(d->root->width(),d->root->height()));
+ // delay, so we catch both width and height changing.
+ d->resizetimer.start(0,this);
+}
+
+void QFxView::timerEvent(QTimerEvent* e)
+{
+ if (e->timerId() == d->resizetimer.timerId()) {
+ if (d->root)
+ emit sceneResized(QSize(d->root->width(),d->root->height()));
+ d->resizetimer.stop();
+ }
}
QFxItem* QFxView::addItem(const QString &xml, QFxItem* parent)