summaryrefslogtreecommitdiff
authorzecke <zecke>2002-11-30 11:28:47 (UTC)
committer zecke <zecke>2002-11-30 11:28:47 (UTC)
commit9b8b30fa6cbdf1424b29cde21fae112e8bf96e6d (patch) (side-by-side diff)
tree896dd858dc2ec2f0b7e1b265cae66ccceecc82da
parent599c58c6ab2ab936890cbbfa4e6299493c141f8a (diff)
downloadopie-9b8b30fa6cbdf1424b29cde21fae112e8bf96e6d.zip
opie-9b8b30fa6cbdf1424b29cde21fae112e8bf96e6d.tar.gz
opie-9b8b30fa6cbdf1424b29cde21fae112e8bf96e6d.tar.bz2
More infrastructure
ORecur has now the nextOccurence function exceptions We've now Notifers like Alarms and DatebookEntries we may add to execute applications... AppName replaced with service cause it is a service Add rtti to OPimRecord as a static function This is used inside the BackEnd classes to static_cast... added removeAllCompleted to the todobackends... add a common Opie PIM mainwindow which takes care of some simple scripting enchangements.. much more
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie/pim/ABSTRACT18
-rw-r--r--libopie/pim/ocontact.cpp4
-rw-r--r--libopie/pim/ocontact.h1
-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.cpp5
-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.cpp5
-rw-r--r--libopie2/opiepim/core/otodoaccess.h17
-rw-r--r--libopie2/opiepim/ocontact.cpp4
-rw-r--r--libopie2/opiepim/ocontact.h1
-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, 2428 insertions, 192 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 @@
+What is Opie PIM? Why is it special?
+Why do we need Opie PIM?
+
+The goal of OpiePIM is to be first of all
+extendable, light weight, scalable and fast.
+For the programmer we try to add a nice but
+powerful API to all classes.
+
+Memory is a costy resource on small and embedded
+devices. So we try to keep the memory usage as
+low as possible. Never the less we won't use structs
+and Pointers in the public API.
+The whole pim framework is value based. Internally we try
+to use implicit sharing as found in other Qt classes as well.
+This makes it possible to give 3rd party devels a nice
+API while keeping the memory usage as low as possible.
+
+We 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
@@ -1094,9 +1094,11 @@ void OContact::insertEmails( const QStringList &v )
{
for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
insertEmail( *it );
}
-
+int OContact::rtti() {
+ return 2;
+}
void OContact::setUid( int i )
{
OPimRecord::setUid(i);
replace( Qtopia::AddressUid , QString::number(i));
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
@@ -210,8 +210,9 @@ public:
QString emailSeparator() const { return " "; }
// the emails should be seperated by a comma
void setEmails( const QString &v );
QString emails() const { return find( Qtopia::Emails ); }
+ static int rtti();
private:
// The XML-Backend needs some access to the private functions
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
@@ -92,8 +92,9 @@ public:
* @param t The item to add.
* @return <i>true</i> if added successfully.
*/
virtual bool add( const T& t ) ;
+ bool add( const OPimRecord& );
/* only the uid matters */
/**
* remove T from the backend
@@ -211,8 +212,17 @@ bool OPimAccessTemplate<T>::add( const T& t ) {
cache( t );
return m_backEnd->add( t );
}
template <class T>
+bool OPimAccessTemplate<T>::add( const OPimRecord& rec) {
+ /* same type */
+ if ( rec.rtti() == T::rtti() ) {
+ const T &t = static_cast<const T&>(rec);
+ return add(t);
+ }
+ return false;
+}
+template <class T>
bool OPimAccessTemplate<T>::remove( const T& t ) {
return remove( t.uid() );
}
template <class T>
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,7 +1,7 @@
#include "opimmaintainer.h"
-OPimMaintainer::OPimMaintainer( enum Mode mode, int uid )
+OPimMaintainer::OPimMaintainer( int mode, int uid )
: m_mode(mode), m_uid(uid )
{}
OPimMaintainer::~OPimMaintainer() {
}
@@ -22,15 +22,15 @@ bool OPimMaintainer::operator==( const OPimMaintainer& main ) {
}
bool OPimMaintainer::operator!=( const OPimMaintainer& main ) {
return !(*this == main );
}
-OPimMaintainer::Mode OPimMaintainer::mode()const {
+int OPimMaintainer::mode()const {
return m_mode;
}
int OPimMaintainer::uid()const {
return m_uid;
}
-void OPimMaintainer::setMode( enum Mode mo) {
+void OPimMaintainer::setMode( int mo) {
m_mode = mo;
}
void OPimMaintainer::setUid( int uid ) {
m_uid = uid;
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
@@ -8,29 +8,33 @@
*/
class OPimMaintainer {
public:
enum Mode { Undefined = -1,
- Responsible = 0,
+ Nothing = 0,
+ Responsible,
DoneBy,
- Coordinating };
- OPimMaintainer( enum Mode mode = Undefined, int uid = 0);
+ Coordinating,
+ };
+ OPimMaintainer( int mode = Undefined, int uid = 0);
OPimMaintainer( const OPimMaintainer& );
~OPimMaintainer();
OPimMaintainer &operator=( const OPimMaintainer& );
bool operator==( const OPimMaintainer& );
bool operator!=( const OPimMaintainer& );
- Mode mode()const;
+ int mode()const;
int uid()const;
- void setMode( enum Mode );
+ void setMode( int mode );
void setUid( int uid );
private:
- Mode m_mode;
+ int m_mode;
int m_uid;
+ class Private;
+ Private *d;
};
#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 @@
+#include <qapplication.h>
+#include <qcopchannel_qws.h>
+
+#include <qpe/qcopenvelope_qws.h>
+
+#include "opimmainwindow.h"
+
+OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent,
+ const char* name, WFlags flag )
+ : QMainWindow( parent, name, flag ), m_service( service ), m_fallBack(0l) {
+
+ /*
+ * let's generate our QCopChannel
+ */
+ m_str = QString("QPE/"+m_service).local8Bit();
+ m_channel= new QCopChannel(m_str, this );
+ connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ),
+ this, SLOT( appMessage( const QCString&, const QByteArray& ) ) );
+
+ /* connect flush and reload */
+ connect(qApp, SIGNAL(flush() ),
+ this, SLOT(flush() ) );
+ connect(qApp, SIGNAL(reload() ),
+ this, SLOT(reload() ) );
+}
+OPimMainWindow::~OPimMainWindow() {
+ delete m_channel;
+}
+QCopChannel* OPimMainWindow::channel() {
+ return m_channel;
+}
+void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) {
+ /*
+ * create demands to create
+ * a new record...
+ */
+ QDataStream stream(array, IO_ReadOnly);
+ if ( cmd == "create()" ) {
+ int uid = create();
+ QCopEnvelope e(m_str, "created(int)" );
+ e << uid;
+ }else if ( cmd == "remove(int)" ) {
+ int uid;
+ stream >> uid;
+ bool rem = remove( uid );
+ QCopEnvelope e(m_str, "removed(bool)" );
+ e << rem;
+ }else if ( cmd == "beam(int,int)" ) {
+ int uid, trans;
+ stream >> uid;
+ stream >> trans;
+ beam( uid, trans );
+ }else if ( cmd == "show(int)" ) {
+ int uid;
+ stream >> uid;
+ show( uid );
+ }else if ( cmd == "edit(int)" ) {
+ int uid;
+ stream >> uid;
+ edit( uid );
+ }else if ( cmd == "add(int,QByteArray)" ) {
+ int rtti;
+ QByteArray array;
+ stream >> rtti;
+ stream >> array;
+ m_fallBack = record(rtti, array );
+ if (!m_fallBack) return;
+ add( *m_fallBack );
+ delete m_fallBack;
+ }
+}
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 @@
+#ifndef OPIE_PIM_MAINWINDOW_H
+#define OPIE_PIM_MAINWINDOW_H
+
+#include <qmainwindow.h>
+
+#include <opie/opimrecord.h>
+
+/**
+ * This is a common Opie PIM MainWindow
+ * it takes care of the QCOP internals
+ * and implements some functions
+ * for the URL scripting schema
+ */
+/*
+ * due Qt and Templates with signal and slots
+ * do not work that good :(
+ * (Ok how to moc a template ;) )
+ * We will have the mainwindow which calls a struct which
+ * is normally reimplemented as a template ;)
+ */
+
+class QCopChannel;
+class OPimMainWindow : public QMainWindow {
+ Q_OBJECT
+public:
+ enum TransPort { BlueTooth=0,
+ IrDa };
+
+ OPimMainWindow( const QString& service, QWidget *parent = 0, const char* name = 0,
+ WFlags f = WType_TopLevel);
+ virtual ~OPimMainWindow();
+
+
+protected slots:
+ /* for syncing */
+ virtual void flush() = 0;
+ virtual void reload() = 0;
+
+ /** create a new Records and return the uid */
+ virtual int create() = 0;
+ /** remove a record with UID == uid */
+ virtual bool remove( int uid ) = 0;
+ /** beam the record with UID = uid */
+ virtual void beam( int uid , int transport = IrDa) = 0;
+
+ /** show the record with UID == uid */
+ virtual void show( int uid ) = 0;
+ /** edit the record */
+ virtual void edit( int uid ) = 0;
+
+ /** make a copy of it! */
+ virtual void add( const OPimRecord& ) = 0;
+
+ /* I would love to do this as a template
+ * but can't think of a right way
+ * because I need signal and slots -zecke
+ */
+ /*
+ * the only pointer in the whole PIM API :(
+ */
+ virtual OPimRecord* record( int rtti, const QByteArray& ) = 0;
+ QCopChannel* channel();
+
+private slots:
+ void appMessage( const QCString&, const QByteArray& );
+
+
+private:
+ class Private;
+ Private* d;
+
+ QCopChannel* m_channel;
+ QString m_service;
+ QCString m_str;
+ OPimRecord* m_fallBack;
+};
+
+
+#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 @@
+#include <qshared.h>
+
+#include "opimnotify.h"
+
+struct OPimNotify::Data : public QShared {
+ Data() : QShared(),dur(-1),parent(0) {
+
+ }
+ QDateTime start;
+ int dur;
+ QString application;
+ int parent;
+};
+
+OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) {
+ data = new Data;
+ data->start = start;
+ data->dur = duration;
+ data->parent = parent;
+}
+OPimNotify::OPimNotify( const OPimNotify& noti)
+ : data( noti.data )
+{
+ data->ref();
+}
+OPimNotify::~OPimNotify() {
+ if ( data->deref() ) {
+ delete data;
+ data = 0l;
+ }
+}
+
+OPimNotify &OPimNotify::operator=( const OPimNotify& noti) {
+ noti.data->ref();
+ deref();
+ data = noti.data;
+
+ return *this;
+}
+bool OPimNotify::operator==( const OPimNotify& noti ) {
+ if ( data == noti.data ) return true;
+ if ( data->dur != noti.data->dur ) return false;
+ if ( data->parent != noti.data->parent ) return false;
+ if ( data->application != noti.data->application ) return false;
+ if ( data->start != noti.data->start ) return false;
+
+ return true;
+}
+QDateTime OPimNotify::dateTime()const {
+ return data->start;
+}
+QString OPimNotify::service()const {
+ return data->application;
+}
+int OPimNotify::parent()const {
+ return data->parent;
+}
+int OPimNotify::duration()const {
+ return data->dur;
+}
+QDateTime OPimNotify::endTime()const {
+ return QDateTime( data->start.date(), data->start.time().addSecs( data->dur) );
+}
+void OPimNotify::setDateTime( const QDateTime& time ) {
+ copyIntern();
+ data->start = time;
+}
+void OPimNotify::setDuration( int dur ) {
+ copyIntern();
+ data->dur = dur;
+}
+void OPimNotify::setParent( int uid ) {
+ copyIntern();
+ data->parent = uid;
+}
+void OPimNotify::setService( const QString& str ) {
+ copyIntern();
+ data->application = str;
+}
+void OPimNotify::copyIntern() {
+ if ( data->count != 1 ) {
+ data->deref();
+ Data* dat = new Data;
+ dat->start = data->start;
+ dat->dur = data->dur;
+ dat->application = data->application;
+ dat->parent = data->parent;
+ data = dat;
+ }
+}
+void OPimNotify::deref() {
+ if ( data->deref() ) {
+ delete data;
+ data = 0;
+ }
+}
+
+/***********************************************************/
+struct OPimAlarm::Data : public QShared {
+ Data() : QShared() {
+ sound = 1;
+ }
+ int sound;
+ QString file;
+};
+OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int parent )
+ : OPimNotify( start, duration, parent )
+{
+ data = new Data;
+ data->sound = sound;
+}
+OPimAlarm::OPimAlarm( const OPimAlarm& al)
+ : OPimNotify(al), data( al.data )
+{
+ data->ref();
+}
+OPimAlarm::~OPimAlarm() {
+ if ( data->deref() ) {
+ delete data;
+ data = 0l;
+ }
+}
+OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al)
+{
+ OPimNotify::operator=( al );
+ deref();
+ al.data->ref();
+
+ data = al.data;
+
+
+ return *this;
+}
+bool OPimAlarm::operator==( const OPimAlarm& al) {
+ if ( data->sound != al.data->sound ) return false;
+ else if ( data->sound == Custom && data->file != al.data->file )
+ return false;
+
+ return OPimNotify::operator==( al );
+}
+QString OPimAlarm::type()const {
+ return QString::fromLatin1("OPimAlarm");
+}
+int OPimAlarm::sound()const {
+ return data->sound;
+}
+QString OPimAlarm::file()const {
+ return data->file;
+}
+void OPimAlarm::setSound( int snd) {
+ copyIntern();
+ data->sound = snd;
+}
+void OPimAlarm::setFile( const QString& sound ) {
+ copyIntern();
+ data->file = sound;
+}
+void OPimAlarm::deref() {
+ if ( data->deref() ) {
+ delete data;
+ data = 0l;
+ }
+}
+void OPimAlarm::copyIntern() {
+ if ( data->count != 1 ) {
+ data->deref();
+ Data *newDat = new Data;
+ newDat->sound = data->sound;
+ newDat->file = data->file;
+ data = newDat;
+ }
+}
+/************************/
+struct OPimReminder::Data : public QShared {
+ Data() : QShared(), record( 0) {
+ }
+ int record;
+
+};
+OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent )
+ : OPimNotify( start, dur, parent )
+{
+ data = new Data;
+ data->record = uid;
+}
+OPimReminder::OPimReminder( const OPimReminder& rem )
+ : OPimNotify( rem ), data( rem.data )
+{
+ data->ref();
+}
+OPimReminder& OPimReminder::operator=( const OPimReminder& rem) {
+ OPimNotify::operator=(rem );
+
+ deref();
+ rem.data->ref();
+ data = rem.data;
+
+ return *this;
+}
+bool OPimReminder::operator==( const OPimReminder& rem) {
+ if ( data->record != rem.data->record ) return false;
+
+ return OPimNotify::operator==( rem );
+}
+QString OPimReminder::type()const {
+ return QString::fromLatin1("OPimReminder");
+}
+int OPimReminder::recordUid()const {
+ return data->record;
+}
+void OPimReminder::setRecordUid( int uid ) {
+ copyIntern();
+ data->record = uid;
+}
+void OPimReminder::deref() {
+ if ( data->deref() ) {
+ delete data;
+ data = 0l;
+ }
+}
+void OPimReminder::copyIntern() {
+ if ( data->count != 1 ) {
+ Data* da = new Data;
+ da->record = data->record;
+ data = da;
+ }
+}
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 @@
+#ifndef OPIE_PIM_NOTIFY_H
+#define OPIE_PIM_NOTIFY_H
+
+#include <qdatetime.h>
+#include <qvaluelist.h>
+
+/**
+ * This is the base class of Notifiers. Possible
+ * notifiers would be Alarms, Reminders
+ * What they share is that they have
+ * A DateTime, Type, Duration
+ * This is what this base class takes care of
+ * on top of that it's shared
+ */
+/*
+ * TALK to eilers: have a class OPimDuration which sets the Duration
+ * given on the Due/Start Date? -zecke
+ * discuss: do we need a uid for the notify? -zecke
+ */
+class OPimNotify {
+public:
+ typedef QValueList<OPimNotify> ValueList;
+ OPimNotify( const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 );
+ OPimNotify( const OPimNotify& );
+ virtual ~OPimNotify();
+
+ OPimNotify &operator=(const OPimNotify& );
+ bool operator==( const OPimNotify& );
+
+ virtual QString type()const = 0;
+
+ /** start date */
+ QDateTime dateTime()const;
+ QString service()const;
+
+ /**
+ * RETURN the parent uid
+ */
+ int parent()const;
+
+ /**
+ * in Seconds
+ */
+ int duration()const;
+
+ /**
+ * Start Time + Duration
+ */
+ QDateTime endTime()const;
+
+ void setDateTime( const QDateTime& );
+ void setDuration( int dur );
+ void setParent(int uid );
+ void setService( const QString& );
+
+
+private:
+ inline void copyIntern();
+ void deref();
+ struct Data;
+ Data* data;
+
+ /* d-pointer */
+ class NotifyPrivate;
+ NotifyPrivate* d;
+
+};
+/**
+ * An alarm is a sound/mail/buzzer played/send
+ * at a given time to inform about
+ * an Event
+ */
+class OPimAlarm : public OPimNotify {
+public:
+ enum Sound{Loud=0, Silent, Custom };
+ OPimAlarm( int sound = Silent, const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 );
+ OPimAlarm( const OPimAlarm& );
+ ~OPimAlarm();
+
+ OPimAlarm &operator=( const OPimAlarm& );
+ bool operator==( const OPimAlarm& );
+ QString type()const;
+
+ int sound()const;
+ QString file()const;
+
+ void setSound( int );
+ /* only when sound is custom... */
+ void setFile( const QString& sound );
+
+private:
+ void deref();
+ void copyIntern();
+ struct Data;
+ Data * data;
+
+ class Private;
+ Private* d;
+
+};
+
+/**
+ * A Reminder will be put into the
+ * datebook
+ */
+class OPimReminder : public OPimNotify {
+public:
+
+ /**
+ * c'tor of a reminder
+ * @param uid The uid of the Record inside the Datebook
+ * @param start the StartDate invalid for all day...
+ * @param duration The duration of the event ( -1 for all day )
+ * @param parent The 'parent' record of this reminder
+ */
+ OPimReminder( int uid = 0, const QDateTime& start = QDateTime(),
+ int duration = 0, int parent = 0 );
+ OPimReminder( const OPimReminder& );
+ OPimReminder &operator=(const OPimReminder& );
+
+ QString type()const;
+
+ bool operator==( const OPimReminder& );
+
+ /**
+ * the uid of the alarm
+ * inside the 'datebook' application
+ */
+ int recordUid()const;
+ void setRecordUid( int uid );
+
+private:
+ void deref();
+ void copyIntern();
+
+ struct Data;
+ Data* data;
+ class Private;
+ Private *d;
+};
+
+#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 @@
+#include "opimnotifymanager.h"
+
+OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al)
+ : m_rem( rem ), m_al( al )
+{}
+OPimNotifyManager::~OPimNotifyManager() {
+}
+/* use static_cast and type instead of dynamic... */
+void OPimNotifyManager::add( const OPimNotify& noti) {
+ if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
+ const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
+ m_rem.append( rem );
+ }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
+ const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
+ m_al.append( al );
+ }
+}
+void OPimNotifyManager::remove( const OPimNotify& noti) {
+ if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
+ const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
+ m_rem.remove( rem );
+ }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
+ const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
+ m_al.remove( al );
+ }
+}
+void OPimNotifyManager::replace( const OPimNotify& noti) {
+ if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
+ const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
+ m_rem.remove( rem );
+ m_rem.append( rem );
+ }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
+ const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
+ m_al.remove( al );
+ m_al.append( al );
+ }
+}
+OPimNotifyManager::Reminders OPimNotifyManager::reminders()const {
+ return m_rem;
+}
+OPimNotifyManager::Alarms OPimNotifyManager::alarms()const {
+ return m_al;
+}
+void OPimNotifyManager::setAlarms( const Alarms& al) {
+ m_al = al;
+}
+void OPimNotifyManager::setReminders( const Reminders& rem) {
+ m_rem = rem;
+}
+/* FIXME!!! */
+/**
+ * The idea is to check if the provider for our service
+ * is online
+ * if it is we will use QCOP
+ * if not the Factory to get the backend...
+ * Qtopia1.6 services would be kewl to have here....
+ */
+void OPimNotifyManager::registerNotify( const OPimNotify& ) {
+
+}
+/* FIXME!!! */
+/**
+ * same as above...
+ * Also implement Url model
+ * have a MainWindow....
+ */
+void OPimNotifyManager::deregister( const OPimNotify& ) {
+
+}
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 @@
+#ifndef OPIE_PIM_NOTIFY_MANAGER_H
+#define OPIE_PIM_NOTIFY_MANAGER_H
+
+#include <qvaluelist.h>
+
+#include <opie/opimnotify.h>
+
+/**
+ * The notify manager keeps track of the Notifiers....
+ */
+class OPimNotifyManager {
+public:
+ typedef QValueList<OPimReminder> Reminders;
+ typedef QValueList<OPimAlarm> Alarms;
+ OPimNotifyManager( const Reminders& rems = Reminders(), const Alarms& alarms = Alarms() );
+ ~OPimNotifyManager();
+
+ /* we will cast it for you ;) */
+ void add( const OPimNotify& );
+ void remove( const OPimNotify& );
+ /* replaces all with this one! */
+ void replace( const OPimNotify& );
+
+ Reminders reminders()const;
+ Alarms alarms()const;
+
+ void setAlarms( const Alarms& );
+ void setReminders( const Reminders& );
+
+ /* register is a Ansi C keyword... */
+ /**
+ * This function will register the Notify to the Alarm Server
+ * or datebook depending on the type of the notify
+ */
+ void registerNotify( const OPimNotify& );
+
+ /**
+ * this will do the opposite..
+ */
+ void deregister( const OPimNotify& );
+
+private:
+ Reminders m_rem;
+ Alarms m_al;
+
+ class Private;
+ Private *d;
+
+};
+
+#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
@@ -78,4 +78,7 @@ Qtopia::UidGen &OPimRecord::uidGen() {
}
OPimXRefManager &OPimRecord::xrefmanager() {
return m_xrefman;
}
+int OPimRecord::rtti(){
+ return 0;
+}
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
@@ -88,18 +88,24 @@ public:
/**
* returns a reference of the
* Cross Reference Manager
- * Partner One is THIS PIM RECORD!
- * Two is the Partner where we link to
+ * Partner 'One' is THIS PIM RECORD!
+ * 'Two' is the Partner where we link to
*/
OPimXRefManager& xrefmanager();
/**
* set the uid
*/
virtual void setUid( int uid );
+ /*
+ * used inside the Templates for casting
+ * REIMPLEMENT in your ....
+ */
+ static int rtti();
+
protected:
Qtopia::UidGen &uidGen();
// QString crossToString()const;
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 @@
+#ifndef OPIE_PIM_RESOLVER
+#define OPIE_PIM_RESOLVER
+
+#include <qstring.h>
+#include <qvaluelist.h>
+
+/**
+ * OPimResolver is a MetaClass to access
+ * available backends read only.
+ * It will be used to resolve uids + app names
+ * to full informations
+ * to traverse through a list of alarms, reminders
+ * to get access to built in PIM functionality
+ * and to more stuff
+ * THE PERFORMANCE will depend on THE BACKEND
+ * USING XML is a waste of memory!!!!!
+ */
+class OPimResolver : public QObject {
+public:
+ enum BuiltIn { TodoList = 0,
+ DateBook,
+ AddressBook
+ };
+ static OPimResolver* self();
+
+
+ /*
+ * return a record for a uid
+ * and an app
+ */
+ OPimRecord &record( const QString& service, int uid );
+
+ /**
+ * return the QCopChannel for service
+ * When we will use Qtopia Services it will be used here
+ */
+ QString qcopChannel( enum BuiltIn& )const;
+ QString qcopChannel( const QString& service );
+
+ /**
+ * return a list of available services
+ */
+ QStringList services()const;
+
+ /**
+ * add a record to a service... ;)
+ */
+ bool add( const QString& service, const OPimRecord& );
+
+private:
+ OPimResolver();
+ OPimRecord *m_last;
+
+}:
+
+#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
@@ -33,10 +33,10 @@ OPimXRefPartner OPimXRef::partner( enum Partners par) const{
void OPimXRef::setPartner( enum Partners par, const OPimXRefPartner& part) {
m_partners[par] = part;
}
bool OPimXRef::containsString( const QString& string ) const{
- if ( m_partners[One].appName() == string ||
- m_partners[Two].appName() == string ) return true;
+ if ( m_partners[One].service() == string ||
+ m_partners[Two].service() == string ) return true;
return false;
}
bool OPimXRef::containsUid( int uid ) const{
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
@@ -25,9 +25,9 @@ public:
OPimXRefPartner partner( enum Partners )const;
void setPartner( enum Partners, const OPimXRefPartner& );
- bool containsString( const QString& appName)const;
+ bool containsString( const QString& service)const;
bool containsUid( int uid )const;
private:
QArray<OPimXRefPartner> m_partners;
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
@@ -35,12 +35,12 @@ QStringList OPimXRefManager::apps()const {
QStringList list;
QString str;
for ( it = m_list.begin(); it != m_list.end(); ++it ) {
- str = (*it).partner( OPimXRef::One ).appName();
+ str = (*it).partner( OPimXRef::One ).service();
if ( !list.contains( str ) ) list << str;
- str = (*it).partner( OPimXRef::Two ).appName();
+ str = (*it).partner( OPimXRef::Two ).service();
if ( !list.contains( str ) ) list << str;
}
return list;
}
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
@@ -30,9 +30,9 @@ public:
* apps participating
*/
QStringList apps()const;
OPimXRef::ValueList list()const;
- OPimXRef::ValueList list( const QString& appName )const;
+ OPimXRef::ValueList list( const QString& service )const;
OPimXRef::ValueList list( int uid )const;
private:
OPimXRef::ValueList m_list;
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
@@ -22,18 +22,18 @@ bool OPimXRefPartner::operator==( const OPimXRefPartner& par ) {
if ( m_field != par.m_field ) return false;
return true;
}
-QString OPimXRefPartner::appName()const {
+QString OPimXRefPartner::service()const {
return m_app;
}
int OPimXRefPartner::uid()const {
return m_uid;
}
int OPimXRefPartner::field()const {
return m_field;
}
-void OPimXRefPartner::setAppName( const QString& appName ) {
+void OPimXRefPartner::setService( const QString& appName ) {
m_app = appName;
}
void OPimXRefPartner::setUid( int uid ) {
m_uid = uid;
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
@@ -11,21 +11,21 @@
* with one tableId( fieldId ) to another.
*/
class OPimXRefPartner {
public:
- OPimXRefPartner( const QString& appName = QString::null,
+ OPimXRefPartner( const QString& service = QString::null,
int uid = 0, int field = -1 );
OPimXRefPartner( const OPimXRefPartner& );
OPimXRefPartner& operator=( const OPimXRefPartner& );
~OPimXRefPartner();
bool operator==(const OPimXRefPartner& );
- QString appName()const;
+ QString service()const;
int uid()const;
int field()const;
- void setAppName( const QString& appName );
+ void setService( const QString& service );
void setUid( int uid );
void setField( int field );
private:
QString m_app;
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
@@ -21,8 +21,11 @@ struct ORecur::Data : public QShared {
bool hasEnd : 1;
time_t end;
time_t create;
int rep;
+ QString app;
+ ExceptionList list;
+ QDate start;
};
ORecur::ORecur() {
@@ -54,8 +57,300 @@ ORecur &ORecur::operator=( const ORecur& re) {
data = re.data;
return *this;
}
+bool ORecur::doesRecur()const {
+ return !( type() == NoRepeat );
+}
+/*
+ * we try to be smart here
+ *
+ */
+bool ORecur::doesRecur( const QDate& date ) {
+ /* the day before the recurrance */
+ QDate da = date.addDays(-1);
+
+ QDate recur;
+ if (!nextOcurrence( da, recur ) )
+ return false;
+
+ return (recur == date);
+}
+// FIXME unuglify!
+// GPL from Datebookdb.cpp
+// FIXME exception list!
+bool ORecur::nextOcurrence( const QDate& from, QDate& next ) {
+
+ // easy checks, first are we too far in the future or too far in the past?
+ QDate tmpDate;
+ int freq = frequency();
+ int diff, diff2, a;
+ int iday, imonth, iyear;
+ int dayOfWeek = 0;
+ int firstOfWeek = 0;
+ int weekOfMonth;
+
+
+ if (hasEndDate() && endDate() < from)
+ return FALSE;
+
+ if (start() >= from) {
+ next = start();
+ return TRUE;
+ }
+
+ switch ( type() ) {
+ case Weekly:
+ /* weekly is just daily by 7 */
+ /* first convert the repeatPattern.Days() mask to the next
+ day of week valid after from */
+ dayOfWeek = from.dayOfWeek();
+ dayOfWeek--; /* we want 0-6, doco for above specs 1-7 */
+
+ /* this is done in case freq > 1 and from in week not
+ for this round */
+ // firstOfWeek = 0; this is already done at decl.
+ while(!((1 << firstOfWeek) & days() ))
+ firstOfWeek++;
+
+ /* there is at least one 'day', or there would be no event */
+ while(!((1 << (dayOfWeek % 7)) & days() ))
+ dayOfWeek++;
+
+ dayOfWeek = dayOfWeek % 7; /* the actual day of week */
+ dayOfWeek -= start().dayOfWeek() -1;
+
+ firstOfWeek = firstOfWeek % 7; /* the actual first of week */
+ firstOfWeek -= start().dayOfWeek() -1;
+
+ // dayOfWeek may be negitive now
+ // day of week is number of days to add to start day
+
+ freq *= 7;
+ // FALL-THROUGH !!!!!
+ case Daily:
+ // the add is for the possible fall through from weekly */
+ if(start().addDays(dayOfWeek) > from) {
+ /* first week exception */
+ next = QDate(start().addDays(dayOfWeek) );
+ if ((next > endDate())
+ && hasEndDate() )
+ return FALSE;
+ return TRUE;
+ }
+ /* if from is middle of a non-week */
+
+ diff = start().addDays(dayOfWeek).daysTo(from) % freq;
+ diff2 = start().addDays(firstOfWeek).daysTo(from) % freq;
+
+ if(diff != 0)
+ diff = freq - diff;
+ if(diff2 != 0)
+ diff2 = freq - diff2;
+ diff = QMIN(diff, diff2);
+
+ next = QDate(from.addDays(diff));
+ if ( (next > endDate())
+ && hasEndDate() )
+ return FALSE;
+ return TRUE;
+ case MonthlyDay:
+ iday = from.day();
+ iyear = from.year();
+ imonth = from.month();
+ /* find equivelent day of month for this month */
+ dayOfWeek = start().dayOfWeek();
+ weekOfMonth = (start().day() - 1) / 7;
+
+ /* work out when the next valid month is */
+ a = from.year() - start().year();
+ a *= 12;
+ a = a + (imonth - start().month());
+ /* a is e.start()monthsFrom(from); */
+ if(a % freq) {
+ a = freq - (a % freq);
+ imonth = from.month() + a;
+ if (imonth > 12) {
+ imonth--;
+ iyear += imonth / 12;
+ imonth = imonth % 12;
+ imonth++;
+ }
+ }
+ /* imonth is now the first month after or on
+ from that matches the frequency given */
+
+ /* find for this month */
+ tmpDate = QDate( iyear, imonth, 1 );
+
+ iday = 1;
+ iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7;
+ iday += 7 * weekOfMonth;
+ while (iday > tmpDate.daysInMonth()) {
+ imonth += freq;
+ if (imonth > 12) {
+ imonth--;
+ iyear += imonth / 12;
+ imonth = imonth % 12;
+ imonth++;
+ }
+ tmpDate = QDate( iyear, imonth, 1 );
+ /* these loops could go for a while, check end case now */
+ if ((tmpDate > endDate()) && hasEndDate() )
+ return FALSE;
+ iday = 1;
+ iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7;
+ iday += 7 * weekOfMonth;
+ }
+ tmpDate = QDate(iyear, imonth, iday);
+
+ if (tmpDate >= from) {
+ next = tmpDate;
+ if ((next > endDate() ) && hasEndDate() )
+ return FALSE;
+ return TRUE;
+ }
+
+ /* need to find the next iteration */
+ do {
+ imonth += freq;
+ if (imonth > 12) {
+ imonth--;
+ iyear += imonth / 12;
+ imonth = imonth % 12;
+ imonth++;
+ }
+ tmpDate = QDate( iyear, imonth, 1 );
+ /* these loops could go for a while, check end case now */
+ if ((tmpDate > endDate()) && hasEndDate() )
+ return FALSE;
+ iday = 1;
+ iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7;
+ iday += 7 * weekOfMonth;
+ } while (iday > tmpDate.daysInMonth());
+ tmpDate = QDate(iyear, imonth, iday);
+
+ next = tmpDate;
+ if ((next > endDate()) && hasEndDate() )
+ return FALSE;
+ return TRUE;
+ case MonthlyDate:
+ iday = start().day();
+ iyear = from.year();
+ imonth = from.month();
+
+ a = from.year() - start().year();
+ a *= 12;
+ a = a + (imonth - start().month());
+ /* a is e.start()monthsFrom(from); */
+ if(a % freq) {
+ a = freq - (a % freq);
+ imonth = from.month() + a;
+ if (imonth > 12) {
+ imonth--;
+ iyear += imonth / 12;
+ imonth = imonth % 12;
+ imonth++;
+ }
+ }
+ /* imonth is now the first month after or on
+ from that matches the frequencey given */
+
+ /* this could go for a while, worse case, 4*12 iterations, probably */
+ while(!QDate::isValid(iyear, imonth, iday) ) {
+ imonth += freq;
+ if (imonth > 12) {
+ imonth--;
+ iyear += imonth / 12;
+ imonth = imonth % 12;
+ imonth++;
+ }
+ /* these loops could go for a while, check end case now */
+ if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() )
+ return FALSE;
+ }
+
+ if(QDate(iyear, imonth, iday) >= from) {
+ /* done */
+ next = QDate(iyear, imonth, iday);
+ if ((next > endDate()) && hasEndDate() )
+ return FALSE;
+ return TRUE;
+ }
+
+ /* ok, need to cycle */
+ imonth += freq;
+ imonth--;
+ iyear += imonth / 12;
+ imonth = imonth % 12;
+ imonth++;
+
+ while(!QDate::isValid(iyear, imonth, iday) ) {
+ imonth += freq;
+ imonth--;
+ iyear += imonth / 12;
+ imonth = imonth % 12;
+ imonth++;
+ if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() )
+ return FALSE;
+ }
+
+ next = QDate(iyear, imonth, iday);
+ if ((next > endDate()) && hasEndDate() )
+ return FALSE;
+ return TRUE;
+ case Yearly:
+ iday = start().day();
+ imonth = start().month();
+ iyear = from.year(); // after all, we want to start in this year
+
+ diff = 1;
+ if(imonth == 2 && iday > 28) {
+ /* leap year, and it counts, calculate actual frequency */
+ if(freq % 4)
+ if (freq % 2)
+ freq = freq * 4;
+ else
+ freq = freq * 2;
+ /* else divides by 4 already, leave freq alone */
+ diff = 4;
+ }
+
+ a = from.year() - start().year();
+ if(a % freq) {
+ a = freq - (a % freq);
+ iyear = iyear + a;
+ }
+
+ /* under the assumption we won't hit one of the special not-leap years twice */
+ if(!QDate::isValid(iyear, imonth, iday)) {
+ /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */
+ iyear += freq;
+ }
+
+ if(QDate(iyear, imonth, iday) >= from) {
+ next = QDate(iyear, imonth, iday);
+
+ if ((next > endDate()) && hasEndDate() )
+ return FALSE;
+ return TRUE;
+ }
+ /* iyear == from.year(), need to advance again */
+ iyear += freq;
+ /* under the assumption we won't hit one of the special not-leap years twice */
+ if(!QDate::isValid(iyear, imonth, iday)) {
+ /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */
+ iyear += freq;
+ }
+
+ next = QDate(iyear, imonth, iday);
+ if ((next > endDate()) && hasEndDate() )
+ return FALSE;
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
ORecur::RepeatType ORecur::type()const{
return data->type;
}
int ORecur::frequency()const {
@@ -72,8 +367,11 @@ bool ORecur::hasEndDate()const {
}
QDate ORecur::endDate()const {
return TimeConversion::fromUTC( data->end ).date();
}
+QDate ORecur::start()const{
+ return data->start;
+}
time_t ORecur::endDateUTC()const {
return data->end;
}
time_t ORecur::createTime()const {
@@ -81,8 +379,14 @@ time_t ORecur::createTime()const {
}
int ORecur::repetition()const {
return data->rep;
}
+QString ORecur::service()const {
+ return data->app;
+}
+ORecur::ExceptionList& ORecur::exceptions() {
+ return data->list;
+}
void ORecur::setType( const RepeatType& z) {
checkOrModify();
data->type = z;
}
@@ -117,8 +421,16 @@ void ORecur::setHasEndDate( bool b) {
void ORecur::setRepitition( int rep ) {
checkOrModify();
data->rep = rep;
}
+void ORecur::setService( const QString& app ) {
+ checkOrModify();
+ data->app = app;
+}
+void ORecur::setStart( const QDate& dt ) {
+ checkOrModify();
+ data->start = dt;
+}
void ORecur::checkOrModify() {
if ( data->count != 1 ) {
data->deref();
Data* d2 = new Data;
@@ -129,8 +441,11 @@ void ORecur::checkOrModify() {
d2->hasEnd = data->hasEnd;
d2->end = data->end;
d2->create = data->create;
d2->rep = data->rep;
+ d2->app = data->app;
+ d2->list = data->list;
+ d2->start = data->start;
data = d2;
}
}
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
@@ -7,13 +7,14 @@
#include <sys/types.h>
#include <qdatetime.h>
-
+#include <qvaluelist.h>
class ORecur {
public:
+ typedef QValueList<QDate> ExceptionList;
enum RepeatType{ NoRepeat = -1, Daily, Weekly, MonthlyDay,
MonthlyDate, Yearly };
enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08,
FRI = 0x10, SAT = 0x20, SUN = 0x40 };
@@ -22,27 +23,53 @@ public:
~ORecur();
ORecur &operator=( const ORecur& );
bool operator==(const ORecur& )const;
+
+ bool doesRecur()const;
+ /* if it recurrs on that day */
+ bool doesRecur( const QDate& );
RepeatType type()const;
int frequency()const;
int position()const;
char days()const;
bool hasEndDate()const;
+ QDate start()const;
QDate endDate()const;
time_t endDateUTC()const;
time_t createTime()const;
+
+ /**
+ * FromWhereToStart is not included!!!
+ */
+ bool nextOcurrence( const QDate& FromWhereToStart, QDate &recurDate );
+ /**
+ * The module this ORecur belongs to
+ */
+ QString service()const;
+
+ /*
+ * reference to the exception list
+ */
+ ExceptionList &exceptions();
+
+ /**
+ * the current repetition
+ */
int repetition()const;
void setType( const RepeatType& );
void setFrequency( int freq );
void setPosition( int pos );
void setDays( char c);
void setEndDate( const QDate& dt );
+ void setStart( const QDate& dt );
void setEndDateUTC( time_t );
void setCreateTime( time_t );
void setHasEndDate( bool b );
void setRepitition(int );
+
+ void setService( const QString& ser );
private:
void deref();
inline void checkOrModify();
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
@@ -14,8 +14,9 @@
#include "opimstate.h"
#include "orecur.h"
#include "opimmaintainer.h"
+#include "opimnotifymanager.h"
#include "otodo.h"
@@ -30,13 +31,14 @@ struct OTodo::OTodoData : public QShared {
QString desc;
QString sum;
QMap<QString, QString> extra;
ushort prog;
- bool hasAlarmDateTime :1;
- QDateTime alarmDateTime;
OPimState state;
ORecur recur;
OPimMaintainer maintainer;
+ QDate start;
+ QDate completed;
+ OPimNotifyManager notifiers;
};
OTodo::OTodo(const OTodo &event )
: OPimRecord( event ), data( event.data )
@@ -72,10 +74,8 @@ OTodo::OTodo(bool completed, int priority,
data->priority = priority;
data->sum = summary;
data->prog = progress;
data->desc = Qtopia::simplifyMultiLineSpace(description );
- data->hasAlarmDateTime = false;
-
}
OTodo::OTodo(bool completed, int priority,
const QStringList &category,
const QString& summary,
@@ -95,10 +95,8 @@ OTodo::OTodo(bool completed, int priority,
data->priority = priority;
data->sum = summary;
data->prog = progress;
data->desc = Qtopia::simplifyMultiLineSpace(description );
- data->hasAlarmDateTime = false;
-
}
bool OTodo::match( const QRegExp &regExp )const
{
if( QString::number( data->priority ).find( regExp ) != -1 ){
@@ -119,11 +117,13 @@ bool OTodo::isCompleted() const
bool OTodo::hasDueDate() const
{
return data->hasDate;
}
-bool OTodo::hasAlarmDateTime() const
-{
- return data->hasAlarmDateTime;
+bool OTodo::hasStartDate()const {
+ return data->start.isValid();
+}
+bool OTodo::hasCompletedDate()const {
+ return data->completed.isValid();
}
int OTodo::priority()const
{
return data->priority;
@@ -139,14 +139,14 @@ ushort OTodo::progress() const
QDate OTodo::dueDate()const
{
return data->date;
}
-
-QDateTime OTodo::alarmDateTime() const
-{
- return data->alarmDateTime;
+QDate OTodo::startDate()const {
+ return data->start;
+}
+QDate OTodo::completedDate()const {
+ return data->completed;
}
-
QString OTodo::description()const
{
return data->desc;
}
@@ -168,13 +168,8 @@ void OTodo::setHasDueDate( bool hasDate )
{
changeOrModify();
data->hasDate = hasDate;
}
-void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime )
-{
- changeOrModify();
- data->hasAlarmDateTime = hasAlarmDateTime;
-}
void OTodo::setDescription(const QString &desc )
{
// qWarning( "desc " + desc );
changeOrModify();
@@ -189,17 +184,20 @@ void OTodo::setPriority(int prio )
{
changeOrModify();
data->priority = prio;
}
-void OTodo::setDueDate( QDate date )
+void OTodo::setDueDate( const QDate& date )
{
changeOrModify();
data->date = date;
}
-void OTodo::setAlarmDateTime( const QDateTime& alarm )
-{
+void OTodo::setStartDate( const QDate& date ) {
+ changeOrModify();
+ data->start = date;
+}
+void OTodo::setCompletedDate( const QDate& date ) {
changeOrModify();
- data->alarmDateTime = alarm;
+ data->completed = date;
}
void OTodo::setState( const OPimState& state ) {
changeOrModify();
data->state = state;
@@ -253,20 +251,18 @@ QString OTodo::toRichText() const
text += "<b>" + QObject::tr( "Deadline:") + " </b>";
text += dueDate().toString();
text += "<br>";
}
- if (hasAlarmDateTime() ){
- text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>";
- text += alarmDateTime().toString();
- text += "<br>";
- }
text += "<b>" + QObject::tr( "Category:") + "</b> ";
text += categoryNames().join(", ");
text += "<br>";
return text;
}
+OPimNotifyManager& OTodo::notifiers() {
+ return data->notifiers;
+}
bool OTodo::operator<( const OTodo &toDoEvent )const{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
@@ -326,12 +322,8 @@ bool OTodo::operator==(const OTodo &toDoEvent )const
if ( data->hasDate != toDoEvent.data->hasDate ) return false;
if ( data->date != toDoEvent.data->date ) return false;
if ( data->sum != toDoEvent.data->sum ) return false;
if ( data->desc != toDoEvent.data->desc ) return false;
- if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime )
- return false;
- if ( data->alarmDateTime != toDoEvent.data->alarmDateTime )
- return false;
if ( data->maintainer != toDoEvent.data->maintainer )
return false;
return OPimRecord::operator==( toDoEvent );
@@ -370,11 +362,13 @@ QMap<int, QString> OTodo::toMap() const {
map.insert( DateMonth, QString::number( data->date.month() ) );
map.insert( DateYear, QString::number( data->date.year() ) );
map.insert( Progress, QString::number( data->prog ) );
// map.insert( CrossReference, crossToString() );
- map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) );
- map.insert( AlarmDateTime, data->alarmDateTime.toString() );
-
+ /* FIXME!!! map.insert( State, );
+ map.insert( Recurrence, );
+ map.insert( Reminders, );
+ map.
+ */
return map;
}
QMap<QString, QString> OTodo::toExtraMap()const {
@@ -407,17 +401,21 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) {
dest->desc = src->desc;
dest->sum = src->sum;
dest->extra = src->extra;
dest->prog = src->prog;
- dest->hasAlarmDateTime = src->hasAlarmDateTime;
- dest->alarmDateTime = src->alarmDateTime;
dest->state = src->state;
dest->recur = src->recur;
dest->maintainer = src->maintainer;
+ dest->start = src->start;
+ dest->completed = src->completed;
+ dest->notifiers = src->notifiers;
}
QString OTodo::type() const {
return QString::fromLatin1("OTodo");
}
QString OTodo::recordField(int /*id*/ )const {
return QString::null;
}
+int OTodo::rtti(){
+ return 1;
+}
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
@@ -18,8 +18,9 @@
class OPimState;
class ORecur;
class OPimMaintainer;
+class OPimNotifyManager;
class OTodo : public OPimRecord {
public:
typedef QValueList<OTodo> ValueList;
enum RecordFields {
@@ -34,15 +35,16 @@ public:
DateMonth,
DateYear,
Progress,
CrossReference,
- HasAlarmDateTime,
- AlarmDateTime,
State,
- Recurrance,
+ Recurrence,
Alarms,
Reminders,
- Notifiers
+ Notifiers,
+ Maintainer,
+ StartDate,
+ CompletedDate
};
public:
// priorities from Very low to very high
enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow };
@@ -72,11 +74,11 @@ public:
ushort progress = 0,
bool hasDate = false, QDate date = QDate::currentDate(),
int uid = 0 /* empty */ );
- /* Copy c'tor
-
- **/
+ /** Copy c'tor
+ *
+ */
OTodo(const OTodo & );
/**
*destructor
@@ -91,8 +93,10 @@ public:
/**
* Does this Event have a deadline
*/
bool hasDueDate() const;
+ bool hasStartDate()const;
+ bool hasCompletedDate()const;
/**
* Does this Event has an alarm time ?
*/
@@ -113,11 +117,16 @@ public:
*/
QDate dueDate()const;
/**
- * Alarm Date and Time
+ * When did it start?
+ */
+ QDate startDate()const;
+
+ /**
+ * When was it completed?
*/
- QDateTime alarmDateTime()const;
+ QDate completedDate()const;
/**
* What is the state of this OTodo?
*/
@@ -148,10 +157,18 @@ public:
* Return this todoevent in a RichText formatted QString
*/
QString toRichText() const;
+ /*
+ * check if the sharing is still fine!! -zecke
+ */
+ /**
+ * return a reference to our notifiers...
+ */
+ OPimNotifyManager &notifiers();
+
/**
- * reimplementation
+ * reimplementations
*/
QString type()const;
QString toShortText()const;
QMap<QString, QString> toExtraMap()const;
@@ -171,13 +188,12 @@ public:
/**
* set if this todo got an end data
*/
void setHasDueDate( bool hasDate );
-
- /**
- * set if this todo has an alarm time and date
- */
- void setHasAlarmDateTime ( bool hasAlarm );
+ // FIXME we do not have these for start, completed
+ // cause we'll use the isNull() of QDate for figuring
+ // out if it's has a date...
+ // decide what to do here? -zecke
/**
* Set the priority of the Todo
*/
@@ -190,10 +206,19 @@ public:
/**
* set the end date
*/
- void setDueDate( QDate date );
+ void setDueDate( const QDate& date );
+ /**
+ * set the start date
+ */
+ void setStartDate( const QDate& date );
+
+ /**
+ * set the completed date
+ */
+ void setCompletedDate( const QDate& date );
void setRecurrence( const ORecur& );
/**
* set the alarm time
@@ -226,8 +251,10 @@ public:
bool operator>=(const OTodo &toDoEvent)const;
bool operator==(const OTodo &toDoEvent )const;
OTodo &operator=(const OTodo &toDoEvent );
+ static int rtti();
+
private:
class OTodoPrivate;
struct OTodoData;
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
@@ -44,8 +44,9 @@ OTodoAccess::List OTodoAccess::overDue() {
List lis( m_todoBackEnd->overDue(), this );
return lis;
}
void OTodoAccess::addAlarm( const OTodo& event) {
+/* FIXME use the new notifier architecture
if (!event.hasAlarmDateTime() )
return;
QDateTime now = QDateTime::currentDateTime();
@@ -56,8 +57,9 @@ void OTodoAccess::addAlarm( const OTodo& event) {
"QPE/Application/todolist",
"alarm(QDateTime,int)", event.uid() );
}
+*/
}
void OTodoAccess::delAlarm( int uid) {
QDateTime schedule; // Create null DateTime
@@ -78,4 +80,7 @@ OTodoAccess::List OTodoAccess::sorted( bool ascending, int sort,int filter, int
filter, cat );
OTodoAccess::List list( ints, this );
return list;
}
+void OTodoAccess::removeAllCompleted() {
+ m_todoBackEnd->removeAllCompleted();
+}
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
@@ -67,8 +67,19 @@ public:
*/
void mergeWith( const QValueList<OTodo>& );
/**
+ * delete all already completed items
+ */
+ void removeAllCompleted();
+
+signals:
+ /**
+ * if the OTodoAccess was changed
+ */
+ void signalChanged( const OTodoAccess* );
+private:
+ /**
* add an Alarm to the AlarmServer
*/
void addAlarm( const OTodo& );
@@ -77,14 +88,8 @@ public:
* the alarm server
*/
void delAlarm( int uid );
-signals:
- /**
- * if the OTodoAccess was changed
- */
- void signalChanged( const OTodoAccess* );
-private:
int m_cat;
OTodoAccessBackend* m_todoBackEnd;
class OTodoAccessPrivate;
OTodoAccessPrivate* d;
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
@@ -13,8 +13,9 @@ public:
bool includeNoDates ) = 0;
virtual QArray<int> overDue() = 0;
virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter,
int cat ) = 0;
+ virtual void removeAllCompleted() = 0;
};
#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
@@ -153,8 +153,14 @@ bool OTodoAccessVCal::remove( int uid ) {
m_map.remove( uid );
m_dirty = true;
return true;
}
+void OTodoAccessVCal::removeAllCompleted() {
+ for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) {
+ if ( (*it).isCompleted() )
+ m_map.remove( it );
+ }
+}
bool OTodoAccessVCal::replace( const OTodo& to ) {
m_map.replace( to.uid(), to );
m_dirty = true;
return true;
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
@@ -25,8 +25,10 @@ public:
bool add( const OTodo& );
bool remove( int uid );
bool replace( const OTodo& );
+ void removeAllCompleted();
+
private:
bool m_dirty : 1;
QString m_file;
QMap<int, OTodo> m_map;
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
@@ -27,9 +27,9 @@ bool OTodoAccessXML::load() {
/* initialize dict */
/*
* UPDATE dict if you change anything!!!
*/
- QAsciiDict<int> dict(15);
+ QAsciiDict<int> dict(21);
dict.setAutoDelete( TRUE );
dict.insert("Categories" , new int(OTodo::Category) );
dict.insert("Uid" , new int(OTodo::Uid) );
dict.insert("HasDate" , new int(OTodo::HasDate) );
@@ -42,13 +42,17 @@ bool OTodoAccessXML::load() {
dict.insert("DateYear" , new int(OTodo::DateYear) );
dict.insert("Progress" , new int(OTodo::Progress) );
dict.insert("Completed", new int(OTodo::Completed) );
dict.insert("CrossReference", new int(OTodo::CrossReference) );
- dict.insert("HasAlarmDateTime",new int(OTodo::HasAlarmDateTime) );
- dict.insert("AlarmDateTime", new int(OTodo::AlarmDateTime) );
+ dict.insert("State", new int(OTodo::State) );
+ dict.insert("Recurrence", new int(OTodo::Recurrence) );
+ dict.insert("Alarms", new int(OTodo::Alarms) );
+ dict.insert("Reminders", new int(OTodo::Reminders) );
+ dict.insert("Notifiers", new int(OTodo::Notifiers) );
+ dict.insert("Maintainer", new int(OTodo::Maintainer) );
// here the custom XML parser from TT it's GPL
- // but we want to push that to TT.....
+ // but we want to push OpiePIM... to TT.....
QFile f(m_file );
if (!f.open(IO_ReadOnly) )
return false;
@@ -335,16 +339,8 @@ void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev,
}
break;
}
- case OTodo::HasAlarmDateTime:
- ev.setHasAlarmDateTime( val.toInt() );
- break;
- case OTodo::AlarmDateTime: {
- /* this sounds better ;) zecke */
- ev.setAlarmDateTime( TimeConversion::fromISO8601( val.local8Bit() ) );
- break;
- }
default:
break;
}
}
@@ -382,9 +378,8 @@ QString OTodoAccessXML::toString( const OTodo& ev )const {
str += extIt.key() + "=\"" + extIt.data() + "\" ";
*/
// cross refernce
- str += "AlarmDateTime=\"" + TimeConversion::toISO8601( ev.alarmDateTime() ) + "\" ";
return str;
}
QString OTodoAccessXML::toString( const QArray<int>& ints ) const {
@@ -615,4 +610,10 @@ QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder,
}
qWarning("array count = %d %d", array.count(), vector.count() );
return array;
};
+void OTodoAccessXML::removeAllCompleted() {
+ for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) {
+ if ( (*it).isCompleted() )
+ m_events.remove( it );
+ }
+}
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
@@ -28,8 +28,9 @@ public:
OTodo find( int uid )const;
void clear();
bool add( const OTodo& );
bool remove( int uid );
+ void removeAllCompleted();
bool replace( const OTodo& );
/* our functions */
QArray<int> effectiveToDos( const QDate& start,
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
@@ -13,8 +13,9 @@ public:
bool includeNoDates ) = 0;
virtual QArray<int> overDue() = 0;
virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter,
int cat ) = 0;
+ virtual void removeAllCompleted() = 0;
};
#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
@@ -153,8 +153,14 @@ bool OTodoAccessVCal::remove( int uid ) {
m_map.remove( uid );
m_dirty = true;
return true;
}
+void OTodoAccessVCal::removeAllCompleted() {
+ for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) {
+ if ( (*it).isCompleted() )
+ m_map.remove( it );
+ }
+}
bool OTodoAccessVCal::replace( const OTodo& to ) {
m_map.replace( to.uid(), to );
m_dirty = true;
return true;
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
@@ -25,8 +25,10 @@ public:
bool add( const OTodo& );
bool remove( int uid );
bool replace( const OTodo& );
+ void removeAllCompleted();
+
private:
bool m_dirty : 1;
QString m_file;
QMap<int, OTodo> m_map;
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
@@ -27,9 +27,9 @@ bool OTodoAccessXML::load() {
/* initialize dict */
/*
* UPDATE dict if you change anything!!!
*/
- QAsciiDict<int> dict(15);
+ QAsciiDict<int> dict(21);
dict.setAutoDelete( TRUE );
dict.insert("Categories" , new int(OTodo::Category) );
dict.insert("Uid" , new int(OTodo::Uid) );
dict.insert("HasDate" , new int(OTodo::HasDate) );
@@ -42,13 +42,17 @@ bool OTodoAccessXML::load() {
dict.insert("DateYear" , new int(OTodo::DateYear) );
dict.insert("Progress" , new int(OTodo::Progress) );
dict.insert("Completed", new int(OTodo::Completed) );
dict.insert("CrossReference", new int(OTodo::CrossReference) );
- dict.insert("HasAlarmDateTime",new int(OTodo::HasAlarmDateTime) );
- dict.insert("AlarmDateTime", new int(OTodo::AlarmDateTime) );
+ dict.insert("State", new int(OTodo::State) );
+ dict.insert("Recurrence", new int(OTodo::Recurrence) );
+ dict.insert("Alarms", new int(OTodo::Alarms) );
+ dict.insert("Reminders", new int(OTodo::Reminders) );
+ dict.insert("Notifiers", new int(OTodo::Notifiers) );
+ dict.insert("Maintainer", new int(OTodo::Maintainer) );
// here the custom XML parser from TT it's GPL
- // but we want to push that to TT.....
+ // but we want to push OpiePIM... to TT.....
QFile f(m_file );
if (!f.open(IO_ReadOnly) )
return false;
@@ -335,16 +339,8 @@ void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev,
}
break;
}
- case OTodo::HasAlarmDateTime:
- ev.setHasAlarmDateTime( val.toInt() );
- break;
- case OTodo::AlarmDateTime: {
- /* this sounds better ;) zecke */
- ev.setAlarmDateTime( TimeConversion::fromISO8601( val.local8Bit() ) );
- break;
- }
default:
break;
}
}
@@ -382,9 +378,8 @@ QString OTodoAccessXML::toString( const OTodo& ev )const {
str += extIt.key() + "=\"" + extIt.data() + "\" ";
*/
// cross refernce
- str += "AlarmDateTime=\"" + TimeConversion::toISO8601( ev.alarmDateTime() ) + "\" ";
return str;
}
QString OTodoAccessXML::toString( const QArray<int>& ints ) const {
@@ -615,4 +610,10 @@ QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder,
}
qWarning("array count = %d %d", array.count(), vector.count() );
return array;
};
+void OTodoAccessXML::removeAllCompleted() {
+ for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) {
+ if ( (*it).isCompleted() )
+ m_events.remove( it );
+ }
+}
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
@@ -28,8 +28,9 @@ public:
OTodo find( int uid )const;
void clear();
bool add( const OTodo& );
bool remove( int uid );
+ void removeAllCompleted();
bool replace( const OTodo& );
/* our functions */
QArray<int> effectiveToDos( const QDate& start,
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
@@ -92,8 +92,9 @@ public:
* @param t The item to add.
* @return <i>true</i> if added successfully.
*/
virtual bool add( const T& t ) ;
+ bool add( const OPimRecord& );
/* only the uid matters */
/**
* remove T from the backend
@@ -211,8 +212,17 @@ bool OPimAccessTemplate<T>::add( const T& t ) {
cache( t );
return m_backEnd->add( t );
}
template <class T>
+bool OPimAccessTemplate<T>::add( const OPimRecord& rec) {
+ /* same type */
+ if ( rec.rtti() == T::rtti() ) {
+ const T &t = static_cast<const T&>(rec);
+ return add(t);
+ }
+ return false;
+}
+template <class T>
bool OPimAccessTemplate<T>::remove( const T& t ) {
return remove( t.uid() );
}
template <class T>
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,7 +1,7 @@
#include "opimmaintainer.h"
-OPimMaintainer::OPimMaintainer( enum Mode mode, int uid )
+OPimMaintainer::OPimMaintainer( int mode, int uid )
: m_mode(mode), m_uid(uid )
{}
OPimMaintainer::~OPimMaintainer() {
}
@@ -22,15 +22,15 @@ bool OPimMaintainer::operator==( const OPimMaintainer& main ) {
}
bool OPimMaintainer::operator!=( const OPimMaintainer& main ) {
return !(*this == main );
}
-OPimMaintainer::Mode OPimMaintainer::mode()const {
+int OPimMaintainer::mode()const {
return m_mode;
}
int OPimMaintainer::uid()const {
return m_uid;
}
-void OPimMaintainer::setMode( enum Mode mo) {
+void OPimMaintainer::setMode( int mo) {
m_mode = mo;
}
void OPimMaintainer::setUid( int uid ) {
m_uid = uid;
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
@@ -8,29 +8,33 @@
*/
class OPimMaintainer {
public:
enum Mode { Undefined = -1,
- Responsible = 0,
+ Nothing = 0,
+ Responsible,
DoneBy,
- Coordinating };
- OPimMaintainer( enum Mode mode = Undefined, int uid = 0);
+ Coordinating,
+ };
+ OPimMaintainer( int mode = Undefined, int uid = 0);
OPimMaintainer( const OPimMaintainer& );
~OPimMaintainer();
OPimMaintainer &operator=( const OPimMaintainer& );
bool operator==( const OPimMaintainer& );
bool operator!=( const OPimMaintainer& );
- Mode mode()const;
+ int mode()const;
int uid()const;
- void setMode( enum Mode );
+ void setMode( int mode );
void setUid( int uid );
private:
- Mode m_mode;
+ int m_mode;
int m_uid;
+ class Private;
+ Private *d;
};
#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 @@
+#include <qshared.h>
+
+#include "opimnotify.h"
+
+struct OPimNotify::Data : public QShared {
+ Data() : QShared(),dur(-1),parent(0) {
+
+ }
+ QDateTime start;
+ int dur;
+ QString application;
+ int parent;
+};
+
+OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) {
+ data = new Data;
+ data->start = start;
+ data->dur = duration;
+ data->parent = parent;
+}
+OPimNotify::OPimNotify( const OPimNotify& noti)
+ : data( noti.data )
+{
+ data->ref();
+}
+OPimNotify::~OPimNotify() {
+ if ( data->deref() ) {
+ delete data;
+ data = 0l;
+ }
+}
+
+OPimNotify &OPimNotify::operator=( const OPimNotify& noti) {
+ noti.data->ref();
+ deref();
+ data = noti.data;
+
+ return *this;
+}
+bool OPimNotify::operator==( const OPimNotify& noti ) {
+ if ( data == noti.data ) return true;
+ if ( data->dur != noti.data->dur ) return false;
+ if ( data->parent != noti.data->parent ) return false;
+ if ( data->application != noti.data->application ) return false;
+ if ( data->start != noti.data->start ) return false;
+
+ return true;
+}
+QDateTime OPimNotify::dateTime()const {
+ return data->start;
+}
+QString OPimNotify::service()const {
+ return data->application;
+}
+int OPimNotify::parent()const {
+ return data->parent;
+}
+int OPimNotify::duration()const {
+ return data->dur;
+}
+QDateTime OPimNotify::endTime()const {
+ return QDateTime( data->start.date(), data->start.time().addSecs( data->dur) );
+}
+void OPimNotify::setDateTime( const QDateTime& time ) {
+ copyIntern();
+ data->start = time;
+}
+void OPimNotify::setDuration( int dur ) {
+ copyIntern();
+ data->dur = dur;
+}
+void OPimNotify::setParent( int uid ) {
+ copyIntern();
+ data->parent = uid;
+}
+void OPimNotify::setService( const QString& str ) {
+ copyIntern();
+ data->application = str;
+}
+void OPimNotify::copyIntern() {
+ if ( data->count != 1 ) {
+ data->deref();
+ Data* dat = new Data;
+ dat->start = data->start;
+ dat->dur = data->dur;
+ dat->application = data->application;
+ dat->parent = data->parent;
+ data = dat;
+ }
+}
+void OPimNotify::deref() {
+ if ( data->deref() ) {
+ delete data;
+ data = 0;
+ }
+}
+
+/***********************************************************/
+struct OPimAlarm::Data : public QShared {
+ Data() : QShared() {
+ sound = 1;
+ }
+ int sound;
+ QString file;
+};
+OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int parent )
+ : OPimNotify( start, duration, parent )
+{
+ data = new Data;
+ data->sound = sound;
+}
+OPimAlarm::OPimAlarm( const OPimAlarm& al)
+ : OPimNotify(al), data( al.data )
+{
+ data->ref();
+}
+OPimAlarm::~OPimAlarm() {
+ if ( data->deref() ) {
+ delete data;
+ data = 0l;
+ }
+}
+OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al)
+{
+ OPimNotify::operator=( al );
+ deref();
+ al.data->ref();
+
+ data = al.data;
+
+
+ return *this;
+}
+bool OPimAlarm::operator==( const OPimAlarm& al) {
+ if ( data->sound != al.data->sound ) return false;
+ else if ( data->sound == Custom && data->file != al.data->file )
+ return false;
+
+ return OPimNotify::operator==( al );
+}
+QString OPimAlarm::type()const {
+ return QString::fromLatin1("OPimAlarm");
+}
+int OPimAlarm::sound()const {
+ return data->sound;
+}
+QString OPimAlarm::file()const {
+ return data->file;
+}
+void OPimAlarm::setSound( int snd) {
+ copyIntern();
+ data->sound = snd;
+}
+void OPimAlarm::setFile( const QString& sound ) {
+ copyIntern();
+ data->file = sound;
+}
+void OPimAlarm::deref() {
+ if ( data->deref() ) {
+ delete data;
+ data = 0l;
+ }
+}
+void OPimAlarm::copyIntern() {
+ if ( data->count != 1 ) {
+ data->deref();
+ Data *newDat = new Data;
+ newDat->sound = data->sound;
+ newDat->file = data->file;
+ data = newDat;
+ }
+}
+/************************/
+struct OPimReminder::Data : public QShared {
+ Data() : QShared(), record( 0) {
+ }
+ int record;
+
+};
+OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent )
+ : OPimNotify( start, dur, parent )
+{
+ data = new Data;
+ data->record = uid;
+}
+OPimReminder::OPimReminder( const OPimReminder& rem )
+ : OPimNotify( rem ), data( rem.data )
+{
+ data->ref();
+}
+OPimReminder& OPimReminder::operator=( const OPimReminder& rem) {
+ OPimNotify::operator=(rem );
+
+ deref();
+ rem.data->ref();
+ data = rem.data;
+
+ return *this;
+}
+bool OPimReminder::operator==( const OPimReminder& rem) {
+ if ( data->record != rem.data->record ) return false;
+
+ return OPimNotify::operator==( rem );
+}
+QString OPimReminder::type()const {
+ return QString::fromLatin1("OPimReminder");
+}
+int OPimReminder::recordUid()const {
+ return data->record;
+}
+void OPimReminder::setRecordUid( int uid ) {
+ copyIntern();
+ data->record = uid;
+}
+void OPimReminder::deref() {
+ if ( data->deref() ) {
+ delete data;
+ data = 0l;
+ }
+}
+void OPimReminder::copyIntern() {
+ if ( data->count != 1 ) {
+ Data* da = new Data;
+ da->record = data->record;
+ data = da;
+ }
+}
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 @@
+#ifndef OPIE_PIM_NOTIFY_H
+#define OPIE_PIM_NOTIFY_H
+
+#include <qdatetime.h>
+#include <qvaluelist.h>
+
+/**
+ * This is the base class of Notifiers. Possible
+ * notifiers would be Alarms, Reminders
+ * What they share is that they have
+ * A DateTime, Type, Duration
+ * This is what this base class takes care of
+ * on top of that it's shared
+ */
+/*
+ * TALK to eilers: have a class OPimDuration which sets the Duration
+ * given on the Due/Start Date? -zecke
+ * discuss: do we need a uid for the notify? -zecke
+ */
+class OPimNotify {
+public:
+ typedef QValueList<OPimNotify> ValueList;
+ OPimNotify( const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 );
+ OPimNotify( const OPimNotify& );
+ virtual ~OPimNotify();
+
+ OPimNotify &operator=(const OPimNotify& );
+ bool operator==( const OPimNotify& );
+
+ virtual QString type()const = 0;
+
+ /** start date */
+ QDateTime dateTime()const;
+ QString service()const;
+
+ /**
+ * RETURN the parent uid
+ */
+ int parent()const;
+
+ /**
+ * in Seconds
+ */
+ int duration()const;
+
+ /**
+ * Start Time + Duration
+ */
+ QDateTime endTime()const;
+
+ void setDateTime( const QDateTime& );
+ void setDuration( int dur );
+ void setParent(int uid );
+ void setService( const QString& );
+
+
+private:
+ inline void copyIntern();
+ void deref();
+ struct Data;
+ Data* data;
+
+ /* d-pointer */
+ class NotifyPrivate;
+ NotifyPrivate* d;
+
+};
+/**
+ * An alarm is a sound/mail/buzzer played/send
+ * at a given time to inform about
+ * an Event
+ */
+class OPimAlarm : public OPimNotify {
+public:
+ enum Sound{Loud=0, Silent, Custom };
+ OPimAlarm( int sound = Silent, const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 );
+ OPimAlarm( const OPimAlarm& );
+ ~OPimAlarm();
+
+ OPimAlarm &operator=( const OPimAlarm& );
+ bool operator==( const OPimAlarm& );
+ QString type()const;
+
+ int sound()const;
+ QString file()const;
+
+ void setSound( int );
+ /* only when sound is custom... */
+ void setFile( const QString& sound );
+
+private:
+ void deref();
+ void copyIntern();
+ struct Data;
+ Data * data;
+
+ class Private;
+ Private* d;
+
+};
+
+/**
+ * A Reminder will be put into the
+ * datebook
+ */
+class OPimReminder : public OPimNotify {
+public:
+
+ /**
+ * c'tor of a reminder
+ * @param uid The uid of the Record inside the Datebook
+ * @param start the StartDate invalid for all day...
+ * @param duration The duration of the event ( -1 for all day )
+ * @param parent The 'parent' record of this reminder
+ */
+ OPimReminder( int uid = 0, const QDateTime& start = QDateTime(),
+ int duration = 0, int parent = 0 );
+ OPimReminder( const OPimReminder& );
+ OPimReminder &operator=(const OPimReminder& );
+
+ QString type()const;
+
+ bool operator==( const OPimReminder& );
+
+ /**
+ * the uid of the alarm
+ * inside the 'datebook' application
+ */
+ int recordUid()const;
+ void setRecordUid( int uid );
+
+private:
+ void deref();
+ void copyIntern();
+
+ struct Data;
+ Data* data;
+ class Private;
+ Private *d;
+};
+
+#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 @@
+#include "opimnotifymanager.h"
+
+OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al)
+ : m_rem( rem ), m_al( al )
+{}
+OPimNotifyManager::~OPimNotifyManager() {
+}
+/* use static_cast and type instead of dynamic... */
+void OPimNotifyManager::add( const OPimNotify& noti) {
+ if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
+ const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
+ m_rem.append( rem );
+ }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
+ const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
+ m_al.append( al );
+ }
+}
+void OPimNotifyManager::remove( const OPimNotify& noti) {
+ if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
+ const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
+ m_rem.remove( rem );
+ }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
+ const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
+ m_al.remove( al );
+ }
+}
+void OPimNotifyManager::replace( const OPimNotify& noti) {
+ if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
+ const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
+ m_rem.remove( rem );
+ m_rem.append( rem );
+ }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
+ const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
+ m_al.remove( al );
+ m_al.append( al );
+ }
+}
+OPimNotifyManager::Reminders OPimNotifyManager::reminders()const {
+ return m_rem;
+}
+OPimNotifyManager::Alarms OPimNotifyManager::alarms()const {
+ return m_al;
+}
+void OPimNotifyManager::setAlarms( const Alarms& al) {
+ m_al = al;
+}
+void OPimNotifyManager::setReminders( const Reminders& rem) {
+ m_rem = rem;
+}
+/* FIXME!!! */
+/**
+ * The idea is to check if the provider for our service
+ * is online
+ * if it is we will use QCOP
+ * if not the Factory to get the backend...
+ * Qtopia1.6 services would be kewl to have here....
+ */
+void OPimNotifyManager::registerNotify( const OPimNotify& ) {
+
+}
+/* FIXME!!! */
+/**
+ * same as above...
+ * Also implement Url model
+ * have a MainWindow....
+ */
+void OPimNotifyManager::deregister( const OPimNotify& ) {
+
+}
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 @@
+#ifndef OPIE_PIM_NOTIFY_MANAGER_H
+#define OPIE_PIM_NOTIFY_MANAGER_H
+
+#include <qvaluelist.h>
+
+#include <opie/opimnotify.h>
+
+/**
+ * The notify manager keeps track of the Notifiers....
+ */
+class OPimNotifyManager {
+public:
+ typedef QValueList<OPimReminder> Reminders;
+ typedef QValueList<OPimAlarm> Alarms;
+ OPimNotifyManager( const Reminders& rems = Reminders(), const Alarms& alarms = Alarms() );
+ ~OPimNotifyManager();
+
+ /* we will cast it for you ;) */
+ void add( const OPimNotify& );
+ void remove( const OPimNotify& );
+ /* replaces all with this one! */
+ void replace( const OPimNotify& );
+
+ Reminders reminders()const;
+ Alarms alarms()const;
+
+ void setAlarms( const Alarms& );
+ void setReminders( const Reminders& );
+
+ /* register is a Ansi C keyword... */
+ /**
+ * This function will register the Notify to the Alarm Server
+ * or datebook depending on the type of the notify
+ */
+ void registerNotify( const OPimNotify& );
+
+ /**
+ * this will do the opposite..
+ */
+ void deregister( const OPimNotify& );
+
+private:
+ Reminders m_rem;
+ Alarms m_al;
+
+ class Private;
+ Private *d;
+
+};
+
+#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
@@ -78,4 +78,7 @@ Qtopia::UidGen &OPimRecord::uidGen() {
}
OPimXRefManager &OPimRecord::xrefmanager() {
return m_xrefman;
}
+int OPimRecord::rtti(){
+ return 0;
+}
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
@@ -88,18 +88,24 @@ public:
/**
* returns a reference of the
* Cross Reference Manager
- * Partner One is THIS PIM RECORD!
- * Two is the Partner where we link to
+ * Partner 'One' is THIS PIM RECORD!
+ * 'Two' is the Partner where we link to
*/
OPimXRefManager& xrefmanager();
/**
* set the uid
*/
virtual void setUid( int uid );
+ /*
+ * used inside the Templates for casting
+ * REIMPLEMENT in your ....
+ */
+ static int rtti();
+
protected:
Qtopia::UidGen &uidGen();
// QString crossToString()const;
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 @@
+#ifndef OPIE_PIM_RESOLVER
+#define OPIE_PIM_RESOLVER
+
+#include <qstring.h>
+#include <qvaluelist.h>
+
+/**
+ * OPimResolver is a MetaClass to access
+ * available backends read only.
+ * It will be used to resolve uids + app names
+ * to full informations
+ * to traverse through a list of alarms, reminders
+ * to get access to built in PIM functionality
+ * and to more stuff
+ * THE PERFORMANCE will depend on THE BACKEND
+ * USING XML is a waste of memory!!!!!
+ */
+class OPimResolver : public QObject {
+public:
+ enum BuiltIn { TodoList = 0,
+ DateBook,
+ AddressBook
+ };
+ static OPimResolver* self();
+
+
+ /*
+ * return a record for a uid
+ * and an app
+ */
+ OPimRecord &record( const QString& service, int uid );
+
+ /**
+ * return the QCopChannel for service
+ * When we will use Qtopia Services it will be used here
+ */
+ QString qcopChannel( enum BuiltIn& )const;
+ QString qcopChannel( const QString& service );
+
+ /**
+ * return a list of available services
+ */
+ QStringList services()const;
+
+ /**
+ * add a record to a service... ;)
+ */
+ bool add( const QString& service, const OPimRecord& );
+
+private:
+ OPimResolver();
+ OPimRecord *m_last;
+
+}:
+
+#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
@@ -33,10 +33,10 @@ OPimXRefPartner OPimXRef::partner( enum Partners par) const{
void OPimXRef::setPartner( enum Partners par, const OPimXRefPartner& part) {
m_partners[par] = part;
}
bool OPimXRef::containsString( const QString& string ) const{
- if ( m_partners[One].appName() == string ||
- m_partners[Two].appName() == string ) return true;
+ if ( m_partners[One].service() == string ||
+ m_partners[Two].service() == string ) return true;
return false;
}
bool OPimXRef::containsUid( int uid ) const{
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
@@ -25,9 +25,9 @@ public:
OPimXRefPartner partner( enum Partners )const;
void setPartner( enum Partners, const OPimXRefPartner& );
- bool containsString( const QString& appName)const;
+ bool containsString( const QString& service)const;
bool containsUid( int uid )const;
private:
QArray<OPimXRefPartner> m_partners;
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
@@ -35,12 +35,12 @@ QStringList OPimXRefManager::apps()const {
QStringList list;
QString str;
for ( it = m_list.begin(); it != m_list.end(); ++it ) {
- str = (*it).partner( OPimXRef::One ).appName();
+ str = (*it).partner( OPimXRef::One ).service();
if ( !list.contains( str ) ) list << str;
- str = (*it).partner( OPimXRef::Two ).appName();
+ str = (*it).partner( OPimXRef::Two ).service();
if ( !list.contains( str ) ) list << str;
}
return list;
}
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
@@ -30,9 +30,9 @@ public:
* apps participating
*/
QStringList apps()const;
OPimXRef::ValueList list()const;
- OPimXRef::ValueList list( const QString& appName )const;
+ OPimXRef::ValueList list( const QString& service )const;
OPimXRef::ValueList list( int uid )const;
private:
OPimXRef::ValueList m_list;
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
@@ -22,18 +22,18 @@ bool OPimXRefPartner::operator==( const OPimXRefPartner& par ) {
if ( m_field != par.m_field ) return false;
return true;
}
-QString OPimXRefPartner::appName()const {
+QString OPimXRefPartner::service()const {
return m_app;
}
int OPimXRefPartner::uid()const {
return m_uid;
}
int OPimXRefPartner::field()const {
return m_field;
}
-void OPimXRefPartner::setAppName( const QString& appName ) {
+void OPimXRefPartner::setService( const QString& appName ) {
m_app = appName;
}
void OPimXRefPartner::setUid( int uid ) {
m_uid = uid;
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
@@ -11,21 +11,21 @@
* with one tableId( fieldId ) to another.
*/
class OPimXRefPartner {
public:
- OPimXRefPartner( const QString& appName = QString::null,
+ OPimXRefPartner( const QString& service = QString::null,
int uid = 0, int field = -1 );
OPimXRefPartner( const OPimXRefPartner& );
OPimXRefPartner& operator=( const OPimXRefPartner& );
~OPimXRefPartner();
bool operator==(const OPimXRefPartner& );
- QString appName()const;
+ QString service()const;
int uid()const;
int field()const;
- void setAppName( const QString& appName );
+ void setService( const QString& service );
void setUid( int uid );
void setField( int field );
private:
QString m_app;
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
@@ -21,8 +21,11 @@ struct ORecur::Data : public QShared {
bool hasEnd : 1;
time_t end;
time_t create;
int rep;
+ QString app;
+ ExceptionList list;
+ QDate start;
};
ORecur::ORecur() {
@@ -54,8 +57,300 @@ ORecur &ORecur::operator=( const ORecur& re) {
data = re.data;
return *this;
}
+bool ORecur::doesRecur()const {
+ return !( type() == NoRepeat );
+}
+/*
+ * we try to be smart here
+ *
+ */
+bool ORecur::doesRecur( const QDate& date ) {
+ /* the day before the recurrance */
+ QDate da = date.addDays(-1);
+
+ QDate recur;
+ if (!nextOcurrence( da, recur ) )
+ return false;
+
+ return (recur == date);
+}
+// FIXME unuglify!
+// GPL from Datebookdb.cpp
+// FIXME exception list!
+bool ORecur::nextOcurrence( const QDate& from, QDate& next ) {
+
+ // easy checks, first are we too far in the future or too far in the past?
+ QDate tmpDate;
+ int freq = frequency();
+ int diff, diff2, a;
+ int iday, imonth, iyear;
+ int dayOfWeek = 0;
+ int firstOfWeek = 0;
+ int weekOfMonth;
+
+
+ if (hasEndDate() && endDate() < from)
+ return FALSE;
+
+ if (start() >= from) {
+ next = start();
+ return TRUE;
+ }
+
+ switch ( type() ) {
+ case Weekly:
+ /* weekly is just daily by 7 */
+ /* first convert the repeatPattern.Days() mask to the next
+ day of week valid after from */
+ dayOfWeek = from.dayOfWeek();
+ dayOfWeek--; /* we want 0-6, doco for above specs 1-7 */
+
+ /* this is done in case freq > 1 and from in week not
+ for this round */
+ // firstOfWeek = 0; this is already done at decl.
+ while(!((1 << firstOfWeek) & days() ))
+ firstOfWeek++;
+
+ /* there is at least one 'day', or there would be no event */
+ while(!((1 << (dayOfWeek % 7)) & days() ))
+ dayOfWeek++;
+
+ dayOfWeek = dayOfWeek % 7; /* the actual day of week */
+ dayOfWeek -= start().dayOfWeek() -1;
+
+ firstOfWeek = firstOfWeek % 7; /* the actual first of week */
+ firstOfWeek -= start().dayOfWeek() -1;
+
+ // dayOfWeek may be negitive now
+ // day of week is number of days to add to start day
+
+ freq *= 7;
+ // FALL-THROUGH !!!!!
+ case Daily:
+ // the add is for the possible fall through from weekly */
+ if(start().addDays(dayOfWeek) > from) {
+ /* first week exception */
+ next = QDate(start().addDays(dayOfWeek) );
+ if ((next > endDate())
+ && hasEndDate() )
+ return FALSE;
+ return TRUE;
+ }
+ /* if from is middle of a non-week */
+
+ diff = start().addDays(dayOfWeek).daysTo(from) % freq;
+ diff2 = start().addDays(firstOfWeek).daysTo(from) % freq;
+
+ if(diff != 0)
+ diff = freq - diff;
+ if(diff2 != 0)
+ diff2 = freq - diff2;
+ diff = QMIN(diff, diff2);
+
+ next = QDate(from.addDays(diff));
+ if ( (next > endDate())
+ && hasEndDate() )
+ return FALSE;
+ return TRUE;
+ case MonthlyDay:
+ iday = from.day();
+ iyear = from.year();
+ imonth = from.month();
+ /* find equivelent day of month for this month */
+ dayOfWeek = start().dayOfWeek();
+ weekOfMonth = (start().day() - 1) / 7;
+
+ /* work out when the next valid month is */
+ a = from.year() - start().year();
+ a *= 12;
+ a = a + (imonth - start().month());
+ /* a is e.start()monthsFrom(from); */
+ if(a % freq) {
+ a = freq - (a % freq);
+ imonth = from.month() + a;
+ if (imonth > 12) {
+ imonth--;
+ iyear += imonth / 12;
+ imonth = imonth % 12;
+ imonth++;
+ }
+ }
+ /* imonth is now the first month after or on
+ from that matches the frequency given */
+
+ /* find for this month */
+ tmpDate = QDate( iyear, imonth, 1 );
+
+ iday = 1;
+ iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7;
+ iday += 7 * weekOfMonth;
+ while (iday > tmpDate.daysInMonth()) {
+ imonth += freq;
+ if (imonth > 12) {
+ imonth--;
+ iyear += imonth / 12;
+ imonth = imonth % 12;
+ imonth++;
+ }
+ tmpDate = QDate( iyear, imonth, 1 );
+ /* these loops could go for a while, check end case now */
+ if ((tmpDate > endDate()) && hasEndDate() )
+ return FALSE;
+ iday = 1;
+ iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7;
+ iday += 7 * weekOfMonth;
+ }
+ tmpDate = QDate(iyear, imonth, iday);
+
+ if (tmpDate >= from) {
+ next = tmpDate;
+ if ((next > endDate() ) && hasEndDate() )
+ return FALSE;
+ return TRUE;
+ }
+
+ /* need to find the next iteration */
+ do {
+ imonth += freq;
+ if (imonth > 12) {
+ imonth--;
+ iyear += imonth / 12;
+ imonth = imonth % 12;
+ imonth++;
+ }
+ tmpDate = QDate( iyear, imonth, 1 );
+ /* these loops could go for a while, check end case now */
+ if ((tmpDate > endDate()) && hasEndDate() )
+ return FALSE;
+ iday = 1;
+ iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7;
+ iday += 7 * weekOfMonth;
+ } while (iday > tmpDate.daysInMonth());
+ tmpDate = QDate(iyear, imonth, iday);
+
+ next = tmpDate;
+ if ((next > endDate()) && hasEndDate() )
+ return FALSE;
+ return TRUE;
+ case MonthlyDate:
+ iday = start().day();
+ iyear = from.year();
+ imonth = from.month();
+
+ a = from.year() - start().year();
+ a *= 12;
+ a = a + (imonth - start().month());
+ /* a is e.start()monthsFrom(from); */
+ if(a % freq) {
+ a = freq - (a % freq);
+ imonth = from.month() + a;
+ if (imonth > 12) {
+ imonth--;
+ iyear += imonth / 12;
+ imonth = imonth % 12;
+ imonth++;
+ }
+ }
+ /* imonth is now the first month after or on
+ from that matches the frequencey given */
+
+ /* this could go for a while, worse case, 4*12 iterations, probably */
+ while(!QDate::isValid(iyear, imonth, iday) ) {
+ imonth += freq;
+ if (imonth > 12) {
+ imonth--;
+ iyear += imonth / 12;
+ imonth = imonth % 12;
+ imonth++;
+ }
+ /* these loops could go for a while, check end case now */
+ if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() )
+ return FALSE;
+ }
+
+ if(QDate(iyear, imonth, iday) >= from) {
+ /* done */
+ next = QDate(iyear, imonth, iday);
+ if ((next > endDate()) && hasEndDate() )
+ return FALSE;
+ return TRUE;
+ }
+
+ /* ok, need to cycle */
+ imonth += freq;
+ imonth--;
+ iyear += imonth / 12;
+ imonth = imonth % 12;
+ imonth++;
+
+ while(!QDate::isValid(iyear, imonth, iday) ) {
+ imonth += freq;
+ imonth--;
+ iyear += imonth / 12;
+ imonth = imonth % 12;
+ imonth++;
+ if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() )
+ return FALSE;
+ }
+
+ next = QDate(iyear, imonth, iday);
+ if ((next > endDate()) && hasEndDate() )
+ return FALSE;
+ return TRUE;
+ case Yearly:
+ iday = start().day();
+ imonth = start().month();
+ iyear = from.year(); // after all, we want to start in this year
+
+ diff = 1;
+ if(imonth == 2 && iday > 28) {
+ /* leap year, and it counts, calculate actual frequency */
+ if(freq % 4)
+ if (freq % 2)
+ freq = freq * 4;
+ else
+ freq = freq * 2;
+ /* else divides by 4 already, leave freq alone */
+ diff = 4;
+ }
+
+ a = from.year() - start().year();
+ if(a % freq) {
+ a = freq - (a % freq);
+ iyear = iyear + a;
+ }
+
+ /* under the assumption we won't hit one of the special not-leap years twice */
+ if(!QDate::isValid(iyear, imonth, iday)) {
+ /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */
+ iyear += freq;
+ }
+
+ if(QDate(iyear, imonth, iday) >= from) {
+ next = QDate(iyear, imonth, iday);
+
+ if ((next > endDate()) && hasEndDate() )
+ return FALSE;
+ return TRUE;
+ }
+ /* iyear == from.year(), need to advance again */
+ iyear += freq;
+ /* under the assumption we won't hit one of the special not-leap years twice */
+ if(!QDate::isValid(iyear, imonth, iday)) {
+ /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */
+ iyear += freq;
+ }
+
+ next = QDate(iyear, imonth, iday);
+ if ((next > endDate()) && hasEndDate() )
+ return FALSE;
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
ORecur::RepeatType ORecur::type()const{
return data->type;
}
int ORecur::frequency()const {
@@ -72,8 +367,11 @@ bool ORecur::hasEndDate()const {
}
QDate ORecur::endDate()const {
return TimeConversion::fromUTC( data->end ).date();
}
+QDate ORecur::start()const{
+ return data->start;
+}
time_t ORecur::endDateUTC()const {
return data->end;
}
time_t ORecur::createTime()const {
@@ -81,8 +379,14 @@ time_t ORecur::createTime()const {
}
int ORecur::repetition()const {
return data->rep;
}
+QString ORecur::service()const {
+ return data->app;
+}
+ORecur::ExceptionList& ORecur::exceptions() {
+ return data->list;
+}
void ORecur::setType( const RepeatType& z) {
checkOrModify();
data->type = z;
}
@@ -117,8 +421,16 @@ void ORecur::setHasEndDate( bool b) {
void ORecur::setRepitition( int rep ) {
checkOrModify();
data->rep = rep;
}
+void ORecur::setService( const QString& app ) {
+ checkOrModify();
+ data->app = app;
+}
+void ORecur::setStart( const QDate& dt ) {
+ checkOrModify();
+ data->start = dt;
+}
void ORecur::checkOrModify() {
if ( data->count != 1 ) {
data->deref();
Data* d2 = new Data;
@@ -129,8 +441,11 @@ void ORecur::checkOrModify() {
d2->hasEnd = data->hasEnd;
d2->end = data->end;
d2->create = data->create;
d2->rep = data->rep;
+ d2->app = data->app;
+ d2->list = data->list;
+ d2->start = data->start;
data = d2;
}
}
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
@@ -7,13 +7,14 @@
#include <sys/types.h>
#include <qdatetime.h>
-
+#include <qvaluelist.h>
class ORecur {
public:
+ typedef QValueList<QDate> ExceptionList;
enum RepeatType{ NoRepeat = -1, Daily, Weekly, MonthlyDay,
MonthlyDate, Yearly };
enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08,
FRI = 0x10, SAT = 0x20, SUN = 0x40 };
@@ -22,27 +23,53 @@ public:
~ORecur();
ORecur &operator=( const ORecur& );
bool operator==(const ORecur& )const;
+
+ bool doesRecur()const;
+ /* if it recurrs on that day */
+ bool doesRecur( const QDate& );
RepeatType type()const;
int frequency()const;
int position()const;
char days()const;
bool hasEndDate()const;
+ QDate start()const;
QDate endDate()const;
time_t endDateUTC()const;
time_t createTime()const;
+
+ /**
+ * FromWhereToStart is not included!!!
+ */
+ bool nextOcurrence( const QDate& FromWhereToStart, QDate &recurDate );
+ /**
+ * The module this ORecur belongs to
+ */
+ QString service()const;
+
+ /*
+ * reference to the exception list
+ */
+ ExceptionList &exceptions();
+
+ /**
+ * the current repetition
+ */
int repetition()const;
void setType( const RepeatType& );
void setFrequency( int freq );
void setPosition( int pos );
void setDays( char c);
void setEndDate( const QDate& dt );
+ void setStart( const QDate& dt );
void setEndDateUTC( time_t );
void setCreateTime( time_t );
void setHasEndDate( bool b );
void setRepitition(int );
+
+ void setService( const QString& ser );
private:
void deref();
inline void checkOrModify();
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
@@ -44,8 +44,9 @@ OTodoAccess::List OTodoAccess::overDue() {
List lis( m_todoBackEnd->overDue(), this );
return lis;
}
void OTodoAccess::addAlarm( const OTodo& event) {
+/* FIXME use the new notifier architecture
if (!event.hasAlarmDateTime() )
return;
QDateTime now = QDateTime::currentDateTime();
@@ -56,8 +57,9 @@ void OTodoAccess::addAlarm( const OTodo& event) {
"QPE/Application/todolist",
"alarm(QDateTime,int)", event.uid() );
}
+*/
}
void OTodoAccess::delAlarm( int uid) {
QDateTime schedule; // Create null DateTime
@@ -78,4 +80,7 @@ OTodoAccess::List OTodoAccess::sorted( bool ascending, int sort,int filter, int
filter, cat );
OTodoAccess::List list( ints, this );
return list;
}
+void OTodoAccess::removeAllCompleted() {
+ m_todoBackEnd->removeAllCompleted();
+}
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
@@ -67,8 +67,19 @@ public:
*/
void mergeWith( const QValueList<OTodo>& );
/**
+ * delete all already completed items
+ */
+ void removeAllCompleted();
+
+signals:
+ /**
+ * if the OTodoAccess was changed
+ */
+ void signalChanged( const OTodoAccess* );
+private:
+ /**
* add an Alarm to the AlarmServer
*/
void addAlarm( const OTodo& );
@@ -77,14 +88,8 @@ public:
* the alarm server
*/
void delAlarm( int uid );
-signals:
- /**
- * if the OTodoAccess was changed
- */
- void signalChanged( const OTodoAccess* );
-private:
int m_cat;
OTodoAccessBackend* m_todoBackEnd;
class OTodoAccessPrivate;
OTodoAccessPrivate* d;
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
@@ -1094,9 +1094,11 @@ void OContact::insertEmails( const QStringList &v )
{
for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
insertEmail( *it );
}
-
+int OContact::rtti() {
+ return 2;
+}
void OContact::setUid( int i )
{
OPimRecord::setUid(i);
replace( Qtopia::AddressUid , QString::number(i));
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
@@ -210,8 +210,9 @@ public:
QString emailSeparator() const { return " "; }
// the emails should be seperated by a comma
void setEmails( const QString &v );
QString emails() const { return find( Qtopia::Emails ); }
+ static int rtti();
private:
// The XML-Backend needs some access to the private functions
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
@@ -14,8 +14,9 @@
#include "opimstate.h"
#include "orecur.h"
#include "opimmaintainer.h"
+#include "opimnotifymanager.h"
#include "otodo.h"
@@ -30,13 +31,14 @@ struct OTodo::OTodoData : public QShared {
QString desc;
QString sum;
QMap<QString, QString> extra;
ushort prog;
- bool hasAlarmDateTime :1;
- QDateTime alarmDateTime;
OPimState state;
ORecur recur;
OPimMaintainer maintainer;
+ QDate start;
+ QDate completed;
+ OPimNotifyManager notifiers;
};
OTodo::OTodo(const OTodo &event )
: OPimRecord( event ), data( event.data )
@@ -72,10 +74,8 @@ OTodo::OTodo(bool completed, int priority,
data->priority = priority;
data->sum = summary;
data->prog = progress;
data->desc = Qtopia::simplifyMultiLineSpace(description );
- data->hasAlarmDateTime = false;
-
}
OTodo::OTodo(bool completed, int priority,
const QStringList &category,
const QString& summary,
@@ -95,10 +95,8 @@ OTodo::OTodo(bool completed, int priority,
data->priority = priority;
data->sum = summary;
data->prog = progress;
data->desc = Qtopia::simplifyMultiLineSpace(description );
- data->hasAlarmDateTime = false;
-
}
bool OTodo::match( const QRegExp &regExp )const
{
if( QString::number( data->priority ).find( regExp ) != -1 ){
@@ -119,11 +117,13 @@ bool OTodo::isCompleted() const
bool OTodo::hasDueDate() const
{
return data->hasDate;
}
-bool OTodo::hasAlarmDateTime() const
-{
- return data->hasAlarmDateTime;
+bool OTodo::hasStartDate()const {
+ return data->start.isValid();
+}
+bool OTodo::hasCompletedDate()const {
+ return data->completed.isValid();
}
int OTodo::priority()const
{
return data->priority;
@@ -139,14 +139,14 @@ ushort OTodo::progress() const
QDate OTodo::dueDate()const
{
return data->date;
}
-
-QDateTime OTodo::alarmDateTime() const
-{
- return data->alarmDateTime;
+QDate OTodo::startDate()const {
+ return data->start;
+}
+QDate OTodo::completedDate()const {
+ return data->completed;
}
-
QString OTodo::description()const
{
return data->desc;
}
@@ -168,13 +168,8 @@ void OTodo::setHasDueDate( bool hasDate )
{
changeOrModify();
data->hasDate = hasDate;
}
-void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime )
-{
- changeOrModify();
- data->hasAlarmDateTime = hasAlarmDateTime;
-}
void OTodo::setDescription(const QString &desc )
{
// qWarning( "desc " + desc );
changeOrModify();
@@ -189,17 +184,20 @@ void OTodo::setPriority(int prio )
{
changeOrModify();
data->priority = prio;
}
-void OTodo::setDueDate( QDate date )
+void OTodo::setDueDate( const QDate& date )
{
changeOrModify();
data->date = date;
}
-void OTodo::setAlarmDateTime( const QDateTime& alarm )
-{
+void OTodo::setStartDate( const QDate& date ) {
+ changeOrModify();
+ data->start = date;
+}
+void OTodo::setCompletedDate( const QDate& date ) {
changeOrModify();
- data->alarmDateTime = alarm;
+ data->completed = date;
}
void OTodo::setState( const OPimState& state ) {
changeOrModify();
data->state = state;
@@ -253,20 +251,18 @@ QString OTodo::toRichText() const
text += "<b>" + QObject::tr( "Deadline:") + " </b>";
text += dueDate().toString();
text += "<br>";
}
- if (hasAlarmDateTime() ){
- text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>";
- text += alarmDateTime().toString();
- text += "<br>";
- }
text += "<b>" + QObject::tr( "Category:") + "</b> ";
text += categoryNames().join(", ");
text += "<br>";
return text;
}
+OPimNotifyManager& OTodo::notifiers() {
+ return data->notifiers;
+}
bool OTodo::operator<( const OTodo &toDoEvent )const{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
@@ -326,12 +322,8 @@ bool OTodo::operator==(const OTodo &toDoEvent )const
if ( data->hasDate != toDoEvent.data->hasDate ) return false;
if ( data->date != toDoEvent.data->date ) return false;
if ( data->sum != toDoEvent.data->sum ) return false;
if ( data->desc != toDoEvent.data->desc ) return false;
- if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime )
- return false;
- if ( data->alarmDateTime != toDoEvent.data->alarmDateTime )
- return false;
if ( data->maintainer != toDoEvent.data->maintainer )
return false;
return OPimRecord::operator==( toDoEvent );
@@ -370,11 +362,13 @@ QMap<int, QString> OTodo::toMap() const {
map.insert( DateMonth, QString::number( data->date.month() ) );
map.insert( DateYear, QString::number( data->date.year() ) );
map.insert( Progress, QString::number( data->prog ) );
// map.insert( CrossReference, crossToString() );
- map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) );
- map.insert( AlarmDateTime, data->alarmDateTime.toString() );
-
+ /* FIXME!!! map.insert( State, );
+ map.insert( Recurrence, );
+ map.insert( Reminders, );
+ map.
+ */
return map;
}
QMap<QString, QString> OTodo::toExtraMap()const {
@@ -407,17 +401,21 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) {
dest->desc = src->desc;
dest->sum = src->sum;
dest->extra = src->extra;
dest->prog = src->prog;
- dest->hasAlarmDateTime = src->hasAlarmDateTime;
- dest->alarmDateTime = src->alarmDateTime;
dest->state = src->state;
dest->recur = src->recur;
dest->maintainer = src->maintainer;
+ dest->start = src->start;
+ dest->completed = src->completed;
+ dest->notifiers = src->notifiers;
}
QString OTodo::type() const {
return QString::fromLatin1("OTodo");
}
QString OTodo::recordField(int /*id*/ )const {
return QString::null;
}
+int OTodo::rtti(){
+ return 1;
+}
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
@@ -18,8 +18,9 @@
class OPimState;
class ORecur;
class OPimMaintainer;
+class OPimNotifyManager;
class OTodo : public OPimRecord {
public:
typedef QValueList<OTodo> ValueList;
enum RecordFields {
@@ -34,15 +35,16 @@ public:
DateMonth,
DateYear,
Progress,
CrossReference,
- HasAlarmDateTime,
- AlarmDateTime,
State,
- Recurrance,
+ Recurrence,
Alarms,
Reminders,
- Notifiers
+ Notifiers,
+ Maintainer,
+ StartDate,
+ CompletedDate
};
public:
// priorities from Very low to very high
enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow };
@@ -72,11 +74,11 @@ public:
ushort progress = 0,
bool hasDate = false, QDate date = QDate::currentDate(),
int uid = 0 /* empty */ );
- /* Copy c'tor
-
- **/
+ /** Copy c'tor
+ *
+ */
OTodo(const OTodo & );
/**
*destructor
@@ -91,8 +93,10 @@ public:
/**
* Does this Event have a deadline
*/
bool hasDueDate() const;
+ bool hasStartDate()const;
+ bool hasCompletedDate()const;
/**
* Does this Event has an alarm time ?
*/
@@ -113,11 +117,16 @@ public:
*/
QDate dueDate()const;
/**
- * Alarm Date and Time
+ * When did it start?
+ */
+ QDate startDate()const;
+
+ /**
+ * When was it completed?
*/
- QDateTime alarmDateTime()const;
+ QDate completedDate()const;
/**
* What is the state of this OTodo?
*/
@@ -148,10 +157,18 @@ public:
* Return this todoevent in a RichText formatted QString
*/
QString toRichText() const;
+ /*
+ * check if the sharing is still fine!! -zecke
+ */
+ /**
+ * return a reference to our notifiers...
+ */
+ OPimNotifyManager &notifiers();
+
/**
- * reimplementation
+ * reimplementations
*/
QString type()const;
QString toShortText()const;
QMap<QString, QString> toExtraMap()const;
@@ -171,13 +188,12 @@ public:
/**
* set if this todo got an end data
*/
void setHasDueDate( bool hasDate );
-
- /**
- * set if this todo has an alarm time and date
- */
- void setHasAlarmDateTime ( bool hasAlarm );
+ // FIXME we do not have these for start, completed
+ // cause we'll use the isNull() of QDate for figuring
+ // out if it's has a date...
+ // decide what to do here? -zecke
/**
* Set the priority of the Todo
*/
@@ -190,10 +206,19 @@ public:
/**
* set the end date
*/
- void setDueDate( QDate date );
+ void setDueDate( const QDate& date );
+ /**
+ * set the start date
+ */
+ void setStartDate( const QDate& date );
+
+ /**
+ * set the completed date
+ */
+ void setCompletedDate( const QDate& date );
void setRecurrence( const ORecur& );
/**
* set the alarm time
@@ -226,8 +251,10 @@ public:
bool operator>=(const OTodo &toDoEvent)const;
bool operator==(const OTodo &toDoEvent )const;
OTodo &operator=(const OTodo &toDoEvent );
+ static int rtti();
+
private:
class OTodoPrivate;
struct OTodoData;
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 @@
+#include <qapplication.h>
+#include <qcopchannel_qws.h>
+
+#include <qpe/qcopenvelope_qws.h>
+
+#include "opimmainwindow.h"
+
+OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent,
+ const char* name, WFlags flag )
+ : QMainWindow( parent, name, flag ), m_service( service ), m_fallBack(0l) {
+
+ /*
+ * let's generate our QCopChannel
+ */
+ m_str = QString("QPE/"+m_service).local8Bit();
+ m_channel= new QCopChannel(m_str, this );
+ connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ),
+ this, SLOT( appMessage( const QCString&, const QByteArray& ) ) );
+
+ /* connect flush and reload */
+ connect(qApp, SIGNAL(flush() ),
+ this, SLOT(flush() ) );
+ connect(qApp, SIGNAL(reload() ),
+ this, SLOT(reload() ) );
+}
+OPimMainWindow::~OPimMainWindow() {
+ delete m_channel;
+}
+QCopChannel* OPimMainWindow::channel() {
+ return m_channel;
+}
+void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) {
+ /*
+ * create demands to create
+ * a new record...
+ */
+ QDataStream stream(array, IO_ReadOnly);
+ if ( cmd == "create()" ) {
+ int uid = create();
+ QCopEnvelope e(m_str, "created(int)" );
+ e << uid;
+ }else if ( cmd == "remove(int)" ) {
+ int uid;
+ stream >> uid;
+ bool rem = remove( uid );
+ QCopEnvelope e(m_str, "removed(bool)" );
+ e << rem;
+ }else if ( cmd == "beam(int,int)" ) {
+ int uid, trans;
+ stream >> uid;
+ stream >> trans;
+ beam( uid, trans );
+ }else if ( cmd == "show(int)" ) {
+ int uid;
+ stream >> uid;
+ show( uid );
+ }else if ( cmd == "edit(int)" ) {
+ int uid;
+ stream >> uid;
+ edit( uid );
+ }else if ( cmd == "add(int,QByteArray)" ) {
+ int rtti;
+ QByteArray array;
+ stream >> rtti;
+ stream >> array;
+ m_fallBack = record(rtti, array );
+ if (!m_fallBack) return;
+ add( *m_fallBack );
+ delete m_fallBack;
+ }
+}
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 @@
+#ifndef OPIE_PIM_MAINWINDOW_H
+#define OPIE_PIM_MAINWINDOW_H
+
+#include <qmainwindow.h>
+
+#include <opie/opimrecord.h>
+
+/**
+ * This is a common Opie PIM MainWindow
+ * it takes care of the QCOP internals
+ * and implements some functions
+ * for the URL scripting schema
+ */
+/*
+ * due Qt and Templates with signal and slots
+ * do not work that good :(
+ * (Ok how to moc a template ;) )
+ * We will have the mainwindow which calls a struct which
+ * is normally reimplemented as a template ;)
+ */
+
+class QCopChannel;
+class OPimMainWindow : public QMainWindow {
+ Q_OBJECT
+public:
+ enum TransPort { BlueTooth=0,
+ IrDa };
+
+ OPimMainWindow( const QString& service, QWidget *parent = 0, const char* name = 0,
+ WFlags f = WType_TopLevel);
+ virtual ~OPimMainWindow();
+
+
+protected slots:
+ /* for syncing */
+ virtual void flush() = 0;
+ virtual void reload() = 0;
+
+ /** create a new Records and return the uid */
+ virtual int create() = 0;
+ /** remove a record with UID == uid */
+ virtual bool remove( int uid ) = 0;
+ /** beam the record with UID = uid */
+ virtual void beam( int uid , int transport = IrDa) = 0;
+
+ /** show the record with UID == uid */
+ virtual void show( int uid ) = 0;
+ /** edit the record */
+ virtual void edit( int uid ) = 0;
+
+ /** make a copy of it! */
+ virtual void add( const OPimRecord& ) = 0;
+
+ /* I would love to do this as a template
+ * but can't think of a right way
+ * because I need signal and slots -zecke
+ */
+ /*
+ * the only pointer in the whole PIM API :(
+ */
+ virtual OPimRecord* record( int rtti, const QByteArray& ) = 0;
+ QCopChannel* channel();
+
+private slots:
+ void appMessage( const QCString&, const QByteArray& );
+
+
+private:
+ class Private;
+ Private* d;
+
+ QCopChannel* m_channel;
+ QString m_service;
+ QCString m_str;
+ OPimRecord* m_fallBack;
+};
+
+
+#endif