From ffd0a764e4ac7f9bf29edf3b9b4d341e153ecf4a Mon Sep 17 00:00:00 2001 From: zecke Date: Sat, 02 Nov 2002 12:36:34 +0000 Subject: Fix a vCard problem in OContact cell phones do not set the UId property... add some more states to otodo --- (limited to 'libopie2/opiepim/core') diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h index dbb94ed..d9ccad4 100644 --- a/libopie2/opiepim/core/opimrecord.h +++ b/libopie2/opiepim/core/opimrecord.h @@ -9,7 +9,7 @@ /** - * This is the base class for + * This is the base class for * all PIM Records * */ @@ -110,7 +110,7 @@ public: * set the relations for an app */ void setRelations( const QString&, QArray ids ); - + /** * set the uid */ diff --git a/libopie2/opiepim/core/opimstate.cpp b/libopie2/opiepim/core/opimstate.cpp new file mode 100644 index 0000000..6fb2feb --- a/dev/null +++ b/libopie2/opiepim/core/opimstate.cpp @@ -0,0 +1,64 @@ +#include + +#include "opimstate.h" + +/* + * for one int this does not make + * much sense but never the less + * we will do it for the future + */ +struct OPimState::Data : public QShared { + Data() : QShared(),state(Undefined) { + } + int state; +}; + +OPimState::OPimState( int state ) { + data = new Data; + data->state = state; +} +OPimState::OPimState( const OPimState& st) : + data( st.data ) { + /* ref up */ + data->ref(); +} +OPimState::~OPimState() { + if ( data->deref() ) { + delete data ; + data = 0; + } +} +bool OPimState::operator==( const OPimState& st) { + if ( data->state == st.data->state ) return true; + + return false; +} +OPimState &OPimState::operator=( const OPimState& st) { + st.data->ref(); + deref(); + data = st.data; + + return *this; +} +void OPimState::setState( int st) { + copyInternally(); + data->state = st; +} +int OPimState::state()const { + return data->state; +} +void OPimState::deref() { + if ( data->deref() ) { + delete data; + data = 0l; + } +} +void OPimState::copyInternally() { + /* we need to change it */ + if ( data->count != 1 ) { + data->deref(); + Data* d2 = new Data; + d2->state = data->state; + data = d2; + } +} diff --git a/libopie2/opiepim/core/opimstate.h b/libopie2/opiepim/core/opimstate.h new file mode 100644 index 0000000..731181e --- a/dev/null +++ b/libopie2/opiepim/core/opimstate.h @@ -0,0 +1,44 @@ +#ifndef OPIE_PIM_STATE_H +#define OPIE_PIM_STATE_H + +#include + +/** + * The State of a Task + * This class encapsules the state of a todo + * and it's shared too + */ +/* + * in c a simple struct would be enough ;) + * g_new_state(); + * g_do_some_thing( state_t* ); + * ;) + */ +class OPimState { +public: + enum State { + Started = 0, + Postponed, + Finished, + NotStarted, + Undefined + }; + OPimState( int state = Undefined ); + OPimState( const OPimState& ); + ~OPimState(); + + bool operator==( const OPimState& ); + OPimState &operator=( const OPimState& ); + void setState( int state); + int state()const; +private: + void deref(); + inline void copyInternally(); + struct Data; + Data* data; + class Private; + Private *d; +}; + + +#endif diff --git a/libopie2/opiepim/core/orecur.cpp b/libopie2/opiepim/core/orecur.cpp index 6c81f8f..257d4fd 100644 --- a/libopie2/opiepim/core/orecur.cpp +++ b/libopie2/opiepim/core/orecur.cpp @@ -21,6 +21,7 @@ struct ORecur::Data : public QShared { bool hasEnd : 1; time_t end; time_t create; + int rep; }; @@ -78,6 +79,9 @@ time_t ORecur::endDateUTC()const { time_t ORecur::createTime()const { return data->create; } +int ORecur::repetition()const { + return data->rep; +} void ORecur::setType( const RepeatType& z) { checkOrModify(); data->type = z; @@ -110,6 +114,10 @@ void ORecur::setHasEndDate( bool b) { checkOrModify(); data->hasEnd = b; } +void ORecur::setRepitition( int rep ) { + checkOrModify(); + data->rep = rep; +} void ORecur::checkOrModify() { if ( data->count != 1 ) { data->deref(); @@ -121,6 +129,7 @@ void ORecur::checkOrModify() { d2->hasEnd = data->hasEnd; d2->end = data->end; d2->create = data->create; + d2->rep = data->rep; data = d2; } } diff --git a/libopie2/opiepim/core/orecur.h b/libopie2/opiepim/core/orecur.h index 89258f8..d24d72d 100644 --- a/libopie2/opiepim/core/orecur.h +++ b/libopie2/opiepim/core/orecur.h @@ -31,6 +31,7 @@ public: QDate endDate()const; time_t endDateUTC()const; time_t createTime()const; + int repetition()const; void setType( const RepeatType& ); void setFrequency( int freq ); @@ -40,6 +41,7 @@ public: void setEndDateUTC( time_t ); void setCreateTime( time_t ); void setHasEndDate( bool b ); + void setRepitition(int ); private: void deref(); inline void checkOrModify(); -- cgit v0.9.0.2