diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-18 06:51:00 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-18 06:51:00 (GMT) |
commit | a762bb1ead644e00290b2f4c023e96f5ef765d43 (patch) | |
tree | ef5cc23be286d2c6e771a04c64c32ca612dfea79 /examples | |
parent | 6dcdab8d9ee66f420a525400d873cfccf78c7003 (diff) | |
parent | fee38b5c766b0285ebd3283df0d1b29a978da316 (diff) | |
download | Qt-a762bb1ead644e00290b2f4c023e96f5ef765d43.zip Qt-a762bb1ead644e00290b2f4c023e96f5ef765d43.tar.gz Qt-a762bb1ead644e00290b2f4c023e96f5ef765d43.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: (147 commits)
Add missing semicolons. moc was confused and positionViewAtIndex not invokable.
Use the correct base URL in resolveUri
Remove timing sensitivity.
Optimize id checking.
Fix examples after 47fb07c9fdf47584ae55f3412102bbeef5576b04.
Don't use QScriptValueIterator to iterate over arrays.
Skip test, to be fixed.
Only release the binding once we're finished with its memory
Make it harder to accidentally delete a binding
Adjust test now that redundant contexts are not create due
Block modifications to internal QDeclarativeContexts
Don't destroy cookie jar until while someone may be using it.
Fix tests after 47fb07c9fdf47584ae55f3412102bbeef5576b04.
Another fix to find
Improve implicit "." import
Fix auto test
Fix type lookup with url
Fix default values on Textinput
Add an implicit import "." to types loaded from a local url
Fix crash
...
Diffstat (limited to 'examples')
28 files changed, 205 insertions, 59 deletions
diff --git a/examples/declarative/animations/color-animation.qml b/examples/declarative/animations/color-animation.qml index 6740522..025134b 100644 --- a/examples/declarative/animations/color-animation.qml +++ b/examples/declarative/animations/color-animation.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import Qt.labs.particles 1.0 Item { id: window diff --git a/examples/declarative/behaviours/behavior.qml b/examples/declarative/behaviours/behavior-example.qml index c84bf62..c84bf62 100644 --- a/examples/declarative/behaviours/behavior.qml +++ b/examples/declarative/behaviours/behavior-example.qml diff --git a/examples/declarative/colorbrowser/colorbrowser.qml b/examples/declarative/colorbrowser/colorbrowser.qml index 421ae07..d4c21e7 100644 --- a/examples/declarative/colorbrowser/colorbrowser.qml +++ b/examples/declarative/colorbrowser/colorbrowser.qml @@ -16,7 +16,7 @@ Rectangle { GridView { id: gridView; model: visualModel.parts.grid; width: mainWindow.width; height: mainWindow.height cellWidth: 160; cellHeight: 160; interactive: false - onCurrentIndexChanged: listView.positionViewAtIndex(currentIndex) + onCurrentIndexChanged: listView.positionViewAtIndex(currentIndex, ListView.Contain) } } @@ -25,7 +25,7 @@ Rectangle { ListView { id: listView; model: visualModel.parts.list; orientation: Qt.Horizontal width: mainWindow.width; height: mainWindow.height; interactive: false - onCurrentIndexChanged: gridView.positionViewAtIndex(currentIndex) + onCurrentIndexChanged: gridView.positionViewAtIndex(currentIndex, GridView.Contain) highlightRangeMode: ListView.StrictlyEnforceRange; snapMode: ListView.SnapOneItem } } diff --git a/examples/declarative/connections/connections.qml b/examples/declarative/connections/connections-example.qml index c35bda5..c35bda5 100644 --- a/examples/declarative/connections/connections.qml +++ b/examples/declarative/connections/connections-example.qml diff --git a/examples/declarative/dial/dial.qml b/examples/declarative/dial/dial-example.qml index 3aed70e..3aed70e 100644 --- a/examples/declarative/dial/dial.qml +++ b/examples/declarative/dial/dial-example.qml diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml index 6af3e81..7de4d38 100644 --- a/examples/declarative/dynamic/dynamic.qml +++ b/examples/declarative/dynamic/dynamic.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import Qt.labs.particles 1.0 import "qml" Item { diff --git a/examples/declarative/extending/adding/main.cpp b/examples/declarative/extending/adding/main.cpp index 76e0736..b9e5aa3 100644 --- a/examples/declarative/extending/adding/main.cpp +++ b/examples/declarative/extending/adding/main.cpp @@ -48,7 +48,7 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - QML_REGISTER_TYPE(People, 1,0, Person, Person); + qmlRegisterType<Person>("People", 1,0, "Person"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/attached/main.cpp b/examples/declarative/extending/attached/main.cpp index 684d8d3..fd2d525 100644 --- a/examples/declarative/extending/attached/main.cpp +++ b/examples/declarative/extending/attached/main.cpp @@ -49,12 +49,12 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - QML_REGISTER_NOCREATE_TYPE(BirthdayPartyAttached); - QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); - QML_REGISTER_NOCREATE_TYPE(ShoeDescription); - QML_REGISTER_NOCREATE_TYPE(Person); - QML_REGISTER_TYPE(People, 1,0, Boy, Boy); - QML_REGISTER_TYPE(People, 1,0, Girl, Girl); + qmlRegisterType<BirthdayPartyAttached>(); + qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty"); + qmlRegisterType<ShoeDescription>(); + qmlRegisterType<Person>(); + qmlRegisterType<Boy>("People", 1,0, "Boy"); + qmlRegisterType<Girl>("People", 1,0, "Girl"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/binding/main.cpp b/examples/declarative/extending/binding/main.cpp index 873f8c9..ce6c50d 100644 --- a/examples/declarative/extending/binding/main.cpp +++ b/examples/declarative/extending/binding/main.cpp @@ -49,14 +49,13 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - - QML_REGISTER_NOCREATE_TYPE(BirthdayPartyAttached); - QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); - QML_REGISTER_TYPE(People, 1,0, HappyBirthday, HappyBirthday); - QML_REGISTER_NOCREATE_TYPE(ShoeDescription); - QML_REGISTER_NOCREATE_TYPE(Person); - QML_REGISTER_TYPE(People, 1,0, Boy, Boy); - QML_REGISTER_TYPE(People, 1,0, Girl, Girl); + qmlRegisterType<BirthdayPartyAttached>(); + qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty"); + qmlRegisterType<HappyBirthday>("People", 1,0, "HappyBirthday"); + qmlRegisterType<ShoeDescription>(); + qmlRegisterType<Person>(); + qmlRegisterType<Boy>("People", 1,0, "Boy"); + qmlRegisterType<Girl>("People", 1,0, "Girl"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/coercion/main.cpp b/examples/declarative/extending/coercion/main.cpp index 1e2209f..312aff9 100644 --- a/examples/declarative/extending/coercion/main.cpp +++ b/examples/declarative/extending/coercion/main.cpp @@ -49,12 +49,12 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); + qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty"); // ![0] - QML_REGISTER_NOCREATE_TYPE(Person); + qmlRegisterType<Person>(); // ![0] - QML_REGISTER_TYPE(People, 1,0, Boy, Boy); - QML_REGISTER_TYPE(People, 1,0, Girl, Girl); + qmlRegisterType<Boy>("People", 1,0, "Boy"); + qmlRegisterType<Girl>("People", 1,0, "Girl"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/default/main.cpp b/examples/declarative/extending/default/main.cpp index 7d7f8a1..06282ad 100644 --- a/examples/declarative/extending/default/main.cpp +++ b/examples/declarative/extending/default/main.cpp @@ -49,10 +49,10 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); - QML_REGISTER_NOCREATE_TYPE(Person); - QML_REGISTER_TYPE(People, 1,0, Boy, Boy); - QML_REGISTER_TYPE(People, 1,0, Girl, Girl); + qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty"); + qmlRegisterType<Person>(); + qmlRegisterType<Boy>("People", 1,0, "Boy"); + qmlRegisterType<Girl>("People", 1,0, "Girl"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/extended/main.cpp b/examples/declarative/extending/extended/main.cpp index 5cbeea3..ca7242d 100644 --- a/examples/declarative/extending/extended/main.cpp +++ b/examples/declarative/extending/extended/main.cpp @@ -49,7 +49,7 @@ int main(int argc, char ** argv) { QApplication app(argc, argv); - QML_REGISTER_EXTENDED_TYPE(People, 1,0, QLineEdit, QLineEdit, LineEditExtension); + qmlRegisterExtendedType<QLineEdit, LineEditExtension>("People", 1,0, "QLineEdit"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/grouped/main.cpp b/examples/declarative/extending/grouped/main.cpp index 15a0bb5..b383a8b 100644 --- a/examples/declarative/extending/grouped/main.cpp +++ b/examples/declarative/extending/grouped/main.cpp @@ -49,11 +49,11 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); - QML_REGISTER_NOCREATE_TYPE(ShoeDescription); - QML_REGISTER_NOCREATE_TYPE(Person); - QML_REGISTER_TYPE(People, 1,0, Boy, Boy); - QML_REGISTER_TYPE(People, 1,0, Girl, Girl); + qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty"); + qmlRegisterType<ShoeDescription>(); + qmlRegisterType<Person>(); + qmlRegisterType<Boy>("People", 1,0, "Boy"); + qmlRegisterType<Girl>("People", 1,0, "Girl"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/properties/main.cpp b/examples/declarative/extending/properties/main.cpp index ce69ad2..350f8bd 100644 --- a/examples/declarative/extending/properties/main.cpp +++ b/examples/declarative/extending/properties/main.cpp @@ -49,8 +49,8 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); - QML_REGISTER_TYPE(People, 1,0, Person, Person); + qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty"); + qmlRegisterType<Person>("People", 1,0, "Person"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/signal/main.cpp b/examples/declarative/extending/signal/main.cpp index afc1a66..1b23a46 100644 --- a/examples/declarative/extending/signal/main.cpp +++ b/examples/declarative/extending/signal/main.cpp @@ -49,12 +49,12 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - QML_REGISTER_NOCREATE_TYPE(BirthdayPartyAttached); - QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); - QML_REGISTER_NOCREATE_TYPE(ShoeDescription); - QML_REGISTER_NOCREATE_TYPE(Person); - QML_REGISTER_TYPE(People, 1,0, Boy, Boy); - QML_REGISTER_TYPE(People, 1,0, Girl, Girl); + qmlRegisterType<BirthdayPartyAttached>(); + qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty"); + qmlRegisterType<ShoeDescription>(); + qmlRegisterType<Person>(); + qmlRegisterType<Boy>("People", 1,0, "Boy"); + qmlRegisterType<Girl>("People", 1,0, "Girl"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/valuesource/main.cpp b/examples/declarative/extending/valuesource/main.cpp index 873f8c9..2574917 100644 --- a/examples/declarative/extending/valuesource/main.cpp +++ b/examples/declarative/extending/valuesource/main.cpp @@ -50,13 +50,13 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - QML_REGISTER_NOCREATE_TYPE(BirthdayPartyAttached); - QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); - QML_REGISTER_TYPE(People, 1,0, HappyBirthday, HappyBirthday); - QML_REGISTER_NOCREATE_TYPE(ShoeDescription); - QML_REGISTER_NOCREATE_TYPE(Person); - QML_REGISTER_TYPE(People, 1,0, Boy, Boy); - QML_REGISTER_TYPE(People, 1,0, Girl, Girl); + qmlRegisterType<BirthdayPartyAttached>(); + qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty"); + qmlRegisterType<HappyBirthday>("People", 1,0, "HappyBirthday"); + qmlRegisterType<ShoeDescription>(); + qmlRegisterType<Person>(); + qmlRegisterType<Boy>("People", 1,0, "Boy"); + qmlRegisterType<Girl>("People", 1,0, "Girl"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/flipable/flipable.qml b/examples/declarative/flipable/flipable-example.qml index c837ebc..c837ebc 100644 --- a/examples/declarative/flipable/flipable.qml +++ b/examples/declarative/flipable/flipable-example.qml diff --git a/examples/declarative/gridview/gridview.qml b/examples/declarative/gridview/gridview-example.qml index 93931c7..93931c7 100644 --- a/examples/declarative/gridview/gridview.qml +++ b/examples/declarative/gridview/gridview-example.qml diff --git a/examples/declarative/imageprovider/imageprovider.qml b/examples/declarative/imageprovider/imageprovider-example.qml index f899b1e..a1f2794 100644 --- a/examples/declarative/imageprovider/imageprovider.qml +++ b/examples/declarative/imageprovider/imageprovider-example.qml @@ -1,5 +1,5 @@ import Qt 4.6 -import "ImageProviderCore" +import ImageProviderCore 1.0 //![0] ListView { width: 100 diff --git a/examples/declarative/workerlistmodel/dataloader.js b/examples/declarative/listmodel-threaded/dataloader.js index eac7478..eac7478 100644 --- a/examples/declarative/workerlistmodel/dataloader.js +++ b/examples/declarative/listmodel-threaded/dataloader.js diff --git a/examples/declarative/workerlistmodel/timedisplay.qml b/examples/declarative/listmodel-threaded/timedisplay.qml index 3bf2630..e8d8fe2 100644 --- a/examples/declarative/workerlistmodel/timedisplay.qml +++ b/examples/declarative/listmodel-threaded/timedisplay.qml @@ -10,7 +10,7 @@ ListView { Text { text: time } } - WorkerListModel { id: listModel } + ListModel { id: listModel } WorkerScript { id: worker diff --git a/examples/declarative/listview/listview.qml b/examples/declarative/listview/listview-example.qml index 92acce1..92acce1 100644 --- a/examples/declarative/listview/listview.qml +++ b/examples/declarative/listview/listview-example.qml diff --git a/examples/declarative/plugins/README b/examples/declarative/plugins/README index 621f570..3ae256d 100644 --- a/examples/declarative/plugins/README +++ b/examples/declarative/plugins/README @@ -1,9 +1,9 @@ -This example shows a module "com.nokia.TimeExample" that is implelement +This example shows a module "com.nokia.TimeExample" that is implemented by a C++ plugin (providing the "Time" type), and by QML files (providing the "Clock" type). To run: make install - qmlviewer plugins.qml + qml plugins.qml diff --git a/examples/declarative/plugins/plugins.qml b/examples/declarative/plugins/plugins.qml index 44b552b..449cd9a 100644 --- a/examples/declarative/plugins/plugins.qml +++ b/examples/declarative/plugins/plugins.qml @@ -1,8 +1,8 @@ import com.nokia.TimeExample 1.0 // import types from the plugin -Clock { // this class is defined in QML (files/Clock.qml) +Clock { // this class is defined in QML (com/nokia/TimeExample/Clock.qml) - Time { // this class is defined in C++ (plugins.cpp) + Time { // this class is defined in C++ (plugin.cpp) id: time } diff --git a/examples/declarative/tic-tac-toe/content/Button.qml b/examples/declarative/tic-tac-toe/content/Button.qml new file mode 100644 index 0000000..cfc2f04 --- /dev/null +++ b/examples/declarative/tic-tac-toe/content/Button.qml @@ -0,0 +1,35 @@ +import Qt 4.6 + +Rectangle { + id: container + + signal clicked + property string text: "Button" + property bool down: false + property string mainCol: "lightgray" + property string darkCol: "darkgray" + property string lightCol: "white" + + color: mainCol; smooth: true + width: txtItem.width + 20; height: txtItem.height + 6 + border.width: 1; border.color: Qt.darker(mainCol); radius: 8; + + gradient: Gradient { + GradientStop { + id: topGrad; position: 0.0 + color: if (container.down) { darkCol } else { lightCol } } + GradientStop { position: 1.0; color: mainCol } + } + + MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() } + + Text { + id: txtItem; text: container.text; + anchors.centerIn: container + color: "blue" + styleColor: "white" + style: Text.Outline + font.pixelSize: 14 + font.bold: true + } +} diff --git a/examples/declarative/tic-tac-toe/content/pics/board.png b/examples/declarative/tic-tac-toe/content/pics/board.png Binary files differindex cd85971..e7a7324 100644 --- a/examples/declarative/tic-tac-toe/content/pics/board.png +++ b/examples/declarative/tic-tac-toe/content/pics/board.png diff --git a/examples/declarative/tic-tac-toe/tic-tac-toe.qml b/examples/declarative/tic-tac-toe/tic-tac-toe.qml index 63ee483..ae187d2 100644 --- a/examples/declarative/tic-tac-toe/tic-tac-toe.qml +++ b/examples/declarative/tic-tac-toe/tic-tac-toe.qml @@ -2,11 +2,17 @@ import Qt 4.6 import "content" Item { - width: boardimage.width - height: boardimage.height + id: game + property bool show: false; + width: 440 + height: 480 + anchors.fill: parent + property real difficulty: 1.0; //chance it will actually think Image { id: boardimage + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter source: "content/pics/board.png" } @@ -31,7 +37,7 @@ Item { } Script { - function winner() + function winner(board) { for (var i=0; i<3; ++i) { if (board.children[i].state!="" @@ -68,7 +74,7 @@ Item { function makeMove(pos,player) { board.children[pos].state = player - if (winner()) { + if (winner(board)) { win(player + " wins") return true } else { @@ -78,13 +84,95 @@ Item { function computerTurn() { - // world's dumbest player - for (var i=0; i<9; ++i) + var r = Math.random(); + if(r < game.difficulty){ + smartAI(); + }else{ + randAI(); + } + } + + function smartAI() + { + function boardCopy(a){ + var ret = new Object; + ret.children = new Array(9); + for(var i = 0; i<9; i++){ + ret.children[i] = new Object; + ret.children[i].state = a.children[i].state; + } + return ret; + } + for(var i=0; i<9; i++){ + var simpleBoard = boardCopy(board); + if (board.children[i].state == "") { + simpleBoard.children[i].state = "O"; + if(winner(simpleBoard)){ + makeMove(i,"O") + return + } + } + } + for(var i=0; i<9; i++){ + var simpleBoard = boardCopy(board); + if (board.children[i].state == "") { + simpleBoard.children[i].state = "X"; + if(winner(simpleBoard)){ + makeMove(i,"O") + return + } + } + } + function thwart(a,b,c){//If they are at a, try b or c + if (board.children[a].state == "X") { + if (board.children[b].state == "") { + makeMove(b,"O") + return true + }else if (board.children[c].state == "") { + makeMove(c,"O") + return true + } + } + return false; + } + if(thwart(4,0,2)) return; + if(thwart(0,4,3)) return; + if(thwart(2,4,1)) return; + if(thwart(6,4,7)) return; + if(thwart(8,4,5)) return; + if(thwart(1,4,2)) return; + if(thwart(3,4,0)) return; + if(thwart(5,4,8)) return; + if(thwart(7,4,6)) return; + for(var i =0; i<9; i++){//Backup if (board.children[i].state == "") { makeMove(i,"O") return } - restart() + } + restart(); + } + + function randAI() + { + var open = 0; + for (var i=0; i<9; ++i) + if (board.children[i].state == "") { + open += 1; + } + if(open == 0){ + restart(); + return; + } + var openA = new Array(open);//JS doesn't have lists I can append to (i think) + var acc = 0; + for (var i=0; i<9; ++i) + if (board.children[i].state == "") { + openA[acc] = i; + acc += 1; + } + var choice = openA[Math.floor(Math.random() * open)]; + makeMove(choice, "O"); } function win(s) @@ -102,6 +190,27 @@ Item { } } + Row { + spacing: 4 + anchors.top: board.bottom + anchors.horizontalCenter: board.horizontalCenter + Button { + text: "Hard" + onClicked: game.difficulty=1.0; + down: game.difficulty == 1.0 + } + Button { + text: "Moderate" + onClicked: game.difficulty=0.8; + down: game.difficulty == 0.8 + } + Button { + text: "Easy" + onClicked: game.difficulty=0.2; + down: game.difficulty == 0.2 + } + } + Text { id: msg opacity: 0 diff --git a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml index 9ef455a..a6ef62c 100644 --- a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml +++ b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import Qt.labs.particles 1.0 Item { id:block property int type: 0 |