From edeaf999ccf3cd9fb662b291282eb47b77a01622 Mon Sep 17 00:00:00 2001 From: Jerome Pasion Date: Wed, 16 May 2012 15:24:34 +0200 Subject: [PATCH] Local Storage: Moving local storage documentation from doc to src -A submodule of QtQuick, moving to src/quick/doc/src/localstorage Change-Id: I394ceacac695e17b656339445c22450cea973e95 Reviewed-by: Geir Vattekar --- doc/src/localstorage/localstorage.qdoc | 138 ---------------------- src/quick/doc/src/localstorage/localstorage.qdoc | 138 ++++++++++++++++++++++ 2 files changed, 138 insertions(+), 138 deletions(-) delete mode 100644 doc/src/localstorage/localstorage.qdoc create mode 100644 src/quick/doc/src/localstorage/localstorage.qdoc diff --git a/doc/src/localstorage/localstorage.qdoc b/doc/src/localstorage/localstorage.qdoc deleted file mode 100644 index 96c4432..0000000 --- a/doc/src/localstorage/localstorage.qdoc +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** 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. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -/*! -\page qml-localstorage.html -\title Local Storage -\brief SQL storage for QML - -The local storage API provides a JavaScript interface to an SQL relational -database. The QtQuick.LocalStorage module contains the API and it may be given -a namespace. - -Import QtQuick.LocalStorage module from QML: -\code -//sql.qml - -import QtQuick.LocalStorage 2.0 as Sql -\endcode - - -Import QtQuick.LocalStorage module from JavaScript: -\code -//sql.js -.import QtQuick.LocalStorage 2.0 as Sql -\endcode - -Note, importing a module from JavaScript is different from importing from QML. -The \l{JavaScript Code} article contains detailed information on importing in JavaScript code. - - -\section2 Database API - -The \c openDatabaseSync() and related functions -provide the ability to access local storage in an SQL database. - -These databases are user-specific and QML-specific, but accessible to all QML applications. -They are stored in the \c Databases subdirectory -of QQmlEngine::offlineStoragePath(), currently as SQLite databases. - -Database connections are automatically closed during Javascript garbage collection. - -The API can be used from JavaScript functions in your QML: - -\snippet declarative/sqllocalstorage/hello.qml 0 - -The API conforms to the Synchronous API of the HTML5 Web Database API, -\link http://www.w3.org/TR/2009/WD-webdatabase-20091029/ W3C Working Draft 29 October 2009\endlink. - -The \l{declarative/sqllocalstorage}{SQL Local Storage example} demonstrates the basics of -using the Local Storage API. - -\section3 db = openDatabaseSync(identifier, version, description, estimated_size, callback(db)) - -Returns the database identified by \e identifier. If the database does not already exist, it -is created, and the function \e callback is called with the database as a parameter. \e description -and \e estimated_size are written to the INI file (described below), but are otherwise currently -unused. - -May throw exception with code property SQLException.DATABASE_ERR, or SQLException.VERSION_ERR. - -When a database is first created, an INI file is also created specifying its characteristics: - -\table -\header \li \b {Key} \li \b {Value} -\row \li Name \li The name of the database passed to \c openDatabase() -\row \li Version \li The version of the database passed to \c openDatabase() -\row \li Description \li The description of the database passed to \c openDatabase() -\row \li EstimatedSize \li The estimated size (in bytes) of the database passed to \c openDatabase() -\row \li Driver \li Currently "QSQLITE" -\endtable - -This data can be used by application tools. - -\section3 db.changeVersion(from, to, callback(tx)) - -This method allows you to perform a \e{Scheme Upgrade}. - -If the current version of \e db is not \e from, then an exception is thrown. - -Otherwise, a database transaction is created and passed to \e callback. In this function, -you can call \e executeSql on \e tx to upgrade the database. - -May throw exception with code property SQLException.DATABASE_ERR or SQLException.UNKNOWN_ERR. - -\section3 db.transaction(callback(tx)) - -This method creates a read/write transaction and passed to \e callback. In this function, -you can call \e executeSql on \e tx to read and modify the database. - -If the callback throws exceptions, the transaction is rolled back. - -\section3 db.readTransaction(callback(tx)) - -This method creates a read-only transaction and passed to \e callback. In this function, -you can call \e executeSql on \e tx to read the database (with SELECT statements). - -\section3 results = tx.executeSql(statement, values) - -This method executes a SQL \e statement, binding the list of \e values to SQL positional parameters ("?"). - -It returns a results object, with the following properties: - -\table -\header \li \b {Type} \li \b {Property} \li \b {Value} \li \b {Applicability} -\row \li int \li rows.length \li The number of rows in the result \li SELECT -\row \li var \li rows.item(i) \li Function that returns row \e i of the result \li SELECT -\row \li int \li rowsAffected \li The number of rows affected by a modification \li UPDATE, DELETE -\row \li string \li insertId \li The id of the row inserted \li INSERT -\endtable - -May throw exception with code property SQLException.DATABASE_ERR, SQLException.SYNTAX_ERR, or SQLException.UNKNOWN_ERR. - - - -*/ diff --git a/src/quick/doc/src/localstorage/localstorage.qdoc b/src/quick/doc/src/localstorage/localstorage.qdoc new file mode 100644 index 0000000..96c4432 --- /dev/null +++ b/src/quick/doc/src/localstorage/localstorage.qdoc @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** GNU Free Documentation License +** 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms +** and conditions contained in a signed written agreement between you +** and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! +\page qml-localstorage.html +\title Local Storage +\brief SQL storage for QML + +The local storage API provides a JavaScript interface to an SQL relational +database. The QtQuick.LocalStorage module contains the API and it may be given +a namespace. + +Import QtQuick.LocalStorage module from QML: +\code +//sql.qml + +import QtQuick.LocalStorage 2.0 as Sql +\endcode + + +Import QtQuick.LocalStorage module from JavaScript: +\code +//sql.js +.import QtQuick.LocalStorage 2.0 as Sql +\endcode + +Note, importing a module from JavaScript is different from importing from QML. +The \l{JavaScript Code} article contains detailed information on importing in JavaScript code. + + +\section2 Database API + +The \c openDatabaseSync() and related functions +provide the ability to access local storage in an SQL database. + +These databases are user-specific and QML-specific, but accessible to all QML applications. +They are stored in the \c Databases subdirectory +of QQmlEngine::offlineStoragePath(), currently as SQLite databases. + +Database connections are automatically closed during Javascript garbage collection. + +The API can be used from JavaScript functions in your QML: + +\snippet declarative/sqllocalstorage/hello.qml 0 + +The API conforms to the Synchronous API of the HTML5 Web Database API, +\link http://www.w3.org/TR/2009/WD-webdatabase-20091029/ W3C Working Draft 29 October 2009\endlink. + +The \l{declarative/sqllocalstorage}{SQL Local Storage example} demonstrates the basics of +using the Local Storage API. + +\section3 db = openDatabaseSync(identifier, version, description, estimated_size, callback(db)) + +Returns the database identified by \e identifier. If the database does not already exist, it +is created, and the function \e callback is called with the database as a parameter. \e description +and \e estimated_size are written to the INI file (described below), but are otherwise currently +unused. + +May throw exception with code property SQLException.DATABASE_ERR, or SQLException.VERSION_ERR. + +When a database is first created, an INI file is also created specifying its characteristics: + +\table +\header \li \b {Key} \li \b {Value} +\row \li Name \li The name of the database passed to \c openDatabase() +\row \li Version \li The version of the database passed to \c openDatabase() +\row \li Description \li The description of the database passed to \c openDatabase() +\row \li EstimatedSize \li The estimated size (in bytes) of the database passed to \c openDatabase() +\row \li Driver \li Currently "QSQLITE" +\endtable + +This data can be used by application tools. + +\section3 db.changeVersion(from, to, callback(tx)) + +This method allows you to perform a \e{Scheme Upgrade}. + +If the current version of \e db is not \e from, then an exception is thrown. + +Otherwise, a database transaction is created and passed to \e callback. In this function, +you can call \e executeSql on \e tx to upgrade the database. + +May throw exception with code property SQLException.DATABASE_ERR or SQLException.UNKNOWN_ERR. + +\section3 db.transaction(callback(tx)) + +This method creates a read/write transaction and passed to \e callback. In this function, +you can call \e executeSql on \e tx to read and modify the database. + +If the callback throws exceptions, the transaction is rolled back. + +\section3 db.readTransaction(callback(tx)) + +This method creates a read-only transaction and passed to \e callback. In this function, +you can call \e executeSql on \e tx to read the database (with SELECT statements). + +\section3 results = tx.executeSql(statement, values) + +This method executes a SQL \e statement, binding the list of \e values to SQL positional parameters ("?"). + +It returns a results object, with the following properties: + +\table +\header \li \b {Type} \li \b {Property} \li \b {Value} \li \b {Applicability} +\row \li int \li rows.length \li The number of rows in the result \li SELECT +\row \li var \li rows.item(i) \li Function that returns row \e i of the result \li SELECT +\row \li int \li rowsAffected \li The number of rows affected by a modification \li UPDATE, DELETE +\row \li string \li insertId \li The id of the row inserted \li INSERT +\endtable + +May throw exception with code property SQLException.DATABASE_ERR, SQLException.SYNTAX_ERR, or SQLException.UNKNOWN_ERR. + + + +*/ -- 1.7.2.5