author | zecke <zecke> | 2002-11-02 12:36:34 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-11-02 12:36:34 (UTC) |
commit | ffd0a764e4ac7f9bf29edf3b9b4d341e153ecf4a (patch) (side-by-side diff) | |
tree | 601ac645a3768c1fe89fce01243f54a24f08dc15 | |
parent | 74f49994a9c19bdfdbfdfb57a5cf5e1a1f966b53 (diff) | |
download | opie-ffd0a764e4ac7f9bf29edf3b9b4d341e153ecf4a.zip opie-ffd0a764e4ac7f9bf29edf3b9b4d341e153ecf4a.tar.gz opie-ffd0a764e4ac7f9bf29edf3b9b4d341e153ecf4a.tar.bz2 |
Fix a vCard problem in OContact
cell phones do not set the UId property...
add some more states to otodo
-rw-r--r-- | libopie/pim/ocontact.cpp | 41 | ||||
-rw-r--r-- | libopie/pim/opimrecord.h | 4 | ||||
-rw-r--r-- | libopie/pim/opimstate.cpp | 64 | ||||
-rw-r--r-- | libopie/pim/opimstate.h | 44 | ||||
-rw-r--r-- | libopie/pim/orecordlist.h | 2 | ||||
-rw-r--r-- | libopie/pim/orecur.cpp | 9 | ||||
-rw-r--r-- | libopie/pim/orecur.h | 2 | ||||
-rw-r--r-- | libopie/pim/otodo.cpp | 23 | ||||
-rw-r--r-- | libopie/pim/otodo.h | 27 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.h | 4 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimstate.cpp | 64 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimstate.h | 44 | ||||
-rw-r--r-- | libopie2/opiepim/core/orecur.cpp | 9 | ||||
-rw-r--r-- | libopie2/opiepim/core/orecur.h | 2 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.cpp | 41 | ||||
-rw-r--r-- | libopie2/opiepim/orecordlist.h | 2 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.cpp | 23 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.h | 27 |
18 files changed, 388 insertions, 44 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp index acd65c4..cd238ef 100644 --- a/libopie/pim/ocontact.cpp +++ b/libopie/pim/ocontact.cpp @@ -1129,3 +1129,3 @@ static VObject *createVObject( const OContact &c ) QString birthd_rfc2425 = QString("%1-%2-%3") - .arg( c.birthday().year() ) + .arg( c.birthday().year() ) .arg( c.birthday().month(), 2 ) @@ -1136,3 +1136,3 @@ static VObject *createVObject( const OContact &c ) birthd_rfc2425.replace( pos, 1, "0" ); - + qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); @@ -1390,3 +1390,3 @@ static OContact parseVObject( VObject *obj ) c.setChildren( value ); - } + } else if ( name == VCBirthDateProp ) { @@ -1394,3 +1394,3 @@ static OContact parseVObject( VObject *obj ) c.setBirthday( convVCardDateToDate( value ) ); - + } @@ -1466,3 +1466,12 @@ QValueList<OContact> OContact::readVCard( const QString &filename ) while ( obj ) { - contacts.append( parseVObject( obj ) ); + OContact con = parseVObject( obj ); + /* + * if uid is 0 assign a new one + * this at least happens on + * Nokia6210 + */ + if ( con.uid() == 0 ) + con.setUid( 1 ); + + contacts.append(con ); @@ -1529,3 +1538,3 @@ class QString OContact::recordField( int pos ) const // In future releases, we should store birthday and anniversary -// internally as QDate instead of QString ! +// internally as QDate instead of QString ! // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) @@ -1536,6 +1545,6 @@ class QString OContact::recordField( int pos ) const void OContact::setBirthday( const QDate &v ) -{ +{ if ( ( !v.isNull() ) && ( v.isValid() ) ) replace( Qtopia::Birthday, TimeConversion::toString( v ) ); - + } @@ -1555,4 +1564,4 @@ void OContact::setAnniversary( const QDate &v ) */ -QDate OContact::birthday() const -{ +QDate OContact::birthday() const +{ QString str = find( Qtopia::Birthday ); @@ -1569,4 +1578,4 @@ QDate OContact::birthday() const */ -QDate OContact::anniversary() const -{ +QDate OContact::anniversary() const +{ QDate empty; @@ -1575,3 +1584,3 @@ QDate OContact::anniversary() const if ( !str.isEmpty() ) - return TimeConversion::fromString ( str ); + return TimeConversion::fromString ( str ); else @@ -1609,3 +1618,3 @@ void OContact::removeEmail( const QString &v ) QStringList emails = emailList(); - + // otherwise, must first contain it @@ -1642,5 +1651,5 @@ void OContact::setDefaultEmail( const QString &v ) - if ( !e.isEmpty() ) + if ( !e.isEmpty() ) insertEmail( e ); - + } diff --git a/libopie/pim/opimrecord.h b/libopie/pim/opimrecord.h index dbb94ed..d9ccad4 100644 --- a/libopie/pim/opimrecord.h +++ b/libopie/pim/opimrecord.h @@ -11,3 +11,3 @@ /** - * This is the base class for + * This is the base class for * all PIM Records @@ -112,3 +112,3 @@ public: void setRelations( const QString&, QArray<int> ids ); - + /** diff --git a/libopie/pim/opimstate.cpp b/libopie/pim/opimstate.cpp new file mode 100644 index 0000000..6fb2feb --- a/dev/null +++ b/libopie/pim/opimstate.cpp @@ -0,0 +1,64 @@ +#include <qshared.h> + +#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/libopie/pim/opimstate.h b/libopie/pim/opimstate.h new file mode 100644 index 0000000..731181e --- a/dev/null +++ b/libopie/pim/opimstate.h @@ -0,0 +1,44 @@ +#ifndef OPIE_PIM_STATE_H +#define OPIE_PIM_STATE_H + +#include <qstring.h> + +/** + * 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/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h index 2f4a5d3..8ed41e2 100644 --- a/libopie/pim/orecordlist.h +++ b/libopie/pim/orecordlist.h @@ -236,3 +236,3 @@ template <class T> uint ORecordListIterator<T>::count()const { - return m_uids.count(); + return m_uids.count(); } diff --git a/libopie/pim/orecur.cpp b/libopie/pim/orecur.cpp index 6c81f8f..257d4fd 100644 --- a/libopie/pim/orecur.cpp +++ b/libopie/pim/orecur.cpp @@ -23,2 +23,3 @@ struct ORecur::Data : public QShared { time_t create; + int rep; }; @@ -80,2 +81,5 @@ time_t ORecur::createTime()const { } +int ORecur::repetition()const { + return data->rep; +} void ORecur::setType( const RepeatType& z) { @@ -112,2 +116,6 @@ void ORecur::setHasEndDate( bool b) { } +void ORecur::setRepitition( int rep ) { + checkOrModify(); + data->rep = rep; +} void ORecur::checkOrModify() { @@ -123,2 +131,3 @@ void ORecur::checkOrModify() { d2->create = data->create; + d2->rep = data->rep; data = d2; diff --git a/libopie/pim/orecur.h b/libopie/pim/orecur.h index 89258f8..d24d72d 100644 --- a/libopie/pim/orecur.h +++ b/libopie/pim/orecur.h @@ -33,2 +33,3 @@ public: time_t createTime()const; + int repetition()const; @@ -42,2 +43,3 @@ public: void setHasEndDate( bool b ); + void setRepitition(int ); private: diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp index 765d5a9..0d5b1d3 100644 --- a/libopie/pim/otodo.cpp +++ b/libopie/pim/otodo.cpp @@ -14,3 +14,4 @@ - +#include "opimstate.h" +#include "orecur.h" #include "otodo.h" @@ -32,2 +33,4 @@ struct OTodo::OTodoData : public QShared { QDateTime alarmDateTime; + OPimState state; + ORecur recur; }; @@ -146,2 +149,8 @@ QString OTodo::description()const } +OPimState OTodo::state()const { + return data->state; +} +ORecur OTodo::recurrence()const { + return data->recur; +} void OTodo::setCompleted( bool completed ) @@ -187,2 +196,10 @@ void OTodo::setAlarmDateTime( const QDateTime& alarm ) } +void OTodo::setState( const OPimState& state ) { + changeOrModify(); + data->state = state; +} +void OTodo::setRecurrence( const ORecur& rec) { + changeOrModify(); + data->recur = rec; +} bool OTodo::isOverdue( ) @@ -360,3 +377,3 @@ void OTodo::changeOrModify() { if ( data->count != 1 ) { -// qWarning("changeOrModify"); + qWarning("changeOrModify"); data->deref(); @@ -378,2 +395,4 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) { dest->alarmDateTime = src->alarmDateTime; + dest->state = src->state; + dest->recur = src->recur; } diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h index 5bd91d6..2cdc587 100644 --- a/libopie/pim/otodo.h +++ b/libopie/pim/otodo.h @@ -18,2 +18,4 @@ +class OPimState; +class ORecur; class OTodo : public OPimRecord { @@ -35,3 +37,8 @@ public: HasAlarmDateTime, - AlarmDateTime + AlarmDateTime, + State, + Recurrance, + Alarms, + Reminders, + Notifiers }; @@ -113,2 +120,12 @@ public: /** + * What is the state of this OTodo? + */ + OPimState state()const; + + /** + * the recurrance of this + */ + ORecur recurrence()const; + + /** * The description of the todo @@ -172,2 +189,4 @@ public: + + void setRecurrence( const ORecur& ); /** @@ -179,2 +198,8 @@ public: void setSummary(const QString& ); + + /** + * set the state of a Todo + * @param state State what the todo should take + */ + void setState( const OPimState& state); bool isOverdue(); 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 @@ -11,3 +11,3 @@ /** - * This is the base class for + * This is the base class for * all PIM Records @@ -112,3 +112,3 @@ public: void setRelations( const QString&, QArray<int> ids ); - + /** 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 <qshared.h> + +#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 <qstring.h> + +/** + * 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 @@ -23,2 +23,3 @@ struct ORecur::Data : public QShared { time_t create; + int rep; }; @@ -80,2 +81,5 @@ time_t ORecur::createTime()const { } +int ORecur::repetition()const { + return data->rep; +} void ORecur::setType( const RepeatType& z) { @@ -112,2 +116,6 @@ void ORecur::setHasEndDate( bool b) { } +void ORecur::setRepitition( int rep ) { + checkOrModify(); + data->rep = rep; +} void ORecur::checkOrModify() { @@ -123,2 +131,3 @@ void ORecur::checkOrModify() { 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 @@ -33,2 +33,3 @@ public: time_t createTime()const; + int repetition()const; @@ -42,2 +43,3 @@ public: void setHasEndDate( bool b ); + void setRepitition(int ); private: diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp index acd65c4..cd238ef 100644 --- a/libopie2/opiepim/ocontact.cpp +++ b/libopie2/opiepim/ocontact.cpp @@ -1129,3 +1129,3 @@ static VObject *createVObject( const OContact &c ) QString birthd_rfc2425 = QString("%1-%2-%3") - .arg( c.birthday().year() ) + .arg( c.birthday().year() ) .arg( c.birthday().month(), 2 ) @@ -1136,3 +1136,3 @@ static VObject *createVObject( const OContact &c ) birthd_rfc2425.replace( pos, 1, "0" ); - + qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); @@ -1390,3 +1390,3 @@ static OContact parseVObject( VObject *obj ) c.setChildren( value ); - } + } else if ( name == VCBirthDateProp ) { @@ -1394,3 +1394,3 @@ static OContact parseVObject( VObject *obj ) c.setBirthday( convVCardDateToDate( value ) ); - + } @@ -1466,3 +1466,12 @@ QValueList<OContact> OContact::readVCard( const QString &filename ) while ( obj ) { - contacts.append( parseVObject( obj ) ); + OContact con = parseVObject( obj ); + /* + * if uid is 0 assign a new one + * this at least happens on + * Nokia6210 + */ + if ( con.uid() == 0 ) + con.setUid( 1 ); + + contacts.append(con ); @@ -1529,3 +1538,3 @@ class QString OContact::recordField( int pos ) const // In future releases, we should store birthday and anniversary -// internally as QDate instead of QString ! +// internally as QDate instead of QString ! // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) @@ -1536,6 +1545,6 @@ class QString OContact::recordField( int pos ) const void OContact::setBirthday( const QDate &v ) -{ +{ if ( ( !v.isNull() ) && ( v.isValid() ) ) replace( Qtopia::Birthday, TimeConversion::toString( v ) ); - + } @@ -1555,4 +1564,4 @@ void OContact::setAnniversary( const QDate &v ) */ -QDate OContact::birthday() const -{ +QDate OContact::birthday() const +{ QString str = find( Qtopia::Birthday ); @@ -1569,4 +1578,4 @@ QDate OContact::birthday() const */ -QDate OContact::anniversary() const -{ +QDate OContact::anniversary() const +{ QDate empty; @@ -1575,3 +1584,3 @@ QDate OContact::anniversary() const if ( !str.isEmpty() ) - return TimeConversion::fromString ( str ); + return TimeConversion::fromString ( str ); else @@ -1609,3 +1618,3 @@ void OContact::removeEmail( const QString &v ) QStringList emails = emailList(); - + // otherwise, must first contain it @@ -1642,5 +1651,5 @@ void OContact::setDefaultEmail( const QString &v ) - if ( !e.isEmpty() ) + if ( !e.isEmpty() ) insertEmail( e ); - + } diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h index 2f4a5d3..8ed41e2 100644 --- a/libopie2/opiepim/orecordlist.h +++ b/libopie2/opiepim/orecordlist.h @@ -236,3 +236,3 @@ template <class T> uint ORecordListIterator<T>::count()const { - return m_uids.count(); + return m_uids.count(); } diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp index 765d5a9..0d5b1d3 100644 --- a/libopie2/opiepim/otodo.cpp +++ b/libopie2/opiepim/otodo.cpp @@ -14,3 +14,4 @@ - +#include "opimstate.h" +#include "orecur.h" #include "otodo.h" @@ -32,2 +33,4 @@ struct OTodo::OTodoData : public QShared { QDateTime alarmDateTime; + OPimState state; + ORecur recur; }; @@ -146,2 +149,8 @@ QString OTodo::description()const } +OPimState OTodo::state()const { + return data->state; +} +ORecur OTodo::recurrence()const { + return data->recur; +} void OTodo::setCompleted( bool completed ) @@ -187,2 +196,10 @@ void OTodo::setAlarmDateTime( const QDateTime& alarm ) } +void OTodo::setState( const OPimState& state ) { + changeOrModify(); + data->state = state; +} +void OTodo::setRecurrence( const ORecur& rec) { + changeOrModify(); + data->recur = rec; +} bool OTodo::isOverdue( ) @@ -360,3 +377,3 @@ void OTodo::changeOrModify() { if ( data->count != 1 ) { -// qWarning("changeOrModify"); + qWarning("changeOrModify"); data->deref(); @@ -378,2 +395,4 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) { dest->alarmDateTime = src->alarmDateTime; + dest->state = src->state; + dest->recur = src->recur; } diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h index 5bd91d6..2cdc587 100644 --- a/libopie2/opiepim/otodo.h +++ b/libopie2/opiepim/otodo.h @@ -18,2 +18,4 @@ +class OPimState; +class ORecur; class OTodo : public OPimRecord { @@ -35,3 +37,8 @@ public: HasAlarmDateTime, - AlarmDateTime + AlarmDateTime, + State, + Recurrance, + Alarms, + Reminders, + Notifiers }; @@ -113,2 +120,12 @@ public: /** + * What is the state of this OTodo? + */ + OPimState state()const; + + /** + * the recurrance of this + */ + ORecur recurrence()const; + + /** * The description of the todo @@ -172,2 +189,4 @@ public: + + void setRecurrence( const ORecur& ); /** @@ -179,2 +198,8 @@ public: void setSummary(const QString& ); + + /** + * set the state of a Todo + * @param state State what the todo should take + */ + void setState( const OPimState& state); bool isOverdue(); |