1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Definition of QDataBrowser 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 QDATABROWSER_H
|
---|
38 | #define QDATABROWSER_H
|
---|
39 |
|
---|
40 | #ifndef QT_H
|
---|
41 | #include "qwidget.h"
|
---|
42 | #include "qstring.h"
|
---|
43 | #include "qstringlist.h"
|
---|
44 | #include "qsql.h"
|
---|
45 | #include "qsqlindex.h"
|
---|
46 | #include "qsqlcursor.h"
|
---|
47 | #include "qsqlerror.h"
|
---|
48 | #endif // QT_H
|
---|
49 |
|
---|
50 | #ifndef QT_NO_SQL_VIEW_WIDGETS
|
---|
51 |
|
---|
52 | class QSqlForm;
|
---|
53 | class QDataBrowserPrivate;
|
---|
54 |
|
---|
55 | class Q_EXPORT QDataBrowser : public QWidget
|
---|
56 | {
|
---|
57 | Q_OBJECT
|
---|
58 | Q_PROPERTY( bool boundaryChecking READ boundaryChecking WRITE setBoundaryChecking )
|
---|
59 | Q_PROPERTY( QString filter READ filter WRITE setFilter )
|
---|
60 | Q_PROPERTY( QStringList sort READ sort WRITE setSort )
|
---|
61 | Q_PROPERTY( bool confirmEdits READ confirmEdits WRITE setConfirmEdits )
|
---|
62 | Q_PROPERTY( bool confirmInsert READ confirmInsert WRITE setConfirmInsert )
|
---|
63 | Q_PROPERTY( bool confirmUpdate READ confirmUpdate WRITE setConfirmUpdate )
|
---|
64 | Q_PROPERTY( bool confirmDelete READ confirmDelete WRITE setConfirmDelete )
|
---|
65 | Q_PROPERTY( bool confirmCancels READ confirmCancels WRITE setConfirmCancels )
|
---|
66 | Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly )
|
---|
67 | Q_PROPERTY( bool autoEdit READ autoEdit WRITE setAutoEdit )
|
---|
68 |
|
---|
69 | public:
|
---|
70 | QDataBrowser( QWidget* parent=0, const char* name=0, WFlags fl = 0 );
|
---|
71 | ~QDataBrowser();
|
---|
72 |
|
---|
73 | enum Boundary {
|
---|
74 | Unknown,
|
---|
75 | None,
|
---|
76 | BeforeBeginning,
|
---|
77 | Beginning,
|
---|
78 | End,
|
---|
79 | AfterEnd
|
---|
80 | };
|
---|
81 |
|
---|
82 | Boundary boundary();
|
---|
83 | void setBoundaryChecking( bool active );
|
---|
84 | bool boundaryChecking() const;
|
---|
85 |
|
---|
86 | void setSort( const QSqlIndex& sort );
|
---|
87 | void setSort( const QStringList& sort );
|
---|
88 | QStringList sort() const;
|
---|
89 | void setFilter( const QString& filter );
|
---|
90 | QString filter() const;
|
---|
91 | virtual void setSqlCursor( QSqlCursor* cursor, bool autoDelete = FALSE );
|
---|
92 | QSqlCursor* sqlCursor() const;
|
---|
93 | virtual void setForm( QSqlForm* form );
|
---|
94 | QSqlForm* form();
|
---|
95 |
|
---|
96 | virtual void setConfirmEdits( bool confirm );
|
---|
97 | virtual void setConfirmInsert( bool confirm );
|
---|
98 | virtual void setConfirmUpdate( bool confirm );
|
---|
99 | virtual void setConfirmDelete( bool confirm );
|
---|
100 | virtual void setConfirmCancels( bool confirm );
|
---|
101 | bool confirmEdits() const;
|
---|
102 | bool confirmInsert() const;
|
---|
103 | bool confirmUpdate() const;
|
---|
104 | bool confirmDelete() const;
|
---|
105 | bool confirmCancels() const;
|
---|
106 |
|
---|
107 | virtual void setReadOnly( bool active );
|
---|
108 | bool isReadOnly() const;
|
---|
109 | virtual void setAutoEdit( bool autoEdit );
|
---|
110 | bool autoEdit() const;
|
---|
111 |
|
---|
112 | virtual bool seek( int i, bool relative = FALSE );
|
---|
113 |
|
---|
114 | signals:
|
---|
115 | void firstRecordAvailable( bool available );
|
---|
116 | void lastRecordAvailable( bool available );
|
---|
117 | void nextRecordAvailable( bool available );
|
---|
118 | void prevRecordAvailable( bool available );
|
---|
119 |
|
---|
120 | void currentChanged( const QSqlRecord* record );
|
---|
121 | void primeInsert( QSqlRecord* buf );
|
---|
122 | void primeUpdate( QSqlRecord* buf );
|
---|
123 | void primeDelete( QSqlRecord* buf );
|
---|
124 | void beforeInsert( QSqlRecord* buf );
|
---|
125 | void beforeUpdate( QSqlRecord* buf );
|
---|
126 | void beforeDelete( QSqlRecord* buf );
|
---|
127 | void cursorChanged( QSqlCursor::Mode mode );
|
---|
128 |
|
---|
129 | public slots:
|
---|
130 | virtual void refresh();
|
---|
131 |
|
---|
132 | virtual void insert();
|
---|
133 | virtual void update();
|
---|
134 | virtual void del();
|
---|
135 |
|
---|
136 | virtual void first();
|
---|
137 | virtual void last();
|
---|
138 | virtual void next();
|
---|
139 | virtual void prev();
|
---|
140 |
|
---|
141 | virtual void readFields();
|
---|
142 | virtual void writeFields();
|
---|
143 | virtual void clearValues();
|
---|
144 |
|
---|
145 | void updateBoundary();
|
---|
146 |
|
---|
147 | protected:
|
---|
148 | virtual bool insertCurrent();
|
---|
149 | virtual bool updateCurrent();
|
---|
150 | virtual bool deleteCurrent();
|
---|
151 | virtual bool currentEdited();
|
---|
152 |
|
---|
153 | virtual QSql::Confirm confirmEdit( QSql::Op m );
|
---|
154 | virtual QSql::Confirm confirmCancel( QSql::Op m );
|
---|
155 |
|
---|
156 | virtual void handleError( const QSqlError& error );
|
---|
157 |
|
---|
158 | private:
|
---|
159 | typedef bool (QSqlCursor::*Nav)();
|
---|
160 | bool preNav();
|
---|
161 | void postNav( bool primeUpd );
|
---|
162 | void nav( Nav nav );
|
---|
163 | QDataBrowserPrivate* d;
|
---|
164 |
|
---|
165 | #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
|
---|
166 | QDataBrowser( const QDataBrowser & );
|
---|
167 | QDataBrowser &operator=( const QDataBrowser & );
|
---|
168 | #endif
|
---|
169 | };
|
---|
170 |
|
---|
171 |
|
---|
172 | #endif
|
---|
173 | #endif
|
---|