author | zautrix <zautrix> | 2004-08-09 11:15:24 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-09 11:15:24 (UTC) |
commit | e0ba2d4770094974ec4a2a48af436a7df9a055bc (patch) (unidiff) | |
tree | 52752d9fcff91934e43b27dd6926ead31c44f4f7 | |
parent | 2d3e20244a156485f6001aa82c4494dfce177b8f (diff) | |
download | kdepimpi-e0ba2d4770094974ec4a2a48af436a7df9a055bc.zip kdepimpi-e0ba2d4770094974ec4a2a48af436a7df9a055bc.tar.gz kdepimpi-e0ba2d4770094974ec4a2a48af436a7df9a055bc.tar.bz2 |
more fixes
-rw-r--r-- | libkcal/phoneformat.cpp | 8 | ||||
-rw-r--r-- | libkcal/sharpformat.cpp | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 94744fb..bc1b863 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -97,146 +97,148 @@ public: | |||
97 | else { | 97 | else { |
98 | todo->setCompleted( false ); | 98 | todo->setCompleted( false ); |
99 | } | 99 | } |
100 | break; | 100 | break; |
101 | case TODO_ALARM_DATETIME: | 101 | case TODO_ALARM_DATETIME: |
102 | dtp = &ToDo->Entries[j].Date ; | 102 | dtp = &ToDo->Entries[j].Date ; |
103 | alarm = true; | 103 | alarm = true; |
104 | alarmDt = fromGSM ( dtp ); | 104 | alarmDt = fromGSM ( dtp ); |
105 | break; | 105 | break; |
106 | case TODO_SILENT_ALARM_DATETIME: | 106 | case TODO_SILENT_ALARM_DATETIME: |
107 | dtp = &ToDo->Entries[j].Date ; | 107 | dtp = &ToDo->Entries[j].Date ; |
108 | alarm = true; | 108 | alarm = true; |
109 | alarmDt = fromGSM ( dtp ); | 109 | alarmDt = fromGSM ( dtp ); |
110 | break; | 110 | break; |
111 | case TODO_TEXT: | 111 | case TODO_TEXT: |
112 | //qDebug(" text *%s* ", (const char*) DecodeUnicodeConsole(ToDo->Entries[j].Text )); | 112 | //qDebug(" text *%s* ", (const char*) DecodeUnicodeConsole(ToDo->Entries[j].Text )); |
113 | todo->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole(ToDo->Entries[j].Text ))); | 113 | todo->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole(ToDo->Entries[j].Text ))); |
114 | break; | 114 | break; |
115 | case TODO_PRIVATE: | 115 | case TODO_PRIVATE: |
116 | if ( ToDo->Entries[j].Number == 1 ) | 116 | if ( ToDo->Entries[j].Number == 1 ) |
117 | todo->setSecrecy( Incidence::SecrecyPrivate ); | 117 | todo->setSecrecy( Incidence::SecrecyPrivate ); |
118 | else | 118 | else |
119 | todo->setSecrecy( Incidence::SecrecyPublic ); | 119 | todo->setSecrecy( Incidence::SecrecyPublic ); |
120 | break; | 120 | break; |
121 | case TODO_CATEGORY: | 121 | case TODO_CATEGORY: |
122 | Category.Location = ToDo->Entries[j].Number; | 122 | Category.Location = ToDo->Entries[j].Number; |
123 | Category.Type = Category_ToDo; | 123 | Category.Type = Category_ToDo; |
124 | error=Phone->GetCategory(s, &Category); | 124 | error=Phone->GetCategory(s, &Category); |
125 | if (error == ERR_NONE) { | 125 | if (error == ERR_NONE) { |
126 | QStringList cat = todo->categories(); | 126 | QStringList cat = todo->categories(); |
127 | QString nCat = QString ( (const char*)Category.Name ); | 127 | QString nCat = QString ( (const char*)Category.Name ); |
128 | if ( !nCat.isEmpty() ) | 128 | if ( !nCat.isEmpty() ) |
129 | if ( !cat.contains( nCat )) { | 129 | if ( !cat.contains( nCat )) { |
130 | cat << nCat; | 130 | cat << nCat; |
131 | todo->setCategories( cat ); | 131 | todo->setCategories( cat ); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | break; | 134 | break; |
135 | case TODO_CONTACTID: | 135 | case TODO_CONTACTID: |
136 | #if 0 | 136 | #if 0 |
137 | // not supported | 137 | // not supported |
138 | entry.Location = ToDo->Entries[j].Number; | 138 | entry.Location = ToDo->Entries[j].Number; |
139 | entry.MemoryType = MEM_ME; | 139 | entry.MemoryType = MEM_ME; |
140 | error=Phone->GetMemory(s, &entry); | 140 | error=Phone->GetMemory(s, &entry); |
141 | if (error == ERR_NONE) { | 141 | if (error == ERR_NONE) { |
142 | name = GSM_PhonebookGetEntryName(&entry); | 142 | name = GSM_PhonebookGetEntryName(&entry); |
143 | if (name != NULL) { | 143 | if (name != NULL) { |
144 | printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); | 144 | printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); |
145 | } else { | 145 | } else { |
146 | printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); | 146 | printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); |
147 | } | 147 | } |
148 | } else { | 148 | } else { |
149 | printmsg("Contact : %d\n",ToDo->Entries[j].Number); | 149 | printmsg("Contact : %d\n",ToDo->Entries[j].Number); |
150 | } | 150 | } |
151 | #endif | 151 | #endif |
152 | break; | 152 | break; |
153 | case TODO_PHONE: | 153 | case TODO_PHONE: |
154 | #if 0 | 154 | #if 0 |
155 | // not supported | 155 | // not supported |
156 | printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); | 156 | printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); |
157 | #endif | 157 | #endif |
158 | break; | 158 | break; |
159 | } | 159 | } |
160 | } | 160 | } |
161 | QString alarmString = ""; | 161 | QString alarmString = "na"; |
162 | if ( alarm ) { | 162 | if ( alarm ) { |
163 | Alarm *alarm; | 163 | Alarm *alarm; |
164 | if ( todo->alarms().count() > 0 ) | 164 | if ( todo->alarms().count() > 0 ) |
165 | alarm = todo->alarms().first(); | 165 | alarm = todo->alarms().first(); |
166 | else { | 166 | else { |
167 | alarm = new Alarm( todo ); | 167 | alarm = new Alarm( todo ); |
168 | todo->addAlarm( alarm ); | 168 | todo->addAlarm( alarm ); |
169 | } | 169 | } |
170 | alarm->setType( Alarm::Audio ); | 170 | alarm->setType( Alarm::Audio ); |
171 | alarm->setEnabled( true ); | 171 | alarm->setEnabled( true ); |
172 | int alarmOffset = alarmDt.secsTo( todo->dtStart() ); | 172 | int alarmOffset = alarmDt.secsTo( todo->dtStart() ); |
173 | alarm->setStartOffset( -alarmOffset ); | 173 | alarm->setStartOffset( -alarmOffset ); |
174 | alarmString = QString::number( alarmOffset ); | 174 | alarmString = QString::number( alarmOffset ); |
175 | } else { | 175 | } else { |
176 | Alarm *alarm; | 176 | Alarm *alarm; |
177 | if ( todo->alarms().count() > 0 ) { | 177 | if ( todo->alarms().count() > 0 ) { |
178 | alarm = todo->alarms().first(); | 178 | alarm = todo->alarms().first(); |
179 | alarm->setType( Alarm::Audio ); | ||
180 | alarm->setStartOffset( -60*15 ); | ||
179 | alarm->setEnabled( false ); | 181 | alarm->setEnabled( false ); |
180 | } | 182 | } |
181 | } | 183 | } |
182 | // csum ***************************************** | 184 | // csum ***************************************** |
183 | QStringList attList; | 185 | QStringList attList; |
184 | uint cSum; | 186 | uint cSum; |
185 | if ( todo->hasDueDate() ) | 187 | if ( todo->hasDueDate() ) |
186 | attList << dtToString ( todo->dtDue() ); | 188 | attList << dtToString ( todo->dtDue() ); |
187 | attList << QString::number( id ); | 189 | attList << QString::number( id ); |
188 | attList << todo->summary(); | 190 | attList << todo->summary(); |
189 | attList << completedString; | 191 | attList << completedString; |
190 | attList << QString::number( todo->priority() ); | 192 | attList << QString::number( todo->priority() ); |
191 | attList << alarmString; | 193 | attList << alarmString; |
192 | attList << todo->categoriesStr(); | 194 | attList << todo->categoriesStr(); |
193 | attList << todo->secrecyStr(); | 195 | attList << todo->secrecyStr(); |
194 | cSum = PhoneFormat::getCsum(attList ); | 196 | cSum = PhoneFormat::getCsum(attList ); |
195 | todo->setCsum( mProfileName, QString::number( cSum )); | 197 | todo->setCsum( mProfileName, QString::number( cSum )); |
196 | mCalendar->addTodo( todo); | 198 | mCalendar->addTodo( todo); |
197 | 199 | ||
198 | return true; | 200 | return true; |
199 | } | 201 | } |
200 | bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note) | 202 | bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note) |
201 | { | 203 | { |
202 | 204 | ||
203 | int id = Note->Location; | 205 | int id = Note->Location; |
204 | Event *event; | 206 | Event *event; |
205 | event = existingCalendar->event( mProfileName ,QString::number( id ) ); | 207 | event = existingCalendar->event( mProfileName ,QString::number( id ) ); |
206 | if ( event ) | 208 | if ( event ) |
207 | event = (Event*)event->clone(); | 209 | event = (Event*)event->clone(); |
208 | else | 210 | else |
209 | event = new Event; | 211 | event = new Event; |
210 | event->setID( mProfileName,QString::number( id ) ); | 212 | event->setID( mProfileName,QString::number( id ) ); |
211 | event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); | 213 | event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); |
212 | 214 | ||
213 | 215 | ||
214 | int i = 0; | 216 | int i = 0; |
215 | bool repeating = false; | 217 | bool repeating = false; |
216 | int repeat_dayofweek = -1; | 218 | int repeat_dayofweek = -1; |
217 | int repeat_day = -1; | 219 | int repeat_day = -1; |
218 | int repeat_weekofmonth = -1; | 220 | int repeat_weekofmonth = -1; |
219 | int repeat_month = -1; | 221 | int repeat_month = -1; |
220 | int repeat_frequency = -1; | 222 | int repeat_frequency = -1; |
221 | int rec_type = -1; | 223 | int rec_type = -1; |
222 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; | 224 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; |
223 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; | 225 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; |
224 | GSM_DateTime* dtp; | 226 | GSM_DateTime* dtp; |
225 | bool alarm = false; | 227 | bool alarm = false; |
226 | QDateTime alarmDt; | 228 | QDateTime alarmDt; |
227 | repeat_startdate.Day= 0; | 229 | repeat_startdate.Day= 0; |
228 | repeat_stopdate.Day = 0; | 230 | repeat_stopdate.Day = 0; |
229 | for (i=0;i<Note->EntriesNum;i++) { | 231 | for (i=0;i<Note->EntriesNum;i++) { |
230 | 232 | ||
231 | //qDebug(" for ev"); | 233 | //qDebug(" for ev"); |
232 | switch (Note->Entries[i].EntryType) { | 234 | switch (Note->Entries[i].EntryType) { |
233 | case CAL_START_DATETIME: | 235 | case CAL_START_DATETIME: |
234 | dtp = &Note->Entries[i].Date ; | 236 | dtp = &Note->Entries[i].Date ; |
235 | if ( dtp->Hour > 24 ) { | 237 | if ( dtp->Hour > 24 ) { |
236 | event->setFloats( true ); | 238 | event->setFloats( true ); |
237 | event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); | 239 | event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); |
238 | } else { | 240 | } else { |
239 | event->setDtStart (fromGSM ( dtp )); | 241 | event->setDtStart (fromGSM ( dtp )); |
240 | 242 | ||
241 | } | 243 | } |
242 | break; | 244 | break; |
@@ -380,147 +382,149 @@ public: | |||
380 | } | 382 | } |
381 | // qDebug("next "); | 383 | // qDebug("next "); |
382 | int pos = 0; | 384 | int pos = 0; |
383 | Recurrence *r = event->recurrence(); | 385 | Recurrence *r = event->recurrence(); |
384 | /* | 386 | /* |
385 | 0 daily; | 387 | 0 daily; |
386 | 1 weekly;x | 388 | 1 weekly;x |
387 | 2 monthpos;x | 389 | 2 monthpos;x |
388 | 3 monthlyday; | 390 | 3 monthlyday; |
389 | 4 rYearlyMont | 391 | 4 rYearlyMont |
390 | bool repeating = false; | 392 | bool repeating = false; |
391 | int repeat_dayofweek = -1; | 393 | int repeat_dayofweek = -1; |
392 | int repeat_day = -1; | 394 | int repeat_day = -1; |
393 | int repeat_weekofmonth = -1; | 395 | int repeat_weekofmonth = -1; |
394 | int repeat_month = -1; | 396 | int repeat_month = -1; |
395 | int repeat_frequency = -1; | 397 | int repeat_frequency = -1; |
396 | */ | 398 | */ |
397 | int dayOfWeek = startDate.dayOfWeek(); | 399 | int dayOfWeek = startDate.dayOfWeek(); |
398 | if ( repeat_weekofmonth >= 0 ) { | 400 | if ( repeat_weekofmonth >= 0 ) { |
399 | rtype = 2; | 401 | rtype = 2; |
400 | pos = repeat_weekofmonth; | 402 | pos = repeat_weekofmonth; |
401 | if ( repeat_dayofweek >= 0 ) | 403 | if ( repeat_dayofweek >= 0 ) |
402 | dayOfWeek = repeat_dayofweek; | 404 | dayOfWeek = repeat_dayofweek; |
403 | } else if ( repeat_dayofweek >= 0 ) { | 405 | } else if ( repeat_dayofweek >= 0 ) { |
404 | rtype = 1; | 406 | rtype = 1; |
405 | } if ( repeat_dayofweek >= 0 ) { | 407 | } if ( repeat_dayofweek >= 0 ) { |
406 | rtype = 1; | 408 | rtype = 1; |
407 | } | 409 | } |
408 | 410 | ||
409 | if ( rtype == 0 ) { | 411 | if ( rtype == 0 ) { |
410 | if ( hasEndDate ) r->setDaily( freq, endDate ); | 412 | if ( hasEndDate ) r->setDaily( freq, endDate ); |
411 | else r->setDaily( freq, -1 ); | 413 | else r->setDaily( freq, -1 ); |
412 | } else if ( rtype == 1 ) { | 414 | } else if ( rtype == 1 ) { |
413 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); | 415 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); |
414 | else r->setWeekly( freq, weekDays, -1 ); | 416 | else r->setWeekly( freq, weekDays, -1 ); |
415 | } else if ( rtype == 3 ) { | 417 | } else if ( rtype == 3 ) { |
416 | if ( hasEndDate ) | 418 | if ( hasEndDate ) |
417 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 419 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
418 | else | 420 | else |
419 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); | 421 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); |
420 | r->addMonthlyDay( startDate.day() ); | 422 | r->addMonthlyDay( startDate.day() ); |
421 | } else if ( rtype == 2 ) { | 423 | } else if ( rtype == 2 ) { |
422 | if ( hasEndDate ) | 424 | if ( hasEndDate ) |
423 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 425 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
424 | else | 426 | else |
425 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); | 427 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); |
426 | QBitArray days( 7 ); | 428 | QBitArray days( 7 ); |
427 | days.fill( false ); | 429 | days.fill( false ); |
428 | days.setBit( dayOfWeek - 1 ); | 430 | days.setBit( dayOfWeek - 1 ); |
429 | r->addMonthlyPos( pos, days ); | 431 | r->addMonthlyPos( pos, days ); |
430 | } else if ( rtype == 4 ) { | 432 | } else if ( rtype == 4 ) { |
431 | if ( hasEndDate ) | 433 | if ( hasEndDate ) |
432 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 434 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
433 | else | 435 | else |
434 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); | 436 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); |
435 | r->addYearlyNum( startDate.month() ); | 437 | r->addYearlyNum( startDate.month() ); |
436 | } | 438 | } |
437 | } else { | 439 | } else { |
438 | event->recurrence()->unsetRecurs(); | 440 | event->recurrence()->unsetRecurs(); |
439 | } | 441 | } |
440 | 442 | ||
441 | QStringList categoryList; | 443 | QStringList categoryList; |
442 | categoryList << getCategory( Note ); | 444 | categoryList << getCategory( Note ); |
443 | event->setCategories( categoryList ); | 445 | event->setCategories( categoryList ); |
444 | QString alarmString = ""; | 446 | QString alarmString = "na"; |
445 | // strange 0 semms to mean: alarm enabled | 447 | // strange 0 semms to mean: alarm enabled |
446 | if ( alarm ) { | 448 | if ( alarm ) { |
447 | Alarm *alarm; | 449 | Alarm *alarm; |
448 | if ( event->alarms().count() > 0 ) | 450 | if ( event->alarms().count() > 0 ) |
449 | alarm = event->alarms().first(); | 451 | alarm = event->alarms().first(); |
450 | else { | 452 | else { |
451 | alarm = new Alarm( event ); | 453 | alarm = new Alarm( event ); |
452 | event->addAlarm( alarm ); | 454 | event->addAlarm( alarm ); |
453 | } | 455 | } |
454 | alarm->setType( Alarm::Audio ); | 456 | alarm->setType( Alarm::Audio ); |
455 | alarm->setEnabled( true ); | 457 | alarm->setEnabled( true ); |
456 | int alarmOffset = alarmDt.secsTo( event->dtStart() ); | 458 | int alarmOffset = alarmDt.secsTo( event->dtStart() ); |
457 | alarm->setStartOffset( -alarmOffset ); | 459 | alarm->setStartOffset( -alarmOffset ); |
458 | alarmString = QString::number( alarmOffset ); | 460 | alarmString = QString::number( alarmOffset ); |
459 | } else { | 461 | } else { |
460 | Alarm *alarm; | 462 | Alarm *alarm; |
461 | if ( event->alarms().count() > 0 ) { | 463 | if ( event->alarms().count() > 0 ) { |
462 | alarm = event->alarms().first(); | 464 | alarm = event->alarms().first(); |
465 | alarm->setType( Alarm::Audio ); | ||
466 | alarm->setStartOffset( -60*15 ); | ||
463 | alarm->setEnabled( false ); | 467 | alarm->setEnabled( false ); |
464 | } | 468 | } |
465 | } | 469 | } |
466 | // csum ***************************************** | 470 | // csum ***************************************** |
467 | QStringList attList; | 471 | QStringList attList; |
468 | uint cSum; | 472 | uint cSum; |
469 | attList << dtToString ( event->dtStart() ); | 473 | attList << dtToString ( event->dtStart() ); |
470 | attList << dtToString ( event->dtEnd() ); | 474 | attList << dtToString ( event->dtEnd() ); |
471 | attList << QString::number( id ); | 475 | attList << QString::number( id ); |
472 | attList << event->summary(); | 476 | attList << event->summary(); |
473 | attList << event->location(); | 477 | attList << event->location(); |
474 | attList << alarmString; | 478 | attList << alarmString; |
475 | attList << recurString; | 479 | attList << recurString; |
476 | attList << event->categoriesStr(); | 480 | attList << event->categoriesStr(); |
477 | attList << event->secrecyStr(); | 481 | attList << event->secrecyStr(); |
478 | cSum = PhoneFormat::getCsum(attList ); | 482 | cSum = PhoneFormat::getCsum(attList ); |
479 | event->setCsum( mProfileName, QString::number( cSum )); | 483 | event->setCsum( mProfileName, QString::number( cSum )); |
480 | mCalendar->addEvent( event); | 484 | mCalendar->addEvent( event); |
481 | 485 | ||
482 | return true; | 486 | return true; |
483 | } | 487 | } |
484 | 488 | ||
485 | 489 | ||
486 | QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = true ) { | 490 | QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = true ) { |
487 | QDateTime dt; | 491 | QDateTime dt; |
488 | int y,m,t,h,min,sec; | 492 | int y,m,t,h,min,sec; |
489 | y = dtp->Year; | 493 | y = dtp->Year; |
490 | m = dtp->Month; | 494 | m = dtp->Month; |
491 | t = dtp->Day; | 495 | t = dtp->Day; |
492 | h = dtp->Hour; | 496 | h = dtp->Hour; |
493 | min = dtp->Minute; | 497 | min = dtp->Minute; |
494 | sec = dtp->Second; | 498 | sec = dtp->Second; |
495 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); | 499 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); |
496 | // dtp->Timezone: offset in hours | 500 | // dtp->Timezone: offset in hours |
497 | int offset = KGlobal::locale()->localTimeOffset( dt ); | 501 | int offset = KGlobal::locale()->localTimeOffset( dt ); |
498 | if ( useTz ) | 502 | if ( useTz ) |
499 | dt = dt.addSecs ( offset*60); | 503 | dt = dt.addSecs ( offset*60); |
500 | return dt; | 504 | return dt; |
501 | 505 | ||
502 | } | 506 | } |
503 | 507 | ||
504 | QString dtToString( const QDateTime& dti, bool useTZ = false ) | 508 | QString dtToString( const QDateTime& dti, bool useTZ = false ) |
505 | { | 509 | { |
506 | QString datestr; | 510 | QString datestr; |
507 | QString timestr; | 511 | QString timestr; |
508 | int offset = KGlobal::locale()->localTimeOffset( dti ); | 512 | int offset = KGlobal::locale()->localTimeOffset( dti ); |
509 | QDateTime dt; | 513 | QDateTime dt; |
510 | if (useTZ) | 514 | if (useTZ) |
511 | dt = dti.addSecs ( -(offset*60)); | 515 | dt = dti.addSecs ( -(offset*60)); |
512 | else | 516 | else |
513 | dt = dti; | 517 | dt = dti; |
514 | if(dt.date().isValid()){ | 518 | if(dt.date().isValid()){ |
515 | const QDate& date = dt.date(); | 519 | const QDate& date = dt.date(); |
516 | datestr.sprintf("%04d%02d%02d", | 520 | datestr.sprintf("%04d%02d%02d", |
517 | date.year(), date.month(), date.day()); | 521 | date.year(), date.month(), date.day()); |
518 | } | 522 | } |
519 | if(dt.time().isValid()){ | 523 | if(dt.time().isValid()){ |
520 | const QTime& time = dt.time(); | 524 | const QTime& time = dt.time(); |
521 | timestr.sprintf("T%02d%02d%02d", | 525 | timestr.sprintf("T%02d%02d%02d", |
522 | time.hour(), time.minute(), time.second()); | 526 | time.hour(), time.minute(), time.second()); |
523 | } | 527 | } |
524 | return datestr + timestr; | 528 | return datestr + timestr; |
525 | } | 529 | } |
526 | QDate datefromGSM ( GSM_DateTime*dtp ) { | 530 | QDate datefromGSM ( GSM_DateTime*dtp ) { |
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index f8b066d..defdb09 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp | |||
@@ -128,128 +128,130 @@ class SharpParser : public QObject | |||
128 | int i; | 128 | int i; |
129 | int bb = 1; | 129 | int bb = 1; |
130 | for( i = 1; i <= 7; ++i ) { | 130 | for( i = 1; i <= 7; ++i ) { |
131 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); | 131 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); |
132 | bb = 2 << (i-1); | 132 | bb = 2 << (i-1); |
133 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); | 133 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); |
134 | } | 134 | } |
135 | // qDebug("next "); | 135 | // qDebug("next "); |
136 | QString posStr = attList[13]; | 136 | QString posStr = attList[13]; |
137 | int pos = posStr.toInt(); | 137 | int pos = posStr.toInt(); |
138 | Recurrence *r = event->recurrence(); | 138 | Recurrence *r = event->recurrence(); |
139 | 139 | ||
140 | if ( rtype == "0" ) { | 140 | if ( rtype == "0" ) { |
141 | if ( hasEndDate ) r->setDaily( freq, endDate ); | 141 | if ( hasEndDate ) r->setDaily( freq, endDate ); |
142 | else r->setDaily( freq, -1 ); | 142 | else r->setDaily( freq, -1 ); |
143 | } else if ( rtype == "1" ) { | 143 | } else if ( rtype == "1" ) { |
144 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); | 144 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); |
145 | else r->setWeekly( freq, weekDays, -1 ); | 145 | else r->setWeekly( freq, weekDays, -1 ); |
146 | } else if ( rtype == "3" ) { | 146 | } else if ( rtype == "3" ) { |
147 | if ( hasEndDate ) | 147 | if ( hasEndDate ) |
148 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 148 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
149 | else | 149 | else |
150 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); | 150 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); |
151 | r->addMonthlyDay( startDate.day() ); | 151 | r->addMonthlyDay( startDate.day() ); |
152 | } else if ( rtype == "2" ) { | 152 | } else if ( rtype == "2" ) { |
153 | if ( hasEndDate ) | 153 | if ( hasEndDate ) |
154 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 154 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
155 | else | 155 | else |
156 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); | 156 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); |
157 | QBitArray days( 7 ); | 157 | QBitArray days( 7 ); |
158 | days.fill( false ); | 158 | days.fill( false ); |
159 | days.setBit( startDate.dayOfWeek() - 1 ); | 159 | days.setBit( startDate.dayOfWeek() - 1 ); |
160 | r->addMonthlyPos( pos, days ); | 160 | r->addMonthlyPos( pos, days ); |
161 | } else if ( rtype == "4" ) { | 161 | } else if ( rtype == "4" ) { |
162 | if ( hasEndDate ) | 162 | if ( hasEndDate ) |
163 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 163 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
164 | else | 164 | else |
165 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); | 165 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); |
166 | r->addYearlyNum( startDate.month() ); | 166 | r->addYearlyNum( startDate.month() ); |
167 | } | 167 | } |
168 | } else { | 168 | } else { |
169 | event->recurrence()->unsetRecurs(); | 169 | event->recurrence()->unsetRecurs(); |
170 | } | 170 | } |
171 | 171 | ||
172 | QString categoryList = attList[1] ; | 172 | QString categoryList = attList[1] ; |
173 | event->setCategories( lookupCategories( categoryList ) ); | 173 | event->setCategories( lookupCategories( categoryList ) ); |
174 | 174 | ||
175 | // strange 0 semms to mean: alarm enabled | 175 | // strange 0 semms to mean: alarm enabled |
176 | if ( attList[8] == "0" ) { | 176 | if ( attList[8] == "0" ) { |
177 | Alarm *alarm; | 177 | Alarm *alarm; |
178 | if ( event->alarms().count() > 0 ) | 178 | if ( event->alarms().count() > 0 ) |
179 | alarm = event->alarms().first(); | 179 | alarm = event->alarms().first(); |
180 | else { | 180 | else { |
181 | alarm = new Alarm( event ); | 181 | alarm = new Alarm( event ); |
182 | event->addAlarm( alarm ); | 182 | event->addAlarm( alarm ); |
183 | } | 183 | } |
184 | alarm->setType( Alarm::Audio ); | 184 | alarm->setType( Alarm::Audio ); |
185 | alarm->setEnabled( true ); | 185 | alarm->setEnabled( true ); |
186 | int alarmOffset = attList[9].toInt(); | 186 | int alarmOffset = attList[9].toInt(); |
187 | alarm->setStartOffset( alarmOffset * -60 ); | 187 | alarm->setStartOffset( alarmOffset * -60 ); |
188 | } else { | 188 | } else { |
189 | Alarm *alarm; | 189 | Alarm *alarm; |
190 | if ( event->alarms().count() > 0 ) { | 190 | if ( event->alarms().count() > 0 ) { |
191 | alarm = event->alarms().first(); | 191 | alarm = event->alarms().first(); |
192 | alarm->setType( Alarm::Audio ); | ||
193 | alarm->setStartOffset( -60*15 ); | ||
192 | alarm->setEnabled( false ); | 194 | alarm->setEnabled( false ); |
193 | } | 195 | } |
194 | } | 196 | } |
195 | 197 | ||
196 | mCalendar->addEvent( event); | 198 | mCalendar->addEvent( event); |
197 | } else if ( qName == "Todo" ) { | 199 | } else if ( qName == "Todo" ) { |
198 | Todo *todo; | 200 | Todo *todo; |
199 | 201 | ||
200 | todo = existingCalendar->todo( "Sharp_DTM", attList[0] ); | 202 | todo = existingCalendar->todo( "Sharp_DTM", attList[0] ); |
201 | if (todo ) | 203 | if (todo ) |
202 | todo = (Todo*)todo->clone(); | 204 | todo = (Todo*)todo->clone(); |
203 | else | 205 | else |
204 | todo = new Todo; | 206 | todo = new Todo; |
205 | 207 | ||
206 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 | 208 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 |
207 | // 0 1 2 3 4 5 6 7 8 | 209 | // 0 1 2 3 4 5 6 7 8 |
208 | //1,,,,,1,4,Loch zumachen,"" | 210 | //1,,,,,1,4,Loch zumachen,"" |
209 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " | 211 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " |
210 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes | 212 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes |
211 | 213 | ||
212 | todo->setID( "Sharp_DTM", attList[0]); | 214 | todo->setID( "Sharp_DTM", attList[0]); |
213 | todo->setCsum( "Sharp_DTM", QString::number( cSum )); | 215 | todo->setCsum( "Sharp_DTM", QString::number( cSum )); |
214 | todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 216 | todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
215 | 217 | ||
216 | todo->setSummary( attList[7] ); | 218 | todo->setSummary( attList[7] ); |
217 | todo->setDescription( attList[8]); | 219 | todo->setDescription( attList[8]); |
218 | 220 | ||
219 | int priority = attList[6].toInt(); | 221 | int priority = attList[6].toInt(); |
220 | if ( priority == 0 ) priority = 3; | 222 | if ( priority == 0 ) priority = 3; |
221 | todo->setPriority( priority ); | 223 | todo->setPriority( priority ); |
222 | 224 | ||
223 | QString categoryList = attList[1]; | 225 | QString categoryList = attList[1]; |
224 | todo->setCategories( lookupCategories( categoryList ) ); | 226 | todo->setCategories( lookupCategories( categoryList ) ); |
225 | 227 | ||
226 | 228 | ||
227 | 229 | ||
228 | QString hasDateStr = attList[3]; // due | 230 | QString hasDateStr = attList[3]; // due |
229 | if ( !hasDateStr.isEmpty() ) { | 231 | if ( !hasDateStr.isEmpty() ) { |
230 | if ( hasDateStr.right(6) == "000000" ) { | 232 | if ( hasDateStr.right(6) == "000000" ) { |
231 | todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); | 233 | todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); |
232 | todo->setFloats( true ); | 234 | todo->setFloats( true ); |
233 | } | 235 | } |
234 | else { | 236 | else { |
235 | todo->setDtDue( fromString( hasDateStr ) ); | 237 | todo->setDtDue( fromString( hasDateStr ) ); |
236 | todo->setFloats( false ); | 238 | todo->setFloats( false ); |
237 | } | 239 | } |
238 | 240 | ||
239 | todo->setHasDueDate( true ); | 241 | todo->setHasDueDate( true ); |
240 | } | 242 | } |
241 | hasDateStr = attList[2];//start | 243 | hasDateStr = attList[2];//start |
242 | if ( !hasDateStr.isEmpty() ) { | 244 | if ( !hasDateStr.isEmpty() ) { |
243 | 245 | ||
244 | todo->setDtStart( fromString( hasDateStr ) ); | 246 | todo->setDtStart( fromString( hasDateStr ) ); |
245 | todo->setHasStartDate( true); | 247 | todo->setHasStartDate( true); |
246 | } else | 248 | } else |
247 | todo->setHasStartDate( false ); | 249 | todo->setHasStartDate( false ); |
248 | hasDateStr = attList[4];//completed | 250 | hasDateStr = attList[4];//completed |
249 | if ( !hasDateStr.isEmpty() ) { | 251 | if ( !hasDateStr.isEmpty() ) { |
250 | todo->setCompleted(fromString( hasDateStr ) ); | 252 | todo->setCompleted(fromString( hasDateStr ) ); |
251 | } | 253 | } |
252 | QString completedStr = attList[5]; | 254 | QString completedStr = attList[5]; |
253 | if ( completedStr == "0" ) | 255 | if ( completedStr == "0" ) |
254 | todo->setCompleted( true ); | 256 | todo->setCompleted( true ); |
255 | else | 257 | else |