summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2004-08-09 12:44:25 (UTC)
committer zautrix <zautrix>2004-08-09 12:44:25 (UTC)
commit48f53b2d2e7ed189e88f924259693ab66ff44b7f (patch) (unidiff)
tree19bcb263aef667ee236b4d49cea89985331805bd /libkcal
parente0ba2d4770094974ec4a2a48af436a7df9a055bc (diff)
downloadkdepimpi-48f53b2d2e7ed189e88f924259693ab66ff44b7f.zip
kdepimpi-48f53b2d2e7ed189e88f924259693ab66ff44b7f.tar.gz
kdepimpi-48f53b2d2e7ed189e88f924259693ab66ff44b7f.tar.bz2
recurrence fixes
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/phoneformat.cpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index bc1b863..596148e 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -282,193 +282,209 @@ public:
282 event->setSecrecy( Incidence::SecrecyPublic ); 282 event->setSecrecy( Incidence::SecrecyPublic );
283 283
284 break; 284 break;
285 case CAL_CONTACTID: 285 case CAL_CONTACTID:
286#if 0 286#if 0
287 entry.Location = Note->Entries[i].Number; 287 entry.Location = Note->Entries[i].Number;
288 entry.MemoryType = MEM_ME; 288 entry.MemoryType = MEM_ME;
289 error=Phone->GetMemory(&s, &entry); 289 error=Phone->GetMemory(&s, &entry);
290 if (error == ERR_NONE) { 290 if (error == ERR_NONE) {
291 name = GSM_PhonebookGetEntryName(&entry); 291 name = GSM_PhonebookGetEntryName(&entry);
292 if (name != NULL) { 292 if (name != NULL) {
293 //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); 293 //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number);
294 } else { 294 } else {
295 //printmsg("Contact ID : %d\n",Note->Entries[i].Number); 295 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
296 } 296 }
297 } else { 297 } else {
298 //printmsg("Contact ID : %d\n",Note->Entries[i].Number); 298 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
299 } 299 }
300#endif 300#endif
301 break; 301 break;
302 case CAL_REPEAT_DAYOFWEEK: 302 case CAL_REPEAT_DAYOFWEEK:
303 repeat_dayofweek = Note->Entries[i].Number; 303 repeat_dayofweek = Note->Entries[i].Number;
304 repeating = true; 304 repeating = true;
305 break; 305 break;
306 case CAL_REPEAT_DAY: 306 case CAL_REPEAT_DAY:
307 repeat_day = Note->Entries[i].Number; 307 repeat_day = Note->Entries[i].Number;
308 repeating = true; 308 repeating = true;
309 break; 309 break;
310 case CAL_REPEAT_WEEKOFMONTH: 310 case CAL_REPEAT_WEEKOFMONTH:
311 repeat_weekofmonth = Note->Entries[i].Number; 311 repeat_weekofmonth = Note->Entries[i].Number;
312 repeating = true; 312 repeating = true;
313 break; 313 break;
314 case CAL_REPEAT_MONTH: 314 case CAL_REPEAT_MONTH:
315 repeat_month = Note->Entries[i].Number; 315 repeat_month = Note->Entries[i].Number;
316 repeating = true; 316 repeating = true;
317 break; 317 break;
318 case CAL_REPEAT_FREQUENCY: 318 case CAL_REPEAT_FREQUENCY:
319 repeat_frequency = Note->Entries[i].Number; 319 repeat_frequency = Note->Entries[i].Number;
320 repeating = true; 320 repeating = true;
321 break; 321 break;
322 case CAL_REPEAT_STARTDATE: 322 case CAL_REPEAT_STARTDATE:
323 repeat_startdate = Note->Entries[i].Date; 323 repeat_startdate = Note->Entries[i].Date;
324 repeating = true; 324 repeating = true;
325 break; 325 break;
326 case CAL_REPEAT_STOPDATE: 326 case CAL_REPEAT_STOPDATE:
327 repeat_stopdate = Note->Entries[i].Date; 327 repeat_stopdate = Note->Entries[i].Date;
328 repeating = true; 328 repeating = true;
329 break; 329 break;
330 } 330 }
331 } 331 }
332#if 0 332#if 0
333 event->setDescription( attList[4] ); 333 event->setDescription( attList[4] );
334 bool repeating = false; 334 bool repeating = false;
335 int repeat_dayofweek = -1; 335 int repeat_dayofweek = -1;
336 int repeat_day = -1; 336 int repeat_day = -1;
337 int repeat_weekofmonth = -1; 337 int repeat_weekofmonth = -1;
338 int repeat_month = -1; 338 int repeat_month = -1;
339 int repeat_frequency = -1; 339 int repeat_frequency = -1;
340 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; 340 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
341 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; 341 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
342 342
343#endif 343#endif
344 344
345 QString recurString = "no"; 345 QString recurString = "no";
346 if ( repeating ) { 346 if ( repeating && repeat_frequency != -1) {
347 recurString = "y"; 347 recurString = "y";
348 if ( repeat_dayofweek >= 0 ) 348 if ( repeat_dayofweek >= 0 )
349 recurString += "dow" + QString::number (repeat_dayofweek); 349 recurString += "dow" + QString::number (repeat_dayofweek);
350 if ( repeat_day >= 0 ) 350 if ( repeat_day >= 0 )
351 recurString += "d" + QString::number (repeat_day); 351 recurString += "d" + QString::number (repeat_day);
352 if ( repeat_weekofmonth >= 0 ) 352 if ( repeat_weekofmonth >= 0 )
353 recurString += "w" + QString::number (repeat_weekofmonth); 353 recurString += "w" + QString::number (repeat_weekofmonth);
354 if ( repeat_month >= 0 ) 354 if ( repeat_month >= 0 )
355 recurString += "m" + QString::number ( repeat_month ); 355 recurString += "m" + QString::number ( repeat_month );
356 if ( repeat_frequency >= 0 ) 356 if ( repeat_frequency >= 0 )
357 recurString += "f" + QString::number (repeat_frequency ); 357 recurString += "f" + QString::number (repeat_frequency );
358 358
359 int rtype = 0; 359 int rtype = 0;
360 // qDebug("recurs "); 360 // qDebug("recurs ");
361 QDate startDate, endDate; 361 QDate startDate, endDate;
362 if ( repeat_startdate.Day > 0 ) 362 if ( repeat_startdate.Day > 0 ) {
363 startDate = datefromGSM ( &repeat_startdate ); 363 startDate = datefromGSM ( &repeat_startdate );
364 else 364 event->setDtStart(QDateTime ( startDate, event->dtStart().time()));
365 } else {
365 startDate = event->dtStart().date(); 366 startDate = event->dtStart().date();
367 }
366 int freq = repeat_frequency; 368 int freq = repeat_frequency;
367 bool hasEndDate = false; 369 bool hasEndDate = false;
368 if ( repeat_stopdate.Day > 0 ) { 370 if ( repeat_stopdate.Day > 0 ) {
369 endDate = datefromGSM ( &repeat_stopdate ); 371 endDate = datefromGSM ( &repeat_stopdate );
370 hasEndDate = true; 372 hasEndDate = true;
371 } 373 }
372 374
373 uint weekDaysNum = repeat_dayofweek ; 375 uint weekDaysNum = repeat_dayofweek ;
374 376 // 1 == monday, 7 == sunday
375 QBitArray weekDays( 7 ); 377 QBitArray weekDays( 7 );
376 int i; 378 int i;
377 int bb = 1; 379 int bb = 1;
378 for( i = 1; i <= 7; ++i ) { 380 for( i = 1; i <= 7; ++i ) {
379 weekDays.setBit( i - 1, ( bb & weekDaysNum )); 381 weekDays.setBit( i - 1, ( bb & weekDaysNum ));
380 bb = 2 << (i-1); 382 bb = 2 << (i-1);
381 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); 383 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) );
382 } 384 }
383 // qDebug("next "); 385 // qDebug("next ");
384 int pos = 0; 386 int pos = 0;
385 Recurrence *r = event->recurrence(); 387 Recurrence *r = event->recurrence();
386 /* 388 /*
387 0 daily; 389 0 daily;
388 1 weekly;x 390 1 weekly;x
389 2 monthpos;x 391 2 monthpos;x
390 3 monthlyday; 392 3 monthlyday;
391 4 rYearlyMont 393 4 rYearlyMont
392 bool repeating = false; 394 bool repeating = false;
393 int repeat_dayofweek = -1; 395 int repeat_dayofweek = -1;
394 int repeat_day = -1; 396 int repeat_day = -1;
395 int repeat_weekofmonth = -1; 397 int repeat_weekofmonth = -1;
396 int repeat_month = -1; 398 int repeat_month = -1;
397 int repeat_frequency = -1; 399 int repeat_frequency = -1;
398 */ 400 */
399 int dayOfWeek = startDate.dayOfWeek(); 401 int dayOfWeek = startDate.dayOfWeek();
400 if ( repeat_weekofmonth >= 0 ) { 402 if ( repeat_weekofmonth >= 0 ) {
401 rtype = 2; 403 rtype = 2; // ************************ 2 MonthlyPos
402 pos = repeat_weekofmonth; 404 pos = repeat_weekofmonth;
403 if ( repeat_dayofweek >= 0 ) 405 if ( repeat_dayofweek >= 0 )
404 dayOfWeek = repeat_dayofweek; 406 dayOfWeek = repeat_dayofweek;
407 if (repeat_month > 0) {
408 if ( repeat_month != event->dtStart().date().month() ) {
409 QDate date (event->dtStart().date().year(),repeat_month,event->dtStart().date().day() );
410 event->setDtStart(QDateTime ( date , event->dtStart().time()) );
411 }
412 if ( freq == 1 )
413 freq = 12;
414 }
405 } else if ( repeat_dayofweek >= 0 ) { 415 } else if ( repeat_dayofweek >= 0 ) {
406 rtype = 1; 416 rtype = 1;// ************************ 1 Weekly
407 } if ( repeat_dayofweek >= 0 ) { 417 } else if ( repeat_day >= 0 ) {
408 rtype = 1; 418 if ( repeat_month > 0) {
419 rtype = 4;
420 } else {
421 rtype = 3;
422 }
423 } else {
424 rtype = 0 ;
409 } 425 }
410 426
411 if ( rtype == 0 ) { 427 if ( rtype == 0 ) {
412 if ( hasEndDate ) r->setDaily( freq, endDate ); 428 if ( hasEndDate ) r->setDaily( freq, endDate );
413 else r->setDaily( freq, -1 ); 429 else r->setDaily( freq, -1 );
414 } else if ( rtype == 1 ) { 430 } else if ( rtype == 1 ) {
415 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); 431 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate );
416 else r->setWeekly( freq, weekDays, -1 ); 432 else r->setWeekly( freq, weekDays, -1 );
417 } else if ( rtype == 3 ) { 433 } else if ( rtype == 3 ) {
418 if ( hasEndDate ) 434 if ( hasEndDate )
419 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); 435 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
420 else 436 else
421 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); 437 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 );
422 r->addMonthlyDay( startDate.day() ); 438 r->addMonthlyDay( startDate.day() );
423 } else if ( rtype == 2 ) { 439 } else if ( rtype == 2 ) {
424 if ( hasEndDate ) 440 if ( hasEndDate )
425 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 441 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
426 else 442 else
427 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); 443 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 );
428 QBitArray days( 7 ); 444 QBitArray days( 7 );
429 days.fill( false ); 445 days.fill( false );
430 days.setBit( dayOfWeek - 1 ); 446 days.setBit( dayOfWeek - 1 );
431 r->addMonthlyPos( pos, days ); 447 r->addMonthlyPos( pos, days );
432 } else if ( rtype == 4 ) { 448 } else if ( rtype == 4 ) {
433 if ( hasEndDate ) 449 if ( hasEndDate )
434 r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); 450 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
435 else 451 else
436 r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); 452 r->setYearly( Recurrence::rYearlyMonth, freq, -1 );
437 r->addYearlyNum( startDate.month() ); 453 r->addYearlyNum( startDate.month() );
438 } 454 }
439 } else { 455 } else {
440 event->recurrence()->unsetRecurs(); 456 event->recurrence()->unsetRecurs();
441 } 457 }
442 458
443 QStringList categoryList; 459 QStringList categoryList;
444 categoryList << getCategory( Note ); 460 categoryList << getCategory( Note );
445 event->setCategories( categoryList ); 461 event->setCategories( categoryList );
446 QString alarmString = "na"; 462 QString alarmString = "na";
447 // strange 0 semms to mean: alarm enabled 463 // strange 0 semms to mean: alarm enabled
448 if ( alarm ) { 464 if ( alarm ) {
449 Alarm *alarm; 465 Alarm *alarm;
450 if ( event->alarms().count() > 0 ) 466 if ( event->alarms().count() > 0 )
451 alarm = event->alarms().first(); 467 alarm = event->alarms().first();
452 else { 468 else {
453 alarm = new Alarm( event ); 469 alarm = new Alarm( event );
454 event->addAlarm( alarm ); 470 event->addAlarm( alarm );
455 } 471 }
456 alarm->setType( Alarm::Audio ); 472 alarm->setType( Alarm::Audio );
457 alarm->setEnabled( true ); 473 alarm->setEnabled( true );
458 int alarmOffset = alarmDt.secsTo( event->dtStart() ); 474 int alarmOffset = alarmDt.secsTo( event->dtStart() );
459 alarm->setStartOffset( -alarmOffset ); 475 alarm->setStartOffset( -alarmOffset );
460 alarmString = QString::number( alarmOffset ); 476 alarmString = QString::number( alarmOffset );
461 } else { 477 } else {
462 Alarm *alarm; 478 Alarm *alarm;
463 if ( event->alarms().count() > 0 ) { 479 if ( event->alarms().count() > 0 ) {
464 alarm = event->alarms().first(); 480 alarm = event->alarms().first();
465 alarm->setType( Alarm::Audio ); 481 alarm->setType( Alarm::Audio );
466 alarm->setStartOffset( -60*15 ); 482 alarm->setStartOffset( -60*15 );
467 alarm->setEnabled( false ); 483 alarm->setEnabled( false );
468 } 484 }
469 } 485 }
470 // csum ***************************************** 486 // csum *****************************************
471 QStringList attList; 487 QStringList attList;
472 uint cSum; 488 uint cSum;
473 attList << dtToString ( event->dtStart() ); 489 attList << dtToString ( event->dtStart() );
474 attList << dtToString ( event->dtEnd() ); 490 attList << dtToString ( event->dtEnd() );