-rw-r--r-- | korganizer/calendarview.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 8d992b9..4b82aa8 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -269,951 +269,953 @@ void MissedAlarmTextBrowser::setSource(const QString & n) | |||
269 | 269 | ||
270 | 270 | ||
271 | class KOBeamPrefs : public QDialog | 271 | class KOBeamPrefs : public QDialog |
272 | { | 272 | { |
273 | public: | 273 | public: |
274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
275 | QDialog( parent, name, true ) | 275 | QDialog( parent, name, true ) |
276 | { | 276 | { |
277 | setCaption( i18n("Beam Options") ); | 277 | setCaption( i18n("Beam Options") ); |
278 | QVBoxLayout* lay = new QVBoxLayout( this ); | 278 | QVBoxLayout* lay = new QVBoxLayout( this ); |
279 | lay->setSpacing( 3 ); | 279 | lay->setSpacing( 3 ); |
280 | lay->setMargin( 3 ); | 280 | lay->setMargin( 3 ); |
281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
282 | lay->addWidget( format ); | 282 | lay->addWidget( format ); |
283 | format->setExclusive ( true ) ; | 283 | format->setExclusive ( true ) ; |
284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
285 | lay->addWidget( time ); time->setExclusive ( true ) ; | 285 | lay->addWidget( time ); time->setExclusive ( true ) ; |
286 | vcal = new QRadioButton(" vCalendar ", format ); | 286 | vcal = new QRadioButton(" vCalendar ", format ); |
287 | ical = new QRadioButton(" iCalendar ", format ); | 287 | ical = new QRadioButton(" iCalendar ", format ); |
288 | vcal->setChecked( true ); | 288 | vcal->setChecked( true ); |
289 | tz = new QRadioButton(i18n(" With timezone "), time ); | 289 | tz = new QRadioButton(i18n(" With timezone "), time ); |
290 | local = new QRadioButton(i18n(" Local time "), time ); | 290 | local = new QRadioButton(i18n(" Local time "), time ); |
291 | tz->setChecked( true ); | 291 | tz->setChecked( true ); |
292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
293 | lay->addWidget( ok ); | 293 | lay->addWidget( ok ); |
294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
295 | lay->addWidget( cancel ); | 295 | lay->addWidget( cancel ); |
296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
298 | resize( 200, 200 ); | 298 | resize( 200, 200 ); |
299 | } | 299 | } |
300 | 300 | ||
301 | bool beamVcal() { return vcal->isChecked(); } | 301 | bool beamVcal() { return vcal->isChecked(); } |
302 | bool beamLocal() { return local->isChecked(); } | 302 | bool beamLocal() { return local->isChecked(); } |
303 | private: | 303 | private: |
304 | QRadioButton* vcal, *ical, *local, *tz; | 304 | QRadioButton* vcal, *ical, *local, *tz; |
305 | }; | 305 | }; |
306 | class KOCatPrefs : public QDialog | 306 | class KOCatPrefs : public QDialog |
307 | { | 307 | { |
308 | public: | 308 | public: |
309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
310 | QDialog( parent, name, true ) | 310 | QDialog( parent, name, true ) |
311 | { | 311 | { |
312 | setCaption( i18n("Manage new Categories") ); | 312 | setCaption( i18n("Manage new Categories") ); |
313 | QVBoxLayout* lay = new QVBoxLayout( this ); | 313 | QVBoxLayout* lay = new QVBoxLayout( this ); |
314 | lay->setSpacing( 3 ); | 314 | lay->setSpacing( 3 ); |
315 | lay->setMargin( 3 ); | 315 | lay->setMargin( 3 ); |
316 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 316 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
317 | lay->addWidget( lab ); | 317 | lay->addWidget( lab ); |
318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
319 | lay->addWidget( format ); | 319 | lay->addWidget( format ); |
320 | format->setExclusive ( true ) ; | 320 | format->setExclusive ( true ) ; |
321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
323 | addCatBut->setChecked( true ); | 323 | addCatBut->setChecked( true ); |
324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
325 | lay->addWidget( ok ); | 325 | lay->addWidget( ok ); |
326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
327 | lay->addWidget( cancel ); | 327 | lay->addWidget( cancel ); |
328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
330 | resize( 200, 200 ); | 330 | resize( 200, 200 ); |
331 | } | 331 | } |
332 | 332 | ||
333 | bool addCat() { return addCatBut->isChecked(); } | 333 | bool addCat() { return addCatBut->isChecked(); } |
334 | private: | 334 | private: |
335 | QRadioButton* addCatBut; | 335 | QRadioButton* addCatBut; |
336 | }; | 336 | }; |
337 | 337 | ||
338 | 338 | ||
339 | 339 | ||
340 | CalendarView::CalendarView( CalendarResources *calendar, | 340 | CalendarView::CalendarView( CalendarResources *calendar, |
341 | QWidget *parent, const char *name ) | 341 | QWidget *parent, const char *name ) |
342 | : CalendarViewBase( parent, name ), | 342 | : CalendarViewBase( parent, name ), |
343 | mCalendar( calendar ), | 343 | mCalendar( calendar ), |
344 | mResourceManager( calendar->resourceManager() ) | 344 | mResourceManager( calendar->resourceManager() ) |
345 | { | 345 | { |
346 | 346 | ||
347 | mEventEditor = 0; | 347 | mEventEditor = 0; |
348 | mTodoEditor = 0; | 348 | mTodoEditor = 0; |
349 | 349 | ||
350 | init(); | 350 | init(); |
351 | } | 351 | } |
352 | 352 | ||
353 | CalendarView::CalendarView( Calendar *calendar, | 353 | CalendarView::CalendarView( Calendar *calendar, |
354 | QWidget *parent, const char *name ) | 354 | QWidget *parent, const char *name ) |
355 | : CalendarViewBase( parent, name ), | 355 | : CalendarViewBase( parent, name ), |
356 | mCalendar( calendar ), | 356 | mCalendar( calendar ), |
357 | mResourceManager( 0 ) | 357 | mResourceManager( 0 ) |
358 | { | 358 | { |
359 | 359 | ||
360 | mEventEditor = 0; | 360 | mEventEditor = 0; |
361 | mTodoEditor = 0; | 361 | mTodoEditor = 0; |
362 | init(); | 362 | init(); |
363 | } | 363 | } |
364 | 364 | ||
365 | void CalendarView::init() | 365 | void CalendarView::init() |
366 | { | 366 | { |
367 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 367 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
368 | setFocusPolicy ( NoFocus ); | 368 | setFocusPolicy ( NoFocus ); |
369 | mViewerCallerIsSearchDialog = false; | 369 | mViewerCallerIsSearchDialog = false; |
370 | mBlockShowDates = false; | 370 | mBlockShowDates = false; |
371 | beamDialog = new KOBeamPrefs(); | 371 | beamDialog = new KOBeamPrefs(); |
372 | mDatePickerMode = 0; | 372 | mDatePickerMode = 0; |
373 | mCurrentSyncDevice = ""; | 373 | mCurrentSyncDevice = ""; |
374 | writeLocale(); | 374 | writeLocale(); |
375 | mViewManager = new KOViewManager( this ); | 375 | mViewManager = new KOViewManager( this ); |
376 | mDialogManager = new KODialogManager( this ); | 376 | mDialogManager = new KODialogManager( this ); |
377 | mEventViewerDialog = 0; | 377 | mEventViewerDialog = 0; |
378 | mModified = false; | 378 | mModified = false; |
379 | mReadOnly = false; | 379 | mReadOnly = false; |
380 | mSelectedIncidence = 0; | 380 | mSelectedIncidence = 0; |
381 | mCalPrinter = 0; | 381 | mCalPrinter = 0; |
382 | mFilters.setAutoDelete(true); | 382 | mFilters.setAutoDelete(true); |
383 | 383 | ||
384 | mCalendar->registerObserver( this ); | 384 | mCalendar->registerObserver( this ); |
385 | // TODO: Make sure that view is updated, when calendar is changed. | 385 | // TODO: Make sure that view is updated, when calendar is changed. |
386 | 386 | ||
387 | mStorage = new FileStorage( mCalendar ); | 387 | mStorage = new FileStorage( mCalendar ); |
388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
389 | 389 | ||
390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
391 | #ifndef KORG_NOSPLITTER | 391 | #ifndef KORG_NOSPLITTER |
392 | // create the main layout frames. | 392 | // create the main layout frames. |
393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
394 | topLayout->addWidget(mPanner); | 394 | topLayout->addWidget(mPanner); |
395 | 395 | ||
396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
397 | "CalendarView::LeftFrame"); | 397 | "CalendarView::LeftFrame"); |
398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
399 | 399 | ||
400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
401 | "CalendarView::DateNavigator" ); | 401 | "CalendarView::DateNavigator" ); |
402 | 402 | ||
403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
405 | mTodoList->setNavigator( mNavigator ); | 405 | mTodoList->setNavigator( mNavigator ); |
406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
407 | 407 | ||
408 | #ifdef KORG_NORESOURCEVIEW | 408 | #ifdef KORG_NORESOURCEVIEW |
409 | mResourceView = 0; | 409 | mResourceView = 0; |
410 | #else | 410 | #else |
411 | if ( mResourceManager ) { | 411 | if ( mResourceManager ) { |
412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
413 | mResourceView->updateView(); | 413 | mResourceView->updateView(); |
414 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 414 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
415 | SLOT( updateView() ) ); | 415 | SLOT( updateView() ) ); |
416 | } else { | 416 | } else { |
417 | mResourceView = 0; | 417 | mResourceView = 0; |
418 | } | 418 | } |
419 | #endif | 419 | #endif |
420 | QWidget *rightBox = new QWidget( mPanner ); | 420 | QWidget *rightBox = new QWidget( mPanner ); |
421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
422 | 422 | ||
423 | mRightFrame = new QWidgetStack( rightBox ); | 423 | mRightFrame = new QWidgetStack( rightBox ); |
424 | rightLayout->addWidget( mRightFrame, 1 ); | 424 | rightLayout->addWidget( mRightFrame, 1 ); |
425 | 425 | ||
426 | mLeftFrame = mLeftSplitter; | 426 | mLeftFrame = mLeftSplitter; |
427 | #else | 427 | #else |
428 | //QWidget *mainBox = new QWidget( this ); | 428 | //QWidget *mainBox = new QWidget( this ); |
429 | //QWidget *leftFrame = new QWidget( mainBox ); | 429 | //QWidget *leftFrame = new QWidget( mainBox ); |
430 | //QBoxLayout * mainBoxLayout; | 430 | //QBoxLayout * mainBoxLayout; |
431 | if ( KOPrefs::instance()->mVerticalScreen ) { | 431 | if ( KOPrefs::instance()->mVerticalScreen ) { |
432 | //mainBoxLayout = new QVBoxLayout(mainBox); | 432 | //mainBoxLayout = new QVBoxLayout(mainBox); |
433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
438 | } else { | 438 | } else { |
439 | //mainBoxLayout = new QHBoxLayout(mainBox); | 439 | //mainBoxLayout = new QHBoxLayout(mainBox); |
440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
445 | } | 445 | } |
446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
447 | //QBoxLayout * leftFrameLayout; | 447 | //QBoxLayout * leftFrameLayout; |
448 | topLayout->addWidget( mMainFrame ); | 448 | topLayout->addWidget( mMainFrame ); |
449 | //mainBoxLayout->addWidget (mLeftFrame); | 449 | //mainBoxLayout->addWidget (mLeftFrame); |
450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
451 | "CalendarView::DateNavigator" ); | 451 | "CalendarView::DateNavigator" ); |
452 | #if 0 | 452 | #if 0 |
453 | // FIXME | 453 | // FIXME |
454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
455 | "CalendarView::DateNavigator", QDate::currentDate()); | 455 | "CalendarView::DateNavigator", QDate::currentDate()); |
456 | #endif | 456 | #endif |
457 | // mDateNavigator->blockSignals( true ); | 457 | // mDateNavigator->blockSignals( true ); |
458 | //leftFrameLayout->addWidget( mDateNavigator ); | 458 | //leftFrameLayout->addWidget( mDateNavigator ); |
459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
461 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 461 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
462 | mTodoList->setNavigator( mNavigator ); | 462 | mTodoList->setNavigator( mNavigator ); |
463 | #if 0 | 463 | #if 0 |
464 | if ( QApplication::desktop()->width() < 480 ) { | 464 | if ( QApplication::desktop()->width() < 480 ) { |
465 | leftFrameLayout->addWidget(mFilterView); | 465 | leftFrameLayout->addWidget(mFilterView); |
466 | leftFrameLayout->addWidget(mTodoList, 2 ); | 466 | leftFrameLayout->addWidget(mTodoList, 2 ); |
467 | 467 | ||
468 | } else { | 468 | } else { |
469 | leftFrameLayout->addWidget(mTodoList,2 ); | 469 | leftFrameLayout->addWidget(mTodoList,2 ); |
470 | leftFrameLayout->addWidget(mFilterView ); | 470 | leftFrameLayout->addWidget(mFilterView ); |
471 | } | 471 | } |
472 | #endif | 472 | #endif |
473 | mFilterView->hide(); | 473 | mFilterView->hide(); |
474 | mCalEditView->hide(); | 474 | mCalEditView->hide(); |
475 | QWidget *rightBox = new QWidget( mMainFrame ); | 475 | QWidget *rightBox = new QWidget( mMainFrame ); |
476 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 476 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
477 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 477 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
478 | mRightFrame = new QWidgetStack( rightBox ); | 478 | mRightFrame = new QWidgetStack( rightBox ); |
479 | rightLayout->addWidget( mRightFrame, 10 ); | 479 | rightLayout->addWidget( mRightFrame, 10 ); |
480 | 480 | ||
481 | //mLeftFrame = (QWidget *)leftFrame; | 481 | //mLeftFrame = (QWidget *)leftFrame; |
482 | if ( KOPrefs::instance()->mVerticalScreen ) { | 482 | if ( KOPrefs::instance()->mVerticalScreen ) { |
483 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 483 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
484 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 484 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
485 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 485 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
486 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 486 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
487 | } else { | 487 | } else { |
488 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 488 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
489 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 489 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
490 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 490 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
491 | } | 491 | } |
492 | if ( !KOPrefs::instance()->mShowDateNavigator) | 492 | if ( !KOPrefs::instance()->mShowDateNavigator) |
493 | mDateNavigator->hide(); | 493 | mDateNavigator->hide(); |
494 | //qDebug("Calendarview Size %d %d ", width(), height()); | 494 | //qDebug("Calendarview Size %d %d ", width(), height()); |
495 | #endif | 495 | #endif |
496 | 496 | ||
497 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 497 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
498 | SLOT( showDates( const KCal::DateList & ) ) ); | 498 | SLOT( showDates( const KCal::DateList & ) ) ); |
499 | 499 | ||
500 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 500 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
501 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 501 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
502 | 502 | ||
503 | 503 | ||
504 | 504 | ||
505 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 505 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
506 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 506 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
507 | 507 | ||
508 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 508 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
509 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 509 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
510 | 510 | ||
511 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 511 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
512 | mNavigator, SLOT( selectPreviousYear() ) ); | 512 | mNavigator, SLOT( selectPreviousYear() ) ); |
513 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 513 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
514 | mNavigator, SLOT( selectNextYear() ) ); | 514 | mNavigator, SLOT( selectNextYear() ) ); |
515 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 515 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
516 | mNavigator, SLOT( selectPreviousMonth() ) ); | 516 | mNavigator, SLOT( selectPreviousMonth() ) ); |
517 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 517 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
518 | mNavigator, SLOT( selectNextMonth() ) ); | 518 | mNavigator, SLOT( selectNextMonth() ) ); |
519 | 519 | ||
520 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 520 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
521 | mNavigator, SLOT( selectPrevious() ) ); | 521 | mNavigator, SLOT( selectPrevious() ) ); |
522 | connect( mDateNavigator, SIGNAL( goNext() ), | 522 | connect( mDateNavigator, SIGNAL( goNext() ), |
523 | mNavigator, SLOT( selectNext() ) ); | 523 | mNavigator, SLOT( selectNext() ) ); |
524 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 524 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
525 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 525 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
526 | 526 | ||
527 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 527 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
528 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 528 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
529 | #if 0 | 529 | #if 0 |
530 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 530 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
531 | SLOT( incidenceAdded( Incidence *) ) ); | 531 | SLOT( incidenceAdded( Incidence *) ) ); |
532 | #endif | 532 | #endif |
533 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 533 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
534 | 534 | ||
535 | connect( this, SIGNAL( configChanged() ), | 535 | connect( this, SIGNAL( configChanged() ), |
536 | mDateNavigator, SLOT( updateConfig() ) ); | 536 | mDateNavigator, SLOT( updateConfig() ) ); |
537 | 537 | ||
538 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 538 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
539 | SLOT( newTodo() ) ); | 539 | SLOT( newTodo() ) ); |
540 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 540 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
541 | SLOT( newSubTodo( Todo * ) ) ); | 541 | SLOT( newSubTodo( Todo * ) ) ); |
542 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 542 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
543 | SLOT( editTodo( Todo * ) ) ); | 543 | SLOT( editTodo( Todo * ) ) ); |
544 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 544 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
545 | SLOT( showTodo( Todo *) ) ); | 545 | SLOT( showTodo( Todo *) ) ); |
546 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 546 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
547 | SLOT( deleteTodo( Todo *) ) ); | 547 | SLOT( deleteTodo( Todo *) ) ); |
548 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 548 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
549 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 549 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
550 | SLOT( purgeCompleted() ) ); | 550 | SLOT( purgeCompleted() ) ); |
551 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 551 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
552 | SIGNAL( todoModified( Todo *, int ) ) ); | 552 | SIGNAL( todoModified( Todo *, int ) ) ); |
553 | 553 | ||
554 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 554 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
555 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 555 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
556 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 556 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
557 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 557 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
558 | 558 | ||
559 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 559 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
560 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 560 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
561 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 561 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
562 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 562 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
563 | 563 | ||
564 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 564 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
565 | this, SLOT ( todo_unsub( Todo * ) ) ); | 565 | this, SLOT ( todo_unsub( Todo * ) ) ); |
566 | 566 | ||
567 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 567 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
568 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 568 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
569 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 569 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
570 | SLOT( updateTodo( Todo *, int ) ) ); | 570 | SLOT( updateTodo( Todo *, int ) ) ); |
571 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 571 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
572 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 572 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
573 | 573 | ||
574 | 574 | ||
575 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 575 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
576 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 576 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
577 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 577 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
578 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 578 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
579 | 579 | ||
580 | 580 | ||
581 | 581 | ||
582 | 582 | ||
583 | 583 | ||
584 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 584 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
585 | SLOT(checkClipboard())); | 585 | SLOT(checkClipboard())); |
586 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 586 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
587 | SLOT( processTodoListSelection( Incidence * ) ) ); | 587 | SLOT( processTodoListSelection( Incidence * ) ) ); |
588 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 588 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
589 | 589 | ||
590 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 590 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
591 | 591 | ||
592 | mDateFrame = new QVBox(0,0,WType_Popup); | 592 | mDateFrame = new QVBox(0,0,WType_Popup); |
593 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 593 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
594 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 594 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
595 | mDateFrame->setLineWidth(3); | 595 | mDateFrame->setLineWidth(3); |
596 | mDateFrame->hide(); | 596 | mDateFrame->hide(); |
597 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 597 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
598 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 598 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
599 | 599 | ||
600 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 600 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
601 | 601 | ||
602 | mEventEditor = mDialogManager->getEventEditor(); | 602 | mEventEditor = mDialogManager->getEventEditor(); |
603 | mTodoEditor = mDialogManager->getTodoEditor(); | 603 | mTodoEditor = mDialogManager->getTodoEditor(); |
604 | 604 | ||
605 | mFlagEditDescription = false; | 605 | mFlagEditDescription = false; |
606 | 606 | ||
607 | mSuspendTimer = new QTimer( this ); | 607 | mSuspendTimer = new QTimer( this ); |
608 | mAlarmTimer = new QTimer( this ); | 608 | mAlarmTimer = new QTimer( this ); |
609 | mRecheckAlarmTimer = new QTimer( this ); | 609 | mRecheckAlarmTimer = new QTimer( this ); |
610 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 610 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
611 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 611 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
612 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 612 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
613 | mAlarmDialog = new AlarmDialog( this ); | 613 | mAlarmDialog = new AlarmDialog( this ); |
614 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 614 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
615 | mAlarmDialog->setServerNotification( false ); | 615 | mAlarmDialog->setServerNotification( false ); |
616 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 616 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
617 | 617 | ||
618 | 618 | ||
619 | #ifndef DESKTOP_VERSION | 619 | #ifndef DESKTOP_VERSION |
620 | //US listen for arriving address resultsets | 620 | //US listen for arriving address resultsets |
621 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 621 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
622 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 622 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
623 | #endif | 623 | #endif |
624 | mDateNavigator->setCalendar( mCalendar ); | 624 | mDateNavigator->setCalendar( mCalendar ); |
625 | } | 625 | } |
626 | 626 | ||
627 | 627 | ||
628 | CalendarView::~CalendarView() | 628 | CalendarView::~CalendarView() |
629 | { | 629 | { |
630 | // kdDebug() << "~CalendarView()" << endl; | 630 | // kdDebug() << "~CalendarView()" << endl; |
631 | //qDebug("CalendarView::~CalendarView() "); | 631 | //qDebug("CalendarView::~CalendarView() "); |
632 | delete mDialogManager; | 632 | delete mDialogManager; |
633 | delete mViewManager; | 633 | delete mViewManager; |
634 | delete mStorage; | 634 | delete mStorage; |
635 | delete mDateFrame ; | 635 | delete mDateFrame ; |
636 | delete beamDialog; | 636 | delete beamDialog; |
637 | delete mEventViewerDialog; | 637 | delete mEventViewerDialog; |
638 | //kdDebug() << "~CalendarView() done" << endl; | 638 | //kdDebug() << "~CalendarView() done" << endl; |
639 | } | 639 | } |
640 | void CalendarView::checkAlarms() | 640 | void CalendarView::checkAlarms() |
641 | { | 641 | { |
642 | KConfig *config = KOGlobals::config(); | 642 | KConfig *config = KOGlobals::config(); |
643 | config->setGroup( "AppRun" ); | 643 | config->setGroup( "AppRun" ); |
644 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 644 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
645 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 645 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
646 | int secs = config->readNumEntry( "LatestProgramStop" , secto) - 30; | 646 | int secs = config->readNumEntry( "LatestProgramStop" , secto) - 30; |
647 | //secs -= ( 3600 * 24*3 ); // debug only | 647 | //secs -= ( 3600 * 24*3 ); // debug only |
648 | QDateTime latest = dt.addSecs ( secs ); | 648 | QDateTime latest = dt.addSecs ( secs ); |
649 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 649 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
650 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 650 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
651 | QPtrList<Incidence> al; | 651 | QPtrList<Incidence> al; |
652 | Incidence* inL = el.first(); | 652 | Incidence* inL = el.first(); |
653 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | ||
654 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | ||
653 | while ( inL ) { | 655 | while ( inL ) { |
654 | bool ok = false; | 656 | bool ok = false; |
655 | int offset = 0; | 657 | int offset = 0; |
656 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 658 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
657 | if ( ok ) { | 659 | if ( ok ) { |
658 | //qDebug("OK %s",next.toString().latin1()); | 660 | //qDebug("OK %s",next.toString().latin1()); |
659 | if ( next < QDateTime::currentDateTime() ) { | 661 | if ( next < cur ) { |
660 | al.append( inL ); | 662 | al.append( inL ); |
661 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 663 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
662 | } | 664 | } |
663 | } | 665 | } |
664 | inL = el.next(); | 666 | inL = el.next(); |
665 | } | 667 | } |
666 | if ( al.count() ) { | 668 | if ( al.count() ) { |
667 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 669 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
668 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 670 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
669 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 671 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
670 | lay->setSpacing( 0 ); | 672 | lay->setSpacing( 0 ); |
671 | lay->setMargin( 0 ); | 673 | lay->setMargin( 0 ); |
672 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 674 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
673 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 675 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
674 | lay->addWidget( matb ); | 676 | lay->addWidget( matb ); |
675 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 677 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
676 | int wid = 210; | 678 | int wid = 210; |
677 | int x = QApplication::desktop()->width() - wid - 7; | 679 | int x = QApplication::desktop()->width() - wid - 7; |
678 | int y = QApplication::desktop()->height() - wid - 70; | 680 | int y = QApplication::desktop()->height() - wid - 70; |
679 | dia->setGeometry ( x,y,wid,wid); | 681 | dia->setGeometry ( x,y,wid,wid); |
680 | } else { | 682 | } else { |
681 | int si = 220; | 683 | int si = 220; |
682 | if ( QApplication::desktop()->width() > 470 ) | 684 | if ( QApplication::desktop()->width() > 470 ) |
683 | si = 400; | 685 | si = 400; |
684 | dia->resize(si,si/2); | 686 | dia->resize(si,si/2); |
685 | } | 687 | } |
686 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 688 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
687 | dia->show(); | 689 | dia->show(); |
688 | 690 | ||
689 | } | 691 | } |
690 | } | 692 | } |
691 | void CalendarView::showDay( QDate d ) | 693 | void CalendarView::showDay( QDate d ) |
692 | { | 694 | { |
693 | dateNavigator()->blockSignals( true ); | 695 | dateNavigator()->blockSignals( true ); |
694 | dateNavigator()->selectDate( d ); | 696 | dateNavigator()->selectDate( d ); |
695 | dateNavigator()->blockSignals( false ); | 697 | dateNavigator()->blockSignals( false ); |
696 | mViewManager->showDayView(); | 698 | mViewManager->showDayView(); |
697 | //dateNavigator()->selectDate( d ); | 699 | //dateNavigator()->selectDate( d ); |
698 | } | 700 | } |
699 | void CalendarView::timerAlarm() | 701 | void CalendarView::timerAlarm() |
700 | { | 702 | { |
701 | //qDebug("CalendarView::timerAlarm() "); | 703 | //qDebug("CalendarView::timerAlarm() "); |
702 | computeAlarm(mAlarmNotification ); | 704 | computeAlarm(mAlarmNotification ); |
703 | } | 705 | } |
704 | 706 | ||
705 | void CalendarView::suspendAlarm() | 707 | void CalendarView::suspendAlarm() |
706 | { | 708 | { |
707 | //qDebug(" CalendarView::suspendAlarm() "); | 709 | //qDebug(" CalendarView::suspendAlarm() "); |
708 | computeAlarm(mSuspendAlarmNotification ); | 710 | computeAlarm(mSuspendAlarmNotification ); |
709 | 711 | ||
710 | } | 712 | } |
711 | 713 | ||
712 | void CalendarView::startAlarm( QString mess , QString filename) | 714 | void CalendarView::startAlarm( QString mess , QString filename) |
713 | { | 715 | { |
714 | 716 | ||
715 | topLevelWidget()->showNormal(); | 717 | topLevelWidget()->showNormal(); |
716 | topLevelWidget()->setActiveWindow(); | 718 | topLevelWidget()->setActiveWindow(); |
717 | topLevelWidget()->raise(); | 719 | topLevelWidget()->raise(); |
718 | 720 | ||
719 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 721 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
720 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 722 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
721 | 723 | ||
722 | } | 724 | } |
723 | 725 | ||
724 | void CalendarView::checkNextTimerAlarm() | 726 | void CalendarView::checkNextTimerAlarm() |
725 | { | 727 | { |
726 | mCalendar->checkAlarmForIncidence( 0, true ); | 728 | mCalendar->checkAlarmForIncidence( 0, true ); |
727 | } | 729 | } |
728 | 730 | ||
729 | void CalendarView::computeAlarm( QString msg ) | 731 | void CalendarView::computeAlarm( QString msg ) |
730 | { | 732 | { |
731 | 733 | ||
732 | QString mess = msg; | 734 | QString mess = msg; |
733 | QString mAlarmMessage = mess.mid( 9 ); | 735 | QString mAlarmMessage = mess.mid( 9 ); |
734 | QString filename = MainWindow::resourcePath(); | 736 | QString filename = MainWindow::resourcePath(); |
735 | filename += "koalarm.wav"; | 737 | filename += "koalarm.wav"; |
736 | QString tempfilename; | 738 | QString tempfilename; |
737 | if ( mess.left( 13 ) == "suspend_alarm") { | 739 | if ( mess.left( 13 ) == "suspend_alarm") { |
738 | bool error = false; | 740 | bool error = false; |
739 | int len = mess.mid( 13 ).find("+++"); | 741 | int len = mess.mid( 13 ).find("+++"); |
740 | if ( len < 2 ) | 742 | if ( len < 2 ) |
741 | error = true; | 743 | error = true; |
742 | else { | 744 | else { |
743 | tempfilename = mess.mid( 13, len ); | 745 | tempfilename = mess.mid( 13, len ); |
744 | if ( !QFile::exists( tempfilename ) ) | 746 | if ( !QFile::exists( tempfilename ) ) |
745 | error = true; | 747 | error = true; |
746 | } | 748 | } |
747 | if ( ! error ) { | 749 | if ( ! error ) { |
748 | filename = tempfilename; | 750 | filename = tempfilename; |
749 | } | 751 | } |
750 | mAlarmMessage = mess.mid( 13+len+3 ); | 752 | mAlarmMessage = mess.mid( 13+len+3 ); |
751 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 753 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
752 | startAlarm( mAlarmMessage, filename); | 754 | startAlarm( mAlarmMessage, filename); |
753 | return; | 755 | return; |
754 | } | 756 | } |
755 | if ( mess.left( 11 ) == "timer_alarm") { | 757 | if ( mess.left( 11 ) == "timer_alarm") { |
756 | //mTimerTime = 0; | 758 | //mTimerTime = 0; |
757 | startAlarm( mess.mid( 11 ), filename ); | 759 | startAlarm( mess.mid( 11 ), filename ); |
758 | return; | 760 | return; |
759 | } | 761 | } |
760 | if ( mess.left( 10 ) == "proc_alarm") { | 762 | if ( mess.left( 10 ) == "proc_alarm") { |
761 | bool error = false; | 763 | bool error = false; |
762 | int len = mess.mid( 10 ).find("+++"); | 764 | int len = mess.mid( 10 ).find("+++"); |
763 | if ( len < 2 ) | 765 | if ( len < 2 ) |
764 | error = true; | 766 | error = true; |
765 | else { | 767 | else { |
766 | tempfilename = mess.mid( 10, len ); | 768 | tempfilename = mess.mid( 10, len ); |
767 | if ( !QFile::exists( tempfilename ) ) | 769 | if ( !QFile::exists( tempfilename ) ) |
768 | error = true; | 770 | error = true; |
769 | } | 771 | } |
770 | if ( error ) { | 772 | if ( error ) { |
771 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 773 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
772 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 774 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
773 | } else { | 775 | } else { |
774 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 776 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
775 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 777 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
776 | #ifndef _WIN32_ | 778 | #ifndef _WIN32_ |
777 | if ( vfork () == 0 ) { | 779 | if ( vfork () == 0 ) { |
778 | execl ( tempfilename.latin1(), 0 ); | 780 | execl ( tempfilename.latin1(), 0 ); |
779 | return; | 781 | return; |
780 | } | 782 | } |
781 | #else | 783 | #else |
782 | QProcess* p = new QProcess(); | 784 | QProcess* p = new QProcess(); |
783 | p->addArgument( tempfilename.latin1() ); | 785 | p->addArgument( tempfilename.latin1() ); |
784 | p->start(); | 786 | p->start(); |
785 | return; | 787 | return; |
786 | #endif | 788 | #endif |
787 | 789 | ||
788 | return; | 790 | return; |
789 | } | 791 | } |
790 | 792 | ||
791 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 793 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
792 | } | 794 | } |
793 | if ( mess.left( 11 ) == "audio_alarm") { | 795 | if ( mess.left( 11 ) == "audio_alarm") { |
794 | bool error = false; | 796 | bool error = false; |
795 | int len = mess.mid( 11 ).find("+++"); | 797 | int len = mess.mid( 11 ).find("+++"); |
796 | if ( len < 2 ) | 798 | if ( len < 2 ) |
797 | error = true; | 799 | error = true; |
798 | else { | 800 | else { |
799 | tempfilename = mess.mid( 11, len ); | 801 | tempfilename = mess.mid( 11, len ); |
800 | if ( !QFile::exists( tempfilename ) ) | 802 | if ( !QFile::exists( tempfilename ) ) |
801 | error = true; | 803 | error = true; |
802 | } | 804 | } |
803 | if ( ! error ) { | 805 | if ( ! error ) { |
804 | filename = tempfilename; | 806 | filename = tempfilename; |
805 | } | 807 | } |
806 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 808 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
807 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 809 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
808 | } | 810 | } |
809 | if ( mess.left( 9 ) == "cal_alarm") { | 811 | if ( mess.left( 9 ) == "cal_alarm") { |
810 | mAlarmMessage = mess.mid( 9 ) ; | 812 | mAlarmMessage = mess.mid( 9 ) ; |
811 | } | 813 | } |
812 | 814 | ||
813 | startAlarm( mAlarmMessage, filename ); | 815 | startAlarm( mAlarmMessage, filename ); |
814 | 816 | ||
815 | 817 | ||
816 | } | 818 | } |
817 | 819 | ||
818 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 820 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
819 | { | 821 | { |
820 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 822 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
821 | 823 | ||
822 | mSuspendAlarmNotification = noti; | 824 | mSuspendAlarmNotification = noti; |
823 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 825 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
824 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 826 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
825 | mSuspendTimer->start( ms , true ); | 827 | mSuspendTimer->start( ms , true ); |
826 | 828 | ||
827 | } | 829 | } |
828 | 830 | ||
829 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 831 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
830 | { | 832 | { |
831 | mNextAlarmDateTime = qdt; | 833 | mNextAlarmDateTime = qdt; |
832 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 834 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
833 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 835 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
834 | #ifndef DESKTOP_VERSION | 836 | #ifndef DESKTOP_VERSION |
835 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 837 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
836 | #endif | 838 | #endif |
837 | return; | 839 | return; |
838 | } | 840 | } |
839 | int maxSec; | 841 | int maxSec; |
840 | //maxSec = 5; //testing only | 842 | //maxSec = 5; //testing only |
841 | maxSec = 86400+3600; // one day+1hour | 843 | maxSec = 86400+3600; // one day+1hour |
842 | mAlarmNotification = noti; | 844 | mAlarmNotification = noti; |
843 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 845 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
844 | if ( sec > maxSec ) { | 846 | if ( sec > maxSec ) { |
845 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 847 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
846 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 848 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
847 | return; | 849 | return; |
848 | } else { | 850 | } else { |
849 | mRecheckAlarmTimer->stop(); | 851 | mRecheckAlarmTimer->stop(); |
850 | } | 852 | } |
851 | //qDebug("Alarm timer started with secs: %d ", sec); | 853 | //qDebug("Alarm timer started with secs: %d ", sec); |
852 | mAlarmTimer->start( sec *1000 , true ); | 854 | mAlarmTimer->start( sec *1000 , true ); |
853 | 855 | ||
854 | } | 856 | } |
855 | // called by mRecheckAlarmTimer to get next alarm | 857 | // called by mRecheckAlarmTimer to get next alarm |
856 | // we need this, because a QTimer has only a max range of 25 days | 858 | // we need this, because a QTimer has only a max range of 25 days |
857 | void CalendarView::recheckTimerAlarm() | 859 | void CalendarView::recheckTimerAlarm() |
858 | { | 860 | { |
859 | mAlarmTimer->stop(); | 861 | mAlarmTimer->stop(); |
860 | mRecheckAlarmTimer->stop(); | 862 | mRecheckAlarmTimer->stop(); |
861 | mCalendar->checkAlarmForIncidence( 0, true ); | 863 | mCalendar->checkAlarmForIncidence( 0, true ); |
862 | } | 864 | } |
863 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 865 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
864 | { | 866 | { |
865 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 867 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
866 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 868 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
867 | #ifndef DESKTOP_VERSION | 869 | #ifndef DESKTOP_VERSION |
868 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 870 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
869 | #endif | 871 | #endif |
870 | return; | 872 | return; |
871 | } | 873 | } |
872 | mAlarmTimer->stop(); | 874 | mAlarmTimer->stop(); |
873 | } | 875 | } |
874 | void CalendarView::selectWeekNum ( int num ) | 876 | void CalendarView::selectWeekNum ( int num ) |
875 | { | 877 | { |
876 | dateNavigator()->blockSignals( true ); | 878 | dateNavigator()->blockSignals( true ); |
877 | dateNavigator()->selectWeek( num ); | 879 | dateNavigator()->selectWeek( num ); |
878 | dateNavigator()->blockSignals( false ); | 880 | dateNavigator()->blockSignals( false ); |
879 | mViewManager->showWeekView(); | 881 | mViewManager->showWeekView(); |
880 | } | 882 | } |
881 | KOViewManager *CalendarView::viewManager() | 883 | KOViewManager *CalendarView::viewManager() |
882 | { | 884 | { |
883 | return mViewManager; | 885 | return mViewManager; |
884 | } | 886 | } |
885 | 887 | ||
886 | KODialogManager *CalendarView::dialogManager() | 888 | KODialogManager *CalendarView::dialogManager() |
887 | { | 889 | { |
888 | return mDialogManager; | 890 | return mDialogManager; |
889 | } | 891 | } |
890 | 892 | ||
891 | QDate CalendarView::startDate() | 893 | QDate CalendarView::startDate() |
892 | { | 894 | { |
893 | DateList dates = mNavigator->selectedDates(); | 895 | DateList dates = mNavigator->selectedDates(); |
894 | 896 | ||
895 | return dates.first(); | 897 | return dates.first(); |
896 | } | 898 | } |
897 | 899 | ||
898 | QDate CalendarView::endDate() | 900 | QDate CalendarView::endDate() |
899 | { | 901 | { |
900 | DateList dates = mNavigator->selectedDates(); | 902 | DateList dates = mNavigator->selectedDates(); |
901 | 903 | ||
902 | return dates.last(); | 904 | return dates.last(); |
903 | } | 905 | } |
904 | 906 | ||
905 | 907 | ||
906 | void CalendarView::createPrinter() | 908 | void CalendarView::createPrinter() |
907 | { | 909 | { |
908 | #ifndef KORG_NOPRINTER | 910 | #ifndef KORG_NOPRINTER |
909 | if (!mCalPrinter) { | 911 | if (!mCalPrinter) { |
910 | mCalPrinter = new CalPrinter(this, mCalendar); | 912 | mCalPrinter = new CalPrinter(this, mCalendar); |
911 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 913 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
912 | } | 914 | } |
913 | #endif | 915 | #endif |
914 | } | 916 | } |
915 | 917 | ||
916 | 918 | ||
917 | //KOPrefs::instance()->mWriteBackFile | 919 | //KOPrefs::instance()->mWriteBackFile |
918 | //KOPrefs::instance()->mWriteBackExistingOnly | 920 | //KOPrefs::instance()->mWriteBackExistingOnly |
919 | 921 | ||
920 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 922 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
921 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 923 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
922 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 924 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
923 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 925 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
924 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 926 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
925 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 927 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
926 | 928 | ||
927 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 929 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
928 | { | 930 | { |
929 | 931 | ||
930 | // 0 equal | 932 | // 0 equal |
931 | // 1 take local | 933 | // 1 take local |
932 | // 2 take remote | 934 | // 2 take remote |
933 | // 3 cancel | 935 | // 3 cancel |
934 | QDateTime lastSync = mLastCalendarSync; | 936 | QDateTime lastSync = mLastCalendarSync; |
935 | QDateTime localMod = local->lastModified(); | 937 | QDateTime localMod = local->lastModified(); |
936 | QDateTime remoteMod = remote->lastModified(); | 938 | QDateTime remoteMod = remote->lastModified(); |
937 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 939 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
938 | bool remCh, locCh; | 940 | bool remCh, locCh; |
939 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 941 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
940 | //if ( remCh ) | 942 | //if ( remCh ) |
941 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 943 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
942 | locCh = ( localMod > mLastCalendarSync ); | 944 | locCh = ( localMod > mLastCalendarSync ); |
943 | if ( !remCh && ! locCh ) { | 945 | if ( !remCh && ! locCh ) { |
944 | //qDebug("both not changed "); | 946 | //qDebug("both not changed "); |
945 | lastSync = localMod.addDays(1); | 947 | lastSync = localMod.addDays(1); |
946 | if ( mode <= SYNC_PREF_ASK ) | 948 | if ( mode <= SYNC_PREF_ASK ) |
947 | return 0; | 949 | return 0; |
948 | } else { | 950 | } else { |
949 | if ( locCh ) { | 951 | if ( locCh ) { |
950 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 952 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
951 | lastSync = localMod.addDays( -1 ); | 953 | lastSync = localMod.addDays( -1 ); |
952 | if ( !remCh ) | 954 | if ( !remCh ) |
953 | remoteMod = ( lastSync.addDays( -1 ) ); | 955 | remoteMod = ( lastSync.addDays( -1 ) ); |
954 | } else { | 956 | } else { |
955 | //qDebug(" not loc changed "); | 957 | //qDebug(" not loc changed "); |
956 | lastSync = localMod.addDays( 1 ); | 958 | lastSync = localMod.addDays( 1 ); |
957 | if ( remCh ) | 959 | if ( remCh ) |
958 | remoteMod =( lastSync.addDays( 1 ) ); | 960 | remoteMod =( lastSync.addDays( 1 ) ); |
959 | 961 | ||
960 | } | 962 | } |
961 | } | 963 | } |
962 | full = true; | 964 | full = true; |
963 | if ( mode < SYNC_PREF_ASK ) | 965 | if ( mode < SYNC_PREF_ASK ) |
964 | mode = SYNC_PREF_ASK; | 966 | mode = SYNC_PREF_ASK; |
965 | } else { | 967 | } else { |
966 | if ( localMod == remoteMod ) | 968 | if ( localMod == remoteMod ) |
967 | // if ( local->revision() == remote->revision() ) | 969 | // if ( local->revision() == remote->revision() ) |
968 | return 0; | 970 | return 0; |
969 | 971 | ||
970 | } | 972 | } |
971 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 973 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
972 | 974 | ||
973 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 975 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
974 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 976 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
975 | //full = true; //debug only | 977 | //full = true; //debug only |
976 | if ( full ) { | 978 | if ( full ) { |
977 | bool equ = false; | 979 | bool equ = false; |
978 | if ( local->typeID() == eventID ) { | 980 | if ( local->typeID() == eventID ) { |
979 | equ = (*((Event*) local) == *((Event*) remote)); | 981 | equ = (*((Event*) local) == *((Event*) remote)); |
980 | } | 982 | } |
981 | else if ( local->typeID() == todoID ) | 983 | else if ( local->typeID() == todoID ) |
982 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 984 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
983 | else if ( local->typeID() == journalID ) | 985 | else if ( local->typeID() == journalID ) |
984 | equ = (*((Journal*) local) == *((Journal*) remote)); | 986 | equ = (*((Journal*) local) == *((Journal*) remote)); |
985 | if ( equ ) { | 987 | if ( equ ) { |
986 | //qDebug("equal "); | 988 | //qDebug("equal "); |
987 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 989 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
988 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 990 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
989 | } | 991 | } |
990 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 992 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
991 | return 0; | 993 | return 0; |
992 | 994 | ||
993 | }//else //debug only | 995 | }//else //debug only |
994 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 996 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
995 | } | 997 | } |
996 | int result; | 998 | int result; |
997 | bool localIsNew; | 999 | bool localIsNew; |
998 | //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() ); | 1000 | //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() ); |
999 | 1001 | ||
1000 | 1002 | ||
1001 | // ************************************************ | 1003 | // ************************************************ |
1002 | // ************************************************ | 1004 | // ************************************************ |
1003 | // ************************************************ | 1005 | // ************************************************ |
1004 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1006 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1005 | // BUT remoteMod != localMod | 1007 | // BUT remoteMod != localMod |
1006 | 1008 | ||
1007 | 1009 | ||
1008 | if ( full && mode < SYNC_PREF_NEWEST ) | 1010 | if ( full && mode < SYNC_PREF_NEWEST ) |
1009 | mode = SYNC_PREF_ASK; | 1011 | mode = SYNC_PREF_ASK; |
1010 | 1012 | ||
1011 | switch( mode ) { | 1013 | switch( mode ) { |
1012 | case SYNC_PREF_LOCAL: | 1014 | case SYNC_PREF_LOCAL: |
1013 | if ( lastSync > remoteMod ) | 1015 | if ( lastSync > remoteMod ) |
1014 | return 1; | 1016 | return 1; |
1015 | if ( lastSync > localMod ) | 1017 | if ( lastSync > localMod ) |
1016 | return 2; | 1018 | return 2; |
1017 | return 1; | 1019 | return 1; |
1018 | break; | 1020 | break; |
1019 | case SYNC_PREF_REMOTE: | 1021 | case SYNC_PREF_REMOTE: |
1020 | if ( lastSync > localMod ) | 1022 | if ( lastSync > localMod ) |
1021 | return 2; | 1023 | return 2; |
1022 | if ( lastSync > remoteMod ) | 1024 | if ( lastSync > remoteMod ) |
1023 | return 1; | 1025 | return 1; |
1024 | return 2; | 1026 | return 2; |
1025 | break; | 1027 | break; |
1026 | case SYNC_PREF_NEWEST: | 1028 | case SYNC_PREF_NEWEST: |
1027 | if ( localMod >= remoteMod ) | 1029 | if ( localMod >= remoteMod ) |
1028 | return 1; | 1030 | return 1; |
1029 | else | 1031 | else |
1030 | return 2; | 1032 | return 2; |
1031 | break; | 1033 | break; |
1032 | case SYNC_PREF_ASK: | 1034 | case SYNC_PREF_ASK: |
1033 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1035 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1034 | if ( lastSync > remoteMod && lastSync > localMod) | 1036 | if ( lastSync > remoteMod && lastSync > localMod) |
1035 | return 0; | 1037 | return 0; |
1036 | if ( lastSync > remoteMod ) | 1038 | if ( lastSync > remoteMod ) |
1037 | return 1; | 1039 | return 1; |
1038 | if ( lastSync > localMod ) | 1040 | if ( lastSync > localMod ) |
1039 | return 2; | 1041 | return 2; |
1040 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1042 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1041 | localIsNew = localMod >= remoteMod; | 1043 | localIsNew = localMod >= remoteMod; |
1042 | if ( localIsNew ) | 1044 | if ( localIsNew ) |
1043 | getEventViewerDialog()->setColorMode( 1 ); | 1045 | getEventViewerDialog()->setColorMode( 1 ); |
1044 | else | 1046 | else |
1045 | getEventViewerDialog()->setColorMode( 2 ); | 1047 | getEventViewerDialog()->setColorMode( 2 ); |
1046 | getEventViewerDialog()->setIncidence(local); | 1048 | getEventViewerDialog()->setIncidence(local); |
1047 | if ( localIsNew ) | 1049 | if ( localIsNew ) |
1048 | getEventViewerDialog()->setColorMode( 2 ); | 1050 | getEventViewerDialog()->setColorMode( 2 ); |
1049 | else | 1051 | else |
1050 | getEventViewerDialog()->setColorMode( 1 ); | 1052 | getEventViewerDialog()->setColorMode( 1 ); |
1051 | getEventViewerDialog()->addIncidence(remote); | 1053 | getEventViewerDialog()->addIncidence(remote); |
1052 | getEventViewerDialog()->setColorMode( 0 ); | 1054 | getEventViewerDialog()->setColorMode( 0 ); |
1053 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1055 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1054 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1056 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1055 | getEventViewerDialog()->showMe(); | 1057 | getEventViewerDialog()->showMe(); |
1056 | result = getEventViewerDialog()->executeS( localIsNew ); | 1058 | result = getEventViewerDialog()->executeS( localIsNew ); |
1057 | return result; | 1059 | return result; |
1058 | 1060 | ||
1059 | break; | 1061 | break; |
1060 | case SYNC_PREF_FORCE_LOCAL: | 1062 | case SYNC_PREF_FORCE_LOCAL: |
1061 | return 1; | 1063 | return 1; |
1062 | break; | 1064 | break; |
1063 | case SYNC_PREF_FORCE_REMOTE: | 1065 | case SYNC_PREF_FORCE_REMOTE: |
1064 | return 2; | 1066 | return 2; |
1065 | break; | 1067 | break; |
1066 | 1068 | ||
1067 | default: | 1069 | default: |
1068 | // SYNC_PREF_TAKE_BOTH not implemented | 1070 | // SYNC_PREF_TAKE_BOTH not implemented |
1069 | break; | 1071 | break; |
1070 | } | 1072 | } |
1071 | return 0; | 1073 | return 0; |
1072 | } | 1074 | } |
1073 | Event* CalendarView::getLastSyncEvent() | 1075 | Event* CalendarView::getLastSyncEvent() |
1074 | { | 1076 | { |
1075 | Event* lse; | 1077 | Event* lse; |
1076 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1078 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1077 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1079 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1078 | if (!lse) { | 1080 | if (!lse) { |
1079 | lse = new Event(); | 1081 | lse = new Event(); |
1080 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1082 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1081 | QString sum = ""; | 1083 | QString sum = ""; |
1082 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1084 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1083 | sum = "E: "; | 1085 | sum = "E: "; |
1084 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1086 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1085 | lse->setDtStart( mLastCalendarSync ); | 1087 | lse->setDtStart( mLastCalendarSync ); |
1086 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1088 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1087 | lse->setCategories( i18n("SyncEvent") ); | 1089 | lse->setCategories( i18n("SyncEvent") ); |
1088 | lse->setReadOnly( true ); | 1090 | lse->setReadOnly( true ); |
1089 | mCalendar->addEvent( lse ); | 1091 | mCalendar->addEvent( lse ); |
1090 | } | 1092 | } |
1091 | 1093 | ||
1092 | return lse; | 1094 | return lse; |
1093 | 1095 | ||
1094 | } | 1096 | } |
1095 | 1097 | ||
1096 | // we check, if the to delete event has a id for a profile | 1098 | // we check, if the to delete event has a id for a profile |
1097 | // if yes, we set this id in the profile to delete | 1099 | // if yes, we set this id in the profile to delete |
1098 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1100 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1099 | { | 1101 | { |
1100 | if ( lastSync.count() == 0 ) { | 1102 | if ( lastSync.count() == 0 ) { |
1101 | //qDebug(" lastSync.count() == 0"); | 1103 | //qDebug(" lastSync.count() == 0"); |
1102 | return; | 1104 | return; |
1103 | } | 1105 | } |
1104 | if ( toDelete->typeID() == journalID ) | 1106 | if ( toDelete->typeID() == journalID ) |
1105 | return; | 1107 | return; |
1106 | 1108 | ||
1107 | Event* eve = lastSync.first(); | 1109 | Event* eve = lastSync.first(); |
1108 | 1110 | ||
1109 | while ( eve ) { | 1111 | while ( eve ) { |
1110 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1112 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1111 | if ( !id.isEmpty() ) { | 1113 | if ( !id.isEmpty() ) { |
1112 | QString des = eve->description(); | 1114 | QString des = eve->description(); |
1113 | QString pref = "e"; | 1115 | QString pref = "e"; |
1114 | if ( toDelete->typeID() == todoID ) | 1116 | if ( toDelete->typeID() == todoID ) |
1115 | pref = "t"; | 1117 | pref = "t"; |
1116 | des += pref+ id + ","; | 1118 | des += pref+ id + ","; |
1117 | eve->setReadOnly( false ); | 1119 | eve->setReadOnly( false ); |
1118 | eve->setDescription( des ); | 1120 | eve->setDescription( des ); |
1119 | //qDebug("setdes %s ", des.latin1()); | 1121 | //qDebug("setdes %s ", des.latin1()); |
1120 | eve->setReadOnly( true ); | 1122 | eve->setReadOnly( true ); |
1121 | } | 1123 | } |
1122 | eve = lastSync.next(); | 1124 | eve = lastSync.next(); |
1123 | } | 1125 | } |
1124 | 1126 | ||
1125 | } | 1127 | } |
1126 | void CalendarView::checkExternalId( Incidence * inc ) | 1128 | void CalendarView::checkExternalId( Incidence * inc ) |
1127 | { | 1129 | { |
1128 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1130 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1129 | checkExternSyncEvent( lastSync, inc ); | 1131 | checkExternSyncEvent( lastSync, inc ); |
1130 | 1132 | ||
1131 | } | 1133 | } |
1132 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1134 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1133 | { | 1135 | { |
1134 | bool syncOK = true; | 1136 | bool syncOK = true; |
1135 | int addedEvent = 0; | 1137 | int addedEvent = 0; |
1136 | int addedEventR = 0; | 1138 | int addedEventR = 0; |
1137 | int deletedEventR = 0; | 1139 | int deletedEventR = 0; |
1138 | int deletedEventL = 0; | 1140 | int deletedEventL = 0; |
1139 | int changedLocal = 0; | 1141 | int changedLocal = 0; |
1140 | int changedRemote = 0; | 1142 | int changedRemote = 0; |
1141 | int filteredIN = 0; | 1143 | int filteredIN = 0; |
1142 | int filteredOUT = 0; | 1144 | int filteredOUT = 0; |
1143 | //QPtrList<Event> el = local->rawEvents(); | 1145 | //QPtrList<Event> el = local->rawEvents(); |
1144 | Event* eventR; | 1146 | Event* eventR; |
1145 | QString uid; | 1147 | QString uid; |
1146 | int take; | 1148 | int take; |
1147 | Event* eventL; | 1149 | Event* eventL; |
1148 | Event* eventRSync; | 1150 | Event* eventRSync; |
1149 | Event* eventLSync; | 1151 | Event* eventLSync; |
1150 | clearAllViews(); | 1152 | clearAllViews(); |
1151 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1153 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1152 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1154 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1153 | bool fullDateRange = false; | 1155 | bool fullDateRange = false; |
1154 | local->resetTempSyncStat(); | 1156 | local->resetTempSyncStat(); |
1155 | mLastCalendarSync = QDateTime::currentDateTime(); | 1157 | mLastCalendarSync = QDateTime::currentDateTime(); |
1156 | if ( mSyncManager->syncWithDesktop() ) { | 1158 | if ( mSyncManager->syncWithDesktop() ) { |
1157 | remote->resetPilotStat(1); | 1159 | remote->resetPilotStat(1); |
1158 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1160 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1159 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1161 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1160 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1162 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1161 | } else { | 1163 | } else { |
1162 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1164 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1163 | } | 1165 | } |
1164 | } | 1166 | } |
1165 | QDateTime modifiedCalendar = mLastCalendarSync; | 1167 | QDateTime modifiedCalendar = mLastCalendarSync; |
1166 | eventLSync = getLastSyncEvent(); | 1168 | eventLSync = getLastSyncEvent(); |
1167 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1169 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1168 | if ( eventR ) { | 1170 | if ( eventR ) { |
1169 | eventRSync = (Event*) eventR->clone(); | 1171 | eventRSync = (Event*) eventR->clone(); |
1170 | remote->deleteEvent(eventR ); | 1172 | remote->deleteEvent(eventR ); |
1171 | 1173 | ||
1172 | } else { | 1174 | } else { |
1173 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1175 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1174 | eventRSync = (Event*)eventLSync->clone(); | 1176 | eventRSync = (Event*)eventLSync->clone(); |
1175 | } else { | 1177 | } else { |
1176 | fullDateRange = true; | 1178 | fullDateRange = true; |
1177 | eventRSync = new Event(); | 1179 | eventRSync = new Event(); |
1178 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1180 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1179 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1181 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1180 | eventRSync->setDtStart( mLastCalendarSync ); | 1182 | eventRSync->setDtStart( mLastCalendarSync ); |
1181 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1183 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1182 | eventRSync->setCategories( i18n("SyncEvent") ); | 1184 | eventRSync->setCategories( i18n("SyncEvent") ); |
1183 | } | 1185 | } |
1184 | } | 1186 | } |
1185 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1187 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1186 | fullDateRange = true; | 1188 | fullDateRange = true; |
1187 | 1189 | ||
1188 | if ( ! fullDateRange ) { | 1190 | if ( ! fullDateRange ) { |
1189 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1191 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1190 | 1192 | ||
1191 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1193 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1192 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1194 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1193 | fullDateRange = true; | 1195 | fullDateRange = true; |
1194 | } | 1196 | } |
1195 | } | 1197 | } |
1196 | if ( mSyncManager->syncWithDesktop() ) { | 1198 | if ( mSyncManager->syncWithDesktop() ) { |
1197 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1199 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1198 | } | 1200 | } |
1199 | if ( fullDateRange ) | 1201 | if ( fullDateRange ) |
1200 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1202 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1201 | else | 1203 | else |
1202 | mLastCalendarSync = eventLSync->dtStart(); | 1204 | mLastCalendarSync = eventLSync->dtStart(); |
1203 | // for resyncing if own file has changed | 1205 | // for resyncing if own file has changed |
1204 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1206 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1205 | mLastCalendarSync = loadedFileVersion; | 1207 | mLastCalendarSync = loadedFileVersion; |
1206 | //qDebug("setting mLastCalendarSync "); | 1208 | //qDebug("setting mLastCalendarSync "); |
1207 | } | 1209 | } |
1208 | //qDebug("*************************** "); | 1210 | //qDebug("*************************** "); |
1209 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1211 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1210 | QPtrList<Incidence> er = remote->rawIncidences(); | 1212 | QPtrList<Incidence> er = remote->rawIncidences(); |
1211 | Incidence* inR = er.first(); | 1213 | Incidence* inR = er.first(); |
1212 | Incidence* inL; | 1214 | Incidence* inL; |
1213 | QProgressBar bar( er.count(),0 ); | 1215 | QProgressBar bar( er.count(),0 ); |
1214 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1216 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1215 | 1217 | ||
1216 | // ************** setting up filter ************* | 1218 | // ************** setting up filter ************* |
1217 | CalFilter *filterIN = 0; | 1219 | CalFilter *filterIN = 0; |
1218 | CalFilter *filterOUT = 0; | 1220 | CalFilter *filterOUT = 0; |
1219 | CalFilter *filter = mFilters.first(); | 1221 | CalFilter *filter = mFilters.first(); |