-rw-r--r-- | korganizer/calendarview.cpp | 80 |
1 files changed, 73 insertions, 7 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index bc1c0c7..9a114d0 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -649,16 +649,82 @@ CalendarView::~CalendarView() | |||
649 | //qDebug("CalendarView::~CalendarView() "); | 649 | //qDebug("CalendarView::~CalendarView() "); |
650 | delete mDialogManager; | 650 | delete mDialogManager; |
651 | delete mViewManager; | 651 | delete mViewManager; |
652 | delete mStorage; | 652 | delete mStorage; |
653 | delete mDateFrame ; | 653 | delete mDateFrame ; |
654 | delete mEventViewerDialog; | 654 | delete mEventViewerDialog; |
655 | //kdDebug() << "~CalendarView() done" << endl; | 655 | //kdDebug() << "~CalendarView() done" << endl; |
656 | } | 656 | } |
657 | void CalendarView::nextConflict( bool all, bool allday ) | ||
658 | { | ||
659 | QDate start = mNavigator->selectedDates().first().addDays(1); | ||
660 | QDate end = start.addDays( 365*2); | ||
661 | while ( start < end ) { | ||
662 | QPtrList<Event> eventList = calendar()->events( start ); | ||
663 | Event * ev = eventList.first(); | ||
664 | QPtrList<Event> test = eventList; | ||
665 | while ( ev ) { | ||
666 | //qDebug("found %d on %s ", eventList.count(), start.toString().latin1()); | ||
667 | Event * t_ev = test.first(); | ||
668 | QDateTime es = ev->dtStart(); | ||
669 | QDateTime ee = ev->dtEnd(); | ||
670 | if ( ev->doesFloat() ) | ||
671 | ee = ee.addDays( 1 ); | ||
672 | if ( ! all ) { | ||
673 | if ( ev->doesFloat() != allday ) | ||
674 | t_ev = 0; | ||
675 | } | ||
676 | while ( t_ev ) { | ||
677 | bool skip = false; | ||
678 | if ( ! all ) { | ||
679 | if ( t_ev->doesFloat() != allday ) | ||
680 | skip = true; | ||
681 | } | ||
682 | if ( !skip && ev != t_ev ) { | ||
683 | QDateTime ets = t_ev->dtStart(); | ||
684 | QDateTime ete = t_ev->dtEnd(); | ||
685 | if ( t_ev->doesFloat() ) | ||
686 | ete = ete.addDays( 1 ); | ||
687 | //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() ); | ||
688 | if ( es < ete && ets < ee ) { | ||
689 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | ||
690 | mViewManager->showDayView(); | ||
691 | mNavigator->slotDaySelect( start ); | ||
692 | int hour = es.time().hour(); | ||
693 | if ( ets > es ) | ||
694 | hour = ets.time().hour(); | ||
695 | mViewManager->agendaView()->setStartHour( hour ); | ||
696 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) ); | ||
697 | return; | ||
698 | } | ||
699 | } | ||
700 | t_ev = test.next(); | ||
701 | } | ||
702 | ev = eventList.next(); | ||
703 | } | ||
704 | start = start.addDays( 1 ); | ||
705 | } | ||
706 | topLevelWidget()->setCaption( i18n("No conflict found within the next two years") ); | ||
707 | qDebug("No conflict found "); | ||
708 | } | ||
709 | |||
710 | void CalendarView::conflictAll() | ||
711 | { | ||
712 | nextConflict ( true, true ); | ||
713 | } | ||
714 | void CalendarView::conflictAllday() | ||
715 | { | ||
716 | nextConflict ( false, true ); | ||
717 | } | ||
718 | void CalendarView::conflictNotAll() | ||
719 | { | ||
720 | nextConflict ( false, false ); | ||
721 | } | ||
722 | |||
657 | void CalendarView::setCalReadOnly( int id, bool readO ) | 723 | void CalendarView::setCalReadOnly( int id, bool readO ) |
658 | { | 724 | { |
659 | if ( readO ) { | 725 | if ( readO ) { |
660 | emit save(); | 726 | emit save(); |
661 | } | 727 | } |
662 | mCalendar->setReadOnly( id, readO ); | 728 | mCalendar->setReadOnly( id, readO ); |
663 | } | 729 | } |
664 | void CalendarView::setScrollBarStep(int val ) | 730 | void CalendarView::setScrollBarStep(int val ) |
@@ -3157,17 +3223,17 @@ void CalendarView::cloneIncidence(Incidence * orgInc ) | |||
3157 | Incidence * newInc = orgInc->clone(); | 3223 | Incidence * newInc = orgInc->clone(); |
3158 | newInc->recreate(); | 3224 | newInc->recreate(); |
3159 | 3225 | ||
3160 | if ( newInc->typeID() == todoID ) { | 3226 | if ( newInc->typeID() == todoID ) { |
3161 | Todo* t = (Todo*) newInc; | 3227 | Todo* t = (Todo*) newInc; |
3162 | bool cloneSub = false; | 3228 | bool cloneSub = false; |
3163 | if ( orgInc->relations().count() ) { | 3229 | if ( orgInc->relations().count() ) { |
3164 | int result = KMessageBox::warningYesNoCancel(this, | 3230 | int result = KMessageBox::warningYesNoCancel(this, |
3165 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), | 3231 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), |
3166 | i18n("Todo has subtodos"), | 3232 | i18n("Todo has subtodos"), |
3167 | i18n("Yes"), | 3233 | i18n("Yes"), |
3168 | i18n("No")); | 3234 | i18n("No")); |
3169 | 3235 | ||
3170 | if ( result == KMessageBox::Cancel ) { | 3236 | if ( result == KMessageBox::Cancel ) { |
3171 | delete t; | 3237 | delete t; |
3172 | return; | 3238 | return; |
3173 | } | 3239 | } |
@@ -3495,17 +3561,17 @@ void CalendarView::todo_unsub(Todo *anTodo ) | |||
3495 | 3561 | ||
3496 | void CalendarView::deleteTodo(Todo *todo) | 3562 | void CalendarView::deleteTodo(Todo *todo) |
3497 | { | 3563 | { |
3498 | if (!todo) { | 3564 | if (!todo) { |
3499 | KNotifyClient::beep(); | 3565 | KNotifyClient::beep(); |
3500 | return; | 3566 | return; |
3501 | } | 3567 | } |
3502 | if (KOPrefs::instance()->mConfirm) { | 3568 | if (KOPrefs::instance()->mConfirm) { |
3503 | QString text = todo->summary().left(20); | 3569 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); |
3504 | if (!todo->relations().isEmpty()) { | 3570 | if (!todo->relations().isEmpty()) { |
3505 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3571 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3506 | 3572 | ||
3507 | } | 3573 | } |
3508 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { | 3574 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { |
3509 | case KMessageBox::Continue: // OK | 3575 | case KMessageBox::Continue: // OK |
3510 | bool deleteT = false; | 3576 | bool deleteT = false; |
3511 | if (!todo->relations().isEmpty()) { | 3577 | if (!todo->relations().isEmpty()) { |
@@ -3541,17 +3607,17 @@ void CalendarView::deleteJournal(Journal *jour) | |||
3541 | if ( !jour->summary().isEmpty() ) { | 3607 | if ( !jour->summary().isEmpty() ) { |
3542 | des = jour->summary(); | 3608 | des = jour->summary(); |
3543 | } else { | 3609 | } else { |
3544 | des = jour->description().left(30); | 3610 | des = jour->description().left(30); |
3545 | des = des.simplifyWhiteSpace (); | 3611 | des = des.simplifyWhiteSpace (); |
3546 | des.replace (QRegExp ("\\n"),"" ); | 3612 | des.replace (QRegExp ("\\n"),"" ); |
3547 | des.replace (QRegExp ("\\r"),"" ); | 3613 | des.replace (QRegExp ("\\r"),"" ); |
3548 | } | 3614 | } |
3549 | switch (msgItemDelete( i18n("Journal:") +"\n"+des.left(20))) { | 3615 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
3550 | case KMessageBox::Continue: // OK | 3616 | case KMessageBox::Continue: // OK |
3551 | calendar()->deleteJournal(jour); | 3617 | calendar()->deleteJournal(jour); |
3552 | updateView(); | 3618 | updateView(); |
3553 | break; | 3619 | break; |
3554 | } // switch | 3620 | } // switch |
3555 | } else { | 3621 | } else { |
3556 | calendar()->deleteJournal(jour);; | 3622 | calendar()->deleteJournal(jour);; |
3557 | updateView(); | 3623 | updateView(); |
@@ -3567,25 +3633,25 @@ void CalendarView::deleteEvent(Event *anEvent) | |||
3567 | } | 3633 | } |
3568 | 3634 | ||
3569 | if (anEvent->recurrence()->doesRecur()) { | 3635 | if (anEvent->recurrence()->doesRecur()) { |
3570 | QDate itemDate = mViewManager->currentSelectionDate(); | 3636 | QDate itemDate = mViewManager->currentSelectionDate(); |
3571 | int km; | 3637 | int km; |
3572 | if (!itemDate.isValid()) { | 3638 | if (!itemDate.isValid()) { |
3573 | //kdDebug() << "Date Not Valid" << endl; | 3639 | //kdDebug() << "Date Not Valid" << endl; |
3574 | if (KOPrefs::instance()->mConfirm) { | 3640 | if (KOPrefs::instance()->mConfirm) { |
3575 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3641 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3576 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3642 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3577 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3643 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3578 | if ( km == KMessageBox::Continue ) | 3644 | if ( km == KMessageBox::Continue ) |
3579 | km = KMessageBox::No; // No = all below | 3645 | km = KMessageBox::No; // No = all below |
3580 | } else | 3646 | } else |
3581 | km = KMessageBox::No; | 3647 | km = KMessageBox::No; |
3582 | } else { | 3648 | } else { |
3583 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 3649 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3584 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3650 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3585 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3651 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3586 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3652 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3587 | i18n("All")); | 3653 | i18n("All")); |
3588 | } | 3654 | } |
3589 | switch(km) { | 3655 | switch(km) { |
3590 | 3656 | ||
3591 | case KMessageBox::No: // Continue // all | 3657 | case KMessageBox::No: // Continue // all |
@@ -3616,17 +3682,17 @@ void CalendarView::deleteEvent(Event *anEvent) | |||
3616 | } | 3682 | } |
3617 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3683 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3618 | } | 3684 | } |
3619 | break; | 3685 | break; |
3620 | //#endif | 3686 | //#endif |
3621 | } // switch | 3687 | } // switch |
3622 | } else { | 3688 | } else { |
3623 | if (KOPrefs::instance()->mConfirm) { | 3689 | if (KOPrefs::instance()->mConfirm) { |
3624 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3690 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3625 | i18n("\nAre you sure you want\nto delete this event?"), | 3691 | i18n("\nAre you sure you want\nto delete this event?"), |
3626 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3692 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3627 | case KMessageBox::Continue: // OK | 3693 | case KMessageBox::Continue: // OK |
3628 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3694 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3629 | schedule(Scheduler::Cancel,anEvent); | 3695 | schedule(Scheduler::Cancel,anEvent); |
3630 | checkExternalId( anEvent); | 3696 | checkExternalId( anEvent); |
3631 | mCalendar->deleteEvent(anEvent); | 3697 | mCalendar->deleteEvent(anEvent); |
3632 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3698 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
@@ -4575,17 +4641,17 @@ void CalendarView::undo_delete() | |||
4575 | { | 4641 | { |
4576 | //qDebug("undo_delete() "); | 4642 | //qDebug("undo_delete() "); |
4577 | Incidence* undo = mCalendar->undoIncidence(); | 4643 | Incidence* undo = mCalendar->undoIncidence(); |
4578 | if ( !undo ) { | 4644 | if ( !undo ) { |
4579 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 4645 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
4580 | i18n("KO/Pi")); | 4646 | i18n("KO/Pi")); |
4581 | return; | 4647 | return; |
4582 | } | 4648 | } |
4583 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 4649 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + |
4584 | i18n("\nAre you sure you want\nto restore this?"), | 4650 | i18n("\nAre you sure you want\nto restore this?"), |
4585 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 4651 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
4586 | mCalendar->undoDeleteIncidence(); | 4652 | mCalendar->undoDeleteIncidence(); |
4587 | updateView(); | 4653 | updateView(); |
4588 | } | 4654 | } |
4589 | } | 4655 | } |
4590 | 4656 | ||
4591 | void CalendarView::slotViewerClosed() | 4657 | void CalendarView::slotViewerClosed() |