-rw-r--r-- | korganizer/calendarview.cpp | 58 | ||||
-rw-r--r-- | korganizer/filtereditdialog.cpp | 7 | ||||
-rw-r--r-- | libkcal/calfilter.cpp | 29 | ||||
-rw-r--r-- | libkcal/calfilter.h | 3 |
4 files changed, 62 insertions, 35 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 8258c74..02c5e45 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -312,1615 +312,1623 @@ void CalendarView::init() | |||
312 | leftFrameLayout->addWidget( mDateNavigator ); | 312 | leftFrameLayout->addWidget( mDateNavigator ); |
313 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 313 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
314 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); | 314 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); |
315 | mTodoList->setNavigator( mNavigator ); | 315 | mTodoList->setNavigator( mNavigator ); |
316 | 316 | ||
317 | if ( QApplication::desktop()->width() < 480 ) { | 317 | if ( QApplication::desktop()->width() < 480 ) { |
318 | leftFrameLayout->addWidget(mFilterView); | 318 | leftFrameLayout->addWidget(mFilterView); |
319 | leftFrameLayout->addWidget(mTodoList, 2 ); | 319 | leftFrameLayout->addWidget(mTodoList, 2 ); |
320 | 320 | ||
321 | } else { | 321 | } else { |
322 | leftFrameLayout->addWidget(mTodoList,2 ); | 322 | leftFrameLayout->addWidget(mTodoList,2 ); |
323 | leftFrameLayout->addWidget(mFilterView ); | 323 | leftFrameLayout->addWidget(mFilterView ); |
324 | } | 324 | } |
325 | mFilterView->hide(); | 325 | mFilterView->hide(); |
326 | QWidget *rightBox = new QWidget( mainBox ); | 326 | QWidget *rightBox = new QWidget( mainBox ); |
327 | mainBoxLayout->addWidget ( rightBox, 10 ); | 327 | mainBoxLayout->addWidget ( rightBox, 10 ); |
328 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 328 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
329 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 329 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
330 | mRightFrame = new QWidgetStack( rightBox ); | 330 | mRightFrame = new QWidgetStack( rightBox ); |
331 | rightLayout->addWidget( mNavigatorBar ); | 331 | rightLayout->addWidget( mNavigatorBar ); |
332 | rightLayout->addWidget( mRightFrame, 10 ); | 332 | rightLayout->addWidget( mRightFrame, 10 ); |
333 | 333 | ||
334 | mLeftFrame = leftFrame; | 334 | mLeftFrame = leftFrame; |
335 | if ( KOPrefs::instance()->mVerticalScreen ) { | 335 | if ( KOPrefs::instance()->mVerticalScreen ) { |
336 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 336 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
337 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 337 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
338 | } else { | 338 | } else { |
339 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 339 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
340 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 340 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
341 | } | 341 | } |
342 | 342 | ||
343 | //qDebug("Calendarview Size %d %d ", width(), height()); | 343 | //qDebug("Calendarview Size %d %d ", width(), height()); |
344 | #endif | 344 | #endif |
345 | 345 | ||
346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
347 | SLOT( showDates( const KCal::DateList & ) ) ); | 347 | SLOT( showDates( const KCal::DateList & ) ) ); |
348 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 348 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
349 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 349 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
350 | 350 | ||
351 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 351 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
352 | mNavigator, SLOT( selectPreviousYear() ) ); | 352 | mNavigator, SLOT( selectPreviousYear() ) ); |
353 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 353 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
354 | mNavigator, SLOT( selectNextYear() ) ); | 354 | mNavigator, SLOT( selectNextYear() ) ); |
355 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 355 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
356 | mNavigator, SLOT( selectPreviousMonth() ) ); | 356 | mNavigator, SLOT( selectPreviousMonth() ) ); |
357 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 357 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
358 | mNavigator, SLOT( selectNextMonth() ) ); | 358 | mNavigator, SLOT( selectNextMonth() ) ); |
359 | 359 | ||
360 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 360 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
361 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 361 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
362 | 362 | ||
363 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 363 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
364 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 364 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
365 | 365 | ||
366 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 366 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
367 | mNavigator, SLOT( selectPreviousYear() ) ); | 367 | mNavigator, SLOT( selectPreviousYear() ) ); |
368 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 368 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
369 | mNavigator, SLOT( selectNextYear() ) ); | 369 | mNavigator, SLOT( selectNextYear() ) ); |
370 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 370 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
371 | mNavigator, SLOT( selectPreviousMonth() ) ); | 371 | mNavigator, SLOT( selectPreviousMonth() ) ); |
372 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 372 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
373 | mNavigator, SLOT( selectNextMonth() ) ); | 373 | mNavigator, SLOT( selectNextMonth() ) ); |
374 | 374 | ||
375 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 375 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
376 | mNavigator, SLOT( selectPrevious() ) ); | 376 | mNavigator, SLOT( selectPrevious() ) ); |
377 | connect( mDateNavigator, SIGNAL( goNext() ), | 377 | connect( mDateNavigator, SIGNAL( goNext() ), |
378 | mNavigator, SLOT( selectNext() ) ); | 378 | mNavigator, SLOT( selectNext() ) ); |
379 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 379 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
381 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 381 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
382 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 382 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
383 | 383 | ||
384 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 384 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
385 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 385 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
386 | 386 | ||
387 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 387 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
388 | SLOT( eventAdded( Event *) ) ); | 388 | SLOT( eventAdded( Event *) ) ); |
389 | 389 | ||
390 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 390 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
391 | 391 | ||
392 | connect( this, SIGNAL( configChanged() ), | 392 | connect( this, SIGNAL( configChanged() ), |
393 | mDateNavigator, SLOT( updateConfig() ) ); | 393 | mDateNavigator, SLOT( updateConfig() ) ); |
394 | 394 | ||
395 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 395 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
396 | SLOT( newTodo() ) ); | 396 | SLOT( newTodo() ) ); |
397 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 397 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
398 | SLOT( newSubTodo( Todo * ) ) ); | 398 | SLOT( newSubTodo( Todo * ) ) ); |
399 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 399 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
400 | SLOT( editTodo( Todo * ) ) ); | 400 | SLOT( editTodo( Todo * ) ) ); |
401 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 401 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
402 | SLOT( showTodo( Todo *) ) ); | 402 | SLOT( showTodo( Todo *) ) ); |
403 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 403 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
404 | SLOT( deleteTodo( Todo *) ) ); | 404 | SLOT( deleteTodo( Todo *) ) ); |
405 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 405 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
406 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 406 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
407 | SLOT( purgeCompleted() ) ); | 407 | SLOT( purgeCompleted() ) ); |
408 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 408 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
409 | SIGNAL( todoModified( Todo *, int ) ) ); | 409 | SIGNAL( todoModified( Todo *, int ) ) ); |
410 | 410 | ||
411 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 411 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
412 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 412 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
413 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 413 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
414 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 414 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
415 | 415 | ||
416 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 416 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
417 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 417 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
418 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 418 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
419 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 419 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
420 | 420 | ||
421 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 421 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
422 | this, SLOT ( todo_unsub( Todo * ) ) ); | 422 | this, SLOT ( todo_unsub( Todo * ) ) ); |
423 | 423 | ||
424 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 424 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
425 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 425 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
426 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 426 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
427 | SLOT( updateTodo( Todo *, int ) ) ); | 427 | SLOT( updateTodo( Todo *, int ) ) ); |
428 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 428 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
429 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 429 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
430 | 430 | ||
431 | 431 | ||
432 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 432 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
433 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 433 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
434 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 434 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
435 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 435 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
436 | 436 | ||
437 | 437 | ||
438 | 438 | ||
439 | 439 | ||
440 | 440 | ||
441 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 441 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
442 | SLOT(checkClipboard())); | 442 | SLOT(checkClipboard())); |
443 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 443 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
444 | SLOT( processTodoListSelection( Incidence * ) ) ); | 444 | SLOT( processTodoListSelection( Incidence * ) ) ); |
445 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 445 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
446 | 446 | ||
447 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 447 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
448 | 448 | ||
449 | mDateFrame = new QVBox(0,0,WType_Popup); | 449 | mDateFrame = new QVBox(0,0,WType_Popup); |
450 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 450 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
451 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 451 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
452 | mDateFrame->setLineWidth(3); | 452 | mDateFrame->setLineWidth(3); |
453 | mDateFrame->hide(); | 453 | mDateFrame->hide(); |
454 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 454 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
455 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 455 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
456 | 456 | ||
457 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 457 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
458 | 458 | ||
459 | mEventEditor = mDialogManager->getEventEditor(); | 459 | mEventEditor = mDialogManager->getEventEditor(); |
460 | mTodoEditor = mDialogManager->getTodoEditor(); | 460 | mTodoEditor = mDialogManager->getTodoEditor(); |
461 | 461 | ||
462 | mFlagEditDescription = false; | 462 | mFlagEditDescription = false; |
463 | 463 | ||
464 | mSuspendTimer = new QTimer( this ); | 464 | mSuspendTimer = new QTimer( this ); |
465 | mAlarmTimer = new QTimer( this ); | 465 | mAlarmTimer = new QTimer( this ); |
466 | mRecheckAlarmTimer = new QTimer( this ); | 466 | mRecheckAlarmTimer = new QTimer( this ); |
467 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 467 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
468 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 468 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
469 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 469 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
470 | mAlarmDialog = new AlarmDialog( this ); | 470 | mAlarmDialog = new AlarmDialog( this ); |
471 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 471 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
472 | mAlarmDialog->setServerNotification( false ); | 472 | mAlarmDialog->setServerNotification( false ); |
473 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 473 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
474 | 474 | ||
475 | 475 | ||
476 | #ifndef DESKTOP_VERSION | 476 | #ifndef DESKTOP_VERSION |
477 | //US listen for arriving address resultsets | 477 | //US listen for arriving address resultsets |
478 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 478 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
479 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 479 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
480 | #endif | 480 | #endif |
481 | 481 | ||
482 | } | 482 | } |
483 | 483 | ||
484 | 484 | ||
485 | CalendarView::~CalendarView() | 485 | CalendarView::~CalendarView() |
486 | { | 486 | { |
487 | // kdDebug() << "~CalendarView()" << endl; | 487 | // kdDebug() << "~CalendarView()" << endl; |
488 | //qDebug("CalendarView::~CalendarView() "); | 488 | //qDebug("CalendarView::~CalendarView() "); |
489 | delete mDialogManager; | 489 | delete mDialogManager; |
490 | delete mViewManager; | 490 | delete mViewManager; |
491 | delete mStorage; | 491 | delete mStorage; |
492 | delete mDateFrame ; | 492 | delete mDateFrame ; |
493 | delete beamDialog; | 493 | delete beamDialog; |
494 | //kdDebug() << "~CalendarView() done" << endl; | 494 | //kdDebug() << "~CalendarView() done" << endl; |
495 | } | 495 | } |
496 | 496 | ||
497 | void CalendarView::showDay( QDate d ) | 497 | void CalendarView::showDay( QDate d ) |
498 | { | 498 | { |
499 | dateNavigator()->selectDate( d ); | 499 | dateNavigator()->selectDate( d ); |
500 | mViewManager->showWeekView(); | 500 | mViewManager->showWeekView(); |
501 | dateNavigator()->selectDate( d ); | 501 | dateNavigator()->selectDate( d ); |
502 | } | 502 | } |
503 | void CalendarView::timerAlarm() | 503 | void CalendarView::timerAlarm() |
504 | { | 504 | { |
505 | //qDebug("CalendarView::timerAlarm() "); | 505 | //qDebug("CalendarView::timerAlarm() "); |
506 | computeAlarm(mAlarmNotification ); | 506 | computeAlarm(mAlarmNotification ); |
507 | } | 507 | } |
508 | 508 | ||
509 | void CalendarView::suspendAlarm() | 509 | void CalendarView::suspendAlarm() |
510 | { | 510 | { |
511 | //qDebug(" CalendarView::suspendAlarm() "); | 511 | //qDebug(" CalendarView::suspendAlarm() "); |
512 | computeAlarm(mSuspendAlarmNotification ); | 512 | computeAlarm(mSuspendAlarmNotification ); |
513 | 513 | ||
514 | } | 514 | } |
515 | 515 | ||
516 | void CalendarView::startAlarm( QString mess , QString filename) | 516 | void CalendarView::startAlarm( QString mess , QString filename) |
517 | { | 517 | { |
518 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 518 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
519 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 519 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
520 | 520 | ||
521 | } | 521 | } |
522 | 522 | ||
523 | void CalendarView::checkNextTimerAlarm() | 523 | void CalendarView::checkNextTimerAlarm() |
524 | { | 524 | { |
525 | mCalendar->checkAlarmForIncidence( 0, true ); | 525 | mCalendar->checkAlarmForIncidence( 0, true ); |
526 | } | 526 | } |
527 | 527 | ||
528 | void CalendarView::computeAlarm( QString msg ) | 528 | void CalendarView::computeAlarm( QString msg ) |
529 | { | 529 | { |
530 | 530 | ||
531 | QString mess = msg; | 531 | QString mess = msg; |
532 | QString mAlarmMessage = mess.mid( 9 ); | 532 | QString mAlarmMessage = mess.mid( 9 ); |
533 | QString filename = MainWindow::resourcePath(); | 533 | QString filename = MainWindow::resourcePath(); |
534 | filename += "koalarm.wav"; | 534 | filename += "koalarm.wav"; |
535 | QString tempfilename; | 535 | QString tempfilename; |
536 | if ( mess.left( 13 ) == "suspend_alarm") { | 536 | if ( mess.left( 13 ) == "suspend_alarm") { |
537 | bool error = false; | 537 | bool error = false; |
538 | int len = mess.mid( 13 ).find("+++"); | 538 | int len = mess.mid( 13 ).find("+++"); |
539 | if ( len < 2 ) | 539 | if ( len < 2 ) |
540 | error = true; | 540 | error = true; |
541 | else { | 541 | else { |
542 | tempfilename = mess.mid( 13, len ); | 542 | tempfilename = mess.mid( 13, len ); |
543 | if ( !QFile::exists( tempfilename ) ) | 543 | if ( !QFile::exists( tempfilename ) ) |
544 | error = true; | 544 | error = true; |
545 | } | 545 | } |
546 | if ( ! error ) { | 546 | if ( ! error ) { |
547 | filename = tempfilename; | 547 | filename = tempfilename; |
548 | } | 548 | } |
549 | mAlarmMessage = mess.mid( 13+len+3 ); | 549 | mAlarmMessage = mess.mid( 13+len+3 ); |
550 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 550 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
551 | startAlarm( mAlarmMessage, filename); | 551 | startAlarm( mAlarmMessage, filename); |
552 | return; | 552 | return; |
553 | } | 553 | } |
554 | if ( mess.left( 11 ) == "timer_alarm") { | 554 | if ( mess.left( 11 ) == "timer_alarm") { |
555 | //mTimerTime = 0; | 555 | //mTimerTime = 0; |
556 | startAlarm( mess.mid( 11 ), filename ); | 556 | startAlarm( mess.mid( 11 ), filename ); |
557 | return; | 557 | return; |
558 | } | 558 | } |
559 | if ( mess.left( 10 ) == "proc_alarm") { | 559 | if ( mess.left( 10 ) == "proc_alarm") { |
560 | bool error = false; | 560 | bool error = false; |
561 | int len = mess.mid( 10 ).find("+++"); | 561 | int len = mess.mid( 10 ).find("+++"); |
562 | if ( len < 2 ) | 562 | if ( len < 2 ) |
563 | error = true; | 563 | error = true; |
564 | else { | 564 | else { |
565 | tempfilename = mess.mid( 10, len ); | 565 | tempfilename = mess.mid( 10, len ); |
566 | if ( !QFile::exists( tempfilename ) ) | 566 | if ( !QFile::exists( tempfilename ) ) |
567 | error = true; | 567 | error = true; |
568 | } | 568 | } |
569 | if ( error ) { | 569 | if ( error ) { |
570 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 570 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
571 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 571 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
572 | } else { | 572 | } else { |
573 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 573 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
574 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 574 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
575 | #ifndef _WIN32_ | 575 | #ifndef _WIN32_ |
576 | if ( vfork () == 0 ) { | 576 | if ( vfork () == 0 ) { |
577 | execl ( tempfilename.latin1(), 0 ); | 577 | execl ( tempfilename.latin1(), 0 ); |
578 | return; | 578 | return; |
579 | } | 579 | } |
580 | #else | 580 | #else |
581 | QProcess* p = new QProcess(); | 581 | QProcess* p = new QProcess(); |
582 | p->addArgument( tempfilename.latin1() ); | 582 | p->addArgument( tempfilename.latin1() ); |
583 | p->start(); | 583 | p->start(); |
584 | return; | 584 | return; |
585 | #endif | 585 | #endif |
586 | 586 | ||
587 | return; | 587 | return; |
588 | } | 588 | } |
589 | 589 | ||
590 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 590 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
591 | } | 591 | } |
592 | if ( mess.left( 11 ) == "audio_alarm") { | 592 | if ( mess.left( 11 ) == "audio_alarm") { |
593 | bool error = false; | 593 | bool error = false; |
594 | int len = mess.mid( 11 ).find("+++"); | 594 | int len = mess.mid( 11 ).find("+++"); |
595 | if ( len < 2 ) | 595 | if ( len < 2 ) |
596 | error = true; | 596 | error = true; |
597 | else { | 597 | else { |
598 | tempfilename = mess.mid( 11, len ); | 598 | tempfilename = mess.mid( 11, len ); |
599 | if ( !QFile::exists( tempfilename ) ) | 599 | if ( !QFile::exists( tempfilename ) ) |
600 | error = true; | 600 | error = true; |
601 | } | 601 | } |
602 | if ( ! error ) { | 602 | if ( ! error ) { |
603 | filename = tempfilename; | 603 | filename = tempfilename; |
604 | } | 604 | } |
605 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 605 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
606 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 606 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
607 | } | 607 | } |
608 | if ( mess.left( 9 ) == "cal_alarm") { | 608 | if ( mess.left( 9 ) == "cal_alarm") { |
609 | mAlarmMessage = mess.mid( 9 ) ; | 609 | mAlarmMessage = mess.mid( 9 ) ; |
610 | } | 610 | } |
611 | 611 | ||
612 | startAlarm( mAlarmMessage, filename ); | 612 | startAlarm( mAlarmMessage, filename ); |
613 | 613 | ||
614 | 614 | ||
615 | } | 615 | } |
616 | 616 | ||
617 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 617 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
618 | { | 618 | { |
619 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 619 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
620 | 620 | ||
621 | mSuspendAlarmNotification = noti; | 621 | mSuspendAlarmNotification = noti; |
622 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 622 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
623 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 623 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
624 | mSuspendTimer->start( ms , true ); | 624 | mSuspendTimer->start( ms , true ); |
625 | 625 | ||
626 | } | 626 | } |
627 | 627 | ||
628 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 628 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
629 | { | 629 | { |
630 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 630 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
631 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 631 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
632 | #ifndef DESKTOP_VERSION | 632 | #ifndef DESKTOP_VERSION |
633 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 633 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
634 | #endif | 634 | #endif |
635 | return; | 635 | return; |
636 | } | 636 | } |
637 | int maxSec; | 637 | int maxSec; |
638 | //maxSec = 5; //testing only | 638 | //maxSec = 5; //testing only |
639 | maxSec = 86400+3600; // one day+1hour | 639 | maxSec = 86400+3600; // one day+1hour |
640 | mAlarmNotification = noti; | 640 | mAlarmNotification = noti; |
641 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 641 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
642 | if ( sec > maxSec ) { | 642 | if ( sec > maxSec ) { |
643 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 643 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
644 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 644 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
645 | return; | 645 | return; |
646 | } else { | 646 | } else { |
647 | mRecheckAlarmTimer->stop(); | 647 | mRecheckAlarmTimer->stop(); |
648 | } | 648 | } |
649 | //qDebug("Alarm timer started with secs: %d ", sec); | 649 | //qDebug("Alarm timer started with secs: %d ", sec); |
650 | mAlarmTimer->start( sec *1000 , true ); | 650 | mAlarmTimer->start( sec *1000 , true ); |
651 | 651 | ||
652 | } | 652 | } |
653 | // called by mRecheckAlarmTimer to get next alarm | 653 | // called by mRecheckAlarmTimer to get next alarm |
654 | // we need this, because a QTimer has only a max range of 25 days | 654 | // we need this, because a QTimer has only a max range of 25 days |
655 | void CalendarView::recheckTimerAlarm() | 655 | void CalendarView::recheckTimerAlarm() |
656 | { | 656 | { |
657 | mAlarmTimer->stop(); | 657 | mAlarmTimer->stop(); |
658 | mRecheckAlarmTimer->stop(); | 658 | mRecheckAlarmTimer->stop(); |
659 | mCalendar->checkAlarmForIncidence( 0, true ); | 659 | mCalendar->checkAlarmForIncidence( 0, true ); |
660 | } | 660 | } |
661 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 661 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
662 | { | 662 | { |
663 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 663 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
664 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 664 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
665 | #ifndef DESKTOP_VERSION | 665 | #ifndef DESKTOP_VERSION |
666 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 666 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
667 | #endif | 667 | #endif |
668 | return; | 668 | return; |
669 | } | 669 | } |
670 | mAlarmTimer->stop(); | 670 | mAlarmTimer->stop(); |
671 | } | 671 | } |
672 | void CalendarView::selectWeekNum ( int num ) | 672 | void CalendarView::selectWeekNum ( int num ) |
673 | { | 673 | { |
674 | dateNavigator()->selectWeek( num ); | 674 | dateNavigator()->selectWeek( num ); |
675 | mViewManager->showWeekView(); | 675 | mViewManager->showWeekView(); |
676 | } | 676 | } |
677 | KOViewManager *CalendarView::viewManager() | 677 | KOViewManager *CalendarView::viewManager() |
678 | { | 678 | { |
679 | return mViewManager; | 679 | return mViewManager; |
680 | } | 680 | } |
681 | 681 | ||
682 | KODialogManager *CalendarView::dialogManager() | 682 | KODialogManager *CalendarView::dialogManager() |
683 | { | 683 | { |
684 | return mDialogManager; | 684 | return mDialogManager; |
685 | } | 685 | } |
686 | 686 | ||
687 | QDate CalendarView::startDate() | 687 | QDate CalendarView::startDate() |
688 | { | 688 | { |
689 | DateList dates = mNavigator->selectedDates(); | 689 | DateList dates = mNavigator->selectedDates(); |
690 | 690 | ||
691 | return dates.first(); | 691 | return dates.first(); |
692 | } | 692 | } |
693 | 693 | ||
694 | QDate CalendarView::endDate() | 694 | QDate CalendarView::endDate() |
695 | { | 695 | { |
696 | DateList dates = mNavigator->selectedDates(); | 696 | DateList dates = mNavigator->selectedDates(); |
697 | 697 | ||
698 | return dates.last(); | 698 | return dates.last(); |
699 | } | 699 | } |
700 | 700 | ||
701 | 701 | ||
702 | void CalendarView::createPrinter() | 702 | void CalendarView::createPrinter() |
703 | { | 703 | { |
704 | #ifndef KORG_NOPRINTER | 704 | #ifndef KORG_NOPRINTER |
705 | if (!mCalPrinter) { | 705 | if (!mCalPrinter) { |
706 | mCalPrinter = new CalPrinter(this, mCalendar); | 706 | mCalPrinter = new CalPrinter(this, mCalendar); |
707 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 707 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
708 | } | 708 | } |
709 | #endif | 709 | #endif |
710 | } | 710 | } |
711 | 711 | ||
712 | 712 | ||
713 | //KOPrefs::instance()->mWriteBackFile | 713 | //KOPrefs::instance()->mWriteBackFile |
714 | //KOPrefs::instance()->mWriteBackExistingOnly | 714 | //KOPrefs::instance()->mWriteBackExistingOnly |
715 | 715 | ||
716 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 716 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
717 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 717 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
718 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 718 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
719 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 719 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
720 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 720 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
721 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 721 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
722 | 722 | ||
723 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 723 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
724 | { | 724 | { |
725 | 725 | ||
726 | // 0 equal | 726 | // 0 equal |
727 | // 1 take local | 727 | // 1 take local |
728 | // 2 take remote | 728 | // 2 take remote |
729 | // 3 cancel | 729 | // 3 cancel |
730 | QDateTime lastSync = mLastCalendarSync; | 730 | QDateTime lastSync = mLastCalendarSync; |
731 | QDateTime localMod = local->lastModified(); | 731 | QDateTime localMod = local->lastModified(); |
732 | QDateTime remoteMod = remote->lastModified(); | 732 | QDateTime remoteMod = remote->lastModified(); |
733 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 733 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
734 | bool remCh, locCh; | 734 | bool remCh, locCh; |
735 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 735 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
736 | //if ( remCh ) | 736 | //if ( remCh ) |
737 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 737 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
738 | locCh = ( localMod > mLastCalendarSync ); | 738 | locCh = ( localMod > mLastCalendarSync ); |
739 | if ( !remCh && ! locCh ) { | 739 | if ( !remCh && ! locCh ) { |
740 | //qDebug("both not changed "); | 740 | //qDebug("both not changed "); |
741 | lastSync = localMod.addDays(1); | 741 | lastSync = localMod.addDays(1); |
742 | if ( mode <= SYNC_PREF_ASK ) | 742 | if ( mode <= SYNC_PREF_ASK ) |
743 | return 0; | 743 | return 0; |
744 | } else { | 744 | } else { |
745 | if ( locCh ) { | 745 | if ( locCh ) { |
746 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 746 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
747 | lastSync = localMod.addDays( -1 ); | 747 | lastSync = localMod.addDays( -1 ); |
748 | if ( !remCh ) | 748 | if ( !remCh ) |
749 | remoteMod = ( lastSync.addDays( -1 ) ); | 749 | remoteMod = ( lastSync.addDays( -1 ) ); |
750 | } else { | 750 | } else { |
751 | //qDebug(" not loc changed "); | 751 | //qDebug(" not loc changed "); |
752 | lastSync = localMod.addDays( 1 ); | 752 | lastSync = localMod.addDays( 1 ); |
753 | if ( remCh ) | 753 | if ( remCh ) |
754 | remoteMod =( lastSync.addDays( 1 ) ); | 754 | remoteMod =( lastSync.addDays( 1 ) ); |
755 | 755 | ||
756 | } | 756 | } |
757 | } | 757 | } |
758 | full = true; | 758 | full = true; |
759 | if ( mode < SYNC_PREF_ASK ) | 759 | if ( mode < SYNC_PREF_ASK ) |
760 | mode = SYNC_PREF_ASK; | 760 | mode = SYNC_PREF_ASK; |
761 | } else { | 761 | } else { |
762 | if ( localMod == remoteMod ) | 762 | if ( localMod == remoteMod ) |
763 | // if ( local->revision() == remote->revision() ) | 763 | // if ( local->revision() == remote->revision() ) |
764 | return 0; | 764 | return 0; |
765 | 765 | ||
766 | } | 766 | } |
767 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 767 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
768 | 768 | ||
769 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 769 | //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() ); | 770 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
771 | //full = true; //debug only | 771 | //full = true; //debug only |
772 | if ( full ) { | 772 | if ( full ) { |
773 | bool equ = false; | 773 | bool equ = false; |
774 | if ( local->type() == "Event" ) { | 774 | if ( local->type() == "Event" ) { |
775 | equ = (*((Event*) local) == *((Event*) remote)); | 775 | equ = (*((Event*) local) == *((Event*) remote)); |
776 | } | 776 | } |
777 | else if ( local->type() =="Todo" ) | 777 | else if ( local->type() =="Todo" ) |
778 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 778 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
779 | else if ( local->type() =="Journal" ) | 779 | else if ( local->type() =="Journal" ) |
780 | equ = (*((Journal*) local) == *((Journal*) remote)); | 780 | equ = (*((Journal*) local) == *((Journal*) remote)); |
781 | if ( equ ) { | 781 | if ( equ ) { |
782 | //qDebug("equal "); | 782 | //qDebug("equal "); |
783 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 783 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
784 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 784 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
785 | } | 785 | } |
786 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 786 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
787 | return 0; | 787 | return 0; |
788 | 788 | ||
789 | }//else //debug only | 789 | }//else //debug only |
790 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 790 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
791 | } | 791 | } |
792 | int result; | 792 | int result; |
793 | bool localIsNew; | 793 | 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() ); | 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() ); |
795 | 795 | ||
796 | if ( full && mode < SYNC_PREF_NEWEST ) | 796 | if ( full && mode < SYNC_PREF_NEWEST ) |
797 | mode = SYNC_PREF_ASK; | 797 | mode = SYNC_PREF_ASK; |
798 | 798 | ||
799 | switch( mode ) { | 799 | switch( mode ) { |
800 | case SYNC_PREF_LOCAL: | 800 | case SYNC_PREF_LOCAL: |
801 | if ( lastSync > remoteMod ) | 801 | if ( lastSync > remoteMod ) |
802 | return 1; | 802 | return 1; |
803 | if ( lastSync > localMod ) | 803 | if ( lastSync > localMod ) |
804 | return 2; | 804 | return 2; |
805 | return 1; | 805 | return 1; |
806 | break; | 806 | break; |
807 | case SYNC_PREF_REMOTE: | 807 | case SYNC_PREF_REMOTE: |
808 | if ( lastSync > remoteMod ) | 808 | if ( lastSync > remoteMod ) |
809 | return 1; | 809 | return 1; |
810 | if ( lastSync > localMod ) | 810 | if ( lastSync > localMod ) |
811 | return 2; | 811 | return 2; |
812 | return 2; | 812 | return 2; |
813 | break; | 813 | break; |
814 | case SYNC_PREF_NEWEST: | 814 | case SYNC_PREF_NEWEST: |
815 | if ( localMod > remoteMod ) | 815 | if ( localMod > remoteMod ) |
816 | return 1; | 816 | return 1; |
817 | else | 817 | else |
818 | return 2; | 818 | return 2; |
819 | break; | 819 | break; |
820 | case SYNC_PREF_ASK: | 820 | case SYNC_PREF_ASK: |
821 | //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() ); |
822 | if ( lastSync > remoteMod ) | 822 | if ( lastSync > remoteMod ) |
823 | return 1; | 823 | return 1; |
824 | if ( lastSync > localMod ) | 824 | if ( lastSync > localMod ) |
825 | return 2; | 825 | return 2; |
826 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 826 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
827 | localIsNew = localMod >= remoteMod; | 827 | localIsNew = localMod >= remoteMod; |
828 | if ( localIsNew ) | 828 | if ( localIsNew ) |
829 | getEventViewerDialog()->setColorMode( 1 ); | 829 | getEventViewerDialog()->setColorMode( 1 ); |
830 | else | 830 | else |
831 | getEventViewerDialog()->setColorMode( 2 ); | 831 | getEventViewerDialog()->setColorMode( 2 ); |
832 | getEventViewerDialog()->setIncidence(local); | 832 | getEventViewerDialog()->setIncidence(local); |
833 | if ( localIsNew ) | 833 | if ( localIsNew ) |
834 | getEventViewerDialog()->setColorMode( 2 ); | 834 | getEventViewerDialog()->setColorMode( 2 ); |
835 | else | 835 | else |
836 | getEventViewerDialog()->setColorMode( 1 ); | 836 | getEventViewerDialog()->setColorMode( 1 ); |
837 | getEventViewerDialog()->addIncidence(remote); | 837 | getEventViewerDialog()->addIncidence(remote); |
838 | getEventViewerDialog()->setColorMode( 0 ); | 838 | getEventViewerDialog()->setColorMode( 0 ); |
839 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 839 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
840 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 840 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
841 | getEventViewerDialog()->showMe(); | 841 | getEventViewerDialog()->showMe(); |
842 | result = getEventViewerDialog()->executeS( localIsNew ); | 842 | result = getEventViewerDialog()->executeS( localIsNew ); |
843 | return result; | 843 | return result; |
844 | 844 | ||
845 | break; | 845 | break; |
846 | case SYNC_PREF_FORCE_LOCAL: | 846 | case SYNC_PREF_FORCE_LOCAL: |
847 | return 1; | 847 | return 1; |
848 | break; | 848 | break; |
849 | case SYNC_PREF_FORCE_REMOTE: | 849 | case SYNC_PREF_FORCE_REMOTE: |
850 | return 2; | 850 | return 2; |
851 | break; | 851 | break; |
852 | 852 | ||
853 | default: | 853 | default: |
854 | // SYNC_PREF_TAKE_BOTH not implemented | 854 | // SYNC_PREF_TAKE_BOTH not implemented |
855 | break; | 855 | break; |
856 | } | 856 | } |
857 | return 0; | 857 | return 0; |
858 | } | 858 | } |
859 | Event* CalendarView::getLastSyncEvent() | 859 | Event* CalendarView::getLastSyncEvent() |
860 | { | 860 | { |
861 | Event* lse; | 861 | Event* lse; |
862 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 862 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
863 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 863 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
864 | if (!lse) { | 864 | if (!lse) { |
865 | lse = new Event(); | 865 | lse = new Event(); |
866 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 866 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
867 | QString sum = ""; | 867 | QString sum = ""; |
868 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 868 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
869 | sum = "E: "; | 869 | sum = "E: "; |
870 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 870 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
871 | lse->setDtStart( mLastCalendarSync ); | 871 | lse->setDtStart( mLastCalendarSync ); |
872 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 872 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
873 | lse->setCategories( i18n("SyncEvent") ); | 873 | lse->setCategories( i18n("SyncEvent") ); |
874 | lse->setReadOnly( true ); | 874 | lse->setReadOnly( true ); |
875 | mCalendar->addEvent( lse ); | 875 | mCalendar->addEvent( lse ); |
876 | } | 876 | } |
877 | 877 | ||
878 | return lse; | 878 | return lse; |
879 | 879 | ||
880 | } | 880 | } |
881 | 881 | ||
882 | // we check, if the to delete event has a id for a profile | 882 | // 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 | 883 | // if yes, we set this id in the profile to delete |
884 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 884 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
885 | { | 885 | { |
886 | if ( lastSync.count() == 0 ) { | 886 | if ( lastSync.count() == 0 ) { |
887 | //qDebug(" lastSync.count() == 0"); | 887 | //qDebug(" lastSync.count() == 0"); |
888 | return; | 888 | return; |
889 | } | 889 | } |
890 | if ( toDelete->type() == "Journal" ) | 890 | if ( toDelete->type() == "Journal" ) |
891 | return; | 891 | return; |
892 | 892 | ||
893 | Event* eve = lastSync.first(); | 893 | Event* eve = lastSync.first(); |
894 | 894 | ||
895 | while ( eve ) { | 895 | while ( eve ) { |
896 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 896 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
897 | if ( !id.isEmpty() ) { | 897 | if ( !id.isEmpty() ) { |
898 | QString des = eve->description(); | 898 | QString des = eve->description(); |
899 | QString pref = "e"; | 899 | QString pref = "e"; |
900 | if ( toDelete->type() == "Todo" ) | 900 | if ( toDelete->type() == "Todo" ) |
901 | pref = "t"; | 901 | pref = "t"; |
902 | des += pref+ id + ","; | 902 | des += pref+ id + ","; |
903 | eve->setReadOnly( false ); | 903 | eve->setReadOnly( false ); |
904 | eve->setDescription( des ); | 904 | eve->setDescription( des ); |
905 | //qDebug("setdes %s ", des.latin1()); | 905 | //qDebug("setdes %s ", des.latin1()); |
906 | eve->setReadOnly( true ); | 906 | eve->setReadOnly( true ); |
907 | } | 907 | } |
908 | eve = lastSync.next(); | 908 | eve = lastSync.next(); |
909 | } | 909 | } |
910 | 910 | ||
911 | } | 911 | } |
912 | void CalendarView::checkExternalId( Incidence * inc ) | 912 | void CalendarView::checkExternalId( Incidence * inc ) |
913 | { | 913 | { |
914 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 914 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
915 | checkExternSyncEvent( lastSync, inc ); | 915 | checkExternSyncEvent( lastSync, inc ); |
916 | 916 | ||
917 | } | 917 | } |
918 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 918 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
919 | { | 919 | { |
920 | bool syncOK = true; | 920 | bool syncOK = true; |
921 | int addedEvent = 0; | 921 | int addedEvent = 0; |
922 | int addedEventR = 0; | 922 | int addedEventR = 0; |
923 | int deletedEventR = 0; | 923 | int deletedEventR = 0; |
924 | int deletedEventL = 0; | 924 | int deletedEventL = 0; |
925 | int changedLocal = 0; | 925 | int changedLocal = 0; |
926 | int changedRemote = 0; | 926 | int changedRemote = 0; |
927 | //QPtrList<Event> el = local->rawEvents(); | 927 | //QPtrList<Event> el = local->rawEvents(); |
928 | Event* eventR; | 928 | Event* eventR; |
929 | QString uid; | 929 | QString uid; |
930 | int take; | 930 | int take; |
931 | Event* eventL; | 931 | Event* eventL; |
932 | Event* eventRSync; | 932 | Event* eventRSync; |
933 | Event* eventLSync; | 933 | Event* eventLSync; |
934 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 934 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
935 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 935 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
936 | bool fullDateRange = false; | 936 | bool fullDateRange = false; |
937 | local->resetTempSyncStat(); | 937 | local->resetTempSyncStat(); |
938 | mLastCalendarSync = QDateTime::currentDateTime(); | 938 | mLastCalendarSync = QDateTime::currentDateTime(); |
939 | if ( mSyncManager->syncWithDesktop() ) { | 939 | if ( mSyncManager->syncWithDesktop() ) { |
940 | remote->resetPilotStat(1); | 940 | remote->resetPilotStat(1); |
941 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 941 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
942 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 942 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
943 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 943 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
944 | } else { | 944 | } else { |
945 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 945 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
946 | } | 946 | } |
947 | } | 947 | } |
948 | QDateTime modifiedCalendar = mLastCalendarSync; | 948 | QDateTime modifiedCalendar = mLastCalendarSync; |
949 | eventLSync = getLastSyncEvent(); | 949 | eventLSync = getLastSyncEvent(); |
950 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 950 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
951 | if ( eventR ) { | 951 | if ( eventR ) { |
952 | eventRSync = (Event*) eventR->clone(); | 952 | eventRSync = (Event*) eventR->clone(); |
953 | remote->deleteEvent(eventR ); | 953 | remote->deleteEvent(eventR ); |
954 | 954 | ||
955 | } else { | 955 | } else { |
956 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 956 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
957 | eventRSync = (Event*)eventLSync->clone(); | 957 | eventRSync = (Event*)eventLSync->clone(); |
958 | } else { | 958 | } else { |
959 | fullDateRange = true; | 959 | fullDateRange = true; |
960 | eventRSync = new Event(); | 960 | eventRSync = new Event(); |
961 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 961 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
962 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 962 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
963 | eventRSync->setDtStart( mLastCalendarSync ); | 963 | eventRSync->setDtStart( mLastCalendarSync ); |
964 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 964 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
965 | eventRSync->setCategories( i18n("SyncEvent") ); | 965 | eventRSync->setCategories( i18n("SyncEvent") ); |
966 | } | 966 | } |
967 | } | 967 | } |
968 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 968 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
969 | fullDateRange = true; | 969 | fullDateRange = true; |
970 | 970 | ||
971 | if ( ! fullDateRange ) { | 971 | if ( ! fullDateRange ) { |
972 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 972 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
973 | 973 | ||
974 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 974 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
975 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 975 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
976 | fullDateRange = true; | 976 | fullDateRange = true; |
977 | } | 977 | } |
978 | } | 978 | } |
979 | if ( mSyncManager->syncWithDesktop() ) { | 979 | if ( mSyncManager->syncWithDesktop() ) { |
980 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 980 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
981 | } | 981 | } |
982 | if ( fullDateRange ) | 982 | if ( fullDateRange ) |
983 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 983 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
984 | else | 984 | else |
985 | mLastCalendarSync = eventLSync->dtStart(); | 985 | mLastCalendarSync = eventLSync->dtStart(); |
986 | // for resyncing if own file has changed | 986 | // for resyncing if own file has changed |
987 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 987 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
988 | mLastCalendarSync = loadedFileVersion; | 988 | mLastCalendarSync = loadedFileVersion; |
989 | //qDebug("setting mLastCalendarSync "); | 989 | //qDebug("setting mLastCalendarSync "); |
990 | } | 990 | } |
991 | //qDebug("*************************** "); | 991 | //qDebug("*************************** "); |
992 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 992 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
993 | QPtrList<Incidence> er = remote->rawIncidences(); | 993 | QPtrList<Incidence> er = remote->rawIncidences(); |
994 | Incidence* inR = er.first(); | 994 | Incidence* inR = er.first(); |
995 | Incidence* inL; | 995 | Incidence* inL; |
996 | QProgressBar bar( er.count(),0 ); | 996 | QProgressBar bar( er.count(),0 ); |
997 | bar.setCaption (i18n("Syncing - close to abort!") ); | 997 | bar.setCaption (i18n("Syncing - close to abort!") ); |
998 | 998 | ||
999 | // ************** setting up filter ************* | 999 | // ************** setting up filter ************* |
1000 | CalFilter *filterIN = 0; | 1000 | CalFilter *filterIN = 0; |
1001 | CalFilter *filterOUT = 0; | 1001 | CalFilter *filterOUT = 0; |
1002 | CalFilter *filter = mFilters.first(); | 1002 | CalFilter *filter = mFilters.first(); |
1003 | while(filter) { | 1003 | while(filter) { |
1004 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1004 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1005 | filterIN = filter; | 1005 | filterIN = filter; |
1006 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1006 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1007 | filterOUT = filter; | 1007 | filterOUT = filter; |
1008 | filter = mFilters.next(); | 1008 | filter = mFilters.next(); |
1009 | } | 1009 | } |
1010 | int w = 300; | 1010 | int w = 300; |
1011 | if ( QApplication::desktop()->width() < 320 ) | 1011 | if ( QApplication::desktop()->width() < 320 ) |
1012 | w = 220; | 1012 | w = 220; |
1013 | int h = bar.sizeHint().height() ; | 1013 | int h = bar.sizeHint().height() ; |
1014 | int dw = QApplication::desktop()->width(); | 1014 | int dw = QApplication::desktop()->width(); |
1015 | int dh = QApplication::desktop()->height(); | 1015 | int dh = QApplication::desktop()->height(); |
1016 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1016 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1017 | bar.show(); | 1017 | bar.show(); |
1018 | int modulo = (er.count()/10)+1; | 1018 | int modulo = (er.count()/10)+1; |
1019 | int incCounter = 0; | 1019 | int incCounter = 0; |
1020 | while ( inR ) { | 1020 | while ( inR ) { |
1021 | if ( ! bar.isVisible() ) | 1021 | if ( ! bar.isVisible() ) |
1022 | return false; | 1022 | return false; |
1023 | if ( incCounter % modulo == 0 ) | 1023 | if ( incCounter % modulo == 0 ) |
1024 | bar.setProgress( incCounter ); | 1024 | bar.setProgress( incCounter ); |
1025 | ++incCounter; | 1025 | ++incCounter; |
1026 | uid = inR->uid(); | 1026 | uid = inR->uid(); |
1027 | bool skipIncidence = false; | 1027 | bool skipIncidence = false; |
1028 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1028 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1029 | skipIncidence = true; | 1029 | skipIncidence = true; |
1030 | QString idS; | 1030 | QString idS; |
1031 | qApp->processEvents(); | 1031 | qApp->processEvents(); |
1032 | if ( !skipIncidence ) { | 1032 | if ( !skipIncidence ) { |
1033 | inL = local->incidence( uid ); | 1033 | inL = local->incidence( uid ); |
1034 | if ( inL ) { // maybe conflict - same uid in both calendars | 1034 | if ( inL ) { // maybe conflict - same uid in both calendars |
1035 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1035 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1036 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1036 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1037 | if ( take == 3 ) | 1037 | if ( take == 3 ) |
1038 | return false; | 1038 | return false; |
1039 | if ( take == 1 ) {// take local ********************** | 1039 | if ( take == 1 ) {// take local ********************** |
1040 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1040 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1041 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1041 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1042 | else | 1042 | else |
1043 | idS = inR->IDStr(); | 1043 | idS = inR->IDStr(); |
1044 | remote->deleteIncidence( inR ); | 1044 | remote->deleteIncidence( inR ); |
1045 | inR = inL->clone(); | 1045 | inR = inL->clone(); |
1046 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1046 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1047 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1047 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1048 | inR->setIDStr( idS ); | 1048 | inR->setIDStr( idS ); |
1049 | remote->addIncidence( inR ); | 1049 | remote->addIncidence( inR ); |
1050 | if ( mSyncManager->syncWithDesktop() ) | 1050 | if ( mSyncManager->syncWithDesktop() ) |
1051 | inR->setPilotId( 2 ); | 1051 | inR->setPilotId( 2 ); |
1052 | ++changedRemote; | 1052 | ++changedRemote; |
1053 | } else {// take remote ********************** | 1053 | } else {// take remote ********************** |
1054 | idS = inL->IDStr(); | 1054 | idS = inL->IDStr(); |
1055 | int pid = inL->pilotId(); | 1055 | int pid = inL->pilotId(); |
1056 | local->deleteIncidence( inL ); | 1056 | local->deleteIncidence( inL ); |
1057 | inL = inR->clone(); | 1057 | inL = inR->clone(); |
1058 | if ( mSyncManager->syncWithDesktop() ) | 1058 | if ( mSyncManager->syncWithDesktop() ) |
1059 | inL->setPilotId( pid ); | 1059 | inL->setPilotId( pid ); |
1060 | inL->setIDStr( idS ); | 1060 | inL->setIDStr( idS ); |
1061 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1061 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1062 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1062 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1063 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1063 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1064 | } | 1064 | } |
1065 | local->addIncidence( inL ); | 1065 | local->addIncidence( inL ); |
1066 | ++changedLocal; | 1066 | ++changedLocal; |
1067 | } | 1067 | } |
1068 | } | 1068 | } |
1069 | } else { // no conflict ********** add or delete remote | 1069 | } else { // no conflict ********** add or delete remote |
1070 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1070 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1071 | QString des = eventLSync->description(); | 1071 | QString des = eventLSync->description(); |
1072 | QString pref = "e"; | 1072 | QString pref = "e"; |
1073 | if ( inR->type() == "Todo" ) | 1073 | if ( inR->type() == "Todo" ) |
1074 | pref = "t"; | 1074 | pref = "t"; |
1075 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1075 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1076 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1076 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1077 | //remote->deleteIncidence( inR ); | 1077 | //remote->deleteIncidence( inR ); |
1078 | ++deletedEventR; | 1078 | ++deletedEventR; |
1079 | } else { | 1079 | } else { |
1080 | inR->setLastModified( modifiedCalendar ); | 1080 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1081 | inL = inR->clone(); | 1081 | inR->setLastModified( modifiedCalendar ); |
1082 | inL->setIDStr( ":" ); | 1082 | inL = inR->clone(); |
1083 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1083 | inL->setIDStr( ":" ); |
1084 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1084 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1085 | local->addIncidence( inL ); | 1085 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1086 | ++addedEvent; | 1086 | local->addIncidence( inL ); |
1087 | ++addedEvent; | ||
1088 | } | ||
1087 | } | 1089 | } |
1088 | } else { | 1090 | } else { |
1089 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1091 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1090 | inR->setLastModified( modifiedCalendar ); | 1092 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1091 | inL = inR->clone(); | 1093 | inR->setLastModified( modifiedCalendar ); |
1092 | inL->setIDStr( ":" ); | 1094 | inL = inR->clone(); |
1093 | local->addIncidence( inL ); | 1095 | inL->setIDStr( ":" ); |
1094 | ++addedEvent; | 1096 | local->addIncidence( inL ); |
1097 | ++addedEvent; | ||
1098 | } | ||
1095 | } else { | 1099 | } else { |
1096 | checkExternSyncEvent(eventRSyncSharp, inR); | 1100 | checkExternSyncEvent(eventRSyncSharp, inR); |
1097 | remote->deleteIncidence( inR ); | 1101 | remote->deleteIncidence( inR ); |
1098 | ++deletedEventR; | 1102 | ++deletedEventR; |
1099 | } | 1103 | } |
1100 | } | 1104 | } |
1101 | } | 1105 | } |
1102 | } | 1106 | } |
1103 | inR = er.next(); | 1107 | inR = er.next(); |
1104 | } | 1108 | } |
1105 | QPtrList<Incidence> el = local->rawIncidences(); | 1109 | QPtrList<Incidence> el = local->rawIncidences(); |
1106 | inL = el.first(); | 1110 | inL = el.first(); |
1107 | modulo = (el.count()/10)+1; | 1111 | modulo = (el.count()/10)+1; |
1108 | bar.setCaption (i18n("Add / remove events") ); | 1112 | bar.setCaption (i18n("Add / remove events") ); |
1109 | bar.setTotalSteps ( el.count() ) ; | 1113 | bar.setTotalSteps ( el.count() ) ; |
1110 | bar.show(); | 1114 | bar.show(); |
1111 | incCounter = 0; | 1115 | incCounter = 0; |
1112 | 1116 | ||
1113 | while ( inL ) { | 1117 | while ( inL ) { |
1114 | 1118 | ||
1115 | qApp->processEvents(); | 1119 | qApp->processEvents(); |
1116 | if ( ! bar.isVisible() ) | 1120 | if ( ! bar.isVisible() ) |
1117 | return false; | 1121 | return false; |
1118 | if ( incCounter % modulo == 0 ) | 1122 | if ( incCounter % modulo == 0 ) |
1119 | bar.setProgress( incCounter ); | 1123 | bar.setProgress( incCounter ); |
1120 | ++incCounter; | 1124 | ++incCounter; |
1121 | uid = inL->uid(); | 1125 | uid = inL->uid(); |
1122 | bool skipIncidence = false; | 1126 | bool skipIncidence = false; |
1123 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1127 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1124 | skipIncidence = true; | 1128 | skipIncidence = true; |
1125 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1129 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1126 | skipIncidence = true; | 1130 | skipIncidence = true; |
1127 | if ( !skipIncidence ) { | 1131 | if ( !skipIncidence ) { |
1128 | inR = remote->incidence( uid ); | 1132 | inR = remote->incidence( uid ); |
1129 | if ( ! inR ) { // no conflict ********** add or delete local | 1133 | if ( ! inR ) { // no conflict ********** add or delete local |
1130 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1134 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1131 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1135 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1132 | checkExternSyncEvent(eventLSyncSharp, inL); | 1136 | checkExternSyncEvent(eventLSyncSharp, inL); |
1133 | local->deleteIncidence( inL ); | 1137 | local->deleteIncidence( inL ); |
1134 | ++deletedEventL; | 1138 | ++deletedEventL; |
1135 | } else { | 1139 | } else { |
1136 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1140 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1137 | inL->removeID(mCurrentSyncDevice ); | 1141 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1138 | ++addedEventR; | 1142 | inL->removeID(mCurrentSyncDevice ); |
1139 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1143 | ++addedEventR; |
1140 | inL->setLastModified( modifiedCalendar ); | 1144 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1141 | inR = inL->clone(); | 1145 | inL->setLastModified( modifiedCalendar ); |
1142 | inR->setIDStr( ":" ); | 1146 | inR = inL->clone(); |
1143 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1147 | inR->setIDStr( ":" ); |
1144 | remote->addIncidence( inR ); | 1148 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1149 | remote->addIncidence( inR ); | ||
1150 | } | ||
1145 | } | 1151 | } |
1146 | } | 1152 | } |
1147 | } else { | 1153 | } else { |
1148 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1154 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1149 | checkExternSyncEvent(eventLSyncSharp, inL); | 1155 | checkExternSyncEvent(eventLSyncSharp, inL); |
1150 | local->deleteIncidence( inL ); | 1156 | local->deleteIncidence( inL ); |
1151 | ++deletedEventL; | 1157 | ++deletedEventL; |
1152 | } else { | 1158 | } else { |
1153 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1159 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1154 | ++addedEventR; | 1160 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1155 | inL->setLastModified( modifiedCalendar ); | 1161 | ++addedEventR; |
1156 | inR = inL->clone(); | 1162 | inL->setLastModified( modifiedCalendar ); |
1157 | inR->setIDStr( ":" ); | 1163 | inR = inL->clone(); |
1158 | remote->addIncidence( inR ); | 1164 | inR->setIDStr( ":" ); |
1165 | remote->addIncidence( inR ); | ||
1166 | } | ||
1159 | } | 1167 | } |
1160 | } | 1168 | } |
1161 | } | 1169 | } |
1162 | } | 1170 | } |
1163 | } | 1171 | } |
1164 | inL = el.next(); | 1172 | inL = el.next(); |
1165 | } | 1173 | } |
1166 | int delFut = 0; | 1174 | int delFut = 0; |
1167 | int remRem = 0; | 1175 | int remRem = 0; |
1168 | if ( mSyncManager->mWriteBackInFuture ) { | 1176 | if ( mSyncManager->mWriteBackInFuture ) { |
1169 | er = remote->rawIncidences(); | 1177 | er = remote->rawIncidences(); |
1170 | remRem = er.count(); | 1178 | remRem = er.count(); |
1171 | inR = er.first(); | 1179 | inR = er.first(); |
1172 | QDateTime dt; | 1180 | QDateTime dt; |
1173 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1181 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1174 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1182 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1175 | while ( inR ) { | 1183 | while ( inR ) { |
1176 | if ( inR->type() == "Todo" ) { | 1184 | if ( inR->type() == "Todo" ) { |
1177 | Todo * t = (Todo*)inR; | 1185 | Todo * t = (Todo*)inR; |
1178 | if ( t->hasDueDate() ) | 1186 | if ( t->hasDueDate() ) |
1179 | dt = t->dtDue(); | 1187 | dt = t->dtDue(); |
1180 | else | 1188 | else |
1181 | dt = cur.addSecs( 62 ); | 1189 | dt = cur.addSecs( 62 ); |
1182 | } | 1190 | } |
1183 | else if (inR->type() == "Event" ) { | 1191 | else if (inR->type() == "Event" ) { |
1184 | bool ok; | 1192 | bool ok; |
1185 | dt = inR->getNextOccurence( cur, &ok ); | 1193 | dt = inR->getNextOccurence( cur, &ok ); |
1186 | if ( !ok ) | 1194 | if ( !ok ) |
1187 | dt = cur.addSecs( -62 ); | 1195 | dt = cur.addSecs( -62 ); |
1188 | } | 1196 | } |
1189 | else | 1197 | else |
1190 | dt = inR->dtStart(); | 1198 | dt = inR->dtStart(); |
1191 | if ( dt < cur || dt > end ) { | 1199 | if ( dt < cur || dt > end ) { |
1192 | remote->deleteIncidence( inR ); | 1200 | remote->deleteIncidence( inR ); |
1193 | ++delFut; | 1201 | ++delFut; |
1194 | } | 1202 | } |
1195 | inR = er.next(); | 1203 | inR = er.next(); |
1196 | } | 1204 | } |
1197 | } | 1205 | } |
1198 | bar.hide(); | 1206 | bar.hide(); |
1199 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1207 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1200 | eventLSync->setReadOnly( false ); | 1208 | eventLSync->setReadOnly( false ); |
1201 | eventLSync->setDtStart( mLastCalendarSync ); | 1209 | eventLSync->setDtStart( mLastCalendarSync ); |
1202 | eventRSync->setDtStart( mLastCalendarSync ); | 1210 | eventRSync->setDtStart( mLastCalendarSync ); |
1203 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1211 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1204 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1212 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1205 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1213 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1206 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1214 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1207 | eventLSync->setReadOnly( true ); | 1215 | eventLSync->setReadOnly( true ); |
1208 | qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); | 1216 | qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); |
1209 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1217 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1210 | remote->addEvent( eventRSync ); | 1218 | remote->addEvent( eventRSync ); |
1211 | else | 1219 | else |
1212 | delete eventRSync; | 1220 | delete eventRSync; |
1213 | QString mes; | 1221 | QString mes; |
1214 | 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 ); | 1222 | 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 ); |
1215 | QString delmess; | 1223 | QString delmess; |
1216 | if ( delFut ) { | 1224 | if ( delFut ) { |
1217 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1225 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1218 | mes += delmess; | 1226 | mes += delmess; |
1219 | } | 1227 | } |
1220 | mes = i18n("Local calendar changed!\n") +mes; | 1228 | mes = i18n("Local calendar changed!\n") +mes; |
1221 | mCalendar->checkAlarmForIncidence( 0, true ); | 1229 | mCalendar->checkAlarmForIncidence( 0, true ); |
1222 | qDebug( mes ); | 1230 | qDebug( mes ); |
1223 | if ( mSyncManager->mShowSyncSummary ) { | 1231 | if ( mSyncManager->mShowSyncSummary ) { |
1224 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1232 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1225 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1233 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1226 | qDebug("cancelled "); | 1234 | qDebug("cancelled "); |
1227 | return false; | 1235 | return false; |
1228 | } | 1236 | } |
1229 | } | 1237 | } |
1230 | return syncOK; | 1238 | return syncOK; |
1231 | } | 1239 | } |
1232 | 1240 | ||
1233 | void CalendarView::setSyncDevice( QString s ) | 1241 | void CalendarView::setSyncDevice( QString s ) |
1234 | { | 1242 | { |
1235 | mCurrentSyncDevice= s; | 1243 | mCurrentSyncDevice= s; |
1236 | } | 1244 | } |
1237 | void CalendarView::setSyncName( QString s ) | 1245 | void CalendarView::setSyncName( QString s ) |
1238 | { | 1246 | { |
1239 | mCurrentSyncName= s; | 1247 | mCurrentSyncName= s; |
1240 | } | 1248 | } |
1241 | bool CalendarView::syncCalendar(QString filename, int mode) | 1249 | bool CalendarView::syncCalendar(QString filename, int mode) |
1242 | { | 1250 | { |
1243 | //qDebug("syncCalendar %s ", filename.latin1()); | 1251 | //qDebug("syncCalendar %s ", filename.latin1()); |
1244 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1252 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1245 | CalendarLocal* calendar = new CalendarLocal(); | 1253 | CalendarLocal* calendar = new CalendarLocal(); |
1246 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1254 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1247 | FileStorage* storage = new FileStorage( calendar ); | 1255 | FileStorage* storage = new FileStorage( calendar ); |
1248 | bool syncOK = false; | 1256 | bool syncOK = false; |
1249 | storage->setFileName( filename ); | 1257 | storage->setFileName( filename ); |
1250 | // qDebug("loading ... "); | 1258 | // qDebug("loading ... "); |
1251 | if ( storage->load() ) { | 1259 | if ( storage->load() ) { |
1252 | getEventViewerDialog()->setSyncMode( true ); | 1260 | getEventViewerDialog()->setSyncMode( true ); |
1253 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1261 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1254 | getEventViewerDialog()->setSyncMode( false ); | 1262 | getEventViewerDialog()->setSyncMode( false ); |
1255 | if ( syncOK ) { | 1263 | if ( syncOK ) { |
1256 | if ( mSyncManager->mWriteBackFile ) | 1264 | if ( mSyncManager->mWriteBackFile ) |
1257 | { | 1265 | { |
1258 | storage->setSaveFormat( new ICalFormat() ); | 1266 | storage->setSaveFormat( new ICalFormat() ); |
1259 | storage->save(); | 1267 | storage->save(); |
1260 | } | 1268 | } |
1261 | } | 1269 | } |
1262 | setModified( true ); | 1270 | setModified( true ); |
1263 | } | 1271 | } |
1264 | delete storage; | 1272 | delete storage; |
1265 | delete calendar; | 1273 | delete calendar; |
1266 | if ( syncOK ) | 1274 | if ( syncOK ) |
1267 | updateView(); | 1275 | updateView(); |
1268 | return syncOK; | 1276 | return syncOK; |
1269 | } | 1277 | } |
1270 | 1278 | ||
1271 | void CalendarView::syncExternal( int mode ) | 1279 | void CalendarView::syncExternal( int mode ) |
1272 | { | 1280 | { |
1273 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1281 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1274 | 1282 | ||
1275 | qApp->processEvents(); | 1283 | qApp->processEvents(); |
1276 | CalendarLocal* calendar = new CalendarLocal(); | 1284 | CalendarLocal* calendar = new CalendarLocal(); |
1277 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1285 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1278 | bool syncOK = false; | 1286 | bool syncOK = false; |
1279 | bool loadSuccess = false; | 1287 | bool loadSuccess = false; |
1280 | PhoneFormat* phoneFormat = 0; | 1288 | PhoneFormat* phoneFormat = 0; |
1281 | emit tempDisableBR(true); | 1289 | emit tempDisableBR(true); |
1282 | #ifndef DESKTOP_VERSION | 1290 | #ifndef DESKTOP_VERSION |
1283 | SharpFormat* sharpFormat = 0; | 1291 | SharpFormat* sharpFormat = 0; |
1284 | if ( mode == 0 ) { // sharp | 1292 | if ( mode == 0 ) { // sharp |
1285 | sharpFormat = new SharpFormat () ; | 1293 | sharpFormat = new SharpFormat () ; |
1286 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1294 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1287 | 1295 | ||
1288 | } else | 1296 | } else |
1289 | #endif | 1297 | #endif |
1290 | if ( mode == 1 ) { // phone | 1298 | if ( mode == 1 ) { // phone |
1291 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1299 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1292 | mSyncManager->mPhoneDevice, | 1300 | mSyncManager->mPhoneDevice, |
1293 | mSyncManager->mPhoneConnection, | 1301 | mSyncManager->mPhoneConnection, |
1294 | mSyncManager->mPhoneModel); | 1302 | mSyncManager->mPhoneModel); |
1295 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1303 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1296 | 1304 | ||
1297 | } else { | 1305 | } else { |
1298 | emit tempDisableBR(false); | 1306 | emit tempDisableBR(false); |
1299 | return; | 1307 | return; |
1300 | } | 1308 | } |
1301 | if ( loadSuccess ) { | 1309 | if ( loadSuccess ) { |
1302 | getEventViewerDialog()->setSyncMode( true ); | 1310 | getEventViewerDialog()->setSyncMode( true ); |
1303 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1311 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1304 | getEventViewerDialog()->setSyncMode( false ); | 1312 | getEventViewerDialog()->setSyncMode( false ); |
1305 | qApp->processEvents(); | 1313 | qApp->processEvents(); |
1306 | if ( syncOK ) { | 1314 | if ( syncOK ) { |
1307 | if ( mSyncManager->mWriteBackFile ) | 1315 | if ( mSyncManager->mWriteBackFile ) |
1308 | { | 1316 | { |
1309 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1317 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1310 | Incidence* inc = iL.first(); | 1318 | Incidence* inc = iL.first(); |
1311 | if ( phoneFormat ) { | 1319 | if ( phoneFormat ) { |
1312 | while ( inc ) { | 1320 | while ( inc ) { |
1313 | inc->removeID(mCurrentSyncDevice); | 1321 | inc->removeID(mCurrentSyncDevice); |
1314 | inc = iL.next(); | 1322 | inc = iL.next(); |
1315 | } | 1323 | } |
1316 | } | 1324 | } |
1317 | #ifndef DESKTOP_VERSION | 1325 | #ifndef DESKTOP_VERSION |
1318 | if ( sharpFormat ) | 1326 | if ( sharpFormat ) |
1319 | sharpFormat->save(calendar); | 1327 | sharpFormat->save(calendar); |
1320 | #endif | 1328 | #endif |
1321 | if ( phoneFormat ) | 1329 | if ( phoneFormat ) |
1322 | phoneFormat->save(calendar); | 1330 | phoneFormat->save(calendar); |
1323 | iL = calendar->rawIncidences(); | 1331 | iL = calendar->rawIncidences(); |
1324 | inc = iL.first(); | 1332 | inc = iL.first(); |
1325 | Incidence* loc; | 1333 | Incidence* loc; |
1326 | while ( inc ) { | 1334 | while ( inc ) { |
1327 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1335 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1328 | loc = mCalendar->incidence(inc->uid() ); | 1336 | loc = mCalendar->incidence(inc->uid() ); |
1329 | if ( loc ) { | 1337 | if ( loc ) { |
1330 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1338 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1331 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1339 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1332 | } | 1340 | } |
1333 | } | 1341 | } |
1334 | inc = iL.next(); | 1342 | inc = iL.next(); |
1335 | } | 1343 | } |
1336 | Incidence* lse = getLastSyncEvent(); | 1344 | Incidence* lse = getLastSyncEvent(); |
1337 | if ( lse ) { | 1345 | if ( lse ) { |
1338 | lse->setReadOnly( false ); | 1346 | lse->setReadOnly( false ); |
1339 | lse->setDescription( "" ); | 1347 | lse->setDescription( "" ); |
1340 | lse->setReadOnly( true ); | 1348 | lse->setReadOnly( true ); |
1341 | } | 1349 | } |
1342 | } | 1350 | } |
1343 | } else { | 1351 | } else { |
1344 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1352 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1345 | } | 1353 | } |
1346 | setModified( true ); | 1354 | setModified( true ); |
1347 | } else { | 1355 | } else { |
1348 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1356 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1349 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1357 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1350 | question, i18n("Ok")) ; | 1358 | question, i18n("Ok")) ; |
1351 | 1359 | ||
1352 | } | 1360 | } |
1353 | delete calendar; | 1361 | delete calendar; |
1354 | updateView(); | 1362 | updateView(); |
1355 | emit tempDisableBR(false); | 1363 | emit tempDisableBR(false); |
1356 | return ;//syncOK; | 1364 | return ;//syncOK; |
1357 | 1365 | ||
1358 | } | 1366 | } |
1359 | 1367 | ||
1360 | bool CalendarView::importBday() | 1368 | bool CalendarView::importBday() |
1361 | { | 1369 | { |
1362 | #ifndef KORG_NOKABC | 1370 | #ifndef KORG_NOKABC |
1363 | 1371 | ||
1364 | #ifdef DESKTOP_VERSION | 1372 | #ifdef DESKTOP_VERSION |
1365 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1373 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1366 | KABC::AddressBook::Iterator it; | 1374 | KABC::AddressBook::Iterator it; |
1367 | int count = 0; | 1375 | int count = 0; |
1368 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1376 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1369 | ++count; | 1377 | ++count; |
1370 | } | 1378 | } |
1371 | QProgressBar bar(count,0 ); | 1379 | QProgressBar bar(count,0 ); |
1372 | int w = 300; | 1380 | int w = 300; |
1373 | if ( QApplication::desktop()->width() < 320 ) | 1381 | if ( QApplication::desktop()->width() < 320 ) |
1374 | w = 220; | 1382 | w = 220; |
1375 | int h = bar.sizeHint().height() ; | 1383 | int h = bar.sizeHint().height() ; |
1376 | int dw = QApplication::desktop()->width(); | 1384 | int dw = QApplication::desktop()->width(); |
1377 | int dh = QApplication::desktop()->height(); | 1385 | int dh = QApplication::desktop()->height(); |
1378 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1386 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1379 | bar.show(); | 1387 | bar.show(); |
1380 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1388 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1381 | qApp->processEvents(); | 1389 | qApp->processEvents(); |
1382 | count = 0; | 1390 | count = 0; |
1383 | int addCount = 0; | 1391 | int addCount = 0; |
1384 | KCal::Attendee* a = 0; | 1392 | KCal::Attendee* a = 0; |
1385 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1393 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1386 | if ( ! bar.isVisible() ) | 1394 | if ( ! bar.isVisible() ) |
1387 | return false; | 1395 | return false; |
1388 | bar.setProgress( count++ ); | 1396 | bar.setProgress( count++ ); |
1389 | qApp->processEvents(); | 1397 | qApp->processEvents(); |
1390 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1398 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1391 | if ( (*it).birthday().date().isValid() ){ | 1399 | if ( (*it).birthday().date().isValid() ){ |
1392 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1400 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1393 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1401 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1394 | ++addCount; | 1402 | ++addCount; |
1395 | } | 1403 | } |
1396 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1404 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1397 | if ( anni.isValid() ){ | 1405 | if ( anni.isValid() ){ |
1398 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1406 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1399 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1407 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1400 | ++addCount; | 1408 | ++addCount; |
1401 | } | 1409 | } |
1402 | } | 1410 | } |
1403 | updateView(); | 1411 | updateView(); |
1404 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1412 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1405 | #else //DESKTOP_VERSION | 1413 | #else //DESKTOP_VERSION |
1406 | 1414 | ||
1407 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1415 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1408 | // the result should now arrive through method insertBirthdays | 1416 | // the result should now arrive through method insertBirthdays |
1409 | 1417 | ||
1410 | #endif //DESKTOP_VERSION | 1418 | #endif //DESKTOP_VERSION |
1411 | 1419 | ||
1412 | #endif //KORG_NOKABC | 1420 | #endif //KORG_NOKABC |
1413 | 1421 | ||
1414 | 1422 | ||
1415 | return true; | 1423 | return true; |
1416 | } | 1424 | } |
1417 | 1425 | ||
1418 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1426 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1419 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1427 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1420 | const QStringList& anniversaryList, const QStringList& realNameList, | 1428 | const QStringList& anniversaryList, const QStringList& realNameList, |
1421 | const QStringList& emailList, const QStringList& assembledNameList, | 1429 | const QStringList& emailList, const QStringList& assembledNameList, |
1422 | const QStringList& uidList) | 1430 | const QStringList& uidList) |
1423 | { | 1431 | { |
1424 | qDebug("CalendarView::insertBirthdays"); | 1432 | qDebug("CalendarView::insertBirthdays"); |
1425 | if (uid == this->name()) | 1433 | if (uid == this->name()) |
1426 | { | 1434 | { |
1427 | int count = birthdayList.count(); | 1435 | int count = birthdayList.count(); |
1428 | int addCount = 0; | 1436 | int addCount = 0; |
1429 | KCal::Attendee* a = 0; | 1437 | KCal::Attendee* a = 0; |
1430 | 1438 | ||
1431 | qDebug("CalView 1 %i", count); | 1439 | qDebug("CalView 1 %i", count); |
1432 | 1440 | ||
1433 | QProgressBar bar(count,0 ); | 1441 | QProgressBar bar(count,0 ); |
1434 | int w = 300; | 1442 | int w = 300; |
1435 | if ( QApplication::desktop()->width() < 320 ) | 1443 | if ( QApplication::desktop()->width() < 320 ) |
1436 | w = 220; | 1444 | w = 220; |
1437 | int h = bar.sizeHint().height() ; | 1445 | int h = bar.sizeHint().height() ; |
1438 | int dw = QApplication::desktop()->width(); | 1446 | int dw = QApplication::desktop()->width(); |
1439 | int dh = QApplication::desktop()->height(); | 1447 | int dh = QApplication::desktop()->height(); |
1440 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1448 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1441 | bar.show(); | 1449 | bar.show(); |
1442 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1450 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1443 | qApp->processEvents(); | 1451 | qApp->processEvents(); |
1444 | 1452 | ||
1445 | QDate birthday; | 1453 | QDate birthday; |
1446 | QDate anniversary; | 1454 | QDate anniversary; |
1447 | QString realName; | 1455 | QString realName; |
1448 | QString email; | 1456 | QString email; |
1449 | QString assembledName; | 1457 | QString assembledName; |
1450 | QString uid; | 1458 | QString uid; |
1451 | bool ok = true; | 1459 | bool ok = true; |
1452 | for ( int i = 0; i < count; i++) | 1460 | for ( int i = 0; i < count; i++) |
1453 | { | 1461 | { |
1454 | if ( ! bar.isVisible() ) | 1462 | if ( ! bar.isVisible() ) |
1455 | return; | 1463 | return; |
1456 | bar.setProgress( i ); | 1464 | bar.setProgress( i ); |
1457 | qApp->processEvents(); | 1465 | qApp->processEvents(); |
1458 | 1466 | ||
1459 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1467 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1460 | if (!ok) { | 1468 | if (!ok) { |
1461 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1469 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1462 | } | 1470 | } |
1463 | 1471 | ||
1464 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1472 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1465 | if (!ok) { | 1473 | if (!ok) { |
1466 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1474 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1467 | } | 1475 | } |
1468 | realName = realNameList[i]; | 1476 | realName = realNameList[i]; |
1469 | email = emailList[i]; | 1477 | email = emailList[i]; |
1470 | assembledName = assembledNameList[i]; | 1478 | assembledName = assembledNameList[i]; |
1471 | uid = uidList[i]; | 1479 | uid = uidList[i]; |
1472 | //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() ); | 1480 | //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() ); |
1473 | 1481 | ||
1474 | if ( birthday.isValid() ){ | 1482 | if ( birthday.isValid() ){ |
1475 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1483 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1476 | KCal::Attendee::ReqParticipant,uid) ; | 1484 | KCal::Attendee::ReqParticipant,uid) ; |
1477 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1485 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1478 | ++addCount; | 1486 | ++addCount; |
1479 | } | 1487 | } |
1480 | 1488 | ||
1481 | if ( anniversary.isValid() ){ | 1489 | if ( anniversary.isValid() ){ |
1482 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1490 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1483 | KCal::Attendee::ReqParticipant,uid) ; | 1491 | KCal::Attendee::ReqParticipant,uid) ; |
1484 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1492 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1485 | ++addCount; | 1493 | ++addCount; |
1486 | } | 1494 | } |
1487 | } | 1495 | } |
1488 | 1496 | ||
1489 | updateView(); | 1497 | updateView(); |
1490 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1498 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1491 | 1499 | ||
1492 | } | 1500 | } |
1493 | 1501 | ||
1494 | } | 1502 | } |
1495 | 1503 | ||
1496 | 1504 | ||
1497 | 1505 | ||
1498 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1506 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1499 | { | 1507 | { |
1500 | //qDebug("addAnni "); | 1508 | //qDebug("addAnni "); |
1501 | Event * ev = new Event(); | 1509 | Event * ev = new Event(); |
1502 | if ( a ) { | 1510 | if ( a ) { |
1503 | ev->addAttendee( a ); | 1511 | ev->addAttendee( a ); |
1504 | } | 1512 | } |
1505 | QString kind; | 1513 | QString kind; |
1506 | if ( birthday ) | 1514 | if ( birthday ) |
1507 | kind = i18n( "Birthday" ); | 1515 | kind = i18n( "Birthday" ); |
1508 | else | 1516 | else |
1509 | kind = i18n( "Anniversary" ); | 1517 | kind = i18n( "Anniversary" ); |
1510 | ev->setSummary( name + " - " + kind ); | 1518 | ev->setSummary( name + " - " + kind ); |
1511 | ev->setOrganizer(a->email()); | 1519 | ev->setOrganizer(a->email()); |
1512 | ev->setCategories( kind ); | 1520 | ev->setCategories( kind ); |
1513 | ev->setDtStart( QDateTime(date) ); | 1521 | ev->setDtStart( QDateTime(date) ); |
1514 | ev->setDtEnd( QDateTime(date) ); | 1522 | ev->setDtEnd( QDateTime(date) ); |
1515 | ev->setFloats( true ); | 1523 | ev->setFloats( true ); |
1516 | Recurrence * rec = ev->recurrence(); | 1524 | Recurrence * rec = ev->recurrence(); |
1517 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1525 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1518 | rec->addYearlyNum( date.month() ); | 1526 | rec->addYearlyNum( date.month() ); |
1519 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1527 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1520 | delete ev; | 1528 | delete ev; |
1521 | return false; | 1529 | return false; |
1522 | } | 1530 | } |
1523 | return true; | 1531 | return true; |
1524 | 1532 | ||
1525 | } | 1533 | } |
1526 | bool CalendarView::importQtopia( const QString &categories, | 1534 | bool CalendarView::importQtopia( const QString &categories, |
1527 | const QString &datebook, | 1535 | const QString &datebook, |
1528 | const QString &todolist ) | 1536 | const QString &todolist ) |
1529 | { | 1537 | { |
1530 | 1538 | ||
1531 | QtopiaFormat qtopiaFormat; | 1539 | QtopiaFormat qtopiaFormat; |
1532 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1540 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1533 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1541 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1534 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1542 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1535 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1543 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1536 | 1544 | ||
1537 | updateView(); | 1545 | updateView(); |
1538 | return true; | 1546 | return true; |
1539 | 1547 | ||
1540 | #if 0 | 1548 | #if 0 |
1541 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1549 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1542 | mCurrentSyncDevice = "qtopia-XML"; | 1550 | mCurrentSyncDevice = "qtopia-XML"; |
1543 | if ( mSyncManager->mAskForPreferences ) | 1551 | if ( mSyncManager->mAskForPreferences ) |
1544 | edit_sync_options(); | 1552 | edit_sync_options(); |
1545 | qApp->processEvents(); | 1553 | qApp->processEvents(); |
1546 | CalendarLocal* calendar = new CalendarLocal(); | 1554 | CalendarLocal* calendar = new CalendarLocal(); |
1547 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1555 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1548 | bool syncOK = false; | 1556 | bool syncOK = false; |
1549 | QtopiaFormat qtopiaFormat; | 1557 | QtopiaFormat qtopiaFormat; |
1550 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1558 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1551 | bool loadOk = true; | 1559 | bool loadOk = true; |
1552 | if ( !categories.isEmpty() ) | 1560 | if ( !categories.isEmpty() ) |
1553 | loadOk = qtopiaFormat.load( calendar, categories ); | 1561 | loadOk = qtopiaFormat.load( calendar, categories ); |
1554 | if ( loadOk && !datebook.isEmpty() ) | 1562 | if ( loadOk && !datebook.isEmpty() ) |
1555 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1563 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1556 | if ( loadOk && !todolist.isEmpty() ) | 1564 | if ( loadOk && !todolist.isEmpty() ) |
1557 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1565 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1558 | 1566 | ||
1559 | if ( loadOk ) { | 1567 | if ( loadOk ) { |
1560 | getEventViewerDialog()->setSyncMode( true ); | 1568 | getEventViewerDialog()->setSyncMode( true ); |
1561 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1569 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1562 | getEventViewerDialog()->setSyncMode( false ); | 1570 | getEventViewerDialog()->setSyncMode( false ); |
1563 | qApp->processEvents(); | 1571 | qApp->processEvents(); |
1564 | if ( syncOK ) { | 1572 | if ( syncOK ) { |
1565 | if ( mSyncManager->mWriteBackFile ) | 1573 | if ( mSyncManager->mWriteBackFile ) |
1566 | { | 1574 | { |
1567 | // write back XML file | 1575 | // write back XML file |
1568 | 1576 | ||
1569 | } | 1577 | } |
1570 | setModified( true ); | 1578 | setModified( true ); |
1571 | } | 1579 | } |
1572 | } else { | 1580 | } else { |
1573 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1581 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1574 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1582 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1575 | question, i18n("Ok")) ; | 1583 | question, i18n("Ok")) ; |
1576 | } | 1584 | } |
1577 | delete calendar; | 1585 | delete calendar; |
1578 | updateView(); | 1586 | updateView(); |
1579 | return syncOK; | 1587 | return syncOK; |
1580 | 1588 | ||
1581 | 1589 | ||
1582 | #endif | 1590 | #endif |
1583 | 1591 | ||
1584 | } | 1592 | } |
1585 | 1593 | ||
1586 | void CalendarView::setSyncEventsReadOnly() | 1594 | void CalendarView::setSyncEventsReadOnly() |
1587 | { | 1595 | { |
1588 | Event * ev; | 1596 | Event * ev; |
1589 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1597 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1590 | ev = eL.first(); | 1598 | ev = eL.first(); |
1591 | while ( ev ) { | 1599 | while ( ev ) { |
1592 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1600 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1593 | ev->setReadOnly( true ); | 1601 | ev->setReadOnly( true ); |
1594 | ev = eL.next(); | 1602 | ev = eL.next(); |
1595 | } | 1603 | } |
1596 | } | 1604 | } |
1597 | bool CalendarView::openCalendar(QString filename, bool merge) | 1605 | bool CalendarView::openCalendar(QString filename, bool merge) |
1598 | { | 1606 | { |
1599 | 1607 | ||
1600 | if (filename.isEmpty()) { | 1608 | if (filename.isEmpty()) { |
1601 | return false; | 1609 | return false; |
1602 | } | 1610 | } |
1603 | 1611 | ||
1604 | if (!QFile::exists(filename)) { | 1612 | if (!QFile::exists(filename)) { |
1605 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1613 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1606 | return false; | 1614 | return false; |
1607 | } | 1615 | } |
1608 | 1616 | ||
1609 | globalFlagBlockAgenda = 1; | 1617 | globalFlagBlockAgenda = 1; |
1610 | if (!merge) mCalendar->close(); | 1618 | if (!merge) mCalendar->close(); |
1611 | 1619 | ||
1612 | mStorage->setFileName( filename ); | 1620 | mStorage->setFileName( filename ); |
1613 | 1621 | ||
1614 | if ( mStorage->load() ) { | 1622 | if ( mStorage->load() ) { |
1615 | if ( merge ) ;//setModified( true ); | 1623 | if ( merge ) ;//setModified( true ); |
1616 | else { | 1624 | else { |
1617 | //setModified( true ); | 1625 | //setModified( true ); |
1618 | mViewManager->setDocumentId( filename ); | 1626 | mViewManager->setDocumentId( filename ); |
1619 | mDialogManager->setDocumentId( filename ); | 1627 | mDialogManager->setDocumentId( filename ); |
1620 | mTodoList->setDocumentId( filename ); | 1628 | mTodoList->setDocumentId( filename ); |
1621 | } | 1629 | } |
1622 | globalFlagBlockAgenda = 2; | 1630 | globalFlagBlockAgenda = 2; |
1623 | // if ( getLastSyncEvent() ) | 1631 | // if ( getLastSyncEvent() ) |
1624 | // getLastSyncEvent()->setReadOnly( true ); | 1632 | // getLastSyncEvent()->setReadOnly( true ); |
1625 | mCalendar->reInitAlarmSettings(); | 1633 | mCalendar->reInitAlarmSettings(); |
1626 | setSyncEventsReadOnly(); | 1634 | setSyncEventsReadOnly(); |
1627 | updateUnmanagedViews(); | 1635 | updateUnmanagedViews(); |
1628 | updateView(); | 1636 | updateView(); |
1629 | if ( filename != MainWindow::defaultFileName() ) { | 1637 | if ( filename != MainWindow::defaultFileName() ) { |
1630 | saveCalendar( MainWindow::defaultFileName() ); | 1638 | saveCalendar( MainWindow::defaultFileName() ); |
1631 | } else { | 1639 | } else { |
1632 | QFileInfo finf ( MainWindow::defaultFileName()); | 1640 | QFileInfo finf ( MainWindow::defaultFileName()); |
1633 | if ( finf.exists() ) { | 1641 | if ( finf.exists() ) { |
1634 | setLoadedFileVersion( finf.lastModified () ); | 1642 | setLoadedFileVersion( finf.lastModified () ); |
1635 | } | 1643 | } |
1636 | } | 1644 | } |
1637 | return true; | 1645 | return true; |
1638 | } else { | 1646 | } else { |
1639 | // while failing to load, the calendar object could | 1647 | // while failing to load, the calendar object could |
1640 | // have become partially populated. Clear it out. | 1648 | // have become partially populated. Clear it out. |
1641 | if ( !merge ) { | 1649 | if ( !merge ) { |
1642 | mCalendar->close(); | 1650 | mCalendar->close(); |
1643 | mViewManager->setDocumentId( filename ); | 1651 | mViewManager->setDocumentId( filename ); |
1644 | mDialogManager->setDocumentId( filename ); | 1652 | mDialogManager->setDocumentId( filename ); |
1645 | mTodoList->setDocumentId( filename ); | 1653 | mTodoList->setDocumentId( filename ); |
1646 | } | 1654 | } |
1647 | 1655 | ||
1648 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1656 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1649 | 1657 | ||
1650 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1658 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1651 | globalFlagBlockAgenda = 2; | 1659 | globalFlagBlockAgenda = 2; |
1652 | mCalendar->reInitAlarmSettings(); | 1660 | mCalendar->reInitAlarmSettings(); |
1653 | setSyncEventsReadOnly(); | 1661 | setSyncEventsReadOnly(); |
1654 | updateUnmanagedViews(); | 1662 | updateUnmanagedViews(); |
1655 | updateView(); | 1663 | updateView(); |
1656 | } | 1664 | } |
1657 | return false; | 1665 | return false; |
1658 | } | 1666 | } |
1659 | void CalendarView::showOpenError() | 1667 | void CalendarView::showOpenError() |
1660 | { | 1668 | { |
1661 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1669 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1662 | } | 1670 | } |
1663 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1671 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1664 | { | 1672 | { |
1665 | loadedFileVersion = dt; | 1673 | loadedFileVersion = dt; |
1666 | } | 1674 | } |
1667 | bool CalendarView::checkFileChanged(QString fn) | 1675 | bool CalendarView::checkFileChanged(QString fn) |
1668 | { | 1676 | { |
1669 | QFileInfo finf ( fn ); | 1677 | QFileInfo finf ( fn ); |
1670 | if ( !finf.exists() ) | 1678 | if ( !finf.exists() ) |
1671 | return true; | 1679 | return true; |
1672 | QDateTime dt = finf.lastModified (); | 1680 | QDateTime dt = finf.lastModified (); |
1673 | if ( dt <= loadedFileVersion ) | 1681 | if ( dt <= loadedFileVersion ) |
1674 | return false; | 1682 | return false; |
1675 | return true; | 1683 | return true; |
1676 | 1684 | ||
1677 | } | 1685 | } |
1678 | void CalendarView::watchSavedFile() | 1686 | void CalendarView::watchSavedFile() |
1679 | { | 1687 | { |
1680 | QFileInfo finf ( MainWindow::defaultFileName()); | 1688 | QFileInfo finf ( MainWindow::defaultFileName()); |
1681 | if ( !finf.exists() ) | 1689 | if ( !finf.exists() ) |
1682 | return; | 1690 | return; |
1683 | QDateTime dt = finf.lastModified (); | 1691 | QDateTime dt = finf.lastModified (); |
1684 | if ( dt < loadedFileVersion ) { | 1692 | if ( dt < loadedFileVersion ) { |
1685 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1693 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1686 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1694 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1687 | return; | 1695 | return; |
1688 | } | 1696 | } |
1689 | loadedFileVersion = dt; | 1697 | loadedFileVersion = dt; |
1690 | } | 1698 | } |
1691 | 1699 | ||
1692 | bool CalendarView::checkFileVersion(QString fn) | 1700 | bool CalendarView::checkFileVersion(QString fn) |
1693 | { | 1701 | { |
1694 | QFileInfo finf ( fn ); | 1702 | QFileInfo finf ( fn ); |
1695 | if ( !finf.exists() ) | 1703 | if ( !finf.exists() ) |
1696 | return true; | 1704 | return true; |
1697 | QDateTime dt = finf.lastModified (); | 1705 | QDateTime dt = finf.lastModified (); |
1698 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1706 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1699 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1707 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1700 | if ( dt <= loadedFileVersion ) | 1708 | if ( dt <= loadedFileVersion ) |
1701 | return true; | 1709 | return true; |
1702 | 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)) , | 1710 | 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)) , |
1703 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1711 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1704 | i18n("Sync+save")); | 1712 | i18n("Sync+save")); |
1705 | 1713 | ||
1706 | if ( km == KMessageBox::Cancel ) | 1714 | if ( km == KMessageBox::Cancel ) |
1707 | return false; | 1715 | return false; |
1708 | if ( km == KMessageBox::Yes ) | 1716 | if ( km == KMessageBox::Yes ) |
1709 | return true; | 1717 | return true; |
1710 | 1718 | ||
1711 | setSyncDevice("deleteaftersync" ); | 1719 | setSyncDevice("deleteaftersync" ); |
1712 | mSyncManager->mAskForPreferences = true; | 1720 | mSyncManager->mAskForPreferences = true; |
1713 | mSyncManager->mSyncAlgoPrefs = 3; | 1721 | mSyncManager->mSyncAlgoPrefs = 3; |
1714 | mSyncManager->mWriteBackFile = false; | 1722 | mSyncManager->mWriteBackFile = false; |
1715 | mSyncManager->mWriteBackExistingOnly = false; | 1723 | mSyncManager->mWriteBackExistingOnly = false; |
1716 | mSyncManager->mShowSyncSummary = false; | 1724 | mSyncManager->mShowSyncSummary = false; |
1717 | syncCalendar( fn, 3 ); | 1725 | syncCalendar( fn, 3 ); |
1718 | Event * e = getLastSyncEvent(); | 1726 | Event * e = getLastSyncEvent(); |
1719 | mCalendar->deleteEvent ( e ); | 1727 | mCalendar->deleteEvent ( e ); |
1720 | updateView(); | 1728 | updateView(); |
1721 | return true; | 1729 | return true; |
1722 | } | 1730 | } |
1723 | 1731 | ||
1724 | bool CalendarView::saveCalendar( QString filename ) | 1732 | bool CalendarView::saveCalendar( QString filename ) |
1725 | { | 1733 | { |
1726 | 1734 | ||
1727 | // Store back all unsaved data into calendar object | 1735 | // Store back all unsaved data into calendar object |
1728 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1736 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1729 | if ( mViewManager->currentView() ) | 1737 | if ( mViewManager->currentView() ) |
1730 | mViewManager->currentView()->flushView(); | 1738 | mViewManager->currentView()->flushView(); |
1731 | 1739 | ||
1732 | 1740 | ||
1733 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1741 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1734 | mStorage->setSaveFormat( new ICalFormat() ); | 1742 | mStorage->setSaveFormat( new ICalFormat() ); |
1735 | mStorage->setFileName( filename ); | 1743 | mStorage->setFileName( filename ); |
1736 | bool success; | 1744 | bool success; |
1737 | success = mStorage->save(); | 1745 | success = mStorage->save(); |
1738 | if ( !success ) { | 1746 | if ( !success ) { |
1739 | return false; | 1747 | return false; |
1740 | } | 1748 | } |
1741 | if ( filename == MainWindow::defaultFileName() ) { | 1749 | if ( filename == MainWindow::defaultFileName() ) { |
1742 | setLoadedFileVersion( lfv ); | 1750 | setLoadedFileVersion( lfv ); |
1743 | watchSavedFile(); | 1751 | watchSavedFile(); |
1744 | } | 1752 | } |
1745 | return true; | 1753 | return true; |
1746 | } | 1754 | } |
1747 | 1755 | ||
1748 | void CalendarView::closeCalendar() | 1756 | void CalendarView::closeCalendar() |
1749 | { | 1757 | { |
1750 | 1758 | ||
1751 | // child windows no longer valid | 1759 | // child windows no longer valid |
1752 | emit closingDown(); | 1760 | emit closingDown(); |
1753 | 1761 | ||
1754 | mCalendar->close(); | 1762 | mCalendar->close(); |
1755 | setModified(false); | 1763 | setModified(false); |
1756 | updateView(); | 1764 | updateView(); |
1757 | } | 1765 | } |
1758 | 1766 | ||
1759 | void CalendarView::archiveCalendar() | 1767 | void CalendarView::archiveCalendar() |
1760 | { | 1768 | { |
1761 | mDialogManager->showArchiveDialog(); | 1769 | mDialogManager->showArchiveDialog(); |
1762 | } | 1770 | } |
1763 | 1771 | ||
1764 | 1772 | ||
1765 | void CalendarView::readSettings() | 1773 | void CalendarView::readSettings() |
1766 | { | 1774 | { |
1767 | 1775 | ||
1768 | 1776 | ||
1769 | // mViewManager->showAgendaView(); | 1777 | // mViewManager->showAgendaView(); |
1770 | QString str; | 1778 | QString str; |
1771 | //qDebug("CalendarView::readSettings() "); | 1779 | //qDebug("CalendarView::readSettings() "); |
1772 | // read settings from the KConfig, supplying reasonable | 1780 | // read settings from the KConfig, supplying reasonable |
1773 | // defaults where none are to be found | 1781 | // defaults where none are to be found |
1774 | KConfig *config = KOGlobals::config(); | 1782 | KConfig *config = KOGlobals::config(); |
1775 | #ifndef KORG_NOSPLITTER | 1783 | #ifndef KORG_NOSPLITTER |
1776 | config->setGroup("KOrganizer Geometry"); | 1784 | config->setGroup("KOrganizer Geometry"); |
1777 | 1785 | ||
1778 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1786 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1779 | if (sizes.count() != 2) { | 1787 | if (sizes.count() != 2) { |
1780 | sizes << mDateNavigator->minimumSizeHint().width(); | 1788 | sizes << mDateNavigator->minimumSizeHint().width(); |
1781 | sizes << 300; | 1789 | sizes << 300; |
1782 | } | 1790 | } |
1783 | mPanner->setSizes(sizes); | 1791 | mPanner->setSizes(sizes); |
1784 | 1792 | ||
1785 | sizes = config->readIntListEntry("Separator2"); | 1793 | sizes = config->readIntListEntry("Separator2"); |
1786 | if ( ( mResourceView && sizes.count() == 4 ) || | 1794 | if ( ( mResourceView && sizes.count() == 4 ) || |
1787 | ( !mResourceView && sizes.count() == 3 ) ) { | 1795 | ( !mResourceView && sizes.count() == 3 ) ) { |
1788 | mLeftSplitter->setSizes(sizes); | 1796 | mLeftSplitter->setSizes(sizes); |
1789 | } | 1797 | } |
1790 | #endif | 1798 | #endif |
1791 | globalFlagBlockAgenda = 1; | 1799 | globalFlagBlockAgenda = 1; |
1792 | mViewManager->showAgendaView(); | 1800 | mViewManager->showAgendaView(); |
1793 | //mViewManager->readSettings( config ); | 1801 | //mViewManager->readSettings( config ); |
1794 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1802 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1795 | readFilterSettings(config); | 1803 | readFilterSettings(config); |
1796 | config->setGroup( "Views" ); | 1804 | config->setGroup( "Views" ); |
1797 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1805 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1798 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1806 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1799 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1807 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1800 | else mNavigator->selectDates( dateCount ); | 1808 | else mNavigator->selectDates( dateCount ); |
1801 | // mViewManager->readSettings( config ); | 1809 | // mViewManager->readSettings( config ); |
1802 | updateConfig(); | 1810 | updateConfig(); |
1803 | globalFlagBlockAgenda = 2; | 1811 | globalFlagBlockAgenda = 2; |
1804 | mViewManager->readSettings( config ); | 1812 | mViewManager->readSettings( config ); |
1805 | #ifdef DESKTOP_VERSION | 1813 | #ifdef DESKTOP_VERSION |
1806 | config->setGroup("WidgetLayout"); | 1814 | config->setGroup("WidgetLayout"); |
1807 | QStringList list; | 1815 | QStringList list; |
1808 | list = config->readListEntry("MainLayout"); | 1816 | list = config->readListEntry("MainLayout"); |
1809 | int x,y,w,h; | 1817 | int x,y,w,h; |
1810 | if ( ! list.isEmpty() ) { | 1818 | if ( ! list.isEmpty() ) { |
1811 | x = list[0].toInt(); | 1819 | x = list[0].toInt(); |
1812 | y = list[1].toInt(); | 1820 | y = list[1].toInt(); |
1813 | w = list[2].toInt(); | 1821 | w = list[2].toInt(); |
1814 | h = list[3].toInt(); | 1822 | h = list[3].toInt(); |
1815 | topLevelWidget()->setGeometry(x,y,w,h); | 1823 | topLevelWidget()->setGeometry(x,y,w,h); |
1816 | 1824 | ||
1817 | } else { | 1825 | } else { |
1818 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1826 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1819 | } | 1827 | } |
1820 | list = config->readListEntry("EditEventLayout"); | 1828 | list = config->readListEntry("EditEventLayout"); |
1821 | if ( ! list.isEmpty() ) { | 1829 | if ( ! list.isEmpty() ) { |
1822 | x = list[0].toInt(); | 1830 | x = list[0].toInt(); |
1823 | y = list[1].toInt(); | 1831 | y = list[1].toInt(); |
1824 | w = list[2].toInt(); | 1832 | w = list[2].toInt(); |
1825 | h = list[3].toInt(); | 1833 | h = list[3].toInt(); |
1826 | mEventEditor->setGeometry(x,y,w,h); | 1834 | mEventEditor->setGeometry(x,y,w,h); |
1827 | 1835 | ||
1828 | } | 1836 | } |
1829 | list = config->readListEntry("EditTodoLayout"); | 1837 | list = config->readListEntry("EditTodoLayout"); |
1830 | if ( ! list.isEmpty() ) { | 1838 | if ( ! list.isEmpty() ) { |
1831 | x = list[0].toInt(); | 1839 | x = list[0].toInt(); |
1832 | y = list[1].toInt(); | 1840 | y = list[1].toInt(); |
1833 | w = list[2].toInt(); | 1841 | w = list[2].toInt(); |
1834 | h = list[3].toInt(); | 1842 | h = list[3].toInt(); |
1835 | mTodoEditor->setGeometry(x,y,w,h); | 1843 | mTodoEditor->setGeometry(x,y,w,h); |
1836 | 1844 | ||
1837 | } | 1845 | } |
1838 | list = config->readListEntry("ViewerLayout"); | 1846 | list = config->readListEntry("ViewerLayout"); |
1839 | if ( ! list.isEmpty() ) { | 1847 | if ( ! list.isEmpty() ) { |
1840 | x = list[0].toInt(); | 1848 | x = list[0].toInt(); |
1841 | y = list[1].toInt(); | 1849 | y = list[1].toInt(); |
1842 | w = list[2].toInt(); | 1850 | w = list[2].toInt(); |
1843 | h = list[3].toInt(); | 1851 | h = list[3].toInt(); |
1844 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1852 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1845 | } | 1853 | } |
1846 | #endif | 1854 | #endif |
1847 | 1855 | ||
1848 | } | 1856 | } |
1849 | 1857 | ||
1850 | 1858 | ||
1851 | void CalendarView::writeSettings() | 1859 | void CalendarView::writeSettings() |
1852 | { | 1860 | { |
1853 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1861 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1854 | 1862 | ||
1855 | KConfig *config = KOGlobals::config(); | 1863 | KConfig *config = KOGlobals::config(); |
1856 | 1864 | ||
1857 | #ifndef KORG_NOSPLITTER | 1865 | #ifndef KORG_NOSPLITTER |
1858 | config->setGroup("KOrganizer Geometry"); | 1866 | config->setGroup("KOrganizer Geometry"); |
1859 | 1867 | ||
1860 | QValueList<int> list = mPanner->sizes(); | 1868 | QValueList<int> list = mPanner->sizes(); |
1861 | config->writeEntry("Separator1",list); | 1869 | config->writeEntry("Separator1",list); |
1862 | 1870 | ||
1863 | list = mLeftSplitter->sizes(); | 1871 | list = mLeftSplitter->sizes(); |
1864 | config->writeEntry("Separator2",list); | 1872 | config->writeEntry("Separator2",list); |
1865 | #endif | 1873 | #endif |
1866 | 1874 | ||
1867 | mViewManager->writeSettings( config ); | 1875 | mViewManager->writeSettings( config ); |
1868 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1876 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1869 | mDialogManager->writeSettings( config ); | 1877 | mDialogManager->writeSettings( config ); |
1870 | //KOPrefs::instance()->usrWriteConfig(); | 1878 | //KOPrefs::instance()->usrWriteConfig(); |
1871 | KOPrefs::instance()->writeConfig(); | 1879 | KOPrefs::instance()->writeConfig(); |
1872 | 1880 | ||
1873 | writeFilterSettings(config); | 1881 | writeFilterSettings(config); |
1874 | 1882 | ||
1875 | config->setGroup( "Views" ); | 1883 | config->setGroup( "Views" ); |
1876 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1884 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1877 | 1885 | ||
1878 | #ifdef DESKTOP_VERSION | 1886 | #ifdef DESKTOP_VERSION |
1879 | config->setGroup("WidgetLayout"); | 1887 | config->setGroup("WidgetLayout"); |
1880 | QStringList list ;//= config->readListEntry("MainLayout"); | 1888 | QStringList list ;//= config->readListEntry("MainLayout"); |
1881 | int x,y,w,h; | 1889 | int x,y,w,h; |
1882 | QWidget* wid; | 1890 | QWidget* wid; |
1883 | wid = topLevelWidget(); | 1891 | wid = topLevelWidget(); |
1884 | x = wid->geometry().x(); | 1892 | x = wid->geometry().x(); |
1885 | y = wid->geometry().y(); | 1893 | y = wid->geometry().y(); |
1886 | w = wid->width(); | 1894 | w = wid->width(); |
1887 | h = wid->height(); | 1895 | h = wid->height(); |
1888 | list.clear(); | 1896 | list.clear(); |
1889 | list << QString::number( x ); | 1897 | list << QString::number( x ); |
1890 | list << QString::number( y ); | 1898 | list << QString::number( y ); |
1891 | list << QString::number( w ); | 1899 | list << QString::number( w ); |
1892 | list << QString::number( h ); | 1900 | list << QString::number( h ); |
1893 | config->writeEntry("MainLayout",list ); | 1901 | config->writeEntry("MainLayout",list ); |
1894 | 1902 | ||
1895 | wid = mEventEditor; | 1903 | wid = mEventEditor; |
1896 | x = wid->geometry().x(); | 1904 | x = wid->geometry().x(); |
1897 | y = wid->geometry().y(); | 1905 | y = wid->geometry().y(); |
1898 | w = wid->width(); | 1906 | w = wid->width(); |
1899 | h = wid->height(); | 1907 | h = wid->height(); |
1900 | list.clear(); | 1908 | list.clear(); |
1901 | list << QString::number( x ); | 1909 | list << QString::number( x ); |
1902 | list << QString::number( y ); | 1910 | list << QString::number( y ); |
1903 | list << QString::number( w ); | 1911 | list << QString::number( w ); |
1904 | list << QString::number( h ); | 1912 | list << QString::number( h ); |
1905 | config->writeEntry("EditEventLayout",list ); | 1913 | config->writeEntry("EditEventLayout",list ); |
1906 | 1914 | ||
1907 | wid = mTodoEditor; | 1915 | wid = mTodoEditor; |
1908 | x = wid->geometry().x(); | 1916 | x = wid->geometry().x(); |
1909 | y = wid->geometry().y(); | 1917 | y = wid->geometry().y(); |
1910 | w = wid->width(); | 1918 | w = wid->width(); |
1911 | h = wid->height(); | 1919 | h = wid->height(); |
1912 | list.clear(); | 1920 | list.clear(); |
1913 | list << QString::number( x ); | 1921 | list << QString::number( x ); |
1914 | list << QString::number( y ); | 1922 | list << QString::number( y ); |
1915 | list << QString::number( w ); | 1923 | list << QString::number( w ); |
1916 | list << QString::number( h ); | 1924 | list << QString::number( h ); |
1917 | config->writeEntry("EditTodoLayout",list ); | 1925 | config->writeEntry("EditTodoLayout",list ); |
1918 | wid = getEventViewerDialog(); | 1926 | wid = getEventViewerDialog(); |
1919 | x = wid->geometry().x(); | 1927 | x = wid->geometry().x(); |
1920 | y = wid->geometry().y(); | 1928 | y = wid->geometry().y(); |
1921 | w = wid->width(); | 1929 | w = wid->width(); |
1922 | h = wid->height(); | 1930 | h = wid->height(); |
1923 | list.clear(); | 1931 | list.clear(); |
1924 | list << QString::number( x ); | 1932 | list << QString::number( x ); |
1925 | list << QString::number( y ); | 1933 | list << QString::number( y ); |
1926 | list << QString::number( w ); | 1934 | list << QString::number( w ); |
diff --git a/korganizer/filtereditdialog.cpp b/korganizer/filtereditdialog.cpp index ca09844..df84911 100644 --- a/korganizer/filtereditdialog.cpp +++ b/korganizer/filtereditdialog.cpp | |||
@@ -1,270 +1,277 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
26 | #include <qcombobox.h> | 26 | #include <qcombobox.h> |
27 | #include <qcheckbox.h> | 27 | #include <qcheckbox.h> |
28 | #include <qradiobutton.h> | 28 | #include <qradiobutton.h> |
29 | #include <qlistbox.h> | 29 | #include <qlistbox.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | 31 | ||
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <klineeditdlg.h> | 34 | #include <klineeditdlg.h> |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | 36 | ||
37 | #include <libkdepim/categoryselectdialog.h> | 37 | #include <libkdepim/categoryselectdialog.h> |
38 | 38 | ||
39 | #include "koprefs.h" | 39 | #include "koprefs.h" |
40 | #include "filteredit_base.h" | 40 | #include "filteredit_base.h" |
41 | 41 | ||
42 | #include "filtereditdialog.h" | 42 | #include "filtereditdialog.h" |
43 | //#include "filtereditdialog.moc" | 43 | //#include "filtereditdialog.moc" |
44 | 44 | ||
45 | // TODO: Make dialog work on a copy of the filters objects. | 45 | // TODO: Make dialog work on a copy of the filters objects. |
46 | 46 | ||
47 | class ComboFilterBox: public QComboBox | 47 | class ComboFilterBox: public QComboBox |
48 | { | 48 | { |
49 | public: | 49 | public: |
50 | ComboFilterBox( QWidget *parent=0, const char *name=0) : | 50 | ComboFilterBox( QWidget *parent=0, const char *name=0) : |
51 | QComboBox( parent,name ) { } | 51 | QComboBox( parent,name ) { } |
52 | void popupBox() { popup(); } | 52 | void popupBox() { popup(); } |
53 | 53 | ||
54 | }; | 54 | }; |
55 | 55 | ||
56 | FilterEditDialog::FilterEditDialog(QPtrList<CalFilter> *filters,QWidget *parent, | 56 | FilterEditDialog::FilterEditDialog(QPtrList<CalFilter> *filters,QWidget *parent, |
57 | const char *name) : | 57 | const char *name) : |
58 | KDialogBase(parent,name,true,i18n("Edit Calendar Filters"), | 58 | KDialogBase(parent,name,true,i18n("Edit Calendar Filters"), |
59 | Ok|Apply|Cancel) | 59 | Ok|Apply|Cancel) |
60 | { | 60 | { |
61 | mFilters = filters; | 61 | mFilters = filters; |
62 | 62 | ||
63 | QWidget *mainWidget = new QWidget(this); | 63 | QWidget *mainWidget = new QWidget(this); |
64 | setMainWidget(mainWidget); | 64 | setMainWidget(mainWidget); |
65 | 65 | ||
66 | mSelectionCombo = new ComboFilterBox(mainWidget); | 66 | mSelectionCombo = new ComboFilterBox(mainWidget); |
67 | connect(mSelectionCombo,SIGNAL(activated(int)),SLOT(filterSelected())); | 67 | connect(mSelectionCombo,SIGNAL(activated(int)),SLOT(filterSelected())); |
68 | // mSelectionCombo->setEditable ( true ); | 68 | // mSelectionCombo->setEditable ( true ); |
69 | QPushButton *addButton = new QPushButton(i18n("Add Filter"),mainWidget); | 69 | QPushButton *addButton = new QPushButton(i18n("Add Filter"),mainWidget); |
70 | connect(addButton,SIGNAL(clicked()),SLOT(slotAdd())); | 70 | connect(addButton,SIGNAL(clicked()),SLOT(slotAdd())); |
71 | addButton->setMaximumSize( addButton->sizeHint()); | 71 | addButton->setMaximumSize( addButton->sizeHint()); |
72 | mRemoveButton = new QPushButton( i18n("Remove"), mainWidget ); | 72 | mRemoveButton = new QPushButton( i18n("Remove"), mainWidget ); |
73 | connect( mRemoveButton, SIGNAL( clicked() ), SLOT( slotRemove() ) ); | 73 | connect( mRemoveButton, SIGNAL( clicked() ), SLOT( slotRemove() ) ); |
74 | mRemoveButton->setMaximumSize( mRemoveButton->sizeHint()); | 74 | mRemoveButton->setMaximumSize( mRemoveButton->sizeHint()); |
75 | 75 | ||
76 | QPushButton *upButton = new QPushButton(i18n("Up"),mainWidget); | 76 | QPushButton *upButton = new QPushButton(i18n("Up"),mainWidget); |
77 | upButton->setMaximumSize( upButton->sizeHint()); | 77 | upButton->setMaximumSize( upButton->sizeHint()); |
78 | connect(upButton,SIGNAL(clicked()),SLOT(slotUp())); | 78 | connect(upButton,SIGNAL(clicked()),SLOT(slotUp())); |
79 | 79 | ||
80 | 80 | ||
81 | mEditor = new FilterEdit_base(mainWidget); | 81 | mEditor = new FilterEdit_base(mainWidget); |
82 | 82 | ||
83 | QGridLayout *topLayout = new QGridLayout(mainWidget,2,2); | 83 | QGridLayout *topLayout = new QGridLayout(mainWidget,2,2); |
84 | topLayout->setSpacing(spacingHint()); | 84 | topLayout->setSpacing(spacingHint()); |
85 | topLayout->addWidget(mSelectionCombo,0,0); | 85 | topLayout->addWidget(mSelectionCombo,0,0); |
86 | topLayout->addWidget(upButton,0,1); | 86 | topLayout->addWidget(upButton,0,1); |
87 | topLayout->addWidget(addButton,0,2); | 87 | topLayout->addWidget(addButton,0,2); |
88 | topLayout->addWidget(mRemoveButton,0,3); | 88 | topLayout->addWidget(mRemoveButton,0,3); |
89 | topLayout->addMultiCellWidget(mEditor,1,1,0,3); | 89 | topLayout->addMultiCellWidget(mEditor,1,1,0,3); |
90 | mSelectionCombo->setMaximumWidth ( QApplication::desktop()->width() - | 90 | mSelectionCombo->setMaximumWidth ( QApplication::desktop()->width() - |
91 | addButton->maximumWidth() - | 91 | addButton->maximumWidth() - |
92 | mRemoveButton->maximumWidth() - | 92 | mRemoveButton->maximumWidth() - |
93 | upButton->maximumWidth() - | 93 | upButton->maximumWidth() - |
94 | spacingHint() * 5 ); | 94 | spacingHint() * 5 ); |
95 | connect(mEditor->mCatEditButton,SIGNAL(clicked()), | 95 | connect(mEditor->mCatEditButton,SIGNAL(clicked()), |
96 | SLOT(editCategorySelection())); | 96 | SLOT(editCategorySelection())); |
97 | 97 | ||
98 | // Clicking cancel exits the dialog without saving | 98 | // Clicking cancel exits the dialog without saving |
99 | connect(this,SIGNAL(cancelClicked()),SLOT(reject())); | 99 | connect(this,SIGNAL(cancelClicked()),SLOT(reject())); |
100 | updateFilterList(); | 100 | updateFilterList(); |
101 | } | 101 | } |
102 | 102 | ||
103 | FilterEditDialog::~FilterEditDialog() | 103 | FilterEditDialog::~FilterEditDialog() |
104 | { | 104 | { |
105 | } | 105 | } |
106 | void FilterEditDialog::slotUp() | 106 | void FilterEditDialog::slotUp() |
107 | { | 107 | { |
108 | 108 | ||
109 | if ( mFilters->count() <= 1 ) return; | 109 | if ( mFilters->count() <= 1 ) return; |
110 | if ( mSelectionCombo->currentItem() == 0 ) return; | 110 | if ( mSelectionCombo->currentItem() == 0 ) return; |
111 | int num = mSelectionCombo->currentItem(); | 111 | int num = mSelectionCombo->currentItem(); |
112 | CalFilter* f = new CalFilter( ); | 112 | CalFilter* f = new CalFilter( ); |
113 | *f = *(mFilters->at( num )); | 113 | *f = *(mFilters->at( num )); |
114 | mFilters->remove( num ); | 114 | mFilters->remove( num ); |
115 | mFilters->insert( num-1, f ); | 115 | mFilters->insert( num-1, f ); |
116 | updateFilterList(); | 116 | updateFilterList(); |
117 | mSelectionCombo->setCurrentItem( num-1 ); | 117 | mSelectionCombo->setCurrentItem( num-1 ); |
118 | readFilter(f); | 118 | readFilter(f); |
119 | //qApp->processEvents(); | 119 | //qApp->processEvents(); |
120 | //mSelectionCombo->popupBox(); | 120 | //mSelectionCombo->popupBox(); |
121 | } | 121 | } |
122 | void FilterEditDialog::updateFilterList() | 122 | void FilterEditDialog::updateFilterList() |
123 | { | 123 | { |
124 | mSelectionCombo->clear(); | 124 | mSelectionCombo->clear(); |
125 | 125 | ||
126 | CalFilter *filter = mFilters->first(); | 126 | CalFilter *filter = mFilters->first(); |
127 | 127 | ||
128 | if (!filter) { | 128 | if (!filter) { |
129 | enableButtonOK(false); | 129 | enableButtonOK(false); |
130 | enableButtonApply(false); | 130 | enableButtonApply(false); |
131 | } else { | 131 | } else { |
132 | while(filter) { | 132 | while(filter) { |
133 | mSelectionCombo->insertItem(filter->name()); | 133 | mSelectionCombo->insertItem(filter->name()); |
134 | filter = mFilters->next(); | 134 | filter = mFilters->next(); |
135 | } | 135 | } |
136 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); | 136 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); |
137 | if (f) readFilter(f); | 137 | if (f) readFilter(f); |
138 | 138 | ||
139 | enableButtonOK(true); | 139 | enableButtonOK(true); |
140 | enableButtonApply(true); | 140 | enableButtonApply(true); |
141 | } | 141 | } |
142 | 142 | ||
143 | mRemoveButton->setEnabled( mFilters->count() > 1 ); | 143 | mRemoveButton->setEnabled( mFilters->count() > 1 ); |
144 | } | 144 | } |
145 | 145 | ||
146 | void FilterEditDialog::slotDefault() | 146 | void FilterEditDialog::slotDefault() |
147 | { | 147 | { |
148 | } | 148 | } |
149 | 149 | ||
150 | void FilterEditDialog::slotApply() | 150 | void FilterEditDialog::slotApply() |
151 | { | 151 | { |
152 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); | 152 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); |
153 | writeFilter(f); | 153 | writeFilter(f); |
154 | emit filterChanged(); | 154 | emit filterChanged(); |
155 | } | 155 | } |
156 | void FilterEditDialog::accept() | 156 | void FilterEditDialog::accept() |
157 | { | 157 | { |
158 | slotOk(); | 158 | slotOk(); |
159 | } | 159 | } |
160 | void FilterEditDialog::slotOk() | 160 | void FilterEditDialog::slotOk() |
161 | { | 161 | { |
162 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); | 162 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); |
163 | writeFilter(f); | 163 | writeFilter(f); |
164 | emit filterChanged(); | 164 | emit filterChanged(); |
165 | QDialog::accept(); | 165 | QDialog::accept(); |
166 | } | 166 | } |
167 | 167 | ||
168 | void FilterEditDialog::slotAdd() | 168 | void FilterEditDialog::slotAdd() |
169 | { | 169 | { |
170 | KLineEditDlg dlg(i18n("Enter filter name:"), "New Filter", this); | 170 | KLineEditDlg dlg(i18n("Enter filter name:"), "New Filter", this); |
171 | dlg.setCaption(i18n("Add Filter")); | 171 | dlg.setCaption(i18n("Add Filter")); |
172 | if (dlg.exec()) { | 172 | if (dlg.exec()) { |
173 | if ( dlg.text().length() > 0 ) { | 173 | if ( dlg.text().length() > 0 ) { |
174 | mFilters->append(new CalFilter(dlg.text())); | 174 | mFilters->append(new CalFilter(dlg.text())); |
175 | updateFilterList(); | 175 | updateFilterList(); |
176 | int num = mSelectionCombo->count() -1 ; | 176 | int num = mSelectionCombo->count() -1 ; |
177 | mSelectionCombo->setCurrentItem( num ); | 177 | mSelectionCombo->setCurrentItem( num ); |
178 | readFilter(mFilters->at( num ) ); | 178 | readFilter(mFilters->at( num ) ); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | } | 181 | } |
182 | 182 | ||
183 | void FilterEditDialog::slotRemove() | 183 | void FilterEditDialog::slotRemove() |
184 | { | 184 | { |
185 | int currentItem = mSelectionCombo->currentItem(); | 185 | int currentItem = mSelectionCombo->currentItem(); |
186 | if ( currentItem < 0 ) return; | 186 | if ( currentItem < 0 ) return; |
187 | 187 | ||
188 | // We need at least a default filter object. | 188 | // We need at least a default filter object. |
189 | if ( mFilters->count() <= 1 ) return; | 189 | if ( mFilters->count() <= 1 ) return; |
190 | 190 | ||
191 | int result = KMessageBox::questionYesNo( this, | 191 | int result = KMessageBox::questionYesNo( this, |
192 | i18n("This item will be\npermanently deleted.") ); | 192 | i18n("This item will be\npermanently deleted.") ); |
193 | 193 | ||
194 | if ( result != KMessageBox::Yes ) { | 194 | if ( result != KMessageBox::Yes ) { |
195 | return; | 195 | return; |
196 | } | 196 | } |
197 | 197 | ||
198 | mFilters->remove( currentItem ); | 198 | mFilters->remove( currentItem ); |
199 | updateFilterList(); | 199 | updateFilterList(); |
200 | emit filterChanged(); | 200 | emit filterChanged(); |
201 | } | 201 | } |
202 | 202 | ||
203 | void FilterEditDialog::editCategorySelection() | 203 | void FilterEditDialog::editCategorySelection() |
204 | { | 204 | { |
205 | KPIM::CategorySelectDialog *dlg = new KPIM::CategorySelectDialog( | 205 | KPIM::CategorySelectDialog *dlg = new KPIM::CategorySelectDialog( |
206 | KOPrefs::instance(), this, "filterCatSelect", true ); | 206 | KOPrefs::instance(), this, "filterCatSelect", true ); |
207 | dlg->setSelected(mCategories); | 207 | dlg->setSelected(mCategories); |
208 | 208 | ||
209 | connect(dlg,SIGNAL(categoriesSelected(const QStringList &)), | 209 | connect(dlg,SIGNAL(categoriesSelected(const QStringList &)), |
210 | SLOT(updateCategorySelection(const QStringList &))); | 210 | SLOT(updateCategorySelection(const QStringList &))); |
211 | 211 | ||
212 | dlg->exec(); | 212 | dlg->exec(); |
213 | } | 213 | } |
214 | 214 | ||
215 | void FilterEditDialog::updateCategorySelection(const QStringList &categories) | 215 | void FilterEditDialog::updateCategorySelection(const QStringList &categories) |
216 | { | 216 | { |
217 | mCategories = categories; | 217 | mCategories = categories; |
218 | 218 | ||
219 | mEditor->mCatList->clear(); | 219 | mEditor->mCatList->clear(); |
220 | mEditor->mCatList->insertStringList(mCategories); | 220 | mEditor->mCatList->insertStringList(mCategories); |
221 | } | 221 | } |
222 | 222 | ||
223 | void FilterEditDialog::filterSelected() | 223 | void FilterEditDialog::filterSelected() |
224 | { | 224 | { |
225 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); | 225 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); |
226 | if (f) readFilter(f); | 226 | if (f) readFilter(f); |
227 | } | 227 | } |
228 | 228 | ||
229 | void FilterEditDialog::readFilter(CalFilter *filter) | 229 | void FilterEditDialog::readFilter(CalFilter *filter) |
230 | { | 230 | { |
231 | int c = filter->criteria(); | 231 | int c = filter->criteria(); |
232 | 232 | ||
233 | mEditor->mCompletedCheck->setChecked(c & CalFilter::HideCompleted); | 233 | mEditor->mCompletedCheck->setChecked(c & CalFilter::HideCompleted); |
234 | mEditor->mRecurringCheck->setChecked(c & CalFilter::HideRecurring); | 234 | mEditor->mRecurringCheck->setChecked(c & CalFilter::HideRecurring); |
235 | mEditor->mPublicCheck->setChecked(c & CalFilter::ShowPublic); | 235 | mEditor->mPublicCheck->setChecked(c & CalFilter::ShowPublic); |
236 | mEditor->mPrivateCheck->setChecked(c & CalFilter::ShowPrivate); | 236 | mEditor->mPrivateCheck->setChecked(c & CalFilter::ShowPrivate); |
237 | mEditor->mConfidentialCheck->setChecked(c & CalFilter::ShowConfidential); | 237 | mEditor->mConfidentialCheck->setChecked(c & CalFilter::ShowConfidential); |
238 | |||
239 | mEditor->mEventCheck->setChecked(c & CalFilter::HideEvents); | ||
240 | mEditor->mTodoCheck->setChecked(c & CalFilter::HideTodos); | ||
241 | mEditor->mJournalCheck->setChecked(c & CalFilter::HideJournals); | ||
238 | 242 | ||
239 | if (c & CalFilter::ShowCategories) { | 243 | if (c & CalFilter::ShowCategories) { |
240 | mEditor->mCatShowCheck->setChecked(true); | 244 | mEditor->mCatShowCheck->setChecked(true); |
241 | } else { | 245 | } else { |
242 | mEditor->mCatHideCheck->setChecked(true); | 246 | mEditor->mCatHideCheck->setChecked(true); |
243 | } | 247 | } |
244 | 248 | ||
245 | mEditor->mCatList->clear(); | 249 | mEditor->mCatList->clear(); |
246 | mEditor->mCatList->insertStringList(filter->categoryList()); | 250 | mEditor->mCatList->insertStringList(filter->categoryList()); |
247 | mCategories = filter->categoryList(); | 251 | mCategories = filter->categoryList(); |
248 | 252 | ||
249 | setCaption( i18n("Filter position: ") + QString::number ( mSelectionCombo->currentItem()+1 )); | 253 | setCaption( i18n("Filter position: ") + QString::number ( mSelectionCombo->currentItem()+1 )); |
250 | } | 254 | } |
251 | 255 | ||
252 | void FilterEditDialog::writeFilter(CalFilter *filter) | 256 | void FilterEditDialog::writeFilter(CalFilter *filter) |
253 | { | 257 | { |
254 | int c = 0; | 258 | int c = 0; |
255 | 259 | ||
256 | if (mEditor->mCompletedCheck->isChecked()) c |= CalFilter::HideCompleted; | 260 | if (mEditor->mCompletedCheck->isChecked()) c |= CalFilter::HideCompleted; |
257 | if (mEditor->mRecurringCheck->isChecked()) c |= CalFilter::HideRecurring; | 261 | if (mEditor->mRecurringCheck->isChecked()) c |= CalFilter::HideRecurring; |
258 | if (mEditor->mCatShowCheck->isChecked()) c |= CalFilter::ShowCategories; | 262 | if (mEditor->mCatShowCheck->isChecked()) c |= CalFilter::ShowCategories; |
259 | if (mEditor->mPublicCheck->isChecked()) c |= CalFilter::ShowPublic; | 263 | if (mEditor->mPublicCheck->isChecked()) c |= CalFilter::ShowPublic; |
260 | if (mEditor->mPrivateCheck->isChecked()) c |= CalFilter::ShowPrivate; | 264 | if (mEditor->mPrivateCheck->isChecked()) c |= CalFilter::ShowPrivate; |
261 | if (mEditor->mConfidentialCheck->isChecked()) c |= CalFilter::ShowConfidential; | 265 | if (mEditor->mConfidentialCheck->isChecked()) c |= CalFilter::ShowConfidential; |
266 | if (mEditor->mEventCheck->isChecked()) c |= CalFilter::HideEvents; | ||
267 | if (mEditor->mTodoCheck->isChecked()) c |= CalFilter::HideTodos; | ||
268 | if (mEditor->mJournalCheck->isChecked()) c |= CalFilter::HideJournals; | ||
262 | 269 | ||
263 | filter->setCriteria(c); | 270 | filter->setCriteria(c); |
264 | 271 | ||
265 | QStringList categoryList; | 272 | QStringList categoryList; |
266 | for(uint i=0;i<mEditor->mCatList->count();++i) { | 273 | for(uint i=0;i<mEditor->mCatList->count();++i) { |
267 | categoryList.append(mEditor->mCatList->text(i)); | 274 | categoryList.append(mEditor->mCatList->text(i)); |
268 | } | 275 | } |
269 | filter->setCategoryList(categoryList); | 276 | filter->setCategoryList(categoryList); |
270 | } | 277 | } |
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp index c182db5..c425dfc 100644 --- a/libkcal/calfilter.cpp +++ b/libkcal/calfilter.cpp | |||
@@ -1,201 +1,212 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kdebug.h> | 21 | #include <kdebug.h> |
22 | 22 | ||
23 | #include "calfilter.h" | 23 | #include "calfilter.h" |
24 | 24 | ||
25 | using namespace KCal; | 25 | using namespace KCal; |
26 | 26 | ||
27 | CalFilter::CalFilter() | 27 | CalFilter::CalFilter() |
28 | { | 28 | { |
29 | mEnabled = true; | 29 | mEnabled = true; |
30 | mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; | 30 | mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; |
31 | } | 31 | } |
32 | 32 | ||
33 | CalFilter::CalFilter(const QString &name) | 33 | CalFilter::CalFilter(const QString &name) |
34 | { | 34 | { |
35 | mName = name; | 35 | mName = name; |
36 | mEnabled = true; | 36 | mEnabled = true; |
37 | mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; | 37 | mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; |
38 | } | 38 | } |
39 | 39 | ||
40 | CalFilter::~CalFilter() | 40 | CalFilter::~CalFilter() |
41 | { | 41 | { |
42 | } | 42 | } |
43 | 43 | ||
44 | void CalFilter::apply(QPtrList<Event> *eventlist) | 44 | void CalFilter::apply(QPtrList<Event> *eventlist) |
45 | { | 45 | { |
46 | if (!mEnabled) return; | 46 | if (!mEnabled) return; |
47 | 47 | ||
48 | // kdDebug(5800) << "CalFilter::apply()" << endl; | 48 | // kdDebug(5800) << "CalFilter::apply()" << endl; |
49 | 49 | ||
50 | Event *event = eventlist->first(); | 50 | Event *event = eventlist->first(); |
51 | while(event) { | 51 | while(event) { |
52 | if (!filterEvent(event)) { | 52 | if (!filterEvent(event)) { |
53 | eventlist->remove(); | 53 | eventlist->remove(); |
54 | event = eventlist->current(); | 54 | event = eventlist->current(); |
55 | } else { | 55 | } else { |
56 | event = eventlist->next(); | 56 | event = eventlist->next(); |
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | // kdDebug(5800) << "CalFilter::apply() done" << endl; | 60 | // kdDebug(5800) << "CalFilter::apply() done" << endl; |
61 | } | 61 | } |
62 | 62 | ||
63 | // TODO: avoid duplicating apply() code | 63 | // TODO: avoid duplicating apply() code |
64 | void CalFilter::apply(QPtrList<Todo> *eventlist) | 64 | void CalFilter::apply(QPtrList<Todo> *eventlist) |
65 | { | 65 | { |
66 | if (!mEnabled) return; | 66 | if (!mEnabled) return; |
67 | |||
68 | // kdDebug(5800) << "CalFilter::apply()" << endl; | ||
69 | |||
70 | Todo *event = eventlist->first(); | 67 | Todo *event = eventlist->first(); |
71 | while(event) { | 68 | while(event) { |
72 | if (!filterTodo(event)) { | 69 | if (!filterTodo(event)) { |
73 | eventlist->remove(); | 70 | eventlist->remove(); |
74 | event = eventlist->current(); | 71 | event = eventlist->current(); |
75 | } else { | 72 | } else { |
76 | event = eventlist->next(); | 73 | event = eventlist->next(); |
77 | } | 74 | } |
78 | } | 75 | } |
79 | 76 | ||
80 | // kdDebug(5800) << "CalFilter::apply() done" << endl; | 77 | // kdDebug(5800) << "CalFilter::apply() done" << endl; |
81 | } | 78 | } |
82 | 79 | bool CalFilter::filterCalendarItem(Incidence *in) | |
80 | { | ||
81 | if ( in->type() == "Event" ) | ||
82 | return filterEvent( (Event*) in ); | ||
83 | else if ( in->type() =="Todo" ) | ||
84 | return filterTodo( (Todo*) in); | ||
85 | else if ( in->type() =="Journal" ) | ||
86 | return filterJournal( (Journal*) in ); | ||
87 | return false; | ||
88 | } | ||
83 | bool CalFilter::filterEvent(Event *event) | 89 | bool CalFilter::filterEvent(Event *event) |
84 | { | 90 | { |
85 | // kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl; | 91 | if (mCriteria & HideEvents) |
86 | 92 | return false; | |
87 | if (mCriteria & HideRecurring) { | 93 | if (mCriteria & HideRecurring) { |
88 | if (event->recurrence()->doesRecur()) return false; | 94 | if (event->recurrence()->doesRecur()) return false; |
89 | } | 95 | } |
90 | 96 | ||
91 | return filterIncidence(event); | 97 | return filterIncidence(event); |
92 | } | 98 | } |
93 | 99 | bool CalFilter::filterJournal(Journal *j) | |
100 | { | ||
101 | if (mCriteria & HideJournals) | ||
102 | return false; | ||
103 | return true; | ||
104 | } | ||
94 | bool CalFilter::filterTodo(Todo *todo) | 105 | bool CalFilter::filterTodo(Todo *todo) |
95 | { | 106 | { |
96 | // kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl; | 107 | if (mCriteria & HideTodos) |
97 | 108 | return false; | |
98 | if (mCriteria & HideCompleted) { | 109 | if (mCriteria & HideCompleted) { |
99 | if (todo->isCompleted()) return false; | 110 | if (todo->isCompleted()) return false; |
100 | } | 111 | } |
101 | 112 | ||
102 | return filterIncidence(todo); | 113 | return filterIncidence(todo); |
103 | } | 114 | } |
104 | bool CalFilter::showCategories() | 115 | bool CalFilter::showCategories() |
105 | { | 116 | { |
106 | return mCriteria & ShowCategories; | 117 | return mCriteria & ShowCategories; |
107 | } | 118 | } |
108 | int CalFilter::getSecrecy() | 119 | int CalFilter::getSecrecy() |
109 | { | 120 | { |
110 | if ( (mCriteria & ShowPublic )) | 121 | if ( (mCriteria & ShowPublic )) |
111 | return Incidence::SecrecyPublic; | 122 | return Incidence::SecrecyPublic; |
112 | if ( (mCriteria & ShowPrivate )) | 123 | if ( (mCriteria & ShowPrivate )) |
113 | return Incidence::SecrecyPrivate; | 124 | return Incidence::SecrecyPrivate; |
114 | if ( (mCriteria & ShowConfidential )) | 125 | if ( (mCriteria & ShowConfidential )) |
115 | return Incidence::SecrecyConfidential; | 126 | return Incidence::SecrecyConfidential; |
116 | return Incidence::SecrecyPublic; | 127 | return Incidence::SecrecyPublic; |
117 | } | 128 | } |
118 | bool CalFilter::filterIncidence(Incidence *incidence) | 129 | bool CalFilter::filterIncidence(Incidence *incidence) |
119 | { | 130 | { |
120 | if ( mCriteria > 7 ) { | 131 | if ( mCriteria > 7 ) { |
121 | switch (incidence->secrecy()) { | 132 | switch (incidence->secrecy()) { |
122 | case Incidence::SecrecyPublic: | 133 | case Incidence::SecrecyPublic: |
123 | if (! (mCriteria & ShowPublic )) | 134 | if (! (mCriteria & ShowPublic )) |
124 | return false; | 135 | return false; |
125 | break; | 136 | break; |
126 | case Incidence::SecrecyPrivate: | 137 | case Incidence::SecrecyPrivate: |
127 | if (! (mCriteria & ShowPrivate )) | 138 | if (! (mCriteria & ShowPrivate )) |
128 | return false; | 139 | return false; |
129 | break; | 140 | break; |
130 | case Incidence::SecrecyConfidential: | 141 | case Incidence::SecrecyConfidential: |
131 | if (! (mCriteria & ShowConfidential )) | 142 | if (! (mCriteria & ShowConfidential )) |
132 | return false; | 143 | return false; |
133 | break; | 144 | break; |
134 | default: | 145 | default: |
135 | return false; | 146 | return false; |
136 | break; | 147 | break; |
137 | } | 148 | } |
138 | } | 149 | } |
139 | 150 | ||
140 | // kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl; | 151 | // kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl; |
141 | 152 | ||
142 | if (mCriteria & ShowCategories) { | 153 | if (mCriteria & ShowCategories) { |
143 | for (QStringList::Iterator it = mCategoryList.begin(); | 154 | for (QStringList::Iterator it = mCategoryList.begin(); |
144 | it != mCategoryList.end(); ++it ) { | 155 | it != mCategoryList.end(); ++it ) { |
145 | QStringList incidenceCategories = incidence->categories(); | 156 | QStringList incidenceCategories = incidence->categories(); |
146 | for (QStringList::Iterator it2 = incidenceCategories.begin(); | 157 | for (QStringList::Iterator it2 = incidenceCategories.begin(); |
147 | it2 != incidenceCategories.end(); ++it2 ) { | 158 | it2 != incidenceCategories.end(); ++it2 ) { |
148 | if ((*it) == (*it2)) { | 159 | if ((*it) == (*it2)) { |
149 | return true; | 160 | return true; |
150 | } | 161 | } |
151 | } | 162 | } |
152 | } | 163 | } |
153 | return false; | 164 | return false; |
154 | } else { | 165 | } else { |
155 | for (QStringList::Iterator it = mCategoryList.begin(); | 166 | for (QStringList::Iterator it = mCategoryList.begin(); |
156 | it != mCategoryList.end(); ++it ) { | 167 | it != mCategoryList.end(); ++it ) { |
157 | QStringList incidenceCategories = incidence->categories(); | 168 | QStringList incidenceCategories = incidence->categories(); |
158 | for (QStringList::Iterator it2 = incidenceCategories.begin(); | 169 | for (QStringList::Iterator it2 = incidenceCategories.begin(); |
159 | it2 != incidenceCategories.end(); ++it2 ) { | 170 | it2 != incidenceCategories.end(); ++it2 ) { |
160 | if ((*it) == (*it2)) { | 171 | if ((*it) == (*it2)) { |
161 | return false; | 172 | return false; |
162 | } | 173 | } |
163 | } | 174 | } |
164 | } | 175 | } |
165 | return true; | 176 | return true; |
166 | } | 177 | } |
167 | 178 | ||
168 | // kdDebug(5800) << "CalFilter::filterEvent(): passed" << endl; | 179 | // kdDebug(5800) << "CalFilter::filterEvent(): passed" << endl; |
169 | 180 | ||
170 | return true; | 181 | return true; |
171 | } | 182 | } |
172 | 183 | ||
173 | void CalFilter::setEnabled(bool enabled) | 184 | void CalFilter::setEnabled(bool enabled) |
174 | { | 185 | { |
175 | mEnabled = enabled; | 186 | mEnabled = enabled; |
176 | } | 187 | } |
177 | 188 | ||
178 | bool CalFilter::isEnabled() | 189 | bool CalFilter::isEnabled() |
179 | { | 190 | { |
180 | return mEnabled; | 191 | return mEnabled; |
181 | } | 192 | } |
182 | 193 | ||
183 | void CalFilter::setCriteria(int criteria) | 194 | void CalFilter::setCriteria(int criteria) |
184 | { | 195 | { |
185 | mCriteria = criteria; | 196 | mCriteria = criteria; |
186 | } | 197 | } |
187 | 198 | ||
188 | int CalFilter::criteria() | 199 | int CalFilter::criteria() |
189 | { | 200 | { |
190 | return mCriteria; | 201 | return mCriteria; |
191 | } | 202 | } |
192 | 203 | ||
193 | void CalFilter::setCategoryList(const QStringList &categoryList) | 204 | void CalFilter::setCategoryList(const QStringList &categoryList) |
194 | { | 205 | { |
195 | mCategoryList = categoryList; | 206 | mCategoryList = categoryList; |
196 | } | 207 | } |
197 | 208 | ||
198 | QStringList CalFilter::categoryList() | 209 | QStringList CalFilter::categoryList() |
199 | { | 210 | { |
200 | return mCategoryList; | 211 | return mCategoryList; |
201 | } | 212 | } |
diff --git a/libkcal/calfilter.h b/libkcal/calfilter.h index 5ad0064..29db441 100644 --- a/libkcal/calfilter.h +++ b/libkcal/calfilter.h | |||
@@ -1,128 +1,129 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef _CALFILTER_H | 21 | #ifndef _CALFILTER_H |
22 | #define _CALFILTER_H | 22 | #define _CALFILTER_H |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | 26 | ||
27 | #include "event.h" | 27 | #include "event.h" |
28 | #include "todo.h" | 28 | #include "todo.h" |
29 | 29 | ||
30 | namespace KCal { | 30 | namespace KCal { |
31 | 31 | ||
32 | /** | 32 | /** |
33 | Filter for calendar objects. | 33 | Filter for calendar objects. |
34 | */ | 34 | */ |
35 | class CalFilter { | 35 | class CalFilter { |
36 | public: | 36 | public: |
37 | /** Construct filter. */ | 37 | /** Construct filter. */ |
38 | CalFilter(); | 38 | CalFilter(); |
39 | /** Construct filter with name */ | 39 | /** Construct filter with name */ |
40 | CalFilter(const QString &name); | 40 | CalFilter(const QString &name); |
41 | /** Destruct filter. */ | 41 | /** Destruct filter. */ |
42 | ~CalFilter(); | 42 | ~CalFilter(); |
43 | 43 | ||
44 | /** | 44 | /** |
45 | Set name of filter. | 45 | Set name of filter. |
46 | */ | 46 | */ |
47 | void setName(const QString &name) { mName = name; } | 47 | void setName(const QString &name) { mName = name; } |
48 | /** | 48 | /** |
49 | Return name of filter. | 49 | Return name of filter. |
50 | */ | 50 | */ |
51 | QString name() const { return mName; } | 51 | QString name() const { return mName; } |
52 | 52 | ||
53 | /** | 53 | /** |
54 | Apply filter to eventlist, all events not matching filter criterias are | 54 | Apply filter to eventlist, all events not matching filter criterias are |
55 | removed from the list. | 55 | removed from the list. |
56 | */ | 56 | */ |
57 | void apply(QPtrList<Event> *eventlist); | 57 | void apply(QPtrList<Event> *eventlist); |
58 | 58 | ||
59 | /** | 59 | /** |
60 | Apply filter to todolist, all todos not matching filter criterias are | 60 | Apply filter to todolist, all todos not matching filter criterias are |
61 | removed from the list. | 61 | removed from the list. |
62 | */ | 62 | */ |
63 | void apply(QPtrList<Todo> *todolist); | 63 | void apply(QPtrList<Todo> *todolist); |
64 | 64 | bool CalFilter::filterCalendarItem(Incidence *in); | |
65 | bool CalFilter::filterJournal(Journal *in); | ||
65 | /** | 66 | /** |
66 | Apply filter criteria on the specified event. Return true, if event passes | 67 | Apply filter criteria on the specified event. Return true, if event passes |
67 | criteria, otherwise return false. | 68 | criteria, otherwise return false. |
68 | */ | 69 | */ |
69 | bool filterEvent(Event *); | 70 | bool filterEvent(Event *); |
70 | 71 | ||
71 | /** | 72 | /** |
72 | Apply filter criteria on the specified todo. Return true, if event passes | 73 | Apply filter criteria on the specified todo. Return true, if event passes |
73 | criteria, otherwise return false. | 74 | criteria, otherwise return false. |
74 | */ | 75 | */ |
75 | bool filterTodo(Todo *); | 76 | bool filterTodo(Todo *); |
76 | 77 | ||
77 | /** | 78 | /** |
78 | Apply filter criteria on the specified incidence. Return true, if event passes | 79 | Apply filter criteria on the specified incidence. Return true, if event passes |
79 | criteria, otherwise return false. | 80 | criteria, otherwise return false. |
80 | */ | 81 | */ |
81 | bool filterIncidence(Incidence *); | 82 | bool filterIncidence(Incidence *); |
82 | 83 | ||
83 | /** | 84 | /** |
84 | Enable or disable filter. | 85 | Enable or disable filter. |
85 | */ | 86 | */ |
86 | void setEnabled(bool); | 87 | void setEnabled(bool); |
87 | /** | 88 | /** |
88 | Return wheter the filter is enabled or not. | 89 | Return wheter the filter is enabled or not. |
89 | */ | 90 | */ |
90 | bool isEnabled(); | 91 | bool isEnabled(); |
91 | bool showCategories(); | 92 | bool showCategories(); |
92 | int getSecrecy(); | 93 | int getSecrecy(); |
93 | /** | 94 | /** |
94 | Set list of categories, which is used for showing/hiding categories of | 95 | Set list of categories, which is used for showing/hiding categories of |
95 | events. | 96 | events. |
96 | See related functions. | 97 | See related functions. |
97 | */ | 98 | */ |
98 | void setCategoryList(const QStringList &); | 99 | void setCategoryList(const QStringList &); |
99 | /** | 100 | /** |
100 | Return category list, used for showing/hiding categories of events. | 101 | Return category list, used for showing/hiding categories of events. |
101 | See related functions. | 102 | See related functions. |
102 | */ | 103 | */ |
103 | QStringList categoryList(); | 104 | QStringList categoryList(); |
104 | 105 | ||
105 | enum { HideRecurring = 1, HideCompleted = 2, ShowCategories = 4 ,ShowPublic = 8, ShowPrivate = 16, ShowConfidential = 32, HideEvents = 64, HideTodos = 128, HideJournals = 256 }; | 106 | enum { HideRecurring = 1, HideCompleted = 2, ShowCategories = 4 ,ShowPublic = 8, ShowPrivate = 16, ShowConfidential = 32, HideEvents = 64, HideTodos = 128, HideJournals = 256 }; |
106 | 107 | ||
107 | /** | 108 | /** |
108 | Set criteria, which have to be fulfilled by events passing the filter. | 109 | Set criteria, which have to be fulfilled by events passing the filter. |
109 | */ | 110 | */ |
110 | void setCriteria(int); | 111 | void setCriteria(int); |
111 | /** | 112 | /** |
112 | Get inclusive filter criteria. | 113 | Get inclusive filter criteria. |
113 | */ | 114 | */ |
114 | int criteria(); | 115 | int criteria(); |
115 | 116 | ||
116 | private: | 117 | private: |
117 | QString mName; | 118 | QString mName; |
118 | 119 | ||
119 | int mCriteria; | 120 | int mCriteria; |
120 | 121 | ||
121 | bool mEnabled; | 122 | bool mEnabled; |
122 | 123 | ||
123 | QStringList mCategoryList; | 124 | QStringList mCategoryList; |
124 | }; | 125 | }; |
125 | 126 | ||
126 | } | 127 | } |
127 | 128 | ||
128 | #endif /* _CALFILTER_H */ | 129 | #endif /* _CALFILTER_H */ |