From ab3634173ba5d5ed084710a32508ea728378d038 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Tue, 22 Sep 2009 09:45:55 +1000 Subject: Repeater doc update. --- doc/src/snippets/declarative/repeater.qml | 16 +++++++++------- src/declarative/fx/qfxrepeater.cpp | 10 +++++----- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/doc/src/snippets/declarative/repeater.qml b/doc/src/snippets/declarative/repeater.qml index 309fead..f8ac856 100644 --- a/doc/src/snippets/declarative/repeater.qml +++ b/doc/src/snippets/declarative/repeater.qml @@ -1,14 +1,16 @@ import Qt 4.6 +Rectangle { + width: 220; height: 20; color: "white" + //! [0] -Rectangle { width: 220; height: 20; color: "white" - Component { id: Dot - Rectangle { width: 20; height: 20; radius: 10; color: "green" } - } - HorizontalLayout { + Row { Rectangle { width: 10; height: 20; color: "red" } - Repeater { component: Dot; dataSource: 10 } + Repeater { + model: 10 + Rectangle { width: 20; height: 20; radius: 10; color: "green" } + } Rectangle { width: 10; height: 20; color: "blue" } } -} //! [0] +} diff --git a/src/declarative/fx/qfxrepeater.cpp b/src/declarative/fx/qfxrepeater.cpp index 719aea9..84804ce 100644 --- a/src/declarative/fx/qfxrepeater.cpp +++ b/src/declarative/fx/qfxrepeater.cpp @@ -62,15 +62,15 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Repeater,QFxRepeater) \qmlclass Repeater \inherits Item - \brief The Repeater item allows you to repeat a component based on a data source. + \brief The Repeater item allows you to repeat a component based on a model. The Repeater item is used when you want to create a large number of - similar items. For each entry in the data source, an item is instantiated - in a context seeded with data from the data source. If the repeater will + similar items. For each entry in the model, an item is instantiated + in a context seeded with data from the model. If the repeater will be instantiating a large number of instances, it may be more efficient to use one of Qt Declarative's \l {xmlViews}{view items}. - The data source may be either an object list, a string list or a Qt model. + The model may be either an object list, a string list, a number or a Qt model. In each case, the data element and the index is exposed to each instantiated component. The index is always exposed as an accessible \c index property. In the case of an object or string list, the data element (of type string @@ -131,7 +131,7 @@ QFxRepeater::~QFxRepeater() The model providing data for the repeater. - The model may be either an object list, a string list or a Qt model. + The model may be either an object list, a string list, a number or a Qt model. In each case, the data element and the index is exposed to each instantiated component. The index is always exposed as an accessible \c index property. In the case of an object or string list, the data element (of type string -- cgit v0.12 From c38c6f984f3b08db106dcd249c3339d42cc82aa3 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 22 Sep 2009 10:06:49 +1000 Subject: Missing files. --- examples/declarative/modules/local/Foo.qml | 6 ++++++ examples/declarative/modules/local/SubLib/Bar.qml | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 examples/declarative/modules/local/Foo.qml create mode 100644 examples/declarative/modules/local/SubLib/Bar.qml diff --git a/examples/declarative/modules/local/Foo.qml b/examples/declarative/modules/local/Foo.qml new file mode 100644 index 0000000..6cb07d5 --- /dev/null +++ b/examples/declarative/modules/local/Foo.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +Text { + text: "lib/Foo.qml" + color: "#00ff00" +} diff --git a/examples/declarative/modules/local/SubLib/Bar.qml b/examples/declarative/modules/local/SubLib/Bar.qml new file mode 100644 index 0000000..ad09d2e --- /dev/null +++ b/examples/declarative/modules/local/SubLib/Bar.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +Text { + text: "lib/SubLib/Bar.qml" + color: "#8898FF" +} -- cgit v0.12 From d125e01313b269d70577975f6e78d28a9105ada1 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 22 Sep 2009 10:07:01 +1000 Subject: Ensure absolute path for qmldir URL. --- src/declarative/qml/qmlengine.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index c6edbe2..dd6b5a4 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -1519,8 +1519,9 @@ public: bool found = false; foreach (QString p, importPath) { QString dir = p+QLatin1Char('/')+url; - if (QFile::exists(dir+QLatin1String("/qmldir"))) { - url = QLatin1String("file://")+dir; + QFileInfo fi(dir+QLatin1String("/qmldir")); + if (fi.isFile()) { + url = QUrl::fromLocalFile(fi.absolutePath()).toString(); found = true; break; } -- cgit v0.12 From 7aee99a762280251297486f118ca2a3cd6762883 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 22 Sep 2009 10:24:23 +1000 Subject: Syntax update id must not be a type Image::fillMode change --- examples/declarative/aspectratio/face_fit.qml | 6 +++--- .../declarative/aspectratio/face_fit_animated.qml | 6 +++--- examples/declarative/aspectratio/scale_and_crop.qml | 6 +++--- .../declarative/aspectratio/scale_and_crop_simple.qml | 19 +++++++++++++++++++ .../declarative/aspectratio/scale_and_sidecrop.qml | 6 +++--- examples/declarative/aspectratio/scale_to_fit.qml | 6 +++--- .../declarative/aspectratio/scale_to_fit_simple.qml | 10 +++++----- 7 files changed, 39 insertions(+), 20 deletions(-) create mode 100644 examples/declarative/aspectratio/scale_and_crop_simple.qml diff --git a/examples/declarative/aspectratio/face_fit.qml b/examples/declarative/aspectratio/face_fit.qml index 4573160..8d38cca 100644 --- a/examples/declarative/aspectratio/face_fit.qml +++ b/examples/declarative/aspectratio/face_fit.qml @@ -8,13 +8,13 @@ import Qt 4.6 // Rectangle { // default size: whole image, unscaled - width: Image.width - height: Image.height + width: Face.width + height: Face.height color: "gray" clip: true Image { - id: Image + id: Face source: "pics/face.png" x: (parent.width-width*scale)/2 y: (parent.height-height*scale)/2 diff --git a/examples/declarative/aspectratio/face_fit_animated.qml b/examples/declarative/aspectratio/face_fit_animated.qml index 7db1c80..7d73900 100644 --- a/examples/declarative/aspectratio/face_fit_animated.qml +++ b/examples/declarative/aspectratio/face_fit_animated.qml @@ -6,13 +6,13 @@ import Qt 4.6 // Rectangle { // default size: whole image, unscaled - width: Image.width - height: Image.height + width: Face.width + height: Face.height color: "gray" clip: true Image { - id: Image + id: Face source: "pics/face.png" x: (parent.width-width*scale)/2 y: (parent.height-height*scale)/2 diff --git a/examples/declarative/aspectratio/scale_and_crop.qml b/examples/declarative/aspectratio/scale_and_crop.qml index 75080b4..3cace8d 100644 --- a/examples/declarative/aspectratio/scale_and_crop.qml +++ b/examples/declarative/aspectratio/scale_and_crop.qml @@ -4,13 +4,13 @@ import Qt 4.6 // Rectangle { // default size: whole image, unscaled - width: Image.width - height: Image.height + width: Face.width + height: Face.height color: "gray" clip: true Image { - id: Image + id: Face source: "pics/face.png" x: (parent.width-width*scale)/2 y: (parent.height-height*scale)/2 diff --git a/examples/declarative/aspectratio/scale_and_crop_simple.qml b/examples/declarative/aspectratio/scale_and_crop_simple.qml new file mode 100644 index 0000000..26758e6 --- /dev/null +++ b/examples/declarative/aspectratio/scale_and_crop_simple.qml @@ -0,0 +1,19 @@ +import Qt 4.6 + +// Here, we implement "Scale to Fit" behaviour, using the +// fillMode property. +// +Rectangle { + // default size: whole image, unscaled + width: Face.width + height: Face.height + color: "gray" + clip: true + + Image { + id: Face + source: "pics/face.png" + fillMode: "PreserveAspectCrop" + anchors.fill: parent + } +} diff --git a/examples/declarative/aspectratio/scale_and_sidecrop.qml b/examples/declarative/aspectratio/scale_and_sidecrop.qml index a6bd2c8..18cc110 100644 --- a/examples/declarative/aspectratio/scale_and_sidecrop.qml +++ b/examples/declarative/aspectratio/scale_and_sidecrop.qml @@ -5,13 +5,13 @@ import Qt 4.6 // Rectangle { // default size: whole image, unscaled - width: Image.width - height: Image.height + width: Face.width + height: Face.height color: "gray" clip: true Image { - id: Image + id: Face source: "pics/face.png" x: (parent.width-width*scale)/2 y: (parent.height-height*scale)/2 diff --git a/examples/declarative/aspectratio/scale_to_fit.qml b/examples/declarative/aspectratio/scale_to_fit.qml index 744abce..7450ea4 100644 --- a/examples/declarative/aspectratio/scale_to_fit.qml +++ b/examples/declarative/aspectratio/scale_to_fit.qml @@ -5,13 +5,13 @@ import Qt 4.6 // Rectangle { // default size: whole image, unscaled - width: Image.width - height: Image.height + width: Face.width + height: Face.height color: "gray" clip: true Image { - id: Image + id: Face source: "pics/face.png" x: (parent.width-width*scale)/2 y: (parent.height-height*scale)/2 diff --git a/examples/declarative/aspectratio/scale_to_fit_simple.qml b/examples/declarative/aspectratio/scale_to_fit_simple.qml index 4ee06ba..dcccd69 100644 --- a/examples/declarative/aspectratio/scale_to_fit_simple.qml +++ b/examples/declarative/aspectratio/scale_to_fit_simple.qml @@ -1,19 +1,19 @@ import Qt 4.6 // Here, we implement "Scale to Fit" behaviour, using the -// preserveAspect property. +// fillMode property. // Rectangle { // default size: whole image, unscaled - width: Image.width - height: Image.height + width: Face.width + height: Face.height color: "gray" clip: true Image { - id: Image + id: Face source: "pics/face.png" - fillMode: "PreserveAspect" + fillMode: "PreserveAspectFit" anchors.fill: parent } } -- cgit v0.12 From 5e5c9c8a7b3184f1c7874fec47d9e3c133cb7146 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 22 Sep 2009 10:38:30 +1000 Subject: import does not currently insist on a version, it should for these cases (but not for non-installed local files) --- .../declarative/qmlparser/importVersionMissingBuiltIn.errors.txt | 1 + tests/auto/declarative/qmlparser/importVersionMissingBuiltIn.qml | 7 +++++++ .../declarative/qmlparser/importVersionMissingInstalled.errors.txt | 1 + tests/auto/declarative/qmlparser/importVersionMissingInstalled.qml | 3 +++ tests/auto/declarative/qmlparser/tst_qmlparser.cpp | 2 ++ 5 files changed, 14 insertions(+) create mode 100644 tests/auto/declarative/qmlparser/importVersionMissingBuiltIn.errors.txt create mode 100644 tests/auto/declarative/qmlparser/importVersionMissingBuiltIn.qml create mode 100644 tests/auto/declarative/qmlparser/importVersionMissingInstalled.errors.txt create mode 100644 tests/auto/declarative/qmlparser/importVersionMissingInstalled.qml diff --git a/tests/auto/declarative/qmlparser/importVersionMissingBuiltIn.errors.txt b/tests/auto/declarative/qmlparser/importVersionMissingBuiltIn.errors.txt new file mode 100644 index 0000000..2235cbc --- /dev/null +++ b/tests/auto/declarative/qmlparser/importVersionMissingBuiltIn.errors.txt @@ -0,0 +1 @@ +SHOULD GIVE AN ERROR ABOUT MISSING VERSION diff --git a/tests/auto/declarative/qmlparser/importVersionMissingBuiltIn.qml b/tests/auto/declarative/qmlparser/importVersionMissingBuiltIn.qml new file mode 100644 index 0000000..23ed566 --- /dev/null +++ b/tests/auto/declarative/qmlparser/importVersionMissingBuiltIn.qml @@ -0,0 +1,7 @@ +import Test as S + +S.MyQmlObject { + property real x; + property real y; +} + diff --git a/tests/auto/declarative/qmlparser/importVersionMissingInstalled.errors.txt b/tests/auto/declarative/qmlparser/importVersionMissingInstalled.errors.txt new file mode 100644 index 0000000..2235cbc --- /dev/null +++ b/tests/auto/declarative/qmlparser/importVersionMissingInstalled.errors.txt @@ -0,0 +1 @@ +SHOULD GIVE AN ERROR ABOUT MISSING VERSION diff --git a/tests/auto/declarative/qmlparser/importVersionMissingInstalled.qml b/tests/auto/declarative/qmlparser/importVersionMissingInstalled.qml new file mode 100644 index 0000000..97ec222 --- /dev/null +++ b/tests/auto/declarative/qmlparser/importVersionMissingInstalled.qml @@ -0,0 +1,3 @@ +import com.nokia.installedtest as T + +T.InstalledTest {} diff --git a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp index b8bd0e7..ee1b072 100644 --- a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp +++ b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp @@ -160,6 +160,8 @@ void tst_qmlparser::errors_data() QTest::newRow("finalOverride") << "finalOverride.qml" << "finalOverride.errors.txt" << false; QTest::newRow("importNamespaceConflict") << "importNamespaceConflict.qml" << "importNamespaceConflict.errors.txt" << false; + QTest::newRow("importVersionMissing (builtin)") << "importVersionMissingBuiltIn.qml" << "importVersionMissingBuiltIn.errors.txt" << false; + QTest::newRow("importVersionMissing (installed)") << "importVersionMissingInstalled.qml" << "importVersionMissingInstalled.errors.txt" << false; QTest::newRow("customParserIdNotAllowed") << "customParserIdNotAllowed.qml" << "customParserIdNotAllowed.errors.txt" << false; } -- cgit v0.12 From ee72eef536c42a3f18d59fd5f3e1d14eb8d8e9d9 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 22 Sep 2009 14:10:29 +1000 Subject: Fixes for framerate monitor. --- src/declarative/util/qfxview.cpp | 2 +- tools/qmldebugger/canvasframerate.cpp | 23 ++++++++++++++++++++++- tools/qmldebugger/canvasframerate.h | 2 ++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp index f67dc75..17bbd1b 100644 --- a/src/declarative/util/qfxview.cpp +++ b/src/declarative/util/qfxview.cpp @@ -103,7 +103,7 @@ public: int e = timer.elapsed(); QByteArray data; QDataStream ds(&data, QIODevice::WriteOnly); - ds << (int)pe << (int)pe << (int)tbf << (int)e + ds << (int)pe << (int)tbf << (int)e << (bool)isFrameBreak; sendMessage(data); } diff --git a/tools/qmldebugger/canvasframerate.cpp b/tools/qmldebugger/canvasframerate.cpp index ae514a5..0d23050 100644 --- a/tools/qmldebugger/canvasframerate.cpp +++ b/tools/qmldebugger/canvasframerate.cpp @@ -13,6 +13,8 @@ #include #include #include +#include +#include QT_BEGIN_NAMESPACE @@ -26,6 +28,7 @@ public: public slots: void addSample(int, int, int, bool); + void setResolutionForHeight(int); protected: virtual void paintEvent(QPaintEvent *); @@ -153,7 +156,7 @@ void QLineGraph::drawSample(QPainter *p, int s, const QRect &rect) first = qMax(0, _samples.count() - samplesPerWidth - 1); int last = qMin(_samples.count() - 1, first + samplesPerWidth); - qreal scaleY = rect.height() / resolutionForHeight; + qreal scaleY = qreal(rect.height()) / resolutionForHeight; qreal scaleX = qreal(rect.width()) / qreal(samplesPerWidth); int xEnd; @@ -205,6 +208,12 @@ void QLineGraph::paintEvent(QPaintEvent *) drawTime(&p, r); } +void QLineGraph::setResolutionForHeight(int resolution) +{ + resolutionForHeight = resolution; + update(); +} + class CanvasFrameRatePlugin : public QmlDebugClient { Q_OBJECT @@ -256,7 +265,18 @@ CanvasFrameRate::CanvasFrameRate(QmlDebugConnection *client, QWidget *parent) layout->addWidget(m_tabs); QHBoxLayout *bottom = new QHBoxLayout; + bottom->setSpacing(5); layout->addLayout(bottom); + + QLabel *label = new QLabel("Resolution", this); + bottom->addWidget(label); + + m_spin = new QSpinBox(this); + m_spin->setRange(50,200); + m_spin->setValue(50); + m_spin->setSuffix("ms"); + bottom->addWidget(m_spin); + bottom->addStretch(2); QCheckBox *check = new QCheckBox("Enable", this); @@ -284,6 +304,7 @@ void CanvasFrameRate::newTab() QLineGraph *graph = new QLineGraph(this); QObject::connect(m_plugin, SIGNAL(sample(int,int,int,bool)), graph, SLOT(addSample(int,int,int,bool))); + QObject::connect(m_spin, SIGNAL(valueChanged(int)), graph, SLOT(setResolutionForHeight(int))); QString name = QLatin1String("Graph ") + QString::number(id); m_tabs->addTab(graph, name); diff --git a/tools/qmldebugger/canvasframerate.h b/tools/qmldebugger/canvasframerate.h index 912412b..cef267d 100644 --- a/tools/qmldebugger/canvasframerate.h +++ b/tools/qmldebugger/canvasframerate.h @@ -7,6 +7,7 @@ QT_BEGIN_NAMESPACE class QmlDebugConnection; class QTabWidget; +class QSpinBox; class CanvasFrameRate : public QWidget { Q_OBJECT @@ -19,6 +20,7 @@ private slots: private: QTabWidget *m_tabs; + QSpinBox *m_spin; QObject *m_plugin; }; -- cgit v0.12 From 835a83221232d1963d4ab0b9e553cc32cb9bc8c9 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Tue, 22 Sep 2009 14:30:07 +1000 Subject: Renaming: QFxView -> QmlView --- demos/declarative/minehunt/main.cpp | 6 +- doc/src/declarative/binding.qdoc | 2 +- doc/src/declarative/focus.qdoc | 2 +- doc/src/declarative/qtprogrammers.qdoc | 2 +- examples/declarative/loader/main.cpp | 6 +- src/declarative/fx/qfxborderimage.cpp | 2 +- src/declarative/fx/qfximage.cpp | 2 +- src/declarative/fx/qfxitem.cpp | 4 +- src/declarative/fx/qfxpainteditem.cpp | 2 +- src/declarative/fx/qfxrect.cpp | 4 +- src/declarative/fx/qfxtext.cpp | 2 +- src/declarative/fx/qfxtextedit.cpp | 2 +- src/declarative/fx/qfxwebview.cpp | 2 +- src/declarative/util/qfxview.cpp | 579 --------------------- src/declarative/util/qfxview.h | 113 ---- src/declarative/util/qmlview.cpp | 579 +++++++++++++++++++++ src/declarative/util/qmlview.h | 113 ++++ src/declarative/util/util.pri | 4 +- tests/auto/declarative/anchors/tst_anchors.cpp | 14 +- .../auto/declarative/animations/tst_animations.cpp | 4 +- tests/auto/declarative/layouts/tst_layouts.cpp | 20 +- tests/auto/declarative/listview/tst_listview.cpp | 16 +- tests/auto/declarative/pathview/tst_pathview.cpp | 14 +- .../declarative/qfxtextedit/tst_qfxtextedit.cpp | 4 +- .../declarative/qfxtextinput/tst_qfxtextinput.cpp | 20 +- tests/auto/declarative/repeater/tst_repeater.cpp | 10 +- tests/auto/declarative/visual/tst_visual.cpp | 2 +- tools/qmldebugger/engine.cpp | 2 +- tools/qmldebugger/engine.h | 4 +- tools/qmlviewer/qfxtester.cpp | 4 +- tools/qmlviewer/qfxtester.h | 4 +- tools/qmlviewer/qmlviewer.cpp | 4 +- tools/qmlviewer/qmlviewer.h | 4 +- 33 files changed, 776 insertions(+), 776 deletions(-) delete mode 100644 src/declarative/util/qfxview.cpp delete mode 100644 src/declarative/util/qfxview.h create mode 100644 src/declarative/util/qmlview.cpp create mode 100644 src/declarative/util/qmlview.h diff --git a/demos/declarative/minehunt/main.cpp b/demos/declarative/minehunt/main.cpp index 20f7492..a9b8828 100644 --- a/demos/declarative/minehunt/main.cpp +++ b/demos/declarative/minehunt/main.cpp @@ -2,7 +2,7 @@ #include "qmlcontext.h" #include "qml.h" #include -#include +#include #include #include @@ -94,7 +94,7 @@ private: int getHint(int row, int col); void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();} - QFxView *canvas; + QmlView *canvas; QList _tiles; int numCols; @@ -123,7 +123,7 @@ MyWidget::MyWidget(int width, int height, QWidget *parent, Qt::WindowFlags flags vbox->setMargin(0); setLayout(vbox); - canvas = new QFxView(this); + canvas = new QmlView(this); canvas->setFixedSize(width, height); vbox->addWidget(canvas); diff --git a/doc/src/declarative/binding.qdoc b/doc/src/declarative/binding.qdoc index 7e8933f..37b4c97 100644 --- a/doc/src/declarative/binding.qdoc +++ b/doc/src/declarative/binding.qdoc @@ -86,7 +86,7 @@ void setBrightness(int b) Next, make an instance of this class visible to the QML bind engine: \code -QFxView *view = new QFxView; +QmlView *view = new QmlView; view->setUrl("MyUI.qml"); MyScreen *screen = new MyScreen; diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc index 7c293ee..028b5f0 100644 --- a/doc/src/declarative/focus.qdoc +++ b/doc/src/declarative/focus.qdoc @@ -13,7 +13,7 @@ and to address some of the cases unique to fluid user interfaces, the QML items When the user presses or releases a key, the following occurs: \list 1 \o Qt receives the key action and generates a key event. -\o If the Qt widget containing the \l QFxView has focus, the key event is delivered to it. Otherwise, regular Qt key handling continues. +\o If the Qt widget containing the \l QmlView has focus, the key event is delivered to it. Otherwise, regular Qt key handling continues. \o The key event is delivered by the scene to the QML \l Item with \e {active focus}. If no \l Item has \e {active focus}, the key event is \l {QEvent::ignore()}{ignored} and regular Qt key handling continues. \o If the QML \l Item with \e {active focus} accepts the key event, propagation stops. Otherwise the event is "bubbled up", by recursively passing it to each \l Item's parent until either the event is accepted, or the root \l Item is reached. diff --git a/doc/src/declarative/qtprogrammers.qdoc b/doc/src/declarative/qtprogrammers.qdoc index 742fc07..3b20539 100644 --- a/doc/src/declarative/qtprogrammers.qdoc +++ b/doc/src/declarative/qtprogrammers.qdoc @@ -20,7 +20,7 @@ QML provides direct access to the following concepts from Qt: \o QAction - the \l {basicqmlaction}{action} type \o QObject signals and slots - available as functions to call in JavaScript \o QObject properties - available as variables in JavaScript - \o QWidget - QFxView is a QML-displaying widget + \o QWidget - QmlView is a QML-displaying widget \o Qt models - used directly in data binding (QAbstractItemModel and next generation QListModelInterface) \endlist diff --git a/examples/declarative/loader/main.cpp b/examples/declarative/loader/main.cpp index 68f20d4..fbae5f1 100644 --- a/examples/declarative/loader/main.cpp +++ b/examples/declarative/loader/main.cpp @@ -11,12 +11,12 @@ #include #include #include -#include +#include #include #include #include -QFxView *canvas = 0; +QmlView *canvas = 0; class Logger : public QWidget { @@ -181,7 +181,7 @@ int main(int argc, char *argv[]) QObject::connect(Logger::instance(), SIGNAL(textChanged()), launcher, SIGNAL(logUpdated())); - canvas = new QFxView; + canvas = new QmlView; canvas->setFocusPolicy(Qt::StrongFocus); canvas->engine()->setNetworkAccessManager(new ConfiguredNetworkAccessManager); diff --git a/src/declarative/fx/qfxborderimage.cpp b/src/declarative/fx/qfxborderimage.cpp index ee505f2..3bc76da 100644 --- a/src/declarative/fx/qfxborderimage.cpp +++ b/src/declarative/fx/qfxborderimage.cpp @@ -65,7 +65,7 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,BorderImage,QFxBorderImage) /*! \internal \class QFxBorderImage BorderImage - \brief The QFxBorderImage class provides an image item that you can add to a QFxView. + \brief The QFxBorderImage class provides an image item that you can add to a QmlView. */ QFxBorderImage::QFxBorderImage(QFxItem *parent) diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index 3ac3f3c..860af66 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -113,7 +113,7 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Image,QFxImage) /*! \internal \class QFxImage Image - \brief The QFxImage class provides an image item that you can add to a QFxView. + \brief The QFxImage class provides an image item that you can add to a QmlView. \ingroup group_coreitems diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 1ca5254..7f4e6b1 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -56,7 +56,7 @@ #include "qmlstate.h" #include "qlistmodelinterface.h" -#include "qfxview.h" +#include "qmlview.h" #include "qmlstategroup.h" #include "qfxitem_p.h" @@ -1216,7 +1216,7 @@ QFxKeysAttached *QFxKeysAttached::qmlAttachedProperties(QObject *obj) /*! \class QFxItem Item - \brief The QFxItem class is a generic QFxView item. It is the base class for all other view items. + \brief The QFxItem class is a generic QmlView item. It is the base class for all other view items. \qmltext All visual items in Qt Declarative inherit from QFxItem. Although QFxItem diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp index 5471e1b..1ed44a9 100644 --- a/src/declarative/fx/qfxpainteditem.cpp +++ b/src/declarative/fx/qfxpainteditem.cpp @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE /*! \class QFxPaintedItem - \brief The QFxPaintedItem class is an abstract base class for QFxView items that want cached painting. + \brief The QFxPaintedItem class is an abstract base class for QmlView items that want cached painting. \ingroup group_coreitems This is a convenience class for implementing items that paint their contents diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index 7d6340f..1a41b5d 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -52,7 +52,7 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Gradient,QFxGradient) /*! \internal \class QFxPen - \brief The QFxPen class provides a pen used for drawing rectangle borders on a QFxView. + \brief The QFxPen class provides a pen used for drawing rectangle borders on a QmlView. By default, the pen is invalid and nothing is drawn. You must either set a color (then the default width is 1) or a width (then the default color is black). @@ -175,7 +175,7 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rectangle,QFxRect) /*! \internal \class QFxRect - \brief The QFxRect class provides a rectangle item that you can add to a QFxView. + \brief The QFxRect class provides a rectangle item that you can add to a QmlView. */ QFxRect::QFxRect(QFxItem *parent) : QFxItem(*(new QFxRectPrivate), parent) diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp index a76b8e6..7c7b3b0 100644 --- a/src/declarative/fx/qfxtext.cpp +++ b/src/declarative/fx/qfxtext.cpp @@ -84,7 +84,7 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Text,QFxText) \qmlclass Text \ingroup group_coreitems - \brief The QFxText class provides a formatted text item that you can add to a QFxView. + \brief The QFxText class provides a formatted text item that you can add to a QmlView. Text was designed for read-only text; it does not allow for any text editing. It can display both plain and rich text. For example: diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index d1bafd6..8094d32 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -84,7 +84,7 @@ TextEdit { \qmlclass TextEdit \ingroup group_coreitems - \brief The QFxTextEdit class provides an editable formatted text item that you can add to a QFxView. + \brief The QFxTextEdit class provides an editable formatted text item that you can add to a QmlView. It can display both plain and rich text. diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index bcbedfb..a06e294 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -241,7 +241,7 @@ public: /*! \internal \class QFxWebView - \brief The QFxWebView class allows you to add web content to a QFxView. + \brief The QFxWebView class allows you to add web content to a QmlView. A WebView renders web content base on a URL. diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp deleted file mode 100644 index f67dc75..0000000 --- a/src/declarative/util/qfxview.cpp +++ /dev/null @@ -1,579 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qscriptvalueiterator.h" -#include "qdebug.h" -#include "qtimer.h" -#include "qevent.h" -#include "qdir.h" -#include "qcoreapplication.h" -#include "qfontdatabase.h" -#include "qicon.h" -#include "qurl.h" -#include "qboxlayout.h" -#include "qbasictimer.h" - -#include "qml.h" -#include "qfxitem.h" -#include "private/qperformancelog_p.h" -#include "private/qfxperf_p.h" - -#include "qfxview.h" -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -DEFINE_BOOL_CONFIG_OPTION(frameRateDebug, QML_SHOW_FRAMERATE) - -class QFxViewDebugServer; -class FrameBreakAnimation : public QAbstractAnimation -{ -public: - FrameBreakAnimation(QFxViewDebugServer *s) - : QAbstractAnimation((QObject*)s), server(s) - { - start(); - } - - virtual int duration() const { return -1; } - virtual void updateCurrentTime(int msecs); - -private: - QFxViewDebugServer *server; -}; - -class QFxViewDebugServer : public QmlDebugService -{ -public: - QFxViewDebugServer(QObject *parent = 0) : QmlDebugService(QLatin1String("CanvasFrameRate"), parent), breaks(0) - { - timer.start(); - new FrameBreakAnimation(this); - } - - void addTiming(int pe, int tbf) - { - if (!isEnabled()) - return; - - bool isFrameBreak = breaks > 1; - breaks = 0; - int e = timer.elapsed(); - QByteArray data; - QDataStream ds(&data, QIODevice::WriteOnly); - ds << (int)pe << (int)pe << (int)tbf << (int)e - << (bool)isFrameBreak; - sendMessage(data); - } - - void frameBreak() { ++breaks; } - -private: - QTime timer; - int breaks; -}; - -Q_GLOBAL_STATIC(QFxViewDebugServer, qfxViewDebugServer); - -void FrameBreakAnimation::updateCurrentTime(int msecs) -{ - Q_UNUSED(msecs); - server->frameBreak(); -} - - -static QVariant stringToKeySequence(const QString &str) -{ - return QVariant::fromValue(QKeySequence(str)); -} - -class QFxViewPrivate -{ -public: - QFxViewPrivate(QFxView *w) - : q(w), root(0), component(0), resizable(false) {} - - QFxView *q; - QFxItem *root; - - QUrl source; - QString qml; - - QmlEngine engine; - QmlComponent *component; - QBasicTimer resizetimer; - - QSize initialSize; - bool resizable; - QTime frameTimer; - - void init(); - - QGraphicsScene scene; -}; - -/*! - \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. - - Typical usage: - \code - ... - QFxView *view = new QFxView(this); - vbox->addWidget(view); - - QUrl url(fileName); - view->setUrl(url); - ... - view->execute(); - ... - \endcode -*/ - -/*! - \fn QFxView::QFxView(QWidget *parent) - - Constructs a QFxView with the given \a parent. -*/ -QFxView::QFxView(QWidget *parent) -: QGraphicsView(parent), d(new QFxViewPrivate(this)) -{ - setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); - d->init(); -} - -void QFxViewPrivate::init() -{ - // XXX: These need to be put in a central location for this kind of thing - QmlMetaType::registerCustomStringConverter(QVariant::KeySequence, &stringToKeySequence); - -#ifdef Q_ENABLE_PERFORMANCE_LOG - QFxPerfTimer perf; -#endif - QFontDatabase database; - - q->setScene(&scene); - - q->setOptimizationFlags(QGraphicsView::DontSavePainterState); - q->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - q->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - q->setFrameStyle(0); - - // These seem to give the best performance - q->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); - scene.setItemIndexMethod(QGraphicsScene::NoIndex); - q->viewport()->setFocusPolicy(Qt::NoFocus); - - scene.setStickyFocus(true); //### needed for correct focus handling -} - -/*! - The destructor clears the view's \l {QFxItem} {items} and - deletes the internal representation. - - \sa clearItems() - */ -QFxView::~QFxView() -{ - clearItems(); - delete d; d = 0; -} - -/*! - Sets the source to the \a url. The QML string is set to - empty. - */ -void QFxView::setUrl(const QUrl& url) -{ - d->source = url; - d->qml = QString(); -} - -/*! - Sets the source to the URL from the \a filename, and sets - the QML string to \a qml. - */ -void QFxView::setQml(const QString &qml, const QString &filename) -{ - d->source = QUrl::fromLocalFile(filename); - d->qml = qml; -} - -/*! - Returns the QML string. - */ -QString QFxView::qml() const -{ - return d->qml; -} - -/*! - Returns a pointer to the QmlEngine used for instantiating - QML Components. - */ -QmlEngine* QFxView::engine() -{ - return &d->engine; -} - -/*! - This function returns the root of the context hierarchy. Each QML - component is instantiated in a QmlContext. QmlContext's are - essential for passing data to QML components. In QML, contexts are - arranged hierarchically and this hierarchy is managed by the - QmlEngine. - */ -QmlContext* QFxView::rootContext() -{ - return d->engine.rootContext(); -} - -/*! - Displays the Qt Declarative user interface. -*/ -void QFxView::execute() -{ - if (d->qml.isEmpty()) { - d->component = new QmlComponent(&d->engine, d->source, this); - } else { - d->component = new QmlComponent(&d->engine, d->qml.toUtf8(), d->source, this); - } - - if (!d->component->isLoading()) { - continueExecute(); - } else { - connect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute())); - } -} - - -/*! - \internal - */ -void QFxView::continueExecute() -{ - disconnect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute())); - - if (!d->component) { - qWarning() << "Error in loading" << d->source; - return; - } - - if(d->component->isError()) { - QList errorList = d->component->errors(); - foreach (const QmlError &error, errorList) { - qWarning() << error; - } - emit errors(errorList); - - return; - } - - QObject *obj = d->component->create(); - - if(d->component->isError()) { - QList errorList = d->component->errors(); - foreach (const QmlError &error, errorList) { - qWarning() << error; - } - emit errors(errorList); - - return; - } - - if (obj) { - if (QFxItem *item = qobject_cast(obj)) { - - d->scene.addItem(item); - - QPerformanceLog::displayData(); - QPerformanceLog::clear(); - d->root = item; - connect(item, SIGNAL(widthChanged()), this, SLOT(sizeChanged())); - connect(item, SIGNAL(heightChanged()), this, SLOT(sizeChanged())); - if (d->initialSize.height() <= 0 && d->root->width() > 0) - d->initialSize.setWidth(d->root->width()); - if (d->initialSize.height() <= 0 && d->root->height() > 0) - d->initialSize.setHeight(d->root->height()); - if (d->resizable) { - d->root->setWidth(width()); - d->root->setHeight(height()); - } else { - QSize sz(d->root->width(),d->root->height()); - emit sceneResized(sz); - resize(sz); - } - } else if (QWidget *wid = qobject_cast(obj)) { - window()->setAttribute(Qt::WA_OpaquePaintEvent, false); - window()->setAttribute(Qt::WA_NoSystemBackground, false); - if (!layout()) { - setLayout(new QVBoxLayout); - layout()->setContentsMargins(0, 0, 0, 0); - } else if (layout()->count()) { - // Hide the QGraphicsView in GV mode. - QLayoutItem *item = layout()->itemAt(0); - if (item->widget()) - item->widget()->hide(); - } - layout()->addWidget(wid); - emit sceneResized(wid->size()); - } - } -} - -/*! \fn void QFxView::sceneResized(QSize size) - This signal is emitted when the view is resized to \a size. - */ - -/*! \fn void QFxView::errors(const QList &errors) - This signal is emitted when the qml loaded contains \a errors. - */ - -/*! - \internal - */ -void QFxView::sizeChanged() -{ - // delay, so we catch both width and height changing. - d->resizetimer.start(0,this); -} - -/*! - If the \l {QTimerEvent} {timer event} \a e is this - view's resize timer, sceneResized() is emitted. - */ -void QFxView::timerEvent(QTimerEvent* e) -{ - if (!e || e->timerId() == d->resizetimer.timerId()) { - if (d->root) { - QSize sz(d->root->width(),d->root->height()); - emit sceneResized(sz); - //if (!d->resizable) - //resize(sz); - } - d->resizetimer.stop(); - updateGeometry(); - } -} - -// modelled on QScrollArea::widgetResizable -/*! - \property QFxView::contentResizable - \brief whether the view should resize the canvas contents - - If this property is set to false (the default), the view - resizes with the root item in the QML. - - If this property is set to true, the view will - automatically resize the root item. - - Regardless of this property, the sizeHint of the view - is the initial size of the root item. -*/ - -void QFxView::setContentResizable(bool on) -{ - if (d->resizable != on) { - d->resizable = on; - if (d->root) { - if (on) { - d->root->setWidth(width()); - d->root->setHeight(height()); - } else { - d->root->setWidth(d->initialSize.width()); - d->root->setHeight(d->initialSize.height()); - } - } - } -} - -bool QFxView::contentResizable() const -{ - return d->resizable; -} - - -/*! - The size hint is the size of the root item. -*/ -QSize QFxView::sizeHint() const -{ - if (d->root) { - if (d->initialSize.width() <= 0) - d->initialSize.setWidth(d->root->width()); - if (d->initialSize.height() <= 0) - d->initialSize.setHeight(d->root->height()); - } - return d->initialSize; -} - -/*! - 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 &qml, QFxItem* parent) -{ - if (!d->root) - return 0; - - QmlComponent component(&d->engine, qml.toUtf8(), QUrl()); - if(d->component->isError()) { - QList errorList = d->component->errors(); - foreach (const QmlError &error, errorList) { - qWarning() << error; - } - emit errors(errorList); - - return 0; - } - - QObject *obj = component.create(); - if(d->component->isError()) { - QList errorList = d->component->errors(); - foreach (const QmlError &error, errorList) { - qWarning() << error; - } - emit errors(errorList); - - return 0; - } - - if (obj){ - QFxItem *item = static_cast(obj); - if (!parent) - parent = d->root; - - item->setParentItem(parent); - return item; - } - return 0; -} - -/*! - Deletes the view's \l {QFxItem} {items} and the \l {QmlEngine} - {QML engine's} Component cache. - */ -void QFxView::reset() -{ - clearItems(); - d->engine.clearComponentCache(); - d->initialSize = QSize(); -} - -/*! - Deletes the view's \l {QFxItem} {items}. - */ -void QFxView::clearItems() -{ - if (!d->root) - return; - delete d->root; - d->root = 0; -} - -/*! - Returns the view's root \l {QFxItem} {item}. - */ -QFxItem *QFxView::root() const -{ - return d->root; -} - -/*! - This function handles the \l {QResizeEvent} {resize event} - \a e. - */ -void QFxView::resizeEvent(QResizeEvent *e) -{ - if (d->resizable && d->root) { - d->root->setWidth(width()); - d->root->setHeight(height()); - } - setSceneRect(rect()); - QGraphicsView::resizeEvent(e); -} - -/*! - \reimp -*/ -void QFxView::paintEvent(QPaintEvent *event) -{ - int time = 0; - if (frameRateDebug() || QFxViewDebugServer::isDebuggingEnabled()) - time = d->frameTimer.restart(); - QGraphicsView::paintEvent(event); - if (QFxViewDebugServer::isDebuggingEnabled()) - qfxViewDebugServer()->addTiming(d->frameTimer.elapsed(), time); - if (frameRateDebug()) - qDebug() << "paintEvent:" << d->frameTimer.elapsed() << "time since last frame:" << time; -} - -/*! \fn void QFxView::focusInEvent(QFocusEvent *e) - This virtual function does nothing with the event \a e - in this class. - */ -void QFxView::focusInEvent(QFocusEvent *e) -{ - // Do nothing (do not call QWidget::update()) - QGraphicsView::focusInEvent(e); -} - - -/*! \fn void QFxView::focusOutEvent(QFocusEvent *e) - This virtual function does nothing with the event \a e - in this class. - */ -void QFxView::focusOutEvent(QFocusEvent *e) -{ - // Do nothing (do not call QWidget::update()) - QGraphicsView::focusOutEvent(e); -} - -QT_END_NAMESPACE diff --git a/src/declarative/util/qfxview.h b/src/declarative/util/qfxview.h deleted file mode 100644 index 25e2997..0000000 --- a/src/declarative/util/qfxview.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFXVIEW_H -#define QFXVIEW_H - -#include -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QFxItem; -class QmlEngine; -class QmlContext; -class QmlError; - -class QFxViewPrivate; -class Q_DECLARATIVE_EXPORT QFxView : public QGraphicsView -{ - Q_OBJECT - Q_PROPERTY(bool contentResizable READ contentResizable WRITE setContentResizable) -public: - explicit QFxView(QWidget *parent = 0); - - virtual ~QFxView(); - - void setUrl(const QUrl&); - 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 &qml, QFxItem* parent=0); - virtual void clearItems(); - - virtual QFxItem *root() const; - - void setContentResizable(bool); - bool contentResizable() const; - QSize sizeHint() const; - -Q_SIGNALS: - void sceneResized(QSize size); - void errors(const QList &error); - -private Q_SLOTS: - void continueExecute(); - void sizeChanged(); - -protected: - virtual void resizeEvent(QResizeEvent *); - virtual void paintEvent(QPaintEvent *event); - void focusInEvent(QFocusEvent *); - void focusOutEvent(QFocusEvent *); - void timerEvent(QTimerEvent*); - -private: - friend class QFxViewPrivate; - QFxViewPrivate *d; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QFXVIEW_H diff --git a/src/declarative/util/qmlview.cpp b/src/declarative/util/qmlview.cpp new file mode 100644 index 0000000..d277cf1 --- /dev/null +++ b/src/declarative/util/qmlview.cpp @@ -0,0 +1,579 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qscriptvalueiterator.h" +#include "qdebug.h" +#include "qtimer.h" +#include "qevent.h" +#include "qdir.h" +#include "qcoreapplication.h" +#include "qfontdatabase.h" +#include "qicon.h" +#include "qurl.h" +#include "qboxlayout.h" +#include "qbasictimer.h" + +#include "qml.h" +#include "qfxitem.h" +#include "private/qperformancelog_p.h" +#include "private/qfxperf_p.h" + +#include "qmlview.h" +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +DEFINE_BOOL_CONFIG_OPTION(frameRateDebug, QML_SHOW_FRAMERATE) + +class QmlViewDebugServer; +class FrameBreakAnimation : public QAbstractAnimation +{ +public: + FrameBreakAnimation(QmlViewDebugServer *s) + : QAbstractAnimation((QObject*)s), server(s) + { + start(); + } + + virtual int duration() const { return -1; } + virtual void updateCurrentTime(int msecs); + +private: + QmlViewDebugServer *server; +}; + +class QmlViewDebugServer : public QmlDebugService +{ +public: + QmlViewDebugServer(QObject *parent = 0) : QmlDebugService(QLatin1String("CanvasFrameRate"), parent), breaks(0) + { + timer.start(); + new FrameBreakAnimation(this); + } + + void addTiming(int pe, int tbf) + { + if (!isEnabled()) + return; + + bool isFrameBreak = breaks > 1; + breaks = 0; + int e = timer.elapsed(); + QByteArray data; + QDataStream ds(&data, QIODevice::WriteOnly); + ds << (int)pe << (int)pe << (int)tbf << (int)e + << (bool)isFrameBreak; + sendMessage(data); + } + + void frameBreak() { ++breaks; } + +private: + QTime timer; + int breaks; +}; + +Q_GLOBAL_STATIC(QmlViewDebugServer, qfxViewDebugServer); + +void FrameBreakAnimation::updateCurrentTime(int msecs) +{ + Q_UNUSED(msecs); + server->frameBreak(); +} + + +static QVariant stringToKeySequence(const QString &str) +{ + return QVariant::fromValue(QKeySequence(str)); +} + +class QmlViewPrivate +{ +public: + QmlViewPrivate(QmlView *w) + : q(w), root(0), component(0), resizable(false) {} + + QmlView *q; + QFxItem *root; + + QUrl source; + QString qml; + + QmlEngine engine; + QmlComponent *component; + QBasicTimer resizetimer; + + QSize initialSize; + bool resizable; + QTime frameTimer; + + void init(); + + QGraphicsScene scene; +}; + +/*! + \class QmlView + \brief The QmlView class provides a widget for displaying a Qt Declarative user interface. + + QmlView currently provides a minimal interface for displaying QML + files, and connecting between QML and C++ Qt objects. + + Typical usage: + \code + ... + QmlView *view = new QmlView(this); + vbox->addWidget(view); + + QUrl url(fileName); + view->setUrl(url); + ... + view->execute(); + ... + \endcode +*/ + +/*! + \fn QmlView::QmlView(QWidget *parent) + + Constructs a QmlView with the given \a parent. +*/ +QmlView::QmlView(QWidget *parent) +: QGraphicsView(parent), d(new QmlViewPrivate(this)) +{ + setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); + d->init(); +} + +void QmlViewPrivate::init() +{ + // XXX: These need to be put in a central location for this kind of thing + QmlMetaType::registerCustomStringConverter(QVariant::KeySequence, &stringToKeySequence); + +#ifdef Q_ENABLE_PERFORMANCE_LOG + QFxPerfTimer perf; +#endif + QFontDatabase database; + + q->setScene(&scene); + + q->setOptimizationFlags(QGraphicsView::DontSavePainterState); + q->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + q->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + q->setFrameStyle(0); + + // These seem to give the best performance + q->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); + scene.setItemIndexMethod(QGraphicsScene::NoIndex); + q->viewport()->setFocusPolicy(Qt::NoFocus); + + scene.setStickyFocus(true); //### needed for correct focus handling +} + +/*! + The destructor clears the view's \l {QFxItem} {items} and + deletes the internal representation. + + \sa clearItems() + */ +QmlView::~QmlView() +{ + clearItems(); + delete d; d = 0; +} + +/*! + Sets the source to the \a url. The QML string is set to + empty. + */ +void QmlView::setUrl(const QUrl& url) +{ + d->source = url; + d->qml = QString(); +} + +/*! + Sets the source to the URL from the \a filename, and sets + the QML string to \a qml. + */ +void QmlView::setQml(const QString &qml, const QString &filename) +{ + d->source = QUrl::fromLocalFile(filename); + d->qml = qml; +} + +/*! + Returns the QML string. + */ +QString QmlView::qml() const +{ + return d->qml; +} + +/*! + Returns a pointer to the QmlEngine used for instantiating + QML Components. + */ +QmlEngine* QmlView::engine() +{ + return &d->engine; +} + +/*! + This function returns the root of the context hierarchy. Each QML + component is instantiated in a QmlContext. QmlContext's are + essential for passing data to QML components. In QML, contexts are + arranged hierarchically and this hierarchy is managed by the + QmlEngine. + */ +QmlContext* QmlView::rootContext() +{ + return d->engine.rootContext(); +} + +/*! + Displays the Qt Declarative user interface. +*/ +void QmlView::execute() +{ + if (d->qml.isEmpty()) { + d->component = new QmlComponent(&d->engine, d->source, this); + } else { + d->component = new QmlComponent(&d->engine, d->qml.toUtf8(), d->source, this); + } + + if (!d->component->isLoading()) { + continueExecute(); + } else { + connect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute())); + } +} + + +/*! + \internal + */ +void QmlView::continueExecute() +{ + disconnect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute())); + + if (!d->component) { + qWarning() << "Error in loading" << d->source; + return; + } + + if(d->component->isError()) { + QList errorList = d->component->errors(); + foreach (const QmlError &error, errorList) { + qWarning() << error; + } + emit errors(errorList); + + return; + } + + QObject *obj = d->component->create(); + + if(d->component->isError()) { + QList errorList = d->component->errors(); + foreach (const QmlError &error, errorList) { + qWarning() << error; + } + emit errors(errorList); + + return; + } + + if (obj) { + if (QFxItem *item = qobject_cast(obj)) { + + d->scene.addItem(item); + + QPerformanceLog::displayData(); + QPerformanceLog::clear(); + d->root = item; + connect(item, SIGNAL(widthChanged()), this, SLOT(sizeChanged())); + connect(item, SIGNAL(heightChanged()), this, SLOT(sizeChanged())); + if (d->initialSize.height() <= 0 && d->root->width() > 0) + d->initialSize.setWidth(d->root->width()); + if (d->initialSize.height() <= 0 && d->root->height() > 0) + d->initialSize.setHeight(d->root->height()); + if (d->resizable) { + d->root->setWidth(width()); + d->root->setHeight(height()); + } else { + QSize sz(d->root->width(),d->root->height()); + emit sceneResized(sz); + resize(sz); + } + } else if (QWidget *wid = qobject_cast(obj)) { + window()->setAttribute(Qt::WA_OpaquePaintEvent, false); + window()->setAttribute(Qt::WA_NoSystemBackground, false); + if (!layout()) { + setLayout(new QVBoxLayout); + layout()->setContentsMargins(0, 0, 0, 0); + } else if (layout()->count()) { + // Hide the QGraphicsView in GV mode. + QLayoutItem *item = layout()->itemAt(0); + if (item->widget()) + item->widget()->hide(); + } + layout()->addWidget(wid); + emit sceneResized(wid->size()); + } + } +} + +/*! \fn void QmlView::sceneResized(QSize size) + This signal is emitted when the view is resized to \a size. + */ + +/*! \fn void QmlView::errors(const QList &errors) + This signal is emitted when the qml loaded contains \a errors. + */ + +/*! + \internal + */ +void QmlView::sizeChanged() +{ + // delay, so we catch both width and height changing. + d->resizetimer.start(0,this); +} + +/*! + If the \l {QTimerEvent} {timer event} \a e is this + view's resize timer, sceneResized() is emitted. + */ +void QmlView::timerEvent(QTimerEvent* e) +{ + if (!e || e->timerId() == d->resizetimer.timerId()) { + if (d->root) { + QSize sz(d->root->width(),d->root->height()); + emit sceneResized(sz); + //if (!d->resizable) + //resize(sz); + } + d->resizetimer.stop(); + updateGeometry(); + } +} + +// modelled on QScrollArea::widgetResizable +/*! + \property QmlView::contentResizable + \brief whether the view should resize the canvas contents + + If this property is set to false (the default), the view + resizes with the root item in the QML. + + If this property is set to true, the view will + automatically resize the root item. + + Regardless of this property, the sizeHint of the view + is the initial size of the root item. +*/ + +void QmlView::setContentResizable(bool on) +{ + if (d->resizable != on) { + d->resizable = on; + if (d->root) { + if (on) { + d->root->setWidth(width()); + d->root->setHeight(height()); + } else { + d->root->setWidth(d->initialSize.width()); + d->root->setHeight(d->initialSize.height()); + } + } + } +} + +bool QmlView::contentResizable() const +{ + return d->resizable; +} + + +/*! + The size hint is the size of the root item. +*/ +QSize QmlView::sizeHint() const +{ + if (d->root) { + if (d->initialSize.width() <= 0) + d->initialSize.setWidth(d->root->width()); + if (d->initialSize.height() <= 0) + d->initialSize.setHeight(d->root->height()); + } + return d->initialSize; +} + +/*! + 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* QmlView::addItem(const QString &qml, QFxItem* parent) +{ + if (!d->root) + return 0; + + QmlComponent component(&d->engine, qml.toUtf8(), QUrl()); + if(d->component->isError()) { + QList errorList = d->component->errors(); + foreach (const QmlError &error, errorList) { + qWarning() << error; + } + emit errors(errorList); + + return 0; + } + + QObject *obj = component.create(); + if(d->component->isError()) { + QList errorList = d->component->errors(); + foreach (const QmlError &error, errorList) { + qWarning() << error; + } + emit errors(errorList); + + return 0; + } + + if (obj){ + QFxItem *item = static_cast(obj); + if (!parent) + parent = d->root; + + item->setParentItem(parent); + return item; + } + return 0; +} + +/*! + Deletes the view's \l {QFxItem} {items} and the \l {QmlEngine} + {QML engine's} Component cache. + */ +void QmlView::reset() +{ + clearItems(); + d->engine.clearComponentCache(); + d->initialSize = QSize(); +} + +/*! + Deletes the view's \l {QFxItem} {items}. + */ +void QmlView::clearItems() +{ + if (!d->root) + return; + delete d->root; + d->root = 0; +} + +/*! + Returns the view's root \l {QFxItem} {item}. + */ +QFxItem *QmlView::root() const +{ + return d->root; +} + +/*! + This function handles the \l {QResizeEvent} {resize event} + \a e. + */ +void QmlView::resizeEvent(QResizeEvent *e) +{ + if (d->resizable && d->root) { + d->root->setWidth(width()); + d->root->setHeight(height()); + } + setSceneRect(rect()); + QGraphicsView::resizeEvent(e); +} + +/*! + \reimp +*/ +void QmlView::paintEvent(QPaintEvent *event) +{ + int time = 0; + if (frameRateDebug() || QmlViewDebugServer::isDebuggingEnabled()) + time = d->frameTimer.restart(); + QGraphicsView::paintEvent(event); + if (QmlViewDebugServer::isDebuggingEnabled()) + qfxViewDebugServer()->addTiming(d->frameTimer.elapsed(), time); + if (frameRateDebug()) + qDebug() << "paintEvent:" << d->frameTimer.elapsed() << "time since last frame:" << time; +} + +/*! \fn void QmlView::focusInEvent(QFocusEvent *e) + This virtual function does nothing with the event \a e + in this class. + */ +void QmlView::focusInEvent(QFocusEvent *e) +{ + // Do nothing (do not call QWidget::update()) + QGraphicsView::focusInEvent(e); +} + + +/*! \fn void QmlView::focusOutEvent(QFocusEvent *e) + This virtual function does nothing with the event \a e + in this class. + */ +void QmlView::focusOutEvent(QFocusEvent *e) +{ + // Do nothing (do not call QWidget::update()) + QGraphicsView::focusOutEvent(e); +} + +QT_END_NAMESPACE diff --git a/src/declarative/util/qmlview.h b/src/declarative/util/qmlview.h new file mode 100644 index 0000000..b54101f --- /dev/null +++ b/src/declarative/util/qmlview.h @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFXVIEW_H +#define QFXVIEW_H + +#include +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QFxItem; +class QmlEngine; +class QmlContext; +class QmlError; + +class QmlViewPrivate; +class Q_DECLARATIVE_EXPORT QmlView : public QGraphicsView +{ + Q_OBJECT + Q_PROPERTY(bool contentResizable READ contentResizable WRITE setContentResizable) +public: + explicit QmlView(QWidget *parent = 0); + + virtual ~QmlView(); + + void setUrl(const QUrl&); + 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 &qml, QFxItem* parent=0); + virtual void clearItems(); + + virtual QFxItem *root() const; + + void setContentResizable(bool); + bool contentResizable() const; + QSize sizeHint() const; + +Q_SIGNALS: + void sceneResized(QSize size); + void errors(const QList &error); + +private Q_SLOTS: + void continueExecute(); + void sizeChanged(); + +protected: + virtual void resizeEvent(QResizeEvent *); + virtual void paintEvent(QPaintEvent *event); + void focusInEvent(QFocusEvent *); + void focusOutEvent(QFocusEvent *); + void timerEvent(QTimerEvent*); + +private: + friend class QmlViewPrivate; + QmlViewPrivate *d; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QFXVIEW_H diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri index 442380a..41c9019 100644 --- a/src/declarative/util/util.pri +++ b/src/declarative/util/util.pri @@ -1,5 +1,5 @@ SOURCES += \ - util/qfxview.cpp \ + util/qmlview.cpp \ util/qfxperf.cpp \ util/qperformancelog.cpp \ util/qmlconnection.cpp \ @@ -23,7 +23,7 @@ SOURCES += \ util/qmlbind.cpp HEADERS += \ - util/qfxview.h \ + util/qmlview.h \ util/qfxperf_p.h \ util/qfxglobal.h \ util/qperformancelog_p.h \ diff --git a/tests/auto/declarative/anchors/tst_anchors.cpp b/tests/auto/declarative/anchors/tst_anchors.cpp index 98ede65..a8b119c 100644 --- a/tests/auto/declarative/anchors/tst_anchors.cpp +++ b/tests/auto/declarative/anchors/tst_anchors.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include class tst_anchors : public QObject @@ -43,7 +43,7 @@ T *tst_anchors::findItem(QFxItem *parent, const QString &objectName) void tst_anchors::basicAnchors() { - QFxView *view = new QFxView; + QmlView *view = new QmlView; view->setUrl(QUrl("file://" SRCDIR "/data/anchors.qml")); view->execute(); @@ -93,7 +93,7 @@ void tst_anchors::basicAnchors() void tst_anchors::loops() { { - QFxView *view = new QFxView; + QmlView *view = new QmlView; view->setUrl(QUrl("file://" SRCDIR "/data/loop1.qml")); @@ -105,7 +105,7 @@ void tst_anchors::loops() } { - QFxView *view = new QFxView; + QmlView *view = new QmlView; view->setUrl(QUrl("file://" SRCDIR "/data/loop2.qml")); @@ -120,7 +120,7 @@ void tst_anchors::loops() void tst_anchors::illegalSets() { { - QFxView *view = new QFxView; + QmlView *view = new QmlView; view->setUrl(QUrl("file://" SRCDIR "/data/illegal1.qml")); @@ -132,7 +132,7 @@ void tst_anchors::illegalSets() } { - QFxView *view = new QFxView; + QmlView *view = new QmlView; view->setUrl(QUrl("file://" SRCDIR "/data/illegal2.qml")); @@ -144,7 +144,7 @@ void tst_anchors::illegalSets() } { - QFxView *view = new QFxView; + QmlView *view = new QmlView; view->setUrl(QUrl("file://" SRCDIR "/data/illegal3.qml")); diff --git a/tests/auto/declarative/animations/tst_animations.cpp b/tests/auto/declarative/animations/tst_animations.cpp index 8e1abc6..f627527 100644 --- a/tests/auto/declarative/animations/tst_animations.cpp +++ b/tests/auto/declarative/animations/tst_animations.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include @@ -97,7 +97,7 @@ void tst_animations::badTypes() { //don't crash { - QFxView *view = new QFxView; + QmlView *view = new QmlView; view->setUrl(QUrl("file://" SRCDIR "/data/badtype1.qml")); view->execute(); diff --git a/tests/auto/declarative/layouts/tst_layouts.cpp b/tests/auto/declarative/layouts/tst_layouts.cpp index 3416b2e..d1e6aab 100644 --- a/tests/auto/declarative/layouts/tst_layouts.cpp +++ b/tests/auto/declarative/layouts/tst_layouts.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include @@ -19,7 +19,7 @@ private slots: void test_grid_spacing(); private: - QFxView *createView(const QString &filename); + QmlView *createView(const QString &filename); }; tst_QFxLayouts::tst_QFxLayouts() @@ -28,7 +28,7 @@ tst_QFxLayouts::tst_QFxLayouts() void tst_QFxLayouts::test_horizontal() { - QFxView *canvas = createView(SRCDIR "/data/horizontal.qml"); + QmlView *canvas = createView(SRCDIR "/data/horizontal.qml"); canvas->execute(); qApp->processEvents(); @@ -52,7 +52,7 @@ void tst_QFxLayouts::test_horizontal() void tst_QFxLayouts::test_horizontal_spacing() { - QFxView *canvas = createView(SRCDIR "/data/horizontal-spacing.qml"); + QmlView *canvas = createView(SRCDIR "/data/horizontal-spacing.qml"); canvas->execute(); qApp->processEvents(); @@ -76,7 +76,7 @@ void tst_QFxLayouts::test_horizontal_spacing() void tst_QFxLayouts::test_vertical() { - QFxView *canvas = createView(SRCDIR "/data/vertical.qml"); + QmlView *canvas = createView(SRCDIR "/data/vertical.qml"); canvas->execute(); qApp->processEvents(); @@ -100,7 +100,7 @@ void tst_QFxLayouts::test_vertical() void tst_QFxLayouts::test_vertical_spacing() { - QFxView *canvas = createView(SRCDIR "/data/vertical-spacing.qml"); + QmlView *canvas = createView(SRCDIR "/data/vertical-spacing.qml"); canvas->execute(); qApp->processEvents(); @@ -124,7 +124,7 @@ void tst_QFxLayouts::test_vertical_spacing() void tst_QFxLayouts::test_grid() { - QFxView *canvas = createView("data/grid.qml"); + QmlView *canvas = createView("data/grid.qml"); canvas->execute(); qApp->processEvents(); @@ -154,7 +154,7 @@ void tst_QFxLayouts::test_grid() void tst_QFxLayouts::test_grid_spacing() { - QFxView *canvas = createView("data/grid-spacing.qml"); + QmlView *canvas = createView("data/grid-spacing.qml"); canvas->execute(); qApp->processEvents(); @@ -182,9 +182,9 @@ void tst_QFxLayouts::test_grid_spacing() QCOMPARE(five->y(), 54.0); } -QFxView *tst_QFxLayouts::createView(const QString &filename) +QmlView *tst_QFxLayouts::createView(const QString &filename) { - QFxView *canvas = new QFxView(0); + QmlView *canvas = new QmlView(0); QFile file(filename); file.open(QFile::ReadOnly); diff --git a/tests/auto/declarative/listview/tst_listview.cpp b/tests/auto/declarative/listview/tst_listview.cpp index ebc3053..19d324d 100644 --- a/tests/auto/declarative/listview/tst_listview.cpp +++ b/tests/auto/declarative/listview/tst_listview.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include @@ -31,7 +31,7 @@ private: template void changed(); template void inserted(); template void removed(); - QFxView *createView(const QString &filename); + QmlView *createView(const QString &filename); template T *findItem(QFxItem *parent, const QString &id, int index=0); }; @@ -169,7 +169,7 @@ tst_QFxListView::tst_QFxListView() template void tst_QFxListView::items() { - QFxView *canvas = createView(SRCDIR "/data/listview.qml"); + QmlView *canvas = createView(SRCDIR "/data/listview.qml"); T model; model.addItem("Fred", "12345"); @@ -205,7 +205,7 @@ void tst_QFxListView::items() template void tst_QFxListView::changed() { - QFxView *canvas = createView(SRCDIR "/data/listview.qml"); + QmlView *canvas = createView(SRCDIR "/data/listview.qml"); T model; model.addItem("Fred", "12345"); @@ -238,7 +238,7 @@ void tst_QFxListView::changed() template void tst_QFxListView::inserted() { - QFxView *canvas = createView(SRCDIR "/data/listview.qml"); + QmlView *canvas = createView(SRCDIR "/data/listview.qml"); T model; model.addItem("Fred", "12345"); @@ -305,7 +305,7 @@ void tst_QFxListView::inserted() template void tst_QFxListView::removed() { - QFxView *canvas = createView(SRCDIR "/data/listview.qml"); + QmlView *canvas = createView(SRCDIR "/data/listview.qml"); T model; for (int i = 0; i < 30; i++) @@ -438,9 +438,9 @@ void tst_QFxListView::qAbstractItemModel_removed() removed(); } -QFxView *tst_QFxListView::createView(const QString &filename) +QmlView *tst_QFxListView::createView(const QString &filename) { - QFxView *canvas = new QFxView(0); + QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); QFile file(filename); diff --git a/tests/auto/declarative/pathview/tst_pathview.cpp b/tests/auto/declarative/pathview/tst_pathview.cpp index 2933323..e2da191 100644 --- a/tests/auto/declarative/pathview/tst_pathview.cpp +++ b/tests/auto/declarative/pathview/tst_pathview.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include @@ -19,7 +19,7 @@ private slots: void limitedItems(); private: - QFxView *createView(const QString &filename); + QmlView *createView(const QString &filename); template T *findItem(QFxItem *parent, const QString &id, int index=0); }; @@ -101,7 +101,7 @@ tst_QFxPathView::tst_QFxPathView() void tst_QFxPathView::items() { - QFxView *canvas = createView(SRCDIR "/data/pathview.qml"); + QmlView *canvas = createView(SRCDIR "/data/pathview.qml"); TestModel model; model.addItem("Fred", "12345"); @@ -133,7 +133,7 @@ void tst_QFxPathView::items() void tst_QFxPathView::pathMoved() { - QFxView *canvas = createView(SRCDIR "/data/pathview.qml"); + QmlView *canvas = createView(SRCDIR "/data/pathview.qml"); TestModel model; model.addItem("Ben", "12345"); @@ -176,7 +176,7 @@ void tst_QFxPathView::pathMoved() void tst_QFxPathView::limitedItems() { - QFxView *canvas = createView(SRCDIR "/data/pathview.qml"); + QmlView *canvas = createView(SRCDIR "/data/pathview.qml"); TestModel model; for(int i=0; i<100; i++) @@ -213,9 +213,9 @@ void tst_QFxPathView::limitedItems() QVERIFY(testItem != 0); } -QFxView *tst_QFxPathView::createView(const QString &filename) +QmlView *tst_QFxPathView::createView(const QString &filename) { - QFxView *canvas = new QFxView(0); + QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); QFile file(filename); diff --git a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp index c4fc506..ffbb09b 100644 --- a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp +++ b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp @@ -424,10 +424,10 @@ void tst_qfxtextedit::selection() QVERIFY(textEditObject->selectedText().size() == 10); } -#include +#include void tst_qfxtextedit::cursorDelegate() { - QFxView* view = new QFxView(0); + QmlView* view = new QmlView(0); view->show(); view->setUrl(QUrl("data/cursorTest.qml")); view->execute(); diff --git a/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp b/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp index c883aa3..13a301d 100644 --- a/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp +++ b/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp @@ -2,7 +2,7 @@ #include "../../../shared/util.h" #include #include -#include +#include #include #include @@ -28,8 +28,8 @@ private slots: void navigation(); private: - void simulateKey(QFxView *, int key); - QFxView *createView(const QString &filename); + void simulateKey(QmlView *, int key); + QmlView *createView(const QString &filename); QmlEngine engine; QStringList standard; @@ -268,7 +268,7 @@ void tst_qfxtextinput::selection() void tst_qfxtextinput::maxLength() { - QFxView *canvas = createView(SRCDIR "/data/navigation.qml"); + QmlView *canvas = createView(SRCDIR "/data/navigation.qml"); canvas->execute(); canvas->show(); @@ -282,7 +282,7 @@ void tst_qfxtextinput::maxLength() void tst_qfxtextinput::masks() { - QFxView *canvas = createView(SRCDIR "/data/navigation.qml"); + QmlView *canvas = createView(SRCDIR "/data/navigation.qml"); canvas->execute(); canvas->show(); @@ -296,7 +296,7 @@ void tst_qfxtextinput::masks() void tst_qfxtextinput::validators() { - QFxView *canvas = createView(SRCDIR "/data/navigation.qml"); + QmlView *canvas = createView(SRCDIR "/data/navigation.qml"); canvas->execute(); canvas->show(); @@ -314,7 +314,7 @@ the extent of the text, then they should ignore the keys. */ void tst_qfxtextinput::navigation() { - QFxView *canvas = createView(SRCDIR "/data/navigation.qml"); + QmlView *canvas = createView(SRCDIR "/data/navigation.qml"); canvas->execute(); canvas->show(); @@ -339,7 +339,7 @@ void tst_qfxtextinput::cursorDelegate() //TODO:Get the QFxTextInput test passing first } -void tst_qfxtextinput::simulateKey(QFxView *view, int key) +void tst_qfxtextinput::simulateKey(QmlView *view, int key) { QKeyEvent press(QKeyEvent::KeyPress, key, 0); QKeyEvent release(QKeyEvent::KeyRelease, key, 0); @@ -348,9 +348,9 @@ void tst_qfxtextinput::simulateKey(QFxView *view, int key) QApplication::sendEvent(view, &release); } -QFxView *tst_qfxtextinput::createView(const QString &filename) +QmlView *tst_qfxtextinput::createView(const QString &filename) { - QFxView *canvas = new QFxView(0); + QmlView *canvas = new QmlView(0); QFile file(filename); file.open(QFile::ReadOnly); diff --git a/tests/auto/declarative/repeater/tst_repeater.cpp b/tests/auto/declarative/repeater/tst_repeater.cpp index 08f9154..5fce70e 100644 --- a/tests/auto/declarative/repeater/tst_repeater.cpp +++ b/tests/auto/declarative/repeater/tst_repeater.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include @@ -15,7 +15,7 @@ private slots: void stringList(); private: - QFxView *createView(const QString &filename); + QmlView *createView(const QString &filename); template T *findItem(QObject *parent, const QString &id); }; @@ -26,7 +26,7 @@ tst_QFxRepeater::tst_QFxRepeater() void tst_QFxRepeater::stringList() { - QFxView *canvas = createView(SRCDIR "/data/repeater.qml"); + QmlView *canvas = createView(SRCDIR "/data/repeater.qml"); QStringList data; data << "One"; @@ -58,9 +58,9 @@ void tst_QFxRepeater::stringList() } -QFxView *tst_QFxRepeater::createView(const QString &filename) +QmlView *tst_QFxRepeater::createView(const QString &filename) { - QFxView *canvas = new QFxView(0); + QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); QFile file(filename); diff --git a/tests/auto/declarative/visual/tst_visual.cpp b/tests/auto/declarative/visual/tst_visual.cpp index f540e62..10823e8 100644 --- a/tests/auto/declarative/visual/tst_visual.cpp +++ b/tests/auto/declarative/visual/tst_visual.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/tools/qmldebugger/engine.cpp b/tools/qmldebugger/engine.cpp index 1f4bcc2..6e163e6 100644 --- a/tools/qmldebugger/engine.cpp +++ b/tools/qmldebugger/engine.cpp @@ -43,7 +43,7 @@ EnginePane::EnginePane(QmlDebugConnection *client, QWidget *parent) enginesFile.open(QFile::ReadOnly); Q_ASSERT(enginesFile.isOpen()); - m_engineView = new QFxView(this); + m_engineView = new QmlView(this); m_engineView->rootContext()->setContextProperty("engines", qVariantFromValue(&m_engineItems)); m_engineView->setContentResizable(true); m_engineView->setQml(enginesFile.readAll()); diff --git a/tools/qmldebugger/engine.h b/tools/qmldebugger/engine.h index 52f0608..5ef28ae 100644 --- a/tools/qmldebugger/engine.h +++ b/tools/qmldebugger/engine.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include QT_BEGIN_NAMESPACE @@ -51,7 +51,7 @@ private: QTreeWidget *m_objTree; QTableWidget *m_propTable; - QFxView *m_engineView; + QmlView *m_engineView; QList m_engineItems; }; diff --git a/tools/qmlviewer/qfxtester.cpp b/tools/qmlviewer/qfxtester.cpp index 3732aaf..d4802f6 100644 --- a/tools/qmlviewer/qfxtester.cpp +++ b/tools/qmlviewer/qfxtester.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -29,7 +29,7 @@ QML_DEFINE_TYPE(Qt.VisualTest, 4, 6, (QT_VERSION&0x00ff00)>>8, Mouse, QFxVisualT QML_DEFINE_TYPE(Qt.VisualTest, 4, 6, (QT_VERSION&0x00ff00)>>8, Key, QFxVisualTestKey); QFxTester::QFxTester(const QString &script, QmlViewer::ScriptOptions opts, - QFxView *parent) + QmlView *parent) : QAbstractAnimation(parent), m_view(parent), filterEvents(true), options(opts), testscript(0), hasFailed(false) { diff --git a/tools/qmlviewer/qfxtester.h b/tools/qmlviewer/qfxtester.h index e37d6aa..4ace2d1 100644 --- a/tools/qmlviewer/qfxtester.h +++ b/tools/qmlviewer/qfxtester.h @@ -155,7 +155,7 @@ QML_DECLARE_TYPE(QFxVisualTestKey) class QFxTester : public QAbstractAnimation { public: - QFxTester(const QString &script, QmlViewer::ScriptOptions options, QFxView *parent); + QFxTester(const QString &script, QmlViewer::ScriptOptions options, QmlView *parent); virtual int duration() const; @@ -174,7 +174,7 @@ private: enum Destination { View, ViewPort }; void addKeyEvent(Destination, QKeyEvent *); void addMouseEvent(Destination, QMouseEvent *); - QFxView *m_view; + QmlView *m_view; struct MouseEvent { MouseEvent(QMouseEvent *e) diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index 2894f1d..2ac13cc 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -11,7 +11,7 @@ ** ****************************************************************************/ -#include +#include #include "ui_recopts.h" #include "qmlviewer.h" @@ -286,7 +286,7 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags) if (!(flags & Qt::FramelessWindowHint)) createMenu(menuBar(),0); - canvas = new QFxView(this); + canvas = new QmlView(this); canvas->setAttribute(Qt::WA_OpaquePaintEvent); canvas->setAttribute(Qt::WA_NoSystemBackground); canvas->setContentResizable(!skin || !scaleSkin); diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h index f0e997c..c785e89 100644 --- a/tools/qmlviewer/qmlviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -21,7 +21,7 @@ QT_BEGIN_NAMESPACE -class QFxView; +class QmlView; class PreviewDeviceSkin; class QFxTestEngine; class QProcess; @@ -95,7 +95,7 @@ private: QString currentFileName; PreviewDeviceSkin *skin; QSize skinscreensize; - QFxView *canvas; + QmlView *canvas; QmlTimer recordTimer; QString frame_fmt; QImage frame; -- cgit v0.12 From 8fbd9381dc2bca5d686371a733e4c0d7d51123dc Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 22 Sep 2009 14:45:26 +1000 Subject: Particles no longer paints things itself. --- src/declarative/extra/qfxparticles.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/declarative/extra/qfxparticles.cpp b/src/declarative/extra/qfxparticles.cpp index 7855f3e..15e257e 100644 --- a/src/declarative/extra/qfxparticles.cpp +++ b/src/declarative/extra/qfxparticles.cpp @@ -603,7 +603,6 @@ QFxParticles::QFxParticles(QFxItem *parent) { Q_D(QFxParticles); d->init(); - setFlag(QGraphicsItem::ItemHasNoContents, false); } QFxParticles::QFxParticles(QFxParticlesPrivate &dd, QFxItem *parent) @@ -611,7 +610,6 @@ QFxParticles::QFxParticles(QFxParticlesPrivate &dd, QFxItem *parent) { Q_D(QFxParticles); d->init(); - setFlag(QGraphicsItem::ItemHasNoContents, false); } QFxParticles::~QFxParticles() -- cgit v0.12