author | zecke <zecke> | 2003-02-22 18:51:44 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-02-22 18:51:44 (UTC) |
commit | 7b04887e382227c80c8985495f01dad2b1890719 (patch) (unidiff) | |
tree | 31db88fd0519c7f03ff05560f21ba69256765d5e | |
parent | 2424bcd292444b3a03c9b92dbc7f5b392c355755 (diff) | |
download | opie-7b04887e382227c80c8985495f01dad2b1890719.zip opie-7b04887e382227c80c8985495f01dad2b1890719.tar.gz opie-7b04887e382227c80c8985495f01dad2b1890719.tar.bz2 |
Fix saving
remove the transport medium from the opimmainwindow
-rw-r--r-- | libopie/pim/odatebookaccessbackend_xml.cpp | 7 | ||||
-rw-r--r-- | libopie/pim/opimmainwindow.h | 2 | ||||
-rw-r--r-- | libopie/pim/test/oevent_test.cpp | 4 | ||||
-rw-r--r-- | libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp | 7 | ||||
-rw-r--r-- | libopie2/opiepim/ui/opimmainwindow.h | 2 |
5 files changed, 17 insertions, 5 deletions
diff --git a/libopie/pim/odatebookaccessbackend_xml.cpp b/libopie/pim/odatebookaccessbackend_xml.cpp index 24b69fe..4a6b7b8 100644 --- a/libopie/pim/odatebookaccessbackend_xml.cpp +++ b/libopie/pim/odatebookaccessbackend_xml.cpp | |||
@@ -39,137 +39,139 @@ char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) | |||
39 | do { | 39 | do { |
40 | if ((haystackChar = *hsearch++) == 0) | 40 | if ((haystackChar = *hsearch++) == 0) |
41 | return (0); | 41 | return (0); |
42 | if (hsearch >= haystack + hLen) | 42 | if (hsearch >= haystack + hLen) |
43 | return (0); | 43 | return (0); |
44 | } while (haystackChar != needleChar); | 44 | } while (haystackChar != needleChar); |
45 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); | 45 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); |
46 | hsearch--; | 46 | hsearch--; |
47 | } | 47 | } |
48 | return ((char *)hsearch); | 48 | return ((char *)hsearch); |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | namespace { | 52 | namespace { |
53 | time_t start, end, created, rp_end; | 53 | time_t start, end, created, rp_end; |
54 | ORecur* rec; | 54 | ORecur* rec; |
55 | ORecur* recur() { | 55 | ORecur* recur() { |
56 | if (!rec) | 56 | if (!rec) |
57 | rec = new ORecur; | 57 | rec = new ORecur; |
58 | 58 | ||
59 | return rec; | 59 | return rec; |
60 | } | 60 | } |
61 | int alarmTime; | 61 | int alarmTime; |
62 | int snd; | 62 | int snd; |
63 | enum Attribute{ | 63 | enum Attribute{ |
64 | FDescription = 0, | 64 | FDescription = 0, |
65 | FLocation, | 65 | FLocation, |
66 | FCategories, | 66 | FCategories, |
67 | FUid, | 67 | FUid, |
68 | FType, | 68 | FType, |
69 | FAlarm, | 69 | FAlarm, |
70 | FSound, | 70 | FSound, |
71 | FRType, | 71 | FRType, |
72 | FRWeekdays, | 72 | FRWeekdays, |
73 | FRPosition, | 73 | FRPosition, |
74 | FRFreq, | 74 | FRFreq, |
75 | FRHasEndDate, | 75 | FRHasEndDate, |
76 | FREndDate, | 76 | FREndDate, |
77 | FRStart, | 77 | FRStart, |
78 | FREnd, | 78 | FREnd, |
79 | FNote, | 79 | FNote, |
80 | FCreated, | 80 | FCreated, |
81 | FTimeZone, | 81 | FTimeZone, |
82 | FRecParent, | 82 | FRecParent, |
83 | FRecChildren, | 83 | FRecChildren, |
84 | FExceptions | 84 | FExceptions |
85 | }; | 85 | }; |
86 | inline void save( const OEvent& ev, QString& buf ) { | 86 | inline void save( const OEvent& ev, QString& buf ) { |
87 | qWarning("Saving %d %s", ev.uid(), ev.description().latin1() ); | ||
87 | buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\""; | 88 | buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\""; |
88 | if (!ev.location().isEmpty() ) | 89 | if (!ev.location().isEmpty() ) |
89 | buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\""; | 90 | buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\""; |
90 | 91 | ||
91 | buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\""; | 92 | buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\""; |
92 | buf += " uid=\"" + QString::number( ev.uid() ) + "\""; | 93 | buf += " uid=\"" + QString::number( ev.uid() ) + "\""; |
93 | 94 | ||
94 | if (ev.isAllDay() ) | 95 | if (ev.isAllDay() ) |
95 | buf += " type=\"AllDay\""; | 96 | buf += " type=\"AllDay\""; |
96 | 97 | ||
97 | if (ev.hasNotifiers() ) { | 98 | if (ev.hasNotifiers() ) { |
98 | OPimAlarm alarm = ev.notifiers().alarms()[0]; // take only the first | 99 | OPimAlarm alarm = ev.notifiers().alarms()[0]; // take only the first |
99 | int minutes = alarm.dateTime().secsTo( ev.startDateTime() ) / 60; | 100 | int minutes = alarm.dateTime().secsTo( ev.startDateTime() ) / 60; |
100 | buf += " alarm=\"" + QString::number(minutes) + "\" sound=\""; | 101 | buf += " alarm=\"" + QString::number(minutes) + "\" sound=\""; |
101 | if ( alarm.sound() == OPimAlarm::Loud ) | 102 | if ( alarm.sound() == OPimAlarm::Loud ) |
102 | buf += "loud"; | 103 | buf += "loud"; |
103 | else | 104 | else |
104 | buf += "silent"; | 105 | buf += "silent"; |
105 | buf += "\""; | 106 | buf += "\""; |
106 | } | 107 | } |
107 | if ( ev.hasRecurrence() ) { | 108 | if ( ev.hasRecurrence() ) { |
108 | buf += ev.recurrence().toString(); | 109 | buf += ev.recurrence().toString(); |
109 | } | 110 | } |
110 | 111 | ||
111 | /* | 112 | /* |
112 | * fscking timezones :) well, we'll first convert | 113 | * fscking timezones :) well, we'll first convert |
113 | * the QDateTime to a QDateTime in UTC time | 114 | * the QDateTime to a QDateTime in UTC time |
114 | * and then we'll create a nice time_t | 115 | * and then we'll create a nice time_t |
115 | */ | 116 | */ |
116 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); | 117 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); |
117 | buf += " start=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.startDateTime(), OTimeZone::utc() ) ) ) + "\""; | 118 | buf += " start=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.startDateTime(), OTimeZone::utc() ) ) ) + "\""; |
118 | buf += " end=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.endDateTime() , OTimeZone::utc() ) ) ) + "\""; | 119 | buf += " end=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.endDateTime() , OTimeZone::utc() ) ) ) + "\""; |
119 | if (!ev.note().isEmpty() ) { | 120 | if (!ev.note().isEmpty() ) { |
120 | buf += " note=\"" + Qtopia::escapeString( ev.note() ) + "\""; | 121 | buf += " note=\"" + Qtopia::escapeString( ev.note() ) + "\""; |
121 | } | 122 | } |
122 | 123 | ||
123 | buf += " timezone=\""; | 124 | buf += " timezone=\""; |
124 | if ( ev.timeZone().isEmpty() ) | 125 | if ( ev.timeZone().isEmpty() ) |
125 | buf += "None"; | 126 | buf += "None"; |
126 | else | 127 | else |
127 | buf += ev.timeZone(); | 128 | buf += ev.timeZone(); |
129 | buf += "\""; | ||
128 | 130 | ||
129 | if (ev.parent() != 0 ) { | 131 | if (ev.parent() != 0 ) { |
130 | buf += " recparent=\""+QString::number(ev.parent() )+"\""; | 132 | buf += " recparent=\""+QString::number(ev.parent() )+"\""; |
131 | } | 133 | } |
132 | 134 | ||
133 | if (ev.children().count() != 0 ) { | 135 | if (ev.children().count() != 0 ) { |
134 | QArray<int> children = ev.children(); | 136 | QArray<int> children = ev.children(); |
135 | buf += " recchildren=\""; | 137 | buf += " recchildren=\""; |
136 | for ( uint i = 0; i < children.count(); i++ ) { | 138 | for ( uint i = 0; i < children.count(); i++ ) { |
137 | if ( i != 0 ) buf += " "; | 139 | if ( i != 0 ) buf += " "; |
138 | buf += QString::number( children[i] ); | 140 | buf += QString::number( children[i] ); |
139 | } | 141 | } |
140 | buf+= "\""; | 142 | buf+= "\""; |
141 | } | 143 | } |
142 | 144 | ||
143 | // skip custom writing | 145 | // skip custom writing |
144 | } | 146 | } |
145 | 147 | ||
146 | inline bool forAll( const QMap<int, OEvent>& list, QFile& file ) { | 148 | inline bool forAll( const QMap<int, OEvent>& list, QFile& file ) { |
147 | QMap<int, OEvent>::ConstIterator it; | 149 | QMap<int, OEvent>::ConstIterator it; |
148 | QString buf; | 150 | QString buf; |
149 | QCString str; | 151 | QCString str; |
150 | int total_written; | 152 | int total_written; |
151 | for ( it = list.begin(); it != list.end(); ++it ) { | 153 | for ( it = list.begin(); it != list.end(); ++it ) { |
152 | buf = "<event"; | 154 | buf = "<event"; |
153 | save( it.data(), buf ); | 155 | save( it.data(), buf ); |
154 | buf += " />\n"; | 156 | buf += " />\n"; |
155 | str = buf.utf8(); | 157 | str = buf.utf8(); |
156 | 158 | ||
157 | total_written = file.writeBlock(str.data(), str.length() ); | 159 | total_written = file.writeBlock(str.data(), str.length() ); |
158 | if ( total_written != int(str.length() ) ) | 160 | if ( total_written != int(str.length() ) ) |
159 | return false; | 161 | return false; |
160 | } | 162 | } |
161 | return true; | 163 | return true; |
162 | } | 164 | } |
163 | } | 165 | } |
164 | 166 | ||
165 | ODateBookAccessBackend_XML::ODateBookAccessBackend_XML( const QString& , | 167 | ODateBookAccessBackend_XML::ODateBookAccessBackend_XML( const QString& , |
166 | const QString& fileName ) | 168 | const QString& fileName ) |
167 | : ODateBookAccessBackend() { | 169 | : ODateBookAccessBackend() { |
168 | m_name = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.xml" ) : fileName; | 170 | m_name = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.xml" ) : fileName; |
169 | m_changed = false; | 171 | m_changed = false; |
170 | } | 172 | } |
171 | ODateBookAccessBackend_XML::~ODateBookAccessBackend_XML() { | 173 | ODateBookAccessBackend_XML::~ODateBookAccessBackend_XML() { |
172 | } | 174 | } |
173 | bool ODateBookAccessBackend_XML::load() { | 175 | bool ODateBookAccessBackend_XML::load() { |
174 | return loadFile(); | 176 | return loadFile(); |
175 | } | 177 | } |
@@ -389,137 +391,140 @@ bool ODateBookAccessBackend_XML::loadFile() { | |||
389 | // we have another attribute, read it. | 391 | // we have another attribute, read it. |
390 | int j = i; | 392 | int j = i; |
391 | while ( j < len && dt[j] != '=' ) | 393 | while ( j < len && dt[j] != '=' ) |
392 | ++j; | 394 | ++j; |
393 | QCString attr( dt+i, j-i+1); | 395 | QCString attr( dt+i, j-i+1); |
394 | 396 | ||
395 | i = ++j; // skip = | 397 | i = ++j; // skip = |
396 | 398 | ||
397 | // find the start of quotes | 399 | // find the start of quotes |
398 | while ( i < len && dt[i] != '"' ) | 400 | while ( i < len && dt[i] != '"' ) |
399 | ++i; | 401 | ++i; |
400 | j = ++i; | 402 | j = ++i; |
401 | 403 | ||
402 | bool haveUtf = FALSE; | 404 | bool haveUtf = FALSE; |
403 | bool haveEnt = FALSE; | 405 | bool haveEnt = FALSE; |
404 | while ( j < len && dt[j] != '"' ) { | 406 | while ( j < len && dt[j] != '"' ) { |
405 | if ( ((unsigned char)dt[j]) > 0x7f ) | 407 | if ( ((unsigned char)dt[j]) > 0x7f ) |
406 | haveUtf = TRUE; | 408 | haveUtf = TRUE; |
407 | if ( dt[j] == '&' ) | 409 | if ( dt[j] == '&' ) |
408 | haveEnt = TRUE; | 410 | haveEnt = TRUE; |
409 | ++j; | 411 | ++j; |
410 | } | 412 | } |
411 | if ( i == j ) { | 413 | if ( i == j ) { |
412 | // empty value | 414 | // empty value |
413 | i = j + 1; | 415 | i = j + 1; |
414 | continue; | 416 | continue; |
415 | } | 417 | } |
416 | 418 | ||
417 | QCString value( dt+i, j-i+1 ); | 419 | QCString value( dt+i, j-i+1 ); |
418 | i = j + 1; | 420 | i = j + 1; |
419 | 421 | ||
420 | QString str = (haveUtf ? QString::fromUtf8( value ) | 422 | QString str = (haveUtf ? QString::fromUtf8( value ) |
421 | : QString::fromLatin1( value ) ); | 423 | : QString::fromLatin1( value ) ); |
422 | if ( haveEnt ) | 424 | if ( haveEnt ) |
423 | str = Qtopia::plainString( str ); | 425 | str = Qtopia::plainString( str ); |
424 | 426 | ||
425 | /* | 427 | /* |
426 | * add key + value | 428 | * add key + value |
427 | */ | 429 | */ |
428 | find = dict[attr.data()]; | 430 | find = dict[attr.data()]; |
429 | if (!find) | 431 | if (!find) |
430 | ev.setCustomField( attr, value ); | 432 | ev.setCustomField( attr, value ); |
431 | else { | 433 | else { |
432 | setField( ev, *find, value ); | 434 | setField( ev, *find, value ); |
433 | } | 435 | } |
434 | } | 436 | } |
435 | /* time to finalize */ | 437 | /* time to finalize */ |
436 | finalizeRecord( ev ); | 438 | finalizeRecord( ev ); |
437 | add( ev ); | ||
438 | delete rec; | 439 | delete rec; |
439 | } | 440 | } |
440 | ::munmap(map_addr, attribute.st_size ); | 441 | ::munmap(map_addr, attribute.st_size ); |
441 | m_changed = false; // changed during add | 442 | m_changed = false; // changed during add |
442 | 443 | ||
443 | return true; | 444 | return true; |
444 | } | 445 | } |
445 | void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { | 446 | void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { |
446 | /* AllDay is alway in UTC */ | 447 | /* AllDay is alway in UTC */ |
447 | if ( ev.isAllDay() ) { | 448 | if ( ev.isAllDay() ) { |
448 | OTimeZone utc = OTimeZone::utc(); | 449 | OTimeZone utc = OTimeZone::utc(); |
449 | ev.setStartDateTime( utc.fromUTCDateTime( start ) ); | 450 | ev.setStartDateTime( utc.fromUTCDateTime( start ) ); |
450 | ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); | 451 | ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); |
451 | ev.setTimeZone( "UTC"); // make sure it is really utc | 452 | ev.setTimeZone( "UTC"); // make sure it is really utc |
452 | }else { | 453 | }else { |
453 | /* to current date time */ | 454 | /* to current date time */ |
455 | qWarning(" Start is %d", start ); | ||
454 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); | 456 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); |
455 | QDateTime date = zone.toDateTime( start ); | 457 | QDateTime date = zone.toDateTime( start ); |
458 | qWarning(" Start is %s", date.toString().latin1() ); | ||
456 | ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); | 459 | ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); |
457 | 460 | ||
458 | date = zone.toDateTime( end ); | 461 | date = zone.toDateTime( end ); |
459 | ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); | 462 | ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); |
460 | } | 463 | } |
461 | if ( rec && rec->doesRecur() ) { | 464 | if ( rec && rec->doesRecur() ) { |
462 | OTimeZone utc = OTimeZone::utc(); | 465 | OTimeZone utc = OTimeZone::utc(); |
463 | ORecur recu( *rec ); // call copy c'tor; | 466 | ORecur recu( *rec ); // call copy c'tor; |
464 | recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); | 467 | recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); |
465 | recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); | 468 | recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); |
466 | recu.setStart( ev.startDateTime().date() ); | 469 | recu.setStart( ev.startDateTime().date() ); |
467 | ev.setRecurrence( recu ); | 470 | ev.setRecurrence( recu ); |
468 | } | 471 | } |
469 | 472 | ||
470 | if (alarmTime != -1 ) { | 473 | if (alarmTime != -1 ) { |
471 | QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); | 474 | QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); |
472 | OPimAlarm al( snd , dt ); | 475 | OPimAlarm al( snd , dt ); |
473 | ev.notifiers().add( al ); | 476 | ev.notifiers().add( al ); |
474 | } | 477 | } |
475 | if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { | 478 | if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { |
479 | qWarning("already contains assign uid"); | ||
476 | ev.setUid( 1 ); | 480 | ev.setUid( 1 ); |
477 | } | 481 | } |
482 | qWarning("addind %d %s", ev.uid(), ev.description().latin1() ); | ||
478 | if ( ev.hasRecurrence() ) | 483 | if ( ev.hasRecurrence() ) |
479 | m_rep.insert( ev.uid(), ev ); | 484 | m_rep.insert( ev.uid(), ev ); |
480 | else | 485 | else |
481 | m_raw.insert( ev.uid(), ev ); | 486 | m_raw.insert( ev.uid(), ev ); |
482 | 487 | ||
483 | } | 488 | } |
484 | void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& value) { | 489 | void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& value) { |
485 | // qWarning(" setting %s", value.latin1() ); | 490 | // qWarning(" setting %s", value.latin1() ); |
486 | switch( id ) { | 491 | switch( id ) { |
487 | case FDescription: | 492 | case FDescription: |
488 | e.setDescription( value ); | 493 | e.setDescription( value ); |
489 | break; | 494 | break; |
490 | case FLocation: | 495 | case FLocation: |
491 | e.setLocation( value ); | 496 | e.setLocation( value ); |
492 | break; | 497 | break; |
493 | case FCategories: | 498 | case FCategories: |
494 | e.setCategories( e.idsFromString( value ) ); | 499 | e.setCategories( e.idsFromString( value ) ); |
495 | break; | 500 | break; |
496 | case FUid: | 501 | case FUid: |
497 | e.setUid( value.toInt() ); | 502 | e.setUid( value.toInt() ); |
498 | break; | 503 | break; |
499 | case FType: | 504 | case FType: |
500 | if ( value == "AllDay" ) { | 505 | if ( value == "AllDay" ) { |
501 | e.setAllDay( true ); | 506 | e.setAllDay( true ); |
502 | e.setTimeZone( "UTC" ); | 507 | e.setTimeZone( "UTC" ); |
503 | } | 508 | } |
504 | break; | 509 | break; |
505 | case FAlarm: | 510 | case FAlarm: |
506 | alarmTime = value.toInt(); | 511 | alarmTime = value.toInt(); |
507 | break; | 512 | break; |
508 | case FSound: | 513 | case FSound: |
509 | snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent; | 514 | snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent; |
510 | break; | 515 | break; |
511 | // recurrence stuff | 516 | // recurrence stuff |
512 | case FRType: | 517 | case FRType: |
513 | if ( value == "Daily" ) | 518 | if ( value == "Daily" ) |
514 | recur()->setType( ORecur::Daily ); | 519 | recur()->setType( ORecur::Daily ); |
515 | else if ( value == "Weekly" ) | 520 | else if ( value == "Weekly" ) |
516 | recur()->setType( ORecur::Weekly); | 521 | recur()->setType( ORecur::Weekly); |
517 | else if ( value == "MonthlyDay" ) | 522 | else if ( value == "MonthlyDay" ) |
518 | recur()->setType( ORecur::MonthlyDay ); | 523 | recur()->setType( ORecur::MonthlyDay ); |
519 | else if ( value == "MonthlyDate" ) | 524 | else if ( value == "MonthlyDate" ) |
520 | recur()->setType( ORecur::MonthlyDate ); | 525 | recur()->setType( ORecur::MonthlyDate ); |
521 | else if ( value == "Yearly" ) | 526 | else if ( value == "Yearly" ) |
522 | recur()->setType( ORecur::Yearly ); | 527 | recur()->setType( ORecur::Yearly ); |
523 | else | 528 | else |
524 | recur()->setType( ORecur::NoRepeat ); | 529 | recur()->setType( ORecur::NoRepeat ); |
525 | break; | 530 | break; |
diff --git a/libopie/pim/opimmainwindow.h b/libopie/pim/opimmainwindow.h index 34b8a71..dca3c82 100644 --- a/libopie/pim/opimmainwindow.h +++ b/libopie/pim/opimmainwindow.h | |||
@@ -1,89 +1,89 @@ | |||
1 | #ifndef OPIE_PIM_MAINWINDOW_H | 1 | #ifndef OPIE_PIM_MAINWINDOW_H |
2 | #define OPIE_PIM_MAINWINDOW_H | 2 | #define OPIE_PIM_MAINWINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | 5 | ||
6 | #include <opie/opimrecord.h> | 6 | #include <opie/opimrecord.h> |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * This is a common Opie PIM MainWindow | 9 | * This is a common Opie PIM MainWindow |
10 | * it takes care of the QCOP internals | 10 | * it takes care of the QCOP internals |
11 | * and implements some functions | 11 | * and implements some functions |
12 | * for the URL scripting schema | 12 | * for the URL scripting schema |
13 | */ | 13 | */ |
14 | /* | 14 | /* |
15 | * due Qt and Templates with signal and slots | 15 | * due Qt and Templates with signal and slots |
16 | * do not work that good :( | 16 | * do not work that good :( |
17 | * (Ok how to moc a template ;) ) | 17 | * (Ok how to moc a template ;) ) |
18 | * We will have the mainwindow which calls a struct which | 18 | * We will have the mainwindow which calls a struct which |
19 | * is normally reimplemented as a template ;) | 19 | * is normally reimplemented as a template ;) |
20 | */ | 20 | */ |
21 | 21 | ||
22 | class QCopChannel; | 22 | class QCopChannel; |
23 | class OPimMainWindow : public QMainWindow { | 23 | class OPimMainWindow : public QMainWindow { |
24 | Q_OBJECT | 24 | Q_OBJECT |
25 | public: | 25 | public: |
26 | enum TransPort { BlueTooth=0, | 26 | enum TransPort { BlueTooth=0, |
27 | IrDa }; | 27 | IrDa }; |
28 | 28 | ||
29 | OPimMainWindow( const QString& service, QWidget *parent = 0, const char* name = 0, | 29 | OPimMainWindow( const QString& service, QWidget *parent = 0, const char* name = 0, |
30 | WFlags f = WType_TopLevel); | 30 | WFlags f = WType_TopLevel); |
31 | virtual ~OPimMainWindow(); | 31 | virtual ~OPimMainWindow(); |
32 | 32 | ||
33 | 33 | ||
34 | protected slots: | 34 | protected slots: |
35 | /* | 35 | /* |
36 | * called when a setDocument | 36 | * called when a setDocument |
37 | * couldn't be handled by this window | 37 | * couldn't be handled by this window |
38 | */ | 38 | */ |
39 | virtual void doSetDocument( const QString& ); | 39 | virtual void doSetDocument( const QString& ); |
40 | /* for syncing */ | 40 | /* for syncing */ |
41 | virtual void flush() = 0; | 41 | virtual void flush() = 0; |
42 | virtual void reload() = 0; | 42 | virtual void reload() = 0; |
43 | 43 | ||
44 | /** create a new Records and return the uid */ | 44 | /** create a new Records and return the uid */ |
45 | virtual int create() = 0; | 45 | virtual int create() = 0; |
46 | /** remove a record with UID == uid */ | 46 | /** remove a record with UID == uid */ |
47 | virtual bool remove( int uid ) = 0; | 47 | virtual bool remove( int uid ) = 0; |
48 | /** beam the record with UID = uid */ | 48 | /** beam the record with UID = uid */ |
49 | virtual void beam( int uid , int transport = IrDa) = 0; | 49 | virtual void beam( int uid ) = 0; |
50 | 50 | ||
51 | /** show the record with UID == uid */ | 51 | /** show the record with UID == uid */ |
52 | virtual void show( int uid ) = 0; | 52 | virtual void show( int uid ) = 0; |
53 | /** edit the record */ | 53 | /** edit the record */ |
54 | virtual void edit( int uid ) = 0; | 54 | virtual void edit( int uid ) = 0; |
55 | 55 | ||
56 | /** make a copy of it! */ | 56 | /** make a copy of it! */ |
57 | virtual void add( const OPimRecord& ) = 0; | 57 | virtual void add( const OPimRecord& ) = 0; |
58 | 58 | ||
59 | 59 | ||
60 | QCopChannel* channel(); | 60 | QCopChannel* channel(); |
61 | 61 | ||
62 | private slots: | 62 | private slots: |
63 | void appMessage( const QCString&, const QByteArray& ); | 63 | void appMessage( const QCString&, const QByteArray& ); |
64 | void setDocument( const QString& ); | 64 | void setDocument( const QString& ); |
65 | 65 | ||
66 | 66 | ||
67 | private: | 67 | private: |
68 | class Private; | 68 | class Private; |
69 | Private* d; | 69 | Private* d; |
70 | 70 | ||
71 | int m_rtti; | 71 | int m_rtti; |
72 | QCopChannel* m_channel; | 72 | QCopChannel* m_channel; |
73 | QString m_service; | 73 | QString m_service; |
74 | QCString m_str; | 74 | QCString m_str; |
75 | OPimRecord* m_fallBack; | 75 | OPimRecord* m_fallBack; |
76 | 76 | ||
77 | /* I would love to do this as a template | 77 | /* I would love to do this as a template |
78 | * but can't think of a right way | 78 | * but can't think of a right way |
79 | * because I need signal and slots -zecke | 79 | * because I need signal and slots -zecke |
80 | */ | 80 | */ |
81 | /* | 81 | /* |
82 | * the only pointer in the whole PIM API :( | 82 | * the only pointer in the whole PIM API :( |
83 | */ | 83 | */ |
84 | virtual OPimRecord* record( int rtti, const QByteArray& ) ; | 84 | virtual OPimRecord* record( int rtti, const QByteArray& ) ; |
85 | int service(); | 85 | int service(); |
86 | }; | 86 | }; |
87 | 87 | ||
88 | 88 | ||
89 | #endif | 89 | #endif |
diff --git a/libopie/pim/test/oevent_test.cpp b/libopie/pim/test/oevent_test.cpp index d83ee0b..9f16911 100644 --- a/libopie/pim/test/oevent_test.cpp +++ b/libopie/pim/test/oevent_test.cpp | |||
@@ -1,33 +1,35 @@ | |||
1 | #include <qdatetime.h> | 1 | #include <qdatetime.h> |
2 | 2 | ||
3 | #include "../oevent.h" | 3 | #include "../oevent.h" |
4 | #include "../odatebookaccess.h" | 4 | #include "../odatebookaccess.h" |
5 | 5 | ||
6 | int main(int argc, char* argv ) { | 6 | int main(int argc, char* argv ) { |
7 | ODateBookAccess acc; | 7 | ODateBookAccess acc; |
8 | if(!acc.load() ) qWarning("could not load"); | 8 | if(!acc.load() ) qWarning("could not load"); |
9 | 9 | ||
10 | ODateBookAccess::List::Iterator it; | 10 | ODateBookAccess::List::Iterator it; |
11 | ODateBookAccess::List list = acc.allRecords(); | 11 | ODateBookAccess::List list = acc.allRecords(); |
12 | 12 | ||
13 | for( it = list.begin(); it != list.end(); ++it ){ | 13 | for( it = list.begin(); it != list.end(); ++it ){ |
14 | OEvent ev = (*it); | 14 | OEvent ev = (*it); |
15 | qWarning("Summary: %s",ev.description().latin1() ); | 15 | qWarning("Summary: %s",ev.description().latin1() ); |
16 | qWarning("Start: %s End: %s",ev.startDateTime().toString().latin1(), ev.endDateTime().toString().latin1() ); | 16 | qWarning("Start: %s End: %s",ev.startDateTime().toString().latin1(), ev.endDateTime().toString().latin1() ); |
17 | qWarning("All Day: %d",ev.isAllDay() ); | 17 | qWarning("All Day: %d Recurrence: %d",ev.isAllDay(), ev.hasRecurrence() ); |
18 | qWarning("UID %d", ev.uid() ); | ||
18 | 19 | ||
19 | } | 20 | } |
20 | QDate date1(2003,02,01 ); | 21 | QDate date1(2003,02,01 ); |
21 | QDate date2(2003,03,01 ); | 22 | QDate date2(2003,03,01 ); |
22 | 23 | ||
23 | OEffectiveEvent::ValueList effList = acc.effectiveEvents( date1,date2 ); | 24 | OEffectiveEvent::ValueList effList = acc.effectiveEvents( date1,date2 ); |
24 | OEffectiveEvent::ValueList::Iterator effIt; | 25 | OEffectiveEvent::ValueList::Iterator effIt; |
25 | 26 | ||
26 | for( effIt = effList.begin(); effIt != effList.end(); ++effIt ){ | 27 | for( effIt = effList.begin(); effIt != effList.end(); ++effIt ){ |
27 | OEffectiveEvent ef = (*effIt); | 28 | OEffectiveEvent ef = (*effIt); |
28 | qWarning("Summary: %s", ef.description().latin1() ); | 29 | qWarning("Summary: %s", ef.description().latin1() ); |
29 | qWarning("Date: %s", ef.date().toString().latin1() ); | 30 | qWarning("Date: %s", ef.date().toString().latin1() ); |
30 | } | 31 | } |
32 | acc.save(); | ||
31 | 33 | ||
32 | return 0; | 34 | return 0; |
33 | } | 35 | } |
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp index 24b69fe..4a6b7b8 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp +++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp | |||
@@ -39,137 +39,139 @@ char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) | |||
39 | do { | 39 | do { |
40 | if ((haystackChar = *hsearch++) == 0) | 40 | if ((haystackChar = *hsearch++) == 0) |
41 | return (0); | 41 | return (0); |
42 | if (hsearch >= haystack + hLen) | 42 | if (hsearch >= haystack + hLen) |
43 | return (0); | 43 | return (0); |
44 | } while (haystackChar != needleChar); | 44 | } while (haystackChar != needleChar); |
45 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); | 45 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); |
46 | hsearch--; | 46 | hsearch--; |
47 | } | 47 | } |
48 | return ((char *)hsearch); | 48 | return ((char *)hsearch); |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | namespace { | 52 | namespace { |
53 | time_t start, end, created, rp_end; | 53 | time_t start, end, created, rp_end; |
54 | ORecur* rec; | 54 | ORecur* rec; |
55 | ORecur* recur() { | 55 | ORecur* recur() { |
56 | if (!rec) | 56 | if (!rec) |
57 | rec = new ORecur; | 57 | rec = new ORecur; |
58 | 58 | ||
59 | return rec; | 59 | return rec; |
60 | } | 60 | } |
61 | int alarmTime; | 61 | int alarmTime; |
62 | int snd; | 62 | int snd; |
63 | enum Attribute{ | 63 | enum Attribute{ |
64 | FDescription = 0, | 64 | FDescription = 0, |
65 | FLocation, | 65 | FLocation, |
66 | FCategories, | 66 | FCategories, |
67 | FUid, | 67 | FUid, |
68 | FType, | 68 | FType, |
69 | FAlarm, | 69 | FAlarm, |
70 | FSound, | 70 | FSound, |
71 | FRType, | 71 | FRType, |
72 | FRWeekdays, | 72 | FRWeekdays, |
73 | FRPosition, | 73 | FRPosition, |
74 | FRFreq, | 74 | FRFreq, |
75 | FRHasEndDate, | 75 | FRHasEndDate, |
76 | FREndDate, | 76 | FREndDate, |
77 | FRStart, | 77 | FRStart, |
78 | FREnd, | 78 | FREnd, |
79 | FNote, | 79 | FNote, |
80 | FCreated, | 80 | FCreated, |
81 | FTimeZone, | 81 | FTimeZone, |
82 | FRecParent, | 82 | FRecParent, |
83 | FRecChildren, | 83 | FRecChildren, |
84 | FExceptions | 84 | FExceptions |
85 | }; | 85 | }; |
86 | inline void save( const OEvent& ev, QString& buf ) { | 86 | inline void save( const OEvent& ev, QString& buf ) { |
87 | qWarning("Saving %d %s", ev.uid(), ev.description().latin1() ); | ||
87 | buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\""; | 88 | buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\""; |
88 | if (!ev.location().isEmpty() ) | 89 | if (!ev.location().isEmpty() ) |
89 | buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\""; | 90 | buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\""; |
90 | 91 | ||
91 | buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\""; | 92 | buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\""; |
92 | buf += " uid=\"" + QString::number( ev.uid() ) + "\""; | 93 | buf += " uid=\"" + QString::number( ev.uid() ) + "\""; |
93 | 94 | ||
94 | if (ev.isAllDay() ) | 95 | if (ev.isAllDay() ) |
95 | buf += " type=\"AllDay\""; | 96 | buf += " type=\"AllDay\""; |
96 | 97 | ||
97 | if (ev.hasNotifiers() ) { | 98 | if (ev.hasNotifiers() ) { |
98 | OPimAlarm alarm = ev.notifiers().alarms()[0]; // take only the first | 99 | OPimAlarm alarm = ev.notifiers().alarms()[0]; // take only the first |
99 | int minutes = alarm.dateTime().secsTo( ev.startDateTime() ) / 60; | 100 | int minutes = alarm.dateTime().secsTo( ev.startDateTime() ) / 60; |
100 | buf += " alarm=\"" + QString::number(minutes) + "\" sound=\""; | 101 | buf += " alarm=\"" + QString::number(minutes) + "\" sound=\""; |
101 | if ( alarm.sound() == OPimAlarm::Loud ) | 102 | if ( alarm.sound() == OPimAlarm::Loud ) |
102 | buf += "loud"; | 103 | buf += "loud"; |
103 | else | 104 | else |
104 | buf += "silent"; | 105 | buf += "silent"; |
105 | buf += "\""; | 106 | buf += "\""; |
106 | } | 107 | } |
107 | if ( ev.hasRecurrence() ) { | 108 | if ( ev.hasRecurrence() ) { |
108 | buf += ev.recurrence().toString(); | 109 | buf += ev.recurrence().toString(); |
109 | } | 110 | } |
110 | 111 | ||
111 | /* | 112 | /* |
112 | * fscking timezones :) well, we'll first convert | 113 | * fscking timezones :) well, we'll first convert |
113 | * the QDateTime to a QDateTime in UTC time | 114 | * the QDateTime to a QDateTime in UTC time |
114 | * and then we'll create a nice time_t | 115 | * and then we'll create a nice time_t |
115 | */ | 116 | */ |
116 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); | 117 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); |
117 | buf += " start=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.startDateTime(), OTimeZone::utc() ) ) ) + "\""; | 118 | buf += " start=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.startDateTime(), OTimeZone::utc() ) ) ) + "\""; |
118 | buf += " end=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.endDateTime() , OTimeZone::utc() ) ) ) + "\""; | 119 | buf += " end=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.endDateTime() , OTimeZone::utc() ) ) ) + "\""; |
119 | if (!ev.note().isEmpty() ) { | 120 | if (!ev.note().isEmpty() ) { |
120 | buf += " note=\"" + Qtopia::escapeString( ev.note() ) + "\""; | 121 | buf += " note=\"" + Qtopia::escapeString( ev.note() ) + "\""; |
121 | } | 122 | } |
122 | 123 | ||
123 | buf += " timezone=\""; | 124 | buf += " timezone=\""; |
124 | if ( ev.timeZone().isEmpty() ) | 125 | if ( ev.timeZone().isEmpty() ) |
125 | buf += "None"; | 126 | buf += "None"; |
126 | else | 127 | else |
127 | buf += ev.timeZone(); | 128 | buf += ev.timeZone(); |
129 | buf += "\""; | ||
128 | 130 | ||
129 | if (ev.parent() != 0 ) { | 131 | if (ev.parent() != 0 ) { |
130 | buf += " recparent=\""+QString::number(ev.parent() )+"\""; | 132 | buf += " recparent=\""+QString::number(ev.parent() )+"\""; |
131 | } | 133 | } |
132 | 134 | ||
133 | if (ev.children().count() != 0 ) { | 135 | if (ev.children().count() != 0 ) { |
134 | QArray<int> children = ev.children(); | 136 | QArray<int> children = ev.children(); |
135 | buf += " recchildren=\""; | 137 | buf += " recchildren=\""; |
136 | for ( uint i = 0; i < children.count(); i++ ) { | 138 | for ( uint i = 0; i < children.count(); i++ ) { |
137 | if ( i != 0 ) buf += " "; | 139 | if ( i != 0 ) buf += " "; |
138 | buf += QString::number( children[i] ); | 140 | buf += QString::number( children[i] ); |
139 | } | 141 | } |
140 | buf+= "\""; | 142 | buf+= "\""; |
141 | } | 143 | } |
142 | 144 | ||
143 | // skip custom writing | 145 | // skip custom writing |
144 | } | 146 | } |
145 | 147 | ||
146 | inline bool forAll( const QMap<int, OEvent>& list, QFile& file ) { | 148 | inline bool forAll( const QMap<int, OEvent>& list, QFile& file ) { |
147 | QMap<int, OEvent>::ConstIterator it; | 149 | QMap<int, OEvent>::ConstIterator it; |
148 | QString buf; | 150 | QString buf; |
149 | QCString str; | 151 | QCString str; |
150 | int total_written; | 152 | int total_written; |
151 | for ( it = list.begin(); it != list.end(); ++it ) { | 153 | for ( it = list.begin(); it != list.end(); ++it ) { |
152 | buf = "<event"; | 154 | buf = "<event"; |
153 | save( it.data(), buf ); | 155 | save( it.data(), buf ); |
154 | buf += " />\n"; | 156 | buf += " />\n"; |
155 | str = buf.utf8(); | 157 | str = buf.utf8(); |
156 | 158 | ||
157 | total_written = file.writeBlock(str.data(), str.length() ); | 159 | total_written = file.writeBlock(str.data(), str.length() ); |
158 | if ( total_written != int(str.length() ) ) | 160 | if ( total_written != int(str.length() ) ) |
159 | return false; | 161 | return false; |
160 | } | 162 | } |
161 | return true; | 163 | return true; |
162 | } | 164 | } |
163 | } | 165 | } |
164 | 166 | ||
165 | ODateBookAccessBackend_XML::ODateBookAccessBackend_XML( const QString& , | 167 | ODateBookAccessBackend_XML::ODateBookAccessBackend_XML( const QString& , |
166 | const QString& fileName ) | 168 | const QString& fileName ) |
167 | : ODateBookAccessBackend() { | 169 | : ODateBookAccessBackend() { |
168 | m_name = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.xml" ) : fileName; | 170 | m_name = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.xml" ) : fileName; |
169 | m_changed = false; | 171 | m_changed = false; |
170 | } | 172 | } |
171 | ODateBookAccessBackend_XML::~ODateBookAccessBackend_XML() { | 173 | ODateBookAccessBackend_XML::~ODateBookAccessBackend_XML() { |
172 | } | 174 | } |
173 | bool ODateBookAccessBackend_XML::load() { | 175 | bool ODateBookAccessBackend_XML::load() { |
174 | return loadFile(); | 176 | return loadFile(); |
175 | } | 177 | } |
@@ -389,137 +391,140 @@ bool ODateBookAccessBackend_XML::loadFile() { | |||
389 | // we have another attribute, read it. | 391 | // we have another attribute, read it. |
390 | int j = i; | 392 | int j = i; |
391 | while ( j < len && dt[j] != '=' ) | 393 | while ( j < len && dt[j] != '=' ) |
392 | ++j; | 394 | ++j; |
393 | QCString attr( dt+i, j-i+1); | 395 | QCString attr( dt+i, j-i+1); |
394 | 396 | ||
395 | i = ++j; // skip = | 397 | i = ++j; // skip = |
396 | 398 | ||
397 | // find the start of quotes | 399 | // find the start of quotes |
398 | while ( i < len && dt[i] != '"' ) | 400 | while ( i < len && dt[i] != '"' ) |
399 | ++i; | 401 | ++i; |
400 | j = ++i; | 402 | j = ++i; |
401 | 403 | ||
402 | bool haveUtf = FALSE; | 404 | bool haveUtf = FALSE; |
403 | bool haveEnt = FALSE; | 405 | bool haveEnt = FALSE; |
404 | while ( j < len && dt[j] != '"' ) { | 406 | while ( j < len && dt[j] != '"' ) { |
405 | if ( ((unsigned char)dt[j]) > 0x7f ) | 407 | if ( ((unsigned char)dt[j]) > 0x7f ) |
406 | haveUtf = TRUE; | 408 | haveUtf = TRUE; |
407 | if ( dt[j] == '&' ) | 409 | if ( dt[j] == '&' ) |
408 | haveEnt = TRUE; | 410 | haveEnt = TRUE; |
409 | ++j; | 411 | ++j; |
410 | } | 412 | } |
411 | if ( i == j ) { | 413 | if ( i == j ) { |
412 | // empty value | 414 | // empty value |
413 | i = j + 1; | 415 | i = j + 1; |
414 | continue; | 416 | continue; |
415 | } | 417 | } |
416 | 418 | ||
417 | QCString value( dt+i, j-i+1 ); | 419 | QCString value( dt+i, j-i+1 ); |
418 | i = j + 1; | 420 | i = j + 1; |
419 | 421 | ||
420 | QString str = (haveUtf ? QString::fromUtf8( value ) | 422 | QString str = (haveUtf ? QString::fromUtf8( value ) |
421 | : QString::fromLatin1( value ) ); | 423 | : QString::fromLatin1( value ) ); |
422 | if ( haveEnt ) | 424 | if ( haveEnt ) |
423 | str = Qtopia::plainString( str ); | 425 | str = Qtopia::plainString( str ); |
424 | 426 | ||
425 | /* | 427 | /* |
426 | * add key + value | 428 | * add key + value |
427 | */ | 429 | */ |
428 | find = dict[attr.data()]; | 430 | find = dict[attr.data()]; |
429 | if (!find) | 431 | if (!find) |
430 | ev.setCustomField( attr, value ); | 432 | ev.setCustomField( attr, value ); |
431 | else { | 433 | else { |
432 | setField( ev, *find, value ); | 434 | setField( ev, *find, value ); |
433 | } | 435 | } |
434 | } | 436 | } |
435 | /* time to finalize */ | 437 | /* time to finalize */ |
436 | finalizeRecord( ev ); | 438 | finalizeRecord( ev ); |
437 | add( ev ); | ||
438 | delete rec; | 439 | delete rec; |
439 | } | 440 | } |
440 | ::munmap(map_addr, attribute.st_size ); | 441 | ::munmap(map_addr, attribute.st_size ); |
441 | m_changed = false; // changed during add | 442 | m_changed = false; // changed during add |
442 | 443 | ||
443 | return true; | 444 | return true; |
444 | } | 445 | } |
445 | void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { | 446 | void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { |
446 | /* AllDay is alway in UTC */ | 447 | /* AllDay is alway in UTC */ |
447 | if ( ev.isAllDay() ) { | 448 | if ( ev.isAllDay() ) { |
448 | OTimeZone utc = OTimeZone::utc(); | 449 | OTimeZone utc = OTimeZone::utc(); |
449 | ev.setStartDateTime( utc.fromUTCDateTime( start ) ); | 450 | ev.setStartDateTime( utc.fromUTCDateTime( start ) ); |
450 | ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); | 451 | ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); |
451 | ev.setTimeZone( "UTC"); // make sure it is really utc | 452 | ev.setTimeZone( "UTC"); // make sure it is really utc |
452 | }else { | 453 | }else { |
453 | /* to current date time */ | 454 | /* to current date time */ |
455 | qWarning(" Start is %d", start ); | ||
454 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); | 456 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); |
455 | QDateTime date = zone.toDateTime( start ); | 457 | QDateTime date = zone.toDateTime( start ); |
458 | qWarning(" Start is %s", date.toString().latin1() ); | ||
456 | ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); | 459 | ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); |
457 | 460 | ||
458 | date = zone.toDateTime( end ); | 461 | date = zone.toDateTime( end ); |
459 | ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); | 462 | ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); |
460 | } | 463 | } |
461 | if ( rec && rec->doesRecur() ) { | 464 | if ( rec && rec->doesRecur() ) { |
462 | OTimeZone utc = OTimeZone::utc(); | 465 | OTimeZone utc = OTimeZone::utc(); |
463 | ORecur recu( *rec ); // call copy c'tor; | 466 | ORecur recu( *rec ); // call copy c'tor; |
464 | recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); | 467 | recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); |
465 | recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); | 468 | recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); |
466 | recu.setStart( ev.startDateTime().date() ); | 469 | recu.setStart( ev.startDateTime().date() ); |
467 | ev.setRecurrence( recu ); | 470 | ev.setRecurrence( recu ); |
468 | } | 471 | } |
469 | 472 | ||
470 | if (alarmTime != -1 ) { | 473 | if (alarmTime != -1 ) { |
471 | QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); | 474 | QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); |
472 | OPimAlarm al( snd , dt ); | 475 | OPimAlarm al( snd , dt ); |
473 | ev.notifiers().add( al ); | 476 | ev.notifiers().add( al ); |
474 | } | 477 | } |
475 | if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { | 478 | if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { |
479 | qWarning("already contains assign uid"); | ||
476 | ev.setUid( 1 ); | 480 | ev.setUid( 1 ); |
477 | } | 481 | } |
482 | qWarning("addind %d %s", ev.uid(), ev.description().latin1() ); | ||
478 | if ( ev.hasRecurrence() ) | 483 | if ( ev.hasRecurrence() ) |
479 | m_rep.insert( ev.uid(), ev ); | 484 | m_rep.insert( ev.uid(), ev ); |
480 | else | 485 | else |
481 | m_raw.insert( ev.uid(), ev ); | 486 | m_raw.insert( ev.uid(), ev ); |
482 | 487 | ||
483 | } | 488 | } |
484 | void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& value) { | 489 | void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& value) { |
485 | // qWarning(" setting %s", value.latin1() ); | 490 | // qWarning(" setting %s", value.latin1() ); |
486 | switch( id ) { | 491 | switch( id ) { |
487 | case FDescription: | 492 | case FDescription: |
488 | e.setDescription( value ); | 493 | e.setDescription( value ); |
489 | break; | 494 | break; |
490 | case FLocation: | 495 | case FLocation: |
491 | e.setLocation( value ); | 496 | e.setLocation( value ); |
492 | break; | 497 | break; |
493 | case FCategories: | 498 | case FCategories: |
494 | e.setCategories( e.idsFromString( value ) ); | 499 | e.setCategories( e.idsFromString( value ) ); |
495 | break; | 500 | break; |
496 | case FUid: | 501 | case FUid: |
497 | e.setUid( value.toInt() ); | 502 | e.setUid( value.toInt() ); |
498 | break; | 503 | break; |
499 | case FType: | 504 | case FType: |
500 | if ( value == "AllDay" ) { | 505 | if ( value == "AllDay" ) { |
501 | e.setAllDay( true ); | 506 | e.setAllDay( true ); |
502 | e.setTimeZone( "UTC" ); | 507 | e.setTimeZone( "UTC" ); |
503 | } | 508 | } |
504 | break; | 509 | break; |
505 | case FAlarm: | 510 | case FAlarm: |
506 | alarmTime = value.toInt(); | 511 | alarmTime = value.toInt(); |
507 | break; | 512 | break; |
508 | case FSound: | 513 | case FSound: |
509 | snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent; | 514 | snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent; |
510 | break; | 515 | break; |
511 | // recurrence stuff | 516 | // recurrence stuff |
512 | case FRType: | 517 | case FRType: |
513 | if ( value == "Daily" ) | 518 | if ( value == "Daily" ) |
514 | recur()->setType( ORecur::Daily ); | 519 | recur()->setType( ORecur::Daily ); |
515 | else if ( value == "Weekly" ) | 520 | else if ( value == "Weekly" ) |
516 | recur()->setType( ORecur::Weekly); | 521 | recur()->setType( ORecur::Weekly); |
517 | else if ( value == "MonthlyDay" ) | 522 | else if ( value == "MonthlyDay" ) |
518 | recur()->setType( ORecur::MonthlyDay ); | 523 | recur()->setType( ORecur::MonthlyDay ); |
519 | else if ( value == "MonthlyDate" ) | 524 | else if ( value == "MonthlyDate" ) |
520 | recur()->setType( ORecur::MonthlyDate ); | 525 | recur()->setType( ORecur::MonthlyDate ); |
521 | else if ( value == "Yearly" ) | 526 | else if ( value == "Yearly" ) |
522 | recur()->setType( ORecur::Yearly ); | 527 | recur()->setType( ORecur::Yearly ); |
523 | else | 528 | else |
524 | recur()->setType( ORecur::NoRepeat ); | 529 | recur()->setType( ORecur::NoRepeat ); |
525 | break; | 530 | break; |
diff --git a/libopie2/opiepim/ui/opimmainwindow.h b/libopie2/opiepim/ui/opimmainwindow.h index 34b8a71..dca3c82 100644 --- a/libopie2/opiepim/ui/opimmainwindow.h +++ b/libopie2/opiepim/ui/opimmainwindow.h | |||
@@ -1,89 +1,89 @@ | |||
1 | #ifndef OPIE_PIM_MAINWINDOW_H | 1 | #ifndef OPIE_PIM_MAINWINDOW_H |
2 | #define OPIE_PIM_MAINWINDOW_H | 2 | #define OPIE_PIM_MAINWINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | 5 | ||
6 | #include <opie/opimrecord.h> | 6 | #include <opie/opimrecord.h> |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * This is a common Opie PIM MainWindow | 9 | * This is a common Opie PIM MainWindow |
10 | * it takes care of the QCOP internals | 10 | * it takes care of the QCOP internals |
11 | * and implements some functions | 11 | * and implements some functions |
12 | * for the URL scripting schema | 12 | * for the URL scripting schema |
13 | */ | 13 | */ |
14 | /* | 14 | /* |
15 | * due Qt and Templates with signal and slots | 15 | * due Qt and Templates with signal and slots |
16 | * do not work that good :( | 16 | * do not work that good :( |
17 | * (Ok how to moc a template ;) ) | 17 | * (Ok how to moc a template ;) ) |
18 | * We will have the mainwindow which calls a struct which | 18 | * We will have the mainwindow which calls a struct which |
19 | * is normally reimplemented as a template ;) | 19 | * is normally reimplemented as a template ;) |
20 | */ | 20 | */ |
21 | 21 | ||
22 | class QCopChannel; | 22 | class QCopChannel; |
23 | class OPimMainWindow : public QMainWindow { | 23 | class OPimMainWindow : public QMainWindow { |
24 | Q_OBJECT | 24 | Q_OBJECT |
25 | public: | 25 | public: |
26 | enum TransPort { BlueTooth=0, | 26 | enum TransPort { BlueTooth=0, |
27 | IrDa }; | 27 | IrDa }; |
28 | 28 | ||
29 | OPimMainWindow( const QString& service, QWidget *parent = 0, const char* name = 0, | 29 | OPimMainWindow( const QString& service, QWidget *parent = 0, const char* name = 0, |
30 | WFlags f = WType_TopLevel); | 30 | WFlags f = WType_TopLevel); |
31 | virtual ~OPimMainWindow(); | 31 | virtual ~OPimMainWindow(); |
32 | 32 | ||
33 | 33 | ||
34 | protected slots: | 34 | protected slots: |
35 | /* | 35 | /* |
36 | * called when a setDocument | 36 | * called when a setDocument |
37 | * couldn't be handled by this window | 37 | * couldn't be handled by this window |
38 | */ | 38 | */ |
39 | virtual void doSetDocument( const QString& ); | 39 | virtual void doSetDocument( const QString& ); |
40 | /* for syncing */ | 40 | /* for syncing */ |
41 | virtual void flush() = 0; | 41 | virtual void flush() = 0; |
42 | virtual void reload() = 0; | 42 | virtual void reload() = 0; |
43 | 43 | ||
44 | /** create a new Records and return the uid */ | 44 | /** create a new Records and return the uid */ |
45 | virtual int create() = 0; | 45 | virtual int create() = 0; |
46 | /** remove a record with UID == uid */ | 46 | /** remove a record with UID == uid */ |
47 | virtual bool remove( int uid ) = 0; | 47 | virtual bool remove( int uid ) = 0; |
48 | /** beam the record with UID = uid */ | 48 | /** beam the record with UID = uid */ |
49 | virtual void beam( int uid , int transport = IrDa) = 0; | 49 | virtual void beam( int uid ) = 0; |
50 | 50 | ||
51 | /** show the record with UID == uid */ | 51 | /** show the record with UID == uid */ |
52 | virtual void show( int uid ) = 0; | 52 | virtual void show( int uid ) = 0; |
53 | /** edit the record */ | 53 | /** edit the record */ |
54 | virtual void edit( int uid ) = 0; | 54 | virtual void edit( int uid ) = 0; |
55 | 55 | ||
56 | /** make a copy of it! */ | 56 | /** make a copy of it! */ |
57 | virtual void add( const OPimRecord& ) = 0; | 57 | virtual void add( const OPimRecord& ) = 0; |
58 | 58 | ||
59 | 59 | ||
60 | QCopChannel* channel(); | 60 | QCopChannel* channel(); |
61 | 61 | ||
62 | private slots: | 62 | private slots: |
63 | void appMessage( const QCString&, const QByteArray& ); | 63 | void appMessage( const QCString&, const QByteArray& ); |
64 | void setDocument( const QString& ); | 64 | void setDocument( const QString& ); |
65 | 65 | ||
66 | 66 | ||
67 | private: | 67 | private: |
68 | class Private; | 68 | class Private; |
69 | Private* d; | 69 | Private* d; |
70 | 70 | ||
71 | int m_rtti; | 71 | int m_rtti; |
72 | QCopChannel* m_channel; | 72 | QCopChannel* m_channel; |
73 | QString m_service; | 73 | QString m_service; |
74 | QCString m_str; | 74 | QCString m_str; |
75 | OPimRecord* m_fallBack; | 75 | OPimRecord* m_fallBack; |
76 | 76 | ||
77 | /* I would love to do this as a template | 77 | /* I would love to do this as a template |
78 | * but can't think of a right way | 78 | * but can't think of a right way |
79 | * because I need signal and slots -zecke | 79 | * because I need signal and slots -zecke |
80 | */ | 80 | */ |
81 | /* | 81 | /* |
82 | * the only pointer in the whole PIM API :( | 82 | * the only pointer in the whole PIM API :( |
83 | */ | 83 | */ |
84 | virtual OPimRecord* record( int rtti, const QByteArray& ) ; | 84 | virtual OPimRecord* record( int rtti, const QByteArray& ) ; |
85 | int service(); | 85 | int service(); |
86 | }; | 86 | }; |
87 | 87 | ||
88 | 88 | ||
89 | #endif | 89 | #endif |