author | zecke <zecke> | 2003-02-22 16:11:16 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-02-22 16:11:16 (UTC) |
commit | 397a7b1635488deda02b36df70692e27f59bb3e0 (patch) (side-by-side diff) | |
tree | 1232b1b7e8ac84c5d48df79b635ba61acbdf0f62 /libopie2/opiepim/core | |
parent | e7981098a5c373748d98158e8a6c59750bb0d7dc (diff) | |
download | opie-397a7b1635488deda02b36df70692e27f59bb3e0.zip opie-397a7b1635488deda02b36df70692e27f59bb3e0.tar.gz opie-397a7b1635488deda02b36df70692e27f59bb3e0.tar.bz2 |
Implement saving of events
Implement the ExceptionList
Add Children and parent to OEvent
Make ORecur honor exceptions
Extend the test app to add and save
-rw-r--r-- | libopie2/opiepim/core/orecur.cpp | 66 | ||||
-rw-r--r-- | libopie2/opiepim/core/orecur.h | 4 |
2 files changed, 69 insertions, 1 deletions
diff --git a/libopie2/opiepim/core/orecur.cpp b/libopie2/opiepim/core/orecur.cpp index e6a4787..e3b45b4 100644 --- a/libopie2/opiepim/core/orecur.cpp +++ b/libopie2/opiepim/core/orecur.cpp @@ -1,7 +1,10 @@ +#include <time.h> + #include <qshared.h> #include <qtopia/timeconversion.h> +#include "otimezone.h" #include "orecur.h" struct ORecur::Data : public QShared { @@ -81,6 +84,14 @@ bool ORecur::doesRecur( const QDate& date ) { // GPL from Datebookdb.cpp // FIXME exception list! bool ORecur::nextOcurrence( const QDate& from, QDate& next ) { + bool stillLooking; + stillLooking = p_nextOccurrence( from, next ); + while ( stillLooking && data->list.contains(next) ) + stillLooking = p_nextOccurrence( next.addDays(1), next ); + + return stillLooking; +} +bool ORecur::p_nextOccurrence( const QDate& from, QDate& next ) { // easy checks, first are we too far in the future or too far in the past? QDate tmpDate; @@ -95,7 +106,7 @@ bool ORecur::nextOcurrence( const QDate& from, QDate& next ) { if (hasEndDate() && endDate() < from) return FALSE; - if (start() >= from) { + if (start() >= from ) { next = start(); return TRUE; } @@ -443,4 +454,57 @@ void ORecur::checkOrModify() { data = d2; } } +QString ORecur::toString()const { + QString buf; + + buf += " rtype=\""; + switch ( data->type ) { + case ORecur::Daily: + buf += "Daily"; + break; + case ORecur::Weekly: + buf += "Weekly"; + break; + case ORecur::MonthlyDay: + buf += "MonthlyDay"; + break; + case ORecur::MonthlyDate: + buf += "MonthlyDate"; + break; + case ORecur::Yearly: + buf += "Yearly"; + break; + default: + buf += "NoRepeat"; + break; + } + buf += "\""; + if (data->days > 0 ) + buf += " rweekdays=\"" + QString::number( static_cast<int>( data->days ) ) + "\""; + if ( data->pos != 0 ) + buf += " rposition=\"" + QString::number(data->pos ) + "\""; + + buf += " rfreq=\"" + QString::number( data->freq ) + "\""; + buf += " rhasenddate=\"" + QString::number( static_cast<int>( data->hasEnd ) ) + "\""; + if ( data->hasEnd ) + buf += " enddt=\"" + + QString::number( OTimeZone::utc().fromUTCDateTime( QDateTime( data->end, QTime(12,0,0) ) ) ) + + "\""; + buf += " created=\"" + QString::number( OTimeZone::utc().fromUTCDateTime( data->create ) ) + "\""; + + if ( data->list.isEmpty() ) return buf; + // save exceptions list here!! + ExceptionList::ConstIterator it; + ExceptionList list = data->list; + buf += " exceptions=\""; + QDate date; + for ( it = list.begin(); it != list.end(); ++it ) { + date = (*it); + if ( it != list.begin() ) buf += " "; + + buf += QCString().sprintf("%04d%02d%02d", date.year(), date.month(), date.day() ); + } + buf += "\""; + return buf; +} diff --git a/libopie2/opiepim/core/orecur.h b/libopie2/opiepim/core/orecur.h index 1e0014b..b214b3f 100644 --- a/libopie2/opiepim/core/orecur.h +++ b/libopie2/opiepim/core/orecur.h @@ -73,7 +73,11 @@ public: void setRepitition(int ); void setService( const QString& ser ); + + /* almost internal */ + QString toString()const; private: + bool p_nextOccurrence( const QDate& from, QDate& next ); void deref(); inline void checkOrModify(); |