summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-04-10 13:17:21 (UTC)
committer zautrix <zautrix>2005-04-10 13:17:21 (UTC)
commitef11b9d4de01d601bfcfb8efacb0aeff1e657edb (patch) (unidiff)
tree5f4e6aa51ef357c6d9ecbe4d9a2908b8c2ca1228 /korganizer
parent04fe8f3523c46511e846a42e4bb92d6b8d33758b (diff)
downloadkdepimpi-ef11b9d4de01d601bfcfb8efacb0aeff1e657edb.zip
kdepimpi-ef11b9d4de01d601bfcfb8efacb0aeff1e657edb.tar.gz
kdepimpi-ef11b9d4de01d601bfcfb8efacb0aeff1e657edb.tar.bz2
fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp25
-rw-r--r--korganizer/kotodoview.cpp6
2 files changed, 26 insertions, 5 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index c530037..bd7376a 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -2579,261 +2579,282 @@ void CalendarView::moveIncidence(Incidence * inc )
2579 da = mMoveIncidence->dtStart().date(); 2579 da = mMoveIncidence->dtStart().date();
2580 } 2580 }
2581 //PENDING set date for recurring incidence to date of recurrence 2581 //PENDING set date for recurring incidence to date of recurrence
2582 //mMoveIncidenceOldDate; 2582 //mMoveIncidenceOldDate;
2583 mDatePicker->setDate( da ); 2583 mDatePicker->setDate( da );
2584} 2584}
2585void CalendarView::showDatePickerPopup() 2585void CalendarView::showDatePickerPopup()
2586{ 2586{
2587 if ( mDateFrame->isVisible() ) 2587 if ( mDateFrame->isVisible() )
2588 mDateFrame->hide(); 2588 mDateFrame->hide();
2589 else { 2589 else {
2590 int offX = 0, offY = 0; 2590 int offX = 0, offY = 0;
2591#ifdef DESKTOP_VERSION 2591#ifdef DESKTOP_VERSION
2592 int w =mDatePicker->sizeHint().width() ; 2592 int w =mDatePicker->sizeHint().width() ;
2593 int h = mDatePicker->sizeHint().height() ; 2593 int h = mDatePicker->sizeHint().height() ;
2594 int dw = topLevelWidget()->width(); 2594 int dw = topLevelWidget()->width();
2595 int dh = topLevelWidget()->height(); 2595 int dh = topLevelWidget()->height();
2596 offX = topLevelWidget()->x(); 2596 offX = topLevelWidget()->x();
2597 offY = topLevelWidget()->y(); 2597 offY = topLevelWidget()->y();
2598#else 2598#else
2599 int w =mDatePicker->sizeHint().width() ; 2599 int w =mDatePicker->sizeHint().width() ;
2600 int h = mDatePicker->sizeHint().height() ; 2600 int h = mDatePicker->sizeHint().height() ;
2601 int dw = QApplication::desktop()->width(); 2601 int dw = QApplication::desktop()->width();
2602 int dh = QApplication::desktop()->height(); 2602 int dh = QApplication::desktop()->height();
2603#endif 2603#endif
2604 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2604 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2605 mDateFrame->show(); 2605 mDateFrame->show();
2606 } 2606 }
2607} 2607}
2608void CalendarView::showDatePicker( ) 2608void CalendarView::showDatePicker( )
2609{ 2609{
2610 showDatePickerPopup(); 2610 showDatePickerPopup();
2611 mDatePickerMode = 1; 2611 mDatePickerMode = 1;
2612 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2612 mDatePicker->setDate( mNavigator->selectedDates().first() );
2613} 2613}
2614 2614
2615void CalendarView::showEventEditor() 2615void CalendarView::showEventEditor()
2616{ 2616{
2617#ifdef DESKTOP_VERSION 2617#ifdef DESKTOP_VERSION
2618 int x,y,w,h; 2618 int x,y,w,h;
2619 x = mEventEditor->geometry().x(); 2619 x = mEventEditor->geometry().x();
2620 y = mEventEditor->geometry().y(); 2620 y = mEventEditor->geometry().y();
2621 w = mEventEditor->width(); 2621 w = mEventEditor->width();
2622 h = mEventEditor->height(); 2622 h = mEventEditor->height();
2623 mEventEditor->show(); 2623 mEventEditor->show();
2624 mEventEditor->setGeometry(x,y,w,h); 2624 mEventEditor->setGeometry(x,y,w,h);
2625#else 2625#else
2626 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2626 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2627 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2627 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2628 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2628 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2629 qApp->processEvents(); 2629 qApp->processEvents();
2630 delete mEventEditor; 2630 delete mEventEditor;
2631 mEventEditor = mDialogManager->getEventEditor(); 2631 mEventEditor = mDialogManager->getEventEditor();
2632 topLevelWidget()->setCaption( i18n("") ); 2632 topLevelWidget()->setCaption( i18n("") );
2633 } 2633 }
2634 mEventEditor->showMaximized(); 2634 mEventEditor->showMaximized();
2635#endif 2635#endif
2636} 2636}
2637void CalendarView::showTodoEditor() 2637void CalendarView::showTodoEditor()
2638{ 2638{
2639#ifdef DESKTOP_VERSION 2639#ifdef DESKTOP_VERSION
2640 int x,y,w,h; 2640 int x,y,w,h;
2641 x = mTodoEditor->geometry().x(); 2641 x = mTodoEditor->geometry().x();
2642 y = mTodoEditor->geometry().y(); 2642 y = mTodoEditor->geometry().y();
2643 w = mTodoEditor->width(); 2643 w = mTodoEditor->width();
2644 h = mTodoEditor->height(); 2644 h = mTodoEditor->height();
2645 mTodoEditor->show(); 2645 mTodoEditor->show();
2646 mTodoEditor->setGeometry(x,y,w,h); 2646 mTodoEditor->setGeometry(x,y,w,h);
2647#else 2647#else
2648 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2648 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2649 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2649 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2650 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2650 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2651 qApp->processEvents(); 2651 qApp->processEvents();
2652 delete mTodoEditor; 2652 delete mTodoEditor;
2653 mTodoEditor = mDialogManager->getTodoEditor(); 2653 mTodoEditor = mDialogManager->getTodoEditor();
2654 topLevelWidget()->setCaption( i18n("") ); 2654 topLevelWidget()->setCaption( i18n("") );
2655 } 2655 }
2656 mTodoEditor->showMaximized(); 2656 mTodoEditor->showMaximized();
2657#endif 2657#endif
2658} 2658}
2659 2659
2660void CalendarView::cloneIncidence() 2660void CalendarView::cloneIncidence()
2661{ 2661{
2662 Incidence *incidence = currentSelection(); 2662 Incidence *incidence = currentSelection();
2663 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2663 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2664 if ( incidence ) { 2664 if ( incidence ) {
2665 cloneIncidence(incidence); 2665 cloneIncidence(incidence);
2666 } 2666 }
2667} 2667}
2668void CalendarView::moveIncidence() 2668void CalendarView::moveIncidence()
2669{ 2669{
2670 Incidence *incidence = currentSelection(); 2670 Incidence *incidence = currentSelection();
2671 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2671 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2672 if ( incidence ) { 2672 if ( incidence ) {
2673 moveIncidence(incidence); 2673 moveIncidence(incidence);
2674 } 2674 }
2675} 2675}
2676void CalendarView::beamIncidence() 2676void CalendarView::beamIncidence()
2677{ 2677{
2678 Incidence *incidence = currentSelection(); 2678 Incidence *incidence = currentSelection();
2679 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2679 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2680 if ( incidence ) { 2680 if ( incidence ) {
2681 beamIncidence(incidence); 2681 beamIncidence(incidence);
2682 } 2682 }
2683} 2683}
2684void CalendarView::toggleCancelIncidence() 2684void CalendarView::toggleCancelIncidence()
2685{ 2685{
2686 Incidence *incidence = currentSelection(); 2686 Incidence *incidence = currentSelection();
2687 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2687 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2688 if ( incidence ) { 2688 if ( incidence ) {
2689 cancelIncidence(incidence); 2689 cancelIncidence(incidence);
2690 } 2690 }
2691} 2691}
2692 2692
2693 2693
2694void CalendarView::cancelIncidence(Incidence * inc ) 2694void CalendarView::cancelIncidence(Incidence * inc )
2695{ 2695{
2696 inc->setCancelled( ! inc->cancelled() ); 2696 inc->setCancelled( ! inc->cancelled() );
2697 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2697 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2698 updateView(); 2698 updateView();
2699} 2699}
2700void CalendarView::cloneIncidence(Incidence * orgInc ) 2700void CalendarView::cloneIncidence(Incidence * orgInc )
2701{ 2701{
2702 Incidence * newInc = orgInc->clone(); 2702 Incidence * newInc = orgInc->clone();
2703 newInc->recreate(); 2703 newInc->recreate();
2704 2704
2705 if ( newInc->type() == "Todo" ) { 2705 if ( newInc->type() == "Todo" ) {
2706 Todo* t = (Todo*) newInc; 2706 Todo* t = (Todo*) newInc;
2707 bool cloneSub = false;
2708 if ( orgInc->relations().count() ) {
2709 int result = KMessageBox::warningYesNoCancel(this,
2710 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 ) ),
2711 i18n("Todo has subtodos"),
2712 i18n("Yes"),
2713 i18n("No"));
2714
2715 if ( result == KMessageBox::Cancel ) {
2716 delete t;
2717 return;
2718 }
2719 if (result == KMessageBox::Yes) cloneSub = true;
2720 }
2707 showTodoEditor(); 2721 showTodoEditor();
2708 mTodoEditor->editTodo( t ); 2722 mTodoEditor->editTodo( t );
2709 if ( mTodoEditor->exec() ) { 2723 if ( mTodoEditor->exec() ) {
2710 mCalendar->addTodo( t ); 2724 if ( cloneSub ) {
2711 updateView(); 2725 orgInc->cloneRelations( t );
2726 mCalendar->addIncidenceBranch( t );
2727 updateView();
2728
2729 } else {
2730 mCalendar->addTodo( t );
2731 updateView();
2732 }
2712 } else { 2733 } else {
2713 delete t; 2734 delete t;
2714 } 2735 }
2715 } 2736 }
2716 else { 2737 else {
2717 Event* e = (Event*) newInc; 2738 Event* e = (Event*) newInc;
2718 showEventEditor(); 2739 showEventEditor();
2719 mEventEditor->editEvent( e ); 2740 mEventEditor->editEvent( e );
2720 if ( mEventEditor->exec() ) { 2741 if ( mEventEditor->exec() ) {
2721 mCalendar->addEvent( e ); 2742 mCalendar->addEvent( e );
2722 updateView(); 2743 updateView();
2723 } else { 2744 } else {
2724 delete e; 2745 delete e;
2725 } 2746 }
2726 } 2747 }
2727 setActiveWindow(); 2748 setActiveWindow();
2728} 2749}
2729 2750
2730void CalendarView::newEvent() 2751void CalendarView::newEvent()
2731{ 2752{
2732 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2753 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2733 KOAgendaView *aView = mViewManager->agendaView(); 2754 KOAgendaView *aView = mViewManager->agendaView();
2734 if (aView) { 2755 if (aView) {
2735 if (aView->selectionStart().isValid()) { 2756 if (aView->selectionStart().isValid()) {
2736 if (aView->selectedIsAllDay()) { 2757 if (aView->selectedIsAllDay()) {
2737 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2758 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2738 } else { 2759 } else {
2739 newEvent(aView->selectionStart(),aView->selectionEnd()); 2760 newEvent(aView->selectionStart(),aView->selectionEnd());
2740 } 2761 }
2741 return; 2762 return;
2742 } 2763 }
2743 } 2764 }
2744 2765
2745 QDate date = mNavigator->selectedDates().first(); 2766 QDate date = mNavigator->selectedDates().first();
2746 QDateTime current = QDateTime::currentDateTime(); 2767 QDateTime current = QDateTime::currentDateTime();
2747 if ( date <= current.date() ) { 2768 if ( date <= current.date() ) {
2748 int hour = current.time().hour() +1; 2769 int hour = current.time().hour() +1;
2749 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2770 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2750 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2771 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2751 } else 2772 } else
2752 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2773 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2753 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2774 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2754 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2775 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2755} 2776}
2756 2777
2757void CalendarView::newEvent(QDateTime fh) 2778void CalendarView::newEvent(QDateTime fh)
2758{ 2779{
2759 newEvent(fh, 2780 newEvent(fh,
2760 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2781 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2761} 2782}
2762 2783
2763void CalendarView::newEvent(QDate dt) 2784void CalendarView::newEvent(QDate dt)
2764{ 2785{
2765 newEvent(QDateTime(dt, QTime(0,0,0)), 2786 newEvent(QDateTime(dt, QTime(0,0,0)),
2766 QDateTime(dt, QTime(0,0,0)), true); 2787 QDateTime(dt, QTime(0,0,0)), true);
2767} 2788}
2768void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 2789void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2769{ 2790{
2770 newEvent(fromHint, toHint, false); 2791 newEvent(fromHint, toHint, false);
2771} 2792}
2772void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2793void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2773{ 2794{
2774 2795
2775 showEventEditor(); 2796 showEventEditor();
2776 mEventEditor->newEvent(fromHint,toHint,allDay); 2797 mEventEditor->newEvent(fromHint,toHint,allDay);
2777 if ( mFilterView->filtersEnabled() ) { 2798 if ( mFilterView->filtersEnabled() ) {
2778 CalFilter *filter = mFilterView->selectedFilter(); 2799 CalFilter *filter = mFilterView->selectedFilter();
2779 if (filter && filter->showCategories()) { 2800 if (filter && filter->showCategories()) {
2780 mEventEditor->setCategories(filter->categoryList().join(",") ); 2801 mEventEditor->setCategories(filter->categoryList().join(",") );
2781 } 2802 }
2782 if ( filter ) 2803 if ( filter )
2783 mEventEditor->setSecrecy( filter->getSecrecy() ); 2804 mEventEditor->setSecrecy( filter->getSecrecy() );
2784 } 2805 }
2785 mEventEditor->exec(); 2806 mEventEditor->exec();
2786 setActiveWindow(); 2807 setActiveWindow();
2787} 2808}
2788void CalendarView::todoAdded(Todo * t) 2809void CalendarView::todoAdded(Todo * t)
2789{ 2810{
2790 2811
2791 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2812 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2792 updateTodoViews(); 2813 updateTodoViews();
2793} 2814}
2794void CalendarView::todoChanged(Todo * t) 2815void CalendarView::todoChanged(Todo * t)
2795{ 2816{
2796 emit todoModified( t, 4 ); 2817 emit todoModified( t, 4 );
2797 // updateTodoViews(); 2818 // updateTodoViews();
2798} 2819}
2799void CalendarView::todoToBeDeleted(Todo *) 2820void CalendarView::todoToBeDeleted(Todo *)
2800{ 2821{
2801 //qDebug("todoToBeDeleted(Todo *) "); 2822 //qDebug("todoToBeDeleted(Todo *) ");
2802 updateTodoViews(); 2823 updateTodoViews();
2803} 2824}
2804void CalendarView::todoDeleted() 2825void CalendarView::todoDeleted()
2805{ 2826{
2806 //qDebug(" todoDeleted()"); 2827 //qDebug(" todoDeleted()");
2807 updateTodoViews(); 2828 updateTodoViews();
2808} 2829}
2809 2830
2810 2831
2811void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 2832void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
2812{ 2833{
2813 showTodoEditor(); 2834 showTodoEditor();
2814 mTodoEditor->newTodo(dt,0,allday); 2835 mTodoEditor->newTodo(dt,0,allday);
2815 if ( mFilterView->filtersEnabled() ) { 2836 if ( mFilterView->filtersEnabled() ) {
2816 CalFilter *filter = mFilterView->selectedFilter(); 2837 CalFilter *filter = mFilterView->selectedFilter();
2817 if (filter && filter->showCategories()) { 2838 if (filter && filter->showCategories()) {
2818 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2839 mTodoEditor->setCategories(filter->categoryList().join(",") );
2819 } 2840 }
2820 if ( filter ) 2841 if ( filter )
2821 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2842 mTodoEditor->setSecrecy( filter->getSecrecy() );
2822 } 2843 }
2823 mTodoEditor->exec(); 2844 mTodoEditor->exec();
2824 setActiveWindow(); 2845 setActiveWindow();
2825} 2846}
2826 2847
2827void CalendarView::newTodo() 2848void CalendarView::newTodo()
2828{ 2849{
2829 newTodoDateTime( QDateTime(),true ); 2850 newTodoDateTime( QDateTime(),true );
2830} 2851}
2831 2852
2832void CalendarView::newSubTodo() 2853void CalendarView::newSubTodo()
2833{ 2854{
2834 Todo *todo = selectedTodo(); 2855 Todo *todo = selectedTodo();
2835 if ( todo ) newSubTodo( todo ); 2856 if ( todo ) newSubTodo( todo );
2836} 2857}
2837 2858
2838void CalendarView::newSubTodo(Todo *parentEvent) 2859void CalendarView::newSubTodo(Todo *parentEvent)
2839{ 2860{
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 7ee1eef..9b5d4ce 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -994,269 +994,269 @@ void KOTodoView::moveTodo()
994void KOTodoView::beamTodo() 994void KOTodoView::beamTodo()
995{ 995{
996 if (mActiveItem) { 996 if (mActiveItem) {
997 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 997 emit beamTodoSignal((Incidence*)mActiveItem->todo());
998 } 998 }
999} 999}
1000 1000
1001 1001
1002void KOTodoView::showTodo() 1002void KOTodoView::showTodo()
1003{ 1003{
1004 if (mActiveItem) { 1004 if (mActiveItem) {
1005 emit showTodoSignal(mActiveItem->todo()); 1005 emit showTodoSignal(mActiveItem->todo());
1006 } 1006 }
1007} 1007}
1008 1008
1009void KOTodoView::deleteTodo() 1009void KOTodoView::deleteTodo()
1010{ 1010{
1011 if (mActiveItem) { 1011 if (mActiveItem) {
1012 emit deleteTodoSignal(mActiveItem->todo()); 1012 emit deleteTodoSignal(mActiveItem->todo());
1013 } 1013 }
1014} 1014}
1015 1015
1016void KOTodoView::setNewPriority(int index) 1016void KOTodoView::setNewPriority(int index)
1017{ 1017{
1018 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1018 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1019 mActiveItem->todo()->setPriority(mPriority[index]); 1019 mActiveItem->todo()->setPriority(mPriority[index]);
1020 mActiveItem->construct(); 1020 mActiveItem->construct();
1021 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 1021 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
1022 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1022 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1023 } 1023 }
1024} 1024}
1025 1025
1026void KOTodoView::setNewPercentage(int index) 1026void KOTodoView::setNewPercentage(int index)
1027{ 1027{
1028 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1028 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1029 1029
1030 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { 1030 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
1031 mActiveItem->setOn( true ); 1031 mActiveItem->setOn( true );
1032 return; 1032 return;
1033 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { 1033 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
1034 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); 1034 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
1035 if ( par && par->isOn() ) 1035 if ( par && par->isOn() )
1036 par->setOn( false ); 1036 par->setOn( false );
1037 } 1037 }
1038 if (mPercentage[index] == 100) { 1038 if (mPercentage[index] == 100) {
1039 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 1039 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
1040 } else { 1040 } else {
1041 mActiveItem->todo()->setCompleted(false); 1041 mActiveItem->todo()->setCompleted(false);
1042 } 1042 }
1043 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 1043 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
1044 mActiveItem->construct(); 1044 mActiveItem->construct();
1045 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 1045 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
1046 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1046 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1047 } 1047 }
1048} 1048}
1049 1049
1050 1050
1051QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) 1051QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
1052{ 1052{
1053 QPopupMenu* tempMenu = new QPopupMenu (this); 1053 QPopupMenu* tempMenu = new QPopupMenu (this);
1054 QStringList checkedCategories = todoItem->todo()->categories (); 1054 QStringList checkedCategories = todoItem->todo()->categories ();
1055 1055
1056 tempMenu->setCheckable (true); 1056 tempMenu->setCheckable (true);
1057 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 1057 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
1058 it != KOPrefs::instance()->mCustomCategories.end (); 1058 it != KOPrefs::instance()->mCustomCategories.end ();
1059 ++it) { 1059 ++it) {
1060 int index = tempMenu->insertItem (*it); 1060 int index = tempMenu->insertItem (*it);
1061 mCategory[index] = *it; 1061 mCategory[index] = *it;
1062 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); 1062 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
1063 } 1063 }
1064 1064
1065 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 1065 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
1066 return tempMenu; 1066 return tempMenu;
1067 1067
1068 1068
1069} 1069}
1070void KOTodoView::changedCategories(int index) 1070void KOTodoView::changedCategories(int index)
1071{ 1071{
1072 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1072 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1073 QStringList categories = mActiveItem->todo()->categories (); 1073 QStringList categories = mActiveItem->todo()->categories ();
1074 QString colcat = categories.first(); 1074 QString colcat = categories.first();
1075 if (categories.find (mCategory[index]) != categories.end ()) 1075 if (categories.find (mCategory[index]) != categories.end ())
1076 categories.remove (mCategory[index]); 1076 categories.remove (mCategory[index]);
1077 else 1077 else
1078 categories.insert (categories.end(), mCategory[index]); 1078 categories.insert (categories.end(), mCategory[index]);
1079 categories.sort (); 1079 categories.sort ();
1080 if ( !colcat.isEmpty() ) { 1080 if ( !colcat.isEmpty() ) {
1081 if ( categories.find ( colcat ) != categories.end () ) { 1081 if ( categories.find ( colcat ) != categories.end () ) {
1082 categories.remove( colcat ); 1082 categories.remove( colcat );
1083 categories.prepend( colcat ); 1083 categories.prepend( colcat );
1084 } 1084 }
1085 } 1085 }
1086 mActiveItem->todo()->setCategories (categories); 1086 mActiveItem->todo()->setCategories (categories);
1087 mActiveItem->construct(); 1087 mActiveItem->construct();
1088 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1088 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1089 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 1089 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
1090 } 1090 }
1091} 1091}
1092void KOTodoView::itemDoubleClicked(QListViewItem *item) 1092void KOTodoView::itemDoubleClicked(QListViewItem *item)
1093{ 1093{
1094 if ( pendingSubtodo != 0 ) { 1094 if ( pendingSubtodo != 0 ) {
1095 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1095 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1096 } 1096 }
1097 pendingSubtodo = 0; 1097 pendingSubtodo = 0;
1098 int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); 1098 int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
1099 //qDebug("ROW %d ", row); 1099 //qDebug("ROW %d ", row);
1100 if (!item) { 1100 if (!item) {
1101 newTodo(); 1101 newTodo();
1102 return; 1102 return;
1103 } else { 1103 } else {
1104 if ( row == 2 ) { 1104 if ( row == 2 ) {
1105 mActiveItem = (KOTodoViewItem *) item; 1105 mActiveItem = (KOTodoViewItem *) item;
1106 newSubTodo(); 1106 newSubTodo();
1107 return; 1107 return;
1108 } 1108 }
1109 if ( row == 1 ) { 1109 if ( row == 1 ) {
1110 mActiveItem = (KOTodoViewItem *) item; 1110 mActiveItem = (KOTodoViewItem *) item;
1111 toggleRunningItem(); 1111 toggleRunningItem();
1112 return; 1112 return;
1113 } 1113 }
1114 } 1114 }
1115 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1115 if ( KOPrefs::instance()->mEditOnDoubleClick )
1116 editItem( item ); 1116 editItem( item );
1117 else 1117 else
1118 showItem( item , QPoint(), 0 ); 1118 showItem( item , QPoint(), 0 );
1119} 1119}
1120void KOTodoView::toggleRunningItem() 1120void KOTodoView::toggleRunningItem()
1121{ 1121{
1122 qDebug("KOTodoView::toggleRunning() "); 1122 // qDebug("KOTodoView::toggleRunning() ");
1123 if ( ! mActiveItem ) 1123 if ( ! mActiveItem )
1124 return; 1124 return;
1125 Todo * t = mActiveItem->todo(); 1125 Todo * t = mActiveItem->todo();
1126 if ( t->isRunning() ) { 1126 if ( t->isRunning() ) {
1127 int result = KMessageBox::warningContinueCancel(this, 1127 int result = KMessageBox::warningContinueCancel(this,
1128 i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 20 ) ),i18n("Todo is started"),i18n("Stop todo"),i18n("Cancel"), true); 1128 i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop todo"),i18n("Cancel"), true);
1129 if (result != KMessageBox::Continue) return; 1129 if (result != KMessageBox::Continue) return;
1130 t->setRunning( false ); 1130 t->setRunning( false );
1131 mActiveItem->construct(); 1131 mActiveItem->construct();
1132 } else { 1132 } else {
1133 int result = KMessageBox::warningContinueCancel(this, 1133 int result = KMessageBox::warningContinueCancel(this,
1134 i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 20 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true); 1134 i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true);
1135 if (result != KMessageBox::Continue) return; 1135 if (result != KMessageBox::Continue) return;
1136 t->setRunning( true ); 1136 t->setRunning( true );
1137 mActiveItem->construct(); 1137 mActiveItem->construct();
1138 } 1138 }
1139} 1139}
1140 1140
1141void KOTodoView::itemClicked(QListViewItem *item) 1141void KOTodoView::itemClicked(QListViewItem *item)
1142{ 1142{
1143 //qDebug("KOTodoView::itemClicked %d", item); 1143 //qDebug("KOTodoView::itemClicked %d", item);
1144 if (!item) { 1144 if (!item) {
1145 if ( pendingSubtodo != 0 ) { 1145 if ( pendingSubtodo != 0 ) {
1146 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1146 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1147 } 1147 }
1148 pendingSubtodo = 0; 1148 pendingSubtodo = 0;
1149 return; 1149 return;
1150 } 1150 }
1151 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1151 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1152 if ( pendingSubtodo != 0 ) { 1152 if ( pendingSubtodo != 0 ) {
1153 bool allowReparent = true; 1153 bool allowReparent = true;
1154 QListViewItem *par = item; 1154 QListViewItem *par = item;
1155 while ( par ) { 1155 while ( par ) {
1156 if ( par == pendingSubtodo ) { 1156 if ( par == pendingSubtodo ) {
1157 allowReparent = false; 1157 allowReparent = false;
1158 break; 1158 break;
1159 } 1159 }
1160 par = par->parent(); 1160 par = par->parent();
1161 } 1161 }
1162 if ( !allowReparent ) { 1162 if ( !allowReparent ) {
1163 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1163 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1164 qDebug("Recursive reparenting not possible "); 1164 qDebug("Recursive reparenting not possible ");
1165 pendingSubtodo = 0; 1165 pendingSubtodo = 0;
1166 } else { 1166 } else {
1167 Todo* newParent = todoItem->todo(); 1167 Todo* newParent = todoItem->todo();
1168 Todo* newSub = pendingSubtodo->todo(); 1168 Todo* newSub = pendingSubtodo->todo();
1169 pendingSubtodo = 0; 1169 pendingSubtodo = 0;
1170 emit reparentTodoSignal( newParent,newSub ); 1170 emit reparentTodoSignal( newParent,newSub );
1171 return; 1171 return;
1172 } 1172 }
1173 } 1173 }
1174#if 0 1174#if 0
1175 // handled by the item itself 1175 // handled by the item itself
1176 bool completed = todoItem->todo()->isCompleted(); // Completed or not? 1176 bool completed = todoItem->todo()->isCompleted(); // Completed or not?
1177 qDebug("com %d ",completed ); 1177 qDebug("com %d ",completed );
1178 qDebug("itemclicked "); 1178 qDebug("itemclicked ");
1179 if (todoItem->isOn()) { 1179 if (todoItem->isOn()) {
1180 qDebug("on "); 1180 qDebug("on ");
1181 if (!completed) { 1181 if (!completed) {
1182 qDebug("set true "); 1182 qDebug("set true ");
1183 todoItem->todo()->setCompleted(QDateTime::currentDateTime()); 1183 todoItem->todo()->setCompleted(QDateTime::currentDateTime());
1184 } 1184 }
1185 } else { 1185 } else {
1186 qDebug("not on "); 1186 qDebug("not on ");
1187 if (completed) { 1187 if (completed) {
1188 qDebug("set false "); 1188 qDebug("set false ");
1189 todoItem->todo()->setCompleted(false); 1189 todoItem->todo()->setCompleted(false);
1190 } 1190 }
1191 } 1191 }
1192#endif 1192#endif
1193} 1193}
1194 1194
1195void KOTodoView::setDocumentId( const QString &id ) 1195void KOTodoView::setDocumentId( const QString &id )
1196{ 1196{
1197 kdDebug() << "KOTodoView::setDocumentId()" << endl; 1197 kdDebug() << "KOTodoView::setDocumentId()" << endl;
1198 1198
1199 mDocPrefs->setDoc( id ); 1199 mDocPrefs->setDoc( id );
1200} 1200}
1201 1201
1202void KOTodoView::itemStateChanged( QListViewItem *item ) 1202void KOTodoView::itemStateChanged( QListViewItem *item )
1203{ 1203{
1204 if (!item) return; 1204 if (!item) return;
1205 1205
1206 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1206 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1207 1207
1208// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 1208// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
1209 1209
1210 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 1210 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
1211} 1211}
1212 1212
1213void KOTodoView::saveLayout(KConfig *config, const QString &group) const 1213void KOTodoView::saveLayout(KConfig *config, const QString &group) const
1214{ 1214{
1215 mTodoListView->saveLayout(config,group); 1215 mTodoListView->saveLayout(config,group);
1216} 1216}
1217 1217
1218void KOTodoView::restoreLayout(KConfig *config, const QString &group) 1218void KOTodoView::restoreLayout(KConfig *config, const QString &group)
1219{ 1219{
1220 mTodoListView->restoreLayout(config,group); 1220 mTodoListView->restoreLayout(config,group);
1221} 1221}
1222 1222
1223void KOTodoView::processSelectionChange() 1223void KOTodoView::processSelectionChange()
1224{ 1224{
1225// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 1225// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
1226 1226
1227 KOTodoViewItem *item = 1227 KOTodoViewItem *item =
1228 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 1228 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
1229 1229
1230 if ( !item ) { 1230 if ( !item ) {
1231 emit incidenceSelected( 0 ); 1231 emit incidenceSelected( 0 );
1232 } else { 1232 } else {
1233 emit incidenceSelected( item->todo() ); 1233 emit incidenceSelected( item->todo() );
1234 } 1234 }
1235} 1235}
1236 1236
1237void KOTodoView::modified(bool b) 1237void KOTodoView::modified(bool b)
1238{ 1238{
1239 emit isModified(b); 1239 emit isModified(b);
1240} 1240}
1241void KOTodoView::setTodoModified( Todo* todo ) 1241void KOTodoView::setTodoModified( Todo* todo )
1242{ 1242{
1243 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 1243 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
1244} 1244}
1245void KOTodoView::clearSelection() 1245void KOTodoView::clearSelection()
1246{ 1246{
1247 mTodoListView->selectAll( false ); 1247 mTodoListView->selectAll( false );
1248} 1248}
1249void KOTodoView::setAllOpen() 1249void KOTodoView::setAllOpen()
1250{ 1250{
1251 if ( isFlatDisplay ) { 1251 if ( isFlatDisplay ) {
1252 isFlatDisplay = false; 1252 isFlatDisplay = false;
1253 mPopupMenu->setItemChecked( 8,false ); 1253 mPopupMenu->setItemChecked( 8,false );
1254 updateView(); 1254 updateView();
1255 } else { 1255 } else {
1256 storeCurrentItem(); 1256 storeCurrentItem();
1257 } 1257 }
1258 setOpen(mTodoListView->firstChild(), true); 1258 setOpen(mTodoListView->firstChild(), true);
1259 resetCurrentItem(); 1259 resetCurrentItem();
1260} 1260}
1261void KOTodoView::setAllClose() 1261void KOTodoView::setAllClose()
1262{ 1262{