summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp7
-rw-r--r--korganizer/kofilterview.cpp10
2 files changed, 11 insertions, 6 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 9674921..3ab4bb4 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -650,193 +650,193 @@ CalendarView::~CalendarView()
650 //qDebug("CalendarView::~CalendarView() "); 650 //qDebug("CalendarView::~CalendarView() ");
651 delete mDialogManager; 651 delete mDialogManager;
652 delete mViewManager; 652 delete mViewManager;
653 delete mStorage; 653 delete mStorage;
654 delete mDateFrame ; 654 delete mDateFrame ;
655 delete mEventViewerDialog; 655 delete mEventViewerDialog;
656 //kdDebug() << "~CalendarView() done" << endl; 656 //kdDebug() << "~CalendarView() done" << endl;
657} 657}
658 658
659 659
660void CalendarView::nextConflict( bool all, bool allday ) 660void CalendarView::nextConflict( bool all, bool allday )
661{ 661{
662 static bool block = false; 662 static bool block = false;
663 if ( block ) return; 663 if ( block ) return;
664 block = true; 664 block = true;
665 QPtrList<Event> testlist = mCalendar->events(); 665 QPtrList<Event> testlist = mCalendar->events();
666 Event * test = testlist.first(); 666 Event * test = testlist.first();
667 while ( test ) { 667 while ( test ) {
668 test->setTagged( false ); 668 test->setTagged( false );
669 test = testlist.next(); 669 test = testlist.next();
670 } 670 }
671 QTime st ( 0,0,0); 671 QTime st ( 0,0,0);
672 if ( mViewManager->currentView() == mViewManager->agendaView() ) 672 if ( mViewManager->currentView() == mViewManager->agendaView() )
673 st = mViewManager->agendaView()->agenda()->getEndTime(); 673 st = mViewManager->agendaView()->agenda()->getEndTime();
674 //qDebug("time %s ", st.toString().latin1()); 674 //qDebug("time %s ", st.toString().latin1());
675 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); 675 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st);
676 QDateTime conflict; 676 QDateTime conflict;
677 QDateTime retVal; 677 QDateTime retVal;
678 bool found = false; 678 bool found = false;
679 Event * cE = 0; 679 Event * cE = 0;
680 Event * cE2 = 0; 680 Event * cE2 = 0;
681 QPtrList<Event> testlist2 = testlist; 681 QPtrList<Event> testlist2 = testlist;
682 test = testlist.first(); 682 test = testlist.first();
683 bool skip = false; 683 bool skip = false;
684 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 684 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
685 //QTime tm; 685 //QTime tm;
686 //tm.start(); 686 //tm.start();
687 while ( test ) { 687 while ( test ) {
688 qApp->processEvents(); 688 qApp->processEvents();
689 skip = false; 689 skip = false;
690 if ( !all ) skip = ( allday != test->doesFloat() ); 690 if ( !all ) skip = ( allday != test->doesFloat() );
691 if ( !skip ) { 691 if ( !skip ) {
692 if ( found ) 692 if ( found )
693 skip = !test->matchTime( &startDT, &conflict ); 693 skip = !test->matchTime( &startDT, &conflict );
694 else 694 else
695 skip = !test->matchTime( &startDT, 0 ); 695 skip = !test->matchTime( &startDT, 0 );
696 } 696 }
697 if ( !skip ) { 697 if ( !skip ) {
698 Event * test2 = testlist2.first(); 698 Event * test2 = testlist2.first();
699 while ( test2 ) { 699 while ( test2 ) {
700 skip = test2->isTagged(); 700 skip = test2->isTagged();
701 if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); 701 if ( !skip && !all ) skip = ( allday != test2->doesFloat() );
702 if ( !skip ) { 702 if ( !skip ) {
703 if ( found ) 703 if ( found )
704 skip = !test2->matchTime( &startDT, &conflict ); 704 skip = !test2->matchTime( &startDT, &conflict );
705 else 705 else
706 skip = !test2->matchTime( &startDT, 0 ); 706 skip = !test2->matchTime( &startDT, 0 );
707 } 707 }
708 if ( !skip ) { 708 if ( !skip ) {
709 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { 709 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) {
710 //qDebug("overlap "); 710 //qDebug("overlap ");
711 if ( ! found ) { 711 if ( ! found ) {
712 if ( retVal >= startDT ) { 712 if ( retVal >= startDT ) {
713 conflict = retVal; 713 conflict = retVal;
714 cE = test; 714 cE = test;
715 cE2 = test2; 715 cE2 = test2;
716 found = true; 716 found = true;
717 } 717 }
718 } else { 718 } else {
719 if ( retVal >= startDT && retVal < conflict ) { 719 if ( retVal >= startDT && retVal < conflict ) {
720 conflict = retVal; 720 conflict = retVal;
721 cE = test; 721 cE = test;
722 cE2 = test2; 722 cE2 = test2;
723 } 723 }
724 } 724 }
725 } 725 }
726 } 726 }
727 test2 = testlist2.next(); 727 test2 = testlist2.next();
728 } 728 }
729 } 729 }
730 test->setTagged( true ); 730 test->setTagged( true );
731 test = testlist.next(); 731 test = testlist.next();
732 } 732 }
733 //qDebug("Search time : %d", tm.elapsed()); 733 //qDebug("Search time : %d", tm.elapsed());
734 if ( found ) { 734 if ( found ) {
735 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 735 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
736 mViewManager->showDayView(); 736 mViewManager->showDayView();
737 mNavigator->slotDaySelect( conflict.date() ); 737 mNavigator->slotDaySelect( conflict.date() );
738 int hour = conflict.time().hour(); 738 int hour = conflict.time().hour();
739 mViewManager->agendaView()->setStartHour( hour ); 739 mViewManager->agendaView()->setStartHour( hour );
740 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); 740 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) );
741 block = false; 741 block = false;
742 return; 742 return;
743 } 743 }
744 744
745 topLevelWidget()->setCaption( i18n("No conflict found") ); 745 topLevelWidget()->setCaption( i18n("No conflict found") );
746 qDebug("No conflict found "); 746 //qDebug("No conflict found ");
747 block = false; 747 block = false;
748 return; 748 return;
749} 749}
750 750
751void CalendarView::conflictAll() 751void CalendarView::conflictAll()
752{ 752{
753 nextConflict ( true, true ); 753 nextConflict ( true, true );
754} 754}
755void CalendarView::conflictAllday() 755void CalendarView::conflictAllday()
756{ 756{
757 nextConflict ( false, true ); 757 nextConflict ( false, true );
758} 758}
759void CalendarView::conflictNotAll() 759void CalendarView::conflictNotAll()
760{ 760{
761 nextConflict ( false, false ); 761 nextConflict ( false, false );
762} 762}
763 763
764void CalendarView::setCalReadOnly( int id, bool readO ) 764void CalendarView::setCalReadOnly( int id, bool readO )
765{ 765{
766 if ( readO ) { 766 if ( readO ) {
767 emit save(); 767 emit save();
768 } 768 }
769 mCalendar->setReadOnly( id, readO ); 769 mCalendar->setReadOnly( id, readO );
770} 770}
771void CalendarView::setScrollBarStep(int val ) 771void CalendarView::setScrollBarStep(int val )
772{ 772{
773#ifdef DESKTOP_VERSION 773#ifdef DESKTOP_VERSION
774 mDateScrollBar->setLineStep ( val ); 774 mDateScrollBar->setLineStep ( val );
775#endif 775#endif
776} 776}
777void CalendarView::scrollBarValue(int val ) 777void CalendarView::scrollBarValue(int val )
778{ 778{
779#ifdef DESKTOP_VERSION 779#ifdef DESKTOP_VERSION
780 if ( QApplication::desktop()->width() < 800 ) return; 780 if ( QApplication::desktop()->width() < 800 ) return;
781 static bool block = false; 781 static bool block = false;
782 if ( block ) return; 782 if ( block ) return;
783 block = true; 783 block = true;
784 int count = mNavigator->selectedDates().count(); 784 int count = mNavigator->selectedDates().count();
785 int day = mNavigator->selectedDates().first().dayOfYear(); 785 int day = mNavigator->selectedDates().first().dayOfYear();
786 int stepdays = val; 786 int stepdays = val;
787 if ( mDateScrollBar->lineStep () <= count ) { 787 if ( mDateScrollBar->lineStep () <= count ) {
788 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 788 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
789 //qDebug("VAL %d ",val ); 789 //qDebug("VAL %d ",val );
790 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 790 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
791 stepdays = day+stepdays; 791 stepdays = day+stepdays;
792 if ( stepdays < 0 ) stepdays = 0; 792 if ( stepdays < 0 ) stepdays = 0;
793 } 793 }
794 if ( stepdays == day ) { 794 if ( stepdays == day ) {
795 block = false; 795 block = false;
796 return; 796 return;
797 } 797 }
798 int year = mNavigator->selectedDates().first().year(); 798 int year = mNavigator->selectedDates().first().year();
799 QDate d ( year,1,1 ); 799 QDate d ( year,1,1 );
800 mNavigator->selectDates( d.addDays( stepdays-1) , count ); 800 mNavigator->selectDates( d.addDays( stepdays-1) , count );
801 block = false; 801 block = false;
802#endif 802#endif
803 803
804} 804}
805void CalendarView::updateView(const QDate &start, const QDate &end) 805void CalendarView::updateView(const QDate &start, const QDate &end)
806{ 806{
807#ifdef DESKTOP_VERSION 807#ifdef DESKTOP_VERSION
808 if ( ! mDateScrollBar->draggingSlider () ) { 808 if ( ! mDateScrollBar->draggingSlider () ) {
809 int dof = start.dayOfYear(); 809 int dof = start.dayOfYear();
810 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); 810 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() );
811 if ( dof != mDateScrollBar->value() ) { 811 if ( dof != mDateScrollBar->value() ) {
812 mDateScrollBar->blockSignals( true ); 812 mDateScrollBar->blockSignals( true );
813 mDateScrollBar->setValue( start.dayOfYear()); 813 mDateScrollBar->setValue( start.dayOfYear());
814 mDateScrollBar->blockSignals( false ); 814 mDateScrollBar->blockSignals( false );
815 } 815 }
816 } 816 }
817#endif 817#endif
818 mTodoList->updateView(); 818 mTodoList->updateView();
819 mViewManager->updateView(start, end); 819 mViewManager->updateView(start, end);
820 //mDateNavigator->updateView(); 820 //mDateNavigator->updateView();
821} 821}
822 822
823 823
824 824
825void CalendarView::checkFiles() 825void CalendarView::checkFiles()
826{ 826{
827 QString message; 827 QString message;
828 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 828 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
829 KopiCalendarFile * cal = calendars.first(); 829 KopiCalendarFile * cal = calendars.first();
830 while ( cal ) { 830 while ( cal ) {
831 if ( cal->mErrorOnLoad ) { 831 if ( cal->mErrorOnLoad ) {
832 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; 832 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n";
833 } 833 }
834 cal = calendars.next(); 834 cal = calendars.next();
835 } 835 }
836 if ( !message.isEmpty() ) { 836 if ( !message.isEmpty() ) {
837 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); 837 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);
838 KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); 838 KMessageBox::error(this,message, i18n("Loding of calendar(s) failed"));
839 } 839 }
840 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); 840 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() ));
841} 841}
842void CalendarView::checkAlarms() 842void CalendarView::checkAlarms()
@@ -2735,200 +2735,201 @@ void CalendarView::changeTodoDisplay(Todo *which, int action)
2735 mViewManager->updateWNview(); 2735 mViewManager->updateWNview();
2736 //mTodoList->updateView(); 2736 //mTodoList->updateView();
2737 } 2737 }
2738 2738
2739} 2739}
2740 2740
2741void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2741void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2742{ 2742{
2743 updateUnmanagedViews(); 2743 updateUnmanagedViews();
2744 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2744 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2745 if ( action == KOGlobals::EVENTDELETED ) { //delete 2745 if ( action == KOGlobals::EVENTDELETED ) { //delete
2746 mCalendar->checkAlarmForIncidence( 0, true ); 2746 mCalendar->checkAlarmForIncidence( 0, true );
2747 if ( mEventViewerDialog ) 2747 if ( mEventViewerDialog )
2748 mEventViewerDialog->hide(); 2748 mEventViewerDialog->hide();
2749 } 2749 }
2750 else 2750 else
2751 mCalendar->checkAlarmForIncidence( which , false ); 2751 mCalendar->checkAlarmForIncidence( which , false );
2752} 2752}
2753 2753
2754// most of the changeEventDisplays() right now just call the view's 2754// most of the changeEventDisplays() right now just call the view's
2755// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2755// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2756void CalendarView::changeEventDisplay(Event *which, int action) 2756void CalendarView::changeEventDisplay(Event *which, int action)
2757{ 2757{
2758 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2758 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2759 changeIncidenceDisplay((Incidence *)which, action); 2759 changeIncidenceDisplay((Incidence *)which, action);
2760 static bool clearallviews = false; 2760 static bool clearallviews = false;
2761 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 2761 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
2762 if ( clearallviews ) { 2762 if ( clearallviews ) {
2763 clearAllViews(); 2763 clearAllViews();
2764 clearallviews = false; 2764 clearallviews = false;
2765 } 2765 }
2766 return; 2766 return;
2767 } 2767 }
2768 clearallviews = true; 2768 clearallviews = true;
2769 mDateNavigator->updateView(); 2769 mDateNavigator->updateView();
2770 //mDialogManager->updateSearchDialog(); 2770 //mDialogManager->updateSearchDialog();
2771 if (which) { 2771 if (which) {
2772 // If there is an event view visible update the display 2772 // If there is an event view visible update the display
2773 mViewManager->currentView()->changeEventDisplay(which,action); 2773 mViewManager->currentView()->changeEventDisplay(which,action);
2774 // TODO: check, if update needed 2774 // TODO: check, if update needed
2775 // if (which->getTodoStatus()) { 2775 // if (which->getTodoStatus()) {
2776 mTodoList->updateView(); 2776 mTodoList->updateView();
2777 if ( action != KOGlobals::EVENTDELETED ) { 2777 if ( action != KOGlobals::EVENTDELETED ) {
2778 mConflictingEvent = which ; 2778 mConflictingEvent = which ;
2779 int time = 1000; 2779 int time = 1000;
2780#ifdef DESKTOP_VERSION 2780#ifdef DESKTOP_VERSION
2781 time = 500; 2781 time = 500;
2782#endif 2782#endif
2783 QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); 2783 QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) );
2784 } 2784 }
2785 // } 2785 // }
2786 } else { 2786 } else {
2787 mViewManager->currentView()->updateView(); 2787 mViewManager->currentView()->updateView();
2788 } 2788 }
2789} 2789}
2790void CalendarView::checkConflictForEvent() 2790void CalendarView::checkConflictForEvent()
2791{ 2791{
2792 2792
2793 if (!KOPrefs::instance()->mConfirm) 2793 if (!KOPrefs::instance()->mConfirm)
2794 return; 2794 return;
2795 if ( ! mConflictingEvent ) return; 2795 if ( ! mConflictingEvent ) return;
2796 QDateTime current = QDateTime::currentDateTime(); 2796 QDateTime current = QDateTime::currentDateTime();
2797 if ( ! mConflictingEvent->matchTime( &current, 0 ) ) { 2797 if ( ! mConflictingEvent->matchTime( &current, 0 ) ) {
2798 mConflictingEvent = 0; 2798 mConflictingEvent = 0;
2799 return; 2799 return;
2800 } 2800 }
2801 QPtrList<Event> testlist = mCalendar->events(); 2801 QPtrList<Event> testlist = mCalendar->events();
2802 Event * test = testlist.first(); 2802 Event * test = testlist.first();
2803 QDateTime conflict; 2803 QDateTime conflict;
2804 QDateTime retVal; 2804 QDateTime retVal;
2805 bool found = false; 2805 bool found = false;
2806 Event * cE = 0; 2806 Event * cE = 0;
2807 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 2807 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
2808 while ( test ) { 2808 while ( test ) {
2809 qApp->processEvents(); 2809 qApp->processEvents();
2810 bool skip = false; 2810 bool skip = false;
2811 if ( found ) 2811 if ( found )
2812 skip = !test->matchTime( &current, &conflict ); 2812 skip = !test->matchTime( &current, &conflict );
2813 else 2813 else
2814 skip = !test->matchTime( &current, 0 ); 2814 skip = !test->matchTime( &current, 0 );
2815 if ( !skip && !test->doesFloat() ) { 2815 if ( !skip && !test->doesFloat() ) {
2816 if ( mConflictingEvent->isOverlapping ( test, &retVal, &current ) ) { 2816 if ( mConflictingEvent->isOverlapping ( test, &retVal, &current ) ) {
2817 if ( ! found ) { 2817 if ( ! found ) {
2818 conflict = retVal; 2818 conflict = retVal;
2819 cE = test; 2819 cE = test;
2820 } else { 2820 } else {
2821 if ( retVal < conflict ) { 2821 if ( retVal < conflict ) {
2822 conflict = retVal; 2822 conflict = retVal;
2823 cE = test; 2823 cE = test;
2824 } 2824 }
2825 } 2825 }
2826 found = true; 2826 found = true;
2827 } 2827 }
2828 } 2828 }
2829 test = testlist.next(); 2829 test = testlist.next();
2830 } 2830 }
2831 topLevelWidget()->setCaption( i18n("KO/Pi") );
2831 if ( found ) { 2832 if ( found ) {
2832 QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; 2833 QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ;
2833 qApp->processEvents(); 2834 qApp->processEvents();
2834 int km = KMessageBox::warningContinueCancel(this,mess, 2835 int km = KMessageBox::warningContinueCancel(this,mess,
2835 i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); 2836 i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!"));
2836 if ( km != KMessageBox::Continue ) 2837 if ( km != KMessageBox::Continue ) {
2837 return; 2838 return;
2838 2839 }
2839 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 2840 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
2840 mViewManager->showDayView(); 2841 mViewManager->showDayView();
2841 mNavigator->slotDaySelect( conflict.date() ); 2842 mNavigator->slotDaySelect( conflict.date() );
2842 int hour = conflict.time().hour(); 2843 int hour = conflict.time().hour();
2843 mViewManager->agendaView()->setStartHour( hour ); 2844 mViewManager->agendaView()->setStartHour( hour );
2844 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); 2845 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) );
2845 } else 2846 } else
2846 topLevelWidget()->setCaption( i18n("No conflict found") ); 2847 topLevelWidget()->setCaption( i18n("No conflict found") );
2847 mConflictingEvent = 0; 2848 mConflictingEvent = 0;
2848 return; 2849 return;
2849 2850
2850} 2851}
2851 2852
2852void CalendarView::updateTodoViews() 2853void CalendarView::updateTodoViews()
2853{ 2854{
2854 mTodoList->updateView(); 2855 mTodoList->updateView();
2855 mViewManager->currentView()->updateView(); 2856 mViewManager->currentView()->updateView();
2856 2857
2857} 2858}
2858 2859
2859 2860
2860 2861
2861void CalendarView::clearAllViews() 2862void CalendarView::clearAllViews()
2862{ 2863{
2863 mTodoList->clearList(); 2864 mTodoList->clearList();
2864 mViewManager->clearAllViews(); 2865 mViewManager->clearAllViews();
2865 SearchDialog * sd = mDialogManager->getSearchDialog(); 2866 SearchDialog * sd = mDialogManager->getSearchDialog();
2866 if ( sd ) { 2867 if ( sd ) {
2867 KOListView* kol = sd->listview(); 2868 KOListView* kol = sd->listview();
2868 if ( kol ) 2869 if ( kol )
2869 kol->clearList(); 2870 kol->clearList();
2870 } 2871 }
2871} 2872}
2872void CalendarView::updateView() 2873void CalendarView::updateView()
2873{ 2874{
2874 static bool clearallviews = false; 2875 static bool clearallviews = false;
2875 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 2876 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
2876 if ( clearallviews ) { 2877 if ( clearallviews ) {
2877 clearAllViews(); 2878 clearAllViews();
2878 clearallviews = false; 2879 clearallviews = false;
2879 } 2880 }
2880 return; 2881 return;
2881 } 2882 }
2882 clearallviews = true; 2883 clearallviews = true;
2883 DateList tmpList = mNavigator->selectedDates(); 2884 DateList tmpList = mNavigator->selectedDates();
2884 2885
2885 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2886 if ( KOPrefs::instance()->mHideNonStartedTodos )
2886 mTodoList->updateView(); 2887 mTodoList->updateView();
2887 // We assume that the navigator only selects consecutive days. 2888 // We assume that the navigator only selects consecutive days.
2888 updateView( tmpList.first(), tmpList.last() ); 2889 updateView( tmpList.first(), tmpList.last() );
2889} 2890}
2890 2891
2891void CalendarView::updateUnmanagedViews() 2892void CalendarView::updateUnmanagedViews()
2892{ 2893{
2893 mDateNavigator->updateDayMatrix(); 2894 mDateNavigator->updateDayMatrix();
2894} 2895}
2895 2896
2896int CalendarView::msgItemDelete(const QString name) 2897int CalendarView::msgItemDelete(const QString name)
2897{ 2898{
2898 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2899 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2899 i18n("This item will be\npermanently deleted."), 2900 i18n("This item will be\npermanently deleted."),
2900 i18n("KO/Pi Confirmation"),i18n("Delete")); 2901 i18n("KO/Pi Confirmation"),i18n("Delete"));
2901} 2902}
2902 2903
2903 2904
2904void CalendarView::edit_cut() 2905void CalendarView::edit_cut()
2905{ 2906{
2906 Event *anEvent=0; 2907 Event *anEvent=0;
2907 2908
2908 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2909 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2909 2910
2910 if (mViewManager->currentView()->isEventView()) { 2911 if (mViewManager->currentView()->isEventView()) {
2911 if ( incidence && incidence->typeID() == eventID ) { 2912 if ( incidence && incidence->typeID() == eventID ) {
2912 anEvent = static_cast<Event *>(incidence); 2913 anEvent = static_cast<Event *>(incidence);
2913 } 2914 }
2914 } 2915 }
2915 2916
2916 if (!anEvent) { 2917 if (!anEvent) {
2917 KNotifyClient::beep(); 2918 KNotifyClient::beep();
2918 return; 2919 return;
2919 } 2920 }
2920 DndFactory factory( mCalendar ); 2921 DndFactory factory( mCalendar );
2921 factory.cutIncidence(anEvent); 2922 factory.cutIncidence(anEvent);
2922 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2923 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2923} 2924}
2924 2925
2925void CalendarView::edit_copy() 2926void CalendarView::edit_copy()
2926{ 2927{
2927 Event *anEvent=0; 2928 Event *anEvent=0;
2928 2929
2929 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2930 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2930 2931
2931 if (mViewManager->currentView()->isEventView()) { 2932 if (mViewManager->currentView()->isEventView()) {
2932 if ( incidence && incidence->typeID() == eventID ) { 2933 if ( incidence && incidence->typeID() == eventID ) {
2933 anEvent = static_cast<Event *>(incidence); 2934 anEvent = static_cast<Event *>(incidence);
2934 } 2935 }
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index 7ce3f1f..6a6fff9 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -272,215 +272,219 @@ void KOCalEditView::readConfig()
272 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); 272 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm()));
273 addBut->setMaximumWidth( addBut->sizeHint().height() ); 273 addBut->setMaximumWidth( addBut->sizeHint().height() );
274 274
275 addBut = new QPushButton ( mw ); 275 addBut = new QPushButton ( mw );
276 addBut->setFocusPolicy(NoFocus); 276 addBut->setFocusPolicy(NoFocus);
277 mainLayout->addWidget( addBut,0,++ii ); 277 mainLayout->addWidget( addBut,0,++ii );
278 addBut->setPixmap ( SmallIcon("pencil")); 278 addBut->setPixmap ( SmallIcon("pencil"));
279 connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); 279 connect(addBut,SIGNAL(clicked()),SLOT(disableRO()));
280 addBut->setMaximumWidth( addBut->sizeHint().height() ); 280 addBut->setMaximumWidth( addBut->sizeHint().height() );
281 lab = new QLabel ( "", mw ); 281 lab = new QLabel ( "", mw );
282 mainLayout->addWidget( lab,0,++ii ); 282 mainLayout->addWidget( lab,0,++ii );
283 283
284 addBut = new QPushButton ( mw ); 284 addBut = new QPushButton ( mw );
285 addBut->setFocusPolicy(NoFocus); 285 addBut->setFocusPolicy(NoFocus);
286 mainLayout->addWidget( addBut,0,++ii ); 286 mainLayout->addWidget( addBut,0,++ii );
287 addBut->setPixmap ( SmallIcon("plus")); 287 addBut->setPixmap ( SmallIcon("plus"));
288 connect(addBut,SIGNAL(clicked()),SLOT(addCal())); 288 connect(addBut,SIGNAL(clicked()),SLOT(addCal()));
289 289
290 lab = new QLabel ( " ", mw ); 290 lab = new QLabel ( " ", mw );
291 mainLayout->addWidget( lab,0,++ii ); 291 mainLayout->addWidget( lab,0,++ii );
292 292
293 293
294 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 294 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
295 int row = 1; 295 int row = 1;
296 bool errorLoadStandard = false; 296 bool errorLoadStandard = false;
297 while ( kkf ) { 297 while ( kkf ) {
298 int iii = 0; 298 int iii = 0;
299 KOCalRadioButton* rb = new KOCalRadioButton( mw ); 299 KOCalRadioButton* rb = new KOCalRadioButton( mw );
300 mainLayout->addWidget( rb,row,0 );mStdandardB.append( rb ); 300 mainLayout->addWidget( rb,row,0 );mStdandardB.append( rb );
301 rb->setChecked( kkf->isStandard ); 301 rb->setChecked( kkf->isStandard );
302 if ( kkf->isStandard && ( kkf->mErrorOnLoad || kkf->isReadOnly ) ) 302 if ( kkf->isStandard && ( kkf->mErrorOnLoad || kkf->isReadOnly ) )
303 errorLoadStandard = true; 303 errorLoadStandard = true;
304 rb->setNum( kkf->mCalNumber ); 304 rb->setNum( kkf->mCalNumber );
305 connect (rb, SIGNAL (selectNum(int)), SLOT ( selectStdCal(int) ) ); 305 connect (rb, SIGNAL (selectNum(int)), SLOT ( selectStdCal(int) ) );
306 if ( kkf->mErrorOnLoad || kkf->isReadOnly ) 306 if ( kkf->mErrorOnLoad || kkf->isReadOnly )
307 rb->setEnabled( false ); 307 rb->setEnabled( false );
308 KOCalCheckButton* cb = new KOCalCheckButton( mw ); 308 KOCalCheckButton* cb = new KOCalCheckButton( mw );
309 mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb ); 309 mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb );
310 cb->setChecked( kkf->isEnabled && !kkf->mErrorOnLoad ); 310 cb->setChecked( kkf->isEnabled && !kkf->mErrorOnLoad );
311 cb->setNum( kkf->mCalNumber ); 311 cb->setNum( kkf->mCalNumber );
312 if ( kkf->mErrorOnLoad ) 312 if ( kkf->mErrorOnLoad )
313 cb->setEnabled( false ); 313 cb->setEnabled( false );
314 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); 314 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) );
315 KOCalButton* name = new KOCalButton( mw ); 315 KOCalButton* name = new KOCalButton( mw );
316 name->setNum( kkf->mCalNumber ); 316 name->setNum( kkf->mCalNumber );
317 name->setText( kkf->mName ); 317 name->setText( kkf->mName );
318 mainLayout->addWidget( name,row,++iii ); 318 mainLayout->addWidget( name,row,++iii );
319 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); 319 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) );
320 //lab = new QLabel (" ", mw ); 320 //lab = new QLabel (" ", mw );
321 //mainLayout->addWidget( lab,row,++iii ); 321 //mainLayout->addWidget( lab,row,++iii );
322 cb = new KOCalCheckButton( mw ); 322 cb = new KOCalCheckButton( mw );
323 mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); 323 mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb );
324 cb->setChecked( kkf->isAlarmEnabled && !kkf->mErrorOnLoad); 324 cb->setChecked( kkf->isAlarmEnabled && !kkf->mErrorOnLoad);
325 cb->setNum( kkf->mCalNumber ); 325 cb->setNum( kkf->mCalNumber );
326 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); 326 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) );
327 if ( kkf->mErrorOnLoad ) 327 if ( kkf->mErrorOnLoad )
328 cb->setEnabled( false ); 328 cb->setEnabled( false );
329 cb = new KOCalCheckButton( mw ); 329 cb = new KOCalCheckButton( mw );
330 mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); 330 mainLayout->addWidget( cb,row,++iii );mROB.append( cb );
331 cb->setChecked( kkf->isReadOnly ); 331 cb->setChecked( kkf->isReadOnly );
332 cb->setNum( kkf->mCalNumber ); 332 cb->setNum( kkf->mCalNumber );
333 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); 333 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) );
334 if ( kkf->mErrorOnLoad ) 334 if ( kkf->mErrorOnLoad )
335 cb->setEnabled( false ); 335 cb->setEnabled( false );
336 if ( row > 1) { 336 if ( row > 1) {
337 KColorButton *colb = new KColorButton( mw ); 337 KColorButton *colb = new KColorButton( mw );
338 mainLayout->addWidget( colb,row,++iii ); 338 mainLayout->addWidget( colb,row,++iii );
339 colb->setID( kkf->mCalNumber ); 339 colb->setID( kkf->mCalNumber );
340 colb->setColor( kkf->mDefaultColor ); 340 colb->setColor( kkf->mDefaultColor );
341 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); 341 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) );
342 KOCalButton* calb = new KOCalButton( mw ); 342 KOCalButton* calb = new KOCalButton( mw );
343 mainLayout->addWidget( calb,row,++iii ); 343 mainLayout->addWidget( calb,row,++iii );
344 calb->setNum( kkf->mCalNumber ); 344 calb->setNum( kkf->mCalNumber );
345 calb->setPixmap ( SmallIcon("minus")); 345 calb->setPixmap ( SmallIcon("minus"));
346 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); 346 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) );
347 int hei = calb->sizeHint().height(); 347 int hei = calb->sizeHint().height();
348 //calb->setMaximumSize( hei*9/10, hei*9/10 ); 348 //calb->setMaximumSize( hei*9/10, hei*9/10 );
349 } 349 }
350 ++row; 350 ++row;
351 kkf = KOPrefs::instance()->mCalendars.next(); 351 kkf = KOPrefs::instance()->mCalendars.next();
352 } 352 }
353 if ( errorLoadStandard ) 353 if ( errorLoadStandard )
354 findNewStandard(); 354 findNewStandard();
355 lab = new QLabel ( "", mw ); 355 lab = new QLabel ( "", mw );
356 mainLayout->addWidget( lab,row,0 ); 356 mainLayout->addWidget( lab,row,0 );
357 mw->show(); 357 mw->show();
358 358
359} 359}
360 360
361void KOCalEditView::defaultInfo() 361void KOCalEditView::defaultInfo()
362{ 362{
363 KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") ); 363 KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") );
364} 364}
365void KOCalEditView::addCal() 365void KOCalEditView::addCal()
366{ 366{
367 bool tryagain = true; 367 bool tryagain = true;
368 QString name, file; 368 QString name, file = KGlobalSettings::calendarDir()+"newCal.ics";
369 while ( tryagain ) { 369 while ( tryagain ) {
370 KONewCalPrefs prefs ( this ); 370 KONewCalPrefs prefs ( this );
371 prefs.nameE->setText( name ); 371 prefs.nameE->setText( name );
372 prefs.url->setURL( file ); 372 prefs.url->setURL( file );
373 if ( ! prefs.exec() ) 373 if ( ! prefs.exec() )
374 return; 374 return;
375 name = prefs.calName(); 375 name = prefs.calName();
376 file = prefs.calFileName(); 376 file = prefs.calFileName();
377 tryagain = false; 377 tryagain = false;
378 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 378 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
379 while ( kkf ) { 379 while ( kkf ) {
380 if ( kkf->mName == name ) { 380 if ( kkf->mName == name ) {
381 KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); 381 KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) );
382 name = ""; 382 name = "";
383 tryagain = true; 383 tryagain = true;
384 break; 384 break;
385 } 385 }
386 if ( kkf->mFileName == file ) { 386 if ( kkf->mFileName == file ) {
387 KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) ); 387 KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) );
388 tryagain = true; 388 tryagain = true;
389 file = ""; 389 file = KGlobalSettings::calendarDir()+"newCal.ics";
390 break; 390 break;
391 } 391 }
392 kkf = KOPrefs::instance()->mCalendars.next(); 392 kkf = KOPrefs::instance()->mCalendars.next();
393 }
394 QFileInfo fi ( file );
395 if ( fi.isDir() ) {
396 tryagain = true;
393 } 397 }
394 } 398 }
395 addCalendar ( name, file ); 399 addCalendar ( name, file );
396 QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); 400 QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) );
397} 401}
398int KOCalEditView::addCalendar( QString name, QString file, bool ask ) 402int KOCalEditView::addCalendar( QString name, QString file, bool ask )
399{ 403{
400 404
401 QFileInfo fi ( file ); 405 QFileInfo fi ( file );
402 QString absFile = file; 406 QString absFile = file;
403 bool isRelative = false; 407 bool isRelative = false;
404 if ( fi.isRelative() ) { 408 if ( fi.isRelative() ) {
405 isRelative = true; 409 isRelative = true;
406 absFile = KGlobalSettings::calendarDir()+file; 410 absFile = KGlobalSettings::calendarDir()+file;
407 fi.setFile( absFile ); 411 fi.setFile( absFile );
408 } else { 412 } else {
409 QString cd = KGlobalSettings::calendarDir(); 413 QString cd = KGlobalSettings::calendarDir();
410 if ( file.left( cd.length() ) == cd ) { 414 if ( file.left( cd.length() ) == cd ) {
411 isRelative = true; 415 isRelative = true;
412 file = fi.fileName (); 416 file = fi.fileName ();
413 fi.setFile( absFile ); 417 fi.setFile( absFile );
414 } 418 }
415 } 419 }
416 if (!fi.exists() ) { 420 if (!fi.exists() ) {
417 if ( ask ) 421 if ( ask )
418 if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( KGlobal::formatMessage (absFile,0) ) )== KMessageBox::No ) 422 if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( KGlobal::formatMessage (absFile,0) ) )== KMessageBox::No )
419 return 0; 423 return 0;
420 QFile fileIn( absFile ); 424 QFile fileIn( absFile );
421 if (!fileIn.open( IO_WriteOnly ) ) { 425 if (!fileIn.open( IO_WriteOnly ) ) {
422 KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); 426 KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) );
423 return 0; 427 return 0;
424 } 428 }
425 QTextStream tsIn( &fileIn ); 429 QTextStream tsIn( &fileIn );
426 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 430 tsIn.setCodec( QTextCodec::codecForName("utf8") );
427 tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; 431 tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n";
428 fileIn.close(); 432 fileIn.close();
429 } 433 }
430 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); 434 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar();
431 kkf->mName = name; 435 kkf->mName = name;
432 kkf->mFileName = absFile; 436 kkf->mFileName = absFile;
433 kkf->mSavedFileName = file; 437 kkf->mSavedFileName = file;
434 kkf->isRelative = isRelative; 438 kkf->isRelative = isRelative;
435 emit calendarAdded( kkf->mCalNumber ); 439 emit calendarAdded( kkf->mCalNumber );
436 if ( ask ) 440 if ( ask )
437 emit needsUpdate(); 441 emit needsUpdate();
438 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 442 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
439 return kkf->mCalNumber; 443 return kkf->mCalNumber;
440} 444}
441int KOCalEditView::getBirtdayID() 445int KOCalEditView::getBirtdayID()
442{ 446{
443 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 447 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
444 while ( kkf ) { 448 while ( kkf ) {
445 if ( kkf->mName == i18n("Birthdays") ) 449 if ( kkf->mName == i18n("Birthdays") )
446 return kkf->mCalNumber; 450 return kkf->mCalNumber;
447 kkf = KOPrefs::instance()->mCalendars.next(); 451 kkf = KOPrefs::instance()->mCalendars.next();
448 } 452 }
449 QString file = locateLocal( "data", "korganizer/birthdays.ics" ); 453 QString file = locateLocal( "data", "korganizer/birthdays.ics" );
450 return addCalendar( i18n("Birthdays"), file, false ); 454 return addCalendar( i18n("Birthdays"), file, false );
451} 455}
452 456
453void KOCalEditView::enableAll() 457void KOCalEditView::enableAll()
454{ 458{
455 toggleList( mEnabledB ); 459 toggleList( mEnabledB );
456} 460}
457void KOCalEditView::enableAlarm() 461void KOCalEditView::enableAlarm()
458{ 462{
459 toggleList( mAlarmB ); 463 toggleList( mAlarmB );
460} 464}
461void KOCalEditView::disableRO() 465void KOCalEditView::disableRO()
462{ 466{
463 toggleList( mROB, false ); 467 toggleList( mROB, false );
464} 468}
465void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list , bool enable ) 469void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list , bool enable )
466{ 470{
467 bool dis = !enable; 471 bool dis = !enable;
468 KOCalCheckButton* it = list.first(); 472 KOCalCheckButton* it = list.first();
469 while ( it ) { 473 while ( it ) {
470 if ( !it->isChecked() == enable && it->isEnabled() ) { 474 if ( !it->isChecked() == enable && it->isEnabled() ) {
471 dis = !dis; 475 dis = !dis;
472 break; 476 break;
473 } 477 }
474 it = list.next(); 478 it = list.next();
475 } 479 }
476 it = list.first(); 480 it = list.first();
477 while ( it ) { 481 while ( it ) {
478 if ( it->isEnabled() ) 482 if ( it->isEnabled() )
479 it->setChecked(dis); 483 it->setChecked(dis);
480 it = list.next(); 484 it = list.next();
481 } 485 }
482} 486}
483void KOCalEditView::deleteAll() 487void KOCalEditView::deleteAll()
484{ 488{
485 qDebug("delteAll"); 489 qDebug("delteAll");
486} 490}