-rw-r--r-- | korganizer/calendarview.cpp | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 3dac20b..1009956 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -224,20 +224,24 @@ CalendarView::CalendarView( Calendar *calendar, | |||
224 | QWidget *parent, const char *name ) | 224 | QWidget *parent, const char *name ) |
225 | : CalendarViewBase( parent, name ), | 225 | : CalendarViewBase( parent, name ), |
226 | mCalendar( calendar ), | 226 | mCalendar( calendar ), |
227 | mResourceManager( 0 ) | 227 | mResourceManager( 0 ) |
228 | { | 228 | { |
229 | 229 | ||
230 | mEventEditor = 0; | 230 | mEventEditor = 0; |
231 | mTodoEditor = 0; | 231 | mTodoEditor = 0; |
232 | init();} | 232 | init(); |
233 | } | ||
233 | 234 | ||
234 | void CalendarView::init() | 235 | void CalendarView::init() |
235 | { | 236 | { |
237 | |||
238 | setFocusPolicy ( WheelFocus ); | ||
239 | mViewerCallerIsSearchDialog = false; | ||
236 | mBlockShowDates = false; | 240 | mBlockShowDates = false; |
237 | beamDialog = new KOBeamPrefs(); | 241 | beamDialog = new KOBeamPrefs(); |
238 | mDatePickerMode = 0; | 242 | mDatePickerMode = 0; |
239 | mCurrentSyncDevice = ""; | 243 | mCurrentSyncDevice = ""; |
240 | writeLocale(); | 244 | writeLocale(); |
241 | mViewManager = new KOViewManager( this ); | 245 | mViewManager = new KOViewManager( this ); |
242 | mDialogManager = new KODialogManager( this ); | 246 | mDialogManager = new KODialogManager( this ); |
243 | mEventViewerDialog = 0; | 247 | mEventViewerDialog = 0; |
@@ -2615,16 +2619,17 @@ void CalendarView::cloneIncidence(Incidence * orgInc ) | |||
2615 | mEventEditor->editEvent( e ); | 2619 | mEventEditor->editEvent( e ); |
2616 | if ( mEventEditor->exec() ) { | 2620 | if ( mEventEditor->exec() ) { |
2617 | mCalendar->addEvent( e ); | 2621 | mCalendar->addEvent( e ); |
2618 | updateView(); | 2622 | updateView(); |
2619 | } else { | 2623 | } else { |
2620 | delete e; | 2624 | delete e; |
2621 | } | 2625 | } |
2622 | } | 2626 | } |
2627 | setActiveWindow(); | ||
2623 | } | 2628 | } |
2624 | 2629 | ||
2625 | void CalendarView::newEvent() | 2630 | void CalendarView::newEvent() |
2626 | { | 2631 | { |
2627 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2632 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2628 | KOAgendaView *aView = mViewManager->agendaView(); | 2633 | KOAgendaView *aView = mViewManager->agendaView(); |
2629 | if (aView) { | 2634 | if (aView) { |
2630 | if (aView->selectionStart().isValid()) { | 2635 | if (aView->selectionStart().isValid()) { |
@@ -2672,16 +2677,18 @@ void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | |||
2672 | if ( mFilterView->filtersEnabled() ) { | 2677 | if ( mFilterView->filtersEnabled() ) { |
2673 | CalFilter *filter = mFilterView->selectedFilter(); | 2678 | CalFilter *filter = mFilterView->selectedFilter(); |
2674 | if (filter && filter->showCategories()) { | 2679 | if (filter && filter->showCategories()) { |
2675 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2680 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2676 | } | 2681 | } |
2677 | if ( filter ) | 2682 | if ( filter ) |
2678 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2683 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2679 | } | 2684 | } |
2685 | mEventEditor->exec(); | ||
2686 | setActiveWindow(); | ||
2680 | } | 2687 | } |
2681 | void CalendarView::todoAdded(Todo * t) | 2688 | void CalendarView::todoAdded(Todo * t) |
2682 | { | 2689 | { |
2683 | 2690 | ||
2684 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2691 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2685 | updateTodoViews(); | 2692 | updateTodoViews(); |
2686 | } | 2693 | } |
2687 | void CalendarView::todoChanged(Todo * t) | 2694 | void CalendarView::todoChanged(Todo * t) |
@@ -2708,16 +2715,18 @@ void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | |||
2708 | if ( mFilterView->filtersEnabled() ) { | 2715 | if ( mFilterView->filtersEnabled() ) { |
2709 | CalFilter *filter = mFilterView->selectedFilter(); | 2716 | CalFilter *filter = mFilterView->selectedFilter(); |
2710 | if (filter && filter->showCategories()) { | 2717 | if (filter && filter->showCategories()) { |
2711 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2718 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2712 | } | 2719 | } |
2713 | if ( filter ) | 2720 | if ( filter ) |
2714 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2721 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2715 | } | 2722 | } |
2723 | mTodoEditor->exec(); | ||
2724 | setActiveWindow(); | ||
2716 | } | 2725 | } |
2717 | 2726 | ||
2718 | void CalendarView::newTodo() | 2727 | void CalendarView::newTodo() |
2719 | { | 2728 | { |
2720 | newTodoDateTime( QDateTime(),true ); | 2729 | newTodoDateTime( QDateTime(),true ); |
2721 | } | 2730 | } |
2722 | 2731 | ||
2723 | void CalendarView::newSubTodo() | 2732 | void CalendarView::newSubTodo() |
@@ -2725,17 +2734,19 @@ void CalendarView::newSubTodo() | |||
2725 | Todo *todo = selectedTodo(); | 2734 | Todo *todo = selectedTodo(); |
2726 | if ( todo ) newSubTodo( todo ); | 2735 | if ( todo ) newSubTodo( todo ); |
2727 | } | 2736 | } |
2728 | 2737 | ||
2729 | void CalendarView::newSubTodo(Todo *parentEvent) | 2738 | void CalendarView::newSubTodo(Todo *parentEvent) |
2730 | { | 2739 | { |
2731 | 2740 | ||
2732 | showTodoEditor(); | 2741 | showTodoEditor(); |
2733 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 2742 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
2743 | mTodoEditor->exec(); | ||
2744 | setActiveWindow(); | ||
2734 | } | 2745 | } |
2735 | 2746 | ||
2736 | void CalendarView::newFloatingEvent() | 2747 | void CalendarView::newFloatingEvent() |
2737 | { | 2748 | { |
2738 | DateList tmpList = mNavigator->selectedDates(); | 2749 | DateList tmpList = mNavigator->selectedDates(); |
2739 | QDate date = tmpList.first(); | 2750 | QDate date = tmpList.first(); |
2740 | 2751 | ||
2741 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2752 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
@@ -2748,16 +2759,19 @@ void CalendarView::editEvent( Event *event ) | |||
2748 | 2759 | ||
2749 | if ( !event ) return; | 2760 | if ( !event ) return; |
2750 | if ( event->isReadOnly() ) { | 2761 | if ( event->isReadOnly() ) { |
2751 | showEvent( event ); | 2762 | showEvent( event ); |
2752 | return; | 2763 | return; |
2753 | } | 2764 | } |
2754 | showEventEditor(); | 2765 | showEventEditor(); |
2755 | mEventEditor->editEvent( event , mFlagEditDescription); | 2766 | mEventEditor->editEvent( event , mFlagEditDescription); |
2767 | mEventEditor->exec(); | ||
2768 | setActiveWindow(); | ||
2769 | |||
2756 | } | 2770 | } |
2757 | void CalendarView::editJournal( Journal *jour ) | 2771 | void CalendarView::editJournal( Journal *jour ) |
2758 | { | 2772 | { |
2759 | if ( !jour ) return; | 2773 | if ( !jour ) return; |
2760 | mDialogManager->hideSearchDialog(); | 2774 | mDialogManager->hideSearchDialog(); |
2761 | mViewManager->showJournalView(); | 2775 | mViewManager->showJournalView(); |
2762 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2776 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2763 | } | 2777 | } |
@@ -2766,29 +2780,33 @@ void CalendarView::editTodo( Todo *todo ) | |||
2766 | if ( !todo ) return; | 2780 | if ( !todo ) return; |
2767 | 2781 | ||
2768 | if ( todo->isReadOnly() ) { | 2782 | if ( todo->isReadOnly() ) { |
2769 | showTodo( todo ); | 2783 | showTodo( todo ); |
2770 | return; | 2784 | return; |
2771 | } | 2785 | } |
2772 | showTodoEditor(); | 2786 | showTodoEditor(); |
2773 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2787 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2788 | mTodoEditor->exec(); | ||
2789 | setActiveWindow(); | ||
2774 | 2790 | ||
2775 | } | 2791 | } |
2776 | 2792 | ||
2777 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2793 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2778 | { | 2794 | { |
2779 | if ( !mEventViewerDialog ) { | 2795 | if ( !mEventViewerDialog ) { |
2780 | mEventViewerDialog = new KOEventViewerDialog(this); | 2796 | mEventViewerDialog = new KOEventViewerDialog(this); |
2781 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2797 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2782 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2798 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2783 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2799 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2784 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2800 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2785 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2801 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2786 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2802 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2803 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | ||
2804 | this, SLOT( slotViewerClosed() ) ); | ||
2787 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 2805 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
2788 | this, SLOT( todoChanged(Todo *) ) ); | 2806 | this, SLOT( todoChanged(Todo *) ) ); |
2789 | mEventViewerDialog->resize( 640, 480 ); | 2807 | mEventViewerDialog->resize( 640, 480 ); |
2790 | 2808 | ||
2791 | } | 2809 | } |
2792 | return mEventViewerDialog; | 2810 | return mEventViewerDialog; |
2793 | } | 2811 | } |
2794 | void CalendarView::showEvent(Event *event) | 2812 | void CalendarView::showEvent(Event *event) |
@@ -3733,16 +3751,17 @@ Todo *CalendarView::selectedTodo() | |||
3733 | 3751 | ||
3734 | void CalendarView::dialogClosing(Incidence *in) | 3752 | void CalendarView::dialogClosing(Incidence *in) |
3735 | { | 3753 | { |
3736 | // mDialogList.remove(in); | 3754 | // mDialogList.remove(in); |
3737 | } | 3755 | } |
3738 | 3756 | ||
3739 | void CalendarView::showIncidence() | 3757 | void CalendarView::showIncidence() |
3740 | { | 3758 | { |
3759 | mViewerCallerIsSearchDialog = false; | ||
3741 | Incidence *incidence = currentSelection(); | 3760 | Incidence *incidence = currentSelection(); |
3742 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3761 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3743 | if ( incidence ) { | 3762 | if ( incidence ) { |
3744 | ShowIncidenceVisitor v; | 3763 | ShowIncidenceVisitor v; |
3745 | v.act( incidence, this ); | 3764 | v.act( incidence, this ); |
3746 | } | 3765 | } |
3747 | } | 3766 | } |
3748 | void CalendarView::editIncidenceDescription() | 3767 | void CalendarView::editIncidenceDescription() |
@@ -3768,16 +3787,23 @@ void CalendarView::deleteIncidence() | |||
3768 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3787 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3769 | if ( incidence ) { | 3788 | if ( incidence ) { |
3770 | deleteIncidence(incidence); | 3789 | deleteIncidence(incidence); |
3771 | } | 3790 | } |
3772 | } | 3791 | } |
3773 | 3792 | ||
3774 | void CalendarView::showIncidence(Incidence *incidence) | 3793 | void CalendarView::showIncidence(Incidence *incidence) |
3775 | { | 3794 | { |
3795 | mViewerCallerIsSearchDialog = false; | ||
3796 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | ||
3797 | if ( sender() && mDialogManager->getSearchDialog() ) { | ||
3798 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | ||
3799 | mViewerCallerIsSearchDialog = true; | ||
3800 | } | ||
3801 | } | ||
3776 | if ( incidence ) { | 3802 | if ( incidence ) { |
3777 | ShowIncidenceVisitor v; | 3803 | ShowIncidenceVisitor v; |
3778 | v.act( incidence, this ); | 3804 | v.act( incidence, this ); |
3779 | } | 3805 | } |
3780 | } | 3806 | } |
3781 | 3807 | ||
3782 | void CalendarView::editIncidence(Incidence *incidence) | 3808 | void CalendarView::editIncidence(Incidence *incidence) |
3783 | { | 3809 | { |
@@ -3917,8 +3943,32 @@ void CalendarView::undo_delete() | |||
3917 | } | 3943 | } |
3918 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 3944 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
3919 | i18n("\nAre you sure you want\nto restore this?"), | 3945 | i18n("\nAre you sure you want\nto restore this?"), |
3920 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 3946 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
3921 | mCalendar->undoDeleteIncidence(); | 3947 | mCalendar->undoDeleteIncidence(); |
3922 | updateView(); | 3948 | updateView(); |
3923 | } | 3949 | } |
3924 | } | 3950 | } |
3951 | |||
3952 | void CalendarView::slotViewerClosed() | ||
3953 | { | ||
3954 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | ||
3955 | } | ||
3956 | |||
3957 | void CalendarView::resetFocus() | ||
3958 | { | ||
3959 | if ( mViewerCallerIsSearchDialog ) { | ||
3960 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | ||
3961 | mDialogManager->getSearchDialog()->raise(); | ||
3962 | mDialogManager->getSearchDialog()->setActiveWindow(); | ||
3963 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | ||
3964 | } else | ||
3965 | mViewerCallerIsSearchDialog = false; | ||
3966 | } | ||
3967 | if ( !mViewerCallerIsSearchDialog ) { | ||
3968 | //mViewManager->currentView()->setFocus(); | ||
3969 | //qDebug("sssssssssssssssset focus "); | ||
3970 | setActiveWindow(); | ||
3971 | //setFocus(); | ||
3972 | } | ||
3973 | mViewerCallerIsSearchDialog = false; | ||
3974 | } | ||