summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp38
-rw-r--r--korganizer/calendarview.h4
-rw-r--r--korganizer/mainwindow.cpp4
3 files changed, 13 insertions, 33 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 04051a2..0c35bb3 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -317,2257 +317,2245 @@ void CalendarView::init()
317 leftFrameLayout->addWidget(mTodoList, 2 ); 317 leftFrameLayout->addWidget(mTodoList, 2 );
318 318
319 } else { 319 } else {
320 leftFrameLayout->addWidget(mTodoList,2 ); 320 leftFrameLayout->addWidget(mTodoList,2 );
321 leftFrameLayout->addWidget(mFilterView ); 321 leftFrameLayout->addWidget(mFilterView );
322 } 322 }
323 mFilterView->hide(); 323 mFilterView->hide();
324 QWidget *rightBox = new QWidget( mainBox ); 324 QWidget *rightBox = new QWidget( mainBox );
325 mainBoxLayout->addWidget ( rightBox, 10 ); 325 mainBoxLayout->addWidget ( rightBox, 10 );
326 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 326 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
327 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 327 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
328 mRightFrame = new QWidgetStack( rightBox ); 328 mRightFrame = new QWidgetStack( rightBox );
329 rightLayout->addWidget( mNavigatorBar ); 329 rightLayout->addWidget( mNavigatorBar );
330 rightLayout->addWidget( mRightFrame, 10 ); 330 rightLayout->addWidget( mRightFrame, 10 );
331 331
332 mLeftFrame = leftFrame; 332 mLeftFrame = leftFrame;
333 if ( KOPrefs::instance()->mVerticalScreen ) { 333 if ( KOPrefs::instance()->mVerticalScreen ) {
334 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 334 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
335 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 335 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
336 } else { 336 } else {
337 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 337 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
338 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 338 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
339 } 339 }
340 340
341 //qDebug("Calendarview Size %d %d ", width(), height()); 341 //qDebug("Calendarview Size %d %d ", width(), height());
342#endif 342#endif
343 343
344 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 344 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
345 SLOT( showDates( const KCal::DateList & ) ) ); 345 SLOT( showDates( const KCal::DateList & ) ) );
346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
348 348
349 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 349 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
350 mNavigator, SLOT( selectPreviousYear() ) ); 350 mNavigator, SLOT( selectPreviousYear() ) );
351 connect( mNavigatorBar, SIGNAL( goNextYear() ), 351 connect( mNavigatorBar, SIGNAL( goNextYear() ),
352 mNavigator, SLOT( selectNextYear() ) ); 352 mNavigator, SLOT( selectNextYear() ) );
353 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 353 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
354 mNavigator, SLOT( selectPreviousMonth() ) ); 354 mNavigator, SLOT( selectPreviousMonth() ) );
355 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 355 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
356 mNavigator, SLOT( selectNextMonth() ) ); 356 mNavigator, SLOT( selectNextMonth() ) );
357 357
358 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 358 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
359 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 359 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
360 360
361 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 361 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
362 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 362 mNavigator, SLOT( selectWeek( const QDate & ) ) );
363 363
364 connect( mDateNavigator, SIGNAL( goPrevYear() ), 364 connect( mDateNavigator, SIGNAL( goPrevYear() ),
365 mNavigator, SLOT( selectPreviousYear() ) ); 365 mNavigator, SLOT( selectPreviousYear() ) );
366 connect( mDateNavigator, SIGNAL( goNextYear() ), 366 connect( mDateNavigator, SIGNAL( goNextYear() ),
367 mNavigator, SLOT( selectNextYear() ) ); 367 mNavigator, SLOT( selectNextYear() ) );
368 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 368 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
369 mNavigator, SLOT( selectPreviousMonth() ) ); 369 mNavigator, SLOT( selectPreviousMonth() ) );
370 connect( mDateNavigator, SIGNAL( goNextMonth() ), 370 connect( mDateNavigator, SIGNAL( goNextMonth() ),
371 mNavigator, SLOT( selectNextMonth() ) ); 371 mNavigator, SLOT( selectNextMonth() ) );
372 372
373 connect( mDateNavigator, SIGNAL( goPrevious() ), 373 connect( mDateNavigator, SIGNAL( goPrevious() ),
374 mNavigator, SLOT( selectPrevious() ) ); 374 mNavigator, SLOT( selectPrevious() ) );
375 connect( mDateNavigator, SIGNAL( goNext() ), 375 connect( mDateNavigator, SIGNAL( goNext() ),
376 mNavigator, SLOT( selectNext() ) ); 376 mNavigator, SLOT( selectNext() ) );
377 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 377 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
378 mNavigator, SLOT( slotMonthSelect( int ) ) ); 378 mNavigator, SLOT( slotMonthSelect( int ) ) );
379 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 379 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
380 mNavigator, SLOT( slotMonthSelect( int ) ) ); 380 mNavigator, SLOT( slotMonthSelect( int ) ) );
381 381
382 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 382 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
383 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 383 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
384 384
385 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 385 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
386 SLOT( eventAdded( Event *) ) ); 386 SLOT( eventAdded( Event *) ) );
387 387
388 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 388 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
389 389
390 connect( this, SIGNAL( configChanged() ), 390 connect( this, SIGNAL( configChanged() ),
391 mDateNavigator, SLOT( updateConfig() ) ); 391 mDateNavigator, SLOT( updateConfig() ) );
392 392
393 connect( mTodoList, SIGNAL( newTodoSignal() ), 393 connect( mTodoList, SIGNAL( newTodoSignal() ),
394 SLOT( newTodo() ) ); 394 SLOT( newTodo() ) );
395 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 395 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
396 SLOT( newSubTodo( Todo * ) ) ); 396 SLOT( newSubTodo( Todo * ) ) );
397 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 397 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
398 SLOT( editTodo( Todo * ) ) ); 398 SLOT( editTodo( Todo * ) ) );
399 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 399 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
400 SLOT( showTodo( Todo *) ) ); 400 SLOT( showTodo( Todo *) ) );
401 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 401 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
402 SLOT( deleteTodo( Todo *) ) ); 402 SLOT( deleteTodo( Todo *) ) );
403 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 403 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
404 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 404 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
405 SLOT( purgeCompleted() ) ); 405 SLOT( purgeCompleted() ) );
406 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 406 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
407 SIGNAL( todoModified( Todo *, int ) ) ); 407 SIGNAL( todoModified( Todo *, int ) ) );
408 408
409 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 409 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
410 this, SLOT ( cloneIncidence( Incidence * ) ) ); 410 this, SLOT ( cloneIncidence( Incidence * ) ) );
411 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 411 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
412 this, SLOT (cancelIncidence( Incidence * ) ) ); 412 this, SLOT (cancelIncidence( Incidence * ) ) );
413 413
414 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 414 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
415 this, SLOT ( moveIncidence( Incidence * ) ) ); 415 this, SLOT ( moveIncidence( Incidence * ) ) );
416 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 416 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
417 this, SLOT ( beamIncidence( Incidence * ) ) ); 417 this, SLOT ( beamIncidence( Incidence * ) ) );
418 418
419 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 419 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
420 this, SLOT ( todo_unsub( Todo * ) ) ); 420 this, SLOT ( todo_unsub( Todo * ) ) );
421 421
422 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 422 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
423 SLOT( updateTodo( Todo *, int ) ) ); 423 SLOT( updateTodo( Todo *, int ) ) );
424 connect( this, SIGNAL( todoModified( Todo *, int )), this, 424 connect( this, SIGNAL( todoModified( Todo *, int )), this,
425 SLOT( changeTodoDisplay( Todo *, int ) ) ); 425 SLOT( changeTodoDisplay( Todo *, int ) ) );
426 426
427 427
428 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 428 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
429 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 429 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
430 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 430 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
431 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 431 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
432 432
433 433
434 434
435 435
436 436
437 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 437 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
438 SLOT(checkClipboard())); 438 SLOT(checkClipboard()));
439 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 439 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
440 SLOT( processTodoListSelection( Incidence * ) ) ); 440 SLOT( processTodoListSelection( Incidence * ) ) );
441 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 441 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
442 442
443 // kdDebug() << "CalendarView::CalendarView() done" << endl; 443 // kdDebug() << "CalendarView::CalendarView() done" << endl;
444 444
445 mDateFrame = new QVBox(0,0,WType_Popup); 445 mDateFrame = new QVBox(0,0,WType_Popup);
446 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 446 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
447 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 447 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
448 mDateFrame->setLineWidth(3); 448 mDateFrame->setLineWidth(3);
449 mDateFrame->hide(); 449 mDateFrame->hide();
450 mDateFrame->setCaption( i18n( "Pick a date to display")); 450 mDateFrame->setCaption( i18n( "Pick a date to display"));
451 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 451 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
452 452
453 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 453 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
454 454
455 mEventEditor = mDialogManager->getEventEditor(); 455 mEventEditor = mDialogManager->getEventEditor();
456 mTodoEditor = mDialogManager->getTodoEditor(); 456 mTodoEditor = mDialogManager->getTodoEditor();
457 457
458 mFlagEditDescription = false; 458 mFlagEditDescription = false;
459 459
460 mSuspendTimer = new QTimer( this ); 460 mSuspendTimer = new QTimer( this );
461 mAlarmTimer = new QTimer( this ); 461 mAlarmTimer = new QTimer( this );
462 mRecheckAlarmTimer = new QTimer( this ); 462 mRecheckAlarmTimer = new QTimer( this );
463 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 463 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
464 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 464 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
465 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 465 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
466 mAlarmDialog = new AlarmDialog( this ); 466 mAlarmDialog = new AlarmDialog( this );
467 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 467 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
468 mAlarmDialog->setServerNotification( false ); 468 mAlarmDialog->setServerNotification( false );
469 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 469 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
470 470
471 471
472#ifndef DESKTOP_VERSION 472#ifndef DESKTOP_VERSION
473//US listen for arriving address resultsets 473//US listen for arriving address resultsets
474 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 474 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
475 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 475 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
476#endif 476#endif
477 477
478} 478}
479 479
480 480
481CalendarView::~CalendarView() 481CalendarView::~CalendarView()
482{ 482{
483 // kdDebug() << "~CalendarView()" << endl; 483 // kdDebug() << "~CalendarView()" << endl;
484 //qDebug("CalendarView::~CalendarView() "); 484 //qDebug("CalendarView::~CalendarView() ");
485 delete mDialogManager; 485 delete mDialogManager;
486 delete mViewManager; 486 delete mViewManager;
487 delete mStorage; 487 delete mStorage;
488 delete mDateFrame ; 488 delete mDateFrame ;
489 delete beamDialog; 489 delete beamDialog;
490 //kdDebug() << "~CalendarView() done" << endl; 490 //kdDebug() << "~CalendarView() done" << endl;
491} 491}
492void CalendarView::timerAlarm() 492void CalendarView::timerAlarm()
493{ 493{
494 //qDebug("CalendarView::timerAlarm() "); 494 //qDebug("CalendarView::timerAlarm() ");
495 computeAlarm(mAlarmNotification ); 495 computeAlarm(mAlarmNotification );
496} 496}
497 497
498void CalendarView::suspendAlarm() 498void CalendarView::suspendAlarm()
499{ 499{
500 //qDebug(" CalendarView::suspendAlarm() "); 500 //qDebug(" CalendarView::suspendAlarm() ");
501 computeAlarm(mSuspendAlarmNotification ); 501 computeAlarm(mSuspendAlarmNotification );
502 502
503} 503}
504 504
505void CalendarView::startAlarm( QString mess , QString filename) 505void CalendarView::startAlarm( QString mess , QString filename)
506{ 506{
507 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 507 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
508 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 508 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
509 509
510} 510}
511 511
512void CalendarView::checkNextTimerAlarm() 512void CalendarView::checkNextTimerAlarm()
513{ 513{
514 mCalendar->checkAlarmForIncidence( 0, true ); 514 mCalendar->checkAlarmForIncidence( 0, true );
515} 515}
516 516
517void CalendarView::computeAlarm( QString msg ) 517void CalendarView::computeAlarm( QString msg )
518{ 518{
519 519
520 QString mess = msg; 520 QString mess = msg;
521 QString mAlarmMessage = mess.mid( 9 ); 521 QString mAlarmMessage = mess.mid( 9 );
522 QString filename = MainWindow::resourcePath(); 522 QString filename = MainWindow::resourcePath();
523 filename += "koalarm.wav"; 523 filename += "koalarm.wav";
524 QString tempfilename; 524 QString tempfilename;
525 if ( mess.left( 13 ) == "suspend_alarm") { 525 if ( mess.left( 13 ) == "suspend_alarm") {
526 bool error = false; 526 bool error = false;
527 int len = mess.mid( 13 ).find("+++"); 527 int len = mess.mid( 13 ).find("+++");
528 if ( len < 2 ) 528 if ( len < 2 )
529 error = true; 529 error = true;
530 else { 530 else {
531 tempfilename = mess.mid( 13, len ); 531 tempfilename = mess.mid( 13, len );
532 if ( !QFile::exists( tempfilename ) ) 532 if ( !QFile::exists( tempfilename ) )
533 error = true; 533 error = true;
534 } 534 }
535 if ( ! error ) { 535 if ( ! error ) {
536 filename = tempfilename; 536 filename = tempfilename;
537 } 537 }
538 mAlarmMessage = mess.mid( 13+len+3 ); 538 mAlarmMessage = mess.mid( 13+len+3 );
539 //qDebug("suspend file %s ",tempfilename.latin1() ); 539 //qDebug("suspend file %s ",tempfilename.latin1() );
540 startAlarm( mAlarmMessage, filename); 540 startAlarm( mAlarmMessage, filename);
541 return; 541 return;
542 } 542 }
543 if ( mess.left( 11 ) == "timer_alarm") { 543 if ( mess.left( 11 ) == "timer_alarm") {
544 //mTimerTime = 0; 544 //mTimerTime = 0;
545 startAlarm( mess.mid( 11 ), filename ); 545 startAlarm( mess.mid( 11 ), filename );
546 return; 546 return;
547 } 547 }
548 if ( mess.left( 10 ) == "proc_alarm") { 548 if ( mess.left( 10 ) == "proc_alarm") {
549 bool error = false; 549 bool error = false;
550 int len = mess.mid( 10 ).find("+++"); 550 int len = mess.mid( 10 ).find("+++");
551 if ( len < 2 ) 551 if ( len < 2 )
552 error = true; 552 error = true;
553 else { 553 else {
554 tempfilename = mess.mid( 10, len ); 554 tempfilename = mess.mid( 10, len );
555 if ( !QFile::exists( tempfilename ) ) 555 if ( !QFile::exists( tempfilename ) )
556 error = true; 556 error = true;
557 } 557 }
558 if ( error ) { 558 if ( error ) {
559 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 559 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
560 mAlarmMessage += mess.mid( 10+len+3+9 ); 560 mAlarmMessage += mess.mid( 10+len+3+9 );
561 } else { 561 } else {
562 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 562 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
563 //qDebug("-----system command %s ",tempfilename.latin1() ); 563 //qDebug("-----system command %s ",tempfilename.latin1() );
564#ifndef _WIN32_ 564#ifndef _WIN32_
565 if ( vfork () == 0 ) { 565 if ( vfork () == 0 ) {
566 execl ( tempfilename.latin1(), 0 ); 566 execl ( tempfilename.latin1(), 0 );
567 return; 567 return;
568 } 568 }
569#else 569#else
570 QProcess* p = new QProcess(); 570 QProcess* p = new QProcess();
571 p->addArgument( tempfilename.latin1() ); 571 p->addArgument( tempfilename.latin1() );
572 p->start(); 572 p->start();
573 return; 573 return;
574#endif 574#endif
575 575
576 return; 576 return;
577 } 577 }
578 578
579 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 579 //qDebug("+++++++system command %s ",tempfilename.latin1() );
580 } 580 }
581 if ( mess.left( 11 ) == "audio_alarm") { 581 if ( mess.left( 11 ) == "audio_alarm") {
582 bool error = false; 582 bool error = false;
583 int len = mess.mid( 11 ).find("+++"); 583 int len = mess.mid( 11 ).find("+++");
584 if ( len < 2 ) 584 if ( len < 2 )
585 error = true; 585 error = true;
586 else { 586 else {
587 tempfilename = mess.mid( 11, len ); 587 tempfilename = mess.mid( 11, len );
588 if ( !QFile::exists( tempfilename ) ) 588 if ( !QFile::exists( tempfilename ) )
589 error = true; 589 error = true;
590 } 590 }
591 if ( ! error ) { 591 if ( ! error ) {
592 filename = tempfilename; 592 filename = tempfilename;
593 } 593 }
594 mAlarmMessage = mess.mid( 11+len+3+9 ); 594 mAlarmMessage = mess.mid( 11+len+3+9 );
595 //qDebug("audio file command %s ",tempfilename.latin1() ); 595 //qDebug("audio file command %s ",tempfilename.latin1() );
596 } 596 }
597 if ( mess.left( 9 ) == "cal_alarm") { 597 if ( mess.left( 9 ) == "cal_alarm") {
598 mAlarmMessage = mess.mid( 9 ) ; 598 mAlarmMessage = mess.mid( 9 ) ;
599 } 599 }
600 600
601 startAlarm( mAlarmMessage, filename ); 601 startAlarm( mAlarmMessage, filename );
602 602
603 603
604} 604}
605 605
606void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 606void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
607{ 607{
608 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 608 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
609 609
610 mSuspendAlarmNotification = noti; 610 mSuspendAlarmNotification = noti;
611 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 611 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
612 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 612 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
613 mSuspendTimer->start( ms , true ); 613 mSuspendTimer->start( ms , true );
614 614
615} 615}
616 616
617void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 617void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
618{ 618{
619 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 619 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
620 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 620 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
621#ifndef DESKTOP_VERSION 621#ifndef DESKTOP_VERSION
622 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 622 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
623#endif 623#endif
624 return; 624 return;
625 } 625 }
626 int maxSec; 626 int maxSec;
627 //maxSec = 5; //testing only 627 //maxSec = 5; //testing only
628 maxSec = 86400+3600; // one day+1hour 628 maxSec = 86400+3600; // one day+1hour
629 mAlarmNotification = noti; 629 mAlarmNotification = noti;
630 int sec = QDateTime::currentDateTime().secsTo( qdt ); 630 int sec = QDateTime::currentDateTime().secsTo( qdt );
631 if ( sec > maxSec ) { 631 if ( sec > maxSec ) {
632 mRecheckAlarmTimer->start( maxSec * 1000 ); 632 mRecheckAlarmTimer->start( maxSec * 1000 );
633 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 633 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
634 return; 634 return;
635 } else { 635 } else {
636 mRecheckAlarmTimer->stop(); 636 mRecheckAlarmTimer->stop();
637 } 637 }
638 //qDebug("Alarm timer started with secs: %d ", sec); 638 //qDebug("Alarm timer started with secs: %d ", sec);
639 mAlarmTimer->start( sec *1000 , true ); 639 mAlarmTimer->start( sec *1000 , true );
640 640
641} 641}
642// called by mRecheckAlarmTimer to get next alarm 642// called by mRecheckAlarmTimer to get next alarm
643// we need this, because a QTimer has only a max range of 25 days 643// we need this, because a QTimer has only a max range of 25 days
644void CalendarView::recheckTimerAlarm() 644void CalendarView::recheckTimerAlarm()
645{ 645{
646 mAlarmTimer->stop(); 646 mAlarmTimer->stop();
647 mRecheckAlarmTimer->stop(); 647 mRecheckAlarmTimer->stop();
648 mCalendar->checkAlarmForIncidence( 0, true ); 648 mCalendar->checkAlarmForIncidence( 0, true );
649} 649}
650void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 650void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
651{ 651{
652 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 652 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
653 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 653 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
654#ifndef DESKTOP_VERSION 654#ifndef DESKTOP_VERSION
655 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 655 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
656#endif 656#endif
657 return; 657 return;
658 } 658 }
659 mAlarmTimer->stop(); 659 mAlarmTimer->stop();
660} 660}
661void CalendarView::selectWeekNum ( int num ) 661void CalendarView::selectWeekNum ( int num )
662{ 662{
663 dateNavigator()->selectWeek( num ); 663 dateNavigator()->selectWeek( num );
664 mViewManager->showWeekView(); 664 mViewManager->showWeekView();
665} 665}
666KOViewManager *CalendarView::viewManager() 666KOViewManager *CalendarView::viewManager()
667{ 667{
668 return mViewManager; 668 return mViewManager;
669} 669}
670 670
671KODialogManager *CalendarView::dialogManager() 671KODialogManager *CalendarView::dialogManager()
672{ 672{
673 return mDialogManager; 673 return mDialogManager;
674} 674}
675 675
676QDate CalendarView::startDate() 676QDate CalendarView::startDate()
677{ 677{
678 DateList dates = mNavigator->selectedDates(); 678 DateList dates = mNavigator->selectedDates();
679 679
680 return dates.first(); 680 return dates.first();
681} 681}
682 682
683QDate CalendarView::endDate() 683QDate CalendarView::endDate()
684{ 684{
685 DateList dates = mNavigator->selectedDates(); 685 DateList dates = mNavigator->selectedDates();
686 686
687 return dates.last(); 687 return dates.last();
688} 688}
689 689
690 690
691void CalendarView::createPrinter() 691void CalendarView::createPrinter()
692{ 692{
693#ifndef KORG_NOPRINTER 693#ifndef KORG_NOPRINTER
694 if (!mCalPrinter) { 694 if (!mCalPrinter) {
695 mCalPrinter = new CalPrinter(this, mCalendar); 695 mCalPrinter = new CalPrinter(this, mCalendar);
696 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 696 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
697 } 697 }
698#endif 698#endif
699} 699}
700 700
701void CalendarView::confSync()
702{
703 //DELETE
704}
705
706 701
707//KOPrefs::instance()->mWriteBackFile 702//KOPrefs::instance()->mWriteBackFile
708//KOPrefs::instance()->mWriteBackExistingOnly 703//KOPrefs::instance()->mWriteBackExistingOnly
709 704
710// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 705// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
711// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 706// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
712// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 707// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
713// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 708// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
714// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 709// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
715// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 710// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
716 711
717int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 712int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
718{ 713{
719 714
720 //void setZaurusId(int id); 715 //void setZaurusId(int id);
721 // int zaurusId() const; 716 // int zaurusId() const;
722 // void setZaurusUid(int id); 717 // void setZaurusUid(int id);
723 // int zaurusUid() const; 718 // int zaurusUid() const;
724 // void setZaurusStat(int id); 719 // void setZaurusStat(int id);
725 // int zaurusStat() const; 720 // int zaurusStat() const;
726 // 0 equal 721 // 0 equal
727 // 1 take local 722 // 1 take local
728 // 2 take remote 723 // 2 take remote
729 // 3 cancel 724 // 3 cancel
730 QDateTime lastSync = mLastCalendarSync; 725 QDateTime lastSync = mLastCalendarSync;
731 QDateTime localMod = local->lastModified(); 726 QDateTime localMod = local->lastModified();
732 QDateTime remoteMod = remote->lastModified(); 727 QDateTime remoteMod = remote->lastModified();
733 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
734 bool remCh, locCh; 729 bool remCh, locCh;
735 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 730 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
736 //if ( remCh ) 731 //if ( remCh )
737 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 732 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
738 locCh = ( localMod > mLastCalendarSync ); 733 locCh = ( localMod > mLastCalendarSync );
739 if ( !remCh && ! locCh ) { 734 if ( !remCh && ! locCh ) {
740 //qDebug("both not changed "); 735 //qDebug("both not changed ");
741 lastSync = localMod.addDays(1); 736 lastSync = localMod.addDays(1);
742 if ( mode <= SYNC_PREF_ASK ) 737 if ( mode <= SYNC_PREF_ASK )
743 return 0; 738 return 0;
744 } else { 739 } else {
745 if ( locCh ) { 740 if ( locCh ) {
746 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 741 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
747 lastSync = localMod.addDays( -1 ); 742 lastSync = localMod.addDays( -1 );
748 if ( !remCh ) 743 if ( !remCh )
749 remoteMod = ( lastSync.addDays( -1 ) ); 744 remoteMod = ( lastSync.addDays( -1 ) );
750 } else { 745 } else {
751 //qDebug(" not loc changed "); 746 //qDebug(" not loc changed ");
752 lastSync = localMod.addDays( 1 ); 747 lastSync = localMod.addDays( 1 );
753 if ( remCh ) 748 if ( remCh )
754 remoteMod =( lastSync.addDays( 1 ) ); 749 remoteMod =( lastSync.addDays( 1 ) );
755 750
756 } 751 }
757 } 752 }
758 full = true; 753 full = true;
759 if ( mode < SYNC_PREF_ASK ) 754 if ( mode < SYNC_PREF_ASK )
760 mode = SYNC_PREF_ASK; 755 mode = SYNC_PREF_ASK;
761 } else { 756 } else {
762 if ( localMod == remoteMod ) 757 if ( localMod == remoteMod )
763 if ( local->revision() == remote->revision() ) 758 if ( local->revision() == remote->revision() )
764 return 0; 759 return 0;
765 760
766 } 761 }
767 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 762 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
768 763
769 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 764 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
770 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 765 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
771 //full = true; //debug only 766 //full = true; //debug only
772 if ( full ) { 767 if ( full ) {
773 bool equ = false; 768 bool equ = false;
774 if ( local->type() == "Event" ) { 769 if ( local->type() == "Event" ) {
775 equ = (*((Event*) local) == *((Event*) remote)); 770 equ = (*((Event*) local) == *((Event*) remote));
776 } 771 }
777 else if ( local->type() =="Todo" ) 772 else if ( local->type() =="Todo" )
778 equ = (*((Todo*) local) == (*(Todo*) remote)); 773 equ = (*((Todo*) local) == (*(Todo*) remote));
779 else if ( local->type() =="Journal" ) 774 else if ( local->type() =="Journal" )
780 equ = (*((Journal*) local) == *((Journal*) remote)); 775 equ = (*((Journal*) local) == *((Journal*) remote));
781 if ( equ ) { 776 if ( equ ) {
782 //qDebug("equal "); 777 //qDebug("equal ");
783 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 778 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
784 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 779 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
785 } 780 }
786 if ( mode < SYNC_PREF_FORCE_LOCAL ) 781 if ( mode < SYNC_PREF_FORCE_LOCAL )
787 return 0; 782 return 0;
788 783
789 }//else //debug only 784 }//else //debug only
790 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 785 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
791 } 786 }
792 int result; 787 int result;
793 bool localIsNew; 788 bool localIsNew;
794 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 789 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
795 790
796 if ( full && mode < SYNC_PREF_NEWEST ) 791 if ( full && mode < SYNC_PREF_NEWEST )
797 mode = SYNC_PREF_ASK; 792 mode = SYNC_PREF_ASK;
798 793
799 switch( mode ) { 794 switch( mode ) {
800 case SYNC_PREF_LOCAL: 795 case SYNC_PREF_LOCAL:
801 if ( lastSync > remoteMod ) 796 if ( lastSync > remoteMod )
802 return 1; 797 return 1;
803 if ( lastSync > localMod ) 798 if ( lastSync > localMod )
804 return 2; 799 return 2;
805 return 1; 800 return 1;
806 break; 801 break;
807 case SYNC_PREF_REMOTE: 802 case SYNC_PREF_REMOTE:
808 if ( lastSync > remoteMod ) 803 if ( lastSync > remoteMod )
809 return 1; 804 return 1;
810 if ( lastSync > localMod ) 805 if ( lastSync > localMod )
811 return 2; 806 return 2;
812 return 2; 807 return 2;
813 break; 808 break;
814 case SYNC_PREF_NEWEST: 809 case SYNC_PREF_NEWEST:
815 if ( localMod > remoteMod ) 810 if ( localMod > remoteMod )
816 return 1; 811 return 1;
817 else 812 else
818 return 2; 813 return 2;
819 break; 814 break;
820 case SYNC_PREF_ASK: 815 case SYNC_PREF_ASK:
821 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 816 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
822 if ( lastSync > remoteMod ) 817 if ( lastSync > remoteMod )
823 return 1; 818 return 1;
824 if ( lastSync > localMod ) 819 if ( lastSync > localMod )
825 return 2; 820 return 2;
826 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 821 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
827 localIsNew = localMod >= remoteMod; 822 localIsNew = localMod >= remoteMod;
828 if ( localIsNew ) 823 if ( localIsNew )
829 getEventViewerDialog()->setColorMode( 1 ); 824 getEventViewerDialog()->setColorMode( 1 );
830 else 825 else
831 getEventViewerDialog()->setColorMode( 2 ); 826 getEventViewerDialog()->setColorMode( 2 );
832 getEventViewerDialog()->setIncidence(local); 827 getEventViewerDialog()->setIncidence(local);
833 if ( localIsNew ) 828 if ( localIsNew )
834 getEventViewerDialog()->setColorMode( 2 ); 829 getEventViewerDialog()->setColorMode( 2 );
835 else 830 else
836 getEventViewerDialog()->setColorMode( 1 ); 831 getEventViewerDialog()->setColorMode( 1 );
837 getEventViewerDialog()->addIncidence(remote); 832 getEventViewerDialog()->addIncidence(remote);
838 getEventViewerDialog()->setColorMode( 0 ); 833 getEventViewerDialog()->setColorMode( 0 );
839 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 834 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
840 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 835 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
841 getEventViewerDialog()->showMe(); 836 getEventViewerDialog()->showMe();
842 result = getEventViewerDialog()->executeS( localIsNew ); 837 result = getEventViewerDialog()->executeS( localIsNew );
843 return result; 838 return result;
844 839
845 break; 840 break;
846 case SYNC_PREF_FORCE_LOCAL: 841 case SYNC_PREF_FORCE_LOCAL:
847 return 1; 842 return 1;
848 break; 843 break;
849 case SYNC_PREF_FORCE_REMOTE: 844 case SYNC_PREF_FORCE_REMOTE:
850 return 2; 845 return 2;
851 break; 846 break;
852 847
853 default: 848 default:
854 // SYNC_PREF_TAKE_BOTH not implemented 849 // SYNC_PREF_TAKE_BOTH not implemented
855 break; 850 break;
856 } 851 }
857 return 0; 852 return 0;
858} 853}
859Event* CalendarView::getLastSyncEvent() 854Event* CalendarView::getLastSyncEvent()
860{ 855{
861 Event* lse; 856 Event* lse;
862 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 857 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
863 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 858 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
864 if (!lse) { 859 if (!lse) {
865 lse = new Event(); 860 lse = new Event();
866 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 861 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
867 QString sum = ""; 862 QString sum = "";
868 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 863 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
869 sum = "E: "; 864 sum = "E: ";
870 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 865 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
871 lse->setDtStart( mLastCalendarSync ); 866 lse->setDtStart( mLastCalendarSync );
872 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 867 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
873 lse->setCategories( i18n("SyncEvent") ); 868 lse->setCategories( i18n("SyncEvent") );
874 lse->setReadOnly( true ); 869 lse->setReadOnly( true );
875 mCalendar->addEvent( lse ); 870 mCalendar->addEvent( lse );
876 } 871 }
877 872
878 return lse; 873 return lse;
879 874
880} 875}
881 876
882// we check, if the to delete event has a id for a profile 877// we check, if the to delete event has a id for a profile
883// if yes, we set this id in the profile to delete 878// if yes, we set this id in the profile to delete
884void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 879void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
885{ 880{
886 if ( lastSync.count() == 0 ) { 881 if ( lastSync.count() == 0 ) {
887 //qDebug(" lastSync.count() == 0"); 882 //qDebug(" lastSync.count() == 0");
888 return; 883 return;
889 } 884 }
890 if ( toDelete->type() == "Journal" ) 885 if ( toDelete->type() == "Journal" )
891 return; 886 return;
892 887
893 Event* eve = lastSync.first(); 888 Event* eve = lastSync.first();
894 889
895 while ( eve ) { 890 while ( eve ) {
896 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 891 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
897 if ( !id.isEmpty() ) { 892 if ( !id.isEmpty() ) {
898 QString des = eve->description(); 893 QString des = eve->description();
899 QString pref = "e"; 894 QString pref = "e";
900 if ( toDelete->type() == "Todo" ) 895 if ( toDelete->type() == "Todo" )
901 pref = "t"; 896 pref = "t";
902 des += pref+ id + ","; 897 des += pref+ id + ",";
903 eve->setReadOnly( false ); 898 eve->setReadOnly( false );
904 eve->setDescription( des ); 899 eve->setDescription( des );
905 //qDebug("setdes %s ", des.latin1()); 900 //qDebug("setdes %s ", des.latin1());
906 eve->setReadOnly( true ); 901 eve->setReadOnly( true );
907 } 902 }
908 eve = lastSync.next(); 903 eve = lastSync.next();
909 } 904 }
910 905
911} 906}
912void CalendarView::checkExternalId( Incidence * inc ) 907void CalendarView::checkExternalId( Incidence * inc )
913{ 908{
914 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 909 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
915 checkExternSyncEvent( lastSync, inc ); 910 checkExternSyncEvent( lastSync, inc );
916 911
917} 912}
918bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 913bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
919{ 914{
920 bool syncOK = true; 915 bool syncOK = true;
921 int addedEvent = 0; 916 int addedEvent = 0;
922 int addedEventR = 0; 917 int addedEventR = 0;
923 int deletedEventR = 0; 918 int deletedEventR = 0;
924 int deletedEventL = 0; 919 int deletedEventL = 0;
925 int changedLocal = 0; 920 int changedLocal = 0;
926 int changedRemote = 0; 921 int changedRemote = 0;
927 //QPtrList<Event> el = local->rawEvents(); 922 //QPtrList<Event> el = local->rawEvents();
928 Event* eventR; 923 Event* eventR;
929 QString uid; 924 QString uid;
930 int take; 925 int take;
931 Event* eventL; 926 Event* eventL;
932 Event* eventRSync; 927 Event* eventRSync;
933 Event* eventLSync; 928 Event* eventLSync;
934 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 929 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
935 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 930 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
936 bool fullDateRange = false; 931 bool fullDateRange = false;
937 local->resetTempSyncStat(); 932 local->resetTempSyncStat();
938 mLastCalendarSync = QDateTime::currentDateTime(); 933 mLastCalendarSync = QDateTime::currentDateTime();
939 QDateTime modifiedCalendar = mLastCalendarSync;; 934 QDateTime modifiedCalendar = mLastCalendarSync;;
940 eventLSync = getLastSyncEvent(); 935 eventLSync = getLastSyncEvent();
941 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 936 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
942 if ( eventR ) { 937 if ( eventR ) {
943 eventRSync = (Event*) eventR->clone(); 938 eventRSync = (Event*) eventR->clone();
944 remote->deleteEvent(eventR ); 939 remote->deleteEvent(eventR );
945 940
946 } else { 941 } else {
947 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 942 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
948 eventRSync = (Event*)eventLSync->clone(); 943 eventRSync = (Event*)eventLSync->clone();
949 } else { 944 } else {
950 fullDateRange = true; 945 fullDateRange = true;
951 eventRSync = new Event(); 946 eventRSync = new Event();
952 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 947 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
953 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 948 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
954 eventRSync->setDtStart( mLastCalendarSync ); 949 eventRSync->setDtStart( mLastCalendarSync );
955 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 950 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
956 eventRSync->setCategories( i18n("SyncEvent") ); 951 eventRSync->setCategories( i18n("SyncEvent") );
957 } 952 }
958 } 953 }
959 if ( eventLSync->dtStart() == mLastCalendarSync ) 954 if ( eventLSync->dtStart() == mLastCalendarSync )
960 fullDateRange = true; 955 fullDateRange = true;
961 956
962 if ( ! fullDateRange ) { 957 if ( ! fullDateRange ) {
963 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 958 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
964 959
965 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 960 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
966 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 961 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
967 fullDateRange = true; 962 fullDateRange = true;
968 } 963 }
969 } 964 }
970 if ( fullDateRange ) 965 if ( fullDateRange )
971 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 966 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
972 else 967 else
973 mLastCalendarSync = eventLSync->dtStart(); 968 mLastCalendarSync = eventLSync->dtStart();
974 // for resyncing if own file has changed 969 // for resyncing if own file has changed
975 if ( mCurrentSyncDevice == "deleteaftersync" ) { 970 if ( mCurrentSyncDevice == "deleteaftersync" ) {
976 mLastCalendarSync = loadedFileVersion; 971 mLastCalendarSync = loadedFileVersion;
977 qDebug("setting mLastCalendarSync "); 972 qDebug("setting mLastCalendarSync ");
978 } 973 }
979 //qDebug("*************************** "); 974 //qDebug("*************************** ");
980 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 975 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
981 QPtrList<Incidence> er = remote->rawIncidences(); 976 QPtrList<Incidence> er = remote->rawIncidences();
982 Incidence* inR = er.first(); 977 Incidence* inR = er.first();
983 Incidence* inL; 978 Incidence* inL;
984 QProgressBar bar( er.count(),0 ); 979 QProgressBar bar( er.count(),0 );
985 bar.setCaption (i18n("Syncing - close to abort!") ); 980 bar.setCaption (i18n("Syncing - close to abort!") );
986 981
987 int w = 300; 982 int w = 300;
988 if ( QApplication::desktop()->width() < 320 ) 983 if ( QApplication::desktop()->width() < 320 )
989 w = 220; 984 w = 220;
990 int h = bar.sizeHint().height() ; 985 int h = bar.sizeHint().height() ;
991 int dw = QApplication::desktop()->width(); 986 int dw = QApplication::desktop()->width();
992 int dh = QApplication::desktop()->height(); 987 int dh = QApplication::desktop()->height();
993 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 988 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
994 bar.show(); 989 bar.show();
995 int modulo = (er.count()/10)+1; 990 int modulo = (er.count()/10)+1;
996 int incCounter = 0; 991 int incCounter = 0;
997 while ( inR ) { 992 while ( inR ) {
998 if ( ! bar.isVisible() ) 993 if ( ! bar.isVisible() )
999 return false; 994 return false;
1000 if ( incCounter % modulo == 0 ) 995 if ( incCounter % modulo == 0 )
1001 bar.setProgress( incCounter ); 996 bar.setProgress( incCounter );
1002 ++incCounter; 997 ++incCounter;
1003 uid = inR->uid(); 998 uid = inR->uid();
1004 bool skipIncidence = false; 999 bool skipIncidence = false;
1005 if ( uid.left(15) == QString("last-syncEvent-") ) 1000 if ( uid.left(15) == QString("last-syncEvent-") )
1006 skipIncidence = true; 1001 skipIncidence = true;
1007 QString idS; 1002 QString idS;
1008 qApp->processEvents(); 1003 qApp->processEvents();
1009 if ( !skipIncidence ) { 1004 if ( !skipIncidence ) {
1010 inL = local->incidence( uid ); 1005 inL = local->incidence( uid );
1011 if ( inL ) { // maybe conflict - same uid in both calendars 1006 if ( inL ) { // maybe conflict - same uid in both calendars
1012 int maxrev = inL->revision(); 1007 int maxrev = inL->revision();
1013 if ( maxrev < inR->revision() ) 1008 if ( maxrev < inR->revision() )
1014 maxrev = inR->revision(); 1009 maxrev = inR->revision();
1015 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1010 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1016 //qDebug("take %d %s ", take, inL->summary().latin1()); 1011 //qDebug("take %d %s ", take, inL->summary().latin1());
1017 if ( take == 3 ) 1012 if ( take == 3 )
1018 return false; 1013 return false;
1019 if ( take == 1 ) {// take local 1014 if ( take == 1 ) {// take local
1020 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1015 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1021 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1016 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1022 else 1017 else
1023 idS = inR->IDStr(); 1018 idS = inR->IDStr();
1024 remote->deleteIncidence( inR ); 1019 remote->deleteIncidence( inR );
1025 if ( inL->revision() < maxrev ) 1020 if ( inL->revision() < maxrev )
1026 inL->setRevision( maxrev ); 1021 inL->setRevision( maxrev );
1027 inR = inL->clone(); 1022 inR = inL->clone();
1028 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1023 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1029 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1024 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1030 inR->setIDStr( idS ); 1025 inR->setIDStr( idS );
1031 remote->addIncidence( inR ); 1026 remote->addIncidence( inR );
1032 ++changedRemote; 1027 ++changedRemote;
1033 } else { 1028 } else {
1034 if ( inR->revision() < maxrev ) 1029 if ( inR->revision() < maxrev )
1035 inR->setRevision( maxrev ); 1030 inR->setRevision( maxrev );
1036 idS = inL->IDStr(); 1031 idS = inL->IDStr();
1037 local->deleteIncidence( inL ); 1032 local->deleteIncidence( inL );
1038 inL = inR->clone(); 1033 inL = inR->clone();
1039 inL->setIDStr( idS ); 1034 inL->setIDStr( idS );
1040 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1035 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1041 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1036 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1042 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1037 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1043 } 1038 }
1044 local->addIncidence( inL ); 1039 local->addIncidence( inL );
1045 ++changedLocal; 1040 ++changedLocal;
1046 } 1041 }
1047 } 1042 }
1048 } else { // no conflict 1043 } else { // no conflict
1049 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1044 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1050 QString des = eventLSync->description(); 1045 QString des = eventLSync->description();
1051 QString pref = "e"; 1046 QString pref = "e";
1052 if ( inR->type() == "Todo" ) 1047 if ( inR->type() == "Todo" )
1053 pref = "t"; 1048 pref = "t";
1054 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1049 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1055 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1050 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1056 //remote->deleteIncidence( inR ); 1051 //remote->deleteIncidence( inR );
1057 ++deletedEventR; 1052 ++deletedEventR;
1058 } else { 1053 } else {
1059 inR->setLastModified( modifiedCalendar ); 1054 inR->setLastModified( modifiedCalendar );
1060 inL = inR->clone(); 1055 inL = inR->clone();
1061 local->addIncidence( inL ); 1056 local->addIncidence( inL );
1062 ++addedEvent; 1057 ++addedEvent;
1063 } 1058 }
1064 } else { 1059 } else {
1065 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1060 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1066 inR->setLastModified( modifiedCalendar ); 1061 inR->setLastModified( modifiedCalendar );
1067 local->addIncidence( inR->clone() ); 1062 local->addIncidence( inR->clone() );
1068 ++addedEvent; 1063 ++addedEvent;
1069 } else { 1064 } else {
1070 checkExternSyncEvent(eventRSyncSharp, inR); 1065 checkExternSyncEvent(eventRSyncSharp, inR);
1071 remote->deleteIncidence( inR ); 1066 remote->deleteIncidence( inR );
1072 ++deletedEventR; 1067 ++deletedEventR;
1073 } 1068 }
1074 } 1069 }
1075 } 1070 }
1076 } 1071 }
1077 inR = er.next(); 1072 inR = er.next();
1078 } 1073 }
1079 QPtrList<Incidence> el = local->rawIncidences(); 1074 QPtrList<Incidence> el = local->rawIncidences();
1080 inL = el.first(); 1075 inL = el.first();
1081 modulo = (el.count()/10)+1; 1076 modulo = (el.count()/10)+1;
1082 bar.setCaption (i18n("Add / remove events") ); 1077 bar.setCaption (i18n("Add / remove events") );
1083 bar.setTotalSteps ( el.count() ) ; 1078 bar.setTotalSteps ( el.count() ) ;
1084 bar.show(); 1079 bar.show();
1085 incCounter = 0; 1080 incCounter = 0;
1086 1081
1087 while ( inL ) { 1082 while ( inL ) {
1088 1083
1089 qApp->processEvents(); 1084 qApp->processEvents();
1090 if ( ! bar.isVisible() ) 1085 if ( ! bar.isVisible() )
1091 return false; 1086 return false;
1092 if ( incCounter % modulo == 0 ) 1087 if ( incCounter % modulo == 0 )
1093 bar.setProgress( incCounter ); 1088 bar.setProgress( incCounter );
1094 ++incCounter; 1089 ++incCounter;
1095 uid = inL->uid(); 1090 uid = inL->uid();
1096 bool skipIncidence = false; 1091 bool skipIncidence = false;
1097 if ( uid.left(15) == QString("last-syncEvent-") ) 1092 if ( uid.left(15) == QString("last-syncEvent-") )
1098 skipIncidence = true; 1093 skipIncidence = true;
1099 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1094 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1100 skipIncidence = true; 1095 skipIncidence = true;
1101 if ( !skipIncidence ) { 1096 if ( !skipIncidence ) {
1102 inR = remote->incidence( uid ); 1097 inR = remote->incidence( uid );
1103 if ( ! inR ) { 1098 if ( ! inR ) {
1104 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1099 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1105 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1100 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1106 checkExternSyncEvent(eventLSyncSharp, inL); 1101 checkExternSyncEvent(eventLSyncSharp, inL);
1107 local->deleteIncidence( inL ); 1102 local->deleteIncidence( inL );
1108 ++deletedEventL; 1103 ++deletedEventL;
1109 } else { 1104 } else {
1110 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1105 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1111 inL->removeID(mCurrentSyncDevice ); 1106 inL->removeID(mCurrentSyncDevice );
1112 ++addedEventR; 1107 ++addedEventR;
1113 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1108 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1114 inL->setLastModified( modifiedCalendar ); 1109 inL->setLastModified( modifiedCalendar );
1115 inR = inL->clone(); 1110 inR = inL->clone();
1116 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1111 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1117 remote->addIncidence( inR ); 1112 remote->addIncidence( inR );
1118 } 1113 }
1119 } 1114 }
1120 } else { 1115 } else {
1121 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1116 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1122 checkExternSyncEvent(eventLSyncSharp, inL); 1117 checkExternSyncEvent(eventLSyncSharp, inL);
1123 local->deleteIncidence( inL ); 1118 local->deleteIncidence( inL );
1124 ++deletedEventL; 1119 ++deletedEventL;
1125 } else { 1120 } else {
1126 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1121 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1127 ++addedEventR; 1122 ++addedEventR;
1128 inL->setLastModified( modifiedCalendar ); 1123 inL->setLastModified( modifiedCalendar );
1129 remote->addIncidence( inL->clone() ); 1124 remote->addIncidence( inL->clone() );
1130 } 1125 }
1131 } 1126 }
1132 } 1127 }
1133 } 1128 }
1134 } 1129 }
1135 inL = el.next(); 1130 inL = el.next();
1136 } 1131 }
1137 int delFut = 0; 1132 int delFut = 0;
1138 if ( mSyncManager->mWriteBackInFuture ) { 1133 if ( mSyncManager->mWriteBackInFuture ) {
1139 er = remote->rawIncidences(); 1134 er = remote->rawIncidences();
1140 inR = er.first(); 1135 inR = er.first();
1141 QDateTime dt; 1136 QDateTime dt;
1142 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1137 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1143 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); 1138 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 );
1144 while ( inR ) { 1139 while ( inR ) {
1145 if ( inR->type() == "Todo" ) { 1140 if ( inR->type() == "Todo" ) {
1146 Todo * t = (Todo*)inR; 1141 Todo * t = (Todo*)inR;
1147 if ( t->hasDueDate() ) 1142 if ( t->hasDueDate() )
1148 dt = t->dtDue(); 1143 dt = t->dtDue();
1149 else 1144 else
1150 dt = cur.addSecs( 62 ); 1145 dt = cur.addSecs( 62 );
1151 } 1146 }
1152 else if (inR->type() == "Event" ) { 1147 else if (inR->type() == "Event" ) {
1153 bool ok; 1148 bool ok;
1154 dt = inR->getNextOccurence( cur, &ok ); 1149 dt = inR->getNextOccurence( cur, &ok );
1155 if ( !ok ) 1150 if ( !ok )
1156 dt = cur.addSecs( -62 ); 1151 dt = cur.addSecs( -62 );
1157 } 1152 }
1158 else 1153 else
1159 dt = inR->dtStart(); 1154 dt = inR->dtStart();
1160 if ( dt < cur || dt > end ) { 1155 if ( dt < cur || dt > end ) {
1161 remote->deleteIncidence( inR ); 1156 remote->deleteIncidence( inR );
1162 ++delFut; 1157 ++delFut;
1163 } 1158 }
1164 inR = er.next(); 1159 inR = er.next();
1165 } 1160 }
1166 } 1161 }
1167 bar.hide(); 1162 bar.hide();
1168 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1163 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1169 eventLSync->setReadOnly( false ); 1164 eventLSync->setReadOnly( false );
1170 eventLSync->setDtStart( mLastCalendarSync ); 1165 eventLSync->setDtStart( mLastCalendarSync );
1171 eventRSync->setDtStart( mLastCalendarSync ); 1166 eventRSync->setDtStart( mLastCalendarSync );
1172 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1167 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1173 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1168 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1174 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1169 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1175 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1170 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1176 eventLSync->setReadOnly( true ); 1171 eventLSync->setReadOnly( true );
1177 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1172 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1178 remote->addEvent( eventRSync ); 1173 remote->addEvent( eventRSync );
1179 QString mes; 1174 QString mes;
1180 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1175 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1181 QString delmess; 1176 QString delmess;
1182 if ( delFut ) { 1177 if ( delFut ) {
1183 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, mSyncManager->mWriteBackInFuture ); 1178 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, mSyncManager->mWriteBackInFuture );
1184 mes += delmess; 1179 mes += delmess;
1185 } 1180 }
1186 if ( mSyncManager->mShowSyncSummary ) { 1181 if ( mSyncManager->mShowSyncSummary ) {
1187 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1182 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1188 } 1183 }
1189 qDebug( mes ); 1184 qDebug( mes );
1190 mCalendar->checkAlarmForIncidence( 0, true ); 1185 mCalendar->checkAlarmForIncidence( 0, true );
1191 return syncOK; 1186 return syncOK;
1192} 1187}
1193 1188
1194void CalendarView::setSyncDevice( QString s ) 1189void CalendarView::setSyncDevice( QString s )
1195{ 1190{
1196 mCurrentSyncDevice= s; 1191 mCurrentSyncDevice= s;
1197} 1192}
1198void CalendarView::setSyncName( QString s ) 1193void CalendarView::setSyncName( QString s )
1199{ 1194{
1200 mCurrentSyncName= s; 1195 mCurrentSyncName= s;
1201} 1196}
1202bool CalendarView::syncCalendar(QString filename, int mode) 1197bool CalendarView::syncCalendar(QString filename, int mode)
1203{ 1198{
1199 //qDebug("syncCalendar %s ", filename.latin1());
1204 mGlobalSyncMode = SYNC_MODE_NORMAL; 1200 mGlobalSyncMode = SYNC_MODE_NORMAL;
1205 CalendarLocal* calendar = new CalendarLocal(); 1201 CalendarLocal* calendar = new CalendarLocal();
1206 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1202 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1207 FileStorage* storage = new FileStorage( calendar ); 1203 FileStorage* storage = new FileStorage( calendar );
1208 bool syncOK = false; 1204 bool syncOK = false;
1209 storage->setFileName( filename ); 1205 storage->setFileName( filename );
1210 // qDebug("loading ... "); 1206 // qDebug("loading ... ");
1211 if ( storage->load() ) { 1207 if ( storage->load() ) {
1212 getEventViewerDialog()->setSyncMode( true ); 1208 getEventViewerDialog()->setSyncMode( true );
1213 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1209 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1214 getEventViewerDialog()->setSyncMode( false ); 1210 getEventViewerDialog()->setSyncMode( false );
1215 if ( syncOK ) { 1211 if ( syncOK ) {
1216 if ( mSyncManager->mWriteBackFile ) 1212 if ( mSyncManager->mWriteBackFile )
1217 { 1213 {
1218 storage->setSaveFormat( new ICalFormat() ); 1214 storage->setSaveFormat( new ICalFormat() );
1219 storage->save(); 1215 storage->save();
1220 } 1216 }
1221 } 1217 }
1222 setModified( true ); 1218 setModified( true );
1223 } 1219 }
1224 delete storage; 1220 delete storage;
1225 delete calendar; 1221 delete calendar;
1226 if ( syncOK ) 1222 if ( syncOK )
1227 updateView(); 1223 updateView();
1228 return syncOK; 1224 return syncOK;
1229} 1225}
1230void CalendarView::syncPhone() 1226
1231{
1232 //DELETE
1233}
1234void CalendarView::syncExternal( int mode ) 1227void CalendarView::syncExternal( int mode )
1235{ 1228{
1236 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1229 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1237 1230
1238 qApp->processEvents(); 1231 qApp->processEvents();
1239 CalendarLocal* calendar = new CalendarLocal(); 1232 CalendarLocal* calendar = new CalendarLocal();
1240 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1233 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1241 bool syncOK = false; 1234 bool syncOK = false;
1242 bool loadSuccess = false; 1235 bool loadSuccess = false;
1243 PhoneFormat* phoneFormat = 0; 1236 PhoneFormat* phoneFormat = 0;
1244#ifndef DESKTOP_VERSION 1237#ifndef DESKTOP_VERSION
1245 SharpFormat* sharpFormat = 0; 1238 SharpFormat* sharpFormat = 0;
1246 if ( mode == 0 ) { // sharp 1239 if ( mode == 0 ) { // sharp
1247 sharpFormat = new SharpFormat () ; 1240 sharpFormat = new SharpFormat () ;
1248 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1241 loadSuccess = sharpFormat->load( calendar, mCalendar );
1249 1242
1250 } else 1243 } else
1251#endif 1244#endif
1252 if ( mode == 1 ) { // phone 1245 if ( mode == 1 ) { // phone
1253 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1246 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1254 mSyncManager->mPhoneDevice, 1247 mSyncManager->mPhoneDevice,
1255 mSyncManager->mPhoneConnection, 1248 mSyncManager->mPhoneConnection,
1256 mSyncManager->mPhoneModel); 1249 mSyncManager->mPhoneModel);
1257 loadSuccess = phoneFormat->load( calendar,mCalendar); 1250 loadSuccess = phoneFormat->load( calendar,mCalendar);
1258 1251
1259 } else 1252 } else
1260 return; 1253 return;
1261 if ( loadSuccess ) { 1254 if ( loadSuccess ) {
1262 getEventViewerDialog()->setSyncMode( true ); 1255 getEventViewerDialog()->setSyncMode( true );
1263 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1256 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1264 getEventViewerDialog()->setSyncMode( false ); 1257 getEventViewerDialog()->setSyncMode( false );
1265 qApp->processEvents(); 1258 qApp->processEvents();
1266 if ( syncOK ) { 1259 if ( syncOK ) {
1267 if ( mSyncManager->mWriteBackFile ) 1260 if ( mSyncManager->mWriteBackFile )
1268 { 1261 {
1269 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1262 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1270 Incidence* inc = iL.first(); 1263 Incidence* inc = iL.first();
1271 if ( phoneFormat ) { 1264 if ( phoneFormat ) {
1272 while ( inc ) { 1265 while ( inc ) {
1273 inc->removeID(mCurrentSyncDevice); 1266 inc->removeID(mCurrentSyncDevice);
1274 inc = iL.next(); 1267 inc = iL.next();
1275 } 1268 }
1276 } 1269 }
1277#ifndef DESKTOP_VERSION 1270#ifndef DESKTOP_VERSION
1278 if ( sharpFormat ) 1271 if ( sharpFormat )
1279 sharpFormat->save(calendar); 1272 sharpFormat->save(calendar);
1280#endif 1273#endif
1281 if ( phoneFormat ) 1274 if ( phoneFormat )
1282 phoneFormat->save(calendar); 1275 phoneFormat->save(calendar);
1283 iL = calendar->rawIncidences(); 1276 iL = calendar->rawIncidences();
1284 inc = iL.first(); 1277 inc = iL.first();
1285 Incidence* loc; 1278 Incidence* loc;
1286 while ( inc ) { 1279 while ( inc ) {
1287 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1280 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1288 loc = mCalendar->incidence(inc->uid() ); 1281 loc = mCalendar->incidence(inc->uid() );
1289 if ( loc ) { 1282 if ( loc ) {
1290 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1283 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1291 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1284 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1292 } 1285 }
1293 } 1286 }
1294 inc = iL.next(); 1287 inc = iL.next();
1295 } 1288 }
1296 Incidence* lse = getLastSyncEvent(); 1289 Incidence* lse = getLastSyncEvent();
1297 if ( lse ) { 1290 if ( lse ) {
1298 lse->setReadOnly( false ); 1291 lse->setReadOnly( false );
1299 lse->setDescription( "" ); 1292 lse->setDescription( "" );
1300 lse->setReadOnly( true ); 1293 lse->setReadOnly( true );
1301 } 1294 }
1302 } 1295 }
1303 } 1296 }
1304 setModified( true ); 1297 setModified( true );
1305 } else { 1298 } else {
1306 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1299 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1307 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1300 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1308 question, i18n("Ok")) ; 1301 question, i18n("Ok")) ;
1309 1302
1310 } 1303 }
1311 delete calendar; 1304 delete calendar;
1312 updateView(); 1305 updateView();
1313 return ;//syncOK; 1306 return ;//syncOK;
1314 1307
1315} 1308}
1316void CalendarView::syncSharp()
1317{
1318 //DELETE
1319
1320}
1321
1322 1309
1323bool CalendarView::importBday() 1310bool CalendarView::importBday()
1324{ 1311{
1325#ifndef KORG_NOKABC 1312#ifndef KORG_NOKABC
1326 1313
1327#ifdef DESKTOP_VERSION 1314#ifdef DESKTOP_VERSION
1328 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1315 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1329 KABC::AddressBook::Iterator it; 1316 KABC::AddressBook::Iterator it;
1330 int count = 0; 1317 int count = 0;
1331 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1318 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1332 ++count; 1319 ++count;
1333 } 1320 }
1334 QProgressBar bar(count,0 ); 1321 QProgressBar bar(count,0 );
1335 int w = 300; 1322 int w = 300;
1336 if ( QApplication::desktop()->width() < 320 ) 1323 if ( QApplication::desktop()->width() < 320 )
1337 w = 220; 1324 w = 220;
1338 int h = bar.sizeHint().height() ; 1325 int h = bar.sizeHint().height() ;
1339 int dw = QApplication::desktop()->width(); 1326 int dw = QApplication::desktop()->width();
1340 int dh = QApplication::desktop()->height(); 1327 int dh = QApplication::desktop()->height();
1341 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1328 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1342 bar.show(); 1329 bar.show();
1343 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1330 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1344 qApp->processEvents(); 1331 qApp->processEvents();
1345 count = 0; 1332 count = 0;
1346 int addCount = 0; 1333 int addCount = 0;
1347 KCal::Attendee* a = 0; 1334 KCal::Attendee* a = 0;
1348 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1335 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1349 if ( ! bar.isVisible() ) 1336 if ( ! bar.isVisible() )
1350 return false; 1337 return false;
1351 bar.setProgress( count++ ); 1338 bar.setProgress( count++ );
1352 qApp->processEvents(); 1339 qApp->processEvents();
1353 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1340 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1354 if ( (*it).birthday().date().isValid() ){ 1341 if ( (*it).birthday().date().isValid() ){
1355 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1342 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1356 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1343 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1357 ++addCount; 1344 ++addCount;
1358 } 1345 }
1359 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1346 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1360 if ( anni.isValid() ){ 1347 if ( anni.isValid() ){
1361 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1348 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1362 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1349 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1363 ++addCount; 1350 ++addCount;
1364 } 1351 }
1365 } 1352 }
1366 updateView(); 1353 updateView();
1367 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1354 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1368#else //DESKTOP_VERSION 1355#else //DESKTOP_VERSION
1369 1356
1370 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1357 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1371 // the result should now arrive through method insertBirthdays 1358 // the result should now arrive through method insertBirthdays
1372 1359
1373#endif //DESKTOP_VERSION 1360#endif //DESKTOP_VERSION
1374 1361
1375#endif //KORG_NOKABC 1362#endif //KORG_NOKABC
1376 1363
1377 1364
1378 return true; 1365 return true;
1379} 1366}
1380 1367
1381// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1368// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1382void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1369void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1383 const QStringList& anniversaryList, const QStringList& realNameList, 1370 const QStringList& anniversaryList, const QStringList& realNameList,
1384 const QStringList& emailList, const QStringList& assembledNameList, 1371 const QStringList& emailList, const QStringList& assembledNameList,
1385 const QStringList& uidList) 1372 const QStringList& uidList)
1386{ 1373{
1387 qDebug("CalendarView::insertBirthdays"); 1374 qDebug("CalendarView::insertBirthdays");
1388 if (uid == this->name()) 1375 if (uid == this->name())
1389 { 1376 {
1390 int count = birthdayList.count(); 1377 int count = birthdayList.count();
1391 int addCount = 0; 1378 int addCount = 0;
1392 KCal::Attendee* a = 0; 1379 KCal::Attendee* a = 0;
1393 1380
1394 qDebug("CalView 1 %i", count); 1381 qDebug("CalView 1 %i", count);
1395 1382
1396 QProgressBar bar(count,0 ); 1383 QProgressBar bar(count,0 );
1397 int w = 300; 1384 int w = 300;
1398 if ( QApplication::desktop()->width() < 320 ) 1385 if ( QApplication::desktop()->width() < 320 )
1399 w = 220; 1386 w = 220;
1400 int h = bar.sizeHint().height() ; 1387 int h = bar.sizeHint().height() ;
1401 int dw = QApplication::desktop()->width(); 1388 int dw = QApplication::desktop()->width();
1402 int dh = QApplication::desktop()->height(); 1389 int dh = QApplication::desktop()->height();
1403 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1390 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1404 bar.show(); 1391 bar.show();
1405 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1392 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1406 qApp->processEvents(); 1393 qApp->processEvents();
1407 1394
1408 QDate birthday; 1395 QDate birthday;
1409 QDate anniversary; 1396 QDate anniversary;
1410 QString realName; 1397 QString realName;
1411 QString email; 1398 QString email;
1412 QString assembledName; 1399 QString assembledName;
1413 QString uid; 1400 QString uid;
1414 bool ok = true; 1401 bool ok = true;
1415 for ( int i = 0; i < count; i++) 1402 for ( int i = 0; i < count; i++)
1416 { 1403 {
1417 if ( ! bar.isVisible() ) 1404 if ( ! bar.isVisible() )
1418 return; 1405 return;
1419 bar.setProgress( i ); 1406 bar.setProgress( i );
1420 qApp->processEvents(); 1407 qApp->processEvents();
1421 1408
1422 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1409 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1423 if (!ok) { 1410 if (!ok) {
1424 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1411 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1425 } 1412 }
1426 1413
1427 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1414 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1428 if (!ok) { 1415 if (!ok) {
1429 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1416 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1430 } 1417 }
1431 realName = realNameList[i]; 1418 realName = realNameList[i];
1432 email = emailList[i]; 1419 email = emailList[i];
1433 assembledName = assembledNameList[i]; 1420 assembledName = assembledNameList[i];
1434 uid = uidList[i]; 1421 uid = uidList[i];
1435 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1422 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1436 1423
1437 if ( birthday.isValid() ){ 1424 if ( birthday.isValid() ){
1438 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1425 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1439 KCal::Attendee::ReqParticipant,uid) ; 1426 KCal::Attendee::ReqParticipant,uid) ;
1440 if ( addAnniversary( birthday, assembledName, a, true ) ) 1427 if ( addAnniversary( birthday, assembledName, a, true ) )
1441 ++addCount; 1428 ++addCount;
1442 } 1429 }
1443 1430
1444 if ( anniversary.isValid() ){ 1431 if ( anniversary.isValid() ){
1445 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1432 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1446 KCal::Attendee::ReqParticipant,uid) ; 1433 KCal::Attendee::ReqParticipant,uid) ;
1447 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1434 if ( addAnniversary( anniversary, assembledName, a, false ) )
1448 ++addCount; 1435 ++addCount;
1449 } 1436 }
1450 } 1437 }
1451 1438
1452 updateView(); 1439 updateView();
1453 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1440 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1454 1441
1455 } 1442 }
1456 1443
1457} 1444}
1458 1445
1459 1446
1460 1447
1461bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1448bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1462{ 1449{
1463 //qDebug("addAnni "); 1450 //qDebug("addAnni ");
1464 Event * ev = new Event(); 1451 Event * ev = new Event();
1465 if ( a ) { 1452 if ( a ) {
1466 ev->addAttendee( a ); 1453 ev->addAttendee( a );
1467 } 1454 }
1468 QString kind; 1455 QString kind;
1469 if ( birthday ) 1456 if ( birthday )
1470 kind = i18n( "Birthday" ); 1457 kind = i18n( "Birthday" );
1471 else 1458 else
1472 kind = i18n( "Anniversary" ); 1459 kind = i18n( "Anniversary" );
1473 ev->setSummary( name + " - " + kind ); 1460 ev->setSummary( name + " - " + kind );
1474 ev->setOrganizer( "nobody@nowhere" ); 1461 ev->setOrganizer( "nobody@nowhere" );
1475 ev->setCategories( kind ); 1462 ev->setCategories( kind );
1476 ev->setDtStart( QDateTime(date) ); 1463 ev->setDtStart( QDateTime(date) );
1477 ev->setDtEnd( QDateTime(date) ); 1464 ev->setDtEnd( QDateTime(date) );
1478 ev->setFloats( true ); 1465 ev->setFloats( true );
1479 Recurrence * rec = ev->recurrence(); 1466 Recurrence * rec = ev->recurrence();
1480 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1467 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1481 rec->addYearlyNum( date.month() ); 1468 rec->addYearlyNum( date.month() );
1482 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1469 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1483 delete ev; 1470 delete ev;
1484 return false; 1471 return false;
1485 } 1472 }
1486 return true; 1473 return true;
1487 1474
1488} 1475}
1489bool CalendarView::importQtopia( const QString &categories, 1476bool CalendarView::importQtopia( const QString &categories,
1490 const QString &datebook, 1477 const QString &datebook,
1491 const QString &todolist ) 1478 const QString &todolist )
1492{ 1479{
1493 1480
1494 QtopiaFormat qtopiaFormat; 1481 QtopiaFormat qtopiaFormat;
1495 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1482 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1496 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1483 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1497 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1484 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1498 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1485 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1499 1486
1500 updateView(); 1487 updateView();
1501 return true; 1488 return true;
1502 1489
1503#if 0 1490#if 0
1504 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1491 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1505 mCurrentSyncDevice = "qtopia-XML"; 1492 mCurrentSyncDevice = "qtopia-XML";
1506 if ( mSyncManager->mAskForPreferences ) 1493 if ( mSyncManager->mAskForPreferences )
1507 edit_sync_options(); 1494 edit_sync_options();
1508 qApp->processEvents(); 1495 qApp->processEvents();
1509 CalendarLocal* calendar = new CalendarLocal(); 1496 CalendarLocal* calendar = new CalendarLocal();
1510 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1497 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1511 bool syncOK = false; 1498 bool syncOK = false;
1512 QtopiaFormat qtopiaFormat; 1499 QtopiaFormat qtopiaFormat;
1513 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1500 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1514 bool loadOk = true; 1501 bool loadOk = true;
1515 if ( !categories.isEmpty() ) 1502 if ( !categories.isEmpty() )
1516 loadOk = qtopiaFormat.load( calendar, categories ); 1503 loadOk = qtopiaFormat.load( calendar, categories );
1517 if ( loadOk && !datebook.isEmpty() ) 1504 if ( loadOk && !datebook.isEmpty() )
1518 loadOk = qtopiaFormat.load( calendar, datebook ); 1505 loadOk = qtopiaFormat.load( calendar, datebook );
1519 if ( loadOk && !todolist.isEmpty() ) 1506 if ( loadOk && !todolist.isEmpty() )
1520 loadOk = qtopiaFormat.load( calendar, todolist ); 1507 loadOk = qtopiaFormat.load( calendar, todolist );
1521 1508
1522 if ( loadOk ) { 1509 if ( loadOk ) {
1523 getEventViewerDialog()->setSyncMode( true ); 1510 getEventViewerDialog()->setSyncMode( true );
1524 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1511 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1525 getEventViewerDialog()->setSyncMode( false ); 1512 getEventViewerDialog()->setSyncMode( false );
1526 qApp->processEvents(); 1513 qApp->processEvents();
1527 if ( syncOK ) { 1514 if ( syncOK ) {
1528 if ( mSyncManager->mWriteBackFile ) 1515 if ( mSyncManager->mWriteBackFile )
1529 { 1516 {
1530 // write back XML file 1517 // write back XML file
1531 1518
1532 } 1519 }
1533 setModified( true ); 1520 setModified( true );
1534 } 1521 }
1535 } else { 1522 } else {
1536 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1523 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1537 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1524 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1538 question, i18n("Ok")) ; 1525 question, i18n("Ok")) ;
1539 } 1526 }
1540 delete calendar; 1527 delete calendar;
1541 updateView(); 1528 updateView();
1542 return syncOK; 1529 return syncOK;
1543 1530
1544 1531
1545#endif 1532#endif
1546 1533
1547} 1534}
1548 1535
1549void CalendarView::setSyncEventsReadOnly() 1536void CalendarView::setSyncEventsReadOnly()
1550{ 1537{
1551 Event * ev; 1538 Event * ev;
1552 QPtrList<Event> eL = mCalendar->rawEvents(); 1539 QPtrList<Event> eL = mCalendar->rawEvents();
1553 ev = eL.first(); 1540 ev = eL.first();
1554 while ( ev ) { 1541 while ( ev ) {
1555 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1542 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1556 ev->setReadOnly( true ); 1543 ev->setReadOnly( true );
1557 ev = eL.next(); 1544 ev = eL.next();
1558 } 1545 }
1559} 1546}
1560bool CalendarView::openCalendar(QString filename, bool merge) 1547bool CalendarView::openCalendar(QString filename, bool merge)
1561{ 1548{
1562 1549
1563 if (filename.isEmpty()) { 1550 if (filename.isEmpty()) {
1564 return false; 1551 return false;
1565 } 1552 }
1566 1553
1567 if (!QFile::exists(filename)) { 1554 if (!QFile::exists(filename)) {
1568 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1555 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1569 return false; 1556 return false;
1570 } 1557 }
1571 1558
1572 globalFlagBlockAgenda = 1; 1559 globalFlagBlockAgenda = 1;
1573 if (!merge) mCalendar->close(); 1560 if (!merge) mCalendar->close();
1574 1561
1575 mStorage->setFileName( filename ); 1562 mStorage->setFileName( filename );
1576 1563
1577 if ( mStorage->load() ) { 1564 if ( mStorage->load() ) {
1578 if ( merge ) ;//setModified( true ); 1565 if ( merge ) ;//setModified( true );
1579 else { 1566 else {
1580 //setModified( true ); 1567 //setModified( true );
1581 mViewManager->setDocumentId( filename ); 1568 mViewManager->setDocumentId( filename );
1582 mDialogManager->setDocumentId( filename ); 1569 mDialogManager->setDocumentId( filename );
1583 mTodoList->setDocumentId( filename ); 1570 mTodoList->setDocumentId( filename );
1584 } 1571 }
1585 globalFlagBlockAgenda = 2; 1572 globalFlagBlockAgenda = 2;
1586 // if ( getLastSyncEvent() ) 1573 // if ( getLastSyncEvent() )
1587 // getLastSyncEvent()->setReadOnly( true ); 1574 // getLastSyncEvent()->setReadOnly( true );
1588 mCalendar->reInitAlarmSettings(); 1575 mCalendar->reInitAlarmSettings();
1589 setSyncEventsReadOnly(); 1576 setSyncEventsReadOnly();
1590 updateUnmanagedViews(); 1577 updateUnmanagedViews();
1591 updateView(); 1578 updateView();
1592 setLoadedFileVersion( QDateTime::currentDateTime().addSecs( -1 ));
1593 if ( filename != MainWindow::defaultFileName() ) { 1579 if ( filename != MainWindow::defaultFileName() ) {
1594 saveCalendar( MainWindow::defaultFileName() ); 1580 saveCalendar( MainWindow::defaultFileName() );
1595 watchSavedFile(); 1581 } else {
1582 QFileInfo finf ( MainWindow::defaultFileName());
1583 if ( finf.exists() ) {
1584 setLoadedFileVersion( finf.lastModified () );
1585 }
1596 } 1586 }
1597 return true; 1587 return true;
1598 } else { 1588 } else {
1599 // while failing to load, the calendar object could 1589 // while failing to load, the calendar object could
1600 // have become partially populated. Clear it out. 1590 // have become partially populated. Clear it out.
1601 if ( !merge ) { 1591 if ( !merge ) {
1602 mCalendar->close(); 1592 mCalendar->close();
1603 mViewManager->setDocumentId( filename ); 1593 mViewManager->setDocumentId( filename );
1604 mDialogManager->setDocumentId( filename ); 1594 mDialogManager->setDocumentId( filename );
1605 mTodoList->setDocumentId( filename ); 1595 mTodoList->setDocumentId( filename );
1606 } 1596 }
1607 1597
1608 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1598 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1609 1599
1610 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1600 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1611 globalFlagBlockAgenda = 2; 1601 globalFlagBlockAgenda = 2;
1612 mCalendar->reInitAlarmSettings(); 1602 mCalendar->reInitAlarmSettings();
1613 setSyncEventsReadOnly(); 1603 setSyncEventsReadOnly();
1614 updateUnmanagedViews(); 1604 updateUnmanagedViews();
1615 updateView(); 1605 updateView();
1616 } 1606 }
1617 return false; 1607 return false;
1618} 1608}
1619void CalendarView::showOpenError() 1609void CalendarView::showOpenError()
1620{ 1610{
1621 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1611 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1622} 1612}
1623void CalendarView::setLoadedFileVersion(QDateTime dt) 1613void CalendarView::setLoadedFileVersion(QDateTime dt)
1624{ 1614{
1625 loadedFileVersion = dt; 1615 loadedFileVersion = dt;
1626} 1616}
1627bool CalendarView::checkFileChanged(QString fn) 1617bool CalendarView::checkFileChanged(QString fn)
1628{ 1618{
1629 QFileInfo finf ( fn ); 1619 QFileInfo finf ( fn );
1630 if ( !finf.exists() ) 1620 if ( !finf.exists() )
1631 return true; 1621 return true;
1632 QDateTime dt = finf.lastModified (); 1622 QDateTime dt = finf.lastModified ();
1633 if ( dt <= loadedFileVersion ) 1623 if ( dt <= loadedFileVersion )
1634 return false; 1624 return false;
1635 return true; 1625 return true;
1636 1626
1637} 1627}
1638void CalendarView::watchSavedFile() 1628void CalendarView::watchSavedFile()
1639{ 1629{
1640 QFileInfo finf ( MainWindow::defaultFileName()); 1630 QFileInfo finf ( MainWindow::defaultFileName());
1641 if ( !finf.exists() ) 1631 if ( !finf.exists() )
1642 return; 1632 return;
1643 QDateTime dt = finf.lastModified (); 1633 QDateTime dt = finf.lastModified ();
1644 if ( dt < loadedFileVersion ) { 1634 if ( dt < loadedFileVersion ) {
1645 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1635 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1646 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1636 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1647 return; 1637 return;
1648 } 1638 }
1649 loadedFileVersion = dt; 1639 loadedFileVersion = dt;
1650} 1640}
1651 1641
1652bool CalendarView::checkFileVersion(QString fn) 1642bool CalendarView::checkFileVersion(QString fn)
1653{ 1643{
1654 QFileInfo finf ( fn ); 1644 QFileInfo finf ( fn );
1655 if ( !finf.exists() ) 1645 if ( !finf.exists() )
1656 return true; 1646 return true;
1657 QDateTime dt = finf.lastModified (); 1647 QDateTime dt = finf.lastModified ();
1658 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1648 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1659 //qDebug("file on disk version %s",dt.toString().latin1()); 1649 //qDebug("file on disk version %s",dt.toString().latin1());
1660 if ( dt <= loadedFileVersion ) 1650 if ( dt <= loadedFileVersion )
1661 return true; 1651 return true;
1662 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1652 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1663 i18n("KO/Pi Warning"),i18n("Overwrite"), 1653 i18n("KO/Pi Warning"),i18n("Overwrite"),
1664 i18n("Sync+save")); 1654 i18n("Sync+save"));
1665 1655
1666 if ( km == KMessageBox::Cancel ) 1656 if ( km == KMessageBox::Cancel )
1667 return false; 1657 return false;
1668 if ( km == KMessageBox::Yes ) 1658 if ( km == KMessageBox::Yes )
1669 return true; 1659 return true;
1670 1660
1671 setSyncDevice("deleteaftersync" ); 1661 setSyncDevice("deleteaftersync" );
1672 mSyncManager->mAskForPreferences = true; 1662 mSyncManager->mAskForPreferences = true;
1673 mSyncManager->mSyncAlgoPrefs = 3; 1663 mSyncManager->mSyncAlgoPrefs = 3;
1674 mSyncManager->mWriteBackFile = false; 1664 mSyncManager->mWriteBackFile = false;
1675 mSyncManager->mWriteBackExistingOnly = false; 1665 mSyncManager->mWriteBackExistingOnly = false;
1676 mSyncManager->mShowSyncSummary = false; 1666 mSyncManager->mShowSyncSummary = false;
1677 syncCalendar( fn, 3 ); 1667 syncCalendar( fn, 3 );
1678 Event * e = getLastSyncEvent(); 1668 Event * e = getLastSyncEvent();
1679 mCalendar->deleteEvent ( e ); 1669 mCalendar->deleteEvent ( e );
1680 updateView(); 1670 updateView();
1681 return true; 1671 return true;
1682} 1672}
1683 1673
1684bool CalendarView::saveCalendar( QString filename ) 1674bool CalendarView::saveCalendar( QString filename )
1685{ 1675{
1686 1676
1687 // Store back all unsaved data into calendar object 1677 // Store back all unsaved data into calendar object
1688 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1678 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1689 if ( mViewManager->currentView() ) 1679 if ( mViewManager->currentView() )
1690 mViewManager->currentView()->flushView(); 1680 mViewManager->currentView()->flushView();
1691 1681
1692 //mStorage->setFileName( filename ); 1682
1693 1683 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1694 mStorage->setSaveFormat( new ICalFormat() ); 1684 mStorage->setSaveFormat( new ICalFormat() );
1695 mStorage->setFileName( filename ); 1685 mStorage->setFileName( filename );
1696 bool success; 1686 bool success;
1697 success = mStorage->save(); 1687 success = mStorage->save();
1698 if ( !success ) { 1688 if ( !success ) {
1699 return false; 1689 return false;
1700 } 1690 }
1701 1691 if ( filename == MainWindow::defaultFileName() ) {
1692 setLoadedFileVersion( lfv );
1693 watchSavedFile();
1694 }
1702 return true; 1695 return true;
1703} 1696}
1704 1697
1705void CalendarView::closeCalendar() 1698void CalendarView::closeCalendar()
1706{ 1699{
1707 1700
1708 // child windows no longer valid 1701 // child windows no longer valid
1709 emit closingDown(); 1702 emit closingDown();
1710 1703
1711 mCalendar->close(); 1704 mCalendar->close();
1712 setModified(false); 1705 setModified(false);
1713 updateView(); 1706 updateView();
1714} 1707}
1715 1708
1716void CalendarView::archiveCalendar() 1709void CalendarView::archiveCalendar()
1717{ 1710{
1718 mDialogManager->showArchiveDialog(); 1711 mDialogManager->showArchiveDialog();
1719} 1712}
1720 1713
1721 1714
1722void CalendarView::readSettings() 1715void CalendarView::readSettings()
1723{ 1716{
1724 1717
1725 1718
1726 // mViewManager->showAgendaView(); 1719 // mViewManager->showAgendaView();
1727 QString str; 1720 QString str;
1728 //qDebug("CalendarView::readSettings() "); 1721 //qDebug("CalendarView::readSettings() ");
1729 // read settings from the KConfig, supplying reasonable 1722 // read settings from the KConfig, supplying reasonable
1730 // defaults where none are to be found 1723 // defaults where none are to be found
1731 KConfig *config = KOGlobals::config(); 1724 KConfig *config = KOGlobals::config();
1732#ifndef KORG_NOSPLITTER 1725#ifndef KORG_NOSPLITTER
1733 config->setGroup("KOrganizer Geometry"); 1726 config->setGroup("KOrganizer Geometry");
1734 1727
1735 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1728 QValueList<int> sizes = config->readIntListEntry("Separator1");
1736 if (sizes.count() != 2) { 1729 if (sizes.count() != 2) {
1737 sizes << mDateNavigator->minimumSizeHint().width(); 1730 sizes << mDateNavigator->minimumSizeHint().width();
1738 sizes << 300; 1731 sizes << 300;
1739 } 1732 }
1740 mPanner->setSizes(sizes); 1733 mPanner->setSizes(sizes);
1741 1734
1742 sizes = config->readIntListEntry("Separator2"); 1735 sizes = config->readIntListEntry("Separator2");
1743 if ( ( mResourceView && sizes.count() == 4 ) || 1736 if ( ( mResourceView && sizes.count() == 4 ) ||
1744 ( !mResourceView && sizes.count() == 3 ) ) { 1737 ( !mResourceView && sizes.count() == 3 ) ) {
1745 mLeftSplitter->setSizes(sizes); 1738 mLeftSplitter->setSizes(sizes);
1746 } 1739 }
1747#endif 1740#endif
1748 globalFlagBlockAgenda = 1; 1741 globalFlagBlockAgenda = 1;
1749 mViewManager->showAgendaView(); 1742 mViewManager->showAgendaView();
1750 //mViewManager->readSettings( config ); 1743 //mViewManager->readSettings( config );
1751 mTodoList->restoreLayout(config,QString("Todo Layout")); 1744 mTodoList->restoreLayout(config,QString("Todo Layout"));
1752 readFilterSettings(config); 1745 readFilterSettings(config);
1753 config->setGroup( "Views" ); 1746 config->setGroup( "Views" );
1754 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1747 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1755 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1748 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1756 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1749 else if ( dateCount == 7 ) mNavigator->selectWeek();
1757 else mNavigator->selectDates( dateCount ); 1750 else mNavigator->selectDates( dateCount );
1758 // mViewManager->readSettings( config ); 1751 // mViewManager->readSettings( config );
1759 updateConfig(); 1752 updateConfig();
1760 globalFlagBlockAgenda = 2; 1753 globalFlagBlockAgenda = 2;
1761 mViewManager->readSettings( config ); 1754 mViewManager->readSettings( config );
1762#ifdef DESKTOP_VERSION 1755#ifdef DESKTOP_VERSION
1763 config->setGroup("WidgetLayout"); 1756 config->setGroup("WidgetLayout");
1764 QStringList list; 1757 QStringList list;
1765 list = config->readListEntry("MainLayout"); 1758 list = config->readListEntry("MainLayout");
1766 int x,y,w,h; 1759 int x,y,w,h;
1767 if ( ! list.isEmpty() ) { 1760 if ( ! list.isEmpty() ) {
1768 x = list[0].toInt(); 1761 x = list[0].toInt();
1769 y = list[1].toInt(); 1762 y = list[1].toInt();
1770 w = list[2].toInt(); 1763 w = list[2].toInt();
1771 h = list[3].toInt(); 1764 h = list[3].toInt();
1772 topLevelWidget()->setGeometry(x,y,w,h); 1765 topLevelWidget()->setGeometry(x,y,w,h);
1773 1766
1774 } else { 1767 } else {
1775 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1768 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1776 } 1769 }
1777 list = config->readListEntry("EditEventLayout"); 1770 list = config->readListEntry("EditEventLayout");
1778 if ( ! list.isEmpty() ) { 1771 if ( ! list.isEmpty() ) {
1779 x = list[0].toInt(); 1772 x = list[0].toInt();
1780 y = list[1].toInt(); 1773 y = list[1].toInt();
1781 w = list[2].toInt(); 1774 w = list[2].toInt();
1782 h = list[3].toInt(); 1775 h = list[3].toInt();
1783 mEventEditor->setGeometry(x,y,w,h); 1776 mEventEditor->setGeometry(x,y,w,h);
1784 1777
1785 } 1778 }
1786 list = config->readListEntry("EditTodoLayout"); 1779 list = config->readListEntry("EditTodoLayout");
1787 if ( ! list.isEmpty() ) { 1780 if ( ! list.isEmpty() ) {
1788 x = list[0].toInt(); 1781 x = list[0].toInt();
1789 y = list[1].toInt(); 1782 y = list[1].toInt();
1790 w = list[2].toInt(); 1783 w = list[2].toInt();
1791 h = list[3].toInt(); 1784 h = list[3].toInt();
1792 mTodoEditor->setGeometry(x,y,w,h); 1785 mTodoEditor->setGeometry(x,y,w,h);
1793 1786
1794 } 1787 }
1795 list = config->readListEntry("ViewerLayout"); 1788 list = config->readListEntry("ViewerLayout");
1796 if ( ! list.isEmpty() ) { 1789 if ( ! list.isEmpty() ) {
1797 x = list[0].toInt(); 1790 x = list[0].toInt();
1798 y = list[1].toInt(); 1791 y = list[1].toInt();
1799 w = list[2].toInt(); 1792 w = list[2].toInt();
1800 h = list[3].toInt(); 1793 h = list[3].toInt();
1801 getEventViewerDialog()->setGeometry(x,y,w,h); 1794 getEventViewerDialog()->setGeometry(x,y,w,h);
1802 } 1795 }
1803#endif 1796#endif
1804 1797
1805} 1798}
1806 1799
1807 1800
1808void CalendarView::writeSettings() 1801void CalendarView::writeSettings()
1809{ 1802{
1810 // kdDebug() << "CalendarView::writeSettings" << endl; 1803 // kdDebug() << "CalendarView::writeSettings" << endl;
1811 1804
1812 KConfig *config = KOGlobals::config(); 1805 KConfig *config = KOGlobals::config();
1813 1806
1814#ifndef KORG_NOSPLITTER 1807#ifndef KORG_NOSPLITTER
1815 config->setGroup("KOrganizer Geometry"); 1808 config->setGroup("KOrganizer Geometry");
1816 1809
1817 QValueList<int> list = mPanner->sizes(); 1810 QValueList<int> list = mPanner->sizes();
1818 config->writeEntry("Separator1",list); 1811 config->writeEntry("Separator1",list);
1819 1812
1820 list = mLeftSplitter->sizes(); 1813 list = mLeftSplitter->sizes();
1821 config->writeEntry("Separator2",list); 1814 config->writeEntry("Separator2",list);
1822#endif 1815#endif
1823 1816
1824 mViewManager->writeSettings( config ); 1817 mViewManager->writeSettings( config );
1825 mTodoList->saveLayout(config,QString("Todo Layout")); 1818 mTodoList->saveLayout(config,QString("Todo Layout"));
1826 mDialogManager->writeSettings( config ); 1819 mDialogManager->writeSettings( config );
1827 //KOPrefs::instance()->usrWriteConfig(); 1820 //KOPrefs::instance()->usrWriteConfig();
1828 KOPrefs::instance()->writeConfig(); 1821 KOPrefs::instance()->writeConfig();
1829 1822
1830 writeFilterSettings(config); 1823 writeFilterSettings(config);
1831 1824
1832 config->setGroup( "Views" ); 1825 config->setGroup( "Views" );
1833 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1826 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1834 1827
1835#ifdef DESKTOP_VERSION 1828#ifdef DESKTOP_VERSION
1836 config->setGroup("WidgetLayout"); 1829 config->setGroup("WidgetLayout");
1837 QStringList list ;//= config->readListEntry("MainLayout"); 1830 QStringList list ;//= config->readListEntry("MainLayout");
1838 int x,y,w,h; 1831 int x,y,w,h;
1839 QWidget* wid; 1832 QWidget* wid;
1840 wid = topLevelWidget(); 1833 wid = topLevelWidget();
1841 x = wid->geometry().x(); 1834 x = wid->geometry().x();
1842 y = wid->geometry().y(); 1835 y = wid->geometry().y();
1843 w = wid->width(); 1836 w = wid->width();
1844 h = wid->height(); 1837 h = wid->height();
1845 list.clear(); 1838 list.clear();
1846 list << QString::number( x ); 1839 list << QString::number( x );
1847 list << QString::number( y ); 1840 list << QString::number( y );
1848 list << QString::number( w ); 1841 list << QString::number( w );
1849 list << QString::number( h ); 1842 list << QString::number( h );
1850 config->writeEntry("MainLayout",list ); 1843 config->writeEntry("MainLayout",list );
1851 1844
1852 wid = mEventEditor; 1845 wid = mEventEditor;
1853 x = wid->geometry().x(); 1846 x = wid->geometry().x();
1854 y = wid->geometry().y(); 1847 y = wid->geometry().y();
1855 w = wid->width(); 1848 w = wid->width();
1856 h = wid->height(); 1849 h = wid->height();
1857 list.clear(); 1850 list.clear();
1858 list << QString::number( x ); 1851 list << QString::number( x );
1859 list << QString::number( y ); 1852 list << QString::number( y );
1860 list << QString::number( w ); 1853 list << QString::number( w );
1861 list << QString::number( h ); 1854 list << QString::number( h );
1862 config->writeEntry("EditEventLayout",list ); 1855 config->writeEntry("EditEventLayout",list );
1863 1856
1864 wid = mTodoEditor; 1857 wid = mTodoEditor;
1865 x = wid->geometry().x(); 1858 x = wid->geometry().x();
1866 y = wid->geometry().y(); 1859 y = wid->geometry().y();
1867 w = wid->width(); 1860 w = wid->width();
1868 h = wid->height(); 1861 h = wid->height();
1869 list.clear(); 1862 list.clear();
1870 list << QString::number( x ); 1863 list << QString::number( x );
1871 list << QString::number( y ); 1864 list << QString::number( y );
1872 list << QString::number( w ); 1865 list << QString::number( w );
1873 list << QString::number( h ); 1866 list << QString::number( h );
1874 config->writeEntry("EditTodoLayout",list ); 1867 config->writeEntry("EditTodoLayout",list );
1875 wid = getEventViewerDialog(); 1868 wid = getEventViewerDialog();
1876 x = wid->geometry().x(); 1869 x = wid->geometry().x();
1877 y = wid->geometry().y(); 1870 y = wid->geometry().y();
1878 w = wid->width(); 1871 w = wid->width();
1879 h = wid->height(); 1872 h = wid->height();
1880 list.clear(); 1873 list.clear();
1881 list << QString::number( x ); 1874 list << QString::number( x );
1882 list << QString::number( y ); 1875 list << QString::number( y );
1883 list << QString::number( w ); 1876 list << QString::number( w );
1884 list << QString::number( h ); 1877 list << QString::number( h );
1885 config->writeEntry("ViewerLayout",list ); 1878 config->writeEntry("ViewerLayout",list );
1886 wid = mDialogManager->getSearchDialog(); 1879 wid = mDialogManager->getSearchDialog();
1887 if ( wid ) { 1880 if ( wid ) {
1888 x = wid->geometry().x(); 1881 x = wid->geometry().x();
1889 y = wid->geometry().y(); 1882 y = wid->geometry().y();
1890 w = wid->width(); 1883 w = wid->width();
1891 h = wid->height(); 1884 h = wid->height();
1892 list.clear(); 1885 list.clear();
1893 list << QString::number( x ); 1886 list << QString::number( x );
1894 list << QString::number( y ); 1887 list << QString::number( y );
1895 list << QString::number( w ); 1888 list << QString::number( w );
1896 list << QString::number( h ); 1889 list << QString::number( h );
1897 config->writeEntry("SearchLayout",list ); 1890 config->writeEntry("SearchLayout",list );
1898 } 1891 }
1899#endif 1892#endif
1900 1893
1901 1894
1902 config->sync(); 1895 config->sync();
1903} 1896}
1904 1897
1905void CalendarView::readFilterSettings(KConfig *config) 1898void CalendarView::readFilterSettings(KConfig *config)
1906{ 1899{
1907 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1900 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1908 1901
1909 mFilters.clear(); 1902 mFilters.clear();
1910 1903
1911 config->setGroup("General"); 1904 config->setGroup("General");
1912 QStringList filterList = config->readListEntry("CalendarFilters"); 1905 QStringList filterList = config->readListEntry("CalendarFilters");
1913 1906
1914 QStringList::ConstIterator it = filterList.begin(); 1907 QStringList::ConstIterator it = filterList.begin();
1915 QStringList::ConstIterator end = filterList.end(); 1908 QStringList::ConstIterator end = filterList.end();
1916 while(it != end) { 1909 while(it != end) {
1917 // kdDebug() << " filter: " << (*it) << endl; 1910 // kdDebug() << " filter: " << (*it) << endl;
1918 1911
1919 CalFilter *filter; 1912 CalFilter *filter;
1920 filter = new CalFilter(*it); 1913 filter = new CalFilter(*it);
1921 config->setGroup("Filter_" + (*it)); 1914 config->setGroup("Filter_" + (*it));
1922 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1915 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1923 filter->setCriteria(config->readNumEntry("Criteria",0)); 1916 filter->setCriteria(config->readNumEntry("Criteria",0));
1924 filter->setCategoryList(config->readListEntry("CategoryList")); 1917 filter->setCategoryList(config->readListEntry("CategoryList"));
1925 mFilters.append(filter); 1918 mFilters.append(filter);
1926 1919
1927 ++it; 1920 ++it;
1928 } 1921 }
1929 1922
1930 if (mFilters.count() == 0) { 1923 if (mFilters.count() == 0) {
1931 CalFilter *filter = new CalFilter(i18n("Default")); 1924 CalFilter *filter = new CalFilter(i18n("Default"));
1932 mFilters.append(filter); 1925 mFilters.append(filter);
1933 } 1926 }
1934 mFilterView->updateFilters(); 1927 mFilterView->updateFilters();
1935 config->setGroup("FilterView"); 1928 config->setGroup("FilterView");
1936 1929
1937 mFilterView->blockSignals(true); 1930 mFilterView->blockSignals(true);
1938 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1931 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1939 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1932 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1940 mFilterView->blockSignals(false); 1933 mFilterView->blockSignals(false);
1941 // We do it manually to avoid it being done twice by the above calls 1934 // We do it manually to avoid it being done twice by the above calls
1942 updateFilter(); 1935 updateFilter();
1943} 1936}
1944 1937
1945void CalendarView::writeFilterSettings(KConfig *config) 1938void CalendarView::writeFilterSettings(KConfig *config)
1946{ 1939{
1947 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1940 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1948 1941
1949 QStringList filterList; 1942 QStringList filterList;
1950 1943
1951 CalFilter *filter = mFilters.first(); 1944 CalFilter *filter = mFilters.first();
1952 while(filter) { 1945 while(filter) {
1953 // kdDebug() << " fn: " << filter->name() << endl; 1946 // kdDebug() << " fn: " << filter->name() << endl;
1954 filterList << filter->name(); 1947 filterList << filter->name();
1955 config->setGroup("Filter_" + filter->name()); 1948 config->setGroup("Filter_" + filter->name());
1956 config->writeEntry("Criteria",filter->criteria()); 1949 config->writeEntry("Criteria",filter->criteria());
1957 config->writeEntry("CategoryList",filter->categoryList()); 1950 config->writeEntry("CategoryList",filter->categoryList());
1958 filter = mFilters.next(); 1951 filter = mFilters.next();
1959 } 1952 }
1960 config->setGroup("General"); 1953 config->setGroup("General");
1961 config->writeEntry("CalendarFilters",filterList); 1954 config->writeEntry("CalendarFilters",filterList);
1962 1955
1963 config->setGroup("FilterView"); 1956 config->setGroup("FilterView");
1964 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1957 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1965 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1958 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1966} 1959}
1967 1960
1968 1961
1969void CalendarView::goToday() 1962void CalendarView::goToday()
1970{ 1963{
1971 mNavigator->selectToday(); 1964 mNavigator->selectToday();
1972} 1965}
1973 1966
1974void CalendarView::goNext() 1967void CalendarView::goNext()
1975{ 1968{
1976 mNavigator->selectNext(); 1969 mNavigator->selectNext();
1977} 1970}
1978 1971
1979void CalendarView::goPrevious() 1972void CalendarView::goPrevious()
1980{ 1973{
1981 mNavigator->selectPrevious(); 1974 mNavigator->selectPrevious();
1982} 1975}
1983void CalendarView::goNextMonth() 1976void CalendarView::goNextMonth()
1984{ 1977{
1985 mNavigator->selectNextMonth(); 1978 mNavigator->selectNextMonth();
1986} 1979}
1987 1980
1988void CalendarView::goPreviousMonth() 1981void CalendarView::goPreviousMonth()
1989{ 1982{
1990 mNavigator->selectPreviousMonth(); 1983 mNavigator->selectPreviousMonth();
1991} 1984}
1992void CalendarView::writeLocale() 1985void CalendarView::writeLocale()
1993{ 1986{
1994 //KPimGlobalPrefs::instance()->setGlobalConfig(); 1987 //KPimGlobalPrefs::instance()->setGlobalConfig();
1995#if 0 1988#if 0
1996 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 1989 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1997 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 1990 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1998 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 1991 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
1999 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 1992 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2000 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1993 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2001 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 1994 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2002 dummy = KOPrefs::instance()->mUserDateFormatShort; 1995 dummy = KOPrefs::instance()->mUserDateFormatShort;
2003 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 1996 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2004 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 1997 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2005 KOPrefs::instance()->mDaylightsavingStart, 1998 KOPrefs::instance()->mDaylightsavingStart,
2006 KOPrefs::instance()->mDaylightsavingEnd ); 1999 KOPrefs::instance()->mDaylightsavingEnd );
2007 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 2000 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
2008#endif 2001#endif
2009} 2002}
2010void CalendarView::updateConfig() 2003void CalendarView::updateConfig()
2011{ 2004{
2012 writeLocale(); 2005 writeLocale();
2013 if ( KOPrefs::instance()->mUseAppColors ) 2006 if ( KOPrefs::instance()->mUseAppColors )
2014 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2007 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2015 emit configChanged(); 2008 emit configChanged();
2016 mTodoList->updateConfig(); 2009 mTodoList->updateConfig();
2017 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2010 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2018 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2011 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2019 // To make the "fill window" configurations work 2012 // To make the "fill window" configurations work
2020 //mViewManager->raiseCurrentView(); 2013 //mViewManager->raiseCurrentView();
2021} 2014}
2022 2015
2023 2016
2024void CalendarView::eventChanged(Event *event) 2017void CalendarView::eventChanged(Event *event)
2025{ 2018{
2026 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2019 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2027 //updateUnmanagedViews(); 2020 //updateUnmanagedViews();
2028} 2021}
2029 2022
2030void CalendarView::eventAdded(Event *event) 2023void CalendarView::eventAdded(Event *event)
2031{ 2024{
2032 changeEventDisplay(event,KOGlobals::EVENTADDED); 2025 changeEventDisplay(event,KOGlobals::EVENTADDED);
2033} 2026}
2034 2027
2035void CalendarView::eventToBeDeleted(Event *) 2028void CalendarView::eventToBeDeleted(Event *)
2036{ 2029{
2037 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2030 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2038} 2031}
2039 2032
2040void CalendarView::eventDeleted() 2033void CalendarView::eventDeleted()
2041{ 2034{
2042 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2035 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2043} 2036}
2044void CalendarView::changeTodoDisplay(Todo *which, int action) 2037void CalendarView::changeTodoDisplay(Todo *which, int action)
2045{ 2038{
2046 changeIncidenceDisplay((Incidence *)which, action); 2039 changeIncidenceDisplay((Incidence *)which, action);
2047 mDateNavigator->updateView(); //LR 2040 mDateNavigator->updateView(); //LR
2048 //mDialogManager->updateSearchDialog(); 2041 //mDialogManager->updateSearchDialog();
2049 2042
2050 if (which) { 2043 if (which) {
2051 mViewManager->updateWNview(); 2044 mViewManager->updateWNview();
2052 //mTodoList->updateView(); 2045 //mTodoList->updateView();
2053 } 2046 }
2054 2047
2055} 2048}
2056 2049
2057void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2050void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2058{ 2051{
2059 updateUnmanagedViews(); 2052 updateUnmanagedViews();
2060 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2053 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2061 if ( action == KOGlobals::EVENTDELETED ) { //delete 2054 if ( action == KOGlobals::EVENTDELETED ) { //delete
2062 mCalendar->checkAlarmForIncidence( 0, true ); 2055 mCalendar->checkAlarmForIncidence( 0, true );
2063 if ( mEventViewerDialog ) 2056 if ( mEventViewerDialog )
2064 mEventViewerDialog->hide(); 2057 mEventViewerDialog->hide();
2065 } 2058 }
2066 else 2059 else
2067 mCalendar->checkAlarmForIncidence( which , false ); 2060 mCalendar->checkAlarmForIncidence( which , false );
2068} 2061}
2069 2062
2070// most of the changeEventDisplays() right now just call the view's 2063// most of the changeEventDisplays() right now just call the view's
2071// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2064// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2072void CalendarView::changeEventDisplay(Event *which, int action) 2065void CalendarView::changeEventDisplay(Event *which, int action)
2073{ 2066{
2074 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2067 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2075 changeIncidenceDisplay((Incidence *)which, action); 2068 changeIncidenceDisplay((Incidence *)which, action);
2076 mDateNavigator->updateView(); 2069 mDateNavigator->updateView();
2077 //mDialogManager->updateSearchDialog(); 2070 //mDialogManager->updateSearchDialog();
2078 2071
2079 if (which) { 2072 if (which) {
2080 // If there is an event view visible update the display 2073 // If there is an event view visible update the display
2081 mViewManager->currentView()->changeEventDisplay(which,action); 2074 mViewManager->currentView()->changeEventDisplay(which,action);
2082 // TODO: check, if update needed 2075 // TODO: check, if update needed
2083 // if (which->getTodoStatus()) { 2076 // if (which->getTodoStatus()) {
2084 mTodoList->updateView(); 2077 mTodoList->updateView();
2085 // } 2078 // }
2086 } else { 2079 } else {
2087 mViewManager->currentView()->updateView(); 2080 mViewManager->currentView()->updateView();
2088 } 2081 }
2089} 2082}
2090 2083
2091 2084
2092void CalendarView::updateTodoViews() 2085void CalendarView::updateTodoViews()
2093{ 2086{
2094 2087
2095 mTodoList->updateView(); 2088 mTodoList->updateView();
2096 mViewManager->currentView()->updateView(); 2089 mViewManager->currentView()->updateView();
2097 2090
2098} 2091}
2099 2092
2100 2093
2101void CalendarView::updateView(const QDate &start, const QDate &end) 2094void CalendarView::updateView(const QDate &start, const QDate &end)
2102{ 2095{
2103 mTodoList->updateView(); 2096 mTodoList->updateView();
2104 mViewManager->updateView(start, end); 2097 mViewManager->updateView(start, end);
2105 //mDateNavigator->updateView(); 2098 //mDateNavigator->updateView();
2106} 2099}
2107 2100
2108void CalendarView::updateView() 2101void CalendarView::updateView()
2109{ 2102{
2110 DateList tmpList = mNavigator->selectedDates(); 2103 DateList tmpList = mNavigator->selectedDates();
2111 2104
2112 // We assume that the navigator only selects consecutive days. 2105 // We assume that the navigator only selects consecutive days.
2113 updateView( tmpList.first(), tmpList.last() ); 2106 updateView( tmpList.first(), tmpList.last() );
2114} 2107}
2115 2108
2116void CalendarView::updateUnmanagedViews() 2109void CalendarView::updateUnmanagedViews()
2117{ 2110{
2118 mDateNavigator->updateDayMatrix(); 2111 mDateNavigator->updateDayMatrix();
2119} 2112}
2120 2113
2121int CalendarView::msgItemDelete() 2114int CalendarView::msgItemDelete()
2122{ 2115{
2123 return KMessageBox::warningContinueCancel(this, 2116 return KMessageBox::warningContinueCancel(this,
2124 i18n("This item will be\npermanently deleted."), 2117 i18n("This item will be\npermanently deleted."),
2125 i18n("KO/Pi Confirmation"),i18n("Delete")); 2118 i18n("KO/Pi Confirmation"),i18n("Delete"));
2126} 2119}
2127 2120
2128 2121
2129void CalendarView::edit_cut() 2122void CalendarView::edit_cut()
2130{ 2123{
2131 Event *anEvent=0; 2124 Event *anEvent=0;
2132 2125
2133 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2126 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2134 2127
2135 if (mViewManager->currentView()->isEventView()) { 2128 if (mViewManager->currentView()->isEventView()) {
2136 if ( incidence && incidence->type() == "Event" ) { 2129 if ( incidence && incidence->type() == "Event" ) {
2137 anEvent = static_cast<Event *>(incidence); 2130 anEvent = static_cast<Event *>(incidence);
2138 } 2131 }
2139 } 2132 }
2140 2133
2141 if (!anEvent) { 2134 if (!anEvent) {
2142 KNotifyClient::beep(); 2135 KNotifyClient::beep();
2143 return; 2136 return;
2144 } 2137 }
2145 DndFactory factory( mCalendar ); 2138 DndFactory factory( mCalendar );
2146 factory.cutEvent(anEvent); 2139 factory.cutEvent(anEvent);
2147 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2140 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2148} 2141}
2149 2142
2150void CalendarView::edit_copy() 2143void CalendarView::edit_copy()
2151{ 2144{
2152 Event *anEvent=0; 2145 Event *anEvent=0;
2153 2146
2154 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2147 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2155 2148
2156 if (mViewManager->currentView()->isEventView()) { 2149 if (mViewManager->currentView()->isEventView()) {
2157 if ( incidence && incidence->type() == "Event" ) { 2150 if ( incidence && incidence->type() == "Event" ) {
2158 anEvent = static_cast<Event *>(incidence); 2151 anEvent = static_cast<Event *>(incidence);
2159 } 2152 }
2160 } 2153 }
2161 2154
2162 if (!anEvent) { 2155 if (!anEvent) {
2163 KNotifyClient::beep(); 2156 KNotifyClient::beep();
2164 return; 2157 return;
2165 } 2158 }
2166 DndFactory factory( mCalendar ); 2159 DndFactory factory( mCalendar );
2167 factory.copyEvent(anEvent); 2160 factory.copyEvent(anEvent);
2168} 2161}
2169 2162
2170void CalendarView::edit_paste() 2163void CalendarView::edit_paste()
2171{ 2164{
2172 QDate date = mNavigator->selectedDates().first(); 2165 QDate date = mNavigator->selectedDates().first();
2173 2166
2174 DndFactory factory( mCalendar ); 2167 DndFactory factory( mCalendar );
2175 Event *pastedEvent = factory.pasteEvent( date ); 2168 Event *pastedEvent = factory.pasteEvent( date );
2176 2169
2177 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2170 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2178} 2171}
2179 2172
2180void CalendarView::edit_options() 2173void CalendarView::edit_options()
2181{ 2174{
2182 mDialogManager->showOptionsDialog(); 2175 mDialogManager->showOptionsDialog();
2183 //writeSettings(); 2176 //writeSettings();
2184} 2177}
2185void CalendarView::edit_sync_options()
2186{
2187 // DELETE
2188
2189}
2190 2178
2191void CalendarView::slotSelectPickerDate( QDate d) 2179void CalendarView::slotSelectPickerDate( QDate d)
2192{ 2180{
2193 mDateFrame->hide(); 2181 mDateFrame->hide();
2194 if ( mDatePickerMode == 1 ) { 2182 if ( mDatePickerMode == 1 ) {
2195 mNavigator->slotDaySelect( d ); 2183 mNavigator->slotDaySelect( d );
2196 } else if ( mDatePickerMode == 2 ) { 2184 } else if ( mDatePickerMode == 2 ) {
2197 if ( mMoveIncidence->type() == "Todo" ) { 2185 if ( mMoveIncidence->type() == "Todo" ) {
2198 Todo * to = (Todo *) mMoveIncidence; 2186 Todo * to = (Todo *) mMoveIncidence;
2199 QTime tim; 2187 QTime tim;
2200 if ( to->hasDueDate() ) 2188 if ( to->hasDueDate() )
2201 tim = to->dtDue().time(); 2189 tim = to->dtDue().time();
2202 else { 2190 else {
2203 tim = QTime ( 0,0,0 ); 2191 tim = QTime ( 0,0,0 );
2204 to->setFloats( true ); 2192 to->setFloats( true );
2205 to->setHasDueDate( true ); 2193 to->setHasDueDate( true );
2206 } 2194 }
2207 QDateTime dt ( d,tim ); 2195 QDateTime dt ( d,tim );
2208 to->setDtDue( dt ); 2196 to->setDtDue( dt );
2209 todoChanged( to ); 2197 todoChanged( to );
2210 } else { 2198 } else {
2211 QTime tim = mMoveIncidence->dtStart().time(); 2199 QTime tim = mMoveIncidence->dtStart().time();
2212 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2200 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2213 QDateTime dt ( d,tim ); 2201 QDateTime dt ( d,tim );
2214 mMoveIncidence->setDtStart( dt ); 2202 mMoveIncidence->setDtStart( dt );
2215 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2203 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2216 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2204 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2217 } 2205 }
2218 2206
2219 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2207 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2220 } 2208 }
2221} 2209}
2222 2210
2223void CalendarView::removeCategories() 2211void CalendarView::removeCategories()
2224{ 2212{
2225 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2213 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2226 QStringList catList = KOPrefs::instance()->mCustomCategories; 2214 QStringList catList = KOPrefs::instance()->mCustomCategories;
2227 QStringList catIncList; 2215 QStringList catIncList;
2228 QStringList newCatList; 2216 QStringList newCatList;
2229 Incidence* inc = incList.first(); 2217 Incidence* inc = incList.first();
2230 int i; 2218 int i;
2231 int count = 0; 2219 int count = 0;
2232 while ( inc ) { 2220 while ( inc ) {
2233 newCatList.clear(); 2221 newCatList.clear();
2234 catIncList = inc->categories() ; 2222 catIncList = inc->categories() ;
2235 for( i = 0; i< catIncList.count(); ++i ) { 2223 for( i = 0; i< catIncList.count(); ++i ) {
2236 if ( catList.contains (catIncList[i])) 2224 if ( catList.contains (catIncList[i]))
2237 newCatList.append( catIncList[i] ); 2225 newCatList.append( catIncList[i] );
2238 } 2226 }
2239 newCatList.sort(); 2227 newCatList.sort();
2240 inc->setCategories( newCatList.join(",") ); 2228 inc->setCategories( newCatList.join(",") );
2241 inc = incList.next(); 2229 inc = incList.next();
2242 } 2230 }
2243} 2231}
2244 2232
2245int CalendarView::addCategories() 2233int CalendarView::addCategories()
2246{ 2234{
2247 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2235 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2248 QStringList catList = KOPrefs::instance()->mCustomCategories; 2236 QStringList catList = KOPrefs::instance()->mCustomCategories;
2249 QStringList catIncList; 2237 QStringList catIncList;
2250 Incidence* inc = incList.first(); 2238 Incidence* inc = incList.first();
2251 int i; 2239 int i;
2252 int count = 0; 2240 int count = 0;
2253 while ( inc ) { 2241 while ( inc ) {
2254 catIncList = inc->categories() ; 2242 catIncList = inc->categories() ;
2255 for( i = 0; i< catIncList.count(); ++i ) { 2243 for( i = 0; i< catIncList.count(); ++i ) {
2256 if ( !catList.contains (catIncList[i])) { 2244 if ( !catList.contains (catIncList[i])) {
2257 catList.append( catIncList[i] ); 2245 catList.append( catIncList[i] );
2258 //qDebug("add cat %s ", catIncList[i].latin1()); 2246 //qDebug("add cat %s ", catIncList[i].latin1());
2259 ++count; 2247 ++count;
2260 } 2248 }
2261 } 2249 }
2262 inc = incList.next(); 2250 inc = incList.next();
2263 } 2251 }
2264 catList.sort(); 2252 catList.sort();
2265 KOPrefs::instance()->mCustomCategories = catList; 2253 KOPrefs::instance()->mCustomCategories = catList;
2266 return count; 2254 return count;
2267} 2255}
2268 2256
2269void CalendarView::manageCategories() 2257void CalendarView::manageCategories()
2270{ 2258{
2271 KOCatPrefs* cp = new KOCatPrefs(); 2259 KOCatPrefs* cp = new KOCatPrefs();
2272 cp->show(); 2260 cp->show();
2273 int w =cp->sizeHint().width() ; 2261 int w =cp->sizeHint().width() ;
2274 int h = cp->sizeHint().height() ; 2262 int h = cp->sizeHint().height() ;
2275 int dw = QApplication::desktop()->width(); 2263 int dw = QApplication::desktop()->width();
2276 int dh = QApplication::desktop()->height(); 2264 int dh = QApplication::desktop()->height();
2277 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2265 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2278 if ( !cp->exec() ) { 2266 if ( !cp->exec() ) {
2279 delete cp; 2267 delete cp;
2280 return; 2268 return;
2281 } 2269 }
2282 int count = 0; 2270 int count = 0;
2283 if ( cp->addCat() ) { 2271 if ( cp->addCat() ) {
2284 count = addCategories(); 2272 count = addCategories();
2285 if ( count ) { 2273 if ( count ) {
2286 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2274 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2287 writeSettings(); 2275 writeSettings();
2288 } 2276 }
2289 } else { 2277 } else {
2290 removeCategories(); 2278 removeCategories();
2291 updateView(); 2279 updateView();
2292 } 2280 }
2293 delete cp; 2281 delete cp;
2294} 2282}
2295 2283
2296void CalendarView::beamIncidence(Incidence * Inc) 2284void CalendarView::beamIncidence(Incidence * Inc)
2297{ 2285{
2298 QPtrList<Incidence> delSel ; 2286 QPtrList<Incidence> delSel ;
2299 delSel.append(Inc); 2287 delSel.append(Inc);
2300 beamIncidenceList( delSel ); 2288 beamIncidenceList( delSel );
2301} 2289}
2302void CalendarView::beamCalendar() 2290void CalendarView::beamCalendar()
2303{ 2291{
2304 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2292 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2305 //qDebug("beamCalendar() "); 2293 //qDebug("beamCalendar() ");
2306 beamIncidenceList( delSel ); 2294 beamIncidenceList( delSel );
2307} 2295}
2308void CalendarView::beamFilteredCalendar() 2296void CalendarView::beamFilteredCalendar()
2309{ 2297{
2310 QPtrList<Incidence> delSel = mCalendar->incidences(); 2298 QPtrList<Incidence> delSel = mCalendar->incidences();
2311 //qDebug("beamFilteredCalendar() "); 2299 //qDebug("beamFilteredCalendar() ");
2312 beamIncidenceList( delSel ); 2300 beamIncidenceList( delSel );
2313} 2301}
2314void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2302void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2315{ 2303{
2316 if ( beamDialog->exec () == QDialog::Rejected ) 2304 if ( beamDialog->exec () == QDialog::Rejected )
2317 return; 2305 return;
2318 2306
2319 QString fn = "/tmp/kopibeamfile"; 2307 QString fn = "/tmp/kopibeamfile";
2320 QString mes; 2308 QString mes;
2321 bool createbup = true; 2309 bool createbup = true;
2322 if ( createbup ) { 2310 if ( createbup ) {
2323 QString description = "\n"; 2311 QString description = "\n";
2324 CalendarLocal* cal = new CalendarLocal(); 2312 CalendarLocal* cal = new CalendarLocal();
2325 if ( beamDialog->beamLocal() ) 2313 if ( beamDialog->beamLocal() )
2326 cal->setLocalTime(); 2314 cal->setLocalTime();
2327 else 2315 else
2328 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2316 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2329 Incidence *incidence = delSel.first(); 2317 Incidence *incidence = delSel.first();
2330 bool addText = false; 2318 bool addText = false;
2331 if ( delSel.count() < 10 ) 2319 if ( delSel.count() < 10 )
2332 addText = true; 2320 addText = true;
2333 else { 2321 else {
2334 description.sprintf(i18n(" %d items?"),delSel.count() ); 2322 description.sprintf(i18n(" %d items?"),delSel.count() );
2335 } 2323 }
2336 while ( incidence ) { 2324 while ( incidence ) {
2337 Incidence *in = incidence->clone(); 2325 Incidence *in = incidence->clone();
2338 if ( addText ) 2326 if ( addText )
2339 description += in->summary() + "\n"; 2327 description += in->summary() + "\n";
2340 cal->addIncidence( in ); 2328 cal->addIncidence( in );
2341 incidence = delSel.next(); 2329 incidence = delSel.next();
2342 } 2330 }
2343 if ( beamDialog->beamVcal() ) { 2331 if ( beamDialog->beamVcal() ) {
2344 fn += ".vcs"; 2332 fn += ".vcs";
2345 FileStorage storage( cal, fn, new VCalFormat ); 2333 FileStorage storage( cal, fn, new VCalFormat );
2346 storage.save(); 2334 storage.save();
2347 } else { 2335 } else {
2348 fn += ".ics"; 2336 fn += ".ics";
2349 FileStorage storage( cal, fn, new ICalFormat( ) ); 2337 FileStorage storage( cal, fn, new ICalFormat( ) );
2350 storage.save(); 2338 storage.save();
2351 } 2339 }
2352 delete cal; 2340 delete cal;
2353 mes = i18n("KO/Pi: Ready for beaming"); 2341 mes = i18n("KO/Pi: Ready for beaming");
2354 setCaption(mes); 2342 setCaption(mes);
2355 2343
2356#ifndef DESKTOP_VERSION 2344#ifndef DESKTOP_VERSION
2357 Ir *ir = new Ir( this ); 2345 Ir *ir = new Ir( this );
2358 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2346 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2359 ir->send( fn, description, "text/x-vCalendar" ); 2347 ir->send( fn, description, "text/x-vCalendar" );
2360#endif 2348#endif
2361 } 2349 }
2362} 2350}
2363void CalendarView::beamDone( Ir *ir ) 2351void CalendarView::beamDone( Ir *ir )
2364{ 2352{
2365#ifndef DESKTOP_VERSION 2353#ifndef DESKTOP_VERSION
2366 delete ir; 2354 delete ir;
2367#endif 2355#endif
2368} 2356}
2369 2357
2370void CalendarView::moveIncidence(Incidence * inc ) 2358void CalendarView::moveIncidence(Incidence * inc )
2371{ 2359{
2372 if ( !inc ) return; 2360 if ( !inc ) return;
2373 // qDebug("showDatePickerForIncidence( ) "); 2361 // qDebug("showDatePickerForIncidence( ) ");
2374 if ( mDateFrame->isVisible() ) 2362 if ( mDateFrame->isVisible() )
2375 mDateFrame->hide(); 2363 mDateFrame->hide();
2376 else { 2364 else {
2377 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2365 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2378 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2366 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2379 int dw = QApplication::desktop()->width(); 2367 int dw = QApplication::desktop()->width();
2380 int dh = QApplication::desktop()->height(); 2368 int dh = QApplication::desktop()->height();
2381 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2369 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2382 mDateFrame->show(); 2370 mDateFrame->show();
2383 } 2371 }
2384 mDatePickerMode = 2; 2372 mDatePickerMode = 2;
2385 mMoveIncidence = inc ; 2373 mMoveIncidence = inc ;
2386 QDate da; 2374 QDate da;
2387 if ( mMoveIncidence->type() == "Todo" ) { 2375 if ( mMoveIncidence->type() == "Todo" ) {
2388 Todo * to = (Todo *) mMoveIncidence; 2376 Todo * to = (Todo *) mMoveIncidence;
2389 if ( to->hasDueDate() ) 2377 if ( to->hasDueDate() )
2390 da = to->dtDue().date(); 2378 da = to->dtDue().date();
2391 else 2379 else
2392 da = QDate::currentDate(); 2380 da = QDate::currentDate();
2393 } else { 2381 } else {
2394 da = mMoveIncidence->dtStart().date(); 2382 da = mMoveIncidence->dtStart().date();
2395 } 2383 }
2396 mDatePicker->setDate( da ); 2384 mDatePicker->setDate( da );
2397} 2385}
2398void CalendarView::showDatePicker( ) 2386void CalendarView::showDatePicker( )
2399{ 2387{
2400 //qDebug("CalendarView::showDatePicker( ) "); 2388 //qDebug("CalendarView::showDatePicker( ) ");
2401 if ( mDateFrame->isVisible() ) 2389 if ( mDateFrame->isVisible() )
2402 mDateFrame->hide(); 2390 mDateFrame->hide();
2403 else { 2391 else {
2404 int w =mDatePicker->sizeHint().width() ; 2392 int w =mDatePicker->sizeHint().width() ;
2405 int h = mDatePicker->sizeHint().height() ; 2393 int h = mDatePicker->sizeHint().height() ;
2406 int dw = QApplication::desktop()->width(); 2394 int dw = QApplication::desktop()->width();
2407 int dh = QApplication::desktop()->height(); 2395 int dh = QApplication::desktop()->height();
2408 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2396 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2409 mDateFrame->show(); 2397 mDateFrame->show();
2410 } 2398 }
2411 mDatePickerMode = 1; 2399 mDatePickerMode = 1;
2412 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2400 mDatePicker->setDate( mNavigator->selectedDates().first() );
2413} 2401}
2414 2402
2415void CalendarView::showEventEditor() 2403void CalendarView::showEventEditor()
2416{ 2404{
2417#ifdef DESKTOP_VERSION 2405#ifdef DESKTOP_VERSION
2418 mEventEditor->show(); 2406 mEventEditor->show();
2419#else 2407#else
2420 mEventEditor->showMaximized(); 2408 mEventEditor->showMaximized();
2421#endif 2409#endif
2422} 2410}
2423void CalendarView::showTodoEditor() 2411void CalendarView::showTodoEditor()
2424{ 2412{
2425#ifdef DESKTOP_VERSION 2413#ifdef DESKTOP_VERSION
2426 mTodoEditor->show(); 2414 mTodoEditor->show();
2427#else 2415#else
2428 mTodoEditor->showMaximized(); 2416 mTodoEditor->showMaximized();
2429#endif 2417#endif
2430} 2418}
2431 2419
2432void CalendarView::cloneIncidence() 2420void CalendarView::cloneIncidence()
2433{ 2421{
2434 Incidence *incidence = currentSelection(); 2422 Incidence *incidence = currentSelection();
2435 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2423 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2436 if ( incidence ) { 2424 if ( incidence ) {
2437 cloneIncidence(incidence); 2425 cloneIncidence(incidence);
2438 } 2426 }
2439} 2427}
2440void CalendarView::moveIncidence() 2428void CalendarView::moveIncidence()
2441{ 2429{
2442 Incidence *incidence = currentSelection(); 2430 Incidence *incidence = currentSelection();
2443 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2431 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2444 if ( incidence ) { 2432 if ( incidence ) {
2445 moveIncidence(incidence); 2433 moveIncidence(incidence);
2446 } 2434 }
2447} 2435}
2448void CalendarView::beamIncidence() 2436void CalendarView::beamIncidence()
2449{ 2437{
2450 Incidence *incidence = currentSelection(); 2438 Incidence *incidence = currentSelection();
2451 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2439 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2452 if ( incidence ) { 2440 if ( incidence ) {
2453 beamIncidence(incidence); 2441 beamIncidence(incidence);
2454 } 2442 }
2455} 2443}
2456void CalendarView::toggleCancelIncidence() 2444void CalendarView::toggleCancelIncidence()
2457{ 2445{
2458 Incidence *incidence = currentSelection(); 2446 Incidence *incidence = currentSelection();
2459 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2447 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2460 if ( incidence ) { 2448 if ( incidence ) {
2461 cancelIncidence(incidence); 2449 cancelIncidence(incidence);
2462 } 2450 }
2463} 2451}
2464 2452
2465 2453
2466void CalendarView::cancelIncidence(Incidence * inc ) 2454void CalendarView::cancelIncidence(Incidence * inc )
2467{ 2455{
2468 inc->setCancelled( ! inc->cancelled() ); 2456 inc->setCancelled( ! inc->cancelled() );
2469 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2457 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2470 updateView(); 2458 updateView();
2471} 2459}
2472void CalendarView::cloneIncidence(Incidence * orgInc ) 2460void CalendarView::cloneIncidence(Incidence * orgInc )
2473{ 2461{
2474 Incidence * newInc = orgInc->clone(); 2462 Incidence * newInc = orgInc->clone();
2475 newInc->recreate(); 2463 newInc->recreate();
2476 2464
2477 if ( newInc->type() == "Todo" ) { 2465 if ( newInc->type() == "Todo" ) {
2478 Todo* t = (Todo*) newInc; 2466 Todo* t = (Todo*) newInc;
2479 mTodoEditor->editTodo( t ); 2467 mTodoEditor->editTodo( t );
2480 showTodoEditor(); 2468 showTodoEditor();
2481 if ( mTodoEditor->exec() ) { 2469 if ( mTodoEditor->exec() ) {
2482 mCalendar->addTodo( t ); 2470 mCalendar->addTodo( t );
2483 updateView(); 2471 updateView();
2484 } else { 2472 } else {
2485 delete t; 2473 delete t;
2486 } 2474 }
2487 } 2475 }
2488 else { 2476 else {
2489 Event* e = (Event*) newInc; 2477 Event* e = (Event*) newInc;
2490 mEventEditor->editEvent( e ); 2478 mEventEditor->editEvent( e );
2491 showEventEditor(); 2479 showEventEditor();
2492 if ( mEventEditor->exec() ) { 2480 if ( mEventEditor->exec() ) {
2493 mCalendar->addEvent( e ); 2481 mCalendar->addEvent( e );
2494 updateView(); 2482 updateView();
2495 } else { 2483 } else {
2496 delete e; 2484 delete e;
2497 } 2485 }
2498 } 2486 }
2499} 2487}
2500 2488
2501void CalendarView::newEvent() 2489void CalendarView::newEvent()
2502{ 2490{
2503 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2491 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2504 KOAgendaView *aView = mViewManager->agendaView(); 2492 KOAgendaView *aView = mViewManager->agendaView();
2505 if (aView) { 2493 if (aView) {
2506 if (aView->selectionStart().isValid()) { 2494 if (aView->selectionStart().isValid()) {
2507 if (aView->selectedIsAllDay()) { 2495 if (aView->selectedIsAllDay()) {
2508 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2496 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2509 } else { 2497 } else {
2510 newEvent(aView->selectionStart(),aView->selectionEnd()); 2498 newEvent(aView->selectionStart(),aView->selectionEnd());
2511 } 2499 }
2512 return; 2500 return;
2513 } 2501 }
2514 } 2502 }
2515 2503
2516 QDate date = mNavigator->selectedDates().first(); 2504 QDate date = mNavigator->selectedDates().first();
2517 QDateTime current = QDateTime::currentDateTime(); 2505 QDateTime current = QDateTime::currentDateTime();
2518 if ( date <= current.date() ) { 2506 if ( date <= current.date() ) {
2519 int hour = current.time().hour() +1; 2507 int hour = current.time().hour() +1;
2520 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2508 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2521 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2509 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2522 } else 2510 } else
2523 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2511 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2524 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2512 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2525 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2513 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2526} 2514}
2527 2515
2528void CalendarView::newEvent(QDateTime fh) 2516void CalendarView::newEvent(QDateTime fh)
2529{ 2517{
2530 newEvent(fh, 2518 newEvent(fh,
2531 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2519 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2532} 2520}
2533 2521
2534void CalendarView::newEvent(QDate dt) 2522void CalendarView::newEvent(QDate dt)
2535{ 2523{
2536 newEvent(QDateTime(dt, QTime(0,0,0)), 2524 newEvent(QDateTime(dt, QTime(0,0,0)),
2537 QDateTime(dt, QTime(0,0,0)), true); 2525 QDateTime(dt, QTime(0,0,0)), true);
2538} 2526}
2539 2527
2540void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2528void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2541{ 2529{
2542 2530
2543 mEventEditor->newEvent(fromHint,toHint,allDay); 2531 mEventEditor->newEvent(fromHint,toHint,allDay);
2544 if ( mFilterView->filtersEnabled() ) { 2532 if ( mFilterView->filtersEnabled() ) {
2545 CalFilter *filter = mFilterView->selectedFilter(); 2533 CalFilter *filter = mFilterView->selectedFilter();
2546 if (filter && filter->showCategories()) { 2534 if (filter && filter->showCategories()) {
2547 mEventEditor->setCategories(filter->categoryList().join(",") ); 2535 mEventEditor->setCategories(filter->categoryList().join(",") );
2548 } 2536 }
2549 if ( filter ) 2537 if ( filter )
2550 mEventEditor->setSecrecy( filter->getSecrecy() ); 2538 mEventEditor->setSecrecy( filter->getSecrecy() );
2551 } 2539 }
2552 showEventEditor(); 2540 showEventEditor();
2553} 2541}
2554void CalendarView::todoAdded(Todo * t) 2542void CalendarView::todoAdded(Todo * t)
2555{ 2543{
2556 2544
2557 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2545 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2558 updateTodoViews(); 2546 updateTodoViews();
2559} 2547}
2560void CalendarView::todoChanged(Todo * t) 2548void CalendarView::todoChanged(Todo * t)
2561{ 2549{
2562 emit todoModified( t, 4 ); 2550 emit todoModified( t, 4 );
2563 // updateTodoViews(); 2551 // updateTodoViews();
2564} 2552}
2565void CalendarView::todoToBeDeleted(Todo *) 2553void CalendarView::todoToBeDeleted(Todo *)
2566{ 2554{
2567 //qDebug("todoToBeDeleted(Todo *) "); 2555 //qDebug("todoToBeDeleted(Todo *) ");
2568 updateTodoViews(); 2556 updateTodoViews();
2569} 2557}
2570void CalendarView::todoDeleted() 2558void CalendarView::todoDeleted()
2571{ 2559{
2572 //qDebug(" todoDeleted()"); 2560 //qDebug(" todoDeleted()");
2573 updateTodoViews(); 2561 updateTodoViews();
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 751b8d9..660cce7 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,606 +1,602 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 3 Copyright (c) 2000, 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef CALENDARVIEW_H 24#ifndef CALENDARVIEW_H
25#define CALENDARVIEW_H 25#define CALENDARVIEW_H
26 26
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qwidget.h> 29#include <qwidget.h>
30#include <qptrlist.h> 30#include <qptrlist.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qmap.h> 32#include <qmap.h>
33#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h> 34#include <qtopia/ir.h>
35#else 35#else
36#define Ir char 36#define Ir char
37#endif 37#endif
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/scheduler.h> 39#include <libkcal/scheduler.h>
40#include <libkcal/calendarresources.h> 40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 41#include <libkcal/resourcecalendar.h>
42 42
43#include <korganizer/calendarviewbase.h> 43#include <korganizer/calendarviewbase.h>
44 44
45#include <ksyncmanager.h> 45#include <ksyncmanager.h>
46 46
47class QWidgetStack; 47class QWidgetStack;
48class QSplitter; 48class QSplitter;
49 49
50class CalPrinter; 50class CalPrinter;
51class KOFilterView; 51class KOFilterView;
52class KOViewManager; 52class KOViewManager;
53class KODialogManager; 53class KODialogManager;
54class KOTodoView; 54class KOTodoView;
55class KDateNavigator; 55class KDateNavigator;
56class DateNavigator; 56class DateNavigator;
57class KOIncidenceEditor; 57class KOIncidenceEditor;
58class KDatePicker; 58class KDatePicker;
59class ResourceView; 59class ResourceView;
60class NavigatorBar; 60class NavigatorBar;
61class KOEventEditor; 61class KOEventEditor;
62class KOTodoEditor ; 62class KOTodoEditor ;
63class KOEventViewerDialog; 63class KOEventViewerDialog;
64class KOBeamPrefs; 64class KOBeamPrefs;
65class KSyncProfile; 65class KSyncProfile;
66class AlarmDialog; 66class AlarmDialog;
67class KCal::Attendee; 67class KCal::Attendee;
68 68
69namespace KCal { class FileStorage; } 69namespace KCal { class FileStorage; }
70 70
71using namespace KCal; 71using namespace KCal;
72 72
73/** 73/**
74 This is the main calendar widget. It provides the different vies on t he 74 This is the main calendar widget. It provides the different vies on t he
75 calendar data as well as the date navigator. It also handles synchronisation 75 calendar data as well as the date navigator. It also handles synchronisation
76 of the different views and controls the different dialogs like preferences, 76 of the different views and controls the different dialogs like preferences,
77 event editor, search dialog etc. 77 event editor, search dialog etc.
78 78
79 @short main calendar view widget 79 @short main calendar view widget
80 @author Cornelius Schumacher 80 @author Cornelius Schumacher
81*/ 81*/
82class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface 82class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
83{ 83{
84 Q_OBJECT 84 Q_OBJECT
85 public: 85 public:
86 /** 86 /**
87 Constructs a new calendar view widget. 87 Constructs a new calendar view widget.
88 88
89 @param calendar calendar document 89 @param calendar calendar document
90 @param parent parent window 90 @param parent parent window
91 @param name Qt internal widget object name 91 @param name Qt internal widget object name
92 */ 92 */
93 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 93 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
94 const char *name = 0 ); 94 const char *name = 0 );
95 CalendarView( Calendar *calendar, QWidget *parent = 0, 95 CalendarView( Calendar *calendar, QWidget *parent = 0,
96 const char *name = 0 ); 96 const char *name = 0 );
97 virtual ~CalendarView(); 97 virtual ~CalendarView();
98 98
99 Calendar *calendar() { return mCalendar; } 99 Calendar *calendar() { return mCalendar; }
100 100
101 KOViewManager *viewManager(); 101 KOViewManager *viewManager();
102 KODialogManager *dialogManager(); 102 KODialogManager *dialogManager();
103 103
104 QDate startDate(); 104 QDate startDate();
105 QDate endDate(); 105 QDate endDate();
106 106
107 QWidgetStack *viewStack(); 107 QWidgetStack *viewStack();
108 QWidget *leftFrame(); 108 QWidget *leftFrame();
109 NavigatorBar *navigatorBar(); 109 NavigatorBar *navigatorBar();
110 110
111 DateNavigator *dateNavigator(); 111 DateNavigator *dateNavigator();
112 KDateNavigator *dateNavigatorWidget(); 112 KDateNavigator *dateNavigatorWidget();
113 113
114 void addView(KOrg::BaseView *); 114 void addView(KOrg::BaseView *);
115 void showView(KOrg::BaseView *); 115 void showView(KOrg::BaseView *);
116 KOEventViewerDialog* getEventViewerDialog(); 116 KOEventViewerDialog* getEventViewerDialog();
117 Incidence *currentSelection(); 117 Incidence *currentSelection();
118 118
119 signals: 119 signals:
120 /** This todo has been modified */ 120 /** This todo has been modified */
121 void todoModified(Todo *, int); 121 void todoModified(Todo *, int);
122 122
123 /** when change is made to options dialog, the topwidget will catch this 123 /** when change is made to options dialog, the topwidget will catch this
124 * and emit this signal which notifies all widgets which have registered 124 * and emit this signal which notifies all widgets which have registered
125 * for notification to update their settings. */ 125 * for notification to update their settings. */
126 void configChanged(); 126 void configChanged();
127 /** emitted when the topwidget is closing down, so that any attached 127 /** emitted when the topwidget is closing down, so that any attached
128 child windows can also close. */ 128 child windows can also close. */
129 void closingDown(); 129 void closingDown();
130 /** emitted right before we die */ 130 /** emitted right before we die */
131 void closed(QWidget *); 131 void closed(QWidget *);
132 132
133 /** Emitted when state of modified flag changes */ 133 /** Emitted when state of modified flag changes */
134 void modifiedChanged(bool); 134 void modifiedChanged(bool);
135 void signalmodified(); 135 void signalmodified();
136 136
137 /** Emitted when state of read-only flag changes */ 137 /** Emitted when state of read-only flag changes */
138 void readOnlyChanged(bool); 138 void readOnlyChanged(bool);
139 139
140 /** Emitted when the unit of navigation changes */ 140 /** Emitted when the unit of navigation changes */
141 void changeNavStringPrev(const QString &); 141 void changeNavStringPrev(const QString &);
142 void changeNavStringNext(const QString &); 142 void changeNavStringNext(const QString &);
143 143
144 /** Emitted when state of events selection has changed and user is organizer*/ 144 /** Emitted when state of events selection has changed and user is organizer*/
145 void organizerEventsSelected(bool); 145 void organizerEventsSelected(bool);
146 /** Emitted when state of events selection has changed and user is attendee*/ 146 /** Emitted when state of events selection has changed and user is attendee*/
147 void groupEventsSelected(bool); 147 void groupEventsSelected(bool);
148 /** 148 /**
149 Emitted when an incidence gets selected. If the selection is cleared the 149 Emitted when an incidence gets selected. If the selection is cleared the
150 signal is emitted with 0 as argument. 150 signal is emitted with 0 as argument.
151 */ 151 */
152 void incidenceSelected( Incidence * ); 152 void incidenceSelected( Incidence * );
153 /** Emitted, when a todoitem is selected or deselected. */ 153 /** Emitted, when a todoitem is selected or deselected. */
154 void todoSelected( bool ); 154 void todoSelected( bool );
155 155
156 /** 156 /**
157 Emitted, when clipboard content changes. Parameter indicates if paste 157 Emitted, when clipboard content changes. Parameter indicates if paste
158 is possible or not. 158 is possible or not.
159 */ 159 */
160 void pasteEnabled(bool); 160 void pasteEnabled(bool);
161 161
162 /** Emitted, when the number of incoming messages has changed. */ 162 /** Emitted, when the number of incoming messages has changed. */
163 void numIncomingChanged(int); 163 void numIncomingChanged(int);
164 164
165 /** Emitted, when the number of outgoing messages has changed. */ 165 /** Emitted, when the number of outgoing messages has changed. */
166 void numOutgoingChanged(int); 166 void numOutgoingChanged(int);
167 167
168 /** Send status message, which can e.g. be displayed in the status bar. */ 168 /** Send status message, which can e.g. be displayed in the status bar. */
169 void statusMessage(const QString &); 169 void statusMessage(const QString &);
170 170
171 void calendarViewExpanded( bool ); 171 void calendarViewExpanded( bool );
172 void updateSearchDialog(); 172 void updateSearchDialog();
173 173
174 174
175 public slots: 175 public slots:
176 void showOpenError(); 176 void showOpenError();
177 void watchSavedFile(); 177 void watchSavedFile();
178 void recheckTimerAlarm(); 178 void recheckTimerAlarm();
179 void checkNextTimerAlarm(); 179 void checkNextTimerAlarm();
180 void addAlarm(const QDateTime &qdt, const QString &noti ); 180 void addAlarm(const QDateTime &qdt, const QString &noti );
181 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 181 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
182 void removeAlarm(const QDateTime &qdt, const QString &noti ); 182 void removeAlarm(const QDateTime &qdt, const QString &noti );
183 183
184 /** options dialog made a changed to the configuration. we catch this 184 /** options dialog made a changed to the configuration. we catch this
185 * and notify all widgets which need to update their configuration. */ 185 * and notify all widgets which need to update their configuration. */
186 void updateConfig(); 186 void updateConfig();
187 187
188 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 188 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
189 const QStringList& anniversaryList, const QStringList& realNameList, 189 const QStringList& anniversaryList, const QStringList& realNameList,
190 const QStringList& emailList, const QStringList& assembledNameList, 190 const QStringList& emailList, const QStringList& assembledNameList,
191 const QStringList& uidList); 191 const QStringList& uidList);
192 192
193 /** 193 /**
194 Load calendar from file \a filename. If \a merge is true, load 194 Load calendar from file \a filename. If \a merge is true, load
195 calendar into existing one, if it is false, clear calendar, before 195 calendar into existing one, if it is false, clear calendar, before
196 loading. Return true, if calendar could be successfully loaded. 196 loading. Return true, if calendar could be successfully loaded.
197 */ 197 */
198 bool openCalendar(QString filename, bool merge=false); 198 bool openCalendar(QString filename, bool merge=false);
199 bool syncCalendar(QString filename,int mode = 0 ); 199 bool syncCalendar(QString filename,int mode = 0 );
200 200
201 /** 201 /**
202 Save calendar data to file. Return true if calendar could be 202 Save calendar data to file. Return true if calendar could be
203 successfully saved. 203 successfully saved.
204 */ 204 */
205 bool saveCalendar(QString filename); 205 bool saveCalendar(QString filename);
206 206
207 /** 207 /**
208 Close calendar. Clear calendar data and reset views to display an empty 208 Close calendar. Clear calendar data and reset views to display an empty
209 calendar. 209 calendar.
210 */ 210 */
211 void closeCalendar(); 211 void closeCalendar();
212 212
213 /** Archive old events of calendar */ 213 /** Archive old events of calendar */
214 void archiveCalendar(); 214 void archiveCalendar();
215 215
216 void showIncidence(); 216 void showIncidence();
217 void editIncidence(); 217 void editIncidence();
218 void editIncidenceDescription(); 218 void editIncidenceDescription();
219 void deleteIncidence(); 219 void deleteIncidence();
220 void cloneIncidence(); 220 void cloneIncidence();
221 void moveIncidence(); 221 void moveIncidence();
222 void beamIncidence(); 222 void beamIncidence();
223 void toggleCancelIncidence(); 223 void toggleCancelIncidence();
224 224
225 /** create an editeventwin with supplied date/time, and if bool is true, 225 /** create an editeventwin with supplied date/time, and if bool is true,
226 * make the event take all day. */ 226 * make the event take all day. */
227 void newEvent(QDateTime, QDateTime, bool allDay = false); 227 void newEvent(QDateTime, QDateTime, bool allDay = false);
228 void newEvent(QDateTime fh); 228 void newEvent(QDateTime fh);
229 void newEvent(QDate dt); 229 void newEvent(QDate dt);
230 /** create new event without having a date hint. Takes current date as 230 /** create new event without having a date hint. Takes current date as
231 default hint. */ 231 default hint. */
232 void newEvent(); 232 void newEvent();
233 void newFloatingEvent(); 233 void newFloatingEvent();
234 234
235 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 235 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
236 void showIncidence(Incidence *); 236 void showIncidence(Incidence *);
237 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 237 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
238 void editIncidence(Incidence *); 238 void editIncidence(Incidence *);
239 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 239 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
240 void deleteIncidence(Incidence *); 240 void deleteIncidence(Incidence *);
241 void cloneIncidence(Incidence *); 241 void cloneIncidence(Incidence *);
242 void cancelIncidence(Incidence *); 242 void cancelIncidence(Incidence *);
243 /** Create an editor for the supplied event. */ 243 /** Create an editor for the supplied event. */
244 void editEvent(Event *); 244 void editEvent(Event *);
245 /** Delete the supplied event. */ 245 /** Delete the supplied event. */
246 void deleteEvent(Event *); 246 void deleteEvent(Event *);
247 /** Delete the event with the given unique ID. Returns false, if event wasn't 247 /** Delete the event with the given unique ID. Returns false, if event wasn't
248 found. */ 248 found. */
249 bool deleteEvent(const QString &uid); 249 bool deleteEvent(const QString &uid);
250 /** Create a read-only viewer dialog for the supplied event. */ 250 /** Create a read-only viewer dialog for the supplied event. */
251 void showEvent(Event *); 251 void showEvent(Event *);
252 252
253 void editJournal(Journal *); 253 void editJournal(Journal *);
254 void showJournal(Journal *); 254 void showJournal(Journal *);
255 void deleteJournal(Journal *); 255 void deleteJournal(Journal *);
256 /** Create an editor dialog for a todo */ 256 /** Create an editor dialog for a todo */
257 void editTodo(Todo *); 257 void editTodo(Todo *);
258 /** Create a read-only viewer dialog for the supplied todo */ 258 /** Create a read-only viewer dialog for the supplied todo */
259 void showTodo(Todo *); 259 void showTodo(Todo *);
260 /** create new todo */ 260 /** create new todo */
261 void newTodo(); 261 void newTodo();
262 /** create new todo with a parent todo */ 262 /** create new todo with a parent todo */
263 void newSubTodo(); 263 void newSubTodo();
264 /** create new todo with a parent todo */ 264 /** create new todo with a parent todo */
265 void newSubTodo(Todo *); 265 void newSubTodo(Todo *);
266 /** Delete todo */ 266 /** Delete todo */
267 void deleteTodo(Todo *); 267 void deleteTodo(Todo *);
268 268
269 269
270 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 270 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
271 * emitted as result. */ 271 * emitted as result. */
272 void checkClipboard(); 272 void checkClipboard();
273 273
274 /** using the KConfig associated with the kapp variable, read in the 274 /** using the KConfig associated with the kapp variable, read in the
275 * settings from the config file. 275 * settings from the config file.
276 */ 276 */
277 void readSettings(); 277 void readSettings();
278 278
279 /** write current state to config file. */ 279 /** write current state to config file. */
280 void writeSettings(); 280 void writeSettings();
281 281
282 /** read settings for calendar filters */ 282 /** read settings for calendar filters */
283 void readFilterSettings(KConfig *config); 283 void readFilterSettings(KConfig *config);
284 284
285 /** write settings for calendar filters */ 285 /** write settings for calendar filters */
286 void writeFilterSettings(KConfig *config); 286 void writeFilterSettings(KConfig *config);
287 287
288 /** passes on the message that an event has changed to the currently 288 /** passes on the message that an event has changed to the currently
289 * activated view so that it can make appropriate display changes. */ 289 * activated view so that it can make appropriate display changes. */
290 void changeEventDisplay(Event *, int); 290 void changeEventDisplay(Event *, int);
291 void changeIncidenceDisplay(Incidence *, int); 291 void changeIncidenceDisplay(Incidence *, int);
292 void changeTodoDisplay(Todo *, int); 292 void changeTodoDisplay(Todo *, int);
293 293
294 void eventAdded(Event *); 294 void eventAdded(Event *);
295 void eventChanged(Event *); 295 void eventChanged(Event *);
296 void eventToBeDeleted(Event *); 296 void eventToBeDeleted(Event *);
297 void eventDeleted(); 297 void eventDeleted();
298 298
299 void todoAdded(Todo *); 299 void todoAdded(Todo *);
300 void todoChanged(Todo *); 300 void todoChanged(Todo *);
301 void todoToBeDeleted(Todo *); 301 void todoToBeDeleted(Todo *);
302 void todoDeleted(); 302 void todoDeleted();
303 303
304 void updateView(const QDate &start, const QDate &end); 304 void updateView(const QDate &start, const QDate &end);
305 void updateView(); 305 void updateView();
306 306
307 /** Full update of visible todo views */ 307 /** Full update of visible todo views */
308 void updateTodoViews(); 308 void updateTodoViews();
309 309
310 void updateUnmanagedViews(); 310 void updateUnmanagedViews();
311 311
312 /** cut the current appointment to the clipboard */ 312 /** cut the current appointment to the clipboard */
313 void edit_cut(); 313 void edit_cut();
314 314
315 /** copy the current appointment(s) to the clipboard */ 315 /** copy the current appointment(s) to the clipboard */
316 void edit_copy(); 316 void edit_copy();
317 317
318 /** paste the current vobject(s) in the clipboard buffer into calendar */ 318 /** paste the current vobject(s) in the clipboard buffer into calendar */
319 void edit_paste(); 319 void edit_paste();
320 320
321 /** edit viewing and configuration options. */ 321 /** edit viewing and configuration options. */
322 void edit_options(); 322 void edit_options();
323 void edit_sync_options();
324 /** 323 /**
325 Functions for printing, previewing a print, and setting up printing 324 Functions for printing, previewing a print, and setting up printing
326 parameters. 325 parameters.
327 */ 326 */
328 void print(); 327 void print();
329 void printSetup(); 328 void printSetup();
330 void printPreview(); 329 void printPreview();
331 330
332 /** Export as iCalendar file */ 331 /** Export as iCalendar file */
333 void exportICalendar(); 332 void exportICalendar();
334 333
335 /** Export as vCalendar file */ 334 /** Export as vCalendar file */
336 bool exportVCalendar( QString fn); 335 bool exportVCalendar( QString fn);
337 336
338 /** pop up a dialog to show an existing appointment. */ 337 /** pop up a dialog to show an existing appointment. */
339 void appointment_show(); 338 void appointment_show();
340 /** 339 /**
341 * pop up an Appointment Dialog to edit an existing appointment.Get 340 * pop up an Appointment Dialog to edit an existing appointment.Get
342 * information on the appointment from the list of unique IDs that is 341 * information on the appointment from the list of unique IDs that is
343 * currently in the View, called currIds. 342 * currently in the View, called currIds.
344 */ 343 */
345 void appointment_edit(); 344 void appointment_edit();
346 /** 345 /**
347 * pop up dialog confirming deletion of currently selected event in the 346 * pop up dialog confirming deletion of currently selected event in the
348 * View. 347 * View.
349 */ 348 */
350 void appointment_delete(); 349 void appointment_delete();
351 350
352 /** mails the currently selected event to a particular user as a vCalendar 351 /** mails the currently selected event to a particular user as a vCalendar
353 attachment. */ 352 attachment. */
354 void action_mail(); 353 void action_mail();
355 354
356 /* frees a subtodo from it's relation */ 355 /* frees a subtodo from it's relation */
357 void todo_unsub( Todo * ); 356 void todo_unsub( Todo * );
358 357
359 /** Take ownership of selected event. */ 358 /** Take ownership of selected event. */
360 void takeOverEvent(); 359 void takeOverEvent();
361 360
362 /** Take ownership of all events in calendar. */ 361 /** Take ownership of all events in calendar. */
363 void takeOverCalendar(); 362 void takeOverCalendar();
364 363
365 /** query whether or not the calendar is "dirty". */ 364 /** query whether or not the calendar is "dirty". */
366 bool isModified(); 365 bool isModified();
367 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 366 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
368 void setModified(bool modified=true); 367 void setModified(bool modified=true);
369 368
370 /** query if the calendar is read-only. */ 369 /** query if the calendar is read-only. */
371 bool isReadOnly(); 370 bool isReadOnly();
372 /** set state of calendar to read-only */ 371 /** set state of calendar to read-only */
373 void setReadOnly(bool readOnly=true); 372 void setReadOnly(bool readOnly=true);
374 373
375 void eventUpdated(Incidence *); 374 void eventUpdated(Incidence *);
376 375
377 /* iTIP scheduling actions */ 376 /* iTIP scheduling actions */
378 void schedule_publish(Incidence *incidence = 0); 377 void schedule_publish(Incidence *incidence = 0);
379 void schedule_request(Incidence *incidence = 0); 378 void schedule_request(Incidence *incidence = 0);
380 void schedule_refresh(Incidence *incidence = 0); 379 void schedule_refresh(Incidence *incidence = 0);
381 void schedule_cancel(Incidence *incidence = 0); 380 void schedule_cancel(Incidence *incidence = 0);
382 void schedule_add(Incidence *incidence = 0); 381 void schedule_add(Incidence *incidence = 0);
383 void schedule_reply(Incidence *incidence = 0); 382 void schedule_reply(Incidence *incidence = 0);
384 void schedule_counter(Incidence *incidence = 0); 383 void schedule_counter(Incidence *incidence = 0);
385 void schedule_declinecounter(Incidence *incidence = 0); 384 void schedule_declinecounter(Incidence *incidence = 0);
386 void schedule_publish_freebusy(int daysToPublish = 30); 385 void schedule_publish_freebusy(int daysToPublish = 30);
387 386
388 void openAddressbook(); 387 void openAddressbook();
389 388
390 void editFilters(); 389 void editFilters();
391 void toggleFilerEnabled(); 390 void toggleFilerEnabled();
392 QPtrList<CalFilter> filters(); 391 QPtrList<CalFilter> filters();
393 void toggleFilter(); 392 void toggleFilter();
394 void showFilter(bool visible); 393 void showFilter(bool visible);
395 void updateFilter(); 394 void updateFilter();
396 void filterEdited(); 395 void filterEdited();
397 void selectFilter( int ); 396 void selectFilter( int );
398 KOFilterView *filterView(); 397 KOFilterView *filterView();
399 398
400 void showIntro(); 399 void showIntro();
401 400
402 /** Move the curdatepient view date to today */ 401 /** Move the curdatepient view date to today */
403 void goToday(); 402 void goToday();
404 403
405 /** Move to the next date(s) in the current view */ 404 /** Move to the next date(s) in the current view */
406 void goNext(); 405 void goNext();
407 406
408 /** Move to the previous date(s) in the current view */ 407 /** Move to the previous date(s) in the current view */
409 void goPrevious(); 408 void goPrevious();
410 /** Move to the next date(s) in the current view */ 409 /** Move to the next date(s) in the current view */
411 void goNextMonth(); 410 void goNextMonth();
412 411
413 /** Move to the previous date(s) in the current view */ 412 /** Move to the previous date(s) in the current view */
414 void goPreviousMonth(); 413 void goPreviousMonth();
415 414
416 void toggleExpand(); 415 void toggleExpand();
417 void toggleDateNavigatorWidget(); 416 void toggleDateNavigatorWidget();
418 void toggleAllDaySize(); 417 void toggleAllDaySize();
419 void dialogClosing(Incidence *); 418 void dialogClosing(Incidence *);
420 419
421 /** Look for new messages in the inbox */ 420 /** Look for new messages in the inbox */
422 void lookForIncomingMessages(); 421 void lookForIncomingMessages();
423 /** Look for new messages in the outbox */ 422 /** Look for new messages in the outbox */
424 void lookForOutgoingMessages(); 423 void lookForOutgoingMessages();
425 424
426 void processMainViewSelection( Incidence * ); 425 void processMainViewSelection( Incidence * );
427 void processTodoListSelection( Incidence * ); 426 void processTodoListSelection( Incidence * );
428 427
429 void processIncidenceSelection( Incidence * ); 428 void processIncidenceSelection( Incidence * );
430 429
431 void purgeCompleted(); 430 void purgeCompleted();
432 bool removeCompletedSubTodos( Todo* ); 431 bool removeCompletedSubTodos( Todo* );
433 void slotCalendarChanged(); 432 void slotCalendarChanged();
434 bool importBday(); 433 bool importBday();
435 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 434 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
436 bool importQtopia( const QString &categoriesFile, 435 bool importQtopia( const QString &categoriesFile,
437 const QString &datebookFile, 436 const QString &datebookFile,
438 const QString &tasklistFile ); 437 const QString &tasklistFile );
439 void syncSharp( );
440 void syncPhone( );
441 void syncExternal( int mode ); 438 void syncExternal( int mode );
442 void slotSelectPickerDate( QDate ) ; 439 void slotSelectPickerDate( QDate ) ;
443 void showDatePicker( ) ; 440 void showDatePicker( ) ;
444 void moveIncidence(Incidence *) ; 441 void moveIncidence(Incidence *) ;
445 void beamIncidence(Incidence *) ; 442 void beamIncidence(Incidence *) ;
446 void beamCalendar() ; 443 void beamCalendar() ;
447 void beamFilteredCalendar() ; 444 void beamFilteredCalendar() ;
448 void beamIncidenceList(QPtrList<Incidence>) ; 445 void beamIncidenceList(QPtrList<Incidence>) ;
449 void manageCategories(); 446 void manageCategories();
450 int addCategories(); 447 int addCategories();
451 void removeCategories(); 448 void removeCategories();
452 void setSyncDevice( QString ); 449 void setSyncDevice( QString );
453 void setSyncName( QString ); 450 void setSyncName( QString );
454 protected slots: 451 protected slots:
455 void timerAlarm(); 452 void timerAlarm();
456 void suspendAlarm(); 453 void suspendAlarm();
457 void beamDone( Ir *ir ); 454 void beamDone( Ir *ir );
458 /** Select a view or adapt the current view to display the specified dates. */ 455 /** Select a view or adapt the current view to display the specified dates. */
459 void showDates( const KCal::DateList & ); 456 void showDates( const KCal::DateList & );
460 void selectWeekNum ( int ); 457 void selectWeekNum ( int );
461 458
462 public: 459 public:
463 // show a standard warning 460 // show a standard warning
464 // returns KMsgBox::yesNoCancel() 461 // returns KMsgBox::yesNoCancel()
465 int msgCalModified(); 462 int msgCalModified();
466 virtual bool sync(KSyncManager* manager, QString filename, int mode); 463 virtual bool sync(KSyncManager* manager, QString filename, int mode);
467 464
468 virtual bool syncExternal(KSyncManager* manager, QString resource); 465 virtual bool syncExternal(KSyncManager* manager, QString resource);
469 void confSync();
470 void setSyncManager(KSyncManager* manager); 466 void setSyncManager(KSyncManager* manager);
471 void setLoadedFileVersion(QDateTime); 467 void setLoadedFileVersion(QDateTime);
472 bool checkFileVersion(QString fn); 468 bool checkFileVersion(QString fn);
473 bool checkFileChanged(QString fn); 469 bool checkFileChanged(QString fn);
474 Event* getLastSyncEvent(); 470 Event* getLastSyncEvent();
475 /** Adapt navigation units correpsonding to step size of navigation of the 471 /** Adapt navigation units correpsonding to step size of navigation of the
476 * current view. 472 * current view.
477 */ 473 */
478 void adaptNavigationUnits(); 474 void adaptNavigationUnits();
479 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 475 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
480 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 476 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
481 //Attendee* getYourAttendee(Event *event); 477 //Attendee* getYourAttendee(Event *event);
482 protected: 478 protected:
483 void schedule(Scheduler::Method, Incidence *incidence = 0); 479 void schedule(Scheduler::Method, Incidence *incidence = 0);
484 480
485 // returns KMsgBox::OKCandel() 481 // returns KMsgBox::OKCandel()
486 int msgItemDelete(); 482 int msgItemDelete();
487 void showEventEditor(); 483 void showEventEditor();
488 void showTodoEditor(); 484 void showTodoEditor();
489 void writeLocale(); 485 void writeLocale();
490 Todo *selectedTodo(); 486 Todo *selectedTodo();
491 487
492 private: 488 private:
493 KSyncManager* mSyncManager; 489 KSyncManager* mSyncManager;
494 AlarmDialog * mAlarmDialog; 490 AlarmDialog * mAlarmDialog;
495 QString mAlarmNotification; 491 QString mAlarmNotification;
496 QString mSuspendAlarmNotification; 492 QString mSuspendAlarmNotification;
497 QTimer* mSuspendTimer; 493 QTimer* mSuspendTimer;
498 QTimer* mAlarmTimer; 494 QTimer* mAlarmTimer;
499 QTimer* mRecheckAlarmTimer; 495 QTimer* mRecheckAlarmTimer;
500 void computeAlarm( QString ); 496 void computeAlarm( QString );
501 void startAlarm( QString, QString ); 497 void startAlarm( QString, QString );
502 void setSyncEventsReadOnly(); 498 void setSyncEventsReadOnly();
503 499
504 QDateTime loadedFileVersion; 500 QDateTime loadedFileVersion;
505 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 501 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
506 void checkExternalId( Incidence * inc ); 502 void checkExternalId( Incidence * inc );
507 int mGlobalSyncMode; 503 int mGlobalSyncMode;
508 QString mCurrentSyncDevice; 504 QString mCurrentSyncDevice;
509 QString mCurrentSyncName; 505 QString mCurrentSyncName;
510 KOBeamPrefs* beamDialog; 506 KOBeamPrefs* beamDialog;
511 void init(); 507 void init();
512 int mDatePickerMode; 508 int mDatePickerMode;
513 bool mFlagEditDescription; 509 bool mFlagEditDescription;
514 QDateTime mLastCalendarSync; 510 QDateTime mLastCalendarSync;
515 void createPrinter(); 511 void createPrinter();
516 512
517 void calendarModified( bool, Calendar * ); 513 void calendarModified( bool, Calendar * );
518 514
519 CalPrinter *mCalPrinter; 515 CalPrinter *mCalPrinter;
520 516
521 QSplitter *mPanner; 517 QSplitter *mPanner;
522 QSplitter *mLeftSplitter; 518 QSplitter *mLeftSplitter;
523 QWidget *mLeftFrame; 519 QWidget *mLeftFrame;
524 QWidgetStack *mRightFrame; 520 QWidgetStack *mRightFrame;
525 521
526 KDatePicker* mDatePicker; 522 KDatePicker* mDatePicker;
527 QVBox* mDateFrame; 523 QVBox* mDateFrame;
528 NavigatorBar *mNavigatorBar; 524 NavigatorBar *mNavigatorBar;
529 525
530 KDateNavigator *mDateNavigator; // widget showing small month view. 526 KDateNavigator *mDateNavigator; // widget showing small month view.
531 527
532 KOFilterView *mFilterView; 528 KOFilterView *mFilterView;
533 529
534 ResourceView *mResourceView; 530 ResourceView *mResourceView;
535 531
536 // calendar object for this viewing instance 532 // calendar object for this viewing instance
537 Calendar *mCalendar; 533 Calendar *mCalendar;
538 534
539 CalendarResourceManager *mResourceManager; 535 CalendarResourceManager *mResourceManager;
540 536
541 FileStorage *mStorage; 537 FileStorage *mStorage;
542 538
543 DateNavigator *mNavigator; 539 DateNavigator *mNavigator;
544 540
545 KOViewManager *mViewManager; 541 KOViewManager *mViewManager;
546 KODialogManager *mDialogManager; 542 KODialogManager *mDialogManager;
547 543
548 // Calendar filters 544 // Calendar filters
549 QPtrList<CalFilter> mFilters; 545 QPtrList<CalFilter> mFilters;
550 546
551 // various housekeeping variables. 547 // various housekeeping variables.
552 bool mModified; // flag indicating if calendar is modified 548 bool mModified; // flag indicating if calendar is modified
553 bool mReadOnly; // flag indicating if calendar is read-only 549 bool mReadOnly; // flag indicating if calendar is read-only
554 QDate mSaveSingleDate; 550 QDate mSaveSingleDate;
555 551
556 Incidence *mSelectedIncidence; 552 Incidence *mSelectedIncidence;
557 Incidence *mMoveIncidence; 553 Incidence *mMoveIncidence;
558 KOTodoView *mTodoList; 554 KOTodoView *mTodoList;
559 KOEventEditor * mEventEditor; 555 KOEventEditor * mEventEditor;
560 KOTodoEditor * mTodoEditor; 556 KOTodoEditor * mTodoEditor;
561 KOEventViewerDialog * mEventViewerDialog; 557 KOEventViewerDialog * mEventViewerDialog;
562 void keyPressEvent ( QKeyEvent *e) ; 558 void keyPressEvent ( QKeyEvent *e) ;
563 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 559 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
564}; 560};
565 561
566 562
567class CalendarViewVisitor : public Incidence::Visitor 563class CalendarViewVisitor : public Incidence::Visitor
568{ 564{
569 public: 565 public:
570 CalendarViewVisitor() : mView( 0 ) {} 566 CalendarViewVisitor() : mView( 0 ) {}
571 567
572 bool act( Incidence *incidence, CalendarView *view ) 568 bool act( Incidence *incidence, CalendarView *view )
573 { 569 {
574 mView = view; 570 mView = view;
575 return incidence->accept( *this ); 571 return incidence->accept( *this );
576 } 572 }
577 573
578 protected: 574 protected:
579 CalendarView *mView; 575 CalendarView *mView;
580}; 576};
581 577
582class ShowIncidenceVisitor : public CalendarViewVisitor 578class ShowIncidenceVisitor : public CalendarViewVisitor
583{ 579{
584 protected: 580 protected:
585 bool visit( Event *event ) { mView->showEvent( event ); return true; } 581 bool visit( Event *event ) { mView->showEvent( event ); return true; }
586 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 582 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
587 bool visit( Journal * j ) { mView->showJournal( j );return true; } 583 bool visit( Journal * j ) { mView->showJournal( j );return true; }
588}; 584};
589 585
590class EditIncidenceVisitor : public CalendarViewVisitor 586class EditIncidenceVisitor : public CalendarViewVisitor
591{ 587{
592 protected: 588 protected:
593 bool visit( Event *event ) { mView->editEvent( event ); return true; } 589 bool visit( Event *event ) { mView->editEvent( event ); return true; }
594 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 590 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
595 bool visit( Journal *j ) { mView->editJournal( j); return true; } 591 bool visit( Journal *j ) { mView->editJournal( j); return true; }
596}; 592};
597 593
598class DeleteIncidenceVisitor : public CalendarViewVisitor 594class DeleteIncidenceVisitor : public CalendarViewVisitor
599{ 595{
600 protected: 596 protected:
601 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 597 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
602 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 598 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
603 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 599 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
604}; 600};
605 601
606#endif 602#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index c7ce8cb..2d17986 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1003,837 +1003,833 @@ void MainWindow::exportToPhone( int mode )
1003 if ( !ok ) 1003 if ( !ok )
1004 dt = cur.addSecs( -62 ); 1004 dt = cur.addSecs( -62 );
1005 } 1005 }
1006 if ( dt < cur || dt > end ) { 1006 if ( dt < cur || dt > end ) {
1007 add = false; 1007 add = false;
1008 } 1008 }
1009 } 1009 }
1010 if ( add ) { 1010 if ( add ) {
1011 Incidence *in = incidence->clone(); 1011 Incidence *in = incidence->clone();
1012 cal->addIncidence( in ); 1012 cal->addIncidence( in );
1013 } 1013 }
1014 } 1014 }
1015 incidence = delSel.next(); 1015 incidence = delSel.next();
1016 } 1016 }
1017 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1017 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1018 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1018 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1019 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1019 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1020 1020
1021 setCaption( i18n("Writing to phone...")); 1021 setCaption( i18n("Writing to phone..."));
1022 if ( PhoneFormat::writeToPhone( cal ) ) 1022 if ( PhoneFormat::writeToPhone( cal ) )
1023 setCaption( i18n("Export to phone successful!")); 1023 setCaption( i18n("Export to phone successful!"));
1024 else 1024 else
1025 setCaption( i18n("Error exporting to phone!")); 1025 setCaption( i18n("Error exporting to phone!"));
1026 delete cal; 1026 delete cal;
1027} 1027}
1028 1028
1029 1029
1030void MainWindow::setDefaultPreferences() 1030void MainWindow::setDefaultPreferences()
1031{ 1031{
1032 KOPrefs *p = KOPrefs::instance(); 1032 KOPrefs *p = KOPrefs::instance();
1033 1033
1034 p->mCompactDialogs = true; 1034 p->mCompactDialogs = true;
1035 p->mConfirm = true; 1035 p->mConfirm = true;
1036 // p->mEnableQuickTodo = false; 1036 // p->mEnableQuickTodo = false;
1037 1037
1038} 1038}
1039 1039
1040QString MainWindow::resourcePath() 1040QString MainWindow::resourcePath()
1041{ 1041{
1042 return KGlobal::iconLoader()->iconPath(); 1042 return KGlobal::iconLoader()->iconPath();
1043} 1043}
1044 1044
1045void MainWindow::displayText( QString text ,QString cap ) 1045void MainWindow::displayText( QString text ,QString cap )
1046{ 1046{
1047 QDialog dia( this, "name", true ); ; 1047 QDialog dia( this, "name", true ); ;
1048 dia.setCaption( cap ); 1048 dia.setCaption( cap );
1049 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1049 QVBoxLayout* lay = new QVBoxLayout( &dia );
1050 lay->setSpacing( 3 ); 1050 lay->setSpacing( 3 );
1051 lay->setMargin( 3 ); 1051 lay->setMargin( 3 );
1052 QTextBrowser tb ( &dia ); 1052 QTextBrowser tb ( &dia );
1053 lay->addWidget( &tb ); 1053 lay->addWidget( &tb );
1054 tb.setText( text ); 1054 tb.setText( text );
1055#ifdef DESKTOP_VERSION 1055#ifdef DESKTOP_VERSION
1056 dia.resize( 640, 480); 1056 dia.resize( 640, 480);
1057#else 1057#else
1058 dia.showMaximized(); 1058 dia.showMaximized();
1059#endif 1059#endif
1060 dia.exec(); 1060 dia.exec();
1061} 1061}
1062void MainWindow::displayFile( QString fn, QString cap ) 1062void MainWindow::displayFile( QString fn, QString cap )
1063{ 1063{
1064 QString fileName = resourcePath() + fn; 1064 QString fileName = resourcePath() + fn;
1065 QString text; 1065 QString text;
1066 QFile file( fileName ); 1066 QFile file( fileName );
1067 if (!file.open( IO_ReadOnly ) ) { 1067 if (!file.open( IO_ReadOnly ) ) {
1068 return ; 1068 return ;
1069 1069
1070 } 1070 }
1071 QTextStream ts( &file ); 1071 QTextStream ts( &file );
1072 text = ts.read(); 1072 text = ts.read();
1073 file.close(); 1073 file.close();
1074 displayText( text, cap); 1074 displayText( text, cap);
1075} 1075}
1076void MainWindow::features() 1076void MainWindow::features()
1077{ 1077{
1078 1078
1079 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1079 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1080} 1080}
1081 1081
1082void MainWindow::usertrans() 1082void MainWindow::usertrans()
1083{ 1083{
1084 1084
1085 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1085 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1086} 1086}
1087 1087
1088void MainWindow::synchowto() 1088void MainWindow::synchowto()
1089{ 1089{
1090#if 0 1090#if 0
1091 QPtrList<Incidence> er = mCalendar->rawIncidences(); 1091 QPtrList<Incidence> er = mCalendar->rawIncidences();
1092 Incidence* inR = er.first(); 1092 Incidence* inR = er.first();
1093 VCalFormat vf; 1093 VCalFormat vf;
1094 QString strout; 1094 QString strout;
1095 while ( inR ) { 1095 while ( inR ) {
1096 if ( inR->type() == "Todo" ) 1096 if ( inR->type() == "Todo" )
1097 strout = vf.todoToString( (Todo *) inR ); 1097 strout = vf.todoToString( (Todo *) inR );
1098 if ( inR->type() == "Event" ) 1098 if ( inR->type() == "Event" )
1099 strout = vf.eventToString( (Event *) inR ); 1099 strout = vf.eventToString( (Event *) inR );
1100 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); 1100 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() );
1101 inR = er.next(); 1101 inR = er.next();
1102 } 1102 }
1103#endif 1103#endif
1104 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1104 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1105} 1105}
1106void MainWindow::faq() 1106void MainWindow::faq()
1107{ 1107{
1108 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1108 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1109 1109
1110} 1110}
1111void MainWindow::whatsNew() 1111void MainWindow::whatsNew()
1112{ 1112{
1113 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1113 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1114 1114
1115} 1115}
1116void MainWindow::licence() 1116void MainWindow::licence()
1117{ 1117{
1118 KApplication::showLicence(); 1118 KApplication::showLicence();
1119 1119
1120} 1120}
1121void MainWindow::about() 1121void MainWindow::about()
1122{ 1122{
1123 QString version; 1123 QString version;
1124#include <../version> 1124#include <../version>
1125 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1125 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1126 i18n("KOrganizer/Platform-independent\n") + 1126 i18n("KOrganizer/Platform-independent\n") +
1127 "(KO/Pi) " + version + " - " + 1127 "(KO/Pi) " + version + " - " +
1128 1128
1129#ifdef DESKTOP_VERSION 1129#ifdef DESKTOP_VERSION
1130 i18n("Desktop Edition\n") + 1130 i18n("Desktop Edition\n") +
1131#else 1131#else
1132 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1132 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1133#endif 1133#endif
1134 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); 1134 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
1135} 1135}
1136void MainWindow::keyBindings() 1136void MainWindow::keyBindings()
1137{ 1137{
1138 QString cap = i18n("Key bindings KOrganizer/Pi"); 1138 QString cap = i18n("Key bindings KOrganizer/Pi");
1139 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1139 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1140 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1140 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1141 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1141 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1142 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1142 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1143 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1143 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1144 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1144 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1145 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1145 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1146 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1146 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1147 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1147 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1148 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1148 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1149 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1149 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1150 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1150 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1151 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1151 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1152 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1152 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1153 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1153 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1154 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1154 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1155 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1155 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1156 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1156 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1157 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1157 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1158 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1158 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1159 i18n("<p><h3>In agenda view:</h3></p>\n") + 1159 i18n("<p><h3>In agenda view:</h3></p>\n") +
1160 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1160 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1161 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1161 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1162 i18n("<p><h3>In todo view:</h3></p>\n") + 1162 i18n("<p><h3>In todo view:</h3></p>\n") +
1163 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1163 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1164 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1164 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1165 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1165 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1166 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1166 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1167 i18n("<p><h3>In list view:</h3></p>\n") + 1167 i18n("<p><h3>In list view:</h3></p>\n") +
1168 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1168 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1169 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1169 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1170 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1170 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1171 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1171 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1172 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1172 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1173 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1173 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1174 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1174 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1175 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1175 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1176 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1176 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1177 i18n("<p><b>E</b>: Edit item</p>\n") + 1177 i18n("<p><b>E</b>: Edit item</p>\n") +
1178 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1178 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1179 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1179 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1180 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1180 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1181 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1181 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1182 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1182 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1183 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1183 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1184 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1184 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1185 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1185 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1186 i18n("<p><b>White</b>: Item readonly</p>\n"); 1186 i18n("<p><b>White</b>: Item readonly</p>\n");
1187 displayText( text, cap); 1187 displayText( text, cap);
1188 1188
1189} 1189}
1190void MainWindow::aboutAutoSaving() 1190void MainWindow::aboutAutoSaving()
1191{ 1191{
1192 QMessageBox* msg; 1192 QMessageBox* msg;
1193 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1193 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1194 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, 1194 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon,
1195 QMessageBox::Ok, 1195 QMessageBox::Ok,
1196 QMessageBox::NoButton, 1196 QMessageBox::NoButton,
1197 QMessageBox::NoButton); 1197 QMessageBox::NoButton);
1198 msg->exec(); 1198 msg->exec();
1199 delete msg; 1199 delete msg;
1200 1200
1201 1201
1202} 1202}
1203void MainWindow::aboutKnownBugs() 1203void MainWindow::aboutKnownBugs()
1204{ 1204{
1205 QMessageBox* msg; 1205 QMessageBox* msg;
1206 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1206 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1207 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1207 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1208 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1208 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1209 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1209 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1210 i18n("\nor report them in the bugtracker on\n") + 1210 i18n("\nor report them in the bugtracker on\n") +
1211 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1211 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1212 QMessageBox::NoIcon, 1212 QMessageBox::NoIcon,
1213 QMessageBox::Ok, 1213 QMessageBox::Ok,
1214 QMessageBox::NoButton, 1214 QMessageBox::NoButton,
1215 QMessageBox::NoButton); 1215 QMessageBox::NoButton);
1216 msg->exec(); 1216 msg->exec();
1217 delete msg; 1217 delete msg;
1218 1218
1219} 1219}
1220 1220
1221QString MainWindow::defaultFileName() 1221QString MainWindow::defaultFileName()
1222{ 1222{
1223 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1223 return locateLocal( "data", "korganizer/mycalendar.ics" );
1224} 1224}
1225QString MainWindow::syncFileName() 1225QString MainWindow::syncFileName()
1226{ 1226{
1227#ifdef _WIN32_ 1227#ifdef _WIN32_
1228 return locateLocal( "tmp", "synccalendar.ics" ); 1228 return locateLocal( "tmp", "synccalendar.ics" );
1229#else 1229#else
1230 return QString( "/tmp/kopitempfile.ics" ); 1230 return QString( "/tmp/kopitempfile.ics" );
1231#endif 1231#endif
1232} 1232}
1233 1233
1234void MainWindow::processIncidenceSelection( Incidence *incidence ) 1234void MainWindow::processIncidenceSelection( Incidence *incidence )
1235{ 1235{
1236 if ( !incidence ) { 1236 if ( !incidence ) {
1237 enableIncidenceActions( false ); 1237 enableIncidenceActions( false );
1238 1238
1239 mNewSubTodoAction->setEnabled( false ); 1239 mNewSubTodoAction->setEnabled( false );
1240 setCaptionToDates(); 1240 setCaptionToDates();
1241 return; 1241 return;
1242 1242
1243 } 1243 }
1244 1244
1245 //KGlobal::locale()->formatDateTime(nextA, true); 1245 //KGlobal::locale()->formatDateTime(nextA, true);
1246 QString startString = ""; 1246 QString startString = "";
1247 if ( incidence->type() != "Todo" ) { 1247 if ( incidence->type() != "Todo" ) {
1248 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1248 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1249 if ( incidence->doesFloat() ) { 1249 if ( incidence->doesFloat() ) {
1250 startString += ": "+incidence->dtStartDateStr( true ); 1250 startString += ": "+incidence->dtStartDateStr( true );
1251 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1251 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1252 1252
1253 } else { 1253 } else {
1254 startString = ": "+incidence->dtStartStr(true); 1254 startString = ": "+incidence->dtStartStr(true);
1255 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1255 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1256 1256
1257 } 1257 }
1258 1258
1259 } else { 1259 } else {
1260 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1260 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1261 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1261 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1262 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1262 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1263 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1263 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1264 } 1264 }
1265 1265
1266 } 1266 }
1267 else 1267 else
1268 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1268 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1269 if ( !incidence->location().isEmpty() ) 1269 if ( !incidence->location().isEmpty() )
1270 startString += " (" +incidence->location()+")"; 1270 startString += " (" +incidence->location()+")";
1271 setCaption( incidence->summary()+startString); 1271 setCaption( incidence->summary()+startString);
1272 1272
1273 enableIncidenceActions( true ); 1273 enableIncidenceActions( true );
1274 1274
1275 if ( incidence->type() == "Event" ) { 1275 if ( incidence->type() == "Event" ) {
1276 mShowAction->setText( i18n("Show Event...") ); 1276 mShowAction->setText( i18n("Show Event...") );
1277 mEditAction->setText( i18n("Edit Event...") ); 1277 mEditAction->setText( i18n("Edit Event...") );
1278 mDeleteAction->setText( i18n("Delete Event...") ); 1278 mDeleteAction->setText( i18n("Delete Event...") );
1279 1279
1280 mNewSubTodoAction->setEnabled( false ); 1280 mNewSubTodoAction->setEnabled( false );
1281 } else if ( incidence->type() == "Todo" ) { 1281 } else if ( incidence->type() == "Todo" ) {
1282 mShowAction->setText( i18n("Show Todo...") ); 1282 mShowAction->setText( i18n("Show Todo...") );
1283 mEditAction->setText( i18n("Edit Todo...") ); 1283 mEditAction->setText( i18n("Edit Todo...") );
1284 mDeleteAction->setText( i18n("Delete Todo...") ); 1284 mDeleteAction->setText( i18n("Delete Todo...") );
1285 1285
1286 mNewSubTodoAction->setEnabled( true ); 1286 mNewSubTodoAction->setEnabled( true );
1287 } else { 1287 } else {
1288 mShowAction->setText( i18n("Show...") ); 1288 mShowAction->setText( i18n("Show...") );
1289 mShowAction->setText( i18n("Edit...") ); 1289 mShowAction->setText( i18n("Edit...") );
1290 mShowAction->setText( i18n("Delete...") ); 1290 mShowAction->setText( i18n("Delete...") );
1291 1291
1292 mNewSubTodoAction->setEnabled( false ); 1292 mNewSubTodoAction->setEnabled( false );
1293 } 1293 }
1294} 1294}
1295 1295
1296void MainWindow::enableIncidenceActions( bool enabled ) 1296void MainWindow::enableIncidenceActions( bool enabled )
1297{ 1297{
1298 mShowAction->setEnabled( enabled ); 1298 mShowAction->setEnabled( enabled );
1299 mEditAction->setEnabled( enabled ); 1299 mEditAction->setEnabled( enabled );
1300 mDeleteAction->setEnabled( enabled ); 1300 mDeleteAction->setEnabled( enabled );
1301 1301
1302 mCloneAction->setEnabled( enabled ); 1302 mCloneAction->setEnabled( enabled );
1303 mMoveAction->setEnabled( enabled ); 1303 mMoveAction->setEnabled( enabled );
1304 mBeamAction->setEnabled( enabled ); 1304 mBeamAction->setEnabled( enabled );
1305 mCancelAction->setEnabled( enabled ); 1305 mCancelAction->setEnabled( enabled );
1306} 1306}
1307 1307
1308void MainWindow::importOL() 1308void MainWindow::importOL()
1309{ 1309{
1310#ifdef _WIN32_ 1310#ifdef _WIN32_
1311 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1311 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1312 id->exec(); 1312 id->exec();
1313 delete id; 1313 delete id;
1314 mView->updateView(); 1314 mView->updateView();
1315#endif 1315#endif
1316} 1316}
1317void MainWindow::importBday() 1317void MainWindow::importBday()
1318{ 1318{
1319 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1319 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1320 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1320 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1321 i18n("Import!"), i18n("Cancel"), 0, 1321 i18n("Import!"), i18n("Cancel"), 0,
1322 0, 1 ); 1322 0, 1 );
1323 if ( result == 0 ) { 1323 if ( result == 0 ) {
1324 mView->importBday(); 1324 mView->importBday();
1325 1325
1326 } 1326 }
1327 1327
1328 1328
1329} 1329}
1330void MainWindow::importQtopia() 1330void MainWindow::importQtopia()
1331{ 1331{
1332#ifndef DESKTOP_VERSION 1332#ifndef DESKTOP_VERSION
1333 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1333 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1334 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), 1334 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"),
1335 i18n("Import!"), i18n("Cancel"), 0, 1335 i18n("Import!"), i18n("Cancel"), 0,
1336 0, 1 ); 1336 0, 1 );
1337 if ( result == 0 ) { 1337 if ( result == 0 ) {
1338 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1338 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1339 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1339 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1340 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1340 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1341 mView->importQtopia( categories, datebook, todolist ); 1341 mView->importQtopia( categories, datebook, todolist );
1342 } 1342 }
1343#else 1343#else
1344 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1344 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1345 i18n("Not supported \non desktop!\n"), 1345 i18n("Not supported \non desktop!\n"),
1346 i18n("Ok"), i18n("Cancel"), 0, 1346 i18n("Ok"), i18n("Cancel"), 0,
1347 0, 1 ); 1347 0, 1 );
1348 1348
1349#endif 1349#endif
1350} 1350}
1351 1351
1352void MainWindow::saveOnClose() 1352void MainWindow::saveOnClose()
1353{ 1353{
1354 KOPrefs *p = KOPrefs::instance(); 1354 KOPrefs *p = KOPrefs::instance();
1355 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1355 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1356 p->mToolBarUp = iconToolBar->x() > width()/2 || 1356 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1357 iconToolBar->y() > height()/2; 1357 iconToolBar->y() > height()/2;
1358 mView->writeSettings(); 1358 mView->writeSettings();
1359 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1359 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1360 save(); 1360 save();
1361} 1361}
1362void MainWindow::slotModifiedChanged( bool changed ) 1362void MainWindow::slotModifiedChanged( bool changed )
1363{ 1363{
1364 if ( mBlockAtStartup ) 1364 if ( mBlockAtStartup )
1365 return; 1365 return;
1366 int msec; 1366 int msec;
1367 // we store the changes after 1 minute, 1367 // we store the changes after 1 minute,
1368 // and for safety reasons after 10 minutes again 1368 // and for safety reasons after 10 minutes again
1369 if ( !mSyncManager->blockSave() ) 1369 if ( !mSyncManager->blockSave() )
1370 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1370 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1371 else 1371 else
1372 msec = 1000 * 600; 1372 msec = 1000 * 600;
1373 mSaveTimer.start( msec, true ); // 1 minute 1373 mSaveTimer.start( msec, true ); // 1 minute
1374 qDebug("KO: Saving File in %d secs!", msec/1000); 1374 qDebug("KO: Saving File in %d secs!", msec/1000);
1375 mCalendarModifiedFlag = true; 1375 mCalendarModifiedFlag = true;
1376} 1376}
1377void MainWindow::save() 1377void MainWindow::save()
1378{ 1378{
1379 if ( mSyncManager->blockSave() ) 1379 if ( mSyncManager->blockSave() )
1380 return; 1380 return;
1381 mSyncManager->setBlockSave(true); 1381 mSyncManager->setBlockSave(true);
1382 if ( mView->checkFileVersion( defaultFileName()) ) { 1382 if ( mView->checkFileVersion( defaultFileName()) ) {
1383 1383
1384 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1384 QTime neededSaveTime = QDateTime::currentDateTime().time();
1385 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1385 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1386 qDebug("KO: Start saving data to file!"); 1386 qDebug("KO: Start saving data to file!");
1387 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1388 mView->saveCalendar( defaultFileName() ); 1387 mView->saveCalendar( defaultFileName() );
1389 1388
1390 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1389 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1391 mView->watchSavedFile();
1392 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1390 qDebug("KO: Needed %d ms for saving.",msNeeded );
1393 QString savemes; 1391 QString savemes;
1394 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1392 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1395 setCaption(savemes); 1393 setCaption(savemes);
1396 } else 1394 } else
1397 setCaption(i18n("Saving cancelled!")); 1395 setCaption(i18n("Saving cancelled!"));
1398 mCalendarModifiedFlag = false; 1396 mCalendarModifiedFlag = false;
1399 mSyncManager->setBlockSave( false ); 1397 mSyncManager->setBlockSave( false );
1400} 1398}
1401 1399
1402void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1400void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1403{ 1401{
1404 if ( !e->isAutoRepeat() ) { 1402 if ( !e->isAutoRepeat() ) {
1405 mFlagKeyPressed = false; 1403 mFlagKeyPressed = false;
1406 } 1404 }
1407} 1405}
1408void MainWindow::keyPressEvent ( QKeyEvent * e ) 1406void MainWindow::keyPressEvent ( QKeyEvent * e )
1409{ 1407{
1410 qApp->processEvents(); 1408 qApp->processEvents();
1411 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1409 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1412 e->ignore(); 1410 e->ignore();
1413 // qDebug(" ignore %d",e->isAutoRepeat() ); 1411 // qDebug(" ignore %d",e->isAutoRepeat() );
1414 return; 1412 return;
1415 } 1413 }
1416 if (! e->isAutoRepeat() ) 1414 if (! e->isAutoRepeat() )
1417 mFlagKeyPressed = true; 1415 mFlagKeyPressed = true;
1418 KOPrefs *p = KOPrefs::instance(); 1416 KOPrefs *p = KOPrefs::instance();
1419 bool showSelectedDates = false; 1417 bool showSelectedDates = false;
1420 int size; 1418 int size;
1421 int pro = 0; 1419 int pro = 0;
1422 //qDebug("MainWindow::keyPressEvent "); 1420 //qDebug("MainWindow::keyPressEvent ");
1423 switch ( e->key() ) { 1421 switch ( e->key() ) {
1424 case Qt::Key_Right: 1422 case Qt::Key_Right:
1425 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1423 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1426 mView->goNextMonth(); 1424 mView->goNextMonth();
1427 else 1425 else
1428 mView->goNext(); 1426 mView->goNext();
1429 showSelectedDates = true; 1427 showSelectedDates = true;
1430 break; 1428 break;
1431 case Qt::Key_Left: 1429 case Qt::Key_Left:
1432 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1430 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1433 mView->goPreviousMonth(); 1431 mView->goPreviousMonth();
1434 else 1432 else
1435 mView->goPrevious(); 1433 mView->goPrevious();
1436 showSelectedDates = true; 1434 showSelectedDates = true;
1437 break; 1435 break;
1438 case Qt::Key_Down: 1436 case Qt::Key_Down:
1439 mView->viewManager()->agendaView()->scrollOneHourDown(); 1437 mView->viewManager()->agendaView()->scrollOneHourDown();
1440 break; 1438 break;
1441 case Qt::Key_Up: 1439 case Qt::Key_Up:
1442 mView->viewManager()->agendaView()->scrollOneHourUp(); 1440 mView->viewManager()->agendaView()->scrollOneHourUp();
1443 break; 1441 break;
1444 case Qt::Key_I: 1442 case Qt::Key_I:
1445 mView->showIncidence(); 1443 mView->showIncidence();
1446 break; 1444 break;
1447 case Qt::Key_Delete: 1445 case Qt::Key_Delete:
1448 case Qt::Key_Backspace: 1446 case Qt::Key_Backspace:
1449 mView->deleteIncidence(); 1447 mView->deleteIncidence();
1450 break; 1448 break;
1451 case Qt::Key_D: 1449 case Qt::Key_D:
1452 mView->viewManager()->showDayView(); 1450 mView->viewManager()->showDayView();
1453 showSelectedDates = true; 1451 showSelectedDates = true;
1454 break; 1452 break;
1455 case Qt::Key_O: 1453 case Qt::Key_O:
1456 mView->toggleFilerEnabled( ); 1454 mView->toggleFilerEnabled( );
1457 break; 1455 break;
1458 case Qt::Key_0: 1456 case Qt::Key_0:
1459 case Qt::Key_1: 1457 case Qt::Key_1:
1460 case Qt::Key_2: 1458 case Qt::Key_2:
1461 case Qt::Key_3: 1459 case Qt::Key_3:
1462 case Qt::Key_4: 1460 case Qt::Key_4:
1463 case Qt::Key_5: 1461 case Qt::Key_5:
1464 case Qt::Key_6: 1462 case Qt::Key_6:
1465 case Qt::Key_7: 1463 case Qt::Key_7:
1466 case Qt::Key_8: 1464 case Qt::Key_8:
1467 case Qt::Key_9: 1465 case Qt::Key_9:
1468 pro = e->key()-48; 1466 pro = e->key()-48;
1469 if ( pro == 0 ) 1467 if ( pro == 0 )
1470 pro = 10; 1468 pro = 10;
1471 if ( e->state() == Qt::ControlButton) 1469 if ( e->state() == Qt::ControlButton)
1472 pro += 10; 1470 pro += 10;
1473 break; 1471 break;
1474 case Qt::Key_M: 1472 case Qt::Key_M:
1475 mView->viewManager()->showMonthView(); 1473 mView->viewManager()->showMonthView();
1476 showSelectedDates = true; 1474 showSelectedDates = true;
1477 break; 1475 break;
1478 case Qt::Key_Insert: 1476 case Qt::Key_Insert:
1479 mView->newEvent(); 1477 mView->newEvent();
1480 break; 1478 break;
1481 case Qt::Key_S : 1479 case Qt::Key_S :
1482 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1480 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1483 mView->newSubTodo(); 1481 mView->newSubTodo();
1484 else 1482 else
1485 mView->dialogManager()->showSearchDialog(); 1483 mView->dialogManager()->showSearchDialog();
1486 break; 1484 break;
1487 case Qt::Key_Y : 1485 case Qt::Key_Y :
1488 case Qt::Key_Z : 1486 case Qt::Key_Z :
1489 mView->viewManager()->showWorkWeekView(); 1487 mView->viewManager()->showWorkWeekView();
1490 showSelectedDates = true; 1488 showSelectedDates = true;
1491 break; 1489 break;
1492 case Qt::Key_U : 1490 case Qt::Key_U :
1493 mView->viewManager()->showWeekView(); 1491 mView->viewManager()->showWeekView();
1494 showSelectedDates = true; 1492 showSelectedDates = true;
1495 break; 1493 break;
1496 case Qt::Key_H : 1494 case Qt::Key_H :
1497 keyBindings(); 1495 keyBindings();
1498 break; 1496 break;
1499 case Qt::Key_W: 1497 case Qt::Key_W:
1500 mView->viewManager()->showWhatsNextView(); 1498 mView->viewManager()->showWhatsNextView();
1501 break; 1499 break;
1502 case Qt::Key_L: 1500 case Qt::Key_L:
1503 mView->viewManager()->showListView(); 1501 mView->viewManager()->showListView();
1504 break; 1502 break;
1505 case Qt::Key_N: 1503 case Qt::Key_N:
1506 mView->viewManager()->showNextXView(); 1504 mView->viewManager()->showNextXView();
1507 showSelectedDates = true; 1505 showSelectedDates = true;
1508 break; 1506 break;
1509 case Qt::Key_V: 1507 case Qt::Key_V:
1510 mView->viewManager()->showTodoView(); 1508 mView->viewManager()->showTodoView();
1511 break; 1509 break;
1512 case Qt::Key_C: 1510 case Qt::Key_C:
1513 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1511 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1514 break; 1512 break;
1515 case Qt::Key_P: 1513 case Qt::Key_P:
1516 mView->showDatePicker( ); 1514 mView->showDatePicker( );
1517 break; 1515 break;
1518 case Qt::Key_F: 1516 case Qt::Key_F:
1519 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1517 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1520 mView->editFilters(); 1518 mView->editFilters();
1521 else 1519 else
1522 mView->toggleFilter(); 1520 mView->toggleFilter();
1523 break; 1521 break;
1524 case Qt::Key_X: 1522 case Qt::Key_X:
1525 mView->toggleDateNavigatorWidget(); 1523 mView->toggleDateNavigatorWidget();
1526 break; 1524 break;
1527 case Qt::Key_Space: 1525 case Qt::Key_Space:
1528 mView->toggleExpand(); 1526 mView->toggleExpand();
1529 break; 1527 break;
1530 case Qt::Key_A: 1528 case Qt::Key_A:
1531 mView->toggleAllDaySize(); 1529 mView->toggleAllDaySize();
1532 break; 1530 break;
1533 case Qt::Key_T: 1531 case Qt::Key_T:
1534 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1532 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1535 mView->newTodo(); 1533 mView->newTodo();
1536 else { 1534 else {
1537 mView->goToday(); 1535 mView->goToday();
1538 showSelectedDates = true; 1536 showSelectedDates = true;
1539 } 1537 }
1540 break; 1538 break;
1541 case Qt::Key_J: 1539 case Qt::Key_J:
1542 mView->viewManager()->showJournalView(); 1540 mView->viewManager()->showJournalView();
1543 break; 1541 break;
1544 case Qt::Key_B: 1542 case Qt::Key_B:
1545 mView->editIncidenceDescription();; 1543 mView->editIncidenceDescription();;
1546 break; 1544 break;
1547 // case Qt::Key_Return: 1545 // case Qt::Key_Return:
1548 case Qt::Key_E: 1546 case Qt::Key_E:
1549 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1547 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1550 mView->newEvent(); 1548 mView->newEvent();
1551 else 1549 else
1552 mView->editIncidence(); 1550 mView->editIncidence();
1553 break; 1551 break;
1554 case Qt::Key_Plus: 1552 case Qt::Key_Plus:
1555 size = p->mHourSize +2; 1553 size = p->mHourSize +2;
1556 if ( size <= 18 ) 1554 if ( size <= 18 )
1557 configureAgenda( size ); 1555 configureAgenda( size );
1558 break; 1556 break;
1559 case Qt::Key_Minus: 1557 case Qt::Key_Minus:
1560 size = p->mHourSize - 2; 1558 size = p->mHourSize - 2;
1561 if ( size >= 4 ) 1559 if ( size >= 4 )
1562 configureAgenda( size ); 1560 configureAgenda( size );
1563 break; 1561 break;
1564 1562
1565 1563
1566 default: 1564 default:
1567 e->ignore(); 1565 e->ignore();
1568 } 1566 }
1569 if ( pro > 0 ) { 1567 if ( pro > 0 ) {
1570 mView->selectFilter( pro-1 ); 1568 mView->selectFilter( pro-1 );
1571 } 1569 }
1572 if ( showSelectedDates ) { 1570 if ( showSelectedDates ) {
1573 ;// setCaptionToDates(); 1571 ;// setCaptionToDates();
1574 } 1572 }
1575 1573
1576} 1574}
1577 1575
1578void MainWindow::fillFilterMenu() 1576void MainWindow::fillFilterMenu()
1579{ 1577{
1580 selectFilterMenu->clear(); 1578 selectFilterMenu->clear();
1581 bool disable = false; 1579 bool disable = false;
1582 if ( mView->filterView()->filtersEnabled() ) { 1580 if ( mView->filterView()->filtersEnabled() ) {
1583 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1581 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1584 } 1582 }
1585 else { 1583 else {
1586 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1584 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1587 disable = true; 1585 disable = true;
1588 } 1586 }
1589 selectFilterMenu->insertSeparator(); 1587 selectFilterMenu->insertSeparator();
1590 QPtrList<CalFilter> fili = mView->filters(); 1588 QPtrList<CalFilter> fili = mView->filters();
1591 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1589 CalFilter *curfilter = mView->filterView()->selectedFilter();
1592 CalFilter *filter = fili.first(); 1590 CalFilter *filter = fili.first();
1593 int iii = 1; 1591 int iii = 1;
1594 while(filter) { 1592 while(filter) {
1595 selectFilterMenu->insertItem( filter->name(), iii ); 1593 selectFilterMenu->insertItem( filter->name(), iii );
1596 if ( filter == curfilter) 1594 if ( filter == curfilter)
1597 selectFilterMenu->setItemChecked( iii, true ); 1595 selectFilterMenu->setItemChecked( iii, true );
1598 if ( disable ) 1596 if ( disable )
1599 selectFilterMenu->setItemEnabled( iii, false ); 1597 selectFilterMenu->setItemEnabled( iii, false );
1600 filter = fili.next(); 1598 filter = fili.next();
1601 ++iii; 1599 ++iii;
1602 } 1600 }
1603} 1601}
1604void MainWindow::selectFilter( int fil ) 1602void MainWindow::selectFilter( int fil )
1605{ 1603{
1606 if ( fil == 0 ) { 1604 if ( fil == 0 ) {
1607 mView->toggleFilerEnabled( ); 1605 mView->toggleFilerEnabled( );
1608 } else { 1606 } else {
1609 mView->selectFilter( fil-1 ); 1607 mView->selectFilter( fil-1 );
1610 } 1608 }
1611} 1609}
1612void MainWindow::configureToolBar( int item ) 1610void MainWindow::configureToolBar( int item )
1613{ 1611{
1614 1612
1615 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1613 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1616 KOPrefs *p = KOPrefs::instance(); 1614 KOPrefs *p = KOPrefs::instance();
1617 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1615 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1618 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1616 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1619 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1617 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1620 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1618 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1621 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1619 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1622 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1620 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1623 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1621 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1624 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1622 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1625 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1623 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1626 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1624 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1627 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1625 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1628 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1626 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1629 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1627 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1630 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1628 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1631 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1629 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1632 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1630 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1633 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1631 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1634 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1632 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1635 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1633 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1636 // initActions(); 1634 // initActions();
1637} 1635}
1638 1636
1639void MainWindow::setCaptionToDates() 1637void MainWindow::setCaptionToDates()
1640{ 1638{
1641 QString selDates; 1639 QString selDates;
1642 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1640 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1643 if (mView->startDate() < mView->endDate() ) 1641 if (mView->startDate() < mView->endDate() )
1644 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1642 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1645 setCaption( i18n("Dates: ") + selDates ); 1643 setCaption( i18n("Dates: ") + selDates );
1646 1644
1647} 1645}
1648// parameter item == 0: reinit 1646// parameter item == 0: reinit
1649void MainWindow::configureAgenda( int item ) 1647void MainWindow::configureAgenda( int item )
1650{ 1648{
1651 1649
1652 KOPrefs *p = KOPrefs::instance(); 1650 KOPrefs *p = KOPrefs::instance();
1653 1651
1654 int i; 1652 int i;
1655 if ( item == 1 ) { 1653 if ( item == 1 ) {
1656 mView->toggleAllDaySize(); 1654 mView->toggleAllDaySize();
1657 return; 1655 return;
1658 } 1656 }
1659 // do not allow 4 for widgets higher than 480 1657 // do not allow 4 for widgets higher than 480
1660 // if ( QApplication::desktop()->height() > 480 ) { 1658 // if ( QApplication::desktop()->height() > 480 ) {
1661// if ( item == 4 ) 1659// if ( item == 4 )
1662// item = 6; 1660// item = 6;
1663// } 1661// }
1664 for ( i = 4; i <= 18; i= i+2 ) 1662 for ( i = 4; i <= 18; i= i+2 )
1665 configureAgendaMenu->setItemChecked( i, false ); 1663 configureAgendaMenu->setItemChecked( i, false );
1666 configureAgendaMenu->setItemChecked( item, true ); 1664 configureAgendaMenu->setItemChecked( item, true );
1667 if ( p->mHourSize == item ) 1665 if ( p->mHourSize == item )
1668 return; 1666 return;
1669 p->mHourSize=item; 1667 p->mHourSize=item;
1670 mView->viewManager()->agendaView()->updateConfig(); 1668 mView->viewManager()->agendaView()->updateConfig();
1671} 1669}
1672 1670
1673void MainWindow::saveCalendar() 1671void MainWindow::saveCalendar()
1674{ 1672{
1675 QString fn = KOPrefs::instance()->mLastSaveFile; 1673 QString fn = KOPrefs::instance()->mLastSaveFile;
1676 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1674 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1677 1675
1678 if ( fn == "" ) 1676 if ( fn == "" )
1679 return; 1677 return;
1680 QFileInfo info; 1678 QFileInfo info;
1681 info.setFile( fn ); 1679 info.setFile( fn );
1682 QString mes; 1680 QString mes;
1683 bool createbup = true; 1681 bool createbup = true;
1684 if ( info. exists() ) { 1682 if ( info. exists() ) {
1685 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1683 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1686 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1684 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1687 i18n("Overwrite!"), i18n("Cancel"), 0, 1685 i18n("Overwrite!"), i18n("Cancel"), 0,
1688 0, 1 ); 1686 0, 1 );
1689 if ( result != 0 ) { 1687 if ( result != 0 ) {
1690 createbup = false; 1688 createbup = false;
1691 } 1689 }
1692 } 1690 }
1693 if ( createbup ) { 1691 if ( createbup ) {
1694 mView->saveCalendar( fn ); 1692 mView->saveCalendar( fn );
1695 mes = i18n("KO/Pi:Saved %1").arg(fn); 1693 mes = i18n("KO/Pi:Saved %1").arg(fn);
1696 KOPrefs::instance()->mLastSaveFile = fn; 1694 KOPrefs::instance()->mLastSaveFile = fn;
1697 setCaption(mes); 1695 setCaption(mes);
1698 } 1696 }
1699} 1697}
1700void MainWindow::loadCalendar() 1698void MainWindow::loadCalendar()
1701{ 1699{
1702 1700
1703 QString fn = KOPrefs::instance()->mLastLoadFile; 1701 QString fn = KOPrefs::instance()->mLastLoadFile;
1704 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1702 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1705 1703
1706 if ( fn == "" ) 1704 if ( fn == "" )
1707 return; 1705 return;
1708 QFileInfo info; 1706 QFileInfo info;
1709 info.setFile( fn ); 1707 info.setFile( fn );
1710 QString mess; 1708 QString mess;
1711 bool loadbup = true; 1709 bool loadbup = true;
1712 if ( info. exists() ) { 1710 if ( info. exists() ) {
1713 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1711 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1714 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1712 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1715 mess, 1713 mess,
1716 i18n("Load!"), i18n("Cancel"), 0, 1714 i18n("Load!"), i18n("Cancel"), 0,
1717 0, 1 ); 1715 0, 1 );
1718 if ( result != 0 ) { 1716 if ( result != 0 ) {
1719 loadbup = false; 1717 loadbup = false;
1720 } 1718 }
1721 } else { 1719 } else {
1722 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1720 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1723 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1721 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1724 0, 1 ); 1722 0, 1 );
1725 1723
1726 return; 1724 return;
1727 } 1725 }
1728 if ( loadbup ) { 1726 if ( loadbup ) {
1729 mView->openCalendar( fn ); 1727 mView->openCalendar( fn );
1730 KOPrefs::instance()->mLastLoadFile = fn; 1728 KOPrefs::instance()->mLastLoadFile = fn;
1731 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1729 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1732 setCaption(mess); 1730 setCaption(mess);
1733 } 1731 }
1734 1732
1735} 1733}
1736void MainWindow::quickImportIcal() 1734void MainWindow::quickImportIcal()
1737{ 1735{
1738 importFile( KOPrefs::instance()->mLastImportFile, false ); 1736 importFile( KOPrefs::instance()->mLastImportFile, false );
1739} 1737}
1740void MainWindow::importFile( QString fn, bool quick ) 1738void MainWindow::importFile( QString fn, bool quick )
1741{ 1739{
1742 QFileInfo info; 1740 QFileInfo info;
1743 info.setFile( fn ); 1741 info.setFile( fn );
1744 QString mess; 1742 QString mess;
1745 bool loadbup = true; 1743 bool loadbup = true;
1746 if ( !info. exists() ) { 1744 if ( !info. exists() ) {
1747 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1745 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1748 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1746 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1749 mess ); 1747 mess );
1750 return; 1748 return;
1751 } 1749 }
1752 int result = 0; 1750 int result = 0;
1753 if ( !quick ) { 1751 if ( !quick ) {
1754 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1752 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1755 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1753 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1756 mess, 1754 mess,
1757 "Import", "Cancel", 0, 1755 "Import", "Cancel", 0,
1758 0, 1 ); 1756 0, 1 );
1759 } 1757 }
1760 if ( result == 0 ) { 1758 if ( result == 0 ) {
1761 if ( mView->openCalendar( fn, true )) { 1759 if ( mView->openCalendar( fn, true )) {
1762 KOPrefs::instance()->mLastImportFile = fn; 1760 KOPrefs::instance()->mLastImportFile = fn;
1763 setCaption(i18n("Imported file successfully")); 1761 setCaption(i18n("Imported file successfully"));
1764 } else { 1762 } else {
1765 setCaption(i18n("Error importing file")); 1763 setCaption(i18n("Error importing file"));
1766 } 1764 }
1767 } 1765 }
1768} 1766}
1769 1767
1770void MainWindow::importIcal() 1768void MainWindow::importIcal()
1771{ 1769{
1772 1770
1773 QString fn =KOPrefs::instance()->mLastImportFile; 1771 QString fn =KOPrefs::instance()->mLastImportFile;
1774 1772
1775 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1773 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1776 if ( fn == "" ) 1774 if ( fn == "" )
1777 return; 1775 return;
1778 importFile( fn, true ); 1776 importFile( fn, true );
1779 1777
1780} 1778}
1781 1779
1782void MainWindow::exportVCalendar() 1780void MainWindow::exportVCalendar()
1783{ 1781{
1784 QString fn = KOPrefs::instance()->mLastVcalFile; 1782 QString fn = KOPrefs::instance()->mLastVcalFile;
1785 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1783 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1786 if ( fn == "" ) 1784 if ( fn == "" )
1787 return; 1785 return;
1788 QFileInfo info; 1786 QFileInfo info;
1789 info.setFile( fn ); 1787 info.setFile( fn );
1790 QString mes; 1788 QString mes;
1791 bool createbup = true; 1789 bool createbup = true;
1792 if ( info. exists() ) { 1790 if ( info. exists() ) {
1793 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1791 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1794 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1792 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1795 i18n("Overwrite!"), i18n("Cancel"), 0, 1793 i18n("Overwrite!"), i18n("Cancel"), 0,
1796 0, 1 ); 1794 0, 1 );
1797 if ( result != 0 ) { 1795 if ( result != 0 ) {
1798 createbup = false; 1796 createbup = false;
1799 } 1797 }
1800 } 1798 }
1801 if ( createbup ) { 1799 if ( createbup ) {
1802 if ( mView->exportVCalendar( fn ) ) { 1800 if ( mView->exportVCalendar( fn ) ) {
1803 KOPrefs::instance()->mLastVcalFile = fn; 1801 KOPrefs::instance()->mLastVcalFile = fn;
1804 if ( fn.length() > 20 ) 1802 if ( fn.length() > 20 )
1805 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1803 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1806 else 1804 else
1807 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1805 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1808 setCaption(mes); 1806 setCaption(mes);
1809 } 1807 }
1810 } 1808 }
1811 1809
1812} 1810}
1813 1811
1814void MainWindow::syncFileRequest() 1812void MainWindow::syncFileRequest()
1815{ 1813{
1816 save(); 1814 save();
1817} 1815}
1818void MainWindow::getFile( bool success ) 1816void MainWindow::getFile( bool success )
1819{ 1817{
1820 if ( ! success ) { 1818 if ( ! success ) {
1821 setCaption( i18n("Error receiving file. Nothing changed!") ); 1819 setCaption( i18n("Error receiving file. Nothing changed!") );
1822 return; 1820 return;
1823 } 1821 }
1824 mView->watchSavedFile();
1825 mView->openCalendar( defaultFileName() ); 1822 mView->openCalendar( defaultFileName() );
1826 setCaption( i18n("Pi-Sync successful!") ); 1823 setCaption( i18n("Pi-Sync successful!") );
1827
1828} 1824}
1829 1825
1830void MainWindow::printSel( ) 1826void MainWindow::printSel( )
1831{ 1827{
1832 mView->viewManager()->agendaView()->agenda()->printSelection(); 1828 mView->viewManager()->agendaView()->agenda()->printSelection();
1833} 1829}
1834 1830
1835void MainWindow::printCal() 1831void MainWindow::printCal()
1836{ 1832{
1837 mView->print();//mCp->showDialog(); 1833 mView->print();//mCp->showDialog();
1838} 1834}
1839 1835