summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-03-02 02:07:40 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-03-02 02:07:40 (GMT)
commit8da93faace82eb2bc86e76c0ad0a0c5c95e3b8bf (patch)
tree1559fc7e2fb0b983979d5e2d9abc53c16cede957 /examples
parent5bfe57bbd1e6055e9b2d70d0b4c28052fefce430 (diff)
downloadQt-8da93faace82eb2bc86e76c0ad0a0c5c95e3b8bf.zip
Qt-8da93faace82eb2bc86e76c0ad0a0c5c95e3b8bf.tar.gz
Qt-8da93faace82eb2bc86e76c0ad0a0c5c95e3b8bf.tar.bz2
Add docs and tests for WorkerListModel.
Task-number: QT-2807
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/workerlistmodel/dataloader.js14
-rw-r--r--examples/declarative/workerlistmodel/timedisplay.qml33
2 files changed, 47 insertions, 0 deletions
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]