author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 21 Apr 2010 12:15:23 +0300 | |
branch | RCL_3 |
changeset 12 | cc75c76972ee |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the Qt3Support module 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 |
#ifndef Q3SQLCURSOR_H |
|
43 |
#define Q3SQLCURSOR_H |
|
44 |
||
45 |
#include <QtCore/qvariant.h> |
|
46 |
#include <QtSql/qsqldatabase.h> |
|
47 |
#include <QtSql/qsqlrecord.h> |
|
48 |
#include <QtCore/qstringlist.h> |
|
49 |
#include <QtSql/qsqlquery.h> |
|
50 |
#include <QtSql/qsqlindex.h> |
|
51 |
||
52 |
QT_BEGIN_HEADER |
|
53 |
||
54 |
QT_BEGIN_NAMESPACE |
|
55 |
||
56 |
QT_MODULE(Qt3Support) |
|
57 |
||
58 |
#ifndef QT_NO_SQL |
|
59 |
||
60 |
class Q3SqlCursorPrivate; |
|
61 |
class Q3SqlFieldInfo; |
|
62 |
||
63 |
class Q_COMPAT_EXPORT Q3SqlCursor : public QSqlRecord, public QSqlQuery |
|
64 |
{ |
|
65 |
public: |
|
66 |
Q3SqlCursor(const QString & name = QString(), bool autopopulate = true, |
|
67 |
QSqlDatabase db = QSqlDatabase()); |
|
68 |
Q3SqlCursor(const Q3SqlCursor & other); |
|
69 |
Q3SqlCursor& operator=(const Q3SqlCursor& other); |
|
70 |
virtual ~Q3SqlCursor(); |
|
71 |
||
72 |
enum Mode { |
|
73 |
ReadOnly = 0, |
|
74 |
Insert = 1, |
|
75 |
Update = 2, |
|
76 |
Delete = 4, |
|
77 |
Writable = 7 |
|
78 |
}; |
|
79 |
||
80 |
QVariant value(int i) const; |
|
81 |
inline QVariant value(const QString &name) const { return value(indexOf(name)); } |
|
82 |
virtual void setValue(int i, const QVariant &val); |
|
83 |
inline void setValue(const QString &name, const QVariant &val) { setValue(indexOf(name), val); } |
|
84 |
virtual QSqlIndex primaryIndex(bool prime = true) const; |
|
85 |
virtual QSqlIndex index(const QStringList& fieldNames) const; |
|
86 |
QSqlIndex index(const QString& fieldName) const; |
|
87 |
virtual void setPrimaryIndex(const QSqlIndex& idx); |
|
88 |
||
89 |
virtual void append(const Q3SqlFieldInfo& fieldInfo); |
|
90 |
virtual void insert(int pos, const Q3SqlFieldInfo &fieldInfo); |
|
91 |
virtual void remove(int pos); |
|
92 |
virtual void clear(); |
|
93 |
virtual void setGenerated(const QString& name, bool generated); |
|
94 |
virtual void setGenerated(int i, bool generated); |
|
95 |
||
96 |
virtual QSqlRecord* editBuffer(bool copy = false); |
|
97 |
virtual QSqlRecord* primeInsert(); |
|
98 |
virtual QSqlRecord* primeUpdate(); |
|
99 |
virtual QSqlRecord* primeDelete(); |
|
100 |
virtual int insert(bool invalidate = true); |
|
101 |
virtual int update(bool invalidate = true); |
|
102 |
virtual int del(bool invalidate = true); |
|
103 |
||
104 |
virtual void setMode(int flags); |
|
105 |
int mode() const; |
|
106 |
virtual void setCalculated(const QString& name, bool calculated); |
|
107 |
bool isCalculated(const QString& name) const; |
|
108 |
virtual void setTrimmed(const QString& name, bool trim); |
|
109 |
bool isTrimmed(const QString& name) const; |
|
110 |
||
111 |
bool isReadOnly() const; |
|
112 |
bool canInsert() const; |
|
113 |
bool canUpdate() const; |
|
114 |
bool canDelete() const; |
|
115 |
||
116 |
bool select(); |
|
117 |
bool select(const QSqlIndex& sort); |
|
118 |
bool select(const QSqlIndex & filter, const QSqlIndex & sort); |
|
119 |
virtual bool select(const QString & filter, const QSqlIndex & sort = QSqlIndex()); |
|
120 |
||
121 |
virtual void setSort(const QSqlIndex& sort); |
|
122 |
QSqlIndex sort() const; |
|
123 |
virtual void setFilter(const QString& filter); |
|
124 |
QString filter() const; |
|
125 |
virtual void setName(const QString& name, bool autopopulate = true); |
|
126 |
QString name() const; |
|
127 |
QString toString(const QString& prefix = QString(), |
|
128 |
const QString& sep = QLatin1String(",")) const; |
|
129 |
bool isNull(int i) const; |
|
130 |
bool isNull(const QString& name) const; |
|
131 |
virtual bool seek(int i, bool relative = false); |
|
132 |
virtual bool next(); |
|
133 |
inline bool previous() { return prev(); } |
|
134 |
virtual bool prev(); |
|
135 |
virtual bool first(); |
|
136 |
virtual bool last(); |
|
137 |
||
138 |
protected: |
|
139 |
virtual bool exec(const QString & sql); |
|
140 |
||
141 |
virtual QVariant calculateField(const QString& name); |
|
142 |
virtual int update(const QString & filter, bool invalidate = true); |
|
143 |
virtual int del(const QString & filter, bool invalidate = true); |
|
144 |
||
145 |
virtual QString toString(const QString& prefix, QSqlField* field, const QString& fieldSep) const; |
|
146 |
virtual QString toString(QSqlRecord* rec, const QString& prefix, const QString& fieldSep, |
|
147 |
const QString& sep) const; |
|
148 |
virtual QString toString(const QSqlIndex& i, QSqlRecord* rec, const QString& prefix, |
|
149 |
const QString& fieldSep, const QString& sep) const; |
|
150 |
||
151 |
private: |
|
152 |
void sync(); |
|
153 |
int apply(const QString& q, bool invalidate); |
|
154 |
int applyPrepared(const QString& q, bool invalidate); |
|
155 |
QSqlRecord& operator=(const QSqlRecord & list); |
|
156 |
void append(const QSqlField& field); |
|
157 |
||
158 |
Q3SqlCursorPrivate* d; |
|
159 |
}; |
|
160 |
||
161 |
#endif // QT_NO_SQL |
|
162 |
||
163 |
QT_END_NAMESPACE |
|
164 |
||
165 |
QT_END_HEADER |
|
166 |
||
167 |
#endif // Q3SQLCURSOR_H |