diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-03-16 01:16:13 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-03-16 01:16:13 (GMT) |
commit | 081fafe395d52ae42b57c36d1279e6ac05ae2cde (patch) | |
tree | bf1fa2e0478ed0ea89f5d03aa54555d724017d1b /examples/declarative/listmodel-threaded | |
parent | db0c932bf816b76547798ec62336e25b453d29b8 (diff) | |
download | Qt-081fafe395d52ae42b57c36d1279e6ac05ae2cde.zip Qt-081fafe395d52ae42b57c36d1279e6ac05ae2cde.tar.gz Qt-081fafe395d52ae42b57c36d1279e6ac05ae2cde.tar.bz2 |
Remove WorkerListModel and integrate its functionality into ListModel.
Task-number: QT-2829
Diffstat (limited to 'examples/declarative/listmodel-threaded')
-rw-r--r-- | examples/declarative/listmodel-threaded/dataloader.js | 14 | ||||
-rw-r--r-- | examples/declarative/listmodel-threaded/timedisplay.qml | 33 |
2 files changed, 47 insertions, 0 deletions
diff --git a/examples/declarative/listmodel-threaded/dataloader.js b/examples/declarative/listmodel-threaded/dataloader.js new file mode 100644 index 0000000..eac7478 --- /dev/null +++ b/examples/declarative/listmodel-threaded/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/listmodel-threaded/timedisplay.qml b/examples/declarative/listmodel-threaded/timedisplay.qml new file mode 100644 index 0000000..e8d8fe2 --- /dev/null +++ b/examples/declarative/listmodel-threaded/timedisplay.qml @@ -0,0 +1,33 @@ +// ![0] +import Qt 4.6 + +ListView { + width: 200 + height: 300 + + model: listModel + delegate: Component { + Text { text: time } + } + + ListModel { 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] |