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 @@ -1082,104 +1082,104 @@ static VObject *createVObject( const OContact &c ) safeAddProp( home_phone, VCCellularProp ); home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); safeAddProp( home_phone, VCHomeProp ); safeAddProp( home_phone, VCFaxProp ); VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); safeAddProp( url, VCHomeProp ); // work properties VObject *work_adr= safeAddProp( vcard, VCAdrProp ); safeAddProp( work_adr, VCWorkProp ); safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); safeAddProp( work_phone, VCWorkProp ); work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); safeAddProp( work_phone, VCWorkProp ); safeAddProp( work_phone, VCCellularProp ); work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); safeAddProp( work_phone, VCWorkProp ); safeAddProp( work_phone, VCFaxProp ); work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); safeAddProp( work_phone, VCWorkProp ); safeAddProp( work_phone, VCPagerProp ); url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); safeAddProp( url, VCWorkProp ); VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); safeAddProp( title, VCWorkProp ); QStringList emails = c.emailList(); emails.prepend( c.defaultEmail() ); for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); safeAddProp( email, VCInternetProp ); } safeAddPropValue( vcard, VCNoteProp, c.notes() ); // Exporting Birthday regarding RFC 2425 (5.8.4) if ( c.birthday().isValid() ){ QString birthd_rfc2425 = QString("%1-%2-%3") - .arg( c.birthday().year() ) + .arg( c.birthday().year() ) .arg( c.birthday().month(), 2 ) .arg( c.birthday().day(), 2 ); // Now replace spaces with "0"... int pos = 0; while ( ( pos = birthd_rfc2425.find (' ') ) > 0 ) birthd_rfc2425.replace( pos, 1, "0" ); - + qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() ); } if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { VObject *org = safeAddProp( vcard, VCOrgProp ); safeAddPropValue( org, VCOrgNameProp, c.company() ); safeAddPropValue( org, VCOrgUnitProp, c.department() ); safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); } // some values we have to export as custom fields safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) ); safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); return vcard; } /*! \internal */ static QDate convVCardDateToDate( const QString& datestr ) { int monthPos = datestr.find('-'); int dayPos = datestr.find('-', monthPos+1 ); int sep_ignore = 1; if ( monthPos == -1 || dayPos == -1 ) { qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD ) if ( datestr.length() == 8 ){ monthPos = 4; dayPos = 6; sep_ignore = 0; qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); } else { return QDate(); } } int y = datestr.left( monthPos ).toInt(); int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); @@ -1343,311 +1343,320 @@ static OContact parseVObject( VObject *obj ) QCString name = vObjectTypeInfo( o ); if ( name == VCHomeProp ) c.setHomeWebpage( value ); else if ( name == VCWorkProp ) c.setBusinessWebpage( value ); } } else if ( name == VCOrgProp ) { VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); QCString name = vObjectName( o ); QString value = vObjectStringZValue( o ); if ( name == VCOrgNameProp ) c.setCompany( value ); else if ( name == VCOrgUnitProp ) c.setDepartment( value ); else if ( name == VCOrgUnit2Prop ) c.setOffice( value ); } } else if ( name == VCTitleProp ) { c.setJobTitle( value ); } else if ( name == "X-Qtopia-Profession" ) { c.setProfession( value ); } else if ( name == "X-Qtopia-Manager" ) { c.setManager( value ); } else if ( name == "X-Qtopia-Assistant" ) { c.setAssistant( value ); } else if ( name == "X-Qtopia-Spouse" ) { c.setSpouse( value ); } else if ( name == "X-Qtopia-Gender" ) { c.setGender( value ); } else if ( name == "X-Qtopia-Anniversary" ) { c.setAnniversary( TimeConversion::fromString( value ) ); } else if ( name == "X-Qtopia-Nickname" ) { c.setNickname( value ); } else if ( name == "X-Qtopia-Children" ) { c.setChildren( value ); - } + } else if ( name == VCBirthDateProp ) { // Reading Birthdate regarding RFC 2425 (5.8.4) c.setBirthday( convVCardDateToDate( value ) ); - + } #if 0 else { printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); QCString name = vObjectName( o ); QString value = vObjectStringZValue( o ); printf(" subprop: %s = %s\n", name.data(), value.latin1() ); } } #endif } c.setFileAs(); return c; } /*! Writes the list of \a contacts as a set of VCards to the file \a filename. */ void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) { QFileDirect f( filename.utf8().data() ); if ( !f.open( IO_WriteOnly ) ) { qWarning("Unable to open vcard write"); return; } QValueList<OContact>::ConstIterator it; for( it = contacts.begin(); it != contacts.end(); ++it ) { VObject *obj = createVObject( *it ); writeVObject(f.directHandle() , obj ); cleanVObject( obj ); } cleanStrTbl(); } /*! writes \a contact as a VCard to the file \a filename. */ void OContact::writeVCard( const QString &filename, const OContact &contact) { QFileDirect f( filename.utf8().data() ); if ( !f.open( IO_WriteOnly ) ) { qWarning("Unable to open vcard write"); return; } VObject *obj = createVObject( contact ); writeVObject( f.directHandle() , obj ); cleanVObject( obj ); cleanStrTbl(); } /*! Returns the set of contacts read as VCards from the file \a filename. */ QValueList<OContact> OContact::readVCard( const QString &filename ) { qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); qDebug("vobject = %p", obj ); QValueList<OContact> contacts; 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 ); VObject *t = obj; obj = nextVObjectInList(obj); cleanVObject( t ); } return contacts; } /*! Returns TRUE if the contact matches the regular expression \a regexp. Otherwise returns FALSE. */ bool OContact::match( const QString ®exp ) const { return match(QRegExp(regexp)); } /*! \overload Returns TRUE if the contact matches the regular expression \a regexp. Otherwise returns FALSE. */ bool OContact::match( const QRegExp &r ) const { bool match; match = false; QMap<int, QString>::ConstIterator it; for ( it = mMap.begin(); it != mMap.end(); ++it ) { if ( (*it).find( r ) > -1 ) { match = true; break; } } return match; } QString OContact::toShortText() const { return ( fullName() ); } QString OContact::type() const { return QString::fromLatin1( "OContact" ); } // Definition is missing ! (se) QMap<QString,QString> OContact::toExtraMap() const { qWarning ("Function not implemented: OContact::toExtraMap()"); QMap <QString,QString> useless; return useless; } class QString OContact::recordField( int pos ) const { QStringList SLFIELDS = fields(); // ?? why this ? (se) return SLFIELDS[pos]; } // 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) /*! \fn void OContact::setBirthday( const QDate& date ) Sets the birthday for the contact to \a date. */ void OContact::setBirthday( const QDate &v ) -{ +{ if ( ( !v.isNull() ) && ( v.isValid() ) ) replace( Qtopia::Birthday, TimeConversion::toString( v ) ); - + } /*! \fn void OContact::setAnniversary( const QDate &date ) Sets the anniversary of the contact to \a date. */ void OContact::setAnniversary( const QDate &v ) { if ( ( !v.isNull() ) && ( v.isValid() ) ) replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); } /*! \fn QDate OContact::birthday() const Returns the birthday of the contact. */ -QDate OContact::birthday() const -{ +QDate OContact::birthday() const +{ QString str = find( Qtopia::Birthday ); qWarning ("Birthday %s", str.latin1() ); if ( !str.isEmpty() ) return TimeConversion::fromString ( str ); else return QDate(); } /*! \fn QDate OContact::anniversary() const Returns the anniversary of the contact. */ -QDate OContact::anniversary() const -{ +QDate OContact::anniversary() const +{ QDate empty; QString str = find( Qtopia::Anniversary ); qWarning ("Anniversary %s", str.latin1() ); if ( !str.isEmpty() ) - return TimeConversion::fromString ( str ); + return TimeConversion::fromString ( str ); else return empty; } void OContact::insertEmail( const QString &v ) { //qDebug("insertEmail %s", v.latin1()); QString e = v.simplifyWhiteSpace(); QString def = defaultEmail(); // if no default, set it as the default email and don't insert if ( def.isEmpty() ) { setDefaultEmail( e ); // will insert into the list for us return; } // otherwise, insert assuming doesn't already exist QString emailsStr = find( Qtopia::Emails ); if ( emailsStr.contains( e )) return; if ( !emailsStr.isEmpty() ) emailsStr += emailSeparator(); emailsStr += e; replace( Qtopia::Emails, emailsStr ); } void OContact::removeEmail( const QString &v ) { QString e = v.simplifyWhiteSpace(); QString def = defaultEmail(); QString emailsStr = find( Qtopia::Emails ); QStringList emails = emailList(); - + // otherwise, must first contain it if ( !emailsStr.contains( e ) ) return; // remove it //qDebug(" removing email from list %s", e.latin1()); emails.remove( e ); // reset the string emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator replace( Qtopia::Emails, emailsStr ); // if default, then replace the default email with the first one if ( def == e ) { //qDebug("removeEmail is default; setting new default"); if ( !emails.count() ) clearEmails(); else // setDefaultEmail will remove e from the list setDefaultEmail( emails.first() ); } } void OContact::clearEmails() { mMap.remove( Qtopia::DefaultEmail ); mMap.remove( Qtopia::Emails ); } void OContact::setDefaultEmail( const QString &v ) { QString e = v.simplifyWhiteSpace(); //qDebug("OContact::setDefaultEmail %s", e.latin1()); replace( Qtopia::DefaultEmail, e ); - if ( !e.isEmpty() ) + if ( !e.isEmpty() ) insertEmail( e ); - + } void OContact::insertEmails( const QStringList &v ) { for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) insertEmail( *it ); } 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 @@ -1,60 +1,60 @@ #ifndef OPIE_PIM_RECORD_H #define OPIE_PIM_RECORD_H #include <qmap.h> #include <qstring.h> #include <qstringlist.h> #include <qpe/palmtoprecord.h> /** - * This is the base class for + * This is the base class for * all PIM Records * */ class OPimRecord : public Qtopia::Record { public: /** * c'tor * uid of 0 isEmpty * uid of 1 will be assigned a new one */ OPimRecord(int uid = 0); ~OPimRecord(); /** * copy c'tor */ OPimRecord( const OPimRecord& rec ); /** * copy operator */ OPimRecord &operator=( const OPimRecord& ); /** * category names resolved */ QStringList categoryNames()const; /** * set category names they will be resolved */ void setCategoryNames( const QStringList& ); /** * addCategoryName adds a name * to the internal category list */ void addCategoryName( const QString& ); /** * if a Record isEmpty * it's empty if it's 0 */ virtual bool isEmpty()const; /** * toRichText summary */ @@ -65,69 +65,69 @@ public: */ virtual QString toShortText()const = 0; /** * the name of the Record */ virtual QString type()const = 0; /** * converts the internal structure to a map */ virtual QMap<int, QString> toMap()const = 0; /** * key value representation of extra items */ virtual QMap<QString, QString> toExtraMap()const = 0; /** * the name for a recordField */ virtual QString recordField(int)const = 0; /** * the related apps names */ QStringList relatedApps()const; /** * the realtions between an app */ QArray<int> relations( const QString& app )const; /** * clear the relations for all relations * with app */ void clearRelation( const QString& app ); /** * add a relation */ void addRelation( const QString& app, int id ); /** * set the relations for an app */ void setRelations( const QString&, QArray<int> ids ); - + /** * set the uid */ virtual void setUid( int uid ); protected: Qtopia::UidGen &uidGen(); QString crossToString()const; private: class OPimRecordPrivate; OPimRecordPrivate *d; QMap<QString, QArray<int> > m_relations; static Qtopia::UidGen m_uidGen; }; #endif 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 @@ -189,97 +189,97 @@ ORecordListIterator<T> &ORecordListIterator<T>::operator++() { template <class T> ORecordListIterator<T> &ORecordListIterator<T>::operator--() { m_direction = false; if ( m_current > 0 ) { --m_current; m_end = false; } else m_end = true; return *this; } template <class T> bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { /* if both are at we're the same.... */ if ( m_end == it.m_end ) return true; if ( m_uids != it.m_uids ) return false; if ( m_current != it.m_current ) return false; if ( m_temp != it.m_temp ) return false; return true; } template <class T> bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { return !(*this == it ); } template <class T> ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, const Base* t ) : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), m_direction( false ) { } template <class T> uint ORecordListIterator<T>::current()const { return m_current; } template <class T> void ORecordListIterator<T>::setCurrent( uint cur ) { if( cur < m_uids.count() ) { m_end = false; m_current= cur; } } template <class T> uint ORecordListIterator<T>::count()const { - return m_uids.count(); + return m_uids.count(); } template <class T> ORecordList<T>::ORecordList( const QArray<int>& ids, const Base* acc ) : m_ids( ids ), m_acc( acc ) { } template <class T> ORecordList<T>::~ORecordList() { /* nothing to do here */ } template <class T> ORecordList<T>::Iterator ORecordList<T>::begin() { Iterator it( m_ids, m_acc ); return it; } template <class T> ORecordList<T>::Iterator ORecordList<T>::end() { Iterator it( m_ids, m_acc ); it.m_end = true; it.m_current = m_ids.count(); return it; } template <class T> uint ORecordList<T>::count()const { return m_ids.count(); } template <class T> T ORecordList<T>::operator[]( uint i ) { if ( i < 0 || (i+1) > m_ids.count() ) return T(); /* forward */ return m_acc->find( m_ids[i], m_ids, i ); } template <class T> int ORecordList<T>::uidAt( uint i ) { return m_ids[i]; } template <class T> bool ORecordList<T>::remove( int uid ) { QArray<int> copy( m_ids.count() ); int counter = 0; bool ret_val = false; for (uint i = 0; i < m_ids.count(); i++){ if ( m_ids[i] != uid ){ 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 @@ -1,127 +1,136 @@ #include <qshared.h> #include <qtopia/timeconversion.h> #include "orecur.h" struct ORecur::Data : public QShared { Data() : QShared() { type = ORecur::NoRepeat; freq = -1; days = 0; pos = 0; create = -1; hasEnd = FALSE; end = 0; } char days; // Q_UINT8 for 8 seven days;) ORecur::RepeatType type; int freq; int pos; bool hasEnd : 1; time_t end; time_t create; + int rep; }; ORecur::ORecur() { data = new Data; } ORecur::ORecur( const ORecur& rec) : data( rec.data ) { data->ref(); } ORecur::~ORecur() { if ( data->deref() ) { delete data; data = 0l; } } void ORecur::deref() { if ( data->deref() ) { delete data; data = 0l; } } bool ORecur::operator==( const ORecur& )const { return false; } ORecur &ORecur::operator=( const ORecur& re) { re.data->ref(); deref(); data = re.data; return *this; } ORecur::RepeatType ORecur::type()const{ return data->type; } int ORecur::frequency()const { return data->freq; } int ORecur::position()const { return data->pos; } char ORecur::days() const{ return data->days; } bool ORecur::hasEndDate()const { return data->hasEnd; } QDate ORecur::endDate()const { return TimeConversion::fromUTC( data->end ).date(); } time_t ORecur::endDateUTC()const { return data->end; } 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; } void ORecur::setFrequency( int freq ) { checkOrModify(); data->freq = freq; } void ORecur::setPosition( int pos ) { checkOrModify(); data->pos = pos; } void ORecur::setDays( char c ) { checkOrModify(); data->days = c; } void ORecur::setEndDate( const QDate& dt) { checkOrModify(); data->end = TimeConversion::toUTC( dt ); } void ORecur::setEndDateUTC( time_t t) { checkOrModify(); data->end = t; } void ORecur::setCreateTime( time_t t) { checkOrModify(); data->create = t; } 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(); Data* d2 = new Data; d2->days = data->days; d2->type = data->type; d2->freq = data->freq; d2->pos = data->pos; d2->hasEnd = data->hasEnd; d2->end = data->end; 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 @@ -1,54 +1,56 @@ /* * GPL from TT */ #ifndef OPIE_RECUR_H #define OPIE_RECUR_H #include <sys/types.h> #include <qdatetime.h> class ORecur { public: 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 }; ORecur(); ORecur( const ORecur& ); ~ORecur(); ORecur &operator=( const ORecur& ); bool operator==(const ORecur& )const; RepeatType type()const; int frequency()const; int position()const; char days()const; bool hasEndDate()const; QDate endDate()const; time_t endDateUTC()const; time_t createTime()const; + 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 setEndDateUTC( time_t ); void setCreateTime( time_t ); void setHasEndDate( bool b ); + void setRepitition(int ); private: void deref(); inline void checkOrModify(); class Data; Data* data; class ORecurPrivate; ORecurPrivate *d; }; #endif 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 @@ -1,80 +1,83 @@ #include <qobject.h> #include <qshared.h> #include <qpe/palmtopuidgen.h> #include <qpe/stringutil.h> #include <qpe/palmtoprecord.h> #include <qpe/stringutil.h> #include <qpe/categories.h> #include <qpe/categoryselect.h> - +#include "opimstate.h" +#include "orecur.h" #include "otodo.h" struct OTodo::OTodoData : public QShared { OTodoData() : QShared() { }; QDate date; bool isCompleted:1; bool hasDate:1; int priority; QString desc; QString sum; QMap<QString, QString> extra; ushort prog; bool hasAlarmDateTime :1; QDateTime alarmDateTime; + OPimState state; + ORecur recur; }; OTodo::OTodo(const OTodo &event ) : OPimRecord( event ), data( event.data ) { data->ref(); // qWarning("ref up"); } OTodo::~OTodo() { // qWarning("~OTodo " ); if ( data->deref() ) { // qWarning("OTodo::dereffing"); delete data; data = 0l; } } OTodo::OTodo(bool completed, int priority, const QArray<int> &category, const QString& summary, const QString &description, ushort progress, bool hasDate, QDate date, int uid ) : OPimRecord( uid ) { // qWarning("OTodoData " + summary); setCategories( category ); data = new OTodoData; data->date = date; data->isCompleted = completed; data->hasDate = hasDate; 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, const QString &description, ushort progress, bool hasDate, QDate date, int uid ) : OPimRecord( uid ) { @@ -99,137 +102,151 @@ bool OTodo::match( const QRegExp ®Exp )const return true; }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ return true; }else if(data->desc.find( regExp ) != -1 ){ return true; }else if(data->sum.find( regExp ) != -1 ) { return true; } return false; } bool OTodo::isCompleted() const { return data->isCompleted; } bool OTodo::hasDueDate() const { return data->hasDate; } bool OTodo::hasAlarmDateTime() const { return data->hasAlarmDateTime; } int OTodo::priority()const { return data->priority; } QString OTodo::summary() const { return data->sum; } ushort OTodo::progress() const { return data->prog; } QDate OTodo::dueDate()const { return data->date; } QDateTime OTodo::alarmDateTime() const { return data->alarmDateTime; } QString OTodo::description()const { return data->desc; } +OPimState OTodo::state()const { + return data->state; +} +ORecur OTodo::recurrence()const { + return data->recur; +} void OTodo::setCompleted( bool completed ) { changeOrModify(); data->isCompleted = completed; } 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(); data->desc = Qtopia::simplifyMultiLineSpace(desc ); } void OTodo::setSummary( const QString& sum ) { changeOrModify(); data->sum = sum; } void OTodo::setPriority(int prio ) { changeOrModify(); data->priority = prio; } void OTodo::setDueDate( QDate date ) { changeOrModify(); data->date = date; } void OTodo::setAlarmDateTime( const QDateTime& alarm ) { changeOrModify(); data->alarmDateTime = alarm; } +void OTodo::setState( const OPimState& state ) { + changeOrModify(); + data->state = state; +} +void OTodo::setRecurrence( const ORecur& rec) { + changeOrModify(); + data->recur = rec; +} bool OTodo::isOverdue( ) { if( data->hasDate && !data->isCompleted) return QDate::currentDate() > data->date; return false; } void OTodo::setProgress(ushort progress ) { changeOrModify(); data->prog = progress; } QString OTodo::toShortText() const { return summary(); } /*! Returns a richt text string */ QString OTodo::toRichText() const { QString text; QStringList catlist; // Description of the todo if ( !summary().isEmpty() ) { text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; } if( !description().isEmpty() ){ text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; } text += "<br><br><br>"; text += "<b>" + QObject::tr( "Priority:") +" </b>" + QString::number( priority() ) + " <br>"; text += "<b>" + QObject::tr( "Progress:") + " </b>" + QString::number( progress() ) + " %<br>"; if (hasDueDate() ){ 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>"; } @@ -313,74 +330,76 @@ void OTodo::deref() { if ( data->deref() ) { // qWarning("deleting"); delete data; data= 0; } } OTodo &OTodo::operator=(const OTodo &item ) { OPimRecord::operator=( item ); //qWarning("operator= ref "); item.data->ref(); deref(); data = item.data; return *this; } QMap<int, QString> OTodo::toMap() const { QMap<int, QString> map; map.insert( Uid, QString::number( uid() ) ); map.insert( Category, idsToString( categories() ) ); map.insert( HasDate, QString::number( data->hasDate ) ); map.insert( Completed, QString::number( data->isCompleted ) ); map.insert( Description, data->desc ); map.insert( Summary, data->sum ); map.insert( Priority, QString::number( data->priority ) ); map.insert( DateDay, QString::number( data->date.day() ) ); 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() ); return map; } QMap<QString, QString> OTodo::toExtraMap()const { return data->extra; } /** * change or modify looks at the ref count and either * creates a new QShared Object or it can modify it * right in place */ void OTodo::changeOrModify() { if ( data->count != 1 ) { -// qWarning("changeOrModify"); + qWarning("changeOrModify"); data->deref(); OTodoData* d2 = new OTodoData(); copy(data, d2 ); data = d2; } } void OTodo::copy( OTodoData* src, OTodoData* dest ) { dest->date = src->date; dest->isCompleted = src->isCompleted; dest->hasDate = src->hasDate; dest->priority = src->priority; 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; } QString OTodo::type() const { return QString::fromLatin1("OTodo"); } QString OTodo::recordField(int id )const { return QString::null; } 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 @@ -1,209 +1,234 @@ #ifndef OPIE_TODO_EVENT_H #define OPIE_TODO_EVENT_H #include <qarray.h> #include <qmap.h> #include <qregexp.h> #include <qstringlist.h> #include <qdatetime.h> #include <qvaluelist.h> #include <qpe/recordfields.h> #include <qpe/palmtopuidgen.h> #include <opie/opimrecord.h> +class OPimState; +class ORecur; class OTodo : public OPimRecord { public: typedef QValueList<OTodo> ValueList; enum RecordFields { Uid = Qtopia::UID_ID, Category = Qtopia::CATEGORY_ID, HasDate, Completed, Description, Summary, Priority, DateDay, DateMonth, DateYear, Progress, CrossReference, HasAlarmDateTime, - AlarmDateTime + AlarmDateTime, + State, + Recurrance, + Alarms, + Reminders, + Notifiers }; public: // priorities from Very low to very high enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; /* Constructs a new ToDoEvent @param completed Is the TodoEvent completed @param priority What is the priority of this ToDoEvent @param category Which category does it belong( uid ) @param summary A small summary of the todo @param description What is this ToDoEvent about @param hasDate Does this Event got a deadline @param date what is the deadline? @param uid what is the UUID of this Event **/ OTodo( bool completed = false, int priority = Normal, const QStringList &category = QStringList(), const QString &summary = QString::null , const QString &description = QString::null, ushort progress = 0, bool hasDate = false, QDate date = QDate::currentDate(), int uid = 0 /*empty*/ ); OTodo( bool completed, int priority, const QArray<int>& category, const QString& summary = QString::null, const QString& description = QString::null, ushort progress = 0, bool hasDate = false, QDate date = QDate::currentDate(), int uid = 0 /* empty */ ); /* Copy c'tor **/ OTodo(const OTodo & ); /** *destructor */ ~OTodo(); /** * Is this event completed? */ bool isCompleted() const; /** * Does this Event have a deadline */ bool hasDueDate() const; /** * Does this Event has an alarm time ? */ bool hasAlarmDateTime() const; /** * What is the priority? */ int priority()const ; /** * progress as ushort 0, 20, 40, 60, 80 or 100% */ ushort progress() const; /** * The due Date */ QDate dueDate()const; /** * Alarm Date and Time */ QDateTime alarmDateTime()const; /** + * What is the state of this OTodo? + */ + OPimState state()const; + + /** + * the recurrance of this + */ + ORecur recurrence()const; + + /** * The description of the todo */ QString description()const; /** * A small summary of the todo */ QString summary() const; /** * @reimplemented * Return this todoevent in a RichText formatted QString */ QString toRichText() const; /** * reimplementation */ QString type()const; QString toShortText()const; QMap<QString, QString> toExtraMap()const; QString recordField(int id )const; /** * toMap puts all data into the map. int relates * to ToDoEvent RecordFields enum */ QMap<int, QString> toMap()const; /** * Set if this Todo is completed */ void setCompleted(bool completed ); /** * 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 ); /** * Set the priority of the Todo */ void setPriority(int priority ); /** * Set the progress. */ void setProgress( ushort progress ); /** * set the end date */ void setDueDate( QDate date ); + + void setRecurrence( const ORecur& ); /** * set the alarm time */ void setAlarmDateTime ( const QDateTime& alarm ); void setDescription(const QString& ); 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(); bool match( const QRegExp &r )const; bool operator<(const OTodo &toDoEvent )const; bool operator<=(const OTodo &toDoEvent )const; bool operator!=(const OTodo &toDoEvent )const; bool operator>(const OTodo &toDoEvent )const; bool operator>=(const OTodo &toDoEvent)const; bool operator==(const OTodo &toDoEvent )const; OTodo &operator=(const OTodo &toDoEvent ); private: class OTodoPrivate; struct OTodoData; void deref(); inline void changeOrModify(); void copy( OTodoData* src, OTodoData* dest ); OTodoPrivate *d; OTodoData *data; }; inline bool OTodo::operator!=(const OTodo &toDoEvent )const { return !(*this == toDoEvent); } #endif 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 @@ -1,60 +1,60 @@ #ifndef OPIE_PIM_RECORD_H #define OPIE_PIM_RECORD_H #include <qmap.h> #include <qstring.h> #include <qstringlist.h> #include <qpe/palmtoprecord.h> /** - * This is the base class for + * This is the base class for * all PIM Records * */ class OPimRecord : public Qtopia::Record { public: /** * c'tor * uid of 0 isEmpty * uid of 1 will be assigned a new one */ OPimRecord(int uid = 0); ~OPimRecord(); /** * copy c'tor */ OPimRecord( const OPimRecord& rec ); /** * copy operator */ OPimRecord &operator=( const OPimRecord& ); /** * category names resolved */ QStringList categoryNames()const; /** * set category names they will be resolved */ void setCategoryNames( const QStringList& ); /** * addCategoryName adds a name * to the internal category list */ void addCategoryName( const QString& ); /** * if a Record isEmpty * it's empty if it's 0 */ virtual bool isEmpty()const; /** * toRichText summary */ @@ -65,69 +65,69 @@ public: */ virtual QString toShortText()const = 0; /** * the name of the Record */ virtual QString type()const = 0; /** * converts the internal structure to a map */ virtual QMap<int, QString> toMap()const = 0; /** * key value representation of extra items */ virtual QMap<QString, QString> toExtraMap()const = 0; /** * the name for a recordField */ virtual QString recordField(int)const = 0; /** * the related apps names */ QStringList relatedApps()const; /** * the realtions between an app */ QArray<int> relations( const QString& app )const; /** * clear the relations for all relations * with app */ void clearRelation( const QString& app ); /** * add a relation */ void addRelation( const QString& app, int id ); /** * set the relations for an app */ void setRelations( const QString&, QArray<int> ids ); - + /** * set the uid */ virtual void setUid( int uid ); protected: Qtopia::UidGen &uidGen(); QString crossToString()const; private: class OPimRecordPrivate; OPimRecordPrivate *d; QMap<QString, QArray<int> > m_relations; static Qtopia::UidGen m_uidGen; }; #endif 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 @@ -1,127 +1,136 @@ #include <qshared.h> #include <qtopia/timeconversion.h> #include "orecur.h" struct ORecur::Data : public QShared { Data() : QShared() { type = ORecur::NoRepeat; freq = -1; days = 0; pos = 0; create = -1; hasEnd = FALSE; end = 0; } char days; // Q_UINT8 for 8 seven days;) ORecur::RepeatType type; int freq; int pos; bool hasEnd : 1; time_t end; time_t create; + int rep; }; ORecur::ORecur() { data = new Data; } ORecur::ORecur( const ORecur& rec) : data( rec.data ) { data->ref(); } ORecur::~ORecur() { if ( data->deref() ) { delete data; data = 0l; } } void ORecur::deref() { if ( data->deref() ) { delete data; data = 0l; } } bool ORecur::operator==( const ORecur& )const { return false; } ORecur &ORecur::operator=( const ORecur& re) { re.data->ref(); deref(); data = re.data; return *this; } ORecur::RepeatType ORecur::type()const{ return data->type; } int ORecur::frequency()const { return data->freq; } int ORecur::position()const { return data->pos; } char ORecur::days() const{ return data->days; } bool ORecur::hasEndDate()const { return data->hasEnd; } QDate ORecur::endDate()const { return TimeConversion::fromUTC( data->end ).date(); } time_t ORecur::endDateUTC()const { return data->end; } 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; } void ORecur::setFrequency( int freq ) { checkOrModify(); data->freq = freq; } void ORecur::setPosition( int pos ) { checkOrModify(); data->pos = pos; } void ORecur::setDays( char c ) { checkOrModify(); data->days = c; } void ORecur::setEndDate( const QDate& dt) { checkOrModify(); data->end = TimeConversion::toUTC( dt ); } void ORecur::setEndDateUTC( time_t t) { checkOrModify(); data->end = t; } void ORecur::setCreateTime( time_t t) { checkOrModify(); data->create = t; } 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(); Data* d2 = new Data; d2->days = data->days; d2->type = data->type; d2->freq = data->freq; d2->pos = data->pos; 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 @@ -1,54 +1,56 @@ /* * GPL from TT */ #ifndef OPIE_RECUR_H #define OPIE_RECUR_H #include <sys/types.h> #include <qdatetime.h> class ORecur { public: 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 }; ORecur(); ORecur( const ORecur& ); ~ORecur(); ORecur &operator=( const ORecur& ); bool operator==(const ORecur& )const; RepeatType type()const; int frequency()const; int position()const; char days()const; bool hasEndDate()const; QDate endDate()const; time_t endDateUTC()const; time_t createTime()const; + 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 setEndDateUTC( time_t ); void setCreateTime( time_t ); void setHasEndDate( bool b ); + void setRepitition(int ); private: void deref(); inline void checkOrModify(); class Data; Data* data; class ORecurPrivate; ORecurPrivate *d; }; #endif 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 @@ -1082,104 +1082,104 @@ static VObject *createVObject( const OContact &c ) safeAddProp( home_phone, VCCellularProp ); home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); safeAddProp( home_phone, VCHomeProp ); safeAddProp( home_phone, VCFaxProp ); VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); safeAddProp( url, VCHomeProp ); // work properties VObject *work_adr= safeAddProp( vcard, VCAdrProp ); safeAddProp( work_adr, VCWorkProp ); safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); safeAddProp( work_phone, VCWorkProp ); work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); safeAddProp( work_phone, VCWorkProp ); safeAddProp( work_phone, VCCellularProp ); work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); safeAddProp( work_phone, VCWorkProp ); safeAddProp( work_phone, VCFaxProp ); work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); safeAddProp( work_phone, VCWorkProp ); safeAddProp( work_phone, VCPagerProp ); url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); safeAddProp( url, VCWorkProp ); VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); safeAddProp( title, VCWorkProp ); QStringList emails = c.emailList(); emails.prepend( c.defaultEmail() ); for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); safeAddProp( email, VCInternetProp ); } safeAddPropValue( vcard, VCNoteProp, c.notes() ); // Exporting Birthday regarding RFC 2425 (5.8.4) if ( c.birthday().isValid() ){ QString birthd_rfc2425 = QString("%1-%2-%3") - .arg( c.birthday().year() ) + .arg( c.birthday().year() ) .arg( c.birthday().month(), 2 ) .arg( c.birthday().day(), 2 ); // Now replace spaces with "0"... int pos = 0; while ( ( pos = birthd_rfc2425.find (' ') ) > 0 ) birthd_rfc2425.replace( pos, 1, "0" ); - + qWarning("Exporting birthday as: %s", birthd_rfc2425.latin1()); safeAddPropValue( vcard, VCBirthDateProp, birthd_rfc2425.latin1() ); } if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { VObject *org = safeAddProp( vcard, VCOrgProp ); safeAddPropValue( org, VCOrgNameProp, c.company() ); safeAddPropValue( org, VCOrgUnitProp, c.department() ); safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); } // some values we have to export as custom fields safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); safeAddPropValue( vcard, "X-Qtopia-Anniversary", TimeConversion::toString( c.anniversary() ) ); safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); return vcard; } /*! \internal */ static QDate convVCardDateToDate( const QString& datestr ) { int monthPos = datestr.find('-'); int dayPos = datestr.find('-', monthPos+1 ); int sep_ignore = 1; if ( monthPos == -1 || dayPos == -1 ) { qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD ) if ( datestr.length() == 8 ){ monthPos = 4; dayPos = 6; sep_ignore = 0; qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); } else { return QDate(); } } int y = datestr.left( monthPos ).toInt(); int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); @@ -1343,311 +1343,320 @@ static OContact parseVObject( VObject *obj ) QCString name = vObjectTypeInfo( o ); if ( name == VCHomeProp ) c.setHomeWebpage( value ); else if ( name == VCWorkProp ) c.setBusinessWebpage( value ); } } else if ( name == VCOrgProp ) { VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); QCString name = vObjectName( o ); QString value = vObjectStringZValue( o ); if ( name == VCOrgNameProp ) c.setCompany( value ); else if ( name == VCOrgUnitProp ) c.setDepartment( value ); else if ( name == VCOrgUnit2Prop ) c.setOffice( value ); } } else if ( name == VCTitleProp ) { c.setJobTitle( value ); } else if ( name == "X-Qtopia-Profession" ) { c.setProfession( value ); } else if ( name == "X-Qtopia-Manager" ) { c.setManager( value ); } else if ( name == "X-Qtopia-Assistant" ) { c.setAssistant( value ); } else if ( name == "X-Qtopia-Spouse" ) { c.setSpouse( value ); } else if ( name == "X-Qtopia-Gender" ) { c.setGender( value ); } else if ( name == "X-Qtopia-Anniversary" ) { c.setAnniversary( TimeConversion::fromString( value ) ); } else if ( name == "X-Qtopia-Nickname" ) { c.setNickname( value ); } else if ( name == "X-Qtopia-Children" ) { c.setChildren( value ); - } + } else if ( name == VCBirthDateProp ) { // Reading Birthdate regarding RFC 2425 (5.8.4) c.setBirthday( convVCardDateToDate( value ) ); - + } #if 0 else { printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); QCString name = vObjectName( o ); QString value = vObjectStringZValue( o ); printf(" subprop: %s = %s\n", name.data(), value.latin1() ); } } #endif } c.setFileAs(); return c; } /*! Writes the list of \a contacts as a set of VCards to the file \a filename. */ void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) { QFileDirect f( filename.utf8().data() ); if ( !f.open( IO_WriteOnly ) ) { qWarning("Unable to open vcard write"); return; } QValueList<OContact>::ConstIterator it; for( it = contacts.begin(); it != contacts.end(); ++it ) { VObject *obj = createVObject( *it ); writeVObject(f.directHandle() , obj ); cleanVObject( obj ); } cleanStrTbl(); } /*! writes \a contact as a VCard to the file \a filename. */ void OContact::writeVCard( const QString &filename, const OContact &contact) { QFileDirect f( filename.utf8().data() ); if ( !f.open( IO_WriteOnly ) ) { qWarning("Unable to open vcard write"); return; } VObject *obj = createVObject( contact ); writeVObject( f.directHandle() , obj ); cleanVObject( obj ); cleanStrTbl(); } /*! Returns the set of contacts read as VCards from the file \a filename. */ QValueList<OContact> OContact::readVCard( const QString &filename ) { qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); qDebug("vobject = %p", obj ); QValueList<OContact> contacts; 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 ); VObject *t = obj; obj = nextVObjectInList(obj); cleanVObject( t ); } return contacts; } /*! Returns TRUE if the contact matches the regular expression \a regexp. Otherwise returns FALSE. */ bool OContact::match( const QString ®exp ) const { return match(QRegExp(regexp)); } /*! \overload Returns TRUE if the contact matches the regular expression \a regexp. Otherwise returns FALSE. */ bool OContact::match( const QRegExp &r ) const { bool match; match = false; QMap<int, QString>::ConstIterator it; for ( it = mMap.begin(); it != mMap.end(); ++it ) { if ( (*it).find( r ) > -1 ) { match = true; break; } } return match; } QString OContact::toShortText() const { return ( fullName() ); } QString OContact::type() const { return QString::fromLatin1( "OContact" ); } // Definition is missing ! (se) QMap<QString,QString> OContact::toExtraMap() const { qWarning ("Function not implemented: OContact::toExtraMap()"); QMap <QString,QString> useless; return useless; } class QString OContact::recordField( int pos ) const { QStringList SLFIELDS = fields(); // ?? why this ? (se) return SLFIELDS[pos]; } // 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) /*! \fn void OContact::setBirthday( const QDate& date ) Sets the birthday for the contact to \a date. */ void OContact::setBirthday( const QDate &v ) -{ +{ if ( ( !v.isNull() ) && ( v.isValid() ) ) replace( Qtopia::Birthday, TimeConversion::toString( v ) ); - + } /*! \fn void OContact::setAnniversary( const QDate &date ) Sets the anniversary of the contact to \a date. */ void OContact::setAnniversary( const QDate &v ) { if ( ( !v.isNull() ) && ( v.isValid() ) ) replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); } /*! \fn QDate OContact::birthday() const Returns the birthday of the contact. */ -QDate OContact::birthday() const -{ +QDate OContact::birthday() const +{ QString str = find( Qtopia::Birthday ); qWarning ("Birthday %s", str.latin1() ); if ( !str.isEmpty() ) return TimeConversion::fromString ( str ); else return QDate(); } /*! \fn QDate OContact::anniversary() const Returns the anniversary of the contact. */ -QDate OContact::anniversary() const -{ +QDate OContact::anniversary() const +{ QDate empty; QString str = find( Qtopia::Anniversary ); qWarning ("Anniversary %s", str.latin1() ); if ( !str.isEmpty() ) - return TimeConversion::fromString ( str ); + return TimeConversion::fromString ( str ); else return empty; } void OContact::insertEmail( const QString &v ) { //qDebug("insertEmail %s", v.latin1()); QString e = v.simplifyWhiteSpace(); QString def = defaultEmail(); // if no default, set it as the default email and don't insert if ( def.isEmpty() ) { setDefaultEmail( e ); // will insert into the list for us return; } // otherwise, insert assuming doesn't already exist QString emailsStr = find( Qtopia::Emails ); if ( emailsStr.contains( e )) return; if ( !emailsStr.isEmpty() ) emailsStr += emailSeparator(); emailsStr += e; replace( Qtopia::Emails, emailsStr ); } void OContact::removeEmail( const QString &v ) { QString e = v.simplifyWhiteSpace(); QString def = defaultEmail(); QString emailsStr = find( Qtopia::Emails ); QStringList emails = emailList(); - + // otherwise, must first contain it if ( !emailsStr.contains( e ) ) return; // remove it //qDebug(" removing email from list %s", e.latin1()); emails.remove( e ); // reset the string emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator replace( Qtopia::Emails, emailsStr ); // if default, then replace the default email with the first one if ( def == e ) { //qDebug("removeEmail is default; setting new default"); if ( !emails.count() ) clearEmails(); else // setDefaultEmail will remove e from the list setDefaultEmail( emails.first() ); } } void OContact::clearEmails() { mMap.remove( Qtopia::DefaultEmail ); mMap.remove( Qtopia::Emails ); } void OContact::setDefaultEmail( const QString &v ) { QString e = v.simplifyWhiteSpace(); //qDebug("OContact::setDefaultEmail %s", e.latin1()); replace( Qtopia::DefaultEmail, e ); - if ( !e.isEmpty() ) + if ( !e.isEmpty() ) insertEmail( e ); - + } void OContact::insertEmails( const QStringList &v ) { for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) insertEmail( *it ); } 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 @@ -189,97 +189,97 @@ ORecordListIterator<T> &ORecordListIterator<T>::operator++() { template <class T> ORecordListIterator<T> &ORecordListIterator<T>::operator--() { m_direction = false; if ( m_current > 0 ) { --m_current; m_end = false; } else m_end = true; return *this; } template <class T> bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { /* if both are at we're the same.... */ if ( m_end == it.m_end ) return true; if ( m_uids != it.m_uids ) return false; if ( m_current != it.m_current ) return false; if ( m_temp != it.m_temp ) return false; return true; } template <class T> bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { return !(*this == it ); } template <class T> ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, const Base* t ) : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), m_direction( false ) { } template <class T> uint ORecordListIterator<T>::current()const { return m_current; } template <class T> void ORecordListIterator<T>::setCurrent( uint cur ) { if( cur < m_uids.count() ) { m_end = false; m_current= cur; } } template <class T> uint ORecordListIterator<T>::count()const { - return m_uids.count(); + return m_uids.count(); } template <class T> ORecordList<T>::ORecordList( const QArray<int>& ids, const Base* acc ) : m_ids( ids ), m_acc( acc ) { } template <class T> ORecordList<T>::~ORecordList() { /* nothing to do here */ } template <class T> ORecordList<T>::Iterator ORecordList<T>::begin() { Iterator it( m_ids, m_acc ); return it; } template <class T> ORecordList<T>::Iterator ORecordList<T>::end() { Iterator it( m_ids, m_acc ); it.m_end = true; it.m_current = m_ids.count(); return it; } template <class T> uint ORecordList<T>::count()const { return m_ids.count(); } template <class T> T ORecordList<T>::operator[]( uint i ) { if ( i < 0 || (i+1) > m_ids.count() ) return T(); /* forward */ return m_acc->find( m_ids[i], m_ids, i ); } template <class T> int ORecordList<T>::uidAt( uint i ) { return m_ids[i]; } template <class T> bool ORecordList<T>::remove( int uid ) { QArray<int> copy( m_ids.count() ); int counter = 0; bool ret_val = false; for (uint i = 0; i < m_ids.count(); i++){ if ( m_ids[i] != uid ){ 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 @@ -1,80 +1,83 @@ #include <qobject.h> #include <qshared.h> #include <qpe/palmtopuidgen.h> #include <qpe/stringutil.h> #include <qpe/palmtoprecord.h> #include <qpe/stringutil.h> #include <qpe/categories.h> #include <qpe/categoryselect.h> - +#include "opimstate.h" +#include "orecur.h" #include "otodo.h" struct OTodo::OTodoData : public QShared { OTodoData() : QShared() { }; QDate date; bool isCompleted:1; bool hasDate:1; int priority; QString desc; QString sum; QMap<QString, QString> extra; ushort prog; bool hasAlarmDateTime :1; QDateTime alarmDateTime; + OPimState state; + ORecur recur; }; OTodo::OTodo(const OTodo &event ) : OPimRecord( event ), data( event.data ) { data->ref(); // qWarning("ref up"); } OTodo::~OTodo() { // qWarning("~OTodo " ); if ( data->deref() ) { // qWarning("OTodo::dereffing"); delete data; data = 0l; } } OTodo::OTodo(bool completed, int priority, const QArray<int> &category, const QString& summary, const QString &description, ushort progress, bool hasDate, QDate date, int uid ) : OPimRecord( uid ) { // qWarning("OTodoData " + summary); setCategories( category ); data = new OTodoData; data->date = date; data->isCompleted = completed; data->hasDate = hasDate; 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, const QString &description, ushort progress, bool hasDate, QDate date, int uid ) : OPimRecord( uid ) { @@ -99,137 +102,151 @@ bool OTodo::match( const QRegExp ®Exp )const return true; }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ return true; }else if(data->desc.find( regExp ) != -1 ){ return true; }else if(data->sum.find( regExp ) != -1 ) { return true; } return false; } bool OTodo::isCompleted() const { return data->isCompleted; } bool OTodo::hasDueDate() const { return data->hasDate; } bool OTodo::hasAlarmDateTime() const { return data->hasAlarmDateTime; } int OTodo::priority()const { return data->priority; } QString OTodo::summary() const { return data->sum; } ushort OTodo::progress() const { return data->prog; } QDate OTodo::dueDate()const { return data->date; } QDateTime OTodo::alarmDateTime() const { return data->alarmDateTime; } QString OTodo::description()const { return data->desc; } +OPimState OTodo::state()const { + return data->state; +} +ORecur OTodo::recurrence()const { + return data->recur; +} void OTodo::setCompleted( bool completed ) { changeOrModify(); data->isCompleted = completed; } 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(); data->desc = Qtopia::simplifyMultiLineSpace(desc ); } void OTodo::setSummary( const QString& sum ) { changeOrModify(); data->sum = sum; } void OTodo::setPriority(int prio ) { changeOrModify(); data->priority = prio; } void OTodo::setDueDate( QDate date ) { changeOrModify(); data->date = date; } void OTodo::setAlarmDateTime( const QDateTime& alarm ) { changeOrModify(); data->alarmDateTime = alarm; } +void OTodo::setState( const OPimState& state ) { + changeOrModify(); + data->state = state; +} +void OTodo::setRecurrence( const ORecur& rec) { + changeOrModify(); + data->recur = rec; +} bool OTodo::isOverdue( ) { if( data->hasDate && !data->isCompleted) return QDate::currentDate() > data->date; return false; } void OTodo::setProgress(ushort progress ) { changeOrModify(); data->prog = progress; } QString OTodo::toShortText() const { return summary(); } /*! Returns a richt text string */ QString OTodo::toRichText() const { QString text; QStringList catlist; // Description of the todo if ( !summary().isEmpty() ) { text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; } if( !description().isEmpty() ){ text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; } text += "<br><br><br>"; text += "<b>" + QObject::tr( "Priority:") +" </b>" + QString::number( priority() ) + " <br>"; text += "<b>" + QObject::tr( "Progress:") + " </b>" + QString::number( progress() ) + " %<br>"; if (hasDueDate() ){ 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>"; } @@ -313,74 +330,76 @@ void OTodo::deref() { if ( data->deref() ) { // qWarning("deleting"); delete data; data= 0; } } OTodo &OTodo::operator=(const OTodo &item ) { OPimRecord::operator=( item ); //qWarning("operator= ref "); item.data->ref(); deref(); data = item.data; return *this; } QMap<int, QString> OTodo::toMap() const { QMap<int, QString> map; map.insert( Uid, QString::number( uid() ) ); map.insert( Category, idsToString( categories() ) ); map.insert( HasDate, QString::number( data->hasDate ) ); map.insert( Completed, QString::number( data->isCompleted ) ); map.insert( Description, data->desc ); map.insert( Summary, data->sum ); map.insert( Priority, QString::number( data->priority ) ); map.insert( DateDay, QString::number( data->date.day() ) ); 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() ); return map; } QMap<QString, QString> OTodo::toExtraMap()const { return data->extra; } /** * change or modify looks at the ref count and either * creates a new QShared Object or it can modify it * right in place */ void OTodo::changeOrModify() { if ( data->count != 1 ) { -// qWarning("changeOrModify"); + qWarning("changeOrModify"); data->deref(); OTodoData* d2 = new OTodoData(); copy(data, d2 ); data = d2; } } void OTodo::copy( OTodoData* src, OTodoData* dest ) { dest->date = src->date; dest->isCompleted = src->isCompleted; dest->hasDate = src->hasDate; dest->priority = src->priority; 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; } QString OTodo::type() const { return QString::fromLatin1("OTodo"); } QString OTodo::recordField(int id )const { return QString::null; } 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 @@ -1,209 +1,234 @@ #ifndef OPIE_TODO_EVENT_H #define OPIE_TODO_EVENT_H #include <qarray.h> #include <qmap.h> #include <qregexp.h> #include <qstringlist.h> #include <qdatetime.h> #include <qvaluelist.h> #include <qpe/recordfields.h> #include <qpe/palmtopuidgen.h> #include <opie/opimrecord.h> +class OPimState; +class ORecur; class OTodo : public OPimRecord { public: typedef QValueList<OTodo> ValueList; enum RecordFields { Uid = Qtopia::UID_ID, Category = Qtopia::CATEGORY_ID, HasDate, Completed, Description, Summary, Priority, DateDay, DateMonth, DateYear, Progress, CrossReference, HasAlarmDateTime, - AlarmDateTime + AlarmDateTime, + State, + Recurrance, + Alarms, + Reminders, + Notifiers }; public: // priorities from Very low to very high enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; /* Constructs a new ToDoEvent @param completed Is the TodoEvent completed @param priority What is the priority of this ToDoEvent @param category Which category does it belong( uid ) @param summary A small summary of the todo @param description What is this ToDoEvent about @param hasDate Does this Event got a deadline @param date what is the deadline? @param uid what is the UUID of this Event **/ OTodo( bool completed = false, int priority = Normal, const QStringList &category = QStringList(), const QString &summary = QString::null , const QString &description = QString::null, ushort progress = 0, bool hasDate = false, QDate date = QDate::currentDate(), int uid = 0 /*empty*/ ); OTodo( bool completed, int priority, const QArray<int>& category, const QString& summary = QString::null, const QString& description = QString::null, ushort progress = 0, bool hasDate = false, QDate date = QDate::currentDate(), int uid = 0 /* empty */ ); /* Copy c'tor **/ OTodo(const OTodo & ); /** *destructor */ ~OTodo(); /** * Is this event completed? */ bool isCompleted() const; /** * Does this Event have a deadline */ bool hasDueDate() const; /** * Does this Event has an alarm time ? */ bool hasAlarmDateTime() const; /** * What is the priority? */ int priority()const ; /** * progress as ushort 0, 20, 40, 60, 80 or 100% */ ushort progress() const; /** * The due Date */ QDate dueDate()const; /** * Alarm Date and Time */ QDateTime alarmDateTime()const; /** + * What is the state of this OTodo? + */ + OPimState state()const; + + /** + * the recurrance of this + */ + ORecur recurrence()const; + + /** * The description of the todo */ QString description()const; /** * A small summary of the todo */ QString summary() const; /** * @reimplemented * Return this todoevent in a RichText formatted QString */ QString toRichText() const; /** * reimplementation */ QString type()const; QString toShortText()const; QMap<QString, QString> toExtraMap()const; QString recordField(int id )const; /** * toMap puts all data into the map. int relates * to ToDoEvent RecordFields enum */ QMap<int, QString> toMap()const; /** * Set if this Todo is completed */ void setCompleted(bool completed ); /** * 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 ); /** * Set the priority of the Todo */ void setPriority(int priority ); /** * Set the progress. */ void setProgress( ushort progress ); /** * set the end date */ void setDueDate( QDate date ); + + void setRecurrence( const ORecur& ); /** * set the alarm time */ void setAlarmDateTime ( const QDateTime& alarm ); void setDescription(const QString& ); 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(); bool match( const QRegExp &r )const; bool operator<(const OTodo &toDoEvent )const; bool operator<=(const OTodo &toDoEvent )const; bool operator!=(const OTodo &toDoEvent )const; bool operator>(const OTodo &toDoEvent )const; bool operator>=(const OTodo &toDoEvent)const; bool operator==(const OTodo &toDoEvent )const; OTodo &operator=(const OTodo &toDoEvent ); private: class OTodoPrivate; struct OTodoData; void deref(); inline void changeOrModify(); void copy( OTodoData* src, OTodoData* dest ); OTodoPrivate *d; OTodoData *data; }; inline bool OTodo::operator!=(const OTodo &toDoEvent )const { return !(*this == toDoEvent); } #endif |