summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ABSTRACT18
-rw-r--r--libopie/pim/ocontact.cpp4
-rw-r--r--libopie/pim/ocontact.h3
-rw-r--r--libopie/pim/opimaccesstemplate.h10
-rw-r--r--libopie/pim/opimmaintainer.cpp6
-rw-r--r--libopie/pim/opimmaintainer.h16
-rw-r--r--libopie/pim/opimmainwindow.cpp71
-rw-r--r--libopie/pim/opimmainwindow.h79
-rw-r--r--libopie/pim/opimnotify.cpp227
-rw-r--r--libopie/pim/opimnotify.h142
-rw-r--r--libopie/pim/opimnotifymanager.cpp69
-rw-r--r--libopie/pim/opimnotifymanager.h51
-rw-r--r--libopie/pim/opimrecord.cpp3
-rw-r--r--libopie/pim/opimrecord.h10
-rw-r--r--libopie/pim/opimresolver.h56
-rw-r--r--libopie/pim/opimxref.cpp4
-rw-r--r--libopie/pim/opimxref.h2
-rw-r--r--libopie/pim/opimxrefmanager.cpp4
-rw-r--r--libopie/pim/opimxrefmanager.h2
-rw-r--r--libopie/pim/opimxrefpartner.cpp4
-rw-r--r--libopie/pim/opimxrefpartner.h6
-rw-r--r--libopie/pim/orecur.cpp315
-rw-r--r--libopie/pim/orecur.h29
-rw-r--r--libopie/pim/otodo.cpp72
-rw-r--r--libopie/pim/otodo.h59
-rw-r--r--libopie/pim/otodoaccess.cpp7
-rw-r--r--libopie/pim/otodoaccess.h17
-rw-r--r--libopie/pim/otodoaccessbackend.h1
-rw-r--r--libopie/pim/otodoaccessvcal.cpp6
-rw-r--r--libopie/pim/otodoaccessvcal.h2
-rw-r--r--libopie/pim/otodoaccessxml.cpp27
-rw-r--r--libopie/pim/otodoaccessxml.h1
-rw-r--r--libopie2/opiepim/backend/otodoaccessbackend.h1
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.cpp6
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.h2
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp27
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.h1
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h10
-rw-r--r--libopie2/opiepim/core/opimmaintainer.cpp6
-rw-r--r--libopie2/opiepim/core/opimmaintainer.h16
-rw-r--r--libopie2/opiepim/core/opimnotify.cpp227
-rw-r--r--libopie2/opiepim/core/opimnotify.h142
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.cpp69
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.h51
-rw-r--r--libopie2/opiepim/core/opimrecord.cpp3
-rw-r--r--libopie2/opiepim/core/opimrecord.h10
-rw-r--r--libopie2/opiepim/core/opimresolver.h56
-rw-r--r--libopie2/opiepim/core/opimxref.cpp4
-rw-r--r--libopie2/opiepim/core/opimxref.h2
-rw-r--r--libopie2/opiepim/core/opimxrefmanager.cpp4
-rw-r--r--libopie2/opiepim/core/opimxrefmanager.h2
-rw-r--r--libopie2/opiepim/core/opimxrefpartner.cpp4
-rw-r--r--libopie2/opiepim/core/opimxrefpartner.h6
-rw-r--r--libopie2/opiepim/core/orecur.cpp315
-rw-r--r--libopie2/opiepim/core/orecur.h29
-rw-r--r--libopie2/opiepim/core/otodoaccess.cpp7
-rw-r--r--libopie2/opiepim/core/otodoaccess.h17
-rw-r--r--libopie2/opiepim/ocontact.cpp4
-rw-r--r--libopie2/opiepim/ocontact.h3
-rw-r--r--libopie2/opiepim/otodo.cpp72
-rw-r--r--libopie2/opiepim/otodo.h59
-rw-r--r--libopie2/opiepim/ui/opimmainwindow.cpp71
-rw-r--r--libopie2/opiepim/ui/opimmainwindow.h79
63 files changed, 2432 insertions, 196 deletions
diff --git a/libopie/pim/ABSTRACT b/libopie/pim/ABSTRACT
new file mode 100644
index 0000000..5538d19
--- a/dev/null
+++ b/libopie/pim/ABSTRACT
@@ -0,0 +1,18 @@
1What is Opie PIM? Why is it special?
2Why do we need Opie PIM?
3
4The goal of OpiePIM is to be first of all
5extendable, light weight, scalable and fast.
6For the programmer we try to add a nice but
7powerful API to all classes.
8
9Memory is a costy resource on small and embedded
10devices. So we try to keep the memory usage as
11low as possible. Never the less we won't use structs
12and Pointers in the public API.
13The whole pim framework is value based. Internally we try
14to use implicit sharing as found in other Qt classes as well.
15This makes it possible to give 3rd party devels a nice
16API while keeping the memory usage as low as possible.
17
18We use C++ Templates
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index 917eb0a..efa2777 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -1090,14 +1090,16 @@ void OContact::setDefaultEmail( const QString &v )
1090 1090
1091} 1091}
1092 1092
1093void OContact::insertEmails( const QStringList &v ) 1093void OContact::insertEmails( const QStringList &v )
1094{ 1094{
1095 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) 1095 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
1096 insertEmail( *it ); 1096 insertEmail( *it );
1097} 1097}
1098 1098int OContact::rtti() {
1099 return 2;
1100}
1099void OContact::setUid( int i ) 1101void OContact::setUid( int i )
1100{ 1102{
1101 OPimRecord::setUid(i); 1103 OPimRecord::setUid(i);
1102 replace( Qtopia::AddressUid , QString::number(i)); 1104 replace( Qtopia::AddressUid , QString::number(i));
1103} 1105}
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h
index d97af1c..65ba43e 100644
--- a/libopie/pim/ocontact.h
+++ b/libopie/pim/ocontact.h
@@ -41,17 +41,17 @@ class QPC_EXPORT OContact : public OPimRecord
41 friend class DataSet; 41 friend class DataSet;
42public: 42public:
43 OContact(); 43 OContact();
44 OContact( const QMap<int, QString> &fromMap ); 44 OContact( const QMap<int, QString> &fromMap );
45 virtual ~OContact(); 45 virtual ~OContact();
46 46
47 enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; 47 enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE };
48 48
49 /* 49 /*
50 * do we need to inline them 50 * do we need to inline them
51 * if yes do we need to inline them this way? 51 * if yes do we need to inline them this way?
52 * -zecke 52 * -zecke
53 */ 53 */
54 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } 54 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); }
55 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } 55 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); }
56 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } 56 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); }
57 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } 57 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); }
@@ -206,16 +206,17 @@ public:
206 QMap<QString,QString> OContact::toExtraMap() const; 206 QMap<QString,QString> OContact::toExtraMap() const;
207 class QString OContact::recordField(int) const; 207 class QString OContact::recordField(int) const;
208 208
209 // Why private ? (eilers,se) 209 // Why private ? (eilers,se)
210 QString emailSeparator() const { return " "; } 210 QString emailSeparator() const { return " "; }
211 // the emails should be seperated by a comma 211 // the emails should be seperated by a comma
212 void setEmails( const QString &v ); 212 void setEmails( const QString &v );
213 QString emails() const { return find( Qtopia::Emails ); } 213 QString emails() const { return find( Qtopia::Emails ); }
214 static int rtti();
214 215
215 216
216private: 217private:
217 // The XML-Backend needs some access to the private functions 218 // The XML-Backend needs some access to the private functions
218 friend class OContactAccessBackend_XML; 219 friend class OContactAccessBackend_XML;
219 220
220 void insert( int key, const QString &value ); 221 void insert( int key, const QString &value );
221 void replace( int key, const QString &value ); 222 void replace( int key, const QString &value );
diff --git a/libopie/pim/opimaccesstemplate.h b/libopie/pim/opimaccesstemplate.h
index 6de68b1..8cf81c8 100644
--- a/libopie/pim/opimaccesstemplate.h
+++ b/libopie/pim/opimaccesstemplate.h
@@ -88,16 +88,17 @@ public:
88 virtual void clear() ; 88 virtual void clear() ;
89 89
90 /** 90 /**
91 * add T to the backend 91 * add T to the backend
92 * @param t The item to add. 92 * @param t The item to add.
93 * @return <i>true</i> if added successfully. 93 * @return <i>true</i> if added successfully.
94 */ 94 */
95 virtual bool add( const T& t ) ; 95 virtual bool add( const T& t ) ;
96 bool add( const OPimRecord& );
96 97
97 /* only the uid matters */ 98 /* only the uid matters */
98 /** 99 /**
99 * remove T from the backend 100 * remove T from the backend
100 * @param t The item to remove 101 * @param t The item to remove
101 * @return <i>true</i> if successful. 102 * @return <i>true</i> if successful.
102 */ 103 */
103 virtual bool remove( const T& t ); 104 virtual bool remove( const T& t );
@@ -207,16 +208,25 @@ void OPimAccessTemplate<T>::clear() {
207 m_backEnd->clear(); 208 m_backEnd->clear();
208} 209}
209template <class T> 210template <class T>
210bool OPimAccessTemplate<T>::add( const T& t ) { 211bool OPimAccessTemplate<T>::add( const T& t ) {
211 cache( t ); 212 cache( t );
212 return m_backEnd->add( t ); 213 return m_backEnd->add( t );
213} 214}
214template <class T> 215template <class T>
216bool OPimAccessTemplate<T>::add( const OPimRecord& rec) {
217 /* same type */
218 if ( rec.rtti() == T::rtti() ) {
219 const T &t = static_cast<const T&>(rec);
220 return add(t);
221 }
222 return false;
223}
224template <class T>
215bool OPimAccessTemplate<T>::remove( const T& t ) { 225bool OPimAccessTemplate<T>::remove( const T& t ) {
216 return remove( t.uid() ); 226 return remove( t.uid() );
217} 227}
218template <class T> 228template <class T>
219bool OPimAccessTemplate<T>::remove( int uid ) { 229bool OPimAccessTemplate<T>::remove( int uid ) {
220 m_cache.remove( uid ); 230 m_cache.remove( uid );
221 return m_backEnd->remove( uid ); 231 return m_backEnd->remove( uid );
222} 232}
diff --git a/libopie/pim/opimmaintainer.cpp b/libopie/pim/opimmaintainer.cpp
index e34f035..92cb25a 100644
--- a/libopie/pim/opimmaintainer.cpp
+++ b/libopie/pim/opimmaintainer.cpp
@@ -1,11 +1,11 @@
1#include "opimmaintainer.h" 1#include "opimmaintainer.h"
2 2
3OPimMaintainer::OPimMaintainer( enum Mode mode, int uid ) 3OPimMaintainer::OPimMaintainer( int mode, int uid )
4 : m_mode(mode), m_uid(uid ) 4 : m_mode(mode), m_uid(uid )
5{} 5{}
6OPimMaintainer::~OPimMaintainer() { 6OPimMaintainer::~OPimMaintainer() {
7} 7}
8OPimMaintainer::OPimMaintainer( const OPimMaintainer& main ) { 8OPimMaintainer::OPimMaintainer( const OPimMaintainer& main ) {
9 *this = main; 9 *this = main;
10} 10}
11OPimMaintainer &OPimMaintainer::operator=( const OPimMaintainer& main ) { 11OPimMaintainer &OPimMaintainer::operator=( const OPimMaintainer& main ) {
@@ -18,20 +18,20 @@ bool OPimMaintainer::operator==( const OPimMaintainer& main ) {
18 if (m_mode != main.m_mode ) return false; 18 if (m_mode != main.m_mode ) return false;
19 if (m_uid != main.m_uid ) return false; 19 if (m_uid != main.m_uid ) return false;
20 20
21 return true; 21 return true;
22} 22}
23bool OPimMaintainer::operator!=( const OPimMaintainer& main ) { 23bool OPimMaintainer::operator!=( const OPimMaintainer& main ) {
24 return !(*this == main ); 24 return !(*this == main );
25} 25}
26OPimMaintainer::Mode OPimMaintainer::mode()const { 26int OPimMaintainer::mode()const {
27 return m_mode; 27 return m_mode;
28} 28}
29int OPimMaintainer::uid()const { 29int OPimMaintainer::uid()const {
30 return m_uid; 30 return m_uid;
31} 31}
32void OPimMaintainer::setMode( enum Mode mo) { 32void OPimMaintainer::setMode( int mo) {
33 m_mode = mo; 33 m_mode = mo;
34} 34}
35void OPimMaintainer::setUid( int uid ) { 35void OPimMaintainer::setUid( int uid ) {
36 m_uid = uid; 36 m_uid = uid;
37} 37}
diff --git a/libopie/pim/opimmaintainer.h b/libopie/pim/opimmaintainer.h
index 310e15a..793d066 100644
--- a/libopie/pim/opimmaintainer.h
+++ b/libopie/pim/opimmaintainer.h
@@ -4,33 +4,37 @@
4#include <qstring.h> 4#include <qstring.h>
5 5
6/** 6/**
7 * Who maintains what? 7 * Who maintains what?
8 */ 8 */
9class OPimMaintainer { 9class OPimMaintainer {
10public: 10public:
11 enum Mode { Undefined = -1, 11 enum Mode { Undefined = -1,
12 Responsible = 0, 12 Nothing = 0,
13 Responsible,
13 DoneBy, 14 DoneBy,
14 Coordinating }; 15 Coordinating,
15 OPimMaintainer( enum Mode mode = Undefined, int uid = 0); 16 };
17 OPimMaintainer( int mode = Undefined, int uid = 0);
16 OPimMaintainer( const OPimMaintainer& ); 18 OPimMaintainer( const OPimMaintainer& );
17 ~OPimMaintainer(); 19 ~OPimMaintainer();
18 20
19 OPimMaintainer &operator=( const OPimMaintainer& ); 21 OPimMaintainer &operator=( const OPimMaintainer& );
20 bool operator==( const OPimMaintainer& ); 22 bool operator==( const OPimMaintainer& );
21 bool operator!=( const OPimMaintainer& ); 23 bool operator!=( const OPimMaintainer& );
22 24
23 25
24 Mode mode()const; 26 int mode()const;
25 int uid()const; 27 int uid()const;
26 28
27 void setMode( enum Mode ); 29 void setMode( int mode );
28 void setUid( int uid ); 30 void setUid( int uid );
29 31
30private: 32private:
31 Mode m_mode; 33 int m_mode;
32 int m_uid; 34 int m_uid;
35 class Private;
36 Private *d;
33 37
34}; 38};
35 39
36#endif 40#endif
diff --git a/libopie/pim/opimmainwindow.cpp b/libopie/pim/opimmainwindow.cpp
new file mode 100644
index 0000000..92be2fd
--- a/dev/null
+++ b/libopie/pim/opimmainwindow.cpp
@@ -0,0 +1,71 @@
1#include <qapplication.h>
2#include <qcopchannel_qws.h>
3
4#include <qpe/qcopenvelope_qws.h>
5
6#include "opimmainwindow.h"
7
8OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent,
9 const char* name, WFlags flag )
10 : QMainWindow( parent, name, flag ), m_service( service ), m_fallBack(0l) {
11
12 /*
13 * let's generate our QCopChannel
14 */
15 m_str = QString("QPE/"+m_service).local8Bit();
16 m_channel= new QCopChannel(m_str, this );
17 connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ),
18 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) );
19
20 /* connect flush and reload */
21 connect(qApp, SIGNAL(flush() ),
22 this, SLOT(flush() ) );
23 connect(qApp, SIGNAL(reload() ),
24 this, SLOT(reload() ) );
25}
26OPimMainWindow::~OPimMainWindow() {
27 delete m_channel;
28}
29QCopChannel* OPimMainWindow::channel() {
30 return m_channel;
31}
32void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) {
33 /*
34 * create demands to create
35 * a new record...
36 */
37 QDataStream stream(array, IO_ReadOnly);
38 if ( cmd == "create()" ) {
39 int uid = create();
40 QCopEnvelope e(m_str, "created(int)" );
41 e << uid;
42 }else if ( cmd == "remove(int)" ) {
43 int uid;
44 stream >> uid;
45 bool rem = remove( uid );
46 QCopEnvelope e(m_str, "removed(bool)" );
47 e << rem;
48 }else if ( cmd == "beam(int,int)" ) {
49 int uid, trans;
50 stream >> uid;
51 stream >> trans;
52 beam( uid, trans );
53 }else if ( cmd == "show(int)" ) {
54 int uid;
55 stream >> uid;
56 show( uid );
57 }else if ( cmd == "edit(int)" ) {
58 int uid;
59 stream >> uid;
60 edit( uid );
61 }else if ( cmd == "add(int,QByteArray)" ) {
62 int rtti;
63 QByteArray array;
64 stream >> rtti;
65 stream >> array;
66 m_fallBack = record(rtti, array );
67 if (!m_fallBack) return;
68 add( *m_fallBack );
69 delete m_fallBack;
70 }
71}
diff --git a/libopie/pim/opimmainwindow.h b/libopie/pim/opimmainwindow.h
new file mode 100644
index 0000000..94100bd
--- a/dev/null
+++ b/libopie/pim/opimmainwindow.h
@@ -0,0 +1,79 @@
1#ifndef OPIE_PIM_MAINWINDOW_H
2#define OPIE_PIM_MAINWINDOW_H
3
4#include <qmainwindow.h>
5
6#include <opie/opimrecord.h>
7
8/**
9 * This is a common Opie PIM MainWindow
10 * it takes care of the QCOP internals
11 * and implements some functions
12 * for the URL scripting schema
13 */
14/*
15 * due Qt and Templates with signal and slots
16 * do not work that good :(
17 * (Ok how to moc a template ;) )
18 * We will have the mainwindow which calls a struct which
19 * is normally reimplemented as a template ;)
20 */
21
22class QCopChannel;
23class OPimMainWindow : public QMainWindow {
24 Q_OBJECT
25public:
26 enum TransPort { BlueTooth=0,
27 IrDa };
28
29 OPimMainWindow( const QString& service, QWidget *parent = 0, const char* name = 0,
30 WFlags f = WType_TopLevel);
31 virtual ~OPimMainWindow();
32
33
34protected slots:
35 /* for syncing */
36 virtual void flush() = 0;
37 virtual void reload() = 0;
38
39 /** create a new Records and return the uid */
40 virtual int create() = 0;
41 /** remove a record with UID == uid */
42 virtual bool remove( int uid ) = 0;
43 /** beam the record with UID = uid */
44 virtual void beam( int uid , int transport = IrDa) = 0;
45
46 /** show the record with UID == uid */
47 virtual void show( int uid ) = 0;
48 /** edit the record */
49 virtual void edit( int uid ) = 0;
50
51 /** make a copy of it! */
52 virtual void add( const OPimRecord& ) = 0;
53
54 /* I would love to do this as a template
55 * but can't think of a right way
56 * because I need signal and slots -zecke
57 */
58 /*
59 * the only pointer in the whole PIM API :(
60 */
61 virtual OPimRecord* record( int rtti, const QByteArray& ) = 0;
62 QCopChannel* channel();
63
64private slots:
65 void appMessage( const QCString&, const QByteArray& );
66
67
68private:
69 class Private;
70 Private* d;
71
72 QCopChannel* m_channel;
73 QString m_service;
74 QCString m_str;
75 OPimRecord* m_fallBack;
76};
77
78
79#endif
diff --git a/libopie/pim/opimnotify.cpp b/libopie/pim/opimnotify.cpp
new file mode 100644
index 0000000..af5514b
--- a/dev/null
+++ b/libopie/pim/opimnotify.cpp
@@ -0,0 +1,227 @@
1#include <qshared.h>
2
3#include "opimnotify.h"
4
5struct OPimNotify::Data : public QShared {
6 Data() : QShared(),dur(-1),parent(0) {
7
8 }
9 QDateTime start;
10 int dur;
11 QString application;
12 int parent;
13};
14
15OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) {
16 data = new Data;
17 data->start = start;
18 data->dur = duration;
19 data->parent = parent;
20}
21OPimNotify::OPimNotify( const OPimNotify& noti)
22 : data( noti.data )
23{
24 data->ref();
25}
26OPimNotify::~OPimNotify() {
27 if ( data->deref() ) {
28 delete data;
29 data = 0l;
30 }
31}
32
33OPimNotify &OPimNotify::operator=( const OPimNotify& noti) {
34 noti.data->ref();
35 deref();
36 data = noti.data;
37
38 return *this;
39}
40bool OPimNotify::operator==( const OPimNotify& noti ) {
41 if ( data == noti.data ) return true;
42 if ( data->dur != noti.data->dur ) return false;
43 if ( data->parent != noti.data->parent ) return false;
44 if ( data->application != noti.data->application ) return false;
45 if ( data->start != noti.data->start ) return false;
46
47 return true;
48}
49QDateTime OPimNotify::dateTime()const {
50 return data->start;
51}
52QString OPimNotify::service()const {
53 return data->application;
54}
55int OPimNotify::parent()const {
56 return data->parent;
57}
58int OPimNotify::duration()const {
59 return data->dur;
60}
61QDateTime OPimNotify::endTime()const {
62 return QDateTime( data->start.date(), data->start.time().addSecs( data->dur) );
63}
64void OPimNotify::setDateTime( const QDateTime& time ) {
65 copyIntern();
66 data->start = time;
67}
68void OPimNotify::setDuration( int dur ) {
69 copyIntern();
70 data->dur = dur;
71}
72void OPimNotify::setParent( int uid ) {
73 copyIntern();
74 data->parent = uid;
75}
76void OPimNotify::setService( const QString& str ) {
77 copyIntern();
78 data->application = str;
79}
80void OPimNotify::copyIntern() {
81 if ( data->count != 1 ) {
82 data->deref();
83 Data* dat = new Data;
84 dat->start = data->start;
85 dat->dur = data->dur;
86 dat->application = data->application;
87 dat->parent = data->parent;
88 data = dat;
89 }
90}
91void OPimNotify::deref() {
92 if ( data->deref() ) {
93 delete data;
94 data = 0;
95 }
96}
97
98/***********************************************************/
99struct OPimAlarm::Data : public QShared {
100 Data() : QShared() {
101 sound = 1;
102 }
103 int sound;
104 QString file;
105};
106OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int parent )
107 : OPimNotify( start, duration, parent )
108{
109 data = new Data;
110 data->sound = sound;
111}
112OPimAlarm::OPimAlarm( const OPimAlarm& al)
113 : OPimNotify(al), data( al.data )
114{
115 data->ref();
116}
117OPimAlarm::~OPimAlarm() {
118 if ( data->deref() ) {
119 delete data;
120 data = 0l;
121 }
122}
123OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al)
124{
125 OPimNotify::operator=( al );
126 deref();
127 al.data->ref();
128
129 data = al.data;
130
131
132 return *this;
133}
134bool OPimAlarm::operator==( const OPimAlarm& al) {
135 if ( data->sound != al.data->sound ) return false;
136 else if ( data->sound == Custom && data->file != al.data->file )
137 return false;
138
139 return OPimNotify::operator==( al );
140}
141QString OPimAlarm::type()const {
142 return QString::fromLatin1("OPimAlarm");
143}
144int OPimAlarm::sound()const {
145 return data->sound;
146}
147QString OPimAlarm::file()const {
148 return data->file;
149}
150void OPimAlarm::setSound( int snd) {
151 copyIntern();
152 data->sound = snd;
153}
154void OPimAlarm::setFile( const QString& sound ) {
155 copyIntern();
156 data->file = sound;
157}
158void OPimAlarm::deref() {
159 if ( data->deref() ) {
160 delete data;
161 data = 0l;
162 }
163}
164void OPimAlarm::copyIntern() {
165 if ( data->count != 1 ) {
166 data->deref();
167 Data *newDat = new Data;
168 newDat->sound = data->sound;
169 newDat->file = data->file;
170 data = newDat;
171 }
172}
173/************************/
174struct OPimReminder::Data : public QShared {
175 Data() : QShared(), record( 0) {
176 }
177 int record;
178
179};
180OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent )
181 : OPimNotify( start, dur, parent )
182{
183 data = new Data;
184 data->record = uid;
185}
186OPimReminder::OPimReminder( const OPimReminder& rem )
187 : OPimNotify( rem ), data( rem.data )
188{
189 data->ref();
190}
191OPimReminder& OPimReminder::operator=( const OPimReminder& rem) {
192 OPimNotify::operator=(rem );
193
194 deref();
195 rem.data->ref();
196 data = rem.data;
197
198 return *this;
199}
200bool OPimReminder::operator==( const OPimReminder& rem) {
201 if ( data->record != rem.data->record ) return false;
202
203 return OPimNotify::operator==( rem );
204}
205QString OPimReminder::type()const {
206 return QString::fromLatin1("OPimReminder");
207}
208int OPimReminder::recordUid()const {
209 return data->record;
210}
211void OPimReminder::setRecordUid( int uid ) {
212 copyIntern();
213 data->record = uid;
214}
215void OPimReminder::deref() {
216 if ( data->deref() ) {
217 delete data;
218 data = 0l;
219 }
220}
221void OPimReminder::copyIntern() {
222 if ( data->count != 1 ) {
223 Data* da = new Data;
224 da->record = data->record;
225 data = da;
226 }
227}
diff --git a/libopie/pim/opimnotify.h b/libopie/pim/opimnotify.h
new file mode 100644
index 0000000..3501948
--- a/dev/null
+++ b/libopie/pim/opimnotify.h
@@ -0,0 +1,142 @@
1#ifndef OPIE_PIM_NOTIFY_H
2#define OPIE_PIM_NOTIFY_H
3
4#include <qdatetime.h>
5#include <qvaluelist.h>
6
7/**
8 * This is the base class of Notifiers. Possible
9 * notifiers would be Alarms, Reminders
10 * What they share is that they have
11 * A DateTime, Type, Duration
12 * This is what this base class takes care of
13 * on top of that it's shared
14 */
15/*
16 * TALK to eilers: have a class OPimDuration which sets the Duration
17 * given on the Due/Start Date? -zecke
18 * discuss: do we need a uid for the notify? -zecke
19 */
20class OPimNotify {
21public:
22 typedef QValueList<OPimNotify> ValueList;
23 OPimNotify( const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 );
24 OPimNotify( const OPimNotify& );
25 virtual ~OPimNotify();
26
27 OPimNotify &operator=(const OPimNotify& );
28 bool operator==( const OPimNotify& );
29
30 virtual QString type()const = 0;
31
32 /** start date */
33 QDateTime dateTime()const;
34 QString service()const;
35
36 /**
37 * RETURN the parent uid
38 */
39 int parent()const;
40
41 /**
42 * in Seconds
43 */
44 int duration()const;
45
46 /**
47 * Start Time + Duration
48 */
49 QDateTime endTime()const;
50
51 void setDateTime( const QDateTime& );
52 void setDuration( int dur );
53 void setParent(int uid );
54 void setService( const QString& );
55
56
57private:
58 inline void copyIntern();
59 void deref();
60 struct Data;
61 Data* data;
62
63 /* d-pointer */
64 class NotifyPrivate;
65 NotifyPrivate* d;
66
67};
68/**
69 * An alarm is a sound/mail/buzzer played/send
70 * at a given time to inform about
71 * an Event
72 */
73class OPimAlarm : public OPimNotify {
74public:
75 enum Sound{Loud=0, Silent, Custom };
76 OPimAlarm( int sound = Silent, const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 );
77 OPimAlarm( const OPimAlarm& );
78 ~OPimAlarm();
79
80 OPimAlarm &operator=( const OPimAlarm& );
81 bool operator==( const OPimAlarm& );
82 QString type()const;
83
84 int sound()const;
85 QString file()const;
86
87 void setSound( int );
88 /* only when sound is custom... */
89 void setFile( const QString& sound );
90
91private:
92 void deref();
93 void copyIntern();
94 struct Data;
95 Data * data;
96
97 class Private;
98 Private* d;
99
100};
101
102/**
103 * A Reminder will be put into the
104 * datebook
105 */
106class OPimReminder : public OPimNotify {
107public:
108
109 /**
110 * c'tor of a reminder
111 * @param uid The uid of the Record inside the Datebook
112 * @param start the StartDate invalid for all day...
113 * @param duration The duration of the event ( -1 for all day )
114 * @param parent The 'parent' record of this reminder
115 */
116 OPimReminder( int uid = 0, const QDateTime& start = QDateTime(),
117 int duration = 0, int parent = 0 );
118 OPimReminder( const OPimReminder& );
119 OPimReminder &operator=(const OPimReminder& );
120
121 QString type()const;
122
123 bool operator==( const OPimReminder& );
124
125 /**
126 * the uid of the alarm
127 * inside the 'datebook' application
128 */
129 int recordUid()const;
130 void setRecordUid( int uid );
131
132private:
133 void deref();
134 void copyIntern();
135
136 struct Data;
137 Data* data;
138 class Private;
139 Private *d;
140};
141
142#endif
diff --git a/libopie/pim/opimnotifymanager.cpp b/libopie/pim/opimnotifymanager.cpp
new file mode 100644
index 0000000..be4a1c2
--- a/dev/null
+++ b/libopie/pim/opimnotifymanager.cpp
@@ -0,0 +1,69 @@
1#include "opimnotifymanager.h"
2
3OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al)
4 : m_rem( rem ), m_al( al )
5{}
6OPimNotifyManager::~OPimNotifyManager() {
7}
8/* use static_cast and type instead of dynamic... */
9void OPimNotifyManager::add( const OPimNotify& noti) {
10 if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
11 const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
12 m_rem.append( rem );
13 }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
14 const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
15 m_al.append( al );
16 }
17}
18void OPimNotifyManager::remove( const OPimNotify& noti) {
19 if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
20 const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
21 m_rem.remove( rem );
22 }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
23 const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
24 m_al.remove( al );
25 }
26}
27void OPimNotifyManager::replace( const OPimNotify& noti) {
28 if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
29 const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
30 m_rem.remove( rem );
31 m_rem.append( rem );
32 }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
33 const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
34 m_al.remove( al );
35 m_al.append( al );
36 }
37}
38OPimNotifyManager::Reminders OPimNotifyManager::reminders()const {
39 return m_rem;
40}
41OPimNotifyManager::Alarms OPimNotifyManager::alarms()const {
42 return m_al;
43}
44void OPimNotifyManager::setAlarms( const Alarms& al) {
45 m_al = al;
46}
47void OPimNotifyManager::setReminders( const Reminders& rem) {
48 m_rem = rem;
49}
50/* FIXME!!! */
51/**
52 * The idea is to check if the provider for our service
53 * is online
54 * if it is we will use QCOP
55 * if not the Factory to get the backend...
56 * Qtopia1.6 services would be kewl to have here....
57 */
58void OPimNotifyManager::registerNotify( const OPimNotify& ) {
59
60}
61/* FIXME!!! */
62/**
63 * same as above...
64 * Also implement Url model
65 * have a MainWindow....
66 */
67void OPimNotifyManager::deregister( const OPimNotify& ) {
68
69}
diff --git a/libopie/pim/opimnotifymanager.h b/libopie/pim/opimnotifymanager.h
new file mode 100644
index 0000000..0eebc9b
--- a/dev/null
+++ b/libopie/pim/opimnotifymanager.h
@@ -0,0 +1,51 @@
1#ifndef OPIE_PIM_NOTIFY_MANAGER_H
2#define OPIE_PIM_NOTIFY_MANAGER_H
3
4#include <qvaluelist.h>
5
6#include <opie/opimnotify.h>
7
8/**
9 * The notify manager keeps track of the Notifiers....
10 */
11class OPimNotifyManager {
12public:
13 typedef QValueList<OPimReminder> Reminders;
14 typedef QValueList<OPimAlarm> Alarms;
15 OPimNotifyManager( const Reminders& rems = Reminders(), const Alarms& alarms = Alarms() );
16 ~OPimNotifyManager();
17
18 /* we will cast it for you ;) */
19 void add( const OPimNotify& );
20 void remove( const OPimNotify& );
21 /* replaces all with this one! */
22 void replace( const OPimNotify& );
23
24 Reminders reminders()const;
25 Alarms alarms()const;
26
27 void setAlarms( const Alarms& );
28 void setReminders( const Reminders& );
29
30 /* register is a Ansi C keyword... */
31 /**
32 * This function will register the Notify to the Alarm Server
33 * or datebook depending on the type of the notify
34 */
35 void registerNotify( const OPimNotify& );
36
37 /**
38 * this will do the opposite..
39 */
40 void deregister( const OPimNotify& );
41
42private:
43 Reminders m_rem;
44 Alarms m_al;
45
46 class Private;
47 Private *d;
48
49};
50
51#endif
diff --git a/libopie/pim/opimrecord.cpp b/libopie/pim/opimrecord.cpp
index 0e3be9d..49b5bf9 100644
--- a/libopie/pim/opimrecord.cpp
+++ b/libopie/pim/opimrecord.cpp
@@ -74,8 +74,11 @@ void OPimRecord::setUid( int uid ) {
74 Qtopia::Record::setUid( uid ); 74 Qtopia::Record::setUid( uid );
75}; 75};
76Qtopia::UidGen &OPimRecord::uidGen() { 76Qtopia::UidGen &OPimRecord::uidGen() {
77 return m_uidGen; 77 return m_uidGen;
78} 78}
79OPimXRefManager &OPimRecord::xrefmanager() { 79OPimXRefManager &OPimRecord::xrefmanager() {
80 return m_xrefman; 80 return m_xrefman;
81} 81}
82int OPimRecord::rtti(){
83 return 0;
84}
diff --git a/libopie/pim/opimrecord.h b/libopie/pim/opimrecord.h
index 1642a5e..ec99a13 100644
--- a/libopie/pim/opimrecord.h
+++ b/libopie/pim/opimrecord.h
@@ -84,26 +84,32 @@ public:
84 /** 84 /**
85 * the name for a recordField 85 * the name for a recordField
86 */ 86 */
87 virtual QString recordField(int)const = 0; 87 virtual QString recordField(int)const = 0;
88 88
89 /** 89 /**
90 * returns a reference of the 90 * returns a reference of the
91 * Cross Reference Manager 91 * Cross Reference Manager
92 * Partner One is THIS PIM RECORD! 92 * Partner 'One' is THIS PIM RECORD!
93 * Two is the Partner where we link to 93 * 'Two' is the Partner where we link to
94 */ 94 */
95 OPimXRefManager& xrefmanager(); 95 OPimXRefManager& xrefmanager();
96 96
97 /** 97 /**
98 * set the uid 98 * set the uid
99 */ 99 */
100 virtual void setUid( int uid ); 100 virtual void setUid( int uid );
101 101
102 /*
103 * used inside the Templates for casting
104 * REIMPLEMENT in your ....
105 */
106 static int rtti();
107
102protected: 108protected:
103 Qtopia::UidGen &uidGen(); 109 Qtopia::UidGen &uidGen();
104// QString crossToString()const; 110// QString crossToString()const;
105 111
106private: 112private:
107 class OPimRecordPrivate; 113 class OPimRecordPrivate;
108 OPimRecordPrivate *d; 114 OPimRecordPrivate *d;
109 OPimXRefManager m_xrefman; 115 OPimXRefManager m_xrefman;
diff --git a/libopie/pim/opimresolver.h b/libopie/pim/opimresolver.h
new file mode 100644
index 0000000..86ae3eb
--- a/dev/null
+++ b/libopie/pim/opimresolver.h
@@ -0,0 +1,56 @@
1#ifndef OPIE_PIM_RESOLVER
2#define OPIE_PIM_RESOLVER
3
4#include <qstring.h>
5#include <qvaluelist.h>
6
7/**
8 * OPimResolver is a MetaClass to access
9 * available backends read only.
10 * It will be used to resolve uids + app names
11 * to full informations
12 * to traverse through a list of alarms, reminders
13 * to get access to built in PIM functionality
14 * and to more stuff
15 * THE PERFORMANCE will depend on THE BACKEND
16 * USING XML is a waste of memory!!!!!
17 */
18class OPimResolver : public QObject {
19public:
20 enum BuiltIn { TodoList = 0,
21 DateBook,
22 AddressBook
23 };
24 static OPimResolver* self();
25
26
27 /*
28 * return a record for a uid
29 * and an app
30 */
31 OPimRecord &record( const QString& service, int uid );
32
33 /**
34 * return the QCopChannel for service
35 * When we will use Qtopia Services it will be used here
36 */
37 QString qcopChannel( enum BuiltIn& )const;
38 QString qcopChannel( const QString& service );
39
40 /**
41 * return a list of available services
42 */
43 QStringList services()const;
44
45 /**
46 * add a record to a service... ;)
47 */
48 bool add( const QString& service, const OPimRecord& );
49
50private:
51 OPimResolver();
52 OPimRecord *m_last;
53
54}:
55
56#endif
diff --git a/libopie/pim/opimxref.cpp b/libopie/pim/opimxref.cpp
index 5cae871..8eefbd8 100644
--- a/libopie/pim/opimxref.cpp
+++ b/libopie/pim/opimxref.cpp
@@ -29,18 +29,18 @@ bool OPimXRef::operator==( const OPimXRef& oper ) {
29} 29}
30OPimXRefPartner OPimXRef::partner( enum Partners par) const{ 30OPimXRefPartner OPimXRef::partner( enum Partners par) const{
31 return m_partners[par]; 31 return m_partners[par];
32} 32}
33void OPimXRef::setPartner( enum Partners par, const OPimXRefPartner& part) { 33void OPimXRef::setPartner( enum Partners par, const OPimXRefPartner& part) {
34 m_partners[par] = part; 34 m_partners[par] = part;
35} 35}
36bool OPimXRef::containsString( const QString& string ) const{ 36bool OPimXRef::containsString( const QString& string ) const{
37 if ( m_partners[One].appName() == string || 37 if ( m_partners[One].service() == string ||
38 m_partners[Two].appName() == string ) return true; 38 m_partners[Two].service() == string ) return true;
39 39
40 return false; 40 return false;
41} 41}
42bool OPimXRef::containsUid( int uid ) const{ 42bool OPimXRef::containsUid( int uid ) const{
43 if ( m_partners[One].uid() == uid || 43 if ( m_partners[One].uid() == uid ||
44 m_partners[Two].uid() == uid ) return true; 44 m_partners[Two].uid() == uid ) return true;
45 45
46 return false; 46 return false;
diff --git a/libopie/pim/opimxref.h b/libopie/pim/opimxref.h
index 354739a..6852651 100644
--- a/libopie/pim/opimxref.h
+++ b/libopie/pim/opimxref.h
@@ -21,17 +21,17 @@ public:
21 21
22 OPimXRef &operator=( const OPimXRef& ); 22 OPimXRef &operator=( const OPimXRef& );
23 bool operator==( const OPimXRef& ); 23 bool operator==( const OPimXRef& );
24 24
25 OPimXRefPartner partner( enum Partners )const; 25 OPimXRefPartner partner( enum Partners )const;
26 26
27 void setPartner( enum Partners, const OPimXRefPartner& ); 27 void setPartner( enum Partners, const OPimXRefPartner& );
28 28
29 bool containsString( const QString& appName)const; 29 bool containsString( const QString& service)const;
30 bool containsUid( int uid )const; 30 bool containsUid( int uid )const;
31 31
32private: 32private:
33 QArray<OPimXRefPartner> m_partners; 33 QArray<OPimXRefPartner> m_partners;
34 34
35 class Private; 35 class Private;
36 Private *d; 36 Private *d;
37}; 37};
diff --git a/libopie/pim/opimxrefmanager.cpp b/libopie/pim/opimxrefmanager.cpp
index 965f542..58bfd24 100644
--- a/libopie/pim/opimxrefmanager.cpp
+++ b/libopie/pim/opimxrefmanager.cpp
@@ -31,20 +31,20 @@ void OPimXRefManager::clear() {
31 m_list.clear(); 31 m_list.clear();
32} 32}
33QStringList OPimXRefManager::apps()const { 33QStringList OPimXRefManager::apps()const {
34 OPimXRef::ValueList::ConstIterator it; 34 OPimXRef::ValueList::ConstIterator it;
35 QStringList list; 35 QStringList list;
36 36
37 QString str; 37 QString str;
38 for ( it = m_list.begin(); it != m_list.end(); ++it ) { 38 for ( it = m_list.begin(); it != m_list.end(); ++it ) {
39 str = (*it).partner( OPimXRef::One ).appName(); 39 str = (*it).partner( OPimXRef::One ).service();
40 if ( !list.contains( str ) ) list << str; 40 if ( !list.contains( str ) ) list << str;
41 41
42 str = (*it).partner( OPimXRef::Two ).appName(); 42 str = (*it).partner( OPimXRef::Two ).service();
43 if ( !list.contains( str ) ) list << str; 43 if ( !list.contains( str ) ) list << str;
44 } 44 }
45 return list; 45 return list;
46} 46}
47OPimXRef::ValueList OPimXRefManager::list()const { 47OPimXRef::ValueList OPimXRefManager::list()const {
48 return m_list; 48 return m_list;
49} 49}
50OPimXRef::ValueList OPimXRefManager::list( const QString& appName )const{ 50OPimXRef::ValueList OPimXRefManager::list( const QString& appName )const{
diff --git a/libopie/pim/opimxrefmanager.h b/libopie/pim/opimxrefmanager.h
index 9b003a3..39e5eef 100644
--- a/libopie/pim/opimxrefmanager.h
+++ b/libopie/pim/opimxrefmanager.h
@@ -26,16 +26,16 @@ public:
26 26
27 void clear(); 27 void clear();
28 28
29 /** 29 /**
30 * apps participating 30 * apps participating
31 */ 31 */
32 QStringList apps()const; 32 QStringList apps()const;
33 OPimXRef::ValueList list()const; 33 OPimXRef::ValueList list()const;
34 OPimXRef::ValueList list( const QString& appName )const; 34 OPimXRef::ValueList list( const QString& service )const;
35 OPimXRef::ValueList list( int uid )const; 35 OPimXRef::ValueList list( int uid )const;
36 36
37private: 37private:
38 OPimXRef::ValueList m_list; 38 OPimXRef::ValueList m_list;
39}; 39};
40 40
41#endif 41#endif
diff --git a/libopie/pim/opimxrefpartner.cpp b/libopie/pim/opimxrefpartner.cpp
index 028f4e6..6ef3efb 100644
--- a/libopie/pim/opimxrefpartner.cpp
+++ b/libopie/pim/opimxrefpartner.cpp
@@ -18,26 +18,26 @@ OPimXRefPartner &OPimXRefPartner::operator=( const OPimXRefPartner& par ) {
18} 18}
19bool OPimXRefPartner::operator==( const OPimXRefPartner& par ) { 19bool OPimXRefPartner::operator==( const OPimXRefPartner& par ) {
20 if ( m_app != par.m_app ) return false; 20 if ( m_app != par.m_app ) return false;
21 if ( m_uid != par.m_uid ) return false; 21 if ( m_uid != par.m_uid ) return false;
22 if ( m_field != par.m_field ) return false; 22 if ( m_field != par.m_field ) return false;
23 23
24 return true; 24 return true;
25} 25}
26QString OPimXRefPartner::appName()const { 26QString OPimXRefPartner::service()const {
27 return m_app; 27 return m_app;
28} 28}
29int OPimXRefPartner::uid()const { 29int OPimXRefPartner::uid()const {
30 return m_uid; 30 return m_uid;
31} 31}
32int OPimXRefPartner::field()const { 32int OPimXRefPartner::field()const {
33 return m_field; 33 return m_field;
34} 34}
35void OPimXRefPartner::setAppName( const QString& appName ) { 35void OPimXRefPartner::setService( const QString& appName ) {
36 m_app = appName; 36 m_app = appName;
37} 37}
38void OPimXRefPartner::setUid( int uid ) { 38void OPimXRefPartner::setUid( int uid ) {
39 m_uid = uid; 39 m_uid = uid;
40} 40}
41void OPimXRefPartner::setField( int field ) { 41void OPimXRefPartner::setField( int field ) {
42 m_field = field; 42 m_field = field;
43} 43}
diff --git a/libopie/pim/opimxrefpartner.h b/libopie/pim/opimxrefpartner.h
index 808b9ab..d76e384 100644
--- a/libopie/pim/opimxrefpartner.h
+++ b/libopie/pim/opimxrefpartner.h
@@ -7,29 +7,29 @@
7 * This class represents one partner 7 * This class represents one partner
8 * of a Cross Reference. 8 * of a Cross Reference.
9 * In Opie one application 9 * In Opie one application
10 * can link one uid 10 * can link one uid
11 * with one tableId( fieldId ) to another. 11 * with one tableId( fieldId ) to another.
12 */ 12 */
13class OPimXRefPartner { 13class OPimXRefPartner {
14public: 14public:
15 OPimXRefPartner( const QString& appName = QString::null, 15 OPimXRefPartner( const QString& service = QString::null,
16 int uid = 0, int field = -1 ); 16 int uid = 0, int field = -1 );
17 OPimXRefPartner( const OPimXRefPartner& ); 17 OPimXRefPartner( const OPimXRefPartner& );
18 OPimXRefPartner& operator=( const OPimXRefPartner& ); 18 OPimXRefPartner& operator=( const OPimXRefPartner& );
19 ~OPimXRefPartner(); 19 ~OPimXRefPartner();
20 20
21 bool operator==(const OPimXRefPartner& ); 21 bool operator==(const OPimXRefPartner& );
22 22
23 QString appName()const; 23 QString service()const;
24 int uid()const; 24 int uid()const;
25 int field()const; 25 int field()const;
26 26
27 void setAppName( const QString& appName ); 27 void setService( const QString& service );
28 void setUid( int uid ); 28 void setUid( int uid );
29 void setField( int field ); 29 void setField( int field );
30private: 30private:
31 QString m_app; 31 QString m_app;
32 int m_uid; 32 int m_uid;
33 int m_field; 33 int m_field;
34 34
35 class Private; 35 class Private;
diff --git a/libopie/pim/orecur.cpp b/libopie/pim/orecur.cpp
index 257d4fd..daf3506 100644
--- a/libopie/pim/orecur.cpp
+++ b/libopie/pim/orecur.cpp
@@ -17,16 +17,19 @@ struct ORecur::Data : public QShared {
17 char days; // Q_UINT8 for 8 seven days;) 17 char days; // Q_UINT8 for 8 seven days;)
18 ORecur::RepeatType type; 18 ORecur::RepeatType type;
19 int freq; 19 int freq;
20 int pos; 20 int pos;
21 bool hasEnd : 1; 21 bool hasEnd : 1;
22 time_t end; 22 time_t end;
23 time_t create; 23 time_t create;
24 int rep; 24 int rep;
25 QString app;
26 ExceptionList list;
27 QDate start;
25}; 28};
26 29
27 30
28ORecur::ORecur() { 31ORecur::ORecur() {
29 data = new Data; 32 data = new Data;
30} 33}
31ORecur::ORecur( const ORecur& rec) 34ORecur::ORecur( const ORecur& rec)
32 : data( rec.data ) 35 : data( rec.data )
@@ -50,16 +53,308 @@ bool ORecur::operator==( const ORecur& )const {
50} 53}
51ORecur &ORecur::operator=( const ORecur& re) { 54ORecur &ORecur::operator=( const ORecur& re) {
52 re.data->ref(); 55 re.data->ref();
53 deref(); 56 deref();
54 data = re.data; 57 data = re.data;
55 58
56 return *this; 59 return *this;
57} 60}
61bool ORecur::doesRecur()const {
62 return !( type() == NoRepeat );
63}
64/*
65 * we try to be smart here
66 *
67 */
68bool ORecur::doesRecur( const QDate& date ) {
69 /* the day before the recurrance */
70 QDate da = date.addDays(-1);
71
72 QDate recur;
73 if (!nextOcurrence( da, recur ) )
74 return false;
75
76 return (recur == date);
77}
78// FIXME unuglify!
79// GPL from Datebookdb.cpp
80// FIXME exception list!
81bool ORecur::nextOcurrence( const QDate& from, QDate& next ) {
82
83 // easy checks, first are we too far in the future or too far in the past?
84 QDate tmpDate;
85 int freq = frequency();
86 int diff, diff2, a;
87 int iday, imonth, iyear;
88 int dayOfWeek = 0;
89 int firstOfWeek = 0;
90 int weekOfMonth;
91
92
93 if (hasEndDate() && endDate() < from)
94 return FALSE;
95
96 if (start() >= from) {
97 next = start();
98 return TRUE;
99 }
100
101 switch ( type() ) {
102 case Weekly:
103 /* weekly is just daily by 7 */
104 /* first convert the repeatPattern.Days() mask to the next
105 day of week valid after from */
106 dayOfWeek = from.dayOfWeek();
107 dayOfWeek--; /* we want 0-6, doco for above specs 1-7 */
108
109 /* this is done in case freq > 1 and from in week not
110 for this round */
111 // firstOfWeek = 0; this is already done at decl.
112 while(!((1 << firstOfWeek) & days() ))
113 firstOfWeek++;
114
115 /* there is at least one 'day', or there would be no event */
116 while(!((1 << (dayOfWeek % 7)) & days() ))
117 dayOfWeek++;
118
119 dayOfWeek = dayOfWeek % 7; /* the actual day of week */
120 dayOfWeek -= start().dayOfWeek() -1;
121
122 firstOfWeek = firstOfWeek % 7; /* the actual first of week */
123 firstOfWeek -= start().dayOfWeek() -1;
124
125 // dayOfWeek may be negitive now
126 // day of week is number of days to add to start day
127
128 freq *= 7;
129 // FALL-THROUGH !!!!!
130 case Daily:
131 // the add is for the possible fall through from weekly */
132 if(start().addDays(dayOfWeek) > from) {
133 /* first week exception */
134 next = QDate(start().addDays(dayOfWeek) );
135 if ((next > endDate())
136 && hasEndDate() )
137 return FALSE;
138 return TRUE;
139 }
140 /* if from is middle of a non-week */
141
142 diff = start().addDays(dayOfWeek).daysTo(from) % freq;
143 diff2 = start().addDays(firstOfWeek).daysTo(from) % freq;
144
145 if(diff != 0)
146 diff = freq - diff;
147 if(diff2 != 0)
148 diff2 = freq - diff2;
149 diff = QMIN(diff, diff2);
150
151 next = QDate(from.addDays(diff));
152 if ( (next > endDate())
153 && hasEndDate() )
154 return FALSE;
155 return TRUE;
156 case MonthlyDay:
157 iday = from.day();
158 iyear = from.year();
159 imonth = from.month();
160 /* find equivelent day of month for this month */
161 dayOfWeek = start().dayOfWeek();
162 weekOfMonth = (start().day() - 1) / 7;
163
164 /* work out when the next valid month is */
165 a = from.year() - start().year();
166 a *= 12;
167 a = a + (imonth - start().month());
168 /* a is e.start()monthsFrom(from); */
169 if(a % freq) {
170 a = freq - (a % freq);
171 imonth = from.month() + a;
172 if (imonth > 12) {
173 imonth--;
174 iyear += imonth / 12;
175 imonth = imonth % 12;
176 imonth++;
177 }
178 }
179 /* imonth is now the first month after or on
180 from that matches the frequency given */
181
182 /* find for this month */
183 tmpDate = QDate( iyear, imonth, 1 );
184
185 iday = 1;
186 iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7;
187 iday += 7 * weekOfMonth;
188 while (iday > tmpDate.daysInMonth()) {
189 imonth += freq;
190 if (imonth > 12) {
191 imonth--;
192 iyear += imonth / 12;
193 imonth = imonth % 12;
194 imonth++;
195 }
196 tmpDate = QDate( iyear, imonth, 1 );
197 /* these loops could go for a while, check end case now */
198 if ((tmpDate > endDate()) && hasEndDate() )
199 return FALSE;
200 iday = 1;
201 iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7;
202 iday += 7 * weekOfMonth;
203 }
204 tmpDate = QDate(iyear, imonth, iday);
205
206 if (tmpDate >= from) {
207 next = tmpDate;
208 if ((next > endDate() ) && hasEndDate() )
209 return FALSE;
210 return TRUE;
211 }
212
213 /* need to find the next iteration */
214 do {
215 imonth += freq;
216 if (imonth > 12) {
217 imonth--;
218 iyear += imonth / 12;
219 imonth = imonth % 12;
220 imonth++;
221 }
222 tmpDate = QDate( iyear, imonth, 1 );
223 /* these loops could go for a while, check end case now */
224 if ((tmpDate > endDate()) && hasEndDate() )
225 return FALSE;
226 iday = 1;
227 iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7;
228 iday += 7 * weekOfMonth;
229 } while (iday > tmpDate.daysInMonth());
230 tmpDate = QDate(iyear, imonth, iday);
231
232 next = tmpDate;
233 if ((next > endDate()) && hasEndDate() )
234 return FALSE;
235 return TRUE;
236 case MonthlyDate:
237 iday = start().day();
238 iyear = from.year();
239 imonth = from.month();
240
241 a = from.year() - start().year();
242 a *= 12;
243 a = a + (imonth - start().month());
244 /* a is e.start()monthsFrom(from); */
245 if(a % freq) {
246 a = freq - (a % freq);
247 imonth = from.month() + a;
248 if (imonth > 12) {
249 imonth--;
250 iyear += imonth / 12;
251 imonth = imonth % 12;
252 imonth++;
253 }
254 }
255 /* imonth is now the first month after or on
256 from that matches the frequencey given */
257
258 /* this could go for a while, worse case, 4*12 iterations, probably */
259 while(!QDate::isValid(iyear, imonth, iday) ) {
260 imonth += freq;
261 if (imonth > 12) {
262 imonth--;
263 iyear += imonth / 12;
264 imonth = imonth % 12;
265 imonth++;
266 }
267 /* these loops could go for a while, check end case now */
268 if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() )
269 return FALSE;
270 }
271
272 if(QDate(iyear, imonth, iday) >= from) {
273 /* done */
274 next = QDate(iyear, imonth, iday);
275 if ((next > endDate()) && hasEndDate() )
276 return FALSE;
277 return TRUE;
278 }
279
280 /* ok, need to cycle */
281 imonth += freq;
282 imonth--;
283 iyear += imonth / 12;
284 imonth = imonth % 12;
285 imonth++;
286
287 while(!QDate::isValid(iyear, imonth, iday) ) {
288 imonth += freq;
289 imonth--;
290 iyear += imonth / 12;
291 imonth = imonth % 12;
292 imonth++;
293 if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() )
294 return FALSE;
295 }
296
297 next = QDate(iyear, imonth, iday);
298 if ((next > endDate()) && hasEndDate() )
299 return FALSE;
300 return TRUE;
301 case Yearly:
302 iday = start().day();
303 imonth = start().month();
304 iyear = from.year(); // after all, we want to start in this year
305
306 diff = 1;
307 if(imonth == 2 && iday > 28) {
308 /* leap year, and it counts, calculate actual frequency */
309 if(freq % 4)
310 if (freq % 2)
311 freq = freq * 4;
312 else
313 freq = freq * 2;
314 /* else divides by 4 already, leave freq alone */
315 diff = 4;
316 }
317
318 a = from.year() - start().year();
319 if(a % freq) {
320 a = freq - (a % freq);
321 iyear = iyear + a;
322 }
323
324 /* under the assumption we won't hit one of the special not-leap years twice */
325 if(!QDate::isValid(iyear, imonth, iday)) {
326 /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */
327 iyear += freq;
328 }
329
330 if(QDate(iyear, imonth, iday) >= from) {
331 next = QDate(iyear, imonth, iday);
332
333 if ((next > endDate()) && hasEndDate() )
334 return FALSE;
335 return TRUE;
336 }
337 /* iyear == from.year(), need to advance again */
338 iyear += freq;
339 /* under the assumption we won't hit one of the special not-leap years twice */
340 if(!QDate::isValid(iyear, imonth, iday)) {
341 /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */
342 iyear += freq;
343 }
344
345 next = QDate(iyear, imonth, iday);
346 if ((next > endDate()) && hasEndDate() )
347 return FALSE;
348 return TRUE;
349 default:
350 return FALSE;
351 }
352}
58ORecur::RepeatType ORecur::type()const{ 353ORecur::RepeatType ORecur::type()const{
59 return data->type; 354 return data->type;
60} 355}
61int ORecur::frequency()const { 356int ORecur::frequency()const {
62 return data->freq; 357 return data->freq;
63} 358}
64int ORecur::position()const { 359int ORecur::position()const {
65 return data->pos; 360 return data->pos;
@@ -68,25 +363,34 @@ char ORecur::days() const{
68 return data->days; 363 return data->days;
69} 364}
70bool ORecur::hasEndDate()const { 365bool ORecur::hasEndDate()const {
71 return data->hasEnd; 366 return data->hasEnd;
72} 367}
73QDate ORecur::endDate()const { 368QDate ORecur::endDate()const {
74 return TimeConversion::fromUTC( data->end ).date(); 369 return TimeConversion::fromUTC( data->end ).date();
75} 370}
371QDate ORecur::start()const{
372 return data->start;
373}
76time_t ORecur::endDateUTC()const { 374time_t ORecur::endDateUTC()const {
77 return data->end; 375 return data->end;
78} 376}
79time_t ORecur::createTime()const { 377time_t ORecur::createTime()const {
80 return data->create; 378 return data->create;
81} 379}
82int ORecur::repetition()const { 380int ORecur::repetition()const {
83 return data->rep; 381 return data->rep;
84} 382}
383QString ORecur::service()const {
384 return data->app;
385}
386ORecur::ExceptionList& ORecur::exceptions() {
387 return data->list;
388}
85void ORecur::setType( const RepeatType& z) { 389void ORecur::setType( const RepeatType& z) {
86 checkOrModify(); 390 checkOrModify();
87 data->type = z; 391 data->type = z;
88} 392}
89void ORecur::setFrequency( int freq ) { 393void ORecur::setFrequency( int freq ) {
90 checkOrModify(); 394 checkOrModify();
91 data->freq = freq; 395 data->freq = freq;
92} 396}
@@ -113,24 +417,35 @@ void ORecur::setCreateTime( time_t t) {
113void ORecur::setHasEndDate( bool b) { 417void ORecur::setHasEndDate( bool b) {
114 checkOrModify(); 418 checkOrModify();
115 data->hasEnd = b; 419 data->hasEnd = b;
116} 420}
117void ORecur::setRepitition( int rep ) { 421void ORecur::setRepitition( int rep ) {
118 checkOrModify(); 422 checkOrModify();
119 data->rep = rep; 423 data->rep = rep;
120} 424}
425void ORecur::setService( const QString& app ) {
426 checkOrModify();
427 data->app = app;
428}
429void ORecur::setStart( const QDate& dt ) {
430 checkOrModify();
431 data->start = dt;
432}
121void ORecur::checkOrModify() { 433void ORecur::checkOrModify() {
122 if ( data->count != 1 ) { 434 if ( data->count != 1 ) {
123 data->deref(); 435 data->deref();
124 Data* d2 = new Data; 436 Data* d2 = new Data;
125 d2->days = data->days; 437 d2->days = data->days;
126 d2->type = data->type; 438 d2->type = data->type;
127 d2->freq = data->freq; 439 d2->freq = data->freq;
128 d2->pos = data->pos; 440 d2->pos = data->pos;
129 d2->hasEnd = data->hasEnd; 441 d2->hasEnd = data->hasEnd;
130 d2->end = data->end; 442 d2->end = data->end;
131 d2->create = data->create; 443 d2->create = data->create;
132 d2->rep = data->rep; 444 d2->rep = data->rep;
445 d2->app = data->app;
446 d2->list = data->list;
447 d2->start = data->start;
133 data = d2; 448 data = d2;
134 } 449 }
135} 450}
136 451
diff --git a/libopie/pim/orecur.h b/libopie/pim/orecur.h
index d24d72d..8713d97 100644
--- a/libopie/pim/orecur.h
+++ b/libopie/pim/orecur.h
@@ -3,50 +3,77 @@
3 */ 3 */
4 4
5#ifndef OPIE_RECUR_H 5#ifndef OPIE_RECUR_H
6#define OPIE_RECUR_H 6#define OPIE_RECUR_H
7 7
8#include <sys/types.h> 8#include <sys/types.h>
9 9
10#include <qdatetime.h> 10#include <qdatetime.h>
11 11#include <qvaluelist.h>
12 12
13 13
14class ORecur { 14class ORecur {
15public: 15public:
16 typedef QValueList<QDate> ExceptionList;
16 enum RepeatType{ NoRepeat = -1, Daily, Weekly, MonthlyDay, 17 enum RepeatType{ NoRepeat = -1, Daily, Weekly, MonthlyDay,
17 MonthlyDate, Yearly }; 18 MonthlyDate, Yearly };
18 enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08, 19 enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08,
19 FRI = 0x10, SAT = 0x20, SUN = 0x40 }; 20 FRI = 0x10, SAT = 0x20, SUN = 0x40 };
20 ORecur(); 21 ORecur();
21 ORecur( const ORecur& ); 22 ORecur( const ORecur& );
22 ~ORecur(); 23 ~ORecur();
23 24
24 ORecur &operator=( const ORecur& ); 25 ORecur &operator=( const ORecur& );
25 bool operator==(const ORecur& )const; 26 bool operator==(const ORecur& )const;
27
28 bool doesRecur()const;
29 /* if it recurrs on that day */
30 bool doesRecur( const QDate& );
26 RepeatType type()const; 31 RepeatType type()const;
27 int frequency()const; 32 int frequency()const;
28 int position()const; 33 int position()const;
29 char days()const; 34 char days()const;
30 bool hasEndDate()const; 35 bool hasEndDate()const;
36 QDate start()const;
31 QDate endDate()const; 37 QDate endDate()const;
32 time_t endDateUTC()const; 38 time_t endDateUTC()const;
33 time_t createTime()const; 39 time_t createTime()const;
40
41 /**
42 * FromWhereToStart is not included!!!
43 */
44 bool nextOcurrence( const QDate& FromWhereToStart, QDate &recurDate );
45 /**
46 * The module this ORecur belongs to
47 */
48 QString service()const;
49
50 /*
51 * reference to the exception list
52 */
53 ExceptionList &exceptions();
54
55 /**
56 * the current repetition
57 */
34 int repetition()const; 58 int repetition()const;
35 59
36 void setType( const RepeatType& ); 60 void setType( const RepeatType& );
37 void setFrequency( int freq ); 61 void setFrequency( int freq );
38 void setPosition( int pos ); 62 void setPosition( int pos );
39 void setDays( char c); 63 void setDays( char c);
40 void setEndDate( const QDate& dt ); 64 void setEndDate( const QDate& dt );
65 void setStart( const QDate& dt );
41 void setEndDateUTC( time_t ); 66 void setEndDateUTC( time_t );
42 void setCreateTime( time_t ); 67 void setCreateTime( time_t );
43 void setHasEndDate( bool b ); 68 void setHasEndDate( bool b );
44 void setRepitition(int ); 69 void setRepitition(int );
70
71 void setService( const QString& ser );
45private: 72private:
46 void deref(); 73 void deref();
47 inline void checkOrModify(); 74 inline void checkOrModify();
48 75
49 76
50 class Data; 77 class Data;
51 Data* data; 78 Data* data;
52 class ORecurPrivate; 79 class ORecurPrivate;
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp
index 6fcf9f6..ece624a 100644
--- a/libopie/pim/otodo.cpp
+++ b/libopie/pim/otodo.cpp
@@ -10,37 +10,39 @@
10#include <qpe/stringutil.h> 10#include <qpe/stringutil.h>
11#include <qpe/categories.h> 11#include <qpe/categories.h>
12#include <qpe/categoryselect.h> 12#include <qpe/categoryselect.h>
13 13
14 14
15#include "opimstate.h" 15#include "opimstate.h"
16#include "orecur.h" 16#include "orecur.h"
17#include "opimmaintainer.h" 17#include "opimmaintainer.h"
18#include "opimnotifymanager.h"
18 19
19#include "otodo.h" 20#include "otodo.h"
20 21
21 22
22struct OTodo::OTodoData : public QShared { 23struct OTodo::OTodoData : public QShared {
23 OTodoData() : QShared() { 24 OTodoData() : QShared() {
24 }; 25 };
25 26
26 QDate date; 27 QDate date;
27 bool isCompleted:1; 28 bool isCompleted:1;
28 bool hasDate:1; 29 bool hasDate:1;
29 int priority; 30 int priority;
30 QString desc; 31 QString desc;
31 QString sum; 32 QString sum;
32 QMap<QString, QString> extra; 33 QMap<QString, QString> extra;
33 ushort prog; 34 ushort prog;
34 bool hasAlarmDateTime :1;
35 QDateTime alarmDateTime;
36 OPimState state; 35 OPimState state;
37 ORecur recur; 36 ORecur recur;
38 OPimMaintainer maintainer; 37 OPimMaintainer maintainer;
38 QDate start;
39 QDate completed;
40 OPimNotifyManager notifiers;
39}; 41};
40 42
41OTodo::OTodo(const OTodo &event ) 43OTodo::OTodo(const OTodo &event )
42 : OPimRecord( event ), data( event.data ) 44 : OPimRecord( event ), data( event.data )
43{ 45{
44 data->ref(); 46 data->ref();
45// qWarning("ref up"); 47// qWarning("ref up");
46} 48}
@@ -68,18 +70,16 @@ OTodo::OTodo(bool completed, int priority,
68 70
69 data->date = date; 71 data->date = date;
70 data->isCompleted = completed; 72 data->isCompleted = completed;
71 data->hasDate = hasDate; 73 data->hasDate = hasDate;
72 data->priority = priority; 74 data->priority = priority;
73 data->sum = summary; 75 data->sum = summary;
74 data->prog = progress; 76 data->prog = progress;
75 data->desc = Qtopia::simplifyMultiLineSpace(description ); 77 data->desc = Qtopia::simplifyMultiLineSpace(description );
76 data->hasAlarmDateTime = false;
77
78} 78}
79OTodo::OTodo(bool completed, int priority, 79OTodo::OTodo(bool completed, int priority,
80 const QStringList &category, 80 const QStringList &category,
81 const QString& summary, 81 const QString& summary,
82 const QString &description, 82 const QString &description,
83 ushort progress, 83 ushort progress,
84 bool hasDate, QDate date, int uid ) 84 bool hasDate, QDate date, int uid )
85 : OPimRecord( uid ) 85 : OPimRecord( uid )
@@ -91,18 +91,16 @@ OTodo::OTodo(bool completed, int priority,
91 91
92 data->date = date; 92 data->date = date;
93 data->isCompleted = completed; 93 data->isCompleted = completed;
94 data->hasDate = hasDate; 94 data->hasDate = hasDate;
95 data->priority = priority; 95 data->priority = priority;
96 data->sum = summary; 96 data->sum = summary;
97 data->prog = progress; 97 data->prog = progress;
98 data->desc = Qtopia::simplifyMultiLineSpace(description ); 98 data->desc = Qtopia::simplifyMultiLineSpace(description );
99 data->hasAlarmDateTime = false;
100
101} 99}
102bool OTodo::match( const QRegExp &regExp )const 100bool OTodo::match( const QRegExp &regExp )const
103{ 101{
104 if( QString::number( data->priority ).find( regExp ) != -1 ){ 102 if( QString::number( data->priority ).find( regExp ) != -1 ){
105 return true; 103 return true;
106 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ 104 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){
107 return true; 105 return true;
108 }else if(data->desc.find( regExp ) != -1 ){ 106 }else if(data->desc.find( regExp ) != -1 ){
@@ -115,19 +113,21 @@ bool OTodo::match( const QRegExp &regExp )const
115bool OTodo::isCompleted() const 113bool OTodo::isCompleted() const
116{ 114{
117 return data->isCompleted; 115 return data->isCompleted;
118} 116}
119bool OTodo::hasDueDate() const 117bool OTodo::hasDueDate() const
120{ 118{
121 return data->hasDate; 119 return data->hasDate;
122} 120}
123bool OTodo::hasAlarmDateTime() const 121bool OTodo::hasStartDate()const {
124{ 122 return data->start.isValid();
125 return data->hasAlarmDateTime; 123}
124bool OTodo::hasCompletedDate()const {
125 return data->completed.isValid();
126} 126}
127int OTodo::priority()const 127int OTodo::priority()const
128{ 128{
129 return data->priority; 129 return data->priority;
130} 130}
131QString OTodo::summary() const 131QString OTodo::summary() const
132{ 132{
133 return data->sum; 133 return data->sum;
@@ -135,22 +135,22 @@ QString OTodo::summary() const
135ushort OTodo::progress() const 135ushort OTodo::progress() const
136{ 136{
137 return data->prog; 137 return data->prog;
138} 138}
139QDate OTodo::dueDate()const 139QDate OTodo::dueDate()const
140{ 140{
141 return data->date; 141 return data->date;
142} 142}
143 143QDate OTodo::startDate()const {
144QDateTime OTodo::alarmDateTime() const 144 return data->start;
145{ 145}
146 return data->alarmDateTime; 146QDate OTodo::completedDate()const {
147 return data->completed;
147} 148}
148
149QString OTodo::description()const 149QString OTodo::description()const
150{ 150{
151 return data->desc; 151 return data->desc;
152} 152}
153OPimState OTodo::state()const { 153OPimState OTodo::state()const {
154 return data->state; 154 return data->state;
155} 155}
156ORecur OTodo::recurrence()const { 156ORecur OTodo::recurrence()const {
@@ -164,46 +164,44 @@ void OTodo::setCompleted( bool completed )
164 changeOrModify(); 164 changeOrModify();
165 data->isCompleted = completed; 165 data->isCompleted = completed;
166} 166}
167void OTodo::setHasDueDate( bool hasDate ) 167void OTodo::setHasDueDate( bool hasDate )
168{ 168{
169 changeOrModify(); 169 changeOrModify();
170 data->hasDate = hasDate; 170 data->hasDate = hasDate;
171} 171}
172void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime )
173{
174 changeOrModify();
175 data->hasAlarmDateTime = hasAlarmDateTime;
176}
177void OTodo::setDescription(const QString &desc ) 172void OTodo::setDescription(const QString &desc )
178{ 173{
179// qWarning( "desc " + desc ); 174// qWarning( "desc " + desc );
180 changeOrModify(); 175 changeOrModify();
181 data->desc = Qtopia::simplifyMultiLineSpace(desc ); 176 data->desc = Qtopia::simplifyMultiLineSpace(desc );
182} 177}
183void OTodo::setSummary( const QString& sum ) 178void OTodo::setSummary( const QString& sum )
184{ 179{
185 changeOrModify(); 180 changeOrModify();
186 data->sum = sum; 181 data->sum = sum;
187} 182}
188void OTodo::setPriority(int prio ) 183void OTodo::setPriority(int prio )
189{ 184{
190 changeOrModify(); 185 changeOrModify();
191 data->priority = prio; 186 data->priority = prio;
192} 187}
193void OTodo::setDueDate( QDate date ) 188void OTodo::setDueDate( const QDate& date )
194{ 189{
195 changeOrModify(); 190 changeOrModify();
196 data->date = date; 191 data->date = date;
197} 192}
198void OTodo::setAlarmDateTime( const QDateTime& alarm ) 193void OTodo::setStartDate( const QDate& date ) {
199{
200 changeOrModify(); 194 changeOrModify();
201 data->alarmDateTime = alarm; 195 data->start = date;
196}
197void OTodo::setCompletedDate( const QDate& date ) {
198 changeOrModify();
199 data->completed = date;
202} 200}
203void OTodo::setState( const OPimState& state ) { 201void OTodo::setState( const OPimState& state ) {
204 changeOrModify(); 202 changeOrModify();
205 data->state = state; 203 data->state = state;
206} 204}
207void OTodo::setRecurrence( const ORecur& rec) { 205void OTodo::setRecurrence( const ORecur& rec) {
208 changeOrModify(); 206 changeOrModify();
209 data->recur = rec; 207 data->recur = rec;
@@ -249,28 +247,26 @@ QString OTodo::toRichText() const
249 + QString::number( priority() ) + " <br>"; 247 + QString::number( priority() ) + " <br>";
250 text += "<b>" + QObject::tr( "Progress:") + " </b>" 248 text += "<b>" + QObject::tr( "Progress:") + " </b>"
251 + QString::number( progress() ) + " %<br>"; 249 + QString::number( progress() ) + " %<br>";
252 if (hasDueDate() ){ 250 if (hasDueDate() ){
253 text += "<b>" + QObject::tr( "Deadline:") + " </b>"; 251 text += "<b>" + QObject::tr( "Deadline:") + " </b>";
254 text += dueDate().toString(); 252 text += dueDate().toString();
255 text += "<br>"; 253 text += "<br>";
256 } 254 }
257 if (hasAlarmDateTime() ){
258 text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>";
259 text += alarmDateTime().toString();
260 text += "<br>";
261 }
262 255
263 text += "<b>" + QObject::tr( "Category:") + "</b> "; 256 text += "<b>" + QObject::tr( "Category:") + "</b> ";
264 text += categoryNames().join(", "); 257 text += categoryNames().join(", ");
265 text += "<br>"; 258 text += "<br>";
266 259
267 return text; 260 return text;
268} 261}
262OPimNotifyManager& OTodo::notifiers() {
263 return data->notifiers;
264}
269 265
270bool OTodo::operator<( const OTodo &toDoEvent )const{ 266bool OTodo::operator<( const OTodo &toDoEvent )const{
271 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 267 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
272 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 268 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
273 if( hasDueDate() && toDoEvent.hasDueDate() ){ 269 if( hasDueDate() && toDoEvent.hasDueDate() ){
274 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 270 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
275 return priority() < toDoEvent.priority(); 271 return priority() < toDoEvent.priority();
276 }else{ 272 }else{
@@ -322,20 +318,16 @@ bool OTodo::operator==(const OTodo &toDoEvent )const
322{ 318{
323 if ( data->priority != toDoEvent.data->priority ) return false; 319 if ( data->priority != toDoEvent.data->priority ) return false;
324 if ( data->priority != toDoEvent.data->prog ) return false; 320 if ( data->priority != toDoEvent.data->prog ) return false;
325 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; 321 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
326 if ( data->hasDate != toDoEvent.data->hasDate ) return false; 322 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
327 if ( data->date != toDoEvent.data->date ) return false; 323 if ( data->date != toDoEvent.data->date ) return false;
328 if ( data->sum != toDoEvent.data->sum ) return false; 324 if ( data->sum != toDoEvent.data->sum ) return false;
329 if ( data->desc != toDoEvent.data->desc ) return false; 325 if ( data->desc != toDoEvent.data->desc ) return false;
330 if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime )
331 return false;
332 if ( data->alarmDateTime != toDoEvent.data->alarmDateTime )
333 return false;
334 if ( data->maintainer != toDoEvent.data->maintainer ) 326 if ( data->maintainer != toDoEvent.data->maintainer )
335 return false; 327 return false;
336 328
337 return OPimRecord::operator==( toDoEvent ); 329 return OPimRecord::operator==( toDoEvent );
338} 330}
339void OTodo::deref() { 331void OTodo::deref() {
340 332
341// qWarning("deref in ToDoEvent"); 333// qWarning("deref in ToDoEvent");
@@ -366,19 +358,21 @@ QMap<int, QString> OTodo::toMap() const {
366 map.insert( Description, data->desc ); 358 map.insert( Description, data->desc );
367 map.insert( Summary, data->sum ); 359 map.insert( Summary, data->sum );
368 map.insert( Priority, QString::number( data->priority ) ); 360 map.insert( Priority, QString::number( data->priority ) );
369 map.insert( DateDay, QString::number( data->date.day() ) ); 361 map.insert( DateDay, QString::number( data->date.day() ) );
370 map.insert( DateMonth, QString::number( data->date.month() ) ); 362 map.insert( DateMonth, QString::number( data->date.month() ) );
371 map.insert( DateYear, QString::number( data->date.year() ) ); 363 map.insert( DateYear, QString::number( data->date.year() ) );
372 map.insert( Progress, QString::number( data->prog ) ); 364 map.insert( Progress, QString::number( data->prog ) );
373// map.insert( CrossReference, crossToString() ); 365// map.insert( CrossReference, crossToString() );
374 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); 366 /* FIXME!!! map.insert( State, );
375 map.insert( AlarmDateTime, data->alarmDateTime.toString() ); 367 map.insert( Recurrence, );
376 368 map.insert( Reminders, );
369 map.
370 */
377 return map; 371 return map;
378} 372}
379 373
380QMap<QString, QString> OTodo::toExtraMap()const { 374QMap<QString, QString> OTodo::toExtraMap()const {
381 return data->extra; 375 return data->extra;
382} 376}
383/** 377/**
384 * change or modify looks at the ref count and either 378 * change or modify looks at the ref count and either
@@ -403,21 +397,25 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) {
403 dest->date = src->date; 397 dest->date = src->date;
404 dest->isCompleted = src->isCompleted; 398 dest->isCompleted = src->isCompleted;
405 dest->hasDate = src->hasDate; 399 dest->hasDate = src->hasDate;
406 dest->priority = src->priority; 400 dest->priority = src->priority;
407 dest->desc = src->desc; 401 dest->desc = src->desc;
408 dest->sum = src->sum; 402 dest->sum = src->sum;
409 dest->extra = src->extra; 403 dest->extra = src->extra;
410 dest->prog = src->prog; 404 dest->prog = src->prog;
411 dest->hasAlarmDateTime = src->hasAlarmDateTime;
412 dest->alarmDateTime = src->alarmDateTime;
413 dest->state = src->state; 405 dest->state = src->state;
414 dest->recur = src->recur; 406 dest->recur = src->recur;
415 dest->maintainer = src->maintainer; 407 dest->maintainer = src->maintainer;
408 dest->start = src->start;
409 dest->completed = src->completed;
410 dest->notifiers = src->notifiers;
416} 411}
417QString OTodo::type() const { 412QString OTodo::type() const {
418 return QString::fromLatin1("OTodo"); 413 return QString::fromLatin1("OTodo");
419} 414}
420QString OTodo::recordField(int /*id*/ )const { 415QString OTodo::recordField(int /*id*/ )const {
421 return QString::null; 416 return QString::null;
422} 417}
423 418
419int OTodo::rtti(){
420 return 1;
421}
diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h
index 70b0253..2f66f55 100644
--- a/libopie/pim/otodo.h
+++ b/libopie/pim/otodo.h
@@ -14,39 +14,41 @@
14#include <qpe/palmtopuidgen.h> 14#include <qpe/palmtopuidgen.h>
15 15
16#include <opie/opimrecord.h> 16#include <opie/opimrecord.h>
17 17
18 18
19class OPimState; 19class OPimState;
20class ORecur; 20class ORecur;
21class OPimMaintainer; 21class OPimMaintainer;
22class OPimNotifyManager;
22class OTodo : public OPimRecord { 23class OTodo : public OPimRecord {
23public: 24public:
24 typedef QValueList<OTodo> ValueList; 25 typedef QValueList<OTodo> ValueList;
25 enum RecordFields { 26 enum RecordFields {
26 Uid = Qtopia::UID_ID, 27 Uid = Qtopia::UID_ID,
27 Category = Qtopia::CATEGORY_ID, 28 Category = Qtopia::CATEGORY_ID,
28 HasDate, 29 HasDate,
29 Completed, 30 Completed,
30 Description, 31 Description,
31 Summary, 32 Summary,
32 Priority, 33 Priority,
33 DateDay, 34 DateDay,
34 DateMonth, 35 DateMonth,
35 DateYear, 36 DateYear,
36 Progress, 37 Progress,
37 CrossReference, 38 CrossReference,
38 HasAlarmDateTime,
39 AlarmDateTime,
40 State, 39 State,
41 Recurrance, 40 Recurrence,
42 Alarms, 41 Alarms,
43 Reminders, 42 Reminders,
44 Notifiers 43 Notifiers,
44 Maintainer,
45 StartDate,
46 CompletedDate
45 }; 47 };
46 public: 48 public:
47 // priorities from Very low to very high 49 // priorities from Very low to very high
48 enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; 50 enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow };
49 51
50 /* Constructs a new ToDoEvent 52 /* Constructs a new ToDoEvent
51 @param completed Is the TodoEvent completed 53 @param completed Is the TodoEvent completed
52 @param priority What is the priority of this ToDoEvent 54 @param priority What is the priority of this ToDoEvent
@@ -68,35 +70,37 @@ public:
68 OTodo( bool completed, int priority, 70 OTodo( bool completed, int priority,
69 const QArray<int>& category, 71 const QArray<int>& category,
70 const QString& summary = QString::null, 72 const QString& summary = QString::null,
71 const QString& description = QString::null, 73 const QString& description = QString::null,
72 ushort progress = 0, 74 ushort progress = 0,
73 bool hasDate = false, QDate date = QDate::currentDate(), 75 bool hasDate = false, QDate date = QDate::currentDate(),
74 int uid = 0 /* empty */ ); 76 int uid = 0 /* empty */ );
75 77
76 /* Copy c'tor 78 /** Copy c'tor
77 79 *
78 **/ 80 */
79 OTodo(const OTodo & ); 81 OTodo(const OTodo & );
80 82
81 /** 83 /**
82 *destructor 84 *destructor
83 */ 85 */
84 ~OTodo(); 86 ~OTodo();
85 87
86 /** 88 /**
87 * Is this event completed? 89 * Is this event completed?
88 */ 90 */
89 bool isCompleted() const; 91 bool isCompleted() const;
90 92
91 /** 93 /**
92 * Does this Event have a deadline 94 * Does this Event have a deadline
93 */ 95 */
94 bool hasDueDate() const; 96 bool hasDueDate() const;
97 bool hasStartDate()const;
98 bool hasCompletedDate()const;
95 99
96 /** 100 /**
97 * Does this Event has an alarm time ? 101 * Does this Event has an alarm time ?
98 */ 102 */
99 bool hasAlarmDateTime() const; 103 bool hasAlarmDateTime() const;
100 104
101 /** 105 /**
102 * What is the priority? 106 * What is the priority?
@@ -109,19 +113,24 @@ public:
109 ushort progress() const; 113 ushort progress() const;
110 114
111 /** 115 /**
112 * The due Date 116 * The due Date
113 */ 117 */
114 QDate dueDate()const; 118 QDate dueDate()const;
115 119
116 /** 120 /**
117 * Alarm Date and Time 121 * When did it start?
122 */
123 QDate startDate()const;
124
125 /**
126 * When was it completed?
118 */ 127 */
119 QDateTime alarmDateTime()const; 128 QDate completedDate()const;
120 129
121 /** 130 /**
122 * What is the state of this OTodo? 131 * What is the state of this OTodo?
123 */ 132 */
124 OPimState state()const; 133 OPimState state()const;
125 134
126 /** 135 /**
127 * the recurrance of this 136 * the recurrance of this
@@ -144,18 +153,26 @@ public:
144 QString summary() const; 153 QString summary() const;
145 154
146 /** 155 /**
147 * @reimplemented 156 * @reimplemented
148 * Return this todoevent in a RichText formatted QString 157 * Return this todoevent in a RichText formatted QString
149 */ 158 */
150 QString toRichText() const; 159 QString toRichText() const;
151 160
161 /*
162 * check if the sharing is still fine!! -zecke
163 */
164 /**
165 * return a reference to our notifiers...
166 */
167 OPimNotifyManager &notifiers();
168
152 /** 169 /**
153 * reimplementation 170 * reimplementations
154 */ 171 */
155 QString type()const; 172 QString type()const;
156 QString toShortText()const; 173 QString toShortText()const;
157 QMap<QString, QString> toExtraMap()const; 174 QMap<QString, QString> toExtraMap()const;
158 QString recordField(int id )const; 175 QString recordField(int id )const;
159 176
160 /** 177 /**
161 * toMap puts all data into the map. int relates 178 * toMap puts all data into the map. int relates
@@ -167,37 +184,45 @@ public:
167 * Set if this Todo is completed 184 * Set if this Todo is completed
168 */ 185 */
169 void setCompleted(bool completed ); 186 void setCompleted(bool completed );
170 187
171 /** 188 /**
172 * set if this todo got an end data 189 * set if this todo got an end data
173 */ 190 */
174 void setHasDueDate( bool hasDate ); 191 void setHasDueDate( bool hasDate );
175 192 // FIXME we do not have these for start, completed
176 /** 193 // cause we'll use the isNull() of QDate for figuring
177 * set if this todo has an alarm time and date 194 // out if it's has a date...
178 */ 195 // decide what to do here? -zecke
179 void setHasAlarmDateTime ( bool hasAlarm );
180 196
181 /** 197 /**
182 * Set the priority of the Todo 198 * Set the priority of the Todo
183 */ 199 */
184 void setPriority(int priority ); 200 void setPriority(int priority );
185 201
186 /** 202 /**
187 * Set the progress. 203 * Set the progress.
188 */ 204 */
189 void setProgress( ushort progress ); 205 void setProgress( ushort progress );
190 206
191 /** 207 /**
192 * set the end date 208 * set the end date
193 */ 209 */
194 void setDueDate( QDate date ); 210 void setDueDate( const QDate& date );
195 211
212 /**
213 * set the start date
214 */
215 void setStartDate( const QDate& date );
216
217 /**
218 * set the completed date
219 */
220 void setCompletedDate( const QDate& date );
196 221
197 void setRecurrence( const ORecur& ); 222 void setRecurrence( const ORecur& );
198 /** 223 /**
199 * set the alarm time 224 * set the alarm time
200 */ 225 */
201 void setAlarmDateTime ( const QDateTime& alarm ); 226 void setAlarmDateTime ( const QDateTime& alarm );
202 227
203 void setDescription(const QString& ); 228 void setDescription(const QString& );
@@ -222,16 +247,18 @@ public:
222 bool operator<(const OTodo &toDoEvent )const; 247 bool operator<(const OTodo &toDoEvent )const;
223 bool operator<=(const OTodo &toDoEvent )const; 248 bool operator<=(const OTodo &toDoEvent )const;
224 bool operator!=(const OTodo &toDoEvent )const; 249 bool operator!=(const OTodo &toDoEvent )const;
225 bool operator>(const OTodo &toDoEvent )const; 250 bool operator>(const OTodo &toDoEvent )const;
226 bool operator>=(const OTodo &toDoEvent)const; 251 bool operator>=(const OTodo &toDoEvent)const;
227 bool operator==(const OTodo &toDoEvent )const; 252 bool operator==(const OTodo &toDoEvent )const;
228 OTodo &operator=(const OTodo &toDoEvent ); 253 OTodo &operator=(const OTodo &toDoEvent );
229 254
255 static int rtti();
256
230 private: 257 private:
231 class OTodoPrivate; 258 class OTodoPrivate;
232 struct OTodoData; 259 struct OTodoData;
233 260
234 void deref(); 261 void deref();
235 inline void changeOrModify(); 262 inline void changeOrModify();
236 void copy( OTodoData* src, OTodoData* dest ); 263 void copy( OTodoData* src, OTodoData* dest );
237 OTodoPrivate *d; 264 OTodoPrivate *d;
diff --git a/libopie/pim/otodoaccess.cpp b/libopie/pim/otodoaccess.cpp
index c258de6..d860411 100644
--- a/libopie/pim/otodoaccess.cpp
+++ b/libopie/pim/otodoaccess.cpp
@@ -40,28 +40,30 @@ OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start,
40 return effectiveToDos( start, QDate::currentDate(), 40 return effectiveToDos( start, QDate::currentDate(),
41 includeNoDates ); 41 includeNoDates );
42} 42}
43OTodoAccess::List OTodoAccess::overDue() { 43OTodoAccess::List OTodoAccess::overDue() {
44 List lis( m_todoBackEnd->overDue(), this ); 44 List lis( m_todoBackEnd->overDue(), this );
45 return lis; 45 return lis;
46} 46}
47void OTodoAccess::addAlarm( const OTodo& event) { 47void OTodoAccess::addAlarm( const OTodo& event) {
48 if (!event.hasAlarmDateTime() ) 48/* FIXME use the new notifier architecture
49 if (!event.hasAlarmDateTime() )
49 return; 50 return;
50 51
51 QDateTime now = QDateTime::currentDateTime(); 52 QDateTime now = QDateTime::currentDateTime();
52 QDateTime schedule = event.alarmDateTime(); 53 QDateTime schedule = event.alarmDateTime();
53 54
54 if ( schedule > now ){ 55 if ( schedule > now ){
55 AlarmServer::addAlarm( schedule, 56 AlarmServer::addAlarm( schedule,
56 "QPE/Application/todolist", 57 "QPE/Application/todolist",
57 "alarm(QDateTime,int)", event.uid() ); 58 "alarm(QDateTime,int)", event.uid() );
58 59
59 } 60 }
61*/
60} 62}
61void OTodoAccess::delAlarm( int uid) { 63void OTodoAccess::delAlarm( int uid) {
62 64
63 QDateTime schedule; // Create null DateTime 65 QDateTime schedule; // Create null DateTime
64 66
65 // I hope this will remove all scheduled alarms 67 // I hope this will remove all scheduled alarms
66 // with the given uid !? 68 // with the given uid !?
67 // If not: I have to rethink how to remove already 69 // If not: I have to rethink how to remove already
@@ -74,8 +76,11 @@ void OTodoAccess::delAlarm( int uid) {
74} 76}
75/* sort order */ 77/* sort order */
76OTodoAccess::List OTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) { 78OTodoAccess::List OTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) {
77 QArray<int> ints = m_todoBackEnd->sorted( ascending, sort, 79 QArray<int> ints = m_todoBackEnd->sorted( ascending, sort,
78 filter, cat ); 80 filter, cat );
79 OTodoAccess::List list( ints, this ); 81 OTodoAccess::List list( ints, this );
80 return list; 82 return list;
81} 83}
84void OTodoAccess::removeAllCompleted() {
85 m_todoBackEnd->removeAllCompleted();
86}
diff --git a/libopie/pim/otodoaccess.h b/libopie/pim/otodoaccess.h
index 390ab0e..c079155 100644
--- a/libopie/pim/otodoaccess.h
+++ b/libopie/pim/otodoaccess.h
@@ -63,31 +63,36 @@ public:
63 63
64 /** 64 /**
65 * merge a list of OTodos into 65 * merge a list of OTodos into
66 * the resource 66 * the resource
67 */ 67 */
68 void mergeWith( const QValueList<OTodo>& ); 68 void mergeWith( const QValueList<OTodo>& );
69 69
70 /** 70 /**
71 * delete all already completed items
72 */
73 void removeAllCompleted();
74
75signals:
76 /**
77 * if the OTodoAccess was changed
78 */
79 void signalChanged( const OTodoAccess* );
80private:
81 /**
71 * add an Alarm to the AlarmServer 82 * add an Alarm to the AlarmServer
72 */ 83 */
73 void addAlarm( const OTodo& ); 84 void addAlarm( const OTodo& );
74 85
75 /** 86 /**
76 * delete an alarm with the uid from 87 * delete an alarm with the uid from
77 * the alarm server 88 * the alarm server
78 */ 89 */
79 void delAlarm( int uid ); 90 void delAlarm( int uid );
80 91
81signals:
82 /**
83 * if the OTodoAccess was changed
84 */
85 void signalChanged( const OTodoAccess* );
86private:
87 int m_cat; 92 int m_cat;
88 OTodoAccessBackend* m_todoBackEnd; 93 OTodoAccessBackend* m_todoBackEnd;
89 class OTodoAccessPrivate; 94 class OTodoAccessPrivate;
90 OTodoAccessPrivate* d; 95 OTodoAccessPrivate* d;
91}; 96};
92 97
93#endif 98#endif
diff --git a/libopie/pim/otodoaccessbackend.h b/libopie/pim/otodoaccessbackend.h
index 3bad6b7..7944a2c 100644
--- a/libopie/pim/otodoaccessbackend.h
+++ b/libopie/pim/otodoaccessbackend.h
@@ -9,12 +9,13 @@ public:
9 OTodoAccessBackend(); 9 OTodoAccessBackend();
10 ~OTodoAccessBackend(); 10 ~OTodoAccessBackend();
11 virtual QArray<int> effectiveToDos( const QDate& start, 11 virtual QArray<int> effectiveToDos( const QDate& start,
12 const QDate& end, 12 const QDate& end,
13 bool includeNoDates ) = 0; 13 bool includeNoDates ) = 0;
14 virtual QArray<int> overDue() = 0; 14 virtual QArray<int> overDue() = 0;
15 virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter, 15 virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter,
16 int cat ) = 0; 16 int cat ) = 0;
17 virtual void removeAllCompleted() = 0;
17 18
18}; 19};
19 20
20#endif 21#endif
diff --git a/libopie/pim/otodoaccessvcal.cpp b/libopie/pim/otodoaccessvcal.cpp
index ac70ea0..e96cc3c 100644
--- a/libopie/pim/otodoaccessvcal.cpp
+++ b/libopie/pim/otodoaccessvcal.cpp
@@ -149,16 +149,22 @@ bool OTodoAccessVCal::add( const OTodo& to ) {
149 m_dirty = true; 149 m_dirty = true;
150 return true; 150 return true;
151} 151}
152bool OTodoAccessVCal::remove( int uid ) { 152bool OTodoAccessVCal::remove( int uid ) {
153 m_map.remove( uid ); 153 m_map.remove( uid );
154 m_dirty = true; 154 m_dirty = true;
155 return true; 155 return true;
156} 156}
157void OTodoAccessVCal::removeAllCompleted() {
158 for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) {
159 if ( (*it).isCompleted() )
160 m_map.remove( it );
161 }
162}
157bool OTodoAccessVCal::replace( const OTodo& to ) { 163bool OTodoAccessVCal::replace( const OTodo& to ) {
158 m_map.replace( to.uid(), to ); 164 m_map.replace( to.uid(), to );
159 m_dirty = true; 165 m_dirty = true;
160 return true; 166 return true;
161} 167}
162OTodo OTodoAccessVCal::find(int uid )const { 168OTodo OTodoAccessVCal::find(int uid )const {
163 return m_map[uid]; 169 return m_map[uid];
164} 170}
diff --git a/libopie/pim/otodoaccessvcal.h b/libopie/pim/otodoaccessvcal.h
index 4499a7e..452f602 100644
--- a/libopie/pim/otodoaccessvcal.h
+++ b/libopie/pim/otodoaccessvcal.h
@@ -21,15 +21,17 @@ public:
21 QArray<int> sorted( bool asc, int sortOrder, int sortFilter, 21 QArray<int> sorted( bool asc, int sortOrder, int sortFilter,
22 int cat ); 22 int cat );
23 OTodo find(int uid)const; 23 OTodo find(int uid)const;
24 void clear(); 24 void clear();
25 bool add( const OTodo& ); 25 bool add( const OTodo& );
26 bool remove( int uid ); 26 bool remove( int uid );
27 bool replace( const OTodo& ); 27 bool replace( const OTodo& );
28 28
29 void removeAllCompleted();
30
29private: 31private:
30 bool m_dirty : 1; 32 bool m_dirty : 1;
31 QString m_file; 33 QString m_file;
32 QMap<int, OTodo> m_map; 34 QMap<int, OTodo> m_map;
33}; 35};
34 36
35#endif 37#endif
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp
index c1682c6..b2dfe80 100644
--- a/libopie/pim/otodoaccessxml.cpp
+++ b/libopie/pim/otodoaccessxml.cpp
@@ -23,36 +23,40 @@ OTodoAccessXML::~OTodoAccessXML() {
23} 23}
24bool OTodoAccessXML::load() { 24bool OTodoAccessXML::load() {
25 m_opened = true; 25 m_opened = true;
26 m_changed = false; 26 m_changed = false;
27 /* initialize dict */ 27 /* initialize dict */
28 /* 28 /*
29 * UPDATE dict if you change anything!!! 29 * UPDATE dict if you change anything!!!
30 */ 30 */
31 QAsciiDict<int> dict(15); 31 QAsciiDict<int> dict(21);
32 dict.setAutoDelete( TRUE ); 32 dict.setAutoDelete( TRUE );
33 dict.insert("Categories" , new int(OTodo::Category) ); 33 dict.insert("Categories" , new int(OTodo::Category) );
34 dict.insert("Uid" , new int(OTodo::Uid) ); 34 dict.insert("Uid" , new int(OTodo::Uid) );
35 dict.insert("HasDate" , new int(OTodo::HasDate) ); 35 dict.insert("HasDate" , new int(OTodo::HasDate) );
36 dict.insert("Completed" , new int(OTodo::Completed) ); 36 dict.insert("Completed" , new int(OTodo::Completed) );
37 dict.insert("Description" , new int(OTodo::Description) ); 37 dict.insert("Description" , new int(OTodo::Description) );
38 dict.insert("Summary" , new int(OTodo::Summary) ); 38 dict.insert("Summary" , new int(OTodo::Summary) );
39 dict.insert("Priority" , new int(OTodo::Priority) ); 39 dict.insert("Priority" , new int(OTodo::Priority) );
40 dict.insert("DateDay" , new int(OTodo::DateDay) ); 40 dict.insert("DateDay" , new int(OTodo::DateDay) );
41 dict.insert("DateMonth" , new int(OTodo::DateMonth) ); 41 dict.insert("DateMonth" , new int(OTodo::DateMonth) );
42 dict.insert("DateYear" , new int(OTodo::DateYear) ); 42 dict.insert("DateYear" , new int(OTodo::DateYear) );
43 dict.insert("Progress" , new int(OTodo::Progress) ); 43 dict.insert("Progress" , new int(OTodo::Progress) );
44 dict.insert("Completed", new int(OTodo::Completed) ); 44 dict.insert("Completed", new int(OTodo::Completed) );
45 dict.insert("CrossReference", new int(OTodo::CrossReference) ); 45 dict.insert("CrossReference", new int(OTodo::CrossReference) );
46 dict.insert("HasAlarmDateTime",new int(OTodo::HasAlarmDateTime) ); 46 dict.insert("State", new int(OTodo::State) );
47 dict.insert("AlarmDateTime", new int(OTodo::AlarmDateTime) ); 47 dict.insert("Recurrence", new int(OTodo::Recurrence) );
48 dict.insert("Alarms", new int(OTodo::Alarms) );
49 dict.insert("Reminders", new int(OTodo::Reminders) );
50 dict.insert("Notifiers", new int(OTodo::Notifiers) );
51 dict.insert("Maintainer", new int(OTodo::Maintainer) );
48 52
49 // here the custom XML parser from TT it's GPL 53 // here the custom XML parser from TT it's GPL
50 // but we want to push that to TT..... 54 // but we want to push OpiePIM... to TT.....
51 QFile f(m_file ); 55 QFile f(m_file );
52 if (!f.open(IO_ReadOnly) ) 56 if (!f.open(IO_ReadOnly) )
53 return false; 57 return false;
54 58
55 QByteArray ba = f.readAll(); 59 QByteArray ba = f.readAll();
56 f.close(); 60 f.close();
57 char* dt = ba.data(); 61 char* dt = ba.data();
58 int len = ba.size(); 62 int len = ba.size();
@@ -331,24 +335,16 @@ void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev,
331 for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { 335 for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) {
332 int pos = (*strIt).find(','); 336 int pos = (*strIt).find(',');
333 if ( pos > -1 ) 337 if ( pos > -1 )
334 ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); 338 ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() );
335 339
336 } 340 }
337 break; 341 break;
338 } 342 }
339 case OTodo::HasAlarmDateTime:
340 ev.setHasAlarmDateTime( val.toInt() );
341 break;
342 case OTodo::AlarmDateTime: {
343 /* this sounds better ;) zecke */
344 ev.setAlarmDateTime( TimeConversion::fromISO8601( val.local8Bit() ) );
345 break;
346 }
347 default: 343 default:
348 break; 344 break;
349 } 345 }
350} 346}
351QString OTodoAccessXML::toString( const OTodo& ev )const { 347QString OTodoAccessXML::toString( const OTodo& ev )const {
352 QString str; 348 QString str;
353 349
354 str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; 350 str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" ";
@@ -378,17 +374,16 @@ QString OTodoAccessXML::toString( const OTodo& ev )const {
378 /* 374 /*
379 QMap<QString, QString> extras = ev.extras(); 375 QMap<QString, QString> extras = ev.extras();
380 QMap<QString, QString>::Iterator extIt; 376 QMap<QString, QString>::Iterator extIt;
381 for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) 377 for (extIt = extras.begin(); extIt != extras.end(); ++extIt )
382 str += extIt.key() + "=\"" + extIt.data() + "\" "; 378 str += extIt.key() + "=\"" + extIt.data() + "\" ";
383 */ 379 */
384 // cross refernce 380 // cross refernce
385 381
386 str += "AlarmDateTime=\"" + TimeConversion::toISO8601( ev.alarmDateTime() ) + "\" ";
387 382
388 return str; 383 return str;
389} 384}
390QString OTodoAccessXML::toString( const QArray<int>& ints ) const { 385QString OTodoAccessXML::toString( const QArray<int>& ints ) const {
391 return Qtopia::Record::idsToString( ints ); 386 return Qtopia::Record::idsToString( ints );
392} 387}
393 388
394/* internal class for sorting 389/* internal class for sorting
@@ -611,8 +606,14 @@ QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder,
611 /* now get the uids */ 606 /* now get the uids */
612 QArray<int> array( vector.count() ); 607 QArray<int> array( vector.count() );
613 for (uint i= 0; i < vector.count(); i++ ) { 608 for (uint i= 0; i < vector.count(); i++ ) {
614 array[i] = ( vector.at(i) )->todo.uid(); 609 array[i] = ( vector.at(i) )->todo.uid();
615 } 610 }
616 qWarning("array count = %d %d", array.count(), vector.count() ); 611 qWarning("array count = %d %d", array.count(), vector.count() );
617 return array; 612 return array;
618}; 613};
614void OTodoAccessXML::removeAllCompleted() {
615 for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) {
616 if ( (*it).isCompleted() )
617 m_events.remove( it );
618 }
619}
diff --git a/libopie/pim/otodoaccessxml.h b/libopie/pim/otodoaccessxml.h
index dc41c32..93609fe 100644
--- a/libopie/pim/otodoaccessxml.h
+++ b/libopie/pim/otodoaccessxml.h
@@ -24,16 +24,17 @@ public:
24 bool save(); 24 bool save();
25 25
26 QArray<int> allRecords()const; 26 QArray<int> allRecords()const;
27 QArray<int> queryByExample( const OTodo&, int querysettings ); 27 QArray<int> queryByExample( const OTodo&, int querysettings );
28 OTodo find( int uid )const; 28 OTodo find( int uid )const;
29 void clear(); 29 void clear();
30 bool add( const OTodo& ); 30 bool add( const OTodo& );
31 bool remove( int uid ); 31 bool remove( int uid );
32 void removeAllCompleted();
32 bool replace( const OTodo& ); 33 bool replace( const OTodo& );
33 34
34 /* our functions */ 35 /* our functions */
35 QArray<int> effectiveToDos( const QDate& start, 36 QArray<int> effectiveToDos( const QDate& start,
36 const QDate& end, 37 const QDate& end,
37 bool includeNoDates ); 38 bool includeNoDates );
38 QArray<int> overDue(); 39 QArray<int> overDue();
39 QArray<int> sorted( bool asc, int sortOrder, 40 QArray<int> sorted( bool asc, int sortOrder,
diff --git a/libopie2/opiepim/backend/otodoaccessbackend.h b/libopie2/opiepim/backend/otodoaccessbackend.h
index 3bad6b7..7944a2c 100644
--- a/libopie2/opiepim/backend/otodoaccessbackend.h
+++ b/libopie2/opiepim/backend/otodoaccessbackend.h
@@ -9,12 +9,13 @@ public:
9 OTodoAccessBackend(); 9 OTodoAccessBackend();
10 ~OTodoAccessBackend(); 10 ~OTodoAccessBackend();
11 virtual QArray<int> effectiveToDos( const QDate& start, 11 virtual QArray<int> effectiveToDos( const QDate& start,
12 const QDate& end, 12 const QDate& end,
13 bool includeNoDates ) = 0; 13 bool includeNoDates ) = 0;
14 virtual QArray<int> overDue() = 0; 14 virtual QArray<int> overDue() = 0;
15 virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter, 15 virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter,
16 int cat ) = 0; 16 int cat ) = 0;
17 virtual void removeAllCompleted() = 0;
17 18
18}; 19};
19 20
20#endif 21#endif
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp
index ac70ea0..e96cc3c 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.cpp
+++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp
@@ -149,16 +149,22 @@ bool OTodoAccessVCal::add( const OTodo& to ) {
149 m_dirty = true; 149 m_dirty = true;
150 return true; 150 return true;
151} 151}
152bool OTodoAccessVCal::remove( int uid ) { 152bool OTodoAccessVCal::remove( int uid ) {
153 m_map.remove( uid ); 153 m_map.remove( uid );
154 m_dirty = true; 154 m_dirty = true;
155 return true; 155 return true;
156} 156}
157void OTodoAccessVCal::removeAllCompleted() {
158 for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) {
159 if ( (*it).isCompleted() )
160 m_map.remove( it );
161 }
162}
157bool OTodoAccessVCal::replace( const OTodo& to ) { 163bool OTodoAccessVCal::replace( const OTodo& to ) {
158 m_map.replace( to.uid(), to ); 164 m_map.replace( to.uid(), to );
159 m_dirty = true; 165 m_dirty = true;
160 return true; 166 return true;
161} 167}
162OTodo OTodoAccessVCal::find(int uid )const { 168OTodo OTodoAccessVCal::find(int uid )const {
163 return m_map[uid]; 169 return m_map[uid];
164} 170}
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.h b/libopie2/opiepim/backend/otodoaccessvcal.h
index 4499a7e..452f602 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.h
+++ b/libopie2/opiepim/backend/otodoaccessvcal.h
@@ -21,15 +21,17 @@ public:
21 QArray<int> sorted( bool asc, int sortOrder, int sortFilter, 21 QArray<int> sorted( bool asc, int sortOrder, int sortFilter,
22 int cat ); 22 int cat );
23 OTodo find(int uid)const; 23 OTodo find(int uid)const;
24 void clear(); 24 void clear();
25 bool add( const OTodo& ); 25 bool add( const OTodo& );
26 bool remove( int uid ); 26 bool remove( int uid );
27 bool replace( const OTodo& ); 27 bool replace( const OTodo& );
28 28
29 void removeAllCompleted();
30
29private: 31private:
30 bool m_dirty : 1; 32 bool m_dirty : 1;
31 QString m_file; 33 QString m_file;
32 QMap<int, OTodo> m_map; 34 QMap<int, OTodo> m_map;
33}; 35};
34 36
35#endif 37#endif
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index c1682c6..b2dfe80 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -23,36 +23,40 @@ OTodoAccessXML::~OTodoAccessXML() {
23} 23}
24bool OTodoAccessXML::load() { 24bool OTodoAccessXML::load() {
25 m_opened = true; 25 m_opened = true;
26 m_changed = false; 26 m_changed = false;
27 /* initialize dict */ 27 /* initialize dict */
28 /* 28 /*
29 * UPDATE dict if you change anything!!! 29 * UPDATE dict if you change anything!!!
30 */ 30 */
31 QAsciiDict<int> dict(15); 31 QAsciiDict<int> dict(21);
32 dict.setAutoDelete( TRUE ); 32 dict.setAutoDelete( TRUE );
33 dict.insert("Categories" , new int(OTodo::Category) ); 33 dict.insert("Categories" , new int(OTodo::Category) );
34 dict.insert("Uid" , new int(OTodo::Uid) ); 34 dict.insert("Uid" , new int(OTodo::Uid) );
35 dict.insert("HasDate" , new int(OTodo::HasDate) ); 35 dict.insert("HasDate" , new int(OTodo::HasDate) );
36 dict.insert("Completed" , new int(OTodo::Completed) ); 36 dict.insert("Completed" , new int(OTodo::Completed) );
37 dict.insert("Description" , new int(OTodo::Description) ); 37 dict.insert("Description" , new int(OTodo::Description) );
38 dict.insert("Summary" , new int(OTodo::Summary) ); 38 dict.insert("Summary" , new int(OTodo::Summary) );
39 dict.insert("Priority" , new int(OTodo::Priority) ); 39 dict.insert("Priority" , new int(OTodo::Priority) );
40 dict.insert("DateDay" , new int(OTodo::DateDay) ); 40 dict.insert("DateDay" , new int(OTodo::DateDay) );
41 dict.insert("DateMonth" , new int(OTodo::DateMonth) ); 41 dict.insert("DateMonth" , new int(OTodo::DateMonth) );
42 dict.insert("DateYear" , new int(OTodo::DateYear) ); 42 dict.insert("DateYear" , new int(OTodo::DateYear) );
43 dict.insert("Progress" , new int(OTodo::Progress) ); 43 dict.insert("Progress" , new int(OTodo::Progress) );
44 dict.insert("Completed", new int(OTodo::Completed) ); 44 dict.insert("Completed", new int(OTodo::Completed) );
45 dict.insert("CrossReference", new int(OTodo::CrossReference) ); 45 dict.insert("CrossReference", new int(OTodo::CrossReference) );
46 dict.insert("HasAlarmDateTime",new int(OTodo::HasAlarmDateTime) ); 46 dict.insert("State", new int(OTodo::State) );
47 dict.insert("AlarmDateTime", new int(OTodo::AlarmDateTime) ); 47 dict.insert("Recurrence", new int(OTodo::Recurrence) );
48 dict.insert("Alarms", new int(OTodo::Alarms) );
49 dict.insert("Reminders", new int(OTodo::Reminders) );
50 dict.insert("Notifiers", new int(OTodo::Notifiers) );
51 dict.insert("Maintainer", new int(OTodo::Maintainer) );
48 52
49 // here the custom XML parser from TT it's GPL 53 // here the custom XML parser from TT it's GPL
50 // but we want to push that to TT..... 54 // but we want to push OpiePIM... to TT.....
51 QFile f(m_file ); 55 QFile f(m_file );
52 if (!f.open(IO_ReadOnly) ) 56 if (!f.open(IO_ReadOnly) )
53 return false; 57 return false;
54 58
55 QByteArray ba = f.readAll(); 59 QByteArray ba = f.readAll();
56 f.close(); 60 f.close();
57 char* dt = ba.data(); 61 char* dt = ba.data();
58 int len = ba.size(); 62 int len = ba.size();
@@ -331,24 +335,16 @@ void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev,
331 for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { 335 for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) {
332 int pos = (*strIt).find(','); 336 int pos = (*strIt).find(',');
333 if ( pos > -1 ) 337 if ( pos > -1 )
334 ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); 338 ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() );
335 339
336 } 340 }
337 break; 341 break;
338 } 342 }
339 case OTodo::HasAlarmDateTime:
340 ev.setHasAlarmDateTime( val.toInt() );
341 break;
342 case OTodo::AlarmDateTime: {
343 /* this sounds better ;) zecke */
344 ev.setAlarmDateTime( TimeConversion::fromISO8601( val.local8Bit() ) );
345 break;
346 }
347 default: 343 default:
348 break; 344 break;
349 } 345 }
350} 346}
351QString OTodoAccessXML::toString( const OTodo& ev )const { 347QString OTodoAccessXML::toString( const OTodo& ev )const {
352 QString str; 348 QString str;
353 349
354 str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; 350 str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" ";
@@ -378,17 +374,16 @@ QString OTodoAccessXML::toString( const OTodo& ev )const {
378 /* 374 /*
379 QMap<QString, QString> extras = ev.extras(); 375 QMap<QString, QString> extras = ev.extras();
380 QMap<QString, QString>::Iterator extIt; 376 QMap<QString, QString>::Iterator extIt;
381 for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) 377 for (extIt = extras.begin(); extIt != extras.end(); ++extIt )
382 str += extIt.key() + "=\"" + extIt.data() + "\" "; 378 str += extIt.key() + "=\"" + extIt.data() + "\" ";
383 */ 379 */
384 // cross refernce 380 // cross refernce
385 381
386 str += "AlarmDateTime=\"" + TimeConversion::toISO8601( ev.alarmDateTime() ) + "\" ";
387 382
388 return str; 383 return str;
389} 384}
390QString OTodoAccessXML::toString( const QArray<int>& ints ) const { 385QString OTodoAccessXML::toString( const QArray<int>& ints ) const {
391 return Qtopia::Record::idsToString( ints ); 386 return Qtopia::Record::idsToString( ints );
392} 387}
393 388
394/* internal class for sorting 389/* internal class for sorting
@@ -611,8 +606,14 @@ QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder,
611 /* now get the uids */ 606 /* now get the uids */
612 QArray<int> array( vector.count() ); 607 QArray<int> array( vector.count() );
613 for (uint i= 0; i < vector.count(); i++ ) { 608 for (uint i= 0; i < vector.count(); i++ ) {
614 array[i] = ( vector.at(i) )->todo.uid(); 609 array[i] = ( vector.at(i) )->todo.uid();
615 } 610 }
616 qWarning("array count = %d %d", array.count(), vector.count() ); 611 qWarning("array count = %d %d", array.count(), vector.count() );
617 return array; 612 return array;
618}; 613};
614void OTodoAccessXML::removeAllCompleted() {
615 for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) {
616 if ( (*it).isCompleted() )
617 m_events.remove( it );
618 }
619}
diff --git a/libopie2/opiepim/backend/otodoaccessxml.h b/libopie2/opiepim/backend/otodoaccessxml.h
index dc41c32..93609fe 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.h
+++ b/libopie2/opiepim/backend/otodoaccessxml.h
@@ -24,16 +24,17 @@ public:
24 bool save(); 24 bool save();
25 25
26 QArray<int> allRecords()const; 26 QArray<int> allRecords()const;
27 QArray<int> queryByExample( const OTodo&, int querysettings ); 27 QArray<int> queryByExample( const OTodo&, int querysettings );
28 OTodo find( int uid )const; 28 OTodo find( int uid )const;
29 void clear(); 29 void clear();
30 bool add( const OTodo& ); 30 bool add( const OTodo& );
31 bool remove( int uid ); 31 bool remove( int uid );
32 void removeAllCompleted();
32 bool replace( const OTodo& ); 33 bool replace( const OTodo& );
33 34
34 /* our functions */ 35 /* our functions */
35 QArray<int> effectiveToDos( const QDate& start, 36 QArray<int> effectiveToDos( const QDate& start,
36 const QDate& end, 37 const QDate& end,
37 bool includeNoDates ); 38 bool includeNoDates );
38 QArray<int> overDue(); 39 QArray<int> overDue();
39 QArray<int> sorted( bool asc, int sortOrder, 40 QArray<int> sorted( bool asc, int sortOrder,
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index 6de68b1..8cf81c8 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -88,16 +88,17 @@ public:
88 virtual void clear() ; 88 virtual void clear() ;
89 89
90 /** 90 /**
91 * add T to the backend 91 * add T to the backend
92 * @param t The item to add. 92 * @param t The item to add.
93 * @return <i>true</i> if added successfully. 93 * @return <i>true</i> if added successfully.
94 */ 94 */
95 virtual bool add( const T& t ) ; 95 virtual bool add( const T& t ) ;
96 bool add( const OPimRecord& );
96 97
97 /* only the uid matters */ 98 /* only the uid matters */
98 /** 99 /**
99 * remove T from the backend 100 * remove T from the backend
100 * @param t The item to remove 101 * @param t The item to remove
101 * @return <i>true</i> if successful. 102 * @return <i>true</i> if successful.
102 */ 103 */
103 virtual bool remove( const T& t ); 104 virtual bool remove( const T& t );
@@ -207,16 +208,25 @@ void OPimAccessTemplate<T>::clear() {
207 m_backEnd->clear(); 208 m_backEnd->clear();
208} 209}
209template <class T> 210template <class T>
210bool OPimAccessTemplate<T>::add( const T& t ) { 211bool OPimAccessTemplate<T>::add( const T& t ) {
211 cache( t ); 212 cache( t );
212 return m_backEnd->add( t ); 213 return m_backEnd->add( t );
213} 214}
214template <class T> 215template <class T>
216bool OPimAccessTemplate<T>::add( const OPimRecord& rec) {
217 /* same type */
218 if ( rec.rtti() == T::rtti() ) {
219 const T &t = static_cast<const T&>(rec);
220 return add(t);
221 }
222 return false;
223}
224template <class T>
215bool OPimAccessTemplate<T>::remove( const T& t ) { 225bool OPimAccessTemplate<T>::remove( const T& t ) {
216 return remove( t.uid() ); 226 return remove( t.uid() );
217} 227}
218template <class T> 228template <class T>
219bool OPimAccessTemplate<T>::remove( int uid ) { 229bool OPimAccessTemplate<T>::remove( int uid ) {
220 m_cache.remove( uid ); 230 m_cache.remove( uid );
221 return m_backEnd->remove( uid ); 231 return m_backEnd->remove( uid );
222} 232}
diff --git a/libopie2/opiepim/core/opimmaintainer.cpp b/libopie2/opiepim/core/opimmaintainer.cpp
index e34f035..92cb25a 100644
--- a/libopie2/opiepim/core/opimmaintainer.cpp
+++ b/libopie2/opiepim/core/opimmaintainer.cpp
@@ -1,11 +1,11 @@
1#include "opimmaintainer.h" 1#include "opimmaintainer.h"
2 2
3OPimMaintainer::OPimMaintainer( enum Mode mode, int uid ) 3OPimMaintainer::OPimMaintainer( int mode, int uid )
4 : m_mode(mode), m_uid(uid ) 4 : m_mode(mode), m_uid(uid )
5{} 5{}
6OPimMaintainer::~OPimMaintainer() { 6OPimMaintainer::~OPimMaintainer() {
7} 7}
8OPimMaintainer::OPimMaintainer( const OPimMaintainer& main ) { 8OPimMaintainer::OPimMaintainer( const OPimMaintainer& main ) {
9 *this = main; 9 *this = main;
10} 10}
11OPimMaintainer &OPimMaintainer::operator=( const OPimMaintainer& main ) { 11OPimMaintainer &OPimMaintainer::operator=( const OPimMaintainer& main ) {
@@ -18,20 +18,20 @@ bool OPimMaintainer::operator==( const OPimMaintainer& main ) {
18 if (m_mode != main.m_mode ) return false; 18 if (m_mode != main.m_mode ) return false;
19 if (m_uid != main.m_uid ) return false; 19 if (m_uid != main.m_uid ) return false;
20 20
21 return true; 21 return true;
22} 22}
23bool OPimMaintainer::operator!=( const OPimMaintainer& main ) { 23bool OPimMaintainer::operator!=( const OPimMaintainer& main ) {
24 return !(*this == main ); 24 return !(*this == main );
25} 25}
26OPimMaintainer::Mode OPimMaintainer::mode()const { 26int OPimMaintainer::mode()const {
27 return m_mode; 27 return m_mode;
28} 28}
29int OPimMaintainer::uid()const { 29int OPimMaintainer::uid()const {
30 return m_uid; 30 return m_uid;
31} 31}
32void OPimMaintainer::setMode( enum Mode mo) { 32void OPimMaintainer::setMode( int mo) {
33 m_mode = mo; 33 m_mode = mo;
34} 34}
35void OPimMaintainer::setUid( int uid ) { 35void OPimMaintainer::setUid( int uid ) {
36 m_uid = uid; 36 m_uid = uid;
37} 37}
diff --git a/libopie2/opiepim/core/opimmaintainer.h b/libopie2/opiepim/core/opimmaintainer.h
index 310e15a..793d066 100644
--- a/libopie2/opiepim/core/opimmaintainer.h
+++ b/libopie2/opiepim/core/opimmaintainer.h
@@ -4,33 +4,37 @@
4#include <qstring.h> 4#include <qstring.h>
5 5
6/** 6/**
7 * Who maintains what? 7 * Who maintains what?
8 */ 8 */
9class OPimMaintainer { 9class OPimMaintainer {
10public: 10public:
11 enum Mode { Undefined = -1, 11 enum Mode { Undefined = -1,
12 Responsible = 0, 12 Nothing = 0,
13 Responsible,
13 DoneBy, 14 DoneBy,
14 Coordinating }; 15 Coordinating,
15 OPimMaintainer( enum Mode mode = Undefined, int uid = 0); 16 };
17 OPimMaintainer( int mode = Undefined, int uid = 0);
16 OPimMaintainer( const OPimMaintainer& ); 18 OPimMaintainer( const OPimMaintainer& );
17 ~OPimMaintainer(); 19 ~OPimMaintainer();
18 20
19 OPimMaintainer &operator=( const OPimMaintainer& ); 21 OPimMaintainer &operator=( const OPimMaintainer& );
20 bool operator==( const OPimMaintainer& ); 22 bool operator==( const OPimMaintainer& );
21 bool operator!=( const OPimMaintainer& ); 23 bool operator!=( const OPimMaintainer& );
22 24
23 25
24 Mode mode()const; 26 int mode()const;
25 int uid()const; 27 int uid()const;
26 28
27 void setMode( enum Mode ); 29 void setMode( int mode );
28 void setUid( int uid ); 30 void setUid( int uid );
29 31
30private: 32private:
31 Mode m_mode; 33 int m_mode;
32 int m_uid; 34 int m_uid;
35 class Private;
36 Private *d;
33 37
34}; 38};
35 39
36#endif 40#endif
diff --git a/libopie2/opiepim/core/opimnotify.cpp b/libopie2/opiepim/core/opimnotify.cpp
new file mode 100644
index 0000000..af5514b
--- a/dev/null
+++ b/libopie2/opiepim/core/opimnotify.cpp
@@ -0,0 +1,227 @@
1#include <qshared.h>
2
3#include "opimnotify.h"
4
5struct OPimNotify::Data : public QShared {
6 Data() : QShared(),dur(-1),parent(0) {
7
8 }
9 QDateTime start;
10 int dur;
11 QString application;
12 int parent;
13};
14
15OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) {
16 data = new Data;
17 data->start = start;
18 data->dur = duration;
19 data->parent = parent;
20}
21OPimNotify::OPimNotify( const OPimNotify& noti)
22 : data( noti.data )
23{
24 data->ref();
25}
26OPimNotify::~OPimNotify() {
27 if ( data->deref() ) {
28 delete data;
29 data = 0l;
30 }
31}
32
33OPimNotify &OPimNotify::operator=( const OPimNotify& noti) {
34 noti.data->ref();
35 deref();
36 data = noti.data;
37
38 return *this;
39}
40bool OPimNotify::operator==( const OPimNotify& noti ) {
41 if ( data == noti.data ) return true;
42 if ( data->dur != noti.data->dur ) return false;
43 if ( data->parent != noti.data->parent ) return false;
44 if ( data->application != noti.data->application ) return false;
45 if ( data->start != noti.data->start ) return false;
46
47 return true;
48}
49QDateTime OPimNotify::dateTime()const {
50 return data->start;
51}
52QString OPimNotify::service()const {
53 return data->application;
54}
55int OPimNotify::parent()const {
56 return data->parent;
57}
58int OPimNotify::duration()const {
59 return data->dur;
60}
61QDateTime OPimNotify::endTime()const {
62 return QDateTime( data->start.date(), data->start.time().addSecs( data->dur) );
63}
64void OPimNotify::setDateTime( const QDateTime& time ) {
65 copyIntern();
66 data->start = time;
67}
68void OPimNotify::setDuration( int dur ) {
69 copyIntern();
70 data->dur = dur;
71}
72void OPimNotify::setParent( int uid ) {
73 copyIntern();
74 data->parent = uid;
75}
76void OPimNotify::setService( const QString& str ) {
77 copyIntern();
78 data->application = str;
79}
80void OPimNotify::copyIntern() {
81 if ( data->count != 1 ) {
82 data->deref();
83 Data* dat = new Data;
84 dat->start = data->start;
85 dat->dur = data->dur;
86 dat->application = data->application;
87 dat->parent = data->parent;
88 data = dat;
89 }
90}
91void OPimNotify::deref() {
92 if ( data->deref() ) {
93 delete data;
94 data = 0;
95 }
96}
97
98/***********************************************************/
99struct OPimAlarm::Data : public QShared {
100 Data() : QShared() {
101 sound = 1;
102 }
103 int sound;
104 QString file;
105};
106OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int parent )
107 : OPimNotify( start, duration, parent )
108{
109 data = new Data;
110 data->sound = sound;
111}
112OPimAlarm::OPimAlarm( const OPimAlarm& al)
113 : OPimNotify(al), data( al.data )
114{
115 data->ref();
116}
117OPimAlarm::~OPimAlarm() {
118 if ( data->deref() ) {
119 delete data;
120 data = 0l;
121 }
122}
123OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al)
124{
125 OPimNotify::operator=( al );
126 deref();
127 al.data->ref();
128
129 data = al.data;
130
131
132 return *this;
133}
134bool OPimAlarm::operator==( const OPimAlarm& al) {
135 if ( data->sound != al.data->sound ) return false;
136 else if ( data->sound == Custom && data->file != al.data->file )
137 return false;
138
139 return OPimNotify::operator==( al );
140}
141QString OPimAlarm::type()const {
142 return QString::fromLatin1("OPimAlarm");
143}
144int OPimAlarm::sound()const {
145 return data->sound;
146}
147QString OPimAlarm::file()const {
148 return data->file;
149}
150void OPimAlarm::setSound( int snd) {
151 copyIntern();
152 data->sound = snd;
153}
154void OPimAlarm::setFile( const QString& sound ) {
155 copyIntern();
156 data->file = sound;
157}
158void OPimAlarm::deref() {
159 if ( data->deref() ) {
160 delete data;
161 data = 0l;
162 }
163}
164void OPimAlarm::copyIntern() {
165 if ( data->count != 1 ) {
166 data->deref();
167 Data *newDat = new Data;
168 newDat->sound = data->sound;
169 newDat->file = data->file;
170 data = newDat;
171 }
172}
173/************************/
174struct OPimReminder::Data : public QShared {
175 Data() : QShared(), record( 0) {
176 }
177 int record;
178
179};
180OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent )
181 : OPimNotify( start, dur, parent )
182{
183 data = new Data;
184 data->record = uid;
185}
186OPimReminder::OPimReminder( const OPimReminder& rem )
187 : OPimNotify( rem ), data( rem.data )
188{
189 data->ref();
190}
191OPimReminder& OPimReminder::operator=( const OPimReminder& rem) {
192 OPimNotify::operator=(rem );
193
194 deref();
195 rem.data->ref();
196 data = rem.data;
197
198 return *this;
199}
200bool OPimReminder::operator==( const OPimReminder& rem) {
201 if ( data->record != rem.data->record ) return false;
202
203 return OPimNotify::operator==( rem );
204}
205QString OPimReminder::type()const {
206 return QString::fromLatin1("OPimReminder");
207}
208int OPimReminder::recordUid()const {
209 return data->record;
210}
211void OPimReminder::setRecordUid( int uid ) {
212 copyIntern();
213 data->record = uid;
214}
215void OPimReminder::deref() {
216 if ( data->deref() ) {
217 delete data;
218 data = 0l;
219 }
220}
221void OPimReminder::copyIntern() {
222 if ( data->count != 1 ) {
223 Data* da = new Data;
224 da->record = data->record;
225 data = da;
226 }
227}
diff --git a/libopie2/opiepim/core/opimnotify.h b/libopie2/opiepim/core/opimnotify.h
new file mode 100644
index 0000000..3501948
--- a/dev/null
+++ b/libopie2/opiepim/core/opimnotify.h
@@ -0,0 +1,142 @@
1#ifndef OPIE_PIM_NOTIFY_H
2#define OPIE_PIM_NOTIFY_H
3
4#include <qdatetime.h>
5#include <qvaluelist.h>
6
7/**
8 * This is the base class of Notifiers. Possible
9 * notifiers would be Alarms, Reminders
10 * What they share is that they have
11 * A DateTime, Type, Duration
12 * This is what this base class takes care of
13 * on top of that it's shared
14 */
15/*
16 * TALK to eilers: have a class OPimDuration which sets the Duration
17 * given on the Due/Start Date? -zecke
18 * discuss: do we need a uid for the notify? -zecke
19 */
20class OPimNotify {
21public:
22 typedef QValueList<OPimNotify> ValueList;
23 OPimNotify( const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 );
24 OPimNotify( const OPimNotify& );
25 virtual ~OPimNotify();
26
27 OPimNotify &operator=(const OPimNotify& );
28 bool operator==( const OPimNotify& );
29
30 virtual QString type()const = 0;
31
32 /** start date */
33 QDateTime dateTime()const;
34 QString service()const;
35
36 /**
37 * RETURN the parent uid
38 */
39 int parent()const;
40
41 /**
42 * in Seconds
43 */
44 int duration()const;
45
46 /**
47 * Start Time + Duration
48 */
49 QDateTime endTime()const;
50
51 void setDateTime( const QDateTime& );
52 void setDuration( int dur );
53 void setParent(int uid );
54 void setService( const QString& );
55
56
57private:
58 inline void copyIntern();
59 void deref();
60 struct Data;
61 Data* data;
62
63 /* d-pointer */
64 class NotifyPrivate;
65 NotifyPrivate* d;
66
67};
68/**
69 * An alarm is a sound/mail/buzzer played/send
70 * at a given time to inform about
71 * an Event
72 */
73class OPimAlarm : public OPimNotify {
74public:
75 enum Sound{Loud=0, Silent, Custom };
76 OPimAlarm( int sound = Silent, const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 );
77 OPimAlarm( const OPimAlarm& );
78 ~OPimAlarm();
79
80 OPimAlarm &operator=( const OPimAlarm& );
81 bool operator==( const OPimAlarm& );
82 QString type()const;
83
84 int sound()const;
85 QString file()const;
86
87 void setSound( int );
88 /* only when sound is custom... */
89 void setFile( const QString& sound );
90
91private:
92 void deref();
93 void copyIntern();
94 struct Data;
95 Data * data;
96
97 class Private;
98 Private* d;
99
100};
101
102/**
103 * A Reminder will be put into the
104 * datebook
105 */
106class OPimReminder : public OPimNotify {
107public:
108
109 /**
110 * c'tor of a reminder
111 * @param uid The uid of the Record inside the Datebook
112 * @param start the StartDate invalid for all day...
113 * @param duration The duration of the event ( -1 for all day )
114 * @param parent The 'parent' record of this reminder
115 */
116 OPimReminder( int uid = 0, const QDateTime& start = QDateTime(),
117 int duration = 0, int parent = 0 );
118 OPimReminder( const OPimReminder& );
119 OPimReminder &operator=(const OPimReminder& );
120
121 QString type()const;
122
123 bool operator==( const OPimReminder& );
124
125 /**
126 * the uid of the alarm
127 * inside the 'datebook' application
128 */
129 int recordUid()const;
130 void setRecordUid( int uid );
131
132private:
133 void deref();
134 void copyIntern();
135
136 struct Data;
137 Data* data;
138 class Private;
139 Private *d;
140};
141
142#endif
diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp
new file mode 100644
index 0000000..be4a1c2
--- a/dev/null
+++ b/libopie2/opiepim/core/opimnotifymanager.cpp
@@ -0,0 +1,69 @@
1#include "opimnotifymanager.h"
2
3OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al)
4 : m_rem( rem ), m_al( al )
5{}
6OPimNotifyManager::~OPimNotifyManager() {
7}
8/* use static_cast and type instead of dynamic... */
9void OPimNotifyManager::add( const OPimNotify& noti) {
10 if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
11 const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
12 m_rem.append( rem );
13 }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
14 const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
15 m_al.append( al );
16 }
17}
18void OPimNotifyManager::remove( const OPimNotify& noti) {
19 if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
20 const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
21 m_rem.remove( rem );
22 }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
23 const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
24 m_al.remove( al );
25 }
26}
27void OPimNotifyManager::replace( const OPimNotify& noti) {
28 if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
29 const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
30 m_rem.remove( rem );
31 m_rem.append( rem );
32 }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
33 const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
34 m_al.remove( al );
35 m_al.append( al );
36 }
37}
38OPimNotifyManager::Reminders OPimNotifyManager::reminders()const {
39 return m_rem;
40}
41OPimNotifyManager::Alarms OPimNotifyManager::alarms()const {
42 return m_al;
43}
44void OPimNotifyManager::setAlarms( const Alarms& al) {
45 m_al = al;
46}
47void OPimNotifyManager::setReminders( const Reminders& rem) {
48 m_rem = rem;
49}
50/* FIXME!!! */
51/**
52 * The idea is to check if the provider for our service
53 * is online
54 * if it is we will use QCOP
55 * if not the Factory to get the backend...
56 * Qtopia1.6 services would be kewl to have here....
57 */
58void OPimNotifyManager::registerNotify( const OPimNotify& ) {
59
60}
61/* FIXME!!! */
62/**
63 * same as above...
64 * Also implement Url model
65 * have a MainWindow....
66 */
67void OPimNotifyManager::deregister( const OPimNotify& ) {
68
69}
diff --git a/libopie2/opiepim/core/opimnotifymanager.h b/libopie2/opiepim/core/opimnotifymanager.h
new file mode 100644
index 0000000..0eebc9b
--- a/dev/null
+++ b/libopie2/opiepim/core/opimnotifymanager.h
@@ -0,0 +1,51 @@
1#ifndef OPIE_PIM_NOTIFY_MANAGER_H
2#define OPIE_PIM_NOTIFY_MANAGER_H
3
4#include <qvaluelist.h>
5
6#include <opie/opimnotify.h>
7
8/**
9 * The notify manager keeps track of the Notifiers....
10 */
11class OPimNotifyManager {
12public:
13 typedef QValueList<OPimReminder> Reminders;
14 typedef QValueList<OPimAlarm> Alarms;
15 OPimNotifyManager( const Reminders& rems = Reminders(), const Alarms& alarms = Alarms() );
16 ~OPimNotifyManager();
17
18 /* we will cast it for you ;) */
19 void add( const OPimNotify& );
20 void remove( const OPimNotify& );
21 /* replaces all with this one! */
22 void replace( const OPimNotify& );
23
24 Reminders reminders()const;
25 Alarms alarms()const;
26
27 void setAlarms( const Alarms& );
28 void setReminders( const Reminders& );
29
30 /* register is a Ansi C keyword... */
31 /**
32 * This function will register the Notify to the Alarm Server
33 * or datebook depending on the type of the notify
34 */
35 void registerNotify( const OPimNotify& );
36
37 /**
38 * this will do the opposite..
39 */
40 void deregister( const OPimNotify& );
41
42private:
43 Reminders m_rem;
44 Alarms m_al;
45
46 class Private;
47 Private *d;
48
49};
50
51#endif
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp
index 0e3be9d..49b5bf9 100644
--- a/libopie2/opiepim/core/opimrecord.cpp
+++ b/libopie2/opiepim/core/opimrecord.cpp
@@ -74,8 +74,11 @@ void OPimRecord::setUid( int uid ) {
74 Qtopia::Record::setUid( uid ); 74 Qtopia::Record::setUid( uid );
75}; 75};
76Qtopia::UidGen &OPimRecord::uidGen() { 76Qtopia::UidGen &OPimRecord::uidGen() {
77 return m_uidGen; 77 return m_uidGen;
78} 78}
79OPimXRefManager &OPimRecord::xrefmanager() { 79OPimXRefManager &OPimRecord::xrefmanager() {
80 return m_xrefman; 80 return m_xrefman;
81} 81}
82int OPimRecord::rtti(){
83 return 0;
84}
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h
index 1642a5e..ec99a13 100644
--- a/libopie2/opiepim/core/opimrecord.h
+++ b/libopie2/opiepim/core/opimrecord.h
@@ -84,26 +84,32 @@ public:
84 /** 84 /**
85 * the name for a recordField 85 * the name for a recordField
86 */ 86 */
87 virtual QString recordField(int)const = 0; 87 virtual QString recordField(int)const = 0;
88 88
89 /** 89 /**
90 * returns a reference of the 90 * returns a reference of the
91 * Cross Reference Manager 91 * Cross Reference Manager
92 * Partner One is THIS PIM RECORD! 92 * Partner 'One' is THIS PIM RECORD!
93 * Two is the Partner where we link to 93 * 'Two' is the Partner where we link to
94 */ 94 */
95 OPimXRefManager& xrefmanager(); 95 OPimXRefManager& xrefmanager();
96 96
97 /** 97 /**
98 * set the uid 98 * set the uid
99 */ 99 */
100 virtual void setUid( int uid ); 100 virtual void setUid( int uid );
101 101
102 /*
103 * used inside the Templates for casting
104 * REIMPLEMENT in your ....
105 */
106 static int rtti();
107
102protected: 108protected:
103 Qtopia::UidGen &uidGen(); 109 Qtopia::UidGen &uidGen();
104// QString crossToString()const; 110// QString crossToString()const;
105 111
106private: 112private:
107 class OPimRecordPrivate; 113 class OPimRecordPrivate;
108 OPimRecordPrivate *d; 114 OPimRecordPrivate *d;
109 OPimXRefManager m_xrefman; 115 OPimXRefManager m_xrefman;
diff --git a/libopie2/opiepim/core/opimresolver.h b/libopie2/opiepim/core/opimresolver.h
new file mode 100644
index 0000000..86ae3eb
--- a/dev/null
+++ b/libopie2/opiepim/core/opimresolver.h
@@ -0,0 +1,56 @@
1#ifndef OPIE_PIM_RESOLVER
2#define OPIE_PIM_RESOLVER
3
4#include <qstring.h>
5#include <qvaluelist.h>
6
7/**
8 * OPimResolver is a MetaClass to access
9 * available backends read only.
10 * It will be used to resolve uids + app names
11 * to full informations
12 * to traverse through a list of alarms, reminders
13 * to get access to built in PIM functionality
14 * and to more stuff
15 * THE PERFORMANCE will depend on THE BACKEND
16 * USING XML is a waste of memory!!!!!
17 */
18class OPimResolver : public QObject {
19public:
20 enum BuiltIn { TodoList = 0,
21 DateBook,
22 AddressBook
23 };
24 static OPimResolver* self();
25
26
27 /*
28 * return a record for a uid
29 * and an app
30 */
31 OPimRecord &record( const QString& service, int uid );
32
33 /**
34 * return the QCopChannel for service
35 * When we will use Qtopia Services it will be used here
36 */
37 QString qcopChannel( enum BuiltIn& )const;
38 QString qcopChannel( const QString& service );
39
40 /**
41 * return a list of available services
42 */
43 QStringList services()const;
44
45 /**
46 * add a record to a service... ;)
47 */
48 bool add( const QString& service, const OPimRecord& );
49
50private:
51 OPimResolver();
52 OPimRecord *m_last;
53
54}:
55
56#endif
diff --git a/libopie2/opiepim/core/opimxref.cpp b/libopie2/opiepim/core/opimxref.cpp
index 5cae871..8eefbd8 100644
--- a/libopie2/opiepim/core/opimxref.cpp
+++ b/libopie2/opiepim/core/opimxref.cpp
@@ -29,18 +29,18 @@ bool OPimXRef::operator==( const OPimXRef& oper ) {
29} 29}
30OPimXRefPartner OPimXRef::partner( enum Partners par) const{ 30OPimXRefPartner OPimXRef::partner( enum Partners par) const{
31 return m_partners[par]; 31 return m_partners[par];
32} 32}
33void OPimXRef::setPartner( enum Partners par, const OPimXRefPartner& part) { 33void OPimXRef::setPartner( enum Partners par, const OPimXRefPartner& part) {
34 m_partners[par] = part; 34 m_partners[par] = part;
35} 35}
36bool OPimXRef::containsString( const QString& string ) const{ 36bool OPimXRef::containsString( const QString& string ) const{
37 if ( m_partners[One].appName() == string || 37 if ( m_partners[One].service() == string ||
38 m_partners[Two].appName() == string ) return true; 38 m_partners[Two].service() == string ) return true;
39 39
40 return false; 40 return false;
41} 41}
42bool OPimXRef::containsUid( int uid ) const{ 42bool OPimXRef::containsUid( int uid ) const{
43 if ( m_partners[One].uid() == uid || 43 if ( m_partners[One].uid() == uid ||
44 m_partners[Two].uid() == uid ) return true; 44 m_partners[Two].uid() == uid ) return true;
45 45
46 return false; 46 return false;
diff --git a/libopie2/opiepim/core/opimxref.h b/libopie2/opiepim/core/opimxref.h
index 354739a..6852651 100644
--- a/libopie2/opiepim/core/opimxref.h
+++ b/libopie2/opiepim/core/opimxref.h
@@ -21,17 +21,17 @@ public:
21 21
22 OPimXRef &operator=( const OPimXRef& ); 22 OPimXRef &operator=( const OPimXRef& );
23 bool operator==( const OPimXRef& ); 23 bool operator==( const OPimXRef& );
24 24
25 OPimXRefPartner partner( enum Partners )const; 25 OPimXRefPartner partner( enum Partners )const;
26 26
27 void setPartner( enum Partners, const OPimXRefPartner& ); 27 void setPartner( enum Partners, const OPimXRefPartner& );
28 28
29 bool containsString( const QString& appName)const; 29 bool containsString( const QString& service)const;
30 bool containsUid( int uid )const; 30 bool containsUid( int uid )const;
31 31
32private: 32private:
33 QArray<OPimXRefPartner> m_partners; 33 QArray<OPimXRefPartner> m_partners;
34 34
35 class Private; 35 class Private;
36 Private *d; 36 Private *d;
37}; 37};
diff --git a/libopie2/opiepim/core/opimxrefmanager.cpp b/libopie2/opiepim/core/opimxrefmanager.cpp
index 965f542..58bfd24 100644
--- a/libopie2/opiepim/core/opimxrefmanager.cpp
+++ b/libopie2/opiepim/core/opimxrefmanager.cpp
@@ -31,20 +31,20 @@ void OPimXRefManager::clear() {
31 m_list.clear(); 31 m_list.clear();
32} 32}
33QStringList OPimXRefManager::apps()const { 33QStringList OPimXRefManager::apps()const {
34 OPimXRef::ValueList::ConstIterator it; 34 OPimXRef::ValueList::ConstIterator it;
35 QStringList list; 35 QStringList list;
36 36
37 QString str; 37 QString str;
38 for ( it = m_list.begin(); it != m_list.end(); ++it ) { 38 for ( it = m_list.begin(); it != m_list.end(); ++it ) {
39 str = (*it).partner( OPimXRef::One ).appName(); 39 str = (*it).partner( OPimXRef::One ).service();
40 if ( !list.contains( str ) ) list << str; 40 if ( !list.contains( str ) ) list << str;
41 41
42 str = (*it).partner( OPimXRef::Two ).appName(); 42 str = (*it).partner( OPimXRef::Two ).service();
43 if ( !list.contains( str ) ) list << str; 43 if ( !list.contains( str ) ) list << str;
44 } 44 }
45 return list; 45 return list;
46} 46}
47OPimXRef::ValueList OPimXRefManager::list()const { 47OPimXRef::ValueList OPimXRefManager::list()const {
48 return m_list; 48 return m_list;
49} 49}
50OPimXRef::ValueList OPimXRefManager::list( const QString& appName )const{ 50OPimXRef::ValueList OPimXRefManager::list( const QString& appName )const{
diff --git a/libopie2/opiepim/core/opimxrefmanager.h b/libopie2/opiepim/core/opimxrefmanager.h
index 9b003a3..39e5eef 100644
--- a/libopie2/opiepim/core/opimxrefmanager.h
+++ b/libopie2/opiepim/core/opimxrefmanager.h
@@ -26,16 +26,16 @@ public:
26 26
27 void clear(); 27 void clear();
28 28
29 /** 29 /**
30 * apps participating 30 * apps participating
31 */ 31 */
32 QStringList apps()const; 32 QStringList apps()const;
33 OPimXRef::ValueList list()const; 33 OPimXRef::ValueList list()const;
34 OPimXRef::ValueList list( const QString& appName )const; 34 OPimXRef::ValueList list( const QString& service )const;
35 OPimXRef::ValueList list( int uid )const; 35 OPimXRef::ValueList list( int uid )const;
36 36
37private: 37private:
38 OPimXRef::ValueList m_list; 38 OPimXRef::ValueList m_list;
39}; 39};
40 40
41#endif 41#endif
diff --git a/libopie2/opiepim/core/opimxrefpartner.cpp b/libopie2/opiepim/core/opimxrefpartner.cpp
index 028f4e6..6ef3efb 100644
--- a/libopie2/opiepim/core/opimxrefpartner.cpp
+++ b/libopie2/opiepim/core/opimxrefpartner.cpp
@@ -18,26 +18,26 @@ OPimXRefPartner &OPimXRefPartner::operator=( const OPimXRefPartner& par ) {
18} 18}
19bool OPimXRefPartner::operator==( const OPimXRefPartner& par ) { 19bool OPimXRefPartner::operator==( const OPimXRefPartner& par ) {
20 if ( m_app != par.m_app ) return false; 20 if ( m_app != par.m_app ) return false;
21 if ( m_uid != par.m_uid ) return false; 21 if ( m_uid != par.m_uid ) return false;
22 if ( m_field != par.m_field ) return false; 22 if ( m_field != par.m_field ) return false;
23 23
24 return true; 24 return true;
25} 25}
26QString OPimXRefPartner::appName()const { 26QString OPimXRefPartner::service()const {
27 return m_app; 27 return m_app;
28} 28}
29int OPimXRefPartner::uid()const { 29int OPimXRefPartner::uid()const {
30 return m_uid; 30 return m_uid;
31} 31}
32int OPimXRefPartner::field()const { 32int OPimXRefPartner::field()const {
33 return m_field; 33 return m_field;
34} 34}
35void OPimXRefPartner::setAppName( const QString& appName ) { 35void OPimXRefPartner::setService( const QString& appName ) {
36 m_app = appName; 36 m_app = appName;
37} 37}
38void OPimXRefPartner::setUid( int uid ) { 38void OPimXRefPartner::setUid( int uid ) {
39 m_uid = uid; 39 m_uid = uid;
40} 40}
41void OPimXRefPartner::setField( int field ) { 41void OPimXRefPartner::setField( int field ) {
42 m_field = field; 42 m_field = field;
43} 43}
diff --git a/libopie2/opiepim/core/opimxrefpartner.h b/libopie2/opiepim/core/opimxrefpartner.h
index 808b9ab..d76e384 100644
--- a/libopie2/opiepim/core/opimxrefpartner.h
+++ b/libopie2/opiepim/core/opimxrefpartner.h
@@ -7,29 +7,29 @@
7 * This class represents one partner 7 * This class represents one partner
8 * of a Cross Reference. 8 * of a Cross Reference.
9 * In Opie one application 9 * In Opie one application
10 * can link one uid 10 * can link one uid
11 * with one tableId( fieldId ) to another. 11 * with one tableId( fieldId ) to another.
12 */ 12 */
13class OPimXRefPartner { 13class OPimXRefPartner {
14public: 14public:
15 OPimXRefPartner( const QString& appName = QString::null, 15 OPimXRefPartner( const QString& service = QString::null,
16 int uid = 0, int field = -1 ); 16 int uid = 0, int field = -1 );
17 OPimXRefPartner( const OPimXRefPartner& ); 17 OPimXRefPartner( const OPimXRefPartner& );
18 OPimXRefPartner& operator=( const OPimXRefPartner& ); 18 OPimXRefPartner& operator=( const OPimXRefPartner& );
19 ~OPimXRefPartner(); 19 ~OPimXRefPartner();
20 20
21 bool operator==(const OPimXRefPartner& ); 21 bool operator==(const OPimXRefPartner& );
22 22
23 QString appName()const; 23 QString service()const;
24 int uid()const; 24 int uid()const;
25 int field()const; 25 int field()const;
26 26
27 void setAppName( const QString& appName ); 27 void setService( const QString& service );
28 void setUid( int uid ); 28 void setUid( int uid );
29 void setField( int field ); 29 void setField( int field );
30private: 30private:
31 QString m_app; 31 QString m_app;
32 int m_uid; 32 int m_uid;
33 int m_field; 33 int m_field;
34 34
35 class Private; 35 class Private;
diff --git a/libopie2/opiepim/core/orecur.cpp b/libopie2/opiepim/core/orecur.cpp
index 257d4fd..daf3506 100644
--- a/libopie2/opiepim/core/orecur.cpp
+++ b/libopie2/opiepim/core/orecur.cpp
@@ -17,16 +17,19 @@ struct ORecur::Data : public QShared {
17 char days; // Q_UINT8 for 8 seven days;) 17 char days; // Q_UINT8 for 8 seven days;)
18 ORecur::RepeatType type; 18 ORecur::RepeatType type;
19 int freq; 19 int freq;
20 int pos; 20 int pos;
21 bool hasEnd : 1; 21 bool hasEnd : 1;
22 time_t end; 22 time_t end;
23 time_t create; 23 time_t create;
24 int rep; 24 int rep;
25 QString app;
26 ExceptionList list;
27 QDate start;
25}; 28};
26 29
27 30
28ORecur::ORecur() { 31ORecur::ORecur() {
29 data = new Data; 32 data = new Data;
30} 33}
31ORecur::ORecur( const ORecur& rec) 34ORecur::ORecur( const ORecur& rec)
32 : data( rec.data ) 35 : data( rec.data )
@@ -50,16 +53,308 @@ bool ORecur::operator==( const ORecur& )const {
50} 53}
51ORecur &ORecur::operator=( const ORecur& re) { 54ORecur &ORecur::operator=( const ORecur& re) {
52 re.data->ref(); 55 re.data->ref();
53 deref(); 56 deref();
54 data = re.data; 57 data = re.data;
55 58
56 return *this; 59 return *this;
57} 60}
61bool ORecur::doesRecur()const {
62 return !( type() == NoRepeat );
63}
64/*
65 * we try to be smart here
66 *
67 */
68bool ORecur::doesRecur( const QDate& date ) {
69 /* the day before the recurrance */
70 QDate da = date.addDays(-1);
71
72 QDate recur;
73 if (!nextOcurrence( da, recur ) )
74 return false;
75
76 return (recur == date);
77}
78// FIXME unuglify!
79// GPL from Datebookdb.cpp
80// FIXME exception list!
81bool ORecur::nextOcurrence( const QDate& from, QDate& next ) {
82
83 // easy checks, first are we too far in the future or too far in the past?
84 QDate tmpDate;
85 int freq = frequency();
86 int diff, diff2, a;
87 int iday, imonth, iyear;
88 int dayOfWeek = 0;
89 int firstOfWeek = 0;
90 int weekOfMonth;
91
92
93 if (hasEndDate() && endDate() < from)
94 return FALSE;
95
96 if (start() >= from) {
97 next = start();
98 return TRUE;
99 }
100
101 switch ( type() ) {
102 case Weekly:
103 /* weekly is just daily by 7 */
104 /* first convert the repeatPattern.Days() mask to the next
105 day of week valid after from */
106 dayOfWeek = from.dayOfWeek();
107 dayOfWeek--; /* we want 0-6, doco for above specs 1-7 */
108
109 /* this is done in case freq > 1 and from in week not
110 for this round */
111 // firstOfWeek = 0; this is already done at decl.
112 while(!((1 << firstOfWeek) & days() ))
113 firstOfWeek++;
114
115 /* there is at least one 'day', or there would be no event */
116 while(!((1 << (dayOfWeek % 7)) & days() ))
117 dayOfWeek++;
118
119 dayOfWeek = dayOfWeek % 7; /* the actual day of week */
120 dayOfWeek -= start().dayOfWeek() -1;
121
122 firstOfWeek = firstOfWeek % 7; /* the actual first of week */
123 firstOfWeek -= start().dayOfWeek() -1;
124
125 // dayOfWeek may be negitive now
126 // day of week is number of days to add to start day
127
128 freq *= 7;
129 // FALL-THROUGH !!!!!
130 case Daily:
131 // the add is for the possible fall through from weekly */
132 if(start().addDays(dayOfWeek) > from) {
133 /* first week exception */
134 next = QDate(start().addDays(dayOfWeek) );
135 if ((next > endDate())
136 && hasEndDate() )
137 return FALSE;
138 return TRUE;
139 }
140 /* if from is middle of a non-week */
141
142 diff = start().addDays(dayOfWeek).daysTo(from) % freq;
143 diff2 = start().addDays(firstOfWeek).daysTo(from) % freq;
144
145 if(diff != 0)
146 diff = freq - diff;
147 if(diff2 != 0)
148 diff2 = freq - diff2;
149 diff = QMIN(diff, diff2);
150
151 next = QDate(from.addDays(diff));
152 if ( (next > endDate())
153 && hasEndDate() )
154 return FALSE;
155 return TRUE;
156 case MonthlyDay:
157 iday = from.day();
158 iyear = from.year();
159 imonth = from.month();
160 /* find equivelent day of month for this month */
161 dayOfWeek = start().dayOfWeek();
162 weekOfMonth = (start().day() - 1) / 7;
163
164 /* work out when the next valid month is */
165 a = from.year() - start().year();
166 a *= 12;
167 a = a + (imonth - start().month());
168 /* a is e.start()monthsFrom(from); */
169 if(a % freq) {
170 a = freq - (a % freq);
171 imonth = from.month() + a;
172 if (imonth > 12) {
173 imonth--;
174 iyear += imonth / 12;
175 imonth = imonth % 12;
176 imonth++;
177 }
178 }
179 /* imonth is now the first month after or on
180 from that matches the frequency given */
181
182 /* find for this month */
183 tmpDate = QDate( iyear, imonth, 1 );
184
185 iday = 1;
186 iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7;
187 iday += 7 * weekOfMonth;
188 while (iday > tmpDate.daysInMonth()) {
189 imonth += freq;
190 if (imonth > 12) {
191 imonth--;
192 iyear += imonth / 12;
193 imonth = imonth % 12;
194 imonth++;
195 }
196 tmpDate = QDate( iyear, imonth, 1 );
197 /* these loops could go for a while, check end case now */
198 if ((tmpDate > endDate()) && hasEndDate() )
199 return FALSE;
200 iday = 1;
201 iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7;
202 iday += 7 * weekOfMonth;
203 }
204 tmpDate = QDate(iyear, imonth, iday);
205
206 if (tmpDate >= from) {
207 next = tmpDate;
208 if ((next > endDate() ) && hasEndDate() )
209 return FALSE;
210 return TRUE;
211 }
212
213 /* need to find the next iteration */
214 do {
215 imonth += freq;
216 if (imonth > 12) {
217 imonth--;
218 iyear += imonth / 12;
219 imonth = imonth % 12;
220 imonth++;
221 }
222 tmpDate = QDate( iyear, imonth, 1 );
223 /* these loops could go for a while, check end case now */
224 if ((tmpDate > endDate()) && hasEndDate() )
225 return FALSE;
226 iday = 1;
227 iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7;
228 iday += 7 * weekOfMonth;
229 } while (iday > tmpDate.daysInMonth());
230 tmpDate = QDate(iyear, imonth, iday);
231
232 next = tmpDate;
233 if ((next > endDate()) && hasEndDate() )
234 return FALSE;
235 return TRUE;
236 case MonthlyDate:
237 iday = start().day();
238 iyear = from.year();
239 imonth = from.month();
240
241 a = from.year() - start().year();
242 a *= 12;
243 a = a + (imonth - start().month());
244 /* a is e.start()monthsFrom(from); */
245 if(a % freq) {
246 a = freq - (a % freq);
247 imonth = from.month() + a;
248 if (imonth > 12) {
249 imonth--;
250 iyear += imonth / 12;
251 imonth = imonth % 12;
252 imonth++;
253 }
254 }
255 /* imonth is now the first month after or on
256 from that matches the frequencey given */
257
258 /* this could go for a while, worse case, 4*12 iterations, probably */
259 while(!QDate::isValid(iyear, imonth, iday) ) {
260 imonth += freq;
261 if (imonth > 12) {
262 imonth--;
263 iyear += imonth / 12;
264 imonth = imonth % 12;
265 imonth++;
266 }
267 /* these loops could go for a while, check end case now */
268 if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() )
269 return FALSE;
270 }
271
272 if(QDate(iyear, imonth, iday) >= from) {
273 /* done */
274 next = QDate(iyear, imonth, iday);
275 if ((next > endDate()) && hasEndDate() )
276 return FALSE;
277 return TRUE;
278 }
279
280 /* ok, need to cycle */
281 imonth += freq;
282 imonth--;
283 iyear += imonth / 12;
284 imonth = imonth % 12;
285 imonth++;
286
287 while(!QDate::isValid(iyear, imonth, iday) ) {
288 imonth += freq;
289 imonth--;
290 iyear += imonth / 12;
291 imonth = imonth % 12;
292 imonth++;
293 if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() )
294 return FALSE;
295 }
296
297 next = QDate(iyear, imonth, iday);
298 if ((next > endDate()) && hasEndDate() )
299 return FALSE;
300 return TRUE;
301 case Yearly:
302 iday = start().day();
303 imonth = start().month();
304 iyear = from.year(); // after all, we want to start in this year
305
306 diff = 1;
307 if(imonth == 2 && iday > 28) {
308 /* leap year, and it counts, calculate actual frequency */
309 if(freq % 4)
310 if (freq % 2)
311 freq = freq * 4;
312 else
313 freq = freq * 2;
314 /* else divides by 4 already, leave freq alone */
315 diff = 4;
316 }
317
318 a = from.year() - start().year();
319 if(a % freq) {
320 a = freq - (a % freq);
321 iyear = iyear + a;
322 }
323
324 /* under the assumption we won't hit one of the special not-leap years twice */
325 if(!QDate::isValid(iyear, imonth, iday)) {
326 /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */
327 iyear += freq;
328 }
329
330 if(QDate(iyear, imonth, iday) >= from) {
331 next = QDate(iyear, imonth, iday);
332
333 if ((next > endDate()) && hasEndDate() )
334 return FALSE;
335 return TRUE;
336 }
337 /* iyear == from.year(), need to advance again */
338 iyear += freq;
339 /* under the assumption we won't hit one of the special not-leap years twice */
340 if(!QDate::isValid(iyear, imonth, iday)) {
341 /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */
342 iyear += freq;
343 }
344
345 next = QDate(iyear, imonth, iday);
346 if ((next > endDate()) && hasEndDate() )
347 return FALSE;
348 return TRUE;
349 default:
350 return FALSE;
351 }
352}
58ORecur::RepeatType ORecur::type()const{ 353ORecur::RepeatType ORecur::type()const{
59 return data->type; 354 return data->type;
60} 355}
61int ORecur::frequency()const { 356int ORecur::frequency()const {
62 return data->freq; 357 return data->freq;
63} 358}
64int ORecur::position()const { 359int ORecur::position()const {
65 return data->pos; 360 return data->pos;
@@ -68,25 +363,34 @@ char ORecur::days() const{
68 return data->days; 363 return data->days;
69} 364}
70bool ORecur::hasEndDate()const { 365bool ORecur::hasEndDate()const {
71 return data->hasEnd; 366 return data->hasEnd;
72} 367}
73QDate ORecur::endDate()const { 368QDate ORecur::endDate()const {
74 return TimeConversion::fromUTC( data->end ).date(); 369 return TimeConversion::fromUTC( data->end ).date();
75} 370}
371QDate ORecur::start()const{
372 return data->start;
373}
76time_t ORecur::endDateUTC()const { 374time_t ORecur::endDateUTC()const {
77 return data->end; 375 return data->end;
78} 376}
79time_t ORecur::createTime()const { 377time_t ORecur::createTime()const {
80 return data->create; 378 return data->create;
81} 379}
82int ORecur::repetition()const { 380int ORecur::repetition()const {
83 return data->rep; 381 return data->rep;
84} 382}
383QString ORecur::service()const {
384 return data->app;
385}
386ORecur::ExceptionList& ORecur::exceptions() {
387 return data->list;
388}
85void ORecur::setType( const RepeatType& z) { 389void ORecur::setType( const RepeatType& z) {
86 checkOrModify(); 390 checkOrModify();
87 data->type = z; 391 data->type = z;
88} 392}
89void ORecur::setFrequency( int freq ) { 393void ORecur::setFrequency( int freq ) {
90 checkOrModify(); 394 checkOrModify();
91 data->freq = freq; 395 data->freq = freq;
92} 396}
@@ -113,24 +417,35 @@ void ORecur::setCreateTime( time_t t) {
113void ORecur::setHasEndDate( bool b) { 417void ORecur::setHasEndDate( bool b) {
114 checkOrModify(); 418 checkOrModify();
115 data->hasEnd = b; 419 data->hasEnd = b;
116} 420}
117void ORecur::setRepitition( int rep ) { 421void ORecur::setRepitition( int rep ) {
118 checkOrModify(); 422 checkOrModify();
119 data->rep = rep; 423 data->rep = rep;
120} 424}
425void ORecur::setService( const QString& app ) {
426 checkOrModify();
427 data->app = app;
428}
429void ORecur::setStart( const QDate& dt ) {
430 checkOrModify();
431 data->start = dt;
432}
121void ORecur::checkOrModify() { 433void ORecur::checkOrModify() {
122 if ( data->count != 1 ) { 434 if ( data->count != 1 ) {
123 data->deref(); 435 data->deref();
124 Data* d2 = new Data; 436 Data* d2 = new Data;
125 d2->days = data->days; 437 d2->days = data->days;
126 d2->type = data->type; 438 d2->type = data->type;
127 d2->freq = data->freq; 439 d2->freq = data->freq;
128 d2->pos = data->pos; 440 d2->pos = data->pos;
129 d2->hasEnd = data->hasEnd; 441 d2->hasEnd = data->hasEnd;
130 d2->end = data->end; 442 d2->end = data->end;
131 d2->create = data->create; 443 d2->create = data->create;
132 d2->rep = data->rep; 444 d2->rep = data->rep;
445 d2->app = data->app;
446 d2->list = data->list;
447 d2->start = data->start;
133 data = d2; 448 data = d2;
134 } 449 }
135} 450}
136 451
diff --git a/libopie2/opiepim/core/orecur.h b/libopie2/opiepim/core/orecur.h
index d24d72d..8713d97 100644
--- a/libopie2/opiepim/core/orecur.h
+++ b/libopie2/opiepim/core/orecur.h
@@ -3,50 +3,77 @@
3 */ 3 */
4 4
5#ifndef OPIE_RECUR_H 5#ifndef OPIE_RECUR_H
6#define OPIE_RECUR_H 6#define OPIE_RECUR_H
7 7
8#include <sys/types.h> 8#include <sys/types.h>
9 9
10#include <qdatetime.h> 10#include <qdatetime.h>
11 11#include <qvaluelist.h>
12 12
13 13
14class ORecur { 14class ORecur {
15public: 15public:
16 typedef QValueList<QDate> ExceptionList;
16 enum RepeatType{ NoRepeat = -1, Daily, Weekly, MonthlyDay, 17 enum RepeatType{ NoRepeat = -1, Daily, Weekly, MonthlyDay,
17 MonthlyDate, Yearly }; 18 MonthlyDate, Yearly };
18 enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08, 19 enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08,
19 FRI = 0x10, SAT = 0x20, SUN = 0x40 }; 20 FRI = 0x10, SAT = 0x20, SUN = 0x40 };
20 ORecur(); 21 ORecur();
21 ORecur( const ORecur& ); 22 ORecur( const ORecur& );
22 ~ORecur(); 23 ~ORecur();
23 24
24 ORecur &operator=( const ORecur& ); 25 ORecur &operator=( const ORecur& );
25 bool operator==(const ORecur& )const; 26 bool operator==(const ORecur& )const;
27
28 bool doesRecur()const;
29 /* if it recurrs on that day */
30 bool doesRecur( const QDate& );
26 RepeatType type()const; 31 RepeatType type()const;
27 int frequency()const; 32 int frequency()const;
28 int position()const; 33 int position()const;
29 char days()const; 34 char days()const;
30 bool hasEndDate()const; 35 bool hasEndDate()const;
36 QDate start()const;
31 QDate endDate()const; 37 QDate endDate()const;
32 time_t endDateUTC()const; 38 time_t endDateUTC()const;
33 time_t createTime()const; 39 time_t createTime()const;
40
41 /**
42 * FromWhereToStart is not included!!!
43 */
44 bool nextOcurrence( const QDate& FromWhereToStart, QDate &recurDate );
45 /**
46 * The module this ORecur belongs to
47 */
48 QString service()const;
49
50 /*
51 * reference to the exception list
52 */
53 ExceptionList &exceptions();
54
55 /**
56 * the current repetition
57 */
34 int repetition()const; 58 int repetition()const;
35 59
36 void setType( const RepeatType& ); 60 void setType( const RepeatType& );
37 void setFrequency( int freq ); 61 void setFrequency( int freq );
38 void setPosition( int pos ); 62 void setPosition( int pos );
39 void setDays( char c); 63 void setDays( char c);
40 void setEndDate( const QDate& dt ); 64 void setEndDate( const QDate& dt );
65 void setStart( const QDate& dt );
41 void setEndDateUTC( time_t ); 66 void setEndDateUTC( time_t );
42 void setCreateTime( time_t ); 67 void setCreateTime( time_t );
43 void setHasEndDate( bool b ); 68 void setHasEndDate( bool b );
44 void setRepitition(int ); 69 void setRepitition(int );
70
71 void setService( const QString& ser );
45private: 72private:
46 void deref(); 73 void deref();
47 inline void checkOrModify(); 74 inline void checkOrModify();
48 75
49 76
50 class Data; 77 class Data;
51 Data* data; 78 Data* data;
52 class ORecurPrivate; 79 class ORecurPrivate;
diff --git a/libopie2/opiepim/core/otodoaccess.cpp b/libopie2/opiepim/core/otodoaccess.cpp
index c258de6..d860411 100644
--- a/libopie2/opiepim/core/otodoaccess.cpp
+++ b/libopie2/opiepim/core/otodoaccess.cpp
@@ -40,28 +40,30 @@ OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start,
40 return effectiveToDos( start, QDate::currentDate(), 40 return effectiveToDos( start, QDate::currentDate(),
41 includeNoDates ); 41 includeNoDates );
42} 42}
43OTodoAccess::List OTodoAccess::overDue() { 43OTodoAccess::List OTodoAccess::overDue() {
44 List lis( m_todoBackEnd->overDue(), this ); 44 List lis( m_todoBackEnd->overDue(), this );
45 return lis; 45 return lis;
46} 46}
47void OTodoAccess::addAlarm( const OTodo& event) { 47void OTodoAccess::addAlarm( const OTodo& event) {
48 if (!event.hasAlarmDateTime() ) 48/* FIXME use the new notifier architecture
49 if (!event.hasAlarmDateTime() )
49 return; 50 return;
50 51
51 QDateTime now = QDateTime::currentDateTime(); 52 QDateTime now = QDateTime::currentDateTime();
52 QDateTime schedule = event.alarmDateTime(); 53 QDateTime schedule = event.alarmDateTime();
53 54
54 if ( schedule > now ){ 55 if ( schedule > now ){
55 AlarmServer::addAlarm( schedule, 56 AlarmServer::addAlarm( schedule,
56 "QPE/Application/todolist", 57 "QPE/Application/todolist",
57 "alarm(QDateTime,int)", event.uid() ); 58 "alarm(QDateTime,int)", event.uid() );
58 59
59 } 60 }
61*/
60} 62}
61void OTodoAccess::delAlarm( int uid) { 63void OTodoAccess::delAlarm( int uid) {
62 64
63 QDateTime schedule; // Create null DateTime 65 QDateTime schedule; // Create null DateTime
64 66
65 // I hope this will remove all scheduled alarms 67 // I hope this will remove all scheduled alarms
66 // with the given uid !? 68 // with the given uid !?
67 // If not: I have to rethink how to remove already 69 // If not: I have to rethink how to remove already
@@ -74,8 +76,11 @@ void OTodoAccess::delAlarm( int uid) {
74} 76}
75/* sort order */ 77/* sort order */
76OTodoAccess::List OTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) { 78OTodoAccess::List OTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) {
77 QArray<int> ints = m_todoBackEnd->sorted( ascending, sort, 79 QArray<int> ints = m_todoBackEnd->sorted( ascending, sort,
78 filter, cat ); 80 filter, cat );
79 OTodoAccess::List list( ints, this ); 81 OTodoAccess::List list( ints, this );
80 return list; 82 return list;
81} 83}
84void OTodoAccess::removeAllCompleted() {
85 m_todoBackEnd->removeAllCompleted();
86}
diff --git a/libopie2/opiepim/core/otodoaccess.h b/libopie2/opiepim/core/otodoaccess.h
index 390ab0e..c079155 100644
--- a/libopie2/opiepim/core/otodoaccess.h
+++ b/libopie2/opiepim/core/otodoaccess.h
@@ -63,31 +63,36 @@ public:
63 63
64 /** 64 /**
65 * merge a list of OTodos into 65 * merge a list of OTodos into
66 * the resource 66 * the resource
67 */ 67 */
68 void mergeWith( const QValueList<OTodo>& ); 68 void mergeWith( const QValueList<OTodo>& );
69 69
70 /** 70 /**
71 * delete all already completed items
72 */
73 void removeAllCompleted();
74
75signals:
76 /**
77 * if the OTodoAccess was changed
78 */
79 void signalChanged( const OTodoAccess* );
80private:
81 /**
71 * add an Alarm to the AlarmServer 82 * add an Alarm to the AlarmServer
72 */ 83 */
73 void addAlarm( const OTodo& ); 84 void addAlarm( const OTodo& );
74 85
75 /** 86 /**
76 * delete an alarm with the uid from 87 * delete an alarm with the uid from
77 * the alarm server 88 * the alarm server
78 */ 89 */
79 void delAlarm( int uid ); 90 void delAlarm( int uid );
80 91
81signals:
82 /**
83 * if the OTodoAccess was changed
84 */
85 void signalChanged( const OTodoAccess* );
86private:
87 int m_cat; 92 int m_cat;
88 OTodoAccessBackend* m_todoBackEnd; 93 OTodoAccessBackend* m_todoBackEnd;
89 class OTodoAccessPrivate; 94 class OTodoAccessPrivate;
90 OTodoAccessPrivate* d; 95 OTodoAccessPrivate* d;
91}; 96};
92 97
93#endif 98#endif
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index 917eb0a..efa2777 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -1090,14 +1090,16 @@ void OContact::setDefaultEmail( const QString &v )
1090 1090
1091} 1091}
1092 1092
1093void OContact::insertEmails( const QStringList &v ) 1093void OContact::insertEmails( const QStringList &v )
1094{ 1094{
1095 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) 1095 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
1096 insertEmail( *it ); 1096 insertEmail( *it );
1097} 1097}
1098 1098int OContact::rtti() {
1099 return 2;
1100}
1099void OContact::setUid( int i ) 1101void OContact::setUid( int i )
1100{ 1102{
1101 OPimRecord::setUid(i); 1103 OPimRecord::setUid(i);
1102 replace( Qtopia::AddressUid , QString::number(i)); 1104 replace( Qtopia::AddressUid , QString::number(i));
1103} 1105}
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h
index d97af1c..65ba43e 100644
--- a/libopie2/opiepim/ocontact.h
+++ b/libopie2/opiepim/ocontact.h
@@ -41,17 +41,17 @@ class QPC_EXPORT OContact : public OPimRecord
41 friend class DataSet; 41 friend class DataSet;
42public: 42public:
43 OContact(); 43 OContact();
44 OContact( const QMap<int, QString> &fromMap ); 44 OContact( const QMap<int, QString> &fromMap );
45 virtual ~OContact(); 45 virtual ~OContact();
46 46
47 enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; 47 enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE };
48 48
49 /* 49 /*
50 * do we need to inline them 50 * do we need to inline them
51 * if yes do we need to inline them this way? 51 * if yes do we need to inline them this way?
52 * -zecke 52 * -zecke
53 */ 53 */
54 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } 54 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); }
55 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } 55 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); }
56 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } 56 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); }
57 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } 57 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); }
@@ -206,16 +206,17 @@ public:
206 QMap<QString,QString> OContact::toExtraMap() const; 206 QMap<QString,QString> OContact::toExtraMap() const;
207 class QString OContact::recordField(int) const; 207 class QString OContact::recordField(int) const;
208 208
209 // Why private ? (eilers,se) 209 // Why private ? (eilers,se)
210 QString emailSeparator() const { return " "; } 210 QString emailSeparator() const { return " "; }
211 // the emails should be seperated by a comma 211 // the emails should be seperated by a comma
212 void setEmails( const QString &v ); 212 void setEmails( const QString &v );
213 QString emails() const { return find( Qtopia::Emails ); } 213 QString emails() const { return find( Qtopia::Emails ); }
214 static int rtti();
214 215
215 216
216private: 217private:
217 // The XML-Backend needs some access to the private functions 218 // The XML-Backend needs some access to the private functions
218 friend class OContactAccessBackend_XML; 219 friend class OContactAccessBackend_XML;
219 220
220 void insert( int key, const QString &value ); 221 void insert( int key, const QString &value );
221 void replace( int key, const QString &value ); 222 void replace( int key, const QString &value );
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp
index 6fcf9f6..ece624a 100644
--- a/libopie2/opiepim/otodo.cpp
+++ b/libopie2/opiepim/otodo.cpp
@@ -10,37 +10,39 @@
10#include <qpe/stringutil.h> 10#include <qpe/stringutil.h>
11#include <qpe/categories.h> 11#include <qpe/categories.h>
12#include <qpe/categoryselect.h> 12#include <qpe/categoryselect.h>
13 13
14 14
15#include "opimstate.h" 15#include "opimstate.h"
16#include "orecur.h" 16#include "orecur.h"
17#include "opimmaintainer.h" 17#include "opimmaintainer.h"
18#include "opimnotifymanager.h"
18 19
19#include "otodo.h" 20#include "otodo.h"
20 21
21 22
22struct OTodo::OTodoData : public QShared { 23struct OTodo::OTodoData : public QShared {
23 OTodoData() : QShared() { 24 OTodoData() : QShared() {
24 }; 25 };
25 26
26 QDate date; 27 QDate date;
27 bool isCompleted:1; 28 bool isCompleted:1;
28 bool hasDate:1; 29 bool hasDate:1;
29 int priority; 30 int priority;
30 QString desc; 31 QString desc;
31 QString sum; 32 QString sum;
32 QMap<QString, QString> extra; 33 QMap<QString, QString> extra;
33 ushort prog; 34 ushort prog;
34 bool hasAlarmDateTime :1;
35 QDateTime alarmDateTime;
36 OPimState state; 35 OPimState state;
37 ORecur recur; 36 ORecur recur;
38 OPimMaintainer maintainer; 37 OPimMaintainer maintainer;
38 QDate start;
39 QDate completed;
40 OPimNotifyManager notifiers;
39}; 41};
40 42
41OTodo::OTodo(const OTodo &event ) 43OTodo::OTodo(const OTodo &event )
42 : OPimRecord( event ), data( event.data ) 44 : OPimRecord( event ), data( event.data )
43{ 45{
44 data->ref(); 46 data->ref();
45// qWarning("ref up"); 47// qWarning("ref up");
46} 48}
@@ -68,18 +70,16 @@ OTodo::OTodo(bool completed, int priority,
68 70
69 data->date = date; 71 data->date = date;
70 data->isCompleted = completed; 72 data->isCompleted = completed;
71 data->hasDate = hasDate; 73 data->hasDate = hasDate;
72 data->priority = priority; 74 data->priority = priority;
73 data->sum = summary; 75 data->sum = summary;
74 data->prog = progress; 76 data->prog = progress;
75 data->desc = Qtopia::simplifyMultiLineSpace(description ); 77 data->desc = Qtopia::simplifyMultiLineSpace(description );
76 data->hasAlarmDateTime = false;
77
78} 78}
79OTodo::OTodo(bool completed, int priority, 79OTodo::OTodo(bool completed, int priority,
80 const QStringList &category, 80 const QStringList &category,
81 const QString& summary, 81 const QString& summary,
82 const QString &description, 82 const QString &description,
83 ushort progress, 83 ushort progress,
84 bool hasDate, QDate date, int uid ) 84 bool hasDate, QDate date, int uid )
85 : OPimRecord( uid ) 85 : OPimRecord( uid )
@@ -91,18 +91,16 @@ OTodo::OTodo(bool completed, int priority,
91 91
92 data->date = date; 92 data->date = date;
93 data->isCompleted = completed; 93 data->isCompleted = completed;
94 data->hasDate = hasDate; 94 data->hasDate = hasDate;
95 data->priority = priority; 95 data->priority = priority;
96 data->sum = summary; 96 data->sum = summary;
97 data->prog = progress; 97 data->prog = progress;
98 data->desc = Qtopia::simplifyMultiLineSpace(description ); 98 data->desc = Qtopia::simplifyMultiLineSpace(description );
99 data->hasAlarmDateTime = false;
100
101} 99}
102bool OTodo::match( const QRegExp &regExp )const 100bool OTodo::match( const QRegExp &regExp )const
103{ 101{
104 if( QString::number( data->priority ).find( regExp ) != -1 ){ 102 if( QString::number( data->priority ).find( regExp ) != -1 ){
105 return true; 103 return true;
106 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ 104 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){
107 return true; 105 return true;
108 }else if(data->desc.find( regExp ) != -1 ){ 106 }else if(data->desc.find( regExp ) != -1 ){
@@ -115,19 +113,21 @@ bool OTodo::match( const QRegExp &regExp )const
115bool OTodo::isCompleted() const 113bool OTodo::isCompleted() const
116{ 114{
117 return data->isCompleted; 115 return data->isCompleted;
118} 116}
119bool OTodo::hasDueDate() const 117bool OTodo::hasDueDate() const
120{ 118{
121 return data->hasDate; 119 return data->hasDate;
122} 120}
123bool OTodo::hasAlarmDateTime() const 121bool OTodo::hasStartDate()const {
124{ 122 return data->start.isValid();
125 return data->hasAlarmDateTime; 123}
124bool OTodo::hasCompletedDate()const {
125 return data->completed.isValid();
126} 126}
127int OTodo::priority()const 127int OTodo::priority()const
128{ 128{
129 return data->priority; 129 return data->priority;
130} 130}
131QString OTodo::summary() const 131QString OTodo::summary() const
132{ 132{
133 return data->sum; 133 return data->sum;
@@ -135,22 +135,22 @@ QString OTodo::summary() const
135ushort OTodo::progress() const 135ushort OTodo::progress() const
136{ 136{
137 return data->prog; 137 return data->prog;
138} 138}
139QDate OTodo::dueDate()const 139QDate OTodo::dueDate()const
140{ 140{
141 return data->date; 141 return data->date;
142} 142}
143 143QDate OTodo::startDate()const {
144QDateTime OTodo::alarmDateTime() const 144 return data->start;
145{ 145}
146 return data->alarmDateTime; 146QDate OTodo::completedDate()const {
147 return data->completed;
147} 148}
148
149QString OTodo::description()const 149QString OTodo::description()const
150{ 150{
151 return data->desc; 151 return data->desc;
152} 152}
153OPimState OTodo::state()const { 153OPimState OTodo::state()const {
154 return data->state; 154 return data->state;
155} 155}
156ORecur OTodo::recurrence()const { 156ORecur OTodo::recurrence()const {
@@ -164,46 +164,44 @@ void OTodo::setCompleted( bool completed )
164 changeOrModify(); 164 changeOrModify();
165 data->isCompleted = completed; 165 data->isCompleted = completed;
166} 166}
167void OTodo::setHasDueDate( bool hasDate ) 167void OTodo::setHasDueDate( bool hasDate )
168{ 168{
169 changeOrModify(); 169 changeOrModify();
170 data->hasDate = hasDate; 170 data->hasDate = hasDate;
171} 171}
172void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime )
173{
174 changeOrModify();
175 data->hasAlarmDateTime = hasAlarmDateTime;
176}
177void OTodo::setDescription(const QString &desc ) 172void OTodo::setDescription(const QString &desc )
178{ 173{
179// qWarning( "desc " + desc ); 174// qWarning( "desc " + desc );
180 changeOrModify(); 175 changeOrModify();
181 data->desc = Qtopia::simplifyMultiLineSpace(desc ); 176 data->desc = Qtopia::simplifyMultiLineSpace(desc );
182} 177}
183void OTodo::setSummary( const QString& sum ) 178void OTodo::setSummary( const QString& sum )
184{ 179{
185 changeOrModify(); 180 changeOrModify();
186 data->sum = sum; 181 data->sum = sum;
187} 182}
188void OTodo::setPriority(int prio ) 183void OTodo::setPriority(int prio )
189{ 184{
190 changeOrModify(); 185 changeOrModify();
191 data->priority = prio; 186 data->priority = prio;
192} 187}
193void OTodo::setDueDate( QDate date ) 188void OTodo::setDueDate( const QDate& date )
194{ 189{
195 changeOrModify(); 190 changeOrModify();
196 data->date = date; 191 data->date = date;
197} 192}
198void OTodo::setAlarmDateTime( const QDateTime& alarm ) 193void OTodo::setStartDate( const QDate& date ) {
199{
200 changeOrModify(); 194 changeOrModify();
201 data->alarmDateTime = alarm; 195 data->start = date;
196}
197void OTodo::setCompletedDate( const QDate& date ) {
198 changeOrModify();
199 data->completed = date;
202} 200}
203void OTodo::setState( const OPimState& state ) { 201void OTodo::setState( const OPimState& state ) {
204 changeOrModify(); 202 changeOrModify();
205 data->state = state; 203 data->state = state;
206} 204}
207void OTodo::setRecurrence( const ORecur& rec) { 205void OTodo::setRecurrence( const ORecur& rec) {
208 changeOrModify(); 206 changeOrModify();
209 data->recur = rec; 207 data->recur = rec;
@@ -249,28 +247,26 @@ QString OTodo::toRichText() const
249 + QString::number( priority() ) + " <br>"; 247 + QString::number( priority() ) + " <br>";
250 text += "<b>" + QObject::tr( "Progress:") + " </b>" 248 text += "<b>" + QObject::tr( "Progress:") + " </b>"
251 + QString::number( progress() ) + " %<br>"; 249 + QString::number( progress() ) + " %<br>";
252 if (hasDueDate() ){ 250 if (hasDueDate() ){
253 text += "<b>" + QObject::tr( "Deadline:") + " </b>"; 251 text += "<b>" + QObject::tr( "Deadline:") + " </b>";
254 text += dueDate().toString(); 252 text += dueDate().toString();
255 text += "<br>"; 253 text += "<br>";
256 } 254 }
257 if (hasAlarmDateTime() ){
258 text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>";
259 text += alarmDateTime().toString();
260 text += "<br>";
261 }
262 255
263 text += "<b>" + QObject::tr( "Category:") + "</b> "; 256 text += "<b>" + QObject::tr( "Category:") + "</b> ";
264 text += categoryNames().join(", "); 257 text += categoryNames().join(", ");
265 text += "<br>"; 258 text += "<br>";
266 259
267 return text; 260 return text;
268} 261}
262OPimNotifyManager& OTodo::notifiers() {
263 return data->notifiers;
264}
269 265
270bool OTodo::operator<( const OTodo &toDoEvent )const{ 266bool OTodo::operator<( const OTodo &toDoEvent )const{
271 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 267 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
272 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 268 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
273 if( hasDueDate() && toDoEvent.hasDueDate() ){ 269 if( hasDueDate() && toDoEvent.hasDueDate() ){
274 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 270 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
275 return priority() < toDoEvent.priority(); 271 return priority() < toDoEvent.priority();
276 }else{ 272 }else{
@@ -322,20 +318,16 @@ bool OTodo::operator==(const OTodo &toDoEvent )const
322{ 318{
323 if ( data->priority != toDoEvent.data->priority ) return false; 319 if ( data->priority != toDoEvent.data->priority ) return false;
324 if ( data->priority != toDoEvent.data->prog ) return false; 320 if ( data->priority != toDoEvent.data->prog ) return false;
325 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; 321 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
326 if ( data->hasDate != toDoEvent.data->hasDate ) return false; 322 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
327 if ( data->date != toDoEvent.data->date ) return false; 323 if ( data->date != toDoEvent.data->date ) return false;
328 if ( data->sum != toDoEvent.data->sum ) return false; 324 if ( data->sum != toDoEvent.data->sum ) return false;
329 if ( data->desc != toDoEvent.data->desc ) return false; 325 if ( data->desc != toDoEvent.data->desc ) return false;
330 if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime )
331 return false;
332 if ( data->alarmDateTime != toDoEvent.data->alarmDateTime )
333 return false;
334 if ( data->maintainer != toDoEvent.data->maintainer ) 326 if ( data->maintainer != toDoEvent.data->maintainer )
335 return false; 327 return false;
336 328
337 return OPimRecord::operator==( toDoEvent ); 329 return OPimRecord::operator==( toDoEvent );
338} 330}
339void OTodo::deref() { 331void OTodo::deref() {
340 332
341// qWarning("deref in ToDoEvent"); 333// qWarning("deref in ToDoEvent");
@@ -366,19 +358,21 @@ QMap<int, QString> OTodo::toMap() const {
366 map.insert( Description, data->desc ); 358 map.insert( Description, data->desc );
367 map.insert( Summary, data->sum ); 359 map.insert( Summary, data->sum );
368 map.insert( Priority, QString::number( data->priority ) ); 360 map.insert( Priority, QString::number( data->priority ) );
369 map.insert( DateDay, QString::number( data->date.day() ) ); 361 map.insert( DateDay, QString::number( data->date.day() ) );
370 map.insert( DateMonth, QString::number( data->date.month() ) ); 362 map.insert( DateMonth, QString::number( data->date.month() ) );
371 map.insert( DateYear, QString::number( data->date.year() ) ); 363 map.insert( DateYear, QString::number( data->date.year() ) );
372 map.insert( Progress, QString::number( data->prog ) ); 364 map.insert( Progress, QString::number( data->prog ) );
373// map.insert( CrossReference, crossToString() ); 365// map.insert( CrossReference, crossToString() );
374 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); 366 /* FIXME!!! map.insert( State, );
375 map.insert( AlarmDateTime, data->alarmDateTime.toString() ); 367 map.insert( Recurrence, );
376 368 map.insert( Reminders, );
369 map.
370 */
377 return map; 371 return map;
378} 372}
379 373
380QMap<QString, QString> OTodo::toExtraMap()const { 374QMap<QString, QString> OTodo::toExtraMap()const {
381 return data->extra; 375 return data->extra;
382} 376}
383/** 377/**
384 * change or modify looks at the ref count and either 378 * change or modify looks at the ref count and either
@@ -403,21 +397,25 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) {
403 dest->date = src->date; 397 dest->date = src->date;
404 dest->isCompleted = src->isCompleted; 398 dest->isCompleted = src->isCompleted;
405 dest->hasDate = src->hasDate; 399 dest->hasDate = src->hasDate;
406 dest->priority = src->priority; 400 dest->priority = src->priority;
407 dest->desc = src->desc; 401 dest->desc = src->desc;
408 dest->sum = src->sum; 402 dest->sum = src->sum;
409 dest->extra = src->extra; 403 dest->extra = src->extra;
410 dest->prog = src->prog; 404 dest->prog = src->prog;
411 dest->hasAlarmDateTime = src->hasAlarmDateTime;
412 dest->alarmDateTime = src->alarmDateTime;
413 dest->state = src->state; 405 dest->state = src->state;
414 dest->recur = src->recur; 406 dest->recur = src->recur;
415 dest->maintainer = src->maintainer; 407 dest->maintainer = src->maintainer;
408 dest->start = src->start;
409 dest->completed = src->completed;
410 dest->notifiers = src->notifiers;
416} 411}
417QString OTodo::type() const { 412QString OTodo::type() const {
418 return QString::fromLatin1("OTodo"); 413 return QString::fromLatin1("OTodo");
419} 414}
420QString OTodo::recordField(int /*id*/ )const { 415QString OTodo::recordField(int /*id*/ )const {
421 return QString::null; 416 return QString::null;
422} 417}
423 418
419int OTodo::rtti(){
420 return 1;
421}
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h
index 70b0253..2f66f55 100644
--- a/libopie2/opiepim/otodo.h
+++ b/libopie2/opiepim/otodo.h
@@ -14,39 +14,41 @@
14#include <qpe/palmtopuidgen.h> 14#include <qpe/palmtopuidgen.h>
15 15
16#include <opie/opimrecord.h> 16#include <opie/opimrecord.h>
17 17
18 18
19class OPimState; 19class OPimState;
20class ORecur; 20class ORecur;
21class OPimMaintainer; 21class OPimMaintainer;
22class OPimNotifyManager;
22class OTodo : public OPimRecord { 23class OTodo : public OPimRecord {
23public: 24public:
24 typedef QValueList<OTodo> ValueList; 25 typedef QValueList<OTodo> ValueList;
25 enum RecordFields { 26 enum RecordFields {
26 Uid = Qtopia::UID_ID, 27 Uid = Qtopia::UID_ID,
27 Category = Qtopia::CATEGORY_ID, 28 Category = Qtopia::CATEGORY_ID,
28 HasDate, 29 HasDate,
29 Completed, 30 Completed,
30 Description, 31 Description,
31 Summary, 32 Summary,
32 Priority, 33 Priority,
33 DateDay, 34 DateDay,
34 DateMonth, 35 DateMonth,
35 DateYear, 36 DateYear,
36 Progress, 37 Progress,
37 CrossReference, 38 CrossReference,
38 HasAlarmDateTime,
39 AlarmDateTime,
40 State, 39 State,
41 Recurrance, 40 Recurrence,
42 Alarms, 41 Alarms,
43 Reminders, 42 Reminders,
44 Notifiers 43 Notifiers,
44 Maintainer,
45 StartDate,
46 CompletedDate
45 }; 47 };
46 public: 48 public:
47 // priorities from Very low to very high 49 // priorities from Very low to very high
48 enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; 50 enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow };
49 51
50 /* Constructs a new ToDoEvent 52 /* Constructs a new ToDoEvent
51 @param completed Is the TodoEvent completed 53 @param completed Is the TodoEvent completed
52 @param priority What is the priority of this ToDoEvent 54 @param priority What is the priority of this ToDoEvent
@@ -68,35 +70,37 @@ public:
68 OTodo( bool completed, int priority, 70 OTodo( bool completed, int priority,
69 const QArray<int>& category, 71 const QArray<int>& category,
70 const QString& summary = QString::null, 72 const QString& summary = QString::null,
71 const QString& description = QString::null, 73 const QString& description = QString::null,
72 ushort progress = 0, 74 ushort progress = 0,
73 bool hasDate = false, QDate date = QDate::currentDate(), 75 bool hasDate = false, QDate date = QDate::currentDate(),
74 int uid = 0 /* empty */ ); 76 int uid = 0 /* empty */ );
75 77
76 /* Copy c'tor 78 /** Copy c'tor
77 79 *
78 **/ 80 */
79 OTodo(const OTodo & ); 81 OTodo(const OTodo & );
80 82
81 /** 83 /**
82 *destructor 84 *destructor
83 */ 85 */
84 ~OTodo(); 86 ~OTodo();
85 87
86 /** 88 /**
87 * Is this event completed? 89 * Is this event completed?
88 */ 90 */
89 bool isCompleted() const; 91 bool isCompleted() const;
90 92
91 /** 93 /**
92 * Does this Event have a deadline 94 * Does this Event have a deadline
93 */ 95 */
94 bool hasDueDate() const; 96 bool hasDueDate() const;
97 bool hasStartDate()const;
98 bool hasCompletedDate()const;
95 99
96 /** 100 /**
97 * Does this Event has an alarm time ? 101 * Does this Event has an alarm time ?
98 */ 102 */
99 bool hasAlarmDateTime() const; 103 bool hasAlarmDateTime() const;
100 104
101 /** 105 /**
102 * What is the priority? 106 * What is the priority?
@@ -109,19 +113,24 @@ public:
109 ushort progress() const; 113 ushort progress() const;
110 114
111 /** 115 /**
112 * The due Date 116 * The due Date
113 */ 117 */
114 QDate dueDate()const; 118 QDate dueDate()const;
115 119
116 /** 120 /**
117 * Alarm Date and Time 121 * When did it start?
122 */
123 QDate startDate()const;
124
125 /**
126 * When was it completed?
118 */ 127 */
119 QDateTime alarmDateTime()const; 128 QDate completedDate()const;
120 129
121 /** 130 /**
122 * What is the state of this OTodo? 131 * What is the state of this OTodo?
123 */ 132 */
124 OPimState state()const; 133 OPimState state()const;
125 134
126 /** 135 /**
127 * the recurrance of this 136 * the recurrance of this
@@ -144,18 +153,26 @@ public:
144 QString summary() const; 153 QString summary() const;
145 154
146 /** 155 /**
147 * @reimplemented 156 * @reimplemented
148 * Return this todoevent in a RichText formatted QString 157 * Return this todoevent in a RichText formatted QString
149 */ 158 */
150 QString toRichText() const; 159 QString toRichText() const;
151 160
161 /*
162 * check if the sharing is still fine!! -zecke
163 */
164 /**
165 * return a reference to our notifiers...
166 */
167 OPimNotifyManager &notifiers();
168
152 /** 169 /**
153 * reimplementation 170 * reimplementations
154 */ 171 */
155 QString type()const; 172 QString type()const;
156 QString toShortText()const; 173 QString toShortText()const;
157 QMap<QString, QString> toExtraMap()const; 174 QMap<QString, QString> toExtraMap()const;
158 QString recordField(int id )const; 175 QString recordField(int id )const;
159 176
160 /** 177 /**
161 * toMap puts all data into the map. int relates 178 * toMap puts all data into the map. int relates
@@ -167,37 +184,45 @@ public:
167 * Set if this Todo is completed 184 * Set if this Todo is completed
168 */ 185 */
169 void setCompleted(bool completed ); 186 void setCompleted(bool completed );
170 187
171 /** 188 /**
172 * set if this todo got an end data 189 * set if this todo got an end data
173 */ 190 */
174 void setHasDueDate( bool hasDate ); 191 void setHasDueDate( bool hasDate );
175 192 // FIXME we do not have these for start, completed
176 /** 193 // cause we'll use the isNull() of QDate for figuring
177 * set if this todo has an alarm time and date 194 // out if it's has a date...
178 */ 195 // decide what to do here? -zecke
179 void setHasAlarmDateTime ( bool hasAlarm );
180 196
181 /** 197 /**
182 * Set the priority of the Todo 198 * Set the priority of the Todo
183 */ 199 */
184 void setPriority(int priority ); 200 void setPriority(int priority );
185 201
186 /** 202 /**
187 * Set the progress. 203 * Set the progress.
188 */ 204 */
189 void setProgress( ushort progress ); 205 void setProgress( ushort progress );
190 206
191 /** 207 /**
192 * set the end date 208 * set the end date
193 */ 209 */
194 void setDueDate( QDate date ); 210 void setDueDate( const QDate& date );
195 211
212 /**
213 * set the start date
214 */
215 void setStartDate( const QDate& date );
216
217 /**
218 * set the completed date
219 */
220 void setCompletedDate( const QDate& date );
196 221
197 void setRecurrence( const ORecur& ); 222 void setRecurrence( const ORecur& );
198 /** 223 /**
199 * set the alarm time 224 * set the alarm time
200 */ 225 */
201 void setAlarmDateTime ( const QDateTime& alarm ); 226 void setAlarmDateTime ( const QDateTime& alarm );
202 227
203 void setDescription(const QString& ); 228 void setDescription(const QString& );
@@ -222,16 +247,18 @@ public:
222 bool operator<(const OTodo &toDoEvent )const; 247 bool operator<(const OTodo &toDoEvent )const;
223 bool operator<=(const OTodo &toDoEvent )const; 248 bool operator<=(const OTodo &toDoEvent )const;
224 bool operator!=(const OTodo &toDoEvent )const; 249 bool operator!=(const OTodo &toDoEvent )const;
225 bool operator>(const OTodo &toDoEvent )const; 250 bool operator>(const OTodo &toDoEvent )const;
226 bool operator>=(const OTodo &toDoEvent)const; 251 bool operator>=(const OTodo &toDoEvent)const;
227 bool operator==(const OTodo &toDoEvent )const; 252 bool operator==(const OTodo &toDoEvent )const;
228 OTodo &operator=(const OTodo &toDoEvent ); 253 OTodo &operator=(const OTodo &toDoEvent );
229 254
255 static int rtti();
256
230 private: 257 private:
231 class OTodoPrivate; 258 class OTodoPrivate;
232 struct OTodoData; 259 struct OTodoData;
233 260
234 void deref(); 261 void deref();
235 inline void changeOrModify(); 262 inline void changeOrModify();
236 void copy( OTodoData* src, OTodoData* dest ); 263 void copy( OTodoData* src, OTodoData* dest );
237 OTodoPrivate *d; 264 OTodoPrivate *d;
diff --git a/libopie2/opiepim/ui/opimmainwindow.cpp b/libopie2/opiepim/ui/opimmainwindow.cpp
new file mode 100644
index 0000000..92be2fd
--- a/dev/null
+++ b/libopie2/opiepim/ui/opimmainwindow.cpp
@@ -0,0 +1,71 @@
1#include <qapplication.h>
2#include <qcopchannel_qws.h>
3
4#include <qpe/qcopenvelope_qws.h>
5
6#include "opimmainwindow.h"
7
8OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent,
9 const char* name, WFlags flag )
10 : QMainWindow( parent, name, flag ), m_service( service ), m_fallBack(0l) {
11
12 /*
13 * let's generate our QCopChannel
14 */
15 m_str = QString("QPE/"+m_service).local8Bit();
16 m_channel= new QCopChannel(m_str, this );
17 connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ),
18 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) );
19
20 /* connect flush and reload */
21 connect(qApp, SIGNAL(flush() ),
22 this, SLOT(flush() ) );
23 connect(qApp, SIGNAL(reload() ),
24 this, SLOT(reload() ) );
25}
26OPimMainWindow::~OPimMainWindow() {
27 delete m_channel;
28}
29QCopChannel* OPimMainWindow::channel() {
30 return m_channel;
31}
32void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) {
33 /*
34 * create demands to create
35 * a new record...
36 */
37 QDataStream stream(array, IO_ReadOnly);
38 if ( cmd == "create()" ) {
39 int uid = create();
40 QCopEnvelope e(m_str, "created(int)" );
41 e << uid;
42 }else if ( cmd == "remove(int)" ) {
43 int uid;
44 stream >> uid;
45 bool rem = remove( uid );
46 QCopEnvelope e(m_str, "removed(bool)" );
47 e << rem;
48 }else if ( cmd == "beam(int,int)" ) {
49 int uid, trans;
50 stream >> uid;
51 stream >> trans;
52 beam( uid, trans );
53 }else if ( cmd == "show(int)" ) {
54 int uid;
55 stream >> uid;
56 show( uid );
57 }else if ( cmd == "edit(int)" ) {
58 int uid;
59 stream >> uid;
60 edit( uid );
61 }else if ( cmd == "add(int,QByteArray)" ) {
62 int rtti;
63 QByteArray array;
64 stream >> rtti;
65 stream >> array;
66 m_fallBack = record(rtti, array );
67 if (!m_fallBack) return;
68 add( *m_fallBack );
69 delete m_fallBack;
70 }
71}
diff --git a/libopie2/opiepim/ui/opimmainwindow.h b/libopie2/opiepim/ui/opimmainwindow.h
new file mode 100644
index 0000000..94100bd
--- a/dev/null
+++ b/libopie2/opiepim/ui/opimmainwindow.h
@@ -0,0 +1,79 @@
1#ifndef OPIE_PIM_MAINWINDOW_H
2#define OPIE_PIM_MAINWINDOW_H
3
4#include <qmainwindow.h>
5
6#include <opie/opimrecord.h>
7
8/**
9 * This is a common Opie PIM MainWindow
10 * it takes care of the QCOP internals
11 * and implements some functions
12 * for the URL scripting schema
13 */
14/*
15 * due Qt and Templates with signal and slots
16 * do not work that good :(
17 * (Ok how to moc a template ;) )
18 * We will have the mainwindow which calls a struct which
19 * is normally reimplemented as a template ;)
20 */
21
22class QCopChannel;
23class OPimMainWindow : public QMainWindow {
24 Q_OBJECT
25public:
26 enum TransPort { BlueTooth=0,
27 IrDa };
28
29 OPimMainWindow( const QString& service, QWidget *parent = 0, const char* name = 0,
30 WFlags f = WType_TopLevel);
31 virtual ~OPimMainWindow();
32
33
34protected slots:
35 /* for syncing */
36 virtual void flush() = 0;
37 virtual void reload() = 0;
38
39 /** create a new Records and return the uid */
40 virtual int create() = 0;
41 /** remove a record with UID == uid */
42 virtual bool remove( int uid ) = 0;
43 /** beam the record with UID = uid */
44 virtual void beam( int uid , int transport = IrDa) = 0;
45
46 /** show the record with UID == uid */
47 virtual void show( int uid ) = 0;
48 /** edit the record */
49 virtual void edit( int uid ) = 0;
50
51 /** make a copy of it! */
52 virtual void add( const OPimRecord& ) = 0;
53
54 /* I would love to do this as a template
55 * but can't think of a right way
56 * because I need signal and slots -zecke
57 */
58 /*
59 * the only pointer in the whole PIM API :(
60 */
61 virtual OPimRecord* record( int rtti, const QByteArray& ) = 0;
62 QCopChannel* channel();
63
64private slots:
65 void appMessage( const QCString&, const QByteArray& );
66
67
68private:
69 class Private;
70 Private* d;
71
72 QCopChannel* m_channel;
73 QString m_service;
74 QCString m_str;
75 OPimRecord* m_fallBack;
76};
77
78
79#endif