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