Eneboo - Documentación para desarrolladores
src/qt/include/qsqlcursor.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 **
00003 ** Definition of QSqlCursor 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 QSQLCURSOR_H
00038 #define QSQLCURSOR_H
00039 
00040 #ifndef QT_H
00041 #include "qsqlrecord.h"
00042 #include "qstringlist.h"
00043 #include "qsqlquery.h"
00044 #include "qsqlindex.h"
00045 #endif // QT_H
00046 
00047 #if !defined( QT_MODULE_SQL ) || defined( QT_LICENSE_PROFESSIONAL )
00048 #define QM_EXPORT_SQL
00049 #else
00050 #define QM_EXPORT_SQL Q_EXPORT
00051 #endif
00052 
00053 #ifndef QT_NO_SQL
00054 
00055 class QSqlDatabase;
00056 class QSqlCursorPrivate;
00057 
00058 class QM_EXPORT_SQL QSqlCursor : public QSqlRecord, public QSqlQuery
00059 {
00060 public:
00061     QSqlCursor( const QString & name = QString::null, bool autopopulate = TRUE, QSqlDatabase* db = 0 );
00062     QSqlCursor( const QSqlCursor & other );
00063     QSqlCursor& operator=( const QSqlCursor& other );
00064     ~QSqlCursor();
00065 
00066     enum Mode {
00067         ReadOnly = 0,
00068         Insert = 1,
00069         Update = 2,
00070         Delete = 4,
00071         Writable = 7
00072     };
00073 
00074     QVariant            value( int i ) const;
00075     QVariant            value( const QString& name ) const;
00076     void                setValue( int i, const QVariant& val );
00077     void                setValue( const QString& name, const QVariant& val );
00078     virtual QSqlIndex   primaryIndex( bool prime = TRUE ) const;
00079     virtual QSqlIndex   index( const QStringList& fieldNames ) const;
00080     QSqlIndex           index( const QString& fieldName ) const;
00081     QSqlIndex           index( const char* fieldName ) const;
00082     virtual void        setPrimaryIndex( const QSqlIndex& idx );
00083 
00084     virtual void        append( const QSqlFieldInfo& fieldInfo );
00085     virtual void        insert( int pos, const QSqlFieldInfo& fieldInfo );
00086     void                remove( int pos );
00087     void                clear();
00088     void                setGenerated( const QString& name, bool generated );
00089     void                setGenerated( int i, bool generated );
00090 
00091     virtual QSqlRecord* editBuffer( bool copy = FALSE );
00092     virtual QSqlRecord* primeInsert();
00093     virtual QSqlRecord* primeUpdate();
00094     virtual QSqlRecord* primeDelete();
00095     virtual int         insert( bool invalidate = TRUE );
00096     virtual int         update( bool invalidate = TRUE );
00097     virtual int         del( bool invalidate = TRUE );
00098 
00099     virtual void        setMode( int flags );
00100     int                 mode() const;
00101     virtual void        setCalculated( const QString& name, bool calculated );
00102     bool                isCalculated( const QString& name ) const;
00103     virtual void        setTrimmed( const QString& name, bool trim );
00104     bool                isTrimmed( const QString& name ) const;
00105 
00106     bool                isReadOnly() const;
00107     bool                canInsert() const;
00108     bool                canUpdate() const;
00109     bool                canDelete() const;
00110 
00111     bool                select();
00112     bool                select( const QSqlIndex& sort );
00113     bool                select( const QSqlIndex & filter, const QSqlIndex & sort );
00114     virtual bool        select( const QString & filter, const QSqlIndex & sort = QSqlIndex() );
00115 
00116     virtual void        setSort( const QSqlIndex& sort );
00117     QSqlIndex           sort() const;
00118     virtual void        setFilter( const QString& filter );
00119     QString             filter() const;
00120     virtual void        setName( const QString& name, bool autopopulate = TRUE );
00121     QString             name() const;
00122     QString             toString( const QString& prefix = QString::null,
00123                                 const QString& sep = "," ) const;
00124     bool                isNull( int i ) const;
00125     bool                isNull( const QString& name ) const;
00126     
00127 //### AbanQ
00128     QSqlError   lastError() const;
00129     
00130 protected:
00131     void                afterSeek();
00132     bool                exec( const QString & sql );
00133 
00134     virtual QVariant    calculateField( const QString& name );
00135     virtual int         update( const QString & filter, bool invalidate = TRUE );
00136     virtual int         del( const QString & filter, bool invalidate = TRUE );
00137 
00138     virtual QString     toString( const QString& prefix, QSqlField* field, const QString& fieldSep ) const;
00139     virtual QString     toString( QSqlRecord* rec, const QString& prefix, const QString& fieldSep,
00140                                 const QString& sep ) const;
00141     virtual QString     toString( const QSqlIndex& i, QSqlRecord* rec, const QString& prefix,
00142                                 const QString& fieldSep, const QString& sep ) const;
00143 
00144 private:
00145     void                sync();
00146     int                 apply( const QString& q, bool invalidate );
00147     int                 applyPrepared( const QString& q, bool invalidate );
00148     QSqlRecord&         operator=( const QSqlRecord & list );
00149     void                append( const QSqlField& field );
00150     void                insert( int pos, const QSqlField& field );
00151 
00152     QSqlCursorPrivate*  d;
00153 };
00154 
00155 
00156 
00157 
00158 #endif  // QT_NO_SQL
00159 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'