0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the documentation of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
/*!
|
|
43 |
\class Q3SqlFieldInfo
|
|
44 |
\brief The Q3SqlFieldInfo class stores meta data associated with a SQL field.
|
|
45 |
|
|
46 |
\compat
|
|
47 |
|
|
48 |
Q3SqlFieldInfo objects only store meta data; field values are
|
|
49 |
stored in QSqlField objects.
|
|
50 |
|
|
51 |
All values must be set in the constructor, and may be retrieved
|
|
52 |
using isRequired(), type(), length(), precision(), defaultValue(),
|
|
53 |
name(), isGenerated() and typeID().
|
|
54 |
|
|
55 |
\sa Q3SqlRecordInfo
|
|
56 |
*/
|
|
57 |
|
|
58 |
/*!
|
|
59 |
\fn Q3SqlFieldInfo::Q3SqlFieldInfo(const QString& name,
|
|
60 |
QVariant::Type typ,
|
|
61 |
int required,
|
|
62 |
int len,
|
|
63 |
int prec,
|
|
64 |
const QVariant& defValue,
|
|
65 |
int typeID,
|
|
66 |
bool generated,
|
|
67 |
bool trim,
|
|
68 |
bool calculated)
|
|
69 |
|
|
70 |
Constructs a Q3SqlFieldInfo with the following parameters:
|
|
71 |
\table
|
|
72 |
\row \i \a name \i the name of the field.
|
|
73 |
\row \i \a typ \i the field's type in a QVariant.
|
|
74 |
\row \i \a required \i greater than 0 if the field is required, 0
|
|
75 |
if its value can be NULL and less than 0 if it cannot be
|
|
76 |
determined whether the field is required or not.
|
|
77 |
\row \i \a len \i the length of the field. Note that for
|
|
78 |
non-character types some databases return either the length in
|
|
79 |
bytes or the number of digits. -1 signifies that the length cannot
|
|
80 |
be determined.
|
|
81 |
\row \i \a prec \i the precision of the field, or -1 if the field
|
|
82 |
has no precision or it cannot be determined.
|
|
83 |
\row \i \a defValue \i the default value that is inserted into
|
|
84 |
the table if none is specified by the user. QVariant() if there is
|
|
85 |
no default value or it cannot be determined.
|
|
86 |
\row \i \a typeID \i the internal typeID of the database system
|
|
87 |
(only useful for low-level programming). 0 if unknown.
|
|
88 |
\row \i \a generated \i TRUE indicates that this field should be
|
|
89 |
included in auto-generated SQL statments, e.g. in Q3SqlCursor.
|
|
90 |
\row \i \a trim \i TRUE indicates that widgets should remove
|
|
91 |
trailing whitespace from character fields. This does not affect
|
|
92 |
the field value but only its representation inside widgets.
|
|
93 |
\row \i \a calculated \i TRUE indicates that the value of this
|
|
94 |
field is calculated. The value of calculated fields can by
|
|
95 |
modified by subclassing Q3SqlCursor and overriding
|
|
96 |
Q3SqlCursor::calculateField().
|
|
97 |
\endtable
|
|
98 |
*/
|
|
99 |
|
|
100 |
/*!
|
|
101 |
\fn Q3SqlFieldInfo::~Q3SqlFieldInfo()
|
|
102 |
|
|
103 |
Destroys the object and frees any allocated resources.
|
|
104 |
*/
|
|
105 |
|
|
106 |
/*!
|
|
107 |
\fn Q3SqlFieldInfo::Q3SqlFieldInfo(const QSqlField & other)
|
|
108 |
|
|
109 |
Creates a Q3SqlFieldInfo object with the type and the name of the
|
|
110 |
QSqlField \a other.
|
|
111 |
*/
|
|
112 |
|
|
113 |
/*!
|
|
114 |
\fn bool Q3SqlFieldInfo::operator==(const Q3SqlFieldInfo& other) const
|
|
115 |
|
|
116 |
Assigns \a other to this field info and returns a reference to it.
|
|
117 |
*/
|
|
118 |
|
|
119 |
/*!
|
|
120 |
\fn QSqlField Q3SqlFieldInfo::toField() const
|
|
121 |
|
|
122 |
Returns an empty QSqlField based on the information in this
|
|
123 |
Q3SqlFieldInfo.
|
|
124 |
*/
|
|
125 |
|
|
126 |
/*!
|
|
127 |
\fn int Q3SqlFieldInfo::isRequired() const
|
|
128 |
|
|
129 |
Returns a value greater than 0 if the field is required (NULL
|
|
130 |
values are not allowed), 0 if it isn't required (NULL values are
|
|
131 |
allowed) or less than 0 if it cannot be determined whether the
|
|
132 |
field is required or not.
|
|
133 |
*/
|
|
134 |
|
|
135 |
/*!
|
|
136 |
\fn QVariant::Type Q3SqlFieldInfo::type() const
|
|
137 |
|
|
138 |
Returns the field's type or QVariant::Invalid if the type is
|
|
139 |
unknown.
|
|
140 |
*/
|
|
141 |
|
|
142 |
/*!
|
|
143 |
\fn int Q3SqlFieldInfo::length() const
|
|
144 |
|
|
145 |
Returns the field's length. For fields storing text the return
|
|
146 |
value is the maximum number of characters the field can hold. For
|
|
147 |
non-character fields some database systems return the number of
|
|
148 |
bytes needed or the number of digits allowed. If the length cannot
|
|
149 |
be determined -1 is returned.
|
|
150 |
*/
|
|
151 |
|
|
152 |
/*!
|
|
153 |
\fn int Q3SqlFieldInfo::precision() const
|
|
154 |
|
|
155 |
Returns the field's precision or -1 if the field has no precision
|
|
156 |
or it cannot be determined.
|
|
157 |
*/
|
|
158 |
|
|
159 |
/*!
|
|
160 |
\fn QVariant Q3SqlFieldInfo::defaultValue() const
|
|
161 |
|
|
162 |
Returns the field's default value or an empty QVariant if the
|
|
163 |
field has no default value or the value couldn't be determined.
|
|
164 |
The default value is the value inserted in the database when it
|
|
165 |
is not explicitly specified by the user.
|
|
166 |
*/
|
|
167 |
|
|
168 |
/*!
|
|
169 |
\fn QString Q3SqlFieldInfo::name() const
|
|
170 |
|
|
171 |
Returns the name of the field in the SQL table.
|
|
172 |
*/
|
|
173 |
|
|
174 |
/*!
|
|
175 |
\fn int Q3SqlFieldInfo::typeID() const
|
|
176 |
|
|
177 |
Returns the internal type identifier as returned from the database
|
|
178 |
system. The return value is 0 if the type is unknown.
|
|
179 |
*/
|
|
180 |
|
|
181 |
/*!
|
|
182 |
\fn bool Q3SqlFieldInfo::isGenerated() const
|
|
183 |
|
|
184 |
Returns TRUE if the field should be included in auto-generated
|
|
185 |
SQL statments, e.g. in Q3SqlCursor; otherwise returns FALSE.
|
|
186 |
|
|
187 |
\sa setGenerated()
|
|
188 |
*/
|
|
189 |
|
|
190 |
/*!
|
|
191 |
\fn bool Q3SqlFieldInfo::isTrim() const
|
|
192 |
|
|
193 |
Returns TRUE if trailing whitespace should be removed from
|
|
194 |
character fields; otherwise returns FALSE.
|
|
195 |
|
|
196 |
\sa setTrim()
|
|
197 |
*/
|
|
198 |
|
|
199 |
/*!
|
|
200 |
\fn bool Q3SqlFieldInfo::isCalculated() const
|
|
201 |
|
|
202 |
Returns TRUE if the field is calculated; otherwise returns FALSE.
|
|
203 |
|
|
204 |
\sa setCalculated()
|
|
205 |
*/
|
|
206 |
|
|
207 |
/*!
|
|
208 |
\fn void Q3SqlFieldInfo::setTrim(bool trim)
|
|
209 |
|
|
210 |
If \a trim is TRUE widgets should remove trailing whitespace from
|
|
211 |
character fields. This does not affect the field value but only
|
|
212 |
its representation inside widgets.
|
|
213 |
|
|
214 |
\sa isTrim()
|
|
215 |
*/
|
|
216 |
|
|
217 |
/*!
|
|
218 |
\fn void Q3SqlFieldInfo::setGenerated(bool generated)
|
|
219 |
|
|
220 |
\a generated set to FALSE indicates that this field should not appear
|
|
221 |
in auto-generated SQL statements (for example in Q3SqlCursor).
|
|
222 |
|
|
223 |
\sa isGenerated()
|
|
224 |
*/
|
|
225 |
|
|
226 |
/*!
|
|
227 |
\fn void Q3SqlFieldInfo::setCalculated(bool calculated)
|
|
228 |
|
|
229 |
\a calculated set to TRUE indicates that this field is a calculated
|
|
230 |
field. The value of calculated fields can by modified by subclassing
|
|
231 |
Q3SqlCursor and overriding Q3SqlCursor::calculateField().
|
|
232 |
|
|
233 |
\sa isCalculated()
|
|
234 |
*/
|