Eneboo - Documentación para desarrolladores
|
00001 /*************************************************************************** 00002 FLSqlSavePoint.h 00003 ------------------- 00004 begin : Fri Nov 26 2004 00005 copyright : (C) 2004-2005 by InfoSiAL S.L. 00006 email : mail@infosial.com 00007 ***************************************************************************/ 00008 /*************************************************************************** 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; version 2 of the License. * 00012 ***************************************************************************/ 00013 /*************************************************************************** 00014 Este programa es software libre. Puede redistribuirlo y/o modificarlo 00015 bajo los términos de la Licencia Pública General de GNU en su 00016 versión 2, publicada por la Free Software Foundation. 00017 ***************************************************************************/ 00018 00019 #ifndef FLSQLSAVEPOINT_H 00020 #define FLSQLSAVEPOINT_H 00021 00022 #include <qptrstack.h> 00023 00024 #include "FLSqlCursor.h" 00025 00039 class FL_EXPORT opInfo : public QObject { 00040 Q_OBJECT 00041 public: 00042 opInfo() : QObject( 0 ) {} 00043 opInfo( const QString & pK, const int o, const QSqlRecord & b, const int a, const QSqlIndex & s, const QString & f, const QString & n, FLSqlCursor * c ) : QObject( 0 ), primaryKey( pK ), op( o ), buffer( b ), at( a ), sort( s ), filter( f ), name( n ), cursor( c ) { 00044 connect( c, SIGNAL( destroyed() ), this, SLOT( cursorDestroyed() ) ); 00045 } 00046 ~opInfo() { } 00047 QString primaryKey; 00048 int op; 00049 QSqlRecord buffer; 00050 int at; 00051 QSqlIndex sort; 00052 QString filter; 00053 QString name; 00054 FLSqlCursor * cursor; 00055 public slots: 00056 void cursorDestroyed() { 00057 cursor = 0; 00058 } 00059 }; 00060 00103 class FL_EXPORT FLSqlSavePoint { 00104 00105 public: 00106 00112 FLSqlSavePoint( int id = 0 ); 00113 00117 ~FLSqlSavePoint(); 00118 00122 void setId( int id ) { 00123 id_ = id; 00124 } 00125 00129 int id() { 00130 return id_; 00131 } 00132 00139 void clear(); 00140 00144 void undo(); 00145 00153 void saveInsert( const QString & primaryKey, QSqlRecord * buffer, FLSqlCursor * cursor ); 00154 00162 void saveEdit( const QString & primaryKey, QSqlRecord * buffer, FLSqlCursor * cursor ); 00163 00171 void saveDel( const QString & primaryKey, QSqlRecord * buffer, FLSqlCursor * cursor ); 00172 00173 #ifdef FL_DEBUG 00174 static long countRefSavePoint; 00175 #endif 00176 00177 private: 00178 00184 void undoInsert( const opInfo * opInf ); 00185 00191 void undoEdit( const opInfo * opInf ); 00192 00198 void undoDel( const opInfo * opInf ); 00199 00203 QPtrStack < opInfo > * opInfos; 00204 00208 int id_; 00209 }; 00210 00211 #endif