~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/qt3support/sql/q3sqlfieldinfo.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the Qt 3 compatibility classes of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef Q3SQLFIELDINFO_H
 
30
#define Q3SQLFIELDINFO_H
 
31
 
 
32
#ifndef QT_NO_SQL
 
33
 
 
34
#include "QtCore/qglobal.h"
 
35
#include "QtSql/qsqlfield.h"
 
36
 
 
37
/* Q3SqlFieldInfo Class
 
38
   obsoleted, use QSqlField instead
 
39
*/
 
40
 
 
41
class Q_COMPAT_EXPORT Q3SqlFieldInfo
 
42
{
 
43
    // class is obsoleted, won't change anyways,
 
44
    // so no d pointer
 
45
    int req, len, prec, tID;
 
46
    uint gen: 1;
 
47
    uint trim: 1;
 
48
    uint calc: 1;
 
49
    QString nm;
 
50
    QVariant::Type typ;
 
51
    QVariant defValue;
 
52
 
 
53
public:
 
54
    Q3SqlFieldInfo(const QString& name = QString(),
 
55
                   QVariant::Type typ = QVariant::Invalid,
 
56
                   int required = -1,
 
57
                   int len = -1,
 
58
                   int prec = -1,
 
59
                   const QVariant& defValue = QVariant(),
 
60
                   int sqlType = 0,
 
61
                   bool generated = true,
 
62
                   bool trim = false,
 
63
                   bool calculated = false) :
 
64
        req(required), len(len), prec(prec), tID(sqlType),
 
65
        gen(generated), trim(trim), calc(calculated),
 
66
        nm(name), typ(typ), defValue(defValue) {}
 
67
 
 
68
    virtual ~Q3SqlFieldInfo() {}
 
69
 
 
70
    Q3SqlFieldInfo(const QSqlField & other)
 
71
    {
 
72
        nm = other.name();
 
73
        typ = other.type();
 
74
        switch (other.requiredStatus()) {
 
75
        case QSqlField::Unknown: req = -1; break;
 
76
        case QSqlField::Required: req = 1; break;
 
77
        case QSqlField::Optional: req = 0; break;
 
78
        }
 
79
        len = other.length();
 
80
        prec = other.precision();
 
81
        defValue = other.defaultValue();
 
82
        tID = other.typeID();
 
83
        gen = other.isGenerated();
 
84
        calc = false;
 
85
        trim = false;
 
86
    }
 
87
 
 
88
    bool operator==(const Q3SqlFieldInfo& f) const
 
89
    {
 
90
        return (nm == f.nm &&
 
91
                typ == f.typ &&
 
92
                req == f.req &&
 
93
                len == f.len &&
 
94
                prec == f.prec &&
 
95
                defValue == f.defValue &&
 
96
                tID == f.tID &&
 
97
                gen == f.gen &&
 
98
                trim == f.trim &&
 
99
                calc == f.calc);
 
100
    }
 
101
 
 
102
    QSqlField toField() const
 
103
    { QSqlField f(nm, typ);
 
104
      f.setRequiredStatus(QSqlField::RequiredStatus(req));
 
105
      f.setLength(len);
 
106
      f.setPrecision(prec);
 
107
      f.setDefaultValue(defValue);
 
108
      f.setSqlType(tID);
 
109
      f.setGenerated(gen);
 
110
      return f;
 
111
    }
 
112
    int isRequired() const
 
113
    { return req; }
 
114
    QVariant::Type type() const
 
115
    { return typ; }
 
116
    int length() const
 
117
    { return len; }
 
118
    int precision() const
 
119
    { return prec; }
 
120
    QVariant defaultValue() const
 
121
    { return defValue; }
 
122
    QString name() const
 
123
    { return nm; }
 
124
    int typeID() const
 
125
    { return tID; }
 
126
    bool isGenerated() const
 
127
    { return gen; }
 
128
    bool isTrim() const
 
129
    { return trim; }
 
130
    bool isCalculated() const
 
131
    { return calc; }
 
132
 
 
133
    virtual void setTrim(bool trim)
 
134
    { this->trim = trim; }
 
135
    virtual void setGenerated(bool generated)
 
136
    { gen = generated; }
 
137
    virtual void setCalculated(bool calculated)
 
138
    { calc = calculated; }
 
139
 
 
140
};
 
141
 
 
142
#endif        // QT_NO_SQL
 
143
 
 
144
#endif