summaryrefslogtreecommitdiffstats
path: root/doc/src/declarative/globalobject.qdoc
blob: 2328c8a55f62959f2ee2ad20a80b1e730d58a34e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the either Technology Preview License Agreement or the
** Beta Release License Agreement.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
\page qmlglobalobject.html
\title QML Global Object

Contains all the properties of the ECMAScript global object, plus:

\list
\o Qt
\o createQmlObject
\o createComponent
\o XMLHttpRequest
\o openDatabase
\endlist


\section1 Qt Object

\section1 Asynchronous JavaScript and XML 

\section1 Offline Storage API

The \c openDatabase() and related functions
provide the ability to access local offline storage in an SQL database.

These databases are user-specific and QML-specific. They are stored in the \c Databases subdirectory
of QmlEngine::offlineStoragePath(), currently as SQLite databases.

The API is based on the HTML5 offline storage SQL draft API. The main difference is that this QML
API is currently synchronous. You should avoid relying on synchronicity to make your scripts more
portable, both to/from HTML5 and to future QML versions.

The API can be used from JavaScript functions in your QML:

\quotefile declarative/sql/hello.qml

\section2 DbObject openDatabase(string name, string version, string description, int estimatedsize)

Opens a database identified by the given \c name and \c version.
If a database with this name and version does not exist, it is created. The \c version should
always be "1.0" until schema upgrade semantics are defined.

The \c description and \c estimatedsize are provided to allow application tools to give the user
control over the databases created, but are otherwise not used by QML.

The returned DbObject has a \c transaction() method by which SQL transactions can be done.

When a database is first created, an INI file is also created specifying its characteristics:

\table
\header \o \bold {Key} \o \bold {Value}
\row \o Name \o The name of the database passed to \c openDatabase()
\row \o Version \o The version of the database passed to \c openDatabase()
\row \o Description \o The description of the database passed to \c openDatabase()
\row \o EstimatedSize \o The estimated size of the database passed to \c openDatabase()
\row \o DbType \o Currently "QSQLITE"
\endtable

This data can be used by application tools.


\section2 void DbObject::transaction(function usesql(DbTxObject), function errorcb=0, function successcb=0)

Executes \c usesql() in a database transaction. The \c DbTxObject object has a \c executeSql() method by which the
code of \c usesql can execute SQL. The optional second and third arguments are an error callback and success
callback respectively (note that the order of these is the opposite to DbTxObject::executeSql()).

\section2 void DbTxObject::executeSql(string sql, function successcb=0, function errorcb=0)

Executes \c sql as an SQL block. The optional second and third arguments are a success callback and error
callback respectively (note that the order of these is the opposite to DbObject::transaction()).

*/