-rw-r--r-- | korganizer/calendarview.cpp | 80 |
1 files changed, 73 insertions, 7 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index bc1c0c7..9a114d0 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -561,192 +561,258 @@ void CalendarView::init() | |||
561 | SLOT( editTodo( Todo * ) ) ); | 561 | SLOT( editTodo( Todo * ) ) ); |
562 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 562 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
563 | SLOT( showTodo( Todo *) ) ); | 563 | SLOT( showTodo( Todo *) ) ); |
564 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 564 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
565 | SLOT( deleteTodo( Todo *) ) ); | 565 | SLOT( deleteTodo( Todo *) ) ); |
566 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 566 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
567 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 567 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
568 | SLOT( purgeCompleted() ) ); | 568 | SLOT( purgeCompleted() ) ); |
569 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 569 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
570 | SIGNAL( todoModified( Todo *, int ) ) ); | 570 | SIGNAL( todoModified( Todo *, int ) ) ); |
571 | 571 | ||
572 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 572 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
573 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 573 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
574 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 574 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
575 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 575 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
576 | 576 | ||
577 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 577 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
578 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 578 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
579 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 579 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
580 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 580 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
581 | 581 | ||
582 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 582 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
583 | this, SLOT ( todo_unsub( Todo * ) ) ); | 583 | this, SLOT ( todo_unsub( Todo * ) ) ); |
584 | 584 | ||
585 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 585 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
586 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 586 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
587 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 587 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
588 | SLOT( updateTodo( Todo *, int ) ) ); | 588 | SLOT( updateTodo( Todo *, int ) ) ); |
589 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 589 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
590 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 590 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
591 | 591 | ||
592 | 592 | ||
593 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 593 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
594 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 594 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
595 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 595 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
596 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 596 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
597 | 597 | ||
598 | 598 | ||
599 | 599 | ||
600 | 600 | ||
601 | 601 | ||
602 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 602 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
603 | SLOT(checkClipboard())); | 603 | SLOT(checkClipboard())); |
604 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 604 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
605 | SLOT( processTodoListSelection( Incidence * ) ) ); | 605 | SLOT( processTodoListSelection( Incidence * ) ) ); |
606 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 606 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
607 | 607 | ||
608 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 608 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
609 | 609 | ||
610 | mDateFrame = new QVBox(0,0,WType_Popup); | 610 | mDateFrame = new QVBox(0,0,WType_Popup); |
611 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 611 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
612 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 612 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
613 | mDateFrame->setLineWidth(3); | 613 | mDateFrame->setLineWidth(3); |
614 | mDateFrame->hide(); | 614 | mDateFrame->hide(); |
615 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 615 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
616 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 616 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
617 | 617 | ||
618 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 618 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
619 | 619 | ||
620 | mEventEditor = mDialogManager->getEventEditor(); | 620 | mEventEditor = mDialogManager->getEventEditor(); |
621 | mTodoEditor = mDialogManager->getTodoEditor(); | 621 | mTodoEditor = mDialogManager->getTodoEditor(); |
622 | 622 | ||
623 | mFlagEditDescription = false; | 623 | mFlagEditDescription = false; |
624 | 624 | ||
625 | mSuspendTimer = new QTimer( this ); | 625 | mSuspendTimer = new QTimer( this ); |
626 | mAlarmTimer = new QTimer( this ); | 626 | mAlarmTimer = new QTimer( this ); |
627 | mRecheckAlarmTimer = new QTimer( this ); | 627 | mRecheckAlarmTimer = new QTimer( this ); |
628 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 628 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
629 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 629 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
630 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 630 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
631 | mAlarmDialog = new AlarmDialog( this ); | 631 | mAlarmDialog = new AlarmDialog( this ); |
632 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 632 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
633 | mAlarmDialog->setServerNotification( false ); | 633 | mAlarmDialog->setServerNotification( false ); |
634 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 634 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
635 | 635 | ||
636 | 636 | ||
637 | #ifndef DESKTOP_VERSION | 637 | #ifndef DESKTOP_VERSION |
638 | //US listen for arriving address resultsets | 638 | //US listen for arriving address resultsets |
639 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 639 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
640 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 640 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
641 | #endif | 641 | #endif |
642 | mDateNavigator->setCalendar( mCalendar ); | 642 | mDateNavigator->setCalendar( mCalendar ); |
643 | } | 643 | } |
644 | 644 | ||
645 | 645 | ||
646 | CalendarView::~CalendarView() | 646 | CalendarView::~CalendarView() |
647 | { | 647 | { |
648 | // kdDebug() << "~CalendarView()" << endl; | 648 | // kdDebug() << "~CalendarView()" << endl; |
649 | //qDebug("CalendarView::~CalendarView() "); | 649 | //qDebug("CalendarView::~CalendarView() "); |
650 | delete mDialogManager; | 650 | delete mDialogManager; |
651 | delete mViewManager; | 651 | delete mViewManager; |
652 | delete mStorage; | 652 | delete mStorage; |
653 | delete mDateFrame ; | 653 | delete mDateFrame ; |
654 | delete mEventViewerDialog; | 654 | delete mEventViewerDialog; |
655 | //kdDebug() << "~CalendarView() done" << endl; | 655 | //kdDebug() << "~CalendarView() done" << endl; |
656 | } | 656 | } |
657 | void CalendarView::nextConflict( bool all, bool allday ) | ||
658 | { | ||
659 | QDate start = mNavigator->selectedDates().first().addDays(1); | ||
660 | QDate end = start.addDays( 365*2); | ||
661 | while ( start < end ) { | ||
662 | QPtrList<Event> eventList = calendar()->events( start ); | ||
663 | Event * ev = eventList.first(); | ||
664 | QPtrList<Event> test = eventList; | ||
665 | while ( ev ) { | ||
666 | //qDebug("found %d on %s ", eventList.count(), start.toString().latin1()); | ||
667 | Event * t_ev = test.first(); | ||
668 | QDateTime es = ev->dtStart(); | ||
669 | QDateTime ee = ev->dtEnd(); | ||
670 | if ( ev->doesFloat() ) | ||
671 | ee = ee.addDays( 1 ); | ||
672 | if ( ! all ) { | ||
673 | if ( ev->doesFloat() != allday ) | ||
674 | t_ev = 0; | ||
675 | } | ||
676 | while ( t_ev ) { | ||
677 | bool skip = false; | ||
678 | if ( ! all ) { | ||
679 | if ( t_ev->doesFloat() != allday ) | ||
680 | skip = true; | ||
681 | } | ||
682 | if ( !skip && ev != t_ev ) { | ||
683 | QDateTime ets = t_ev->dtStart(); | ||
684 | QDateTime ete = t_ev->dtEnd(); | ||
685 | if ( t_ev->doesFloat() ) | ||
686 | ete = ete.addDays( 1 ); | ||
687 | //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() ); | ||
688 | if ( es < ete && ets < ee ) { | ||
689 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | ||
690 | mViewManager->showDayView(); | ||
691 | mNavigator->slotDaySelect( start ); | ||
692 | int hour = es.time().hour(); | ||
693 | if ( ets > es ) | ||
694 | hour = ets.time().hour(); | ||
695 | mViewManager->agendaView()->setStartHour( hour ); | ||
696 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) ); | ||
697 | return; | ||
698 | } | ||
699 | } | ||
700 | t_ev = test.next(); | ||
701 | } | ||
702 | ev = eventList.next(); | ||
703 | } | ||
704 | start = start.addDays( 1 ); | ||
705 | } | ||
706 | topLevelWidget()->setCaption( i18n("No conflict found within the next two years") ); | ||
707 | qDebug("No conflict found "); | ||
708 | } | ||
709 | |||
710 | void CalendarView::conflictAll() | ||
711 | { | ||
712 | nextConflict ( true, true ); | ||
713 | } | ||
714 | void CalendarView::conflictAllday() | ||
715 | { | ||
716 | nextConflict ( false, true ); | ||
717 | } | ||
718 | void CalendarView::conflictNotAll() | ||
719 | { | ||
720 | nextConflict ( false, false ); | ||
721 | } | ||
722 | |||
657 | void CalendarView::setCalReadOnly( int id, bool readO ) | 723 | void CalendarView::setCalReadOnly( int id, bool readO ) |
658 | { | 724 | { |
659 | if ( readO ) { | 725 | if ( readO ) { |
660 | emit save(); | 726 | emit save(); |
661 | } | 727 | } |
662 | mCalendar->setReadOnly( id, readO ); | 728 | mCalendar->setReadOnly( id, readO ); |
663 | } | 729 | } |
664 | void CalendarView::setScrollBarStep(int val ) | 730 | void CalendarView::setScrollBarStep(int val ) |
665 | { | 731 | { |
666 | #ifdef DESKTOP_VERSION | 732 | #ifdef DESKTOP_VERSION |
667 | mDateScrollBar->setLineStep ( val ); | 733 | mDateScrollBar->setLineStep ( val ); |
668 | #endif | 734 | #endif |
669 | } | 735 | } |
670 | void CalendarView::scrollBarValue(int val ) | 736 | void CalendarView::scrollBarValue(int val ) |
671 | { | 737 | { |
672 | #ifdef DESKTOP_VERSION | 738 | #ifdef DESKTOP_VERSION |
673 | if ( QApplication::desktop()->width() < 800 ) return; | 739 | if ( QApplication::desktop()->width() < 800 ) return; |
674 | static bool block = false; | 740 | static bool block = false; |
675 | if ( block ) return; | 741 | if ( block ) return; |
676 | block = true; | 742 | block = true; |
677 | int count = mNavigator->selectedDates().count(); | 743 | int count = mNavigator->selectedDates().count(); |
678 | int day = mNavigator->selectedDates().first().dayOfYear(); | 744 | int day = mNavigator->selectedDates().first().dayOfYear(); |
679 | int stepdays = val; | 745 | int stepdays = val; |
680 | if ( mDateScrollBar->lineStep () <= count ) { | 746 | if ( mDateScrollBar->lineStep () <= count ) { |
681 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 747 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
682 | //qDebug("VAL %d ",val ); | 748 | //qDebug("VAL %d ",val ); |
683 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 749 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
684 | stepdays = day+stepdays; | 750 | stepdays = day+stepdays; |
685 | if ( stepdays < 0 ) stepdays = 0; | 751 | if ( stepdays < 0 ) stepdays = 0; |
686 | } | 752 | } |
687 | if ( stepdays == day ) { | 753 | if ( stepdays == day ) { |
688 | block = false; | 754 | block = false; |
689 | return; | 755 | return; |
690 | } | 756 | } |
691 | int year = mNavigator->selectedDates().first().year(); | 757 | int year = mNavigator->selectedDates().first().year(); |
692 | QDate d ( year,1,1 ); | 758 | QDate d ( year,1,1 ); |
693 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 759 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
694 | block = false; | 760 | block = false; |
695 | #endif | 761 | #endif |
696 | 762 | ||
697 | } | 763 | } |
698 | void CalendarView::updateView(const QDate &start, const QDate &end) | 764 | void CalendarView::updateView(const QDate &start, const QDate &end) |
699 | { | 765 | { |
700 | #ifdef DESKTOP_VERSION | 766 | #ifdef DESKTOP_VERSION |
701 | if ( ! mDateScrollBar->draggingSlider () ) { | 767 | if ( ! mDateScrollBar->draggingSlider () ) { |
702 | int dof = start.dayOfYear(); | 768 | int dof = start.dayOfYear(); |
703 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 769 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
704 | if ( dof != mDateScrollBar->value() ) { | 770 | if ( dof != mDateScrollBar->value() ) { |
705 | mDateScrollBar->blockSignals( true ); | 771 | mDateScrollBar->blockSignals( true ); |
706 | mDateScrollBar->setValue( start.dayOfYear()); | 772 | mDateScrollBar->setValue( start.dayOfYear()); |
707 | mDateScrollBar->blockSignals( false ); | 773 | mDateScrollBar->blockSignals( false ); |
708 | } | 774 | } |
709 | } | 775 | } |
710 | #endif | 776 | #endif |
711 | mTodoList->updateView(); | 777 | mTodoList->updateView(); |
712 | mViewManager->updateView(start, end); | 778 | mViewManager->updateView(start, end); |
713 | //mDateNavigator->updateView(); | 779 | //mDateNavigator->updateView(); |
714 | } | 780 | } |
715 | 781 | ||
716 | 782 | ||
717 | 783 | ||
718 | void CalendarView::checkFiles() | 784 | void CalendarView::checkFiles() |
719 | { | 785 | { |
720 | QString message; | 786 | QString message; |
721 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 787 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
722 | KopiCalendarFile * cal = calendars.first(); | 788 | KopiCalendarFile * cal = calendars.first(); |
723 | while ( cal ) { | 789 | while ( cal ) { |
724 | if ( cal->mErrorOnLoad ) { | 790 | if ( cal->mErrorOnLoad ) { |
725 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 791 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
726 | } | 792 | } |
727 | cal = calendars.next(); | 793 | cal = calendars.next(); |
728 | } | 794 | } |
729 | if ( !message.isEmpty() ) { | 795 | if ( !message.isEmpty() ) { |
730 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); | 796 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); |
731 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); | 797 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); |
732 | } | 798 | } |
733 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 799 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
734 | } | 800 | } |
735 | void CalendarView::checkAlarms() | 801 | void CalendarView::checkAlarms() |
736 | { | 802 | { |
737 | 803 | ||
738 | 804 | ||
739 | KConfig *config = KOGlobals::config(); | 805 | KConfig *config = KOGlobals::config(); |
740 | config->setGroup( "AppRun" ); | 806 | config->setGroup( "AppRun" ); |
741 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 807 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
742 | int daysto = dt.daysTo( QDate::currentDate() ); | 808 | int daysto = dt.daysTo( QDate::currentDate() ); |
743 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 809 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
744 | dt = dt.addDays( days ); | 810 | dt = dt.addDays( days ); |
745 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 811 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
746 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 812 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
747 | //qDebug("KO: Reading program stop %d ", secs); | 813 | //qDebug("KO: Reading program stop %d ", secs); |
748 | //secs -= ( 3600 * 24*3 ); // debug only | 814 | //secs -= ( 3600 * 24*3 ); // debug only |
749 | QDateTime latest = dt.addSecs ( secs ); | 815 | QDateTime latest = dt.addSecs ( secs ); |
750 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 816 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
751 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 817 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
752 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 818 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
@@ -3069,193 +3135,193 @@ void CalendarView::showDatePicker( ) | |||
3069 | 3135 | ||
3070 | void CalendarView::showEventEditor() | 3136 | void CalendarView::showEventEditor() |
3071 | { | 3137 | { |
3072 | #ifdef DESKTOP_VERSION | 3138 | #ifdef DESKTOP_VERSION |
3073 | int x,y,w,h; | 3139 | int x,y,w,h; |
3074 | x = mEventEditor->geometry().x(); | 3140 | x = mEventEditor->geometry().x(); |
3075 | y = mEventEditor->geometry().y(); | 3141 | y = mEventEditor->geometry().y(); |
3076 | w = mEventEditor->width(); | 3142 | w = mEventEditor->width(); |
3077 | h = mEventEditor->height(); | 3143 | h = mEventEditor->height(); |
3078 | mEventEditor->show(); | 3144 | mEventEditor->show(); |
3079 | mEventEditor->setGeometry(x,y,w,h); | 3145 | mEventEditor->setGeometry(x,y,w,h); |
3080 | #else | 3146 | #else |
3081 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 3147 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
3082 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3148 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3083 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 3149 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
3084 | qApp->processEvents(); | 3150 | qApp->processEvents(); |
3085 | delete mEventEditor; | 3151 | delete mEventEditor; |
3086 | mEventEditor = mDialogManager->getEventEditor(); | 3152 | mEventEditor = mDialogManager->getEventEditor(); |
3087 | topLevelWidget()->setCaption( i18n("") ); | 3153 | topLevelWidget()->setCaption( i18n("") ); |
3088 | } | 3154 | } |
3089 | mEventEditor->showMaximized(); | 3155 | mEventEditor->showMaximized(); |
3090 | #endif | 3156 | #endif |
3091 | } | 3157 | } |
3092 | void CalendarView::showTodoEditor() | 3158 | void CalendarView::showTodoEditor() |
3093 | { | 3159 | { |
3094 | #ifdef DESKTOP_VERSION | 3160 | #ifdef DESKTOP_VERSION |
3095 | int x,y,w,h; | 3161 | int x,y,w,h; |
3096 | x = mTodoEditor->geometry().x(); | 3162 | x = mTodoEditor->geometry().x(); |
3097 | y = mTodoEditor->geometry().y(); | 3163 | y = mTodoEditor->geometry().y(); |
3098 | w = mTodoEditor->width(); | 3164 | w = mTodoEditor->width(); |
3099 | h = mTodoEditor->height(); | 3165 | h = mTodoEditor->height(); |
3100 | mTodoEditor->show(); | 3166 | mTodoEditor->show(); |
3101 | mTodoEditor->setGeometry(x,y,w,h); | 3167 | mTodoEditor->setGeometry(x,y,w,h); |
3102 | #else | 3168 | #else |
3103 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3169 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3104 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3170 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3105 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3171 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3106 | qApp->processEvents(); | 3172 | qApp->processEvents(); |
3107 | delete mTodoEditor; | 3173 | delete mTodoEditor; |
3108 | mTodoEditor = mDialogManager->getTodoEditor(); | 3174 | mTodoEditor = mDialogManager->getTodoEditor(); |
3109 | topLevelWidget()->setCaption( i18n("") ); | 3175 | topLevelWidget()->setCaption( i18n("") ); |
3110 | } | 3176 | } |
3111 | mTodoEditor->showMaximized(); | 3177 | mTodoEditor->showMaximized(); |
3112 | #endif | 3178 | #endif |
3113 | } | 3179 | } |
3114 | 3180 | ||
3115 | void CalendarView::cloneIncidence() | 3181 | void CalendarView::cloneIncidence() |
3116 | { | 3182 | { |
3117 | Incidence *incidence = currentSelection(); | 3183 | Incidence *incidence = currentSelection(); |
3118 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3184 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3119 | if ( incidence ) { | 3185 | if ( incidence ) { |
3120 | cloneIncidence(incidence); | 3186 | cloneIncidence(incidence); |
3121 | } | 3187 | } |
3122 | } | 3188 | } |
3123 | void CalendarView::moveIncidence() | 3189 | void CalendarView::moveIncidence() |
3124 | { | 3190 | { |
3125 | Incidence *incidence = currentSelection(); | 3191 | Incidence *incidence = currentSelection(); |
3126 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3192 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3127 | if ( incidence ) { | 3193 | if ( incidence ) { |
3128 | moveIncidence(incidence); | 3194 | moveIncidence(incidence); |
3129 | } | 3195 | } |
3130 | } | 3196 | } |
3131 | void CalendarView::beamIncidence() | 3197 | void CalendarView::beamIncidence() |
3132 | { | 3198 | { |
3133 | Incidence *incidence = currentSelection(); | 3199 | Incidence *incidence = currentSelection(); |
3134 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3200 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3135 | if ( incidence ) { | 3201 | if ( incidence ) { |
3136 | beamIncidence(incidence); | 3202 | beamIncidence(incidence); |
3137 | } | 3203 | } |
3138 | } | 3204 | } |
3139 | void CalendarView::toggleCancelIncidence() | 3205 | void CalendarView::toggleCancelIncidence() |
3140 | { | 3206 | { |
3141 | Incidence *incidence = currentSelection(); | 3207 | Incidence *incidence = currentSelection(); |
3142 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3208 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3143 | if ( incidence ) { | 3209 | if ( incidence ) { |
3144 | cancelIncidence(incidence); | 3210 | cancelIncidence(incidence); |
3145 | } | 3211 | } |
3146 | } | 3212 | } |
3147 | 3213 | ||
3148 | 3214 | ||
3149 | void CalendarView::cancelIncidence(Incidence * inc ) | 3215 | void CalendarView::cancelIncidence(Incidence * inc ) |
3150 | { | 3216 | { |
3151 | inc->setCancelled( ! inc->cancelled() ); | 3217 | inc->setCancelled( ! inc->cancelled() ); |
3152 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3218 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3153 | updateView(); | 3219 | updateView(); |
3154 | } | 3220 | } |
3155 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3221 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3156 | { | 3222 | { |
3157 | Incidence * newInc = orgInc->clone(); | 3223 | Incidence * newInc = orgInc->clone(); |
3158 | newInc->recreate(); | 3224 | newInc->recreate(); |
3159 | 3225 | ||
3160 | if ( newInc->typeID() == todoID ) { | 3226 | if ( newInc->typeID() == todoID ) { |
3161 | Todo* t = (Todo*) newInc; | 3227 | Todo* t = (Todo*) newInc; |
3162 | bool cloneSub = false; | 3228 | bool cloneSub = false; |
3163 | if ( orgInc->relations().count() ) { | 3229 | if ( orgInc->relations().count() ) { |
3164 | int result = KMessageBox::warningYesNoCancel(this, | 3230 | int result = KMessageBox::warningYesNoCancel(this, |
3165 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), | 3231 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), |
3166 | i18n("Todo has subtodos"), | 3232 | i18n("Todo has subtodos"), |
3167 | i18n("Yes"), | 3233 | i18n("Yes"), |
3168 | i18n("No")); | 3234 | i18n("No")); |
3169 | 3235 | ||
3170 | if ( result == KMessageBox::Cancel ) { | 3236 | if ( result == KMessageBox::Cancel ) { |
3171 | delete t; | 3237 | delete t; |
3172 | return; | 3238 | return; |
3173 | } | 3239 | } |
3174 | if (result == KMessageBox::Yes) cloneSub = true; | 3240 | if (result == KMessageBox::Yes) cloneSub = true; |
3175 | } | 3241 | } |
3176 | showTodoEditor(); | 3242 | showTodoEditor(); |
3177 | mTodoEditor->editTodo( t ); | 3243 | mTodoEditor->editTodo( t ); |
3178 | if ( mTodoEditor->exec() ) { | 3244 | if ( mTodoEditor->exec() ) { |
3179 | if ( cloneSub ) { | 3245 | if ( cloneSub ) { |
3180 | orgInc->cloneRelations( t ); | 3246 | orgInc->cloneRelations( t ); |
3181 | mCalendar->addIncidenceBranch( t ); | 3247 | mCalendar->addIncidenceBranch( t ); |
3182 | updateView(); | 3248 | updateView(); |
3183 | 3249 | ||
3184 | } else { | 3250 | } else { |
3185 | mCalendar->addTodo( t ); | 3251 | mCalendar->addTodo( t ); |
3186 | updateView(); | 3252 | updateView(); |
3187 | } | 3253 | } |
3188 | } else { | 3254 | } else { |
3189 | delete t; | 3255 | delete t; |
3190 | } | 3256 | } |
3191 | } | 3257 | } |
3192 | else if ( newInc->typeID() == eventID ) { | 3258 | else if ( newInc->typeID() == eventID ) { |
3193 | Event* e = (Event*) newInc; | 3259 | Event* e = (Event*) newInc; |
3194 | showEventEditor(); | 3260 | showEventEditor(); |
3195 | mEventEditor->editEvent( e ); | 3261 | mEventEditor->editEvent( e ); |
3196 | if ( mEventEditor->exec() ) { | 3262 | if ( mEventEditor->exec() ) { |
3197 | mCalendar->addEvent( e ); | 3263 | mCalendar->addEvent( e ); |
3198 | updateView(); | 3264 | updateView(); |
3199 | } else { | 3265 | } else { |
3200 | delete e; | 3266 | delete e; |
3201 | } | 3267 | } |
3202 | } if ( newInc->typeID() == journalID ) { | 3268 | } if ( newInc->typeID() == journalID ) { |
3203 | mCalendar->addJournal( (Journal*) newInc ); | 3269 | mCalendar->addJournal( (Journal*) newInc ); |
3204 | editJournal( (Journal*) newInc ); | 3270 | editJournal( (Journal*) newInc ); |
3205 | } | 3271 | } |
3206 | setActiveWindow(); | 3272 | setActiveWindow(); |
3207 | } | 3273 | } |
3208 | 3274 | ||
3209 | void CalendarView::newEvent() | 3275 | void CalendarView::newEvent() |
3210 | { | 3276 | { |
3211 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3277 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3212 | KOAgendaView *aView = mViewManager->agendaView(); | 3278 | KOAgendaView *aView = mViewManager->agendaView(); |
3213 | if (aView) { | 3279 | if (aView) { |
3214 | if (aView->selectionStart().isValid()) { | 3280 | if (aView->selectionStart().isValid()) { |
3215 | if (aView->selectedIsAllDay()) { | 3281 | if (aView->selectedIsAllDay()) { |
3216 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3282 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3217 | } else { | 3283 | } else { |
3218 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3284 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3219 | } | 3285 | } |
3220 | return; | 3286 | return; |
3221 | } | 3287 | } |
3222 | } | 3288 | } |
3223 | 3289 | ||
3224 | QDate date = mNavigator->selectedDates().first(); | 3290 | QDate date = mNavigator->selectedDates().first(); |
3225 | QDateTime current = QDateTime::currentDateTime(); | 3291 | QDateTime current = QDateTime::currentDateTime(); |
3226 | if ( date <= current.date() ) { | 3292 | if ( date <= current.date() ) { |
3227 | int hour = current.time().hour() +1; | 3293 | int hour = current.time().hour() +1; |
3228 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3294 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3229 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3295 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3230 | } else | 3296 | } else |
3231 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3297 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3232 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3298 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3233 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3299 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3234 | } | 3300 | } |
3235 | 3301 | ||
3236 | void CalendarView::newEvent(QDateTime fh) | 3302 | void CalendarView::newEvent(QDateTime fh) |
3237 | { | 3303 | { |
3238 | newEvent(fh, | 3304 | newEvent(fh, |
3239 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3305 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3240 | } | 3306 | } |
3241 | 3307 | ||
3242 | void CalendarView::newEvent(QDate dt) | 3308 | void CalendarView::newEvent(QDate dt) |
3243 | { | 3309 | { |
3244 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3310 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3245 | QDateTime(dt, QTime(0,0,0)), true); | 3311 | QDateTime(dt, QTime(0,0,0)), true); |
3246 | } | 3312 | } |
3247 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3313 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3248 | { | 3314 | { |
3249 | newEvent(fromHint, toHint, false); | 3315 | newEvent(fromHint, toHint, false); |
3250 | } | 3316 | } |
3251 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3317 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3252 | { | 3318 | { |
3253 | 3319 | ||
3254 | showEventEditor(); | 3320 | showEventEditor(); |
3255 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3321 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3256 | if ( mFilterView->filtersEnabled() ) { | 3322 | if ( mFilterView->filtersEnabled() ) { |
3257 | CalFilter *filter = mFilterView->selectedFilter(); | 3323 | CalFilter *filter = mFilterView->selectedFilter(); |
3258 | if (filter && filter->showCategories()) { | 3324 | if (filter && filter->showCategories()) { |
3259 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3325 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3260 | } | 3326 | } |
3261 | if ( filter ) | 3327 | if ( filter ) |
@@ -3407,314 +3473,314 @@ void CalendarView::showJournal( Journal *jour ) | |||
3407 | 3473 | ||
3408 | } | 3474 | } |
3409 | // void CalendarView::todoModified (Todo *event, int changed) | 3475 | // void CalendarView::todoModified (Todo *event, int changed) |
3410 | // { | 3476 | // { |
3411 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3477 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3412 | // // kdDebug() << "Todo modified and open" << endl; | 3478 | // // kdDebug() << "Todo modified and open" << endl; |
3413 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3479 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3414 | // // temp->modified (changed); | 3480 | // // temp->modified (changed); |
3415 | 3481 | ||
3416 | // // } | 3482 | // // } |
3417 | 3483 | ||
3418 | // mViewManager->updateView(); | 3484 | // mViewManager->updateView(); |
3419 | // } | 3485 | // } |
3420 | 3486 | ||
3421 | void CalendarView::appointment_show() | 3487 | void CalendarView::appointment_show() |
3422 | { | 3488 | { |
3423 | Event *anEvent = 0; | 3489 | Event *anEvent = 0; |
3424 | 3490 | ||
3425 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3491 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3426 | 3492 | ||
3427 | if (mViewManager->currentView()->isEventView()) { | 3493 | if (mViewManager->currentView()->isEventView()) { |
3428 | if ( incidence && incidence->typeID() == eventID ) { | 3494 | if ( incidence && incidence->typeID() == eventID ) { |
3429 | anEvent = static_cast<Event *>(incidence); | 3495 | anEvent = static_cast<Event *>(incidence); |
3430 | } | 3496 | } |
3431 | } | 3497 | } |
3432 | 3498 | ||
3433 | if (!anEvent) { | 3499 | if (!anEvent) { |
3434 | KNotifyClient::beep(); | 3500 | KNotifyClient::beep(); |
3435 | return; | 3501 | return; |
3436 | } | 3502 | } |
3437 | 3503 | ||
3438 | showEvent(anEvent); | 3504 | showEvent(anEvent); |
3439 | } | 3505 | } |
3440 | 3506 | ||
3441 | void CalendarView::appointment_edit() | 3507 | void CalendarView::appointment_edit() |
3442 | { | 3508 | { |
3443 | Event *anEvent = 0; | 3509 | Event *anEvent = 0; |
3444 | 3510 | ||
3445 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3511 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3446 | 3512 | ||
3447 | if (mViewManager->currentView()->isEventView()) { | 3513 | if (mViewManager->currentView()->isEventView()) { |
3448 | if ( incidence && incidence->typeID() == eventID ) { | 3514 | if ( incidence && incidence->typeID() == eventID ) { |
3449 | anEvent = static_cast<Event *>(incidence); | 3515 | anEvent = static_cast<Event *>(incidence); |
3450 | } | 3516 | } |
3451 | } | 3517 | } |
3452 | 3518 | ||
3453 | if (!anEvent) { | 3519 | if (!anEvent) { |
3454 | KNotifyClient::beep(); | 3520 | KNotifyClient::beep(); |
3455 | return; | 3521 | return; |
3456 | } | 3522 | } |
3457 | 3523 | ||
3458 | editEvent(anEvent); | 3524 | editEvent(anEvent); |
3459 | } | 3525 | } |
3460 | 3526 | ||
3461 | void CalendarView::appointment_delete() | 3527 | void CalendarView::appointment_delete() |
3462 | { | 3528 | { |
3463 | Event *anEvent = 0; | 3529 | Event *anEvent = 0; |
3464 | 3530 | ||
3465 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3531 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3466 | 3532 | ||
3467 | if (mViewManager->currentView()->isEventView()) { | 3533 | if (mViewManager->currentView()->isEventView()) { |
3468 | if ( incidence && incidence->typeID() == eventID ) { | 3534 | if ( incidence && incidence->typeID() == eventID ) { |
3469 | anEvent = static_cast<Event *>(incidence); | 3535 | anEvent = static_cast<Event *>(incidence); |
3470 | } | 3536 | } |
3471 | } | 3537 | } |
3472 | 3538 | ||
3473 | if (!anEvent) { | 3539 | if (!anEvent) { |
3474 | KNotifyClient::beep(); | 3540 | KNotifyClient::beep(); |
3475 | return; | 3541 | return; |
3476 | } | 3542 | } |
3477 | 3543 | ||
3478 | deleteEvent(anEvent); | 3544 | deleteEvent(anEvent); |
3479 | } | 3545 | } |
3480 | 3546 | ||
3481 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3547 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3482 | { | 3548 | { |
3483 | if (!sub) return; | 3549 | if (!sub) return; |
3484 | if ( sub->relatedTo() == parent ) | 3550 | if ( sub->relatedTo() == parent ) |
3485 | return; | 3551 | return; |
3486 | sub->setRelatedTo(parent); | 3552 | sub->setRelatedTo(parent); |
3487 | sub->updated(); | 3553 | sub->updated(); |
3488 | setModified(true); | 3554 | setModified(true); |
3489 | updateView(); | 3555 | updateView(); |
3490 | } | 3556 | } |
3491 | void CalendarView::todo_unsub(Todo *anTodo ) | 3557 | void CalendarView::todo_unsub(Todo *anTodo ) |
3492 | { | 3558 | { |
3493 | todo_resub( 0, anTodo ); | 3559 | todo_resub( 0, anTodo ); |
3494 | } | 3560 | } |
3495 | 3561 | ||
3496 | void CalendarView::deleteTodo(Todo *todo) | 3562 | void CalendarView::deleteTodo(Todo *todo) |
3497 | { | 3563 | { |
3498 | if (!todo) { | 3564 | if (!todo) { |
3499 | KNotifyClient::beep(); | 3565 | KNotifyClient::beep(); |
3500 | return; | 3566 | return; |
3501 | } | 3567 | } |
3502 | if (KOPrefs::instance()->mConfirm) { | 3568 | if (KOPrefs::instance()->mConfirm) { |
3503 | QString text = todo->summary().left(20); | 3569 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); |
3504 | if (!todo->relations().isEmpty()) { | 3570 | if (!todo->relations().isEmpty()) { |
3505 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3571 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3506 | 3572 | ||
3507 | } | 3573 | } |
3508 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { | 3574 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { |
3509 | case KMessageBox::Continue: // OK | 3575 | case KMessageBox::Continue: // OK |
3510 | bool deleteT = false; | 3576 | bool deleteT = false; |
3511 | if (!todo->relations().isEmpty()) { | 3577 | if (!todo->relations().isEmpty()) { |
3512 | deleteT = removeCompletedSubTodos( todo ); | 3578 | deleteT = removeCompletedSubTodos( todo ); |
3513 | } | 3579 | } |
3514 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3580 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3515 | if ( !deleteT ) { | 3581 | if ( !deleteT ) { |
3516 | checkExternalId( todo ); | 3582 | checkExternalId( todo ); |
3517 | calendar()->deleteTodo(todo); | 3583 | calendar()->deleteTodo(todo); |
3518 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3584 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3519 | updateView(); | 3585 | updateView(); |
3520 | } | 3586 | } |
3521 | break; | 3587 | break; |
3522 | } // switch | 3588 | } // switch |
3523 | } else { | 3589 | } else { |
3524 | checkExternalId( todo ); | 3590 | checkExternalId( todo ); |
3525 | mCalendar->deleteTodo(todo); | 3591 | mCalendar->deleteTodo(todo); |
3526 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3592 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3527 | updateView(); | 3593 | updateView(); |
3528 | } | 3594 | } |
3529 | 3595 | ||
3530 | emit updateSearchDialog(); | 3596 | emit updateSearchDialog(); |
3531 | } | 3597 | } |
3532 | void CalendarView::deleteJournal(Journal *jour) | 3598 | void CalendarView::deleteJournal(Journal *jour) |
3533 | { | 3599 | { |
3534 | if (!jour) { | 3600 | if (!jour) { |
3535 | KNotifyClient::beep(); | 3601 | KNotifyClient::beep(); |
3536 | return; | 3602 | return; |
3537 | } | 3603 | } |
3538 | if (KOPrefs::instance()->mConfirm) { | 3604 | if (KOPrefs::instance()->mConfirm) { |
3539 | 3605 | ||
3540 | QString des; | 3606 | QString des; |
3541 | if ( !jour->summary().isEmpty() ) { | 3607 | if ( !jour->summary().isEmpty() ) { |
3542 | des = jour->summary(); | 3608 | des = jour->summary(); |
3543 | } else { | 3609 | } else { |
3544 | des = jour->description().left(30); | 3610 | des = jour->description().left(30); |
3545 | des = des.simplifyWhiteSpace (); | 3611 | des = des.simplifyWhiteSpace (); |
3546 | des.replace (QRegExp ("\\n"),"" ); | 3612 | des.replace (QRegExp ("\\n"),"" ); |
3547 | des.replace (QRegExp ("\\r"),"" ); | 3613 | des.replace (QRegExp ("\\r"),"" ); |
3548 | } | 3614 | } |
3549 | switch (msgItemDelete( i18n("Journal:") +"\n"+des.left(20))) { | 3615 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
3550 | case KMessageBox::Continue: // OK | 3616 | case KMessageBox::Continue: // OK |
3551 | calendar()->deleteJournal(jour); | 3617 | calendar()->deleteJournal(jour); |
3552 | updateView(); | 3618 | updateView(); |
3553 | break; | 3619 | break; |
3554 | } // switch | 3620 | } // switch |
3555 | } else { | 3621 | } else { |
3556 | calendar()->deleteJournal(jour);; | 3622 | calendar()->deleteJournal(jour);; |
3557 | updateView(); | 3623 | updateView(); |
3558 | } | 3624 | } |
3559 | emit updateSearchDialog(); | 3625 | emit updateSearchDialog(); |
3560 | } | 3626 | } |
3561 | 3627 | ||
3562 | void CalendarView::deleteEvent(Event *anEvent) | 3628 | void CalendarView::deleteEvent(Event *anEvent) |
3563 | { | 3629 | { |
3564 | if (!anEvent) { | 3630 | if (!anEvent) { |
3565 | KNotifyClient::beep(); | 3631 | KNotifyClient::beep(); |
3566 | return; | 3632 | return; |
3567 | } | 3633 | } |
3568 | 3634 | ||
3569 | if (anEvent->recurrence()->doesRecur()) { | 3635 | if (anEvent->recurrence()->doesRecur()) { |
3570 | QDate itemDate = mViewManager->currentSelectionDate(); | 3636 | QDate itemDate = mViewManager->currentSelectionDate(); |
3571 | int km; | 3637 | int km; |
3572 | if (!itemDate.isValid()) { | 3638 | if (!itemDate.isValid()) { |
3573 | //kdDebug() << "Date Not Valid" << endl; | 3639 | //kdDebug() << "Date Not Valid" << endl; |
3574 | if (KOPrefs::instance()->mConfirm) { | 3640 | if (KOPrefs::instance()->mConfirm) { |
3575 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3641 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3576 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3642 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3577 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3643 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3578 | if ( km == KMessageBox::Continue ) | 3644 | if ( km == KMessageBox::Continue ) |
3579 | km = KMessageBox::No; // No = all below | 3645 | km = KMessageBox::No; // No = all below |
3580 | } else | 3646 | } else |
3581 | km = KMessageBox::No; | 3647 | km = KMessageBox::No; |
3582 | } else { | 3648 | } else { |
3583 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 3649 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3584 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3650 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3585 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3651 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3586 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3652 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3587 | i18n("All")); | 3653 | i18n("All")); |
3588 | } | 3654 | } |
3589 | switch(km) { | 3655 | switch(km) { |
3590 | 3656 | ||
3591 | case KMessageBox::No: // Continue // all | 3657 | case KMessageBox::No: // Continue // all |
3592 | //qDebug("KMessageBox::No "); | 3658 | //qDebug("KMessageBox::No "); |
3593 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3659 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3594 | schedule(Scheduler::Cancel,anEvent); | 3660 | schedule(Scheduler::Cancel,anEvent); |
3595 | 3661 | ||
3596 | checkExternalId( anEvent); | 3662 | checkExternalId( anEvent); |
3597 | mCalendar->deleteEvent(anEvent); | 3663 | mCalendar->deleteEvent(anEvent); |
3598 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3664 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3599 | break; | 3665 | break; |
3600 | 3666 | ||
3601 | // Disabled because it does not work | 3667 | // Disabled because it does not work |
3602 | //#if 0 | 3668 | //#if 0 |
3603 | case KMessageBox::Yes: // just this one | 3669 | case KMessageBox::Yes: // just this one |
3604 | //QDate qd = mNavigator->selectedDates().first(); | 3670 | //QDate qd = mNavigator->selectedDates().first(); |
3605 | //if (!qd.isValid()) { | 3671 | //if (!qd.isValid()) { |
3606 | // kdDebug() << "no date selected, or invalid date" << endl; | 3672 | // kdDebug() << "no date selected, or invalid date" << endl; |
3607 | // KNotifyClient::beep(); | 3673 | // KNotifyClient::beep(); |
3608 | // return; | 3674 | // return; |
3609 | //} | 3675 | //} |
3610 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3676 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3611 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3677 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3612 | anEvent->addExDate(itemDate); | 3678 | anEvent->addExDate(itemDate); |
3613 | int duration = anEvent->recurrence()->duration(); | 3679 | int duration = anEvent->recurrence()->duration(); |
3614 | if ( duration > 0 ) { | 3680 | if ( duration > 0 ) { |
3615 | anEvent->recurrence()->setDuration( duration - 1 ); | 3681 | anEvent->recurrence()->setDuration( duration - 1 ); |
3616 | } | 3682 | } |
3617 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3683 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3618 | } | 3684 | } |
3619 | break; | 3685 | break; |
3620 | //#endif | 3686 | //#endif |
3621 | } // switch | 3687 | } // switch |
3622 | } else { | 3688 | } else { |
3623 | if (KOPrefs::instance()->mConfirm) { | 3689 | if (KOPrefs::instance()->mConfirm) { |
3624 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3690 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3625 | i18n("\nAre you sure you want\nto delete this event?"), | 3691 | i18n("\nAre you sure you want\nto delete this event?"), |
3626 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3692 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3627 | case KMessageBox::Continue: // OK | 3693 | case KMessageBox::Continue: // OK |
3628 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3694 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3629 | schedule(Scheduler::Cancel,anEvent); | 3695 | schedule(Scheduler::Cancel,anEvent); |
3630 | checkExternalId( anEvent); | 3696 | checkExternalId( anEvent); |
3631 | mCalendar->deleteEvent(anEvent); | 3697 | mCalendar->deleteEvent(anEvent); |
3632 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3698 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3633 | break; | 3699 | break; |
3634 | } // switch | 3700 | } // switch |
3635 | } else { | 3701 | } else { |
3636 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3702 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3637 | schedule(Scheduler::Cancel,anEvent); | 3703 | schedule(Scheduler::Cancel,anEvent); |
3638 | checkExternalId( anEvent); | 3704 | checkExternalId( anEvent); |
3639 | mCalendar->deleteEvent(anEvent); | 3705 | mCalendar->deleteEvent(anEvent); |
3640 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3706 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3641 | } | 3707 | } |
3642 | } // if-else | 3708 | } // if-else |
3643 | emit updateSearchDialog(); | 3709 | emit updateSearchDialog(); |
3644 | } | 3710 | } |
3645 | 3711 | ||
3646 | bool CalendarView::deleteEvent(const QString &uid) | 3712 | bool CalendarView::deleteEvent(const QString &uid) |
3647 | { | 3713 | { |
3648 | Event *ev = mCalendar->event(uid); | 3714 | Event *ev = mCalendar->event(uid); |
3649 | if (ev) { | 3715 | if (ev) { |
3650 | deleteEvent(ev); | 3716 | deleteEvent(ev); |
3651 | return true; | 3717 | return true; |
3652 | } else { | 3718 | } else { |
3653 | return false; | 3719 | return false; |
3654 | } | 3720 | } |
3655 | } | 3721 | } |
3656 | 3722 | ||
3657 | /*****************************************************************************/ | 3723 | /*****************************************************************************/ |
3658 | 3724 | ||
3659 | void CalendarView::action_mail() | 3725 | void CalendarView::action_mail() |
3660 | { | 3726 | { |
3661 | #ifndef KORG_NOMAIL | 3727 | #ifndef KORG_NOMAIL |
3662 | KOMailClient mailClient; | 3728 | KOMailClient mailClient; |
3663 | 3729 | ||
3664 | Incidence *incidence = currentSelection(); | 3730 | Incidence *incidence = currentSelection(); |
3665 | 3731 | ||
3666 | if (!incidence) { | 3732 | if (!incidence) { |
3667 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3733 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3668 | return; | 3734 | return; |
3669 | } | 3735 | } |
3670 | if(incidence->attendeeCount() == 0 ) { | 3736 | if(incidence->attendeeCount() == 0 ) { |
3671 | KMessageBox::sorry(this, | 3737 | KMessageBox::sorry(this, |
3672 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3738 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3673 | return; | 3739 | return; |
3674 | } | 3740 | } |
3675 | 3741 | ||
3676 | CalendarLocal cal_tmp; | 3742 | CalendarLocal cal_tmp; |
3677 | Event *event = 0; | 3743 | Event *event = 0; |
3678 | Event *ev = 0; | 3744 | Event *ev = 0; |
3679 | if ( incidence && incidence->typeID() == eventID ) { | 3745 | if ( incidence && incidence->typeID() == eventID ) { |
3680 | event = static_cast<Event *>(incidence); | 3746 | event = static_cast<Event *>(incidence); |
3681 | ev = new Event(*event); | 3747 | ev = new Event(*event); |
3682 | cal_tmp.addEvent(ev); | 3748 | cal_tmp.addEvent(ev); |
3683 | } | 3749 | } |
3684 | ICalFormat mForm(); | 3750 | ICalFormat mForm(); |
3685 | QString attachment = mForm.toString( &cal_tmp ); | 3751 | QString attachment = mForm.toString( &cal_tmp ); |
3686 | if (ev) delete(ev); | 3752 | if (ev) delete(ev); |
3687 | 3753 | ||
3688 | mailClient.mailAttendees(currentSelection(), attachment); | 3754 | mailClient.mailAttendees(currentSelection(), attachment); |
3689 | 3755 | ||
3690 | #endif | 3756 | #endif |
3691 | 3757 | ||
3692 | #if 0 | 3758 | #if 0 |
3693 | Event *anEvent = 0; | 3759 | Event *anEvent = 0; |
3694 | if (mViewManager->currentView()->isEventView()) { | 3760 | if (mViewManager->currentView()->isEventView()) { |
3695 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3761 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3696 | } | 3762 | } |
3697 | 3763 | ||
3698 | if (!anEvent) { | 3764 | if (!anEvent) { |
3699 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3765 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3700 | return; | 3766 | return; |
3701 | } | 3767 | } |
3702 | if(anEvent->attendeeCount() == 0 ) { | 3768 | if(anEvent->attendeeCount() == 0 ) { |
3703 | KMessageBox::sorry(this, | 3769 | KMessageBox::sorry(this, |
3704 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3770 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3705 | return; | 3771 | return; |
3706 | } | 3772 | } |
3707 | 3773 | ||
3708 | mailobject.emailEvent(anEvent); | 3774 | mailobject.emailEvent(anEvent); |
3709 | #endif | 3775 | #endif |
3710 | } | 3776 | } |
3711 | 3777 | ||
3712 | 3778 | ||
3713 | void CalendarView::schedule_publish(Incidence *incidence) | 3779 | void CalendarView::schedule_publish(Incidence *incidence) |
3714 | { | 3780 | { |
3715 | Event *event = 0; | 3781 | Event *event = 0; |
3716 | Todo *todo = 0; | 3782 | Todo *todo = 0; |
3717 | 3783 | ||
3718 | if (incidence == 0) { | 3784 | if (incidence == 0) { |
3719 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3785 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3720 | if (incidence == 0) { | 3786 | if (incidence == 0) { |
@@ -4487,175 +4553,175 @@ bool CalendarView::removeCompletedSubTodos( Todo* t ) | |||
4487 | } | 4553 | } |
4488 | if ( deleteTodo ) { | 4554 | if ( deleteTodo ) { |
4489 | if ( t->isCompleted() && !t->doesRecur()) { | 4555 | if ( t->isCompleted() && !t->doesRecur()) { |
4490 | checkExternalId( t ); | 4556 | checkExternalId( t ); |
4491 | mCalendar->deleteTodo( t ); | 4557 | mCalendar->deleteTodo( t ); |
4492 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 4558 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4493 | } | 4559 | } |
4494 | else | 4560 | else |
4495 | deleteTodo = false; | 4561 | deleteTodo = false; |
4496 | } | 4562 | } |
4497 | return deleteTodo; | 4563 | return deleteTodo; |
4498 | 4564 | ||
4499 | } | 4565 | } |
4500 | void CalendarView::purgeCompleted() | 4566 | void CalendarView::purgeCompleted() |
4501 | { | 4567 | { |
4502 | int result = KMessageBox::warningContinueCancel(this, | 4568 | int result = KMessageBox::warningContinueCancel(this, |
4503 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 4569 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
4504 | 4570 | ||
4505 | if (result == KMessageBox::Continue) { | 4571 | if (result == KMessageBox::Continue) { |
4506 | 4572 | ||
4507 | QPtrList<Todo> todoCal; | 4573 | QPtrList<Todo> todoCal; |
4508 | QPtrList<Todo> rootTodos; | 4574 | QPtrList<Todo> rootTodos; |
4509 | //QPtrList<Incidence> rel; | 4575 | //QPtrList<Incidence> rel; |
4510 | Todo *aTodo; | 4576 | Todo *aTodo; |
4511 | todoCal = calendar()->todos(); | 4577 | todoCal = calendar()->todos(); |
4512 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 4578 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
4513 | if ( !aTodo->relatedTo() ) | 4579 | if ( !aTodo->relatedTo() ) |
4514 | rootTodos.append( aTodo ); | 4580 | rootTodos.append( aTodo ); |
4515 | } | 4581 | } |
4516 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 4582 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
4517 | removeCompletedSubTodos( aTodo ); | 4583 | removeCompletedSubTodos( aTodo ); |
4518 | } | 4584 | } |
4519 | 4585 | ||
4520 | updateView(); | 4586 | updateView(); |
4521 | } | 4587 | } |
4522 | } | 4588 | } |
4523 | 4589 | ||
4524 | void CalendarView::slotCalendarChanged() | 4590 | void CalendarView::slotCalendarChanged() |
4525 | { | 4591 | { |
4526 | ; | 4592 | ; |
4527 | } | 4593 | } |
4528 | 4594 | ||
4529 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 4595 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
4530 | { | 4596 | { |
4531 | //qDebug(" alendarView::keyPressEvent "); | 4597 | //qDebug(" alendarView::keyPressEvent "); |
4532 | e->ignore(); | 4598 | e->ignore(); |
4533 | } | 4599 | } |
4534 | 4600 | ||
4535 | 4601 | ||
4536 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 4602 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
4537 | { | 4603 | { |
4538 | 4604 | ||
4539 | if ( manager != mSyncManager) | 4605 | if ( manager != mSyncManager) |
4540 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 4606 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
4541 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 4607 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
4542 | qDebug("KO: SyncKDE request detected!"); | 4608 | qDebug("KO: SyncKDE request detected!"); |
4543 | } | 4609 | } |
4544 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4610 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4545 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4611 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4546 | return syncCalendar( filename, mode ); | 4612 | return syncCalendar( filename, mode ); |
4547 | } | 4613 | } |
4548 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 4614 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
4549 | { | 4615 | { |
4550 | //mSyncManager = manager; | 4616 | //mSyncManager = manager; |
4551 | if ( manager != mSyncManager) | 4617 | if ( manager != mSyncManager) |
4552 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 4618 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
4553 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 4619 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
4554 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 4620 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
4555 | if ( resource == "sharp" ) | 4621 | if ( resource == "sharp" ) |
4556 | syncExternal( 0 ); | 4622 | syncExternal( 0 ); |
4557 | if ( resource == "phone" ) | 4623 | if ( resource == "phone" ) |
4558 | syncExternal( 1 ); | 4624 | syncExternal( 1 ); |
4559 | // pending setmodified | 4625 | // pending setmodified |
4560 | return true; | 4626 | return true; |
4561 | } | 4627 | } |
4562 | void CalendarView::setSyncManager(KSyncManager* manager) | 4628 | void CalendarView::setSyncManager(KSyncManager* manager) |
4563 | { | 4629 | { |
4564 | mSyncManager = manager; | 4630 | mSyncManager = manager; |
4565 | } | 4631 | } |
4566 | 4632 | ||
4567 | void CalendarView::removeSyncInfo( QString syncProfile) | 4633 | void CalendarView::removeSyncInfo( QString syncProfile) |
4568 | { | 4634 | { |
4569 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 4635 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
4570 | mCalendar->removeSyncInfo( syncProfile ); | 4636 | mCalendar->removeSyncInfo( syncProfile ); |
4571 | 4637 | ||
4572 | } | 4638 | } |
4573 | 4639 | ||
4574 | void CalendarView::undo_delete() | 4640 | void CalendarView::undo_delete() |
4575 | { | 4641 | { |
4576 | //qDebug("undo_delete() "); | 4642 | //qDebug("undo_delete() "); |
4577 | Incidence* undo = mCalendar->undoIncidence(); | 4643 | Incidence* undo = mCalendar->undoIncidence(); |
4578 | if ( !undo ) { | 4644 | if ( !undo ) { |
4579 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 4645 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
4580 | i18n("KO/Pi")); | 4646 | i18n("KO/Pi")); |
4581 | return; | 4647 | return; |
4582 | } | 4648 | } |
4583 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 4649 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + |
4584 | i18n("\nAre you sure you want\nto restore this?"), | 4650 | i18n("\nAre you sure you want\nto restore this?"), |
4585 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 4651 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
4586 | mCalendar->undoDeleteIncidence(); | 4652 | mCalendar->undoDeleteIncidence(); |
4587 | updateView(); | 4653 | updateView(); |
4588 | } | 4654 | } |
4589 | } | 4655 | } |
4590 | 4656 | ||
4591 | void CalendarView::slotViewerClosed() | 4657 | void CalendarView::slotViewerClosed() |
4592 | { | 4658 | { |
4593 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 4659 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
4594 | } | 4660 | } |
4595 | 4661 | ||
4596 | void CalendarView::resetFocus() | 4662 | void CalendarView::resetFocus() |
4597 | { | 4663 | { |
4598 | if ( mViewerCallerIsSearchDialog ) { | 4664 | if ( mViewerCallerIsSearchDialog ) { |
4599 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 4665 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
4600 | mDialogManager->getSearchDialog()->raise(); | 4666 | mDialogManager->getSearchDialog()->raise(); |
4601 | mDialogManager->getSearchDialog()->setActiveWindow(); | 4667 | mDialogManager->getSearchDialog()->setActiveWindow(); |
4602 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 4668 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
4603 | } else | 4669 | } else |
4604 | mViewerCallerIsSearchDialog = false; | 4670 | mViewerCallerIsSearchDialog = false; |
4605 | } | 4671 | } |
4606 | if ( !mViewerCallerIsSearchDialog ) { | 4672 | if ( !mViewerCallerIsSearchDialog ) { |
4607 | //mViewManager->currentView()->setFocus(); | 4673 | //mViewManager->currentView()->setFocus(); |
4608 | //qDebug("sssssssssssssssset focus "); | 4674 | //qDebug("sssssssssssssssset focus "); |
4609 | topLevelWidget()->raise(); | 4675 | topLevelWidget()->raise(); |
4610 | setActiveWindow(); | 4676 | setActiveWindow(); |
4611 | //setFocus(); | 4677 | //setFocus(); |
4612 | } | 4678 | } |
4613 | mViewerCallerIsSearchDialog = false; | 4679 | mViewerCallerIsSearchDialog = false; |
4614 | } | 4680 | } |
4615 | 4681 | ||
4616 | void CalendarView::showNextAlarms() | 4682 | void CalendarView::showNextAlarms() |
4617 | { | 4683 | { |
4618 | QString message; | 4684 | QString message; |
4619 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); | 4685 | QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); |
4620 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { | 4686 | if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { |
4621 | QString sum = mCalendar->nextSummary(); | 4687 | QString sum = mCalendar->nextSummary(); |
4622 | QDateTime nextA = mNextAlarmDateTime; | 4688 | QDateTime nextA = mNextAlarmDateTime; |
4623 | QDateTime cur = QDateTime::currentDateTime(); | 4689 | QDateTime cur = QDateTime::currentDateTime(); |
4624 | int secs = cur.secsTo( nextA ); | 4690 | int secs = cur.secsTo( nextA ); |
4625 | int min = secs /60; | 4691 | int min = secs /60; |
4626 | int hours = min /60; | 4692 | int hours = min /60; |
4627 | min = min % 60; | 4693 | min = min % 60; |
4628 | int days = hours /24; | 4694 | int days = hours /24; |
4629 | hours = hours % 24; | 4695 | hours = hours % 24; |
4630 | 4696 | ||
4631 | //message = i18n("The next alarm is in:\n"); | 4697 | //message = i18n("The next alarm is in:\n"); |
4632 | if ( days > 1 ) | 4698 | if ( days > 1 ) |
4633 | message += i18n("%1 days\n").arg( days ); | 4699 | message += i18n("%1 days\n").arg( days ); |
4634 | else if ( days == 1 ) | 4700 | else if ( days == 1 ) |
4635 | message += i18n("1 day\n"); | 4701 | message += i18n("1 day\n"); |
4636 | if ( hours > 1 ) | 4702 | if ( hours > 1 ) |
4637 | message += i18n("%1 hours\n").arg( hours ); | 4703 | message += i18n("%1 hours\n").arg( hours ); |
4638 | else if ( hours == 1 ) | 4704 | else if ( hours == 1 ) |
4639 | message += i18n("1 hour\n"); | 4705 | message += i18n("1 hour\n"); |
4640 | if ( min > 1 ) | 4706 | if ( min > 1 ) |
4641 | message += i18n("%1 minutes\n").arg( min ); | 4707 | message += i18n("%1 minutes\n").arg( min ); |
4642 | else if ( min == 1 ) | 4708 | else if ( min == 1 ) |
4643 | message += i18n("1 minute\n"); | 4709 | message += i18n("1 minute\n"); |
4644 | if ( message.isEmpty() ) | 4710 | if ( message.isEmpty() ) |
4645 | message = i18n("The next alarm is in\nless than one minute!"); | 4711 | message = i18n("The next alarm is in\nless than one minute!"); |
4646 | else | 4712 | else |
4647 | message = i18n("The next alarm is in:\n") + message; | 4713 | message = i18n("The next alarm is in:\n") + message; |
4648 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; | 4714 | message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; |
4649 | } else { | 4715 | } else { |
4650 | message = i18n("There is no next alarm."); | 4716 | message = i18n("There is no next alarm."); |
4651 | 4717 | ||
4652 | } | 4718 | } |
4653 | #ifdef DESKTOP_VERSION | 4719 | #ifdef DESKTOP_VERSION |
4654 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 4720 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
4655 | message += i18n("\nThe internal alarm notification is disabled!\n"); | 4721 | message += i18n("\nThe internal alarm notification is disabled!\n"); |
4656 | message += i18n("Enable it in the settings menu, TAB alarm."); | 4722 | message += i18n("Enable it in the settings menu, TAB alarm."); |
4657 | } | 4723 | } |
4658 | 4724 | ||
4659 | #endif | 4725 | #endif |
4660 | KMessageBox::information( this, message); | 4726 | KMessageBox::information( this, message); |
4661 | } | 4727 | } |