From a6065d60f158ffad7a94877883af69731da94295 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 29 Nov 2012 16:02:34 +0100 Subject: centralize and fixup example sources install targets follow respective change in qtbase Change-Id: I27502eb7ebea973e19ec5f7c3ec0e2338556f6e0 Reviewed-by: Oswald Buddenhagen Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com> --- .../quick/localstorage/doc/src/localstorage.qdoc | 38 +++++++++++ examples/quick/localstorage/localstorage.pro | 2 + examples/quick/localstorage/localstorage/hello.qml | 78 ++++++++++++++++++++++ .../localstorage/localstorage/localstorage.pro | 9 +++ .../localstorage/localstorage/localstorage.qml | 54 +++++++++++++++ .../localstorage/localstorage.qmlproject | 16 +++++ examples/quick/localstorage/localstorage/main.cpp | 41 ++++++++++++ 7 files changed, 238 insertions(+) create mode 100644 examples/quick/localstorage/doc/src/localstorage.qdoc create mode 100644 examples/quick/localstorage/localstorage.pro create mode 100644 examples/quick/localstorage/localstorage/hello.qml create mode 100644 examples/quick/localstorage/localstorage/localstorage.pro create mode 100644 examples/quick/localstorage/localstorage/localstorage.qml create mode 100644 examples/quick/localstorage/localstorage/localstorage.qmlproject create mode 100644 examples/quick/localstorage/localstorage/main.cpp (limited to 'examples/quick/localstorage') diff --git a/examples/quick/localstorage/doc/src/localstorage.qdoc b/examples/quick/localstorage/doc/src/localstorage.qdoc new file mode 100644 index 0000000000..45456abbab --- /dev/null +++ b/examples/quick/localstorage/doc/src/localstorage.qdoc @@ -0,0 +1,38 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \title QtQuick Examples - Local Storage + \example localstorage + \brief This is a collection of QML local storage examples + \image qml-localstorage-example.png + + This is a collection of small QML examples relating to local storage functionality. + + Hello World demos creating a simple SQL table and how to do inserting/selecting operations. + +*/ + diff --git a/examples/quick/localstorage/localstorage.pro b/examples/quick/localstorage/localstorage.pro new file mode 100644 index 0000000000..dd2eb80250 --- /dev/null +++ b/examples/quick/localstorage/localstorage.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS += localstorage diff --git a/examples/quick/localstorage/localstorage/hello.qml b/examples/quick/localstorage/localstorage/hello.qml new file mode 100644 index 0000000000..5a25052675 --- /dev/null +++ b/examples/quick/localstorage/localstorage/hello.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc 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 2.0 +import QtQuick.LocalStorage 2.0 + +Rectangle { + width: 200 + height: 100 + + Text { + text: "?" + anchors.horizontalCenter: parent.horizontalCenter + + function findGreetings() { + var db = LocalStorage.openDatabaseSync("QQmlExampleDB", "1.0", "The Example QML SQL!", 1000000); + + db.transaction( + function(tx) { + // Create the database if it doesn't already exist + tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); + + // Add (another) greeting row + tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); + + // Show all added greetings + var rs = tx.executeSql('SELECT * FROM Greeting'); + + var r = "" + for(var i = 0; i < rs.rows.length; i++) { + r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n" + } + text = r + } + ) + } + + Component.onCompleted: findGreetings() + } +} +//![0] diff --git a/examples/quick/localstorage/localstorage/localstorage.pro b/examples/quick/localstorage/localstorage/localstorage.pro new file mode 100644 index 0000000000..ef90b63546 --- /dev/null +++ b/examples/quick/localstorage/localstorage/localstorage.pro @@ -0,0 +1,9 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/localstorage/localstorage +qml.files = localstorage.qml hello.qml +qml.path = $$[QT_INSTALL_EXAMPLES]/quick/localstorage/localstorage +INSTALLS += target qml diff --git a/examples/quick/localstorage/localstorage/localstorage.qml b/examples/quick/localstorage/localstorage/localstorage.qml new file mode 100644 index 0000000000..c5b045460d --- /dev/null +++ b/examples/quick/localstorage/localstorage/localstorage.qml @@ -0,0 +1,54 @@ + /**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc 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 2.0 +import "../../shared" as Examples + +Item { + height: 480 + width: 320 + Examples.LauncherList { + id: ll + anchors.fill: parent + Component.onCompleted: { + addExample("Hello World", "Simple SQL operations with local storage API", Qt.resolvedUrl("hello.qml")); + } + } +} diff --git a/examples/quick/localstorage/localstorage/localstorage.qmlproject b/examples/quick/localstorage/localstorage/localstorage.qmlproject new file mode 100644 index 0000000000..6835d23503 --- /dev/null +++ b/examples/quick/localstorage/localstorage/localstorage.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + mainFile: "localstorage.qml" + /* Include .qml, .js, and image files from current directory and subdirectories */ + + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} \ No newline at end of file diff --git a/examples/quick/localstorage/localstorage/main.cpp b/examples/quick/localstorage/localstorage/main.cpp new file mode 100644 index 0000000000..0f69fb7fdb --- /dev/null +++ b/examples/quick/localstorage/localstorage/main.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** 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 Digia Plc 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 "../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(localstorage) -- cgit v1.2.3