00001 /* 00002 * Linux Advanced Business Enterprise Management System 00003 * 00004 * 00005 * File name....... : qlabdatabasecashboxclient.h 00006 * File version.... : 1.2.7 00007 * Revision Date... : sat jan 17 2004 00008 * 00009 * File Description : Database Client abstraction layer 00010 * 00011 * Author.......... : DJ Anubis 00012 * Copyright....... : (C) 2001-2004 by DJ Anubis 00013 * Email .......... : labproject@free.fr 00014 * 00015 * License : 00016 * Please read the license file in doc directory. 00017 * 1. Lab Public License. 00018 * You should have received a copy of the Lab Public License with this package. 00019 * If this is not the case, you can read it or download it at: 00020 * http://labproject.free.fr 00021 * 2. Q Public License. 00022 * Conformant to Trolltech QPL license. 00023 * 3. GNU General Public License. 00024 * Reserved for free projects. 00025 * 4. Commercial license. 00026 * Recommanded if your code is not distributed under one of the 3 models above. 00027 * 00028 * Read the license FAQ in doc directory. 00029 * 00030 * Comments 00031 * 00032 * This class implements the database abstraction layer for all and every 00033 * supported backends. 00034 * 00035 * Revised to improve comments and documentation. 00036 * 00037 */ 00038 00039 00040 #ifndef QLABDATABASECASHBOXCLIENT_H 00041 #define QLABDATABASECASHBOXCLIENT_H 00042 00043 #include <qobject.h> 00044 #include <qvariant.h> 00045 00046 class QlabTicketLine ; 00047 class QlabDatabaseCashboxClient_priv ; 00048 class QSqlRecord ; 00049 00050 class Q_EXPORT QlabDatabaseCashboxClient : public QObject 00051 { 00052 Q_OBJECT ; 00053 00054 Q_ENUMS( Modes ) ; 00055 Q_ENUMS( MasterConversation ) ; 00056 Q_PROPERTY( QString tableName READ tableName WRITE setTableName ) ; 00057 Q_PROPERTY( QString defaultGetField READ defaultGetField WRITE setDefaultGetField ) ; 00058 00059 00060 public : 00061 QlabDatabaseCashboxClient( const QString & tablename = 0, 00062 QObject * parent = 0, char * name = 0 ) ; 00063 ~QlabDatabaseCashboxClient() ; 00064 00069 enum Modes { None, 00070 Select, 00071 Edit, 00072 Delete 00073 } ; 00074 00078 enum MasterConversation { MasterTicketLine, 00079 MasterTicketEnd, 00080 MasterCountOpening, 00081 MasterCountClose, 00082 MasterCountRedrawal, 00083 MasterCountInsertion, 00084 MasterCancelation, 00085 MasterAnomality, 00086 MasterSessionStart, 00087 MasterSessionPause, 00088 MasterSessionReprise, 00089 MasterSessionClose, 00090 MasterSessionLoginError, 00091 MasterSessionSuperLoginError, 00092 MasterLocalMode } ; 00093 00094 00095 public slots : 00096 QString tableName() const ; 00097 void setTableName( const QString & tblName ) ; 00098 QString defaultGetField() const ; 00099 void setDefaultGetField( const QString & fld ) ; 00100 int sequenceGetNextValue() ; 00101 QString getIniVar( const QString & section, const QString & varname ) ; 00102 00103 bool checkUser( const QString & user, const QString & passwd ) ; 00104 00105 bool informMaster( MasterConversation mc, QObject * clnt ) ; 00106 bool informMaster( MasterConversation mc, const QString & msg ) ; 00107 bool postToMaster( const int & userID, const int & cashboxID, 00108 const int & ticketNo, const QString & ticketStamp, 00109 const QMap<uint, QlabTicketLine *> & act ) ; 00110 QVariant value( const QString & fld ) ; 00111 void setValue( const QString & fld, const QVariant & value ) ; 00112 bool get( const QVariant & itemInfo, bool unique = TRUE ) ; 00113 void create() ; 00114 bool store() ; 00115 00116 uint size() ; 00117 QSqlRecord * first() ; 00118 QSqlRecord * next() ; 00119 QSqlRecord * last() ; 00120 QSqlRecord * seek( int pos ) ; 00121 void setFilter( const QString & flt ) ; 00122 void setOrder( const QString & ord ) ; 00123 void select() ; 00124 00125 QString lastError() ; 00126 void setup() ; 00127 bool createConnection( const QString & connectionName ) ; 00128 00129 int ticketRecallFromMaster( const QString & recallCode, const QString & recallKey, 00130 const QMap<uint, QlabTicketLine *> & act ) ; 00131 int ticketPushToMaster( const QMap<uint, QlabTicketLine *> & act ) ; 00132 00133 signals : 00138 void currentChanged( int recid ) ; 00142 void selectionChanged() ; 00146 void error( MasterConversation mc, const QString & msg ) ; 00147 00148 private : 00149 QString table ; 00150 QlabDatabaseCashboxClient_priv * cursor ; 00152 Modes activeMode ; 00153 QString defGetField ; 00154 int activeRecord ; 00155 QMap< QString, QlabDatabaseCashboxClient> associations ; 00157 } ; 00158 00159 #endif // QLABDATABASECLIENT_H 00160