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