diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-04 14:08:21 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-04 14:08:21 (GMT) |
commit | 48edd0b663b29413452389c906487cc9b0408b29 (patch) | |
tree | 0b5e3e9de4c45adec46a80845ed640ee16ba46b1 | |
parent | 8bc0456491e5a7e1fc677fce6e76932ab0d923e8 (diff) | |
parent | 6f09fc3a475eb2e1c843f4aebe7ea0d15182ac1d (diff) | |
download | Qt-48edd0b663b29413452389c906487cc9b0408b29.zip Qt-48edd0b663b29413452389c906487cc9b0408b29.tar.gz Qt-48edd0b663b29413452389c906487cc9b0408b29.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (100 commits)
Update QML PropertyAnimation::easing docs
Add testcase for QTBUG-7730
Add autotests for tab and backtab in Keys and KeyNavigation.
Run signal expressions on attached property objects in correct scope
Fixup test
Add support for tab and backtab in KeyNavigation
Mark QGraphicsItem position properties as FINAL
Move the multimedia files to the correct place.
Fix grammar stringifying "on" as "readonly"
Improve grouped property error messages
Don't mess with highlight size if highlightFollowsCurrentItem is false.
Fix ListView contentHeight calculation.
Remove Qt.playSound()
Add formatting functions to QML's global Qt object.
Signal handler requires exactly one value.
QDeclarativeContext::contextProperty() should also access ids
Compile without QVariant::EasingCurve in Qt 4.6.2.
Documented view behavior when items are removed from start of view.
Fix tests failing due to javascript eval errors.
Remove unnecessary additional hash of QDeclarativeGridViewAttached
...
390 files changed, 4302 insertions, 1436 deletions
diff --git a/demos/declarative/flickr/common/ImageDetails.qml b/demos/declarative/flickr/common/ImageDetails.qml index 9604f10..862eeb1 100644 --- a/demos/declarative/flickr/common/ImageDetails.qml +++ b/demos/declarative/flickr/common/ImageDetails.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 Flipable { id: container diff --git a/demos/declarative/flickr/common/Loading.qml b/demos/declarative/flickr/common/Loading.qml index 174cd21..938a080 100644 --- a/demos/declarative/flickr/common/Loading.qml +++ b/demos/declarative/flickr/common/Loading.qml @@ -2,7 +2,7 @@ import Qt 4.6 Image { id: loading; source: "pics/loading.png"; transformOrigin: "Center" - rotation: NumberAnimation { + NumberAnimation on rotation { from: 0; to: 360; running: loading.visible == true; repeat: true; duration: 900 } } diff --git a/demos/declarative/flickr/mobile/GridDelegate.qml b/demos/declarative/flickr/mobile/GridDelegate.qml index 7634573..291d874 100644 --- a/demos/declarative/flickr/mobile/GridDelegate.qml +++ b/demos/declarative/flickr/mobile/GridDelegate.qml @@ -23,7 +23,7 @@ Item { anchors.centerIn: parent scale: 0.0 - scale: Behavior { NumberAnimation { easing.type: "InOutQuad"} } + Behavior on scale { NumberAnimation { easing.type: "InOutQuad"} } id: scaleMe Rectangle { height: 79; width: 79; id: blackRect; anchors.centerIn: parent; color: "black"; smooth: true } diff --git a/demos/declarative/flickr/mobile/ImageDetails.qml b/demos/declarative/flickr/mobile/ImageDetails.qml index c51371c..2f4df8a 100644 --- a/demos/declarative/flickr/mobile/ImageDetails.qml +++ b/demos/declarative/flickr/mobile/ImageDetails.qml @@ -45,7 +45,7 @@ Flipable { Text { color: "white"; elide: Text.ElideRight; text: "<b>Author:</b> " + container.photoAuthor } Text { color: "white"; elide: Text.ElideRight; text: "<b>Published:</b> " + container.photoDate } Text { color: "white"; elide: Text.ElideRight; text: container.photoTags == "" ? "" : "<b>Tags:</b> " } - Text { color: "white"; elide: Text.ElideRight; elide: Text.ElideRight; text: container.photoTags } + Text { color: "white"; elide: Text.ElideRight; text: container.photoTags } } } diff --git a/demos/declarative/flickr/mobile/ListDelegate.qml b/demos/declarative/flickr/mobile/ListDelegate.qml index 75c4572..381664b 100644 --- a/demos/declarative/flickr/mobile/ListDelegate.qml +++ b/demos/declarative/flickr/mobile/ListDelegate.qml @@ -15,8 +15,8 @@ Component { Column { x: 92; width: wrapper.ListView.view.width - 95; y: 15; spacing: 2 Text { text: title; color: "white"; width: parent.width; font.bold: true; elide: Text.ElideRight; style: Text.Raised; styleColor: "black" } - Text { text: photoAuthor; color: "white"; width: parent.width; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" } - Text { text: photoDate; color: "white"; width: parent.width; elide: Text.ElideRight; color: "#cccccc"; style: Text.Raised; styleColor: "black" } + Text { text: photoAuthor; width: parent.width; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" } + Text { text: photoDate; width: parent.width; elide: Text.ElideRight; color: "#cccccc"; style: Text.Raised; styleColor: "black" } } } } diff --git a/demos/declarative/minehunt/Description.qml b/demos/declarative/minehunt/Description.qml deleted file mode 100644 index cc4d3b2..0000000 --- a/demos/declarative/minehunt/Description.qml +++ /dev/null @@ -1,34 +0,0 @@ -import Qt 4.6 - -Item { - id: page - height: myText.height + 20 - property var text - MouseArea { - anchors.fill: parent - drag.target: page - drag.axis: "XandYAxis" - drag.minimumX: 0 - drag.maximumX: 1000 - drag.minimumY: 0 - drag.maximumY: 1000 - } - Rectangle { - radius: 10 - anchors.fill: parent - color: "lightsteelblue" - } - Item { - x: 10 - y: 10 - width: parent.width - 20 - height: parent.height - 20 - Text { - id: myText - text: page.text - width: parent.width - clip: true - wrap: true - } - } -} diff --git a/demos/declarative/minehunt/Explosion.qml b/demos/declarative/minehunt/MinehuntCore/Explosion.qml index e337c46..e337c46 100644 --- a/demos/declarative/minehunt/Explosion.qml +++ b/demos/declarative/minehunt/MinehuntCore/Explosion.qml diff --git a/demos/declarative/minehunt/pics/No-Ones-Laughing-3.jpg b/demos/declarative/minehunt/MinehuntCore/pics/No-Ones-Laughing-3.jpg Binary files differindex 445567f..445567f 100644 --- a/demos/declarative/minehunt/pics/No-Ones-Laughing-3.jpg +++ b/demos/declarative/minehunt/MinehuntCore/pics/No-Ones-Laughing-3.jpg diff --git a/demos/declarative/minehunt/pics/back.png b/demos/declarative/minehunt/MinehuntCore/pics/back.png Binary files differindex f6b3f0b..f6b3f0b 100644 --- a/demos/declarative/minehunt/pics/back.png +++ b/demos/declarative/minehunt/MinehuntCore/pics/back.png diff --git a/demos/declarative/minehunt/pics/bomb-color.png b/demos/declarative/minehunt/MinehuntCore/pics/bomb-color.png Binary files differindex 61ad0a9..61ad0a9 100644 --- a/demos/declarative/minehunt/pics/bomb-color.png +++ b/demos/declarative/minehunt/MinehuntCore/pics/bomb-color.png diff --git a/demos/declarative/minehunt/pics/bomb.png b/demos/declarative/minehunt/MinehuntCore/pics/bomb.png Binary files differindex a992575..a992575 100644 --- a/demos/declarative/minehunt/pics/bomb.png +++ b/demos/declarative/minehunt/MinehuntCore/pics/bomb.png diff --git a/demos/declarative/minehunt/pics/face-sad.png b/demos/declarative/minehunt/MinehuntCore/pics/face-sad.png Binary files differindex cf00aaf..cf00aaf 100644 --- a/demos/declarative/minehunt/pics/face-sad.png +++ b/demos/declarative/minehunt/MinehuntCore/pics/face-sad.png diff --git a/demos/declarative/minehunt/pics/face-smile-big.png b/demos/declarative/minehunt/MinehuntCore/pics/face-smile-big.png Binary files differindex f9c2335..f9c2335 100644 --- a/demos/declarative/minehunt/pics/face-smile-big.png +++ b/demos/declarative/minehunt/MinehuntCore/pics/face-smile-big.png diff --git a/demos/declarative/minehunt/pics/face-smile.png b/demos/declarative/minehunt/MinehuntCore/pics/face-smile.png Binary files differindex 3d66d72..3d66d72 100644 --- a/demos/declarative/minehunt/pics/face-smile.png +++ b/demos/declarative/minehunt/MinehuntCore/pics/face-smile.png diff --git a/demos/declarative/minehunt/pics/flag-color.png b/demos/declarative/minehunt/MinehuntCore/pics/flag-color.png Binary files differindex aadad0f..aadad0f 100644 --- a/demos/declarative/minehunt/pics/flag-color.png +++ b/demos/declarative/minehunt/MinehuntCore/pics/flag-color.png diff --git a/demos/declarative/minehunt/pics/flag.png b/demos/declarative/minehunt/MinehuntCore/pics/flag.png Binary files differindex 39cde4d..39cde4d 100644 --- a/demos/declarative/minehunt/pics/flag.png +++ b/demos/declarative/minehunt/MinehuntCore/pics/flag.png diff --git a/demos/declarative/minehunt/pics/front.png b/demos/declarative/minehunt/MinehuntCore/pics/front.png Binary files differindex 834331b..834331b 100644 --- a/demos/declarative/minehunt/pics/front.png +++ b/demos/declarative/minehunt/MinehuntCore/pics/front.png diff --git a/demos/declarative/minehunt/pics/star.png b/demos/declarative/minehunt/MinehuntCore/pics/star.png Binary files differindex 3772359..3772359 100644 --- a/demos/declarative/minehunt/pics/star.png +++ b/demos/declarative/minehunt/MinehuntCore/pics/star.png diff --git a/demos/declarative/minehunt/MinehuntCore/qmldir b/demos/declarative/minehunt/MinehuntCore/qmldir new file mode 100644 index 0000000..862c396 --- /dev/null +++ b/demos/declarative/minehunt/MinehuntCore/qmldir @@ -0,0 +1,2 @@ +plugin minehunt +Explosion 1.0 Explosion.qml diff --git a/demos/declarative/minehunt/README b/demos/declarative/minehunt/README new file mode 100644 index 0000000..7379dcf --- /dev/null +++ b/demos/declarative/minehunt/README @@ -0,0 +1,3 @@ +To run, simply load the minehunt.qml file with the qml runtime. + +Note that on X11, this demo has problems with the native graphicssystem. If you are using the X11 window system, please pass -graphicssystem raster to the qml binary. diff --git a/demos/declarative/minehunt/main.cpp b/demos/declarative/minehunt/minehunt.cpp index e7a1d7c..89845ef 100644 --- a/demos/declarative/minehunt/main.cpp +++ b/demos/declarative/minehunt/minehunt.cpp @@ -38,21 +38,15 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "qdeclarativeengine.h" -#include "qdeclarativecontext.h" -#include "qdeclarative.h" -#include <qdeclarativeitem.h> -#include <qdeclarativeview.h> - -#include <QWidget> -#include <QApplication> -#include <QFile> + +#include <stdlib.h> +#include <qdeclarativeextensionplugin.h> +#include <qdeclarativecontext.h> +#include <qdeclarativeengine.h> +#include <qdeclarative.h> + #include <QTime> #include <QTimer> -#include <QVBoxLayout> -#include <QFileInfo> - -QString fileName = "minehunt.qml"; class Tile : public QObject { @@ -91,17 +85,14 @@ private: bool _flipped; }; -QML_DECLARE_TYPE(Tile); - -class MyWidget : public QWidget +class MinehuntGame : public QObject { -Q_OBJECT + Q_OBJECT public: - MyWidget(int = 370, int = 480, QWidget *parent=0, Qt::WindowFlags flags=0); - ~MyWidget(); + MinehuntGame(); Q_PROPERTY(QDeclarativeListProperty<Tile> tiles READ tiles CONSTANT); - QDeclarativeListProperty<Tile> tiles() { return _tilesProperty; } + QDeclarativeListProperty<Tile> tiles() { return QDeclarativeListProperty<Tile>(this, _tiles); } Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged); bool isPlaying() {return playing;} @@ -133,10 +124,7 @@ private: int getHint(int row, int col); void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();} - QDeclarativeView *canvas; - QList<Tile *> _tiles; - QDeclarativeListProperty<Tile> _tilesProperty; int numCols; int numRows; bool playing; @@ -146,11 +134,10 @@ private: int nFlags; }; -Q_DECLARE_METATYPE(QList<Tile*>) -MyWidget::MyWidget(int width, int height, QWidget *parent, Qt::WindowFlags flags) -: QWidget(parent, flags), canvas(0), numCols(9), numRows(9), playing(true), won(false) +MinehuntGame::MinehuntGame() +: numCols(9), numRows(9), playing(true), won(false) { - setObjectName("mainWidget"); + setObjectName("mainObject"); srand(QTime(0,0,0).secsTo(QTime::currentTime())); //initialize array @@ -159,27 +146,9 @@ MyWidget::MyWidget(int width, int height, QWidget *parent, Qt::WindowFlags flags } reset(); - QVBoxLayout *vbox = new QVBoxLayout; - vbox->setMargin(0); - setLayout(vbox); - - canvas = new QDeclarativeView(this); - canvas->setFixedSize(width, height); - vbox->addWidget(canvas); - - _tilesProperty = QDeclarativeListProperty<Tile>(this, _tiles); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->addDefaultObject(this); - - canvas->setSource(QUrl::fromLocalFile(fileName)); -} - -MyWidget::~MyWidget() -{ } -void MyWidget::setBoard() +void MinehuntGame::setBoard() { foreach(Tile* t, _tiles){ t->setHasMine(false); @@ -213,7 +182,7 @@ void MyWidget::setBoard() setPlaying(true); } -void MyWidget::reset() +void MinehuntGame::reset() { foreach(Tile* t, _tiles){ t->unflip(); @@ -225,7 +194,7 @@ void MyWidget::reset() QTimer::singleShot(600,this, SLOT(setBoard())); } -int MyWidget::getHint(int row, int col) +int MinehuntGame::getHint(int row, int col) { int hint = 0; for (int c = col-1; c <= col+1; c++) @@ -237,7 +206,7 @@ int MyWidget::getHint(int row, int col) return hint; } -bool MyWidget::flip(int row, int col) +bool MinehuntGame::flip(int row, int col) { if(!playing) return false; @@ -302,7 +271,7 @@ bool MyWidget::flip(int row, int col) return true; } -bool MyWidget::flag(int row, int col) +bool MinehuntGame::flag(int row, int col) { Tile *t = tile(row, col); if(!t) @@ -313,42 +282,33 @@ bool MyWidget::flag(int row, int col) emit numFlagsChanged(); return true; } -///////////////////////////////////////////////////////// -int main(int argc, char ** argv) +QML_DECLARE_TYPE(Tile); +QML_DECLARE_TYPE(MinehuntGame); + +class MinehuntExtensionPlugin : public QDeclarativeExtensionPlugin { -#ifdef Q_WS_X11 - // native on X11 is terrible for this demo. - QApplication::setGraphicsSystem("raster"); -#endif - QApplication app(argc, argv); - - bool frameless = false; - - int width = 370; - int height = 480; - - QML_REGISTER_TYPE(0,0,0,Tile,Tile); - - for (int i = 1; i < argc; ++i) { - QString arg = argv[i]; - if (arg == "-frameless") { - frameless = true; - } else if(arg == "-width" && i < (argc - 1)) { - ++i; - width = ::atoi(argv[i]); - } else if(arg == "-height" && i < (argc - 1)) { - ++i; - height = ::atoi(argv[i]); - } else if (arg[0] != '-') { - fileName = arg; - } + Q_OBJECT + + public: + void registerTypes(const char *uri) { + Q_UNUSED(uri); + QML_REGISTER_TYPE(SameGameCore, 0, 1, Tile, Tile); + QML_REGISTER_TYPE(SameGameCore, 0, 1, Game, MinehuntGame); } - MyWidget wid(width, height, 0, frameless ? Qt::FramelessWindowHint : Qt::Widget); - wid.show(); + void initializeEngine(QDeclarativeEngine *engine, const char *uri) { + Q_UNUSED(uri); - return app.exec(); -} + srand(QTime(0,0,0).secsTo(QTime::currentTime())); + + MinehuntGame* game = new MinehuntGame(); + + engine->rootContext()->addDefaultObject(game); + } +}; + +#include "minehunt.moc" + +Q_EXPORT_PLUGIN(MinehuntExtensionPlugin); -#include "main.moc" diff --git a/demos/declarative/minehunt/minehunt.pro b/demos/declarative/minehunt/minehunt.pro index 01791b1..a497b0f 100644 --- a/demos/declarative/minehunt/minehunt.pro +++ b/demos/declarative/minehunt/minehunt.pro @@ -1,9 +1,11 @@ -SOURCES = main.cpp +TEMPLATE = lib +TARGET = minehunt +QT += declarative +CONFIG += qt plugin -QT += script declarative -contains(QT_CONFIG, opengles2)|contains(QT_CONFIG, opengles1): QT += opengl +TARGET = $$qtLibraryTarget($$TARGET) +DESTDIR = MinehuntCore + +# Input +SOURCES += minehunt.cpp -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/minehunt -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS minehunt.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/minehunt -INSTALLS += target sources diff --git a/demos/declarative/minehunt/minehunt.qml b/demos/declarative/minehunt/minehunt.qml index 8a3cab1..9e99706 100644 --- a/demos/declarative/minehunt/minehunt.qml +++ b/demos/declarative/minehunt/minehunt.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import MinehuntCore 1.0 Item { id: field @@ -24,15 +25,15 @@ Item { angle: flipable.angle; } front: Image { - source: "pics/front.png" + source: "MinehuntCore/pics/front.png" width: 40 height: 40 Image { anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - source: "pics/flag.png" + source: "MinehuntCore/pics/flag.png" opacity: modelData.hasFlag - opacity: Behavior { + Behavior on opacity { NumberAnimation { property: "opacity" duration: 250 @@ -41,7 +42,7 @@ Item { } } back: Image { - source: "pics/back.png" + source: "MinehuntCore/pics/back.png" width: 40 height: 40 Text { @@ -55,7 +56,7 @@ Item { Image { anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - source: "pics/bomb.png" + source: "MinehuntCore/pics/bomb.png" opacity: modelData.hasMine } Explosion { @@ -120,16 +121,9 @@ Item { } ] Image { - source: "pics/No-Ones-Laughing-3.jpg" + source: "MinehuntCore/pics/No-Ones-Laughing-3.jpg" fillMode: Image.Tile } - Description { - text: "Use the 'minehunt' executable to run this demo!" - width: 300 - opacity: tiles?0:1 - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - } Repeater { id: repeater model: tiles @@ -156,7 +150,7 @@ Item { Image { // x: 100 // y: 20 - source: "pics/bomb-color.png" + source: "MinehuntCore/pics/bomb-color.png" } Text { // x: 100 @@ -172,7 +166,7 @@ Item { Image { // x: 140 // y: 20 - source: "pics/flag-color.png" + source: "MinehuntCore/pics/flag-color.png" } Text { // x: 140 @@ -187,7 +181,7 @@ Item { y: 390 anchors.right: field.right anchors.rightMargin: 20 - source: isPlaying ? 'pics/face-smile.png' : hasWon ? 'pics/face-smile-big.png': 'pics/face-sad.png' + source: isPlaying ? 'MinehuntCore/pics/face-smile.png' : hasWon ? 'MinehuntCore/pics/face-smile-big.png': 'MinehuntCore/pics/face-sad.png' MouseArea { anchors.fill: parent onPressed: { reset() } diff --git a/demos/declarative/minehunt/test.qml b/demos/declarative/minehunt/test.qml deleted file mode 100644 index 11ed182..0000000 --- a/demos/declarative/minehunt/test.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt 4.6 - - Image { - source: "pics/front.png" - width: 40 - height: 40 - Image { - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - source: "pics/flag.png" - opacity: 1 - } - } diff --git a/demos/declarative/samegame/content/BoomBlock.qml b/demos/declarative/samegame/SamegameCore/BoomBlock.qml index 723e62a..e48194a 100644 --- a/demos/declarative/samegame/content/BoomBlock.qml +++ b/demos/declarative/samegame/SamegameCore/BoomBlock.qml @@ -7,8 +7,8 @@ Item { id:block property int targetX: 0 property int targetY: 0 - x: SpringFollow { enabled: spawned; source: targetX; spring: 2; damping: 0.2 } - y: SpringFollow { source: targetY; spring: 2; damping: 0.2 } + SpringFollow on x { enabled: spawned; source: targetX; spring: 2; damping: 0.2 } + SpringFollow on y { source: targetY; spring: 2; damping: 0.2 } Image { id: img source: { @@ -21,7 +21,7 @@ Item { id:block } } opacity: 0 - opacity: Behavior { NumberAnimation { duration: 200 } } + Behavior on opacity { NumberAnimation { duration: 200 } } anchors.fill: parent } diff --git a/demos/declarative/samegame/content/Button.qml b/demos/declarative/samegame/SamegameCore/Button.qml index 6629302..6629302 100644 --- a/demos/declarative/samegame/content/Button.qml +++ b/demos/declarative/samegame/SamegameCore/Button.qml diff --git a/demos/declarative/samegame/content/Dialog.qml b/demos/declarative/samegame/SamegameCore/Dialog.qml index 7769328..6d5d6b5 100644 --- a/demos/declarative/samegame/content/Dialog.qml +++ b/demos/declarative/samegame/SamegameCore/Dialog.qml @@ -14,7 +14,7 @@ Rectangle { property Item text: myText color: "white"; border.width: 1; width: myText.width + 20; height: myText.height + 40; opacity: 0 - opacity: Behavior { + Behavior on opacity { NumberAnimation { duration: 1000 } } Text { id: myText; anchors.centerIn: parent; text: "Hello World!" } diff --git a/demos/declarative/samegame/content/pics/background.png b/demos/declarative/samegame/SamegameCore/pics/background.png Binary files differindex 3734a27..3734a27 100644 --- a/demos/declarative/samegame/content/pics/background.png +++ b/demos/declarative/samegame/SamegameCore/pics/background.png diff --git a/demos/declarative/samegame/content/pics/blueStar.png b/demos/declarative/samegame/SamegameCore/pics/blueStar.png Binary files differindex ff9588f..ff9588f 100644 --- a/demos/declarative/samegame/content/pics/blueStar.png +++ b/demos/declarative/samegame/SamegameCore/pics/blueStar.png diff --git a/demos/declarative/samegame/content/pics/blueStone.png b/demos/declarative/samegame/SamegameCore/pics/blueStone.png Binary files differindex 20e43c7..20e43c7 100644 --- a/demos/declarative/samegame/content/pics/blueStone.png +++ b/demos/declarative/samegame/SamegameCore/pics/blueStone.png diff --git a/demos/declarative/samegame/content/pics/greenStar.png b/demos/declarative/samegame/SamegameCore/pics/greenStar.png Binary files differindex cd06854..cd06854 100644 --- a/demos/declarative/samegame/content/pics/greenStar.png +++ b/demos/declarative/samegame/SamegameCore/pics/greenStar.png diff --git a/demos/declarative/samegame/content/pics/greenStone.png b/demos/declarative/samegame/SamegameCore/pics/greenStone.png Binary files differindex b568a19..b568a19 100644 --- a/demos/declarative/samegame/content/pics/greenStone.png +++ b/demos/declarative/samegame/SamegameCore/pics/greenStone.png diff --git a/demos/declarative/samegame/content/pics/redStar.png b/demos/declarative/samegame/SamegameCore/pics/redStar.png Binary files differindex 0a4dffe..0a4dffe 100644 --- a/demos/declarative/samegame/content/pics/redStar.png +++ b/demos/declarative/samegame/SamegameCore/pics/redStar.png diff --git a/demos/declarative/samegame/content/pics/redStone.png b/demos/declarative/samegame/SamegameCore/pics/redStone.png Binary files differindex 36b09a2..36b09a2 100644 --- a/demos/declarative/samegame/content/pics/redStone.png +++ b/demos/declarative/samegame/SamegameCore/pics/redStone.png diff --git a/demos/declarative/samegame/content/pics/star.png b/demos/declarative/samegame/SamegameCore/pics/star.png Binary files differindex defbde5..defbde5 100644 --- a/demos/declarative/samegame/content/pics/star.png +++ b/demos/declarative/samegame/SamegameCore/pics/star.png diff --git a/demos/declarative/samegame/content/pics/yellowStone.png b/demos/declarative/samegame/SamegameCore/pics/yellowStone.png Binary files differindex b1ce762..b1ce762 100644 --- a/demos/declarative/samegame/content/pics/yellowStone.png +++ b/demos/declarative/samegame/SamegameCore/pics/yellowStone.png diff --git a/demos/declarative/samegame/content/qmldir b/demos/declarative/samegame/SamegameCore/qmldir index a8f8a98..a8f8a98 100644 --- a/demos/declarative/samegame/content/qmldir +++ b/demos/declarative/samegame/SamegameCore/qmldir diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/SamegameCore/samegame.js index c0f10bd..1214b79 100755 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/SamegameCore/samegame.js @@ -4,7 +4,7 @@ var maxX = 10;//Nums are for gameCanvas.tileSize 40 var maxY = 15; var maxIndex = maxX*maxY; var board = new Array(maxIndex); -var tileSrc = "content/BoomBlock.qml"; +var tileSrc = "SamegameCore/BoomBlock.qml"; var scoresURL = "http://qtfx-nokia.trolltech.com.au/samegame/scores.php"; var scoresURL = ""; var timer; diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml index 50f6293..3b19cbe 100644 --- a/demos/declarative/samegame/samegame.qml +++ b/demos/declarative/samegame/samegame.qml @@ -1,5 +1,5 @@ import Qt 4.6 -import "content" +import SamegameCore 1.0 Rectangle { id: screen @@ -12,7 +12,7 @@ Rectangle { Image { id: background - anchors.fill: parent; source: "content/pics/background.png" + anchors.fill: parent; source: "SamegameCore/pics/background.png" fillMode: Image.PreserveAspectCrop smooth: true } @@ -22,7 +22,7 @@ Rectangle { property int score: 0 property int tileSize: 40 - Script { source: "content/samegame.js" } + Script { source: "SamegameCore/samegame.js" } z: 20; anchors.centerIn: parent width: parent.width - (parent.width % getTileSize()); @@ -39,7 +39,7 @@ Rectangle { Dialog { id: scoreName; anchors.centerIn: parent; z: 22; property int initialWidth: 0 - width: Behavior{NumberAnimation{} enabled: initialWidth!=0} + Behavior on width {NumberAnimation{} enabled: initialWidth!=0} Text { id: spacer anchors.left: scoreName.left diff --git a/demos/declarative/snake/content/Cookie.qml b/demos/declarative/snake/content/Cookie.qml index 7f0aadf..0ea95cb 100644 --- a/demos/declarative/snake/content/Cookie.qml +++ b/demos/declarative/snake/content/Cookie.qml @@ -17,7 +17,7 @@ Item { anchors.fill: parent source: "pics/cookie.png" opacity: 0 - opacity: Behavior { NumberAnimation { duration: 100 } } + Behavior on opacity { NumberAnimation { duration: 100 } } Text { font.bold: true anchors.verticalCenter: parent.verticalCenter diff --git a/demos/declarative/snake/content/Link.qml b/demos/declarative/snake/content/Link.qml index 1b3f7bf..31ac4b9 100644 --- a/demos/declarative/snake/content/Link.qml +++ b/demos/declarative/snake/content/Link.qml @@ -13,8 +13,8 @@ Item { id:link x: margin - 3 + gridSize * column y: margin - 3 + gridSize * row - x: Behavior { NumberAnimation { duration: spawned ? heartbeatInterval : 0} } - y: Behavior { NumberAnimation { duration: spawned ? heartbeatInterval : 0 } } + Behavior on x { NumberAnimation { duration: spawned ? heartbeatInterval : 0} } + Behavior on y { NumberAnimation { duration: spawned ? heartbeatInterval : 0 } } Item { @@ -35,7 +35,7 @@ Item { id:link id: actualImageRotation origin.x: width/2; origin.y: height/2; angle: rotation * 90 - angle: Behavior{ NumberAnimation { duration: spawned ? 200 : 0} } + Behavior on angle { NumberAnimation { duration: spawned ? 200 : 0} } } } @@ -44,7 +44,7 @@ Item { id:link } opacity: 0 - opacity: Behavior { NumberAnimation { duration: 200 } } + Behavior on opacity { NumberAnimation { duration: 200 } } } diff --git a/demos/declarative/snake/content/Skull.qml b/demos/declarative/snake/content/Skull.qml index 585e7d3..821996a 100644 --- a/demos/declarative/snake/content/Skull.qml +++ b/demos/declarative/snake/content/Skull.qml @@ -9,11 +9,11 @@ Image { x: margin + column * gridSize + 2 y: margin + row * gridSize - 3 - x: Behavior { NumberAnimation { duration: spawned ? halfbeatInterval : 0} } - y: Behavior { NumberAnimation { duration: spawned ? halfbeatInterval : 0 } } + Behavior on x { NumberAnimation { duration: spawned ? halfbeatInterval : 0} } + Behavior on y { NumberAnimation { duration: spawned ? halfbeatInterval : 0 } } opacity: spawned ? 1 : 0 - opacity: Behavior { NumberAnimation { duration: 200 } } + Behavior on opacity { NumberAnimation { duration: 200 } } source: "pics/skull.png" width: 24 diff --git a/demos/declarative/snake/content/snake.js b/demos/declarative/snake/content/snake.js index a65aebc..12176c7 100644 --- a/demos/declarative/snake/content/snake.js +++ b/demos/declarative/snake/content/snake.js @@ -54,7 +54,7 @@ function startNewGame() } else { if(linkComponent.isReady == false){ if(linkComponent.isError == true) - print(linkComponent.errorString()); + print(linkComponent.errorsString()); else print("Still loading linkComponent"); continue;//TODO: Better error handling? @@ -295,7 +295,7 @@ function createCookie(value) { if(cookieComponent.isReady == false){ if(cookieComponent.isError == true) - print(cookieComponent.errorString()); + print(cookieComponent.errorsString()); else print("Still loading cookieComponent"); return;//TODO: Better error handling? diff --git a/demos/declarative/snake/snake.qml b/demos/declarative/snake/snake.qml index 09b6b7f..f9d02c7 100644 --- a/demos/declarative/snake/snake.qml +++ b/demos/declarative/snake/snake.qml @@ -65,7 +65,7 @@ Rectangle { anchors.fill: parent anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - opacity: Behavior { NumberAnimation { duration: 500 } } + Behavior on opacity { NumberAnimation { duration: 500 } } Text { color: "white" @@ -121,7 +121,7 @@ Rectangle { Rectangle { id: progressBar opacity: 0 - opacity: Behavior { NumberAnimation { duration: 200 } } + Behavior on opacity { NumberAnimation { duration: 200 } } color: "transparent" border.width: 2 border.color: "#221edd" @@ -137,7 +137,7 @@ Rectangle { id: progressIndicator color: "#221edd"; width: 0; - width: Behavior { NumberAnimation { duration: startHeartbeatTimer.running ? 1000 : 0}} + Behavior on width { NumberAnimation { duration: startHeartbeatTimer.running ? 1000 : 0}} height: 30; } } diff --git a/demos/declarative/twitter/content/AuthView.qml b/demos/declarative/twitter/TwitterCore/AuthView.qml index bcf4646..bcf4646 100644 --- a/demos/declarative/twitter/content/AuthView.qml +++ b/demos/declarative/twitter/TwitterCore/AuthView.qml diff --git a/demos/declarative/twitter/content/Button.qml b/demos/declarative/twitter/TwitterCore/Button.qml index 4cba8c3..4cba8c3 100644 --- a/demos/declarative/twitter/content/Button.qml +++ b/demos/declarative/twitter/TwitterCore/Button.qml diff --git a/demos/declarative/twitter/content/FatDelegate.qml b/demos/declarative/twitter/TwitterCore/FatDelegate.qml index 2b9288b..0f013e6 100644 --- a/demos/declarative/twitter/content/FatDelegate.qml +++ b/demos/declarative/twitter/TwitterCore/FatDelegate.qml @@ -37,7 +37,7 @@ Component { + '<a href="app://@'+userScreenName+'"><b>'+userScreenName + "</b></a> from " +source + "<br /><b>" + addTags(statusText) + "</b></html>"; textFormat: Qt.RichText - color: "white"; color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrap: true + color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrap: true anchors.left: whiteRect.right; anchors.right: blackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6 onLinkActivated: handleLink(link) } diff --git a/demos/declarative/twitter/content/HomeTitleBar.qml b/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml index a206c87..a206c87 100644 --- a/demos/declarative/twitter/content/HomeTitleBar.qml +++ b/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml diff --git a/demos/declarative/twitter/content/Loading.qml b/demos/declarative/twitter/TwitterCore/Loading.qml index 3151415..76bf64b 100644 --- a/demos/declarative/twitter/content/Loading.qml +++ b/demos/declarative/twitter/TwitterCore/Loading.qml @@ -2,7 +2,7 @@ import Qt 4.6 Image { id: loading; source: "images/loading.png"; transformOrigin: "Center" - rotation: NumberAnimation { + NumberAnimation on rotation { from: 0; to: 360; running: loading.visible == true; repeat: true; duration: 900 } } diff --git a/demos/declarative/twitter/content/MultiTitleBar.qml b/demos/declarative/twitter/TwitterCore/MultiTitleBar.qml index e0205b8..e0205b8 100644 --- a/demos/declarative/twitter/content/MultiTitleBar.qml +++ b/demos/declarative/twitter/TwitterCore/MultiTitleBar.qml diff --git a/demos/declarative/twitter/content/RssModel.qml b/demos/declarative/twitter/TwitterCore/RssModel.qml index 9d88bb7..9d88bb7 100644 --- a/demos/declarative/twitter/content/RssModel.qml +++ b/demos/declarative/twitter/TwitterCore/RssModel.qml diff --git a/demos/declarative/twitter/content/TitleBar.qml b/demos/declarative/twitter/TwitterCore/TitleBar.qml index 149aa82..149aa82 100644 --- a/demos/declarative/twitter/content/TitleBar.qml +++ b/demos/declarative/twitter/TwitterCore/TitleBar.qml diff --git a/demos/declarative/twitter/content/ToolBar.qml b/demos/declarative/twitter/TwitterCore/ToolBar.qml index f96c767..f96c767 100644 --- a/demos/declarative/twitter/content/ToolBar.qml +++ b/demos/declarative/twitter/TwitterCore/ToolBar.qml diff --git a/demos/declarative/twitter/content/UserModel.qml b/demos/declarative/twitter/TwitterCore/UserModel.qml index c146b84..c146b84 100644 --- a/demos/declarative/twitter/content/UserModel.qml +++ b/demos/declarative/twitter/TwitterCore/UserModel.qml diff --git a/demos/declarative/twitter/content/images/gloss.png b/demos/declarative/twitter/TwitterCore/images/gloss.png Binary files differindex 5d370cd..5d370cd 100644 --- a/demos/declarative/twitter/content/images/gloss.png +++ b/demos/declarative/twitter/TwitterCore/images/gloss.png diff --git a/demos/declarative/twitter/content/images/lineedit.png b/demos/declarative/twitter/TwitterCore/images/lineedit.png Binary files differindex 2cc38dc..2cc38dc 100644 --- a/demos/declarative/twitter/content/images/lineedit.png +++ b/demos/declarative/twitter/TwitterCore/images/lineedit.png diff --git a/demos/declarative/twitter/content/images/lineedit.sci b/demos/declarative/twitter/TwitterCore/images/lineedit.sci index 054bff7..054bff7 100644 --- a/demos/declarative/twitter/content/images/lineedit.sci +++ b/demos/declarative/twitter/TwitterCore/images/lineedit.sci diff --git a/demos/declarative/twitter/content/images/loading.png b/demos/declarative/twitter/TwitterCore/images/loading.png Binary files differindex 47a1589..47a1589 100644 --- a/demos/declarative/twitter/content/images/loading.png +++ b/demos/declarative/twitter/TwitterCore/images/loading.png diff --git a/demos/declarative/twitter/content/images/stripes.png b/demos/declarative/twitter/TwitterCore/images/stripes.png Binary files differindex 9f36727..9f36727 100644 --- a/demos/declarative/twitter/content/images/stripes.png +++ b/demos/declarative/twitter/TwitterCore/images/stripes.png diff --git a/demos/declarative/twitter/content/images/titlebar.png b/demos/declarative/twitter/TwitterCore/images/titlebar.png Binary files differindex 51c9008..51c9008 100644 --- a/demos/declarative/twitter/content/images/titlebar.png +++ b/demos/declarative/twitter/TwitterCore/images/titlebar.png diff --git a/demos/declarative/twitter/content/images/titlebar.sci b/demos/declarative/twitter/TwitterCore/images/titlebar.sci index 0418d94..0418d94 100644 --- a/demos/declarative/twitter/content/images/titlebar.sci +++ b/demos/declarative/twitter/TwitterCore/images/titlebar.sci diff --git a/demos/declarative/twitter/content/images/toolbutton.png b/demos/declarative/twitter/TwitterCore/images/toolbutton.png Binary files differindex 1131001..1131001 100644 --- a/demos/declarative/twitter/content/images/toolbutton.png +++ b/demos/declarative/twitter/TwitterCore/images/toolbutton.png diff --git a/demos/declarative/twitter/content/images/toolbutton.sci b/demos/declarative/twitter/TwitterCore/images/toolbutton.sci index 9e4f965..9e4f965 100644 --- a/demos/declarative/twitter/content/images/toolbutton.sci +++ b/demos/declarative/twitter/TwitterCore/images/toolbutton.sci diff --git a/demos/declarative/twitter/TwitterCore/qmldir b/demos/declarative/twitter/TwitterCore/qmldir new file mode 100644 index 0000000..8b56c56 --- /dev/null +++ b/demos/declarative/twitter/TwitterCore/qmldir @@ -0,0 +1,10 @@ +AuthView 1.0 AuthView.qml +Button 1.0 Button.qml +FatDelegate 1.0 FatDelegate.qml +HomeTitleBar 1.0 HomeTitleBar.qml +Loading 1.0 Loading.qml +MultiTitleBar 1.0 MultiTitleBar.qml +TitleBar 1.0 TitleBar.qml +RssModel 1.0 RssModel.qml +UserModel 1.0 UserModel.qml +ToolBar 1.0 ToolBar.qml diff --git a/demos/declarative/twitter/twitter.qml b/demos/declarative/twitter/twitter.qml index b091b03..259f79a 100644 --- a/demos/declarative/twitter/twitter.qml +++ b/demos/declarative/twitter/twitter.qml @@ -1,5 +1,5 @@ import Qt 4.6 -import "content" as Twitter +import TwitterCore 1.0 as Twitter Item { id: screen; width: 320; height: 480 @@ -28,14 +28,14 @@ Item { id: background anchors.fill: parent; color: "#343434"; - Image { source: "content/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 } + Image { source: "TwitterCore/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 } Twitter.RssModel { id: rssModel } Twitter.Loading { anchors.centerIn: parent; visible: rssModel.status==XmlListModel.Loading && state!='unauthed'} Text { width: 180 text: "Could not access twitter using this screen name and password pair."; - color: "white"; color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrap: true + color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrap: true visible: rssModel.status==XmlListModel.Error; anchors.centerIn: parent } diff --git a/demos/declarative/webbrowser/content/FlickableWebView.qml b/demos/declarative/webbrowser/content/FlickableWebView.qml index 76a5813..30a5d78 100644 --- a/demos/declarative/webbrowser/content/FlickableWebView.qml +++ b/demos/declarative/webbrowser/content/FlickableWebView.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 Flickable { property alias title: webView.title @@ -22,6 +23,7 @@ Flickable { WebView { id: webView pixelCacheSize: 4000000 + transformOrigin: Item.TopLeft Script { function fixUrl(url) diff --git a/demos/declarative/webbrowser/content/fieldtext/FieldText.qml b/demos/declarative/webbrowser/content/fieldtext/FieldText.qml index 19b6acc..d282209 100644 --- a/demos/declarative/webbrowser/content/fieldtext/FieldText.qml +++ b/demos/declarative/webbrowser/content/fieldtext/FieldText.qml @@ -85,7 +85,7 @@ Item { font.bold: true text: label opacity: textEdit.text == '' ? 1 : 0 - opacity: Behavior { + Behavior on opacity { NumberAnimation { property: "opacity" duration: 250 diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 6a427f4..b6cccb0 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 import "content" diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index 1fd4dad..6cca39b 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -91,6 +91,7 @@ The following table lists the QML elements provided by the Qt Declarative module \o \l VisualDataModel \o \l Package \o \l XmlListModel and XmlRole +\o \l WorkerListModel \o \l DateTimeFormatter \o \l NumberFormatter \endlist @@ -102,6 +103,7 @@ The following table lists the QML elements provided by the Qt Declarative module \o \l Component \o \l Timer \o \l QtObject +\o \l WorkerScript \endlist \endtable diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc index c718a6d..4b1c7d3 100644 --- a/doc/src/declarative/globalobject.qdoc +++ b/doc/src/declarative/globalobject.qdoc @@ -87,6 +87,82 @@ This function returns a Point with the specified \c x and \c y coordinates. This function returns as Size with the specified \c width and \c height. \section3 Qt.vector3d(real x, real y, real z) This function returns a Vector3D with the specified \c x, \c y and \c z. + +\section2 Formatters +The Qt object contains several functions for formatting dates and times. + +\section3 Qt.formatDate(datetime date, variant format) +This function returns the string representation of \c date, formatted according to \c format. +\section3 Qt.formatTime(datetime time, variant format) +This function returns the string representation of \c time, formatted according to \c format. +\section3 Qt.formatDateTime(datetime dateTime, variant format) +This function returns the string representation of \c dateTime, formatted according to \c format. + +\c format for the above formatting functions can be specified as follows. + + These expressions may be used for the date: + + \table + \header \i Expression \i Output + \row \i d \i the day as number without a leading zero (1 to 31) + \row \i dd \i the day as number with a leading zero (01 to 31) + \row \i ddd + \i the abbreviated localized day name (e.g. 'Mon' to 'Sun'). + Uses QDate::shortDayName(). + \row \i dddd + \i the long localized day name (e.g. 'Monday' to 'Qt::Sunday'). + Uses QDate::longDayName(). + \row \i M \i the month as number without a leading zero (1-12) + \row \i MM \i the month as number with a leading zero (01-12) + \row \i MMM + \i the abbreviated localized month name (e.g. 'Jan' to 'Dec'). + Uses QDate::shortMonthName(). + \row \i MMMM + \i the long localized month name (e.g. 'January' to 'December'). + Uses QDate::longMonthName(). + \row \i yy \i the year as two digit number (00-99) + \row \i yyyy \i the year as four digit number + \endtable + + These expressions may be used for the time: + + \table + \header \i Expression \i Output + \row \i h + \i the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) + \row \i hh + \i the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) + \row \i m \i the minute without a leading zero (0 to 59) + \row \i mm \i the minute with a leading zero (00 to 59) + \row \i s \i the second without a leading zero (0 to 59) + \row \i ss \i the second with a leading zero (00 to 59) + \row \i z \i the milliseconds without leading zeroes (0 to 999) + \row \i zzz \i the milliseconds with leading zeroes (000 to 999) + \row \i AP + \i use AM/PM display. \e AP will be replaced by either "AM" or "PM". + \row \i ap + \i use am/pm display. \e ap will be replaced by either "am" or "pm". + \endtable + + All other input characters will be ignored. Any sequence of characters that + are enclosed in singlequotes will be treated as text and not be used as an + expression. Two consecutive singlequotes ("''") are replaced by a singlequote + in the output. + + Example format strings (assumed that the date and time is 21 May 2001 + 14:13:09): + + \table + \header \i Format \i Result + \row \i dd.MM.yyyy \i 21.05.2001 + \row \i ddd MMMM d yy \i Tue May 21 01 + \row \i hh:mm:ss.zzz \i 14:13:09.042 + \row \i h:m:s ap \i 2:13:9 pm + \endtable + +If no format is specified the locale's short format is used. Alternatively, you can specify +\c Qt.DefaultLocaleLongDate to get the locale's long format. + \section2 Functions The Qt object also contains the following miscellaneous functions which expose Qt functionality for use in QML. @@ -119,9 +195,6 @@ while the following would rotate myItem clockwise from 350 degrees to 370 degree NumberAnimation { target: myItem; property: "rotation"; from: 350; to: Qt.closetAngle(350, 10) } \endqml -\section3 Qt.playSound(url soundLocation) -This function plays the audio file located at \c soundLocation. Only .wav files are supported. - \section3 Qt.openUrlExternally(url target) This function attempts to open the specified \c target url in an external application, based on the user's desktop preferences. It will return true if it succeeds, and false otherwise. diff --git a/doc/src/declarative/tutorial.qdoc b/doc/src/declarative/tutorial.qdoc index 98efe12..310b776 100644 --- a/doc/src/declarative/tutorial.qdoc +++ b/doc/src/declarative/tutorial.qdoc @@ -173,10 +173,10 @@ In this case the rectangle will have the same size as its parent (see \l{anchor- \snippet examples/declarative/tutorials/helloworld/Cell.qml 3 -In order to change the color of the text when clicking on a cell, we create a \l MouseRegion element with +In order to change the color of the text when clicking on a cell, we create a \l MouseArea element with the same size as its parent. -A \l MouseRegion defines a signal called \e clicked. +A \l MouseArea defines a signal called \e clicked. When this signal is triggered we want to emit our own \e clicked signal with the color as parameter. \section2 The main QML file @@ -214,7 +214,7 @@ Here is the QML code: \snippet examples/declarative/tutorials/helloworld/tutorial3.qml 2 First, we create a new \e down state for our text element. -This state will be activated when the \l MouseRegion is pressed, and deactivated when it is released. +This state will be activated when the \l MouseArea is pressed, and deactivated when it is released. The \e down state includes a set of property changes from our implicit \e {default state} (the items as they were initially defined in the QML). diff --git a/examples/declarative/animations/color-animation.qml b/examples/declarative/animations/color-animation.qml index 7171a69..6740522 100644 --- a/examples/declarative/animations/color-animation.qml +++ b/examples/declarative/animations/color-animation.qml @@ -10,7 +10,7 @@ Item { gradient: Gradient { GradientStop { position: 0.0 - color: SequentialAnimation { + SequentialAnimation on color { repeat: true ColorAnimation { from: "DeepSkyBlue"; to: "#0E1533"; duration: 5000 } ColorAnimation { from: "#0E1533"; to: "DeepSkyBlue"; duration: 5000 } @@ -18,7 +18,7 @@ Item { } GradientStop { position: 1.0 - color: SequentialAnimation { + SequentialAnimation on color { repeat: true ColorAnimation { from: "SkyBlue"; to: "#437284"; duration: 5000 } ColorAnimation { from: "#437284"; to: "SkyBlue"; duration: 5000 } @@ -31,7 +31,7 @@ Item { Item { width: parent.width; height: 2 * parent.height transformOrigin: Item.Center - rotation: NumberAnimation { from: 0; to: 360; duration: 10000; repeat: true } + NumberAnimation on rotation { from: 0; to: 360; duration: 10000; repeat: true } Image { source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter transformOrigin: Item.Center; rotation: -3 * parent.rotation @@ -44,7 +44,7 @@ Item { x: 0; y: parent.height/2; width: parent.width; height: parent.height/2 source: "images/star.png"; angleDeviation: 360; velocity: 0 velocityDeviation: 0; count: parent.width / 10; fadeInDuration: 2800 - opacity: SequentialAnimation { + SequentialAnimation on opacity { repeat: true NumberAnimation { from: 0; to: 1; duration: 5000 } NumberAnimation { from: 1; to: 0; duration: 5000 } @@ -58,7 +58,7 @@ Item { gradient: Gradient { GradientStop { position: 0.0 - color: SequentialAnimation { + SequentialAnimation on color { repeat: true ColorAnimation { from: "ForestGreen"; to: "#001600"; duration: 5000 } ColorAnimation { from: "#001600"; to: "ForestGreen"; duration: 5000 } diff --git a/examples/declarative/animations/property-animation.qml b/examples/declarative/animations/property-animation.qml index 537ee26..4428f34 100644 --- a/examples/declarative/animations/property-animation.qml +++ b/examples/declarative/animations/property-animation.qml @@ -42,7 +42,7 @@ Item { // Animate the y property. Setting repeat to true makes the // animation repeat indefinitely, otherwise it would only run once. - y: SequentialAnimation { + SequentialAnimation on y { repeat: true // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function diff --git a/examples/declarative/aspectratio/face_fit_animated.qml b/examples/declarative/aspectratio/face_fit_animated.qml index 90ea516..79e99e9 100644 --- a/examples/declarative/aspectratio/face_fit_animated.qml +++ b/examples/declarative/aspectratio/face_fit_animated.qml @@ -18,7 +18,7 @@ Rectangle { source: "pics/face.png" x: (parent.width-width*scale)/2 y: (parent.height-height*scale)/2 - scale: SpringFollow { + SpringFollow on scale { source: Math.max(Math.min(face.parent.width/face.width*1.333,face.parent.height/face.height), Math.min(face.parent.width/face.width,face.parent.height/face.height*1.333)) spring: 1 diff --git a/examples/declarative/behaviours/behavior.qml b/examples/declarative/behaviours/behavior.qml index 2732c0a..c84bf62 100644 --- a/examples/declarative/behaviours/behavior.qml +++ b/examples/declarative/behaviours/behavior.qml @@ -50,12 +50,12 @@ Rectangle { radius: 5 border.width: 10; border.color: "white"; x: 100-37; y: 100-25 - x: Behavior { NumberAnimation { duration: 300 } } - y: Behavior { NumberAnimation { duration: 300 } } + Behavior on x { NumberAnimation { duration: 300 } } + Behavior on y { NumberAnimation { duration: 300 } } Text { id: focusText text: focusRect.text; - text: Behavior { + Behavior on text { SequentialAnimation { NumberAnimation { target: focusText; property: "opacity"; to: 0; duration: 150 } PropertyAction {} diff --git a/examples/declarative/behaviours/test.qml b/examples/declarative/behaviours/test.qml deleted file mode 100644 index 8fffd59..0000000 --- a/examples/declarative/behaviours/test.qml +++ /dev/null @@ -1,102 +0,0 @@ -import Qt 4.6 - -Rectangle { - color: "lightsteelblue" - width: 800 - height: 600 - id: page - MouseArea { - anchors.fill: parent - onClicked: { bluerect.parent = page; console.log(mouseX); bluerect.x = mouseX; } - } - MyRect { - color: "green" - x: 200 - y: 200 - } - MyRect { - color: "red" - x: 400 - y: 200 - } - MyRect { - color: "yellow" - x: 400 - y: 400 - } - MyRect { - color: "orange" - x: 400 - y: 500 - } - MyRect { - color: "pink" - x: 400 - y: 0 - } - MyRect { - color: "lightsteelblue" - x: 100 - y: 500 - } - MyRect { - color: "black" - x: 0 - y: 200 - } - MyRect { - color: "white" - x: 400 - y: 0 - } - Rectangle { - color: "blue" - x: 0 - y: 0 - width: 100 - height: 100 - id: bluerect - x: Behavior { - ParallelAnimation { - SequentialAnimation { - NumberAnimation { - target: bluerect - property: "y" - from: 0 - to: 10 - easing.type: "OutBounce" - easing.amplitude: 30 - duration: 250 - } - NumberAnimation { - target: bluerect - property: "y" - from: 10 - to: 0 - easing.type: "OutBounce" - easing.amplitude: 30 - duration: 250 - } - } - NumberAnimation { duration: 500 } - } - } - parent: Behavior { - SequentialAnimation { - NumberAnimation { - target: bluerect - property: "opacity" - to: 0 - duration: 150 - } - PropertyAction {} - NumberAnimation { - target: bluerect - property: "opacity" - to: 1 - duration: 150 - } - } - } - } -} diff --git a/examples/declarative/border-image/content/MyBorderImage.qml b/examples/declarative/border-image/content/MyBorderImage.qml index ca886e9..5621e18 100644 --- a/examples/declarative/border-image/content/MyBorderImage.qml +++ b/examples/declarative/border-image/content/MyBorderImage.qml @@ -17,13 +17,13 @@ Item { BorderImage { id: image; x: container.width / 2 - width / 2; y: container.height / 2 - height / 2 - width: SequentialAnimation { + SequentialAnimation on width { repeat: true NumberAnimation { from: container.minWidth; to: container.maxWidth; duration: 2000; easing.type: "InOutQuad"} NumberAnimation { from: container.maxWidth; to: container.minWidth; duration: 2000; easing.type: "InOutQuad" } } - height: SequentialAnimation { + SequentialAnimation on height { repeat: true NumberAnimation { from: container.minHeight; to: container.maxHeight; duration: 2000; easing.type: "InOutQuad"} NumberAnimation { from: container.maxHeight; to: container.minHeight; duration: 2000; easing.type: "InOutQuad" } diff --git a/examples/declarative/clocks/content/Clock.qml b/examples/declarative/clocks/content/Clock.qml index 0c6836f..75a1cf5 100644 --- a/examples/declarative/clocks/content/Clock.qml +++ b/examples/declarative/clocks/content/Clock.qml @@ -34,7 +34,7 @@ Item { transform: Rotation { id: hourRotation origin.x: 7.5; origin.y: 73; angle: 0 - angle: SpringFollow { + SpringFollow on angle { spring: 2; damping: 0.2; modulus: 360 source: (clock.hours * 30) + (clock.minutes * 0.5) } @@ -48,7 +48,7 @@ Item { transform: Rotation { id: minuteRotation origin.x: 6.5; origin.y: 83; angle: 0 - angle: SpringFollow { + SpringFollow on angle { spring: 2; damping: 0.2; modulus: 360 source: clock.minutes * 6 } @@ -62,7 +62,7 @@ Item { transform: Rotation { id: secondRotation origin.x: 2.5; origin.y: 80; angle: 0 - angle: SpringFollow { + SpringFollow on angle { spring: 5; damping: 0.25; modulus: 360 source: clock.seconds * 6 } diff --git a/examples/declarative/colorbrowser/colorbrowser.qml b/examples/declarative/colorbrowser/colorbrowser.qml new file mode 100644 index 0000000..421ae07 --- /dev/null +++ b/examples/declarative/colorbrowser/colorbrowser.qml @@ -0,0 +1,101 @@ +import Qt 4.6 +import 'qml' + +Rectangle { + id: mainWindow + width: 800; height: 480; color: '#454545' + + VisualDataModel { id: colorsVisualModel; delegate: colorsDelegate; model: ColorsModel } + + Component { + id: colorsDelegate + Package { + + Item { + Package.name: 'grid' + GridView { + id: gridView; model: visualModel.parts.grid; width: mainWindow.width; height: mainWindow.height + cellWidth: 160; cellHeight: 160; interactive: false + onCurrentIndexChanged: listView.positionViewAtIndex(currentIndex) + } + } + + Item { + Package.name: 'fullscreen' + ListView { + id: listView; model: visualModel.parts.list; orientation: Qt.Horizontal + width: mainWindow.width; height: mainWindow.height; interactive: false + onCurrentIndexChanged: gridView.positionViewAtIndex(currentIndex) + highlightRangeMode: ListView.StrictlyEnforceRange; snapMode: ListView.SnapOneItem + } + } + + Item { + Package.name: 'stack' + id: wrapper + width: 260; height: 240 + + VisualDataModel { id: visualModel; model: colors; delegate: ColorDelegate {} } + + PathView { + id: pathView; model: visualModel.parts.stack; anchors.centerIn: parent + pathItemCount: 3 + path: Path { + PathAttribute { name: 'z'; value: 9999.0 } + PathLine { x: 1; y: 1 } + PathAttribute { name: 'z'; value: 0.0 } + } + } + + Item { + anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom; anchors.bottomMargin: 20 + width: albumTitle.width + 20 ; height: albumTitle.height + 4 + Text { id: albumTitle; text: name; color: 'white'; font.bold: true; anchors.centerIn: parent } + } + + MouseArea { anchors.fill: parent; onClicked: wrapper.state = 'inGrid' } + + states: [ + State { + name: 'inGrid' + PropertyChanges { target: gridView; interactive: true } + PropertyChanges { target: shade; opacity: 1 } + }, + State { + name: 'fullscreen'; extend: 'inGrid' + PropertyChanges { target: gridView; interactive: false } + PropertyChanges { target: listView; interactive: true } + PropertyChanges { target: infobox; opacity: 1 } + } + ] + + transitions: [ + Transition { + from: ''; to: 'inGrid'; reversible: true + NumberAnimation { target: shade; properties: 'opacity'; duration: 300 } + }, + Transition { + from: 'inGrid'; to: 'fullscreen'; reversible: true + SequentialAnimation { + PauseAnimation { duration: 300 } + NumberAnimation { target: infobox; properties: 'opacity'; duration: 300 } + } + } + ] + } + } + } + + GridView { width: parent.width; height: parent.height; cellWidth: 260; cellHeight: 240; model: colorsVisualModel.parts.stack } + Rectangle { id: shade; color: '#454545'; width: parent.width; height: parent.height; opacity: 0 } + ListView { anchors.fill: parent; model: colorsVisualModel.parts.grid; interactive: false } + ListView { anchors.fill: parent; model: colorsVisualModel.parts.fullscreen; interactive: false } + Item { id: foreground; anchors.fill: parent } + + Column { + id: infobox; opacity: 0 + anchors { left: parent.left; leftMargin: 20; bottom: parent.bottom; bottomMargin: 20 } + Text { id: infoColorName; color: '#eeeeee'; style: Text.Outline; styleColor: '#222222'; font.pointSize: 18 } + Text { id: infoColorHex; color: '#eeeeee'; style: Text.Outline; styleColor: '#222222'; font.pointSize: 14 } + } +} diff --git a/examples/declarative/colorbrowser/dummydata/ColorsModel.qml b/examples/declarative/colorbrowser/dummydata/ColorsModel.qml new file mode 100644 index 0000000..eefbcfe --- /dev/null +++ b/examples/declarative/colorbrowser/dummydata/ColorsModel.qml @@ -0,0 +1,96 @@ +import Qt 4.6 + +ListModel { + id: colorsModel + + ListElement { + name: "Reds" + colors: [ + ListElement { name: "Fire Brick"; hex: "#B22222" }, + ListElement { name: "Fire Brick 1"; hex: "#FF3030" }, + ListElement { name: "Fire Brick 2"; hex: "#EE2C2C" }, + ListElement { name: "Fire Brick 3"; hex: "#CD2626" }, + ListElement { name: "Fire Brick 4"; hex: "#8B1A1A" }, + ListElement { name: "Red"; hex: "#FF0000" }, + ListElement { name: "Red 2"; hex: "#EE0000" }, + ListElement { name: "Red 3"; hex: "#CD0000" }, + ListElement { name: "Red 4"; hex: "#8B0000" }, + ListElement { name: "Tomato"; hex: "#FF6347" }, + ListElement { name: "Tomato 2"; hex: "#EE5C42" }, + ListElement { name: "Tomato 3"; hex: "#CD4F39" }, + ListElement { name: "Tomato 4"; hex: "#8B3626" }, + ListElement { name: "Orange Red"; hex: "#FF4500" }, + ListElement { name: "Orange Red 2"; hex: "#EE4000" }, + ListElement { name: "Orange Red 3"; hex: "#CD3700" }, + ListElement { name: "Orange Red 4"; hex: "#8B2500" }, + ListElement { name: "Indian Red 2"; hex: "#EE6363" }, + ListElement { name: "Indian Red 3"; hex: "#CD5555" }, + ListElement { name: "Indian Red 4"; hex: "#8B3A3A" }, + ListElement { name: "Brown"; hex: "#A52A2A" }, + ListElement { name: "Brown 1"; hex: "#FF4040" }, + ListElement { name: "Brown 2"; hex: "#EE3B3B" }, + ListElement { name: "Brown 3"; hex: "#CD3333" }, + ListElement { name: "Brown 4"; hex: "#8B2323" } + ] + } + ListElement { + name: "Greens" + colors: [ + ListElement { name: "Green"; hex: "#008000" }, + ListElement { name: "Green 2"; hex: "#00EE00" }, + ListElement { name: "Green 3"; hex: "#00CD00" }, + ListElement { name: "Green 4"; hex: "#008B00" }, + ListElement { name: "Dark Green"; hex: "#006400" }, + ListElement { name: "Sap Green"; hex: "#308014" }, + ListElement { name: "Medium Spring Green"; hex: "#00FA9A" }, + ListElement { name: "Spring Green"; hex: "#00FF7F" }, + ListElement { name: "Spring Green 1"; hex: "#00EE76" }, + ListElement { name: "Spring Green 2"; hex: "#00CD66" }, + ListElement { name: "Spring Green 3"; hex: "#008B45" }, + ListElement { name: "Medium Sea Green"; hex: "#3CB371" }, + ListElement { name: "Sea Green 1"; hex: "#54FF9F" }, + ListElement { name: "Sea Green 2"; hex: "#4EEE94" }, + ListElement { name: "Sea Green 3"; hex: "#43CD80" }, + ListElement { name: "Sea Green 4"; hex: "#2E8B57" }, + ListElement { name: "Emerald Green"; hex: "#00C957" }, + ListElement { name: "Mint"; hex: "#BDFCC9" }, + ListElement { name: "Cobalt Green"; hex: "#3D9140" }, + ListElement { name: "Dark Sea Green"; hex: "#8FBC8F" }, + ListElement { name: "Dark Sea Green 1"; hex: "#C1FFC1" }, + ListElement { name: "Dark Sea Green 2"; hex: "#B4EEB4" }, + ListElement { name: "Dark Sea Green 3"; hex: "#9BCD9B" }, + ListElement { name: "Dark Sea Green 4"; hex: "#698B69" }, + ListElement { name: "Lime Green"; hex: "#00FF00" } + ] + } + ListElement { + name: "Blues" + colors: [ + ListElement { name: "Dark Slate Blue"; hex: "#483D8B" }, + ListElement { name: "Light Slate Blue"; hex: "#8470FF" }, + ListElement { name: "Medium Slate Blue"; hex: "#7B68EE" }, + ListElement { name: "Slate Blue"; hex: "#6A5ACD" }, + ListElement { name: "Blue"; hex: "#0000FF" }, + ListElement { name: "Midnight Blue"; hex: "#191970" }, + ListElement { name: "Cobalt"; hex: "#3D59AB" }, + ListElement { name: "Royal Blue"; hex: "#4169E1" }, + ListElement { name: "Corn Flower Blue"; hex: "#6495ED" }, + ListElement { name: "Light Steel Blue"; hex: "#B0C4DE" }, + ListElement { name: "Light Steel Blue 1"; hex: "#CAE1FF" }, + ListElement { name: "Light Steel Blue 2"; hex: "#BCD2EE" }, + ListElement { name: "Light Steel Blue 3"; hex: "#A2B5CD" }, + ListElement { name: "Dodger Blue"; hex: "#1E90FF" }, + ListElement { name: "Dodger Blue 2"; hex: "#1C86EE" }, + ListElement { name: "Dodger Blue 3"; hex: "#1874CD" }, + ListElement { name: "Dodger Blue 4"; hex: "#104E8B" }, + ListElement { name: "Steel Blue"; hex: "#4682B4" }, + ListElement { name: "Light Sky Blue"; hex: "#87CEFA" }, + ListElement { name: "Sky Blue"; hex: "#87CEEB" }, + ListElement { name: "Peacock"; hex: "#33A1C9" }, + ListElement { name: "Light Blue"; hex: "#ADD8E6" }, + ListElement { name: "Powder Blue"; hex: "#B0E0E6" }, + ListElement { name: "Cadet Blue"; hex: "#5F9EA0" }, + ListElement { name: "Cyan"; hex: "#00FFFF" } + ] + } +} diff --git a/examples/declarative/colorbrowser/qml/ColorDelegate.qml b/examples/declarative/colorbrowser/qml/ColorDelegate.qml new file mode 100644 index 0000000..c123d12 --- /dev/null +++ b/examples/declarative/colorbrowser/qml/ColorDelegate.qml @@ -0,0 +1,114 @@ +import Qt 4.6 + +Package { + Item { id: stack; Package.name: 'stack'; width: 110; height: 110; z: stack.PathView.z } + Item { id: list; Package.name: 'list'; width: mainWindow.width + 4; height: 110 } + Item { id: grid; Package.name: 'grid'; width: 110; height: 110 } + + Item { + id: delegate + + property double randomAngle: Math.random() * (2 * 8 + 1) - 8 + property bool open: false + + width: 110; height: 110; z: stack.PathView.z + + Image { x: -6; y: -5; source: 'box-shadow.png'; smooth: true; } + Rectangle { color: hex; anchors.fill: parent; smooth: true } + Image { id: box; source: 'box.png'; smooth: true; anchors.fill: parent } + + Binding { + target: infoColorName; property: 'text' + value: name; when: delegate.open && list.ListView.isCurrentItem + } + + Binding { + target: infoColorHex; property: 'text' + value: hex; when: delegate.open && list.ListView.isCurrentItem + } + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.RightButton | Qt.LeftButton + onClicked: { + if (wrapper.state == 'inGrid' && mouse.button == Qt.RightButton) { + wrapper.state = '' + } else if (wrapper.state == 'inGrid') { + grid.GridView.view.currentIndex = index; + wrapper.state = 'fullscreen' + } else { + grid.GridView.view.currentIndex = index; + wrapper.state = 'inGrid' + } + } + } + + states: [ + State { + name: 'stacked'; when: wrapper.state == '' + ParentChange { target: delegate; parent: stack; x: 0; y: 0; rotation: delegate.randomAngle } + PropertyChanges { target: delegate; visible: stack.PathView.onPath ? 1.0 : 0.0 } + }, + State { + name: 'inGrid'; when: wrapper.state == 'inGrid' + ParentChange { target: delegate; parent: grid; x: 24; y: 24 } + PropertyChanges { target: delegate; open: true } + }, + State { + name: 'fullscreen'; when: wrapper.state == 'fullscreen' + ParentChange { target: delegate; parent: list; x: 0; y: 0; width: mainWindow.width; height: mainWindow.height } + PropertyChanges { target: box; opacity: 0 } + PropertyChanges { target: delegate; open: true } + } + ] + + transitions: [ + Transition { + from: 'stacked'; to: 'inGrid' + SequentialAnimation { + PauseAnimation { duration: 20 * index } + ParentAnimation { + target: delegate; via: foreground + NumberAnimation { targets: delegate; properties: 'x,y,width,height,rotation'; duration: 600; easing.type: 'OutBack' } + } + } + }, + Transition { + from: 'inGrid'; to: 'stacked' + ParentAnimation { + target: delegate; via: foreground + NumberAnimation { properties: 'x,y,width,height,rotation'; duration: 300; easing.type: 'InOutQuad' } + } + }, + Transition { + from: 'inGrid'; to: 'fullscreen' + SequentialAnimation { + PauseAnimation { duration: grid.GridView.isCurrentItem ? 0 : 300 } + ParentAnimation { + target: delegate; via: foreground + NumberAnimation { + properties: 'x,y,width,height,opacity' + duration: grid.GridView.isCurrentItem ? 300 : 1; easing.type: 'InOutQuad' + } + } + } + }, + Transition { + from: 'fullscreen'; to: 'inGrid' + SequentialAnimation { + PauseAnimation { duration: grid.GridView.isCurrentItem ? 3 : 0 } + ParallelAnimation { + ParentAnimation { + target: delegate; via: foreground + NumberAnimation { + properties: 'x,y,width,height' + duration: grid.GridView.isCurrentItem ? 300 : 1; easing.type: 'InOutQuad' + } + } + NumberAnimation { properties: 'opacity'; duration: grid.GridView.isCurrentItem ? 300 : 1; easing.type: 'InOutQuad' } + } + } + } + ] + } +} diff --git a/examples/declarative/colorbrowser/qml/box-shadow.png b/examples/declarative/colorbrowser/qml/box-shadow.png Binary files differnew file mode 100644 index 0000000..3281a37 --- /dev/null +++ b/examples/declarative/colorbrowser/qml/box-shadow.png diff --git a/examples/declarative/colorbrowser/qml/box.png b/examples/declarative/colorbrowser/qml/box.png Binary files differnew file mode 100644 index 0000000..86538aa --- /dev/null +++ b/examples/declarative/colorbrowser/qml/box.png diff --git a/examples/declarative/connections/connections.qml b/examples/declarative/connections/connections.qml index 4692343..c35bda5 100644 --- a/examples/declarative/connections/connections.qml +++ b/examples/declarative/connections/connections.qml @@ -10,7 +10,7 @@ Rectangle { Image { id: image; source: "content/bg1.jpg"; anchors.centerIn: parent; transformOrigin: Item.Center rotation: window.angle - rotation: Behavior { NumberAnimation { easing.type: "OutCubic"; duration: 300 } } + Behavior on rotation { NumberAnimation { easing.type: "OutCubic"; duration: 300 } } } Button { diff --git a/examples/declarative/dial/content/Dial.qml b/examples/declarative/dial/content/Dial.qml index 6fd0f39..ad4717a 100644 --- a/examples/declarative/dial/content/Dial.qml +++ b/examples/declarative/dial/content/Dial.qml @@ -26,7 +26,7 @@ Item { id: needleRotation origin.x: 7; origin.y: 65 angle: -130 - angle: SpringFollow { + SpringFollow on angle { spring: 1.4 damping: .15 source: Math.min(Math.max(-130, root.value*2.6 - 130), 133) diff --git a/examples/declarative/dynamic/qml/Sun.qml b/examples/declarative/dynamic/qml/Sun.qml index 796a370..81b6e9b 100644 --- a/examples/declarative/dynamic/qml/Sun.qml +++ b/examples/declarative/dynamic/qml/Sun.qml @@ -11,14 +11,14 @@ Image { //x and y get set when instantiated //head offscreen - y: NumberAnimation { - to: parent.height; - duration: 10000; + NumberAnimation on y { + to: window.height / 2; running: created + onRunningChanged: if (running) duration = (window.height - sun.y) * 10; else state = "OffScreen"; } states: State { - name: "OffScreen"; when: created && y > window.height / 2;//Below the ground + name: "OffScreen"; StateChangeScript { script: { sun.created = false; sun.destroy() } } } } diff --git a/examples/declarative/effects/effects.qml b/examples/declarative/effects/effects.qml index 0674433..997d7de 100644 --- a/examples/declarative/effects/effects.qml +++ b/examples/declarative/effects/effects.qml @@ -11,7 +11,7 @@ Rectangle { source: "pic.png" effect: Blur { - blurRadius: NumberAnimation { + NumberAnimation on blurRadius { id: blurEffect running: false from: 0; to: 10 @@ -33,7 +33,7 @@ Rectangle { effect: DropShadow { blurRadius: 3 offset.x: 3 - offset.y: NumberAnimation { id: dropShadowEffect; from: 0; to: 10; duration: 1000; running: false; repeat: true; } + NumberAnimation on offset.y { id: dropShadowEffect; from: 0; to: 10; duration: 1000; running: false; repeat: true; } } MouseArea { anchors.fill: parent; onClicked: dropShadowEffect.running = !dropShadowEffect.running } diff --git a/examples/declarative/fillmode/fillmode.qml b/examples/declarative/fillmode/fillmode.qml index ec3717f..ab0f81c 100644 --- a/examples/declarative/fillmode/fillmode.qml +++ b/examples/declarative/fillmode/fillmode.qml @@ -4,7 +4,7 @@ Image { width: 400 height: 250 source: "face.png" - fillMode: SequentialAnimation { + SequentialAnimation on fillMode { repeat: true PropertyAction { value: Image.Stretch } PropertyAction { target: label; property: "text"; value: "Stretch" } diff --git a/examples/declarative/focusscope/test5.qml b/examples/declarative/focusscope/test5.qml new file mode 100644 index 0000000..da98350 --- /dev/null +++ b/examples/declarative/focusscope/test5.qml @@ -0,0 +1,83 @@ +import Qt 4.6 + +Rectangle { + color: "white" + width: 800 + height: 600 + + Keys.onReturnPressed: console.log("Error - Root") + + FocusScope { + id: myScope + focus: true + + Keys.onReturnPressed: console.log("Error - FocusScope") + + Rectangle { + height: 120 + width: 420 + + color: "transparent" + border.width: 5 + border.color: myScope.wantsFocus?"blue":"black" + + Rectangle { + x: 10; y: 10 + width: 100; height: 100; color: "green" + border.width: 5 + border.color: item1.wantsFocus?"blue":"black" + } + + TextEdit { + id: item1 + x: 20; y: 20 + width: 90; height: 90 + color: "white" + font.pixelSize: 20 + Keys.onReturnPressed: console.log("Top Left"); + KeyNavigation.right: item2 + focus: true + wrap: true + text: "Box 1" + } + + Rectangle { + id: item2 + x: 310; y: 10 + width: 100; height: 100; color: "green" + border.width: 5 + border.color: wantsFocus?"blue":"black" + KeyNavigation.left: item1 + Keys.onReturnPressed: console.log("Top Right"); + + Rectangle { + width: 50; height: 50; anchors.centerIn: parent + color: parent.focus?"red":"transparent" + } + } + } + KeyNavigation.down: item3 + } + + Text { x:100; y:170; text: "Blue border indicates scoped focus\nBlack border indicates NOT scoped focus\nRed box or flashing cursor indicates active focus\nUse arrow keys to navigate\nPress Ctrl-Return to print currently focused item" } + + Rectangle { + x: 10; y: 300 + width: 100; height: 100; color: "green" + border.width: 5 + border.color: item3.wantsFocus?"blue":"black" + } + + TextEdit { + id: item3 + x: 20; y: 310 + width: 90; height: 90 + color: "white" + font.pixelSize: 20 + text: "Box 3" + + Keys.onReturnPressed: console.log("Bottom Left"); + KeyNavigation.up: myScope + wrap: true + } +} diff --git a/examples/declarative/fonts/banner.qml b/examples/declarative/fonts/banner.qml index 00b8660..7989f80 100644 --- a/examples/declarative/fonts/banner.qml +++ b/examples/declarative/fonts/banner.qml @@ -10,7 +10,7 @@ Rectangle { Row { y: -screen.height / 4.5 - x: NumberAnimation { from: 0; to: -text.width; duration: 6000; repeat: true } + NumberAnimation on x { from: 0; to: -text.width; duration: 6000; repeat: true } Text { id: text; font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } diff --git a/examples/declarative/fonts/hello.qml b/examples/declarative/fonts/hello.qml index fcc9580..334409e 100644 --- a/examples/declarative/fonts/hello.qml +++ b/examples/declarative/fonts/hello.qml @@ -9,7 +9,7 @@ Rectangle { id: text; color: "white"; anchors.centerIn: parent text: "Hello world!"; font.pixelSize: 60 - font.letterSpacing: SequentialAnimation { + SequentialAnimation on font.letterSpacing { repeat: true; NumberAnimation { from: 100; to: 300; easing.type: "InQuad"; duration: 3000 } ScriptAction { script: { @@ -17,7 +17,7 @@ Rectangle { container.x = (screen.width / 4) + (Math.random() * screen.width / 2) } } } - opacity: SequentialAnimation { + SequentialAnimation on opacity { repeat: true; NumberAnimation { from: 1; to: 0; duration: 2600 } PauseAnimation { duration: 400 } diff --git a/examples/declarative/imageprovider/ImageProviderCore/qmldir b/examples/declarative/imageprovider/ImageProviderCore/qmldir new file mode 100644 index 0000000..1028590 --- /dev/null +++ b/examples/declarative/imageprovider/ImageProviderCore/qmldir @@ -0,0 +1,2 @@ +plugin imageprovider + diff --git a/examples/declarative/imageprovider/main.cpp b/examples/declarative/imageprovider/imageprovider.cpp index d9d4c1a..253dbf5 100644 --- a/examples/declarative/imageprovider/main.cpp +++ b/examples/declarative/imageprovider/imageprovider.cpp @@ -39,7 +39,8 @@ ** ****************************************************************************/ -#include <QApplication> + +#include <qdeclarativeextensionplugin.h> #include <qdeclarativeengine.h> #include <qdeclarativecontext.h> @@ -70,29 +71,37 @@ public: } }; -int main(int argc, char ** argv) + +class ImageProviderExtensionPlugin : public QDeclarativeExtensionPlugin { - QApplication app(argc, argv); + Q_OBJECT +public: + void registerTypes(const char *uri) { + Q_UNUSED(uri); + + } - QDeclarativeView view; + void initializeEngine(QDeclarativeEngine *engine, const char *uri) { + Q_UNUSED(uri); - view.engine()->addImageProvider("colors", new ColorImageProvider); + engine->addImageProvider("colors", new ColorImageProvider); - QStringList dataList; - dataList.append("image://colors/red"); - dataList.append("image://colors/green"); - dataList.append("image://colors/blue"); - dataList.append("image://colors/brown"); - dataList.append("image://colors/orange"); - dataList.append("image://colors/purple"); - dataList.append("image://colors/yellow"); + QStringList dataList; + dataList.append("image://colors/red"); + dataList.append("image://colors/green"); + dataList.append("image://colors/blue"); + dataList.append("image://colors/brown"); + dataList.append("image://colors/orange"); + dataList.append("image://colors/purple"); + dataList.append("image://colors/yellow"); - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); + QDeclarativeContext *ctxt = engine->rootContext(); + ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); + } - view.setSource(QUrl("qrc:view.qml")); - view.show(); +}; + +#include "imageprovider.moc" + +Q_EXPORT_PLUGIN(ImageProviderExtensionPlugin); - return app.exec(); -} -//![0] diff --git a/examples/declarative/imageprovider/imageprovider.pro b/examples/declarative/imageprovider/imageprovider.pro index 60423ab..e403bf8 100644 --- a/examples/declarative/imageprovider/imageprovider.pro +++ b/examples/declarative/imageprovider/imageprovider.pro @@ -1,9 +1,11 @@ -TEMPLATE = app -TARGET = imageprovider -DEPENDPATH += . -INCLUDEPATH += . +TEMPLATE = lib +TARGET = imageprovider QT += declarative +CONFIG += qt plugin + +TARGET = $$qtLibraryTarget($$TARGET) +DESTDIR = ImageProviderCore # Input -SOURCES += main.cpp -RESOURCES += imageprovider.qrc +SOURCES += imageprovider.cpp + diff --git a/examples/declarative/imageprovider/view.qml b/examples/declarative/imageprovider/imageprovider.qml index 2ab729d..f899b1e 100644 --- a/examples/declarative/imageprovider/view.qml +++ b/examples/declarative/imageprovider/imageprovider.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import "ImageProviderCore" //![0] ListView { width: 100 diff --git a/examples/declarative/imageprovider/imageprovider.qrc b/examples/declarative/imageprovider/imageprovider.qrc deleted file mode 100644 index 17e9301..0000000 --- a/examples/declarative/imageprovider/imageprovider.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>view.qml</file> -</qresource> -</RCC> diff --git a/examples/declarative/layouts/layouts.qml b/examples/declarative/layouts/layouts.qml index accd969..4b2a3f8 100644 --- a/examples/declarative/layouts/layouts.qml +++ b/examples/declarative/layouts/layouts.qml @@ -1,5 +1,5 @@ import Qt 4.6 - +import Qt.widgets 4.6 Item { id: resizable width:400 diff --git a/examples/declarative/layouts/positioners.qml b/examples/declarative/layouts/positioners.qml index 7146702..bce53bd 100644 --- a/examples/declarative/layouts/positioners.qml +++ b/examples/declarative/layouts/positioners.qml @@ -21,11 +21,11 @@ Rectangle { } Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 } Rectangle { id: blueV1; color: "lightsteelblue"; width: 100; height: 50; border.color: "black"; radius: 15 - opacity: Behavior{NumberAnimation{}} + Behavior on opacity {NumberAnimation{}} } Rectangle { color: "green"; width: 100; height: 50; border.color: "black"; radius: 15 } Rectangle { id: blueV2; color: "lightsteelblue"; width: 100; height: 50; border.color: "black"; radius: 15 - opacity: Behavior{NumberAnimation{}} + Behavior on opacity {NumberAnimation{}} } Rectangle { color: "orange"; width: 100; height: 50; border.color: "black"; radius: 15 } } @@ -45,11 +45,11 @@ Rectangle { } Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 } Rectangle { id: blueH1; color: "lightsteelblue"; width: 50; height: 100; border.color: "black"; radius: 15 - opacity: Behavior{NumberAnimation{}} + Behavior on opacity {NumberAnimation{}} } Rectangle { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 } Rectangle { id: blueH2; color: "lightsteelblue"; width: 50; height: 100; border.color: "black"; radius: 15 - opacity: Behavior{NumberAnimation{}} + Behavior on opacity {NumberAnimation{}} } Rectangle { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 } } @@ -113,15 +113,15 @@ Rectangle { Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } Rectangle { id: blueG1; color: "lightsteelblue"; width: 50; height: 50; border.color: "black"; radius: 15 - opacity: Behavior{NumberAnimation{}} + Behavior on opacity {NumberAnimation{}} } Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } Rectangle { id: blueG2; color: "lightsteelblue"; width: 50; height: 50; border.color: "black"; radius: 15 - opacity: Behavior{NumberAnimation{}} + Behavior on opacity {NumberAnimation{}} } Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } Rectangle { id: blueG3; color: "lightsteelblue"; width: 50; height: 50; border.color: "black"; radius: 15 - opacity: Behavior{NumberAnimation{}} + Behavior on opacity {NumberAnimation{}} } Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } @@ -147,15 +147,15 @@ Rectangle { } Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } Rectangle { id: blueF1; color: "lightsteelblue"; width: 60; height: 50; border.color: "black"; radius: 15 - opacity: Behavior{NumberAnimation{}} + Behavior on opacity {NumberAnimation{}} } Rectangle { color: "green"; width: 30; height: 50; border.color: "black"; radius: 15 } Rectangle { id: blueF2; color: "lightsteelblue"; width: 60; height: 50; border.color: "black"; radius: 15 - opacity: Behavior{NumberAnimation{}} + Behavior on opacity {NumberAnimation{}} } Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } Rectangle { id: blueF3; color: "lightsteelblue"; width: 40; height: 50; border.color: "black"; radius: 15 - opacity: Behavior{NumberAnimation{}} + Behavior on opacity {NumberAnimation{}} } Rectangle { color: "red"; width: 80; height: 50; border.color: "black"; radius: 15 } } diff --git a/examples/declarative/listview/content/ClickAutoRepeating.qml b/examples/declarative/listview/content/ClickAutoRepeating.qml index 0850f4e..5240e65 100644 --- a/examples/declarative/listview/content/ClickAutoRepeating.qml +++ b/examples/declarative/listview/content/ClickAutoRepeating.qml @@ -10,7 +10,7 @@ Item { signal released signal clicked - isPressed: SequentialAnimation { + SequentialAnimation on isPressed { running: false id: autoRepeat PropertyAction { target: page; property: "isPressed"; value: true } diff --git a/examples/declarative/listview/highlight.qml b/examples/declarative/listview/highlight.qml index be1f62d..5e4911d 100644 --- a/examples/declarative/listview/highlight.qml +++ b/examples/declarative/listview/highlight.qml @@ -44,7 +44,7 @@ Rectangle { id: petHighlight Rectangle { width: 200; height: 50; color: "#FFFF88" - y: SpringFollow { source: list1.currentItem.y; spring: 3; damping: 0.1 } + SpringFollow on y { source: list1.currentItem.y; spring: 3; damping: 0.1 } } } ListView { diff --git a/examples/declarative/package/Delegate.qml b/examples/declarative/package/Delegate.qml index 4109633..f35314f 100644 --- a/examples/declarative/package/Delegate.qml +++ b/examples/declarative/package/Delegate.qml @@ -2,24 +2,26 @@ import Qt 4.6 //![0] Package { - Text { id: listDelegate; width: 200; height: 25; text: "Empty"; Package.name: "list" } - Text { id: gridDelegate; width: 100; height: 50; text: "Empty"; Package.name: "grid" } + Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' } + Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' } Rectangle { id: wrapper width: 200; height: 25 - color: "lightsteelblue" + color: 'lightsteelblue' + Text { text: display; anchors.centerIn: parent } - MouseRegion { + MouseArea { anchors.fill: parent onClicked: { - if (wrapper.state == "inList") - wrapper.state = "inGrid"; + if (wrapper.state == 'inList') + wrapper.state = 'inGrid'; else - wrapper.state = "inList"; + wrapper.state = 'inList'; } } - state: "inList" + + state: 'inList' states: [ State { name: 'inList' @@ -27,15 +29,17 @@ Package { }, State { name: 'inGrid' - ParentChange { target: wrapper; parent: gridDelegate } - PropertyChanges { target: wrapper; x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height } + ParentChange { + target: wrapper; parent: gridDelegate + x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height + } } ] + transitions: [ Transition { - SequentialAnimation { - ParentAction { target: wrapper } - NumberAnimation { targets: wrapper; properties: 'x,y,width,height'; duration: 300 } + ParentAnimation { + NumberAnimation { properties: 'x,y,width,height'; duration: 300 } } } ] diff --git a/examples/declarative/parallax/qml/ParallaxView.qml b/examples/declarative/parallax/qml/ParallaxView.qml index 5e58100..08193ae 100644 --- a/examples/declarative/parallax/qml/ParallaxView.qml +++ b/examples/declarative/parallax/qml/ParallaxView.qml @@ -25,6 +25,7 @@ Item { anchors.fill: parent model: VisualItemModel { id: visualModel } + highlightRangeMode: ListView.StrictlyEnforceRange snapMode: ListView.SnapOneItem } diff --git a/examples/declarative/parallax/qml/Smiley.qml b/examples/declarative/parallax/qml/Smiley.qml index 81eadda..4442d5e 100644 --- a/examples/declarative/parallax/qml/Smiley.qml +++ b/examples/declarative/parallax/qml/Smiley.qml @@ -24,7 +24,7 @@ Item { // Animate the y property. Setting repeat to true makes the // animation repeat indefinitely, otherwise it would only run once. - y: SequentialAnimation { + SequentialAnimation on y { repeat: true // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function diff --git a/examples/declarative/progressbar/content/ProgressBar.qml b/examples/declarative/progressbar/content/ProgressBar.qml index bfc801c..65c80b2 100644 --- a/examples/declarative/progressbar/content/ProgressBar.qml +++ b/examples/declarative/progressbar/content/ProgressBar.qml @@ -21,7 +21,7 @@ Item { id: highlight; radius: 1 anchors.left: parent.left; anchors.top: parent.top; anchors.bottom: parent.bottom anchors.leftMargin: 3; anchors.topMargin: 3; anchors.bottomMargin: 3 - width: EaseFollow { source: highlight.widthDest; velocity: 1200 } + EaseFollow on width { source: highlight.widthDest; velocity: 1200 } gradient: Gradient { GradientStop { id: g1; position: 0.0 } GradientStop { id: g2; position: 1.0 } diff --git a/examples/declarative/progressbar/progressbars.qml b/examples/declarative/progressbar/progressbars.qml index 6530c3d..a66d544 100644 --- a/examples/declarative/progressbar/progressbars.qml +++ b/examples/declarative/progressbar/progressbars.qml @@ -14,9 +14,9 @@ Rectangle { ProgressBar { property int r: Math.floor(Math.random() * 5000 + 1000) width: main.width - 20 - value: NumberAnimation { duration: r; from: 0; to: 100; repeat: true } - color: ColorAnimation { duration: r; from: "lightsteelblue"; to: "thistle"; repeat: true } - secondColor: ColorAnimation { duration: r; from: "steelblue"; to: "#CD96CD"; repeat: true } + NumberAnimation on value { duration: r; from: 0; to: 100; repeat: true } + ColorAnimation on color { duration: r; from: "lightsteelblue"; to: "thistle"; repeat: true } + ColorAnimation on secondColor { duration: r; from: "steelblue"; to: "#CD96CD"; repeat: true } } } } diff --git a/examples/declarative/snow/ImageBatch.qml b/examples/declarative/snow/ImageBatch.qml deleted file mode 100644 index c2a2674..0000000 --- a/examples/declarative/snow/ImageBatch.qml +++ /dev/null @@ -1,72 +0,0 @@ -import Qt 4.6 - -GridView { - id: grid - property int offset: 0 - property var ref - property bool isSelected: ref.selectedItemColumn >= offset && ref.selectedItemColumn < offset + 5 - - currentIndex: (ref.selectedItemColumn - offset) + ref.selectedItemRow * 5 - - property int imageWidth: ref.imageWidth - property int imageHeight: ref.imageHeight - - width: 5 * imageWidth - height: 4 * imageHeight - cellWidth: imageWidth - cellHeight: imageHeight - - states: State { - name: "selected"; when: grid.isSelected - PropertyChanges { target: grid; z: 150 } - } - transitions: Transition { - SequentialAnimation { - PauseAnimation { duration: 150 } - PropertyAction { properties: "z" } - } - } - model: XmlListModel { - property string tags : "" - source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+tags+"&" : "")+"format=rss2" - query: "/rss/channel/item" - namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" - - XmlRole { name: "url"; query: "media:content/@url/string()" } - } - - delegate: Item { - id: root - property bool isSelected: GridView.isCurrentItem && grid.isSelected - transformOrigin: Item.Center - width: grid.imageWidth; height: grid.imageHeight; - - Image { id: flickrImage; source: url; fillMode: Image.PreserveAspectFit; smooth: true; anchors.fill: parent; - opacity: (status == Image.Ready)?1:0; opacity: Behavior { NumberAnimation { } } } - Loading { anchors.centerIn: parent; visible: flickrImage.status!=1 } - - states: State { - name: "selected" - when: root.isSelected - PropertyChanges { target: root; scale: 3; z: 100 } - } - transitions: [ - Transition { - to: "selected" - SequentialAnimation { - PauseAnimation { duration: 150 } - PropertyAction { properties: "z" } - NumberAnimation { properties: "scale"; duration: 150; } - } - }, - Transition { - from: "selected" - SequentialAnimation { - NumberAnimation { properties: "scale"; duration: 150 } - PropertyAction { properties: "z" } - } - } - ] - } -} - diff --git a/examples/declarative/snow/Loading.qml b/examples/declarative/snow/Loading.qml deleted file mode 100644 index 238d9c7..0000000 --- a/examples/declarative/snow/Loading.qml +++ /dev/null @@ -1,8 +0,0 @@ -import Qt 4.6 - -Image { - id: loading; source: "pics/loading.png"; transformOrigin: Item.Center - rotation: NumberAnimation { - id: rotationAnimation; from: 0; to: 360; running: loading.visible == true; repeat: true; duration: 900 - } -} diff --git a/examples/declarative/snow/create.js b/examples/declarative/snow/create.js deleted file mode 100644 index 2bdae4a..0000000 --- a/examples/declarative/snow/create.js +++ /dev/null @@ -1,12 +0,0 @@ -var myComponent = null; - -function createNewBlock() { - if (myComponent == null) - myComponent = createComponent("ImageBatch.qml"); - - var obj = myComponent.createObject(); - obj.parent = layout; - obj.offset = maximumColumn + 1; - obj.ref = imagePanel; - maximumColumn += 5; -} diff --git a/examples/declarative/snow/pics/loading.png b/examples/declarative/snow/pics/loading.png Binary files differdeleted file mode 100644 index 0296cfe..0000000 --- a/examples/declarative/snow/pics/loading.png +++ /dev/null diff --git a/examples/declarative/snow/snow.qml b/examples/declarative/snow/snow.qml deleted file mode 100644 index 39c9c43..0000000 --- a/examples/declarative/snow/snow.qml +++ /dev/null @@ -1,69 +0,0 @@ -import Qt 4.6 - -Rectangle { - id: imagePanel - width: 1024 - height: 768 - color: "black" - - property int maximumColumn: 4 - property int selectedItemRow: 0 - property int selectedItemColumn: 0 - - Script { source: "create.js" } - - onSelectedItemColumnChanged: if (selectedItemColumn == maximumColumn) createNewBlock(); - - property int imageWidth: 200 - property int imageHeight: 200 - - property int selectedX: selectedItemColumn * imageWidth - property int selectedY: selectedItemRow * imageHeight - - Item { - anchors.centerIn: parent - Row { - id: layout - property real targetX: -(selectedX + imageWidth / 2) - - property real targetDeform: 0 - property bool slowDeform: true - - property real deform: 0 - deform: SpringFollow { - id: deformFollow; source: layout.targetDeform; velocity: layout.slowDeform?0.1:2 - onSyncChanged: if(inSync) { layout.slowDeform = true; layout.targetDeform = 0; } - } - - ImageBatch { offset: 0; ref: imagePanel } - - x: SpringFollow { source: layout.targetX; velocity: 1000 } - y: SpringFollow { source: -(selectedY + imageHeight / 2); velocity: 500 } - } - - transform: Rotation { - axis.y: 1; axis.z: 0 - angle: layout.deform * -100 - } - } - - Script { - function left() { - if (selectedItemColumn <= 0) return; - selectedItemColumn -= 1; - layout.slowDeform = false; - layout.targetDeform = Math.max(Math.min(layout.deform - 0.1, -0.1), -0.4); - } - function right() { - selectedItemColumn += 1; - layout.slowDeform = false; - layout.targetDeform = Math.min(Math.max(layout.deform + 0.1, 0.1), 0.4); - } - } - - focus: true - Keys.onLeftPressed: "left()" - Keys.onRightPressed: "right()" - Keys.onUpPressed: "if (selectedItemRow > 0) selectedItemRow = selectedItemRow - 1" - Keys.onDownPressed: "if (selectedItemRow < 3) selectedItemRow = selectedItemRow + 1" -} diff --git a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml index 9d35832..36178ec 100644 --- a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml +++ b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml @@ -14,7 +14,7 @@ Rectangle { signal closed(); color: "white"; border.width: 1; width: myText.width + 20; height: 60; opacity: 0 - opacity: Behavior { + Behavior on opacity { NumberAnimation { duration: 1000 } } Text { id: myText; anchors.centerIn: parent; text: "Hello World!" } diff --git a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml index 85c2c93..9ef455a 100644 --- a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml +++ b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml @@ -8,8 +8,8 @@ Item { id:block property int targetX: 0 property int targetY: 0 - x: SpringFollow { enabled: spawned; source: targetX; spring: 2; damping: 0.2 } - y: SpringFollow { source: targetY; spring: 2; damping: 0.2 } + SpringFollow on x { enabled: spawned; source: targetX; spring: 2; damping: 0.2 } + SpringFollow on y { source: targetY; spring: 2; damping: 0.2 } //![1] //![2] @@ -24,7 +24,7 @@ Item { id:block } } opacity: 0 - opacity: Behavior { NumberAnimation { properties:"opacity"; duration: 200 } } + Behavior on opacity { NumberAnimation { properties:"opacity"; duration: 200 } } anchors.fill: parent } //![2] diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml index ed9fd32..831c03b 100644 --- a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml +++ b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml @@ -13,7 +13,7 @@ Rectangle { signal closed(); color: "white"; border.width: 1; width: myText.width + 20; height: 60; opacity: 0 - opacity: Behavior { + Behavior on opacity { NumberAnimation { duration: 1000 } } Text { id: myText; anchors.centerIn: parent; text: "Hello World!" } diff --git a/examples/declarative/tvtennis/tvtennis.qml b/examples/declarative/tvtennis/tvtennis.qml index 4bd5319..6022a15 100644 --- a/examples/declarative/tvtennis/tvtennis.qml +++ b/examples/declarative/tvtennis/tvtennis.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import Qt.multimedia 4.7 Rectangle { id: page @@ -15,27 +16,30 @@ Rectangle { color: "Lime" x: 20; width: 20; height: 20; z: 1 + SoundEffect { id: paddle; source: "paddle.wav" } + SoundEffect { id: wall; source: "click.wav" } + // Move the ball to the right and back to the left repeatedly - x: SequentialAnimation { + SequentialAnimation on x { repeat: true NumberAnimation { to: page.width - 40; duration: 2000 } - ScriptAction { script: Qt.playSound('paddle.wav') } + ScriptAction { script: paddle.play() } PropertyAction { target: ball; property: "direction"; value: "left" } NumberAnimation { to: 20; duration: 2000 } - ScriptAction { script: Qt.playSound('paddle.wav') } + ScriptAction { script: paddle.play() } PropertyAction { target: ball; property: "direction"; value: "right" } } // Make y follow the target y coordinate, with a velocity of 200 - y: SpringFollow { source: ball.targetY; velocity: 200 } + SpringFollow on y { source: ball.targetY; velocity: 200 } // Detect the ball hitting the top or bottom of the view and bounce it onYChanged: { if (y <= 0) { - Qt.playSound('click.wav'); + wall.play(); targetY = page.height - 20; } else if (y >= page.height - 20) { - Qt.playSound('click.wav'); + wall.play(); targetY = 0; } } @@ -47,7 +51,7 @@ Rectangle { id: leftBat color: "Lime" x: 2; width: 20; height: 90 - y: SpringFollow { + SpringFollow on y { source: ball.y - 45; velocity: 300 enabled: ball.direction == 'left' } @@ -56,7 +60,7 @@ Rectangle { id: rightBat color: "Lime" x: page.width - 22; width: 20; height: 90 - y: SpringFollow { + SpringFollow on y { source: ball.y-45; velocity: 300 enabled: ball.direction == 'right' } diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml index c39f99b..7424f60 100644 --- a/examples/declarative/velocity/Day.qml +++ b/examples/declarative/velocity/Day.qml @@ -24,7 +24,7 @@ Rectangle { id: stickyPage x: Math.random() * 200 + 100 y: Math.random() * 300 + 50 - rotation: SpringFollow { + SpringFollow on rotation { source: -flickable.horizontalVelocity / 100 spring: 2.0; damping: 0.1 } diff --git a/examples/declarative/webview/autosize.qml b/examples/declarative/webview/autosize.qml index 74c6844..3c00ee6 100644 --- a/examples/declarative/webview/autosize.qml +++ b/examples/declarative/webview/autosize.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 // The WebView size is determined by the width, height, // preferredWidth, and preferredHeight properties. diff --git a/examples/declarative/webview/content/FieldText.qml b/examples/declarative/webview/content/FieldText.qml index 19b6acc..d282209 100644 --- a/examples/declarative/webview/content/FieldText.qml +++ b/examples/declarative/webview/content/FieldText.qml @@ -85,7 +85,7 @@ Item { font.bold: true text: label opacity: textEdit.text == '' ? 1 : 0 - opacity: Behavior { + Behavior on opacity { NumberAnimation { property: "opacity" duration: 250 diff --git a/examples/declarative/webview/content/Mapping/Map.qml b/examples/declarative/webview/content/Mapping/Map.qml index 2e98940..6c3b021 100644 --- a/examples/declarative/webview/content/Mapping/Map.qml +++ b/examples/declarative/webview/content/Mapping/Map.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 Item { id: page diff --git a/examples/declarative/webview/evalandattach.qml b/examples/declarative/webview/evalandattach.qml index 94301cd..d219d84 100644 --- a/examples/declarative/webview/evalandattach.qml +++ b/examples/declarative/webview/evalandattach.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 Item { height: 640 diff --git a/examples/declarative/webview/googleMaps.qml b/examples/declarative/webview/googleMaps.qml index 1886961..a04fecb 100644 --- a/examples/declarative/webview/googleMaps.qml +++ b/examples/declarative/webview/googleMaps.qml @@ -6,6 +6,7 @@ // order to create a Map. import Qt 4.6 +import org.webkit 1.0 import "content/Mapping" Map { diff --git a/examples/declarative/webview/inline-html.qml b/examples/declarative/webview/inline-html.qml index 23b4555..41dfec3 100644 --- a/examples/declarative/webview/inline-html.qml +++ b/examples/declarative/webview/inline-html.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 // Inline HTML with loose formatting can be // set on the html property. diff --git a/examples/declarative/webview/newwindows.qml b/examples/declarative/webview/newwindows.qml index 5dd4cd5..c62aba6 100644 --- a/examples/declarative/webview/newwindows.qml +++ b/examples/declarative/webview/newwindows.qml @@ -4,6 +4,7 @@ // allow it on WebView with settings.javascriptCanOpenWindows: true import Qt 4.6 +import org.webkit 1.0 Grid { columns: 3 diff --git a/examples/declarative/webview/qdeclarative-in-html.qml b/examples/declarative/webview/qdeclarative-in-html.qml index 77180ec..172ea4b 100644 --- a/examples/declarative/webview/qdeclarative-in-html.qml +++ b/examples/declarative/webview/qdeclarative-in-html.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 // The WebView supports QML data through the HTML OBJECT tag Rectangle { diff --git a/examples/declarative/webview/transparent.qml b/examples/declarative/webview/transparent.qml index 9332f3e..5530819 100644 --- a/examples/declarative/webview/transparent.qml +++ b/examples/declarative/webview/transparent.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 // The WebView background is transparent // if the HTML does not specify a background diff --git a/examples/declarative/workerlistmodel/dataloader.js b/examples/declarative/workerlistmodel/dataloader.js new file mode 100644 index 0000000..eac7478 --- /dev/null +++ b/examples/declarative/workerlistmodel/dataloader.js @@ -0,0 +1,14 @@ +// ![0] +WorkerScript.onMessage = function(msg) { + console.log("Worker told to", msg.action); + + if (msg.action == 'appendCurrentTime') { + var data = {'time': new Date().toTimeString()}; + msg.model.append(data); + msg.model.sync(); // updates the changes to the list + + var msgToSend = {'msg': 'Model updated!'}; + WorkerScript.sendMessage(msgToSend); + } +} +// ![0] diff --git a/examples/declarative/workerlistmodel/timedisplay.qml b/examples/declarative/workerlistmodel/timedisplay.qml new file mode 100644 index 0000000..3bf2630 --- /dev/null +++ b/examples/declarative/workerlistmodel/timedisplay.qml @@ -0,0 +1,33 @@ +// ![0] +import Qt 4.6 + +ListView { + width: 200 + height: 300 + + model: listModel + delegate: Component { + Text { text: time } + } + + WorkerListModel { id: listModel } + + WorkerScript { + id: worker + source: "dataloader.js" + onMessage: { + console.log("Worker said", messageObject.msg); + } + } + + Timer { + id: timer + interval: 2000; repeat: true; running: true; triggeredOnStart: true + + onTriggered: { + var msg = {'action': 'appendCurrentTime', 'model': listModel}; + worker.sendMessage(msg); + } + } +} +// ![0] diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 34e4834..6e77abf 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -6,12 +6,14 @@ Flickable: renamed viewportHeight -> contentHeight Flickable: renamed viewportX -> contentX Flickable: renamed viewportY -> contentY Removed Flickable.reportedVelocitySmoothing +Removed Qt.playSound (replaced by SoundEffect element) Renamed MouseRegion -> MouseArea Connection: syntax and rename: Connection { sender: a; signal: foo(); script: xxx } Connection { sender: a; signal: bar(); script: yyy } becomes: Connections { target: a; onFoo: xxx; onBar: yyy } +Using WebView now requires "import org.webkit 1.0" QmlView ------- @@ -52,6 +54,16 @@ matchProperties and matchTargets have been renamed back to properties and target The semantics are explained in the PropertyAnimation::properties documentation and the animation overview documentation. +Behavior and Animation syntax +----------------------------- + +Previously animations and behaviors could be "assigned" to properties like this: + Item { x: Behavior {}; y: NumberAnimation {} } +To make it more obvious that these are not regular value assignments a new "on" +syntax has been introduced: + Item { Behavior on x {}; NumberAnimation on y {} } +Only the syntax has changed, the behavior is identical. + ============================================================================= The changes below are pre-4.6.0 release. diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/declarative/graphicsitems/graphicsitems.pri index 7a85f00..3ff92b1 100644 --- a/src/declarative/graphicsitems/graphicsitems.pri +++ b/src/declarative/graphicsitems/graphicsitems.pri @@ -84,10 +84,3 @@ SOURCES += \ $$PWD/qdeclarativegraphicsobjectcontainer.cpp \ $$PWD/qdeclarativeparticles.cpp \ $$PWD/qdeclarativelayoutitem.cpp \ - -contains(QT_CONFIG, webkit) { - QT+=webkit - SOURCES += $$PWD/qdeclarativewebview.cpp - HEADERS += $$PWD/qdeclarativewebview_p.h - HEADERS += $$PWD/qdeclarativewebview_p_p.h -} diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index c54ddd0..2fdd720 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -682,7 +682,7 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent else rejectY = true; } - if (!rejectY) { + if (!rejectY && stealMouse) { _moveY.setValue(newY); moved = true; } @@ -709,7 +709,7 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent else rejectX = true; } - if (!rejectX) { + if (!rejectX && stealMouse) { _moveX.setValue(newX); moved = true; } @@ -752,6 +752,8 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent void QDeclarativeFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event) { Q_Q(QDeclarativeFlickable); + stealMouse = false; + q->setKeepMouseGrab(false); pressed = false; if (lastPosTime.isNull()) return; @@ -781,7 +783,6 @@ void QDeclarativeFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEv fixupX(); } - stealMouse = false; lastPosTime = QTime(); if (!timeline.isActive()) @@ -804,6 +805,8 @@ void QDeclarativeFlickable::mouseMoveEvent(QGraphicsSceneMouseEvent *event) Q_D(QDeclarativeFlickable); if (d->interactive) { d->handleMouseMoveEvent(event); + if (d->stealMouse) + setKeepMouseGrab(true); event->accept(); } else { QDeclarativeItem::mouseMoveEvent(event); @@ -1141,7 +1144,8 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) QGraphicsScene *s = scene(); QDeclarativeItem *grabber = s ? qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem()) : 0; - if ((d->stealMouse || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) { + bool stealThisEvent = d->stealMouse; + if ((stealThisEvent || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) { mouseEvent.setAccepted(false); for (int i = 0x1; i <= 0x10; i <<= 1) { if (event->buttons() & i) { @@ -1176,17 +1180,19 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) break; } grabber = qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem()); - if (grabber && d->stealMouse && !grabber->keepMouseGrab() && grabber != this) { + if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this) { d->clearDelayedPress(); grabMouse(); } - return d->stealMouse || d->delayedPressEvent; + return stealThisEvent || d->delayedPressEvent; } else if (!d->lastPosTime.isNull()) { d->lastPosTime = QTime(); } - if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) + if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) { d->clearDelayedPress(); + d->stealMouse = false; + } return false; } diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index b43b30b..463b238 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -45,14 +45,13 @@ #include "qdeclarativeflickable_p_p.h" #include <qdeclarativeeasefollow_p.h> +#include <qdeclarativeguard_p.h> #include <qlistmodelinterface_p.h> #include <QKeyEvent> QT_BEGIN_NAMESPACE -QHash<QObject*, QDeclarativeGridViewAttached*> QDeclarativeGridViewAttached::attachedProperties; - //---------------------------------------------------------------------------- @@ -60,8 +59,9 @@ class FxGridItem { public: FxGridItem(QDeclarativeItem *i, QDeclarativeGridView *v) : item(i), view(v) { - attached = QDeclarativeGridViewAttached::properties(item); - attached->m_view = view; + attached = static_cast<QDeclarativeGridViewAttached*>(qmlAttachedPropertiesObject<QDeclarativeGridView>(item)); + if (attached) + attached->m_view = view; } ~FxGridItem() {} @@ -251,7 +251,7 @@ public: } } - QGuard<QDeclarativeVisualModel> model; + QDeclarativeGuard<QDeclarativeVisualModel> model; QVariant modelVariant; QList<FxGridItem*> visibleItems; QHash<QDeclarativeItem*,int> unrequestedItems; @@ -618,7 +618,7 @@ void QDeclarativeGridViewPrivate::createHighlight() } } if (changed) - emit q->highlightChanged(); + emit q->highlightItemChanged(); } void QDeclarativeGridViewPrivate::updateHighlight() @@ -696,6 +696,11 @@ void QDeclarativeGridViewPrivate::updateCurrent(int modelIndex) In this case ListModel is a handy way for us to test our UI. In practice the model would be implemented in C++, or perhaps via a SQL data source. + + Note that views do not enable \e clip automatically. If the view + is not clipped by another item or the screen, it will be necessary + to set \e {clip: true} in order to have the out of view items clipped + nicely. */ QDeclarativeGridView::QDeclarativeGridView(QDeclarativeItem *parent) : QDeclarativeFlickable(*(new QDeclarativeGridViewPrivate), parent) @@ -743,7 +748,7 @@ QDeclarativeGridView::~QDeclarativeGridView() id: myDelegate Item { id: wrapper - GridView.onRemove: SequentialAnimation { + SequentialAnimation on GridView.onRemove { PropertyAction { target: wrapper.GridView; property: "delayRemove"; value: true } NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" } PropertyAction { target: wrapper.GridView; property: "delayRemove"; value: false } @@ -784,6 +789,8 @@ QVariant QDeclarativeGridView::model() const void QDeclarativeGridView::setModel(const QVariant &model) { Q_D(QDeclarativeGridView); + if (d->modelVariant == model) + return; if (d->model) { disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); @@ -828,6 +835,7 @@ void QDeclarativeGridView::setModel(const QVariant &model) connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); emit countChanged(); } + emit modelChanged(); } /*! @@ -871,6 +879,7 @@ void QDeclarativeGridView::setDelegate(QDeclarativeComponent *delegate) d->moveReason = QDeclarativeGridViewPrivate::SetIndex; d->updateCurrent(d->currentIndex); } + emit delegateChanged(); } } @@ -966,6 +975,7 @@ void QDeclarativeGridView::setHighlight(QDeclarativeComponent *highlight) if (highlight != d->highlightComponent) { d->highlightComponent = highlight; d->updateCurrent(d->currentIndex); + emit highlightChanged(); } } @@ -983,8 +993,8 @@ void QDeclarativeGridView::setHighlight(QDeclarativeComponent *highlight) id: myHighlight Rectangle { id: wrapper; color: "lightsteelblue"; radius: 4; width: 320; height: 60 - y: SpringFollow { source: Wrapper.GridView.view.currentItem.y; spring: 3; damping: 0.2 } - x: SpringFollow { source: Wrapper.GridView.view.currentItem.x; spring: 3; damping: 0.2 } + SpringFollow on y { source: Wrapper.GridView.view.currentItem.y; spring: 3; damping: 0.2 } + SpringFollow on x { source: Wrapper.GridView.view.currentItem.x; spring: 3; damping: 0.2 } } } \endcode @@ -1039,6 +1049,7 @@ void QDeclarativeGridView::setFlow(Flow flow) d->updateGrid(); refill(); d->updateCurrent(d->currentIndex); + emit flowChanged(); } } @@ -1058,7 +1069,10 @@ bool QDeclarativeGridView::isWrapEnabled() const void QDeclarativeGridView::setWrapEnabled(bool wrap) { Q_D(QDeclarativeGridView); + if (d->wrap == wrap) + return; d->wrap = wrap; + emit keyNavigationWrapsChanged(); } /*! @@ -1082,6 +1096,7 @@ void QDeclarativeGridView::setCacheBuffer(int buffer) d->buffer = buffer; if (isComponentComplete()) refill(); + emit cacheBufferChanged(); } } @@ -1325,6 +1340,18 @@ void QDeclarativeGridView::moveCurrentIndexRight() } } +/*! + \qmlmethod GridView::positionViewAtIndex(int index) + + Positions the view such that the \a index is at the top (or left for horizontal orientation) of the view. + If positioning the view at the index would cause empty space to be displayed at + the end of the view, the view will be positioned at the end. + + It is not recommended to use contentX or contentY to position the view + at a particular index. This is unreliable since removing items from the start + of the list does not cause all other items to be repositioned. + The correct way to bring an item into view is with positionViewAtIndex. +*/ void QDeclarativeGridView::positionViewAtIndex(int index) { Q_D(QDeclarativeGridView); @@ -1732,7 +1759,7 @@ void QDeclarativeGridView::refill() QDeclarativeGridViewAttached *QDeclarativeGridView::qmlAttachedProperties(QObject *obj) { - return QDeclarativeGridViewAttached::properties(obj); + return new QDeclarativeGridViewAttached(obj); } QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/declarative/graphicsitems/qdeclarativegridview_p.h index b488475..22fcef6 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview_p.h +++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h @@ -57,19 +57,19 @@ class Q_DECLARATIVE_EXPORT QDeclarativeGridView : public QDeclarativeFlickable Q_OBJECT Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeGridView) - Q_PROPERTY(QVariant model READ model WRITE setModel) - Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate) + Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged) + Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) Q_PROPERTY(QDeclarativeItem *currentItem READ currentItem NOTIFY currentIndexChanged) Q_PROPERTY(int count READ count NOTIFY countChanged) - Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight) - Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightChanged) + Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged) + Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightItemChanged) Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem) - Q_PROPERTY(Flow flow READ flow WRITE setFlow) - Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled) - Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer) + Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged) + Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled NOTIFY keyNavigationWrapsChanged) + Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged) Q_PROPERTY(int cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellWidthChanged) Q_PROPERTY(int cellHeight READ cellHeight WRITE setCellHeight NOTIFY cellHeightChanged) Q_CLASSINFO("DefaultProperty", "data") @@ -129,6 +129,12 @@ Q_SIGNALS: void cellWidthChanged(); void cellHeightChanged(); void highlightChanged(); + void highlightItemChanged(); + void modelChanged(); + void delegateChanged(); + void flowChanged(); + void keyNavigationWrapsChanged(); + void cacheBufferChanged(); protected: virtual void viewportMoved(); @@ -161,9 +167,7 @@ class QDeclarativeGridViewAttached : public QObject public: QDeclarativeGridViewAttached(QObject *parent) : QObject(parent), m_isCurrent(false), m_delayRemove(false) {} - ~QDeclarativeGridViewAttached() { - attachedProperties.remove(parent()); - } + ~QDeclarativeGridViewAttached() {} Q_PROPERTY(QDeclarativeGridView *view READ view CONSTANT) QDeclarativeGridView *view() { return m_view; } @@ -186,15 +190,6 @@ public: } } - static QDeclarativeGridViewAttached *properties(QObject *obj) { - QDeclarativeGridViewAttached *rv = attachedProperties.value(obj); - if (!rv) { - rv = new QDeclarativeGridViewAttached(obj); - attachedProperties.insert(obj, rv); - } - return rv; - } - void emitAdd() { emit add(); } void emitRemove() { emit remove(); } @@ -206,10 +201,8 @@ Q_SIGNALS: public: QDeclarativeGridView *m_view; - bool m_isCurrent; - bool m_delayRemove; - - static QHash<QObject*, QDeclarativeGridViewAttached*> attachedProperties; + bool m_isCurrent : 1; + bool m_delayRemove : 1; }; diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index 99ab053..2739ab8 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -232,6 +232,16 @@ qreal QDeclarativeImage::paintedHeight() const \o Error - an error occurred while loading the image \endlist + Note that a change in the status property does not cause anything to happen + (although it reflects what has happened with the image internally). If you wish + to react to the change in status you need to do it yourself, for example in one + of the following ways: + \list + \o Create a state, so that a state change occurs, e.g. State{name: 'loaded'; when: image.status = Image.Ready;} + \o Do something inside the onStatusChanged signal handler, e.g. Image{id: image; onStatusChanged: if(image.status == Image.Ready) console.log('Loaded');} + \o Bind to the status variable somewhere, e.g. Text{text: if(image.status!=Image.Ready){'Not Loaded';}else{'Loaded';}} + \endlist + \sa progress */ diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 5014fd8..3bee5b8 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -498,6 +498,32 @@ void QDeclarativeKeyNavigationAttached::setDown(QDeclarativeItem *i) emit changed(); } +QDeclarativeItem *QDeclarativeKeyNavigationAttached::tab() const +{ + Q_D(const QDeclarativeKeyNavigationAttached); + return d->tab; +} + +void QDeclarativeKeyNavigationAttached::setTab(QDeclarativeItem *i) +{ + Q_D(QDeclarativeKeyNavigationAttached); + d->tab = i; + emit changed(); +} + +QDeclarativeItem *QDeclarativeKeyNavigationAttached::backtab() const +{ + Q_D(const QDeclarativeKeyNavigationAttached); + return d->backtab; +} + +void QDeclarativeKeyNavigationAttached::setBacktab(QDeclarativeItem *i) +{ + Q_D(QDeclarativeKeyNavigationAttached); + d->backtab = i; + emit changed(); +} + void QDeclarativeKeyNavigationAttached::keyPressed(QKeyEvent *event) { Q_D(QDeclarativeKeyNavigationAttached); @@ -529,6 +555,18 @@ void QDeclarativeKeyNavigationAttached::keyPressed(QKeyEvent *event) event->accept(); } break; + case Qt::Key_Tab: + if (d->tab) { + d->tab->setFocus(true); + event->accept(); + } + break; + case Qt::Key_Backtab: + if (d->backtab) { + d->backtab->setFocus(true); + event->accept(); + } + break; default: break; } @@ -563,6 +601,16 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event) event->accept(); } break; + case Qt::Key_Tab: + if (d->tab) { + event->accept(); + } + break; + case Qt::Key_Backtab: + if (d->backtab) { + event->accept(); + } + break; default: break; } @@ -902,6 +950,8 @@ const QDeclarativeKeysAttached::SigMap QDeclarativeKeysAttached::sigMap[] = { { Qt::Key_Right, "rightPressed" }, { Qt::Key_Up, "upPressed" }, { Qt::Key_Down, "downPressed" }, + { Qt::Key_Tab, "tabPressed" }, + { Qt::Key_Backtab, "backtabPressed" }, { Qt::Key_Asterisk, "asteriskPressed" }, { Qt::Key_NumberSign, "numberSignPressed" }, { Qt::Key_Escape, "escapePressed" }, @@ -1440,7 +1490,7 @@ QDeclarativeAnchors *QDeclarativeItem::anchors() void QDeclarativeItemPrivate::data_append(QDeclarativeListProperty<QObject> *prop, QObject *o) { QDeclarativeItem *i = qobject_cast<QDeclarativeItem *>(o); - if (i) + if (i) i->setParentItem(static_cast<QDeclarativeItem *>(prop->object)); else o->setParent(static_cast<QDeclarativeItem *>(prop->object)); @@ -1568,7 +1618,7 @@ void QDeclarativeItemPrivate::transform_clear(QDeclarativeListProperty<QGraphics */ /*! \internal */ -QDeclarativeListProperty<QObject> QDeclarativeItem::data() +QDeclarativeListProperty<QObject> QDeclarativeItem::data() { return QDeclarativeListProperty<QObject>(this, 0, QDeclarativeItemPrivate::data_append); } @@ -2179,16 +2229,16 @@ void QDeclarativeItem::focusChanged(bool flag) QDeclarativeListProperty<QDeclarativeItem> QDeclarativeItem::fxChildren() { return QDeclarativeListProperty<QDeclarativeItem>(this, 0, QDeclarativeItemPrivate::children_append, - QDeclarativeItemPrivate::children_count, - QDeclarativeItemPrivate::children_at); + QDeclarativeItemPrivate::children_count, + QDeclarativeItemPrivate::children_at); } /*! \internal */ QDeclarativeListProperty<QObject> QDeclarativeItem::resources() { - return QDeclarativeListProperty<QObject>(this, 0, QDeclarativeItemPrivate::resources_append, - QDeclarativeItemPrivate::resources_count, - QDeclarativeItemPrivate::resources_at); + return QDeclarativeListProperty<QObject>(this, 0, QDeclarativeItemPrivate::resources_append, + QDeclarativeItemPrivate::resources_count, + QDeclarativeItemPrivate::resources_at); } /*! @@ -2465,14 +2515,26 @@ QPointF QDeclarativeItemPrivate::computeTransformOrigin() const /*! \internal */ bool QDeclarativeItem::sceneEvent(QEvent *event) { - bool rv = QGraphicsItem::sceneEvent(event); + if (event->type() == QEvent::KeyPress) { + QKeyEvent *k = static_cast<QKeyEvent *>(event); - if (event->type() == QEvent::FocusIn || - event->type() == QEvent::FocusOut) { - focusChanged(hasFocus()); - } + if ((k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) && + !(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { + keyPressEvent(static_cast<QKeyEvent *>(event)); + if (!event->isAccepted()) + QGraphicsItem::sceneEvent(event); + } else { + QGraphicsItem::sceneEvent(event); + } + } else { + bool rv = QGraphicsItem::sceneEvent(event); - return rv; + if (event->type() == QEvent::FocusIn || + event->type() == QEvent::FocusOut) { + focusChanged(hasFocus()); + } + return rv; + } } /*! \internal */ diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index 4b4917e..e424970 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -289,12 +289,14 @@ class QDeclarativeKeyNavigationAttachedPrivate : public QObjectPrivate { public: QDeclarativeKeyNavigationAttachedPrivate() - : QObjectPrivate(), left(0), right(0), up(0), down(0) {} + : QObjectPrivate(), left(0), right(0), up(0), down(0), tab(0), backtab(0) {} QDeclarativeItem *left; QDeclarativeItem *right; QDeclarativeItem *up; QDeclarativeItem *down; + QDeclarativeItem *tab; + QDeclarativeItem *backtab; }; class QDeclarativeKeyNavigationAttached : public QObject, public QDeclarativeItemKeyFilter @@ -306,6 +308,9 @@ class QDeclarativeKeyNavigationAttached : public QObject, public QDeclarativeIte Q_PROPERTY(QDeclarativeItem *right READ right WRITE setRight NOTIFY changed) Q_PROPERTY(QDeclarativeItem *up READ up WRITE setUp NOTIFY changed) Q_PROPERTY(QDeclarativeItem *down READ down WRITE setDown NOTIFY changed) + Q_PROPERTY(QDeclarativeItem *tab READ tab WRITE setTab NOTIFY changed) + Q_PROPERTY(QDeclarativeItem *backtab READ backtab WRITE setBacktab NOTIFY changed) + public: QDeclarativeKeyNavigationAttached(QObject * = 0); @@ -317,6 +322,10 @@ public: void setUp(QDeclarativeItem *); QDeclarativeItem *down() const; void setDown(QDeclarativeItem *); + QDeclarativeItem *tab() const; + void setTab(QDeclarativeItem *); + QDeclarativeItem *backtab() const; + void setBacktab(QDeclarativeItem *); static QDeclarativeKeyNavigationAttached *qmlAttachedProperties(QObject *); @@ -407,6 +416,8 @@ Q_SIGNALS: void rightPressed(QDeclarativeKeyEvent *event); void upPressed(QDeclarativeKeyEvent *event); void downPressed(QDeclarativeKeyEvent *event); + void tabPressed(QDeclarativeKeyEvent *event); + void backtabPressed(QDeclarativeKeyEvent *event); void asteriskPressed(QDeclarativeKeyEvent *event); void numberSignPressed(QDeclarativeKeyEvent *event); diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp index f3b9385..e0ae2eb 100644 --- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp @@ -139,9 +139,6 @@ void QDeclarativeItemModule::defineModule() QML_REGISTER_TYPE(Qt,4,6,VisibleArea,QDeclarativeFlickableVisibleArea); QML_REGISTER_TYPE(Qt,4,6,VisualDataModel,QDeclarativeVisualDataModel); QML_REGISTER_TYPE(Qt,4,6,VisualItemModel,QDeclarativeVisualItemModel); -#ifdef QT_WEBKIT_LIB - QML_REGISTER_TYPE(Qt,4,6,WebView,QDeclarativeWebView); -#endif QML_REGISTER_NOCREATE_TYPE(QDeclarativeAnchors); QML_REGISTER_NOCREATE_TYPE(QGraphicsEffect); diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 03303a0..cd8d143 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -47,6 +47,7 @@ #include <qdeclarativeeasefollow_p.h> #include <qdeclarativeexpression.h> #include <qdeclarativeengine.h> +#include <qdeclarativeguard_p.h> #include <qlistmodelinterface_p.h> #include <QKeyEvent> @@ -222,7 +223,7 @@ public: if (!visibleItems.isEmpty()) { pos = (*visibleItems.constBegin())->position(); if (visibleIndex > 0) - pos -= visibleIndex * (averageSize + spacing) - spacing; + pos -= visibleIndex * (averageSize + spacing); } return pos; } @@ -429,7 +430,7 @@ public: virtual void flickX(qreal velocity); virtual void flickY(qreal velocity); - QGuard<QDeclarativeVisualModel> model; + QDeclarativeGuard<QDeclarativeVisualModel> model; QVariant modelVariant; QList<FxListItem*> visibleItems; QHash<QDeclarativeItem*,int> unrequestedItems; @@ -798,10 +799,13 @@ void QDeclarativeListViewPrivate::createHighlight() if (item) { item->setParent(q->viewport()); highlight = new FxListItem(item, q); - if (orient == QDeclarativeListView::Vertical) - highlight->item->setHeight(currentItem->item->height()); - else - highlight->item->setWidth(currentItem->item->width()); + if (currentItem && autoHighlight) { + if (orient == QDeclarativeListView::Vertical) { + highlight->item->setHeight(currentItem->item->height()); + } else { + highlight->item->setWidth(currentItem->item->width()); + } + } const QLatin1String posProp(orient == QDeclarativeListView::Vertical ? "y" : "x"); highlightPosAnimator = new QDeclarativeEaseFollow(q); highlightPosAnimator->setTarget(QDeclarativeProperty(highlight->item, posProp)); @@ -816,7 +820,7 @@ void QDeclarativeListViewPrivate::createHighlight() } } if (changed) - emit q->highlightChanged(); + emit q->highlightItemChanged(); } void QDeclarativeListViewPrivate::updateHighlight() @@ -1358,6 +1362,11 @@ void QDeclarativeListViewPrivate::flickY(qreal velocity) In this case ListModel is a handy way for us to test our UI. In practice the model would be implemented in C++, or perhaps via a SQL data source. + + Note that views do not enable \e clip automatically. If the view + is not clipped by another item or the screen, it will be necessary + to set \e {clip: true} in order to have the out of view items clipped + nicely. */ QDeclarativeListView::QDeclarativeListView(QDeclarativeItem *parent) @@ -1430,7 +1439,7 @@ QDeclarativeListView::~QDeclarativeListView() id: myDelegate Item { id: wrapper - ListView.onRemove: SequentialAnimation { + SequentialAnimation on ListView.onRemove { PropertyAction { target: wrapper.ListView; property: "delayRemove"; value: true } NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" } PropertyAction { target: wrapper.ListView; property: "delayRemove"; value: false } @@ -1473,6 +1482,8 @@ QVariant QDeclarativeListView::model() const void QDeclarativeListView::setModel(const QVariant &model) { Q_D(QDeclarativeListView); + if (d->modelVariant == model) + return; if (d->model) { disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); @@ -1517,6 +1528,7 @@ void QDeclarativeListView::setModel(const QVariant &model) connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); emit countChanged(); } + emit modelChanged(); } /*! @@ -1563,6 +1575,7 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate) d->updateCurrent(d->currentIndex); } } + emit delegateChanged(); } /*! @@ -1663,6 +1676,7 @@ void QDeclarativeListView::setHighlight(QDeclarativeComponent *highlight) d->createHighlight(); if (d->currentItem) d->updateHighlight(); + emit highlightChanged(); } } @@ -1700,6 +1714,7 @@ void QDeclarativeListView::setHighlightFollowsCurrentItem(bool autoHighlight) d->highlightSizeAnimator->setEnabled(d->autoHighlight); } d->updateHighlight(); + emit highlightFollowsCurrentItemChanged(); } } @@ -1745,8 +1760,11 @@ qreal QDeclarativeListView::preferredHighlightBegin() const void QDeclarativeListView::setPreferredHighlightBegin(qreal start) { Q_D(QDeclarativeListView); + if (d->highlightRangeStart == start) + return; d->highlightRangeStart = start; d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd; + emit preferredHighlightBeginChanged(); } qreal QDeclarativeListView::preferredHighlightEnd() const @@ -1758,8 +1776,11 @@ qreal QDeclarativeListView::preferredHighlightEnd() const void QDeclarativeListView::setPreferredHighlightEnd(qreal end) { Q_D(QDeclarativeListView); + if (d->highlightRangeEnd == end) + return; d->highlightRangeEnd = end; d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd; + emit preferredHighlightEndChanged(); } QDeclarativeListView::HighlightRangeMode QDeclarativeListView::highlightRangeMode() const @@ -1771,8 +1792,11 @@ QDeclarativeListView::HighlightRangeMode QDeclarativeListView::highlightRangeMod void QDeclarativeListView::setHighlightRangeMode(HighlightRangeMode mode) { Q_D(QDeclarativeListView); + if (d->highlightRange == mode) + return; d->highlightRange = mode; d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd; + emit highlightRangeModeChanged(); } /*! @@ -1848,7 +1872,10 @@ bool QDeclarativeListView::isWrapEnabled() const void QDeclarativeListView::setWrapEnabled(bool wrap) { Q_D(QDeclarativeListView); + if (d->wrap == wrap) + return; d->wrap = wrap; + emit keyNavigationWrapsChanged(); } /*! @@ -1874,6 +1901,7 @@ void QDeclarativeListView::setCacheBuffer(int b) d->bufferMode = QDeclarativeListViewPrivate::BufferBefore | QDeclarativeListViewPrivate::BufferAfter; refill(); } + emit cacheBufferChanged(); } } @@ -1998,6 +2026,7 @@ void QDeclarativeListView::setSnapMode(SnapMode mode) Q_D(QDeclarativeListView); if (d->snapMode != mode) { d->snapMode = mode; + emit snapModeChanged(); } } @@ -2020,6 +2049,7 @@ void QDeclarativeListView::setFooter(QDeclarativeComponent *footer) d->maxExtentDirty = true; d->updateFooter(); d->updateViewport(); + emit footerChanged(); } } @@ -2043,6 +2073,7 @@ void QDeclarativeListView::setHeader(QDeclarativeComponent *header) d->updateHeader(); d->updateFooter(); d->updateViewport(); + emit headerChanged(); } } @@ -2258,6 +2289,12 @@ void QDeclarativeListView::decrementCurrentIndex() Positions the view such that the \a index is at the top (or left for horizontal orientation) of the view. If positioning the view at the index would cause empty space to be displayed at the end of the view, the view will be positioned at the end. + + It is not recommended to use contentX or contentY to position the view + at a particular index. This is unreliable since removing items from the start + of the list does not cause all other items to be repositioned, and because + the actual start of the view can vary based on the size of the delegates. + The correct way to bring an item into view is with positionViewAtIndex. */ void QDeclarativeListView::positionViewAtIndex(int index) { @@ -2380,7 +2417,8 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) int i = d->visibleItems.count() - 1; while (i > 0 && d->visibleItems.at(i)->index == -1) --i; - if (d->visibleItems.at(i)->index + 1 == modelIndex) { + if (d->visibleItems.at(i)->index + 1 == modelIndex + && d->visibleItems.at(i)->endPosition() < d->buffer+d->position()+d->size()-1) { // Special case of appending an item to the model. modelIndex = d->visibleIndex + d->visibleItems.count(); } else { diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/declarative/graphicsitems/qdeclarativelistview_p.h index 5e3edb0..f9b7b50 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview_p.h +++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h @@ -91,33 +91,33 @@ class Q_DECLARATIVE_EXPORT QDeclarativeListView : public QDeclarativeFlickable Q_OBJECT Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeListView) - Q_PROPERTY(QVariant model READ model WRITE setModel) - Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate) + Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged) + Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) Q_PROPERTY(QDeclarativeItem *currentItem READ currentItem NOTIFY currentIndexChanged) Q_PROPERTY(int count READ count NOTIFY countChanged) - Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight) - Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightChanged) - Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem) + Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged) + Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightItemChanged) + Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem NOTIFY highlightFollowsCurrentItemChanged) Q_PROPERTY(qreal highlightMoveSpeed READ highlightMoveSpeed WRITE setHighlightMoveSpeed NOTIFY highlightMoveSpeedChanged) Q_PROPERTY(qreal highlightResizeSpeed READ highlightResizeSpeed WRITE setHighlightResizeSpeed NOTIFY highlightResizeSpeedChanged) - Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin) - Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd) - Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode) + Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin NOTIFY preferredHighlightBeginChanged) + Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged) + Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode NOTIFY highlightRangeModeChanged) Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged) Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged) - Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled) - Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer) + Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled NOTIFY keyNavigationWrapsChanged) + Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged) Q_PROPERTY(QDeclarativeViewSection *section READ sectionCriteria CONSTANT) Q_PROPERTY(QString currentSection READ currentSection NOTIFY currentSectionChanged) - Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode) + Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged) - Q_PROPERTY(QDeclarativeComponent *header READ header WRITE setHeader) - Q_PROPERTY(QDeclarativeComponent *footer READ footer WRITE setFooter) + Q_PROPERTY(QDeclarativeComponent *header READ header WRITE setHeader NOTIFY headerChanged) + Q_PROPERTY(QDeclarativeComponent *footer READ footer WRITE setFooter NOTIFY footerChanged) Q_ENUMS(HighlightRangeMode) Q_ENUMS(Orientation) @@ -205,6 +205,18 @@ Q_SIGNALS: void highlightMoveSpeedChanged(); void highlightResizeSpeedChanged(); void highlightChanged(); + void highlightItemChanged(); + void modelChanged(); + void delegateChanged(); + void highlightFollowsCurrentItemChanged(); + void preferredHighlightBeginChanged(); + void preferredHighlightEndChanged(); + void highlightRangeModeChanged(); + void keyNavigationWrapsChanged(); + void cacheBufferChanged(); + void snapModeChanged(); + void headerChanged(); + void footerChanged(); protected: virtual void viewportMoved(); diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp index bd89321..b0499d7 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader.cpp +++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp @@ -320,6 +320,15 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded() \o Error - an error occurred while loading the QML source \endlist + Note that a change in the status property does not cause anything to happen + (although it reflects what has happened to the loader internally). If you wish + to react to the change in status you need to do it yourself, for example in one + of the following ways: + \list + \o Create a state, so that a state change occurs, e.g. State{name: 'loaded'; when: loader.status = Loader.Ready;} + \o Do something inside the onStatusChanged signal handler, e.g. Loader{id: loader; onStatusChanged: if(loader.status == Loader.Ready) console.log('Loaded');} + \o Bind to the status variable somewhere, e.g. Text{text: if(loader.status!=Loader.Ready){'Not Loaded';}else{'Loaded';}} + \endlist \sa progress */ diff --git a/src/declarative/graphicsitems/qdeclarativeparticles.cpp b/src/declarative/graphicsitems/qdeclarativeparticles.cpp index 1a58d3f..deabdd6 100644 --- a/src/declarative/graphicsitems/qdeclarativeparticles.cpp +++ b/src/declarative/graphicsitems/qdeclarativeparticles.cpp @@ -1260,7 +1260,11 @@ void QDeclarativeParticlesPainter::paint(QPainter *p, const QStyleOptionGraphics const int myX = x() + parentItem()->x(); const int myY = y() + parentItem()->y(); +#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) QVarLengthArray<QPainter::Fragment, 256> pixmapData; +#else + QVarLengthArray<QDrawPixmaps::Data, 256> pixmapData; +#endif pixmapData.resize(d->particles.count()); const QRectF sourceRect = d->image.rect(); @@ -1268,20 +1272,32 @@ void QDeclarativeParticlesPainter::paint(QPainter *p, const QStyleOptionGraphics qreal halfPHeight = sourceRect.height()/2.; for (int i = 0; i < d->particles.count(); ++i) { const QDeclarativeParticle &particle = d->particles.at(i); +#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) pixmapData[i].x = particle.x - myX + halfPWidth; pixmapData[i].y = particle.y - myY + halfPHeight; +#else + pixmapData[i].point = QPointF(particle.x - myX + halfPWidth, particle.y - myY + halfPHeight); +#endif pixmapData[i].opacity = particle.opacity; //these never change pixmapData[i].rotation = 0; pixmapData[i].scaleX = 1; pixmapData[i].scaleY = 1; +#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) pixmapData[i].sourceLeft = sourceRect.left(); pixmapData[i].sourceTop = sourceRect.top(); pixmapData[i].width = sourceRect.width(); pixmapData[i].height = sourceRect.height(); +#else + pixmapData[i].source = sourceRect; +#endif } +#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) p->drawPixmapFragments(pixmapData.data(), d->particles.count(), d->image); +#else + qDrawPixmaps(p, pixmapData.data(), d->particles.count(), d->image); +#endif } void QDeclarativeParticles::componentComplete() diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/graphicsitems/qdeclarativepath.cpp index 48f112a..80586b8 100644 --- a/src/declarative/graphicsitems/qdeclarativepath.cpp +++ b/src/declarative/graphicsitems/qdeclarativepath.cpp @@ -114,7 +114,10 @@ qreal QDeclarativePath::startX() const void QDeclarativePath::setStartX(qreal x) { Q_D(QDeclarativePath); + if (qFuzzyCompare(x, d->startX)) + return; d->startX = x; + emit startXChanged(); } qreal QDeclarativePath::startY() const @@ -126,7 +129,10 @@ qreal QDeclarativePath::startY() const void QDeclarativePath::setStartY(qreal y) { Q_D(QDeclarativePath); + if (qFuzzyCompare(y, d->startY)) + return; d->startY = y; + emit startYChanged(); } /*! @@ -522,7 +528,10 @@ QString QDeclarativePathAttribute::name() const void QDeclarativePathAttribute::setName(const QString &name) { - _name = name; + if (_name == name) + return; + _name = name; + emit nameChanged(); } /*! diff --git a/src/declarative/graphicsitems/qdeclarativepath_p.h b/src/declarative/graphicsitems/qdeclarativepath_p.h index b3139f8..d7cfca1 100644 --- a/src/declarative/graphicsitems/qdeclarativepath_p.h +++ b/src/declarative/graphicsitems/qdeclarativepath_p.h @@ -67,7 +67,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativePathAttribute : public QDeclarativePathEl { Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY changed) public: QDeclarativePathAttribute(QObject *parent=0) : QDeclarativePathElement(parent), _value(0) {} @@ -79,6 +79,9 @@ public: qreal value() const; void setValue(qreal value); +Q_SIGNALS: + void nameChanged(); + private: QString _name; qreal _value; @@ -190,8 +193,8 @@ class Q_DECLARATIVE_EXPORT QDeclarativePath : public QObject, public QDeclarativ Q_INTERFACES(QDeclarativeParserStatus) Q_PROPERTY(QDeclarativeListProperty<QDeclarativePathElement> pathElements READ pathElements) - Q_PROPERTY(qreal startX READ startX WRITE setStartX) - Q_PROPERTY(qreal startY READ startY WRITE setStartY) + Q_PROPERTY(qreal startX READ startX WRITE setStartX NOTIFY startXChanged) + Q_PROPERTY(qreal startY READ startY WRITE setStartY NOTIFY startYChanged) Q_PROPERTY(bool closed READ isClosed NOTIFY changed) Q_CLASSINFO("DefaultProperty", "pathElements") Q_INTERFACES(QDeclarativeParserStatus) @@ -216,6 +219,8 @@ public: Q_SIGNALS: void changed(); + void startXChanged(); + void startYChanged(); protected: virtual void componentComplete(); diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index f1b0213..50aa9ef 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -203,6 +203,9 @@ QVariant QDeclarativePathView::model() const void QDeclarativePathView::setModel(const QVariant &model) { Q_D(QDeclarativePathView); + if (d->modelVariant == model) + return; + if (d->model) { disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); @@ -242,6 +245,7 @@ void QDeclarativePathView::setModel(const QVariant &model) d->pathOffset = 0; d->regenerate(); d->fixOffset(); + emit modelChanged(); } /*! @@ -269,9 +273,12 @@ QDeclarativePath *QDeclarativePathView::path() const void QDeclarativePathView::setPath(QDeclarativePath *path) { Q_D(QDeclarativePathView); + if (d->path == path) + return; d->path = path; connect(d->path, SIGNAL(changed()), this, SLOT(refill())); d->regenerate(); + emit pathChanged(); } /*! @@ -333,7 +340,7 @@ void QDeclarativePathViewPrivate::setOffset(qreal o) /*! \qmlproperty real PathView::snapPosition - This property determines the position (0-100) the nearest item will snap to. + This property determines the position (0.0-1.0) the nearest item will snap to. */ qreal QDeclarativePathView::snapPosition() const { @@ -344,8 +351,12 @@ qreal QDeclarativePathView::snapPosition() const void QDeclarativePathView::setSnapPosition(qreal pos) { Q_D(QDeclarativePathView); - d->snapPos = pos/100; + qreal normalizedPos = pos - int(pos); + if (qFuzzyCompare(normalizedPos, d->snapPos)) + return; + d->snapPos = normalizedPos; d->fixOffset(); + emit snapPositionChanged(); } /*! @@ -365,7 +376,10 @@ qreal QDeclarativePathView::dragMargin() const void QDeclarativePathView::setDragMargin(qreal dragMargin) { Q_D(QDeclarativePathView); + if (d->dragMargin == dragMargin) + return; d->dragMargin = dragMargin; + emit dragMarginChanged(); } /*! @@ -392,16 +406,19 @@ QDeclarativeComponent *QDeclarativePathView::delegate() const return 0; } -void QDeclarativePathView::setDelegate(QDeclarativeComponent *c) +void QDeclarativePathView::setDelegate(QDeclarativeComponent *delegate) { Q_D(QDeclarativePathView); + if (delegate == this->delegate()) + return; if (!d->ownModel) { d->model = new QDeclarativeVisualDataModel(qmlContext(this)); d->ownModel = true; } if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) { - dataModel->setDelegate(c); + dataModel->setDelegate(delegate); d->regenerate(); + emit delegateChanged(); } } @@ -422,6 +439,7 @@ void QDeclarativePathView::setPathItemCount(int i) return; d->pathItems = i; d->regenerate(); + pathItemCountChanged(); } QPointF QDeclarativePathViewPrivate::pointNear(const QPointF &point, qreal *nearPercent) const diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p.h index 709a4fc..df9c6ae 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview_p.h +++ b/src/declarative/graphicsitems/qdeclarativepathview_p.h @@ -56,15 +56,15 @@ class Q_DECLARATIVE_EXPORT QDeclarativePathView : public QDeclarativeItem { Q_OBJECT - Q_PROPERTY(QVariant model READ model WRITE setModel) - Q_PROPERTY(QDeclarativePath *path READ path WRITE setPath) + Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged) + Q_PROPERTY(QDeclarativePath *path READ path WRITE setPath NOTIFY pathChanged) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) Q_PROPERTY(qreal offset READ offset WRITE setOffset NOTIFY offsetChanged) - Q_PROPERTY(qreal snapPosition READ snapPosition WRITE setSnapPosition) - Q_PROPERTY(qreal dragMargin READ dragMargin WRITE setDragMargin) + Q_PROPERTY(qreal snapPosition READ snapPosition WRITE setSnapPosition NOTIFY snapPositionChanged) + Q_PROPERTY(qreal dragMargin READ dragMargin WRITE setDragMargin NOTIFY dragMarginChanged) Q_PROPERTY(int count READ count) - Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate) - Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount) + Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) + Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount NOTIFY pathItemCountChanged) public: QDeclarativePathView(QDeclarativeItem *parent=0); @@ -101,6 +101,12 @@ public: Q_SIGNALS: void currentIndexChanged(); void offsetChanged(); + void modelChanged(); + void pathChanged(); + void dragMarginChanged(); + void snapPositionChanged(); + void delegateChanged(); + void pathItemCountChanged(); protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h index ca50910..6344a8a 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h @@ -60,6 +60,7 @@ #include <qdeclarative.h> #include <qdeclarativeanimation_p_p.h> +#include <qdeclarativeguard_p.h> #include <qdatetime.h> @@ -132,7 +133,7 @@ public: int pathOffset; int requestedIndex; QList<QDeclarativeItem *> items; - QGuard<QDeclarativeVisualModel> model; + QDeclarativeGuard<QDeclarativeVisualModel> model; QVariant modelVariant; enum MovementReason { Other, Key, Mouse }; MovementReason moveReason; diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp index d534f21..05fe0f7 100644 --- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp +++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp @@ -393,9 +393,10 @@ void QDeclarativeRectangle::paint(QPainter *p, const QStyleOptionGraphicsItem *, void QDeclarativeRectangle::drawRect(QPainter &p) { Q_D(QDeclarativeRectangle); - if (d->gradient && d->gradient->gradient()) { + if ((d->gradient && d->gradient->gradient()) + || d->radius > width()/2 || d->radius > height()/2) { // XXX This path is still slower than the image path - // Image path won't work for gradients though + // Image path won't work for gradients or invalid radius though bool oldAA = p.testRenderHint(QPainter::Antialiasing); if (d->smooth) p.setRenderHint(QPainter::Antialiasing); @@ -405,11 +406,23 @@ void QDeclarativeRectangle::drawRect(QPainter &p) } else { p.setPen(Qt::NoPen); } - p.setBrush(*d->gradient->gradient()); - if (d->radius > 0.) - p.drawRoundedRect(0, 0, width(), height(), d->radius, d->radius); + if (d->gradient && d->gradient->gradient()) + p.setBrush(*d->gradient->gradient()); else - p.drawRect(0, 0, width(), height()); + p.setBrush(d->color); + const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0; + QRectF rect; + if (pw%2) + rect = QRectF(0.5, 0.5, width()-1, height()-1); + else + rect = QRectF(0, 0, width(), height()); + qreal radius = d->radius; + if (radius > width()/2 || radius > height()/2) + radius = qMin(width()/2, height()/2); + if (radius > 0.) + p.drawRoundedRect(rect, radius, radius); + else + p.drawRect(rect); if (d->smooth) p.setRenderHint(QPainter::Antialiasing, oldAA); } else { diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 8e44b26..be73b39 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -613,6 +613,11 @@ void QDeclarativeTextEdit::setPersistentSelection(bool on) emit persistentSelectionChanged(d->persistentSelection); } +/* + \qmlproperty number TextEdit::textMargin + + The margin, in pixels, around the text in the TextEdit. +*/ qreal QDeclarativeTextEdit::textMargin() const { Q_D(const QDeclarativeTextEdit); diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index cd72ef9..55f1c89 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -53,6 +53,7 @@ #include <qdeclarativedeclarativedata_p.h> #include <qdeclarativepropertycache_p.h> #include <qdeclarativeguard_p.h> +#include <qdeclarativeglobal_p.h> #include <qlistmodelinterface_p.h> #include <qhash.h> @@ -80,6 +81,14 @@ public: static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->emitChildrenChanged(); } + static int children_count(QDeclarativeListProperty<QDeclarativeItem> *prop) { + return static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->children.count(); + } + + static QDeclarativeItem *children_at(QDeclarativeListProperty<QDeclarativeItem> *prop, int index) { + return static_cast<QDeclarativeVisualItemModelPrivate *>(prop->data)->children.at(index); + } + void itemAppended() { Q_Q(QDeclarativeVisualItemModel); QDeclarativeVisualItemModelAttached *attached = QDeclarativeVisualItemModelAttached::properties(children.last()); @@ -135,7 +144,8 @@ QDeclarativeVisualItemModel::QDeclarativeVisualItemModel() QDeclarativeListProperty<QDeclarativeItem> QDeclarativeVisualItemModel::children() { Q_D(QDeclarativeVisualItemModel); - return QDeclarativeListProperty<QDeclarativeItem>(this, d, QDeclarativeVisualItemModelPrivate::children_append); + return QDeclarativeListProperty<QDeclarativeItem>(this, d, d->children_append, + d->children_count, d->children_at); } /*! @@ -473,7 +483,7 @@ QVariant QDeclarativeVisualDataModelDataMetaObject::initialValue(int propId) QDeclarativeVisualDataModelData::QDeclarativeVisualDataModelData(int index, QDeclarativeVisualDataModel *model) -: m_index(index), m_model(model), +: m_index(index), m_model(model), m_meta(new QDeclarativeVisualDataModelDataMetaObject(this, QDeclarativeVisualDataModelPrivate::get(model)->m_delegateDataType)) { QDeclarativeVisualDataModelPrivate *modelPriv = QDeclarativeVisualDataModelPrivate::get(model); @@ -540,7 +550,7 @@ QVariant QDeclarativeVisualDataModelPartsMetaObject::initialValue(int id) } QDeclarativeVisualDataModelParts::QDeclarativeVisualDataModelParts(QDeclarativeVisualDataModel *parent) -: QObject(parent), model(parent) +: QObject(parent), model(parent) { new QDeclarativeVisualDataModelPartsMetaObject(this); } @@ -830,7 +840,7 @@ void QDeclarativeVisualDataModel::setDelegate(QDeclarativeComponent *delegate) Rectangle { height: 25; width: 100 Text { text: path } - MouseRegion { + MouseArea { anchors.fill: parent; onClicked: myModel.setRoot(path) } @@ -959,7 +969,7 @@ QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(Q QObject *QDeclarativeVisualDataModel::parts() { Q_D(QDeclarativeVisualDataModel); - if (!d->m_parts) + if (!d->m_parts) d->m_parts = new QDeclarativeVisualDataModelParts(this); return d->m_parts; } @@ -984,8 +994,8 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray if (complete) d->m_delegate->completeCreate(); if (nobj) { - ctxt->setParent(nobj); - data->setParent(nobj); + QDeclarative_setParent_noEvent(ctxt, nobj); + QDeclarative_setParent_noEvent(data, nobj); d->m_cache.insertItem(index, nobj); if (QDeclarativePackage *package = qobject_cast<QDeclarativePackage *>(nobj)) emit createdPackage(index, package); @@ -1268,7 +1278,6 @@ void QDeclarativeVisualDataModel::_q_dataChanged(const QModelIndex &begin, const void QDeclarativeVisualDataModel::_q_modelReset() { - Q_D(QDeclarativeVisualDataModel); emit modelReset(); } diff --git a/src/declarative/qml/parser/qdeclarativejs.g b/src/declarative/qml/parser/qdeclarativejs.g index 7cf81b2..493ad25 100644 --- a/src/declarative/qml/parser/qdeclarativejs.g +++ b/src/declarative/qml/parser/qdeclarativejs.g @@ -1020,7 +1020,7 @@ case $rule_number: { JsIdentifier: T_ON ; /. case $rule_number: { - QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_READONLY]); + QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_ON]); sym(1).sval = driver->intern(s.constData(), s.length()); break; } diff --git a/src/declarative/qml/parser/qdeclarativejsgrammar.cpp b/src/declarative/qml/parser/qdeclarativejsgrammar.cpp index 0677bc5..89493ff 100644 --- a/src/declarative/qml/parser/qdeclarativejsgrammar.cpp +++ b/src/declarative/qml/parser/qdeclarativejsgrammar.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtCore module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/declarative/qml/parser/qdeclarativejsgrammar_p.h b/src/declarative/qml/parser/qdeclarativejsgrammar_p.h index 2b2e3d1..32bb12b 100644 --- a/src/declarative/qml/parser/qdeclarativejsgrammar_p.h +++ b/src/declarative/qml/parser/qdeclarativejsgrammar_p.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtCore module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE class QDeclarativeJSGrammar { public: - enum { + enum VariousConstants { EOF_SYMBOL = 0, REDUCE_HERE = 100, SHIFT_THERE = 99, diff --git a/src/declarative/qml/parser/qdeclarativejsparser.cpp b/src/declarative/qml/parser/qdeclarativejsparser.cpp index fd9e690..c86e047 100644 --- a/src/declarative/qml/parser/qdeclarativejsparser.cpp +++ b/src/declarative/qml/parser/qdeclarativejsparser.cpp @@ -516,7 +516,7 @@ case 66: { } case 67: { - QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_READONLY]); + QString s = QLatin1String(QDeclarativeJSGrammar::spell[T_ON]); sym(1).sval = driver->intern(s.constData(), s.length()); break; } diff --git a/src/declarative/qml/qdeclarativebinding_p.h b/src/declarative/qml/qdeclarativebinding_p.h index ec5809d..1a714f0 100644 --- a/src/declarative/qml/qdeclarativebinding_p.h +++ b/src/declarative/qml/qdeclarativebinding_p.h @@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE -class Q_AUTOTEST_EXPORT QDeclarativeAbstractBinding +class Q_DECLARATIVE_EXPORT QDeclarativeAbstractBinding { public: QDeclarativeAbstractBinding(); @@ -101,7 +101,7 @@ private: class QDeclarativeContext; class QDeclarativeBindingPrivate; -class Q_AUTOTEST_EXPORT QDeclarativeBinding : public QDeclarativeExpression, public QDeclarativeAbstractBinding +class Q_DECLARATIVE_EXPORT QDeclarativeBinding : public QDeclarativeExpression, public QDeclarativeAbstractBinding { Q_OBJECT public: diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index 5da207d..5a2f3b5 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -65,6 +65,7 @@ #include "qdeclarativescriptparser_p.h" #include "qdeclarativebinding_p.h" #include "qdeclarativecompiledbindings_p.h" +#include "qdeclarativeglobalscriptclass_p.h" #include <qfxperf_p_p.h> @@ -113,32 +114,6 @@ QList<QDeclarativeError> QDeclarativeCompiler::errors() const } /*! - Returns true if \a val is a legal object id, false otherwise. - - Legal ids must start with a lower-case letter or underscore, and contain only - letters, numbers and underscores. -*/ -bool QDeclarativeCompiler::isValidId(const QString &val) -{ - if (val.isEmpty()) - return false; - - if (val.at(0).isLetter() && !val.at(0).isLower()) { - qWarning().nospace() << "id " << val << " is invalid: ids cannot start with uppercase letters"; - return false; - } - - QChar u(QLatin1Char('_')); - for (int ii = 0; ii < val.count(); ++ii) - if (val.at(ii) != u && - ((ii == 0 && !val.at(ii).isLetter()) || - (ii != 0 && !val.at(ii).isLetterOrNumber())) ) - return false; - - return true; -} - -/*! Returns true if \a name refers to an attached property, false otherwise. Attached property names are those that start with a capital letter. @@ -718,6 +693,7 @@ bool QDeclarativeCompiler::buildObject(Object *obj, const BindingContext &ctxt) BindingContext objCtxt(obj); // Create the synthesized meta object, ignoring aliases + COMPILE_CHECK(checkDynamicMeta(obj)); COMPILE_CHECK(mergeDynamicMetaProperties(obj)); COMPILE_CHECK(buildDynamicMeta(obj, IgnoreAliases)); @@ -1007,12 +983,15 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj) } else if (v->type == Value::SignalExpression) { + BindingContext ctxt = compileState.signalExpressions.value(v); + QDeclarativeInstruction store; store.type = QDeclarativeInstruction::StoreSignal; store.line = v->location.start.line; store.storeSignal.signalIndex = prop->index; store.storeSignal.value = output->indexForString(v->value.asScript().trimmed()); + store.storeSignal.context = ctxt.stack; output->bytecode << store; } @@ -1139,10 +1118,11 @@ bool QDeclarativeCompiler::buildComponent(QDeclarativeParser::Object *obj, if (obj->properties.count()) idProp = *obj->properties.begin(); - if (idProp && (idProp->value || idProp->values.count() > 1 || !isValidId(idProp->values.first()->primitive()))) - COMPILE_EXCEPTION(idProp, QCoreApplication::translate("QDeclarativeCompiler","Invalid component id specification")); - if (idProp) { + if (idProp->value || idProp->values.count() > 1 || idProp->values.at(0)->object) + COMPILE_EXCEPTION(idProp, QCoreApplication::translate("QDeclarativeCompiler","Invalid component id specification")); + COMPILE_CHECK(checkValidId(idProp->values.first(), idProp->values.first()->primitive())); + QString idVal = idProp->values.first()->primitive(); if (compileState.ids.contains(idVal)) @@ -1344,7 +1324,7 @@ QMetaMethod QDeclarativeCompiler::findSignalByName(const QMetaObject *mo, const } bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj, - const BindingContext &ctxt) + const BindingContext &ctxt) { Q_ASSERT(obj->metaObject()); Q_ASSERT(!prop->isEmpty()); @@ -1365,7 +1345,7 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDecl } else { - if (prop->value || prop->values.count() > 1) + if (prop->value || prop->values.count() != 1) COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Incorrectly specified signal")); prop->index = sigIdx; @@ -1380,6 +1360,8 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDecl QString script = prop->values.at(0)->value.asScript().trimmed(); if (script.isEmpty()) COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Empty signal assignment")); + + compileState.signalExpressions.insert(prop->values.at(0), ctxt); } } @@ -1623,6 +1605,10 @@ void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeParser::Property *p for (int ii = 0; ii < prop->values.count(); ++ii) { QDeclarativeParser::Value *v = prop->values.at(ii); + Q_ASSERT(v->type == Value::CreatedObject || + v->type == Value::PropertyBinding || + v->type == Value::Literal); + if (v->type == Value::CreatedObject) { genObject(v->object); @@ -1652,7 +1638,27 @@ void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeParser::Property *p output->bytecode << store; } - } else if (v->type == Value::ValueSource) { + } else if (v->type == Value::PropertyBinding) { + + genBindingAssignment(v, prop, obj, valueTypeProperty); + + } else if (v->type == Value::Literal) { + + QMetaProperty mp = obj->metaObject()->property(prop->index); + genLiteralAssignment(mp, v); + + } + + } + + for (int ii = 0; ii < prop->onValues.count(); ++ii) { + + QDeclarativeParser::Value *v = prop->onValues.at(ii); + + Q_ASSERT(v->type == Value::ValueSource || + v->type == Value::ValueInterceptor); + + if (v->type == Value::ValueSource) { genObject(v->object); QDeclarativeInstruction store; @@ -1685,16 +1691,6 @@ void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeParser::Property *p QDeclarativeType *valueType = toQmlType(v->object); store.assignValueInterceptor.castValue = valueType->propertyValueInterceptorCast(); output->bytecode << store; - - } else if (v->type == Value::PropertyBinding) { - - genBindingAssignment(v, prop, obj, valueTypeProperty); - - } else if (v->type == Value::Literal) { - - QMetaProperty mp = obj->metaObject()->property(prop->index); - genLiteralAssignment(mp, v); - } } @@ -1711,8 +1707,7 @@ bool QDeclarativeCompiler::buildIdProperty(QDeclarativeParser::Property *prop, QDeclarativeParser::Value *idValue = prop->values.at(0); QString val = idValue->primitive(); - if (!isValidId(val)) - COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","\"%1\" is not a valid object id").arg(val)); + COMPILE_CHECK(checkValidId(idValue, val)); // We disallow id's that conflict with import prefixes and types QDeclarativeEnginePrivate::ImportedNamespace *ns = 0; @@ -1793,19 +1788,25 @@ bool QDeclarativeCompiler::buildAttachedProperty(QDeclarativeParser::Property *p // } // font is a nested property. pointSize and family are not. bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeParser::Property *prop, - QDeclarativeParser::Object *obj, - const BindingContext &ctxt) + QDeclarativeParser::Object *obj, + const BindingContext &ctxt) { Q_ASSERT(prop->type != 0); Q_ASSERT(prop->index != -1); - if (prop->values.count()) - COMPILE_EXCEPTION(prop->values.first(), QCoreApplication::translate("QDeclarativeCompiler", "Invalid value in grouped property")); - - if (prop->type < (int)QVariant::UserType) { + if (QDeclarativeValueTypeFactory::isValueType(prop->type)) { QDeclarativeEnginePrivate *ep = static_cast<QDeclarativeEnginePrivate *>(QObjectPrivate::get(engine)); if (prop->type >= 0 /* QVariant == -1 */ && ep->valueTypes[prop->type]) { + + if (prop->values.count()) { + if (prop->values.at(0)->location < prop->value->location) { + COMPILE_EXCEPTION(prop->value, QCoreApplication::translate("QDeclarativeCompiler", "Property has already been assigned a value")); + } else { + COMPILE_EXCEPTION(prop->values.at(0), QCoreApplication::translate("QDeclarativeCompiler", "Property has already been assigned a value")); + } + } + COMPILE_CHECK(buildValueTypeProperty(ep->valueTypes[prop->type], prop->value, obj, ctxt.incr())); obj->addValueTypeProperty(prop); @@ -1820,6 +1821,9 @@ bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeParser::Property *pr if (!prop->value->metatype) COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Invalid grouped property access")); + if (prop->values.count()) + COMPILE_EXCEPTION(prop->values.at(0), QCoreApplication::translate("QDeclarativeCompiler", "Cannot assign a value directly to a grouped property")); + obj->addGroupedProperty(prop); COMPILE_CHECK(buildSubObject(prop->value, ctxt.incr())); @@ -1829,9 +1833,9 @@ bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeParser::Property *pr } bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type, - QDeclarativeParser::Object *obj, - QDeclarativeParser::Object *baseObj, - const BindingContext &ctxt) + QDeclarativeParser::Object *obj, + QDeclarativeParser::Object *baseObj, + const BindingContext &ctxt) { if (obj->defaultProperty) COMPILE_EXCEPTION(obj, QCoreApplication::translate("QDeclarativeCompiler","Invalid property use")); @@ -1848,37 +1852,36 @@ bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type, if (prop->value) COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Property assignment expected")); - if (prop->values.count() != 1) + if (prop->values.count() > 1) { COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Single property assignment expected")); + } else if (prop->values.count()) { + Value *value = prop->values.at(0); - Value *value = prop->values.at(0); - - if (value->object) { - bool isPropertyValue = output->types.at(value->object->type).type->propertyValueSourceCast() != -1; - bool isPropertyInterceptor = output->types.at(value->object->type).type->propertyValueInterceptorCast() != -1; - if (!isPropertyValue && !isPropertyInterceptor) { + if (value->object) { COMPILE_EXCEPTION(prop, QCoreApplication::translate("QDeclarativeCompiler","Unexpected object assignment")); - } else { - COMPILE_CHECK(buildObject(value->object, ctxt)); - - if (isPropertyInterceptor && baseObj->synthdata.isEmpty()) - buildDynamicMeta(baseObj, ForceCreation); - value->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor; + } else if (value->value.isScript()) { + // ### Check for writability + BindingReference reference; + reference.expression = value->value; + reference.property = prop; + reference.value = value; + reference.bindingContext = ctxt; + reference.bindingContext.owner++; + addBindingReference(reference); + value->type = Value::PropertyBinding; + } else { + COMPILE_CHECK(testLiteralAssignment(p, value)); + value->type = Value::Literal; } - } else if (value->value.isScript()) { - // ### Check for writability - BindingReference reference; - reference.expression = value->value; - reference.property = prop; - reference.value = value; - reference.bindingContext = ctxt; - reference.bindingContext.owner++; - addBindingReference(reference); - value->type = Value::PropertyBinding; - } else { - COMPILE_CHECK(testLiteralAssignment(p, value)); - value->type = Value::Literal; } + + for (int ii = 0; ii < prop->onValues.count(); ++ii) { + Value *v = prop->onValues.at(ii); + Q_ASSERT(v->object); + + COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, baseObj, v, ctxt)); + } + obj->addValueProperty(prop); } @@ -1886,13 +1889,11 @@ bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type, } // Build assignments to QML lists. QML lists are properties of type -// QList<T *> * and QDeclarativeList<T *> *. -// -// QList<T *> * types can accept a list of objects, or a single binding -// QDeclarativeList<T *> * types can accept a list of objects +// QDeclarativeListProperty<T>. List properties can accept a list of +// objects, or a single binding. bool QDeclarativeCompiler::buildListProperty(QDeclarativeParser::Property *prop, - QDeclarativeParser::Object *obj, - const BindingContext &ctxt) + QDeclarativeParser::Object *obj, + const BindingContext &ctxt) { Q_ASSERT(QDeclarativeEnginePrivate::get(engine)->isList(prop->type)); @@ -1950,20 +1951,6 @@ bool QDeclarativeCompiler::buildScriptStringProperty(QDeclarativeParser::Propert } // Compile regular property assignments of the form "property: <value>" -// -// ### The following problems exist -// -// There is no distinction between how "lists" of values are specified. This -// Item { -// children: Item {} -// children: Item {} -// } -// is identical to -// Item { -// children: [ Item {}, Item {} ] -// } -// -// We allow assignming multiple values to single value properties bool QDeclarativeCompiler::buildPropertyAssignment(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj, const BindingContext &ctxt) @@ -1983,14 +1970,21 @@ bool QDeclarativeCompiler::buildPropertyAssignment(QDeclarativeParser::Property } } + for (int ii = 0; ii < prop->onValues.count(); ++ii) { + Value *v = prop->onValues.at(ii); + + Q_ASSERT(v->object); + COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, obj, v, ctxt)); + } + return true; } // Compile assigning a single object instance to a regular property bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeParser::Property *prop, - QDeclarativeParser::Object *obj, - QDeclarativeParser::Value *v, - const BindingContext &ctxt) + QDeclarativeParser::Object *obj, + QDeclarativeParser::Value *v, + const BindingContext &ctxt) { Q_ASSERT(prop->index != -1); Q_ASSERT(v->object->type != -1); @@ -2019,15 +2013,6 @@ bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeParser::Pro v->object->metatype = output->types.at(v->object->type).metaObject(); Q_ASSERT(v->object->metaObject()); - // Will be true if the assigned type inherits QDeclarativePropertyValueSource - bool isPropertyValue = false; - // Will be true if the assigned type inherits QDeclarativePropertyValueInterceptor - bool isPropertyInterceptor = false; - if (QDeclarativeType *valueType = toQmlType(v->object)) { - isPropertyValue = valueType->propertyValueSourceCast() != -1; - isPropertyInterceptor = valueType->propertyValueInterceptorCast() != -1; - } - // We want to raw metaObject here as the raw metaobject is the // actual property type before we applied any extensions that might // effect the properties on the type, but don't effect assignability @@ -2063,13 +2048,6 @@ bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeParser::Pro component->getDefaultProperty()->addValue(componentValue); v->object = component; COMPILE_CHECK(buildPropertyObjectAssignment(prop, obj, v, ctxt)); - } else if (isPropertyValue || isPropertyInterceptor) { - // Assign as a property value source - COMPILE_CHECK(buildObject(v->object, ctxt)); - - if (isPropertyInterceptor && prop->parent->synthdata.isEmpty()) - buildDynamicMeta(prop->parent, ForceCreation); - v->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor; } else { COMPILE_EXCEPTION(v->object, QCoreApplication::translate("QDeclarativeCompiler","Cannot assign object to property")); } @@ -2078,6 +2056,55 @@ bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeParser::Pro return true; } +// Compile assigning a single object instance to a regular property using the "on" syntax. +// +// For example: +// Item { +// NumberAnimation on x { } +// } +bool QDeclarativeCompiler::buildPropertyOnAssignment(QDeclarativeParser::Property *prop, + QDeclarativeParser::Object *obj, + QDeclarativeParser::Object *baseObj, + QDeclarativeParser::Value *v, + const BindingContext &ctxt) +{ + Q_ASSERT(prop->index != -1); + Q_ASSERT(v->object->type != -1); + + if (!obj->metaObject()->property(prop->index).isWritable()) + COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop->name))); + + + // Normally buildObject() will set this up, but we need the static + // meta object earlier to test for assignability. It doesn't matter + // that there may still be outstanding synthesized meta object changes + // on this type, as they are not relevant for assignability testing + v->object->metatype = output->types.at(v->object->type).metaObject(); + Q_ASSERT(v->object->metaObject()); + + // Will be true if the assigned type inherits QDeclarativePropertyValueSource + bool isPropertyValue = false; + // Will be true if the assigned type inherits QDeclarativePropertyValueInterceptor + bool isPropertyInterceptor = false; + if (QDeclarativeType *valueType = toQmlType(v->object)) { + isPropertyValue = valueType->propertyValueSourceCast() != -1; + isPropertyInterceptor = valueType->propertyValueInterceptorCast() != -1; + } + + if (isPropertyValue || isPropertyInterceptor) { + // Assign as a property value source + COMPILE_CHECK(buildObject(v->object, ctxt)); + + if (isPropertyInterceptor && prop->parent->synthdata.isEmpty()) + buildDynamicMeta(baseObj, ForceCreation); + v->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor; + } else { + COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler","\"%1\" cannot operate on \"%2\"").arg(v->object->typeName.constData()).arg(prop->name.constData())); + } + + return true; +} + // Compile assigning a literal or binding to a regular property bool QDeclarativeCompiler::buildPropertyLiteralAssignment(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj, @@ -2203,10 +2230,13 @@ bool QDeclarativeCompiler::mergeDynamicMetaProperties(QDeclarativeParser::Object continue; Property *property = 0; - if (p.isDefaultProperty) + if (p.isDefaultProperty) { property = obj->getDefaultProperty(); - else + } else { property = obj->getProperty(p.name); + if (!property->values.isEmpty()) + COMPILE_EXCEPTION(property, QCoreApplication::translate("QDeclarativeCompiler","Property value set multiple times")); + } if (property->value) COMPILE_EXCEPTION(property, QCoreApplication::translate("QDeclarativeCompiler","Invalid property nesting")); @@ -2233,8 +2263,6 @@ bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeParser::Object *obj, Dyn obj->dynamicSlots.isEmpty()) return true; - COMPILE_CHECK(checkDynamicMeta(obj)); - QByteArray dynamicData(sizeof(QDeclarativeVMEMetaData), (char)0); QByteArray newClassName = obj->metatype->className(); @@ -2437,6 +2465,31 @@ bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeParser::Object *obj, Dyn return true; } +bool QDeclarativeCompiler::checkValidId(QDeclarativeParser::Value *v, const QString &val) +{ + if (val.isEmpty()) + COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "Invalid empty ID")); + + if (val.at(0).isLetter() && !val.at(0).isLower()) + COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "IDs cannot start with an uppercase letter")); + + QChar u(QLatin1Char('_')); + for (int ii = 0; ii < val.count(); ++ii) { + + if (ii == 0 && !val.at(ii).isLetter() && val.at(ii) != u) { + COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "IDs must start with a letter or underscore")); + } else if (ii != 0 && !val.at(ii).isLetterOrNumber() && val.at(ii) != u) { + COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "IDs must contain only letters, numbers, and underscores")); + } + + } + + if (QDeclarativeEnginePrivate::get(engine)->globalClass->illegalNames().contains(val)) + COMPILE_EXCEPTION(v, QCoreApplication::translate("QDeclarativeCompiler", "ID illegally masks global JavaScript property")); + + return true; +} + #include <qdeclarativejsparser_p.h> static QStringList astNodeToStringList(QDeclarativeJS::AST::Node *node) @@ -2560,9 +2613,9 @@ bool QDeclarativeCompiler::buildBinding(QDeclarativeParser::Value *value, } void QDeclarativeCompiler::genBindingAssignment(QDeclarativeParser::Value *binding, - QDeclarativeParser::Property *prop, - QDeclarativeParser::Object *obj, - QDeclarativeParser::Property *valueTypeProperty) + QDeclarativeParser::Property *prop, + QDeclarativeParser::Object *obj, + QDeclarativeParser::Property *valueTypeProperty) { Q_UNUSED(obj); Q_ASSERT(compileState.bindings.contains(binding)); diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h index 2ea3366..cca42e2 100644 --- a/src/declarative/qml/qdeclarativecompiler_p.h +++ b/src/declarative/qml/qdeclarativecompiler_p.h @@ -155,7 +155,6 @@ public: bool isError() const; QList<QDeclarativeError> errors() const; - static bool isValidId(const QString &); static bool isAttachedPropertyName(const QByteArray &); static bool isSignalPropertyName(const QByteArray &); @@ -219,6 +218,11 @@ private: QDeclarativeParser::Object *obj, QDeclarativeParser::Value *value, const BindingContext &ctxt); + bool buildPropertyOnAssignment(QDeclarativeParser::Property *prop, + QDeclarativeParser::Object *obj, + QDeclarativeParser::Object *baseObj, + QDeclarativeParser::Value *value, + const BindingContext &ctxt); bool buildPropertyLiteralAssignment(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj, QDeclarativeParser::Value *value, @@ -242,6 +246,7 @@ private: QDeclarativeParser::Object *obj, const QDeclarativeParser::Object::DynamicProperty &); bool completeComponentBuild(); + bool checkValidId(QDeclarativeParser::Value *, const QString &); void genObject(QDeclarativeParser::Object *obj); @@ -302,6 +307,7 @@ private: QByteArray compiledBindingData; QHash<QDeclarativeParser::Value *, BindingReference> bindings; + QHash<QDeclarativeParser::Value *, BindingContext> signalExpressions; QList<QDeclarativeParser::Object *> aliasingObjects; QDeclarativeParser::Object *root; }; diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 6a2d2d1..d6bb216 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -437,6 +437,13 @@ void QDeclarativeComponent::loadUrl(const QUrl &url) else d->url = url; + if (url.isEmpty()) { + QDeclarativeError error; + error.setDescription(tr("Invalid empty URL")); + d->state.errors << error; + return; + } + QDeclarativeCompositeTypeData *data = QDeclarativeEnginePrivate::get(d->engine)->typeManager.get(d->url); diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp index b244cd8..f70e143 100644 --- a/src/declarative/qml/qdeclarativecontext.cpp +++ b/src/declarative/qml/qdeclarativecontext.cpp @@ -47,6 +47,7 @@ #include "qdeclarativeengine.h" #include "qdeclarativecompiledbindings_p.h" #include "qdeclarativeinfo.h" +#include "qdeclarativeglobalscriptclass_p.h" #include <qscriptengine.h> #include <QtCore/qvarlengtharray.h> @@ -74,10 +75,13 @@ void QDeclarativeContextPrivate::addScript(const QDeclarativeParser::Object::Scr QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine); QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine); + scriptContext->pushScope(enginePriv->contextClass->newContext(q, scopeObject)); + scriptContext->pushScope(enginePriv->globalClass->globalObject()); QScriptValue scope = scriptEngine->newObject(); scriptContext->setActivationObject(scope); + scriptContext->pushScope(scope); for (int ii = 0; ii < script.codes.count(); ++ii) { scriptEngine->evaluate(script.codes.at(ii), script.files.at(ii), script.lineNumbers.at(ii)); @@ -480,7 +484,10 @@ QVariant QDeclarativeContext::contextProperty(const QString &name) const if (!value.isValid() && parentContext()) value = parentContext()->contextProperty(name); } else { - value = d->propertyValues[idx]; + if (idx >= d->propertyValues.count()) + value = QVariant::fromValue(d->idValues[idx - d->propertyValues.count()].data()); + else + value = d->propertyValues[idx]; } return value; diff --git a/src/declarative/qml/qdeclarativecontextscriptclass.cpp b/src/declarative/qml/qdeclarativecontextscriptclass.cpp index 7deed0b..d6305d8 100644 --- a/src/declarative/qml/qdeclarativecontextscriptclass.cpp +++ b/src/declarative/qml/qdeclarativecontextscriptclass.cpp @@ -50,10 +50,11 @@ QT_BEGIN_NAMESPACE struct ContextData : public QScriptDeclarativeClass::Object { - ContextData() : isSharedContext(true) {} - ContextData(QDeclarativeContext *c, QObject *o) : context(c), scopeObject(o), isSharedContext(false) {} + ContextData() : overrideObject(0), isSharedContext(true) {} + ContextData(QDeclarativeContext *c, QObject *o) : context(c), scopeObject(o), overrideObject(0), isSharedContext(false) {} QDeclarativeGuard<QDeclarativeContext> context; QDeclarativeGuard<QObject> scopeObject; + QObject *overrideObject; bool isSharedContext; QDeclarativeContext *getContext(QDeclarativeEngine *engine) { @@ -110,6 +111,17 @@ QDeclarativeContext *QDeclarativeContextScriptClass::contextFromValue(const QScr return data->getContext(engine); } +QObject *QDeclarativeContextScriptClass::setOverrideObject(QScriptValue &v, QObject *override) +{ + if (scriptClass(v) != this) + return 0; + + ContextData *data = (ContextData *)object(v); + QObject *rv = data->overrideObject; + data->overrideObject = override; + return rv; +} + QScriptClass::QueryFlags QDeclarativeContextScriptClass::queryProperty(Object *object, const Identifier &name, QScriptClass::QueryFlags flags) @@ -127,6 +139,20 @@ QDeclarativeContextScriptClass::queryProperty(Object *object, const Identifier & if (!bindContext) return 0; + QObject *overrideObject = ((ContextData *)object)->overrideObject; + if (overrideObject) { + QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); + QScriptClass::QueryFlags rv = + ep->objectClass->queryProperty(overrideObject, name, flags, bindContext, + QDeclarativeObjectScriptClass::ImplicitObject | + QDeclarativeObjectScriptClass::SkipAttachedProperties); + if (rv) { + lastScopeObject = overrideObject; + lastContext = bindContext; + return rv; + } + } + bool includeTypes = true; while (bindContext) { QScriptClass::QueryFlags rv = diff --git a/src/declarative/qml/qdeclarativecontextscriptclass_p.h b/src/declarative/qml/qdeclarativecontextscriptclass_p.h index 26086ec..4b0dca0 100644 --- a/src/declarative/qml/qdeclarativecontextscriptclass_p.h +++ b/src/declarative/qml/qdeclarativecontextscriptclass_p.h @@ -70,6 +70,7 @@ public: QScriptValue newSharedContext(); QDeclarativeContext *contextFromValue(const QScriptValue &); + QObject *setOverrideObject(QScriptValue &, QObject *); protected: virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, diff --git a/src/declarative/qml/qdeclarativedeclarativedata_p.h b/src/declarative/qml/qdeclarativedeclarativedata_p.h index 2c92419..ae40130 100644 --- a/src/declarative/qml/qdeclarativedeclarativedata_p.h +++ b/src/declarative/qml/qdeclarativedeclarativedata_p.h @@ -103,7 +103,10 @@ public: static QDeclarativeDeclarativeData *get(const QObject *object, bool create = false) { QObjectPrivate *priv = QObjectPrivate::get(const_cast<QObject *>(object)); - if (priv->declarativeData) { + if (priv->wasDeleted) { + Q_ASSERT(!create); + return 0; + } else if (priv->declarativeData) { return static_cast<QDeclarativeDeclarativeData *>(priv->declarativeData); } else if (create) { priv->declarativeData = new QDeclarativeDeclarativeData; @@ -117,6 +120,11 @@ public: template<class T> void QDeclarativeGuard<T>::addGuard() { + if (QObjectPrivate::get(o)->wasDeleted) { + if (prev) remGuard(); + return; + } + QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(o, true); next = data->guards; if (next) reinterpret_cast<QDeclarativeGuard<T> *>(next)->prev = &next; diff --git a/src/declarative/qml/qdeclarativedom.cpp b/src/declarative/qml/qdeclarativedom.cpp index 6c81f34..cb56ead 100644 --- a/src/declarative/qml/qdeclarativedom.cpp +++ b/src/declarative/qml/qdeclarativedom.cpp @@ -374,7 +374,10 @@ QDeclarativeDomValue QDeclarativeDomProperty::value() const QDeclarativeDomValue rv; if (d->property) { rv.d->property = d->property; - rv.d->value = d->property->values.at(0); + if (d->property->values.count()) + rv.d->value = d->property->values.at(0); + else + rv.d->value = d->property->onValues.at(0); rv.d->property->addref(); rv.d->value->addref(); } @@ -505,7 +508,7 @@ int QDeclarativeDomDynamicProperty::propertyType() const QByteArray QDeclarativeDomDynamicProperty::propertyTypeName() const { - if (isValid()) + if (isValid()) return d->property.customType; return QByteArray(); @@ -1181,7 +1184,7 @@ QDeclarativeDomObject QDeclarativeDomValueValueSource::object() const \qml Rectangle { - x: Behavior { NumberAnimation { duration: 500 } } + Behavior on x { NumberAnimation { duration: 500 } } } \endqml */ @@ -1225,7 +1228,7 @@ QDeclarativeDomValueValueInterceptor &QDeclarativeDomValueValueInterceptor::oper returned. \qml Rectangle { - x: Behavior { NumberAnimation { duration: 500 } } + Behavior on x { NumberAnimation { duration: 500 } } } \endqml */ @@ -1346,7 +1349,7 @@ QDeclarativeDomValue::Type QDeclarativeDomValue::type() const { if (d->property) if (QDeclarativeMetaType::isList(d->property->type) || - (d->property && d->property->values.count() > 1)) + (d->property && (d->property->values.count() + d->property->onValues.count()) > 1)) return List; QDeclarativeParser::Value *value = d->value; @@ -1628,6 +1631,13 @@ QList<QDeclarativeDomValue> QDeclarativeDomList::values() const rv << v; } + for (int ii = 0; ii < d->property->onValues.count(); ++ii) { + QDeclarativeDomValue v; + v.d->value = d->property->onValues.at(ii); + v.d->value->addref(); + rv << v; + } + return rv; } diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index af75e98..1711cf1 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -236,9 +236,13 @@ QDeclarativeScriptEngine::QDeclarativeScriptEngine(QDeclarativeEnginePrivate *pr qtObject.setProperty(QLatin1String("tint"), newFunction(QDeclarativeEnginePrivate::tint, 2)); } + //date/time formatting + qtObject.setProperty(QLatin1String("formatDate"),newFunction(QDeclarativeEnginePrivate::formatDate, 2)); + qtObject.setProperty(QLatin1String("formatTime"),newFunction(QDeclarativeEnginePrivate::formatTime, 2)); + qtObject.setProperty(QLatin1String("formatDateTime"),newFunction(QDeclarativeEnginePrivate::formatDateTime, 2)); + //misc methods qtObject.setProperty(QLatin1String("closestAngle"), newFunction(QDeclarativeEnginePrivate::closestAngle, 2)); - qtObject.setProperty(QLatin1String("playSound"), newFunction(QDeclarativeEnginePrivate::playSound, 1)); qtObject.setProperty(QLatin1String("openUrlExternally"),newFunction(QDeclarativeEnginePrivate::desktopOpenUrl, 1)); qtObject.setProperty(QLatin1String("md5"),newFunction(QDeclarativeEnginePrivate::md5, 1)); qtObject.setProperty(QLatin1String("btoa"),newFunction(QDeclarativeEnginePrivate::btoa, 1)); @@ -936,6 +940,66 @@ QScriptValue QDeclarativeEnginePrivate::vector(QScriptContext *ctxt, QScriptEngi return engine->newVariant(qVariantFromValue(QVector3D(x, y, z))); } +QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptEngine*engine) +{ + int argCount = ctxt->argumentCount(); + if(argCount == 0 || argCount > 2) + return engine->nullValue(); + + QDate date = ctxt->argument(0).toDateTime().date(); + Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; + if (argCount == 2) { + if (ctxt->argument(1).isString()) { + QString format = ctxt->argument(1).toString(); + return engine->newVariant(qVariantFromValue(date.toString(format))); + } else if (ctxt->argument(1).isNumber()) { + enumFormat = Qt::DateFormat(ctxt->argument(1).toInteger()); + } else + return engine->nullValue(); + } + return engine->newVariant(qVariantFromValue(date.toString(enumFormat))); +} + +QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptEngine*engine) +{ + int argCount = ctxt->argumentCount(); + if(argCount == 0 || argCount > 2) + return engine->nullValue(); + + QTime date = ctxt->argument(0).toDateTime().time(); + Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; + if (argCount == 2) { + if (ctxt->argument(1).isString()) { + QString format = ctxt->argument(1).toString(); + return engine->newVariant(qVariantFromValue(date.toString(format))); + } else if (ctxt->argument(1).isNumber()) { + enumFormat = Qt::DateFormat(ctxt->argument(1).toInteger()); + } else + return engine->nullValue(); + } + return engine->newVariant(qVariantFromValue(date.toString(enumFormat))); +} + +QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScriptEngine*engine) +{ + int argCount = ctxt->argumentCount(); + if(argCount == 0 || argCount > 2) + return engine->nullValue(); + + QDateTime date = ctxt->argument(0).toDateTime(); + Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; + if (argCount == 2) { + if (ctxt->argument(1).isString()) { + QString format = ctxt->argument(1).toString(); + return engine->newVariant(qVariantFromValue(date.toString(format))); + } else if (ctxt->argument(1).isNumber()) { + enumFormat = Qt::DateFormat(ctxt->argument(1).toInteger()); + } else + return engine->nullValue(); + } + return engine->newVariant(qVariantFromValue(date.toString(enumFormat))); +} + QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine *engine) { int argCount = ctxt->argumentCount(); @@ -1040,30 +1104,6 @@ QScriptValue QDeclarativeEnginePrivate::darker(QScriptContext *ctxt, QScriptEngi return qScriptValueFromValue(engine, qVariantFromValue(color)); } -QScriptValue QDeclarativeEnginePrivate::playSound(QScriptContext *ctxt, QScriptEngine *engine) -{ - if (ctxt->argumentCount() != 1) - return engine->undefinedValue(); - - QUrl url(ctxt->argument(0).toString()); - - QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine); - if (url.isRelative()) { - QDeclarativeContext *context = enginePriv->getContext(ctxt); - if (!context) - return engine->undefinedValue(); - - url = context->resolvedUrl(url); - } - - if (url.scheme() == QLatin1String("file")) { - - QSound::play(url.toLocalFile()); - - } - return engine->undefinedValue(); -} - QScriptValue QDeclarativeEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QScriptEngine *e) { if(ctxt->argumentCount() < 1) @@ -1383,7 +1423,11 @@ public: paths += QFileInfo(base.toLocalFile()).path(); paths += importPath; paths += QDeclarativeEnginePrivate::get(engine)->environmentImportPath; +#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) QString builtinPath = QLibraryInfo::location(QLibraryInfo::ImportsPath); +#else + QString builtinPath; +#endif if (!builtinPath.isEmpty()) paths += builtinPath; @@ -1687,6 +1731,7 @@ QString QDeclarativeEngine::offlineStoragePath() const \internal Returns the result of the merge of \a baseName with \a dir, \a suffixes, and \a prefix. + The \a prefix must contain the dot. */ QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString &baseName, const QStringList &suffixes, @@ -1696,7 +1741,6 @@ QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString QString pluginFileName = prefix; pluginFileName += baseName; - pluginFileName += QLatin1Char('.'); pluginFileName += suffix; QFileInfo fileInfo(dir, pluginFileName); @@ -1728,14 +1772,26 @@ QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString &baseName) { #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) - return resolvePlugin(dir, baseName, QStringList(QLatin1String("dll"))); + return resolvePlugin(dir, baseName, + QStringList() +# ifdef QT_DEBUG + << QLatin1String("d.dll") // try a qmake-style debug build first +# endif + << QLatin1String(".dll")); #elif defined(Q_OS_SYMBIAN) - return resolvePlugin(dir, baseName, QStringList() << QLatin1String("dll") << QLatin1String("qtplugin")); + return resolvePlugin(dir, baseName, + QStringList() + << QLatin1String(".dll") + << QLatin1String(".qtplugin")); #else # if defined(Q_OS_DARWIN) - return resolvePlugin(dir, baseName, QStringList() << QLatin1String("dylib") << QLatin1String("so") << QLatin1String("bundle"), + return resolvePlugin(dir, baseName, + QStringList() + << QLatin1String(".dylib") + << QLatin1String(".so") + << QLatin1String(".bundle"), QLatin1String("lib")); # else // Generic Unix QStringList validSuffixList; @@ -1746,14 +1802,14 @@ QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString "In PA-RISC (PA-32 and PA-64) shared libraries are suffixed with .sl. In IPF (32-bit and 64-bit), the shared libraries are suffixed with .so. For compatibility, the IPF linker also supports the .sl suffix." */ - validSuffixList << QLatin1String("sl"); + validSuffixList << QLatin1String(".sl"); # if defined __ia64 - validSuffixList << QLatin1String("so"); + validSuffixList << QLatin1String(".so"); # endif # elif defined(Q_OS_AIX) - validSuffixList << QLatin1String("a") << QLatin1String("so"); + validSuffixList << QLatin1String(".a") << QLatin1String(".so"); # elif defined(Q_OS_UNIX) - validSuffixList << QLatin1String("so"); + validSuffixList << QLatin1String(".so"); # endif // Examples of valid library names: diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index 0359f98..459a325 100644 --- a/src/declarative/qml/qdeclarativeengine_p.h +++ b/src/declarative/qml/qdeclarativeengine_p.h @@ -238,7 +238,8 @@ public: QHash<const QMetaObject *, QDeclarativePropertyCache *> propertyCache; QDeclarativePropertyCache *cache(QObject *obj) { Q_Q(QDeclarativeEngine); - if (!obj || QObjectPrivate::get(obj)->metaObject) return 0; + if (!obj || QObjectPrivate::get(obj)->metaObject || + QObjectPrivate::get(obj)->wasDeleted) return 0; const QMetaObject *mo = obj->metaObject(); QDeclarativePropertyCache *rv = propertyCache.value(mo); if (!rv) { @@ -318,7 +319,6 @@ public: static QScriptValue tint(QScriptContext*, QScriptEngine*); static QScriptValue closestAngle(QScriptContext*, QScriptEngine*); - static QScriptValue playSound(QScriptContext*, QScriptEngine*); static QScriptValue desktopOpenUrl(QScriptContext*, QScriptEngine*); static QScriptValue md5(QScriptContext*, QScriptEngine*); static QScriptValue btoa(QScriptContext*, QScriptEngine*); @@ -326,6 +326,10 @@ public: static QScriptValue consoleLog(QScriptContext*, QScriptEngine*); static QScriptValue quit(QScriptContext*, QScriptEngine*); + static QScriptValue formatDate(QScriptContext*, QScriptEngine*); + static QScriptValue formatTime(QScriptContext*, QScriptEngine*); + static QScriptValue formatDateTime(QScriptContext*, QScriptEngine*); + static QScriptEngine *getScriptEngine(QDeclarativeEngine *e) { return &e->d_func()->scriptEngine; } static QDeclarativeEngine *getEngine(QScriptEngine *e) { return static_cast<QDeclarativeScriptEngine*>(e)->p->q_func(); } static QDeclarativeEnginePrivate *get(QDeclarativeEngine *e) { return e->d_func(); } diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp index 09882cb..3e4acbe 100644 --- a/src/declarative/qml/qdeclarativeenginedebug.cpp +++ b/src/declarative/qml/qdeclarativeenginedebug.cpp @@ -117,7 +117,7 @@ QDeclarativeEngineDebugServer::propertyData(QObject *obj, int propIdx) QVariant value = prop.read(obj); rv.value = valueContents(value); - if (QVariant::Type(prop.userType()) < QVariant::UserType) { + if (QDeclarativeValueTypeFactory::isValueType(prop.userType())) { rv.type = QDeclarativeObjectProperty::Basic; } else if (QDeclarativeMetaType::isQObject(prop.userType())) { rv.type = QDeclarativeObjectProperty::Object; @@ -131,7 +131,7 @@ QDeclarativeEngineDebugServer::propertyData(QObject *obj, int propIdx) QVariant QDeclarativeEngineDebugServer::valueContents(const QVariant &value) const { int userType = value.userType(); - if (QVariant::Type(userType) < QVariant::UserType) + if (QDeclarativeValueTypeFactory::isValueType(userType)) return value; /* diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp index ae1e790..e528e9e 100644 --- a/src/declarative/qml/qdeclarativeexpression.cpp +++ b/src/declarative/qml/qdeclarativeexpression.cpp @@ -46,6 +46,7 @@ #include "qdeclarativecontext_p.h" #include "qdeclarativerewrite_p.h" #include "qdeclarativecompiler_p.h" +#include "qdeclarativeglobalscriptclass_p.h" #include <QtCore/qdebug.h> #include <QtScript/qscriptprogram.h> @@ -135,6 +136,7 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContext *ctxt, void *expr, if (!dd->cachedClosures.at(progIdx)) { QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine); scriptContext->pushScope(ep->contextClass->newSharedContext()); + scriptContext->pushScope(ep->globalClass->globalObject()); dd->cachedClosures[progIdx] = new QScriptValue(scriptEngine->evaluate(data->expression, data->url, data->line)); scriptEngine->popContext(); } @@ -151,9 +153,11 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContext *ctxt, void *expr, new QScriptProgram(data->expression, data->url, data->line); } - data->expressionFunction = evalInObjectScope(ctxt, me, *dd->cachedPrograms.at(progIdx)); + data->expressionFunction = evalInObjectScope(ctxt, me, *dd->cachedPrograms.at(progIdx), + &data->expressionContext); #else - data->expressionFunction = evalInObjectScope(ctxt, me, data->expression); + data->expressionFunction = evalInObjectScope(ctxt, me, data->expression, + &data->expressionContext); #endif data->expressionFunctionValid = true; @@ -164,22 +168,34 @@ void QDeclarativeExpressionPrivate::init(QDeclarativeContext *ctxt, void *expr, } QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContext *context, QObject *object, - const QString &program) + const QString &program, QScriptValue *contextObject) { QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine()); QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(&ep->scriptEngine); - scriptContext->pushScope(ep->contextClass->newContext(context, object)); + if (contextObject) { + *contextObject = ep->contextClass->newContext(context, object); + scriptContext->pushScope(*contextObject); + } else { + scriptContext->pushScope(ep->contextClass->newContext(context, object)); + } + scriptContext->pushScope(ep->globalClass->globalObject()); QScriptValue rv = ep->scriptEngine.evaluate(program); ep->scriptEngine.popContext(); return rv; } QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContext *context, QObject *object, - const QScriptProgram &program) + const QScriptProgram &program, QScriptValue *contextObject) { QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine()); QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(&ep->scriptEngine); - scriptContext->pushScope(ep->contextClass->newContext(context, object)); + if (contextObject) { + *contextObject = ep->contextClass->newContext(context, object); + scriptContext->pushScope(*contextObject); + } else { + scriptContext->pushScope(ep->contextClass->newContext(context, object)); + } + scriptContext->pushScope(ep->globalClass->globalObject()); QScriptValue rv = ep->scriptEngine.evaluate(program); ep->scriptEngine.popContext(); return rv; @@ -326,15 +342,14 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo QDeclarativeEngine *engine = data->context()->engine(); QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); - if (secondaryScope) - ctxtPriv->defaultObjects.append(secondaryScope); - QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine); if (!data->expressionFunctionValid) { QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine); - scriptContext->pushScope(ep->contextClass->newContext(data->context(), data->me)); + data->expressionContext = ep->contextClass->newContext(data->context(), data->me); + scriptContext->pushScope(data->expressionContext); + scriptContext->pushScope(ep->globalClass->globalObject()); if (data->expressionRewritten) { data->expressionFunction = scriptEngine->evaluate(data->expression, @@ -357,11 +372,14 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo QDeclarativeContext *oldSharedContext = 0; QObject *oldSharedScope = 0; + QObject *oldOverride = 0; if (data->isShared) { oldSharedContext = ep->sharedContext; oldSharedScope = ep->sharedScope; ep->sharedContext = data->context(); ep->sharedScope = data->me; + } else { + oldOverride = ep->contextClass->setOverrideObject(data->expressionContext, secondaryScope); } QScriptValue svalue = data->expressionFunction.call(); @@ -369,6 +387,8 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo if (data->isShared) { ep->sharedContext = oldSharedContext; ep->sharedScope = oldSharedScope; + } else { + ep->contextClass->setOverrideObject(data->expressionContext, oldOverride); } if (isUndefined) @@ -383,12 +403,6 @@ QVariant QDeclarativeExpressionPrivate::evalQtScript(QObject *secondaryScope, bo data->error = QDeclarativeError(); } - if (secondaryScope) { - QObject *last = ctxtPriv->defaultObjects.takeLast(); - Q_ASSERT(last == secondaryScope); - Q_UNUSED(last); - } - QVariant rv; if (svalue.isArray()) { diff --git a/src/declarative/qml/qdeclarativeexpression_p.h b/src/declarative/qml/qdeclarativeexpression_p.h index 91ac4c0..cd1729d 100644 --- a/src/declarative/qml/qdeclarativeexpression_p.h +++ b/src/declarative/qml/qdeclarativeexpression_p.h @@ -119,6 +119,7 @@ public: bool expressionFunctionValid:1; bool expressionRewritten:1; QScriptValue expressionFunction; + QScriptValue expressionContext; QObject *me; bool trackChange; @@ -180,8 +181,8 @@ public: virtual void emitValueChanged(); static void exceptionToError(QScriptEngine *, QDeclarativeError &); - static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QString &); - static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QScriptProgram &); + static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QString &, QScriptValue * = 0); + static QScriptValue evalInObjectScope(QDeclarativeContext *, QObject *, const QScriptProgram &, QScriptValue * = 0); }; QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp index 5b06b42..9ee2fe5 100644 --- a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp @@ -53,15 +53,17 @@ QT_BEGIN_NAMESPACE QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass(QScriptEngine *engine) : QScriptClass(engine) { - QScriptValue v = engine->newObject(); - globalObject = engine->globalObject(); + QScriptValue globalObject = engine->globalObject(); + m_globalObject = engine->newObject(); QScriptValueIterator iter(globalObject); while (iter.hasNext()) { iter.next(); - v.setProperty(iter.scriptName(), iter.value()); + m_globalObject.setProperty(iter.scriptName(), iter.value()); + m_illegalNames.insert(iter.name()); } + QScriptValue v = engine->newObject(); v.setScriptClass(this); engine->setGlobalObject(v); } @@ -101,12 +103,14 @@ void QDeclarativeGlobalScriptClass::setProperty(QScriptValue &object, engine()->currentContext()->throwError(error); } +/* This method is for the use of tst_qdeclarativeecmascript::callQtInvokables() only */ void QDeclarativeGlobalScriptClass::explicitSetProperty(const QString &name, const QScriptValue &value) { + QScriptValue globalObject = engine()->globalObject(); + QScriptValue v = engine()->newObject(); - globalObject = engine()->globalObject(); - QScriptValueIterator iter(globalObject); + QScriptValueIterator iter(v); while (iter.hasNext()) { iter.next(); v.setProperty(iter.scriptName(), iter.value()); @@ -114,6 +118,7 @@ void QDeclarativeGlobalScriptClass::explicitSetProperty(const QString &name, con v.setProperty(name, value); v.setScriptClass(this); + engine()->setGlobalObject(v); } diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h index a33cf5e..1b34aee 100644 --- a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h +++ b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h @@ -54,6 +54,7 @@ // #include <QtScript/qscriptclass.h> +#include <QtCore/qset.h> QT_BEGIN_NAMESPACE @@ -74,8 +75,12 @@ public: void explicitSetProperty(const QString &, const QScriptValue &); + const QScriptValue &globalObject() const { return m_globalObject; } + const QSet<QString> &illegalNames() const { return m_illegalNames; } + private: - QScriptValue globalObject; + QSet<QString> m_illegalNames; + QScriptValue m_globalObject; }; QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeinstruction_p.h b/src/declarative/qml/qdeclarativeinstruction_p.h index d8af6a7..c41b14f 100644 --- a/src/declarative/qml/qdeclarativeinstruction_p.h +++ b/src/declarative/qml/qdeclarativeinstruction_p.h @@ -293,6 +293,7 @@ public: struct { int signalIndex; int value; + int context; } storeSignal; struct { int signal; diff --git a/src/declarative/qml/qdeclarativelist.h b/src/declarative/qml/qdeclarativelist.h index 8d59384..eac4967 100644 --- a/src/declarative/qml/qdeclarativelist.h +++ b/src/declarative/qml/qdeclarativelist.h @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QObject; -class QMetaObject; +struct QMetaObject; template<typename T> struct QDeclarativeListProperty { typedef void (*AppendFunction)(QDeclarativeListProperty<T> *, T*); diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index 542f417..2e4ffa7 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -232,7 +232,7 @@ QDeclarativeObjectScriptClass::property(QObject *obj, const Identifier &name) QDeclarativeEnginePrivate::CapturedProperty(obj, lastData->coreIndex, lastData->notifyIndex); } - if ((uint)lastData->propType < QVariant::UserType) { + if (QDeclarativeValueTypeFactory::isValueType((uint)lastData->propType)) { QDeclarativeValueType *valueType = enginePriv->valueTypes[lastData->propType]; if (valueType) return Value(scriptEngine, enginePriv->valueTypeClass->newObject(obj, lastData->coreIndex, valueType)); diff --git a/src/declarative/qml/qdeclarativeparser.cpp b/src/declarative/qml/qdeclarativeparser.cpp index 5ac49d5..b0599ad 100644 --- a/src/declarative/qml/qdeclarativeparser.cpp +++ b/src/declarative/qml/qdeclarativeparser.cpp @@ -221,12 +221,14 @@ QDeclarativeParser::Property::~Property() { foreach(Value *value, values) value->release(); + foreach(Value *value, onValues) + value->release(); if (value) value->release(); } -Object *QDeclarativeParser::Property::getValue() +Object *QDeclarativeParser::Property::getValue(const LocationSpan &l) { - if (!value) value = new Object; + if (!value) { value = new Object; value->location = l; } return value; } @@ -235,9 +237,14 @@ void QDeclarativeParser::Property::addValue(Value *v) values << v; } +void QDeclarativeParser::Property::addOnValue(Value *v) +{ + onValues << v; +} + bool QDeclarativeParser::Property::isEmpty() const { - return !value && values.isEmpty(); + return !value && values.isEmpty() && onValues.isEmpty(); } QDeclarativeParser::Value::Value() diff --git a/src/declarative/qml/qdeclarativeparser_p.h b/src/declarative/qml/qdeclarativeparser_p.h index aae507e..5bf4b68 100644 --- a/src/declarative/qml/qdeclarativeparser_p.h +++ b/src/declarative/qml/qdeclarativeparser_p.h @@ -104,6 +104,11 @@ namespace QDeclarativeParser Location start; Location end; LocationRange range; + + bool operator<(LocationSpan &o) const { + return (start.line < o.start.line) || + (start.line == o.start.line && start.column < o.start.column); + } }; class Property; @@ -318,8 +323,9 @@ namespace QDeclarativeParser // The Object to which this property is attached Object *parent; - Object *getValue(); + Object *getValue(const LocationSpan &); void addValue(Value *v); + void addOnValue(Value *v); // The QVariant::Type of the property, or 0 (QVariant::Invalid) if // unknown. @@ -333,6 +339,8 @@ namespace QDeclarativeParser // The list of values assigned to this property. Content in values // and value are mutually exclusive QList<Value *> values; + // The list of values assigned to this property using the "on" syntax + QList<Value *> onValues; // The accessed property. This is used to represent dot properties. // Content in value and values are mutually exclusive. Object *value; diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index e1ec2cd..4f73b89 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -238,10 +238,10 @@ void QDeclarativePropertyPrivate::initProperty(QObject *obj, const QString &name if (property->flags & QDeclarativePropertyCache::Data::IsFunction) return; // Not an object property - if (ii == (path.count() - 2) && property->propType < (int)QVariant::UserType) { + if (ii == (path.count() - 2) && QDeclarativeValueTypeFactory::isValueType(property->propType)) { // We're now at a value type property. We can use a global valuetypes array as we // never actually use the objects, just look up their properties. - QObject *typeObject = qmlValueTypes()->valueTypes[property->propType]; + QObject *typeObject = (*qmlValueTypes())[property->propType]; if (!typeObject) return; // Not a value type int idx = typeObject->metaObject()->indexOfProperty(path.last().toUtf8().constData()); @@ -346,7 +346,7 @@ QDeclarativePropertyPrivate::propertyTypeCategory() const int type = propertyType(); if (type == QVariant::Invalid) return QDeclarativeProperty::InvalidCategory; - else if ((uint)type < QVariant::UserType) + else if (QDeclarativeValueTypeFactory::isValueType((uint)type)) return QDeclarativeProperty::Normal; else if (core.flags & QDeclarativePropertyCache::Data::IsQObjectDerived) return QDeclarativeProperty::Object; @@ -793,7 +793,7 @@ QVariant QDeclarativeProperty::read(QObject *object, const QString &name, QDecla QVariant QDeclarativePropertyPrivate::readValueProperty() { - if(isValueType()) { + if (isValueType()) { QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context); QDeclarativeValueType *valueType = 0; @@ -809,13 +809,20 @@ QVariant QDeclarativePropertyPrivate::readValueProperty() if (!ep) delete valueType; return rv; - } else if(core.flags & QDeclarativePropertyCache::Data::IsQList) { + } else if (core.flags & QDeclarativePropertyCache::Data::IsQList) { QDeclarativeListProperty<QObject> prop; void *args[] = { &prop, 0 }; QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args); return QVariant::fromValue(QDeclarativeListReferencePrivate::init(prop, core.propType, engine)); + } else if (core.flags & QDeclarativePropertyCache::Data::IsQObjectDerived) { + + QObject *rv = 0; + void *args[] = { &rv, 0 }; + QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args); + return QVariant::fromValue(rv); + } else { return object->metaObject()->property(core.coreIndex).read(object.data()); diff --git a/src/declarative/qml/qdeclarativeproperty_p.h b/src/declarative/qml/qdeclarativeproperty_p.h index 1fda7f4..c31e2d3 100644 --- a/src/declarative/qml/qdeclarativeproperty_p.h +++ b/src/declarative/qml/qdeclarativeproperty_p.h @@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE class QDeclarativeContext; class QDeclarativeEnginePrivate; class QDeclarativeExpression; -class Q_AUTOTEST_EXPORT QDeclarativePropertyPrivate +class Q_DECLARATIVE_EXPORT QDeclarativePropertyPrivate { public: enum WriteFlag { BypassInterceptor = 0x01, DontRemoveBinding = 0x02 }; diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp index 08b47b7..fea59e5 100644 --- a/src/declarative/qml/qdeclarativepropertycache.cpp +++ b/src/declarative/qml/qdeclarativepropertycache.cpp @@ -155,9 +155,9 @@ QDeclarativePropertyCache::Data QDeclarativePropertyCache::create(const QMetaObj int parenIdx = methodName.indexOf(QLatin1Char('(')); Q_ASSERT(parenIdx != -1); - methodName = methodName.left(parenIdx); + QStringRef methodNameRef = methodName.leftRef(parenIdx); - if (methodName == property) { + if (methodNameRef == property) { rv.load(m); return rv; } diff --git a/src/declarative/qml/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescriptparser.cpp index f4c9cdd..fe516c5 100644 --- a/src/declarative/qml/qdeclarativescriptparser.cpp +++ b/src/declarative/qml/qdeclarativescriptparser.cpp @@ -85,8 +85,8 @@ class ProcessAST: protected AST::Visitor { const State &state = top(); if (state.property) { - State s(state.property->getValue(), - state.property->getValue()->getProperty(name.toUtf8())); + State s(state.property->getValue(location), + state.property->getValue(location)->getProperty(name.toUtf8())); s.property->location = location; push(s); } else { @@ -106,12 +106,12 @@ public: void operator()(const QString &code, AST::Node *node); protected: - Object *defineObjectBinding(AST::UiQualifiedId *propertyName, + Object *defineObjectBinding(AST::UiQualifiedId *propertyName, bool onAssignment, AST::UiQualifiedId *objectTypeName, LocationSpan location, AST::UiObjectInitializer *initializer = 0); - Object *defineObjectBinding_helper(AST::UiQualifiedId *propertyName, + Object *defineObjectBinding_helper(AST::UiQualifiedId *propertyName, bool onAssignment, const QString &objectType, AST::SourceLocation typeLocation, LocationSpan location, @@ -243,6 +243,7 @@ QString ProcessAST::asString(AST::UiQualifiedId *node) const Object * ProcessAST::defineObjectBinding_helper(AST::UiQualifiedId *propertyName, + bool onAssignment, const QString &objectType, AST::SourceLocation typeLocation, LocationSpan location, @@ -254,10 +255,19 @@ ProcessAST::defineObjectBinding_helper(AST::UiQualifiedId *propertyName, (lastTypeDot >= 0 && objectType.at(lastTypeDot+1).isUpper())); int propertyCount = 0; - for (; propertyName; propertyName = propertyName->next){ + for (AST::UiQualifiedId *name = propertyName; name; name = name->next){ ++propertyCount; - _stateStack.pushProperty(propertyName->name->asString(), - this->location(propertyName)); + _stateStack.pushProperty(name->name->asString(), + this->location(name)); + } + + if (!onAssignment && propertyCount && currentProperty() && currentProperty()->values.count()) { + QDeclarativeError error; + error.setDescription(QCoreApplication::translate("QDeclarativeParser","Property value set multiple times")); + error.setLine(this->location(propertyName).start.line); + error.setColumn(this->location(propertyName).start.column); + _parser->_errors << error; + return 0; } if (!isType) { @@ -327,7 +337,10 @@ ProcessAST::defineObjectBinding_helper(AST::UiQualifiedId *propertyName, Value *v = new Value; v->object = obj; v->location = obj->location; - prop->addValue(v); + if (onAssignment) + prop->addOnValue(v); + else + prop->addValue(v); while (propertyCount--) _stateStack.pop(); @@ -363,7 +376,7 @@ ProcessAST::defineObjectBinding_helper(AST::UiQualifiedId *propertyName, } } -Object *ProcessAST::defineObjectBinding(AST::UiQualifiedId *qualifiedId, +Object *ProcessAST::defineObjectBinding(AST::UiQualifiedId *qualifiedId, bool onAssignment, AST::UiQualifiedId *objectTypeName, LocationSpan location, AST::UiObjectInitializer *initializer) @@ -395,7 +408,7 @@ Object *ProcessAST::defineObjectBinding(AST::UiQualifiedId *qualifiedId, } - return defineObjectBinding_helper(qualifiedId, objectType, typeLocation, location, initializer); + return defineObjectBinding_helper(qualifiedId, onAssignment, objectType, typeLocation, location, initializer); } LocationSpan ProcessAST::location(AST::UiQualifiedId *id) @@ -623,7 +636,7 @@ bool ProcessAST::visit(AST::UiObjectDefinition *node) LocationSpan l = location(node->firstSourceLocation(), node->lastSourceLocation()); - defineObjectBinding(/*propertyName = */ 0, + defineObjectBinding(/*propertyName = */ 0, false, node->qualifiedTypeNameId, l, node->initializer); @@ -638,7 +651,7 @@ bool ProcessAST::visit(AST::UiObjectBinding *node) LocationSpan l = location(node->qualifiedTypeNameId->identifierToken, node->initializer->rbraceToken); - defineObjectBinding(node->qualifiedId, + defineObjectBinding(node->qualifiedId, node->hasOnToken, node->qualifiedTypeNameId, l, node->initializer); @@ -674,14 +687,23 @@ bool ProcessAST::visit(AST::UiScriptBinding *node) { int propertyCount = 0; AST::UiQualifiedId *propertyName = node->qualifiedId; - for (; propertyName; propertyName = propertyName->next){ + for (AST::UiQualifiedId *name = propertyName; name; name = name->next){ ++propertyCount; - _stateStack.pushProperty(propertyName->name->asString(), - location(propertyName)); + _stateStack.pushProperty(name->name->asString(), + location(name)); } Property *prop = currentProperty(); + if (prop->values.count()) { + QDeclarativeError error; + error.setDescription(QCoreApplication::translate("QDeclarativeParser","Property value set multiple times")); + error.setLine(this->location(propertyName).start.line); + error.setColumn(this->location(propertyName).start.column); + _parser->_errors << error; + return 0; + } + QDeclarativeParser::Variant primitive; if (AST::ExpressionStatement *stmt = AST::cast<AST::ExpressionStatement *>(node->statement)) { @@ -724,16 +746,26 @@ bool ProcessAST::visit(AST::UiArrayBinding *node) { int propertyCount = 0; AST::UiQualifiedId *propertyName = node->qualifiedId; - for (; propertyName; propertyName = propertyName->next){ + for (AST::UiQualifiedId *name = propertyName; name; name = name->next){ ++propertyCount; - _stateStack.pushProperty(propertyName->name->asString(), - location(propertyName)); + _stateStack.pushProperty(name->name->asString(), + location(name)); + } + + Property* prop = currentProperty(); + + if (prop->values.count()) { + QDeclarativeError error; + error.setDescription(QCoreApplication::translate("QDeclarativeParser","Property value set multiple times")); + error.setLine(this->location(propertyName).start.line); + error.setColumn(this->location(propertyName).start.column); + _parser->_errors << error; + return 0; } accept(node->members); // For the DOM, store the position of the T_LBRACKET upto the T_RBRACKET as the range: - Property* prop = currentProperty(); prop->listValueRange.offset = node->lbracketToken.offset; prop->listValueRange.length = node->rbracketToken.offset + node->rbracketToken.length - node->lbracketToken.offset; diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp index 01fa214..34d3795 100644 --- a/src/declarative/qml/qdeclarativevaluetype.cpp +++ b/src/declarative/qml/qdeclarativevaluetype.cpp @@ -45,19 +45,50 @@ QT_BEGIN_NAMESPACE +#if (QT_VERSION < QT_VERSION_CHECK(4,7,0)) +Q_DECLARE_METATYPE(QEasingCurve); +#endif + QDeclarativeValueTypeFactory::QDeclarativeValueTypeFactory() { // ### Optimize for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii) valueTypes[ii] = valueType(ii); +#if (QT_VERSION < QT_VERSION_CHECK(4,7,0)) + easingType = qMetaTypeId<QEasingCurve>(); + easingValueType = valueType(easingType); +#endif } QDeclarativeValueTypeFactory::~QDeclarativeValueTypeFactory() { for (unsigned int ii = 0; ii < (QVariant::UserType - 1); ++ii) delete valueTypes[ii]; +#if (QT_VERSION < QT_VERSION_CHECK(4,7,0)) + delete easingValueType; +#endif +} + +bool QDeclarativeValueTypeFactory::isValueType(int idx) +{ + if ((uint)idx < QVariant::UserType) + return true; +#if (QT_VERSION < QT_VERSION_CHECK(4,7,0)) + if (idx == qMetaTypeId<QEasingCurve>()) + return true; +#endif + return false; } +QDeclarativeValueType *QDeclarativeValueTypeFactory::operator[](int idx) const +{ +#if (QT_VERSION < QT_VERSION_CHECK(4,7,0)) + if (idx == easingType) return easingValueType; +#endif + return valueTypes[idx]; +} + + QDeclarativeValueType *QDeclarativeValueTypeFactory::valueType(int t) { switch (t) { @@ -75,11 +106,17 @@ QDeclarativeValueType *QDeclarativeValueTypeFactory::valueType(int t) return new QDeclarativeRectFValueType; case QVariant::Vector3D: return new QDeclarativeVector3DValueType; +#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) case QVariant::EasingCurve: return new QDeclarativeEasingValueType; +#endif case QVariant::Font: return new QDeclarativeFontValueType; default: +#if (QT_VERSION < QT_VERSION_CHECK(4,7,0)) + if (t == qMetaTypeId<QEasingCurve>()) + return new QDeclarativeEasingValueType; +#endif return 0; } } @@ -495,7 +532,11 @@ void QDeclarativeEasingValueType::write(QObject *obj, int idx, QDeclarativePrope QVariant QDeclarativeEasingValueType::value() { +#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) return QVariant(easing); +#else + return QVariant::fromValue<QEasingCurve>(easing); +#endif } void QDeclarativeEasingValueType::setValue(QVariant value) diff --git a/src/declarative/qml/qdeclarativevaluetype_p.h b/src/declarative/qml/qdeclarativevaluetype_p.h index cb153be..e69f161 100644 --- a/src/declarative/qml/qdeclarativevaluetype_p.h +++ b/src/declarative/qml/qdeclarativevaluetype_p.h @@ -81,10 +81,17 @@ class Q_DECLARATIVE_EXPORT QDeclarativeValueTypeFactory public: QDeclarativeValueTypeFactory(); ~QDeclarativeValueTypeFactory(); + static bool isValueType(int); static QDeclarativeValueType *valueType(int); + QDeclarativeValueType *operator[](int idx) const; + +private: QDeclarativeValueType *valueTypes[QVariant::UserType - 1]; - QDeclarativeValueType *operator[](int idx) const { return valueTypes[idx]; } +#if (QT_VERSION < QT_VERSION_CHECK(4,7,0)) + int easingType; + QDeclarativeValueType *easingValueType; +#endif }; class Q_AUTOTEST_EXPORT QDeclarativePointFValueType : public QDeclarativeValueType diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp index fc3722d..6a08674 100644 --- a/src/declarative/qml/qdeclarativevme.cpp +++ b/src/declarative/qml/qdeclarativevme.cpp @@ -538,13 +538,13 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack, QDeclarati case QDeclarativeInstruction::StoreSignal: { QObject *target = stack.top(); - // XXX scope - QMetaMethod signal = - target->metaObject()->method(instr.storeSignal.signalIndex); + QObject *context = stack.at(stack.count() - 1 - instr.assignBinding.context); + + QMetaMethod signal = target->metaObject()->method(instr.storeSignal.signalIndex); QDeclarativeBoundSignal *bs = new QDeclarativeBoundSignal(target, signal, target); QDeclarativeExpression *expr = - new QDeclarativeExpression(ctxt, primitives.at(instr.storeSignal.value), target); + new QDeclarativeExpression(ctxt, primitives.at(instr.storeSignal.value), context); expr->setSourceLocation(comp->name, instr.line); bs->setExpression(expr); } diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp index 03151e4..784353a 100644 --- a/src/declarative/qml/qdeclarativeworkerscript.cpp +++ b/src/declarative/qml/qdeclarativeworkerscript.cpp @@ -365,6 +365,8 @@ void QDeclarativeWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url) workerEngine->evaluate(script); workerEngine->popContext(); + } else { + qWarning().nospace() << "WorkerScript: Cannot find source file " << url.toString(); } } @@ -382,7 +384,7 @@ QVariant QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(const QScri quint32 length = (quint32)value.property(QLatin1String("length")).toNumber(); for (quint32 ii = 0; ii < length; ++ii) { - QVariant v = scriptValueToVariant(ii); + QVariant v = scriptValueToVariant(value.property(ii)); list << v; } @@ -561,6 +563,65 @@ void QDeclarativeWorkerScriptEngine::run() delete d->workerEngine; d->workerEngine = 0; } + +/*! + \qmlclass WorkerScript QDeclarativeWorkerScript + \brief The WorkerScript element enables the use of threads in QML. + + Use WorkerScript to run operations in a new thread. + This is useful for running operations in the background so + that the main GUI thread is not blocked. + + Messages can be passed between the new thread and the parent thread + using sendMessage() and the onMessage() handler. + + Here is an example: + + \qml + import Qt 4.6 + + Rectangle { + width: 300 + height: 300 + + Text { + id: myText + text: 'Click anywhere' + } + + WorkerScript { + id: myWorker + source: "script.js" + + onMessage: { + myText.text = messageObject.reply + } + } + + MouseArea { + anchors.fill: parent + onClicked: myWorker.sendMessage( {'x': mouse.x, 'y': mouse.y} ); + } + } + \endqml + + The above worker script specifies a javascript file, "script.js", that handles + the operations to be performed in the new thread: + + \qml + WorkerScript.onMessage = function(message) { + // ... long-running operations and calculations are done here + WorkerScript.sendMessage( {'reply': 'Mouse is at ' + message.x + ',' + message.y} ); + } + \endqml + + When the user clicks anywhere within the rectangle, \c sendMessage() is + called, triggering the \tt WorkerScript.onMessage() handler in + \tt source.js. This in turn sends a reply message that is then received + by the \tt onMessage() handler of \tt myWorker. + + \sa WorkerListModel +*/ QDeclarativeWorkerScript::QDeclarativeWorkerScript(QObject *parent) : QObject(parent), m_engine(0), m_scriptId(-1) { @@ -571,6 +632,12 @@ QDeclarativeWorkerScript::~QDeclarativeWorkerScript() if (m_scriptId != -1) m_engine->removeWorkerScript(m_scriptId); } +/*! + \qmlproperty url WorkerScript::source + + This holds the url of the javascript file that implements the + \tt WorkerScript.onMessage() handler for threaded operations. +*/ QUrl QDeclarativeWorkerScript::source() const { return m_source; @@ -589,6 +656,13 @@ void QDeclarativeWorkerScript::setSource(const QUrl &source) emit sourceChanged(); } +/* + \qmlmethod WorkerScript::sendMessage(jsobject message) + + Sends the given \a message to a worker script handler in another + thread. The other worker script handler can receive this message + through the onMessage() handler. +*/ void QDeclarativeWorkerScript::sendMessage(const QScriptValue &message) { if (!m_engine) { @@ -616,6 +690,13 @@ void QDeclarativeWorkerScript::componentComplete() } } +/*! + \qmlsignal WorkerScript::onMessage(jsobject msg) + + This handler is called when a message \a msg is received from a worker + script in another thread through a call to sendMessage(). +*/ + bool QDeclarativeWorkerScript::event(QEvent *event) { if (event->type() == (QEvent::Type)WorkerDataEvent::WorkerData) { @@ -841,6 +922,41 @@ bool QDeclarativeWorkerListModelAgent::event(QEvent *e) return QObject::event(e); } +/*! + \qmlclass WorkerListModel QDeclarativeWorkerListModel + \brief The WorkerListModel element provides a threaded list model. + + Use WorkerListModel together with WorkerScript to define a list model + that is controlled by a separate thread. This is useful if list modification + operations are synchronous and take some time: using WorkerListModel + moves these operations to a different thread and avoids blocking of the + main GUI thread. + + The thread that creates the WorkerListModel can modify the model for any + initial set-up requirements. However, once the model has been modified by + the associated WorkerScript, the model can only be modified by that worker + script and becomes read-only to all other threads. + + Here is an example application that uses WorkerScript to append the + current time to a WorkerListModel: + + \snippet examples/declarative/workerlistmodel/timedisplay.qml 0 + + The included file, \tt dataloader.js, looks like this: + + \snippet examples/declarative/workerlistmodel/dataloader.js 0 + + The application's \tt Timer object periodically sends a message to the + worker script by calling \tt WorkerScript::sendMessage(). When this message + is received, \tt WorkerScript.onMessage() is invoked in + \tt dataloader.js, which appends the current time to the worker list + model. + + Note that unlike ListModel, WorkerListModel does not have \tt move() and + \tt setProperty() methods. + + \sa WorkerScript, ListModel +*/ QDeclarativeWorkerListModel::QDeclarativeWorkerListModel(QObject *parent) : QListModelInterface(parent), m_agent(0) { @@ -854,6 +970,14 @@ QDeclarativeWorkerListModel::~QDeclarativeWorkerListModel() } } +/*! + \qmlmethod WorkerListModel::clear() + + Deletes all content from the model. The properties are cleared such that + different properties may be set on subsequent additions. + + \sa append() remove() +*/ void QDeclarativeWorkerListModel::clear() { if (m_agent) { @@ -869,6 +993,13 @@ void QDeclarativeWorkerListModel::clear() } } +/*! + \qmlmethod WorkerListModel::remove(int index) + + Deletes the content at \a index from the model. + + \sa clear() +*/ void QDeclarativeWorkerListModel::remove(int index) { if (m_agent) { @@ -884,6 +1015,18 @@ void QDeclarativeWorkerListModel::remove(int index) emit countChanged(); } +/*! + \qmlmethod WorkerListModel::append(jsobject dict) + + Adds a new item to the end of the list model, with the + values in \a dict. + + \code + FruitModel.append({"cost": 5.95, "name":"Pizza"}) + \endcode + + \sa set() remove() +*/ void QDeclarativeWorkerListModel::append(const QScriptValue &value) { if (m_agent) { @@ -914,6 +1057,21 @@ void QDeclarativeWorkerListModel::append(const QScriptValue &value) emit countChanged(); } +/*! + \qmlmethod WorkerListModel::insert(int index, jsobject dict) + + Adds a new item to the list model at position \a index, with the + values in \a dict. + + \code + FruitModel.insert(2, {"cost": 5.95, "name":"Pizza"}) + \endcode + + The \a index must be to an existing item in the list, or one past + the end of the list (equivalent to append). + + \sa set() append() +*/ void QDeclarativeWorkerListModel::insert(int index, const QScriptValue &value) { if (m_agent) { @@ -946,6 +1104,30 @@ void QDeclarativeWorkerListModel::insert(int index, const QScriptValue &value) emit countChanged(); } +/*! + \qmlmethod object ListModel::get(int index) + + Returns the item at \a index in the list model. + + \code + FruitModel.append({"cost": 5.95, "name":"Jackfruit"}) + FruitModel.get(0).cost + \endcode + + The \a index must be an element in the list. + + Note that properties of the returned object that are themselves objects + will also be models, and this get() method is used to access elements: + + \code + FruitModel.append(..., "attributes": + [{"name":"spikes","value":"7mm"}, + {"name":"color","value":"green"}]); + FruitModel.get(0).attributes.get(1).value; // == "green" + \endcode + + \sa append() +*/ QScriptValue QDeclarativeWorkerListModel::get(int index) const { QDeclarativeEngine *engine = qmlEngine(this); @@ -962,6 +1144,21 @@ QScriptValue QDeclarativeWorkerListModel::get(int index) const return rv; } +/*! + \qmlmethod WorkerListModel::set(int index, jsobject dict) + + Changes the item at \a index in the list model with the + values in \a dict. Properties not appearing in \a valuemap + are left unchanged. + + \code + FruitModel.set(3, {"cost": 5.95, "name":"Pizza"}) + \endcode + + The \a index must be an element in the list. + + \sa append() +*/ void QDeclarativeWorkerListModel::set(int index, const QScriptValue &value) { if (m_agent) { @@ -995,6 +1192,22 @@ void QDeclarativeWorkerListModel::set(int index, const QScriptValue &value) } } +/*! + \qmlmethod WorkerListModel::sync() + + Writes any unsaved changes to the list model. This must be called after + changes have been made to the list model in the worker script. + + Note that this method can only be called from the associated worker script. +*/ +void QDeclarativeWorkerListModel::sync() +{ + // This is really a dummy method to make it look like sync() exists in + // WorkerListModel (and not QDeclarativeWorkerListModelAgent) and to let + // us document sync(). + qmlInfo(this) << "sync() can only be called from a WorkerScript"; +} + QDeclarativeWorkerListModelAgent *QDeclarativeWorkerListModel::agent() { if (!m_agent) @@ -1013,6 +1226,10 @@ QString QDeclarativeWorkerListModel::toString(int role) const return m_roles.value(role); } +/*! + \qmlproperty int ListModel::count + The number of data entries in the model. +*/ int QDeclarativeWorkerListModel::count() const { return m_values.count(); @@ -1038,4 +1255,3 @@ QT_END_NAMESPACE #include "qdeclarativeworkerscript.moc" - diff --git a/src/declarative/qml/qdeclarativeworkerscript_p.h b/src/declarative/qml/qdeclarativeworkerscript_p.h index 8ebd2c1..912eac9 100644 --- a/src/declarative/qml/qdeclarativeworkerscript_p.h +++ b/src/declarative/qml/qdeclarativeworkerscript_p.h @@ -61,8 +61,12 @@ #include <QtScript/qscriptvalue.h> #include <QtCore/qurl.h> +QT_BEGIN_HEADER + QT_BEGIN_NAMESPACE +QT_MODULE(Declarative) + class QDeclarativeWorkerScript; class QDeclarativeWorkerScriptEnginePrivate; class QDeclarativeWorkerScriptEngine : public QThread @@ -84,7 +88,7 @@ private: QDeclarativeWorkerScriptEnginePrivate *d; }; -class QDeclarativeWorkerScript : public QObject, public QDeclarativeParserStatus +class Q_DECLARATIVE_EXPORT QDeclarativeWorkerScript : public QObject, public QDeclarativeParserStatus { Q_OBJECT Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) @@ -115,7 +119,7 @@ private: }; class QDeclarativeWorkerListModelAgent; -class QDeclarativeWorkerListModel : public QListModelInterface +class Q_DECLARATIVE_EXPORT QDeclarativeWorkerListModel : public QListModelInterface { Q_OBJECT Q_PROPERTY(int count READ count NOTIFY countChanged) @@ -130,6 +134,7 @@ public: Q_INVOKABLE void insert(int index, const QScriptValue&); Q_INVOKABLE QScriptValue get(int index) const; Q_INVOKABLE void set(int index, const QScriptValue &); + Q_INVOKABLE void sync(); QDeclarativeWorkerListModelAgent *agent(); @@ -157,4 +162,6 @@ QT_END_NAMESPACE QML_DECLARE_TYPE(QDeclarativeWorkerScript); QML_DECLARE_TYPE(QDeclarativeWorkerListModel); +QT_END_HEADER + #endif // QDECLARATIVEWORKERSCRIPT_P_H diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 10230d3..76b6a58 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -52,6 +52,7 @@ #include <qdeclarativestringconverters_p.h> #include <qdeclarativeglobal_p.h> #include <qdeclarativemetatype_p.h> +#include <qdeclarativevaluetype_p.h> #include <qdeclarativeproperty_p.h> #include <qvariant.h> @@ -110,7 +111,7 @@ QDeclarativeAbstractAnimation::QDeclarativeAbstractAnimation(QDeclarativeAbstrac \code Rectangle { width: 100; height: 100 - x: NumberAnimation { + NumberAnimation on x { running: myMouse.pressed from: 0; to: 100 } @@ -310,7 +311,7 @@ void QDeclarativeAbstractAnimation::setAlwaysRunToEnd(bool f) \code Rectangle { - rotation: NumberAnimation { running: true; repeat: true; from: 0 to: 360 } + NumberAnimation on rotation { running: true; repeat: true; from: 0 to: 360 } } \endcode */ @@ -412,7 +413,7 @@ void QDeclarativeAbstractAnimation::resume() no further influence on property values. In this example animation \code Rectangle { - x: NumberAnimation { from: 0; to: 100; duration: 500 } + NumberAnimation on x { from: 0; to: 100; duration: 500 } } \endcode was stopped at time 250ms, the \c x property will have a value of 50. @@ -450,7 +451,7 @@ void QDeclarativeAbstractAnimation::restart() its end. In the following example, \code Rectangle { - x: NumberAnimation { from: 0; to: 100; duration: 500 } + NumberAnimation on x { from: 0; to: 100; duration: 500 } } \endcode calling \c stop() at time 250ms will result in the \c x property having @@ -1292,7 +1293,7 @@ QDeclarativeVector3dAnimation::QDeclarativeVector3dAnimation(QObject *parent) Q_D(QDeclarativePropertyAnimation); d->interpolatorType = QMetaType::QVector3D; d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); - d->defaultToInterpolatorType = true; + d->defaultToInterpolatorType = true; } QDeclarativeVector3dAnimation::~QDeclarativeVector3dAnimation() @@ -1573,7 +1574,8 @@ QDeclarativeSequentialAnimation::QDeclarativeSequentialAnimation(QObject *parent QDeclarativeAnimationGroup(parent) { Q_D(QDeclarativeAnimationGroup); - d->ag = new QSequentialAnimationGroup(this); + d->ag = new QSequentialAnimationGroup; + QDeclarative_setParent_noEvent(d->ag, this); } QDeclarativeSequentialAnimation::~QDeclarativeSequentialAnimation() @@ -1638,7 +1640,8 @@ QDeclarativeParallelAnimation::QDeclarativeParallelAnimation(QObject *parent) : QDeclarativeAnimationGroup(parent) { Q_D(QDeclarativeAnimationGroup); - d->ag = new QParallelAnimationGroup(this); + d->ag = new QParallelAnimationGroup; + QDeclarative_setParent_noEvent(d->ag, this); } QDeclarativeParallelAnimation::~QDeclarativeParallelAnimation() @@ -1708,12 +1711,13 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int break; } default: - if ((uint)type >= QVariant::UserType) { + if (QDeclarativeValueTypeFactory::isValueType((uint)type)) { + variant.convert((QVariant::Type)type); + } else { QDeclarativeMetaType::StringConverter converter = QDeclarativeMetaType::customStringConverter(type); if (converter) variant = converter(variant.toString()); - } else - variant.convert((QVariant::Type)type); + } break; } } @@ -1732,14 +1736,14 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int Animate any objects that have changed their x or y properties in the target state using an InOutQuad easing curve: \qml - Transition { PropertyAnimation { properties: "x,y"; easing: "InOutQuad" } } + Transition { PropertyAnimation { properties: "x,y"; easing.type: "InOutQuad" } } \endqml \o In a Behavior Animate all changes to a rectangle's x property. \qml Rectangle { - x: Behavior { PropertyAnimation {} } + Behavior on x { PropertyAnimation {} } } \endqml \o As a property value source @@ -1747,7 +1751,7 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int Repeatedly animate the rectangle's x property. \qml Rectangle { - x: SequentialAnimation { + SequentialAnimation on x { repeat: true PropertyAnimation { to: 50 } PropertyAnimation { to: 0 } @@ -1797,7 +1801,7 @@ QDeclarativePropertyAnimation::~QDeclarativePropertyAnimation() void QDeclarativePropertyAnimationPrivate::init() { Q_Q(QDeclarativePropertyAnimation); - va = new QDeclarativeTimeLineValueAnimator; + va = new QDeclarativeBulkValueAnimator; QDeclarative_setParent_noEvent(va, q); } @@ -1873,7 +1877,13 @@ void QDeclarativePropertyAnimation::setTo(const QVariant &t) \qmlproperty QEasingCurve PropertyAnimation::easing \brief the easing curve used for the transition. - Available values are: + For the easing you can specify the following parameters: type, amplitude, period and overshoot. + + \qml + PropertyAnimation { properties: "y"; easing.type: "InOutElastc"; easing.amplitude: 2.0; easing.period: 1.5 } + \endqml + + Available types are: \table \row @@ -2044,6 +2054,15 @@ void QDeclarativePropertyAnimation::setTo(const QVariant &t) \o \inlineimage qeasingcurve-outinbounce.png \endtable + easing.amplitude is not applicable for all curve types. It is only applicable for bounce and elastic curves (curves of type + QEasingCurve::InBounce, QEasingCurve::OutBounce, QEasingCurve::InOutBounce, QEasingCurve::OutInBounce, QEasingCurve::InElastic, + QEasingCurve::OutElastic, QEasingCurve::InOutElastic or QEasingCurve::OutInElastic). + + easing.overshoot is not applicable for all curve types. It is only applicable if type is: QEasingCurve::InBack, QEasingCurve::OutBack, + QEasingCurve::InOutBack or QEasingCurve::OutInBack. + + easing.period is not applicable for all curve types. It is only applicable if type is: QEasingCurve::InElastic, QEasingCurve::OutElastic, + QEasingCurve::InOutElastic or QEasingCurve::OutInElastic. */ QEasingCurve QDeclarativePropertyAnimation::easing() const { @@ -2138,8 +2157,8 @@ void QDeclarativePropertyAnimation::setProperties(const QString &prop) id: theRect width: 100; height: 100 color: Qt.rgba(0,0,1) - x: NumberAnimation { to: 500; repeat: true } //animate theRect's x property - y: Behavior { NumberAnimation {} } //animate theRect's y property + NumberAnimation on x { to: 500; repeat: true } //animate theRect's x property + Behavior on y { NumberAnimation {} } //animate theRect's y property } \endqml \row @@ -2213,7 +2232,7 @@ QAbstractAnimation *QDeclarativePropertyAnimation::qtAnimation() return d->va; } -struct PropertyUpdater : public QDeclarativeTimeLineValue +struct PropertyUpdater : public QDeclarativeBulkValueUpdater { QDeclarativeStateActions actions; int interpolatorType; //for Number/ColorAnimation @@ -2223,7 +2242,7 @@ struct PropertyUpdater : public QDeclarativeTimeLineValue bool fromSourced; bool fromDefined; bool *wasDeleted; - PropertyUpdater() : wasDeleted(0) {} + PropertyUpdater() : prevInterpolatorType(0), wasDeleted(0) {} ~PropertyUpdater() { if (wasDeleted) *wasDeleted = true; } void setValue(qreal v) { @@ -2231,7 +2250,6 @@ struct PropertyUpdater : public QDeclarativeTimeLineValue wasDeleted = &deleted; if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1 v = 1 - v; - QDeclarativeTimeLineValue::setValue(v); for (int ii = 0; ii < actions.count(); ++ii) { QDeclarativeAction &action = actions[ii]; diff --git a/src/declarative/util/qdeclarativeanimation_p_p.h b/src/declarative/util/qdeclarativeanimation_p_p.h index e582066..ae82a90 100644 --- a/src/declarative/util/qdeclarativeanimation_p_p.h +++ b/src/declarative/util/qdeclarativeanimation_p_p.h @@ -149,14 +149,21 @@ private: bool running; }; -//animates QDeclarativeTimeLineValue (assumes start and end values will be reals or compatible) -class QDeclarativeTimeLineValueAnimator : public QVariantAnimation +class QDeclarativeBulkValueUpdater +{ +public: + virtual ~QDeclarativeBulkValueUpdater() {} + virtual void setValue(qreal value) = 0; +}; + +//animates QDeclarativeBulkValueUpdater (assumes start and end values will be reals or compatible) +class QDeclarativeBulkValueAnimator : public QVariantAnimation { Q_OBJECT public: - QDeclarativeTimeLineValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), fromSourced(0), policy(KeepWhenStopped) {} - ~QDeclarativeTimeLineValueAnimator() { if (policy == DeleteWhenStopped) { delete animValue; animValue = 0; } } - void setAnimValue(QDeclarativeTimeLineValue *value, DeletionPolicy p) + QDeclarativeBulkValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), fromSourced(0), policy(KeepWhenStopped) {} + ~QDeclarativeBulkValueAnimator() { if (policy == DeleteWhenStopped) { delete animValue; animValue = 0; } } + void setAnimValue(QDeclarativeBulkValueUpdater *value, DeletionPolicy p) { if (state() == Running) stop(); @@ -193,7 +200,7 @@ protected: } private: - QDeclarativeTimeLineValue *animValue; + QDeclarativeBulkValueUpdater *animValue; bool *fromSourced; DeletionPolicy policy; }; @@ -352,7 +359,7 @@ public: int interpolatorType; QVariantAnimation::Interpolator interpolator; - QDeclarativeTimeLineValueAnimator *va; + QDeclarativeBulkValueAnimator *va; static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress); static void convertVariant(QVariant &variant, int type); diff --git a/src/declarative/util/qdeclarativebehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp index 5352341..dea2c02 100644 --- a/src/declarative/util/qdeclarativebehavior.cpp +++ b/src/declarative/util/qdeclarativebehavior.cpp @@ -75,13 +75,13 @@ public: Behaviors provide one way to specify \l{qdeclarativeanimation.html}{animations} in QML. - In the example below, the rect will use a bounce easing curve over 200 millisecond for any changes to its y property: + In the example below, the rectangle will use a bounce easing curve over 200 millisecond for any changes to its y property: \code Rectangle { width: 20; height: 20 color: "#00ff00" - y: 200 //initial value - y: Behavior { + y: 200 // initial value + Behavior on y { NumberAnimation { easing: "easeOutBounce(amplitude:100)" duration: 200 diff --git a/src/declarative/util/qdeclarativebind.cpp b/src/declarative/util/qdeclarativebind.cpp index e95a03e..26baa38 100644 --- a/src/declarative/util/qdeclarativebind.cpp +++ b/src/declarative/util/qdeclarativebind.cpp @@ -72,7 +72,7 @@ public: /*! \qmlclass Binding QDeclarativeBind - \since 4.7 + \since 4.7 \brief The Binding element allows arbitrary property bindings to be created. Sometimes it is necessary to bind to a property of an object that wasn't @@ -114,6 +114,19 @@ QDeclarativeBind::~QDeclarativeBind() { } +/*! + \qmlproperty bool Binding::when + + This property holds when the binding is active. + This should be set to an expression that evaluates to true when you want the binding to be active. + + \code + Binding { + target: contactName; property: 'text' + value: name; when: list.ListView.isCurrentItem + } + \endcode +*/ bool QDeclarativeBind::when() const { Q_D(const QDeclarativeBind); diff --git a/src/declarative/util/qdeclarativeeasefollow.cpp b/src/declarative/util/qdeclarativeeasefollow.cpp index 3fa9866..ee181dd 100644 --- a/src/declarative/util/qdeclarativeeasefollow.cpp +++ b/src/declarative/util/qdeclarativeeasefollow.cpp @@ -59,10 +59,10 @@ class QDeclarativeEaseFollowPrivate : public QObjectPrivate public: QDeclarativeEaseFollowPrivate() : source(0), velocity(200), duration(-1), maximumEasingTime(-1), - reversingMode(QDeclarativeEaseFollow::Eased), initialVelocity(0), + reversingMode(QDeclarativeEaseFollow::Eased), initialVelocity(0), initialValue(0), invert(false), enabled(true), trackVelocity(0), clockOffset(0), lastTick(0), clock(this) - {} + {} qreal source; qreal velocity; @@ -173,7 +173,7 @@ bool QDeclarativeEaseFollowPrivate::recalc() } /* - qWarning() << "a:" << a << "tf:" << tf << "tp:" << tp << "vp:" + qWarning() << "a:" << a << "tf:" << tf << "tp:" << tp << "vp:" << vp << "sp:" << sp << "vi:" << vi << "invert:" << invert; */ return true; @@ -254,19 +254,19 @@ void QDeclarativeEaseFollowPrivate::tick(int t) \since 4.7 \brief The EaseFollow element allows a property to smoothly track a value. - The EaseFollow smoothly animates a property's value to a set target value + The EaseFollow smoothly animates a property's value to a set target value using an ease in/out quad easing curve. If the target value changes while - the animation is in progress, the easing curves used to animate to the old + the animation is in progress, the easing curves used to animate to the old and the new target values are spliced together to avoid any obvious visual glitches. The property animation is configured by setting the velocity at which the - animation should occur, or the duration that the animation should take. + animation should occur, or the duration that the animation should take. If both a velocity and a duration are specified, the one that results in the quickest animation is chosen for each change in the target value. For example, animating from 0 to 800 will take 4 seconds if a velocity - of 200 is set, will take 8 seconds with a duration of 8000 set, and will + of 200 is set, will take 8 seconds with a duration of 8000 set, and will take 4 seconds with both a velocity of 200 and a duration of 8000 set. Animating from 0 to 20000 will take 10 seconds if a velocity of 200 is set, will take 8 seconds with a duration of 8000 set, and will take 8 seconds @@ -283,8 +283,8 @@ Rectangle { color: "green" width: 60; height: 60; x: -5; y: -5; - x: EaseFollow { source: rect1.x - 5; velocity: 200 } - y: EaseFollow { source: rect1.y - 5; velocity: 200 } + EaseFollow on x { source: rect1.x - 5; velocity: 200 } + EaseFollow on y { source: rect1.y - 5; velocity: 200 } } Rectangle { @@ -338,8 +338,8 @@ qreal QDeclarativeEaseFollow::sourceValue() const Sets how the EaseFollow behaves if an animation direction is reversed. If reversing mode is \c Eased, the animation will smoothly decelerate, and - then reverse direction. If the reversing mode is \c Immediate, the - animation will immediately begin accelerating in the reverse direction, + then reverse direction. If the reversing mode is \c Immediate, the + animation will immediately begin accelerating in the reverse direction, begining with a velocity of 0. If the reversing mode is \c Sync, the property is immediately set to the target value. */ @@ -373,7 +373,7 @@ void QDeclarativeEaseFollowPrivate::restart() return; } - bool hasReversed = trackVelocity != 0. && + bool hasReversed = trackVelocity != 0. && ((trackVelocity > 0) == ((initialValue - source) > 0)); if (hasReversed) { @@ -440,7 +440,7 @@ void QDeclarativeEaseFollow::setDuration(qreal v) d->duration = v; d->trackVelocity = 0; - if (d->clock.state() == QAbstractAnimation::Running) + if (d->clock.state() == QAbstractAnimation::Running) d->restart(); emit durationChanged(); @@ -470,7 +470,7 @@ void QDeclarativeEaseFollow::setVelocity(qreal v) d->velocity = v; d->trackVelocity = 0; - if (d->clock.state() == QAbstractAnimation::Running) + if (d->clock.state() == QAbstractAnimation::Running) d->restart(); emit velocityChanged(); @@ -511,8 +511,8 @@ void QDeclarativeEaseFollow::setTarget(const QDeclarativeProperty &t) \qmlproperty qreal EaseFollow::maximumEasingTime This property specifies the maximum time an "eases" during the follow should take. -Setting this property causes the velocity to "level out" after at a time. Setting -a negative value reverts to the normal mode of easing over the entire animation +Setting this property causes the velocity to "level out" after at a time. Setting +a negative value reverts to the normal mode of easing over the entire animation duration. The default value is -1. @@ -528,7 +528,7 @@ void QDeclarativeEaseFollow::setMaximumEasingTime(qreal v) Q_D(QDeclarativeEaseFollow); d->maximumEasingTime = v; - if (d->clock.state() == QAbstractAnimation::Running) + if (d->clock.state() == QAbstractAnimation::Running) d->restart(); emit maximumEasingTimeChanged(); diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp index 4d12ae1..8f5f537 100644 --- a/src/declarative/util/qdeclarativefontloader.cpp +++ b/src/declarative/util/qdeclarativefontloader.cpp @@ -189,6 +189,16 @@ void QDeclarativeFontLoader::setName(const QString &name) \o Loading - the font is currently being loaded \o Error - an error occurred while loading the font \endlist + + Note that a change in the status property does not cause anything to happen + (although it reflects what has happened to the font loader internally). If you wish + to react to the change in status you need to do it yourself, for example in one + of the following ways: + \list + \o Create a state, so that a state change occurs, e.g. State{name: 'loaded'; when: loader.status = FontLoader.Ready;} + \o Do something inside the onStatusChanged signal handler, e.g. FontLoader{id: loader; onStatusChanged: if(loader.status == FontLoader.Ready) console.log('Loaded');} + \o Bind to the status variable somewhere, e.g. Text{text: if(loader.status!=FontLoader.Ready){'Not Loaded';}else{'Loaded';}} + \endlist */ QDeclarativeFontLoader::Status QDeclarativeFontLoader::status() const { diff --git a/src/declarative/util/qdeclarativespringfollow.cpp b/src/declarative/util/qdeclarativespringfollow.cpp index 6205ab9..1d69dd3 100644 --- a/src/declarative/util/qdeclarativespringfollow.cpp +++ b/src/declarative/util/qdeclarativespringfollow.cpp @@ -222,8 +222,8 @@ void QDeclarativeSpringFollowPrivate::stop() id: rect1 width: 20; height: 20 color: "#00ff00" - y: 200 //initial value - y: SequentialAnimation { + y: 200 // initial value + SequentialAnimation on y { running: true repeat: true NumberAnimation { @@ -239,7 +239,7 @@ void QDeclarativeSpringFollowPrivate::stop() x: rect1.width width: 20; height: 20 color: "#ff0000" - y: SpringFollow { source: rect1.y; velocity: 200 } + SpringFollow on y { source: rect1.y; velocity: 200 } } \endcode diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp index 6fe5bf3..cd67aeb 100644 --- a/src/declarative/util/qdeclarativeview.cpp +++ b/src/declarative/util/qdeclarativeview.cpp @@ -51,6 +51,7 @@ #include <qdeclarativedebug_p.h> #include <qdeclarativedebugservice_p.h> #include <qdeclarativeglobal_p.h> +#include <qdeclarativeguard_p.h> #include <qscriptvalueiterator.h> #include <qdebug.h> @@ -136,8 +137,8 @@ public: QDeclarativeView *q; - QGuard<QGraphicsObject> root; - QGuard<QDeclarativeItem> qmlRoot; + QDeclarativeGuard<QGraphicsObject> root; + QDeclarativeGuard<QDeclarativeItem> qmlRoot; QUrl source; @@ -193,6 +194,7 @@ void QDeclarativeViewPrivate::execute() \o Initializes QGraphicsView for QML key handling: \list \o QGraphicsView::viewport()->setFocusPolicy(Qt::NoFocus); + \o QGraphicsView::setFocusPolicy(Qt::StrongFocus); \o QGraphicsScene::setStickyFocus(true); \endlist \endlist @@ -267,6 +269,7 @@ void QDeclarativeViewPrivate::init() q->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); scene.setItemIndexMethod(QGraphicsScene::NoIndex); q->viewport()->setFocusPolicy(Qt::NoFocus); + q->setFocusPolicy(Qt::StrongFocus); scene.setStickyFocus(true); //### needed for correct focus handling } @@ -282,13 +285,14 @@ QDeclarativeView::~QDeclarativeView() /*! Sets the source to the \a url, loads the QML component and instantiates it. + + Calling this methods multiple times with the same url will result + in the QML being reloaded. */ void QDeclarativeView::setSource(const QUrl& url) { - if (url != d->source) { - d->source = url; - d->execute(); - } + d->source = url; + d->execute(); } /*! diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 162a669..d260ada 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -647,11 +647,21 @@ void QDeclarativeXmlListModel::setNamespaceDeclarations(const QString &declarati This property holds the status of data source loading. It can be one of: \list \o Null - no data source has been set - \o Ready - nthe data source has been loaded + \o Ready - the data source has been loaded \o Loading - the data source is currently being loaded \o Error - an error occurred while loading the data source \endlist + Note that a change in the status property does not cause anything to happen + (although it reflects what has happened to the XmlListModel internally). If you wish + to react to the change in status you need to do it yourself, for example in one + of the following ways: + \list + \o Create a state, so that a state change occurs, e.g. State{name: 'loaded'; when: xmlListModel.status = XmlListModel.Ready;} + \o Do something inside the onStatusChanged signal handler, e.g. XmlListModel{id: xmlListModel; onStatusChanged: if(xmlListModel.status == XmlListModel.Ready) console.log('Loaded');} + \o Bind to the status variable somewhere, e.g. Text{text: if(xmlListModel.status!=XmlListModel.Ready){'Not Loaded';}else{'Loaded';}} + \endlist + \sa progress */ diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index d72833b..56f94a2 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -540,10 +540,10 @@ class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged FINAL) Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) - Q_PROPERTY(QPointF pos READ pos WRITE setPos) - Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged) - Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) - Q_PROPERTY(qreal z READ zValue WRITE setZValue NOTIFY zChanged) + Q_PROPERTY(QPointF pos READ pos WRITE setPos FINAL) + Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged FINAL) + Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged FINAL) + Q_PROPERTY(qreal z READ zValue WRITE setZValue NOTIFY zChanged FINAL) Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged) Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint WRITE setTransformOriginPoint) diff --git a/src/plugins/qdeclarativemodules/qdeclarativemodules.pro b/src/imports/imports.pro index 0a6f444..8b47043 100644 --- a/src/plugins/qdeclarativemodules/qdeclarativemodules.pro +++ b/src/imports/imports.pro @@ -2,5 +2,6 @@ TEMPLATE = subdirs SUBDIRS += widgets +contains(QT_CONFIG, webkit): SUBDIRS += webkit contains(QT_CONFIG, multimedia): SUBDIRS += multimedia diff --git a/src/plugins/qdeclarativemodules/multimedia/multimedia.cpp b/src/imports/multimedia/multimedia.cpp index a2e74f4..a2e74f4 100644 --- a/src/plugins/qdeclarativemodules/multimedia/multimedia.cpp +++ b/src/imports/multimedia/multimedia.cpp diff --git a/src/plugins/qdeclarativemodules/multimedia/multimedia.pro b/src/imports/multimedia/multimedia.pro index 7b63e7c..117aa9b 100644 --- a/src/plugins/qdeclarativemodules/multimedia/multimedia.pro +++ b/src/imports/multimedia/multimedia.pro @@ -1,5 +1,6 @@ TARGET = multimedia -include(../../qpluginbase.pri) +TARGETPATH = $$[QT_INSTALL_IMPORTS]/Qt/multimedia +include(../qimportbase.pri) QT += multimedia declarative @@ -17,10 +18,9 @@ SOURCES += \ qmetadatacontrolmetaobject.cpp QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/Qt/multimedia -target.path = $$[QT_INSTALL_IMPORTS]/Qt/multimedia +target.path = $$TARGETPATH qmldir.files += $$QT_BUILD_TREE/imports/Qt/multimedia/qmldir -qmldir.path += $$[QT_INSTALL_IMPORTS]/Qt/multimedia +qmldir.path += $$TARGETPATH INSTALLS += target qmldir - diff --git a/src/plugins/qdeclarativemodules/multimedia/qdeclarativeaudio.cpp b/src/imports/multimedia/qdeclarativeaudio.cpp index df2888c..df2888c 100644 --- a/src/plugins/qdeclarativemodules/multimedia/qdeclarativeaudio.cpp +++ b/src/imports/multimedia/qdeclarativeaudio.cpp diff --git a/src/plugins/qdeclarativemodules/multimedia/qdeclarativeaudio_p.h b/src/imports/multimedia/qdeclarativeaudio_p.h index 9881dbc..9881dbc 100644 --- a/src/plugins/qdeclarativemodules/multimedia/qdeclarativeaudio_p.h +++ b/src/imports/multimedia/qdeclarativeaudio_p.h diff --git a/src/plugins/qdeclarativemodules/multimedia/qdeclarativemediabase.cpp b/src/imports/multimedia/qdeclarativemediabase.cpp index 8e87e44..8e87e44 100644 --- a/src/plugins/qdeclarativemodules/multimedia/qdeclarativemediabase.cpp +++ b/src/imports/multimedia/qdeclarativemediabase.cpp diff --git a/src/plugins/qdeclarativemodules/multimedia/qdeclarativemediabase_p.h b/src/imports/multimedia/qdeclarativemediabase_p.h index b40e84e..b40e84e 100644 --- a/src/plugins/qdeclarativemodules/multimedia/qdeclarativemediabase_p.h +++ b/src/imports/multimedia/qdeclarativemediabase_p.h diff --git a/src/plugins/qdeclarativemodules/multimedia/qdeclarativevideo.cpp b/src/imports/multimedia/qdeclarativevideo.cpp index 064f242..064f242 100644 --- a/src/plugins/qdeclarativemodules/multimedia/qdeclarativevideo.cpp +++ b/src/imports/multimedia/qdeclarativevideo.cpp diff --git a/src/plugins/qdeclarativemodules/multimedia/qdeclarativevideo_p.h b/src/imports/multimedia/qdeclarativevideo_p.h index fb13519..fb13519 100644 --- a/src/plugins/qdeclarativemodules/multimedia/qdeclarativevideo_p.h +++ b/src/imports/multimedia/qdeclarativevideo_p.h diff --git a/src/plugins/qdeclarativemodules/multimedia/qmetadatacontrolmetaobject.cpp b/src/imports/multimedia/qmetadatacontrolmetaobject.cpp index e90cbd6..e90cbd6 100644 --- a/src/plugins/qdeclarativemodules/multimedia/qmetadatacontrolmetaobject.cpp +++ b/src/imports/multimedia/qmetadatacontrolmetaobject.cpp diff --git a/src/plugins/qdeclarativemodules/multimedia/qmetadatacontrolmetaobject_p.h b/src/imports/multimedia/qmetadatacontrolmetaobject_p.h index c381f2d..c381f2d 100644 --- a/src/plugins/qdeclarativemodules/multimedia/qmetadatacontrolmetaobject_p.h +++ b/src/imports/multimedia/qmetadatacontrolmetaobject_p.h diff --git a/imports/Qt/multimedia/qmldir b/src/imports/multimedia/qmldir index 0e6f656..0e6f656 100644 --- a/imports/Qt/multimedia/qmldir +++ b/src/imports/multimedia/qmldir diff --git a/src/imports/qimportbase.pri b/src/imports/qimportbase.pri new file mode 100644 index 0000000..363dd88 --- /dev/null +++ b/src/imports/qimportbase.pri @@ -0,0 +1,33 @@ +TEMPLATE = lib +CONFIG += qt plugin + +win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release + +isEmpty(TARGETPATH) { + error("qimportbase.pri: You must provide a TARGETPATH!") +} +isEmpty(TARGET) { + error("qimportbase.pri: You must provide a TARGET!") +} + +QMLDIRFILE = $${_PRO_FILE_PWD_}/qmldir +copy2build.input = QMLDIRFILE +copy2build.output = $$TARGETPATH/qmldir +isEmpty(vcproj):copy2build.variable_out = PRE_TARGETDEPS +copy2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT} +copy2build.name = COPY ${QMAKE_FILE_IN} +copy2build.CONFIG += no_link +QMAKE_EXTRA_COMPILERS += copy2build + +TARGET = $$qtLibraryTarget($$TARGET) +contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols + +include(../../qt_targets.pri) + +wince*:LIBS += $$QMAKE_LIBS_GUI + +symbian: { + TARGET.EPOCALLOWDLLDATA=1 + TARGET.CAPABILITY = All -Tcb + load(armcc_warnings) +} diff --git a/tests/auto/declarative/qdeclarativewebview/testtypes.h b/src/imports/webkit/plugin.cpp index 8eb703f..799fe9e 100644 --- a/tests/auto/declarative/qdeclarativewebview/testtypes.h +++ b/src/imports/webkit/plugin.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the test suite of the Qt Toolkit. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -38,29 +38,30 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef TESTTYPES_H -#define TESTTYPES_H -#include <private/qdeclarativewebview_p.h> +#include <QtDeclarative/qdeclarativeextensionplugin.h> +#include <QtDeclarative/qdeclarative.h> -class MyWebView : public QDeclarativeWebView +#include "qdeclarativewebview_p.h" +#include "qdeclarativewebview_p_p.h" + +QT_BEGIN_NAMESPACE + +class WebKitQmlPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT - Q_PROPERTY(int pixelsPainted READ pixelsPainted); - public: - MyWebView() : pp(0) {} - - int pixelsPainted() const { return pp; } - - void drawContents(QPainter *p, const QRect &r); - -private: - int pp; + virtual void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == QLatin1String("org.webkit")); + QML_REGISTER_NOCREATE_TYPE(QDeclarativeWebSettings); + qmlRegisterType<QDeclarativeWebView>(uri,1,0,"WebView"); + } }; -QML_DECLARE_TYPE(MyWebView); +QT_END_NAMESPACE + +#include "plugin.moc" -void registerTypes(); +Q_EXPORT_PLUGIN2(webkitqmlplugin, QT_PREPEND_NAMESPACE(WebKitQmlPlugin)); -#endif // TESTTYPES_H diff --git a/src/declarative/graphicsitems/qdeclarativewebview.cpp b/src/imports/webkit/qdeclarativewebview.cpp index a2b16ba..d78ba28 100644 --- a/src/declarative/graphicsitems/qdeclarativewebview.cpp +++ b/src/imports/webkit/qdeclarativewebview.cpp @@ -42,11 +42,11 @@ #include "qdeclarativewebview_p.h" #include "qdeclarativewebview_p_p.h" -#include "qdeclarativepainteditem_p_p.h" +#include <private/qdeclarativepainteditem_p_p.h> #include <qdeclarative.h> #include <qdeclarativeengine.h> -#include <qdeclarativestate_p.h> +#include <private/qdeclarativestate_p.h> #include <QDebug> #include <QPen> @@ -61,7 +61,7 @@ #include <QtWebKit/QWebFrame> #include <QtWebKit/QWebElement> #include <QtWebKit/QWebSettings> -#include <qlistmodelinterface_p.h> +#include <private/qlistmodelinterface_p.h> QT_BEGIN_NAMESPACE @@ -128,6 +128,8 @@ public: usually laying out the web content to fit the preferredWidth. \qml + import org.webkit 1.0 + WebView { url: "http://www.nokia.com" width: 490 diff --git a/src/declarative/graphicsitems/qdeclarativewebview_p.h b/src/imports/webkit/qdeclarativewebview_p.h index a65aab3..145e74b 100644 --- a/src/declarative/graphicsitems/qdeclarativewebview_p.h +++ b/src/imports/webkit/qdeclarativewebview_p.h @@ -42,7 +42,9 @@ #ifndef QDECLARATIVEWEBVIEW_H #define QDECLARATIVEWEBVIEW_H -#include "qdeclarativepainteditem_p.h" +#include "webkitqmlplugin_export.h" + +#include <private/qdeclarativepainteditem_p.h> #include <QtGui/QAction> #include <QtCore/QUrl> @@ -57,11 +59,12 @@ class QWebSettings; QT_BEGIN_NAMESPACE QT_MODULE(Declarative) +class QDeclarativeWebSettings; class QDeclarativeWebViewPrivate; class QNetworkRequest; class QDeclarativeWebView; -class Q_DECLARATIVE_EXPORT QDeclarativeWebPage : public QWebPage +class WEBKITQMLPLUGIN_EXPORT QDeclarativeWebPage : public QWebPage { Q_OBJECT public: @@ -82,11 +85,10 @@ private: class QDeclarativeWebViewAttached; -class QDeclarativeWebSettings; //### TODO: browser plugins -class Q_DECLARATIVE_EXPORT QDeclarativeWebView : public QDeclarativePaintedItem +class WEBKITQMLPLUGIN_EXPORT QDeclarativeWebView : public QDeclarativePaintedItem { Q_OBJECT diff --git a/src/declarative/graphicsitems/qdeclarativewebview_p_p.h b/src/imports/webkit/qdeclarativewebview_p_p.h index 258b472..3ad9e9a 100644 --- a/src/declarative/graphicsitems/qdeclarativewebview_p_p.h +++ b/src/imports/webkit/qdeclarativewebview_p_p.h @@ -42,6 +42,8 @@ #ifndef QDECLARATIVEWEBVIEW_P_H #define QDECLARATIVEWEBVIEW_P_H +#include "webkitqmlplugin_export.h" + #include <qdeclarative.h> #include <QtWebKit/QWebPage> @@ -52,7 +54,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeWebSettings : public QObject { +class WEBKITQMLPLUGIN_EXPORT QDeclarativeWebSettings : public QObject { Q_OBJECT Q_PROPERTY(QString standardFontFamily READ standardFontFamily WRITE setStandardFontFamily) diff --git a/src/imports/webkit/qmldir b/src/imports/webkit/qmldir new file mode 100644 index 0000000..258aa2c --- /dev/null +++ b/src/imports/webkit/qmldir @@ -0,0 +1 @@ +plugin webkitqmlplugin diff --git a/src/imports/webkit/webkit.pro b/src/imports/webkit/webkit.pro new file mode 100644 index 0000000..76b46f1 --- /dev/null +++ b/src/imports/webkit/webkit.pro @@ -0,0 +1,19 @@ +TARGET = webkitqmlplugin +TARGETPATH = $$[QT_INSTALL_IMPORTS]/org/webkit +include(../qimportbase.pri) + +QT += webkit declarative +DEFINES += WEBKITQMLPLUGIN_EXPORTS + +SOURCES += qdeclarativewebview.cpp plugin.cpp +HEADERS += qdeclarativewebview_p.h \ + qdeclarativewebview_p_p.h \ + webkitqmlplugin_export.h + +QTDIR_build:DESTDIR = $$TARGETPATH +target.path = $$TARGETPATH + +qmldir.files += $$QT_BUILD_TREE/imports/org/webkit/qmldir +qmldir.path += $$TARGETPATH + +INSTALLS += target qmldir diff --git a/tests/auto/declarative/qdeclarativewebview/testtypes.cpp b/src/imports/webkit/webkitqmlplugin_export.h index 7efc214..974fd24 100644 --- a/tests/auto/declarative/qdeclarativewebview/testtypes.cpp +++ b/src/imports/webkit/webkitqmlplugin_export.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the test suite of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -38,15 +38,16 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "testtypes.h" -void MyWebView::drawContents(QPainter *p, const QRect &r) -{ - pp += r.width()*r.height(); - QDeclarativeWebView::drawContents(p,r); -} +#ifndef WEBKITQMLPLUGIN_EXPORT_H +#define WEBKITQMLPLUGIN_EXPORT_H -void registerTypes() -{ - QML_REGISTER_TYPE(Test,1,0,MyWebView,MyWebView); -} +#include <QtCore/QtGlobal> + +#if defined WEBKITQMLPLUGIN_EXPORTS +# define WEBKITQMLPLUGIN_EXPORT Q_DECL_EXPORT +#else +# define WEBKITQMLPLUGIN_EXPORT Q_DECL_IMPORT +#endif + +#endif // WEBKITQMLPLUGIN_EXPORT_H diff --git a/src/plugins/qdeclarativemodules/widgets/graphicslayouts.cpp b/src/imports/widgets/graphicslayouts.cpp index fc15ad2..fc15ad2 100644 --- a/src/plugins/qdeclarativemodules/widgets/graphicslayouts.cpp +++ b/src/imports/widgets/graphicslayouts.cpp diff --git a/src/plugins/qdeclarativemodules/widgets/graphicslayouts_p.h b/src/imports/widgets/graphicslayouts_p.h index f9b9ae8..f9b9ae8 100644 --- a/src/plugins/qdeclarativemodules/widgets/graphicslayouts_p.h +++ b/src/imports/widgets/graphicslayouts_p.h diff --git a/src/plugins/qdeclarativemodules/widgets/graphicswidgets.cpp b/src/imports/widgets/graphicswidgets.cpp index 062e516..062e516 100644 --- a/src/plugins/qdeclarativemodules/widgets/graphicswidgets.cpp +++ b/src/imports/widgets/graphicswidgets.cpp diff --git a/src/plugins/qdeclarativemodules/widgets/graphicswidgets_p.h b/src/imports/widgets/graphicswidgets_p.h index 2c2b707..2c2b707 100644 --- a/src/plugins/qdeclarativemodules/widgets/graphicswidgets_p.h +++ b/src/imports/widgets/graphicswidgets_p.h diff --git a/imports/Qt/widgets/qmldir b/src/imports/widgets/qmldir index 6f19878..6f19878 100644 --- a/imports/Qt/widgets/qmldir +++ b/src/imports/widgets/qmldir diff --git a/src/plugins/qdeclarativemodules/widgets/widgets.cpp b/src/imports/widgets/widgets.cpp index ec21cc4..ec21cc4 100644 --- a/src/plugins/qdeclarativemodules/widgets/widgets.cpp +++ b/src/imports/widgets/widgets.cpp diff --git a/src/plugins/qdeclarativemodules/widgets/widgets.pro b/src/imports/widgets/widgets.pro index 3ec38da..b98be59 100644 --- a/src/plugins/qdeclarativemodules/widgets/widgets.pro +++ b/src/imports/widgets/widgets.pro @@ -1,5 +1,6 @@ TARGET = widgets -include(../../qpluginbase.pri) +TARGETPATH = $$[QT_INSTALL_IMPORTS]/Qt/widgets +include(../qimportbase.pri) QT += declarative @@ -12,9 +13,10 @@ HEADERS += \ graphicslayouts_p.h QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/Qt/widgets -target.path = $$[QT_INSTALL_IMPORTS]/Qt/widgets +target.path = $$TARGETPATH -qmldir.files += $$QT_BUILD_TREE/imports/Qt/widgets/qmldir -qmldir.path += $$[QT_INSTALL_IMPORTS]/Qt/widgets +# install qmldir file +qmldir.files += qmldir +qmldir.path = $$TARGETPATH INSTALLS += target qmldir diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 418fd81..730fdc5 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -12,6 +12,5 @@ embedded:SUBDIRS *= gfxdrivers decorations mousedrivers kbddrivers symbian:SUBDIRS += s60 contains(QT_CONFIG, phonon): SUBDIRS *= phonon contains(QT_CONFIG, multimedia): SUBDIRS *= audio mediaservices -contains(QT_CONFIG, declarative): SUBDIRS *= qdeclarativemodules diff --git a/src/src.pro b/src/src.pro index ebfd44b..8c21ef7 100644 --- a/src/src.pro +++ b/src/src.pro @@ -29,6 +29,7 @@ contains(QT_CONFIG, scripttools): SRC_SUBDIRS += src_scripttools contains(QT_CONFIG, declarative): SRC_SUBDIRS += src_declarative contains(QT_CONFIG, multimedia): SRC_SUBDIRS += src_multimedia SRC_SUBDIRS += src_plugins +contains(QT_CONFIG, declarative): SRC_SUBDIRS += src_imports src_s60main.subdir = $$QT_SOURCE_TREE/src/s60main src_s60main.target = sub-s60main @@ -70,6 +71,8 @@ src_activeqt.subdir = $$QT_SOURCE_TREE/src/activeqt src_activeqt.target = sub-activeqt src_plugins.subdir = $$QT_SOURCE_TREE/src/plugins src_plugins.target = sub-plugins +src_imports.subdir = $$QT_SOURCE_TREE/src/imports +src_imports.target = sub-imports src_testlib.subdir = $$QT_SOURCE_TREE/src/testlib src_testlib.target = sub-testlib src_javascriptcore.subdir = $$QT_SOURCE_TREE/src/3rdparty/webkit/JavaScriptCore @@ -103,11 +106,13 @@ src_declarative.target = sub-declarative src_tools_activeqt.depends = src_tools_idc src_gui src_declarative.depends = src_xml src_gui src_script src_network src_svg src_plugins.depends = src_gui src_sql src_svg src_multimedia + src_imports.depends = src_gui src_declarative contains(QT_CONFIG, webkit) { src_webkit.depends = src_gui src_sql src_network src_xml contains(QT_CONFIG, phonon):src_webkit.depends += src_phonon contains(QT_CONFIG, xmlpatterns): src_webkit.depends += src_xmlpatterns contains(QT_CONFIG, declarative):src_declarative.depends += src_webkit + src_imports.depends += webkit #exists($$QT_SOURCE_TREE/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro): src_webkit.depends += src_javascriptcore } contains(QT_CONFIG, qt3support): src_plugins.depends += src_qt3support diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 42ff523..99a32d9 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -7,6 +7,7 @@ SUBDIRS += \ qdeclarativeanimations \ # Cover qdeclarativebehaviors \ # Cover qdeclarativebinding \ # Cover + qdeclarativecomponent \ # Cover qdeclarativeconnection \ # Cover qdeclarativecontext \ # Cover qdeclarativedatetimeformatter \ # Cover @@ -55,6 +56,8 @@ SUBDIRS += \ qdeclarativexmllistmodel \ # Cover qpacketprotocol \ # Cover qdeclarativerepeater \ # Cover + qdeclarativeworkerscript \ # Cover + qdeclarativeworkerlistmodel \ # Cover qdeclarativevaluetypes \ # Cover qdeclarativexmlhttprequest \ # Cover qdeclarativeimageprovider \ # Cover diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp index 6160e7c..106a4e0 100644 --- a/tests/auto/declarative/examples/tst_examples.cpp +++ b/tests/auto/declarative/examples/tst_examples.cpp @@ -190,7 +190,6 @@ void tst_examples::examples() << "-scriptopts" << "play,testerror,exitoncomplete,exitonfailure" << file; QProcess p; -qDebug() << qmlruntime << arguments; p.start(qmlruntime, arguments); QVERIFY(p.waitForFinished()); QCOMPARE(p.exitStatus(), QProcess::NormalExit); diff --git a/tests/auto/declarative/qdeclarativeanimations/data/badtype1.qml b/tests/auto/declarative/qdeclarativeanimations/data/badtype1.qml index 6381df3..2629cf4 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/badtype1.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/badtype1.qml @@ -7,6 +7,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: PropertyAnimation { from: "blue"; to: "green"; } + PropertyAnimation on x { from: "blue"; to: "green"; } } } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/badtype2.qml b/tests/auto/declarative/qdeclarativeanimations/data/badtype2.qml index 8d57e41..1543a2a 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/badtype2.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/badtype2.qml @@ -7,6 +7,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { from: "blue"; to: "green"; } + NumberAnimation on x { from: "blue"; to: "green"; } } } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/badtype3.qml b/tests/auto/declarative/qdeclarativeanimations/data/badtype3.qml index c4867c3..aa98c33 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/badtype3.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/badtype3.qml @@ -5,7 +5,7 @@ Rectangle { height: 320 Rectangle { color: "red" - color: ColorAnimation { from: 10; to: 15; } + ColorAnimation on color { from: 10; to: 15; } width: 50; height: 50 x: 100; y: 100 } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml b/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml index d9660b6..3f00e68 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml @@ -9,7 +9,7 @@ Rectangle { id: redRect width: 100; height: 100 color: Qt.rgba(1,0,0) - x: Behavior { + Behavior on x { NumberAnimation { objectName: "MyAnim"; target: redRect; property: "y"; to: 300; repeat: true} } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/dontStart.qml b/tests/auto/declarative/qdeclarativeanimations/data/dontStart.qml index 36417db..efed058 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/dontStart.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/dontStart.qml @@ -9,7 +9,7 @@ Rectangle { id: redRect width: 100; height: 100 color: Qt.rgba(1,0,0) - x: SequentialAnimation { + SequentialAnimation on x { running: false NumberAnimation { objectName: "MyAnim"; running: true } } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/properties.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties.qml index 7e73f57..4437815 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/properties.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/properties.qml @@ -9,6 +9,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { to: 200 } + NumberAnimation on x { to: 200 } } } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/properties2.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties2.qml index 6c96155..b1f2020 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/properties2.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/properties2.qml @@ -9,6 +9,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { targets: theRect; properties: "x"; to: 200; } + NumberAnimation on x { targets: theRect; properties: "x"; to: 200; } } } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/properties3.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties3.qml index ff08885..0a0ed6f 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/properties3.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/properties3.qml @@ -9,6 +9,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { target: theRect; property: "x"; to: 300; } + NumberAnimation on x { target: theRect; property: "x"; to: 300; } } } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/properties4.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties4.qml index dab7e5f..a90f004 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/properties4.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/properties4.qml @@ -9,6 +9,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { target: theRect; property: "y"; to: 200; } + NumberAnimation on x { target: theRect; property: "y"; to: 200; } } } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/properties5.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties5.qml index 38396b1..7d3cec9 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/properties5.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/properties5.qml @@ -9,6 +9,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { targets: theRect; properties: "y"; to: 200; } + NumberAnimation on x { targets: theRect; properties: "y"; to: 200; } } } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/valuesource.qml b/tests/auto/declarative/qdeclarativeanimations/data/valuesource.qml index c35063d..2260440 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/valuesource.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/valuesource.qml @@ -9,6 +9,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { id: anim; objectName: "MyAnim"; to: 200 } + NumberAnimation on x { id: anim; objectName: "MyAnim"; to: 200 } } } diff --git a/tests/auto/declarative/qdeclarativeanimations/data/valuesource2.qml b/tests/auto/declarative/qdeclarativeanimations/data/valuesource2.qml index 1a60542..36d6c72 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/valuesource2.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/valuesource2.qml @@ -9,6 +9,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { id: anim; objectName: "MyAnim"; running: false; to: 200 } + NumberAnimation on x { id: anim; objectName: "MyAnim"; running: false; to: 200 } } } diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp index 53c63b5..f5e15fb 100644 --- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp @@ -217,21 +217,21 @@ void tst_qdeclarativeanimations::resume() animation.setProperty("x"); animation.setFrom(10); animation.setTo(200); - animation.setDuration(500); + animation.setDuration(1000); QVERIFY(animation.from() == 10); animation.start(); - QTest::qWait(100); + QTest::qWait(400); animation.pause(); qreal x = rect.x(); - QVERIFY(x != qreal(200)); + QVERIFY(x != qreal(200) && x != qreal(10)); QVERIFY(animation.isRunning()); QVERIFY(animation.isPaused()); animation.resume(); QVERIFY(animation.isRunning()); QVERIFY(!animation.isPaused()); - QTest::qWait(100); + QTest::qWait(400); animation.stop(); QVERIFY(rect.x() > x); } diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml b/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml index 201da37..e982f21 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml @@ -9,7 +9,7 @@ Rectangle { objectName: "MyRect" width: 100; height: 100; color: "green" x: basex - x: Behavior { NumberAnimation { duration: 500; } } + Behavior on x { NumberAnimation { duration: 500; } } } MouseArea { id: clicker diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/color.qml b/tests/auto/declarative/qdeclarativebehaviors/data/color.qml index 91dbbd1..f2f4742 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/color.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/color.qml @@ -7,7 +7,7 @@ Rectangle { objectName: "MyRect" width: 100; height: 100; color: "green" - color: Behavior { ColorAnimation { duration: 500; } } + Behavior on color { ColorAnimation { duration: 500; } } } MouseArea { id: clicker diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/cpptrigger.qml b/tests/auto/declarative/qdeclarativebehaviors/data/cpptrigger.qml index 8d032f0..3ea9376 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/cpptrigger.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/cpptrigger.qml @@ -6,6 +6,6 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior { NumberAnimation { duration: 500; } } + Behavior on x { NumberAnimation { duration: 500; } } } } diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/disabled.qml b/tests/auto/declarative/qdeclarativebehaviors/data/disabled.qml index 3c7078a..1403eb9 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/disabled.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/disabled.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior { + Behavior on x { objectName: "MyBehavior"; enabled: false NumberAnimation { duration: 200; } diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml b/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml index ba7cc9c..12b1b7b 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml @@ -9,7 +9,7 @@ Rectangle { id: redRect width: 100; height: 100 color: Qt.rgba(1,0,0) - x: Behavior { + Behavior on x { NumberAnimation { objectName: "MyAnim"; running: true } } diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/empty.qml b/tests/auto/declarative/qdeclarativebehaviors/data/empty.qml index 95d934a..5e30f03 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/empty.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/empty.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior {} + Behavior on x {} } MouseArea { id: clicker diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/explicit.qml b/tests/auto/declarative/qdeclarativebehaviors/data/explicit.qml index 1b2025a..ca0ea54 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/explicit.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/explicit.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior { + Behavior on x { objectName: "MyBehavior"; NumberAnimation { target: rect; property: "x"; duration: 500; } } diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty.qml b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty.qml index 14883d4..a6c4ed9 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - pos: Behavior { PropertyAnimation { duration: 500; } } + Behavior on pos { PropertyAnimation { duration: 500; } } } MouseArea { id: clicker diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty2.qml b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty2.qml index b43ddbc..2dda220 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty2.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty2.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - pos.x: Behavior { NumberAnimation { duration: 500; } } + Behavior on pos.x { NumberAnimation { duration: 500; } } } MouseArea { id: clicker diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/loop.qml b/tests/auto/declarative/qdeclarativebehaviors/data/loop.qml index 5f2c057..6187768 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/loop.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/loop.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior { NumberAnimation { duration: 200; } } + Behavior on x { NumberAnimation { duration: 200; } } onXChanged: x = 100; } states: State { diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/nonSelecting2.qml b/tests/auto/declarative/qdeclarativebehaviors/data/nonSelecting2.qml index f267a05..640a7d1 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/nonSelecting2.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/nonSelecting2.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior { + Behavior on x { objectName: "MyBehavior"; NumberAnimation { targets: rect; properties: "y"; duration: 200; } } diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/parent.qml b/tests/auto/declarative/qdeclarativebehaviors/data/parent.qml index 7c7fdcb..3860ec7 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/parent.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/parent.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - parent: Behavior { + Behavior on parent { SequentialAnimation { PauseAnimation { duration: 500 } PropertyAction {} diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml b/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml index ba744b1..6419a6b 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior { + Behavior on x { objectName: "MyBehavior" NumberAnimation { duration: 200 } NumberAnimation { duration: 1000 } diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml b/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml index a91ca88..b22441a 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml @@ -11,6 +11,6 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior { NumberAnimation { duration: 500; } } + Behavior on x { NumberAnimation { duration: 500; } } } } diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml b/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml index ac98ed0..c28fa9a 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - x: Behavior { + Behavior on x { objectName: "MyBehavior"; NumberAnimation { duration: 500; } } diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index f87330d..0bf0b81 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -260,7 +260,7 @@ void tst_qdeclarativebehaviors::reassignedAnimation() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml")); - QTest::ignoreMessage(QtWarningMsg, QString("QML Behavior (" + QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:12) Cannot change the animation assigned to a Behavior.").toUtf8().constData()); + QTest::ignoreMessage(QtWarningMsg, QString("QML Behavior (" + QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:9) Cannot change the animation assigned to a Behavior.").toUtf8().constData()); QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create()); QVERIFY(rect); QCOMPARE(qobject_cast<QDeclarativeNumberAnimation*>( diff --git a/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro b/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro new file mode 100644 index 0000000..c7affb7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro @@ -0,0 +1,8 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +QT += script network +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativecomponent.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp new file mode 100644 index 0000000..c9e304c --- /dev/null +++ b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <qtest.h> + +#include <QtDeclarative/qdeclarativeengine.h> +#include <QtDeclarative/qdeclarativecomponent.h> + +class tst_qdeclarativecomponent : public QObject +{ + Q_OBJECT +public: + tst_qdeclarativecomponent() { } + +private slots: + void loadEmptyUrl(); + +private: + QDeclarativeEngine engine; +}; + +void tst_qdeclarativecomponent::loadEmptyUrl() +{ + QDeclarativeComponent c(&engine); + c.loadUrl(QUrl()); + + QVERIFY(c.isError()); + QCOMPARE(c.errors().count(), 1); + QDeclarativeError error = c.errors().first(); + QCOMPARE(error.url(), QUrl()); + QCOMPARE(error.line(), -1); + QCOMPARE(error.column(), -1); + QCOMPARE(error.description(), QLatin1String("Invalid empty URL")); +} + +QTEST_MAIN(tst_qdeclarativecomponent) + +#include "tst_qdeclarativecomponent.moc" diff --git a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp index 5f03989..f0117f5 100644 --- a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp +++ b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp @@ -60,6 +60,7 @@ private slots: void setContextProperty(); void addDefaultObject(); void destruction(); + void idAsContextProperty(); private: QDeclarativeEngine engine; @@ -429,6 +430,25 @@ void tst_qdeclarativecontext::destruction() QCOMPARE(ctxt, expr.context()); } +void tst_qdeclarativecontext::idAsContextProperty() +{ + QDeclarativeComponent component(&engine); + component.setData("import Qt 4.6; QtObject { property var a; a: QtObject { id: myObject } }", QUrl()); + + QObject *obj = component.create(); + QVERIFY(obj); + + QVariant a = obj->property("a"); + QVERIFY(a.userType() == QMetaType::QObjectStar); + + QVariant ctxt = qmlContext(obj)->contextProperty("myObject"); + QVERIFY(ctxt.userType() == QMetaType::QObjectStar); + + QVERIFY(a == ctxt); + + delete obj; +} + QTEST_MAIN(tst_qdeclarativecontext) #include "tst_qdeclarativecontext.moc" diff --git a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp index 9543280..6cd0bdb 100644 --- a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp +++ b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp @@ -274,7 +274,7 @@ void tst_qdeclarativedom::loadComposite() void tst_qdeclarativedom::testValueSource() { QByteArray qml = "import Qt 4.6\n" - "Rectangle { height: SpringFollow { spring: 1.4; damping: .15; source: Math.min(Math.max(-130, value*2.2 - 130), 133); }}"; + "Rectangle { SpringFollow on height { spring: 1.4; damping: .15; source: Math.min(Math.max(-130, value*2.2 - 130), 133); }}"; QDeclarativeEngine freshEngine; QDeclarativeDomDocument document; @@ -306,7 +306,7 @@ void tst_qdeclarativedom::testValueSource() void tst_qdeclarativedom::testValueInterceptor() { QByteArray qml = "import Qt 4.6\n" - "Rectangle { height: Behavior { NumberAnimation { duration: 100 } } }"; + "Rectangle { Behavior on height { NumberAnimation { duration: 100 } } }"; QDeclarativeEngine freshEngine; QDeclarativeDomDocument document; @@ -823,8 +823,8 @@ void tst_qdeclarativedom::copy() " property int a: 10\n" " x: 10\n" " y: x + 10\n" - " z: NumberAnimation {}\n" - " opacity: Behavior {}\n" + " NumberAnimation on z {}\n" + " Behavior on opacity {}\n" " Component {\n" " Item{}\n" " }\n" @@ -1193,18 +1193,18 @@ void tst_qdeclarativedom::copy() void tst_qdeclarativedom::position() { QByteArray qml = "import Qt 4.6\n" - /*14*/ "Item {\n" - /*21*/ " id: myItem\n" - /*36*/ " property int a: 10\n" - /*59*/ " x: 10\n" - /*69*/ " y: x + 10\n" - /*83*/ " z: NumberAnimation {}\n" - /*109*/ " opacity: Behavior {}\n" - /*134*/ " Component {\n" - /*150*/ " Item{}\n" - /*165*/ " }\n" - /*171*/ " children: [ Item{}, Item{} ]\n" - /*204*/ "}\n"; + "Item {\n" + " id: myItem\n" + " property int a: 10\n" + " x: 10\n" + " y: x + 10\n" + " NumberAnimation on z {}\n" + " Behavior on opacity {}\n" + " Component {\n" + " Item{}\n" + " }\n" + " children: [ Item{}, Item{} ]\n" + "}\n"; QDeclarativeDomDocument document; @@ -1227,19 +1227,19 @@ void tst_qdeclarativedom::position() QCOMPARE(y.length(), 1); QDeclarativeDomProperty z = root.property("z"); - QCOMPARE(z.position(), 87); + QCOMPARE(z.position(), 106); QCOMPARE(z.length(), 1); QDeclarativeDomProperty opacity = root.property("opacity"); - QCOMPARE(opacity.position(), 113); + QCOMPARE(opacity.position(), 127); QCOMPARE(opacity.length(), 7); QDeclarativeDomProperty data = root.property("data"); - QCOMPARE(data.position(), 138); + QCOMPARE(data.position(), 142); QCOMPARE(data.length(), 0); QDeclarativeDomProperty children = root.property("children"); - QCOMPARE(children.position(), 175); + QCOMPARE(children.position(), 179); QCOMPARE(children.length(), 8); QDeclarativeDomList dataList = data.value().toList(); @@ -1249,30 +1249,30 @@ void tst_qdeclarativedom::position() // All QDeclarativeDomObject QCOMPARE(root.position(), 14); - QCOMPARE(root.length(), 191); + QCOMPARE(root.length(), 195); QDeclarativeDomObject numberAnimation = z.value().toValueSource().object(); - QCOMPARE(numberAnimation.position(), 90); - QCOMPARE(numberAnimation.length(), 18); + QCOMPARE(numberAnimation.position(), 87); + QCOMPARE(numberAnimation.length(), 23); QDeclarativeDomObject behavior = opacity.value().toValueInterceptor().object(); - QCOMPARE(behavior.position(), 122); - QCOMPARE(behavior.length(), 11); + QCOMPARE(behavior.position(), 115); + QCOMPARE(behavior.length(), 22); QDeclarativeDomObject component = dataList.values().at(0).toObject(); - QCOMPARE(component.position(), 138); + QCOMPARE(component.position(), 142); QCOMPARE(component.length(), 32); QDeclarativeDomObject componentRoot = component.toComponent().componentRoot(); - QCOMPARE(componentRoot.position(), 158); + QCOMPARE(componentRoot.position(), 162); QCOMPARE(componentRoot.length(), 6); QDeclarativeDomObject child1 = childrenList.values().at(0).toObject(); - QCOMPARE(child1.position(), 187); + QCOMPARE(child1.position(), 191); QCOMPARE(child1.length(), 6); QDeclarativeDomObject child2 = childrenList.values().at(1).toObject(); - QCOMPARE(child2.position(), 195); + QCOMPARE(child2.position(), 199); QCOMPARE(child2.length(), 6); // All QDeclarativeDomValue @@ -1285,23 +1285,23 @@ void tst_qdeclarativedom::position() QCOMPARE(yValue.length(), 6); QDeclarativeDomValue zValue = z.value(); - QCOMPARE(zValue.position(), 90); - QCOMPARE(zValue.length(), 18); + QCOMPARE(zValue.position(), 87); + QCOMPARE(zValue.length(), 23); QDeclarativeDomValue opacityValue = opacity.value(); - QCOMPARE(opacityValue.position(), 122); - QCOMPARE(opacityValue.length(), 11); + QCOMPARE(opacityValue.position(), 115); + QCOMPARE(opacityValue.length(), 22); QDeclarativeDomValue dataValue = data.value(); - QCOMPARE(dataValue.position(), 138); + QCOMPARE(dataValue.position(), 142); QCOMPARE(dataValue.length(), 32); QDeclarativeDomValue child1Value = childrenList.values().at(0); - QCOMPARE(child1Value.position(), 187); + QCOMPARE(child1Value.position(), 191); QCOMPARE(child1Value.length(), 6); QDeclarativeDomValue child2Value = childrenList.values().at(1); - QCOMPARE(child2Value.position(), 195); + QCOMPARE(child2Value.position(), 199); QCOMPARE(child2Value.length(), 6); // All QDeclarativeDomList diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml b/tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml new file mode 100644 index 0000000..4b5464d --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml @@ -0,0 +1,9 @@ +import Qt 4.6 +import Qt.test 1.0 + +QtObject { + property int value: 9 + property int value2 + + MyQmlObject.onMySignal: value2 = value +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml b/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml index 3d45b15..5ba324a 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml @@ -1,7 +1,7 @@ import Qt 4.6 Item { - property alias x: item.x + property alias blah: item.x Item { id: item } function testFunction() { return 9; } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml new file mode 100644 index 0000000..4ad7f34 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml @@ -0,0 +1,13 @@ +import Qt 4.6 + +Item { + id: root + + property int foo: 12 + property int console: 11 + + property bool test1: foo == 12 + property bool test2: console != 11 + property bool test3: root.console == 11 +} + diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.4.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scope.4.qml new file mode 100644 index 0000000..d65b6e7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scope.4.qml @@ -0,0 +1,12 @@ +import Qt.test 1.0 + +MyQmlObject { + id: a + property int b: 9 + + property int test + property string test2 + + // Should resolve to signal arguments, not to other elements in the file + onArgumentSignal: { test = a; test2 = b; } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.1.qml new file mode 100644 index 0000000..9b11fa9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.1.qml @@ -0,0 +1,13 @@ +import Qt.test 1.0 + +MyQmlObject { + property string result + + Script{ + function f() { + result = b + } + + } + onArgumentSignal: f() +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.2.qml new file mode 100644 index 0000000..ec727e2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.2.qml @@ -0,0 +1,11 @@ +import Qt.test 1.0 + +MyQmlObject { + property string result + property string aProp: "hello" + + Script{ + source: "scriptScope.js" + } + onBasicSignal: f() +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.js b/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.js new file mode 100644 index 0000000..5689930 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptScope.js @@ -0,0 +1,5 @@ +var aProp = "world"; + +function f() { + result = aProp; +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index 8fbd071..a283e3f 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -60,10 +60,21 @@ class MyQmlAttachedObject : public QObject { Q_OBJECT Q_PROPERTY(int value READ value CONSTANT) + Q_PROPERTY(int value2 READ value2 WRITE setValue2) public: - MyQmlAttachedObject(QObject *parent) : QObject(parent) {} + MyQmlAttachedObject(QObject *parent) : QObject(parent), m_value2(0) {} int value() const { return 19; } + int value2() const { return m_value2; } + void setValue2(int v) { m_value2 = v; } + + void emitMySignal() { emit mySignal(); } + +signals: + void mySignal(); + +private: + int m_value2; }; class MyQmlObject : public QObject diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 60c380c..b5649cb 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -122,6 +122,8 @@ private slots: void listToVariant(); void multiEngineObject(); void deletedObject(); + void scriptScope(); + void attachedPropertyScope(); void bug1(); @@ -728,6 +730,33 @@ void tst_qdeclarativeecmascript::scope() QCOMPARE(object->property("test5").toInt(), 24); QCOMPARE(object->property("test6").toInt(), 24); } + + { + QDeclarativeComponent component(&engine, TEST_FILE("scope.3.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toBool(), true); + QCOMPARE(object->property("test2").toBool(), true); + QCOMPARE(object->property("test3").toBool(), true); + } + + // Signal argument scope + { + QDeclarativeComponent component(&engine, TEST_FILE("scope.4.qml")); + MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toInt(), 0); + QCOMPARE(object->property("test2").toString(), QString()); + + emit object->argumentSignal(13, "Argument Scope", 9); + + QCOMPARE(object->property("test").toInt(), 13); + QCOMPARE(object->property("test2").toString(), QString("Argument Scope")); + + delete object; + } } /* @@ -1657,6 +1686,51 @@ void tst_qdeclarativeecmascript::deletedObject() delete object; } +void tst_qdeclarativeecmascript::scriptScope() +{ + { + QDeclarativeComponent component(&engine, TEST_FILE("scriptScope.1.qml")); + + MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); + QVERIFY(object != 0); + emit object->argumentSignal(19, "Hello world!", 10.3); + QCOMPARE(object->property("result").toString(), QString()); + + delete object; + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("scriptScope.2.qml")); + + MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); + QVERIFY(object != 0); + emit object->basicSignal(); + QCOMPARE(object->property("result").toString(), QLatin1String("world")); + + delete object; + } +} + +void tst_qdeclarativeecmascript::attachedPropertyScope() +{ + QDeclarativeComponent component(&engine, TEST_FILE("attachedPropertyScope.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + MyQmlAttachedObject *attached = + qobject_cast<MyQmlAttachedObject *>(qmlAttachedPropertiesObject<MyQmlObject>(object)); + QVERIFY(attached != 0); + + QCOMPARE(object->property("value2").toInt(), 0); + + attached->emitMySignal(); + + QCOMPARE(object->property("value2").toInt(), 9); + + delete object; +} + QTEST_MAIN(tst_qdeclarativeecmascript) #include "tst_qdeclarativeecmascript.moc" diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview.qml index 344b4b5..ba6b807 100644 --- a/tests/auto/declarative/qdeclarativegridview/data/gridview.qml +++ b/tests/auto/declarative/qdeclarativegridview/data/gridview.qml @@ -1,6 +1,10 @@ import Qt 4.6 Rectangle { + id: root + property int added: -1 + property var removed + width: 240 height: 320 color: "#ffffff" @@ -33,6 +37,8 @@ Rectangle { text: number } color: GridView.isCurrentItem ? "lightsteelblue" : "white" + GridView.onAdd: root.added = index + GridView.onRemove: root.removed = name } } ] diff --git a/tests/auto/declarative/qdeclarativegridview/data/propertychanges.qml b/tests/auto/declarative/qdeclarativegridview/data/propertychanges.qml new file mode 100644 index 0000000..da2e8d0 --- /dev/null +++ b/tests/auto/declarative/qdeclarativegridview/data/propertychanges.qml @@ -0,0 +1,69 @@ +import Qt 4.6 + +Rectangle { + width: 360; height: 120; color: "white" + Component { + id: delegate + Item { + id: wrapper + width: 180; height: 40; + Column { + x: 5; y: 5 + Text { text: '<b>Name:</b> ' + name } + Text { text: '<b>Number:</b> ' + number } + } + } + } + Component { + id: highlightRed + Rectangle { + color: "red" + radius: 10 + opacity: 0.5 + } + } + GridView { + cellWidth:180 + cellHeight:40 + objectName: "gridView" + anchors.fill: parent + model: listModel + delegate: delegate + highlight: highlightRed + focus: true + keyNavigationWraps: true + cacheBuffer: 10 + flow: GridView.LeftToRight + } + + data:[ + ListModel { + id: listModel + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + }, + ListModel { + objectName: "alternateModel" + ListElement { + name: "Jack" + number: "555 8426" + } + ListElement { + name: "Mary" + number: "555 3264" + } + } + ] +} + +
\ No newline at end of file diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index 2a60fee..7ade309 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -39,16 +39,17 @@ ** ****************************************************************************/ -#include <qdeclarativeengine.h> -#include <qdeclarativecomponent.h> -#include <QStringListModel> #include <QtTest/QtTest> -#include <private/qlistmodelinterface_p.h> -#include <qdeclarativeview.h> -#include <private/qdeclarativegridview_p.h> -#include <private/qdeclarativetext_p.h> -#include <qdeclarativecontext.h> -#include <qdeclarativeexpression.h> +#include <QtGui/qstringlistmodel.h> +#include <QtDeclarative/qdeclarativeview.h> +#include <QtDeclarative/qdeclarativeengine.h> +#include <QtDeclarative/qdeclarativecomponent.h> +#include <QtDeclarative/qdeclarativecontext.h> +#include <QtDeclarative/qdeclarativeexpression.h> +#include <QtDeclarative/private/qlistmodelinterface_p.h> +#include <QtDeclarative/private/qdeclarativegridview_p.h> +#include <QtDeclarative/private/qdeclarativetext_p.h> +#include <QtDeclarative/private/qdeclarativelistmodel_p.h> class tst_QDeclarativeGridView : public QObject { @@ -66,6 +67,9 @@ private slots: void currentIndex(); void defaultValues(); void properties(); + void propertyChanges(); + void componentChanges(); + void modelChanges(); void positionViewAtIndex(); void resetModel(); void QTBUG_8456(); @@ -91,7 +95,7 @@ public: setRoleNames(roles); } - int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); } + int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); } QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const { QVariant rv; if (role == Name) @@ -253,7 +257,7 @@ void tst_QDeclarativeGridView::inserted() model.insertItem(1, "Will", "9876"); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item @@ -264,6 +268,10 @@ void tst_QDeclarativeGridView::inserted() QVERIFY(number != 0); QCOMPARE(number->text(), model.number(1)); + // Checks that onAdd is called + int added = canvas->rootObject()->property("added").toInt(); + QCOMPARE(added, 1); + // Confirm items positioned correctly for (int i = 0; i < model.count(); ++i) { QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i); @@ -274,7 +282,7 @@ void tst_QDeclarativeGridView::inserted() model.insertItem(0, "Foo", "1111"); // zero index, and current item // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item @@ -296,14 +304,14 @@ void tst_QDeclarativeGridView::inserted() for (int i = model.count(); i < 30; ++i) model.insertItem(i, "Hello", QString::number(i)); - QTest::qWait(300); + QTest::qWait(100); gridview->setContentY(120); - QTest::qWait(300); + QTest::qWait(100); // Insert item outside visible area model.insertItem(1, "Hello", "1324"); - QTest::qWait(300); + QTest::qWait(100); QVERIFY(gridview->contentY() == 120); @@ -334,7 +342,7 @@ void tst_QDeclarativeGridView::removed() model.removeItem(1); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1); QVERIFY(name != 0); @@ -343,6 +351,10 @@ void tst_QDeclarativeGridView::removed() QVERIFY(number != 0); QCOMPARE(number->text(), model.number(1)); + // Checks that onRemove is called + QString removed = canvas->rootObject()->property("removed").toString(); + QCOMPARE(removed, QString("Item1")); + // Confirm items positioned correctly int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); for (int i = 0; i < model.count() && i < itemCount; ++i) { @@ -357,7 +369,7 @@ void tst_QDeclarativeGridView::removed() model.removeItem(0); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); name = findItem<QDeclarativeText>(viewport, "textName", 0); QVERIFY(name != 0); @@ -379,7 +391,7 @@ void tst_QDeclarativeGridView::removed() // Remove items not visible model.removeItem(25); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); // Confirm items positioned correctly itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); @@ -393,11 +405,11 @@ void tst_QDeclarativeGridView::removed() // Remove items before visible gridview->setContentY(120); - QTest::qWait(500); + QTest::qWait(100); gridview->setCurrentIndex(10); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); // Setting currentIndex above shouldn't cause view to scroll QCOMPARE(gridview->contentY(), 120.0); @@ -405,7 +417,7 @@ void tst_QDeclarativeGridView::removed() model.removeItem(1); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); // Confirm items positioned correctly for (int i = 6; i < 18; ++i) { @@ -419,14 +431,14 @@ void tst_QDeclarativeGridView::removed() // Remove currentIndex QDeclarativeItem *oldCurrent = gridview->currentItem(); model.removeItem(9); - QTest::qWait(500); + QTest::qWait(100); QCOMPARE(gridview->currentIndex(), 9); QVERIFY(gridview->currentItem() != oldCurrent); gridview->setContentY(0); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); // Confirm items positioned correctly itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); @@ -440,7 +452,7 @@ void tst_QDeclarativeGridView::removed() // remove item outside current view. gridview->setCurrentIndex(32); - QTest::qWait(500); + QTest::qWait(100); gridview->setContentY(240); model.removeItem(30); @@ -448,21 +460,21 @@ void tst_QDeclarativeGridView::removed() // remove current item beyond visible items. gridview->setCurrentIndex(20); - QTest::qWait(500); + QTest::qWait(100); gridview->setContentY(0); model.removeItem(20); - QTest::qWait(500); + QTest::qWait(100); QCOMPARE(gridview->currentIndex(), 20); QVERIFY(gridview->currentItem() != 0); // remove item before current, but visible gridview->setCurrentIndex(8); - QTest::qWait(500); + QTest::qWait(100); gridview->setContentY(240); oldCurrent = gridview->currentItem(); model.removeItem(6); - QTest::qWait(500); + QTest::qWait(100); QCOMPARE(gridview->currentIndex(), 7); QVERIFY(gridview->currentItem() == oldCurrent); @@ -494,7 +506,7 @@ void tst_QDeclarativeGridView::moved() model.moveItem(1, 8); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1); QVERIFY(name != 0); @@ -526,7 +538,7 @@ void tst_QDeclarativeGridView::moved() model.moveItem(1, 25); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); // Confirm items positioned correctly and indexes correct itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count()-1; @@ -548,7 +560,7 @@ void tst_QDeclarativeGridView::moved() model.moveItem(28, 8); // let transitions settle. - QTest::qWait(300); + QTest::qWait(100); // Confirm items positioned correctly and indexes correct for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) { @@ -591,7 +603,7 @@ void tst_QDeclarativeGridView::currentIndex() QDeclarativeItem *viewport = gridview->viewport(); QVERIFY(viewport != 0); - QTest::qWait(500); + QTest::qWait(300); // current item should be third item QCOMPARE(gridview->currentIndex(), 5); @@ -618,7 +630,7 @@ void tst_QDeclarativeGridView::currentIndex() QCOMPARE(gridview->currentIndex(), 0); gridview->setCurrentIndex(model.count()-1); - QTest::qWait(500); + QTest::qWait(100); QCOMPARE(gridview->currentIndex(), model.count()-1); gridview->moveCurrentIndexRight(); @@ -677,8 +689,6 @@ void tst_QDeclarativeGridView::currentIndex() // turn off auto highlight gridview->setHighlightFollowsCurrentItem(false); QVERIFY(gridview->highlightFollowsCurrentItem() == false); - - QTest::qWait(500); QVERIFY(gridview->highlightItem()); qreal hlPosX = gridview->highlightItem()->x(); qreal hlPosY = gridview->highlightItem()->y(); @@ -729,7 +739,7 @@ void tst_QDeclarativeGridView::changeFlow() } ctxt->setContextProperty("testTopToBottom", QVariant(true)); - QTest::qWait(500); + QTest::qWait(100); // Confirm items positioned correctly and indexes correct itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count(); @@ -796,6 +806,107 @@ void tst_QDeclarativeGridView::properties() delete obj; } +void tst_QDeclarativeGridView::propertyChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativeGridView *gridView = canvas->rootObject()->findChild<QDeclarativeGridView*>("gridView"); + QVERIFY(gridView); + + QSignalSpy keyNavigationWrapsSpy(gridView, SIGNAL(keyNavigationWrapsChanged())); + QSignalSpy cacheBufferSpy(gridView, SIGNAL(cacheBufferChanged())); + QSignalSpy flowSpy(gridView, SIGNAL(flowChanged())); + + QCOMPARE(gridView->isWrapEnabled(), true); + QCOMPARE(gridView->cacheBuffer(), 10); + QCOMPARE(gridView->flow(), QDeclarativeGridView::LeftToRight); + + gridView->setWrapEnabled(false); + gridView->setCacheBuffer(3); + gridView->setFlow(QDeclarativeGridView::TopToBottom); + + QCOMPARE(gridView->isWrapEnabled(), false); + QCOMPARE(gridView->cacheBuffer(), 3); + QCOMPARE(gridView->flow(), QDeclarativeGridView::TopToBottom); + + QCOMPARE(keyNavigationWrapsSpy.count(),1); + QCOMPARE(cacheBufferSpy.count(),1); + QCOMPARE(flowSpy.count(),1); + + gridView->setWrapEnabled(false); + gridView->setCacheBuffer(3); + gridView->setFlow(QDeclarativeGridView::TopToBottom); + + QCOMPARE(keyNavigationWrapsSpy.count(),1); + QCOMPARE(cacheBufferSpy.count(),1); + QCOMPARE(flowSpy.count(),1); + + delete canvas; +} + +void tst_QDeclarativeGridView::componentChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativeGridView *gridView = canvas->rootObject()->findChild<QDeclarativeGridView*>("gridView"); + QVERIFY(gridView); + + QDeclarativeComponent component(canvas->engine()); + component.setData("import Qt 4.6; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile("")); + + QDeclarativeComponent delegateComponent(canvas->engine()); + delegateComponent.setData("import Qt 4.6; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile("")); + + QSignalSpy highlightSpy(gridView, SIGNAL(highlightChanged())); + QSignalSpy delegateSpy(gridView, SIGNAL(delegateChanged())); + + gridView->setHighlight(&component); + gridView->setDelegate(&delegateComponent); + + QCOMPARE(gridView->highlight(), &component); + QCOMPARE(gridView->delegate(), &delegateComponent); + + QCOMPARE(highlightSpy.count(),1); + QCOMPARE(delegateSpy.count(),1); + + gridView->setHighlight(&component); + gridView->setDelegate(&delegateComponent); + + QCOMPARE(highlightSpy.count(),1); + QCOMPARE(delegateSpy.count(),1); + delete canvas; +} + +void tst_QDeclarativeGridView::modelChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativeGridView *gridView = canvas->rootObject()->findChild<QDeclarativeGridView*>("gridView"); + QVERIFY(gridView); + + QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel"); + QVERIFY(alternateModel); + QVariant modelVariant = QVariant::fromValue(alternateModel); + QSignalSpy modelSpy(gridView, SIGNAL(modelChanged())); + + gridView->setModel(modelVariant); + QCOMPARE(gridView->model(), modelVariant); + QCOMPARE(modelSpy.count(),1); + + gridView->setModel(modelVariant); + QCOMPARE(modelSpy.count(),1); + + gridView->setModel(QVariant()); + QCOMPARE(modelSpy.count(),2); + delete canvas; +} + void tst_QDeclarativeGridView::positionViewAtIndex() { QDeclarativeView *canvas = createView(); diff --git a/tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml b/tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml index 9281a17..08da901 100644 --- a/tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml +++ b/tests/auto/declarative/qdeclarativeitem/data/keynavigation.qml @@ -11,6 +11,8 @@ Grid { color: focus ? "red" : "lightgray" KeyNavigation.right: item2 KeyNavigation.down: item3 + KeyNavigation.tab: item2 + KeyNavigation.backtab: item4 } Rectangle { id: item2 @@ -19,6 +21,8 @@ Grid { color: focus ? "red" : "lightgray" KeyNavigation.left: item1 KeyNavigation.down: item4 + KeyNavigation.tab: item3 + KeyNavigation.backtab: item1 } Rectangle { id: item3 @@ -27,6 +31,8 @@ Grid { color: focus ? "red" : "lightgray" KeyNavigation.right: item4 KeyNavigation.up: item1 + KeyNavigation.tab: item4 + KeyNavigation.backtab: item2 } Rectangle { id: item4 @@ -35,5 +41,7 @@ Grid { color: focus ? "red" : "lightgray" KeyNavigation.left: item3 KeyNavigation.up: item2 + KeyNavigation.tab: item1 + KeyNavigation.backtab: item3 } } diff --git a/tests/auto/declarative/qdeclarativeitem/data/keys.qml b/tests/auto/declarative/qdeclarativeitem/data/keys.qml index f3c1f7b..7d34fc8 100644 --- a/tests/auto/declarative/qdeclarativeitem/data/keys.qml +++ b/tests/auto/declarative/qdeclarativeitem/data/keys.qml @@ -7,6 +7,8 @@ Item { Keys.onReturnPressed: keysTestObject.keyPress(event.key, "Return", event.modifiers) Keys.onDigit0Pressed: keysTestObject.keyPress(event.key, event.text, event.modifiers) Keys.onDigit9Pressed: { event.accepted = false; keysTestObject.keyPress(event.key, event.text, event.modifiers) } + Keys.onTabPressed: keysTestObject.keyPress(event.key, "Tab", event.modifiers) + Keys.onBacktabPressed: keysTestObject.keyPress(event.key, "Backtab", event.modifiers) Keys.forwardTo: [ item2 ] Keys.enabled: enableKeyHanding diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index 36dcf1f..dbcba16 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -176,6 +176,26 @@ void tst_QDeclarativeItem::keys() testObject->reset(); + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_Tab)); + QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Tab)); + QCOMPARE(testObject->mText, QLatin1String("Tab")); + QVERIFY(testObject->mModifiers == Qt::NoModifier); + QVERIFY(key.isAccepted()); + + testObject->reset(); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_Backtab)); + QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Backtab)); + QCOMPARE(testObject->mText, QLatin1String("Backtab")); + QVERIFY(testObject->mModifiers == Qt::NoModifier); + QVERIFY(key.isAccepted()); + + testObject->reset(); + canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(false)); key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1); @@ -240,6 +260,24 @@ void tst_QDeclarativeItem::keyNavigation() item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1"); QVERIFY(item); QVERIFY(item->hasFocus()); + + // tab + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); + QApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem<QDeclarativeItem>(canvas->rootObject(), "item2"); + QVERIFY(item); + QVERIFY(item->hasFocus()); + + // backtab + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); + QApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1"); + QVERIFY(item); + QVERIFY(item->hasFocus()); } void tst_QDeclarativeItem::smooth() diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml index c86c96b..9fe0ded 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml @@ -10,8 +10,6 @@ MyTypeObject { floatProperty: 8.5 colorProperty: "red" dateProperty: "1982-11-25" - timeProperty: "11:11:31" - timeProperty: "11:11:32" timeProperty: "11:11:32" dateTimeProperty: "2009-05-12T13:22:01" pointProperty: "99,13" diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt index 9a13142..450fc16 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt @@ -1 +1 @@ -6:9:Invalid component id specification +6:9:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/customOnProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/customOnProperty.qml new file mode 100644 index 0000000..7cd6a83 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/customOnProperty.qml @@ -0,0 +1,7 @@ +import Qt 4.6 + +QtObject { + property int on + + Component.onCompleted: on = 10 +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt index 945d51b..32055f6 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt @@ -1 +1 @@ -7:9:Invalid value in grouped property +7:9:Cannot assign a value directly to a grouped property diff --git a/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt index 2aea251..e1f7ec5 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt @@ -1 +1 @@ -5:5:Incorrectly specified signal +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.errors.txt new file mode 100644 index 0000000..1fcb1b6 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.errors.txt @@ -0,0 +1 @@ +4:14:Cannot assign a value directly to a grouped property diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.qml new file mode 100644 index 0000000..41aa3e2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + grouped: "10x10" + grouped.value: 10 +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt index 8331725..e1f7ec5 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt @@ -1 +1 @@ -5:18:Single property assignment expected +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.errors.txt new file mode 100644 index 0000000..fa0da21 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.errors.txt @@ -0,0 +1 @@ +5:19:Property has already been assigned a value diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.qml new file mode 100644 index 0000000..56fca9b --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + pointProperty: "10x10" + pointProperty.x: 10 +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.errors.txt new file mode 100644 index 0000000..6d837a7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.errors.txt @@ -0,0 +1 @@ +5:20:Property has already been assigned a value diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.qml new file mode 100644 index 0000000..982ab26 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + pointProperty.x: 10 + pointProperty: "10x10" +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt index 56e3eeb..2c6b8bf 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt @@ -1,2 +1,2 @@ -3:5:"" is not a valid object id +3:9:Invalid empty ID diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt index cfe8756..c721fe9 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt @@ -1 +1 @@ -4:5:Invalid use of id property +4:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt index 160e8b5..7251de1 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt @@ -1 +1 @@ -3:5:"StartsWithUpperCase" is not a valid object id +3:9:IDs cannot start with an uppercase letter diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.errors.txt new file mode 100644 index 0000000..e4fd1db --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.errors.txt @@ -0,0 +1 @@ +3:9:ID illegally masks global JavaScript property diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.qml new file mode 100644 index 0000000..d4bc539 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyQmlObject { + id: gc +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.errors.txt new file mode 100644 index 0000000..b03ec6c --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.errors.txt @@ -0,0 +1 @@ +3:9:IDs must contain only letters, numbers, and underscores diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.qml new file mode 100644 index 0000000..1ea615c --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyQmlObject { + id: hello.world +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.errors.txt new file mode 100644 index 0000000..c010e79 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.errors.txt @@ -0,0 +1 @@ +3:9:IDs must start with a letter or underscore diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.qml new file mode 100644 index 0000000..57474b7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyQmlObject { + id: "3hello" +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt index 1ca678c..c010e79 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt @@ -1 +1 @@ -3:5:"1" is not a valid object id +3:9:IDs must start with a letter or underscore diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt index 8c7b7e9..c721fe9 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt @@ -1 +1 @@ -4:15:Can only assign one binding to lists +4:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.errors.txt new file mode 100644 index 0000000..e1f7ec5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.qml new file mode 100644 index 0000000..649c49e --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + intProperty: 10 + intProperty: 11 +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.errors.txt new file mode 100644 index 0000000..e1f7ec5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.qml new file mode 100644 index 0000000..bc21db9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + property int a: 10 + a: 11 +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.errors.txt new file mode 100644 index 0000000..e1f7ec5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.qml new file mode 100644 index 0000000..abcd216 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + intProperty: 10 + intProperty: a + 10 +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.errors.txt new file mode 100644 index 0000000..e1f7ec5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.qml new file mode 100644 index 0000000..77eaba0 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + intProperty: a + 10 + intProperty: 10 +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.errors.txt new file mode 100644 index 0000000..e1f7ec5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.qml new file mode 100644 index 0000000..c16d04f --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + intProperty: 10 + intProperty: MyTypeObject {} +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.errors.txt new file mode 100644 index 0000000..e1f7ec5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.qml new file mode 100644 index 0000000..2980c5b --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyContainer { + children: MyContainer {} + children: MyContainer {} +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.errors.txt new file mode 100644 index 0000000..e1f7ec5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.qml new file mode 100644 index 0000000..492c720 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyContainer { + children: MyContainer {} + children: [ MyContainer {}, MyContainer {} ] +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.errors.txt new file mode 100644 index 0000000..e1f7ec5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.qml new file mode 100644 index 0000000..2a9c1d0 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyContainer { + children: [ MyContainer {}, MyContainer {} ] + children: MyContainer {} +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.errors.txt new file mode 100644 index 0000000..450fc16 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.errors.txt @@ -0,0 +1 @@ +6:9:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.qml new file mode 100644 index 0000000..052437e --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + grouped { + value: 10 + value: 11 + } +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.errors.txt new file mode 100644 index 0000000..e1f7ec5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.qml new file mode 100644 index 0000000..e2e954f --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + grouped.value: 10 + grouped.value: 11 +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml index 57a6070..e48526a 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml @@ -1,5 +1,5 @@ import Test 1.0 MyTypeObject { - intProperty : MyCompositeValueSource {} + MyCompositeValueSource on intProperty {} } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml b/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml index ad71fcf..22aa682 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml @@ -1,4 +1,4 @@ import Test 1.0 MyTypeObject { - intProperty : MyPropertyValueSource {} + MyPropertyValueSource on intProperty {} } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt index b5bf1a8..450fc16 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt @@ -1 +1 @@ -6:9:Invalid Script source value +6:9:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h index 09cddcb..df93dc8 100644 --- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h +++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h @@ -78,17 +78,20 @@ Q_DECLARE_METATYPE(MyCustomVariantType); class MyAttachedObject : public QObject { Q_OBJECT - Q_PROPERTY(int value READ value WRITE setValue) + Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged) Q_PROPERTY(int value2 READ value2 WRITE setValue2) public: MyAttachedObject(QObject *parent) : QObject(parent), m_value(0), m_value2(0) {} int value() const { return m_value; } - void setValue(int v) { m_value = v; } + void setValue(int v) { if (m_value != v) { m_value = v; emit valueChanged(); } } int value2() const { return m_value2; } void setValue2(int v) { m_value2 = v; } +signals: + void valueChanged(); + private: int m_value; int m_value2; @@ -169,11 +172,16 @@ class MyGroupedObject : public QObject { Q_OBJECT Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript); + Q_PROPERTY(int value READ value WRITE setValue); public: QDeclarativeScriptString script() const { return m_script; } void setScript(const QDeclarativeScriptString &s) { m_script = s; } + int value() const { return m_value; } + void setValue(int v) { m_value = v; } + private: + int m_value; QDeclarativeScriptString m_script; }; diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 1ba4454..3ce15cb 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -128,6 +128,8 @@ private slots: void qmlAttachedPropertiesObjectMethod(); + void customOnProperty(); + // regression tests for crashes void crash1(); void crash2(); @@ -232,6 +234,9 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("invalidID.4") << "invalidID.4.qml" << "invalidID.4.errors.txt" << false; QTest::newRow("invalidID.5") << "invalidID.5.qml" << "invalidID.5.errors.txt" << false; QTest::newRow("invalidID.6") << "invalidID.6.qml" << "invalidID.6.errors.txt" << false; + QTest::newRow("invalidID.7") << "invalidID.7.qml" << "invalidID.7.errors.txt" << false; + QTest::newRow("invalidID.8") << "invalidID.8.qml" << "invalidID.8.errors.txt" << false; + QTest::newRow("invalidID.9") << "invalidID.9.qml" << "invalidID.9.errors.txt" << false; QTest::newRow("unsupportedProperty") << "unsupportedProperty.qml" << "unsupportedProperty.errors.txt" << false; QTest::newRow("nullDotProperty") << "nullDotProperty.qml" << "nullDotProperty.errors.txt" << true; @@ -252,6 +257,9 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("invalidGroupedProperty.5") << "invalidGroupedProperty.5.qml" << "invalidGroupedProperty.5.errors.txt" << false; QTest::newRow("invalidGroupedProperty.6") << "invalidGroupedProperty.6.qml" << "invalidGroupedProperty.6.errors.txt" << false; QTest::newRow("invalidGroupedProperty.7") << "invalidGroupedProperty.7.qml" << "invalidGroupedProperty.7.errors.txt" << true; + QTest::newRow("invalidGroupedProperty.8") << "invalidGroupedProperty.8.qml" << "invalidGroupedProperty.8.errors.txt" << false; + QTest::newRow("invalidGroupedProperty.9") << "invalidGroupedProperty.9.qml" << "invalidGroupedProperty.9.errors.txt" << false; + QTest::newRow("invalidGroupedProperty.10") << "invalidGroupedProperty.10.qml" << "invalidGroupedProperty.10.errors.txt" << false; QTest::newRow("importNamespaceConflict") << "importNamespaceConflict.qml" << "importNamespaceConflict.errors.txt" << false; QTest::newRow("importVersionMissing (builtin)") << "importVersionMissingBuiltIn.qml" << "importVersionMissingBuiltIn.errors.txt" << false; @@ -288,6 +296,17 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("Component.5") << "component.5.qml" << "component.5.errors.txt" << false; QTest::newRow("Component.6") << "component.6.qml" << "component.6.errors.txt" << false; + QTest::newRow("MultiSet.1") << "multiSet.1.qml" << "multiSet.1.errors.txt" << false; + QTest::newRow("MultiSet.2") << "multiSet.2.qml" << "multiSet.2.errors.txt" << false; + QTest::newRow("MultiSet.3") << "multiSet.3.qml" << "multiSet.3.errors.txt" << false; + QTest::newRow("MultiSet.4") << "multiSet.4.qml" << "multiSet.4.errors.txt" << false; + QTest::newRow("MultiSet.5") << "multiSet.5.qml" << "multiSet.5.errors.txt" << false; + QTest::newRow("MultiSet.6") << "multiSet.6.qml" << "multiSet.6.errors.txt" << false; + QTest::newRow("MultiSet.7") << "multiSet.7.qml" << "multiSet.7.errors.txt" << false; + QTest::newRow("MultiSet.8") << "multiSet.8.qml" << "multiSet.8.errors.txt" << false; + QTest::newRow("MultiSet.9") << "multiSet.9.qml" << "multiSet.9.errors.txt" << false; + QTest::newRow("MultiSet.10") << "multiSet.10.qml" << "multiSet.10.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.1") << "invalidAttachedProperty.1.qml" << "invalidAttachedProperty.1.errors.txt" << false; QTest::newRow("invalidAttachedProperty.2") << "invalidAttachedProperty.2.qml" << "invalidAttachedProperty.2.errors.txt" << false; QTest::newRow("invalidAttachedProperty.3") << "invalidAttachedProperty.3.qml" << "invalidAttachedProperty.3.errors.txt" << false; @@ -316,9 +335,6 @@ void tst_qdeclarativelanguage::errors() QFETCH(QString, errorFile); QFETCH(bool, create); - if (file == "invalidID.6.qml") - QTest::ignoreMessage(QtWarningMsg, "id \"StartsWithUpperCase\" is invalid: ids cannot start with uppercase letters"); - QDeclarativeComponent component(&engine, TEST_FILE(file)); if(create) { @@ -1378,6 +1394,19 @@ void tst_qdeclarativelanguage::crash2() QDeclarativeComponent component(&engine, TEST_FILE("crash2.qml")); } +// QTBUG-8676 +void tst_qdeclarativelanguage::customOnProperty() +{ + QDeclarativeComponent component(&engine, TEST_FILE("customOnProperty.qml")); + + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("on").toInt(), 10); + + delete object; +} void tst_qdeclarativelanguage::initTestCase() { diff --git a/tests/auto/declarative/qdeclarativelistview/data/propertychanges.qml b/tests/auto/declarative/qdeclarativelistview/data/propertychanges.qml new file mode 100644 index 0000000..a41f003 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelistview/data/propertychanges.qml @@ -0,0 +1,71 @@ +import Qt 4.6 + +Rectangle { + width: 180; height: 120; color: "white" + Component { + id: delegate + Item { + id: wrapper + width: 180; height: 40; + Column { + x: 5; y: 5 + Text { text: '<b>Name:</b> ' + name } + Text { text: '<b>Number:</b> ' + number } + } + } + } + Component { + id: highlightRed + Rectangle { + color: "red" + radius: 10 + opacity: 0.5 + } + } + ListView { + objectName: "listView" + anchors.fill: parent + model: listModel + delegate: delegate + highlight: highlightRed + focus: true + highlightFollowsCurrentItem: true + preferredHighlightBegin: 0.0 + preferredHighlightEnd: 0.0 + highlightRangeMode: ListView.ApplyRange + keyNavigationWraps: true + cacheBuffer: 10 + snapMode: ListView.SnapToItem + } + + data:[ + ListModel { + id: listModel + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + }, + ListModel { + objectName: "alternateModel" + ListElement { + name: "Jack" + number: "555 8426" + } + ListElement { + name: "Mary" + number: "555 3264" + } + } + ] +} + +
\ No newline at end of file diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index f15f26b..a36224f 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -38,15 +38,18 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include <QtTest/QtTest> -#include <QStringListModel> -#include <private/qlistmodelinterface_p.h> -#include <qdeclarativeview.h> -#include <private/qdeclarativelistview_p.h> -#include <private/qdeclarativetext_p.h> -#include <private/qdeclarativevisualitemmodel_p.h> -#include <qdeclarativecontext.h> -#include <qdeclarativeexpression.h> +#include <QtGui/QStringListModel> +#include <QtDeclarative/qdeclarativeview.h> +#include <QtDeclarative/qdeclarativeengine.h> +#include <QtDeclarative/qdeclarativecontext.h> +#include <QtDeclarative/qdeclarativeexpression.h> +#include <QtDeclarative/private/qdeclarativelistview_p.h> +#include <QtDeclarative/private/qdeclarativetext_p.h> +#include <QtDeclarative/private/qdeclarativevisualitemmodel_p.h> +#include <QtDeclarative/private/qdeclarativelistmodel_p.h> +#include <QtDeclarative/private/qlistmodelinterface_p.h> class tst_QDeclarativeListView : public QObject { @@ -82,6 +85,9 @@ private slots: void cacheBuffer(); void positionViewAtIndex(); void resetModel(); + void propertyChanges(); + void componentChanges(); + void modelChanges(); private: template <class T> void items(); @@ -240,7 +246,7 @@ public: setRoleNames(roles); } - int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); } + int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); } QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const { QVariant rv; if (role == Name) @@ -379,6 +385,7 @@ void tst_QDeclarativeListView::items() delete canvas; } + template <class T> void tst_QDeclarativeListView::changed() { @@ -1275,6 +1282,149 @@ void tst_QDeclarativeListView::resetModel() } } +void tst_QDeclarativeListView::propertyChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativeListView *listView = canvas->rootObject()->findChild<QDeclarativeListView*>("listView"); + QVERIFY(listView); + + QSignalSpy highlightFollowsCurrentItemSpy(listView, SIGNAL(highlightFollowsCurrentItemChanged())); + QSignalSpy preferredHighlightBeginSpy(listView, SIGNAL(preferredHighlightBeginChanged())); + QSignalSpy preferredHighlightEndSpy(listView, SIGNAL(preferredHighlightEndChanged())); + QSignalSpy highlightRangeModeSpy(listView, SIGNAL(highlightRangeModeChanged())); + QSignalSpy keyNavigationWrapsSpy(listView, SIGNAL(keyNavigationWrapsChanged())); + QSignalSpy cacheBufferSpy(listView, SIGNAL(cacheBufferChanged())); + QSignalSpy snapModeSpy(listView, SIGNAL(snapModeChanged())); + + QCOMPARE(listView->highlightFollowsCurrentItem(), true); + QCOMPARE(listView->preferredHighlightBegin(), 0.0); + QCOMPARE(listView->preferredHighlightEnd(), 0.0); + QCOMPARE(listView->highlightRangeMode(), QDeclarativeListView::ApplyRange); + QCOMPARE(listView->isWrapEnabled(), true); + QCOMPARE(listView->cacheBuffer(), 10); + QCOMPARE(listView->snapMode(), QDeclarativeListView::SnapToItem); + + listView->setHighlightFollowsCurrentItem(false); + listView->setPreferredHighlightBegin(1.0); + listView->setPreferredHighlightEnd(1.0); + listView->setHighlightRangeMode(QDeclarativeListView::StrictlyEnforceRange); + listView->setWrapEnabled(false); + listView->setCacheBuffer(3); + listView->setSnapMode(QDeclarativeListView::SnapOneItem); + + QCOMPARE(listView->highlightFollowsCurrentItem(), false); + QCOMPARE(listView->preferredHighlightBegin(), 1.0); + QCOMPARE(listView->preferredHighlightEnd(), 1.0); + QCOMPARE(listView->highlightRangeMode(), QDeclarativeListView::StrictlyEnforceRange); + QCOMPARE(listView->isWrapEnabled(), false); + QCOMPARE(listView->cacheBuffer(), 3); + QCOMPARE(listView->snapMode(), QDeclarativeListView::SnapOneItem); + + QCOMPARE(highlightFollowsCurrentItemSpy.count(),1); + QCOMPARE(preferredHighlightBeginSpy.count(),1); + QCOMPARE(preferredHighlightEndSpy.count(),1); + QCOMPARE(highlightRangeModeSpy.count(),1); + QCOMPARE(keyNavigationWrapsSpy.count(),1); + QCOMPARE(cacheBufferSpy.count(),1); + QCOMPARE(snapModeSpy.count(),1); + + listView->setHighlightFollowsCurrentItem(false); + listView->setPreferredHighlightBegin(1.0); + listView->setPreferredHighlightEnd(1.0); + listView->setHighlightRangeMode(QDeclarativeListView::StrictlyEnforceRange); + listView->setWrapEnabled(false); + listView->setCacheBuffer(3); + listView->setSnapMode(QDeclarativeListView::SnapOneItem); + + QCOMPARE(highlightFollowsCurrentItemSpy.count(),1); + QCOMPARE(preferredHighlightBeginSpy.count(),1); + QCOMPARE(preferredHighlightEndSpy.count(),1); + QCOMPARE(highlightRangeModeSpy.count(),1); + QCOMPARE(keyNavigationWrapsSpy.count(),1); + QCOMPARE(cacheBufferSpy.count(),1); + QCOMPARE(snapModeSpy.count(),1); + + delete canvas; +} + +void tst_QDeclarativeListView::componentChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativeListView *listView = canvas->rootObject()->findChild<QDeclarativeListView*>("listView"); + QVERIFY(listView); + + QDeclarativeComponent component(canvas->engine()); + component.setData("import Qt 4.6; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile("")); + + QDeclarativeComponent delegateComponent(canvas->engine()); + delegateComponent.setData("import Qt 4.6; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile("")); + + QSignalSpy highlightSpy(listView, SIGNAL(highlightChanged())); + QSignalSpy delegateSpy(listView, SIGNAL(delegateChanged())); + QSignalSpy headerSpy(listView, SIGNAL(headerChanged())); + QSignalSpy footerSpy(listView, SIGNAL(footerChanged())); + + listView->setHighlight(&component); + listView->setHeader(&component); + listView->setFooter(&component); + listView->setDelegate(&delegateComponent); + + QCOMPARE(listView->highlight(), &component); + QCOMPARE(listView->header(), &component); + QCOMPARE(listView->footer(), &component); + QCOMPARE(listView->delegate(), &delegateComponent); + + QCOMPARE(highlightSpy.count(),1); + QCOMPARE(delegateSpy.count(),1); + QCOMPARE(headerSpy.count(),1); + QCOMPARE(footerSpy.count(),1); + + listView->setHighlight(&component); + listView->setHeader(&component); + listView->setFooter(&component); + listView->setDelegate(&delegateComponent); + + QCOMPARE(highlightSpy.count(),1); + QCOMPARE(delegateSpy.count(),1); + QCOMPARE(headerSpy.count(),1); + QCOMPARE(footerSpy.count(),1); + + delete canvas; +} + +void tst_QDeclarativeListView::modelChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativeListView *listView = canvas->rootObject()->findChild<QDeclarativeListView*>("listView"); + QVERIFY(listView); + + QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel"); + QVERIFY(alternateModel); + QVariant modelVariant = QVariant::fromValue(alternateModel); + QSignalSpy modelSpy(listView, SIGNAL(modelChanged())); + + listView->setModel(modelVariant); + QCOMPARE(listView->model(), modelVariant); + QCOMPARE(modelSpy.count(),1); + + listView->setModel(modelVariant); + QCOMPARE(modelSpy.count(),1); + + listView->setModel(QVariant()); + QCOMPARE(modelSpy.count(),2); + + delete canvas; +} + void tst_QDeclarativeListView::qListModelInterface_items() { items<TestModel>(); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp index f3caa7f..92f7aef 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp @@ -50,7 +50,6 @@ class tst_qdeclarativemoduleplugin : public QObject public: tst_qdeclarativemoduleplugin() { QCoreApplication::addLibraryPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("plugin")); -qDebug() << QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("plugin"); } private slots: diff --git a/tests/auto/declarative/qdeclarativenumberformatter/tst_qdeclarativenumberformatter.cpp b/tests/auto/declarative/qdeclarativenumberformatter/tst_qdeclarativenumberformatter.cpp index 26ff3d5..a9a0077 100644 --- a/tests/auto/declarative/qdeclarativenumberformatter/tst_qdeclarativenumberformatter.cpp +++ b/tests/auto/declarative/qdeclarativenumberformatter/tst_qdeclarativenumberformatter.cpp @@ -172,9 +172,11 @@ tst_qdeclarativenumberformatter::tst_qdeclarativenumberformatter() << "00,000,001.0000" << "00,000,001.0100"; // end + /* qDebug() << "strings.size()" << strings.size() << "\nformats.size()" << formats.size() << "texts.size()" << texts.size(); + */ } void tst_qdeclarativenumberformatter::text_data() diff --git a/tests/auto/declarative/qdeclarativeparticles/data/particles.qml b/tests/auto/declarative/qdeclarativeparticles/data/particles.qml index c58927e..0d42645 100644 --- a/tests/auto/declarative/qdeclarativeparticles/data/particles.qml +++ b/tests/auto/declarative/qdeclarativeparticles/data/particles.qml @@ -8,7 +8,7 @@ Rectangle{ objectName: "particles" width:1; height:1; anchors.centerIn: parent; opacity: 1 lifeSpan: 100; lifeSpanDeviation: 20; count:1000; - fadeInDuration: 20; fadeOutDuration: 20; count: -1; emissionRate: 1000 + fadeInDuration: 20; fadeOutDuration: 20; emissionRate: 1000 angle: 0; angleDeviation: 360; velocity: 500; velocityDeviation:30 source: "particle.png" } diff --git a/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml b/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml index 627f38a..ab1538b 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml @@ -33,7 +33,7 @@ Rectangle { height: 320 model: testModel delegate: delegate - snapPosition: 0.01 + snapPosition: 0.0001 path: Path { startY: 120 startX: 160 diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview.qml index 8fa8d59..c5d88cd 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/pathview.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview.qml @@ -39,7 +39,7 @@ Rectangle { height: 320 model: testModel delegate: delegate - snapPosition: 0.01 + snapPosition: 0.0001 path: Path { startY: 120 startX: 160 diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview2.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview2.qml index 0d5c98b..c825292 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/pathview2.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview2.qml @@ -1,7 +1,7 @@ import Qt 4.6 PathView { - id: photoPathView; model: rssModel; delegate: photoDelegate + id: photoPathView y: 100; width: 800; height: 330; pathItemCount: 10; z: 1 path: Path { diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml index 412cca2..f8ed29f 100644 --- a/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml @@ -1,9 +1,9 @@ import Qt 4.6 PathView { - id: photoPathView; model: rssModel; delegate: photoDelegate + id: photoPathView y: 100; width: 800; height: 330; pathItemCount: 4; offset: 10 - dragMargin: 24; snapPosition: 50 + dragMargin: 24; snapPosition: 0.50 path: Path { startX: -50; startY: 40; diff --git a/tests/auto/declarative/qdeclarativepathview/data/propertychanges.qml b/tests/auto/declarative/qdeclarativepathview/data/propertychanges.qml new file mode 100644 index 0000000..db70b7b --- /dev/null +++ b/tests/auto/declarative/qdeclarativepathview/data/propertychanges.qml @@ -0,0 +1,115 @@ +import Qt 4.6 + +Rectangle { + width: 350; height: 220; color: "white" + Component { + id: myDelegate + Item { + id: wrapper + width: 180; height: 40; + opacity: PathView.opacity + Column { + x: 5; y: 5 + Text { text: '<b>Name:</b> ' + name } + Text { text: '<b>Number:</b> ' + number } + } + } + } + + PathView { + snapPosition: 0.1 + dragMargin: 5.0 + id: pathView + objectName: "pathView" + anchors.fill: parent + model: listModel + delegate: myDelegate + focus: true + path: Path { + id: myPath + objectName: "path" + startX: 220; startY: 200 + PathAttribute { name: "opacity"; value: 1.0; objectName: "pathAttribute"; } + PathQuad { x: 220; y: 25; controlX: 260; controlY: 75 } + PathAttribute { name: "opacity"; value: 0.3 } + PathQuad { x: 220; y: 200; controlX: -20; controlY: 75 } + } + Timer { + interval: 2000; running: true; repeat: true + onTriggered: { + if (pathView.path == alternatePath) + pathView.path = myPath; + else + pathView.path = alternatePath; + } + } + } + + data:[ + ListModel { + id: listModel + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + }, + ListModel { + objectName: "alternateModel" + ListElement { + name: "Jack" + number: "555 8426" + } + ListElement { + name: "Mary" + number: "555 3264" + } + }, + Path { + id: alternatePath + objectName: "alternatePath" + startX: 100; startY: 40 + PathAttribute { name: "opacity"; value: 0.0 } + PathLine { x: 100; y: 160 } + PathAttribute { name: "opacity"; value: 0.2 } + PathLine { x: 300; y: 160 } + PathAttribute { name: "opacity"; value: 0.0 } + PathLine { x: 300; y: 40 } + PathAttribute { name: "opacity"; value: 0.2 } + PathLine { x: 100; y: 40 } + } + ] +} + + diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index 79bc607..fa4e9d3 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -38,20 +38,23 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include <private/qdeclarativepathview_p.h> -#include <private/qdeclarativepath_p.h> -#include <qdeclarativecontext.h> -#include <qdeclarativeexpression.h> -#include <qtest.h> + +#include <QtTest/QtTest> +#include <QtDeclarative/qdeclarativeview.h> #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativecomponent.h> -#include <QtDeclarative/qdeclarativeview.h> +#include <QtDeclarative/qdeclarativecontext.h> +#include <QtDeclarative/qdeclarativeexpression.h> +#include <QtDeclarative/private/qdeclarativepathview_p.h> +#include <QtDeclarative/private/qdeclarativepath_p.h> #include <QtDeclarative/private/qdeclarativetext_p.h> #include <QtDeclarative/private/qdeclarativerectangle_p.h> +#include <QtDeclarative/private/qdeclarativelistmodel_p.h> +#include <QtDeclarative/private/qdeclarativevaluetype_p.h> #include <QAbstractListModel> #include <QStringListModel> #include <QFile> -#include <private/qdeclarativevaluetype_p.h> + #include "../../../shared/util.h" class tst_QDeclarativePathView : public QObject @@ -69,6 +72,11 @@ private slots: void path(); void pathMoved(); void resetModel(); + void propertyChanges(); + void pathChanges(); + void componentChanges(); + void modelChanges(); + private: QDeclarativeView *createView(); @@ -120,7 +128,7 @@ public: setRoleNames(roles); } - int rowCount(const QModelIndex &parent=QModelIndex()) const { return list.count(); } + int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); } QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const { QVariant rv; if (role == Name) @@ -465,6 +473,149 @@ void tst_QDeclarativePathView::resetModel() } } +void tst_QDeclarativePathView::propertyChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativePathView *pathView = canvas->rootObject()->findChild<QDeclarativePathView*>("pathView"); + QVERIFY(pathView); + + QSignalSpy snapPositionSpy(pathView, SIGNAL(snapPositionChanged())); + QSignalSpy dragMarginSpy(pathView, SIGNAL(dragMarginChanged())); + + QCOMPARE(pathView->snapPosition(), 0.1); + QCOMPARE(pathView->dragMargin(), 5.0); + + pathView->setSnapPosition(0.4); + pathView->setDragMargin(20.0); + + QCOMPARE(pathView->snapPosition(), 0.4); + QCOMPARE(pathView->dragMargin(), 20.0); + + QCOMPARE(snapPositionSpy.count(), 1); + QCOMPARE(dragMarginSpy.count(), 1); + + pathView->setSnapPosition(0.4); + pathView->setDragMargin(20.0); + + QCOMPARE(snapPositionSpy.count(), 1); + QCOMPARE(dragMarginSpy.count(), 1); + delete canvas; +} + +void tst_QDeclarativePathView::pathChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativePathView *pathView = canvas->rootObject()->findChild<QDeclarativePathView*>("pathView"); + QVERIFY(pathView); + + QDeclarativePath *path = canvas->rootObject()->findChild<QDeclarativePath*>("path"); + QVERIFY(path); + + QSignalSpy startXSpy(path, SIGNAL(startXChanged())); + QSignalSpy startYSpy(path, SIGNAL(startYChanged())); + + QCOMPARE(path->startX(), 220.0); + QCOMPARE(path->startY(), 200.0); + + path->setStartX(240.0); + path->setStartY(220.0); + + QCOMPARE(path->startX(), 240.0); + QCOMPARE(path->startY(), 220.0); + + QCOMPARE(startXSpy.count(),1); + QCOMPARE(startYSpy.count(),1); + + path->setStartX(240); + path->setStartY(220); + + QCOMPARE(startXSpy.count(),1); + QCOMPARE(startYSpy.count(),1); + + QDeclarativePath *alternatePath = canvas->rootObject()->findChild<QDeclarativePath*>("alternatePath"); + QVERIFY(alternatePath); + + QSignalSpy pathSpy(pathView, SIGNAL(pathChanged())); + + QCOMPARE(pathView->path(), path); + + pathView->setPath(alternatePath); + QCOMPARE(pathView->path(), alternatePath); + QCOMPARE(pathSpy.count(),1); + + pathView->setPath(alternatePath); + QCOMPARE(pathSpy.count(),1); + + QDeclarativePathAttribute *pathAttribute = canvas->rootObject()->findChild<QDeclarativePathAttribute*>("pathAttribute"); + QVERIFY(pathAttribute); + + QSignalSpy nameSpy(pathAttribute, SIGNAL(nameChanged())); + QCOMPARE(pathAttribute->name(), QString("opacity")); + + pathAttribute->setName("scale"); + QCOMPARE(pathAttribute->name(), QString("scale")); + QCOMPARE(nameSpy.count(),1); + + pathAttribute->setName("scale"); + QCOMPARE(nameSpy.count(),1); + delete canvas; +} + +void tst_QDeclarativePathView::componentChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativePathView *pathView = canvas->rootObject()->findChild<QDeclarativePathView*>("pathView"); + QVERIFY(pathView); + + QDeclarativeComponent delegateComponent(canvas->engine()); + delegateComponent.setData("import Qt 4.6; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile("")); + + QSignalSpy delegateSpy(pathView, SIGNAL(delegateChanged())); + + pathView->setDelegate(&delegateComponent); + QCOMPARE(pathView->delegate(), &delegateComponent); + QCOMPARE(delegateSpy.count(),1); + + pathView->setDelegate(&delegateComponent); + QCOMPARE(delegateSpy.count(),1); + delete canvas; +} + +void tst_QDeclarativePathView::modelChanges() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + + QDeclarativePathView *pathView = canvas->rootObject()->findChild<QDeclarativePathView*>("pathView"); + QVERIFY(pathView); + + QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel"); + QVERIFY(alternateModel); + QVariant modelVariant = QVariant::fromValue(alternateModel); + QSignalSpy modelSpy(pathView, SIGNAL(modelChanged())); + + pathView->setModel(modelVariant); + QCOMPARE(pathView->model(), modelVariant); + QCOMPARE(modelSpy.count(),1); + + pathView->setModel(modelVariant); + QCOMPARE(modelSpy.count(),1); + + pathView->setModel(QVariant()); + QCOMPARE(modelSpy.count(),2); + + delete canvas; +} QDeclarativeView *tst_QDeclarativePathView::createView() { diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp index 3a8a892..d23d74c 100644 --- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp @@ -365,7 +365,7 @@ void tst_QDeclarativePositioners::test_grid_animated() } void tst_QDeclarativePositioners::test_propertychanges() { - QDeclarativeView *canvas = createView("data/propertychanges.qml"); + QDeclarativeView *canvas = createView(SRCDIR "/data/propertychanges.qml"); QDeclarativeGrid *grid = qobject_cast<QDeclarativeGrid*>(canvas->rootObject()); QDeclarativeTransition *rowTransition = canvas->rootObject()->findChild<QDeclarativeTransition*>("rowTransition"); diff --git a/tests/auto/declarative/qdeclarativeproperty/data/TestType.qml b/tests/auto/declarative/qdeclarativeproperty/data/TestType.qml new file mode 100644 index 0000000..1dfb3e1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeproperty/data/TestType.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +QtObject { + property int a: 10 +} + diff --git a/tests/auto/declarative/qdeclarativeproperty/data/readSynthesizedObject.qml b/tests/auto/declarative/qdeclarativeproperty/data/readSynthesizedObject.qml new file mode 100644 index 0000000..8085db2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeproperty/data/readSynthesizedObject.qml @@ -0,0 +1,9 @@ +import Qt 4.6 + +QtObject { + property TestType test + + test: TestType { + property int b: 19 + } +} diff --git a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro index 22e50cc..af1e1b6 100644 --- a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro +++ b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro @@ -3,3 +3,5 @@ contains(QT_CONFIG,declarative): QT += declarative macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeproperty.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp index 0333d98..9b8a643 100644 --- a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp +++ b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp @@ -46,6 +46,14 @@ #include <private/qguard_p.h> #include <private/qdeclarativebinding_p.h> #include <QtGui/QLineEdit> +#include <QtCore/qfileinfo.h> +#include <QtCore/qdir.h> + +inline QUrl TEST_FILE(const QString &filename) +{ + QFileInfo fileInfo(__FILE__); + return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(QLatin1String("data/") + filename)); +} class MyQmlObject : public QObject { @@ -181,6 +189,7 @@ class PropertyObject : public QObject Q_PROPERTY(QUrl url READ url WRITE setUrl); Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty); Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal) + Q_PROPERTY(MyQmlObject *qmlObject READ qmlObject); Q_CLASSINFO("DefaultProperty", "defaultProperty"); public: @@ -202,6 +211,7 @@ public: int propertyWithNotify() const { return m_propertyWithNotify; } void setPropertyWithNotify(int i) { m_propertyWithNotify = i; emit oddlyNamedNotifySignal(); } + MyQmlObject *qmlObject() { return &m_qmlObject; } signals: void clicked(); void oddlyNamedNotifySignal(); @@ -211,6 +221,7 @@ private: QRect m_rect; QUrl m_url; int m_propertyWithNotify; + MyQmlObject m_qmlObject; }; QML_DECLARE_TYPE(PropertyObject); @@ -953,6 +964,32 @@ void tst_qdeclarativeproperty::read() QCOMPARE(p.read(), QVariant()); } + // Object property + { + PropertyObject o; + QDeclarativeProperty p(&o, "qmlObject"); + QCOMPARE(p.propertyTypeCategory(), QDeclarativeProperty::Object); + QCOMPARE(p.propertyType(), qMetaTypeId<MyQmlObject*>()); + QVariant v = p.read(); + QVERIFY(v.userType() == QMetaType::QObjectStar); + QVERIFY(qvariant_cast<QObject *>(v) == o.qmlObject()); + } + { + QDeclarativeComponent component(&engine, TEST_FILE("readSynthesizedObject.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QDeclarativeProperty p(object, "test", &engine); + + QCOMPARE(p.propertyTypeCategory(), QDeclarativeProperty::Object); + QVERIFY(p.propertyType() != QMetaType::QObjectStar); + + QVariant v = p.read(); + QVERIFY(v.userType() == QMetaType::QObjectStar); + QCOMPARE(qvariant_cast<QObject *>(v)->property("a").toInt(), 10); + QCOMPARE(qvariant_cast<QObject *>(v)->property("b").toInt(), 19); + } + // Attached property { QDeclarativeComponent component(&engine); diff --git a/tests/auto/declarative/qdeclarativeqt/data/formatting.qml b/tests/auto/declarative/qdeclarativeqt/data/formatting.qml new file mode 100644 index 0000000..e62749a --- /dev/null +++ b/tests/auto/declarative/qdeclarativeqt/data/formatting.qml @@ -0,0 +1,19 @@ +import Qt 4.6 + +QtObject { + property date date1: "2008-12-24" + property string test1: Qt.formatDate(date1) + property string test2: Qt.formatDate(date1, Qt.DefaultLocaleLongDate) + property string test3: Qt.formatDate(date1, "ddd MMMM d yy") + + property var time1: new Date(0,0,0,14,15,38,200) + property string test4: Qt.formatTime(time1) + property string test5: Qt.formatTime(time1, Qt.DefaultLocaleLongDate) + property string test6: Qt.formatTime(time1, "H:m:s a") + property string test7: Qt.formatTime(time1, "hh:mm:ss.zzz") + + property var dateTime1: new Date(1978,2,4,9,13,54) + property string test8: Qt.formatDateTime(dateTime1) + property string test9: Qt.formatDateTime(dateTime1, Qt.DefaultLocaleLongDate) + property string test10: Qt.formatDateTime(dateTime1, "M/d/yy H:m:s a") +} diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index 9ec6872..90afd4e 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -67,12 +67,12 @@ private slots: void darker(); void tint(); void closestAngle(); - void playSound(); void openUrlExternally(); void md5(); void createComponent(); void createQmlObject(); void consoleLog(); + void formatting(); private: QDeclarativeEngine engine; @@ -279,12 +279,6 @@ void tst_qdeclarativeqt::closestAngle() delete object; } -void tst_qdeclarativeqt::playSound() -{ - QEXPECT_FAIL("", "How do we test this?", Abort); - QVERIFY(false); -} - void tst_qdeclarativeqt::openUrlExternally() { QEXPECT_FAIL("", "How do we test this?", Abort); @@ -364,6 +358,34 @@ void tst_qdeclarativeqt::consoleLog() delete object; } +void tst_qdeclarativeqt::formatting() +{ + QDeclarativeComponent component(&engine, TEST_FILE("formatting.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QDate date1(2008,12,24); + QCOMPARE(object->property("date1").toDate(), date1); + QCOMPARE(object->property("test1").toString(), date1.toString(Qt::DefaultLocaleShortDate)); + QCOMPARE(object->property("test2").toString(), date1.toString(Qt::DefaultLocaleLongDate)); + QCOMPARE(object->property("test3").toString(), date1.toString("ddd MMMM d yy")); + + QTime time1(14,15,38,200); + QCOMPARE(object->property("time1").toTime(), time1); + QCOMPARE(object->property("test4").toString(), time1.toString(Qt::DefaultLocaleShortDate)); + QCOMPARE(object->property("test5").toString(), time1.toString(Qt::DefaultLocaleLongDate)); + QCOMPARE(object->property("test6").toString(), time1.toString("H:m:s a")); + QCOMPARE(object->property("test7").toString(), time1.toString("hh:mm:ss.zzz")); + + QDateTime dateTime1(QDate(1978,03,04),QTime(9,13,54)); + QCOMPARE(object->property("dateTime1").toDateTime(),dateTime1); + QCOMPARE(object->property("test8").toString(), dateTime1.toString(Qt::DefaultLocaleShortDate)); + QCOMPARE(object->property("test9").toString(), dateTime1.toString(Qt::DefaultLocaleLongDate)); + QCOMPARE(object->property("test10").toString(), dateTime1.toString("M/d/yy H:m:s a")); + + delete object; +} + QTEST_MAIN(tst_qdeclarativeqt) #include "tst_qdeclarativeqt.moc" diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index b677fec..b1935df 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -663,15 +663,17 @@ void tst_qdeclarativetextedit::delegateLoading() QVERIFY(delegate); view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail1.qml")); view->show(); + QTRY_VERIFY(view->status()==QDeclarativeView::Error); view->setFocus(); QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail2.qml")); view->show(); + QTRY_VERIFY(view->status()==QDeclarativeView::Error); view->setFocus(); QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test - //ErrorB should get a component which is ready but component.create() returns null + //A test should be added here with a component which is ready but component.create() returns null //Not sure how to accomplish this with QDeclarativeTextEdits cursor delegate - //###This could be a case of overzealous defensive programming + //###This was only needed for code coverage, and could be a case of overzealous defensive programming //delegate = view->rootObject()->findChild<QDeclarativeItem*>("delegateErrorB"); //QVERIFY(!delegate); } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml index 026ae83..0897847 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml @@ -3,6 +3,6 @@ import Test 1.0 MyTypeObject { property int value: 13; - rect.x: MyOffsetValueInterceptor {} + MyOffsetValueInterceptor on rect.x {} rect.x: value } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml index d4d4391..717f350 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml @@ -1,5 +1,5 @@ import Test 1.0 MyTypeObject { - rect.x: MyConstantValueSource {} + MyConstantValueSource on rect.x {} } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index 69646b9..8732215 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -502,10 +502,9 @@ void tst_qdeclarativevaluetypes::valueInterceptors() QDeclarativeComponent component(&engine, TEST_FILE("valueInterceptors.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); checkNoErrors(component); - QEXPECT_FAIL("", "QT-2920", Abort); QVERIFY(object != 0); - QCOMPARE(object->rect().x(), 26); + QCOMPARE(object->rect().x(), 13); object->setProperty("value", 99); diff --git a/tests/auto/declarative/qdeclarativewebview/data/basic.qml b/tests/auto/declarative/qdeclarativewebview/data/basic.qml index 5394837..f0b41ef 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/basic.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/basic.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { url: "basic.html" diff --git a/tests/auto/declarative/qdeclarativewebview/data/elements.qml b/tests/auto/declarative/qdeclarativewebview/data/elements.qml index 7c030e6..16e5788 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/elements.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/elements.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { url: "elements.html" diff --git a/tests/auto/declarative/qdeclarativewebview/data/forward.png b/tests/auto/declarative/qdeclarativewebview/data/forward.png Binary files differnew file mode 100644 index 0000000..a82533e --- /dev/null +++ b/tests/auto/declarative/qdeclarativewebview/data/forward.png diff --git a/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml b/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml index 07eee88..0e92e0e 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/javaScript.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { url: "javaScript.html" diff --git a/tests/auto/declarative/qdeclarativewebview/data/loadError.qml b/tests/auto/declarative/qdeclarativewebview/data/loadError.qml index 1460f30..f827238 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/loadError.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/loadError.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { url: "does-not-exist.html" diff --git a/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml b/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml index 0bc8263..4d9df43 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/newwindows.qml @@ -1,6 +1,7 @@ // Demonstrates opening new WebViews from HTML import Qt 4.6 +import org.webkit 1.0 Grid { columns: 3 diff --git a/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml b/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml index 3dd4e51..0770acf 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/propertychanges.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 Item { width: 240 @@ -30,4 +31,4 @@ Item { pressGrabTime: 200 } } -}
\ No newline at end of file +} diff --git a/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml b/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml index 063b5a8..9e17597 100644 --- a/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml +++ b/tests/auto/declarative/qdeclarativewebview/data/sethtml.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { html: "<p>This is a <b>string</b> set on the WebView" diff --git a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro index 6af0a60..20173c6 100644 --- a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro +++ b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro @@ -3,8 +3,7 @@ contains(QT_CONFIG,declarative): QT += declarative contains(QT_CONFIG,webkit): QT += webkit macx:CONFIG -= app_bundle -SOURCES += tst_qdeclarativewebview.cpp testtypes.cpp -HEADERS += testtypes.h +SOURCES += tst_qdeclarativewebview.cpp # Define SRCDIR equal to test's source directory DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp b/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp index 6d16056..b63e14b 100644 --- a/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp +++ b/tests/auto/declarative/qdeclarativewebview/tst_qdeclarativewebview.cpp @@ -43,15 +43,12 @@ #include "../../../shared/util.h" #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativecomponent.h> -#include <private/qdeclarativewebview_p.h> -#include <private/qdeclarativewebview_p_p.h> #include <private/qdeclarativepositioners_p.h> #include <QtWebKit/qwebpage.h> #include <QtWebKit/qwebframe.h> #include <QtCore/qdir.h> #include <QtCore/qfile.h> #include <QtGui/qpainter.h> -#include "testtypes.h" class tst_qdeclarativewebview : public QObject { @@ -70,7 +67,7 @@ private slots: void setHtml(); void javaScript(); void cleanupTestCase(); - void pixelCache(); + //void pixelCache(); void newWindowParent(); void newWindowComponent(); void renderingEnabled(); @@ -89,7 +86,6 @@ private: void tst_qdeclarativewebview::initTestCase() { - registerTypes(); } static QString strippedHtml(QString html) @@ -148,81 +144,82 @@ void tst_qdeclarativewebview::basicProperties() checkNoErrors(component); QWebSettings::enablePersistentStorage(tmpDir()); - QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create()); + QObject *wv = component.create(); QVERIFY(wv != 0); - QTRY_COMPARE(wv->progress(), 1.0); - QCOMPARE(wv->title(),QString("Basic")); - QTRY_COMPARE(wv->icon().width(), 48); - QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/basic.png")); - QCOMPARE(wv->statusText(),QString("status here")); - QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html())); - QCOMPARE(wv->width(), 123.0); - QCOMPARE(wv->preferredWidth(), 0); - QCOMPARE(wv->preferredHeight(), 0); - QCOMPARE(wv->zoomFactor(), 1.0); - QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html")); - QCOMPARE(wv->status(), QDeclarativeWebView::Ready); - QVERIFY(wv->reloadAction()); - QVERIFY(wv->reloadAction()->isEnabled()); - QVERIFY(wv->backAction()); - QVERIFY(!wv->backAction()->isEnabled()); - QVERIFY(wv->forwardAction()); - QVERIFY(!wv->forwardAction()->isEnabled()); - QVERIFY(wv->stopAction()); - QVERIFY(!wv->stopAction()->isEnabled()); - - wv->setPixelCacheSize(0); // mainly testing that it doesn't crash or anything! - QCOMPARE(wv->pixelCacheSize(),0); - wv->reloadAction()->trigger(); - QTRY_COMPARE(wv->progress(), 1.0); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); + QCOMPARE(wv->property("title").toString(),QString("Basic")); + QTRY_COMPARE(qvariant_cast<QPixmap>(wv->property("icon")).width(), 48); + QCOMPARE(qvariant_cast<QPixmap>(wv->property("icon")),QPixmap(SRCDIR "/data/basic.png")); + QCOMPARE(wv->property("statusText").toString(),QString("status here")); + QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->property("html").toString())); + QCOMPARE(wv->property("width").toDouble(), 123.0); + QCOMPARE(wv->property("preferredWidth").toInt(), 0); + QCOMPARE(wv->property("preferredHeight").toInt(), 0); + QCOMPARE(wv->property("zoomFactor").toDouble(), 1.0); + QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/basic.html")); + QCOMPARE(wv->property("status").toInt(), 1 /*QDeclarativeWebView::Ready*/); + QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))); + QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("back"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("back"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("forward"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("forward"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("stop"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("stop"))->isEnabled()); + + wv->setProperty("pixelCacheSize", 0); // mainly testing that it doesn't crash or anything! + QCOMPARE(wv->property("pixelCacheSize").toInt(),0); + qvariant_cast<QAction*>(wv->property("reload"))->trigger(); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); } void tst_qdeclarativewebview::settings() { QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml")); checkNoErrors(component); - QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create()); + QObject *wv = component.create(); QVERIFY(wv != 0); - QTRY_COMPARE(wv->progress(), 1.0); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); - QDeclarativeWebSettings *s = wv->settingsObject(); + QObject *s = QDeclarativeProperty(wv,"settings").object(); + QVERIFY(s != 0); // merely tests that setting gets stored (in QWebSettings) // behavioural tests are in WebKit. for (int b=0; b<=1; ++b) { bool on = !!b; - s->setAutoLoadImages(on); - s->setDeveloperExtrasEnabled(on); - s->setJavaEnabled(on); - s->setJavascriptCanAccessClipboard(on); - s->setJavascriptCanOpenWindows(on); - s->setJavascriptEnabled(on); - s->setLinksIncludedInFocusChain(on); - s->setLocalContentCanAccessRemoteUrls(on); - s->setLocalStorageDatabaseEnabled(on); - s->setOfflineStorageDatabaseEnabled(on); - s->setOfflineWebApplicationCacheEnabled(on); - s->setPluginsEnabled(on); - s->setPrintElementBackgrounds(on); - s->setPrivateBrowsingEnabled(on); - s->setZoomTextOnly(on); - - QVERIFY(s->autoLoadImages() == on); - QVERIFY(s->developerExtrasEnabled() == on); - QVERIFY(s->javaEnabled() == on); - QVERIFY(s->javascriptCanAccessClipboard() == on); - QVERIFY(s->javascriptCanOpenWindows() == on); - QVERIFY(s->javascriptEnabled() == on); - QVERIFY(s->linksIncludedInFocusChain() == on); - QVERIFY(s->localContentCanAccessRemoteUrls() == on); - QVERIFY(s->localStorageDatabaseEnabled() == on); - QVERIFY(s->offlineStorageDatabaseEnabled() == on); - QVERIFY(s->offlineWebApplicationCacheEnabled() == on); - QVERIFY(s->pluginsEnabled() == on); - QVERIFY(s->printElementBackgrounds() == on); - QVERIFY(s->privateBrowsingEnabled() == on); - QVERIFY(s->zoomTextOnly() == on); + s->setProperty("autoLoadImages", on); + s->setProperty("developerExtrasEnabled", on); + s->setProperty("javaEnabled", on); + s->setProperty("javascriptCanAccessClipboard", on); + s->setProperty("javascriptCanOpenWindows", on); + s->setProperty("javascriptEnabled", on); + s->setProperty("linksIncludedInFocusChain", on); + s->setProperty("localContentCanAccessRemoteUrls", on); + s->setProperty("localStorageDatabaseEnabled", on); + s->setProperty("offlineStorageDatabaseEnabled", on); + s->setProperty("offlineWebApplicationCacheEnabled", on); + s->setProperty("pluginsEnabled", on); + s->setProperty("printElementBackgrounds", on); + s->setProperty("privateBrowsingEnabled", on); + s->setProperty("zoomTextOnly", on); + + QVERIFY(s->property("autoLoadImages") == on); + QVERIFY(s->property("developerExtrasEnabled") == on); + QVERIFY(s->property("javaEnabled") == on); + QVERIFY(s->property("javascriptCanAccessClipboard") == on); + QVERIFY(s->property("javascriptCanOpenWindows") == on); + QVERIFY(s->property("javascriptEnabled") == on); + QVERIFY(s->property("linksIncludedInFocusChain") == on); + QVERIFY(s->property("localContentCanAccessRemoteUrls") == on); + QVERIFY(s->property("localStorageDatabaseEnabled") == on); + QVERIFY(s->property("offlineStorageDatabaseEnabled") == on); + QVERIFY(s->property("offlineWebApplicationCacheEnabled") == on); + QVERIFY(s->property("pluginsEnabled") == on); + QVERIFY(s->property("printElementBackgrounds") == on); + QVERIFY(s->property("privateBrowsingEnabled") == on); + QVERIFY(s->property("zoomTextOnly") == on); QVERIFY(s->property("autoLoadImages") == on); QVERIFY(s->property("developerExtrasEnabled") == on); @@ -248,65 +245,65 @@ void tst_qdeclarativewebview::historyNav() checkNoErrors(component); QWebSettings::enablePersistentStorage(tmpDir()); - QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create()); + QObject *wv = component.create(); QVERIFY(wv != 0); for (int i=1; i<=2; ++i) { - QTRY_COMPARE(wv->progress(), 1.0); - QCOMPARE(wv->title(),QString("Basic")); - QTRY_COMPARE(wv->icon().width(), 48); - QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/basic.png")); - QCOMPARE(wv->statusText(),QString("status here")); - QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html())); - QCOMPARE(wv->width(), 123.0); - QCOMPARE(wv->preferredWidth(), 0); - QCOMPARE(wv->zoomFactor(), 1.0); - QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html")); - QCOMPARE(wv->status(), QDeclarativeWebView::Ready); - QVERIFY(wv->reloadAction()); - QVERIFY(wv->reloadAction()->isEnabled()); - QVERIFY(wv->backAction()); - QVERIFY(!wv->backAction()->isEnabled()); - QVERIFY(wv->forwardAction()); - QVERIFY(!wv->forwardAction()->isEnabled()); - QVERIFY(wv->stopAction()); - QVERIFY(!wv->stopAction()->isEnabled()); - - wv->reloadAction()->trigger(); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); + QCOMPARE(wv->property("title").toString(),QString("Basic")); + QTRY_COMPARE(qvariant_cast<QPixmap>(wv->property("icon")).width(), 48); + QCOMPARE(qvariant_cast<QPixmap>(wv->property("icon")),QPixmap(SRCDIR "/data/basic.png")); + QCOMPARE(wv->property("statusText").toString(),QString("status here")); + QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->property("html").toString())); + QCOMPARE(wv->property("width").toDouble(), 123.0); + QCOMPARE(wv->property("preferredWidth").toDouble(), 0.0); + QCOMPARE(wv->property("zoomFactor").toDouble(), 1.0); + QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/basic.html")); + QCOMPARE(wv->property("status").toInt(), 1 /*QDeclarativeWebView::Ready*/); + QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))); + QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("back"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("back"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("forward"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("forward"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("stop"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("stop"))->isEnabled()); + + qvariant_cast<QAction*>(wv->property("reload"))->trigger(); } - wv->setUrl(QUrl::fromLocalFile(SRCDIR "/data/forward.html")); - QTRY_COMPARE(wv->progress(), 1.0); - QCOMPARE(wv->title(),QString("Forward")); - QTRY_COMPARE(wv->icon().width(), 32); - QCOMPARE(wv->icon(),QPixmap(SRCDIR "/data/forward.png")); - QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/forward.html")), strippedHtml(wv->html())); - QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/forward.html")); - QCOMPARE(wv->status(), QDeclarativeWebView::Ready); - QCOMPARE(wv->statusText(),QString("")); - QVERIFY(wv->reloadAction()); - QVERIFY(wv->reloadAction()->isEnabled()); - QVERIFY(wv->backAction()); - QVERIFY(wv->backAction()->isEnabled()); - QVERIFY(wv->forwardAction()); - QVERIFY(!wv->forwardAction()->isEnabled()); - QVERIFY(wv->stopAction()); - QVERIFY(!wv->stopAction()->isEnabled()); - - wv->backAction()->trigger(); - - QTRY_COMPARE(wv->progress(), 1.0); - QCOMPARE(wv->title(),QString("Basic")); - QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->html())); - QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/basic.html")); - QCOMPARE(wv->status(), QDeclarativeWebView::Ready); - QVERIFY(wv->reloadAction()); - QVERIFY(wv->reloadAction()->isEnabled()); - QVERIFY(wv->backAction()); - QVERIFY(!wv->backAction()->isEnabled()); - QVERIFY(wv->forwardAction()); - QVERIFY(wv->forwardAction()->isEnabled()); - QVERIFY(wv->stopAction()); - QVERIFY(!wv->stopAction()->isEnabled()); + wv->setProperty("url", QUrl::fromLocalFile(SRCDIR "/data/forward.html")); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); + QCOMPARE(wv->property("title").toString(),QString("Forward")); + QTRY_COMPARE(qvariant_cast<QPixmap>(wv->property("icon")).width(), 32); + QCOMPARE(qvariant_cast<QPixmap>(wv->property("icon")),QPixmap(SRCDIR "/data/forward.png")); + QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/forward.html")), strippedHtml(wv->property("html").toString())); + QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/forward.html")); + QCOMPARE(wv->property("status").toInt(), 1 /*QDeclarativeWebView::Ready*/); + QCOMPARE(wv->property("statusText").toString(),QString("")); + QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))); + QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("back"))); + QVERIFY(qvariant_cast<QAction*>(wv->property("back"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("forward"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("forward"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("stop"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("stop"))->isEnabled()); + + qvariant_cast<QAction*>(wv->property("back"))->trigger(); + + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); + QCOMPARE(wv->property("title").toString(),QString("Basic")); + QCOMPARE(strippedHtml(fileContents(SRCDIR "/data/basic.html")), strippedHtml(wv->property("html").toString())); + QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/basic.html")); + QCOMPARE(wv->property("status").toInt(), 1 /*QDeclarativeWebView::Ready*/); + QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))); + QVERIFY(qvariant_cast<QAction*>(wv->property("reload"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("back"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("back"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("forward"))); + QVERIFY(qvariant_cast<QAction*>(wv->property("forward"))->isEnabled()); + QVERIFY(qvariant_cast<QAction*>(wv->property("stop"))); + QVERIFY(!qvariant_cast<QAction*>(wv->property("stop"))->isEnabled()); } void tst_qdeclarativewebview::multipleWindows() @@ -328,16 +325,16 @@ void tst_qdeclarativewebview::loadError() checkNoErrors(component); QWebSettings::enablePersistentStorage(tmpDir()); - QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create()); + QObject *wv = component.create(); QVERIFY(wv != 0); for (int i=1; i<=2; ++i) { - QTRY_COMPARE(wv->progress(), 1.0); - QCOMPARE(wv->title(),QString("")); - QCOMPARE(wv->statusText(),QString("")); // HTML 'status bar' text, not error message - QCOMPARE(wv->url(), QUrl::fromLocalFile(SRCDIR "/data/does-not-exist.html")); // Unlike QWebPage, which loses url - QCOMPARE(wv->status(), QDeclarativeWebView::Error); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); + QCOMPARE(wv->property("title").toString(),QString("")); + QCOMPARE(wv->property("statusText").toString(),QString("")); // HTML 'status bar' text, not error message + QCOMPARE(wv->property("url").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/does-not-exist.html")); // Unlike QWebPage, which loses url + QCOMPARE(wv->property("status").toInt(), 3 /*QDeclarativeWebView::Error*/); - wv->reloadAction()->trigger(); + qvariant_cast<QAction*>(wv->property("reload"))->trigger(); } } @@ -345,12 +342,12 @@ void tst_qdeclarativewebview::setHtml() { QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/sethtml.qml")); checkNoErrors(component); - QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create()); + QObject *wv = component.create(); QVERIFY(wv != 0); - QCOMPARE(wv->html(),QString("<html><head></head><body><p>This is a <b>string</b> set on the WebView</p></body></html>")); + QCOMPARE(wv->property("html").toString(),QString("<html><head></head><body><p>This is a <b>string</b> set on the WebView</p></body></html>")); QSignalSpy spy(wv, SIGNAL(htmlChanged())); - wv->setHtml(QString("<html><head><title>Basic</title></head><body><p>text</p></body></html>")); + wv->setProperty("html", QString("<html><head><title>Basic</title></head><body><p>text</p></body></html>")); QCOMPARE(spy.count(),1); } @@ -358,81 +355,91 @@ void tst_qdeclarativewebview::elementAreaAt() { QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/elements.qml")); checkNoErrors(component); - QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create()); + QObject *wv = component.create(); QVERIFY(wv != 0); - QTRY_COMPARE(wv->progress(), 1.0); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); + /* not now it's a plugin... QCOMPARE(wv->elementAreaAt(40,30,100,100),QRect(1,1,75,54)); // Area A in data/elements.html QCOMPARE(wv->elementAreaAt(130,30,200,100),QRect(78,3,110,50)); // Area B QCOMPARE(wv->elementAreaAt(40,30,400,400),QRect(0,0,310,100)); // Whole view QCOMPARE(wv->elementAreaAt(130,30,280,280),QRect(76,1,223,54)); // Area BC QCOMPARE(wv->elementAreaAt(130,30,400,400),QRect(0,0,310,100)); // Whole view + */ } void tst_qdeclarativewebview::javaScript() { QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/javaScript.qml")); checkNoErrors(component); - QDeclarativeWebView *wv = qobject_cast<QDeclarativeWebView*>(component.create()); + QObject *wv = component.create(); QVERIFY(wv != 0); - QTRY_COMPARE(wv->progress(), 1.0); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); + /* not now it's a plugin... QCOMPARE(wv->evaluateJavaScript("123").toInt(), 123); QCOMPARE(wv->evaluateJavaScript("window.status").toString(), QString("status here")); QCOMPARE(wv->evaluateJavaScript("window.myjsname.qmlprop").toString(), QString("qmlvalue")); + */ } +/* +Cannot be done now that webkit is a plugin + void tst_qdeclarativewebview::pixelCache() { + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/pixelCache.qml")); checkNoErrors(component); MyWebView *wv = qobject_cast<MyWebView*>(component.create()); QVERIFY(wv != 0); - QTRY_COMPARE(wv->progress(), 1.0); + QTRY_COMPARE(wv->property("progress"), 1.0); QPixmap pm(150,150); QPainter p(&pm); wv->paint(&p,0,0); const int expected = 120*(150+128); // 120 = width of HTML page, 150=pixmap height, 128=cache extra area - QCOMPARE(wv->pixelsPainted(), expected); + QCOMPARE(wv->property("pixelsPainted"), expected); wv->paint(&p,0,0); - QCOMPARE(wv->pixelsPainted(), expected); // nothing new needed to be painted - wv->setPixelCacheSize(0); // clears the cache + QCOMPARE(wv->property("pixelsPainted"), expected); // nothing new needed to be painted + wv->setProperty("pixelCacheSize", 0); // clears the cache wv->paint(&p,0,0); - QCOMPARE(wv->pixelsPainted(), expected*2); // everything needed to be painted + QCOMPARE(wv->property("pixelsPainted"), expected*2); // everything needed to be painted // Note that painted things always go into the cache (even if they don't "fit"), // just that they will be removed if anything else needs to be painted. - wv->setPixelCacheSize(expected); // won't clear the cache + wv->setProperty("pixelCacheSize", expected); // won't clear the cache wv->paint(&p,0,0); - QCOMPARE(wv->pixelsPainted(), expected*2); // still there - wv->setPixelCacheSize(expected-1); // too small - will clear the cache + QCOMPARE(wv->property("pixelsPainted"), expected*2); // still there + wv->setProperty("pixelCacheSize", expected-1); // too small - will clear the cache wv->paint(&p,0,0); - QCOMPARE(wv->pixelsPainted(), expected*3); // repainted + QCOMPARE(wv->property("pixelsPainted"), expected*3); // repainted } +*/ void tst_qdeclarativewebview::newWindowParent() { QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); checkNoErrors(component); QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create()); - QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView"); + QObject *wv = rootItem->findChild<QObject*>("webView"); QVERIFY(rootItem != 0); QVERIFY(wv != 0); - QTRY_COMPARE(wv->progress(), 1.0); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); QDeclarativeItem* oldWindowParent = rootItem->findChild<QDeclarativeItem*>("oldWindowParent"); - QCOMPARE(wv->newWindowParent(), oldWindowParent); + QCOMPARE(qvariant_cast<QDeclarativeItem*>(wv->property("newWindowParent")), oldWindowParent); QSignalSpy newWindowParentSpy(wv, SIGNAL(newWindowParentChanged())); QDeclarativeItem* newWindowParent = rootItem->findChild<QDeclarativeItem*>("newWindowParent"); - wv->setNewWindowParent(newWindowParent); + wv->setProperty("newWindowParent", QVariant::fromValue(newWindowParent)); + QVERIFY(newWindowParent); QVERIFY(oldWindowParent); QVERIFY(oldWindowParent->childItems().count() == 0); - QCOMPARE(wv->newWindowParent(), newWindowParent); + QCOMPARE(wv->property("newWindowParent"), QVariant::fromValue(newWindowParent)); QCOMPARE(newWindowParentSpy.count(),1); - wv->setNewWindowParent(newWindowParent); + wv->setProperty("newWindowParent", QVariant::fromValue(newWindowParent)); QCOMPARE(newWindowParentSpy.count(),1); - wv->setNewWindowParent(0); + wv->setProperty("newWindowParent", QVariant::fromValue((QDeclarativeItem*)0)); QCOMPARE(newWindowParentSpy.count(),2); } @@ -441,23 +448,23 @@ void tst_qdeclarativewebview::newWindowComponent() QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); checkNoErrors(component); QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create()); - QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView"); + QObject *wv = rootItem->findChild<QObject*>("webView"); QVERIFY(rootItem != 0); QVERIFY(wv != 0); - QTRY_COMPARE(wv->progress(), 1.0); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); QDeclarativeComponent substituteComponent(&engine); substituteComponent.setData("import Qt 4.6; WebView { objectName: 'newWebView'; url: 'basic.html'; }", QUrl::fromLocalFile("")); QSignalSpy newWindowComponentSpy(wv, SIGNAL(newWindowComponentChanged())); - wv->setNewWindowComponent(&substituteComponent); - QCOMPARE(wv->newWindowComponent(), &substituteComponent); + wv->setProperty("newWindowComponent", QVariant::fromValue(&substituteComponent)); + QCOMPARE(wv->property("newWindowComponent"), QVariant::fromValue(&substituteComponent)); QCOMPARE(newWindowComponentSpy.count(),1); - wv->setNewWindowComponent(&substituteComponent); + wv->setProperty("newWindowComponent", QVariant::fromValue(&substituteComponent)); QCOMPARE(newWindowComponentSpy.count(),1); - wv->setNewWindowComponent(0); + wv->setProperty("newWindowComponent", QVariant::fromValue((QDeclarativeComponent*)0)); QCOMPARE(newWindowComponentSpy.count(),2); } @@ -466,22 +473,22 @@ void tst_qdeclarativewebview::renderingEnabled() QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); checkNoErrors(component); QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create()); - QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView"); + QObject *wv = rootItem->findChild<QObject*>("webView"); QVERIFY(rootItem != 0); QVERIFY(wv != 0); - QTRY_COMPARE(wv->progress(), 1.0); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); - QVERIFY(wv->renderingEnabled()); + QVERIFY(wv->property("renderingEnabled").toBool()); QSignalSpy renderingEnabledSpy(wv, SIGNAL(renderingEnabledChanged())); - wv->setRenderingEnabled(false); - QVERIFY(!wv->renderingEnabled()); + wv->setProperty("renderingEnabled", false); + QVERIFY(!wv->property("renderingEnabled").toBool()); QCOMPARE(renderingEnabledSpy.count(),1); - wv->setRenderingEnabled(false); + wv->setProperty("renderingEnabled", false); QCOMPARE(renderingEnabledSpy.count(),1); - wv->setRenderingEnabled(true); + wv->setProperty("renderingEnabled", true); QCOMPARE(renderingEnabledSpy.count(),2); } @@ -490,21 +497,21 @@ void tst_qdeclarativewebview::pressGrabTime() QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); checkNoErrors(component); QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create()); - QDeclarativeWebView *wv = rootItem->findChild<QDeclarativeWebView*>("webView"); + QObject *wv = rootItem->findChild<QObject*>("webView"); QVERIFY(rootItem != 0); QVERIFY(wv != 0); - QTRY_COMPARE(wv->progress(), 1.0); - QCOMPARE(wv->pressGrabTime(), 200); + QTRY_COMPARE(wv->property("progress").toDouble(), 1.0); + QCOMPARE(wv->property("pressGrabTime").toInt(), 200); QSignalSpy pressGrabTimeSpy(wv, SIGNAL(pressGrabTimeChanged())); - wv->setPressGrabTime(100); - QCOMPARE(wv->pressGrabTime(), 100); + wv->setProperty("pressGrabTime", 100); + QCOMPARE(wv->property("pressGrabTime").toInt(), 100); QCOMPARE(pressGrabTimeSpy.count(),1); - wv->setPressGrabTime(100); + wv->setProperty("pressGrabTime", 100); QCOMPARE(pressGrabTimeSpy.count(),1); - wv->setPressGrabTime(0); + wv->setProperty("pressGrabTime", 0); QCOMPARE(pressGrabTimeSpy.count(),2); } diff --git a/tests/auto/declarative/qdeclarativeworkerlistmodel/data/model.qml b/tests/auto/declarative/qdeclarativeworkerlistmodel/data/model.qml new file mode 100644 index 0000000..be94e00 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeworkerlistmodel/data/model.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Item { + property alias model: model + + WorkerListModel { id: model } + + function workerModifyModel(cmd) { worker.sendMessage({'command': cmd, 'model': model}) } + + WorkerScript { + id: worker + source: "script.js" + } +} diff --git a/tests/auto/declarative/qdeclarativeworkerlistmodel/data/script.js b/tests/auto/declarative/qdeclarativeworkerlistmodel/data/script.js new file mode 100644 index 0000000..8ee62b4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeworkerlistmodel/data/script.js @@ -0,0 +1,6 @@ +WorkerScript.onMessage = function(msg) { + eval("msg.model." + msg.command) + msg.model.sync() +} + + diff --git a/tests/auto/declarative/qdeclarativeworkerlistmodel/qdeclarativeworkerlistmodel.pro b/tests/auto/declarative/qdeclarativeworkerlistmodel/qdeclarativeworkerlistmodel.pro new file mode 100644 index 0000000..960dbe1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeworkerlistmodel/qdeclarativeworkerlistmodel.pro @@ -0,0 +1,9 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +QT += script +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativeworkerlistmodel.cpp + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeworkerlistmodel/tst_qdeclarativeworkerlistmodel.cpp b/tests/auto/declarative/qdeclarativeworkerlistmodel/tst_qdeclarativeworkerlistmodel.cpp new file mode 100644 index 0000000..11a7447 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeworkerlistmodel/tst_qdeclarativeworkerlistmodel.cpp @@ -0,0 +1,193 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <qtest.h> +#include <QtCore/qdebug.h> + +#include <QtDeclarative/qdeclarativecomponent.h> +#include <QtDeclarative/qdeclarativeengine.h> +#include <QtDeclarative/qdeclarativeitem.h> + +#include <private/qdeclarativeworkerscript_p.h> +#include <private/qdeclarativelistmodel_p.h> +#include "../../../shared/util.h" + + + +class tst_QDeclarativeWorkerListModel : public QObject +{ + Q_OBJECT +public: + tst_QDeclarativeWorkerListModel() {} +private slots: + void clear(); + void remove(); + void append(); + void insert(); + void get(); + void set(); + +private: + QByteArray modificationWarning() const { + QString file = QUrl::fromLocalFile(SRCDIR "/data/model.qml").toString(); + return QString("QML WorkerListModel (" + file + ":6:5) List can only be modified from a WorkerScript").toUtf8(); + } + + QDeclarativeEngine m_engine; +}; + +void tst_QDeclarativeWorkerListModel::clear() +{ + QDeclarativeComponent component(&m_engine, SRCDIR "/data/model.qml"); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item != 0); + QDeclarativeWorkerListModel *model = item->property("model").value<QDeclarativeWorkerListModel*>(); + QVERIFY(model != 0); + + QCOMPARE(model->count(), 0); + QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "append({'name': 'A'})"))); + QTRY_COMPARE(model->count(), 1); + + QTest::ignoreMessage(QtWarningMsg, modificationWarning().constData()); + model->clear(); + QCOMPARE(model->count(), 1); + + QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "clear()"))); + QTRY_COMPARE(model->count(), 0); + + qApp->processEvents(); +} + +void tst_QDeclarativeWorkerListModel::remove() +{ + QDeclarativeComponent component(&m_engine, SRCDIR "/data/model.qml"); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item != 0); + QDeclarativeWorkerListModel *model = item->property("model").value<QDeclarativeWorkerListModel*>(); + QVERIFY(model != 0); + + QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "append({'name': 'A'})"))); + QTRY_COMPARE(model->count(), 1); + + QTest::ignoreMessage(QtWarningMsg, modificationWarning().constData()); + model->remove(0); + QCOMPARE(model->count(), 1); + + QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "remove(0)"))); + QTRY_COMPARE(model->count(), 0); + + qApp->processEvents(); +} + +void tst_QDeclarativeWorkerListModel::append() +{ + QDeclarativeComponent component(&m_engine, SRCDIR "/data/model.qml"); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item != 0); + QDeclarativeWorkerListModel *model = item->property("model").value<QDeclarativeWorkerListModel*>(); + QVERIFY(model != 0); + + QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "append({'name': 'A'})"))); + QTRY_COMPARE(model->count(), 1); + + QTest::ignoreMessage(QtWarningMsg, modificationWarning().constData()); + model->append(QScriptValue(1)); + QCOMPARE(model->count(), 1); + + qApp->processEvents(); +} + +void tst_QDeclarativeWorkerListModel::insert() +{ + QDeclarativeComponent component(&m_engine, SRCDIR "/data/model.qml"); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item != 0); + QDeclarativeWorkerListModel *model = item->property("model").value<QDeclarativeWorkerListModel*>(); + QVERIFY(model != 0); + + QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "insert(0, {'name': 'A'})"))); + QTRY_COMPARE(model->count(), 1); + + QTest::ignoreMessage(QtWarningMsg, modificationWarning().constData()); + model->insert(0, QScriptValue(1)); + QCOMPARE(model->count(), 1); + + qApp->processEvents(); +} + +void tst_QDeclarativeWorkerListModel::get() +{ + QDeclarativeComponent component(&m_engine, SRCDIR "/data/model.qml"); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item != 0); + QDeclarativeWorkerListModel *model = item->property("model").value<QDeclarativeWorkerListModel*>(); + QVERIFY(model != 0); + + QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "append({'name': 'A'})"))); + QTRY_COMPARE(model->count(), 1); + QCOMPARE(model->get(0).property("name").toString(), QString("A")); + + qApp->processEvents(); +} + +void tst_QDeclarativeWorkerListModel::set() +{ + QDeclarativeComponent component(&m_engine, SRCDIR "/data/model.qml"); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item != 0); + QDeclarativeWorkerListModel *model = item->property("model").value<QDeclarativeWorkerListModel*>(); + QVERIFY(model != 0); + + QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "append({'name': 'A'})"))); + QTRY_COMPARE(model->count(), 1); + + QTest::ignoreMessage(QtWarningMsg, modificationWarning().constData()); + model->set(0, QScriptValue(1)); + + QVERIFY(QMetaObject::invokeMethod(item, "workerModifyModel", Q_ARG(QVariant, "set(0, {'name': 'Z'})"))); + QTRY_COMPARE(model->get(0).property("name").toString(), QString("Z")); + + qApp->processEvents(); +} + +QTEST_MAIN(tst_QDeclarativeWorkerListModel) + +#include "tst_qdeclarativeworkerlistmodel.moc" + diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script.js b/tests/auto/declarative/qdeclarativeworkerscript/data/script.js new file mode 100644 index 0000000..09199de --- /dev/null +++ b/tests/auto/declarative/qdeclarativeworkerscript/data/script.js @@ -0,0 +1,5 @@ +WorkerScript.onMessage = function(msg) { + WorkerScript.sendMessage(msg) +} + + diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml new file mode 100644 index 0000000..1fce155 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml @@ -0,0 +1,24 @@ +import Qt 4.6 + +WorkerScript { + id: worker + source: "script.js" + + property var response + + signal done() + + function testSend(value) { + worker.sendMessage(value) + } + + function compareLiteralResponse(expected) { + var e = eval('(' + expected + ')') + return worker.response == e + } + + onMessage: { + worker.response = messageObject + worker.done() + } +} diff --git a/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro b/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro new file mode 100644 index 0000000..0543ff6 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro @@ -0,0 +1,9 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +QT += script +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativeworkerscript.cpp + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp new file mode 100644 index 0000000..27ecef4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp @@ -0,0 +1,194 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite 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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <qtest.h> +#include <QtCore/qdebug.h> +#include <QtCore/qtimer.h> +#include <QtScript/qscriptengine.h> + +#include <QtDeclarative/qdeclarativecomponent.h> +#include <QtDeclarative/qdeclarativeengine.h> +#include <QtDeclarative/qdeclarativeitem.h> + +#include <private/qdeclarativeworkerscript_p.h> +#include <private/qdeclarativeengine_p.h> +#include "../../../shared/util.h" + +Q_DECLARE_METATYPE(QScriptValue) + +class tst_QDeclarativeWorkerScript : public QObject +{ + Q_OBJECT +public: + tst_QDeclarativeWorkerScript() {} +private slots: + void source(); + void source_data(); + void messaging(); + void messaging_data(); + void messaging_sendQObjectList(); + void messaging_sendJsObject(); + +private: + void waitForEchoMessage(QDeclarativeWorkerScript *worker) { + QEventLoop loop; + QVERIFY(connect(worker, SIGNAL(done()), &loop, SLOT(quit()))); + QTimer timer; + timer.setSingleShot(true); + connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + timer.start(10000); + loop.exec(); + QVERIFY(timer.isActive()); + } + + QDeclarativeEngine m_engine; +}; + +void tst_QDeclarativeWorkerScript::source() +{ + QFETCH(QUrl, source); + QFETCH(bool, valid); + + if (!valid) { + QByteArray w = "WorkerScript: Cannot find source file \"" + source.toString().toUtf8() + "\""; + QTest::ignoreMessage(QtWarningMsg, w.constData()); + } + + QDeclarativeComponent component(&m_engine); + component.setData("import Qt 4.6\nWorkerScript { source: '" + source.toString().toUtf8() + "'; }", QUrl()); + + QDeclarativeWorkerScript *item = qobject_cast<QDeclarativeWorkerScript*>(component.create()); + QVERIFY(item != 0); + + QCOMPARE(item->source(), source); + + qApp->processEvents(); +} + +void tst_QDeclarativeWorkerScript::source_data() +{ + QTest::addColumn<QUrl>("source"); + QTest::addColumn<bool>("valid"); + + QTest::newRow("valid") << QUrl::fromLocalFile(SRCDIR "/data/worker.qml") << true; + QTest::newRow("invalid") << QUrl::fromLocalFile("asdjfk.js") << false; +} + +void tst_QDeclarativeWorkerScript::messaging() +{ + QFETCH(QVariant, value); + + QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker.qml"); + QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create()); + QVERIFY(worker != 0); + + QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value))); + waitForEchoMessage(worker); + + const QMetaObject *mo = worker->metaObject(); + QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value); + + qApp->processEvents(); +} + +void tst_QDeclarativeWorkerScript::messaging_data() +{ + QTest::addColumn<QVariant>("value"); + + QTest::newRow("invalid") << QVariant(); + QTest::newRow("bool") << qVariantFromValue(true); + QTest::newRow("int") << qVariantFromValue(1001); + QTest::newRow("real") << qVariantFromValue(10334.323); + QTest::newRow("string") << qVariantFromValue(QString("More cheeeese, Gromit!")); + QTest::newRow("variant list") << qVariantFromValue((QVariantList() << "a" << "b" << "c")); +} + +void tst_QDeclarativeWorkerScript::messaging_sendQObjectList() +{ + // Not allowed to send QObjects other than QDeclarativeWorkerListModelAgent + // instances. If objects are sent in a list, they will be sent as 'undefined' + // js values. + + QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker.qml"); + QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create()); + QVERIFY(worker != 0); + + QVariantList objects; + for (int i=0; i<3; i++) + objects << qVariantFromValue(new QObject(this)); + + QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, qVariantFromValue(objects)))); + waitForEchoMessage(worker); + + const QMetaObject *mo = worker->metaObject(); + QVariantList result = mo->property(mo->indexOfProperty("response")).read(worker).value<QVariantList>(); + QCOMPARE(result, (QVariantList() << QVariant() << QVariant() << QVariant())); + + qApp->processEvents(); +} + +void tst_QDeclarativeWorkerScript::messaging_sendJsObject() +{ + QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker.qml"); + QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create()); + QVERIFY(worker != 0); + + QString jsObject = "{'name': 'zyz', 'spell power': 3101, 'haste': 1125}"; + + QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(worker)); + QScriptValue sv = engine->newObject(); + sv.setProperty("name", "zyz"); + sv.setProperty("spell power", 3101); + sv.setProperty("haste", 1125); + + QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, qVariantFromValue(sv)))); + waitForEchoMessage(worker); + + QVariant result = qVariantFromValue(false); + QVERIFY(QMetaObject::invokeMethod(worker, "compareLiteralResponse", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, jsObject))); + QVERIFY(result.toBool()); + + qApp->processEvents(); +} + +QTEST_MAIN(tst_QDeclarativeWorkerScript) + +#include "tst_qdeclarativeworkerscript.moc" diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp index 37d48fa..7dec0ee 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp @@ -1168,7 +1168,7 @@ void tst_qdeclarativexmlhttprequest::redirects() TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirecttarget.html"); - server.serveDirectory("data"); + server.serveDirectory(SRCDIR "/data"); QDeclarativeComponent component(&engine, TEST_FILE("redirects.qml")); QObject *object = component.beginCreate(engine.rootContext()); @@ -1187,7 +1187,7 @@ void tst_qdeclarativexmlhttprequest::redirects() TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirectmissing.html"); - server.serveDirectory("data"); + server.serveDirectory(SRCDIR "/data"); QDeclarativeComponent component(&engine, TEST_FILE("redirectError.qml")); QObject *object = component.beginCreate(engine.rootContext()); @@ -1206,7 +1206,7 @@ void tst_qdeclarativexmlhttprequest::redirects() TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirect.html"); - server.serveDirectory("data"); + server.serveDirectory(SRCDIR "/data"); QDeclarativeComponent component(&engine, TEST_FILE("redirectRecur.qml")); QObject *object = component.beginCreate(engine.rootContext()); diff --git a/tests/auto/declarative/runall.sh b/tests/auto/declarative/runall.sh index 39485d3..62e03e3 100755 --- a/tests/auto/declarative/runall.sh +++ b/tests/auto/declarative/runall.sh @@ -41,37 +41,60 @@ ## ############################################################################/ -Xnest :7 2>/dev/null & -sleep 1 -trap "kill $!" EXIT -export DISPLAY=:7 +if [ "$(uname)" = Linux ] +then + Xnest :7 2>/dev/null & + sleep 1 + trap "kill $!" EXIT + export DISPLAY=:7 + export LANG=en_US + kwin 2>/dev/null & + sleep 1 +fi -( make -k -j1 install 2>&1; - for exe in $(make install | sed -n 's/^install .* "\([^"]*qt4\/tst_[^"]*\)".*/\1/p') - do - $exe - done -) | +function filter +{ + exe=$1 + skip=0 while read line do - case "$line" in - make*Error) echo "$line";; - make*Stop) echo "$line";; - make*) ;; - install*) ;; - */qmake*) ;; - */bin/moc*) ;; - *targ.debug*) ;; - g++*) ;; - cd*) ;; - PASS*) ;; - QDEBUG*) ;; - Makefile*) ;; - Config*) ;; - Totals*) ;; - \**) ;; - ./*) ;; - *) echo "$line" - esac + if [ $skip != 0 ] + then + let skip=skip-1 + else + case "$line" in + make*Error) echo "$line";; + make*Stop) echo "$line";; + /*/bin/make*) ;; + make*) ;; + install*) ;; + QDeclarativeDebugServer:*Waiting*) ;; + QDeclarativeDebugServer:*Connection*) ;; + */qmake*) ;; + */bin/moc*) ;; + *targ.debug*) ;; + g++*) ;; + cd*) ;; + XFAIL*) skip=1;; + SKIP*) skip=1;; + PASS*) ;; + QDEBUG*) ;; + Makefile*) ;; + Config*) ;; + Totals*) ;; + \**) ;; + ./*) ;; + *tst_*) echo "$line" ;; + *) echo "$exe: $line" + esac + fi done +} + +make -k -j1 install 2>&1 | filter build +for exe in $(make install | sed -n 's/^install .* "\([^"]*qt4\/tst_[^"]*\)".*/\1/p') +do + echo $exe + $exe 2>&1 | filter $exe +done diff --git a/tests/auto/declarative/visual/qfxwebview/autosize/autosize.qml b/tests/auto/declarative/visual/qfxwebview/autosize/autosize.qml index 74c6844..3c00ee6 100644 --- a/tests/auto/declarative/visual/qfxwebview/autosize/autosize.qml +++ b/tests/auto/declarative/visual/qfxwebview/autosize/autosize.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 // The WebView size is determined by the width, height, // preferredWidth, and preferredHeight properties. diff --git a/tests/auto/declarative/visual/webview/embedding/nesting.qml b/tests/auto/declarative/visual/webview/embedding/nesting.qml index 0d76579..5e35306 100644 --- a/tests/auto/declarative/visual/webview/embedding/nesting.qml +++ b/tests/auto/declarative/visual/webview/embedding/nesting.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { width: 300 diff --git a/tests/auto/declarative/visual/webview/javascript/evaluateJavaScript.qml b/tests/auto/declarative/visual/webview/javascript/evaluateJavaScript.qml index 78d5cfc..6c01382 100644 --- a/tests/auto/declarative/visual/webview/javascript/evaluateJavaScript.qml +++ b/tests/auto/declarative/visual/webview/javascript/evaluateJavaScript.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 Column { WebView { diff --git a/tests/auto/declarative/visual/webview/javascript/windowObjects.qml b/tests/auto/declarative/visual/webview/javascript/windowObjects.qml index a41de9a..8c52aff 100644 --- a/tests/auto/declarative/visual/webview/javascript/windowObjects.qml +++ b/tests/auto/declarative/visual/webview/javascript/windowObjects.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 Column { WebView { diff --git a/tests/auto/declarative/visual/webview/settings/fontFamily.qml b/tests/auto/declarative/visual/webview/settings/fontFamily.qml index 2bb2a53..f547b0e 100644 --- a/tests/auto/declarative/visual/webview/settings/fontFamily.qml +++ b/tests/auto/declarative/visual/webview/settings/fontFamily.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { id: web diff --git a/tests/auto/declarative/visual/webview/settings/fontSize.qml b/tests/auto/declarative/visual/webview/settings/fontSize.qml index b970783..7eaa96b 100644 --- a/tests/auto/declarative/visual/webview/settings/fontSize.qml +++ b/tests/auto/declarative/visual/webview/settings/fontSize.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 Grid { columns: 3 diff --git a/tests/auto/declarative/visual/webview/settings/noAutoLoadImages.qml b/tests/auto/declarative/visual/webview/settings/noAutoLoadImages.qml index 72e672d..67f1633 100644 --- a/tests/auto/declarative/visual/webview/settings/noAutoLoadImages.qml +++ b/tests/auto/declarative/visual/webview/settings/noAutoLoadImages.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 Grid { columns: 2 diff --git a/tests/auto/declarative/visual/webview/settings/setFontFamily.qml b/tests/auto/declarative/visual/webview/settings/setFontFamily.qml index 26deed8..823469f 100644 --- a/tests/auto/declarative/visual/webview/settings/setFontFamily.qml +++ b/tests/auto/declarative/visual/webview/settings/setFontFamily.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { url: "test.html" diff --git a/tests/auto/declarative/visual/webview/zooming/pageWidth.qml b/tests/auto/declarative/visual/webview/zooming/pageWidth.qml index 86dd7d2..4a876dd 100644 --- a/tests/auto/declarative/visual/webview/zooming/pageWidth.qml +++ b/tests/auto/declarative/visual/webview/zooming/pageWidth.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { width: 200 diff --git a/tests/auto/declarative/visual/webview/zooming/renderControl.qml b/tests/auto/declarative/visual/webview/zooming/renderControl.qml index 0c8bb3b..49eb91b 100644 --- a/tests/auto/declarative/visual/webview/zooming/renderControl.qml +++ b/tests/auto/declarative/visual/webview/zooming/renderControl.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 Rectangle { width: 200 diff --git a/tests/auto/declarative/visual/webview/zooming/resolution.qml b/tests/auto/declarative/visual/webview/zooming/resolution.qml index a9d4e3a..8542768 100644 --- a/tests/auto/declarative/visual/webview/zooming/resolution.qml +++ b/tests/auto/declarative/visual/webview/zooming/resolution.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { width: 200 * zoomFactor diff --git a/tests/auto/declarative/visual/webview/zooming/zoomTextOnly.qml b/tests/auto/declarative/visual/webview/zooming/zoomTextOnly.qml index 4455b43..c2e9348 100644 --- a/tests/auto/declarative/visual/webview/zooming/zoomTextOnly.qml +++ b/tests/auto/declarative/visual/webview/zooming/zoomTextOnly.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 WebView { width: 200 diff --git a/tests/auto/declarative/visual/webview/zooming/zooming.qml b/tests/auto/declarative/visual/webview/zooming/zooming.qml index 0ea9131..9f0b865 100644 --- a/tests/auto/declarative/visual/webview/zooming/zooming.qml +++ b/tests/auto/declarative/visual/webview/zooming/zooming.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import org.webkit 1.0 // Note that zooming is better done using zoomFactor and careful // control of rendering to avoid excessive re-rendering during diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp index 3745767..12c5843 100644 --- a/tests/auto/headers/tst_headers.cpp +++ b/tests/auto/headers/tst_headers.cpp @@ -271,6 +271,7 @@ void tst_Headers::macros() if (header.endsWith("_p.h") || header.endsWith("_pch.h") || header.contains("global/qconfig-") || header.endsWith("/qconfig.h") || header.contains("/src/tools/") || header.contains("/src/plugins/") + || header.contains("/src/imports/") || header.endsWith("/qiconset.h") || header.endsWith("/qfeatures.h") || header.endsWith("qt_windows.h")) return; diff --git a/tests/benchmarks/declarative/binding/binding.pro b/tests/benchmarks/declarative/binding/binding.pro index aa4cc41..5ceaf34 100644 --- a/tests/benchmarks/declarative/binding/binding.pro +++ b/tests/benchmarks/declarative/binding/binding.pro @@ -7,6 +7,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_binding.cpp testtypes.cpp HEADERS += testtypes.h +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" + symbian* { data.sources = data/* data.path = data diff --git a/tests/benchmarks/declarative/binding/data/idproperty.txt b/tests/benchmarks/declarative/binding/data/idproperty.txt index 71e3c4e..4e474ba 100644 --- a/tests/benchmarks/declarative/binding/data/idproperty.txt +++ b/tests/benchmarks/declarative/binding/data/idproperty.txt @@ -1,7 +1,7 @@ import Test 1.0 MyQmlObject { - id: MyObject + id: myObject MyQmlObject { result: ### diff --git a/tests/benchmarks/declarative/binding/data/objectproperty.txt b/tests/benchmarks/declarative/binding/data/objectproperty.txt index 63fa74d..6133dd6 100644 --- a/tests/benchmarks/declarative/binding/data/objectproperty.txt +++ b/tests/benchmarks/declarative/binding/data/objectproperty.txt @@ -1,7 +1,7 @@ import Test 1.0 MyQmlObject { - id: MyObject + id: myObject result: ### } diff --git a/tests/benchmarks/declarative/binding/testtypes.h b/tests/benchmarks/declarative/binding/testtypes.h index 4b103ce..523f94d 100644 --- a/tests/benchmarks/declarative/binding/testtypes.h +++ b/tests/benchmarks/declarative/binding/testtypes.h @@ -50,7 +50,7 @@ class MyQmlObject : public QObject Q_PROPERTY(int result READ result WRITE setResult); Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged); Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged); - Q_PROPERTY(QDeclarativeList<QObject *> *data READ data); + Q_PROPERTY(QDeclarativeListProperty<QObject> data READ data); Q_CLASSINFO("DefaultProperty", "data"); public: MyQmlObject() : m_result(0), m_value(0), m_object(0) {} @@ -61,7 +61,7 @@ public: int value() const { return m_value; } void setValue(int v) { m_value = v; emit valueChanged(); } - QDeclarativeList<QObject *> *data() { return &m_data; } + QDeclarativeListProperty<QObject> data() { return QDeclarativeListProperty<QObject>(this, m_data); } MyQmlObject *object() const { return m_object; } void setObject(MyQmlObject *o) { m_object = o; emit objectChanged(); } @@ -71,7 +71,7 @@ signals: void objectChanged(); private: - QDeclarativeConcreteList<QObject *> m_data; + QList<QObject *> m_data; int m_result; int m_value; MyQmlObject *m_object; diff --git a/tests/benchmarks/declarative/binding/tst_binding.cpp b/tests/benchmarks/declarative/binding/tst_binding.cpp index ee529a7..dbddac3 100644 --- a/tests/benchmarks/declarative/binding/tst_binding.cpp +++ b/tests/benchmarks/declarative/binding/tst_binding.cpp @@ -103,8 +103,8 @@ void tst_binding::objectproperty_data() QTest::addColumn<QString>("file"); QTest::addColumn<QString>("binding"); - QTest::newRow("object.value") << "data/objectproperty.txt" << "object.value"; - QTest::newRow("object.value + 10") << "data/objectproperty.txt" << "object.value + 10"; + QTest::newRow("object.value") << SRCDIR "/data/objectproperty.txt" << "object.value"; + QTest::newRow("object.value + 10") << SRCDIR "/data/objectproperty.txt" << "object.value + 10"; } void tst_binding::objectproperty() @@ -132,13 +132,13 @@ void tst_binding::basicproperty_data() QTest::addColumn<QString>("file"); QTest::addColumn<QString>("binding"); - QTest::newRow("value") << "data/localproperty.txt" << "value"; - QTest::newRow("value + 10") << "data/localproperty.txt" << "value + 10"; - QTest::newRow("value + value + 10") << "data/localproperty.txt" << "value + value + 10"; + QTest::newRow("value") << SRCDIR "/data/localproperty.txt" << "value"; + QTest::newRow("value + 10") << SRCDIR "/data/localproperty.txt" << "value + 10"; + QTest::newRow("value + value + 10") << SRCDIR "/data/localproperty.txt" << "value + value + 10"; - QTest::newRow("MyObject.value") << "data/idproperty.txt" << "MyObject.value"; - QTest::newRow("MyObject.value + 10") << "data/idproperty.txt" << "MyObject.value + 10"; - QTest::newRow("MyObject.value + MyObject.value + 10") << "data/idproperty.txt" << "MyObject.value + MyObject.value + 10"; + QTest::newRow("myObject.value") << SRCDIR "/data/idproperty.txt" << "myObject.value"; + QTest::newRow("myObject.value + 10") << SRCDIR "/data/idproperty.txt" << "myObject.value + 10"; + QTest::newRow("myObject.value + myObject.value + 10") << SRCDIR "/data/idproperty.txt" << "myObject.value + myObject.value + 10"; } void tst_binding::basicproperty() diff --git a/tests/benchmarks/declarative/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp index 9c0fd27..4319208 100644 --- a/tests/benchmarks/declarative/creation/tst_creation.cpp +++ b/tests/benchmarks/declarative/creation/tst_creation.cpp @@ -42,7 +42,7 @@ #include <qtest.h> #include <QDeclarativeEngine> #include <QDeclarativeComponent> -#include <QDeclarativeMetaType> +#include <private/qdeclarativemetatype_p.h> #include <QDebug> #include <QGraphicsScene> #include <QGraphicsItem> @@ -339,7 +339,8 @@ void tst_creation::itemtree_data_cpp() for (int i = 0; i < 30; ++i) { QDeclarativeItem *child = new QDeclarativeItem; QDeclarativeGraphics_setParent_noEvent(child,item); - item->data()->append(child); + QDeclarativeListReference ref(item, "data"); + ref.append(child); } delete item; } diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml index 69114af..dc29f15 100644 --- a/tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml @@ -1,6 +1,6 @@ import Qt 4.6 QtObject { - id: Blah + id: blah } diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml index 723e62a..e48194a 100644 --- a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml @@ -7,8 +7,8 @@ Item { id:block property int targetX: 0 property int targetY: 0 - x: SpringFollow { enabled: spawned; source: targetX; spring: 2; damping: 0.2 } - y: SpringFollow { source: targetY; spring: 2; damping: 0.2 } + SpringFollow on x { enabled: spawned; source: targetX; spring: 2; damping: 0.2 } + SpringFollow on y { source: targetY; spring: 2; damping: 0.2 } Image { id: img source: { @@ -21,7 +21,7 @@ Item { id:block } } opacity: 0 - opacity: Behavior { NumberAnimation { duration: 200 } } + Behavior on opacity { NumberAnimation { duration: 200 } } anchors.fill: parent } diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro b/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro index 12fa9f4..30ef235 100644 --- a/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro +++ b/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro @@ -7,6 +7,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativecomponent.cpp testtypes.cpp HEADERS += testtypes.h +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" + symbian* { data.sources = data/* data.path = data diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h b/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h index 4b103ce..523f94d 100644 --- a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h +++ b/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h @@ -50,7 +50,7 @@ class MyQmlObject : public QObject Q_PROPERTY(int result READ result WRITE setResult); Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged); Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged); - Q_PROPERTY(QDeclarativeList<QObject *> *data READ data); + Q_PROPERTY(QDeclarativeListProperty<QObject> data READ data); Q_CLASSINFO("DefaultProperty", "data"); public: MyQmlObject() : m_result(0), m_value(0), m_object(0) {} @@ -61,7 +61,7 @@ public: int value() const { return m_value; } void setValue(int v) { m_value = v; emit valueChanged(); } - QDeclarativeList<QObject *> *data() { return &m_data; } + QDeclarativeListProperty<QObject> data() { return QDeclarativeListProperty<QObject>(this, m_data); } MyQmlObject *object() const { return m_object; } void setObject(MyQmlObject *o) { m_object = o; emit objectChanged(); } @@ -71,7 +71,7 @@ signals: void objectChanged(); private: - QDeclarativeConcreteList<QObject *> m_data; + QList<QObject *> m_data; int m_result; int m_value; MyQmlObject *m_object; diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp b/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp index 7065303..4b1456e 100644 --- a/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp +++ b/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp @@ -90,13 +90,13 @@ void tst_qmlcomponent::creation_data() { QTest::addColumn<QString>("file"); - QTest::newRow("Object") << "data/object.qml"; - QTest::newRow("Object - Id") << "data/object_id.qml"; - QTest::newRow("MyQmlObject") << "data/myqmlobject.qml"; - QTest::newRow("MyQmlObject: basic binding") << "data/myqmlobject_binding.qml"; - QTest::newRow("Synthesized properties") << "data/synthesized_properties.qml"; - QTest::newRow("Synthesized properties.2") << "data/synthesized_properties.2.qml"; - QTest::newRow("SameGame - BoomBlock") << "data/samegame/BoomBlock.qml"; + QTest::newRow("Object") << SRCDIR "/data/object.qml"; + QTest::newRow("Object - Id") << SRCDIR "/data/object_id.qml"; + QTest::newRow("MyQmlObject") << SRCDIR "/data/myqmlobject.qml"; + QTest::newRow("MyQmlObject: basic binding") << SRCDIR "/data/myqmlobject_binding.qml"; + QTest::newRow("Synthesized properties") << SRCDIR "/data/synthesized_properties.qml"; + QTest::newRow("Synthesized properties.2") << SRCDIR "/data/synthesized_properties.2.qml"; + QTest::newRow("SameGame - BoomBlock") << SRCDIR "/data/samegame/BoomBlock.qml"; } void tst_qmlcomponent::creation() diff --git a/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro b/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro index 8070768..79fdd26 100644 --- a/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro +++ b/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro @@ -6,3 +6,5 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativemetaproperty.cpp +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp b/tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp index dae1751..8a5f4ae 100644 --- a/tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp +++ b/tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp @@ -42,7 +42,7 @@ #include <qtest.h> #include <QDeclarativeEngine> #include <QDeclarativeComponent> -#include <QDeclarativeMetaProperty> +#include <QDeclarativeProperty> #include <QFile> #include <QDebug> @@ -89,8 +89,8 @@ void tst_qmlmetaproperty::lookup_data() { QTest::addColumn<QString>("file"); - QTest::newRow("Simple Object") << "data/object.qml"; - QTest::newRow("Synthesized Object") << "data/synthesized_object.qml"; + QTest::newRow("Simple Object") << SRCDIR "/data/object.qml"; + QTest::newRow("Synthesized Object") << SRCDIR "/data/synthesized_object.qml"; } void tst_qmlmetaproperty::lookup() @@ -103,7 +103,7 @@ void tst_qmlmetaproperty::lookup() QObject *obj = c.create(); QBENCHMARK { - QDeclarativeMetaProperty p(obj, "x"); + QDeclarativeProperty p(obj, "x"); } delete obj; diff --git a/tests/benchmarks/declarative/script/tst_script.cpp b/tests/benchmarks/declarative/script/tst_script.cpp index 61f5fc8..9dd4076 100644 --- a/tests/benchmarks/declarative/script/tst_script.cpp +++ b/tests/benchmarks/declarative/script/tst_script.cpp @@ -96,11 +96,6 @@ private slots: private: }; -void tst_script::initTestCase() -{ - QML_REGISTER_TYPE(Qt.test, 1, 0, TestObject, TestObject); -} - inline QUrl TEST_FILE(const QString &filename) { return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); @@ -147,6 +142,12 @@ int TestObject::x() return m_x++; } +void tst_script::initTestCase() +{ + QML_REGISTER_TYPE(Qt.test, 1, 0, TestObject, TestObject); +} + + #define PROPERTY_PROGRAM \ "(function(testObject) { return (function() { " \ " var test = 0; " \ diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 6339813..a4de339 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -311,8 +311,11 @@ int main(int argc, char ** argv) usage(); } + viewer.addLibraryPath(QCoreApplication::applicationDirPath()); + foreach (QString lib, libraries) viewer.addLibraryPath(lib); + viewer.setNetworkCacheSize(cache); viewer.setRecordFile(recordfile); if (resizeview) diff --git a/tools/qml/qfxtester.h b/tools/qml/qfxtester.h index 1a9f077..6521409 100644 --- a/tools/qml/qfxtester.h +++ b/tools/qml/qfxtester.h @@ -54,12 +54,12 @@ QT_BEGIN_NAMESPACE class QDeclarativeVisualTest : public QObject { Q_OBJECT - Q_PROPERTY(QList<QObject *>* events READ events CONSTANT) + Q_PROPERTY(QDeclarativeListProperty<QObject> events READ events CONSTANT) Q_CLASSINFO("DefaultProperty", "events") public: QDeclarativeVisualTest() {} - QList<QObject *> *events() { return &m_events; } + QDeclarativeListProperty<QObject> events() { return QDeclarativeListProperty<QObject>(this, m_events); } int count() const { return m_events.count(); } QObject *event(int idx) { return m_events.at(idx); } |