Diffstat (limited to 'libopie2/opiepim/backend/otodoaccessxml.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessxml.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp index c1682c6..b2dfe80 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.cpp +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp | |||
@@ -19,44 +19,48 @@ OTodoAccessXML::OTodoAccessXML( const QString& appName, | |||
19 | m_file = Global::applicationFileName( "todolist", "todolist.xml" ); | 19 | m_file = Global::applicationFileName( "todolist", "todolist.xml" ); |
20 | } | 20 | } |
21 | OTodoAccessXML::~OTodoAccessXML() { | 21 | OTodoAccessXML::~OTodoAccessXML() { |
22 | 22 | ||
23 | } | 23 | } |
24 | bool OTodoAccessXML::load() { | 24 | bool OTodoAccessXML::load() { |
25 | m_opened = true; | 25 | m_opened = true; |
26 | m_changed = false; | 26 | m_changed = false; |
27 | /* initialize dict */ | 27 | /* initialize dict */ |
28 | /* | 28 | /* |
29 | * UPDATE dict if you change anything!!! | 29 | * UPDATE dict if you change anything!!! |
30 | */ | 30 | */ |
31 | QAsciiDict<int> dict(15); | 31 | QAsciiDict<int> dict(21); |
32 | dict.setAutoDelete( TRUE ); | 32 | dict.setAutoDelete( TRUE ); |
33 | dict.insert("Categories" , new int(OTodo::Category) ); | 33 | dict.insert("Categories" , new int(OTodo::Category) ); |
34 | dict.insert("Uid" , new int(OTodo::Uid) ); | 34 | dict.insert("Uid" , new int(OTodo::Uid) ); |
35 | dict.insert("HasDate" , new int(OTodo::HasDate) ); | 35 | dict.insert("HasDate" , new int(OTodo::HasDate) ); |
36 | dict.insert("Completed" , new int(OTodo::Completed) ); | 36 | dict.insert("Completed" , new int(OTodo::Completed) ); |
37 | dict.insert("Description" , new int(OTodo::Description) ); | 37 | dict.insert("Description" , new int(OTodo::Description) ); |
38 | dict.insert("Summary" , new int(OTodo::Summary) ); | 38 | dict.insert("Summary" , new int(OTodo::Summary) ); |
39 | dict.insert("Priority" , new int(OTodo::Priority) ); | 39 | dict.insert("Priority" , new int(OTodo::Priority) ); |
40 | dict.insert("DateDay" , new int(OTodo::DateDay) ); | 40 | dict.insert("DateDay" , new int(OTodo::DateDay) ); |
41 | dict.insert("DateMonth" , new int(OTodo::DateMonth) ); | 41 | dict.insert("DateMonth" , new int(OTodo::DateMonth) ); |
42 | dict.insert("DateYear" , new int(OTodo::DateYear) ); | 42 | dict.insert("DateYear" , new int(OTodo::DateYear) ); |
43 | dict.insert("Progress" , new int(OTodo::Progress) ); | 43 | dict.insert("Progress" , new int(OTodo::Progress) ); |
44 | dict.insert("Completed", new int(OTodo::Completed) ); | 44 | dict.insert("Completed", new int(OTodo::Completed) ); |
45 | dict.insert("CrossReference", new int(OTodo::CrossReference) ); | 45 | dict.insert("CrossReference", new int(OTodo::CrossReference) ); |
46 | dict.insert("HasAlarmDateTime",new int(OTodo::HasAlarmDateTime) ); | 46 | dict.insert("State", new int(OTodo::State) ); |
47 | dict.insert("AlarmDateTime", new int(OTodo::AlarmDateTime) ); | 47 | dict.insert("Recurrence", new int(OTodo::Recurrence) ); |
48 | dict.insert("Alarms", new int(OTodo::Alarms) ); | ||
49 | dict.insert("Reminders", new int(OTodo::Reminders) ); | ||
50 | dict.insert("Notifiers", new int(OTodo::Notifiers) ); | ||
51 | dict.insert("Maintainer", new int(OTodo::Maintainer) ); | ||
48 | 52 | ||
49 | // here the custom XML parser from TT it's GPL | 53 | // here the custom XML parser from TT it's GPL |
50 | // but we want to push that to TT..... | 54 | // but we want to push OpiePIM... to TT..... |
51 | QFile f(m_file ); | 55 | QFile f(m_file ); |
52 | if (!f.open(IO_ReadOnly) ) | 56 | if (!f.open(IO_ReadOnly) ) |
53 | return false; | 57 | return false; |
54 | 58 | ||
55 | QByteArray ba = f.readAll(); | 59 | QByteArray ba = f.readAll(); |
56 | f.close(); | 60 | f.close(); |
57 | char* dt = ba.data(); | 61 | char* dt = ba.data(); |
58 | int len = ba.size(); | 62 | int len = ba.size(); |
59 | int i = 0; | 63 | int i = 0; |
60 | char *point; | 64 | char *point; |
61 | const char* collectionString = "<Task "; | 65 | const char* collectionString = "<Task "; |
62 | while ( dt+i != 0 && ( point = strstr( dt+i, collectionString ) ) != 0l ) { | 66 | while ( dt+i != 0 && ( point = strstr( dt+i, collectionString ) ) != 0l ) { |
@@ -327,32 +331,24 @@ void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev, | |||
327 | * we need to split it up | 331 | * we need to split it up |
328 | */ | 332 | */ |
329 | QStringList refs = QStringList::split(';', val ); | 333 | QStringList refs = QStringList::split(';', val ); |
330 | QStringList::Iterator strIt; | 334 | QStringList::Iterator strIt; |
331 | for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { | 335 | for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { |
332 | int pos = (*strIt).find(','); | 336 | int pos = (*strIt).find(','); |
333 | if ( pos > -1 ) | 337 | if ( pos > -1 ) |
334 | ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); | 338 | ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); |
335 | 339 | ||
336 | } | 340 | } |
337 | break; | 341 | break; |
338 | } | 342 | } |
339 | case OTodo::HasAlarmDateTime: | ||
340 | ev.setHasAlarmDateTime( val.toInt() ); | ||
341 | break; | ||
342 | case OTodo::AlarmDateTime: { | ||
343 | /* this sounds better ;) zecke */ | ||
344 | ev.setAlarmDateTime( TimeConversion::fromISO8601( val.local8Bit() ) ); | ||
345 | break; | ||
346 | } | ||
347 | default: | 343 | default: |
348 | break; | 344 | break; |
349 | } | 345 | } |
350 | } | 346 | } |
351 | QString OTodoAccessXML::toString( const OTodo& ev )const { | 347 | QString OTodoAccessXML::toString( const OTodo& ev )const { |
352 | QString str; | 348 | QString str; |
353 | 349 | ||
354 | str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; | 350 | str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; |
355 | str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; | 351 | str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; |
356 | str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; | 352 | str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; |
357 | str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; | 353 | str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; |
358 | 354 | ||
@@ -374,25 +370,24 @@ QString OTodoAccessXML::toString( const OTodo& ev )const { | |||
374 | * but don' iterate over the list | 370 | * but don' iterate over the list |
375 | * I may do #define private protected | 371 | * I may do #define private protected |
376 | * for this case - cough --zecke | 372 | * for this case - cough --zecke |
377 | */ | 373 | */ |
378 | /* | 374 | /* |
379 | QMap<QString, QString> extras = ev.extras(); | 375 | QMap<QString, QString> extras = ev.extras(); |
380 | QMap<QString, QString>::Iterator extIt; | 376 | QMap<QString, QString>::Iterator extIt; |
381 | for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) | 377 | for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) |
382 | str += extIt.key() + "=\"" + extIt.data() + "\" "; | 378 | str += extIt.key() + "=\"" + extIt.data() + "\" "; |
383 | */ | 379 | */ |
384 | // cross refernce | 380 | // cross refernce |
385 | 381 | ||
386 | str += "AlarmDateTime=\"" + TimeConversion::toISO8601( ev.alarmDateTime() ) + "\" "; | ||
387 | 382 | ||
388 | return str; | 383 | return str; |
389 | } | 384 | } |
390 | QString OTodoAccessXML::toString( const QArray<int>& ints ) const { | 385 | QString OTodoAccessXML::toString( const QArray<int>& ints ) const { |
391 | return Qtopia::Record::idsToString( ints ); | 386 | return Qtopia::Record::idsToString( ints ); |
392 | } | 387 | } |
393 | 388 | ||
394 | /* internal class for sorting | 389 | /* internal class for sorting |
395 | * | 390 | * |
396 | * Inspired by todoxmlio.cpp from TT | 391 | * Inspired by todoxmlio.cpp from TT |
397 | */ | 392 | */ |
398 | 393 | ||
@@ -607,12 +602,18 @@ QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, | |||
607 | qWarning("XXX %d Items added", item); | 602 | qWarning("XXX %d Items added", item); |
608 | vector.resize( item ); | 603 | vector.resize( item ); |
609 | /* sort it now */ | 604 | /* sort it now */ |
610 | vector.sort(); | 605 | vector.sort(); |
611 | /* now get the uids */ | 606 | /* now get the uids */ |
612 | QArray<int> array( vector.count() ); | 607 | QArray<int> array( vector.count() ); |
613 | for (uint i= 0; i < vector.count(); i++ ) { | 608 | for (uint i= 0; i < vector.count(); i++ ) { |
614 | array[i] = ( vector.at(i) )->todo.uid(); | 609 | array[i] = ( vector.at(i) )->todo.uid(); |
615 | } | 610 | } |
616 | qWarning("array count = %d %d", array.count(), vector.count() ); | 611 | qWarning("array count = %d %d", array.count(), vector.count() ); |
617 | return array; | 612 | return array; |
618 | }; | 613 | }; |
614 | void OTodoAccessXML::removeAllCompleted() { | ||
615 | for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { | ||
616 | if ( (*it).isCompleted() ) | ||
617 | m_events.remove( it ); | ||
618 | } | ||
619 | } | ||