summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core
Unidiff
Diffstat (limited to 'libopie2/opiepim/core') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/ocontactaccess.h14
-rw-r--r--libopie2/opiepim/core/odatebookaccess.cpp19
-rw-r--r--libopie2/opiepim/core/odatebookaccess.h9
-rw-r--r--libopie2/opiepim/core/otimezone.cpp11
4 files changed, 46 insertions, 7 deletions
diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h
index 9b0a719..bd6da40 100644
--- a/libopie2/opiepim/core/ocontactaccess.h
+++ b/libopie2/opiepim/core/ocontactaccess.h
@@ -8,24 +8,36 @@
8 *This program is free software; you can redistribute it and/or 8 *This program is free software; you can redistribute it and/or
9 *modify it under the terms of the GNU Library General Public 9 *modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; 10 * License as published by the Free Software Foundation;
11 * either version 2 of the License, or (at your option) any later 11 * either version 2 of the License, or (at your option) any later
12 * version. 12 * version.
13 * ===================================================================== 13 * =====================================================================
14 * ToDo: Define enum for query settings 14 * ToDo: Define enum for query settings
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.10 2003/12/22 10:19:26 eilers
21 * Finishing implementation of sql-backend for datebook. But I have to
22 * port the PIM datebook application to use it, before I could debug the
23 * whole stuff.
24 * Thus, PIM-Database backend is finished, but highly experimental. And some
25 * parts are still generic. For instance, the "queryByExample()" methods are
26 * not (or not fully) implemented. Todo: custom-entries not stored.
27 * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular
28 * expression search in the database, which is not supported by sqlite !
29 * Therefore we need either an extended sqlite or a workaround which would
30 * be very slow and memory consuming..
31 *
20 * Revision 1.9 2003/08/01 12:30:16 eilers 32 * Revision 1.9 2003/08/01 12:30:16 eilers
21 * Merging changes from BRANCH_1_0 to HEAD 33 * Merging changes from BRANCH_1_0 to HEAD
22 * 34 *
23 * Revision 1.8.2.1 2003/06/30 14:34:19 eilers 35 * Revision 1.8.2.1 2003/06/30 14:34:19 eilers
24 * Patches from Zecke: 36 * Patches from Zecke:
25 * Fixing and cleaning up extraMap handling 37 * Fixing and cleaning up extraMap handling
26 * Adding d_ptr for binary compatibility in the future 38 * Adding d_ptr for binary compatibility in the future
27 * 39 *
28 * Revision 1.8 2003/05/08 13:55:09 tille 40 * Revision 1.8 2003/05/08 13:55:09 tille
29 * search stuff 41 * search stuff
30 * and match, toRichText & toShortText in oevent 42 * and match, toRichText & toShortText in oevent
31 * 43 *
@@ -69,25 +81,25 @@
69#include <qfileinfo.h> 81#include <qfileinfo.h>
70 82
71#include "ocontact.h" 83#include "ocontact.h"
72#include "ocontactaccessbackend.h" 84#include "ocontactaccessbackend.h"
73#include "opimaccesstemplate.h" 85#include "opimaccesstemplate.h"
74 86
75/** 87/**
76 * Class to access the contacts database. 88 * Class to access the contacts database.
77 * This is just a frontend for the real database handling which is 89 * This is just a frontend for the real database handling which is
78 * done by the backend. 90 * done by the backend.
79 * This class is used to access the Contacts on a system. This class as any OPIE PIM 91 * This class is used to access the Contacts on a system. This class as any OPIE PIM
80 * class is backend independent. 92 * class is backend independent.
81 93 * @author Stefan Eilers, Holger Freyther
82 * @see OPimAccessTemplate 94 * @see OPimAccessTemplate
83 */ 95 */
84class OContactAccess: public QObject, public OPimAccessTemplate<OContact> 96class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
85{ 97{
86 Q_OBJECT 98 Q_OBJECT
87 99
88 public: 100 public:
89 /** 101 /**
90 * Create Database with contacts (addressbook). 102 * Create Database with contacts (addressbook).
91 * @param appname Name of application which wants access to the database 103 * @param appname Name of application which wants access to the database
92 * (i.e. "todolist") 104 * (i.e. "todolist")
93 * @param filename The name of the database file. If not set, the default one 105 * @param filename The name of the database file. If not set, the default one
diff --git a/libopie2/opiepim/core/odatebookaccess.cpp b/libopie2/opiepim/core/odatebookaccess.cpp
index a3661a3..82934f9 100644
--- a/libopie2/opiepim/core/odatebookaccess.cpp
+++ b/libopie2/opiepim/core/odatebookaccess.cpp
@@ -47,20 +47,35 @@ ODateBookAccess::List ODateBookAccess::nonRepeats()const {
47 QArray<int> ints = m_backEnd->nonRepeats(); 47 QArray<int> ints = m_backEnd->nonRepeats();
48 48
49 List lis( ints, this ); 49 List lis( ints, this );
50 return lis; 50 return lis;
51} 51}
52 52
53/** 53/**
54 * @return dates in the time span between from and to 54 * @return dates in the time span between from and to
55 * @param from Include all events from... 55 * @param from Include all events from...
56 * @param to Include all events to... 56 * @param to Include all events to...
57 */ 57 */
58OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDate& from, const QDate& to ) { 58OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDate& from, const QDate& to ) {
59 return m_backEnd->effecticeEvents( from, to ); 59 return m_backEnd->effectiveEvents( from, to );
60} 60}
61/** 61/**
62 * @return all events at a given datetime 62 * @return all events at a given datetime
63 */ 63 */
64OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDateTime& start ) { 64OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDateTime& start ) {
65 return m_backEnd->effecticeEvents( start ); 65 return m_backEnd->effectiveEvents( start );
66}
67
68/**
69 * @return non repeating dates in the time span between from and to
70 * @param from Include all events from...
71 * @param to Include all events to...
72 */
73OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) {
74 return m_backEnd->effectiveNonRepeatingEvents( from, to );
75}
76/**
77 * @return all non repeating events at a given datetime
78 */
79OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDateTime& start ) {
80 return m_backEnd->effectiveNonRepeatingEvents( start );
66} 81}
diff --git a/libopie2/opiepim/core/odatebookaccess.h b/libopie2/opiepim/core/odatebookaccess.h
index 7c7a63f..62196da 100644
--- a/libopie2/opiepim/core/odatebookaccess.h
+++ b/libopie2/opiepim/core/odatebookaccess.h
@@ -4,38 +4,41 @@
4#include "odatebookaccessbackend.h" 4#include "odatebookaccessbackend.h"
5#include "opimaccesstemplate.h" 5#include "opimaccesstemplate.h"
6 6
7#include "oevent.h" 7#include "oevent.h"
8 8
9/** 9/**
10 * This is the object orientated datebook database. It'll use OBackendFactory 10 * This is the object orientated datebook database. It'll use OBackendFactory
11 * to query for a backend. 11 * to query for a backend.
12 * All access to the datebook should be done via this class. 12 * All access to the datebook should be done via this class.
13 * Make sure to load and save the datebook this is not part of 13 * Make sure to load and save the datebook this is not part of
14 * destructing and creating the object 14 * destructing and creating the object
15 * 15 *
16 * @author Holger Freyther 16 * @author Holger Freyther, Stefan Eilers
17 */ 17 */
18class ODateBookAccess : public OPimAccessTemplate<OEvent> { 18class ODateBookAccess : public OPimAccessTemplate<OEvent> {
19public: 19public:
20 ODateBookAccess( ODateBookAccessBackend* = 0l, enum Access acc = Random ); 20 ODateBookAccess( ODateBookAccessBackend* = 0l, enum Access acc = Random );
21 ~ODateBookAccess(); 21 ~ODateBookAccess();
22 22
23 /* return all events */ 23 /* return all events */
24 List rawEvents()const; 24 List rawEvents()const;
25 25
26 /* return repeating events */ 26 /* return repeating events */
27 List rawRepeats()const; 27 List rawRepeats()const;
28 28
29 /* return non repeating events */ 29 /* return non repeating events */
30 List nonRepeats()const; 30 List nonRepeats()const;
31 31
32 OEffectiveEvent::ValueList effectiveEvents( const QDate& from, const QDate& to ); 32 /* return non repeating events (from,to) */
33 OEffectiveEvent::ValueList effectiveEvents( const QDateTime& start ); 33 OEffectiveEvent::ValueList effectiveEvents( const QDate& from, const QDate& to ) const;
34 OEffectiveEvent::ValueList effectiveEvents( const QDateTime& start ) const;
35 OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const;
36 OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDateTime& start ) const;
34 37
35private: 38private:
36 ODateBookAccessBackend* m_backEnd; 39 ODateBookAccessBackend* m_backEnd;
37 class Private; 40 class Private;
38 Private* d; 41 Private* d;
39}; 42};
40 43
41#endif 44#endif
diff --git a/libopie2/opiepim/core/otimezone.cpp b/libopie2/opiepim/core/otimezone.cpp
index b2bd3aa..34659c3 100644
--- a/libopie2/opiepim/core/otimezone.cpp
+++ b/libopie2/opiepim/core/otimezone.cpp
@@ -7,55 +7,64 @@
7 7
8namespace { 8namespace {
9 9
10 QDateTime utcTime( time_t t) { 10 QDateTime utcTime( time_t t) {
11 tm* broken = ::gmtime( &t ); 11 tm* broken = ::gmtime( &t );
12 QDateTime ret; 12 QDateTime ret;
13 ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon +1, broken->tm_mday ) ); 13 ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon +1, broken->tm_mday ) );
14 ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); 14 ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) );
15 return ret; 15 return ret;
16 } 16 }
17 QDateTime utcTime( time_t t, const QString& zone) { 17 QDateTime utcTime( time_t t, const QString& zone) {
18 QCString org = ::getenv( "TZ" ); 18 QCString org = ::getenv( "TZ" );
19#ifndef Q_OS_MACX // Following line causes bus errors on Mac
19 ::setenv( "TZ", zone.latin1(), true ); 20 ::setenv( "TZ", zone.latin1(), true );
20 ::tzset(); 21 ::tzset();
21 22
22 tm* broken = ::localtime( &t ); 23 tm* broken = ::localtime( &t );
23 ::setenv( "TZ", org, true ); 24 ::setenv( "TZ", org, true );
25#else
26#warning "Need a replacement for MacOSX!!"
27 tm* broken = ::localtime( &t );
28#endif
24 29
25 QDateTime ret; 30 QDateTime ret;
26 ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon +1, broken->tm_mday ) ); 31 ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon +1, broken->tm_mday ) );
27 ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); 32 ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) );
28 33
29 return ret; 34 return ret;
30 } 35 }
31 time_t to_Time_t( const QDateTime& utc, const QString& str ) { 36 time_t to_Time_t( const QDateTime& utc, const QString& str ) {
32 QDate d = utc.date(); 37 QDate d = utc.date();
33 QTime t = utc.time(); 38 QTime t = utc.time();
34 39
35 tm broken; 40 tm broken;
36 broken.tm_year = d.year() - 1900; 41 broken.tm_year = d.year() - 1900;
37 broken.tm_mon = d.month() - 1; 42 broken.tm_mon = d.month() - 1;
38 broken.tm_mday = d.day(); 43 broken.tm_mday = d.day();
39 broken.tm_hour = t.hour(); 44 broken.tm_hour = t.hour();
40 broken.tm_min = t.minute(); 45 broken.tm_min = t.minute();
41 broken.tm_sec = t.second(); 46 broken.tm_sec = t.second();
42 47
43 QCString org = ::getenv( "TZ" ); 48 QCString org = ::getenv( "TZ" );
49#ifndef Q_OS_MACX // Following line causes bus errors on Mac
44 ::setenv( "TZ", str.latin1(), true ); 50 ::setenv( "TZ", str.latin1(), true );
45 ::tzset(); 51 ::tzset();
46 52
47 time_t ti = ::mktime( &broken ); 53 time_t ti = ::mktime( &broken );
48 ::setenv( "TZ", org, true ); 54 ::setenv( "TZ", org, true );
49 55#else
56#warning "Need a replacement for MacOSX!!"
57 time_t ti = ::mktime( &broken );
58#endif
50 return ti; 59 return ti;
51 } 60 }
52} 61}
53OTimeZone::OTimeZone( const ZoneName& zone ) 62OTimeZone::OTimeZone( const ZoneName& zone )
54 : m_name(zone) { 63 : m_name(zone) {
55} 64}
56OTimeZone::~OTimeZone() { 65OTimeZone::~OTimeZone() {
57} 66}
58 67
59bool OTimeZone::isValid()const { 68bool OTimeZone::isValid()const {
60 return !m_name.isEmpty(); 69 return !m_name.isEmpty();
61} 70}