summaryrefslogtreecommitdiff
path: root/libopie/pim/otodoaccessxml.cpp
Side-by-side diff
Diffstat (limited to 'libopie/pim/otodoaccessxml.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/otodoaccessxml.cpp72
1 files changed, 69 insertions, 3 deletions
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
@@ -12,16 +12,34 @@
#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)
@@ -56,12 +74,13 @@ OTodoAccessXML::OTodoAccessXML( const QString& appName,
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!!!
*/
@@ -75,20 +94,26 @@ bool OTodoAccessXML::load() {
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;
@@ -178,14 +203,23 @@ bool OTodoAccessXML::load() {
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;
@@ -394,12 +428,43 @@ void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev,
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;
@@ -432,14 +497,15 @@ QString OTodoAccessXML::toString( const OTodo& ev )const {
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 );
}