source: trunk/include/qsqlfield.h

Last change on this file was 196, checked in by rudi, 14 years ago

Add SQL module (currently it isn't build by default, however it's needed for QtDesigner)

File size: 4.3 KB
Line 
1/****************************************************************************
2**
3** Definition of QSqlField class
4**
5** Created : 2000-11-03
6**
7** Copyright (C) 2005-2007 Trolltech ASA. All rights reserved.
8**
9** This file is part of the sql module of the Qt GUI Toolkit.
10**
11** This file may be distributed under the terms of the Q Public License
12** as defined by Trolltech ASA of Norway and appearing in the file
13** LICENSE.QPL included in the packaging of this file.
14**
15** This file may be distributed and/or modified under the terms of the
16** GNU General Public License version 2 as published by the Free Software
17** Foundation and appearing in the file LICENSE.GPL included in the
18** packaging of this file.
19**
20** Licensees holding valid Qt Enterprise Edition licenses may use this
21** file in accordance with the Qt Commercial License Agreement provided
22** with the Software.
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** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
28** information about Qt Commercial License Agreements.
29** See http://www.trolltech.com/qpl/ for QPL licensing information.
30** See http://www.trolltech.com/gpl/ for GPL licensing information.
31**
32** Contact info@trolltech.com if any conditions of this licensing are
33** not clear to you.
34**
35**********************************************************************/
36
37#ifndef QSQLFIELD_H
38#define QSQLFIELD_H
39
40#ifndef QT_H
41#include "qstring.h"
42#include "qvariant.h"
43#endif // QT_H
44
45#if !defined( QT_MODULE_SQL ) || defined( QT_LICENSE_PROFESSIONAL )
46#define QM_EXPORT_SQL
47#else
48#define QM_EXPORT_SQL Q_EXPORT
49#endif
50
51#ifndef QT_NO_SQL
52
53class QSqlFieldPrivate
54{
55public:
56 QVariant::Type type;
57};
58
59class QM_EXPORT_SQL QSqlField
60{
61public:
62 QSqlField( const QString& fieldName = QString::null, QVariant::Type type = QVariant::Invalid );
63 QSqlField( const QSqlField& other );
64 QSqlField& operator=( const QSqlField& other );
65 bool operator==(const QSqlField& other) const;
66 virtual ~QSqlField();
67
68 virtual void setValue( const QVariant& value );
69 virtual QVariant value() const;
70 virtual void setName( const QString& name );
71 QString name() const;
72 virtual void setNull();
73 bool isNull() const;
74 virtual void setReadOnly( bool readOnly );
75 bool isReadOnly() const;
76 void clear( bool nullify = TRUE );
77 QVariant::Type type() const;
78
79private:
80 QString nm;
81 QVariant val;
82 uint ro: 1;
83 uint nul: 1;
84 QSqlFieldPrivate* d;
85};
86
87inline QVariant QSqlField::value() const
88{ return val; }
89
90inline QString QSqlField::name() const
91{ return nm; }
92
93inline bool QSqlField::isNull() const
94{ return nul; }
95
96inline bool QSqlField::isReadOnly() const
97{ return ro; }
98
99inline QVariant::Type QSqlField::type() const
100{ return d->type; }
101
102
103/******************************************/
104/******* QSqlFieldInfo Class ******/
105/******************************************/
106
107struct QSqlFieldInfoPrivate;
108
109class QM_EXPORT_SQL QSqlFieldInfo
110{
111public:
112 QSqlFieldInfo( const QString& name = QString::null,
113 QVariant::Type typ = QVariant::Invalid,
114 int required = -1,
115 int len = -1,
116 int prec = -1,
117 const QVariant& defValue = QVariant(),
118 int sqlType = 0,
119 bool generated = TRUE,
120 bool trim = FALSE,
121 bool calculated = FALSE );
122 QSqlFieldInfo( const QSqlFieldInfo & other );
123 QSqlFieldInfo( const QSqlField & other, bool generated = TRUE );
124 virtual ~QSqlFieldInfo();
125 QSqlFieldInfo& operator=( const QSqlFieldInfo& other );
126 bool operator==( const QSqlFieldInfo& f ) const;
127
128 QSqlField toField() const;
129 int isRequired() const;
130 QVariant::Type type() const;
131 int length() const;
132 int precision() const;
133 QVariant defaultValue() const;
134 QString name() const;
135 int typeID() const;
136 bool isGenerated() const;
137 bool isTrim() const;
138 bool isCalculated() const;
139
140 virtual void setTrim( bool trim );
141 virtual void setGenerated( bool gen );
142 virtual void setCalculated( bool calc );
143
144private:
145 QSqlFieldInfoPrivate* d;
146};
147
148
149#endif // QT_NO_SQL
150#endif
Note: See TracBrowser for help on using the repository browser.