-rw-r--r-- | libopie/pim/opimnotifymanager.cpp | 3 | ||||
-rw-r--r-- | libopie/pim/opimnotifymanager.h | 3 | ||||
-rw-r--r-- | libopie/pim/orecur.cpp | 2 | ||||
-rw-r--r-- | libopie/pim/otodoaccessxml.cpp | 72 | ||||
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessxml.cpp | 72 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimnotifymanager.cpp | 3 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimnotifymanager.h | 3 | ||||
-rw-r--r-- | libopie2/opiepim/core/orecur.cpp | 2 |
8 files changed, 152 insertions, 8 deletions
diff --git a/libopie/pim/opimnotifymanager.cpp b/libopie/pim/opimnotifymanager.cpp index be4a1c2..49af757 100644 --- a/libopie/pim/opimnotifymanager.cpp +++ b/libopie/pim/opimnotifymanager.cpp @@ -58,12 +58,15 @@ void OPimNotifyManager::setReminders( const Reminders& rem) { void OPimNotifyManager::registerNotify( const OPimNotify& ) { } /* FIXME!!! */ /** * same as above... * Also implement Url model * have a MainWindow.... */ void OPimNotifyManager::deregister( const OPimNotify& ) { } +bool OPimNotifyManager::isEmpty()const { + return ( m_rem.isEmpty() && m_al.isEmpty() ); +} diff --git a/libopie/pim/opimnotifymanager.h b/libopie/pim/opimnotifymanager.h index 0eebc9b..0ac30a1 100644 --- a/libopie/pim/opimnotifymanager.h +++ b/libopie/pim/opimnotifymanager.h @@ -30,22 +30,25 @@ public: /* register is a Ansi C keyword... */ /** * This function will register the Notify to the Alarm Server * or datebook depending on the type of the notify */ void registerNotify( const OPimNotify& ); /** * this will do the opposite.. */ void deregister( const OPimNotify& ); + + bool isEmpty()const; + private: Reminders m_rem; Alarms m_al; class Private; Private *d; }; #endif diff --git a/libopie/pim/orecur.cpp b/libopie/pim/orecur.cpp index e3b45b4..eae1fdc 100644 --- a/libopie/pim/orecur.cpp +++ b/libopie/pim/orecur.cpp @@ -495,16 +495,16 @@ QString ORecur::toString()const { 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 += "\""; + buf += "\" "; return buf; } diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp index c0d8dfc..71b6a7e 100644 --- a/libopie/pim/otodoaccessxml.cpp +++ b/libopie/pim/otodoaccessxml.cpp @@ -6,28 +6,46 @@ #include <sys/types.h> #include <unistd.h> #include <qfile.h> #include <qvector.h> #include <qpe/global.h> #include <qpe/stringutil.h> #include <qpe/timeconversion.h> +#include "otimezone.h" #include "orecur.h" #include "otodoaccessxml.h" namespace { + time_t rp_end; + ORecur* rec; + ORecur *recur() { + if (!rec ) rec = new ORecur; + return rec; + } + int snd; + enum MoreAttributes { + FRType = OTodo::CompletedDate + 2, + FRWeekdays, + FRPosition, + FRFreq, + FRHasEndDate, + FREndDate, + FRStart, + FREnd + }; // FROM TT again char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) { char needleChar; char haystackChar; if (!needle || !haystack || !hLen || !nLen) return 0; const char* hsearch = haystack; if ((needleChar = *needle++) != 0) { nLen--; //(to make up for needle++) @@ -50,51 +68,58 @@ OTodoAccessXML::OTodoAccessXML( const QString& appName, const QString& fileName ) : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) { if (!fileName.isEmpty() ) m_file = fileName; else m_file = Global::applicationFileName( "todolist", "todolist.xml" ); } OTodoAccessXML::~OTodoAccessXML() { } bool OTodoAccessXML::load() { + rec = 0; m_opened = true; m_changed = false; /* initialize dict */ /* * UPDATE dict if you change anything!!! */ QAsciiDict<int> dict(21); dict.setAutoDelete( TRUE ); dict.insert("Categories" , new int(OTodo::Category) ); dict.insert("Uid" , new int(OTodo::Uid) ); dict.insert("HasDate" , new int(OTodo::HasDate) ); dict.insert("Completed" , new int(OTodo::Completed) ); dict.insert("Description" , new int(OTodo::Description) ); dict.insert("Summary" , new int(OTodo::Summary) ); dict.insert("Priority" , new int(OTodo::Priority) ); dict.insert("DateDay" , new int(OTodo::DateDay) ); dict.insert("DateMonth" , new int(OTodo::DateMonth) ); dict.insert("DateYear" , new int(OTodo::DateYear) ); dict.insert("Progress" , new int(OTodo::Progress) ); - dict.insert("Completed", new int(OTodo::Completed) ); + dict.insert("CompletedDate", new int(OTodo::CompletedDate) ); dict.insert("CrossReference", new int(OTodo::CrossReference) ); dict.insert("State", new int(OTodo::State) ); - dict.insert("Recurrence", new int(OTodo::Recurrence) ); dict.insert("Alarms", new int(OTodo::Alarms) ); dict.insert("Reminders", new int(OTodo::Reminders) ); dict.insert("Notifiers", new int(OTodo::Notifiers) ); dict.insert("Maintainer", new int(OTodo::Maintainer) ); + dict.insert("rtype", new int(FRType) ); + dict.insert("rweekdays", new int(FRWeekdays) ); + dict.insert("rposition", new int(FRPosition) ); + dict.insert("rfreq", new int(FRFreq) ); + dict.insert("start", new int(FRStart) ); + dict.insert("rhasenddate", new int(FRHasEndDate) ); + dict.insert("enddt", new int(FREndDate) ); // here the custom XML parser from TT it's GPL // but we want to push OpiePIM... to TT..... // mmap part from zecke :) int fd = ::open( QFile::encodeName(m_file).data(), O_RDONLY ); struct stat attribut; if ( fd < 0 ) return false; if ( fstat(fd, &attribut ) == -1 ) { ::close( fd ); return false; } @@ -172,26 +197,35 @@ bool OTodoAccessXML::load() { } /* * now add it */ qWarning("End at %d", i ); if (m_events.contains( ev.uid() ) || ev.uid() == 0) { ev.setUid( 1 ); m_changed = true; } if ( ev.hasDueDate() ) { ev.setDueDate( QDate(m_year, m_month, m_day) ); } + if ( rec && rec->doesRecur() ) { + OTimeZone utc = OTimeZone::utc(); + ORecur recu( *rec ); // call copy c'tor + recu.setEndDate( utc.fromUTCDateTime( rp_end ).date() ); + recu.setStart( ev.dueDate() ); + ev.setRecurrence( recu ); + } m_events.insert(ev.uid(), ev ); m_year = m_month = m_day = -1; + delete rec; + rec = 0; } munmap(map_addr, attribut.st_size ); qWarning("counts %d records loaded!", m_events.count() ); return true; } bool OTodoAccessXML::reload() { m_events.clear(); return load(); } bool OTodoAccessXML::save() { @@ -388,24 +422,55 @@ void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev, * we need to split it up */ QStringList refs = QStringList::split(';', val ); QStringList::Iterator strIt; for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { int pos = (*strIt).find(','); if ( pos > -1 ) ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); } break; } + /* Recurrence stuff below + post processing later */ + case FRType: + if ( val == "Daily" ) + recur()->setType( ORecur::Daily ); + else if ( val == "Weekly" ) + recur()->setType( ORecur::Weekly); + else if ( val == "MonthlyDay" ) + recur()->setType( ORecur::MonthlyDay ); + else if ( val == "MonthlyDate" ) + recur()->setType( ORecur::MonthlyDate ); + else if ( val == "Yearly" ) + recur()->setType( ORecur::Yearly ); + else + recur()->setType( ORecur::NoRepeat ); + break; + case FRWeekdays: + recur()->setDays( val.toInt() ); + break; + case FRPosition: + recur()->setPosition( val.toInt() ); + break; + case FRFreq: + recur()->setFrequency( val.toInt() ); + break; + case FRHasEndDate: + recur()->setHasEndDate( val.toInt() ); + break; + case FREndDate: { + rp_end = (time_t) val.toLong(); + break; + } default: break; } } QString OTodoAccessXML::toString( const OTodo& ev )const { QString str; str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; @@ -426,26 +491,27 @@ QString OTodoAccessXML::toString( const OTodo& ev )const { * possible you can set custom fields * but don' iterate over the list * I may do #define private protected * for this case - cough --zecke */ /* QMap<QString, QString> extras = ev.extras(); QMap<QString, QString>::Iterator extIt; for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) str += extIt.key() + "=\"" + extIt.data() + "\" "; */ // cross refernce - if ( ev.hasRecurrence() ) + if ( ev.hasRecurrence() ) { str += ev.recurrence().toString(); + } return str; } QString OTodoAccessXML::toString( const QArray<int>& ints ) const { return Qtopia::Record::idsToString( ints ); } /* internal class for sorting * * Inspired by todoxmlio.cpp from TT */ diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp index c0d8dfc..71b6a7e 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.cpp +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp @@ -6,28 +6,46 @@ #include <sys/types.h> #include <unistd.h> #include <qfile.h> #include <qvector.h> #include <qpe/global.h> #include <qpe/stringutil.h> #include <qpe/timeconversion.h> +#include "otimezone.h" #include "orecur.h" #include "otodoaccessxml.h" namespace { + time_t rp_end; + ORecur* rec; + ORecur *recur() { + if (!rec ) rec = new ORecur; + return rec; + } + int snd; + enum MoreAttributes { + FRType = OTodo::CompletedDate + 2, + FRWeekdays, + FRPosition, + FRFreq, + FRHasEndDate, + FREndDate, + FRStart, + FREnd + }; // FROM TT again char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) { char needleChar; char haystackChar; if (!needle || !haystack || !hLen || !nLen) return 0; const char* hsearch = haystack; if ((needleChar = *needle++) != 0) { nLen--; //(to make up for needle++) @@ -50,51 +68,58 @@ OTodoAccessXML::OTodoAccessXML( const QString& appName, const QString& fileName ) : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) { if (!fileName.isEmpty() ) m_file = fileName; else m_file = Global::applicationFileName( "todolist", "todolist.xml" ); } OTodoAccessXML::~OTodoAccessXML() { } bool OTodoAccessXML::load() { + rec = 0; m_opened = true; m_changed = false; /* initialize dict */ /* * UPDATE dict if you change anything!!! */ QAsciiDict<int> dict(21); dict.setAutoDelete( TRUE ); dict.insert("Categories" , new int(OTodo::Category) ); dict.insert("Uid" , new int(OTodo::Uid) ); dict.insert("HasDate" , new int(OTodo::HasDate) ); dict.insert("Completed" , new int(OTodo::Completed) ); dict.insert("Description" , new int(OTodo::Description) ); dict.insert("Summary" , new int(OTodo::Summary) ); dict.insert("Priority" , new int(OTodo::Priority) ); dict.insert("DateDay" , new int(OTodo::DateDay) ); dict.insert("DateMonth" , new int(OTodo::DateMonth) ); dict.insert("DateYear" , new int(OTodo::DateYear) ); dict.insert("Progress" , new int(OTodo::Progress) ); - dict.insert("Completed", new int(OTodo::Completed) ); + dict.insert("CompletedDate", new int(OTodo::CompletedDate) ); dict.insert("CrossReference", new int(OTodo::CrossReference) ); dict.insert("State", new int(OTodo::State) ); - dict.insert("Recurrence", new int(OTodo::Recurrence) ); dict.insert("Alarms", new int(OTodo::Alarms) ); dict.insert("Reminders", new int(OTodo::Reminders) ); dict.insert("Notifiers", new int(OTodo::Notifiers) ); dict.insert("Maintainer", new int(OTodo::Maintainer) ); + dict.insert("rtype", new int(FRType) ); + dict.insert("rweekdays", new int(FRWeekdays) ); + dict.insert("rposition", new int(FRPosition) ); + dict.insert("rfreq", new int(FRFreq) ); + dict.insert("start", new int(FRStart) ); + dict.insert("rhasenddate", new int(FRHasEndDate) ); + dict.insert("enddt", new int(FREndDate) ); // here the custom XML parser from TT it's GPL // but we want to push OpiePIM... to TT..... // mmap part from zecke :) int fd = ::open( QFile::encodeName(m_file).data(), O_RDONLY ); struct stat attribut; if ( fd < 0 ) return false; if ( fstat(fd, &attribut ) == -1 ) { ::close( fd ); return false; } @@ -172,26 +197,35 @@ bool OTodoAccessXML::load() { } /* * now add it */ qWarning("End at %d", i ); if (m_events.contains( ev.uid() ) || ev.uid() == 0) { ev.setUid( 1 ); m_changed = true; } if ( ev.hasDueDate() ) { ev.setDueDate( QDate(m_year, m_month, m_day) ); } + if ( rec && rec->doesRecur() ) { + OTimeZone utc = OTimeZone::utc(); + ORecur recu( *rec ); // call copy c'tor + recu.setEndDate( utc.fromUTCDateTime( rp_end ).date() ); + recu.setStart( ev.dueDate() ); + ev.setRecurrence( recu ); + } m_events.insert(ev.uid(), ev ); m_year = m_month = m_day = -1; + delete rec; + rec = 0; } munmap(map_addr, attribut.st_size ); qWarning("counts %d records loaded!", m_events.count() ); return true; } bool OTodoAccessXML::reload() { m_events.clear(); return load(); } bool OTodoAccessXML::save() { @@ -388,24 +422,55 @@ void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev, * we need to split it up */ QStringList refs = QStringList::split(';', val ); QStringList::Iterator strIt; for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { int pos = (*strIt).find(','); if ( pos > -1 ) ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); } break; } + /* Recurrence stuff below + post processing later */ + case FRType: + if ( val == "Daily" ) + recur()->setType( ORecur::Daily ); + else if ( val == "Weekly" ) + recur()->setType( ORecur::Weekly); + else if ( val == "MonthlyDay" ) + recur()->setType( ORecur::MonthlyDay ); + else if ( val == "MonthlyDate" ) + recur()->setType( ORecur::MonthlyDate ); + else if ( val == "Yearly" ) + recur()->setType( ORecur::Yearly ); + else + recur()->setType( ORecur::NoRepeat ); + break; + case FRWeekdays: + recur()->setDays( val.toInt() ); + break; + case FRPosition: + recur()->setPosition( val.toInt() ); + break; + case FRFreq: + recur()->setFrequency( val.toInt() ); + break; + case FRHasEndDate: + recur()->setHasEndDate( val.toInt() ); + break; + case FREndDate: { + rp_end = (time_t) val.toLong(); + break; + } default: break; } } QString OTodoAccessXML::toString( const OTodo& ev )const { QString str; str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; @@ -426,26 +491,27 @@ QString OTodoAccessXML::toString( const OTodo& ev )const { * possible you can set custom fields * but don' iterate over the list * I may do #define private protected * for this case - cough --zecke */ /* QMap<QString, QString> extras = ev.extras(); QMap<QString, QString>::Iterator extIt; for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) str += extIt.key() + "=\"" + extIt.data() + "\" "; */ // cross refernce - if ( ev.hasRecurrence() ) + if ( ev.hasRecurrence() ) { str += ev.recurrence().toString(); + } return str; } QString OTodoAccessXML::toString( const QArray<int>& ints ) const { return Qtopia::Record::idsToString( ints ); } /* internal class for sorting * * Inspired by todoxmlio.cpp from TT */ diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp index be4a1c2..49af757 100644 --- a/libopie2/opiepim/core/opimnotifymanager.cpp +++ b/libopie2/opiepim/core/opimnotifymanager.cpp @@ -58,12 +58,15 @@ void OPimNotifyManager::setReminders( const Reminders& rem) { void OPimNotifyManager::registerNotify( const OPimNotify& ) { } /* FIXME!!! */ /** * same as above... * Also implement Url model * have a MainWindow.... */ void OPimNotifyManager::deregister( const OPimNotify& ) { } +bool OPimNotifyManager::isEmpty()const { + return ( m_rem.isEmpty() && m_al.isEmpty() ); +} diff --git a/libopie2/opiepim/core/opimnotifymanager.h b/libopie2/opiepim/core/opimnotifymanager.h index 0eebc9b..0ac30a1 100644 --- a/libopie2/opiepim/core/opimnotifymanager.h +++ b/libopie2/opiepim/core/opimnotifymanager.h @@ -30,22 +30,25 @@ public: /* register is a Ansi C keyword... */ /** * This function will register the Notify to the Alarm Server * or datebook depending on the type of the notify */ void registerNotify( const OPimNotify& ); /** * this will do the opposite.. */ void deregister( const OPimNotify& ); + + bool isEmpty()const; + private: Reminders m_rem; Alarms m_al; class Private; Private *d; }; #endif diff --git a/libopie2/opiepim/core/orecur.cpp b/libopie2/opiepim/core/orecur.cpp index e3b45b4..eae1fdc 100644 --- a/libopie2/opiepim/core/orecur.cpp +++ b/libopie2/opiepim/core/orecur.cpp @@ -495,16 +495,16 @@ QString ORecur::toString()const { 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 += "\""; + buf += "\" "; return buf; } |