From 34e86ddf4f9b1045a5b730beab2d8d72e2dd4d56 Mon Sep 17 00:00:00 2001 From: eilers Date: Mon, 22 Sep 2003 14:31:15 +0000 Subject: Added first experimental incarnation of sql-backend for addressbook. Some modifications to be able to compile the todo sql-backend. A lot of changes fill follow... --- (limited to 'libopie/pim/ocontactaccessbackend_sql.h') diff --git a/libopie/pim/ocontactaccessbackend_sql.h b/libopie/pim/ocontactaccessbackend_sql.h new file mode 100644 index 0000000..bb22551 --- a/dev/null +++ b/libopie/pim/ocontactaccessbackend_sql.h @@ -0,0 +1,96 @@ +/* + * SQL Backend for the OPIE-Contact Database. + * + * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) + * + * ===================================================================== + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * ===================================================================== + * + * + * ===================================================================== + * Version: $Id$ + * ===================================================================== + * History: + * $Log$ + * Revision 1.1 2003/09/22 14:31:16 eilers + * Added first experimental incarnation of sql-backend for addressbook. + * Some modifications to be able to compile the todo sql-backend. + * A lot of changes fill follow... + * + * + */ + +#ifndef _OContactAccessBackend_SQL_ +#define _OContactAccessBackend_SQL_ + +#include "ocontactaccessbackend.h" +#include "ocontactaccess.h" + +#include +#include + +class OSQLDriver; +class OSQLResult; +class OSQLResultItem; + +/* the default xml implementation */ +/** + * This class is the SQL implementation of a Contact backend + * it does implement everything available for OContact. + * @see OPimAccessBackend for more information of available methods + */ +class OContactAccessBackend_SQL : public OContactAccessBackend { + public: + OContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null ); + + bool save(); + + bool load (); + + void clear (); + + bool wasChangedExternally(); + + QArray allRecords() const; + + OContact find ( int uid ) const; + // FIXME: Add lookahead-cache support ! + //OContact find(int uid, const QArray&, uint cur, Frontend::CacheDirection )const; + + QArray queryByExample ( const OContact &query, int settings, + const QDateTime& d ); + + QArray matchRegexp( const QRegExp &r ) const; + + const uint querySettings(); + + bool hasQuerySettings (uint querySettings) const; + + // Currently only asc implemented.. + QArray sorted( bool asc, int , int , int ); + bool add ( const OContact &newcontact ); + + bool replace ( const OContact &contact ); + + bool remove ( int uid ); + bool reload(); + + private: + QArray extractUids( OSQLResult& res ) const; + QMap requestNonCustom( int uid ) const; + QMap requestCustom( int uid ) const; + void update(); + + protected: + bool m_changed; + QString m_fileName; + QArray m_uids; + + OSQLDriver* m_driver; +}; + +#endif -- cgit v0.9.0.2