Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** 00003 ** Definition of QDataBrowser class 00004 ** 00005 ** Created : 2000-11-03 00006 ** 00007 ** Copyright (C) 2005-2007 Trolltech ASA. All rights reserved. 00008 ** 00009 ** This file is part of the sql module of the Qt GUI Toolkit. 00010 ** 00011 ** This file may be distributed under the terms of the Q Public License 00012 ** as defined by Trolltech ASA of Norway and appearing in the file 00013 ** LICENSE.QPL included in the packaging of this file. 00014 ** 00015 ** This file may be distributed and/or modified under the terms of the 00016 ** GNU General Public License version 2 as published by the Free Software 00017 ** Foundation and appearing in the file LICENSE.GPL included in the 00018 ** packaging of this file. 00019 ** 00020 ** Licensees holding valid Qt Enterprise Edition licenses may use this 00021 ** file in accordance with the Qt Commercial License Agreement provided 00022 ** with the Software. 00023 ** 00024 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00025 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00026 ** 00027 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00028 ** information about Qt Commercial License Agreements. 00029 ** See http://www.trolltech.com/qpl/ for QPL licensing information. 00030 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00031 ** 00032 ** Contact info@trolltech.com if any conditions of this licensing are 00033 ** not clear to you. 00034 ** 00035 **********************************************************************/ 00036 00037 #ifndef QDATABROWSER_H 00038 #define QDATABROWSER_H 00039 00040 #ifndef QT_H 00041 #include "qwidget.h" 00042 #include "qstring.h" 00043 #include "qstringlist.h" 00044 #include "qsql.h" 00045 #include "qsqlindex.h" 00046 #include "qsqlcursor.h" 00047 #include "qsqlerror.h" 00048 #endif // QT_H 00049 00050 #ifndef QT_NO_SQL_VIEW_WIDGETS 00051 00052 class QSqlForm; 00053 class QDataBrowserPrivate; 00054 00055 class Q_EXPORT QDataBrowser : public QWidget 00056 { 00057 Q_OBJECT 00058 Q_PROPERTY( bool boundaryChecking READ boundaryChecking WRITE setBoundaryChecking ) 00059 Q_PROPERTY( QString filter READ filter WRITE setFilter ) 00060 Q_PROPERTY( QStringList sort READ sort WRITE setSort ) 00061 Q_PROPERTY( bool confirmEdits READ confirmEdits WRITE setConfirmEdits ) 00062 Q_PROPERTY( bool confirmInsert READ confirmInsert WRITE setConfirmInsert ) 00063 Q_PROPERTY( bool confirmUpdate READ confirmUpdate WRITE setConfirmUpdate ) 00064 Q_PROPERTY( bool confirmDelete READ confirmDelete WRITE setConfirmDelete ) 00065 Q_PROPERTY( bool confirmCancels READ confirmCancels WRITE setConfirmCancels ) 00066 Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly ) 00067 Q_PROPERTY( bool autoEdit READ autoEdit WRITE setAutoEdit ) 00068 00069 public: 00070 QDataBrowser( QWidget* parent=0, const char* name=0, WFlags fl = 0 ); 00071 ~QDataBrowser(); 00072 00073 enum Boundary { 00074 Unknown, 00075 None, 00076 BeforeBeginning, 00077 Beginning, 00078 End, 00079 AfterEnd 00080 }; 00081 00082 Boundary boundary(); 00083 void setBoundaryChecking( bool active ); 00084 bool boundaryChecking() const; 00085 00086 void setSort( const QSqlIndex& sort ); 00087 void setSort( const QStringList& sort ); 00088 QStringList sort() const; 00089 void setFilter( const QString& filter ); 00090 QString filter() const; 00091 virtual void setSqlCursor( QSqlCursor* cursor, bool autoDelete = FALSE ); 00092 QSqlCursor* sqlCursor() const; 00093 virtual void setForm( QSqlForm* form ); 00094 QSqlForm* form(); 00095 00096 virtual void setConfirmEdits( bool confirm ); 00097 virtual void setConfirmInsert( bool confirm ); 00098 virtual void setConfirmUpdate( bool confirm ); 00099 virtual void setConfirmDelete( bool confirm ); 00100 virtual void setConfirmCancels( bool confirm ); 00101 bool confirmEdits() const; 00102 bool confirmInsert() const; 00103 bool confirmUpdate() const; 00104 bool confirmDelete() const; 00105 bool confirmCancels() const; 00106 00107 virtual void setReadOnly( bool active ); 00108 bool isReadOnly() const; 00109 virtual void setAutoEdit( bool autoEdit ); 00110 bool autoEdit() const; 00111 00112 virtual bool seek( int i, bool relative = FALSE ); 00113 00114 signals: 00115 void firstRecordAvailable( bool available ); 00116 void lastRecordAvailable( bool available ); 00117 void nextRecordAvailable( bool available ); 00118 void prevRecordAvailable( bool available ); 00119 00120 void currentChanged( const QSqlRecord* record ); 00121 void primeInsert( QSqlRecord* buf ); 00122 void primeUpdate( QSqlRecord* buf ); 00123 void primeDelete( QSqlRecord* buf ); 00124 void beforeInsert( QSqlRecord* buf ); 00125 void beforeUpdate( QSqlRecord* buf ); 00126 void beforeDelete( QSqlRecord* buf ); 00127 void cursorChanged( QSqlCursor::Mode mode ); 00128 00129 public slots: 00130 virtual void refresh(); 00131 00132 virtual void insert(); 00133 virtual void update(); 00134 virtual void del(); 00135 00136 virtual void first(); 00137 virtual void last(); 00138 virtual void next(); 00139 virtual void prev(); 00140 00141 virtual void readFields(); 00142 virtual void writeFields(); 00143 virtual void clearValues(); 00144 00145 void updateBoundary(); 00146 00147 protected: 00148 virtual bool insertCurrent(); 00149 virtual bool updateCurrent(); 00150 virtual bool deleteCurrent(); 00151 virtual bool currentEdited(); 00152 00153 virtual QSql::Confirm confirmEdit( QSql::Op m ); 00154 virtual QSql::Confirm confirmCancel( QSql::Op m ); 00155 00156 virtual void handleError( const QSqlError& error ); 00157 00158 private: 00159 typedef bool (QSqlCursor::*Nav)(); 00160 bool preNav(); 00161 void postNav( bool primeUpd ); 00162 void nav( Nav nav ); 00163 QDataBrowserPrivate* d; 00164 00165 #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator= 00166 QDataBrowser( const QDataBrowser & ); 00167 QDataBrowser &operator=( const QDataBrowser & ); 00168 #endif 00169 }; 00170 00171 00172 #endif 00173 #endif