-rw-r--r-- | korganizer/calendarview.cpp | 71 |
1 files changed, 35 insertions, 36 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 02c5e45..685bb60 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -302,1633 +302,1632 @@ void CalendarView::init() | |||
302 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 302 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
303 | } else { | 303 | } else { |
304 | mainBoxLayout = new QHBoxLayout(mainBox); | 304 | mainBoxLayout = new QHBoxLayout(mainBox); |
305 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 305 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
306 | } | 306 | } |
307 | topLayout->addWidget( mainBox ); | 307 | topLayout->addWidget( mainBox ); |
308 | mainBoxLayout->addWidget (leftFrame); | 308 | mainBoxLayout->addWidget (leftFrame); |
309 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 309 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
310 | "CalendarView::DateNavigator", QDate::currentDate()); | 310 | "CalendarView::DateNavigator", QDate::currentDate()); |
311 | // mDateNavigator->blockSignals( true ); | 311 | // mDateNavigator->blockSignals( true ); |
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 ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1071 | QString des = eventLSync->description(); | 1071 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1072 | QString pref = "e"; | 1072 | QString des = eventLSync->description(); |
1073 | if ( inR->type() == "Todo" ) | 1073 | QString pref = "e"; |
1074 | pref = "t"; | 1074 | if ( inR->type() == "Todo" ) |
1075 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1075 | pref = "t"; |
1076 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1076 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1077 | //remote->deleteIncidence( inR ); | 1077 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1078 | ++deletedEventR; | 1078 | //remote->deleteIncidence( inR ); |
1079 | } else { | 1079 | ++deletedEventR; |
1080 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1080 | } else { |
1081 | inR->setLastModified( modifiedCalendar ); | 1081 | inR->setLastModified( modifiedCalendar ); |
1082 | inL = inR->clone(); | 1082 | inL = inR->clone(); |
1083 | inL->setIDStr( ":" ); | 1083 | inL->setIDStr( ":" ); |
1084 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1084 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1085 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1085 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1086 | local->addIncidence( inL ); | 1086 | local->addIncidence( inL ); |
1087 | ++addedEvent; | 1087 | ++addedEvent; |
1088 | |||
1088 | } | 1089 | } |
1089 | } | 1090 | } else { |
1090 | } else { | 1091 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1091 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | ||
1092 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | ||
1093 | inR->setLastModified( modifiedCalendar ); | 1092 | inR->setLastModified( modifiedCalendar ); |
1094 | inL = inR->clone(); | 1093 | inL = inR->clone(); |
1095 | inL->setIDStr( ":" ); | 1094 | inL->setIDStr( ":" ); |
1096 | local->addIncidence( inL ); | 1095 | local->addIncidence( inL ); |
1097 | ++addedEvent; | 1096 | ++addedEvent; |
1097 | |||
1098 | } else { | ||
1099 | checkExternSyncEvent(eventRSyncSharp, inR); | ||
1100 | remote->deleteIncidence( inR ); | ||
1101 | ++deletedEventR; | ||
1098 | } | 1102 | } |
1099 | } else { | ||
1100 | checkExternSyncEvent(eventRSyncSharp, inR); | ||
1101 | remote->deleteIncidence( inR ); | ||
1102 | ++deletedEventR; | ||
1103 | } | 1103 | } |
1104 | } | 1104 | } |
1105 | } | 1105 | } |
1106 | } | 1106 | } |
1107 | inR = er.next(); | 1107 | inR = er.next(); |
1108 | } | 1108 | } |
1109 | QPtrList<Incidence> el = local->rawIncidences(); | 1109 | QPtrList<Incidence> el = local->rawIncidences(); |
1110 | inL = el.first(); | 1110 | inL = el.first(); |
1111 | modulo = (el.count()/10)+1; | 1111 | modulo = (el.count()/10)+1; |
1112 | bar.setCaption (i18n("Add / remove events") ); | 1112 | bar.setCaption (i18n("Add / remove events") ); |
1113 | bar.setTotalSteps ( el.count() ) ; | 1113 | bar.setTotalSteps ( el.count() ) ; |
1114 | bar.show(); | 1114 | bar.show(); |
1115 | incCounter = 0; | 1115 | incCounter = 0; |
1116 | 1116 | ||
1117 | while ( inL ) { | 1117 | while ( inL ) { |
1118 | 1118 | ||
1119 | qApp->processEvents(); | 1119 | qApp->processEvents(); |
1120 | if ( ! bar.isVisible() ) | 1120 | if ( ! bar.isVisible() ) |
1121 | return false; | 1121 | return false; |
1122 | if ( incCounter % modulo == 0 ) | 1122 | if ( incCounter % modulo == 0 ) |
1123 | bar.setProgress( incCounter ); | 1123 | bar.setProgress( incCounter ); |
1124 | ++incCounter; | 1124 | ++incCounter; |
1125 | uid = inL->uid(); | 1125 | uid = inL->uid(); |
1126 | bool skipIncidence = false; | 1126 | bool skipIncidence = false; |
1127 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1127 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1128 | skipIncidence = true; | 1128 | skipIncidence = true; |
1129 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1129 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1130 | skipIncidence = true; | 1130 | skipIncidence = true; |
1131 | if ( filterOUT && ! filterOUT->filterCalendarItem( inL ) ){ | ||
1132 | skipIncidence = true; | ||
1133 | } | ||
1131 | if ( !skipIncidence ) { | 1134 | if ( !skipIncidence ) { |
1132 | inR = remote->incidence( uid ); | 1135 | inR = remote->incidence( uid ); |
1133 | if ( ! inR ) { // no conflict ********** add or delete local | 1136 | if ( ! inR ) { // no conflict ********** add or delete local |
1134 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1137 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1135 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1138 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1136 | checkExternSyncEvent(eventLSyncSharp, inL); | 1139 | checkExternSyncEvent(eventLSyncSharp, inL); |
1137 | local->deleteIncidence( inL ); | 1140 | local->deleteIncidence( inL ); |
1138 | ++deletedEventL; | 1141 | ++deletedEventL; |
1139 | } else { | 1142 | } else { |
1140 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1143 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1141 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1144 | inL->removeID(mCurrentSyncDevice ); |
1142 | inL->removeID(mCurrentSyncDevice ); | 1145 | ++addedEventR; |
1143 | ++addedEventR; | 1146 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1144 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1147 | inL->setLastModified( modifiedCalendar ); |
1145 | inL->setLastModified( modifiedCalendar ); | 1148 | inR = inL->clone(); |
1146 | inR = inL->clone(); | 1149 | inR->setIDStr( ":" ); |
1147 | inR->setIDStr( ":" ); | 1150 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1148 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1151 | remote->addIncidence( inR ); |
1149 | remote->addIncidence( inR ); | ||
1150 | } | ||
1151 | } | 1152 | } |
1152 | } | 1153 | } |
1153 | } else { | 1154 | } else { |
1154 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1155 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1155 | checkExternSyncEvent(eventLSyncSharp, inL); | 1156 | checkExternSyncEvent(eventLSyncSharp, inL); |
1156 | local->deleteIncidence( inL ); | 1157 | local->deleteIncidence( inL ); |
1157 | ++deletedEventL; | 1158 | ++deletedEventL; |
1158 | } else { | 1159 | } else { |
1159 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1160 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1160 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1161 | ++addedEventR; |
1161 | ++addedEventR; | 1162 | inL->setLastModified( modifiedCalendar ); |
1162 | inL->setLastModified( modifiedCalendar ); | 1163 | inR = inL->clone(); |
1163 | inR = inL->clone(); | 1164 | inR->setIDStr( ":" ); |
1164 | inR->setIDStr( ":" ); | 1165 | remote->addIncidence( inR ); |
1165 | remote->addIncidence( inR ); | ||
1166 | } | ||
1167 | } | 1166 | } |
1168 | } | 1167 | } |
1169 | } | 1168 | } |
1170 | } | 1169 | } |
1171 | } | 1170 | } |
1172 | inL = el.next(); | 1171 | inL = el.next(); |
1173 | } | 1172 | } |
1174 | int delFut = 0; | 1173 | int delFut = 0; |
1175 | int remRem = 0; | 1174 | int remRem = 0; |
1176 | if ( mSyncManager->mWriteBackInFuture ) { | 1175 | if ( mSyncManager->mWriteBackInFuture ) { |
1177 | er = remote->rawIncidences(); | 1176 | er = remote->rawIncidences(); |
1178 | remRem = er.count(); | 1177 | remRem = er.count(); |
1179 | inR = er.first(); | 1178 | inR = er.first(); |
1180 | QDateTime dt; | 1179 | QDateTime dt; |
1181 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1180 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1182 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1181 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1183 | while ( inR ) { | 1182 | while ( inR ) { |
1184 | if ( inR->type() == "Todo" ) { | 1183 | if ( inR->type() == "Todo" ) { |
1185 | Todo * t = (Todo*)inR; | 1184 | Todo * t = (Todo*)inR; |
1186 | if ( t->hasDueDate() ) | 1185 | if ( t->hasDueDate() ) |
1187 | dt = t->dtDue(); | 1186 | dt = t->dtDue(); |
1188 | else | 1187 | else |
1189 | dt = cur.addSecs( 62 ); | 1188 | dt = cur.addSecs( 62 ); |
1190 | } | 1189 | } |
1191 | else if (inR->type() == "Event" ) { | 1190 | else if (inR->type() == "Event" ) { |
1192 | bool ok; | 1191 | bool ok; |
1193 | dt = inR->getNextOccurence( cur, &ok ); | 1192 | dt = inR->getNextOccurence( cur, &ok ); |
1194 | if ( !ok ) | 1193 | if ( !ok ) |
1195 | dt = cur.addSecs( -62 ); | 1194 | dt = cur.addSecs( -62 ); |
1196 | } | 1195 | } |
1197 | else | 1196 | else |
1198 | dt = inR->dtStart(); | 1197 | dt = inR->dtStart(); |
1199 | if ( dt < cur || dt > end ) { | 1198 | if ( dt < cur || dt > end ) { |
1200 | remote->deleteIncidence( inR ); | 1199 | remote->deleteIncidence( inR ); |
1201 | ++delFut; | 1200 | ++delFut; |
1202 | } | 1201 | } |
1203 | inR = er.next(); | 1202 | inR = er.next(); |
1204 | } | 1203 | } |
1205 | } | 1204 | } |
1206 | bar.hide(); | 1205 | bar.hide(); |
1207 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1206 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1208 | eventLSync->setReadOnly( false ); | 1207 | eventLSync->setReadOnly( false ); |
1209 | eventLSync->setDtStart( mLastCalendarSync ); | 1208 | eventLSync->setDtStart( mLastCalendarSync ); |
1210 | eventRSync->setDtStart( mLastCalendarSync ); | 1209 | eventRSync->setDtStart( mLastCalendarSync ); |
1211 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1210 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1212 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1211 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1213 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1212 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1214 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1213 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1215 | eventLSync->setReadOnly( true ); | 1214 | eventLSync->setReadOnly( true ); |
1216 | qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); | 1215 | qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); |
1217 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1216 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1218 | remote->addEvent( eventRSync ); | 1217 | remote->addEvent( eventRSync ); |
1219 | else | 1218 | else |
1220 | delete eventRSync; | 1219 | delete eventRSync; |
1221 | QString mes; | 1220 | QString mes; |
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 ); | 1221 | 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 ); |
1223 | QString delmess; | 1222 | QString delmess; |
1224 | if ( delFut ) { | 1223 | if ( 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); | 1224 | 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); |
1226 | mes += delmess; | 1225 | mes += delmess; |
1227 | } | 1226 | } |
1228 | mes = i18n("Local calendar changed!\n") +mes; | 1227 | mes = i18n("Local calendar changed!\n") +mes; |
1229 | mCalendar->checkAlarmForIncidence( 0, true ); | 1228 | mCalendar->checkAlarmForIncidence( 0, true ); |
1230 | qDebug( mes ); | 1229 | qDebug( mes ); |
1231 | if ( mSyncManager->mShowSyncSummary ) { | 1230 | if ( mSyncManager->mShowSyncSummary ) { |
1232 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1231 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1233 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1232 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1234 | qDebug("cancelled "); | 1233 | qDebug("cancelled "); |
1235 | return false; | 1234 | return false; |
1236 | } | 1235 | } |
1237 | } | 1236 | } |
1238 | return syncOK; | 1237 | return syncOK; |
1239 | } | 1238 | } |
1240 | 1239 | ||
1241 | void CalendarView::setSyncDevice( QString s ) | 1240 | void CalendarView::setSyncDevice( QString s ) |
1242 | { | 1241 | { |
1243 | mCurrentSyncDevice= s; | 1242 | mCurrentSyncDevice= s; |
1244 | } | 1243 | } |
1245 | void CalendarView::setSyncName( QString s ) | 1244 | void CalendarView::setSyncName( QString s ) |
1246 | { | 1245 | { |
1247 | mCurrentSyncName= s; | 1246 | mCurrentSyncName= s; |
1248 | } | 1247 | } |
1249 | bool CalendarView::syncCalendar(QString filename, int mode) | 1248 | bool CalendarView::syncCalendar(QString filename, int mode) |
1250 | { | 1249 | { |
1251 | //qDebug("syncCalendar %s ", filename.latin1()); | 1250 | //qDebug("syncCalendar %s ", filename.latin1()); |
1252 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1251 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1253 | CalendarLocal* calendar = new CalendarLocal(); | 1252 | CalendarLocal* calendar = new CalendarLocal(); |
1254 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1253 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1255 | FileStorage* storage = new FileStorage( calendar ); | 1254 | FileStorage* storage = new FileStorage( calendar ); |
1256 | bool syncOK = false; | 1255 | bool syncOK = false; |
1257 | storage->setFileName( filename ); | 1256 | storage->setFileName( filename ); |
1258 | // qDebug("loading ... "); | 1257 | // qDebug("loading ... "); |
1259 | if ( storage->load() ) { | 1258 | if ( storage->load() ) { |
1260 | getEventViewerDialog()->setSyncMode( true ); | 1259 | getEventViewerDialog()->setSyncMode( true ); |
1261 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1260 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1262 | getEventViewerDialog()->setSyncMode( false ); | 1261 | getEventViewerDialog()->setSyncMode( false ); |
1263 | if ( syncOK ) { | 1262 | if ( syncOK ) { |
1264 | if ( mSyncManager->mWriteBackFile ) | 1263 | if ( mSyncManager->mWriteBackFile ) |
1265 | { | 1264 | { |
1266 | storage->setSaveFormat( new ICalFormat() ); | 1265 | storage->setSaveFormat( new ICalFormat() ); |
1267 | storage->save(); | 1266 | storage->save(); |
1268 | } | 1267 | } |
1269 | } | 1268 | } |
1270 | setModified( true ); | 1269 | setModified( true ); |
1271 | } | 1270 | } |
1272 | delete storage; | 1271 | delete storage; |
1273 | delete calendar; | 1272 | delete calendar; |
1274 | if ( syncOK ) | 1273 | if ( syncOK ) |
1275 | updateView(); | 1274 | updateView(); |
1276 | return syncOK; | 1275 | return syncOK; |
1277 | } | 1276 | } |
1278 | 1277 | ||
1279 | void CalendarView::syncExternal( int mode ) | 1278 | void CalendarView::syncExternal( int mode ) |
1280 | { | 1279 | { |
1281 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1280 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1282 | 1281 | ||
1283 | qApp->processEvents(); | 1282 | qApp->processEvents(); |
1284 | CalendarLocal* calendar = new CalendarLocal(); | 1283 | CalendarLocal* calendar = new CalendarLocal(); |
1285 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1284 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1286 | bool syncOK = false; | 1285 | bool syncOK = false; |
1287 | bool loadSuccess = false; | 1286 | bool loadSuccess = false; |
1288 | PhoneFormat* phoneFormat = 0; | 1287 | PhoneFormat* phoneFormat = 0; |
1289 | emit tempDisableBR(true); | 1288 | emit tempDisableBR(true); |
1290 | #ifndef DESKTOP_VERSION | 1289 | #ifndef DESKTOP_VERSION |
1291 | SharpFormat* sharpFormat = 0; | 1290 | SharpFormat* sharpFormat = 0; |
1292 | if ( mode == 0 ) { // sharp | 1291 | if ( mode == 0 ) { // sharp |
1293 | sharpFormat = new SharpFormat () ; | 1292 | sharpFormat = new SharpFormat () ; |
1294 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1293 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1295 | 1294 | ||
1296 | } else | 1295 | } else |
1297 | #endif | 1296 | #endif |
1298 | if ( mode == 1 ) { // phone | 1297 | if ( mode == 1 ) { // phone |
1299 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1298 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1300 | mSyncManager->mPhoneDevice, | 1299 | mSyncManager->mPhoneDevice, |
1301 | mSyncManager->mPhoneConnection, | 1300 | mSyncManager->mPhoneConnection, |
1302 | mSyncManager->mPhoneModel); | 1301 | mSyncManager->mPhoneModel); |
1303 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1302 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1304 | 1303 | ||
1305 | } else { | 1304 | } else { |
1306 | emit tempDisableBR(false); | 1305 | emit tempDisableBR(false); |
1307 | return; | 1306 | return; |
1308 | } | 1307 | } |
1309 | if ( loadSuccess ) { | 1308 | if ( loadSuccess ) { |
1310 | getEventViewerDialog()->setSyncMode( true ); | 1309 | getEventViewerDialog()->setSyncMode( true ); |
1311 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1310 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1312 | getEventViewerDialog()->setSyncMode( false ); | 1311 | getEventViewerDialog()->setSyncMode( false ); |
1313 | qApp->processEvents(); | 1312 | qApp->processEvents(); |
1314 | if ( syncOK ) { | 1313 | if ( syncOK ) { |
1315 | if ( mSyncManager->mWriteBackFile ) | 1314 | if ( mSyncManager->mWriteBackFile ) |
1316 | { | 1315 | { |
1317 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1316 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1318 | Incidence* inc = iL.first(); | 1317 | Incidence* inc = iL.first(); |
1319 | if ( phoneFormat ) { | 1318 | if ( phoneFormat ) { |
1320 | while ( inc ) { | 1319 | while ( inc ) { |
1321 | inc->removeID(mCurrentSyncDevice); | 1320 | inc->removeID(mCurrentSyncDevice); |
1322 | inc = iL.next(); | 1321 | inc = iL.next(); |
1323 | } | 1322 | } |
1324 | } | 1323 | } |
1325 | #ifndef DESKTOP_VERSION | 1324 | #ifndef DESKTOP_VERSION |
1326 | if ( sharpFormat ) | 1325 | if ( sharpFormat ) |
1327 | sharpFormat->save(calendar); | 1326 | sharpFormat->save(calendar); |
1328 | #endif | 1327 | #endif |
1329 | if ( phoneFormat ) | 1328 | if ( phoneFormat ) |
1330 | phoneFormat->save(calendar); | 1329 | phoneFormat->save(calendar); |
1331 | iL = calendar->rawIncidences(); | 1330 | iL = calendar->rawIncidences(); |
1332 | inc = iL.first(); | 1331 | inc = iL.first(); |
1333 | Incidence* loc; | 1332 | Incidence* loc; |
1334 | while ( inc ) { | 1333 | while ( inc ) { |
1335 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1334 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1336 | loc = mCalendar->incidence(inc->uid() ); | 1335 | loc = mCalendar->incidence(inc->uid() ); |
1337 | if ( loc ) { | 1336 | if ( loc ) { |
1338 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1337 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1339 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1338 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1340 | } | 1339 | } |
1341 | } | 1340 | } |
1342 | inc = iL.next(); | 1341 | inc = iL.next(); |
1343 | } | 1342 | } |
1344 | Incidence* lse = getLastSyncEvent(); | 1343 | Incidence* lse = getLastSyncEvent(); |
1345 | if ( lse ) { | 1344 | if ( lse ) { |
1346 | lse->setReadOnly( false ); | 1345 | lse->setReadOnly( false ); |
1347 | lse->setDescription( "" ); | 1346 | lse->setDescription( "" ); |
1348 | lse->setReadOnly( true ); | 1347 | lse->setReadOnly( true ); |
1349 | } | 1348 | } |
1350 | } | 1349 | } |
1351 | } else { | 1350 | } else { |
1352 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1351 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1353 | } | 1352 | } |
1354 | setModified( true ); | 1353 | setModified( true ); |
1355 | } else { | 1354 | } else { |
1356 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1355 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1357 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1356 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1358 | question, i18n("Ok")) ; | 1357 | question, i18n("Ok")) ; |
1359 | 1358 | ||
1360 | } | 1359 | } |
1361 | delete calendar; | 1360 | delete calendar; |
1362 | updateView(); | 1361 | updateView(); |
1363 | emit tempDisableBR(false); | 1362 | emit tempDisableBR(false); |
1364 | return ;//syncOK; | 1363 | return ;//syncOK; |
1365 | 1364 | ||
1366 | } | 1365 | } |
1367 | 1366 | ||
1368 | bool CalendarView::importBday() | 1367 | bool CalendarView::importBday() |
1369 | { | 1368 | { |
1370 | #ifndef KORG_NOKABC | 1369 | #ifndef KORG_NOKABC |
1371 | 1370 | ||
1372 | #ifdef DESKTOP_VERSION | 1371 | #ifdef DESKTOP_VERSION |
1373 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1372 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1374 | KABC::AddressBook::Iterator it; | 1373 | KABC::AddressBook::Iterator it; |
1375 | int count = 0; | 1374 | int count = 0; |
1376 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1375 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1377 | ++count; | 1376 | ++count; |
1378 | } | 1377 | } |
1379 | QProgressBar bar(count,0 ); | 1378 | QProgressBar bar(count,0 ); |
1380 | int w = 300; | 1379 | int w = 300; |
1381 | if ( QApplication::desktop()->width() < 320 ) | 1380 | if ( QApplication::desktop()->width() < 320 ) |
1382 | w = 220; | 1381 | w = 220; |
1383 | int h = bar.sizeHint().height() ; | 1382 | int h = bar.sizeHint().height() ; |
1384 | int dw = QApplication::desktop()->width(); | 1383 | int dw = QApplication::desktop()->width(); |
1385 | int dh = QApplication::desktop()->height(); | 1384 | int dh = QApplication::desktop()->height(); |
1386 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1385 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1387 | bar.show(); | 1386 | bar.show(); |
1388 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1387 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1389 | qApp->processEvents(); | 1388 | qApp->processEvents(); |
1390 | count = 0; | 1389 | count = 0; |
1391 | int addCount = 0; | 1390 | int addCount = 0; |
1392 | KCal::Attendee* a = 0; | 1391 | KCal::Attendee* a = 0; |
1393 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1392 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1394 | if ( ! bar.isVisible() ) | 1393 | if ( ! bar.isVisible() ) |
1395 | return false; | 1394 | return false; |
1396 | bar.setProgress( count++ ); | 1395 | bar.setProgress( count++ ); |
1397 | qApp->processEvents(); | 1396 | qApp->processEvents(); |
1398 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1397 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1399 | if ( (*it).birthday().date().isValid() ){ | 1398 | if ( (*it).birthday().date().isValid() ){ |
1400 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1399 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1401 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1400 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1402 | ++addCount; | 1401 | ++addCount; |
1403 | } | 1402 | } |
1404 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1403 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1405 | if ( anni.isValid() ){ | 1404 | if ( anni.isValid() ){ |
1406 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1405 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1407 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1406 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1408 | ++addCount; | 1407 | ++addCount; |
1409 | } | 1408 | } |
1410 | } | 1409 | } |
1411 | updateView(); | 1410 | updateView(); |
1412 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1411 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1413 | #else //DESKTOP_VERSION | 1412 | #else //DESKTOP_VERSION |
1414 | 1413 | ||
1415 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1414 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1416 | // the result should now arrive through method insertBirthdays | 1415 | // the result should now arrive through method insertBirthdays |
1417 | 1416 | ||
1418 | #endif //DESKTOP_VERSION | 1417 | #endif //DESKTOP_VERSION |
1419 | 1418 | ||
1420 | #endif //KORG_NOKABC | 1419 | #endif //KORG_NOKABC |
1421 | 1420 | ||
1422 | 1421 | ||
1423 | return true; | 1422 | return true; |
1424 | } | 1423 | } |
1425 | 1424 | ||
1426 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1425 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1427 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1426 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1428 | const QStringList& anniversaryList, const QStringList& realNameList, | 1427 | const QStringList& anniversaryList, const QStringList& realNameList, |
1429 | const QStringList& emailList, const QStringList& assembledNameList, | 1428 | const QStringList& emailList, const QStringList& assembledNameList, |
1430 | const QStringList& uidList) | 1429 | const QStringList& uidList) |
1431 | { | 1430 | { |
1432 | qDebug("CalendarView::insertBirthdays"); | 1431 | qDebug("CalendarView::insertBirthdays"); |
1433 | if (uid == this->name()) | 1432 | if (uid == this->name()) |
1434 | { | 1433 | { |
1435 | int count = birthdayList.count(); | 1434 | int count = birthdayList.count(); |
1436 | int addCount = 0; | 1435 | int addCount = 0; |
1437 | KCal::Attendee* a = 0; | 1436 | KCal::Attendee* a = 0; |
1438 | 1437 | ||
1439 | qDebug("CalView 1 %i", count); | 1438 | qDebug("CalView 1 %i", count); |
1440 | 1439 | ||
1441 | QProgressBar bar(count,0 ); | 1440 | QProgressBar bar(count,0 ); |
1442 | int w = 300; | 1441 | int w = 300; |
1443 | if ( QApplication::desktop()->width() < 320 ) | 1442 | if ( QApplication::desktop()->width() < 320 ) |
1444 | w = 220; | 1443 | w = 220; |
1445 | int h = bar.sizeHint().height() ; | 1444 | int h = bar.sizeHint().height() ; |
1446 | int dw = QApplication::desktop()->width(); | 1445 | int dw = QApplication::desktop()->width(); |
1447 | int dh = QApplication::desktop()->height(); | 1446 | int dh = QApplication::desktop()->height(); |
1448 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1447 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1449 | bar.show(); | 1448 | bar.show(); |
1450 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1449 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1451 | qApp->processEvents(); | 1450 | qApp->processEvents(); |
1452 | 1451 | ||
1453 | QDate birthday; | 1452 | QDate birthday; |
1454 | QDate anniversary; | 1453 | QDate anniversary; |
1455 | QString realName; | 1454 | QString realName; |
1456 | QString email; | 1455 | QString email; |
1457 | QString assembledName; | 1456 | QString assembledName; |
1458 | QString uid; | 1457 | QString uid; |
1459 | bool ok = true; | 1458 | bool ok = true; |
1460 | for ( int i = 0; i < count; i++) | 1459 | for ( int i = 0; i < count; i++) |
1461 | { | 1460 | { |
1462 | if ( ! bar.isVisible() ) | 1461 | if ( ! bar.isVisible() ) |
1463 | return; | 1462 | return; |
1464 | bar.setProgress( i ); | 1463 | bar.setProgress( i ); |
1465 | qApp->processEvents(); | 1464 | qApp->processEvents(); |
1466 | 1465 | ||
1467 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1466 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1468 | if (!ok) { | 1467 | if (!ok) { |
1469 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1468 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1470 | } | 1469 | } |
1471 | 1470 | ||
1472 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1471 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1473 | if (!ok) { | 1472 | if (!ok) { |
1474 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1473 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1475 | } | 1474 | } |
1476 | realName = realNameList[i]; | 1475 | realName = realNameList[i]; |
1477 | email = emailList[i]; | 1476 | email = emailList[i]; |
1478 | assembledName = assembledNameList[i]; | 1477 | assembledName = assembledNameList[i]; |
1479 | uid = uidList[i]; | 1478 | uid = uidList[i]; |
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() ); | 1479 | //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() ); |
1481 | 1480 | ||
1482 | if ( birthday.isValid() ){ | 1481 | if ( birthday.isValid() ){ |
1483 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1482 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1484 | KCal::Attendee::ReqParticipant,uid) ; | 1483 | KCal::Attendee::ReqParticipant,uid) ; |
1485 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1484 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1486 | ++addCount; | 1485 | ++addCount; |
1487 | } | 1486 | } |
1488 | 1487 | ||
1489 | if ( anniversary.isValid() ){ | 1488 | if ( anniversary.isValid() ){ |
1490 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1489 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1491 | KCal::Attendee::ReqParticipant,uid) ; | 1490 | KCal::Attendee::ReqParticipant,uid) ; |
1492 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1491 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1493 | ++addCount; | 1492 | ++addCount; |
1494 | } | 1493 | } |
1495 | } | 1494 | } |
1496 | 1495 | ||
1497 | updateView(); | 1496 | updateView(); |
1498 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1497 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1499 | 1498 | ||
1500 | } | 1499 | } |
1501 | 1500 | ||
1502 | } | 1501 | } |
1503 | 1502 | ||
1504 | 1503 | ||
1505 | 1504 | ||
1506 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1505 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1507 | { | 1506 | { |
1508 | //qDebug("addAnni "); | 1507 | //qDebug("addAnni "); |
1509 | Event * ev = new Event(); | 1508 | Event * ev = new Event(); |
1510 | if ( a ) { | 1509 | if ( a ) { |
1511 | ev->addAttendee( a ); | 1510 | ev->addAttendee( a ); |
1512 | } | 1511 | } |
1513 | QString kind; | 1512 | QString kind; |
1514 | if ( birthday ) | 1513 | if ( birthday ) |
1515 | kind = i18n( "Birthday" ); | 1514 | kind = i18n( "Birthday" ); |
1516 | else | 1515 | else |
1517 | kind = i18n( "Anniversary" ); | 1516 | kind = i18n( "Anniversary" ); |
1518 | ev->setSummary( name + " - " + kind ); | 1517 | ev->setSummary( name + " - " + kind ); |
1519 | ev->setOrganizer(a->email()); | 1518 | ev->setOrganizer(a->email()); |
1520 | ev->setCategories( kind ); | 1519 | ev->setCategories( kind ); |
1521 | ev->setDtStart( QDateTime(date) ); | 1520 | ev->setDtStart( QDateTime(date) ); |
1522 | ev->setDtEnd( QDateTime(date) ); | 1521 | ev->setDtEnd( QDateTime(date) ); |
1523 | ev->setFloats( true ); | 1522 | ev->setFloats( true ); |
1524 | Recurrence * rec = ev->recurrence(); | 1523 | Recurrence * rec = ev->recurrence(); |
1525 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1524 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1526 | rec->addYearlyNum( date.month() ); | 1525 | rec->addYearlyNum( date.month() ); |
1527 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1526 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1528 | delete ev; | 1527 | delete ev; |
1529 | return false; | 1528 | return false; |
1530 | } | 1529 | } |
1531 | return true; | 1530 | return true; |
1532 | 1531 | ||
1533 | } | 1532 | } |
1534 | bool CalendarView::importQtopia( const QString &categories, | 1533 | bool CalendarView::importQtopia( const QString &categories, |
1535 | const QString &datebook, | 1534 | const QString &datebook, |
1536 | const QString &todolist ) | 1535 | const QString &todolist ) |
1537 | { | 1536 | { |
1538 | 1537 | ||
1539 | QtopiaFormat qtopiaFormat; | 1538 | QtopiaFormat qtopiaFormat; |
1540 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1539 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1541 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1540 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1542 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1541 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1543 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1542 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1544 | 1543 | ||
1545 | updateView(); | 1544 | updateView(); |
1546 | return true; | 1545 | return true; |
1547 | 1546 | ||
1548 | #if 0 | 1547 | #if 0 |
1549 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1548 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1550 | mCurrentSyncDevice = "qtopia-XML"; | 1549 | mCurrentSyncDevice = "qtopia-XML"; |
1551 | if ( mSyncManager->mAskForPreferences ) | 1550 | if ( mSyncManager->mAskForPreferences ) |
1552 | edit_sync_options(); | 1551 | edit_sync_options(); |
1553 | qApp->processEvents(); | 1552 | qApp->processEvents(); |
1554 | CalendarLocal* calendar = new CalendarLocal(); | 1553 | CalendarLocal* calendar = new CalendarLocal(); |
1555 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1554 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1556 | bool syncOK = false; | 1555 | bool syncOK = false; |
1557 | QtopiaFormat qtopiaFormat; | 1556 | QtopiaFormat qtopiaFormat; |
1558 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1557 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1559 | bool loadOk = true; | 1558 | bool loadOk = true; |
1560 | if ( !categories.isEmpty() ) | 1559 | if ( !categories.isEmpty() ) |
1561 | loadOk = qtopiaFormat.load( calendar, categories ); | 1560 | loadOk = qtopiaFormat.load( calendar, categories ); |
1562 | if ( loadOk && !datebook.isEmpty() ) | 1561 | if ( loadOk && !datebook.isEmpty() ) |
1563 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1562 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1564 | if ( loadOk && !todolist.isEmpty() ) | 1563 | if ( loadOk && !todolist.isEmpty() ) |
1565 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1564 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1566 | 1565 | ||
1567 | if ( loadOk ) { | 1566 | if ( loadOk ) { |
1568 | getEventViewerDialog()->setSyncMode( true ); | 1567 | getEventViewerDialog()->setSyncMode( true ); |
1569 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1568 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1570 | getEventViewerDialog()->setSyncMode( false ); | 1569 | getEventViewerDialog()->setSyncMode( false ); |
1571 | qApp->processEvents(); | 1570 | qApp->processEvents(); |
1572 | if ( syncOK ) { | 1571 | if ( syncOK ) { |
1573 | if ( mSyncManager->mWriteBackFile ) | 1572 | if ( mSyncManager->mWriteBackFile ) |
1574 | { | 1573 | { |
1575 | // write back XML file | 1574 | // write back XML file |
1576 | 1575 | ||
1577 | } | 1576 | } |
1578 | setModified( true ); | 1577 | setModified( true ); |
1579 | } | 1578 | } |
1580 | } else { | 1579 | } else { |
1581 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1580 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1582 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1581 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1583 | question, i18n("Ok")) ; | 1582 | question, i18n("Ok")) ; |
1584 | } | 1583 | } |
1585 | delete calendar; | 1584 | delete calendar; |
1586 | updateView(); | 1585 | updateView(); |
1587 | return syncOK; | 1586 | return syncOK; |
1588 | 1587 | ||
1589 | 1588 | ||
1590 | #endif | 1589 | #endif |
1591 | 1590 | ||
1592 | } | 1591 | } |
1593 | 1592 | ||
1594 | void CalendarView::setSyncEventsReadOnly() | 1593 | void CalendarView::setSyncEventsReadOnly() |
1595 | { | 1594 | { |
1596 | Event * ev; | 1595 | Event * ev; |
1597 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1596 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1598 | ev = eL.first(); | 1597 | ev = eL.first(); |
1599 | while ( ev ) { | 1598 | while ( ev ) { |
1600 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1599 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1601 | ev->setReadOnly( true ); | 1600 | ev->setReadOnly( true ); |
1602 | ev = eL.next(); | 1601 | ev = eL.next(); |
1603 | } | 1602 | } |
1604 | } | 1603 | } |
1605 | bool CalendarView::openCalendar(QString filename, bool merge) | 1604 | bool CalendarView::openCalendar(QString filename, bool merge) |
1606 | { | 1605 | { |
1607 | 1606 | ||
1608 | if (filename.isEmpty()) { | 1607 | if (filename.isEmpty()) { |
1609 | return false; | 1608 | return false; |
1610 | } | 1609 | } |
1611 | 1610 | ||
1612 | if (!QFile::exists(filename)) { | 1611 | if (!QFile::exists(filename)) { |
1613 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1612 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1614 | return false; | 1613 | return false; |
1615 | } | 1614 | } |
1616 | 1615 | ||
1617 | globalFlagBlockAgenda = 1; | 1616 | globalFlagBlockAgenda = 1; |
1618 | if (!merge) mCalendar->close(); | 1617 | if (!merge) mCalendar->close(); |
1619 | 1618 | ||
1620 | mStorage->setFileName( filename ); | 1619 | mStorage->setFileName( filename ); |
1621 | 1620 | ||
1622 | if ( mStorage->load() ) { | 1621 | if ( mStorage->load() ) { |
1623 | if ( merge ) ;//setModified( true ); | 1622 | if ( merge ) ;//setModified( true ); |
1624 | else { | 1623 | else { |
1625 | //setModified( true ); | 1624 | //setModified( true ); |
1626 | mViewManager->setDocumentId( filename ); | 1625 | mViewManager->setDocumentId( filename ); |
1627 | mDialogManager->setDocumentId( filename ); | 1626 | mDialogManager->setDocumentId( filename ); |
1628 | mTodoList->setDocumentId( filename ); | 1627 | mTodoList->setDocumentId( filename ); |
1629 | } | 1628 | } |
1630 | globalFlagBlockAgenda = 2; | 1629 | globalFlagBlockAgenda = 2; |
1631 | // if ( getLastSyncEvent() ) | 1630 | // if ( getLastSyncEvent() ) |
1632 | // getLastSyncEvent()->setReadOnly( true ); | 1631 | // getLastSyncEvent()->setReadOnly( true ); |
1633 | mCalendar->reInitAlarmSettings(); | 1632 | mCalendar->reInitAlarmSettings(); |
1634 | setSyncEventsReadOnly(); | 1633 | setSyncEventsReadOnly(); |
1635 | updateUnmanagedViews(); | 1634 | updateUnmanagedViews(); |
1636 | updateView(); | 1635 | updateView(); |
1637 | if ( filename != MainWindow::defaultFileName() ) { | 1636 | if ( filename != MainWindow::defaultFileName() ) { |
1638 | saveCalendar( MainWindow::defaultFileName() ); | 1637 | saveCalendar( MainWindow::defaultFileName() ); |
1639 | } else { | 1638 | } else { |
1640 | QFileInfo finf ( MainWindow::defaultFileName()); | 1639 | QFileInfo finf ( MainWindow::defaultFileName()); |
1641 | if ( finf.exists() ) { | 1640 | if ( finf.exists() ) { |
1642 | setLoadedFileVersion( finf.lastModified () ); | 1641 | setLoadedFileVersion( finf.lastModified () ); |
1643 | } | 1642 | } |
1644 | } | 1643 | } |
1645 | return true; | 1644 | return true; |
1646 | } else { | 1645 | } else { |
1647 | // while failing to load, the calendar object could | 1646 | // while failing to load, the calendar object could |
1648 | // have become partially populated. Clear it out. | 1647 | // have become partially populated. Clear it out. |
1649 | if ( !merge ) { | 1648 | if ( !merge ) { |
1650 | mCalendar->close(); | 1649 | mCalendar->close(); |
1651 | mViewManager->setDocumentId( filename ); | 1650 | mViewManager->setDocumentId( filename ); |
1652 | mDialogManager->setDocumentId( filename ); | 1651 | mDialogManager->setDocumentId( filename ); |
1653 | mTodoList->setDocumentId( filename ); | 1652 | mTodoList->setDocumentId( filename ); |
1654 | } | 1653 | } |
1655 | 1654 | ||
1656 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1655 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1657 | 1656 | ||
1658 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1657 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1659 | globalFlagBlockAgenda = 2; | 1658 | globalFlagBlockAgenda = 2; |
1660 | mCalendar->reInitAlarmSettings(); | 1659 | mCalendar->reInitAlarmSettings(); |
1661 | setSyncEventsReadOnly(); | 1660 | setSyncEventsReadOnly(); |
1662 | updateUnmanagedViews(); | 1661 | updateUnmanagedViews(); |
1663 | updateView(); | 1662 | updateView(); |
1664 | } | 1663 | } |
1665 | return false; | 1664 | return false; |
1666 | } | 1665 | } |
1667 | void CalendarView::showOpenError() | 1666 | void CalendarView::showOpenError() |
1668 | { | 1667 | { |
1669 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1668 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1670 | } | 1669 | } |
1671 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1670 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1672 | { | 1671 | { |
1673 | loadedFileVersion = dt; | 1672 | loadedFileVersion = dt; |
1674 | } | 1673 | } |
1675 | bool CalendarView::checkFileChanged(QString fn) | 1674 | bool CalendarView::checkFileChanged(QString fn) |
1676 | { | 1675 | { |
1677 | QFileInfo finf ( fn ); | 1676 | QFileInfo finf ( fn ); |
1678 | if ( !finf.exists() ) | 1677 | if ( !finf.exists() ) |
1679 | return true; | 1678 | return true; |
1680 | QDateTime dt = finf.lastModified (); | 1679 | QDateTime dt = finf.lastModified (); |
1681 | if ( dt <= loadedFileVersion ) | 1680 | if ( dt <= loadedFileVersion ) |
1682 | return false; | 1681 | return false; |
1683 | return true; | 1682 | return true; |
1684 | 1683 | ||
1685 | } | 1684 | } |
1686 | void CalendarView::watchSavedFile() | 1685 | void CalendarView::watchSavedFile() |
1687 | { | 1686 | { |
1688 | QFileInfo finf ( MainWindow::defaultFileName()); | 1687 | QFileInfo finf ( MainWindow::defaultFileName()); |
1689 | if ( !finf.exists() ) | 1688 | if ( !finf.exists() ) |
1690 | return; | 1689 | return; |
1691 | QDateTime dt = finf.lastModified (); | 1690 | QDateTime dt = finf.lastModified (); |
1692 | if ( dt < loadedFileVersion ) { | 1691 | if ( dt < loadedFileVersion ) { |
1693 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1692 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1694 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1693 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1695 | return; | 1694 | return; |
1696 | } | 1695 | } |
1697 | loadedFileVersion = dt; | 1696 | loadedFileVersion = dt; |
1698 | } | 1697 | } |
1699 | 1698 | ||
1700 | bool CalendarView::checkFileVersion(QString fn) | 1699 | bool CalendarView::checkFileVersion(QString fn) |
1701 | { | 1700 | { |
1702 | QFileInfo finf ( fn ); | 1701 | QFileInfo finf ( fn ); |
1703 | if ( !finf.exists() ) | 1702 | if ( !finf.exists() ) |
1704 | return true; | 1703 | return true; |
1705 | QDateTime dt = finf.lastModified (); | 1704 | QDateTime dt = finf.lastModified (); |
1706 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1705 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1707 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1706 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1708 | if ( dt <= loadedFileVersion ) | 1707 | if ( dt <= loadedFileVersion ) |
1709 | return true; | 1708 | return 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)) , | 1709 | 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)) , |
1711 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1710 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1712 | i18n("Sync+save")); | 1711 | i18n("Sync+save")); |
1713 | 1712 | ||
1714 | if ( km == KMessageBox::Cancel ) | 1713 | if ( km == KMessageBox::Cancel ) |
1715 | return false; | 1714 | return false; |
1716 | if ( km == KMessageBox::Yes ) | 1715 | if ( km == KMessageBox::Yes ) |
1717 | return true; | 1716 | return true; |
1718 | 1717 | ||
1719 | setSyncDevice("deleteaftersync" ); | 1718 | setSyncDevice("deleteaftersync" ); |
1720 | mSyncManager->mAskForPreferences = true; | 1719 | mSyncManager->mAskForPreferences = true; |
1721 | mSyncManager->mSyncAlgoPrefs = 3; | 1720 | mSyncManager->mSyncAlgoPrefs = 3; |
1722 | mSyncManager->mWriteBackFile = false; | 1721 | mSyncManager->mWriteBackFile = false; |
1723 | mSyncManager->mWriteBackExistingOnly = false; | 1722 | mSyncManager->mWriteBackExistingOnly = false; |
1724 | mSyncManager->mShowSyncSummary = false; | 1723 | mSyncManager->mShowSyncSummary = false; |
1725 | syncCalendar( fn, 3 ); | 1724 | syncCalendar( fn, 3 ); |
1726 | Event * e = getLastSyncEvent(); | 1725 | Event * e = getLastSyncEvent(); |
1727 | mCalendar->deleteEvent ( e ); | 1726 | mCalendar->deleteEvent ( e ); |
1728 | updateView(); | 1727 | updateView(); |
1729 | return true; | 1728 | return true; |
1730 | } | 1729 | } |
1731 | 1730 | ||
1732 | bool CalendarView::saveCalendar( QString filename ) | 1731 | bool CalendarView::saveCalendar( QString filename ) |
1733 | { | 1732 | { |
1734 | 1733 | ||
1735 | // Store back all unsaved data into calendar object | 1734 | // Store back all unsaved data into calendar object |
1736 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1735 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1737 | if ( mViewManager->currentView() ) | 1736 | if ( mViewManager->currentView() ) |
1738 | mViewManager->currentView()->flushView(); | 1737 | mViewManager->currentView()->flushView(); |
1739 | 1738 | ||
1740 | 1739 | ||
1741 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1740 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1742 | mStorage->setSaveFormat( new ICalFormat() ); | 1741 | mStorage->setSaveFormat( new ICalFormat() ); |
1743 | mStorage->setFileName( filename ); | 1742 | mStorage->setFileName( filename ); |
1744 | bool success; | 1743 | bool success; |
1745 | success = mStorage->save(); | 1744 | success = mStorage->save(); |
1746 | if ( !success ) { | 1745 | if ( !success ) { |
1747 | return false; | 1746 | return false; |
1748 | } | 1747 | } |
1749 | if ( filename == MainWindow::defaultFileName() ) { | 1748 | if ( filename == MainWindow::defaultFileName() ) { |
1750 | setLoadedFileVersion( lfv ); | 1749 | setLoadedFileVersion( lfv ); |
1751 | watchSavedFile(); | 1750 | watchSavedFile(); |
1752 | } | 1751 | } |
1753 | return true; | 1752 | return true; |
1754 | } | 1753 | } |
1755 | 1754 | ||
1756 | void CalendarView::closeCalendar() | 1755 | void CalendarView::closeCalendar() |
1757 | { | 1756 | { |
1758 | 1757 | ||
1759 | // child windows no longer valid | 1758 | // child windows no longer valid |
1760 | emit closingDown(); | 1759 | emit closingDown(); |
1761 | 1760 | ||
1762 | mCalendar->close(); | 1761 | mCalendar->close(); |
1763 | setModified(false); | 1762 | setModified(false); |
1764 | updateView(); | 1763 | updateView(); |
1765 | } | 1764 | } |
1766 | 1765 | ||
1767 | void CalendarView::archiveCalendar() | 1766 | void CalendarView::archiveCalendar() |
1768 | { | 1767 | { |
1769 | mDialogManager->showArchiveDialog(); | 1768 | mDialogManager->showArchiveDialog(); |
1770 | } | 1769 | } |
1771 | 1770 | ||
1772 | 1771 | ||
1773 | void CalendarView::readSettings() | 1772 | void CalendarView::readSettings() |
1774 | { | 1773 | { |
1775 | 1774 | ||
1776 | 1775 | ||
1777 | // mViewManager->showAgendaView(); | 1776 | // mViewManager->showAgendaView(); |
1778 | QString str; | 1777 | QString str; |
1779 | //qDebug("CalendarView::readSettings() "); | 1778 | //qDebug("CalendarView::readSettings() "); |
1780 | // read settings from the KConfig, supplying reasonable | 1779 | // read settings from the KConfig, supplying reasonable |
1781 | // defaults where none are to be found | 1780 | // defaults where none are to be found |
1782 | KConfig *config = KOGlobals::config(); | 1781 | KConfig *config = KOGlobals::config(); |
1783 | #ifndef KORG_NOSPLITTER | 1782 | #ifndef KORG_NOSPLITTER |
1784 | config->setGroup("KOrganizer Geometry"); | 1783 | config->setGroup("KOrganizer Geometry"); |
1785 | 1784 | ||
1786 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1785 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1787 | if (sizes.count() != 2) { | 1786 | if (sizes.count() != 2) { |
1788 | sizes << mDateNavigator->minimumSizeHint().width(); | 1787 | sizes << mDateNavigator->minimumSizeHint().width(); |
1789 | sizes << 300; | 1788 | sizes << 300; |
1790 | } | 1789 | } |
1791 | mPanner->setSizes(sizes); | 1790 | mPanner->setSizes(sizes); |
1792 | 1791 | ||
1793 | sizes = config->readIntListEntry("Separator2"); | 1792 | sizes = config->readIntListEntry("Separator2"); |
1794 | if ( ( mResourceView && sizes.count() == 4 ) || | 1793 | if ( ( mResourceView && sizes.count() == 4 ) || |
1795 | ( !mResourceView && sizes.count() == 3 ) ) { | 1794 | ( !mResourceView && sizes.count() == 3 ) ) { |
1796 | mLeftSplitter->setSizes(sizes); | 1795 | mLeftSplitter->setSizes(sizes); |
1797 | } | 1796 | } |
1798 | #endif | 1797 | #endif |
1799 | globalFlagBlockAgenda = 1; | 1798 | globalFlagBlockAgenda = 1; |
1800 | mViewManager->showAgendaView(); | 1799 | mViewManager->showAgendaView(); |
1801 | //mViewManager->readSettings( config ); | 1800 | //mViewManager->readSettings( config ); |
1802 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1801 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1803 | readFilterSettings(config); | 1802 | readFilterSettings(config); |
1804 | config->setGroup( "Views" ); | 1803 | config->setGroup( "Views" ); |
1805 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1804 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1806 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1805 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1807 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1806 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1808 | else mNavigator->selectDates( dateCount ); | 1807 | else mNavigator->selectDates( dateCount ); |
1809 | // mViewManager->readSettings( config ); | 1808 | // mViewManager->readSettings( config ); |
1810 | updateConfig(); | 1809 | updateConfig(); |
1811 | globalFlagBlockAgenda = 2; | 1810 | globalFlagBlockAgenda = 2; |
1812 | mViewManager->readSettings( config ); | 1811 | mViewManager->readSettings( config ); |
1813 | #ifdef DESKTOP_VERSION | 1812 | #ifdef DESKTOP_VERSION |
1814 | config->setGroup("WidgetLayout"); | 1813 | config->setGroup("WidgetLayout"); |
1815 | QStringList list; | 1814 | QStringList list; |
1816 | list = config->readListEntry("MainLayout"); | 1815 | list = config->readListEntry("MainLayout"); |
1817 | int x,y,w,h; | 1816 | int x,y,w,h; |
1818 | if ( ! list.isEmpty() ) { | 1817 | if ( ! list.isEmpty() ) { |
1819 | x = list[0].toInt(); | 1818 | x = list[0].toInt(); |
1820 | y = list[1].toInt(); | 1819 | y = list[1].toInt(); |
1821 | w = list[2].toInt(); | 1820 | w = list[2].toInt(); |
1822 | h = list[3].toInt(); | 1821 | h = list[3].toInt(); |
1823 | topLevelWidget()->setGeometry(x,y,w,h); | 1822 | topLevelWidget()->setGeometry(x,y,w,h); |
1824 | 1823 | ||
1825 | } else { | 1824 | } else { |
1826 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1825 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1827 | } | 1826 | } |
1828 | list = config->readListEntry("EditEventLayout"); | 1827 | list = config->readListEntry("EditEventLayout"); |
1829 | if ( ! list.isEmpty() ) { | 1828 | if ( ! list.isEmpty() ) { |
1830 | x = list[0].toInt(); | 1829 | x = list[0].toInt(); |
1831 | y = list[1].toInt(); | 1830 | y = list[1].toInt(); |
1832 | w = list[2].toInt(); | 1831 | w = list[2].toInt(); |
1833 | h = list[3].toInt(); | 1832 | h = list[3].toInt(); |
1834 | mEventEditor->setGeometry(x,y,w,h); | 1833 | mEventEditor->setGeometry(x,y,w,h); |
1835 | 1834 | ||
1836 | } | 1835 | } |
1837 | list = config->readListEntry("EditTodoLayout"); | 1836 | list = config->readListEntry("EditTodoLayout"); |
1838 | if ( ! list.isEmpty() ) { | 1837 | if ( ! list.isEmpty() ) { |
1839 | x = list[0].toInt(); | 1838 | x = list[0].toInt(); |
1840 | y = list[1].toInt(); | 1839 | y = list[1].toInt(); |
1841 | w = list[2].toInt(); | 1840 | w = list[2].toInt(); |
1842 | h = list[3].toInt(); | 1841 | h = list[3].toInt(); |
1843 | mTodoEditor->setGeometry(x,y,w,h); | 1842 | mTodoEditor->setGeometry(x,y,w,h); |
1844 | 1843 | ||
1845 | } | 1844 | } |
1846 | list = config->readListEntry("ViewerLayout"); | 1845 | list = config->readListEntry("ViewerLayout"); |
1847 | if ( ! list.isEmpty() ) { | 1846 | if ( ! list.isEmpty() ) { |
1848 | x = list[0].toInt(); | 1847 | x = list[0].toInt(); |
1849 | y = list[1].toInt(); | 1848 | y = list[1].toInt(); |
1850 | w = list[2].toInt(); | 1849 | w = list[2].toInt(); |
1851 | h = list[3].toInt(); | 1850 | h = list[3].toInt(); |
1852 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1851 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1853 | } | 1852 | } |
1854 | #endif | 1853 | #endif |
1855 | 1854 | ||
1856 | } | 1855 | } |
1857 | 1856 | ||
1858 | 1857 | ||
1859 | void CalendarView::writeSettings() | 1858 | void CalendarView::writeSettings() |
1860 | { | 1859 | { |
1861 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1860 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1862 | 1861 | ||
1863 | KConfig *config = KOGlobals::config(); | 1862 | KConfig *config = KOGlobals::config(); |
1864 | 1863 | ||
1865 | #ifndef KORG_NOSPLITTER | 1864 | #ifndef KORG_NOSPLITTER |
1866 | config->setGroup("KOrganizer Geometry"); | 1865 | config->setGroup("KOrganizer Geometry"); |
1867 | 1866 | ||
1868 | QValueList<int> list = mPanner->sizes(); | 1867 | QValueList<int> list = mPanner->sizes(); |
1869 | config->writeEntry("Separator1",list); | 1868 | config->writeEntry("Separator1",list); |
1870 | 1869 | ||
1871 | list = mLeftSplitter->sizes(); | 1870 | list = mLeftSplitter->sizes(); |
1872 | config->writeEntry("Separator2",list); | 1871 | config->writeEntry("Separator2",list); |
1873 | #endif | 1872 | #endif |
1874 | 1873 | ||
1875 | mViewManager->writeSettings( config ); | 1874 | mViewManager->writeSettings( config ); |
1876 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1875 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1877 | mDialogManager->writeSettings( config ); | 1876 | mDialogManager->writeSettings( config ); |
1878 | //KOPrefs::instance()->usrWriteConfig(); | 1877 | //KOPrefs::instance()->usrWriteConfig(); |
1879 | KOPrefs::instance()->writeConfig(); | 1878 | KOPrefs::instance()->writeConfig(); |
1880 | 1879 | ||
1881 | writeFilterSettings(config); | 1880 | writeFilterSettings(config); |
1882 | 1881 | ||
1883 | config->setGroup( "Views" ); | 1882 | config->setGroup( "Views" ); |
1884 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1883 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1885 | 1884 | ||
1886 | #ifdef DESKTOP_VERSION | 1885 | #ifdef DESKTOP_VERSION |
1887 | config->setGroup("WidgetLayout"); | 1886 | config->setGroup("WidgetLayout"); |
1888 | QStringList list ;//= config->readListEntry("MainLayout"); | 1887 | QStringList list ;//= config->readListEntry("MainLayout"); |
1889 | int x,y,w,h; | 1888 | int x,y,w,h; |
1890 | QWidget* wid; | 1889 | QWidget* wid; |
1891 | wid = topLevelWidget(); | 1890 | wid = topLevelWidget(); |
1892 | x = wid->geometry().x(); | 1891 | x = wid->geometry().x(); |
1893 | y = wid->geometry().y(); | 1892 | y = wid->geometry().y(); |
1894 | w = wid->width(); | 1893 | w = wid->width(); |
1895 | h = wid->height(); | 1894 | h = wid->height(); |
1896 | list.clear(); | 1895 | list.clear(); |
1897 | list << QString::number( x ); | 1896 | list << QString::number( x ); |
1898 | list << QString::number( y ); | 1897 | list << QString::number( y ); |
1899 | list << QString::number( w ); | 1898 | list << QString::number( w ); |
1900 | list << QString::number( h ); | 1899 | list << QString::number( h ); |
1901 | config->writeEntry("MainLayout",list ); | 1900 | config->writeEntry("MainLayout",list ); |
1902 | 1901 | ||
1903 | wid = mEventEditor; | 1902 | wid = mEventEditor; |
1904 | x = wid->geometry().x(); | 1903 | x = wid->geometry().x(); |
1905 | y = wid->geometry().y(); | 1904 | y = wid->geometry().y(); |
1906 | w = wid->width(); | 1905 | w = wid->width(); |
1907 | h = wid->height(); | 1906 | h = wid->height(); |
1908 | list.clear(); | 1907 | list.clear(); |
1909 | list << QString::number( x ); | 1908 | list << QString::number( x ); |
1910 | list << QString::number( y ); | 1909 | list << QString::number( y ); |
1911 | list << QString::number( w ); | 1910 | list << QString::number( w ); |
1912 | list << QString::number( h ); | 1911 | list << QString::number( h ); |
1913 | config->writeEntry("EditEventLayout",list ); | 1912 | config->writeEntry("EditEventLayout",list ); |
1914 | 1913 | ||
1915 | wid = mTodoEditor; | 1914 | wid = mTodoEditor; |
1916 | x = wid->geometry().x(); | 1915 | x = wid->geometry().x(); |
1917 | y = wid->geometry().y(); | 1916 | y = wid->geometry().y(); |
1918 | w = wid->width(); | 1917 | w = wid->width(); |
1919 | h = wid->height(); | 1918 | h = wid->height(); |
1920 | list.clear(); | 1919 | list.clear(); |
1921 | list << QString::number( x ); | 1920 | list << QString::number( x ); |
1922 | list << QString::number( y ); | 1921 | list << QString::number( y ); |
1923 | list << QString::number( w ); | 1922 | list << QString::number( w ); |
1924 | list << QString::number( h ); | 1923 | list << QString::number( h ); |
1925 | config->writeEntry("EditTodoLayout",list ); | 1924 | config->writeEntry("EditTodoLayout",list ); |
1926 | wid = getEventViewerDialog(); | 1925 | wid = getEventViewerDialog(); |
1927 | x = wid->geometry().x(); | 1926 | x = wid->geometry().x(); |
1928 | y = wid->geometry().y(); | 1927 | y = wid->geometry().y(); |
1929 | w = wid->width(); | 1928 | w = wid->width(); |
1930 | h = wid->height(); | 1929 | h = wid->height(); |
1931 | list.clear(); | 1930 | list.clear(); |
1932 | list << QString::number( x ); | 1931 | list << QString::number( x ); |
1933 | list << QString::number( y ); | 1932 | list << QString::number( y ); |
1934 | list << QString::number( w ); | 1933 | list << QString::number( w ); |