From 3a5396262602ca117eeba2d8763555bd03fd7bf5 Mon Sep 17 00:00:00 2001 From: artoka Date: Thu, 17 Nov 2011 15:50:01 +0100 Subject: threading/ threadedlistmodel and workerscript example modifications Modified examples to use centralized qmlapplicationviewer, removed duplicate files and modified project files according to the changes. Merge-request: 2719 Reviewed-by: Casper van Donderen --- .../threading/threadedlistmodel/dataloader.js | 49 ----------- .../threading/threadedlistmodel/main.cpp | 54 ++++++++++++ .../qml/threadedlistmodel/dataloader.js | 49 +++++++++++ .../qml/threadedlistmodel/timedisplay.qml | 76 +++++++++++++++++ .../threadedlistmodel/threadedlistmodel.desktop | 11 +++ .../threadedlistmodel/threadedlistmodel.pro | 37 ++++++++ .../threadedlistmodel/threadedlistmodel.qmlproject | 6 +- .../threadedlistmodel/threadedlistmodel.svg | 93 +++++++++++++++++++++ .../threadedlistmodel/threadedlistmodel64.png | Bin 0 -> 3400 bytes .../threadedlistmodel/threadedlistmodel80.png | Bin 0 -> 4945 bytes .../threadedlistmodel_harmattan.desktop | 11 +++ .../threading/threadedlistmodel/timedisplay.qml | 76 ----------------- .../declarative/threading/workerscript/main.cpp | 54 ++++++++++++ .../workerscript/qml/workerscript/workerscript.js | 15 ++++ .../workerscript/qml/workerscript/workerscript.qml | 83 ++++++++++++++++++ .../threading/workerscript/workerscript.desktop | 11 +++ .../threading/workerscript/workerscript.js | 15 ---- .../threading/workerscript/workerscript.pro | 37 ++++++++ .../threading/workerscript/workerscript.qml | 83 ------------------ .../threading/workerscript/workerscript.qmlproject | 6 +- .../threading/workerscript/workerscript.svg | 93 +++++++++++++++++++++ .../threading/workerscript/workerscript64.png | Bin 0 -> 3400 bytes .../threading/workerscript/workerscript80.png | Bin 0 -> 4945 bytes .../workerscript/workerscript_harmattan.desktop | 11 +++ 24 files changed, 641 insertions(+), 229 deletions(-) delete mode 100644 examples/declarative/threading/threadedlistmodel/dataloader.js create mode 100644 examples/declarative/threading/threadedlistmodel/main.cpp create mode 100644 examples/declarative/threading/threadedlistmodel/qml/threadedlistmodel/dataloader.js create mode 100644 examples/declarative/threading/threadedlistmodel/qml/threadedlistmodel/timedisplay.qml create mode 100644 examples/declarative/threading/threadedlistmodel/threadedlistmodel.desktop create mode 100644 examples/declarative/threading/threadedlistmodel/threadedlistmodel.pro create mode 100644 examples/declarative/threading/threadedlistmodel/threadedlistmodel.svg create mode 100644 examples/declarative/threading/threadedlistmodel/threadedlistmodel64.png create mode 100644 examples/declarative/threading/threadedlistmodel/threadedlistmodel80.png create mode 100644 examples/declarative/threading/threadedlistmodel/threadedlistmodel_harmattan.desktop delete mode 100644 examples/declarative/threading/threadedlistmodel/timedisplay.qml create mode 100644 examples/declarative/threading/workerscript/main.cpp create mode 100644 examples/declarative/threading/workerscript/qml/workerscript/workerscript.js create mode 100644 examples/declarative/threading/workerscript/qml/workerscript/workerscript.qml create mode 100644 examples/declarative/threading/workerscript/workerscript.desktop delete mode 100644 examples/declarative/threading/workerscript/workerscript.js create mode 100644 examples/declarative/threading/workerscript/workerscript.pro delete mode 100644 examples/declarative/threading/workerscript/workerscript.qml create mode 100644 examples/declarative/threading/workerscript/workerscript.svg create mode 100644 examples/declarative/threading/workerscript/workerscript64.png create mode 100644 examples/declarative/threading/workerscript/workerscript80.png create mode 100644 examples/declarative/threading/workerscript/workerscript_harmattan.desktop diff --git a/examples/declarative/threading/threadedlistmodel/dataloader.js b/examples/declarative/threading/threadedlistmodel/dataloader.js deleted file mode 100644 index dffcd56..0000000 --- a/examples/declarative/threading/threadedlistmodel/dataloader.js +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// ![0] -WorkerScript.onMessage = function(msg) { - if (msg.action == 'appendCurrentTime') { - var data = {'time': new Date().toTimeString()}; - msg.model.append(data); - msg.model.sync(); // updates the changes to the list - } -} -// ![0] diff --git a/examples/declarative/threading/threadedlistmodel/main.cpp b/examples/declarative/threading/threadedlistmodel/main.cpp new file mode 100644 index 0000000..e3cd9e9 --- /dev/null +++ b/examples/declarative/threading/threadedlistmodel/main.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlapplicationviewer.h" +#include + +Q_DECL_EXPORT int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QmlApplicationViewer viewer; + viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); + viewer.setMainQmlFile(QLatin1String("qml/threadedlistmodel/timedisplay.qml")); + viewer.showExpanded(); + + return app.exec(); +} diff --git a/examples/declarative/threading/threadedlistmodel/qml/threadedlistmodel/dataloader.js b/examples/declarative/threading/threadedlistmodel/qml/threadedlistmodel/dataloader.js new file mode 100644 index 0000000..dffcd56 --- /dev/null +++ b/examples/declarative/threading/threadedlistmodel/qml/threadedlistmodel/dataloader.js @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// ![0] +WorkerScript.onMessage = function(msg) { + if (msg.action == 'appendCurrentTime') { + var data = {'time': new Date().toTimeString()}; + msg.model.append(data); + msg.model.sync(); // updates the changes to the list + } +} +// ![0] diff --git a/examples/declarative/threading/threadedlistmodel/qml/threadedlistmodel/timedisplay.qml b/examples/declarative/threading/threadedlistmodel/qml/threadedlistmodel/timedisplay.qml new file mode 100644 index 0000000..42d1345 --- /dev/null +++ b/examples/declarative/threading/threadedlistmodel/qml/threadedlistmodel/timedisplay.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// ![0] +import QtQuick 1.0 + +Rectangle { + color: "white" + width: 200 + height: 300 + + ListView { + anchors.fill: parent + model: listModel + delegate: Component { + Text { text: time } + } + + ListModel { id: listModel } + + WorkerScript { + id: worker + source: "dataloader.js" + } + + 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/examples/declarative/threading/threadedlistmodel/threadedlistmodel.desktop b/examples/declarative/threading/threadedlistmodel/threadedlistmodel.desktop new file mode 100644 index 0000000..41646a8 --- /dev/null +++ b/examples/declarative/threading/threadedlistmodel/threadedlistmodel.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=threadedlistmodel +Exec=/opt/threadedlistmodel/bin/threadedlistmodel +Icon=threadedlistmodel64 +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/declarative/threading/threadedlistmodel/threadedlistmodel.pro b/examples/declarative/threading/threadedlistmodel/threadedlistmodel.pro new file mode 100644 index 0000000..d81bf62 --- /dev/null +++ b/examples/declarative/threading/threadedlistmodel/threadedlistmodel.pro @@ -0,0 +1,37 @@ +# Add more folders to ship with the application, here +folder_01.source = qml/threadedlistmodel +folder_01.target = qml +DEPLOYMENTFOLDERS = folder_01 + +# Additional import path used to resolve QML modules in Creator's code model +QML_IMPORT_PATH = + +symbian:TARGET.UID3 = 0xE3DA53C6 + +# Smart Installer package's UID +# This UID is from the protected range and therefore the package will +# fail to install if self-signed. By default qmake uses the unprotected +# range value if unprotected UID is defined for the application and +# 0x2002CCCF value if protected UID is given to the application +#symbian:DEPLOYMENT.installer_header = 0x2002CCCF + +# Allow network access on Symbian +symbian:TARGET.CAPABILITY += NetworkServices + +# If your application uses the Qt Mobility libraries, uncomment the following +# lines and add the respective components to the MOBILITY variable. +# CONFIG += mobility +# MOBILITY += + +# Speed up launching on MeeGo/Harmattan when using applauncherd daemon +# CONFIG += qdeclarative-boostable + +# Add dependency to Symbian components +# CONFIG += qt-components + +# The .cpp file which was generated for your project. Feel free to hack it. +SOURCES += main.cpp + +# Please do not modify the following two lines. Required for deployment. +include(../../../tools/qmlapplicationviewer/qmlapplicationviewer.pri) +qtcAddDeployment() diff --git a/examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject b/examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject index fe2dc29..e462c07 100644 --- a/examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject +++ b/examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject @@ -43,13 +43,13 @@ import QmlProject 1.0 Project { /* Include .qml, .js, and image files from current directory and subdirectories */ QmlFiles { - directory: "." + directory: "qml/threadedlistmodel" } JavaScriptFiles { - directory: "." + directory: "qml/threadedlistmodel" } ImageFiles { - directory: "." + directory: "qml/threadedlistmodel" } /* List of plugin directories passed to QML runtime */ // importPaths: [ " ../exampleplugin " ] diff --git a/examples/declarative/threading/threadedlistmodel/threadedlistmodel.svg b/examples/declarative/threading/threadedlistmodel/threadedlistmodel.svg new file mode 100644 index 0000000..566acfa --- /dev/null +++ b/examples/declarative/threading/threadedlistmodel/threadedlistmodel.svg @@ -0,0 +1,93 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/threading/threadedlistmodel/threadedlistmodel64.png b/examples/declarative/threading/threadedlistmodel/threadedlistmodel64.png new file mode 100644 index 0000000..707d5c4 Binary files /dev/null and b/examples/declarative/threading/threadedlistmodel/threadedlistmodel64.png differ diff --git a/examples/declarative/threading/threadedlistmodel/threadedlistmodel80.png b/examples/declarative/threading/threadedlistmodel/threadedlistmodel80.png new file mode 100644 index 0000000..6ad8096 Binary files /dev/null and b/examples/declarative/threading/threadedlistmodel/threadedlistmodel80.png differ diff --git a/examples/declarative/threading/threadedlistmodel/threadedlistmodel_harmattan.desktop b/examples/declarative/threading/threadedlistmodel/threadedlistmodel_harmattan.desktop new file mode 100644 index 0000000..ae9851a --- /dev/null +++ b/examples/declarative/threading/threadedlistmodel/threadedlistmodel_harmattan.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=threadedlistmodel +Exec=/usr/bin/single-instance /opt/threadedlistmodel/bin/threadedlistmodel +Icon=/usr/share/icons/hicolor/80x80/apps/threadedlistmodel80.png +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/declarative/threading/threadedlistmodel/timedisplay.qml b/examples/declarative/threading/threadedlistmodel/timedisplay.qml deleted file mode 100644 index 42d1345..0000000 --- a/examples/declarative/threading/threadedlistmodel/timedisplay.qml +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// ![0] -import QtQuick 1.0 - -Rectangle { - color: "white" - width: 200 - height: 300 - - ListView { - anchors.fill: parent - model: listModel - delegate: Component { - Text { text: time } - } - - ListModel { id: listModel } - - WorkerScript { - id: worker - source: "dataloader.js" - } - - 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/examples/declarative/threading/workerscript/main.cpp b/examples/declarative/threading/workerscript/main.cpp new file mode 100644 index 0000000..78e06f6 --- /dev/null +++ b/examples/declarative/threading/workerscript/main.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlapplicationviewer.h" +#include + +Q_DECL_EXPORT int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QmlApplicationViewer viewer; + viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); + viewer.setMainQmlFile(QLatin1String("qml/workerscript/workerscript.qml")); + viewer.showExpanded(); + + return app.exec(); +} diff --git a/examples/declarative/threading/workerscript/qml/workerscript/workerscript.js b/examples/declarative/threading/workerscript/qml/workerscript/workerscript.js new file mode 100644 index 0000000..f76471f --- /dev/null +++ b/examples/declarative/threading/workerscript/qml/workerscript/workerscript.js @@ -0,0 +1,15 @@ +var lastx = 0; +var lasty = 0; + +WorkerScript.onMessage = function(message) { + var ydiff = message.y - lasty; + var xdiff = message.x - lastx; + + var total = Math.sqrt(ydiff * ydiff + xdiff * xdiff); + + lastx = message.x; + lasty = message.y; + + WorkerScript.sendMessage( {xmove: xdiff, ymove: ydiff, move: total} ); +} + diff --git a/examples/declarative/threading/workerscript/qml/workerscript/workerscript.qml b/examples/declarative/threading/workerscript/qml/workerscript/workerscript.qml new file mode 100644 index 0000000..f3ba481 --- /dev/null +++ b/examples/declarative/threading/workerscript/qml/workerscript/workerscript.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 + +Rectangle { + width: 480; height: 320 + + WorkerScript { + id: myWorker + source: "workerscript.js" + + onMessage: { + console.log("Moved " + messageObject.xmove + " along the X axis."); + console.log("Moved " + messageObject.ymove + " along the Y axis."); + console.log("Moved " + messageObject.move + " pixels."); + } + } + + Rectangle { + width: 200; height: 200 + anchors.left: parent.left; anchors.leftMargin: 20 + color: "red" + + MouseArea { + anchors.fill: parent + onClicked: myWorker.sendMessage( { rectangle: "red", x: mouse.x, y: mouse.y } ); + } + } + + Rectangle { + width: 200; height: 200 + anchors.right: parent.right; anchors.rightMargin: 20 + color: "blue" + + MouseArea { + anchors.fill: parent + onClicked: myWorker.sendMessage( { rectangle: "blue", x: mouse.x, y: mouse.y } ); + } + } + + Text { + text: "Click a Rectangle!" + anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 50 } + } +} diff --git a/examples/declarative/threading/workerscript/workerscript.desktop b/examples/declarative/threading/workerscript/workerscript.desktop new file mode 100644 index 0000000..c8e378d --- /dev/null +++ b/examples/declarative/threading/workerscript/workerscript.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=workerscript +Exec=/opt/workerscript/bin/workerscript +Icon=workerscript64 +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/declarative/threading/workerscript/workerscript.js b/examples/declarative/threading/workerscript/workerscript.js deleted file mode 100644 index f76471f..0000000 --- a/examples/declarative/threading/workerscript/workerscript.js +++ /dev/null @@ -1,15 +0,0 @@ -var lastx = 0; -var lasty = 0; - -WorkerScript.onMessage = function(message) { - var ydiff = message.y - lasty; - var xdiff = message.x - lastx; - - var total = Math.sqrt(ydiff * ydiff + xdiff * xdiff); - - lastx = message.x; - lasty = message.y; - - WorkerScript.sendMessage( {xmove: xdiff, ymove: ydiff, move: total} ); -} - diff --git a/examples/declarative/threading/workerscript/workerscript.pro b/examples/declarative/threading/workerscript/workerscript.pro new file mode 100644 index 0000000..fa60c1b --- /dev/null +++ b/examples/declarative/threading/workerscript/workerscript.pro @@ -0,0 +1,37 @@ +# Add more folders to ship with the application, here +folder_01.source = qml/workerscript +folder_01.target = qml +DEPLOYMENTFOLDERS = folder_01 + +# Additional import path used to resolve QML modules in Creator's code model +QML_IMPORT_PATH = + +symbian:TARGET.UID3 = 0xE1474B5B + +# Smart Installer package's UID +# This UID is from the protected range and therefore the package will +# fail to install if self-signed. By default qmake uses the unprotected +# range value if unprotected UID is defined for the application and +# 0x2002CCCF value if protected UID is given to the application +#symbian:DEPLOYMENT.installer_header = 0x2002CCCF + +# Allow network access on Symbian +symbian:TARGET.CAPABILITY += NetworkServices + +# If your application uses the Qt Mobility libraries, uncomment the following +# lines and add the respective components to the MOBILITY variable. +# CONFIG += mobility +# MOBILITY += + +# Speed up launching on MeeGo/Harmattan when using applauncherd daemon +# CONFIG += qdeclarative-boostable + +# Add dependency to Symbian components +# CONFIG += qt-components + +# The .cpp file which was generated for your project. Feel free to hack it. +SOURCES += main.cpp + +# Please do not modify the following two lines. Required for deployment. +include(../../../tools/qmlapplicationviewer/qmlapplicationviewer.pri) +qtcAddDeployment() diff --git a/examples/declarative/threading/workerscript/workerscript.qml b/examples/declarative/threading/workerscript/workerscript.qml deleted file mode 100644 index f3ba481..0000000 --- a/examples/declarative/threading/workerscript/workerscript.qml +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - width: 480; height: 320 - - WorkerScript { - id: myWorker - source: "workerscript.js" - - onMessage: { - console.log("Moved " + messageObject.xmove + " along the X axis."); - console.log("Moved " + messageObject.ymove + " along the Y axis."); - console.log("Moved " + messageObject.move + " pixels."); - } - } - - Rectangle { - width: 200; height: 200 - anchors.left: parent.left; anchors.leftMargin: 20 - color: "red" - - MouseArea { - anchors.fill: parent - onClicked: myWorker.sendMessage( { rectangle: "red", x: mouse.x, y: mouse.y } ); - } - } - - Rectangle { - width: 200; height: 200 - anchors.right: parent.right; anchors.rightMargin: 20 - color: "blue" - - MouseArea { - anchors.fill: parent - onClicked: myWorker.sendMessage( { rectangle: "blue", x: mouse.x, y: mouse.y } ); - } - } - - Text { - text: "Click a Rectangle!" - anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 50 } - } -} diff --git a/examples/declarative/threading/workerscript/workerscript.qmlproject b/examples/declarative/threading/workerscript/workerscript.qmlproject index d4909f8..11ae5e5 100644 --- a/examples/declarative/threading/workerscript/workerscript.qmlproject +++ b/examples/declarative/threading/workerscript/workerscript.qmlproject @@ -3,13 +3,13 @@ import QmlProject 1.0 Project { /* Include .qml, .js, and image files from current directory and subdirectories */ QmlFiles { - directory: "." + directory: "qml/workerscript" } JavaScriptFiles { - directory: "." + directory: "qml/workerscript" } ImageFiles { - directory: "." + directory: "qml/workerscript" } /* List of plugin directories passed to QML runtime */ // importPaths: [ " ../exampleplugin " ] diff --git a/examples/declarative/threading/workerscript/workerscript.svg b/examples/declarative/threading/workerscript/workerscript.svg new file mode 100644 index 0000000..566acfa --- /dev/null +++ b/examples/declarative/threading/workerscript/workerscript.svg @@ -0,0 +1,93 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/threading/workerscript/workerscript64.png b/examples/declarative/threading/workerscript/workerscript64.png new file mode 100644 index 0000000..707d5c4 Binary files /dev/null and b/examples/declarative/threading/workerscript/workerscript64.png differ diff --git a/examples/declarative/threading/workerscript/workerscript80.png b/examples/declarative/threading/workerscript/workerscript80.png new file mode 100644 index 0000000..6ad8096 Binary files /dev/null and b/examples/declarative/threading/workerscript/workerscript80.png differ diff --git a/examples/declarative/threading/workerscript/workerscript_harmattan.desktop b/examples/declarative/threading/workerscript/workerscript_harmattan.desktop new file mode 100644 index 0000000..3517ca7 --- /dev/null +++ b/examples/declarative/threading/workerscript/workerscript_harmattan.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=workerscript +Exec=/usr/bin/single-instance /opt/workerscript/bin/workerscript +Icon=/usr/share/icons/hicolor/80x80/apps/workerscript80.png +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable -- cgit v0.12