-rw-r--r-- | korganizer/calendarview.cpp | 27 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 6 |
2 files changed, 26 insertions, 7 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 98e0ac1..bc1c0c7 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -2798,70 +2798,74 @@ void CalendarView::slotSelectPickerDate( QDate d) | |||
2798 | Todo * to = (Todo *) mMoveIncidence; | 2798 | Todo * to = (Todo *) mMoveIncidence; |
2799 | QTime tim; | 2799 | QTime tim; |
2800 | int len = 0; | 2800 | int len = 0; |
2801 | if ( to->hasStartDate() && to->hasDueDate() ) | 2801 | if ( to->hasStartDate() && to->hasDueDate() ) |
2802 | len = to->dtStart().secsTo( to->dtDue()); | 2802 | len = to->dtStart().secsTo( to->dtDue()); |
2803 | if ( to->hasDueDate() ) | 2803 | if ( to->hasDueDate() ) |
2804 | tim = to->dtDue().time(); | 2804 | tim = to->dtDue().time(); |
2805 | else { | 2805 | else { |
2806 | tim = QTime ( 0,0,0 ); | 2806 | tim = QTime ( 0,0,0 ); |
2807 | to->setFloats( true ); | 2807 | to->setFloats( true ); |
2808 | to->setHasDueDate( true ); | 2808 | to->setHasDueDate( true ); |
2809 | } | 2809 | } |
2810 | QDateTime dt ( d,tim ); | 2810 | QDateTime dt ( d,tim ); |
2811 | to->setDtDue( dt ); | 2811 | to->setDtDue( dt ); |
2812 | 2812 | ||
2813 | if ( to->hasStartDate() ) { | 2813 | if ( to->hasStartDate() ) { |
2814 | if ( len>0 ) | 2814 | if ( len>0 ) |
2815 | to->setDtStart(to->dtDue().addSecs( -len )); | 2815 | to->setDtStart(to->dtDue().addSecs( -len )); |
2816 | else | 2816 | else |
2817 | if (to->dtStart() > to->dtDue() ) | 2817 | if (to->dtStart() > to->dtDue() ) |
2818 | to->setDtStart(to->dtDue().addDays( -3 )); | 2818 | to->setDtStart(to->dtDue().addDays( -3 )); |
2819 | } | 2819 | } |
2820 | 2820 | ||
2821 | todoChanged( to ); | 2821 | todoChanged( to ); |
2822 | } else { | 2822 | } else if ( mMoveIncidence->typeID() == eventID ) { |
2823 | if ( mMoveIncidence->doesRecur() ) { | 2823 | if ( mMoveIncidence->doesRecur() ) { |
2824 | #if 0 | 2824 | #if 0 |
2825 | // PENDING implement this | 2825 | // PENDING implement this |
2826 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2826 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2827 | mCalendar()->addIncidence( newInc ); | 2827 | mCalendar()->addIncidence( newInc ); |
2828 | if ( mMoveIncidence->typeID() == todoID ) | 2828 | if ( mMoveIncidence->typeID() == todoID ) |
2829 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2829 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2830 | else | 2830 | else |
2831 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2831 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2832 | mMoveIncidence = newInc; | 2832 | mMoveIncidence = newInc; |
2833 | 2833 | ||
2834 | #endif | 2834 | #endif |
2835 | } | 2835 | } |
2836 | QTime tim = mMoveIncidence->dtStart().time(); | 2836 | QTime tim = mMoveIncidence->dtStart().time(); |
2837 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2837 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2838 | QDateTime dt ( d,tim ); | 2838 | QDateTime dt ( d,tim ); |
2839 | mMoveIncidence->setDtStart( dt ); | 2839 | mMoveIncidence->setDtStart( dt ); |
2840 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2840 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2841 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2841 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2842 | } else if ( mMoveIncidence->typeID() == journalID ) { | ||
2843 | QTime tim = mMoveIncidence->dtStart().time(); | ||
2844 | QDateTime dt ( d,tim ); | ||
2845 | mMoveIncidence->setDtStart( dt ); | ||
2846 | updateView(); | ||
2842 | } | 2847 | } |
2843 | |||
2844 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2848 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2845 | } | 2849 | } |
2846 | } | 2850 | } |
2847 | 2851 | ||
2848 | void CalendarView::removeCategories() | 2852 | void CalendarView::removeCategories() |
2849 | { | 2853 | { |
2850 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2854 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2851 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2855 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2852 | QStringList catIncList; | 2856 | QStringList catIncList; |
2853 | QStringList newCatList; | 2857 | QStringList newCatList; |
2854 | Incidence* inc = incList.first(); | 2858 | Incidence* inc = incList.first(); |
2855 | uint i; | 2859 | uint i; |
2856 | while ( inc ) { | 2860 | while ( inc ) { |
2857 | newCatList.clear(); | 2861 | newCatList.clear(); |
2858 | catIncList = inc->categories() ; | 2862 | catIncList = inc->categories() ; |
2859 | for( i = 0; i< catIncList.count(); ++i ) { | 2863 | for( i = 0; i< catIncList.count(); ++i ) { |
2860 | if ( catList.contains (catIncList[i])) | 2864 | if ( catList.contains (catIncList[i])) |
2861 | newCatList.append( catIncList[i] ); | 2865 | newCatList.append( catIncList[i] ); |
2862 | } | 2866 | } |
2863 | newCatList.sort(); | 2867 | newCatList.sort(); |
2864 | inc->setCategories( newCatList.join(",") ); | 2868 | inc->setCategories( newCatList.join(",") ); |
2865 | inc = incList.next(); | 2869 | inc = incList.next(); |
2866 | } | 2870 | } |
2867 | } | 2871 | } |
@@ -3164,58 +3168,61 @@ void CalendarView::cloneIncidence(Incidence * orgInc ) | |||
3164 | i18n("No")); | 3168 | i18n("No")); |
3165 | 3169 | ||
3166 | if ( result == KMessageBox::Cancel ) { | 3170 | if ( result == KMessageBox::Cancel ) { |
3167 | delete t; | 3171 | delete t; |
3168 | return; | 3172 | return; |
3169 | } | 3173 | } |
3170 | if (result == KMessageBox::Yes) cloneSub = true; | 3174 | if (result == KMessageBox::Yes) cloneSub = true; |
3171 | } | 3175 | } |
3172 | showTodoEditor(); | 3176 | showTodoEditor(); |
3173 | mTodoEditor->editTodo( t ); | 3177 | mTodoEditor->editTodo( t ); |
3174 | if ( mTodoEditor->exec() ) { | 3178 | if ( mTodoEditor->exec() ) { |
3175 | if ( cloneSub ) { | 3179 | if ( cloneSub ) { |
3176 | orgInc->cloneRelations( t ); | 3180 | orgInc->cloneRelations( t ); |
3177 | mCalendar->addIncidenceBranch( t ); | 3181 | mCalendar->addIncidenceBranch( t ); |
3178 | updateView(); | 3182 | updateView(); |
3179 | 3183 | ||
3180 | } else { | 3184 | } else { |
3181 | mCalendar->addTodo( t ); | 3185 | mCalendar->addTodo( t ); |
3182 | updateView(); | 3186 | updateView(); |
3183 | } | 3187 | } |
3184 | } else { | 3188 | } else { |
3185 | delete t; | 3189 | delete t; |
3186 | } | 3190 | } |
3187 | } | 3191 | } |
3188 | else { | 3192 | else if ( newInc->typeID() == eventID ) { |
3189 | Event* e = (Event*) newInc; | 3193 | Event* e = (Event*) newInc; |
3190 | showEventEditor(); | 3194 | showEventEditor(); |
3191 | mEventEditor->editEvent( e ); | 3195 | mEventEditor->editEvent( e ); |
3192 | if ( mEventEditor->exec() ) { | 3196 | if ( mEventEditor->exec() ) { |
3193 | mCalendar->addEvent( e ); | 3197 | mCalendar->addEvent( e ); |
3194 | updateView(); | 3198 | updateView(); |
3195 | } else { | 3199 | } else { |
3196 | delete e; | 3200 | delete e; |
3197 | } | 3201 | } |
3202 | } if ( newInc->typeID() == journalID ) { | ||
3203 | mCalendar->addJournal( (Journal*) newInc ); | ||
3204 | editJournal( (Journal*) newInc ); | ||
3198 | } | 3205 | } |
3199 | setActiveWindow(); | 3206 | setActiveWindow(); |
3200 | } | 3207 | } |
3201 | 3208 | ||
3202 | void CalendarView::newEvent() | 3209 | void CalendarView::newEvent() |
3203 | { | 3210 | { |
3204 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3211 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3205 | KOAgendaView *aView = mViewManager->agendaView(); | 3212 | KOAgendaView *aView = mViewManager->agendaView(); |
3206 | if (aView) { | 3213 | if (aView) { |
3207 | if (aView->selectionStart().isValid()) { | 3214 | if (aView->selectionStart().isValid()) { |
3208 | if (aView->selectedIsAllDay()) { | 3215 | if (aView->selectedIsAllDay()) { |
3209 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3216 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3210 | } else { | 3217 | } else { |
3211 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3218 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3212 | } | 3219 | } |
3213 | return; | 3220 | return; |
3214 | } | 3221 | } |
3215 | } | 3222 | } |
3216 | 3223 | ||
3217 | QDate date = mNavigator->selectedDates().first(); | 3224 | QDate date = mNavigator->selectedDates().first(); |
3218 | QDateTime current = QDateTime::currentDateTime(); | 3225 | QDateTime current = QDateTime::currentDateTime(); |
3219 | if ( date <= current.date() ) { | 3226 | if ( date <= current.date() ) { |
3220 | int hour = current.time().hour() +1; | 3227 | int hour = current.time().hour() +1; |
3221 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3228 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
@@ -3477,80 +3484,90 @@ void CalendarView::todo_resub( Todo * parent, Todo * sub ) | |||
3477 | if ( sub->relatedTo() == parent ) | 3484 | if ( sub->relatedTo() == parent ) |
3478 | return; | 3485 | return; |
3479 | sub->setRelatedTo(parent); | 3486 | sub->setRelatedTo(parent); |
3480 | sub->updated(); | 3487 | sub->updated(); |
3481 | setModified(true); | 3488 | setModified(true); |
3482 | updateView(); | 3489 | updateView(); |
3483 | } | 3490 | } |
3484 | void CalendarView::todo_unsub(Todo *anTodo ) | 3491 | void CalendarView::todo_unsub(Todo *anTodo ) |
3485 | { | 3492 | { |
3486 | todo_resub( 0, anTodo ); | 3493 | todo_resub( 0, anTodo ); |
3487 | } | 3494 | } |
3488 | 3495 | ||
3489 | void CalendarView::deleteTodo(Todo *todo) | 3496 | void CalendarView::deleteTodo(Todo *todo) |
3490 | { | 3497 | { |
3491 | if (!todo) { | 3498 | if (!todo) { |
3492 | KNotifyClient::beep(); | 3499 | KNotifyClient::beep(); |
3493 | return; | 3500 | return; |
3494 | } | 3501 | } |
3495 | if (KOPrefs::instance()->mConfirm) { | 3502 | if (KOPrefs::instance()->mConfirm) { |
3496 | QString text = todo->summary().left(20); | 3503 | QString text = todo->summary().left(20); |
3497 | if (!todo->relations().isEmpty()) { | 3504 | if (!todo->relations().isEmpty()) { |
3498 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3505 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3499 | 3506 | ||
3500 | } | 3507 | } |
3501 | switch (msgItemDelete(text)) { | 3508 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { |
3502 | case KMessageBox::Continue: // OK | 3509 | case KMessageBox::Continue: // OK |
3503 | bool deleteT = false; | 3510 | bool deleteT = false; |
3504 | if (!todo->relations().isEmpty()) { | 3511 | if (!todo->relations().isEmpty()) { |
3505 | deleteT = removeCompletedSubTodos( todo ); | 3512 | deleteT = removeCompletedSubTodos( todo ); |
3506 | } | 3513 | } |
3507 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3514 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3508 | if ( !deleteT ) { | 3515 | if ( !deleteT ) { |
3509 | checkExternalId( todo ); | 3516 | checkExternalId( todo ); |
3510 | calendar()->deleteTodo(todo); | 3517 | calendar()->deleteTodo(todo); |
3511 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3518 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3512 | updateView(); | 3519 | updateView(); |
3513 | } | 3520 | } |
3514 | break; | 3521 | break; |
3515 | } // switch | 3522 | } // switch |
3516 | } else { | 3523 | } else { |
3517 | checkExternalId( todo ); | 3524 | checkExternalId( todo ); |
3518 | mCalendar->deleteTodo(todo); | 3525 | mCalendar->deleteTodo(todo); |
3519 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3526 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3520 | updateView(); | 3527 | updateView(); |
3521 | } | 3528 | } |
3522 | 3529 | ||
3523 | emit updateSearchDialog(); | 3530 | emit updateSearchDialog(); |
3524 | } | 3531 | } |
3525 | void CalendarView::deleteJournal(Journal *jour) | 3532 | void CalendarView::deleteJournal(Journal *jour) |
3526 | { | 3533 | { |
3527 | if (!jour) { | 3534 | if (!jour) { |
3528 | KNotifyClient::beep(); | 3535 | KNotifyClient::beep(); |
3529 | return; | 3536 | return; |
3530 | } | 3537 | } |
3531 | if (KOPrefs::instance()->mConfirm) { | 3538 | if (KOPrefs::instance()->mConfirm) { |
3532 | switch (msgItemDelete( jour->description().left(20))) { | 3539 | |
3540 | QString des; | ||
3541 | if ( !jour->summary().isEmpty() ) { | ||
3542 | des = jour->summary(); | ||
3543 | } else { | ||
3544 | des = jour->description().left(30); | ||
3545 | des = des.simplifyWhiteSpace (); | ||
3546 | des.replace (QRegExp ("\\n"),"" ); | ||
3547 | des.replace (QRegExp ("\\r"),"" ); | ||
3548 | } | ||
3549 | switch (msgItemDelete( i18n("Journal:") +"\n"+des.left(20))) { | ||
3533 | case KMessageBox::Continue: // OK | 3550 | case KMessageBox::Continue: // OK |
3534 | calendar()->deleteJournal(jour); | 3551 | calendar()->deleteJournal(jour); |
3535 | updateView(); | 3552 | updateView(); |
3536 | break; | 3553 | break; |
3537 | } // switch | 3554 | } // switch |
3538 | } else { | 3555 | } else { |
3539 | calendar()->deleteJournal(jour);; | 3556 | calendar()->deleteJournal(jour);; |
3540 | updateView(); | 3557 | updateView(); |
3541 | } | 3558 | } |
3542 | emit updateSearchDialog(); | 3559 | emit updateSearchDialog(); |
3543 | } | 3560 | } |
3544 | 3561 | ||
3545 | void CalendarView::deleteEvent(Event *anEvent) | 3562 | void CalendarView::deleteEvent(Event *anEvent) |
3546 | { | 3563 | { |
3547 | if (!anEvent) { | 3564 | if (!anEvent) { |
3548 | KNotifyClient::beep(); | 3565 | KNotifyClient::beep(); |
3549 | return; | 3566 | return; |
3550 | } | 3567 | } |
3551 | 3568 | ||
3552 | if (anEvent->recurrence()->doesRecur()) { | 3569 | if (anEvent->recurrence()->doesRecur()) { |
3553 | QDate itemDate = mViewManager->currentSelectionDate(); | 3570 | QDate itemDate = mViewManager->currentSelectionDate(); |
3554 | int km; | 3571 | int km; |
3555 | if (!itemDate.isValid()) { | 3572 | if (!itemDate.isValid()) { |
3556 | //kdDebug() << "Date Not Valid" << endl; | 3573 | //kdDebug() << "Date Not Valid" << endl; |
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 5f90dc6..7783dd4 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -950,75 +950,77 @@ void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, | |||
950 | #ifndef KORG_NOPRINTER | 950 | #ifndef KORG_NOPRINTER |
951 | calPrinter->preview(CalPrinter::Day, fd, td); | 951 | calPrinter->preview(CalPrinter::Day, fd, td); |
952 | #endif | 952 | #endif |
953 | } | 953 | } |
954 | 954 | ||
955 | void KOListView::showDates() | 955 | void KOListView::showDates() |
956 | { | 956 | { |
957 | showDates(true); | 957 | showDates(true); |
958 | } | 958 | } |
959 | 959 | ||
960 | void KOListView::hideDates() | 960 | void KOListView::hideDates() |
961 | { | 961 | { |
962 | showDates(false); | 962 | showDates(false); |
963 | } | 963 | } |
964 | 964 | ||
965 | void KOListView::resetFocus() | 965 | void KOListView::resetFocus() |
966 | { | 966 | { |
967 | topLevelWidget()->setActiveWindow(); | 967 | topLevelWidget()->setActiveWindow(); |
968 | topLevelWidget()->raise(); | 968 | topLevelWidget()->raise(); |
969 | mListView->setFocus(); | 969 | mListView->setFocus(); |
970 | } | 970 | } |
971 | void KOListView::updateView() | 971 | void KOListView::updateView() |
972 | { | 972 | { |
973 | mListView->setFocus(); | 973 | mListView->setFocus(); |
974 | if ( mListView->firstChild () ) | 974 | if ( mListView->firstChild () ) { |
975 | mListView->setCurrentItem( mListView->firstChild () ); | 975 | mListView->setCurrentItem( mListView->firstChild () ); |
976 | } | ||
977 | processSelectionChange( mListView->firstChild () ); | ||
976 | } | 978 | } |
977 | void KOListView::updateConfig() | 979 | void KOListView::updateConfig() |
978 | { | 980 | { |
979 | 981 | ||
980 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 982 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
981 | updateView(); | 983 | updateView(); |
982 | 984 | ||
983 | } | 985 | } |
984 | void KOListView::setStartDate(const QDate &start) | 986 | void KOListView::setStartDate(const QDate &start) |
985 | { | 987 | { |
986 | mStartDate = start; | 988 | mStartDate = start; |
987 | } | 989 | } |
988 | 990 | ||
989 | void KOListView::showDates(const QDate &start, const QDate &end) | 991 | void KOListView::showDates(const QDate &start, const QDate &end) |
990 | { | 992 | { |
991 | clear(); | 993 | clear(); |
992 | mStartDate = start; | 994 | mStartDate = start; |
993 | QDate date = start; | 995 | QDate date = start; |
994 | while( date <= end ) { | 996 | while( date <= end ) { |
995 | addEvents(calendar()->events(date)); | 997 | addEvents(calendar()->events(date)); |
996 | addTodos(calendar()->todos(date)); | 998 | addTodos(calendar()->todos(date)); |
997 | addJournals( calendar()->journals4Date(date) ); | 999 | addJournals( calendar()->journals4Date(date) ); |
998 | date = date.addDays( 1 ); | 1000 | date = date.addDays( 1 ); |
999 | } | 1001 | } |
1000 | emit incidenceSelected( 0 ); | 1002 | //emit incidenceSelected( 0 ); |
1001 | updateView(); | 1003 | updateView(); |
1002 | 1004 | ||
1003 | } | 1005 | } |
1004 | 1006 | ||
1005 | void KOListView::addEvents(QPtrList<Event> eventList) | 1007 | void KOListView::addEvents(QPtrList<Event> eventList) |
1006 | { | 1008 | { |
1007 | 1009 | ||
1008 | Event *ev; | 1010 | Event *ev; |
1009 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 1011 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
1010 | addIncidence(ev); | 1012 | addIncidence(ev); |
1011 | } | 1013 | } |
1012 | if ( !mListView->currentItem() ){ | 1014 | if ( !mListView->currentItem() ){ |
1013 | updateView(); | 1015 | updateView(); |
1014 | } | 1016 | } |
1015 | } | 1017 | } |
1016 | 1018 | ||
1017 | void KOListView::addTodos(QPtrList<Todo> eventList) | 1019 | void KOListView::addTodos(QPtrList<Todo> eventList) |
1018 | { | 1020 | { |
1019 | Todo *ev; | 1021 | Todo *ev; |
1020 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 1022 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
1021 | addIncidence(ev); | 1023 | addIncidence(ev); |
1022 | } | 1024 | } |
1023 | if ( !mListView->currentItem() ){ | 1025 | if ( !mListView->currentItem() ){ |
1024 | updateView(); | 1026 | updateView(); |