-rw-r--r-- | korganizer/calendarview.cpp | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 543897a..15c5dd9 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -398,192 +398,199 @@ void CalendarView::init() | |||
398 | SLOT( editTodo( Todo * ) ) ); | 398 | SLOT( editTodo( Todo * ) ) ); |
399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
400 | SLOT( showTodo( Todo *) ) ); | 400 | SLOT( showTodo( Todo *) ) ); |
401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
402 | SLOT( deleteTodo( Todo *) ) ); | 402 | SLOT( deleteTodo( Todo *) ) ); |
403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
405 | SLOT( purgeCompleted() ) ); | 405 | SLOT( purgeCompleted() ) ); |
406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
407 | SIGNAL( todoModified( Todo *, int ) ) ); | 407 | SIGNAL( todoModified( Todo *, int ) ) ); |
408 | 408 | ||
409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
412 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 412 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
413 | 413 | ||
414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
415 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 415 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
417 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 417 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
418 | 418 | ||
419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
420 | this, SLOT ( todo_unsub( Todo * ) ) ); | 420 | this, SLOT ( todo_unsub( Todo * ) ) ); |
421 | 421 | ||
422 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 422 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
423 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 423 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
424 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 424 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
425 | SLOT( updateTodo( Todo *, int ) ) ); | 425 | SLOT( updateTodo( Todo *, int ) ) ); |
426 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 426 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
427 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 427 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
428 | 428 | ||
429 | 429 | ||
430 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 430 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
431 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 431 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
432 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 432 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
433 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 433 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
434 | 434 | ||
435 | 435 | ||
436 | 436 | ||
437 | 437 | ||
438 | 438 | ||
439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
440 | SLOT(checkClipboard())); | 440 | SLOT(checkClipboard())); |
441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
442 | SLOT( processTodoListSelection( Incidence * ) ) ); | 442 | SLOT( processTodoListSelection( Incidence * ) ) ); |
443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
444 | 444 | ||
445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
446 | 446 | ||
447 | mDateFrame = new QVBox(0,0,WType_Popup); | 447 | mDateFrame = new QVBox(0,0,WType_Popup); |
448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
450 | mDateFrame->setLineWidth(3); | 450 | mDateFrame->setLineWidth(3); |
451 | mDateFrame->hide(); | 451 | mDateFrame->hide(); |
452 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 452 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
454 | 454 | ||
455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
456 | 456 | ||
457 | mEventEditor = mDialogManager->getEventEditor(); | 457 | mEventEditor = mDialogManager->getEventEditor(); |
458 | mTodoEditor = mDialogManager->getTodoEditor(); | 458 | mTodoEditor = mDialogManager->getTodoEditor(); |
459 | 459 | ||
460 | mFlagEditDescription = false; | 460 | mFlagEditDescription = false; |
461 | 461 | ||
462 | mSuspendTimer = new QTimer( this ); | 462 | mSuspendTimer = new QTimer( this ); |
463 | mAlarmTimer = new QTimer( this ); | 463 | mAlarmTimer = new QTimer( this ); |
464 | mRecheckAlarmTimer = new QTimer( this ); | 464 | mRecheckAlarmTimer = new QTimer( this ); |
465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
468 | mAlarmDialog = new AlarmDialog( this ); | 468 | mAlarmDialog = new AlarmDialog( this ); |
469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
470 | mAlarmDialog->setServerNotification( false ); | 470 | mAlarmDialog->setServerNotification( false ); |
471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
472 | 472 | ||
473 | 473 | ||
474 | #ifndef DESKTOP_VERSION | 474 | #ifndef DESKTOP_VERSION |
475 | //US listen for arriving address resultsets | 475 | //US listen for arriving address resultsets |
476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
478 | #endif | 478 | #endif |
479 | 479 | ||
480 | } | 480 | } |
481 | 481 | ||
482 | 482 | ||
483 | CalendarView::~CalendarView() | 483 | CalendarView::~CalendarView() |
484 | { | 484 | { |
485 | // kdDebug() << "~CalendarView()" << endl; | 485 | // kdDebug() << "~CalendarView()" << endl; |
486 | //qDebug("CalendarView::~CalendarView() "); | 486 | //qDebug("CalendarView::~CalendarView() "); |
487 | delete mDialogManager; | 487 | delete mDialogManager; |
488 | delete mViewManager; | 488 | delete mViewManager; |
489 | delete mStorage; | 489 | delete mStorage; |
490 | delete mDateFrame ; | 490 | delete mDateFrame ; |
491 | delete beamDialog; | 491 | delete beamDialog; |
492 | //kdDebug() << "~CalendarView() done" << endl; | 492 | //kdDebug() << "~CalendarView() done" << endl; |
493 | } | 493 | } |
494 | |||
495 | void CalendarView::showDay( QDate d ) | ||
496 | { | ||
497 | dateNavigator()->selectDate( d ); | ||
498 | mViewManager->showWeekView(); | ||
499 | dateNavigator()->selectDate( d ); | ||
500 | } | ||
494 | void CalendarView::timerAlarm() | 501 | void CalendarView::timerAlarm() |
495 | { | 502 | { |
496 | //qDebug("CalendarView::timerAlarm() "); | 503 | //qDebug("CalendarView::timerAlarm() "); |
497 | computeAlarm(mAlarmNotification ); | 504 | computeAlarm(mAlarmNotification ); |
498 | } | 505 | } |
499 | 506 | ||
500 | void CalendarView::suspendAlarm() | 507 | void CalendarView::suspendAlarm() |
501 | { | 508 | { |
502 | //qDebug(" CalendarView::suspendAlarm() "); | 509 | //qDebug(" CalendarView::suspendAlarm() "); |
503 | computeAlarm(mSuspendAlarmNotification ); | 510 | computeAlarm(mSuspendAlarmNotification ); |
504 | 511 | ||
505 | } | 512 | } |
506 | 513 | ||
507 | void CalendarView::startAlarm( QString mess , QString filename) | 514 | void CalendarView::startAlarm( QString mess , QString filename) |
508 | { | 515 | { |
509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 516 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 517 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
511 | 518 | ||
512 | } | 519 | } |
513 | 520 | ||
514 | void CalendarView::checkNextTimerAlarm() | 521 | void CalendarView::checkNextTimerAlarm() |
515 | { | 522 | { |
516 | mCalendar->checkAlarmForIncidence( 0, true ); | 523 | mCalendar->checkAlarmForIncidence( 0, true ); |
517 | } | 524 | } |
518 | 525 | ||
519 | void CalendarView::computeAlarm( QString msg ) | 526 | void CalendarView::computeAlarm( QString msg ) |
520 | { | 527 | { |
521 | 528 | ||
522 | QString mess = msg; | 529 | QString mess = msg; |
523 | QString mAlarmMessage = mess.mid( 9 ); | 530 | QString mAlarmMessage = mess.mid( 9 ); |
524 | QString filename = MainWindow::resourcePath(); | 531 | QString filename = MainWindow::resourcePath(); |
525 | filename += "koalarm.wav"; | 532 | filename += "koalarm.wav"; |
526 | QString tempfilename; | 533 | QString tempfilename; |
527 | if ( mess.left( 13 ) == "suspend_alarm") { | 534 | if ( mess.left( 13 ) == "suspend_alarm") { |
528 | bool error = false; | 535 | bool error = false; |
529 | int len = mess.mid( 13 ).find("+++"); | 536 | int len = mess.mid( 13 ).find("+++"); |
530 | if ( len < 2 ) | 537 | if ( len < 2 ) |
531 | error = true; | 538 | error = true; |
532 | else { | 539 | else { |
533 | tempfilename = mess.mid( 13, len ); | 540 | tempfilename = mess.mid( 13, len ); |
534 | if ( !QFile::exists( tempfilename ) ) | 541 | if ( !QFile::exists( tempfilename ) ) |
535 | error = true; | 542 | error = true; |
536 | } | 543 | } |
537 | if ( ! error ) { | 544 | if ( ! error ) { |
538 | filename = tempfilename; | 545 | filename = tempfilename; |
539 | } | 546 | } |
540 | mAlarmMessage = mess.mid( 13+len+3 ); | 547 | mAlarmMessage = mess.mid( 13+len+3 ); |
541 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 548 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
542 | startAlarm( mAlarmMessage, filename); | 549 | startAlarm( mAlarmMessage, filename); |
543 | return; | 550 | return; |
544 | } | 551 | } |
545 | if ( mess.left( 11 ) == "timer_alarm") { | 552 | if ( mess.left( 11 ) == "timer_alarm") { |
546 | //mTimerTime = 0; | 553 | //mTimerTime = 0; |
547 | startAlarm( mess.mid( 11 ), filename ); | 554 | startAlarm( mess.mid( 11 ), filename ); |
548 | return; | 555 | return; |
549 | } | 556 | } |
550 | if ( mess.left( 10 ) == "proc_alarm") { | 557 | if ( mess.left( 10 ) == "proc_alarm") { |
551 | bool error = false; | 558 | bool error = false; |
552 | int len = mess.mid( 10 ).find("+++"); | 559 | int len = mess.mid( 10 ).find("+++"); |
553 | if ( len < 2 ) | 560 | if ( len < 2 ) |
554 | error = true; | 561 | error = true; |
555 | else { | 562 | else { |
556 | tempfilename = mess.mid( 10, len ); | 563 | tempfilename = mess.mid( 10, len ); |
557 | if ( !QFile::exists( tempfilename ) ) | 564 | if ( !QFile::exists( tempfilename ) ) |
558 | error = true; | 565 | error = true; |
559 | } | 566 | } |
560 | if ( error ) { | 567 | if ( error ) { |
561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 568 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
562 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 569 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
563 | } else { | 570 | } else { |
564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 571 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
565 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 572 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
566 | #ifndef _WIN32_ | 573 | #ifndef _WIN32_ |
567 | if ( vfork () == 0 ) { | 574 | if ( vfork () == 0 ) { |
568 | execl ( tempfilename.latin1(), 0 ); | 575 | execl ( tempfilename.latin1(), 0 ); |
569 | return; | 576 | return; |
570 | } | 577 | } |
571 | #else | 578 | #else |
572 | QProcess* p = new QProcess(); | 579 | QProcess* p = new QProcess(); |
573 | p->addArgument( tempfilename.latin1() ); | 580 | p->addArgument( tempfilename.latin1() ); |
574 | p->start(); | 581 | p->start(); |
575 | return; | 582 | return; |
576 | #endif | 583 | #endif |
577 | 584 | ||
578 | return; | 585 | return; |
579 | } | 586 | } |
580 | 587 | ||
581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 588 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
582 | } | 589 | } |
583 | if ( mess.left( 11 ) == "audio_alarm") { | 590 | if ( mess.left( 11 ) == "audio_alarm") { |
584 | bool error = false; | 591 | bool error = false; |
585 | int len = mess.mid( 11 ).find("+++"); | 592 | int len = mess.mid( 11 ).find("+++"); |
586 | if ( len < 2 ) | 593 | if ( len < 2 ) |
587 | error = true; | 594 | error = true; |
588 | else { | 595 | else { |
589 | tempfilename = mess.mid( 11, len ); | 596 | tempfilename = mess.mid( 11, len ); |
@@ -2116,212 +2123,226 @@ void CalendarView::changeEventDisplay(Event *which, int action) | |||
2116 | 2123 | ||
2117 | 2124 | ||
2118 | void CalendarView::updateTodoViews() | 2125 | void CalendarView::updateTodoViews() |
2119 | { | 2126 | { |
2120 | 2127 | ||
2121 | mTodoList->updateView(); | 2128 | mTodoList->updateView(); |
2122 | mViewManager->currentView()->updateView(); | 2129 | mViewManager->currentView()->updateView(); |
2123 | 2130 | ||
2124 | } | 2131 | } |
2125 | 2132 | ||
2126 | 2133 | ||
2127 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2134 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2128 | { | 2135 | { |
2129 | mTodoList->updateView(); | 2136 | mTodoList->updateView(); |
2130 | mViewManager->updateView(start, end); | 2137 | mViewManager->updateView(start, end); |
2131 | //mDateNavigator->updateView(); | 2138 | //mDateNavigator->updateView(); |
2132 | } | 2139 | } |
2133 | 2140 | ||
2134 | void CalendarView::updateView() | 2141 | void CalendarView::updateView() |
2135 | { | 2142 | { |
2136 | DateList tmpList = mNavigator->selectedDates(); | 2143 | DateList tmpList = mNavigator->selectedDates(); |
2137 | 2144 | ||
2138 | // We assume that the navigator only selects consecutive days. | 2145 | // We assume that the navigator only selects consecutive days. |
2139 | updateView( tmpList.first(), tmpList.last() ); | 2146 | updateView( tmpList.first(), tmpList.last() ); |
2140 | } | 2147 | } |
2141 | 2148 | ||
2142 | void CalendarView::updateUnmanagedViews() | 2149 | void CalendarView::updateUnmanagedViews() |
2143 | { | 2150 | { |
2144 | mDateNavigator->updateDayMatrix(); | 2151 | mDateNavigator->updateDayMatrix(); |
2145 | } | 2152 | } |
2146 | 2153 | ||
2147 | int CalendarView::msgItemDelete() | 2154 | int CalendarView::msgItemDelete() |
2148 | { | 2155 | { |
2149 | return KMessageBox::warningContinueCancel(this, | 2156 | return KMessageBox::warningContinueCancel(this, |
2150 | i18n("This item will be\npermanently deleted."), | 2157 | i18n("This item will be\npermanently deleted."), |
2151 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2158 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2152 | } | 2159 | } |
2153 | 2160 | ||
2154 | 2161 | ||
2155 | void CalendarView::edit_cut() | 2162 | void CalendarView::edit_cut() |
2156 | { | 2163 | { |
2157 | Event *anEvent=0; | 2164 | Event *anEvent=0; |
2158 | 2165 | ||
2159 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2166 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2160 | 2167 | ||
2161 | if (mViewManager->currentView()->isEventView()) { | 2168 | if (mViewManager->currentView()->isEventView()) { |
2162 | if ( incidence && incidence->type() == "Event" ) { | 2169 | if ( incidence && incidence->type() == "Event" ) { |
2163 | anEvent = static_cast<Event *>(incidence); | 2170 | anEvent = static_cast<Event *>(incidence); |
2164 | } | 2171 | } |
2165 | } | 2172 | } |
2166 | 2173 | ||
2167 | if (!anEvent) { | 2174 | if (!anEvent) { |
2168 | KNotifyClient::beep(); | 2175 | KNotifyClient::beep(); |
2169 | return; | 2176 | return; |
2170 | } | 2177 | } |
2171 | DndFactory factory( mCalendar ); | 2178 | DndFactory factory( mCalendar ); |
2172 | factory.cutEvent(anEvent); | 2179 | factory.cutEvent(anEvent); |
2173 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2180 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2174 | } | 2181 | } |
2175 | 2182 | ||
2176 | void CalendarView::edit_copy() | 2183 | void CalendarView::edit_copy() |
2177 | { | 2184 | { |
2178 | Event *anEvent=0; | 2185 | Event *anEvent=0; |
2179 | 2186 | ||
2180 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2187 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2181 | 2188 | ||
2182 | if (mViewManager->currentView()->isEventView()) { | 2189 | if (mViewManager->currentView()->isEventView()) { |
2183 | if ( incidence && incidence->type() == "Event" ) { | 2190 | if ( incidence && incidence->type() == "Event" ) { |
2184 | anEvent = static_cast<Event *>(incidence); | 2191 | anEvent = static_cast<Event *>(incidence); |
2185 | } | 2192 | } |
2186 | } | 2193 | } |
2187 | 2194 | ||
2188 | if (!anEvent) { | 2195 | if (!anEvent) { |
2189 | KNotifyClient::beep(); | 2196 | KNotifyClient::beep(); |
2190 | return; | 2197 | return; |
2191 | } | 2198 | } |
2192 | DndFactory factory( mCalendar ); | 2199 | DndFactory factory( mCalendar ); |
2193 | factory.copyEvent(anEvent); | 2200 | factory.copyEvent(anEvent); |
2194 | } | 2201 | } |
2195 | 2202 | ||
2196 | void CalendarView::edit_paste() | 2203 | void CalendarView::edit_paste() |
2197 | { | 2204 | { |
2198 | QDate date = mNavigator->selectedDates().first(); | 2205 | QDate date = mNavigator->selectedDates().first(); |
2199 | 2206 | ||
2200 | DndFactory factory( mCalendar ); | 2207 | DndFactory factory( mCalendar ); |
2201 | Event *pastedEvent = factory.pasteEvent( date ); | 2208 | Event *pastedEvent = factory.pasteEvent( date ); |
2202 | 2209 | ||
2203 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2210 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2204 | } | 2211 | } |
2205 | 2212 | ||
2206 | void CalendarView::edit_options() | 2213 | void CalendarView::edit_options() |
2207 | { | 2214 | { |
2208 | mDialogManager->showOptionsDialog(); | 2215 | mDialogManager->showOptionsDialog(); |
2209 | //writeSettings(); | 2216 | //writeSettings(); |
2210 | } | 2217 | } |
2211 | 2218 | ||
2219 | |||
2212 | void CalendarView::slotSelectPickerDate( QDate d) | 2220 | void CalendarView::slotSelectPickerDate( QDate d) |
2213 | { | 2221 | { |
2214 | mDateFrame->hide(); | 2222 | mDateFrame->hide(); |
2215 | if ( mDatePickerMode == 1 ) { | 2223 | if ( mDatePickerMode == 1 ) { |
2216 | mNavigator->slotDaySelect( d ); | 2224 | mNavigator->slotDaySelect( d ); |
2217 | } else if ( mDatePickerMode == 2 ) { | 2225 | } else if ( mDatePickerMode == 2 ) { |
2218 | if ( mMoveIncidence->type() == "Todo" ) { | 2226 | if ( mMoveIncidence->type() == "Todo" ) { |
2219 | Todo * to = (Todo *) mMoveIncidence; | 2227 | Todo * to = (Todo *) mMoveIncidence; |
2220 | QTime tim; | 2228 | QTime tim; |
2221 | if ( to->hasDueDate() ) | 2229 | if ( to->hasDueDate() ) |
2222 | tim = to->dtDue().time(); | 2230 | tim = to->dtDue().time(); |
2223 | else { | 2231 | else { |
2224 | tim = QTime ( 0,0,0 ); | 2232 | tim = QTime ( 0,0,0 ); |
2225 | to->setFloats( true ); | 2233 | to->setFloats( true ); |
2226 | to->setHasDueDate( true ); | 2234 | to->setHasDueDate( true ); |
2227 | } | 2235 | } |
2228 | QDateTime dt ( d,tim ); | 2236 | QDateTime dt ( d,tim ); |
2229 | to->setDtDue( dt ); | 2237 | to->setDtDue( dt ); |
2230 | todoChanged( to ); | 2238 | todoChanged( to ); |
2231 | } else { | 2239 | } else { |
2240 | if ( mMoveIncidence->doesRecur() ) { | ||
2241 | #if 0 | ||
2242 | // PENDING implement this | ||
2243 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | ||
2244 | mCalendar()->addIncidence( newInc ); | ||
2245 | if ( mMoveIncidence->type() == "Todo" ) | ||
2246 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | ||
2247 | else | ||
2248 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | ||
2249 | mMoveIncidence = newInc; | ||
2250 | |||
2251 | #endif | ||
2252 | } | ||
2232 | QTime tim = mMoveIncidence->dtStart().time(); | 2253 | QTime tim = mMoveIncidence->dtStart().time(); |
2233 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2254 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2234 | QDateTime dt ( d,tim ); | 2255 | QDateTime dt ( d,tim ); |
2235 | mMoveIncidence->setDtStart( dt ); | 2256 | mMoveIncidence->setDtStart( dt ); |
2236 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2257 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2237 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2258 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2238 | } | 2259 | } |
2239 | 2260 | ||
2240 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2261 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2241 | } | 2262 | } |
2242 | } | 2263 | } |
2243 | 2264 | ||
2244 | void CalendarView::removeCategories() | 2265 | void CalendarView::removeCategories() |
2245 | { | 2266 | { |
2246 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2267 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2247 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2268 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2248 | QStringList catIncList; | 2269 | QStringList catIncList; |
2249 | QStringList newCatList; | 2270 | QStringList newCatList; |
2250 | Incidence* inc = incList.first(); | 2271 | Incidence* inc = incList.first(); |
2251 | int i; | 2272 | int i; |
2252 | int count = 0; | 2273 | int count = 0; |
2253 | while ( inc ) { | 2274 | while ( inc ) { |
2254 | newCatList.clear(); | 2275 | newCatList.clear(); |
2255 | catIncList = inc->categories() ; | 2276 | catIncList = inc->categories() ; |
2256 | for( i = 0; i< catIncList.count(); ++i ) { | 2277 | for( i = 0; i< catIncList.count(); ++i ) { |
2257 | if ( catList.contains (catIncList[i])) | 2278 | if ( catList.contains (catIncList[i])) |
2258 | newCatList.append( catIncList[i] ); | 2279 | newCatList.append( catIncList[i] ); |
2259 | } | 2280 | } |
2260 | newCatList.sort(); | 2281 | newCatList.sort(); |
2261 | inc->setCategories( newCatList.join(",") ); | 2282 | inc->setCategories( newCatList.join(",") ); |
2262 | inc = incList.next(); | 2283 | inc = incList.next(); |
2263 | } | 2284 | } |
2264 | } | 2285 | } |
2265 | 2286 | ||
2266 | int CalendarView::addCategories() | 2287 | int CalendarView::addCategories() |
2267 | { | 2288 | { |
2268 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2289 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2269 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2290 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2270 | QStringList catIncList; | 2291 | QStringList catIncList; |
2271 | Incidence* inc = incList.first(); | 2292 | Incidence* inc = incList.first(); |
2272 | int i; | 2293 | int i; |
2273 | int count = 0; | 2294 | int count = 0; |
2274 | while ( inc ) { | 2295 | while ( inc ) { |
2275 | catIncList = inc->categories() ; | 2296 | catIncList = inc->categories() ; |
2276 | for( i = 0; i< catIncList.count(); ++i ) { | 2297 | for( i = 0; i< catIncList.count(); ++i ) { |
2277 | if ( !catList.contains (catIncList[i])) { | 2298 | if ( !catList.contains (catIncList[i])) { |
2278 | catList.append( catIncList[i] ); | 2299 | catList.append( catIncList[i] ); |
2279 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2300 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2280 | ++count; | 2301 | ++count; |
2281 | } | 2302 | } |
2282 | } | 2303 | } |
2283 | inc = incList.next(); | 2304 | inc = incList.next(); |
2284 | } | 2305 | } |
2285 | catList.sort(); | 2306 | catList.sort(); |
2286 | KOPrefs::instance()->mCustomCategories = catList; | 2307 | KOPrefs::instance()->mCustomCategories = catList; |
2287 | return count; | 2308 | return count; |
2288 | } | 2309 | } |
2289 | 2310 | ||
2290 | void CalendarView::manageCategories() | 2311 | void CalendarView::manageCategories() |
2291 | { | 2312 | { |
2292 | KOCatPrefs* cp = new KOCatPrefs(); | 2313 | KOCatPrefs* cp = new KOCatPrefs(); |
2293 | cp->show(); | 2314 | cp->show(); |
2294 | int w =cp->sizeHint().width() ; | 2315 | int w =cp->sizeHint().width() ; |
2295 | int h = cp->sizeHint().height() ; | 2316 | int h = cp->sizeHint().height() ; |
2296 | int dw = QApplication::desktop()->width(); | 2317 | int dw = QApplication::desktop()->width(); |
2297 | int dh = QApplication::desktop()->height(); | 2318 | int dh = QApplication::desktop()->height(); |
2298 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2319 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2299 | if ( !cp->exec() ) { | 2320 | if ( !cp->exec() ) { |
2300 | delete cp; | 2321 | delete cp; |
2301 | return; | 2322 | return; |
2302 | } | 2323 | } |
2303 | int count = 0; | 2324 | int count = 0; |
2304 | if ( cp->addCat() ) { | 2325 | if ( cp->addCat() ) { |
2305 | count = addCategories(); | 2326 | count = addCategories(); |
2306 | if ( count ) { | 2327 | if ( count ) { |
2307 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2328 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2308 | writeSettings(); | 2329 | writeSettings(); |
2309 | } else | 2330 | } else |
2310 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2331 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2311 | } else { | 2332 | } else { |
2312 | removeCategories(); | 2333 | removeCategories(); |
2313 | updateView(); | 2334 | updateView(); |
2314 | } | 2335 | } |
2315 | delete cp; | 2336 | delete cp; |
2316 | } | 2337 | } |
2317 | 2338 | ||
2318 | void CalendarView::beamIncidence(Incidence * Inc) | 2339 | void CalendarView::beamIncidence(Incidence * Inc) |
2319 | { | 2340 | { |
2320 | QPtrList<Incidence> delSel ; | 2341 | QPtrList<Incidence> delSel ; |
2321 | delSel.append(Inc); | 2342 | delSel.append(Inc); |
2322 | beamIncidenceList( delSel ); | 2343 | beamIncidenceList( delSel ); |
2323 | } | 2344 | } |
2324 | void CalendarView::beamCalendar() | 2345 | void CalendarView::beamCalendar() |
2325 | { | 2346 | { |
2326 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2347 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2327 | //qDebug("beamCalendar() "); | 2348 | //qDebug("beamCalendar() "); |
@@ -2333,192 +2354,194 @@ void CalendarView::beamFilteredCalendar() | |||
2333 | //qDebug("beamFilteredCalendar() "); | 2354 | //qDebug("beamFilteredCalendar() "); |
2334 | beamIncidenceList( delSel ); | 2355 | beamIncidenceList( delSel ); |
2335 | } | 2356 | } |
2336 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2357 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2337 | { | 2358 | { |
2338 | if ( beamDialog->exec () == QDialog::Rejected ) | 2359 | if ( beamDialog->exec () == QDialog::Rejected ) |
2339 | return; | 2360 | return; |
2340 | #ifdef DESKTOP_VERSION | 2361 | #ifdef DESKTOP_VERSION |
2341 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2362 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2342 | #else | 2363 | #else |
2343 | QString fn = "/tmp/kopibeamfile"; | 2364 | QString fn = "/tmp/kopibeamfile"; |
2344 | #endif | 2365 | #endif |
2345 | QString mes; | 2366 | QString mes; |
2346 | bool createbup = true; | 2367 | bool createbup = true; |
2347 | if ( createbup ) { | 2368 | if ( createbup ) { |
2348 | QString description = "\n"; | 2369 | QString description = "\n"; |
2349 | CalendarLocal* cal = new CalendarLocal(); | 2370 | CalendarLocal* cal = new CalendarLocal(); |
2350 | if ( beamDialog->beamLocal() ) | 2371 | if ( beamDialog->beamLocal() ) |
2351 | cal->setLocalTime(); | 2372 | cal->setLocalTime(); |
2352 | else | 2373 | else |
2353 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2374 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2354 | Incidence *incidence = delSel.first(); | 2375 | Incidence *incidence = delSel.first(); |
2355 | bool addText = false; | 2376 | bool addText = false; |
2356 | if ( delSel.count() < 10 ) | 2377 | if ( delSel.count() < 10 ) |
2357 | addText = true; | 2378 | addText = true; |
2358 | else { | 2379 | else { |
2359 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2380 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2360 | } | 2381 | } |
2361 | while ( incidence ) { | 2382 | while ( incidence ) { |
2362 | Incidence *in = incidence->clone(); | 2383 | Incidence *in = incidence->clone(); |
2363 | if ( ! in->summary().isEmpty() ) { | 2384 | if ( ! in->summary().isEmpty() ) { |
2364 | in->setDescription(""); | 2385 | in->setDescription(""); |
2365 | } else { | 2386 | } else { |
2366 | in->setSummary( in->description().left(20)); | 2387 | in->setSummary( in->description().left(20)); |
2367 | in->setDescription(""); | 2388 | in->setDescription(""); |
2368 | } | 2389 | } |
2369 | if ( addText ) | 2390 | if ( addText ) |
2370 | description += in->summary() + "\n"; | 2391 | description += in->summary() + "\n"; |
2371 | cal->addIncidence( in ); | 2392 | cal->addIncidence( in ); |
2372 | incidence = delSel.next(); | 2393 | incidence = delSel.next(); |
2373 | } | 2394 | } |
2374 | if ( beamDialog->beamVcal() ) { | 2395 | if ( beamDialog->beamVcal() ) { |
2375 | fn += ".vcs"; | 2396 | fn += ".vcs"; |
2376 | FileStorage storage( cal, fn, new VCalFormat ); | 2397 | FileStorage storage( cal, fn, new VCalFormat ); |
2377 | storage.save(); | 2398 | storage.save(); |
2378 | } else { | 2399 | } else { |
2379 | fn += ".ics"; | 2400 | fn += ".ics"; |
2380 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2401 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2381 | storage.save(); | 2402 | storage.save(); |
2382 | } | 2403 | } |
2383 | delete cal; | 2404 | delete cal; |
2384 | mes = i18n("KO/Pi: Ready for beaming"); | 2405 | mes = i18n("KO/Pi: Ready for beaming"); |
2385 | topLevelWidget()->setCaption(mes); | 2406 | topLevelWidget()->setCaption(mes); |
2386 | KApplication::convert2latin1( fn ); | 2407 | KApplication::convert2latin1( fn ); |
2387 | #ifndef DESKTOP_VERSION | 2408 | #ifndef DESKTOP_VERSION |
2388 | Ir *ir = new Ir( this ); | 2409 | Ir *ir = new Ir( this ); |
2389 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2410 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2390 | ir->send( fn, description, "text/x-vCalendar" ); | 2411 | ir->send( fn, description, "text/x-vCalendar" ); |
2391 | #endif | 2412 | #endif |
2392 | } | 2413 | } |
2393 | } | 2414 | } |
2394 | void CalendarView::beamDone( Ir *ir ) | 2415 | void CalendarView::beamDone( Ir *ir ) |
2395 | { | 2416 | { |
2396 | #ifndef DESKTOP_VERSION | 2417 | #ifndef DESKTOP_VERSION |
2397 | delete ir; | 2418 | delete ir; |
2398 | #endif | 2419 | #endif |
2399 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2420 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2400 | topLevelWidget()->raise(); | 2421 | topLevelWidget()->raise(); |
2401 | } | 2422 | } |
2402 | 2423 | ||
2403 | void CalendarView::moveIncidence(Incidence * inc ) | 2424 | void CalendarView::moveIncidence(Incidence * inc ) |
2404 | { | 2425 | { |
2405 | if ( !inc ) return; | 2426 | if ( !inc ) return; |
2406 | // qDebug("showDatePickerForIncidence( ) "); | 2427 | // qDebug("showDatePickerForIncidence( ) "); |
2407 | if ( mDateFrame->isVisible() ) | 2428 | if ( mDateFrame->isVisible() ) |
2408 | mDateFrame->hide(); | 2429 | mDateFrame->hide(); |
2409 | else { | 2430 | else { |
2410 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2431 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2411 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2432 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2412 | int dw = QApplication::desktop()->width(); | 2433 | int dw = QApplication::desktop()->width(); |
2413 | int dh = QApplication::desktop()->height(); | 2434 | int dh = QApplication::desktop()->height(); |
2414 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2435 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2415 | mDateFrame->show(); | 2436 | mDateFrame->show(); |
2416 | } | 2437 | } |
2417 | mDatePickerMode = 2; | 2438 | mDatePickerMode = 2; |
2418 | mMoveIncidence = inc ; | 2439 | mMoveIncidence = inc ; |
2419 | QDate da; | 2440 | QDate da; |
2420 | if ( mMoveIncidence->type() == "Todo" ) { | 2441 | if ( mMoveIncidence->type() == "Todo" ) { |
2421 | Todo * to = (Todo *) mMoveIncidence; | 2442 | Todo * to = (Todo *) mMoveIncidence; |
2422 | if ( to->hasDueDate() ) | 2443 | if ( to->hasDueDate() ) |
2423 | da = to->dtDue().date(); | 2444 | da = to->dtDue().date(); |
2424 | else | 2445 | else |
2425 | da = QDate::currentDate(); | 2446 | da = QDate::currentDate(); |
2426 | } else { | 2447 | } else { |
2427 | da = mMoveIncidence->dtStart().date(); | 2448 | da = mMoveIncidence->dtStart().date(); |
2428 | } | 2449 | } |
2450 | //PENDING set date for recurring incidence to date of recurrence | ||
2451 | //mMoveIncidenceOldDate; | ||
2429 | mDatePicker->setDate( da ); | 2452 | mDatePicker->setDate( da ); |
2430 | } | 2453 | } |
2431 | void CalendarView::showDatePicker( ) | 2454 | void CalendarView::showDatePicker( ) |
2432 | { | 2455 | { |
2433 | //qDebug("CalendarView::showDatePicker( ) "); | 2456 | //qDebug("CalendarView::showDatePicker( ) "); |
2434 | if ( mDateFrame->isVisible() ) | 2457 | if ( mDateFrame->isVisible() ) |
2435 | mDateFrame->hide(); | 2458 | mDateFrame->hide(); |
2436 | else { | 2459 | else { |
2437 | int w =mDatePicker->sizeHint().width() ; | 2460 | int w =mDatePicker->sizeHint().width() ; |
2438 | int h = mDatePicker->sizeHint().height() ; | 2461 | int h = mDatePicker->sizeHint().height() ; |
2439 | int dw = QApplication::desktop()->width(); | 2462 | int dw = QApplication::desktop()->width(); |
2440 | int dh = QApplication::desktop()->height(); | 2463 | int dh = QApplication::desktop()->height(); |
2441 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2464 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2442 | mDateFrame->show(); | 2465 | mDateFrame->show(); |
2443 | } | 2466 | } |
2444 | mDatePickerMode = 1; | 2467 | mDatePickerMode = 1; |
2445 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2468 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2446 | } | 2469 | } |
2447 | 2470 | ||
2448 | void CalendarView::showEventEditor() | 2471 | void CalendarView::showEventEditor() |
2449 | { | 2472 | { |
2450 | #ifdef DESKTOP_VERSION | 2473 | #ifdef DESKTOP_VERSION |
2451 | mEventEditor->show(); | 2474 | mEventEditor->show(); |
2452 | #else | 2475 | #else |
2453 | if ( mEventEditor->width() != QApplication::desktop()->width() ) { | 2476 | if ( mEventEditor->width() != QApplication::desktop()->width() ) { |
2454 | qDebug("CalendarView: recreate mEventEditor "); | 2477 | qDebug("CalendarView: recreate mEventEditor "); |
2455 | delete mEventEditor; | 2478 | delete mEventEditor; |
2456 | mEventEditor = mDialogManager->getEventEditor(); | 2479 | mEventEditor = mDialogManager->getEventEditor(); |
2457 | } | 2480 | } |
2458 | mEventEditor->showMaximized(); | 2481 | mEventEditor->showMaximized(); |
2459 | #endif | 2482 | #endif |
2460 | } | 2483 | } |
2461 | void CalendarView::showTodoEditor() | 2484 | void CalendarView::showTodoEditor() |
2462 | { | 2485 | { |
2463 | #ifdef DESKTOP_VERSION | 2486 | #ifdef DESKTOP_VERSION |
2464 | mTodoEditor->show(); | 2487 | mTodoEditor->show(); |
2465 | #else | 2488 | #else |
2466 | if ( mTodoEditor->width() != QApplication::desktop()->width() ) { | 2489 | if ( mTodoEditor->width() != QApplication::desktop()->width() ) { |
2467 | qDebug("CalendarView: recreate mTodoEditor "); | 2490 | qDebug("CalendarView: recreate mTodoEditor "); |
2468 | delete mTodoEditor; | 2491 | delete mTodoEditor; |
2469 | mTodoEditor = mDialogManager->getTodoEditor(); | 2492 | mTodoEditor = mDialogManager->getTodoEditor(); |
2470 | } | 2493 | } |
2471 | mTodoEditor->showMaximized(); | 2494 | mTodoEditor->showMaximized(); |
2472 | #endif | 2495 | #endif |
2473 | } | 2496 | } |
2474 | 2497 | ||
2475 | void CalendarView::cloneIncidence() | 2498 | void CalendarView::cloneIncidence() |
2476 | { | 2499 | { |
2477 | Incidence *incidence = currentSelection(); | 2500 | Incidence *incidence = currentSelection(); |
2478 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2501 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2479 | if ( incidence ) { | 2502 | if ( incidence ) { |
2480 | cloneIncidence(incidence); | 2503 | cloneIncidence(incidence); |
2481 | } | 2504 | } |
2482 | } | 2505 | } |
2483 | void CalendarView::moveIncidence() | 2506 | void CalendarView::moveIncidence() |
2484 | { | 2507 | { |
2485 | Incidence *incidence = currentSelection(); | 2508 | Incidence *incidence = currentSelection(); |
2486 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2509 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2487 | if ( incidence ) { | 2510 | if ( incidence ) { |
2488 | moveIncidence(incidence); | 2511 | moveIncidence(incidence); |
2489 | } | 2512 | } |
2490 | } | 2513 | } |
2491 | void CalendarView::beamIncidence() | 2514 | void CalendarView::beamIncidence() |
2492 | { | 2515 | { |
2493 | Incidence *incidence = currentSelection(); | 2516 | Incidence *incidence = currentSelection(); |
2494 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2517 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2495 | if ( incidence ) { | 2518 | if ( incidence ) { |
2496 | beamIncidence(incidence); | 2519 | beamIncidence(incidence); |
2497 | } | 2520 | } |
2498 | } | 2521 | } |
2499 | void CalendarView::toggleCancelIncidence() | 2522 | void CalendarView::toggleCancelIncidence() |
2500 | { | 2523 | { |
2501 | Incidence *incidence = currentSelection(); | 2524 | Incidence *incidence = currentSelection(); |
2502 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2525 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2503 | if ( incidence ) { | 2526 | if ( incidence ) { |
2504 | cancelIncidence(incidence); | 2527 | cancelIncidence(incidence); |
2505 | } | 2528 | } |
2506 | } | 2529 | } |
2507 | 2530 | ||
2508 | 2531 | ||
2509 | void CalendarView::cancelIncidence(Incidence * inc ) | 2532 | void CalendarView::cancelIncidence(Incidence * inc ) |
2510 | { | 2533 | { |
2511 | inc->setCancelled( ! inc->cancelled() ); | 2534 | inc->setCancelled( ! inc->cancelled() ); |
2512 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2535 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2513 | updateView(); | 2536 | updateView(); |
2514 | } | 2537 | } |
2515 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2538 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2516 | { | 2539 | { |
2517 | Incidence * newInc = orgInc->clone(); | 2540 | Incidence * newInc = orgInc->clone(); |
2518 | newInc->recreate(); | 2541 | newInc->recreate(); |
2519 | 2542 | ||
2520 | if ( newInc->type() == "Todo" ) { | 2543 | if ( newInc->type() == "Todo" ) { |
2521 | Todo* t = (Todo*) newInc; | 2544 | Todo* t = (Todo*) newInc; |
2522 | mTodoEditor->editTodo( t ); | 2545 | mTodoEditor->editTodo( t ); |
2523 | showTodoEditor(); | 2546 | showTodoEditor(); |
2524 | if ( mTodoEditor->exec() ) { | 2547 | if ( mTodoEditor->exec() ) { |
@@ -2791,242 +2814,242 @@ void CalendarView::appointment_delete() | |||
2791 | deleteEvent(anEvent); | 2814 | deleteEvent(anEvent); |
2792 | } | 2815 | } |
2793 | 2816 | ||
2794 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2817 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2795 | { | 2818 | { |
2796 | if (!sub) return; | 2819 | if (!sub) return; |
2797 | if (!parent) return; | 2820 | if (!parent) return; |
2798 | if ( sub->relatedTo() ) | 2821 | if ( sub->relatedTo() ) |
2799 | sub->relatedTo()->removeRelation(sub); | 2822 | sub->relatedTo()->removeRelation(sub); |
2800 | sub->setRelatedTo(parent); | 2823 | sub->setRelatedTo(parent); |
2801 | sub->setRelatedToUid(parent->uid()); | 2824 | sub->setRelatedToUid(parent->uid()); |
2802 | parent->addRelation(sub); | 2825 | parent->addRelation(sub); |
2803 | sub->updated(); | 2826 | sub->updated(); |
2804 | parent->updated(); | 2827 | parent->updated(); |
2805 | setModified(true); | 2828 | setModified(true); |
2806 | updateView(); | 2829 | updateView(); |
2807 | } | 2830 | } |
2808 | void CalendarView::todo_unsub(Todo *anTodo ) | 2831 | void CalendarView::todo_unsub(Todo *anTodo ) |
2809 | { | 2832 | { |
2810 | // Todo *anTodo = selectedTodo(); | 2833 | // Todo *anTodo = selectedTodo(); |
2811 | if (!anTodo) return; | 2834 | if (!anTodo) return; |
2812 | if (!anTodo->relatedTo()) return; | 2835 | if (!anTodo->relatedTo()) return; |
2813 | anTodo->relatedTo()->removeRelation(anTodo); | 2836 | anTodo->relatedTo()->removeRelation(anTodo); |
2814 | anTodo->setRelatedTo(0); | 2837 | anTodo->setRelatedTo(0); |
2815 | anTodo->updated(); | 2838 | anTodo->updated(); |
2816 | anTodo->setRelatedToUid(""); | 2839 | anTodo->setRelatedToUid(""); |
2817 | setModified(true); | 2840 | setModified(true); |
2818 | updateView(); | 2841 | updateView(); |
2819 | } | 2842 | } |
2820 | 2843 | ||
2821 | void CalendarView::deleteTodo(Todo *todo) | 2844 | void CalendarView::deleteTodo(Todo *todo) |
2822 | { | 2845 | { |
2823 | if (!todo) { | 2846 | if (!todo) { |
2824 | KNotifyClient::beep(); | 2847 | KNotifyClient::beep(); |
2825 | return; | 2848 | return; |
2826 | } | 2849 | } |
2827 | if (KOPrefs::instance()->mConfirm) { | 2850 | if (KOPrefs::instance()->mConfirm) { |
2828 | switch (msgItemDelete()) { | 2851 | switch (msgItemDelete()) { |
2829 | case KMessageBox::Continue: // OK | 2852 | case KMessageBox::Continue: // OK |
2830 | if (!todo->relations().isEmpty()) { | 2853 | if (!todo->relations().isEmpty()) { |
2831 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2854 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2832 | i18n("Delete To-Do")); | 2855 | i18n("Delete To-Do")); |
2833 | } else { | 2856 | } else { |
2834 | checkExternalId( todo ); | 2857 | checkExternalId( todo ); |
2835 | calendar()->deleteTodo(todo); | 2858 | calendar()->deleteTodo(todo); |
2836 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2859 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2837 | updateView(); | 2860 | updateView(); |
2838 | } | 2861 | } |
2839 | break; | 2862 | break; |
2840 | } // switch | 2863 | } // switch |
2841 | } else { | 2864 | } else { |
2842 | if (!todo->relations().isEmpty()) { | 2865 | if (!todo->relations().isEmpty()) { |
2843 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2866 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2844 | i18n("Delete To-Do")); | 2867 | i18n("Delete To-Do")); |
2845 | } else { | 2868 | } else { |
2846 | checkExternalId( todo ); | 2869 | checkExternalId( todo ); |
2847 | mCalendar->deleteTodo(todo); | 2870 | mCalendar->deleteTodo(todo); |
2848 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2871 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2849 | updateView(); | 2872 | updateView(); |
2850 | } | 2873 | } |
2851 | } | 2874 | } |
2852 | emit updateSearchDialog(); | 2875 | emit updateSearchDialog(); |
2853 | } | 2876 | } |
2854 | void CalendarView::deleteJournal(Journal *jour) | 2877 | void CalendarView::deleteJournal(Journal *jour) |
2855 | { | 2878 | { |
2856 | if (!jour) { | 2879 | if (!jour) { |
2857 | KNotifyClient::beep(); | 2880 | KNotifyClient::beep(); |
2858 | return; | 2881 | return; |
2859 | } | 2882 | } |
2860 | if (KOPrefs::instance()->mConfirm) { | 2883 | if (KOPrefs::instance()->mConfirm) { |
2861 | switch (msgItemDelete()) { | 2884 | switch (msgItemDelete()) { |
2862 | case KMessageBox::Continue: // OK | 2885 | case KMessageBox::Continue: // OK |
2863 | calendar()->deleteJournal(jour); | 2886 | calendar()->deleteJournal(jour); |
2864 | updateView(); | 2887 | updateView(); |
2865 | break; | 2888 | break; |
2866 | } // switch | 2889 | } // switch |
2867 | } else { | 2890 | } else { |
2868 | calendar()->deleteJournal(jour);; | 2891 | calendar()->deleteJournal(jour);; |
2869 | updateView(); | 2892 | updateView(); |
2870 | } | 2893 | } |
2871 | emit updateSearchDialog(); | 2894 | emit updateSearchDialog(); |
2872 | } | 2895 | } |
2873 | 2896 | ||
2874 | void CalendarView::deleteEvent(Event *anEvent) | 2897 | void CalendarView::deleteEvent(Event *anEvent) |
2875 | { | 2898 | { |
2876 | if (!anEvent) { | 2899 | if (!anEvent) { |
2877 | KNotifyClient::beep(); | 2900 | KNotifyClient::beep(); |
2878 | return; | 2901 | return; |
2879 | } | 2902 | } |
2880 | 2903 | ||
2881 | if (anEvent->recurrence()->doesRecur()) { | 2904 | if (anEvent->recurrence()->doesRecur()) { |
2882 | QDate itemDate = mViewManager->currentSelectionDate(); | 2905 | QDate itemDate = mViewManager->currentSelectionDate(); |
2883 | int km; | 2906 | int km; |
2884 | if (!itemDate.isValid()) { | 2907 | if (!itemDate.isValid()) { |
2885 | //kdDebug() << "Date Not Valid" << endl; | 2908 | //kdDebug() << "Date Not Valid" << endl; |
2886 | if (KOPrefs::instance()->mConfirm) { | 2909 | if (KOPrefs::instance()->mConfirm) { |
2887 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2910 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
2888 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2911 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2889 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2912 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2890 | if ( km == KMessageBox::Continue ) | 2913 | if ( km == KMessageBox::Continue ) |
2891 | km = KMessageBox::No; // No = all below | 2914 | km = KMessageBox::No; // No = all below |
2892 | } else | 2915 | } else |
2893 | km = KMessageBox::No; | 2916 | km = KMessageBox::No; |
2894 | } else { | 2917 | } else { |
2895 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + | 2918 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
2896 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2919 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2897 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2920 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2898 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2921 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2899 | i18n("All")); | 2922 | i18n("All")); |
2900 | } | 2923 | } |
2901 | switch(km) { | 2924 | switch(km) { |
2902 | 2925 | ||
2903 | case KMessageBox::No: // Continue // all | 2926 | case KMessageBox::No: // Continue // all |
2904 | //qDebug("KMessageBox::No "); | 2927 | //qDebug("KMessageBox::No "); |
2905 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2928 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2906 | schedule(Scheduler::Cancel,anEvent); | 2929 | schedule(Scheduler::Cancel,anEvent); |
2907 | 2930 | ||
2908 | checkExternalId( anEvent); | 2931 | checkExternalId( anEvent); |
2909 | mCalendar->deleteEvent(anEvent); | 2932 | mCalendar->deleteEvent(anEvent); |
2910 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2933 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2911 | break; | 2934 | break; |
2912 | 2935 | ||
2913 | // Disabled because it does not work | 2936 | // Disabled because it does not work |
2914 | //#if 0 | 2937 | //#if 0 |
2915 | case KMessageBox::Yes: // just this one | 2938 | case KMessageBox::Yes: // just this one |
2916 | //QDate qd = mNavigator->selectedDates().first(); | 2939 | //QDate qd = mNavigator->selectedDates().first(); |
2917 | //if (!qd.isValid()) { | 2940 | //if (!qd.isValid()) { |
2918 | // kdDebug() << "no date selected, or invalid date" << endl; | 2941 | // kdDebug() << "no date selected, or invalid date" << endl; |
2919 | // KNotifyClient::beep(); | 2942 | // KNotifyClient::beep(); |
2920 | // return; | 2943 | // return; |
2921 | //} | 2944 | //} |
2922 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2945 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2923 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2946 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2924 | anEvent->addExDate(itemDate); | 2947 | anEvent->addExDate(itemDate); |
2925 | int duration = anEvent->recurrence()->duration(); | 2948 | int duration = anEvent->recurrence()->duration(); |
2926 | if ( duration > 0 ) { | 2949 | if ( duration > 0 ) { |
2927 | anEvent->recurrence()->setDuration( duration - 1 ); | 2950 | anEvent->recurrence()->setDuration( duration - 1 ); |
2928 | } | 2951 | } |
2929 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2952 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2930 | } | 2953 | } |
2931 | break; | 2954 | break; |
2932 | //#endif | 2955 | //#endif |
2933 | } // switch | 2956 | } // switch |
2934 | } else { | 2957 | } else { |
2935 | if (KOPrefs::instance()->mConfirm) { | 2958 | if (KOPrefs::instance()->mConfirm) { |
2936 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2959 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
2937 | i18n("\nAre you sure you want\nto delete this event?"), | 2960 | i18n("\nAre you sure you want\nto delete this event?"), |
2938 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 2961 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
2939 | case KMessageBox::Continue: // OK | 2962 | case KMessageBox::Continue: // OK |
2940 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2963 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2941 | schedule(Scheduler::Cancel,anEvent); | 2964 | schedule(Scheduler::Cancel,anEvent); |
2942 | checkExternalId( anEvent); | 2965 | checkExternalId( anEvent); |
2943 | mCalendar->deleteEvent(anEvent); | 2966 | mCalendar->deleteEvent(anEvent); |
2944 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2967 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2945 | break; | 2968 | break; |
2946 | } // switch | 2969 | } // switch |
2947 | } else { | 2970 | } else { |
2948 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2971 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2949 | schedule(Scheduler::Cancel,anEvent); | 2972 | schedule(Scheduler::Cancel,anEvent); |
2950 | checkExternalId( anEvent); | 2973 | checkExternalId( anEvent); |
2951 | mCalendar->deleteEvent(anEvent); | 2974 | mCalendar->deleteEvent(anEvent); |
2952 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2975 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2953 | } | 2976 | } |
2954 | } // if-else | 2977 | } // if-else |
2955 | emit updateSearchDialog(); | 2978 | emit updateSearchDialog(); |
2956 | } | 2979 | } |
2957 | 2980 | ||
2958 | bool CalendarView::deleteEvent(const QString &uid) | 2981 | bool CalendarView::deleteEvent(const QString &uid) |
2959 | { | 2982 | { |
2960 | Event *ev = mCalendar->event(uid); | 2983 | Event *ev = mCalendar->event(uid); |
2961 | if (ev) { | 2984 | if (ev) { |
2962 | deleteEvent(ev); | 2985 | deleteEvent(ev); |
2963 | return true; | 2986 | return true; |
2964 | } else { | 2987 | } else { |
2965 | return false; | 2988 | return false; |
2966 | } | 2989 | } |
2967 | } | 2990 | } |
2968 | 2991 | ||
2969 | /*****************************************************************************/ | 2992 | /*****************************************************************************/ |
2970 | 2993 | ||
2971 | void CalendarView::action_mail() | 2994 | void CalendarView::action_mail() |
2972 | { | 2995 | { |
2973 | #ifndef KORG_NOMAIL | 2996 | #ifndef KORG_NOMAIL |
2974 | KOMailClient mailClient; | 2997 | KOMailClient mailClient; |
2975 | 2998 | ||
2976 | Incidence *incidence = currentSelection(); | 2999 | Incidence *incidence = currentSelection(); |
2977 | 3000 | ||
2978 | if (!incidence) { | 3001 | if (!incidence) { |
2979 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3002 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2980 | return; | 3003 | return; |
2981 | } | 3004 | } |
2982 | if(incidence->attendeeCount() == 0 ) { | 3005 | if(incidence->attendeeCount() == 0 ) { |
2983 | KMessageBox::sorry(this, | 3006 | KMessageBox::sorry(this, |
2984 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3007 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2985 | return; | 3008 | return; |
2986 | } | 3009 | } |
2987 | 3010 | ||
2988 | CalendarLocal cal_tmp; | 3011 | CalendarLocal cal_tmp; |
2989 | Event *event = 0; | 3012 | Event *event = 0; |
2990 | Event *ev = 0; | 3013 | Event *ev = 0; |
2991 | if ( incidence && incidence->type() == "Event" ) { | 3014 | if ( incidence && incidence->type() == "Event" ) { |
2992 | event = static_cast<Event *>(incidence); | 3015 | event = static_cast<Event *>(incidence); |
2993 | ev = new Event(*event); | 3016 | ev = new Event(*event); |
2994 | cal_tmp.addEvent(ev); | 3017 | cal_tmp.addEvent(ev); |
2995 | } | 3018 | } |
2996 | ICalFormat mForm(); | 3019 | ICalFormat mForm(); |
2997 | QString attachment = mForm.toString( &cal_tmp ); | 3020 | QString attachment = mForm.toString( &cal_tmp ); |
2998 | if (ev) delete(ev); | 3021 | if (ev) delete(ev); |
2999 | 3022 | ||
3000 | mailClient.mailAttendees(currentSelection(), attachment); | 3023 | mailClient.mailAttendees(currentSelection(), attachment); |
3001 | 3024 | ||
3002 | #endif | 3025 | #endif |
3003 | 3026 | ||
3004 | #if 0 | 3027 | #if 0 |
3005 | Event *anEvent = 0; | 3028 | Event *anEvent = 0; |
3006 | if (mViewManager->currentView()->isEventView()) { | 3029 | if (mViewManager->currentView()->isEventView()) { |
3007 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3030 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3008 | } | 3031 | } |
3009 | 3032 | ||
3010 | if (!anEvent) { | 3033 | if (!anEvent) { |
3011 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3034 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3012 | return; | 3035 | return; |
3013 | } | 3036 | } |
3014 | if(anEvent->attendeeCount() == 0 ) { | 3037 | if(anEvent->attendeeCount() == 0 ) { |
3015 | KMessageBox::sorry(this, | 3038 | KMessageBox::sorry(this, |
3016 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3039 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3017 | return; | 3040 | return; |
3018 | } | 3041 | } |
3019 | 3042 | ||
3020 | mailobject.emailEvent(anEvent); | 3043 | mailobject.emailEvent(anEvent); |
3021 | #endif | 3044 | #endif |
3022 | } | 3045 | } |
3023 | 3046 | ||
3024 | 3047 | ||
3025 | void CalendarView::schedule_publish(Incidence *incidence) | 3048 | void CalendarView::schedule_publish(Incidence *incidence) |
3026 | { | 3049 | { |
3027 | Event *event = 0; | 3050 | Event *event = 0; |
3028 | Todo *todo = 0; | 3051 | Todo *todo = 0; |
3029 | 3052 | ||
3030 | if (incidence == 0) { | 3053 | if (incidence == 0) { |
3031 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3054 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3032 | if (incidence == 0) { | 3055 | if (incidence == 0) { |
@@ -3706,96 +3729,113 @@ bool CalendarView::removeCompletedSubTodos( Todo* t ) | |||
3706 | subTodos = t->relations(); | 3729 | subTodos = t->relations(); |
3707 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3730 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3708 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3731 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3709 | deleteTodo = false; | 3732 | deleteTodo = false; |
3710 | } | 3733 | } |
3711 | if ( deleteTodo ) { | 3734 | if ( deleteTodo ) { |
3712 | if ( t->isCompleted() ) { | 3735 | if ( t->isCompleted() ) { |
3713 | checkExternalId( t ); | 3736 | checkExternalId( t ); |
3714 | mCalendar->deleteTodo( t ); | 3737 | mCalendar->deleteTodo( t ); |
3715 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3738 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3716 | } | 3739 | } |
3717 | else | 3740 | else |
3718 | deleteTodo = false; | 3741 | deleteTodo = false; |
3719 | } | 3742 | } |
3720 | return deleteTodo; | 3743 | return deleteTodo; |
3721 | 3744 | ||
3722 | } | 3745 | } |
3723 | void CalendarView::purgeCompleted() | 3746 | void CalendarView::purgeCompleted() |
3724 | { | 3747 | { |
3725 | int result = KMessageBox::warningContinueCancel(this, | 3748 | int result = KMessageBox::warningContinueCancel(this, |
3726 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3749 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3727 | 3750 | ||
3728 | if (result == KMessageBox::Continue) { | 3751 | if (result == KMessageBox::Continue) { |
3729 | 3752 | ||
3730 | QPtrList<Todo> todoCal; | 3753 | QPtrList<Todo> todoCal; |
3731 | QPtrList<Todo> rootTodos; | 3754 | QPtrList<Todo> rootTodos; |
3732 | //QPtrList<Incidence> rel; | 3755 | //QPtrList<Incidence> rel; |
3733 | Todo *aTodo;//, *rTodo; | 3756 | Todo *aTodo;//, *rTodo; |
3734 | Incidence *rIncidence; | 3757 | Incidence *rIncidence; |
3735 | bool childDelete = false; | 3758 | bool childDelete = false; |
3736 | bool deletedOne = true; | 3759 | bool deletedOne = true; |
3737 | todoCal = calendar()->todos(); | 3760 | todoCal = calendar()->todos(); |
3738 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3761 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3739 | if ( !aTodo->relatedTo() ) | 3762 | if ( !aTodo->relatedTo() ) |
3740 | rootTodos.append( aTodo ); | 3763 | rootTodos.append( aTodo ); |
3741 | } | 3764 | } |
3742 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3765 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3743 | removeCompletedSubTodos( aTodo ); | 3766 | removeCompletedSubTodos( aTodo ); |
3744 | } | 3767 | } |
3745 | 3768 | ||
3746 | updateView(); | 3769 | updateView(); |
3747 | } | 3770 | } |
3748 | } | 3771 | } |
3749 | 3772 | ||
3750 | void CalendarView::slotCalendarChanged() | 3773 | void CalendarView::slotCalendarChanged() |
3751 | { | 3774 | { |
3752 | ; | 3775 | ; |
3753 | } | 3776 | } |
3754 | 3777 | ||
3755 | NavigatorBar *CalendarView::navigatorBar() | 3778 | NavigatorBar *CalendarView::navigatorBar() |
3756 | { | 3779 | { |
3757 | return mNavigatorBar; | 3780 | return mNavigatorBar; |
3758 | } | 3781 | } |
3759 | 3782 | ||
3760 | 3783 | ||
3761 | 3784 | ||
3762 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3785 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3763 | { | 3786 | { |
3764 | //qDebug(" alendarView::keyPressEvent "); | 3787 | //qDebug(" alendarView::keyPressEvent "); |
3765 | e->ignore(); | 3788 | e->ignore(); |
3766 | } | 3789 | } |
3767 | 3790 | ||
3768 | 3791 | ||
3769 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3792 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3770 | { | 3793 | { |
3771 | // mSyncManager = manager; | 3794 | // mSyncManager = manager; |
3772 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3795 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3773 | qDebug("SyncKDE request detected!"); | 3796 | qDebug("SyncKDE request detected!"); |
3774 | } | 3797 | } |
3775 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3798 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3776 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3799 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3777 | return syncCalendar( filename, mode ); | 3800 | return syncCalendar( filename, mode ); |
3778 | } | 3801 | } |
3779 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3802 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3780 | { | 3803 | { |
3781 | //mSyncManager = manager; | 3804 | //mSyncManager = manager; |
3782 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3805 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3783 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3806 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3784 | if ( resource == "sharp" ) | 3807 | if ( resource == "sharp" ) |
3785 | syncExternal( 0 ); | 3808 | syncExternal( 0 ); |
3786 | if ( resource == "phone" ) | 3809 | if ( resource == "phone" ) |
3787 | syncExternal( 1 ); | 3810 | syncExternal( 1 ); |
3788 | // pending setmodified | 3811 | // pending setmodified |
3789 | return true; | 3812 | return true; |
3790 | } | 3813 | } |
3791 | void CalendarView::setSyncManager(KSyncManager* manager) | 3814 | void CalendarView::setSyncManager(KSyncManager* manager) |
3792 | { | 3815 | { |
3793 | mSyncManager = manager; | 3816 | mSyncManager = manager; |
3794 | } | 3817 | } |
3795 | 3818 | ||
3796 | void CalendarView::removeSyncInfo( QString syncProfile) | 3819 | void CalendarView::removeSyncInfo( QString syncProfile) |
3797 | { | 3820 | { |
3798 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); | 3821 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); |
3799 | mCalendar->removeSyncInfo( syncProfile ); | 3822 | mCalendar->removeSyncInfo( syncProfile ); |
3800 | 3823 | ||
3801 | } | 3824 | } |
3825 | |||
3826 | void CalendarView::undo_delete() | ||
3827 | { | ||
3828 | //qDebug("undo_delete() "); | ||
3829 | Incidence* undo = mCalendar->undoIncidence(); | ||
3830 | if ( !undo ) { | ||
3831 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | ||
3832 | i18n("KO/Pi")); | ||
3833 | return; | ||
3834 | } | ||
3835 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | ||
3836 | i18n("\nAre you sure you want\nto restore this?"), | ||
3837 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | ||
3838 | mCalendar->undoDeleteIncidence(); | ||
3839 | updateView(); | ||
3840 | } | ||
3841 | } | ||