summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
authorzautrix <zautrix>2005-02-23 18:47:45 (UTC)
committer zautrix <zautrix>2005-02-23 18:47:45 (UTC)
commit31f24d21cd23bb7e4033e7ffa000e6c979133ce7 (patch) (unidiff)
tree2fa81f67efc6544a3664e6039a9602ef6f3466b9 /korganizer/calendarview.cpp
parentfaedffc5ce8391204e0340a21eaaf582319ac824 (diff)
downloadkdepimpi-31f24d21cd23bb7e4033e7ffa000e6c979133ce7.zip
kdepimpi-31f24d21cd23bb7e4033e7ffa000e6c979133ce7.tar.gz
kdepimpi-31f24d21cd23bb7e4033e7ffa000e6c979133ce7.tar.bz2
many focus fixes
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp52
1 files changed, 51 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 3dac20b..1009956 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -184,100 +184,104 @@ class KOCatPrefs : public QDialog
184 lay->setSpacing( 3 ); 184 lay->setSpacing( 3 );
185 lay->setMargin( 3 ); 185 lay->setMargin( 3 );
186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
187 lay->addWidget( lab ); 187 lay->addWidget( lab );
188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
189 lay->addWidget( format ); 189 lay->addWidget( format );
190 format->setExclusive ( true ) ; 190 format->setExclusive ( true ) ;
191 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 191 addCatBut = new QRadioButton(i18n("Add to category list"), format );
192 new QRadioButton(i18n("Remove from Events/Todos"), format ); 192 new QRadioButton(i18n("Remove from Events/Todos"), format );
193 addCatBut->setChecked( true ); 193 addCatBut->setChecked( true );
194 QPushButton * ok = new QPushButton( i18n("OK"), this ); 194 QPushButton * ok = new QPushButton( i18n("OK"), this );
195 lay->addWidget( ok ); 195 lay->addWidget( ok );
196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
197 lay->addWidget( cancel ); 197 lay->addWidget( cancel );
198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
200 resize( 200, 200 ); 200 resize( 200, 200 );
201 } 201 }
202 202
203 bool addCat() { return addCatBut->isChecked(); } 203 bool addCat() { return addCatBut->isChecked(); }
204private: 204private:
205 QRadioButton* addCatBut; 205 QRadioButton* addCatBut;
206}; 206};
207 207
208 208
209 209
210CalendarView::CalendarView( CalendarResources *calendar, 210CalendarView::CalendarView( CalendarResources *calendar,
211 QWidget *parent, const char *name ) 211 QWidget *parent, const char *name )
212 : CalendarViewBase( parent, name ), 212 : CalendarViewBase( parent, name ),
213 mCalendar( calendar ), 213 mCalendar( calendar ),
214 mResourceManager( calendar->resourceManager() ) 214 mResourceManager( calendar->resourceManager() )
215{ 215{
216 216
217 mEventEditor = 0; 217 mEventEditor = 0;
218 mTodoEditor = 0; 218 mTodoEditor = 0;
219 219
220 init(); 220 init();
221} 221}
222 222
223CalendarView::CalendarView( Calendar *calendar, 223CalendarView::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
234void CalendarView::init() 235void 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;
244 mModified = false; 248 mModified = false;
245 mReadOnly = false; 249 mReadOnly = false;
246 mSelectedIncidence = 0; 250 mSelectedIncidence = 0;
247 mCalPrinter = 0; 251 mCalPrinter = 0;
248 mFilters.setAutoDelete(true); 252 mFilters.setAutoDelete(true);
249 253
250 mCalendar->registerObserver( this ); 254 mCalendar->registerObserver( this );
251 // TODO: Make sure that view is updated, when calendar is changed. 255 // TODO: Make sure that view is updated, when calendar is changed.
252 256
253 mStorage = new FileStorage( mCalendar ); 257 mStorage = new FileStorage( mCalendar );
254 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 258 mNavigator = new DateNavigator( this, "datevav", mViewManager );
255 259
256 QBoxLayout *topLayout = (QBoxLayout*)layout(); 260 QBoxLayout *topLayout = (QBoxLayout*)layout();
257#ifndef KORG_NOSPLITTER 261#ifndef KORG_NOSPLITTER
258 // create the main layout frames. 262 // create the main layout frames.
259 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 263 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
260 topLayout->addWidget(mPanner); 264 topLayout->addWidget(mPanner);
261 265
262 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 266 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
263 "CalendarView::LeftFrame"); 267 "CalendarView::LeftFrame");
264 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 268 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
265 269
266 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 270 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
267 "CalendarView::DateNavigator", QDate::currentDate() ); 271 "CalendarView::DateNavigator", QDate::currentDate() );
268 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 272 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
269 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 273 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
270 mTodoList->setNavigator( mNavigator ); 274 mTodoList->setNavigator( mNavigator );
271 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 275 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
272 276
273#ifdef KORG_NORESOURCEVIEW 277#ifdef KORG_NORESOURCEVIEW
274 mResourceView = 0; 278 mResourceView = 0;
275#else 279#else
276 if ( mResourceManager ) { 280 if ( mResourceManager ) {
277 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 281 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
278 mResourceView->updateView(); 282 mResourceView->updateView();
279 connect( mResourceView, SIGNAL( resourcesChanged() ), 283 connect( mResourceView, SIGNAL( resourcesChanged() ),
280 SLOT( updateView() ) ); 284 SLOT( updateView() ) );
281 } else { 285 } else {
282 mResourceView = 0; 286 mResourceView = 0;
283 } 287 }
@@ -2575,260 +2579,274 @@ void CalendarView::beamIncidence()
2575 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2579 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2576 if ( incidence ) { 2580 if ( incidence ) {
2577 beamIncidence(incidence); 2581 beamIncidence(incidence);
2578 } 2582 }
2579} 2583}
2580void CalendarView::toggleCancelIncidence() 2584void CalendarView::toggleCancelIncidence()
2581{ 2585{
2582 Incidence *incidence = currentSelection(); 2586 Incidence *incidence = currentSelection();
2583 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2587 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2584 if ( incidence ) { 2588 if ( incidence ) {
2585 cancelIncidence(incidence); 2589 cancelIncidence(incidence);
2586 } 2590 }
2587} 2591}
2588 2592
2589 2593
2590void CalendarView::cancelIncidence(Incidence * inc ) 2594void CalendarView::cancelIncidence(Incidence * inc )
2591{ 2595{
2592 inc->setCancelled( ! inc->cancelled() ); 2596 inc->setCancelled( ! inc->cancelled() );
2593 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2597 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2594 updateView(); 2598 updateView();
2595} 2599}
2596void CalendarView::cloneIncidence(Incidence * orgInc ) 2600void CalendarView::cloneIncidence(Incidence * orgInc )
2597{ 2601{
2598 Incidence * newInc = orgInc->clone(); 2602 Incidence * newInc = orgInc->clone();
2599 newInc->recreate(); 2603 newInc->recreate();
2600 2604
2601 if ( newInc->type() == "Todo" ) { 2605 if ( newInc->type() == "Todo" ) {
2602 Todo* t = (Todo*) newInc; 2606 Todo* t = (Todo*) newInc;
2603 showTodoEditor(); 2607 showTodoEditor();
2604 mTodoEditor->editTodo( t ); 2608 mTodoEditor->editTodo( t );
2605 if ( mTodoEditor->exec() ) { 2609 if ( mTodoEditor->exec() ) {
2606 mCalendar->addTodo( t ); 2610 mCalendar->addTodo( t );
2607 updateView(); 2611 updateView();
2608 } else { 2612 } else {
2609 delete t; 2613 delete t;
2610 } 2614 }
2611 } 2615 }
2612 else { 2616 else {
2613 Event* e = (Event*) newInc; 2617 Event* e = (Event*) newInc;
2614 showEventEditor(); 2618 showEventEditor();
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
2625void CalendarView::newEvent() 2630void 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()) {
2631 if (aView->selectedIsAllDay()) { 2636 if (aView->selectedIsAllDay()) {
2632 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2637 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2633 } else { 2638 } else {
2634 newEvent(aView->selectionStart(),aView->selectionEnd()); 2639 newEvent(aView->selectionStart(),aView->selectionEnd());
2635 } 2640 }
2636 return; 2641 return;
2637 } 2642 }
2638 } 2643 }
2639 2644
2640 QDate date = mNavigator->selectedDates().first(); 2645 QDate date = mNavigator->selectedDates().first();
2641 QDateTime current = QDateTime::currentDateTime(); 2646 QDateTime current = QDateTime::currentDateTime();
2642 if ( date <= current.date() ) { 2647 if ( date <= current.date() ) {
2643 int hour = current.time().hour() +1; 2648 int hour = current.time().hour() +1;
2644 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2649 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2645 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2650 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2646 } else 2651 } else
2647 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2652 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2648 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2653 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2649 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2654 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2650} 2655}
2651 2656
2652void CalendarView::newEvent(QDateTime fh) 2657void CalendarView::newEvent(QDateTime fh)
2653{ 2658{
2654 newEvent(fh, 2659 newEvent(fh,
2655 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2660 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2656} 2661}
2657 2662
2658void CalendarView::newEvent(QDate dt) 2663void CalendarView::newEvent(QDate dt)
2659{ 2664{
2660 newEvent(QDateTime(dt, QTime(0,0,0)), 2665 newEvent(QDateTime(dt, QTime(0,0,0)),
2661 QDateTime(dt, QTime(0,0,0)), true); 2666 QDateTime(dt, QTime(0,0,0)), true);
2662} 2667}
2663void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 2668void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2664{ 2669{
2665 newEvent(fromHint, toHint, false); 2670 newEvent(fromHint, toHint, false);
2666} 2671}
2667void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2672void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2668{ 2673{
2669 2674
2670 showEventEditor(); 2675 showEventEditor();
2671 mEventEditor->newEvent(fromHint,toHint,allDay); 2676 mEventEditor->newEvent(fromHint,toHint,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}
2681void CalendarView::todoAdded(Todo * t) 2688void CalendarView::todoAdded(Todo * t)
2682{ 2689{
2683 2690
2684 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2691 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2685 updateTodoViews(); 2692 updateTodoViews();
2686} 2693}
2687void CalendarView::todoChanged(Todo * t) 2694void CalendarView::todoChanged(Todo * t)
2688{ 2695{
2689 emit todoModified( t, 4 ); 2696 emit todoModified( t, 4 );
2690 // updateTodoViews(); 2697 // updateTodoViews();
2691} 2698}
2692void CalendarView::todoToBeDeleted(Todo *) 2699void CalendarView::todoToBeDeleted(Todo *)
2693{ 2700{
2694 //qDebug("todoToBeDeleted(Todo *) "); 2701 //qDebug("todoToBeDeleted(Todo *) ");
2695 updateTodoViews(); 2702 updateTodoViews();
2696} 2703}
2697void CalendarView::todoDeleted() 2704void CalendarView::todoDeleted()
2698{ 2705{
2699 //qDebug(" todoDeleted()"); 2706 //qDebug(" todoDeleted()");
2700 updateTodoViews(); 2707 updateTodoViews();
2701} 2708}
2702 2709
2703 2710
2704void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 2711void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
2705{ 2712{
2706 showTodoEditor(); 2713 showTodoEditor();
2707 mTodoEditor->newTodo(dt,0,allday); 2714 mTodoEditor->newTodo(dt,0,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
2718void CalendarView::newTodo() 2727void CalendarView::newTodo()
2719{ 2728{
2720 newTodoDateTime( QDateTime(),true ); 2729 newTodoDateTime( QDateTime(),true );
2721} 2730}
2722 2731
2723void CalendarView::newSubTodo() 2732void CalendarView::newSubTodo()
2724{ 2733{
2725 Todo *todo = selectedTodo(); 2734 Todo *todo = selectedTodo();
2726 if ( todo ) newSubTodo( todo ); 2735 if ( todo ) newSubTodo( todo );
2727} 2736}
2728 2737
2729void CalendarView::newSubTodo(Todo *parentEvent) 2738void 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
2736void CalendarView::newFloatingEvent() 2747void 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 ) ),
2742 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2753 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2743} 2754}
2744 2755
2745 2756
2746void CalendarView::editEvent( Event *event ) 2757void CalendarView::editEvent( Event *event )
2747{ 2758{
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}
2757void CalendarView::editJournal( Journal *jour ) 2771void 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}
2764void CalendarView::editTodo( Todo *todo ) 2778void CalendarView::editTodo( Todo *todo )
2765{ 2779{
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
2777KOEventViewerDialog* CalendarView::getEventViewerDialog() 2793KOEventViewerDialog* 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}
2794void CalendarView::showEvent(Event *event) 2812void CalendarView::showEvent(Event *event)
2795{ 2813{
2796 getEventViewerDialog()->setEvent(event); 2814 getEventViewerDialog()->setEvent(event);
2797 getEventViewerDialog()->showMe(); 2815 getEventViewerDialog()->showMe();
2798} 2816}
2799 2817
2800void CalendarView::showTodo(Todo *event) 2818void CalendarView::showTodo(Todo *event)
2801{ 2819{
2802 getEventViewerDialog()->setTodo(event); 2820 getEventViewerDialog()->setTodo(event);
2803 getEventViewerDialog()->showMe(); 2821 getEventViewerDialog()->showMe();
2804} 2822}
2805void CalendarView::showJournal( Journal *jour ) 2823void CalendarView::showJournal( Journal *jour )
2806{ 2824{
2807 getEventViewerDialog()->setJournal(jour); 2825 getEventViewerDialog()->setJournal(jour);
2808 getEventViewerDialog()->showMe(); 2826 getEventViewerDialog()->showMe();
2809 2827
2810} 2828}
2811// void CalendarView::todoModified (Todo *event, int changed) 2829// void CalendarView::todoModified (Todo *event, int changed)
2812// { 2830// {
2813// // if (mDialogList.find (event) != mDialogList.end ()) { 2831// // if (mDialogList.find (event) != mDialogList.end ()) {
2814// // kdDebug() << "Todo modified and open" << endl; 2832// // kdDebug() << "Todo modified and open" << endl;
2815// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2833// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2816// // temp->modified (changed); 2834// // temp->modified (changed);
2817 2835
2818// // } 2836// // }
2819 2837
2820// mViewManager->updateView(); 2838// mViewManager->updateView();
2821// } 2839// }
2822 2840
2823void CalendarView::appointment_show() 2841void CalendarView::appointment_show()
2824{ 2842{
2825 Event *anEvent = 0; 2843 Event *anEvent = 0;
2826 2844
2827 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2845 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2828 2846
2829 if (mViewManager->currentView()->isEventView()) { 2847 if (mViewManager->currentView()->isEventView()) {
2830 if ( incidence && incidence->type() == "Event" ) { 2848 if ( incidence && incidence->type() == "Event" ) {
2831 anEvent = static_cast<Event *>(incidence); 2849 anEvent = static_cast<Event *>(incidence);
2832 } 2850 }
2833 } 2851 }
2834 2852
@@ -3693,131 +3711,139 @@ void CalendarView::toggleAllDaySize()
3693 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3711 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3694 */ 3712 */
3695 viewManager()->agendaView()->toggleAllDay(); 3713 viewManager()->agendaView()->toggleAllDay();
3696} 3714}
3697void CalendarView::toggleExpand() 3715void CalendarView::toggleExpand()
3698{ 3716{
3699 // if ( mLeftFrame->isHidden() ) { 3717 // if ( mLeftFrame->isHidden() ) {
3700 // mLeftFrame->show(); 3718 // mLeftFrame->show();
3701 // emit calendarViewExpanded( false ); 3719 // emit calendarViewExpanded( false );
3702 // } else { 3720 // } else {
3703 // mLeftFrame->hide(); 3721 // mLeftFrame->hide();
3704 // emit calendarViewExpanded( true ); 3722 // emit calendarViewExpanded( true );
3705 // } 3723 // }
3706 //qDebug(" CalendarView::toggleExpand()"); 3724 //qDebug(" CalendarView::toggleExpand()");
3707 globalFlagBlockAgenda = 1; 3725 globalFlagBlockAgenda = 1;
3708 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3726 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3709 globalFlagBlockAgenda = 5; 3727 globalFlagBlockAgenda = 5;
3710 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3728 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3711 //mViewManager->showView( 0, true ); 3729 //mViewManager->showView( 0, true );
3712} 3730}
3713 3731
3714void CalendarView::calendarModified( bool modified, Calendar * ) 3732void CalendarView::calendarModified( bool modified, Calendar * )
3715{ 3733{
3716 setModified( modified ); 3734 setModified( modified );
3717} 3735}
3718 3736
3719Todo *CalendarView::selectedTodo() 3737Todo *CalendarView::selectedTodo()
3720{ 3738{
3721 Incidence *incidence = currentSelection(); 3739 Incidence *incidence = currentSelection();
3722 if ( incidence && incidence->type() == "Todo" ) { 3740 if ( incidence && incidence->type() == "Todo" ) {
3723 return static_cast<Todo *>( incidence ); 3741 return static_cast<Todo *>( incidence );
3724 } 3742 }
3725 3743
3726 incidence = mTodoList->selectedIncidences().first(); 3744 incidence = mTodoList->selectedIncidences().first();
3727 if ( incidence && incidence->type() == "Todo" ) { 3745 if ( incidence && incidence->type() == "Todo" ) {
3728 return static_cast<Todo *>( incidence ); 3746 return static_cast<Todo *>( incidence );
3729 } 3747 }
3730 3748
3731 return 0; 3749 return 0;
3732} 3750}
3733 3751
3734void CalendarView::dialogClosing(Incidence *in) 3752void CalendarView::dialogClosing(Incidence *in)
3735{ 3753{
3736 // mDialogList.remove(in); 3754 // mDialogList.remove(in);
3737} 3755}
3738 3756
3739void CalendarView::showIncidence() 3757void 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}
3748void CalendarView::editIncidenceDescription() 3767void CalendarView::editIncidenceDescription()
3749{ 3768{
3750 mFlagEditDescription = true; 3769 mFlagEditDescription = true;
3751 editIncidence(); 3770 editIncidence();
3752 mFlagEditDescription = false; 3771 mFlagEditDescription = false;
3753} 3772}
3754void CalendarView::editIncidence() 3773void CalendarView::editIncidence()
3755{ 3774{
3756 // qDebug("editIncidence() "); 3775 // qDebug("editIncidence() ");
3757 Incidence *incidence = currentSelection(); 3776 Incidence *incidence = currentSelection();
3758 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3777 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3759 if ( incidence ) { 3778 if ( incidence ) {
3760 EditIncidenceVisitor v; 3779 EditIncidenceVisitor v;
3761 v.act( incidence, this ); 3780 v.act( incidence, this );
3762 } 3781 }
3763} 3782}
3764 3783
3765void CalendarView::deleteIncidence() 3784void CalendarView::deleteIncidence()
3766{ 3785{
3767 Incidence *incidence = currentSelection(); 3786 Incidence *incidence = currentSelection();
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
3774void CalendarView::showIncidence(Incidence *incidence) 3793void 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
3782void CalendarView::editIncidence(Incidence *incidence) 3808void CalendarView::editIncidence(Incidence *incidence)
3783{ 3809{
3784 if ( incidence ) { 3810 if ( incidence ) {
3785 3811
3786 EditIncidenceVisitor v; 3812 EditIncidenceVisitor v;
3787 v.act( incidence, this ); 3813 v.act( incidence, this );
3788 3814
3789 } 3815 }
3790} 3816}
3791 3817
3792void CalendarView::deleteIncidence(Incidence *incidence) 3818void CalendarView::deleteIncidence(Incidence *incidence)
3793{ 3819{
3794 //qDebug(" CalendarView::deleteIncidence "); 3820 //qDebug(" CalendarView::deleteIncidence ");
3795 if ( incidence ) { 3821 if ( incidence ) {
3796 DeleteIncidenceVisitor v; 3822 DeleteIncidenceVisitor v;
3797 v.act( incidence, this ); 3823 v.act( incidence, this );
3798 } 3824 }
3799} 3825}
3800 3826
3801 3827
3802void CalendarView::lookForOutgoingMessages() 3828void CalendarView::lookForOutgoingMessages()
3803{ 3829{
3804 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3830 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3805 ogd->loadMessages(); 3831 ogd->loadMessages();
3806} 3832}
3807 3833
3808void CalendarView::lookForIncomingMessages() 3834void CalendarView::lookForIncomingMessages()
3809{ 3835{
3810 IncomingDialog *icd = mDialogManager->incomingDialog(); 3836 IncomingDialog *icd = mDialogManager->incomingDialog();
3811 icd->retrieve(); 3837 icd->retrieve();
3812} 3838}
3813 3839
3814bool CalendarView::removeCompletedSubTodos( Todo* t ) 3840bool CalendarView::removeCompletedSubTodos( Todo* t )
3815{ 3841{
3816 bool deleteTodo = true; 3842 bool deleteTodo = true;
3817 QPtrList<Incidence> subTodos; 3843 QPtrList<Incidence> subTodos;
3818 Incidence *aTodo; 3844 Incidence *aTodo;
3819 subTodos = t->relations(); 3845 subTodos = t->relations();
3820 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3846 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3821 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3847 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3822 deleteTodo = false; 3848 deleteTodo = false;
3823 } 3849 }
@@ -3877,48 +3903,72 @@ bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3877 // mSyncManager = manager; 3903 // mSyncManager = manager;
3878 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3904 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3879 qDebug("KO: SyncKDE request detected!"); 3905 qDebug("KO: SyncKDE request detected!");
3880 } 3906 }
3881 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3907 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3882 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3908 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3883 return syncCalendar( filename, mode ); 3909 return syncCalendar( filename, mode );
3884} 3910}
3885bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3911bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3886{ 3912{
3887 //mSyncManager = manager; 3913 //mSyncManager = manager;
3888 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3914 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3889 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3915 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3890 if ( resource == "sharp" ) 3916 if ( resource == "sharp" )
3891 syncExternal( 0 ); 3917 syncExternal( 0 );
3892 if ( resource == "phone" ) 3918 if ( resource == "phone" )
3893 syncExternal( 1 ); 3919 syncExternal( 1 );
3894 // pending setmodified 3920 // pending setmodified
3895 return true; 3921 return true;
3896} 3922}
3897void CalendarView::setSyncManager(KSyncManager* manager) 3923void CalendarView::setSyncManager(KSyncManager* manager)
3898{ 3924{
3899 mSyncManager = manager; 3925 mSyncManager = manager;
3900} 3926}
3901 3927
3902void CalendarView::removeSyncInfo( QString syncProfile) 3928void CalendarView::removeSyncInfo( QString syncProfile)
3903{ 3929{
3904 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 3930 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
3905 mCalendar->removeSyncInfo( syncProfile ); 3931 mCalendar->removeSyncInfo( syncProfile );
3906 3932
3907} 3933}
3908 3934
3909void CalendarView::undo_delete() 3935void CalendarView::undo_delete()
3910{ 3936{
3911 //qDebug("undo_delete() "); 3937 //qDebug("undo_delete() ");
3912 Incidence* undo = mCalendar->undoIncidence(); 3938 Incidence* undo = mCalendar->undoIncidence();
3913 if ( !undo ) { 3939 if ( !undo ) {
3914 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 3940 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
3915 i18n("KO/Pi")); 3941 i18n("KO/Pi"));
3916 return; 3942 return;
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
3952void CalendarView::slotViewerClosed()
3953{
3954 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
3955}
3956
3957void 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}