source: trunk/src/qt3support/sql/q3sqlfieldinfo.h@ 651

Last change on this file since 651 was 651, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.2 sources.

File size: 5.0 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the Qt3Support module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
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
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
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** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef Q3SQLFIELDINFO_H
43#define Q3SQLFIELDINFO_H
44
45#ifndef QT_NO_SQL
46
47#include <QtCore/qglobal.h>
48#include <QtSql/qsqlfield.h>
49
50QT_BEGIN_HEADER
51
52QT_BEGIN_NAMESPACE
53
54QT_MODULE(Qt3Support)
55
56/* Q3SqlFieldInfo Class
57 obsoleted, use QSqlField instead
58*/
59
60class Q_COMPAT_EXPORT Q3SqlFieldInfo
61{
62 // class is obsoleted, won't change anyways,
63 // so no d pointer
64 int req, len, prec, tID;
65 uint gen: 1;
66 uint trim: 1;
67 uint calc: 1;
68 QString nm;
69 QVariant::Type typ;
70 QVariant defValue;
71
72public:
73 Q3SqlFieldInfo(const QString& name = QString(),
74 QVariant::Type typ = QVariant::Invalid,
75 int required = -1,
76 int len = -1,
77 int prec = -1,
78 const QVariant& defValue = QVariant(),
79 int sqlType = 0,
80 bool generated = true,
81 bool trim = false,
82 bool calculated = false) :
83 req(required), len(len), prec(prec), tID(sqlType),
84 gen(generated), trim(trim), calc(calculated),
85 nm(name), typ(typ), defValue(defValue) {}
86
87 virtual ~Q3SqlFieldInfo() {}
88
89 Q3SqlFieldInfo(const QSqlField & other)
90 {
91 nm = other.name();
92 typ = other.type();
93 switch (other.requiredStatus()) {
94 case QSqlField::Unknown: req = -1; break;
95 case QSqlField::Required: req = 1; break;
96 case QSqlField::Optional: req = 0; break;
97 }
98 len = other.length();
99 prec = other.precision();
100 defValue = other.defaultValue();
101 tID = other.typeID();
102 gen = other.isGenerated();
103 calc = false;
104 trim = false;
105 }
106
107 bool operator==(const Q3SqlFieldInfo& f) const
108 {
109 return (nm == f.nm &&
110 typ == f.typ &&
111 req == f.req &&
112 len == f.len &&
113 prec == f.prec &&
114 defValue == f.defValue &&
115 tID == f.tID &&
116 gen == f.gen &&
117 trim == f.trim &&
118 calc == f.calc);
119 }
120
121 QSqlField toField() const
122 { QSqlField f(nm, typ);
123 f.setRequiredStatus(QSqlField::RequiredStatus(req));
124 f.setLength(len);
125 f.setPrecision(prec);
126 f.setDefaultValue(defValue);
127 f.setSqlType(tID);
128 f.setGenerated(gen);
129 return f;
130 }
131 int isRequired() const
132 { return req; }
133 QVariant::Type type() const
134 { return typ; }
135 int length() const
136 { return len; }
137 int precision() const
138 { return prec; }
139 QVariant defaultValue() const
140 { return defValue; }
141 QString name() const
142 { return nm; }
143 int typeID() const
144 { return tID; }
145 bool isGenerated() const
146 { return gen; }
147 bool isTrim() const
148 { return trim; }
149 bool isCalculated() const
150 { return calc; }
151
152 virtual void setTrim(bool trim)
153 { this->trim = trim; }
154 virtual void setGenerated(bool generated)
155 { gen = generated; }
156 virtual void setCalculated(bool calculated)
157 { calc = calculated; }
158
159};
160
161QT_END_NAMESPACE
162
163QT_END_HEADER
164
165#endif // QT_NO_SQL
166
167#endif // Q3SQLFIELDINFO_H
Note: See TracBrowser for help on using the repository browser.