Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ocontactaccessbackend_sql.h

Go to the documentation of this file.
00001 /*
00002  * SQL Backend for the OPIE-Contact Database.
00003  *
00004  * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
00005  *
00006  * =====================================================================
00007  *      This program is free software; you can redistribute it and/or
00008  *      modify it under the terms of the GNU Library General Public
00009  *      License as published by the Free Software Foundation; either
00010  *      version 2 of the License, or (at your option) any later version.
00011  * =====================================================================
00012  *
00013  *
00014  * =====================================================================
00015  * Version: $Id: ocontactaccessbackend_sql.h,v 1.1 2004/11/16 21:46:07 mickeyl Exp $
00016  * =====================================================================
00017  * History:
00018  * $Log: ocontactaccessbackend_sql.h,v $
00019  * Revision 1.1  2004/11/16 21:46:07  mickeyl
00020  * libopie1 goes into unsupported
00021  *
00022  * Revision 1.3  2004/03/14 13:50:35  alwin
00023  * namespace correction
00024  *
00025  * Revision 1.2  2003/12/08 15:18:11  eilers
00026  * Committing unfinished sql implementation before merging to libopie2 starts..
00027  *
00028  * Revision 1.1  2003/09/22 14:31:16  eilers
00029  * Added first experimental incarnation of sql-backend for addressbook.
00030  * Some modifications to be able to compile the todo sql-backend.
00031  * A lot of changes fill follow...
00032  *
00033  *
00034  */
00035 
00036 #ifndef _OContactAccessBackend_SQL_
00037 #define _OContactAccessBackend_SQL_
00038 
00039 #include "ocontactaccessbackend.h"
00040 #include "ocontactaccess.h"
00041 
00042 #include <qlist.h>
00043 #include <qdict.h>
00044 
00045 namespace Opie { namespace DB {
00046 class OSQLDriver;
00047 class OSQLResult;
00048 class OSQLResultItem;
00049 
00050 }}
00051 
00052 /* the default xml implementation */
00058 class OContactAccessBackend_SQL : public OContactAccessBackend {
00059  public:
00060         OContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null );
00061 
00062         ~OContactAccessBackend_SQL ();
00063 
00064         bool save();
00065 
00066         bool load ();
00067 
00068         void clear ();
00069 
00070         bool wasChangedExternally();
00071 
00072         QArray<int> allRecords() const;
00073 
00074         OContact find ( int uid ) const;
00075         // FIXME: Add lookahead-cache support !
00076         //OContact find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const;
00077 
00078         QArray<int> queryByExample ( const OContact &query, int settings, 
00079                                      const QDateTime& d );
00080 
00081         QArray<int> matchRegexp(  const QRegExp &r ) const;
00082 
00083         const uint querySettings();
00084 
00085         bool hasQuerySettings (uint querySettings) const;
00086 
00087         // Currently only asc implemented..
00088         QArray<int> sorted( bool asc,  int , int ,  int );
00089         bool add ( const OContact &newcontact );
00090 
00091         bool replace ( const OContact &contact );
00092 
00093         bool remove ( int uid );
00094         bool reload();
00095 
00096  private:
00097         QArray<int> extractUids( Opie::DB::OSQLResult& res ) const;
00098         QMap<int, QString>  requestNonCustom( int uid ) const;
00099         QMap<QString, QString>  requestCustom( int uid ) const;
00100         void update();
00101 
00102  protected:
00103         bool m_changed;
00104         QString m_fileName;
00105         QArray<int> m_uids;
00106 
00107         Opie::DB::OSQLDriver* m_driver;
00108 };
00109 
00110 #endif

Generated on Sat Nov 5 16:16:14 2005 for OPIE by  doxygen 1.4.2