summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp17
-rw-r--r--korganizer/calendarview.h4
-rw-r--r--korganizer/koagenda.cpp66
-rw-r--r--korganizer/koagenda.h6
-rw-r--r--korganizer/koagendaview.cpp19
-rw-r--r--korganizer/koagendaview.h3
-rw-r--r--korganizer/koeditorgeneraltodo.cpp17
-rw-r--r--korganizer/koviewmanager.cpp9
8 files changed, 119 insertions, 22 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 257a4dd..035d630 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -2457,438 +2457,445 @@ void CalendarView::beamDone( Ir *ir )
2457#endif 2457#endif
2458 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2458 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2459 topLevelWidget()->raise(); 2459 topLevelWidget()->raise();
2460} 2460}
2461 2461
2462void CalendarView::moveIncidence(Incidence * inc ) 2462void CalendarView::moveIncidence(Incidence * inc )
2463{ 2463{
2464 if ( !inc ) return; 2464 if ( !inc ) return;
2465 // qDebug("showDatePickerForIncidence( ) "); 2465 // qDebug("showDatePickerForIncidence( ) ");
2466 if ( mDateFrame->isVisible() ) 2466 if ( mDateFrame->isVisible() )
2467 mDateFrame->hide(); 2467 mDateFrame->hide();
2468 else { 2468 else {
2469 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2469 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2470 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2470 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2471 int dw = QApplication::desktop()->width(); 2471 int dw = QApplication::desktop()->width();
2472 int dh = QApplication::desktop()->height(); 2472 int dh = QApplication::desktop()->height();
2473 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2473 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2474 mDateFrame->show(); 2474 mDateFrame->show();
2475 } 2475 }
2476 mDatePickerMode = 2; 2476 mDatePickerMode = 2;
2477 mMoveIncidence = inc ; 2477 mMoveIncidence = inc ;
2478 QDate da; 2478 QDate da;
2479 if ( mMoveIncidence->type() == "Todo" ) { 2479 if ( mMoveIncidence->type() == "Todo" ) {
2480 Todo * to = (Todo *) mMoveIncidence; 2480 Todo * to = (Todo *) mMoveIncidence;
2481 if ( to->hasDueDate() ) 2481 if ( to->hasDueDate() )
2482 da = to->dtDue().date(); 2482 da = to->dtDue().date();
2483 else 2483 else
2484 da = QDate::currentDate(); 2484 da = QDate::currentDate();
2485 } else { 2485 } else {
2486 da = mMoveIncidence->dtStart().date(); 2486 da = mMoveIncidence->dtStart().date();
2487 } 2487 }
2488 //PENDING set date for recurring incidence to date of recurrence 2488 //PENDING set date for recurring incidence to date of recurrence
2489 //mMoveIncidenceOldDate; 2489 //mMoveIncidenceOldDate;
2490 mDatePicker->setDate( da ); 2490 mDatePicker->setDate( da );
2491} 2491}
2492void CalendarView::showDatePicker( ) 2492void CalendarView::showDatePicker( )
2493{ 2493{
2494 //qDebug("CalendarView::showDatePicker( ) "); 2494 //qDebug("CalendarView::showDatePicker( ) ");
2495 if ( mDateFrame->isVisible() ) 2495 if ( mDateFrame->isVisible() )
2496 mDateFrame->hide(); 2496 mDateFrame->hide();
2497 else { 2497 else {
2498 int w =mDatePicker->sizeHint().width() ; 2498 int w =mDatePicker->sizeHint().width() ;
2499 int h = mDatePicker->sizeHint().height() ; 2499 int h = mDatePicker->sizeHint().height() ;
2500 int dw = QApplication::desktop()->width(); 2500 int dw = QApplication::desktop()->width();
2501 int dh = QApplication::desktop()->height(); 2501 int dh = QApplication::desktop()->height();
2502 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2502 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2503 mDateFrame->show(); 2503 mDateFrame->show();
2504 } 2504 }
2505 mDatePickerMode = 1; 2505 mDatePickerMode = 1;
2506 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2506 mDatePicker->setDate( mNavigator->selectedDates().first() );
2507} 2507}
2508 2508
2509void CalendarView::showEventEditor() 2509void CalendarView::showEventEditor()
2510{ 2510{
2511#ifdef DESKTOP_VERSION 2511#ifdef DESKTOP_VERSION
2512 mEventEditor->show(); 2512 mEventEditor->show();
2513#else 2513#else
2514 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2514 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2515 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2515 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2516 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2516 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2517 qApp->processEvents(); 2517 qApp->processEvents();
2518 delete mEventEditor; 2518 delete mEventEditor;
2519 mEventEditor = mDialogManager->getEventEditor(); 2519 mEventEditor = mDialogManager->getEventEditor();
2520 topLevelWidget()->setCaption( i18n("") ); 2520 topLevelWidget()->setCaption( i18n("") );
2521 } 2521 }
2522 mEventEditor->showMaximized(); 2522 mEventEditor->showMaximized();
2523#endif 2523#endif
2524} 2524}
2525void CalendarView::showTodoEditor() 2525void CalendarView::showTodoEditor()
2526{ 2526{
2527#ifdef DESKTOP_VERSION 2527#ifdef DESKTOP_VERSION
2528 mTodoEditor->show(); 2528 mTodoEditor->show();
2529#else 2529#else
2530 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2530 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2531 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2531 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2532 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2532 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2533 qApp->processEvents(); 2533 qApp->processEvents();
2534 delete mTodoEditor; 2534 delete mTodoEditor;
2535 mTodoEditor = mDialogManager->getTodoEditor(); 2535 mTodoEditor = mDialogManager->getTodoEditor();
2536 topLevelWidget()->setCaption( i18n("") ); 2536 topLevelWidget()->setCaption( i18n("") );
2537 } 2537 }
2538 mTodoEditor->showMaximized(); 2538 mTodoEditor->showMaximized();
2539#endif 2539#endif
2540} 2540}
2541 2541
2542void CalendarView::cloneIncidence() 2542void CalendarView::cloneIncidence()
2543{ 2543{
2544 Incidence *incidence = currentSelection(); 2544 Incidence *incidence = currentSelection();
2545 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2545 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2546 if ( incidence ) { 2546 if ( incidence ) {
2547 cloneIncidence(incidence); 2547 cloneIncidence(incidence);
2548 } 2548 }
2549} 2549}
2550void CalendarView::moveIncidence() 2550void CalendarView::moveIncidence()
2551{ 2551{
2552 Incidence *incidence = currentSelection(); 2552 Incidence *incidence = currentSelection();
2553 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2553 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2554 if ( incidence ) { 2554 if ( incidence ) {
2555 moveIncidence(incidence); 2555 moveIncidence(incidence);
2556 } 2556 }
2557} 2557}
2558void CalendarView::beamIncidence() 2558void CalendarView::beamIncidence()
2559{ 2559{
2560 Incidence *incidence = currentSelection(); 2560 Incidence *incidence = currentSelection();
2561 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2561 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2562 if ( incidence ) { 2562 if ( incidence ) {
2563 beamIncidence(incidence); 2563 beamIncidence(incidence);
2564 } 2564 }
2565} 2565}
2566void CalendarView::toggleCancelIncidence() 2566void CalendarView::toggleCancelIncidence()
2567{ 2567{
2568 Incidence *incidence = currentSelection(); 2568 Incidence *incidence = currentSelection();
2569 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2569 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2570 if ( incidence ) { 2570 if ( incidence ) {
2571 cancelIncidence(incidence); 2571 cancelIncidence(incidence);
2572 } 2572 }
2573} 2573}
2574 2574
2575 2575
2576void CalendarView::cancelIncidence(Incidence * inc ) 2576void CalendarView::cancelIncidence(Incidence * inc )
2577{ 2577{
2578 inc->setCancelled( ! inc->cancelled() ); 2578 inc->setCancelled( ! inc->cancelled() );
2579 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2579 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2580 updateView(); 2580 updateView();
2581} 2581}
2582void CalendarView::cloneIncidence(Incidence * orgInc ) 2582void CalendarView::cloneIncidence(Incidence * orgInc )
2583{ 2583{
2584 Incidence * newInc = orgInc->clone(); 2584 Incidence * newInc = orgInc->clone();
2585 newInc->recreate(); 2585 newInc->recreate();
2586 2586
2587 if ( newInc->type() == "Todo" ) { 2587 if ( newInc->type() == "Todo" ) {
2588 Todo* t = (Todo*) newInc; 2588 Todo* t = (Todo*) newInc;
2589 showTodoEditor(); 2589 showTodoEditor();
2590 mTodoEditor->editTodo( t ); 2590 mTodoEditor->editTodo( t );
2591 if ( mTodoEditor->exec() ) { 2591 if ( mTodoEditor->exec() ) {
2592 mCalendar->addTodo( t ); 2592 mCalendar->addTodo( t );
2593 updateView(); 2593 updateView();
2594 } else { 2594 } else {
2595 delete t; 2595 delete t;
2596 } 2596 }
2597 } 2597 }
2598 else { 2598 else {
2599 Event* e = (Event*) newInc; 2599 Event* e = (Event*) newInc;
2600 showEventEditor(); 2600 showEventEditor();
2601 mEventEditor->editEvent( e ); 2601 mEventEditor->editEvent( e );
2602 if ( mEventEditor->exec() ) { 2602 if ( mEventEditor->exec() ) {
2603 mCalendar->addEvent( e ); 2603 mCalendar->addEvent( e );
2604 updateView(); 2604 updateView();
2605 } else { 2605 } else {
2606 delete e; 2606 delete e;
2607 } 2607 }
2608 } 2608 }
2609} 2609}
2610 2610
2611void CalendarView::newEvent() 2611void CalendarView::newEvent()
2612{ 2612{
2613 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2613 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2614 KOAgendaView *aView = mViewManager->agendaView(); 2614 KOAgendaView *aView = mViewManager->agendaView();
2615 if (aView) { 2615 if (aView) {
2616 if (aView->selectionStart().isValid()) { 2616 if (aView->selectionStart().isValid()) {
2617 if (aView->selectedIsAllDay()) { 2617 if (aView->selectedIsAllDay()) {
2618 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2618 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2619 } else { 2619 } else {
2620 newEvent(aView->selectionStart(),aView->selectionEnd()); 2620 newEvent(aView->selectionStart(),aView->selectionEnd());
2621 } 2621 }
2622 return; 2622 return;
2623 } 2623 }
2624 } 2624 }
2625 2625
2626 QDate date = mNavigator->selectedDates().first(); 2626 QDate date = mNavigator->selectedDates().first();
2627 QDateTime current = QDateTime::currentDateTime(); 2627 QDateTime current = QDateTime::currentDateTime();
2628 if ( date <= current.date() ) { 2628 if ( date <= current.date() ) {
2629 int hour = current.time().hour() +1; 2629 int hour = current.time().hour() +1;
2630 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2630 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2631 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2631 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2632 } else 2632 } else
2633 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2633 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2634 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2634 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2635 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2635 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2636} 2636}
2637 2637
2638void CalendarView::newEvent(QDateTime fh) 2638void CalendarView::newEvent(QDateTime fh)
2639{ 2639{
2640 newEvent(fh, 2640 newEvent(fh,
2641 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2641 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2642} 2642}
2643 2643
2644void CalendarView::newEvent(QDate dt) 2644void CalendarView::newEvent(QDate dt)
2645{ 2645{
2646 newEvent(QDateTime(dt, QTime(0,0,0)), 2646 newEvent(QDateTime(dt, QTime(0,0,0)),
2647 QDateTime(dt, QTime(0,0,0)), true); 2647 QDateTime(dt, QTime(0,0,0)), true);
2648} 2648}
2649 2649void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2650{
2651 newEvent(fromHint, toHint, false);
2652}
2650void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2653void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2651{ 2654{
2652 2655
2653 showEventEditor(); 2656 showEventEditor();
2654 mEventEditor->newEvent(fromHint,toHint,allDay); 2657 mEventEditor->newEvent(fromHint,toHint,allDay);
2655 if ( mFilterView->filtersEnabled() ) { 2658 if ( mFilterView->filtersEnabled() ) {
2656 CalFilter *filter = mFilterView->selectedFilter(); 2659 CalFilter *filter = mFilterView->selectedFilter();
2657 if (filter && filter->showCategories()) { 2660 if (filter && filter->showCategories()) {
2658 mEventEditor->setCategories(filter->categoryList().join(",") ); 2661 mEventEditor->setCategories(filter->categoryList().join(",") );
2659 } 2662 }
2660 if ( filter ) 2663 if ( filter )
2661 mEventEditor->setSecrecy( filter->getSecrecy() ); 2664 mEventEditor->setSecrecy( filter->getSecrecy() );
2662 } 2665 }
2663} 2666}
2664void CalendarView::todoAdded(Todo * t) 2667void CalendarView::todoAdded(Todo * t)
2665{ 2668{
2666 2669
2667 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2670 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2668 updateTodoViews(); 2671 updateTodoViews();
2669} 2672}
2670void CalendarView::todoChanged(Todo * t) 2673void CalendarView::todoChanged(Todo * t)
2671{ 2674{
2672 emit todoModified( t, 4 ); 2675 emit todoModified( t, 4 );
2673 // updateTodoViews(); 2676 // updateTodoViews();
2674} 2677}
2675void CalendarView::todoToBeDeleted(Todo *) 2678void CalendarView::todoToBeDeleted(Todo *)
2676{ 2679{
2677 //qDebug("todoToBeDeleted(Todo *) "); 2680 //qDebug("todoToBeDeleted(Todo *) ");
2678 updateTodoViews(); 2681 updateTodoViews();
2679} 2682}
2680void CalendarView::todoDeleted() 2683void CalendarView::todoDeleted()
2681{ 2684{
2682 //qDebug(" todoDeleted()"); 2685 //qDebug(" todoDeleted()");
2683 updateTodoViews(); 2686 updateTodoViews();
2684} 2687}
2685 2688
2686 2689
2687 2690void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
2688void CalendarView::newTodo()
2689{ 2691{
2690 2692 qDebug("datetime ");
2691 showTodoEditor(); 2693 showTodoEditor();
2692 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2694 mTodoEditor->newTodo(dt,0,allday);
2693 if ( mFilterView->filtersEnabled() ) { 2695 if ( mFilterView->filtersEnabled() ) {
2694 CalFilter *filter = mFilterView->selectedFilter(); 2696 CalFilter *filter = mFilterView->selectedFilter();
2695 if (filter && filter->showCategories()) { 2697 if (filter && filter->showCategories()) {
2696 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2698 mTodoEditor->setCategories(filter->categoryList().join(",") );
2697 } 2699 }
2698 if ( filter ) 2700 if ( filter )
2699 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2701 mTodoEditor->setSecrecy( filter->getSecrecy() );
2700 } 2702 }
2701} 2703}
2702 2704
2705void CalendarView::newTodo()
2706{
2707 newTodoDateTime( QDateTime(),true );
2708}
2709
2703void CalendarView::newSubTodo() 2710void CalendarView::newSubTodo()
2704{ 2711{
2705 Todo *todo = selectedTodo(); 2712 Todo *todo = selectedTodo();
2706 if ( todo ) newSubTodo( todo ); 2713 if ( todo ) newSubTodo( todo );
2707} 2714}
2708 2715
2709void CalendarView::newSubTodo(Todo *parentEvent) 2716void CalendarView::newSubTodo(Todo *parentEvent)
2710{ 2717{
2711 2718
2712 showTodoEditor(); 2719 showTodoEditor();
2713 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2720 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2714} 2721}
2715 2722
2716void CalendarView::newFloatingEvent() 2723void CalendarView::newFloatingEvent()
2717{ 2724{
2718 DateList tmpList = mNavigator->selectedDates(); 2725 DateList tmpList = mNavigator->selectedDates();
2719 QDate date = tmpList.first(); 2726 QDate date = tmpList.first();
2720 2727
2721 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2728 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2722 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2729 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2723} 2730}
2724 2731
2725 2732
2726void CalendarView::editEvent( Event *event ) 2733void CalendarView::editEvent( Event *event )
2727{ 2734{
2728 2735
2729 if ( !event ) return; 2736 if ( !event ) return;
2730 if ( event->isReadOnly() ) { 2737 if ( event->isReadOnly() ) {
2731 showEvent( event ); 2738 showEvent( event );
2732 return; 2739 return;
2733 } 2740 }
2734 showEventEditor(); 2741 showEventEditor();
2735 mEventEditor->editEvent( event , mFlagEditDescription); 2742 mEventEditor->editEvent( event , mFlagEditDescription);
2736} 2743}
2737void CalendarView::editJournal( Journal *jour ) 2744void CalendarView::editJournal( Journal *jour )
2738{ 2745{
2739 if ( !jour ) return; 2746 if ( !jour ) return;
2740 mDialogManager->hideSearchDialog(); 2747 mDialogManager->hideSearchDialog();
2741 mViewManager->showJournalView(); 2748 mViewManager->showJournalView();
2742 mNavigator->slotDaySelect( jour->dtStart().date() ); 2749 mNavigator->slotDaySelect( jour->dtStart().date() );
2743} 2750}
2744void CalendarView::editTodo( Todo *todo ) 2751void CalendarView::editTodo( Todo *todo )
2745{ 2752{
2746 if ( !todo ) return; 2753 if ( !todo ) return;
2747 2754
2748 if ( todo->isReadOnly() ) { 2755 if ( todo->isReadOnly() ) {
2749 showTodo( todo ); 2756 showTodo( todo );
2750 return; 2757 return;
2751 } 2758 }
2752 showTodoEditor(); 2759 showTodoEditor();
2753 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2760 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2754 2761
2755} 2762}
2756 2763
2757KOEventViewerDialog* CalendarView::getEventViewerDialog() 2764KOEventViewerDialog* CalendarView::getEventViewerDialog()
2758{ 2765{
2759 if ( !mEventViewerDialog ) { 2766 if ( !mEventViewerDialog ) {
2760 mEventViewerDialog = new KOEventViewerDialog(this); 2767 mEventViewerDialog = new KOEventViewerDialog(this);
2761 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2768 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2762 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2769 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2763 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2770 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2764 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2771 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2765 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2772 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2766 viewManager(), SLOT( showAgendaView( bool ) ) ); 2773 viewManager(), SLOT( showAgendaView( bool ) ) );
2767 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2774 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2768 this, SLOT( todoChanged(Todo *) ) ); 2775 this, SLOT( todoChanged(Todo *) ) );
2769 mEventViewerDialog->resize( 640, 480 ); 2776 mEventViewerDialog->resize( 640, 480 );
2770 2777
2771 } 2778 }
2772 return mEventViewerDialog; 2779 return mEventViewerDialog;
2773} 2780}
2774void CalendarView::showEvent(Event *event) 2781void CalendarView::showEvent(Event *event)
2775{ 2782{
2776 getEventViewerDialog()->setEvent(event); 2783 getEventViewerDialog()->setEvent(event);
2777 getEventViewerDialog()->showMe(); 2784 getEventViewerDialog()->showMe();
2778} 2785}
2779 2786
2780void CalendarView::showTodo(Todo *event) 2787void CalendarView::showTodo(Todo *event)
2781{ 2788{
2782 getEventViewerDialog()->setTodo(event); 2789 getEventViewerDialog()->setTodo(event);
2783 getEventViewerDialog()->showMe(); 2790 getEventViewerDialog()->showMe();
2784} 2791}
2785void CalendarView::showJournal( Journal *jour ) 2792void CalendarView::showJournal( Journal *jour )
2786{ 2793{
2787 getEventViewerDialog()->setJournal(jour); 2794 getEventViewerDialog()->setJournal(jour);
2788 getEventViewerDialog()->showMe(); 2795 getEventViewerDialog()->showMe();
2789 2796
2790} 2797}
2791// void CalendarView::todoModified (Todo *event, int changed) 2798// void CalendarView::todoModified (Todo *event, int changed)
2792// { 2799// {
2793// // if (mDialogList.find (event) != mDialogList.end ()) { 2800// // if (mDialogList.find (event) != mDialogList.end ()) {
2794// // kdDebug() << "Todo modified and open" << endl; 2801// // kdDebug() << "Todo modified and open" << endl;
2795// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2802// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2796// // temp->modified (changed); 2803// // temp->modified (changed);
2797 2804
2798// // } 2805// // }
2799 2806
2800// mViewManager->updateView(); 2807// mViewManager->updateView();
2801// } 2808// }
2802 2809
2803void CalendarView::appointment_show() 2810void CalendarView::appointment_show()
2804{ 2811{
2805 Event *anEvent = 0; 2812 Event *anEvent = 0;
2806 2813
2807 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2814 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2808 2815
2809 if (mViewManager->currentView()->isEventView()) { 2816 if (mViewManager->currentView()->isEventView()) {
2810 if ( incidence && incidence->type() == "Event" ) { 2817 if ( incidence && incidence->type() == "Event" ) {
2811 anEvent = static_cast<Event *>(incidence); 2818 anEvent = static_cast<Event *>(incidence);
2812 } 2819 }
2813 } 2820 }
2814 2821
2815 if (!anEvent) { 2822 if (!anEvent) {
2816 KNotifyClient::beep(); 2823 KNotifyClient::beep();
2817 return; 2824 return;
2818 } 2825 }
2819 2826
2820 showEvent(anEvent); 2827 showEvent(anEvent);
2821} 2828}
2822 2829
2823void CalendarView::appointment_edit() 2830void CalendarView::appointment_edit()
2824{ 2831{
2825 Event *anEvent = 0; 2832 Event *anEvent = 0;
2826 2833
2827 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2834 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2828 2835
2829 if (mViewManager->currentView()->isEventView()) { 2836 if (mViewManager->currentView()->isEventView()) {
2830 if ( incidence && incidence->type() == "Event" ) { 2837 if ( incidence && incidence->type() == "Event" ) {
2831 anEvent = static_cast<Event *>(incidence); 2838 anEvent = static_cast<Event *>(incidence);
2832 } 2839 }
2833 } 2840 }
2834 2841
2835 if (!anEvent) { 2842 if (!anEvent) {
2836 KNotifyClient::beep(); 2843 KNotifyClient::beep();
2837 return; 2844 return;
2838 } 2845 }
2839 2846
2840 editEvent(anEvent); 2847 editEvent(anEvent);
2841} 2848}
2842 2849
2843void CalendarView::appointment_delete() 2850void CalendarView::appointment_delete()
2844{ 2851{
2845 Event *anEvent = 0; 2852 Event *anEvent = 0;
2846 2853
2847 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2854 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2848 2855
2849 if (mViewManager->currentView()->isEventView()) { 2856 if (mViewManager->currentView()->isEventView()) {
2850 if ( incidence && incidence->type() == "Event" ) { 2857 if ( incidence && incidence->type() == "Event" ) {
2851 anEvent = static_cast<Event *>(incidence); 2858 anEvent = static_cast<Event *>(incidence);
2852 } 2859 }
2853 } 2860 }
2854 2861
2855 if (!anEvent) { 2862 if (!anEvent) {
2856 KNotifyClient::beep(); 2863 KNotifyClient::beep();
2857 return; 2864 return;
2858 } 2865 }
2859 2866
2860 deleteEvent(anEvent); 2867 deleteEvent(anEvent);
2861} 2868}
2862 2869
2863void CalendarView::todo_resub( Todo * parent, Todo * sub ) 2870void CalendarView::todo_resub( Todo * parent, Todo * sub )
2864{ 2871{
2865 if (!sub) return; 2872 if (!sub) return;
2866 if (!parent) return; 2873 if (!parent) return;
2867 if ( sub->relatedTo() ) 2874 if ( sub->relatedTo() )
2868 sub->relatedTo()->removeRelation(sub); 2875 sub->relatedTo()->removeRelation(sub);
2869 sub->setRelatedTo(parent); 2876 sub->setRelatedTo(parent);
2870 sub->setRelatedToUid(parent->uid()); 2877 sub->setRelatedToUid(parent->uid());
2871 parent->addRelation(sub); 2878 parent->addRelation(sub);
2872 sub->updated(); 2879 sub->updated();
2873 parent->updated(); 2880 parent->updated();
2874 setModified(true); 2881 setModified(true);
2875 updateView(); 2882 updateView();
2876} 2883}
2877void CalendarView::todo_unsub(Todo *anTodo ) 2884void CalendarView::todo_unsub(Todo *anTodo )
2878{ 2885{
2879 // Todo *anTodo = selectedTodo(); 2886 // Todo *anTodo = selectedTodo();
2880 if (!anTodo) return; 2887 if (!anTodo) return;
2881 if (!anTodo->relatedTo()) return; 2888 if (!anTodo->relatedTo()) return;
2882 anTodo->relatedTo()->removeRelation(anTodo); 2889 anTodo->relatedTo()->removeRelation(anTodo);
2883 anTodo->setRelatedTo(0); 2890 anTodo->setRelatedTo(0);
2884 anTodo->updated(); 2891 anTodo->updated();
2885 anTodo->setRelatedToUid(""); 2892 anTodo->setRelatedToUid("");
2886 setModified(true); 2893 setModified(true);
2887 updateView(); 2894 updateView();
2888} 2895}
2889 2896
2890void CalendarView::deleteTodo(Todo *todo) 2897void CalendarView::deleteTodo(Todo *todo)
2891{ 2898{
2892 if (!todo) { 2899 if (!todo) {
2893 KNotifyClient::beep(); 2900 KNotifyClient::beep();
2894 return; 2901 return;
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index c8d6bdd..7c59a8d 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -36,419 +36,421 @@
36#define Ir char 36#define Ir char
37#endif 37#endif
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/scheduler.h> 39#include <libkcal/scheduler.h>
40#include <libkcal/calendarresources.h> 40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 41#include <libkcal/resourcecalendar.h>
42 42
43#include <korganizer/calendarviewbase.h> 43#include <korganizer/calendarviewbase.h>
44 44
45#include <ksyncmanager.h> 45#include <ksyncmanager.h>
46 46
47class QWidgetStack; 47class QWidgetStack;
48class QSplitter; 48class QSplitter;
49 49
50class CalPrinter; 50class CalPrinter;
51class KOFilterView; 51class KOFilterView;
52class KOViewManager; 52class KOViewManager;
53class KODialogManager; 53class KODialogManager;
54class KOTodoView; 54class KOTodoView;
55class KDateNavigator; 55class KDateNavigator;
56class DateNavigator; 56class DateNavigator;
57class KOIncidenceEditor; 57class KOIncidenceEditor;
58class KDatePicker; 58class KDatePicker;
59class ResourceView; 59class ResourceView;
60class NavigatorBar; 60class NavigatorBar;
61class KOEventEditor; 61class KOEventEditor;
62class KOTodoEditor ; 62class KOTodoEditor ;
63class KOEventViewerDialog; 63class KOEventViewerDialog;
64class KOBeamPrefs; 64class KOBeamPrefs;
65class KSyncProfile; 65class KSyncProfile;
66class AlarmDialog; 66class AlarmDialog;
67class KCal::Attendee; 67class KCal::Attendee;
68 68
69namespace KCal { class FileStorage; } 69namespace KCal { class FileStorage; }
70 70
71using namespace KCal; 71using namespace KCal;
72 72
73/** 73/**
74 This is the main calendar widget. It provides the different vies on t he 74 This is the main calendar widget. It provides the different vies on t he
75 calendar data as well as the date navigator. It also handles synchronisation 75 calendar data as well as the date navigator. It also handles synchronisation
76 of the different views and controls the different dialogs like preferences, 76 of the different views and controls the different dialogs like preferences,
77 event editor, search dialog etc. 77 event editor, search dialog etc.
78 78
79 @short main calendar view widget 79 @short main calendar view widget
80 @author Cornelius Schumacher 80 @author Cornelius Schumacher
81*/ 81*/
82class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface 82class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
83{ 83{
84 Q_OBJECT 84 Q_OBJECT
85 public: 85 public:
86 /** 86 /**
87 Constructs a new calendar view widget. 87 Constructs a new calendar view widget.
88 88
89 @param calendar calendar document 89 @param calendar calendar document
90 @param parent parent window 90 @param parent parent window
91 @param name Qt internal widget object name 91 @param name Qt internal widget object name
92 */ 92 */
93 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 93 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
94 const char *name = 0 ); 94 const char *name = 0 );
95 CalendarView( Calendar *calendar, QWidget *parent = 0, 95 CalendarView( Calendar *calendar, QWidget *parent = 0,
96 const char *name = 0 ); 96 const char *name = 0 );
97 virtual ~CalendarView(); 97 virtual ~CalendarView();
98 98
99 Calendar *calendar() { return mCalendar; } 99 Calendar *calendar() { return mCalendar; }
100 100
101 KOViewManager *viewManager(); 101 KOViewManager *viewManager();
102 KODialogManager *dialogManager(); 102 KODialogManager *dialogManager();
103 103
104 QDate startDate(); 104 QDate startDate();
105 QDate endDate(); 105 QDate endDate();
106 106
107 QWidgetStack *viewStack(); 107 QWidgetStack *viewStack();
108 QWidget *leftFrame(); 108 QWidget *leftFrame();
109 NavigatorBar *navigatorBar(); 109 NavigatorBar *navigatorBar();
110 110
111 DateNavigator *dateNavigator(); 111 DateNavigator *dateNavigator();
112 KDateNavigator *dateNavigatorWidget(); 112 KDateNavigator *dateNavigatorWidget();
113 113
114 void addView(KOrg::BaseView *); 114 void addView(KOrg::BaseView *);
115 void showView(KOrg::BaseView *); 115 void showView(KOrg::BaseView *);
116 KOEventViewerDialog* getEventViewerDialog(); 116 KOEventViewerDialog* getEventViewerDialog();
117 Incidence *currentSelection(); 117 Incidence *currentSelection();
118 118
119 signals: 119 signals:
120 void tempDisableBR(bool); 120 void tempDisableBR(bool);
121 /** This todo has been modified */ 121 /** This todo has been modified */
122 void todoModified(Todo *, int); 122 void todoModified(Todo *, int);
123 123
124 /** when change is made to options dialog, the topwidget will catch this 124 /** when change is made to options dialog, the topwidget will catch this
125 * and emit this signal which notifies all widgets which have registered 125 * and emit this signal which notifies all widgets which have registered
126 * for notification to update their settings. */ 126 * for notification to update their settings. */
127 void configChanged(); 127 void configChanged();
128 /** emitted when the topwidget is closing down, so that any attached 128 /** emitted when the topwidget is closing down, so that any attached
129 child windows can also close. */ 129 child windows can also close. */
130 void closingDown(); 130 void closingDown();
131 /** emitted right before we die */ 131 /** emitted right before we die */
132 void closed(QWidget *); 132 void closed(QWidget *);
133 133
134 /** Emitted when state of modified flag changes */ 134 /** Emitted when state of modified flag changes */
135 void modifiedChanged(bool); 135 void modifiedChanged(bool);
136 void signalmodified(); 136 void signalmodified();
137 137
138 /** Emitted when state of read-only flag changes */ 138 /** Emitted when state of read-only flag changes */
139 void readOnlyChanged(bool); 139 void readOnlyChanged(bool);
140 140
141 /** Emitted when the unit of navigation changes */ 141 /** Emitted when the unit of navigation changes */
142 void changeNavStringPrev(const QString &); 142 void changeNavStringPrev(const QString &);
143 void changeNavStringNext(const QString &); 143 void changeNavStringNext(const QString &);
144 144
145 /** Emitted when state of events selection has changed and user is organizer*/ 145 /** Emitted when state of events selection has changed and user is organizer*/
146 void organizerEventsSelected(bool); 146 void organizerEventsSelected(bool);
147 /** Emitted when state of events selection has changed and user is attendee*/ 147 /** Emitted when state of events selection has changed and user is attendee*/
148 void groupEventsSelected(bool); 148 void groupEventsSelected(bool);
149 /** 149 /**
150 Emitted when an incidence gets selected. If the selection is cleared the 150 Emitted when an incidence gets selected. If the selection is cleared the
151 signal is emitted with 0 as argument. 151 signal is emitted with 0 as argument.
152 */ 152 */
153 void incidenceSelected( Incidence * ); 153 void incidenceSelected( Incidence * );
154 /** Emitted, when a todoitem is selected or deselected. */ 154 /** Emitted, when a todoitem is selected or deselected. */
155 void todoSelected( bool ); 155 void todoSelected( bool );
156 156
157 /** 157 /**
158 Emitted, when clipboard content changes. Parameter indicates if paste 158 Emitted, when clipboard content changes. Parameter indicates if paste
159 is possible or not. 159 is possible or not.
160 */ 160 */
161 void pasteEnabled(bool); 161 void pasteEnabled(bool);
162 162
163 /** Emitted, when the number of incoming messages has changed. */ 163 /** Emitted, when the number of incoming messages has changed. */
164 void numIncomingChanged(int); 164 void numIncomingChanged(int);
165 165
166 /** Emitted, when the number of outgoing messages has changed. */ 166 /** Emitted, when the number of outgoing messages has changed. */
167 void numOutgoingChanged(int); 167 void numOutgoingChanged(int);
168 168
169 /** Send status message, which can e.g. be displayed in the status bar. */ 169 /** Send status message, which can e.g. be displayed in the status bar. */
170 void statusMessage(const QString &); 170 void statusMessage(const QString &);
171 171
172 void calendarViewExpanded( bool ); 172 void calendarViewExpanded( bool );
173 void updateSearchDialog(); 173 void updateSearchDialog();
174 174
175 175
176 public slots: 176 public slots:
177 void showOpenError(); 177 void showOpenError();
178 void watchSavedFile(); 178 void watchSavedFile();
179 void recheckTimerAlarm(); 179 void recheckTimerAlarm();
180 void checkNextTimerAlarm(); 180 void checkNextTimerAlarm();
181 void addAlarm(const QDateTime &qdt, const QString &noti ); 181 void addAlarm(const QDateTime &qdt, const QString &noti );
182 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 182 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
183 void removeAlarm(const QDateTime &qdt, const QString &noti ); 183 void removeAlarm(const QDateTime &qdt, const QString &noti );
184 184
185 /** options dialog made a changed to the configuration. we catch this 185 /** options dialog made a changed to the configuration. we catch this
186 * and notify all widgets which need to update their configuration. */ 186 * and notify all widgets which need to update their configuration. */
187 void updateConfig(); 187 void updateConfig();
188 188
189 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 189 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
190 const QStringList& anniversaryList, const QStringList& realNameList, 190 const QStringList& anniversaryList, const QStringList& realNameList,
191 const QStringList& emailList, const QStringList& assembledNameList, 191 const QStringList& emailList, const QStringList& assembledNameList,
192 const QStringList& uidList); 192 const QStringList& uidList);
193 193
194 /** 194 /**
195 Load calendar from file \a filename. If \a merge is true, load 195 Load calendar from file \a filename. If \a merge is true, load
196 calendar into existing one, if it is false, clear calendar, before 196 calendar into existing one, if it is false, clear calendar, before
197 loading. Return true, if calendar could be successfully loaded. 197 loading. Return true, if calendar could be successfully loaded.
198 */ 198 */
199 bool openCalendar(QString filename, bool merge=false); 199 bool openCalendar(QString filename, bool merge=false);
200 bool syncCalendar(QString filename,int mode = 0 ); 200 bool syncCalendar(QString filename,int mode = 0 );
201 201
202 /** 202 /**
203 Save calendar data to file. Return true if calendar could be 203 Save calendar data to file. Return true if calendar could be
204 successfully saved. 204 successfully saved.
205 */ 205 */
206 bool saveCalendar(QString filename); 206 bool saveCalendar(QString filename);
207 207
208 /** 208 /**
209 Close calendar. Clear calendar data and reset views to display an empty 209 Close calendar. Clear calendar data and reset views to display an empty
210 calendar. 210 calendar.
211 */ 211 */
212 void closeCalendar(); 212 void closeCalendar();
213 213
214 /** Archive old events of calendar */ 214 /** Archive old events of calendar */
215 void archiveCalendar(); 215 void archiveCalendar();
216 216
217 void showIncidence(); 217 void showIncidence();
218 void editIncidence(); 218 void editIncidence();
219 void editIncidenceDescription(); 219 void editIncidenceDescription();
220 void deleteIncidence(); 220 void deleteIncidence();
221 void cloneIncidence(); 221 void cloneIncidence();
222 void moveIncidence(); 222 void moveIncidence();
223 void beamIncidence(); 223 void beamIncidence();
224 void toggleCancelIncidence(); 224 void toggleCancelIncidence();
225 225
226 /** create an editeventwin with supplied date/time, and if bool is true, 226 /** create an editeventwin with supplied date/time, and if bool is true,
227 * make the event take all day. */ 227 * make the event take all day. */
228 void newEvent(QDateTime, QDateTime, bool allDay = false); 228 void newEvent(QDateTime, QDateTime, bool allDay );
229 void newEvent(QDateTime, QDateTime);
229 void newEvent(QDateTime fh); 230 void newEvent(QDateTime fh);
230 void newEvent(QDate dt); 231 void newEvent(QDate dt);
231 /** create new event without having a date hint. Takes current date as 232 /** create new event without having a date hint. Takes current date as
232 default hint. */ 233 default hint. */
233 void newEvent(); 234 void newEvent();
234 void newFloatingEvent(); 235 void newFloatingEvent();
235 236
236 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 237 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
237 void showIncidence(Incidence *); 238 void showIncidence(Incidence *);
238 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 239 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
239 void editIncidence(Incidence *); 240 void editIncidence(Incidence *);
240 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 241 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
241 void deleteIncidence(Incidence *); 242 void deleteIncidence(Incidence *);
242 void cloneIncidence(Incidence *); 243 void cloneIncidence(Incidence *);
243 void cancelIncidence(Incidence *); 244 void cancelIncidence(Incidence *);
244 /** Create an editor for the supplied event. */ 245 /** Create an editor for the supplied event. */
245 void editEvent(Event *); 246 void editEvent(Event *);
246 /** Delete the supplied event. */ 247 /** Delete the supplied event. */
247 void deleteEvent(Event *); 248 void deleteEvent(Event *);
248 /** Delete the event with the given unique ID. Returns false, if event wasn't 249 /** Delete the event with the given unique ID. Returns false, if event wasn't
249 found. */ 250 found. */
250 bool deleteEvent(const QString &uid); 251 bool deleteEvent(const QString &uid);
251 /** Create a read-only viewer dialog for the supplied event. */ 252 /** Create a read-only viewer dialog for the supplied event. */
252 void showEvent(Event *); 253 void showEvent(Event *);
253 254
254 void editJournal(Journal *); 255 void editJournal(Journal *);
255 void showJournal(Journal *); 256 void showJournal(Journal *);
256 void deleteJournal(Journal *); 257 void deleteJournal(Journal *);
257 /** Create an editor dialog for a todo */ 258 /** Create an editor dialog for a todo */
258 void editTodo(Todo *); 259 void editTodo(Todo *);
259 /** Create a read-only viewer dialog for the supplied todo */ 260 /** Create a read-only viewer dialog for the supplied todo */
260 void showTodo(Todo *); 261 void showTodo(Todo *);
261 /** create new todo */ 262 /** create new todo */
262 void newTodo(); 263 void newTodo();
264 void newTodoDateTime(QDateTime, bool allday);
263 /** create new todo with a parent todo */ 265 /** create new todo with a parent todo */
264 void newSubTodo(); 266 void newSubTodo();
265 /** create new todo with a parent todo */ 267 /** create new todo with a parent todo */
266 void newSubTodo(Todo *); 268 void newSubTodo(Todo *);
267 /** Delete todo */ 269 /** Delete todo */
268 void deleteTodo(Todo *); 270 void deleteTodo(Todo *);
269 271
270 272
271 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 273 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
272 * emitted as result. */ 274 * emitted as result. */
273 void checkClipboard(); 275 void checkClipboard();
274 276
275 /** using the KConfig associated with the kapp variable, read in the 277 /** using the KConfig associated with the kapp variable, read in the
276 * settings from the config file. 278 * settings from the config file.
277 */ 279 */
278 void readSettings(); 280 void readSettings();
279 281
280 /** write current state to config file. */ 282 /** write current state to config file. */
281 void writeSettings(); 283 void writeSettings();
282 284
283 /** read settings for calendar filters */ 285 /** read settings for calendar filters */
284 void readFilterSettings(KConfig *config); 286 void readFilterSettings(KConfig *config);
285 287
286 /** write settings for calendar filters */ 288 /** write settings for calendar filters */
287 void writeFilterSettings(KConfig *config); 289 void writeFilterSettings(KConfig *config);
288 290
289 /** passes on the message that an event has changed to the currently 291 /** passes on the message that an event has changed to the currently
290 * activated view so that it can make appropriate display changes. */ 292 * activated view so that it can make appropriate display changes. */
291 void changeEventDisplay(Event *, int); 293 void changeEventDisplay(Event *, int);
292 void changeIncidenceDisplay(Incidence *, int); 294 void changeIncidenceDisplay(Incidence *, int);
293 void changeTodoDisplay(Todo *, int); 295 void changeTodoDisplay(Todo *, int);
294 296
295 void eventAdded(Event *); 297 void eventAdded(Event *);
296 void eventChanged(Event *); 298 void eventChanged(Event *);
297 void eventToBeDeleted(Event *); 299 void eventToBeDeleted(Event *);
298 void eventDeleted(); 300 void eventDeleted();
299 301
300 void todoAdded(Todo *); 302 void todoAdded(Todo *);
301 void todoChanged(Todo *); 303 void todoChanged(Todo *);
302 void todoToBeDeleted(Todo *); 304 void todoToBeDeleted(Todo *);
303 void todoDeleted(); 305 void todoDeleted();
304 306
305 void updateView(const QDate &start, const QDate &end); 307 void updateView(const QDate &start, const QDate &end);
306 void updateView(); 308 void updateView();
307 309
308 /** Full update of visible todo views */ 310 /** Full update of visible todo views */
309 void updateTodoViews(); 311 void updateTodoViews();
310 312
311 void updateUnmanagedViews(); 313 void updateUnmanagedViews();
312 314
313 /** cut the current appointment to the clipboard */ 315 /** cut the current appointment to the clipboard */
314 void edit_cut(); 316 void edit_cut();
315 317
316 /** copy the current appointment(s) to the clipboard */ 318 /** copy the current appointment(s) to the clipboard */
317 void edit_copy(); 319 void edit_copy();
318 320
319 /** paste the current vobject(s) in the clipboard buffer into calendar */ 321 /** paste the current vobject(s) in the clipboard buffer into calendar */
320 void edit_paste(); 322 void edit_paste();
321 323
322 /** edit viewing and configuration options. */ 324 /** edit viewing and configuration options. */
323 void edit_options(); 325 void edit_options();
324 /** 326 /**
325 Functions for printing, previewing a print, and setting up printing 327 Functions for printing, previewing a print, and setting up printing
326 parameters. 328 parameters.
327 */ 329 */
328 void print(); 330 void print();
329 void printSetup(); 331 void printSetup();
330 void printPreview(); 332 void printPreview();
331 333
332 /** Export as iCalendar file */ 334 /** Export as iCalendar file */
333 void exportICalendar(); 335 void exportICalendar();
334 336
335 /** Export as vCalendar file */ 337 /** Export as vCalendar file */
336 bool exportVCalendar( QString fn); 338 bool exportVCalendar( QString fn);
337 339
338 /** pop up a dialog to show an existing appointment. */ 340 /** pop up a dialog to show an existing appointment. */
339 void appointment_show(); 341 void appointment_show();
340 /** 342 /**
341 * pop up an Appointment Dialog to edit an existing appointment.Get 343 * pop up an Appointment Dialog to edit an existing appointment.Get
342 * information on the appointment from the list of unique IDs that is 344 * information on the appointment from the list of unique IDs that is
343 * currently in the View, called currIds. 345 * currently in the View, called currIds.
344 */ 346 */
345 void appointment_edit(); 347 void appointment_edit();
346 /** 348 /**
347 * pop up dialog confirming deletion of currently selected event in the 349 * pop up dialog confirming deletion of currently selected event in the
348 * View. 350 * View.
349 */ 351 */
350 void appointment_delete(); 352 void appointment_delete();
351 353
352 /** mails the currently selected event to a particular user as a vCalendar 354 /** mails the currently selected event to a particular user as a vCalendar
353 attachment. */ 355 attachment. */
354 void action_mail(); 356 void action_mail();
355 357
356 /* frees a subtodo from it's relation */ 358 /* frees a subtodo from it's relation */
357 void todo_unsub( Todo * ); 359 void todo_unsub( Todo * );
358 void todo_resub( Todo * parent, Todo * sub ); 360 void todo_resub( Todo * parent, Todo * sub );
359 361
360 /** Take ownership of selected event. */ 362 /** Take ownership of selected event. */
361 void takeOverEvent(); 363 void takeOverEvent();
362 364
363 /** Take ownership of all events in calendar. */ 365 /** Take ownership of all events in calendar. */
364 void takeOverCalendar(); 366 void takeOverCalendar();
365 367
366 /** query whether or not the calendar is "dirty". */ 368 /** query whether or not the calendar is "dirty". */
367 bool isModified(); 369 bool isModified();
368 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 370 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
369 void setModified(bool modified=true); 371 void setModified(bool modified=true);
370 372
371 /** query if the calendar is read-only. */ 373 /** query if the calendar is read-only. */
372 bool isReadOnly(); 374 bool isReadOnly();
373 /** set state of calendar to read-only */ 375 /** set state of calendar to read-only */
374 void setReadOnly(bool readOnly=true); 376 void setReadOnly(bool readOnly=true);
375 377
376 void eventUpdated(Incidence *); 378 void eventUpdated(Incidence *);
377 379
378 /* iTIP scheduling actions */ 380 /* iTIP scheduling actions */
379 void schedule_publish(Incidence *incidence = 0); 381 void schedule_publish(Incidence *incidence = 0);
380 void schedule_request(Incidence *incidence = 0); 382 void schedule_request(Incidence *incidence = 0);
381 void schedule_refresh(Incidence *incidence = 0); 383 void schedule_refresh(Incidence *incidence = 0);
382 void schedule_cancel(Incidence *incidence = 0); 384 void schedule_cancel(Incidence *incidence = 0);
383 void schedule_add(Incidence *incidence = 0); 385 void schedule_add(Incidence *incidence = 0);
384 void schedule_reply(Incidence *incidence = 0); 386 void schedule_reply(Incidence *incidence = 0);
385 void schedule_counter(Incidence *incidence = 0); 387 void schedule_counter(Incidence *incidence = 0);
386 void schedule_declinecounter(Incidence *incidence = 0); 388 void schedule_declinecounter(Incidence *incidence = 0);
387 void schedule_publish_freebusy(int daysToPublish = 30); 389 void schedule_publish_freebusy(int daysToPublish = 30);
388 390
389 void openAddressbook(); 391 void openAddressbook();
390 392
391 void editFilters(); 393 void editFilters();
392 void toggleFilerEnabled(); 394 void toggleFilerEnabled();
393 QPtrList<CalFilter> filters(); 395 QPtrList<CalFilter> filters();
394 void toggleFilter(); 396 void toggleFilter();
395 void showFilter(bool visible); 397 void showFilter(bool visible);
396 void updateFilter(); 398 void updateFilter();
397 void filterEdited(); 399 void filterEdited();
398 void selectFilter( int ); 400 void selectFilter( int );
399 KOFilterView *filterView(); 401 KOFilterView *filterView();
400 402
401 void showIntro(); 403 void showIntro();
402 404
403 /** Move the curdatepient view date to today */ 405 /** Move the curdatepient view date to today */
404 void goToday(); 406 void goToday();
405 407
406 /** Move to the next date(s) in the current view */ 408 /** Move to the next date(s) in the current view */
407 void goNext(); 409 void goNext();
408 410
409 /** Move to the previous date(s) in the current view */ 411 /** Move to the previous date(s) in the current view */
410 void goPrevious(); 412 void goPrevious();
411 /** Move to the next date(s) in the current view */ 413 /** Move to the next date(s) in the current view */
412 void goNextMonth(); 414 void goNextMonth();
413 415
414 /** Move to the previous date(s) in the current view */ 416 /** Move to the previous date(s) in the current view */
415 void goPreviousMonth(); 417 void goPreviousMonth();
416 418
417 void toggleExpand(); 419 void toggleExpand();
418 void toggleDateNavigatorWidget(); 420 void toggleDateNavigatorWidget();
419 void toggleAllDaySize(); 421 void toggleAllDaySize();
420 void dialogClosing(Incidence *); 422 void dialogClosing(Incidence *);
421 423
422 /** Look for new messages in the inbox */ 424 /** Look for new messages in the inbox */
423 void lookForIncomingMessages(); 425 void lookForIncomingMessages();
424 /** Look for new messages in the outbox */ 426 /** Look for new messages in the outbox */
425 void lookForOutgoingMessages(); 427 void lookForOutgoingMessages();
426 428
427 void processMainViewSelection( Incidence * ); 429 void processMainViewSelection( Incidence * );
428 void processTodoListSelection( Incidence * ); 430 void processTodoListSelection( Incidence * );
429 431
430 void processIncidenceSelection( Incidence * ); 432 void processIncidenceSelection( Incidence * );
431 433
432 void purgeCompleted(); 434 void purgeCompleted();
433 bool removeCompletedSubTodos( Todo* ); 435 bool removeCompletedSubTodos( Todo* );
434 void slotCalendarChanged(); 436 void slotCalendarChanged();
435 bool importBday(); 437 bool importBday();
436 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 438 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
437 bool importQtopia( const QString &categoriesFile, 439 bool importQtopia( const QString &categoriesFile,
438 const QString &datebookFile, 440 const QString &datebookFile,
439 const QString &tasklistFile ); 441 const QString &tasklistFile );
440 void syncExternal( int mode ); 442 void syncExternal( int mode );
441 void slotSelectPickerDate( QDate ) ; 443 void slotSelectPickerDate( QDate ) ;
442 void showDatePicker( ) ; 444 void showDatePicker( ) ;
443 void moveIncidence(Incidence *) ; 445 void moveIncidence(Incidence *) ;
444 void beamIncidence(Incidence *) ; 446 void beamIncidence(Incidence *) ;
445 void beamCalendar() ; 447 void beamCalendar() ;
446 void beamFilteredCalendar() ; 448 void beamFilteredCalendar() ;
447 void beamIncidenceList(QPtrList<Incidence>) ; 449 void beamIncidenceList(QPtrList<Incidence>) ;
448 void manageCategories(); 450 void manageCategories();
449 int addCategories(); 451 int addCategories();
450 void removeCategories(); 452 void removeCategories();
451 void setSyncDevice( QString ); 453 void setSyncDevice( QString );
452 void setSyncName( QString ); 454 void setSyncName( QString );
453 void showDay( QDate ); 455 void showDay( QDate );
454 void undo_delete(); 456 void undo_delete();
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 7e0b216..73ee5cb 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1,810 +1,862 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 Marcus Bains line. 5 Marcus Bains line.
6 Copyright (c) 2001 Ali Rahimi 6 Copyright (c) 2001 Ali Rahimi
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 (at your option) any later version.
12 12
13 This program is distributed in the hope that it will be useful, 13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17 17
18 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 21
22 As a special exception, permission is given to link this program 22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable, 23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution. 24 without including the source code for Qt in the source distribution.
25*/ 25*/
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#define protected public 28#define protected public
29#include <qwidget.h> 29#include <qwidget.h>
30#undef protected 30#undef protected
31#endif 31#endif
32#include <qintdict.h> 32#include <qintdict.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34#include <qapplication.h> 34#include <qapplication.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <qcursor.h> 36#include <qcursor.h>
37#include <qpainter.h> 37#include <qpainter.h>
38 38
39#include <kdebug.h> 39#include <kdebug.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kiconloader.h> 41#include <kiconloader.h>
42#include <kglobal.h> 42#include <kglobal.h>
43 43
44#include "koagendaitem.h" 44#include "koagendaitem.h"
45#include "koprefs.h" 45#include "koprefs.h"
46#include "koglobals.h" 46#include "koglobals.h"
47 47
48#include "koagenda.h" 48#include "koagenda.h"
49 49
50#include <libkcal/event.h> 50#include <libkcal/event.h>
51#include <libkcal/todo.h> 51#include <libkcal/todo.h>
52 52
53#ifndef DESKTOP_VERSION 53#ifndef DESKTOP_VERSION
54#include <qpe/qpeapplication.h> 54#include <qpe/qpeapplication.h>
55#endif 55#endif
56 56
57//extern bool globalFlagBlockPainting; 57//extern bool globalFlagBlockPainting;
58extern int globalFlagBlockAgenda; 58extern int globalFlagBlockAgenda;
59extern int globalFlagBlockAgendaItemPaint; 59extern int globalFlagBlockAgendaItemPaint;
60extern int globalFlagBlockAgendaItemUpdate; 60extern int globalFlagBlockAgendaItemUpdate;
61extern int globalFlagBlockStartup; 61extern int globalFlagBlockStartup;
62 62
63//////////////////////////////////////////////////////////////////////////// 63////////////////////////////////////////////////////////////////////////////
64MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) 64MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
65 : QFrame(_agenda->viewport(),name), agenda(_agenda) 65 : QFrame(_agenda->viewport(),name), agenda(_agenda)
66{ 66{
67 setLineWidth(0); 67 setLineWidth(0);
68 setMargin(0); 68 setMargin(0);
69 setBackgroundColor(Qt::red); 69 setBackgroundColor(Qt::red);
70 minutes = new QTimer(this); 70 minutes = new QTimer(this);
71 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); 71 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc()));
72 minutes->start(0, true); 72 minutes->start(0, true);
73 73
74 mTimeBox = new QLabel(this); 74 mTimeBox = new QLabel(this);
75 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); 75 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom);
76 QPalette pal = mTimeBox->palette(); 76 QPalette pal = mTimeBox->palette();
77 pal.setColor(QColorGroup::Foreground, Qt::red); 77 pal.setColor(QColorGroup::Foreground, Qt::red);
78 mTimeBox->setPalette(pal); 78 mTimeBox->setPalette(pal);
79 //mTimeBox->setAutoMask(true); 79 //mTimeBox->setAutoMask(true);
80 80
81 agenda->addChild(mTimeBox); 81 agenda->addChild(mTimeBox);
82 82
83 oldToday = -1; 83 oldToday = -1;
84} 84}
85 85
86MarcusBains::~MarcusBains() 86MarcusBains::~MarcusBains()
87{ 87{
88 delete minutes; 88 delete minutes;
89} 89}
90 90
91int MarcusBains::todayColumn() 91int MarcusBains::todayColumn()
92{ 92{
93 QDate currentDate = QDate::currentDate(); 93 QDate currentDate = QDate::currentDate();
94 94
95 DateList dateList = agenda->dateList(); 95 DateList dateList = agenda->dateList();
96 DateList::ConstIterator it; 96 DateList::ConstIterator it;
97 int col = 0; 97 int col = 0;
98 for(it = dateList.begin(); it != dateList.end(); ++it) { 98 for(it = dateList.begin(); it != dateList.end(); ++it) {
99 if((*it) == currentDate) 99 if((*it) == currentDate)
100 return KOGlobals::self()->reverseLayout() ? 100 return KOGlobals::self()->reverseLayout() ?
101 agenda->columns() - 1 - col : col; 101 agenda->columns() - 1 - col : col;
102 ++col; 102 ++col;
103 } 103 }
104 104
105 return -1; 105 return -1;
106} 106}
107void MarcusBains::updateLoc() 107void MarcusBains::updateLoc()
108{ 108{
109 updateLocation(); 109 updateLocation();
110} 110}
111void MarcusBains::updateLocation(bool recalculate) 111void MarcusBains::updateLocation(bool recalculate)
112{ 112{
113 113
114 QTime tim = QTime::currentTime(); 114 QTime tim = QTime::currentTime();
115 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); 115 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1());
116 if((tim.hour() == 0) && (oldTime.hour()==23)) 116 if((tim.hour() == 0) && (oldTime.hour()==23))
117 recalculate = true; 117 recalculate = true;
118 118
119 int mins = tim.hour()*60 + tim.minute(); 119 int mins = tim.hour()*60 + tim.minute();
120 int minutesPerCell = 24 * 60 / agenda->rows(); 120 int minutesPerCell = 24 * 60 / agenda->rows();
121 int y = mins*agenda->gridSpacingY()/minutesPerCell; 121 int y = mins*agenda->gridSpacingY()/minutesPerCell;
122 int today = recalculate ? todayColumn() : oldToday; 122 int today = recalculate ? todayColumn() : oldToday;
123 int x = agenda->gridSpacingX()*today; 123 int x = agenda->gridSpacingX()*today;
124 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); 124 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled);
125 125
126 oldTime = tim; 126 oldTime = tim;
127 oldToday = today; 127 oldToday = today;
128 128
129 if(disabled || (today<0)) { 129 if(disabled || (today<0)) {
130 hide(); mTimeBox->hide(); 130 hide(); mTimeBox->hide();
131 return; 131 return;
132 } else { 132 } else {
133 show(); mTimeBox->show(); 133 show(); mTimeBox->show();
134 } 134 }
135 135
136 if(recalculate) 136 if(recalculate)
137 setFixedSize(agenda->gridSpacingX(),1); 137 setFixedSize(agenda->gridSpacingX(),1);
138 agenda->moveChild(this, x, y); 138 agenda->moveChild(this, x, y);
139 raise(); 139 raise();
140 140
141 if(recalculate) 141 if(recalculate)
142 //mTimeBox->setFont(QFont("helvetica",10)); 142 //mTimeBox->setFont(QFont("helvetica",10));
143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); 143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont);
144 144
145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); 145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds));
146 mTimeBox->adjustSize(); 146 mTimeBox->adjustSize();
147 // the -2 below is there because there is a bug in this program 147 // the -2 below is there because there is a bug in this program
148 // somewhere, where the last column of this widget is a few pixels 148 // somewhere, where the last column of this widget is a few pixels
149 // narrower than the other columns. 149 // narrower than the other columns.
150 int offs = (today==agenda->columns()-1) ? -4 : 0; 150 int offs = (today==agenda->columns()-1) ? -4 : 0;
151 agenda->moveChild(mTimeBox, 151 agenda->moveChild(mTimeBox,
152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, 152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
153 y-mTimeBox->height()); 153 y-mTimeBox->height());
154 154
155 mTimeBox->raise(); 155 mTimeBox->raise();
156 //mTimeBox->setAutoMask(true); 156 //mTimeBox->setAutoMask(true);
157 minutes->start(5000,true); 157 minutes->start(5000,true);
158} 158}
159 159
160 160
161//////////////////////////////////////////////////////////////////////////// 161////////////////////////////////////////////////////////////////////////////
162 162
163 163
164/* 164/*
165 Create an agenda widget with rows rows and columns columns. 165 Create an agenda widget with rows rows and columns columns.
166*/ 166*/
167KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 167KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
168 const char *name,WFlags f) : 168 const char *name,WFlags f) :
169 QScrollView(parent,name,f) 169 QScrollView(parent,name,f)
170{ 170{
171 171 mNewItemPopup = new QPopupMenu( this );
172 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
173 QString pathString = "";
174 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
175 if ( QApplication::desktop()->width() < 480 )
176 pathString += "icons16/";
177 } else
178 pathString += "iconsmini/";
179
180 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
181 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
182
172 mColumns = columns; 183 mColumns = columns;
173 mRows = rows; 184 mRows = rows;
174 mGridSpacingY = rowSize; 185 mGridSpacingY = rowSize;
175 mAllDayMode = false; 186 mAllDayMode = false;
176#ifndef DESKTOP_VERSION 187#ifndef DESKTOP_VERSION
177 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 188 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
178#endif 189#endif
179 mHolidayMask = 0; 190 mHolidayMask = 0;
180 init(); 191 init();
181} 192}
182 193
183/* 194/*
184 Create an agenda widget with columns columns and one row. This is used for 195 Create an agenda widget with columns columns and one row. This is used for
185 all-day events. 196 all-day events.
186*/ 197*/
187KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : 198KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
188 QScrollView(parent,name,f) 199 QScrollView(parent,name,f)
189{ 200{
190 201 mNewItemPopup = new QPopupMenu( this );
202 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
203 QString pathString = "";
204 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
205 if ( QApplication::desktop()->width() < 480 )
206 pathString += "icons16/";
207 } else
208 pathString += "iconsmini/";
209 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."),1 );
210 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
191 blockResize = false; 211 blockResize = false;
192 mColumns = columns; 212 mColumns = columns;
193 mRows = 1; 213 mRows = 1;
194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 214 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
195 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 215 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
196 mAllDayMode = true; 216 mAllDayMode = true;
197#ifndef DESKTOP_VERSION 217#ifndef DESKTOP_VERSION
198 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 218 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
199#endif 219#endif
200 mHolidayMask = 0; 220 mHolidayMask = 0;
201 init(); 221 init();
202} 222}
203 223
204 224
205KOAgenda::~KOAgenda() 225KOAgenda::~KOAgenda()
206{ 226{
207 if(mMarcusBains) delete mMarcusBains; 227 if(mMarcusBains) delete mMarcusBains;
208 228
209} 229}
210 230
211Incidence *KOAgenda::selectedIncidence() const 231Incidence *KOAgenda::selectedIncidence() const
212{ 232{
213 return (mSelectedItem ? mSelectedItem->incidence() : 0); 233 return (mSelectedItem ? mSelectedItem->incidence() : 0);
214} 234}
215 235
216 236
217QDate KOAgenda::selectedIncidenceDate() const 237QDate KOAgenda::selectedIncidenceDate() const
218{ 238{
219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 239 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
220} 240}
221 241
222 242
223void KOAgenda::init() 243void KOAgenda::init()
224{ 244{
225#ifndef _WIN32_ 245#ifndef _WIN32_
226 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 246 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
227 viewport()->setWFlags ( wflags); 247 viewport()->setWFlags ( wflags);
228#endif 248#endif
229 mGridSpacingX = 80; 249 mGridSpacingX = 80;
230 mResizeBorderWidth = 8; 250 mResizeBorderWidth = 8;
231 mScrollBorderWidth = 8; 251 mScrollBorderWidth = 8;
232 mScrollDelay = 30; 252 mScrollDelay = 30;
233 mScrollOffset = 10; 253 mScrollOffset = 10;
234 mPaintPixmap.resize( 20,20); 254 mPaintPixmap.resize( 20,20);
235 //enableClipper(true); 255 //enableClipper(true);
236 256
237 // Grab key strokes for keyboard navigation of agenda. Seems to have no 257 // Grab key strokes for keyboard navigation of agenda. Seems to have no
238 // effect. Has to be fixed. 258 // effect. Has to be fixed.
239 setFocusPolicy(WheelFocus); 259 setFocusPolicy(WheelFocus);
240 260
241 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 261 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
242 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 262 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
243 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 263 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
244 264
245 mStartCellX = 0; 265 mStartCellX = 0;
246 mStartCellY = 0; 266 mStartCellY = 0;
247 mCurrentCellX = 0; 267 mCurrentCellX = 0;
248 mCurrentCellY = 0; 268 mCurrentCellY = 0;
249 269
250 mSelectionCellX = 0; 270 mSelectionCellX = 0;
251 mSelectionYTop = 0; 271 mSelectionYTop = 0;
252 mSelectionHeight = 0; 272 mSelectionHeight = 0;
253 273
254 mOldLowerScrollValue = -1; 274 mOldLowerScrollValue = -1;
255 mOldUpperScrollValue = -1; 275 mOldUpperScrollValue = -1;
256 276
257 mClickedItem = 0; 277 mClickedItem = 0;
258 278
259 mActionItem = 0; 279 mActionItem = 0;
260 mActionType = NOP; 280 mActionType = NOP;
261 mItemMoved = false; 281 mItemMoved = false;
262 282
263 mSelectedItem = 0; 283 mSelectedItem = 0;
264 284
265 // mItems.setAutoDelete(true); 285 // mItems.setAutoDelete(true);
266 286
267 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 287 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
268 288
269 viewport()->update(); 289 viewport()->update();
270 290
271 setMinimumSize(30, 1); 291 setMinimumSize(30, 1);
272// setMaximumHeight(mGridSpacingY * mRows + 5); 292// setMaximumHeight(mGridSpacingY * mRows + 5);
273 293
274 // Disable horizontal scrollbar. This is a hack. The geometry should be 294 // Disable horizontal scrollbar. This is a hack. The geometry should be
275 // controlled in a way that the contents horizontally always fits. Then it is 295 // controlled in a way that the contents horizontally always fits. Then it is
276 // not necessary to turn off the scrollbar. 296 // not necessary to turn off the scrollbar.
277 setHScrollBarMode(AlwaysOff); 297 setHScrollBarMode(AlwaysOff);
278 if ( ! mAllDayMode ) 298 if ( ! mAllDayMode )
279 setVScrollBarMode(AlwaysOn); 299 setVScrollBarMode(AlwaysOn);
280 else 300 else
281 setVScrollBarMode(AlwaysOff); 301 setVScrollBarMode(AlwaysOff);
282 302
283 setStartHour(KOPrefs::instance()->mDayBegins); 303 setStartHour(KOPrefs::instance()->mDayBegins);
284 304
285 calculateWorkingHours(); 305 calculateWorkingHours();
286 306
287 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 307 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
288 SLOT(checkScrollBoundaries(int))); 308 SLOT(checkScrollBoundaries(int)));
289 309
290 // Create the Marcus Bains line. 310 // Create the Marcus Bains line.
291 if(mAllDayMode) 311 if(mAllDayMode)
292 mMarcusBains = 0; 312 mMarcusBains = 0;
293 else { 313 else {
294 mMarcusBains = new MarcusBains(this); 314 mMarcusBains = new MarcusBains(this);
295 addChild(mMarcusBains); 315 addChild(mMarcusBains);
296 } 316 }
297} 317}
298 318
299void KOAgenda::clear() 319void KOAgenda::clear()
300{ 320{
301 KOAgendaItem *item; 321 KOAgendaItem *item;
302 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 322 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
303 mUnusedItems.append( item ); 323 mUnusedItems.append( item );
304 //item->hide(); 324 //item->hide();
305 } 325 }
306 mItems.clear(); 326 mItems.clear();
307 mSelectedItem = 0; 327 mSelectedItem = 0;
308 clearSelection(); 328 clearSelection();
309} 329}
310 330
311void KOAgenda::clearSelection() 331void KOAgenda::clearSelection()
312{ 332{
313 mSelectionCellX = 0; 333 mSelectionCellX = 0;
314 mSelectionYTop = 0; 334 mSelectionYTop = 0;
315 mSelectionHeight = 0; 335 mSelectionHeight = 0;
316} 336}
317 337
318void KOAgenda::marcus_bains() 338void KOAgenda::marcus_bains()
319{ 339{
320 if(mMarcusBains) mMarcusBains->updateLocation(true); 340 if(mMarcusBains) mMarcusBains->updateLocation(true);
321} 341}
322 342
323 343
324void KOAgenda::changeColumns(int columns) 344void KOAgenda::changeColumns(int columns)
325{ 345{
326 if (columns == 0) { 346 if (columns == 0) {
327 kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; 347 kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl;
328 return; 348 return;
329 } 349 }
330 350
331 clear(); 351 clear();
332 352
333 mColumns = columns; 353 mColumns = columns;
334// setMinimumSize(mColumns * 10, mGridSpacingY + 1); 354// setMinimumSize(mColumns * 10, mGridSpacingY + 1);
335// init(); 355// init();
336// update(); 356// update();
337 //qDebug("KOAgenda::changeColumns "); 357 //qDebug("KOAgenda::changeColumns ");
338 computeSizes(); 358 computeSizes();
339 // QResizeEvent event( size(), size() ); 359 // QResizeEvent event( size(), size() );
340 360
341 //QApplication::sendEvent( this, &event ); 361 //QApplication::sendEvent( this, &event );
342} 362}
343 363
344/* 364/*
345 This is the eventFilter function, which gets all events from the KOAgendaItems 365 This is the eventFilter function, which gets all events from the KOAgendaItems
346 contained in the agenda. It has to handle moving and resizing for all items. 366 contained in the agenda. It has to handle moving and resizing for all items.
347*/ 367*/
348bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 368bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
349{ 369{
350// kdDebug() << "KOAgenda::eventFilter" << endl; 370// kdDebug() << "KOAgenda::eventFilter" << endl;
351 switch(event->type()) { 371 switch(event->type()) {
352 case QEvent::MouseButtonPress: 372 case QEvent::MouseButtonPress:
353 case QEvent::MouseButtonDblClick: 373 case QEvent::MouseButtonDblClick:
354 case QEvent::MouseButtonRelease: 374 case QEvent::MouseButtonRelease:
355 case QEvent::MouseMove: 375 case QEvent::MouseMove:
356 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 376 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
357 377
358 case (QEvent::Leave): 378 case (QEvent::Leave):
359 if (!mActionItem) 379 if (!mActionItem)
360 setCursor(arrowCursor); 380 setCursor(arrowCursor);
361 return true; 381 return true;
362 382
363 default: 383 default:
364 return QScrollView::eventFilter(object,event); 384 return QScrollView::eventFilter(object,event);
365 } 385 }
366} 386}
367 387
368 388
369bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 389bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
370{ 390{
371 //qDebug("KOAgenda::eventFilter_mous "); 391 //qDebug("KOAgenda::eventFilter_mous ");
372 QPoint viewportPos; 392 QPoint viewportPos;
373 if (object != viewport()) { 393 if (object != viewport()) {
374 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 394 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
375 } else { 395 } else {
376 viewportPos = me->pos(); 396 viewportPos = me->pos();
377 } 397 }
378 static int startX = 0; 398 static int startX = 0;
379 static int startY = 0; 399 static int startY = 0;
380 static bool block = true; 400 static bool block = true;
381 switch (me->type()) { 401 switch (me->type()) {
382 case QEvent::MouseButtonPress: 402 case QEvent::MouseButtonPress:
383 //qDebug("QEvent::MouseButtonPress: "); 403 //qDebug("QEvent::MouseButtonPress: ");
384 // kdDebug() << "koagenda: filtered button press" << endl; 404 // kdDebug() << "koagenda: filtered button press" << endl;
385 if (object != viewport()) { 405 if (object != viewport()) {
386 if (me->button() == RightButton) { 406 if (me->button() == RightButton) {
387 407
388 mClickedItem = (KOAgendaItem *)object; 408 mClickedItem = (KOAgendaItem *)object;
389 if (mClickedItem) { 409 if (mClickedItem) {
390 selectItem(mClickedItem); 410 selectItem(mClickedItem);
391 // emit showIncidencePopupSignal(mClickedItem->incidence()); 411 // emit showIncidencePopupSignal(mClickedItem->incidence());
392 } 412 }
393 //mItemPopup->popup(QCursor::pos()); 413 //mItemPopup->popup(QCursor::pos());
394 } else { 414 } else {
395 mActionItem = (KOAgendaItem *)object; 415 mActionItem = (KOAgendaItem *)object;
396 if (mActionItem) { 416 if (mActionItem) {
397 if ( mSelectionHeight > 0 ) { 417 if ( mSelectionHeight > 0 ) {
398 int selectionCellX = mSelectionCellX * mGridSpacingX; 418 int selectionCellX = mSelectionCellX * mGridSpacingX;
399 int selectionYTop = mSelectionYTop; 419 int selectionYTop = mSelectionYTop;
400 int gridSpacingX = mGridSpacingX; 420 int gridSpacingX = mGridSpacingX;
401 int selectionHeight = mSelectionHeight; 421 int selectionHeight = mSelectionHeight;
402 clearSelection(); 422 clearSelection();
403 repaintContents( selectionCellX, selectionYTop, 423 repaintContents( selectionCellX, selectionYTop,
404 gridSpacingX, selectionHeight,false ); 424 gridSpacingX, selectionHeight,false );
405 } 425 }
406 selectItem(mActionItem); 426 selectItem(mActionItem);
407 Incidence *incidence = mActionItem->incidence(); 427 Incidence *incidence = mActionItem->incidence();
408 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 428 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
409 mActionItem = 0; 429 mActionItem = 0;
410 } else { 430 } else {
411 startItemAction(viewportPos); 431 startItemAction(viewportPos);
412 startX = viewportPos.x(); 432 startX = viewportPos.x();
413 startY = viewportPos.y(); 433 startY = viewportPos.y();
414 block = true; 434 block = true;
415 } 435 }
416 } 436 }
417 } 437 }
418 } else { 438 } else {
419 selectItem(0); 439 selectItem(0);
420 mActionItem = 0; 440 mActionItem = 0;
421 setCursor(arrowCursor); 441 if (me->button() == RightButton ) {
422 startSelectAction(viewportPos); 442 blockNewEvent = true;
443 qDebug("right ");
444 int x,y;
445 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
446 int gx,gy;
447 contentsToGrid(x,y,gx,gy);
448 mStartCellX = gx;
449 mStartCellY = gy;
450 mCurrentCellX = gx;
451 mCurrentCellY = gy;
452 mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) );
453
454 } else {
455 blockNewEvent = false;
456 setCursor(arrowCursor);
457 startSelectAction(viewportPos);
458 }
423 } 459 }
424 break; 460 break;
425 461
426 case QEvent::MouseButtonRelease: 462 case QEvent::MouseButtonRelease:
427 //qDebug("QEvent::MouseButtonRelease: "); 463 //qDebug("QEvent::MouseButtonRelease: ");
428 if (me->button() == RightButton && block ) { 464 if (me->button() == RightButton && block ) {
429 if (object != viewport()) { 465 if (object != viewport()) {
430 mClickedItem = (KOAgendaItem *)object; 466 mClickedItem = (KOAgendaItem *)object;
431 if (mActionItem ) { 467 if (mActionItem ) {
432 endItemAction(); 468 endItemAction();
433 } 469 }
434 if (mClickedItem) { 470 if (mClickedItem) {
435 selectItem(mClickedItem); 471 selectItem(mClickedItem);
436 emit showIncidencePopupSignal(mClickedItem->incidence()); 472 emit showIncidencePopupSignal(mClickedItem->incidence());
437 } 473 }
438 } 474 }
439 break; 475 break;
440 } 476 }
441 block = true; 477 block = true;
442 if (mActionItem) { 478 if (mActionItem) {
443 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 479 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
444 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 480 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
445 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 481 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
446 mScrollUpTimer.stop(); 482 mScrollUpTimer.stop();
447 mScrollDownTimer.stop(); 483 mScrollDownTimer.stop();
448 mActionItem->resetMove(); 484 mActionItem->resetMove();
449 placeSubCells( mActionItem ); 485 placeSubCells( mActionItem );
450 // emit startDragSignal( mActionItem->incidence() ); 486 // emit startDragSignal( mActionItem->incidence() );
451 setCursor( arrowCursor ); 487 setCursor( arrowCursor );
452 mActionItem = 0; 488 mActionItem = 0;
453 mActionType = NOP; 489 mActionType = NOP;
454 mItemMoved = 0; 490 mItemMoved = 0;
455 return true; 491 return true;
456 } 492 }
457 endItemAction(); 493 endItemAction();
458 } else if ( mActionType == SELECT ) { 494 } else if ( mActionType == SELECT ) {
459 endSelectAction(); 495 if (me->button() == RightButton ) {
496
497 } else {
498 endSelectAction( !blockNewEvent );
499 }
460 } 500 }
461 break; 501 break;
462 502
463 case QEvent::MouseMove: 503 case QEvent::MouseMove:
464 if (object != viewport()) { 504 if (object != viewport()) {
465 KOAgendaItem *moveItem = (KOAgendaItem *)object; 505 KOAgendaItem *moveItem = (KOAgendaItem *)object;
466 //qDebug("moveItem %d ",moveItem ); 506 //qDebug("moveItem %d ",moveItem );
467 if (!moveItem->incidence()->isReadOnly() /*&& 507 if (!moveItem->incidence()->isReadOnly() /*&&
468 !moveItem->incidence()->recurrence()->doesRecur()*/ ) 508 !moveItem->incidence()->recurrence()->doesRecur()*/ )
469 if (!mActionItem) 509 if (!mActionItem)
470 setNoActionCursor(moveItem,viewportPos); 510 setNoActionCursor(moveItem,viewportPos);
471 else { 511 else {
472 if ( block ) { 512 if ( block ) {
473 int dX, dY; 513 int dX, dY;
474 dX = startX - viewportPos.x(); 514 dX = startX - viewportPos.x();
475 if ( dX < 0 ) 515 if ( dX < 0 )
476 dX = -dX; 516 dX = -dX;
477 dY = viewportPos.y() - startY; 517 dY = viewportPos.y() - startY;
478 if ( dY < 0 ) 518 if ( dY < 0 )
479 dY = -dY; 519 dY = -dY;
480 int diff = 30; 520 int diff = 30;
481 if ( QApplication::desktop()->width() < 480 ) 521 if ( QApplication::desktop()->width() < 480 )
482 diff = 15; 522 diff = 15;
483 // qDebug(" %d %d ",dX, dY ); 523 // qDebug(" %d %d ",dX, dY );
484 if ( dX > diff || dY > diff ) { 524 if ( dX > diff || dY > diff ) {
485 block = false; 525 block = false;
486 } 526 }
487 } 527 }
488 if ( !block ) 528 if ( !block )
489 performItemAction(viewportPos); 529 performItemAction(viewportPos);
490 } 530 }
491 } else { 531 } else {
492 if ( mActionType == SELECT ) { 532 if ( mActionType == SELECT ) {
493 performSelectAction( viewportPos ); 533 performSelectAction( viewportPos );
494 } 534 }
495 } 535 }
496 break; 536 break;
497 537
498 case QEvent::MouseButtonDblClick: 538 case QEvent::MouseButtonDblClick:
499 if (object == viewport()) { 539 if (object == viewport()) {
500 selectItem(0); 540 selectItem(0);
501 int x,y; 541 int x,y;
502 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 542 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
503 int gx,gy; 543 int gx,gy;
504 contentsToGrid(x,y,gx,gy); 544 contentsToGrid(x,y,gx,gy);
505 emit newEventSignal(gx,gy); 545 emit newEventSignal(gx,gy);
506 } else { 546 } else {
507 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 547 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
508 selectItem(doubleClickedItem); 548 selectItem(doubleClickedItem);
509 if ( KOPrefs::instance()->mEditOnDoubleClick ) 549 if ( KOPrefs::instance()->mEditOnDoubleClick )
510 emit editIncidenceSignal(doubleClickedItem->incidence()); 550 emit editIncidenceSignal(doubleClickedItem->incidence());
511 else 551 else
512 emit showIncidenceSignal(doubleClickedItem->incidence()); 552 emit showIncidenceSignal(doubleClickedItem->incidence());
513 } 553 }
514 break; 554 break;
515 555
516 default: 556 default:
517 break; 557 break;
518 } 558 }
519 559
520 return true; 560 return true;
521} 561}
522 562
563void KOAgenda::newItem( int item )
564{
565 qDebug("new %d ", item);
566 if ( item == 1 ) { //new event
567 newEventSignal(mStartCellX ,mStartCellY );
568 }
569 if ( item == 2 ) { //new event
570 newTodoSignal(mStartCellX ,mStartCellY );
571 }
572}
523void KOAgenda::startSelectAction(QPoint viewportPos) 573void KOAgenda::startSelectAction(QPoint viewportPos)
524{ 574{
525 //emit newStartSelectSignal(); 575 //emit newStartSelectSignal();
526 576
527 mActionType = SELECT; 577 mActionType = SELECT;
528 578
529 int x,y; 579 int x,y;
530 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 580 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
531 int gx,gy; 581 int gx,gy;
532 contentsToGrid(x,y,gx,gy); 582 contentsToGrid(x,y,gx,gy);
533 583
534 mStartCellX = gx; 584 mStartCellX = gx;
535 mStartCellY = gy; 585 mStartCellY = gy;
536 mCurrentCellX = gx; 586 mCurrentCellX = gx;
537 mCurrentCellY = gy; 587 mCurrentCellY = gy;
538 588
539 // Store coordinates of old selection 589 // Store coordinates of old selection
540 int selectionX = mSelectionCellX * mGridSpacingX; 590 int selectionX = mSelectionCellX * mGridSpacingX;
541 int selectionYTop = mSelectionYTop; 591 int selectionYTop = mSelectionYTop;
542 int selectionHeight = mSelectionHeight; 592 int selectionHeight = mSelectionHeight;
543 593
544 // Store new selection 594 // Store new selection
545 mSelectionCellX = gx; 595 mSelectionCellX = gx;
546 mSelectionYTop = gy * mGridSpacingY; 596 mSelectionYTop = gy * mGridSpacingY;
547 mSelectionHeight = mGridSpacingY; 597 mSelectionHeight = mGridSpacingY;
548 598
549 // Clear old selection 599 // Clear old selection
550 repaintContents( selectionX, selectionYTop, 600 repaintContents( selectionX, selectionYTop,
551 mGridSpacingX, selectionHeight,false ); 601 mGridSpacingX, selectionHeight,false );
552 602
553 // Paint new selection 603 // Paint new selection
554 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, 604 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop,
555 // mGridSpacingX, mSelectionHeight ); 605 // mGridSpacingX, mSelectionHeight );
556} 606}
557 607
558void KOAgenda::performSelectAction(QPoint viewportPos) 608void KOAgenda::performSelectAction(QPoint viewportPos)
559{ 609{
560 int x,y; 610 int x,y;
561 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 611 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
562 int gx,gy; 612 int gx,gy;
563 contentsToGrid(x,y,gx,gy); 613 contentsToGrid(x,y,gx,gy);
564 614
565 QPoint clipperPos = clipper()-> 615 QPoint clipperPos = clipper()->
566 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 616 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
567 617
568 // Scroll if cursor was moved to upper or lower end of agenda. 618 // Scroll if cursor was moved to upper or lower end of agenda.
569 if (clipperPos.y() < mScrollBorderWidth) { 619 if (clipperPos.y() < mScrollBorderWidth) {
570 mScrollUpTimer.start(mScrollDelay); 620 mScrollUpTimer.start(mScrollDelay);
571 } else if (visibleHeight() - clipperPos.y() < 621 } else if (visibleHeight() - clipperPos.y() <
572 mScrollBorderWidth) { 622 mScrollBorderWidth) {
573 mScrollDownTimer.start(mScrollDelay); 623 mScrollDownTimer.start(mScrollDelay);
574 } else { 624 } else {
575 mScrollUpTimer.stop(); 625 mScrollUpTimer.stop();
576 mScrollDownTimer.stop(); 626 mScrollDownTimer.stop();
577 } 627 }
578 628
579 if ( gy > mCurrentCellY ) { 629 if ( gy > mCurrentCellY ) {
580 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 630 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
581 631
582#if 0 632#if 0
583 // FIXME: Repaint only the newly selected region 633 // FIXME: Repaint only the newly selected region
584 repaintContents( mSelectionCellX * mGridSpacingX, 634 repaintContents( mSelectionCellX * mGridSpacingX,
585 mCurrentCellY + mGridSpacingY, 635 mCurrentCellY + mGridSpacingY,
586 mGridSpacingX, 636 mGridSpacingX,
587 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); 637 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY );
588#else 638#else
589 repaintContents( (KOGlobals::self()->reverseLayout() ? 639 repaintContents( (KOGlobals::self()->reverseLayout() ?
590 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 640 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
591 mGridSpacingX, mSelectionYTop, 641 mGridSpacingX, mSelectionYTop,
592 mGridSpacingX, mSelectionHeight , false); 642 mGridSpacingX, mSelectionHeight , false);
593#endif 643#endif
594 644
595 mCurrentCellY = gy; 645 mCurrentCellY = gy;
596 } else if ( gy < mCurrentCellY ) { 646 } else if ( gy < mCurrentCellY ) {
597 if ( gy >= mStartCellY ) { 647 if ( gy >= mStartCellY ) {
598 int selectionHeight = mSelectionHeight; 648 int selectionHeight = mSelectionHeight;
599 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 649 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
600 650
601 repaintContents( (KOGlobals::self()->reverseLayout() ? 651 repaintContents( (KOGlobals::self()->reverseLayout() ?
602 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 652 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
603 mGridSpacingX, mSelectionYTop, 653 mGridSpacingX, mSelectionYTop,
604 mGridSpacingX, selectionHeight,false ); 654 mGridSpacingX, selectionHeight,false );
605 655
606 mCurrentCellY = gy; 656 mCurrentCellY = gy;
607 } else { 657 } else {
608 } 658 }
609 } 659 }
610} 660}
611 661
612void KOAgenda::endSelectAction() 662void KOAgenda::endSelectAction( bool emitNewEvent )
613{ 663{
614 mActionType = NOP; 664 mActionType = NOP;
615 mScrollUpTimer.stop(); 665 mScrollUpTimer.stop();
616 mScrollDownTimer.stop(); 666 mScrollDownTimer.stop();
617 667
618 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 668 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
669 if ( emitNewEvent && mStartCellY < mCurrentCellY )
670 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
619} 671}
620 672
621void KOAgenda::startItemAction(QPoint viewportPos) 673void KOAgenda::startItemAction(QPoint viewportPos)
622{ 674{
623 int x,y; 675 int x,y;
624 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 676 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
625 int gx,gy; 677 int gx,gy;
626 contentsToGrid(x,y,gx,gy); 678 contentsToGrid(x,y,gx,gy);
627 679
628 mStartCellX = gx; 680 mStartCellX = gx;
629 mStartCellY = gy; 681 mStartCellY = gy;
630 mCurrentCellX = gx; 682 mCurrentCellX = gx;
631 mCurrentCellY = gy; 683 mCurrentCellY = gy;
632 684
633 if (mAllDayMode) { 685 if (mAllDayMode) {
634 int gridDistanceX = (x - gx * mGridSpacingX); 686 int gridDistanceX = (x - gx * mGridSpacingX);
635 if (gridDistanceX < mResizeBorderWidth && 687 if (gridDistanceX < mResizeBorderWidth &&
636 mActionItem->cellX() == mCurrentCellX) { 688 mActionItem->cellX() == mCurrentCellX) {
637 mActionType = RESIZELEFT; 689 mActionType = RESIZELEFT;
638 setCursor(sizeHorCursor); 690 setCursor(sizeHorCursor);
639 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 691 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
640 mActionItem->cellXWidth() == mCurrentCellX) { 692 mActionItem->cellXWidth() == mCurrentCellX) {
641 mActionType = RESIZERIGHT; 693 mActionType = RESIZERIGHT;
642 setCursor(sizeHorCursor); 694 setCursor(sizeHorCursor);
643 } else { 695 } else {
644 mActionType = MOVE; 696 mActionType = MOVE;
645 mActionItem->startMove(); 697 mActionItem->startMove();
646 setCursor(sizeAllCursor); 698 setCursor(sizeAllCursor);
647 } 699 }
648 } else { 700 } else {
649 int gridDistanceY = (y - gy * mGridSpacingY); 701 int gridDistanceY = (y - gy * mGridSpacingY);
650 bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); 702 bool allowResize = ( mActionItem->incidence()->type() != "Todo" );
651 if (allowResize && gridDistanceY < mResizeBorderWidth && 703 if (allowResize && gridDistanceY < mResizeBorderWidth &&
652 mActionItem->cellYTop() == mCurrentCellY && 704 mActionItem->cellYTop() == mCurrentCellY &&
653 !mActionItem->firstMultiItem()) { 705 !mActionItem->firstMultiItem()) {
654 mActionType = RESIZETOP; 706 mActionType = RESIZETOP;
655 setCursor(sizeVerCursor); 707 setCursor(sizeVerCursor);
656 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 708 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
657 mActionItem->cellYBottom() == mCurrentCellY && 709 mActionItem->cellYBottom() == mCurrentCellY &&
658 !mActionItem->lastMultiItem()) { 710 !mActionItem->lastMultiItem()) {
659 mActionType = RESIZEBOTTOM; 711 mActionType = RESIZEBOTTOM;
660 setCursor(sizeVerCursor); 712 setCursor(sizeVerCursor);
661 } else { 713 } else {
662 mActionType = MOVE; 714 mActionType = MOVE;
663 mActionItem->startMove(); 715 mActionItem->startMove();
664 setCursor(sizeAllCursor); 716 setCursor(sizeAllCursor);
665 } 717 }
666 } 718 }
667} 719}
668 720
669void KOAgenda::performItemAction(QPoint viewportPos) 721void KOAgenda::performItemAction(QPoint viewportPos)
670{ 722{
671// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 723// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
672// QPoint point = viewport()->mapToGlobal(viewportPos); 724// QPoint point = viewport()->mapToGlobal(viewportPos);
673// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 725// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
674// point = clipper()->mapFromGlobal(point); 726// point = clipper()->mapFromGlobal(point);
675// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 727// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
676// kdDebug() << "visible height: " << visibleHeight() << endl; 728// kdDebug() << "visible height: " << visibleHeight() << endl;
677 int x,y; 729 int x,y;
678 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 730 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
679// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 731// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
680 int gx,gy; 732 int gx,gy;
681 contentsToGrid(x,y,gx,gy); 733 contentsToGrid(x,y,gx,gy);
682 QPoint clipperPos = clipper()-> 734 QPoint clipperPos = clipper()->
683 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 735 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
684 736
685 // Cursor left active agenda area. 737 // Cursor left active agenda area.
686 // This starts a drag. 738 // This starts a drag.
687 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ 739 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/
688 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { 740 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) {
689 if ( mActionType == MOVE ) { 741 if ( mActionType == MOVE ) {
690 mScrollUpTimer.stop(); 742 mScrollUpTimer.stop();
691 mScrollDownTimer.stop(); 743 mScrollDownTimer.stop();
692 mActionItem->resetMove(); 744 mActionItem->resetMove();
693 placeSubCells( mActionItem ); 745 placeSubCells( mActionItem );
694 // emit startDragSignal( mActionItem->incidence() ); 746 // emit startDragSignal( mActionItem->incidence() );
695 setCursor( arrowCursor ); 747 setCursor( arrowCursor );
696 mActionItem = 0; 748 mActionItem = 0;
697 mActionType = NOP; 749 mActionType = NOP;
698 mItemMoved = 0; 750 mItemMoved = 0;
699 return; 751 return;
700 } 752 }
701 } else { 753 } else {
702 switch ( mActionType ) { 754 switch ( mActionType ) {
703 case MOVE: 755 case MOVE:
704 setCursor( sizeAllCursor ); 756 setCursor( sizeAllCursor );
705 break; 757 break;
706 case RESIZETOP: 758 case RESIZETOP:
707 case RESIZEBOTTOM: 759 case RESIZEBOTTOM:
708 setCursor( sizeVerCursor ); 760 setCursor( sizeVerCursor );
709 break; 761 break;
710 case RESIZELEFT: 762 case RESIZELEFT:
711 case RESIZERIGHT: 763 case RESIZERIGHT:
712 setCursor( sizeHorCursor ); 764 setCursor( sizeHorCursor );
713 break; 765 break;
714 default: 766 default:
715 setCursor( arrowCursor ); 767 setCursor( arrowCursor );
716 } 768 }
717 } 769 }
718 770
719 // Scroll if item was moved to upper or lower end of agenda. 771 // Scroll if item was moved to upper or lower end of agenda.
720 if (clipperPos.y() < mScrollBorderWidth) { 772 if (clipperPos.y() < mScrollBorderWidth) {
721 mScrollUpTimer.start(mScrollDelay); 773 mScrollUpTimer.start(mScrollDelay);
722 } else if (visibleHeight() - clipperPos.y() < 774 } else if (visibleHeight() - clipperPos.y() <
723 mScrollBorderWidth) { 775 mScrollBorderWidth) {
724 mScrollDownTimer.start(mScrollDelay); 776 mScrollDownTimer.start(mScrollDelay);
725 } else { 777 } else {
726 mScrollUpTimer.stop(); 778 mScrollUpTimer.stop();
727 mScrollDownTimer.stop(); 779 mScrollDownTimer.stop();
728 } 780 }
729 781
730 // Move or resize item if necessary 782 // Move or resize item if necessary
731 if (mCurrentCellX != gx || mCurrentCellY != gy) { 783 if (mCurrentCellX != gx || mCurrentCellY != gy) {
732 mItemMoved = true; 784 mItemMoved = true;
733 mActionItem->raise(); 785 mActionItem->raise();
734 if (mActionType == MOVE) { 786 if (mActionType == MOVE) {
735 // Move all items belonging to a multi item 787 // Move all items belonging to a multi item
736 KOAgendaItem *moveItem = mActionItem->firstMultiItem(); 788 KOAgendaItem *moveItem = mActionItem->firstMultiItem();
737 bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); 789 bool isMultiItem = (moveItem || mActionItem->lastMultiItem());
738 if (!moveItem) moveItem = mActionItem; 790 if (!moveItem) moveItem = mActionItem;
739 while (moveItem) { 791 while (moveItem) {
740 int dy; 792 int dy;
741 if (isMultiItem) dy = 0; 793 if (isMultiItem) dy = 0;
742 else dy = gy - mCurrentCellY; 794 else dy = gy - mCurrentCellY;
743 moveItem->moveRelative(gx - mCurrentCellX,dy); 795 moveItem->moveRelative(gx - mCurrentCellX,dy);
744 int x,y; 796 int x,y;
745 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); 797 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
746 moveItem->resize(mGridSpacingX * moveItem->cellWidth(), 798 moveItem->resize(mGridSpacingX * moveItem->cellWidth(),
747 mGridSpacingY * moveItem->cellHeight()); 799 mGridSpacingY * moveItem->cellHeight());
748 moveChild(moveItem,x,y); 800 moveChild(moveItem,x,y);
749 moveItem = moveItem->nextMultiItem(); 801 moveItem = moveItem->nextMultiItem();
750 } 802 }
751 } else if (mActionType == RESIZETOP) { 803 } else if (mActionType == RESIZETOP) {
752 if (mCurrentCellY <= mActionItem->cellYBottom()) { 804 if (mCurrentCellY <= mActionItem->cellYBottom()) {
753 mActionItem->expandTop(gy - mCurrentCellY); 805 mActionItem->expandTop(gy - mCurrentCellY);
754 mActionItem->resize(mActionItem->width(), 806 mActionItem->resize(mActionItem->width(),
755 mGridSpacingY * mActionItem->cellHeight()); 807 mGridSpacingY * mActionItem->cellHeight());
756 int x,y; 808 int x,y;
757 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); 809 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
758 //moveChild(mActionItem,childX(mActionItem),y); 810 //moveChild(mActionItem,childX(mActionItem),y);
759 QScrollView::moveChild( mActionItem,childX(mActionItem),y ); 811 QScrollView::moveChild( mActionItem,childX(mActionItem),y );
760 } 812 }
761 } else if (mActionType == RESIZEBOTTOM) { 813 } else if (mActionType == RESIZEBOTTOM) {
762 if (mCurrentCellY >= mActionItem->cellYTop()) { 814 if (mCurrentCellY >= mActionItem->cellYTop()) {
763 mActionItem->expandBottom(gy - mCurrentCellY); 815 mActionItem->expandBottom(gy - mCurrentCellY);
764 mActionItem->resize(mActionItem->width(), 816 mActionItem->resize(mActionItem->width(),
765 mGridSpacingY * mActionItem->cellHeight()); 817 mGridSpacingY * mActionItem->cellHeight());
766 } 818 }
767 } else if (mActionType == RESIZELEFT) { 819 } else if (mActionType == RESIZELEFT) {
768 if (mCurrentCellX <= mActionItem->cellXWidth()) { 820 if (mCurrentCellX <= mActionItem->cellXWidth()) {
769 mActionItem->expandLeft(gx - mCurrentCellX); 821 mActionItem->expandLeft(gx - mCurrentCellX);
770 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 822 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
771 mActionItem->height()); 823 mActionItem->height());
772 int x,y; 824 int x,y;
773 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); 825 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
774 moveChild(mActionItem,x,childY(mActionItem)); 826 moveChild(mActionItem,x,childY(mActionItem));
775 } 827 }
776 } else if (mActionType == RESIZERIGHT) { 828 } else if (mActionType == RESIZERIGHT) {
777 if (mCurrentCellX >= mActionItem->cellX()) { 829 if (mCurrentCellX >= mActionItem->cellX()) {
778 mActionItem->expandRight(gx - mCurrentCellX); 830 mActionItem->expandRight(gx - mCurrentCellX);
779 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 831 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
780 mActionItem->height()); 832 mActionItem->height());
781 } 833 }
782 } 834 }
783 mCurrentCellX = gx; 835 mCurrentCellX = gx;
784 mCurrentCellY = gy; 836 mCurrentCellY = gy;
785 } 837 }
786} 838}
787 839
788void KOAgenda::endItemAction() 840void KOAgenda::endItemAction()
789{ 841{
790 842
791 if ( mItemMoved ) { 843 if ( mItemMoved ) {
792 KOAgendaItem *placeItem = mActionItem->firstMultiItem(); 844 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
793 if ( !placeItem ) { 845 if ( !placeItem ) {
794 placeItem = mActionItem; 846 placeItem = mActionItem;
795 } 847 }
796 if ( placeItem->incidence()->recurrence()->doesRecur() ) { 848 if ( placeItem->incidence()->recurrence()->doesRecur() ) {
797 Incidence* oldInc = placeItem->incidence(); 849 Incidence* oldInc = placeItem->incidence();
798 placeItem->recreateIncidence(); 850 placeItem->recreateIncidence();
799 emit addToCalSignal(placeItem->incidence(), oldInc ); 851 emit addToCalSignal(placeItem->incidence(), oldInc );
800 } 852 }
801 int type = mActionType; 853 int type = mActionType;
802 if ( mAllDayMode ) 854 if ( mAllDayMode )
803 type = -1; 855 type = -1;
804 KOAgendaItem *modifiedItem = placeItem; 856 KOAgendaItem *modifiedItem = placeItem;
805 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); 857 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */);
806 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); 858 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems();
807 KOAgendaItem *item; 859 KOAgendaItem *item;
808 860
809 if ( placeItem->incidence()->type() == "Todo" ) { 861 if ( placeItem->incidence()->type() == "Todo" ) {
810 mSelectedItem = 0; 862 mSelectedItem = 0;
@@ -1471,385 +1523,385 @@ KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int
1471 mItems.append(agendaItem); 1523 mItems.append(agendaItem);
1472 1524
1473 placeSubCells(agendaItem); 1525 placeSubCells(agendaItem);
1474 1526
1475 //agendaItem->show(); 1527 //agendaItem->show();
1476 1528
1477 marcus_bains(); 1529 marcus_bains();
1478 1530
1479 return agendaItem; 1531 return agendaItem;
1480} 1532}
1481 1533
1482 1534
1483/* 1535/*
1484 Insert all-day KOAgendaItem into agenda. 1536 Insert all-day KOAgendaItem into agenda.
1485*/ 1537*/
1486KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) 1538KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
1487{ 1539{
1488 if (!mAllDayMode) { 1540 if (!mAllDayMode) {
1489 return 0; 1541 return 0;
1490 } 1542 }
1491 1543
1492 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1544 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1493 1545
1494 agendaItem->setCellXY(XBegin,0,0); 1546 agendaItem->setCellXY(XBegin,0,0);
1495 agendaItem->setCellXWidth(XEnd); 1547 agendaItem->setCellXWidth(XEnd);
1496 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); 1548 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
1497 1549
1498 //addChild(agendaItem,XBegin*mGridSpacingX,0); 1550 //addChild(agendaItem,XBegin*mGridSpacingX,0);
1499 mItems.append(agendaItem); 1551 mItems.append(agendaItem);
1500 1552
1501 placeSubCells(agendaItem); 1553 placeSubCells(agendaItem);
1502 1554
1503 //agendaItem->show(); 1555 //agendaItem->show();
1504 1556
1505 return agendaItem; 1557 return agendaItem;
1506} 1558}
1507 1559
1508 1560
1509void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 1561void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1510 int YTop,int YBottom) 1562 int YTop,int YBottom)
1511{ 1563{
1512 if (mAllDayMode) { 1564 if (mAllDayMode) {
1513 ; 1565 ;
1514 return; 1566 return;
1515 } 1567 }
1516 1568
1517 int cellX,cellYTop,cellYBottom; 1569 int cellX,cellYTop,cellYBottom;
1518 QString newtext; 1570 QString newtext;
1519 int width = XEnd - XBegin + 1; 1571 int width = XEnd - XBegin + 1;
1520 int count = 0; 1572 int count = 0;
1521 KOAgendaItem *current = 0; 1573 KOAgendaItem *current = 0;
1522 QPtrList<KOAgendaItem> multiItems; 1574 QPtrList<KOAgendaItem> multiItems;
1523 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1575 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1524 if (cellX == XBegin) cellYTop = YTop; 1576 if (cellX == XBegin) cellYTop = YTop;
1525 else cellYTop = 0; 1577 else cellYTop = 0;
1526 if (cellX == XEnd) cellYBottom = YBottom; 1578 if (cellX == XEnd) cellYBottom = YBottom;
1527 else cellYBottom = rows() - 1; 1579 else cellYBottom = rows() - 1;
1528 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1580 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1529 newtext.append(event->summary()); 1581 newtext.append(event->summary());
1530 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1582 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1531 current->setText(newtext); 1583 current->setText(newtext);
1532 multiItems.append(current); 1584 multiItems.append(current);
1533 } 1585 }
1534 1586
1535 KOAgendaItem *next = 0; 1587 KOAgendaItem *next = 0;
1536 KOAgendaItem *last = multiItems.last(); 1588 KOAgendaItem *last = multiItems.last();
1537 KOAgendaItem *first = multiItems.first(); 1589 KOAgendaItem *first = multiItems.first();
1538 KOAgendaItem *setFirst,*setLast; 1590 KOAgendaItem *setFirst,*setLast;
1539 current = first; 1591 current = first;
1540 while (current) { 1592 while (current) {
1541 next = multiItems.next(); 1593 next = multiItems.next();
1542 if (current == first) setFirst = 0; 1594 if (current == first) setFirst = 0;
1543 else setFirst = first; 1595 else setFirst = first;
1544 if (current == last) setLast = 0; 1596 if (current == last) setLast = 0;
1545 else setLast = last; 1597 else setLast = last;
1546 1598
1547 current->setMultiItem(setFirst,next,setLast); 1599 current->setMultiItem(setFirst,next,setLast);
1548 current = next; 1600 current = next;
1549 } 1601 }
1550 1602
1551 marcus_bains(); 1603 marcus_bains();
1552} 1604}
1553 1605
1554 1606
1555//QSizePolicy KOAgenda::sizePolicy() const 1607//QSizePolicy KOAgenda::sizePolicy() const
1556//{ 1608//{
1557 // Thought this would make the all-day event agenda minimum size and the 1609 // Thought this would make the all-day event agenda minimum size and the
1558 // normal agenda take the remaining space. But it doesn´t work. The QSplitter 1610 // normal agenda take the remaining space. But it doesn´t work. The QSplitter
1559 // don´t seem to think that an Expanding widget needs more space than a 1611 // don´t seem to think that an Expanding widget needs more space than a
1560 // Preferred one. 1612 // Preferred one.
1561 // But it doesn´t hurt, so it stays. 1613 // But it doesn´t hurt, so it stays.
1562// if (mAllDayMode) { 1614// if (mAllDayMode) {
1563// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 1615// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1564// } else { 1616// } else {
1565// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 1617// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1566// } 1618// }
1567//} 1619//}
1568void KOAgenda::finishResize ( ) 1620void KOAgenda::finishResize ( )
1569{ 1621{
1570 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1622 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1571 if ( globalFlagBlockAgenda == 0 ) { 1623 if ( globalFlagBlockAgenda == 0 ) {
1572 finishUpdate(); 1624 finishUpdate();
1573 //qDebug("finishUpdate() called "); 1625 //qDebug("finishUpdate() called ");
1574 } 1626 }
1575} 1627}
1576/* 1628/*
1577 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1629 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1578*/ 1630*/
1579void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1631void KOAgenda::resizeEvent ( QResizeEvent *ev )
1580{ 1632{
1581 1633
1582 mResizeTimer.start( 150 , true ); 1634 mResizeTimer.start( 150 , true );
1583 computeSizes(); 1635 computeSizes();
1584 return; 1636 return;
1585 1637
1586} 1638}
1587void KOAgenda::computeSizes() 1639void KOAgenda::computeSizes()
1588{ 1640{
1589 if ( globalFlagBlockStartup ) 1641 if ( globalFlagBlockStartup )
1590 return; 1642 return;
1591 1643
1592 if (mAllDayMode) { 1644 if (mAllDayMode) {
1593 mGridSpacingX = (width()-3) / mColumns; 1645 mGridSpacingX = (width()-3) / mColumns;
1594 mGridSpacingY = height() - 2 * frameWidth() - 1; 1646 mGridSpacingY = height() - 2 * frameWidth() - 1;
1595 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1647 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1596// mGridSpacingY = height(); 1648// mGridSpacingY = height();
1597// resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1649// resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1598 1650
1599 KOAgendaItem *item; 1651 KOAgendaItem *item;
1600 int subCellWidth; 1652 int subCellWidth;
1601 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1653 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1602 subCellWidth = mGridSpacingY / item->subCells(); 1654 subCellWidth = mGridSpacingY / item->subCells();
1603 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); 1655 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1604 moveChild(item,KOGlobals::self()->reverseLayout() ? 1656 moveChild(item,KOGlobals::self()->reverseLayout() ?
1605 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1657 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1606 item->cellX() * mGridSpacingX, 1658 item->cellX() * mGridSpacingX,
1607 item->subCell() * subCellWidth); 1659 item->subCell() * subCellWidth);
1608 } 1660 }
1609 KOPrefs::instance()->mAllDaySize = mGridSpacingY; 1661 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1610 } else { 1662 } else {
1611 mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; 1663 mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns;
1612 if (height() > mGridSpacingY * mRows + 1 ) { 1664 if (height() > mGridSpacingY * mRows + 1 ) {
1613 KOPrefs::instance()->mHourSize = ((height())/mRows)+1; 1665 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
1614 mGridSpacingY = KOPrefs::instance()->mHourSize ; 1666 mGridSpacingY = KOPrefs::instance()->mHourSize ;
1615 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1667 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1616 emit resizedSignal(); 1668 emit resizedSignal();
1617 } else 1669 } else
1618 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1670 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1619 KOAgendaItem *item; 1671 KOAgendaItem *item;
1620 int subCellWidth; 1672 int subCellWidth;
1621 1673
1622 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1674 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1623 subCellWidth = mGridSpacingX / item->subCells(); 1675 subCellWidth = mGridSpacingX / item->subCells();
1624 item->resize(subCellWidth,item->height()); 1676 item->resize(subCellWidth,item->height());
1625 moveChild(item,(KOGlobals::self()->reverseLayout() ? 1677 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1626 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1678 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1627 item->cellX() * mGridSpacingX) + 1679 item->cellX() * mGridSpacingX) +
1628 item->subCell() * subCellWidth,childY(item)); 1680 item->subCell() * subCellWidth,childY(item));
1629 } 1681 }
1630 } 1682 }
1631 int cw = contentsWidth(); 1683 int cw = contentsWidth();
1632 int ch = contentsHeight(); 1684 int ch = contentsHeight();
1633 if ( mAllDayMode ) { 1685 if ( mAllDayMode ) {
1634 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); 1686 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1635 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) 1687 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 )
1636 paintPixAll->resize( cw, ch ); 1688 paintPixAll->resize( cw, ch );
1637 } else { 1689 } else {
1638 QPixmap* paintPix = KOAgendaItem::paintPix(); 1690 QPixmap* paintPix = KOAgendaItem::paintPix();
1639 if ( paintPix->width() < cw || paintPix->height() < ch ) 1691 if ( paintPix->width() < cw || paintPix->height() < ch )
1640 KOAgendaItem::resizePixmap( cw , ch ); 1692 KOAgendaItem::resizePixmap( cw , ch );
1641 } 1693 }
1642 1694
1643 checkScrollBoundaries(); 1695 checkScrollBoundaries();
1644 marcus_bains(); 1696 marcus_bains();
1645 drawContentsToPainter(); 1697 drawContentsToPainter();
1646 viewport()->repaint(false); 1698 viewport()->repaint(false);
1647} 1699}
1648 1700
1649void KOAgenda::scrollUp() 1701void KOAgenda::scrollUp()
1650{ 1702{
1651 scrollBy(0,-mScrollOffset); 1703 scrollBy(0,-mScrollOffset);
1652} 1704}
1653 1705
1654 1706
1655void KOAgenda::scrollDown() 1707void KOAgenda::scrollDown()
1656{ 1708{
1657 scrollBy(0,mScrollOffset); 1709 scrollBy(0,mScrollOffset);
1658} 1710}
1659 1711
1660void KOAgenda::popupAlarm() 1712void KOAgenda::popupAlarm()
1661{ 1713{
1662 if (!mClickedItem) { 1714 if (!mClickedItem) {
1663 kdDebug() << "KOAgenda::popupAlarm() called without having a clicked item" << endl; 1715 qDebug("KOAgenda::popupAlarm() called without having a clicked item ");
1664 return; 1716 return;
1665 } 1717 }
1666// TODO: deal correctly with multiple alarms 1718// TODO: deal correctly with multiple alarms
1667 Alarm* alarm; 1719 Alarm* alarm;
1668 QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); 1720 QPtrList<Alarm> list(mClickedItem->incidence()->alarms());
1669 for(alarm=list.first();alarm;alarm=list.next()) { 1721 for(alarm=list.first();alarm;alarm=list.next()) {
1670 alarm->toggleAlarm(); 1722 alarm->toggleAlarm();
1671 } 1723 }
1672 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); 1724 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
1673 mClickedItem->paintMe( true ); 1725 mClickedItem->paintMe( true );
1674 mClickedItem->repaint( false ); 1726 mClickedItem->repaint( false );
1675} 1727}
1676 1728
1677/* 1729/*
1678 Calculates the minimum width 1730 Calculates the minimum width
1679*/ 1731*/
1680int KOAgenda::minimumWidth() const 1732int KOAgenda::minimumWidth() const
1681{ 1733{
1682 // TODO:: develop a way to dynamically determine the minimum width 1734 // TODO:: develop a way to dynamically determine the minimum width
1683 int min = 100; 1735 int min = 100;
1684 1736
1685 return min; 1737 return min;
1686} 1738}
1687 1739
1688void KOAgenda::updateConfig() 1740void KOAgenda::updateConfig()
1689{ 1741{
1690 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) 1742 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor)
1691 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); 1743 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
1692 if ( mAllDayMode ) { 1744 if ( mAllDayMode ) {
1693 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; 1745 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize;
1694 //mGridSpacingY = KOPrefs::instance()->mAllDaySize; 1746 //mGridSpacingY = KOPrefs::instance()->mAllDaySize;
1695 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); 1747 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 );
1696 // setMaximumHeight( mGridSpacingY+1 ); 1748 // setMaximumHeight( mGridSpacingY+1 );
1697 viewport()->repaint( false ); 1749 viewport()->repaint( false );
1698 //setFixedHeight( mGridSpacingY+1 ); 1750 //setFixedHeight( mGridSpacingY+1 );
1699 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); 1751 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize);
1700 } 1752 }
1701 else { 1753 else {
1702 mGridSpacingY = KOPrefs::instance()->mHourSize; 1754 mGridSpacingY = KOPrefs::instance()->mHourSize;
1703 calculateWorkingHours(); 1755 calculateWorkingHours();
1704 marcus_bains(); 1756 marcus_bains();
1705 } 1757 }
1706} 1758}
1707 1759
1708void KOAgenda::checkScrollBoundaries() 1760void KOAgenda::checkScrollBoundaries()
1709{ 1761{
1710 // Invalidate old values to force update 1762 // Invalidate old values to force update
1711 mOldLowerScrollValue = -1; 1763 mOldLowerScrollValue = -1;
1712 mOldUpperScrollValue = -1; 1764 mOldUpperScrollValue = -1;
1713 1765
1714 checkScrollBoundaries(verticalScrollBar()->value()); 1766 checkScrollBoundaries(verticalScrollBar()->value());
1715} 1767}
1716 1768
1717void KOAgenda::checkScrollBoundaries(int v) 1769void KOAgenda::checkScrollBoundaries(int v)
1718{ 1770{
1719 if ( mGridSpacingY == 0 ) 1771 if ( mGridSpacingY == 0 )
1720 return; 1772 return;
1721 int yMin = v/mGridSpacingY; 1773 int yMin = v/mGridSpacingY;
1722 int yMax = (v+visibleHeight())/mGridSpacingY; 1774 int yMax = (v+visibleHeight())/mGridSpacingY;
1723 1775
1724// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; 1776// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl;
1725 1777
1726 if (yMin != mOldLowerScrollValue) { 1778 if (yMin != mOldLowerScrollValue) {
1727 mOldLowerScrollValue = yMin; 1779 mOldLowerScrollValue = yMin;
1728 emit lowerYChanged(yMin); 1780 emit lowerYChanged(yMin);
1729 } 1781 }
1730 if (yMax != mOldUpperScrollValue) { 1782 if (yMax != mOldUpperScrollValue) {
1731 mOldUpperScrollValue = yMax; 1783 mOldUpperScrollValue = yMax;
1732 emit upperYChanged(yMax); 1784 emit upperYChanged(yMax);
1733 } 1785 }
1734} 1786}
1735 1787
1736void KOAgenda::deselectItem() 1788void KOAgenda::deselectItem()
1737{ 1789{
1738 if (mSelectedItem.isNull()) return; 1790 if (mSelectedItem.isNull()) return;
1739 mSelectedItem->select(false); 1791 mSelectedItem->select(false);
1740 mSelectedItem = 0; 1792 mSelectedItem = 0;
1741} 1793}
1742 1794
1743void KOAgenda::selectItem(KOAgendaItem *item) 1795void KOAgenda::selectItem(KOAgendaItem *item)
1744{ 1796{
1745 if ((KOAgendaItem *)mSelectedItem == item) return; 1797 if ((KOAgendaItem *)mSelectedItem == item) return;
1746 deselectItem(); 1798 deselectItem();
1747 if (item == 0) { 1799 if (item == 0) {
1748 emit incidenceSelected( 0 ); 1800 emit incidenceSelected( 0 );
1749 return; 1801 return;
1750 } 1802 }
1751 mSelectedItem = item; 1803 mSelectedItem = item;
1752 mSelectedItem->select(); 1804 mSelectedItem->select();
1753 emit incidenceSelected( mSelectedItem->incidence() ); 1805 emit incidenceSelected( mSelectedItem->incidence() );
1754} 1806}
1755 1807
1756// This function seems never be called. 1808// This function seems never be called.
1757void KOAgenda::keyPressEvent( QKeyEvent *kev ) 1809void KOAgenda::keyPressEvent( QKeyEvent *kev )
1758{ 1810{
1759 switch(kev->key()) { 1811 switch(kev->key()) {
1760 case Key_PageDown: 1812 case Key_PageDown:
1761 verticalScrollBar()->addPage(); 1813 verticalScrollBar()->addPage();
1762 break; 1814 break;
1763 case Key_PageUp: 1815 case Key_PageUp:
1764 verticalScrollBar()->subtractPage(); 1816 verticalScrollBar()->subtractPage();
1765 break; 1817 break;
1766 case Key_Down: 1818 case Key_Down:
1767 verticalScrollBar()->addLine(); 1819 verticalScrollBar()->addLine();
1768 break; 1820 break;
1769 case Key_Up: 1821 case Key_Up:
1770 verticalScrollBar()->subtractLine(); 1822 verticalScrollBar()->subtractLine();
1771 break; 1823 break;
1772 default: 1824 default:
1773 ; 1825 ;
1774 } 1826 }
1775} 1827}
1776 1828
1777void KOAgenda::calculateWorkingHours() 1829void KOAgenda::calculateWorkingHours()
1778{ 1830{
1779// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; 1831// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours;
1780 mWorkingHoursEnable = !mAllDayMode; 1832 mWorkingHoursEnable = !mAllDayMode;
1781 1833
1782 mWorkingHoursYTop = mGridSpacingY * 1834 mWorkingHoursYTop = mGridSpacingY *
1783 KOPrefs::instance()->mWorkingHoursStart * 4; 1835 KOPrefs::instance()->mWorkingHoursStart * 4;
1784 mWorkingHoursYBottom = mGridSpacingY * 1836 mWorkingHoursYBottom = mGridSpacingY *
1785 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; 1837 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1;
1786} 1838}
1787 1839
1788 1840
1789DateList KOAgenda::dateList() const 1841DateList KOAgenda::dateList() const
1790{ 1842{
1791 return mSelectedDates; 1843 return mSelectedDates;
1792} 1844}
1793 1845
1794void KOAgenda::setDateList(const DateList &selectedDates) 1846void KOAgenda::setDateList(const DateList &selectedDates)
1795{ 1847{
1796 mSelectedDates = selectedDates; 1848 mSelectedDates = selectedDates;
1797 marcus_bains(); 1849 marcus_bains();
1798} 1850}
1799 1851
1800void KOAgenda::setHolidayMask(QMemArray<bool> *mask) 1852void KOAgenda::setHolidayMask(QMemArray<bool> *mask)
1801{ 1853{
1802 mHolidayMask = mask; 1854 mHolidayMask = mask;
1803 1855
1804/* 1856/*
1805 kdDebug() << "HolidayMask: "; 1857 kdDebug() << "HolidayMask: ";
1806 for(uint i=0;i<mask->count();++i) { 1858 for(uint i=0;i<mask->count();++i) {
1807 kdDebug() << (mask->at(i) ? "*" : "o"); 1859 kdDebug() << (mask->at(i) ? "*" : "o");
1808 } 1860 }
1809 kdDebug() << endl; 1861 kdDebug() << endl;
1810*/ 1862*/
1811} 1863}
1812 1864
1813void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) 1865void KOAgenda::contentsMousePressEvent ( QMouseEvent *event )
1814{ 1866{
1815 1867
1816 QScrollView::contentsMousePressEvent(event); 1868 QScrollView::contentsMousePressEvent(event);
1817} 1869}
1818 1870
1819void KOAgenda::storePosition() 1871void KOAgenda::storePosition()
1820{ 1872{
1821 //mContentPosition 1873 //mContentPosition
1822 int max = mGridSpacingY*4*24; 1874 int max = mGridSpacingY*4*24;
1823 if ( contentsY() < 5 && max > viewport()->height()*3/2 ) 1875 if ( contentsY() < 5 && max > viewport()->height()*3/2 )
1824 mContentPosition = 0; 1876 mContentPosition = 0;
1825 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) 1877 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2)
1826 mContentPosition = -1.0; 1878 mContentPosition = -1.0;
1827 else 1879 else
1828 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); 1880 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2)));
1829 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); 1881 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height());
1830 1882
1831} 1883}
1832void KOAgenda::restorePosition() 1884void KOAgenda::restorePosition()
1833{ 1885{
1834 int posY; 1886 int posY;
1835 int max = mGridSpacingY*4*24; 1887 int max = mGridSpacingY*4*24;
1836 if ( mContentPosition < 0 ) 1888 if ( mContentPosition < 0 )
1837 posY = max-viewport()->height(); 1889 posY = max-viewport()->height();
1838 else 1890 else
1839 if ( mContentPosition == 0 ) 1891 if ( mContentPosition == 0 )
1840 posY = 0; 1892 posY = 0;
1841 else 1893 else
1842 posY = (max/mContentPosition)-(viewport()->height()/2); 1894 posY = (max/mContentPosition)-(viewport()->height()/2);
1843 setContentsPos (0, posY ); 1895 setContentsPos (0, posY );
1844 //qDebug("posY %d hei %d", posY, max); 1896 //qDebug("posY %d hei %d", posY, max);
1845 1897
1846} 1898}
1847void KOAgenda::moveChild( QWidget *w, int x , int y ) 1899void KOAgenda::moveChild( QWidget *w, int x , int y )
1848{ 1900{
1849 ++x; 1901 ++x;
1850 QScrollView::moveChild( w, x , y ); 1902 QScrollView::moveChild( w, x , y );
1851} 1903}
1852#include <qmessagebox.h> 1904#include <qmessagebox.h>
1853#ifdef DESKTOP_VERSION 1905#ifdef DESKTOP_VERSION
1854#include <qprinter.h> 1906#include <qprinter.h>
1855#include <qpainter.h> 1907#include <qpainter.h>
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index 111242f..12943d7 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -1,286 +1,290 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOAGENDA_H 23#ifndef KOAGENDA_H
24#define KOAGENDA_H 24#define KOAGENDA_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qmemarray.h> 28#include <qmemarray.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qpixmap.h> 30#include <qpixmap.h>
31#include <qguardedptr.h> 31#include <qguardedptr.h>
32 32
33#include "koagendaitem.h" 33#include "koagendaitem.h"
34 34
35class QPopupMenu; 35class QPopupMenu;
36class QTime; 36class QTime;
37class KConfig; 37class KConfig;
38class QFrame; 38class QFrame;
39class KOAgenda; 39class KOAgenda;
40class KCal::Event; 40class KCal::Event;
41class KCal::Todo; 41class KCal::Todo;
42 42
43using namespace KCal; 43using namespace KCal;
44 44
45class MarcusBains : public QFrame { 45class MarcusBains : public QFrame {
46 Q_OBJECT 46 Q_OBJECT
47 public: 47 public:
48 MarcusBains(KOAgenda *agenda=0,const char *name=0); 48 MarcusBains(KOAgenda *agenda=0,const char *name=0);
49 virtual ~MarcusBains(); 49 virtual ~MarcusBains();
50 50
51 public slots: 51 public slots:
52 void updateLocation(bool recalculate=false); 52 void updateLocation(bool recalculate=false);
53 void updateLoc(); 53 void updateLoc();
54 54
55 private: 55 private:
56 int todayColumn(); 56 int todayColumn();
57 QTimer *minutes; 57 QTimer *minutes;
58 QLabel *mTimeBox; 58 QLabel *mTimeBox;
59 KOAgenda *agenda; 59 KOAgenda *agenda;
60 QTime oldTime; 60 QTime oldTime;
61 int oldToday; 61 int oldToday;
62}; 62};
63 63
64 64
65class KOAgenda : public QScrollView 65class KOAgenda : public QScrollView
66{ 66{
67 Q_OBJECT 67 Q_OBJECT
68 public: 68 public:
69 enum MouseActionType { NOP, MOVE, SELECT, 69 enum MouseActionType { NOP, MOVE, SELECT,
70 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; 70 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT };
71 71
72 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, 72 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0,
73 const char * name=0, WFlags f=0 ); 73 const char * name=0, WFlags f=0 );
74 KOAgenda ( int columns, QWidget * parent=0, 74 KOAgenda ( int columns, QWidget * parent=0,
75 const char * name=0, WFlags f=0 ); 75 const char * name=0, WFlags f=0 );
76 virtual ~KOAgenda(); 76 virtual ~KOAgenda();
77 77
78 Incidence *selectedIncidence() const; 78 Incidence *selectedIncidence() const;
79 QDate selectedIncidenceDate() const; 79 QDate selectedIncidenceDate() const;
80 80
81 virtual bool eventFilter ( QObject *, QEvent * ); 81 virtual bool eventFilter ( QObject *, QEvent * );
82 82
83 void contentsToGrid (int x, int y, int& gx, int& gy); 83 void contentsToGrid (int x, int y, int& gx, int& gy);
84 void gridToContents (int gx, int gy, int& x, int& y); 84 void gridToContents (int gx, int gy, int& x, int& y);
85 85
86 int timeToY (const QTime &time); 86 int timeToY (const QTime &time);
87 QTime gyToTime (int y); 87 QTime gyToTime (int y);
88 88
89 void setStartHour(int startHour); 89 void setStartHour(int startHour);
90 90
91 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); 91 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom);
92 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); 92 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd);
93 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 93 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
94 int YTop,int YBottom); 94 int YTop,int YBottom);
95 95
96 void changeColumns(int columns); 96 void changeColumns(int columns);
97 97
98 int columns() { return mColumns; } 98 int columns() { return mColumns; }
99 int rows() { return mRows; } 99 int rows() { return mRows; }
100 100
101 int gridSpacingX() const { return mGridSpacingX; } 101 int gridSpacingX() const { return mGridSpacingX; }
102 int gridSpacingY() const { return mGridSpacingY; } 102 int gridSpacingY() const { return mGridSpacingY; }
103 103
104// virtual QSizePolicy sizePolicy() const; 104// virtual QSizePolicy sizePolicy() const;
105 105
106 void clear(); 106 void clear();
107 107
108 void clearSelection(); 108 void clearSelection();
109 void hideUnused(); 109 void hideUnused();
110 110
111 /** Calculates the minimum width */ 111 /** Calculates the minimum width */
112 virtual int minimumWidth() const; 112 virtual int minimumWidth() const;
113 /** Update configuration from preference settings */ 113 /** Update configuration from preference settings */
114 void updateConfig(); 114 void updateConfig();
115 115
116 void checkScrollBoundaries(); 116 void checkScrollBoundaries();
117 117
118 void setHolidayMask(QMemArray<bool> *); 118 void setHolidayMask(QMemArray<bool> *);
119 void setDateList(const DateList &selectedDates); 119 void setDateList(const DateList &selectedDates);
120 DateList dateList() const; 120 DateList dateList() const;
121 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); 121 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false);
122 void finishUpdate(); 122 void finishUpdate();
123 void printSelection(); 123 void printSelection();
124 void storePosition(); 124 void storePosition();
125 void restorePosition(); 125 void restorePosition();
126 126
127 127
128 public slots: 128 public slots:
129 void newItem( int );
129 void moveChild( QWidget *, int, int ); 130 void moveChild( QWidget *, int, int );
130 void scrollUp(); 131 void scrollUp();
131 void scrollDown(); 132 void scrollDown();
132 void updateTodo( Todo * t, int , bool ); 133 void updateTodo( Todo * t, int , bool );
133 void popupAlarm(); 134 void popupAlarm();
134 135
135 void checkScrollBoundaries(int); 136 void checkScrollBoundaries(int);
136 137
137 /** Deselect selected items. This function does not emit any signals. */ 138 /** Deselect selected items. This function does not emit any signals. */
138 void deselectItem(); 139 void deselectItem();
139 /** Select item. If the argument is 0, the currently selected item gets 140 /** Select item. If the argument is 0, the currently selected item gets
140 deselected. This function emits the itemSelected(bool) signal to inform 141 deselected. This function emits the itemSelected(bool) signal to inform
141 about selection/deseelction of events. */ 142 about selection/deseelction of events. */
142 void selectItem(KOAgendaItem *); 143 void selectItem(KOAgendaItem *);
143 void finishResize(); 144 void finishResize();
144 145
145 signals: 146 signals:
146 void newEventSignal(); 147 void newEventSignal();
147 void newEventSignal(int gx,int gy); 148 void newEventSignal(int gx,int gy);
149 void newTodoSignal(int gx,int gy);
148 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 150 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
149 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 151 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
150 void newStartSelectSignal(); 152 void newStartSelectSignal();
151 void showIncidenceSignal(Incidence *); 153 void showIncidenceSignal(Incidence *);
152 void editIncidenceSignal(Incidence *); 154 void editIncidenceSignal(Incidence *);
153 void deleteIncidenceSignal(Incidence *); 155 void deleteIncidenceSignal(Incidence *);
154 void showIncidencePopupSignal(Incidence *); 156 void showIncidencePopupSignal(Incidence *);
155 157
156 void itemModified(KOAgendaItem *item, int ); 158 void itemModified(KOAgendaItem *item, int );
157 void incidenceSelected(Incidence *); 159 void incidenceSelected(Incidence *);
158 160
159 void lowerYChanged(int); 161 void lowerYChanged(int);
160 void upperYChanged(int); 162 void upperYChanged(int);
161 163
162 void startDragSignal(Incidence *); 164 void startDragSignal(Incidence *);
163 void addToCalSignal(Incidence *, Incidence *); 165 void addToCalSignal(Incidence *, Incidence *);
164 void resizedSignal(); 166 void resizedSignal();
165 167
166 protected: 168 protected:
167 QPainter mPixPainter; 169 QPainter mPixPainter;
168 QPixmap mPaintPixmap; 170 QPixmap mPaintPixmap;
169 QPixmap mHighlightPixmap; 171 QPixmap mHighlightPixmap;
170 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 172 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
171 virtual void resizeEvent ( QResizeEvent * ); 173 virtual void resizeEvent ( QResizeEvent * );
172 174
173 /** Handles mouse events. Called from eventFilter */ 175 /** Handles mouse events. Called from eventFilter */
174 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); 176 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * );
175 177
176 /** Start selecting time span. */ 178 /** Start selecting time span. */
177 void startSelectAction(QPoint viewportPos); 179 void startSelectAction(QPoint viewportPos);
178 180
179 /** Select time span. */ 181 /** Select time span. */
180 void performSelectAction(QPoint viewportPos); 182 void performSelectAction(QPoint viewportPos);
181 183
182 /** Emd selecting time span. */ 184 /** Emd selecting time span. */
183 void endSelectAction(); 185 void endSelectAction( bool emitNewEvent = false );
184 186
185 /** Start moving/resizing agenda item */ 187 /** Start moving/resizing agenda item */
186 void startItemAction(QPoint viewportPos); 188 void startItemAction(QPoint viewportPos);
187 189
188 /** Move/resize agenda item */ 190 /** Move/resize agenda item */
189 void performItemAction(QPoint viewportPos); 191 void performItemAction(QPoint viewportPos);
190 192
191 /** End moving/resizing agenda item */ 193 /** End moving/resizing agenda item */
192 void endItemAction(); 194 void endItemAction();
193 195
194 /** Set cursor, when no item action is in progress */ 196 /** Set cursor, when no item action is in progress */
195 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); 197 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos);
196 198
197 /** Place agenda item in agenda and adjust other cells if necessary */ 199 /** Place agenda item in agenda and adjust other cells if necessary */
198 void placeSubCells(KOAgendaItem *placeItem); 200 void placeSubCells(KOAgendaItem *placeItem);
199 201
200 /** Process the keyevent, including the ignored keyevents of eventwidgets. 202 /** Process the keyevent, including the ignored keyevents of eventwidgets.
201 * Implements pgup/pgdn and cursor key navigation in the view. 203 * Implements pgup/pgdn and cursor key navigation in the view.
202 */ 204 */
203 void keyPressEvent( QKeyEvent * ); 205 void keyPressEvent( QKeyEvent * );
204 206
205 void calculateWorkingHours(); 207 void calculateWorkingHours();
206 208
207 virtual void contentsMousePressEvent ( QMouseEvent * ); 209 virtual void contentsMousePressEvent ( QMouseEvent * );
208 210
209 private: 211 private:
212 bool blockNewEvent;
210 void init(); 213 void init();
211 void marcus_bains(); 214 void marcus_bains();
212 bool mAllDayMode; 215 bool mAllDayMode;
213 bool blockResize; 216 bool blockResize;
214 QTimer mResizeTimer; 217 QTimer mResizeTimer;
215 double mContentPosition; 218 double mContentPosition;
216 219
217 // Width and height of agenda cells 220 // Width and height of agenda cells
218 int mGridSpacingX; 221 int mGridSpacingX;
219 int mGridSpacingY; 222 int mGridSpacingY;
220 223
221 // size of border, where mouse action will resize the KOAgendaItem 224 // size of border, where mouse action will resize the KOAgendaItem
222 int mResizeBorderWidth; 225 int mResizeBorderWidth;
223 226
224 // size of border, where mouse mve will cause a scroll of the agenda 227 // size of border, where mouse mve will cause a scroll of the agenda
225 int mScrollBorderWidth; 228 int mScrollBorderWidth;
226 int mScrollDelay; 229 int mScrollDelay;
227 int mScrollOffset; 230 int mScrollOffset;
228 231
229 QTimer mScrollUpTimer; 232 QTimer mScrollUpTimer;
230 QTimer mScrollDownTimer; 233 QTimer mScrollDownTimer;
231 234
232 // Number of Columns/Rows of agenda grid 235 // Number of Columns/Rows of agenda grid
233 int mColumns; 236 int mColumns;
234 int mRows; 237 int mRows;
235 238
236 // Cells to store Move and Resize coordiantes 239 // Cells to store Move and Resize coordiantes
237 int mStartCellX; 240 int mStartCellX;
238 int mStartCellY; 241 int mStartCellY;
239 int mCurrentCellX; 242 int mCurrentCellX;
240 int mCurrentCellY; 243 int mCurrentCellY;
241 244
242 // Working Hour coordiantes 245 // Working Hour coordiantes
243 bool mWorkingHoursEnable; 246 bool mWorkingHoursEnable;
244 int mWorkingHoursYTop; 247 int mWorkingHoursYTop;
245 int mWorkingHoursYBottom; 248 int mWorkingHoursYBottom;
246 249
247 // Selection 250 // Selection
248 int mSelectionCellX; 251 int mSelectionCellX;
249 int mSelectionYTop; 252 int mSelectionYTop;
250 int mSelectionHeight; 253 int mSelectionHeight;
251 254
252 // List of dates to be displayed 255 // List of dates to be displayed
253 DateList mSelectedDates; 256 DateList mSelectedDates;
254 257
255 // The KOAgendaItem, which has been right-clicked last 258 // The KOAgendaItem, which has been right-clicked last
256 KOAgendaItem *mClickedItem; 259 KOAgendaItem *mClickedItem;
257 260
258 // The KOAgendaItem, which is being moved/resized 261 // The KOAgendaItem, which is being moved/resized
259 QGuardedPtr<KOAgendaItem> mActionItem; 262 QGuardedPtr<KOAgendaItem> mActionItem;
260 263
261 // Currently selected item 264 // Currently selected item
262 QGuardedPtr<KOAgendaItem> mSelectedItem; 265 QGuardedPtr<KOAgendaItem> mSelectedItem;
263 266
264 // The Marcus Bains Line widget. 267 // The Marcus Bains Line widget.
265 MarcusBains *mMarcusBains; 268 MarcusBains *mMarcusBains;
266 void computeSizes(); 269 void computeSizes();
267 270
268 MouseActionType mActionType; 271 MouseActionType mActionType;
269 272
270 bool mItemMoved; 273 bool mItemMoved;
271 274
272 // List of all Items contained in agenda 275 // List of all Items contained in agenda
273 QPtrList<KOAgendaItem> mItems; 276 QPtrList<KOAgendaItem> mItems;
274 QPtrList<KOAgendaItem> mUnusedItems; 277 QPtrList<KOAgendaItem> mUnusedItems;
275 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); 278 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport);
276 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems 279 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems
280 QPopupMenu *mNewItemPopup;
277 281
278 int mOldLowerScrollValue; 282 int mOldLowerScrollValue;
279 int mOldUpperScrollValue; 283 int mOldUpperScrollValue;
280 KOAgendaItem * getItemForTodo ( Todo * todo ); 284 KOAgendaItem * getItemForTodo ( Todo * todo );
281 QMemArray<bool> *mHolidayMask; 285 QMemArray<bool> *mHolidayMask;
282 int mCurPixWid; 286 int mCurPixWid;
283 int mCurPixHei; 287 int mCurPixHei;
284}; 288};
285 289
286#endif // KOAGENDA_H 290#endif // KOAGENDA_H
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index f54f7bc..60ae41f 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -299,388 +299,392 @@ void EventIndicator::drawContents(QPainter *p)
299 299
300 QPainter pa( han ); 300 QPainter pa( han );
301 int i; 301 int i;
302 bool setColor = false; 302 bool setColor = false;
303 for(i=0;i<mColumns;++i) { 303 for(i=0;i<mColumns;++i) {
304 if (mEnabled[i]) { 304 if (mEnabled[i]) {
305 setColor = true; 305 setColor = true;
306 306
307 int cellWidth = contentsRect().right()/mColumns; 307 int cellWidth = contentsRect().right()/mColumns;
308 int xOffset = KOGlobals::self()->reverseLayout() ? 308 int xOffset = KOGlobals::self()->reverseLayout() ?
309 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 309 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
310 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 310 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
311 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 311 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
312 //qDebug("222draw pix %d ",xOffset ); 312 //qDebug("222draw pix %d ",xOffset );
313 313
314 } 314 }
315 315
316 } 316 }
317 pa.end(); 317 pa.end();
318 318
319 } 319 }
320} 320}
321 321
322void EventIndicator::setXOffset( int x ) 322void EventIndicator::setXOffset( int x )
323{ 323{
324 mXOffset = x; 324 mXOffset = x;
325} 325}
326void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 326void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
327{ 327{
328 mPaintWidget = w; 328 mPaintWidget = w;
329} 329}
330void EventIndicator::changeColumns(int columns) 330void EventIndicator::changeColumns(int columns)
331{ 331{
332 mColumns = columns; 332 mColumns = columns;
333 mEnabled.resize(mColumns); 333 mEnabled.resize(mColumns);
334 334
335 update(); 335 update();
336} 336}
337 337
338void EventIndicator::enableColumn(int column, bool enable) 338void EventIndicator::enableColumn(int column, bool enable)
339{ 339{
340 mEnabled[column] = enable; 340 mEnabled[column] = enable;
341} 341}
342 342
343 343
344//////////////////////////////////////////////////////////////////////////// 344////////////////////////////////////////////////////////////////////////////
345//////////////////////////////////////////////////////////////////////////// 345////////////////////////////////////////////////////////////////////////////
346//////////////////////////////////////////////////////////////////////////// 346////////////////////////////////////////////////////////////////////////////
347 347
348KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 348KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
349 KOEventView (cal,parent,name) 349 KOEventView (cal,parent,name)
350{ 350{
351 mBlockUpdating = true; 351 mBlockUpdating = true;
352 mStartHour = 8; 352 mStartHour = 8;
353 mSelectedDates.append(QDate::currentDate()); 353 mSelectedDates.append(QDate::currentDate());
354 354
355 mLayoutDayLabels = 0; 355 mLayoutDayLabels = 0;
356 mDayLabelsFrame = 0; 356 mDayLabelsFrame = 0;
357 mDayLabels = 0; 357 mDayLabels = 0;
358 bool isRTL = KOGlobals::self()->reverseLayout(); 358 bool isRTL = KOGlobals::self()->reverseLayout();
359 359
360 if ( KOPrefs::instance()->mVerticalScreen ) { 360 if ( KOPrefs::instance()->mVerticalScreen ) {
361 mExpandedPixmap = SmallIcon( "1downarrow" ); 361 mExpandedPixmap = SmallIcon( "1downarrow" );
362 mNotExpandedPixmap = SmallIcon( "1uparrow" ); 362 mNotExpandedPixmap = SmallIcon( "1uparrow" );
363 } else { 363 } else {
364 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); 364 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" );
365 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); 365 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" );
366 } 366 }
367 367
368 QBoxLayout *topLayout = new QVBoxLayout(this); 368 QBoxLayout *topLayout = new QVBoxLayout(this);
369 369
370 // Create day name labels for agenda columns 370 // Create day name labels for agenda columns
371 mDayLabelsFrame = new QHBox(this); 371 mDayLabelsFrame = new QHBox(this);
372 topLayout->addWidget(mDayLabelsFrame); 372 topLayout->addWidget(mDayLabelsFrame);
373 mDayLabels = new QFrame (mDayLabelsFrame); 373 mDayLabels = new QFrame (mDayLabelsFrame);
374 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 374 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
375 // Create agenda splitter 375 // Create agenda splitter
376#ifndef KORG_NOSPLITTER 376#ifndef KORG_NOSPLITTER
377 mSplitterAgenda = new QSplitter(Vertical,this); 377 mSplitterAgenda = new QSplitter(Vertical,this);
378 topLayout->addWidget(mSplitterAgenda); 378 topLayout->addWidget(mSplitterAgenda);
379 mSplitterAgenda->setOpaqueResize(); 379 mSplitterAgenda->setOpaqueResize();
380 380
381 mAllDayFrame = new QHBox(mSplitterAgenda); 381 mAllDayFrame = new QHBox(mSplitterAgenda);
382 382
383 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 383 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
384#else 384#else
385#if 0 385#if 0
386 QWidget *mainBox = new QWidget( this ); 386 QWidget *mainBox = new QWidget( this );
387 topLayout->addWidget( mainBox ); 387 topLayout->addWidget( mainBox );
388 QBoxLayout *mainLayout = new QVBoxLayout(mainBox); 388 QBoxLayout *mainLayout = new QVBoxLayout(mainBox);
389 mAllDayFrame = new QHBox(mainBox); 389 mAllDayFrame = new QHBox(mainBox);
390 mainLayout->addWidget(mAllDayFrame); 390 mainLayout->addWidget(mAllDayFrame);
391 mainLayout->setStretchFactor( mAllDayFrame, 0 ); 391 mainLayout->setStretchFactor( mAllDayFrame, 0 );
392 mAllDayFrame->setFocusPolicy(NoFocus); 392 mAllDayFrame->setFocusPolicy(NoFocus);
393 QWidget *agendaFrame = new QWidget(mainBox); 393 QWidget *agendaFrame = new QWidget(mainBox);
394 mainLayout->addWidget(agendaFrame); 394 mainLayout->addWidget(agendaFrame);
395 mainLayout->setStretchFactor( agendaFrame, 10 ); 395 mainLayout->setStretchFactor( agendaFrame, 10 );
396 396
397 agendaFrame->setFocusPolicy(NoFocus); 397 agendaFrame->setFocusPolicy(NoFocus);
398#endif 398#endif
399 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 399 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
400 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 400 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
401 topLayout->addWidget( mSplitterAgenda ); 401 topLayout->addWidget( mSplitterAgenda );
402 mAllDayFrame = new QHBox(mSplitterAgenda); 402 mAllDayFrame = new QHBox(mSplitterAgenda);
403 mAllDayFrame->setFocusPolicy(NoFocus); 403 mAllDayFrame->setFocusPolicy(NoFocus);
404 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 404 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
405 agendaFrame->setFocusPolicy(NoFocus); 405 agendaFrame->setFocusPolicy(NoFocus);
406 406
407#endif 407#endif
408 408
409 // Create all-day agenda widget 409 // Create all-day agenda widget
410 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 410 mDummyAllDayLeft = new QVBox( mAllDayFrame );
411 411
412 mExpandButton = new QPushButton(mDummyAllDayLeft); 412 mExpandButton = new QPushButton(mDummyAllDayLeft);
413 mExpandButton->setPixmap( mNotExpandedPixmap ); 413 mExpandButton->setPixmap( mNotExpandedPixmap );
414 int widebut = mExpandButton->sizeHint().width(); 414 int widebut = mExpandButton->sizeHint().width();
415 if ( QApplication::desktop()->width() < 480 ) 415 if ( QApplication::desktop()->width() < 480 )
416 widebut = widebut*2; 416 widebut = widebut*2;
417 else 417 else
418 widebut = (widebut*3) / 2; 418 widebut = (widebut*3) / 2;
419 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 419 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
420 // QSizePolicy::Fixed ) ); 420 // QSizePolicy::Fixed ) );
421 mExpandButton->setFixedSize( widebut, widebut); 421 mExpandButton->setFixedSize( widebut, widebut);
422 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 422 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
423 mExpandButton->setFocusPolicy(NoFocus); 423 mExpandButton->setFocusPolicy(NoFocus);
424 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 424 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
425 mAllDayAgenda->setFocusPolicy(NoFocus); 425 mAllDayAgenda->setFocusPolicy(NoFocus);
426 QWidget *dummyAllDayRight = new QWidget(mAllDayFrame); 426 QWidget *dummyAllDayRight = new QWidget(mAllDayFrame);
427 427
428 // Create event context menu for all day agenda 428 // Create event context menu for all day agenda
429 mAllDayAgendaPopup = eventPopup(); 429 mAllDayAgendaPopup = eventPopup();
430 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 430 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
431 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 431 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
432 432
433 // Create agenda frame 433 // Create agenda frame
434 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); 434 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3);
435 // QHBox *agendaFrame = new QHBox(splitterAgenda); 435 // QHBox *agendaFrame = new QHBox(splitterAgenda);
436 436
437 // create event indicator bars 437 // create event indicator bars
438 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 438 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
439 agendaLayout->addWidget(mEventIndicatorTop,0,1); 439 agendaLayout->addWidget(mEventIndicatorTop,0,1);
440 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 440 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
441 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 441 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
442 agendaFrame); 442 agendaFrame);
443 agendaLayout->addWidget(mEventIndicatorBottom,2,1); 443 agendaLayout->addWidget(mEventIndicatorBottom,2,1);
444 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 444 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
445 agendaLayout->addWidget(dummyAgendaRight,0,2); 445 agendaLayout->addWidget(dummyAgendaRight,0,2);
446 446
447 // Create time labels 447 // Create time labels
448 mTimeLabels = new TimeLabels(24,agendaFrame); 448 mTimeLabels = new TimeLabels(24,agendaFrame);
449 agendaLayout->addWidget(mTimeLabels,1,0); 449 agendaLayout->addWidget(mTimeLabels,1,0);
450 connect(mTimeLabels,SIGNAL( scaleChanged()), 450 connect(mTimeLabels,SIGNAL( scaleChanged()),
451 this,SLOT(updateConfig())); 451 this,SLOT(updateConfig()));
452 452
453 // Create agenda 453 // Create agenda
454 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 454 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
455 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); 455 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2);
456 agendaLayout->setColStretch(1,1); 456 agendaLayout->setColStretch(1,1);
457 mAgenda->setFocusPolicy(NoFocus); 457 mAgenda->setFocusPolicy(NoFocus);
458 // Create event context menu for agenda 458 // Create event context menu for agenda
459 mAgendaPopup = eventPopup(); 459 mAgendaPopup = eventPopup();
460 460
461 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 461 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
462 i18n("Toggle Alarm"),mAgenda, 462 i18n("Toggle Alarm"),mAgenda,
463 SLOT(popupAlarm()),true); 463 SLOT(popupAlarm()),true);
464 464
465 465
466 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 466 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
467 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 467 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
468 468
469 // make connections between dependent widgets 469 // make connections between dependent widgets
470 mTimeLabels->setAgenda(mAgenda); 470 mTimeLabels->setAgenda(mAgenda);
471 471
472 // Update widgets to reflect user preferences 472 // Update widgets to reflect user preferences
473 // updateConfig(); 473 // updateConfig();
474 474
475 // createDayLabels(); 475 // createDayLabels();
476 476
477 // these blank widgets make the All Day Event box line up with the agenda 477 // these blank widgets make the All Day Event box line up with the agenda
478 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 478 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
479 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 479 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
480 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 480 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
481 481
482 // Scrolling 482 // Scrolling
483 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 483 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
484 mTimeLabels, SLOT(positionChanged())); 484 mTimeLabels, SLOT(positionChanged()));
485 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 485 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
486 SLOT(setContentsPos(int))); 486 SLOT(setContentsPos(int)));
487 487
488 // Create/Show/Edit/Delete Event 488 // Create/Show/Edit/Delete Event
489 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 489 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
490 SLOT(newEvent(int,int))); 490 SLOT(newEvent(int,int)));
491 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
492 SLOT(newTodo(int,int)));
491 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 493 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
492 SLOT(newEvent(int,int,int,int))); 494 SLOT(newEvent(int,int,int,int)));
493 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 495 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
494 SLOT(newEventAllDay(int,int))); 496 SLOT(newEventAllDay(int,int)));
497 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
498 SLOT(newTodoAllDay(int,int)));
495 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 499 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
496 SLOT(newEventAllDay(int,int))); 500 SLOT(newEventAllDay(int,int)));
497 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 501 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
498 SLOT(newTimeSpanSelected(int,int,int,int))); 502 SLOT(newTimeSpanSelected(int,int,int,int)));
499 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 503 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
500 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 504 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
501 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 505 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
502 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 506 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
503 507
504 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 508 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
505 SIGNAL(editIncidenceSignal(Incidence *))); 509 SIGNAL(editIncidenceSignal(Incidence *)));
506 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 510 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
507 SIGNAL(editIncidenceSignal(Incidence *))); 511 SIGNAL(editIncidenceSignal(Incidence *)));
508 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 512 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
509 SIGNAL(showIncidenceSignal(Incidence *))); 513 SIGNAL(showIncidenceSignal(Incidence *)));
510 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 514 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
511 SIGNAL(showIncidenceSignal(Incidence *))); 515 SIGNAL(showIncidenceSignal(Incidence *)));
512 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 516 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
513 SIGNAL(deleteIncidenceSignal(Incidence *))); 517 SIGNAL(deleteIncidenceSignal(Incidence *)));
514 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 518 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
515 SIGNAL(deleteIncidenceSignal(Incidence *))); 519 SIGNAL(deleteIncidenceSignal(Incidence *)));
516 520
517 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 521 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
518 SLOT(updateEventDates(KOAgendaItem *, int ))); 522 SLOT(updateEventDates(KOAgendaItem *, int )));
519 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 523 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
520 SLOT(updateEventDates(KOAgendaItem *, int))); 524 SLOT(updateEventDates(KOAgendaItem *, int)));
521 525
522 // event indicator update 526 // event indicator update
523 connect(mAgenda,SIGNAL(lowerYChanged(int)), 527 connect(mAgenda,SIGNAL(lowerYChanged(int)),
524 SLOT(updateEventIndicatorTop(int))); 528 SLOT(updateEventIndicatorTop(int)));
525 connect(mAgenda,SIGNAL(upperYChanged(int)), 529 connect(mAgenda,SIGNAL(upperYChanged(int)),
526 SLOT(updateEventIndicatorBottom(int))); 530 SLOT(updateEventIndicatorBottom(int)));
527 // drag signals 531 // drag signals
528 /* 532 /*
529 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 533 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
530 SLOT(startDrag(Event *))); 534 SLOT(startDrag(Event *)));
531 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 535 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
532 SLOT(startDrag(Event *))); 536 SLOT(startDrag(Event *)));
533 */ 537 */
534 // synchronize selections 538 // synchronize selections
535 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 539 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
536 mAllDayAgenda, SLOT( deselectItem() ) ); 540 mAllDayAgenda, SLOT( deselectItem() ) );
537 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 541 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
538 mAgenda, SLOT( deselectItem() ) ); 542 mAgenda, SLOT( deselectItem() ) );
539 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 543 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
540 SIGNAL( incidenceSelected( Incidence * ) ) ); 544 SIGNAL( incidenceSelected( Incidence * ) ) );
541 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 545 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
542 SIGNAL( incidenceSelected( Incidence * ) ) ); 546 SIGNAL( incidenceSelected( Incidence * ) ) );
543 connect( mAgenda, SIGNAL( resizedSignal() ), 547 connect( mAgenda, SIGNAL( resizedSignal() ),
544 SLOT( updateConfig( ) ) ); 548 SLOT( updateConfig( ) ) );
545 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 549 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
546 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 550 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
547 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 551 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
548 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 552 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
549 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 553 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
550 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 554 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
551 555
552 556
553} 557}
554 558
555void KOAgendaView::toggleAllDay() 559void KOAgendaView::toggleAllDay()
556{ 560{
557 if ( mSplitterAgenda->firstHandle() ) 561 if ( mSplitterAgenda->firstHandle() )
558 mSplitterAgenda->firstHandle()->toggle(); 562 mSplitterAgenda->firstHandle()->toggle();
559} 563}
560void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 564void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
561{ 565{
562 calendar()->addIncidence( inc ); 566 calendar()->addIncidence( inc );
563 567
564 if ( incOld ) { 568 if ( incOld ) {
565 if ( incOld->type() == "Todo" ) 569 if ( incOld->type() == "Todo" )
566 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 570 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
567 else 571 else
568 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 572 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
569 } 573 }
570 574
571} 575}
572 576
573KOAgendaView::~KOAgendaView() 577KOAgendaView::~KOAgendaView()
574{ 578{
575 delete mAgendaPopup; 579 delete mAgendaPopup;
576 delete mAllDayAgendaPopup; 580 delete mAllDayAgendaPopup;
577 delete KOAgendaItem::paintPix(); 581 delete KOAgendaItem::paintPix();
578 delete KOAgendaItem::paintPixSel(); 582 delete KOAgendaItem::paintPixSel();
579} 583}
580void KOAgendaView::resizeEvent( QResizeEvent* e ) 584void KOAgendaView::resizeEvent( QResizeEvent* e )
581{ 585{
582 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 586 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
583 bool uc = false; 587 bool uc = false;
584 int ow = e->oldSize().width(); 588 int ow = e->oldSize().width();
585 int oh = e->oldSize().height(); 589 int oh = e->oldSize().height();
586 int w = e->size().width(); 590 int w = e->size().width();
587 int h = e->size().height(); 591 int h = e->size().height();
588 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 592 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
589 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 593 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
590 uc = true; 594 uc = true;
591 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 595 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
592 } 596 }
593 mUpcomingWidth = e->size().width() ; 597 mUpcomingWidth = e->size().width() ;
594 if ( mBlockUpdating || uc ) { 598 if ( mBlockUpdating || uc ) {
595 mBlockUpdating = false; 599 mBlockUpdating = false;
596 //mAgenda->setMinimumSize(800 , 600 ); 600 //mAgenda->setMinimumSize(800 , 600 );
597 //qDebug("mAgenda->resize+++++++++++++++ "); 601 //qDebug("mAgenda->resize+++++++++++++++ ");
598 updateConfig(); 602 updateConfig();
599 //qDebug("KOAgendaView::Updating now possible "); 603 //qDebug("KOAgendaView::Updating now possible ");
600 } else 604 } else
601 createDayLabels(); 605 createDayLabels();
602 //qDebug("resizeEvent end "); 606 //qDebug("resizeEvent end ");
603 607
604} 608}
605void KOAgendaView::createDayLabels() 609void KOAgendaView::createDayLabels()
606{ 610{
607 611
608 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 612 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
609 // qDebug(" KOAgendaView::createDayLabels() blocked "); 613 // qDebug(" KOAgendaView::createDayLabels() blocked ");
610 return; 614 return;
611 615
612 } 616 }
613 int newHight; 617 int newHight;
614 618
615 // ### Before deleting and recreating we could check if mSelectedDates changed... 619 // ### Before deleting and recreating we could check if mSelectedDates changed...
616 // It would remove some flickering and gain speed (since this is called by 620 // It would remove some flickering and gain speed (since this is called by
617 // each updateView() call) 621 // each updateView() call)
618 622
619 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; 623 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
620 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 624 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
621 if ( maxWid < 0 ) 625 if ( maxWid < 0 )
622 maxWid = 20; 626 maxWid = 20;
623 627
624 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 628 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
625 QFontMetrics fm ( dlf ); 629 QFontMetrics fm ( dlf );
626 int selCount = mSelectedDates.count(); 630 int selCount = mSelectedDates.count();
627 QString dayTest = "Mon 20"; 631 QString dayTest = "Mon 20";
628 int wid = fm.width( dayTest ); 632 int wid = fm.width( dayTest );
629 maxWid -= ( selCount * 3 ); 633 maxWid -= ( selCount * 3 );
630 if ( maxWid < 0 ) 634 if ( maxWid < 0 )
631 maxWid = 20; 635 maxWid = 20;
632 int needWid = wid * selCount; 636 int needWid = wid * selCount;
633 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 637 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
634 //if ( needWid > maxWid ) 638 //if ( needWid > maxWid )
635 // qDebug("DAYLABELS TOOOOOOO BIG "); 639 // qDebug("DAYLABELS TOOOOOOO BIG ");
636 while ( needWid > maxWid ) { 640 while ( needWid > maxWid ) {
637 dayTest = dayTest.left( dayTest.length() - 1 ); 641 dayTest = dayTest.left( dayTest.length() - 1 );
638 wid = fm.width( dayTest ); 642 wid = fm.width( dayTest );
639 needWid = wid * selCount; 643 needWid = wid * selCount;
640 } 644 }
641 int maxLen = dayTest.length(); 645 int maxLen = dayTest.length();
642 int fontPoint = dlf.pointSize(); 646 int fontPoint = dlf.pointSize();
643 if ( maxLen < 2 ) { 647 if ( maxLen < 2 ) {
644 int fontPoint = dlf.pointSize(); 648 int fontPoint = dlf.pointSize();
645 while ( fontPoint > 4 ) { 649 while ( fontPoint > 4 ) {
646 --fontPoint; 650 --fontPoint;
647 dlf.setPointSize( fontPoint ); 651 dlf.setPointSize( fontPoint );
648 QFontMetrics f( dlf ); 652 QFontMetrics f( dlf );
649 wid = f.width( "20" ); 653 wid = f.width( "20" );
650 needWid = wid * selCount; 654 needWid = wid * selCount;
651 if ( needWid < maxWid ) 655 if ( needWid < maxWid )
652 break; 656 break;
653 } 657 }
654 maxLen = 2; 658 maxLen = 2;
655 } 659 }
656 //qDebug("Max len %d ", dayTest.length() ); 660 //qDebug("Max len %d ", dayTest.length() );
657 661
658 QFontMetrics tempF( dlf ); 662 QFontMetrics tempF( dlf );
659 newHight = tempF.height(); 663 newHight = tempF.height();
660 mDayLabels->setFont( dlf ); 664 mDayLabels->setFont( dlf );
661 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 665 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
662 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 666 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
663 //mLayoutDayLabels->addSpacing( 2 ); 667 //mLayoutDayLabels->addSpacing( 2 );
664 // QFont lFont = dlf; 668 // QFont lFont = dlf;
665 bool appendLabels = false; 669 bool appendLabels = false;
666 QLabel *dayLabel; 670 QLabel *dayLabel;
667 dayLabel = mDayLabelsList.first(); 671 dayLabel = mDayLabelsList.first();
668 if ( !dayLabel ) { 672 if ( !dayLabel ) {
669 appendLabels = true; 673 appendLabels = true;
670 dayLabel = new QLabel(mDayLabels); 674 dayLabel = new QLabel(mDayLabels);
671 mDayLabelsList.append( dayLabel ); 675 mDayLabelsList.append( dayLabel );
672 mLayoutDayLabels->addWidget(dayLabel); 676 mLayoutDayLabels->addWidget(dayLabel);
673 } 677 }
674 dayLabel->setFixedWidth( mTimeLabels->width()+2 ); 678 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
675 dayLabel->setFont( dlf ); 679 dayLabel->setFont( dlf );
676 dayLabel->setAlignment(QLabel::AlignHCenter); 680 dayLabel->setAlignment(QLabel::AlignHCenter);
677 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 681 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
678 dayLabel->show(); 682 dayLabel->show();
679 DateList::ConstIterator dit; 683 DateList::ConstIterator dit;
680 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 684 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
681 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 685 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
682 QDate date = *dit; 686 QDate date = *dit;
683 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 687 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
684 if ( ! appendLabels ) { 688 if ( ! appendLabels ) {
685 dayLabel = mDayLabelsList.next(); 689 dayLabel = mDayLabelsList.next();
686 if ( !dayLabel ) 690 if ( !dayLabel )
@@ -1094,384 +1098,399 @@ void KOAgendaView::fillAgenda()
1094 } else if (event->isMultiDay()) { 1098 } else if (event->isMultiDay()) {
1095 if ( event->doesRecur () ) { 1099 if ( event->doesRecur () ) {
1096 QDate dateit = currentDate; 1100 QDate dateit = currentDate;
1097 int count = 0; 1101 int count = 0;
1098 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1102 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1099 while (! event->recursOn( dateit ) && count <= max ) { 1103 while (! event->recursOn( dateit ) && count <= max ) {
1100 ++count; 1104 ++count;
1101 dateit = dateit.addDays( -1 ); 1105 dateit = dateit.addDays( -1 );
1102 } 1106 }
1103 bool ok; 1107 bool ok;
1104 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1108 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1105 if ( ok ) 1109 if ( ok )
1106 { 1110 {
1107 int secs = event->dtStart().secsTo( event->dtEnd() ); 1111 int secs = event->dtStart().secsTo( event->dtEnd() );
1108 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1112 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1109 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1113 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1110 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1114 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1111 1115
1112 } 1116 }
1113 } 1117 }
1114 int startY = mAgenda->timeToY(event->dtStart().time()); 1118 int startY = mAgenda->timeToY(event->dtStart().time());
1115 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1119 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1116 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1120 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1117 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1121 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1118 //qDebug("insert!!! "); 1122 //qDebug("insert!!! ");
1119 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1123 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1120 } 1124 }
1121 if (beginX == curCol) { 1125 if (beginX == curCol) {
1122 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1126 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1123 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1127 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1124 } else if (endX == curCol) { 1128 } else if (endX == curCol) {
1125 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1129 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1126 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1130 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1127 } else { 1131 } else {
1128 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1132 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1129 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1133 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1130 } 1134 }
1131 } else { 1135 } else {
1132 int startY = mAgenda->timeToY(event->dtStart().time()); 1136 int startY = mAgenda->timeToY(event->dtStart().time());
1133 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1137 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1134 if (endY < startY) endY = startY; 1138 if (endY < startY) endY = startY;
1135 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1139 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1136 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1140 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1137 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1141 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1138 } 1142 }
1139 } 1143 }
1140 // ---------- [display Todos -------------- 1144 // ---------- [display Todos --------------
1141 unsigned int numTodo; 1145 unsigned int numTodo;
1142 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1146 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1143 Todo *todo = todos.at(numTodo); 1147 Todo *todo = todos.at(numTodo);
1144 1148
1145 if ( ! todo->hasDueDate() ) continue; // todo shall not be displayed if it has no date 1149 if ( ! todo->hasDueDate() ) continue; // todo shall not be displayed if it has no date
1146 1150
1147 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1151 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1148 // Already completed items can be displayed on their original due date 1152 // Already completed items can be displayed on their original due date
1149 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1153 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1150 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1154 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1151 1155
1152 if ( ((todo->dtDue().date() == currentDate) && !overdue) || 1156 if ( ((todo->dtDue().date() == currentDate) && !overdue) ||
1153 ((currentDate == today) && overdue) ) { 1157 ((currentDate == today) && overdue) ) {
1154 if ( todo->doesFloat() || overdue ) { // Todo has no due-time set or is already overdue 1158 if ( todo->doesFloat() || overdue ) { // Todo has no due-time set or is already overdue
1155 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1159 if ( KOPrefs::instance()->mShowTodoInAgenda )
1156 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1160 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1157 } 1161 }
1158 else { 1162 else {
1159 1163
1160 int endY = mAgenda->timeToY(todo->dtDue().time()) - 1; 1164 int endY = mAgenda->timeToY(todo->dtDue().time()) - 1;
1161 int hi = (18/KOPrefs::instance()->mHourSize); 1165 int hi = (18/KOPrefs::instance()->mHourSize);
1162 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1166 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1163 int startY = endY -hi; 1167 int startY = endY -hi;
1164 1168
1165 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1169 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1166 1170
1167 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1171 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1168 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1172 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1169 } 1173 }
1170 } 1174 }
1171 } 1175 }
1172 // ---------- display Todos] -------------- 1176 // ---------- display Todos] --------------
1173 1177
1174 ++curCol; 1178 ++curCol;
1175 } 1179 }
1176 mAgenda->hideUnused(); 1180 mAgenda->hideUnused();
1177 mAllDayAgenda->hideUnused(); 1181 mAllDayAgenda->hideUnused();
1178 mAgenda->checkScrollBoundaries(); 1182 mAgenda->checkScrollBoundaries();
1179 1183
1180 deleteSelectedDateTime(); 1184 deleteSelectedDateTime();
1181 1185
1182 createDayLabels(); 1186 createDayLabels();
1183 emit incidenceSelected( 0 ); 1187 emit incidenceSelected( 0 );
1184 1188
1185 if ( globalFlagBlockAgenda == 2 ) { 1189 if ( globalFlagBlockAgenda == 2 ) {
1186 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1190 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1187 setStartHour( KOPrefs::instance()->mDayBegins ); 1191 setStartHour( KOPrefs::instance()->mDayBegins );
1188 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1192 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1189 setStartHour( QTime::currentTime ().hour() ); 1193 setStartHour( QTime::currentTime ().hour() );
1190 // qApp->processEvents(); 1194 // qApp->processEvents();
1191 } 1195 }
1192 qApp->processEvents(); 1196 qApp->processEvents();
1193 //qDebug("qApp->processEvents(); END "); 1197 //qDebug("qApp->processEvents(); END ");
1194 globalFlagBlockAgenda = 0; 1198 globalFlagBlockAgenda = 0;
1195 1199
1196 // mAgenda->hideUnused(); 1200 // mAgenda->hideUnused();
1197 //mAllDayAgenda->hideUnused(); 1201 //mAllDayAgenda->hideUnused();
1198 mAllDayAgenda->drawContentsToPainter(); 1202 mAllDayAgenda->drawContentsToPainter();
1199 mAgenda->drawContentsToPainter(); 1203 mAgenda->drawContentsToPainter();
1200 repaintAgenda(); 1204 repaintAgenda();
1201 // mAgenda->finishUpdate(); 1205 // mAgenda->finishUpdate();
1202 //mAllDayAgenda->finishUpdate(); 1206 //mAllDayAgenda->finishUpdate();
1203 1207
1204 // repaintAgenda(); 1208 // repaintAgenda();
1205 //qApp->processEvents(); 1209 //qApp->processEvents();
1206 // globalFlagBlockAgenda = 0; 1210 // globalFlagBlockAgenda = 0;
1207} 1211}
1208void KOAgendaView::repaintAgenda() 1212void KOAgendaView::repaintAgenda()
1209{ 1213{
1210 // mAllDayAgenda->drawContentsToPainter(); 1214 // mAllDayAgenda->drawContentsToPainter();
1211// mAllDayAgenda->viewport()->repaint( false ); 1215// mAllDayAgenda->viewport()->repaint( false );
1212// mAgenda->drawContentsToPainter(); 1216// mAgenda->drawContentsToPainter();
1213// mAgenda->viewport()->repaint( false ); 1217// mAgenda->viewport()->repaint( false );
1214// qApp->processEvents(); 1218// qApp->processEvents();
1215 1219
1216 //qDebug("KOAgendaView::repaintAgenda() "); 1220 //qDebug("KOAgendaView::repaintAgenda() ");
1217 //qApp->processEvents(); 1221 //qApp->processEvents();
1218 mAgenda->viewport()->repaint( false ); 1222 mAgenda->viewport()->repaint( false );
1219 mAllDayAgenda->viewport()->repaint( false ); 1223 mAllDayAgenda->viewport()->repaint( false );
1220 mAgenda->finishUpdate(); 1224 mAgenda->finishUpdate();
1221 mAllDayAgenda->finishUpdate(); 1225 mAllDayAgenda->finishUpdate();
1222} 1226}
1223 1227
1224 1228
1225void KOAgendaView::clearView() 1229void KOAgendaView::clearView()
1226{ 1230{
1227 // kdDebug() << "ClearView" << endl; 1231 // kdDebug() << "ClearView" << endl;
1228 mAllDayAgenda->clear(); 1232 mAllDayAgenda->clear();
1229 mAgenda->clear(); 1233 mAgenda->clear();
1230} 1234}
1231 1235
1232void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1236void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1233 const QDate &td) 1237 const QDate &td)
1234{ 1238{
1235#ifndef KORG_NOPRINTER 1239#ifndef KORG_NOPRINTER
1236 if (fd == td) 1240 if (fd == td)
1237 calPrinter->preview(CalPrinter::Day, fd, td); 1241 calPrinter->preview(CalPrinter::Day, fd, td);
1238 else 1242 else
1239 calPrinter->preview(CalPrinter::Week, fd, td); 1243 calPrinter->preview(CalPrinter::Week, fd, td);
1240#endif 1244#endif
1241} 1245}
1242 1246
1243// void KOAgendaView::updateMovedTodo() 1247// void KOAgendaView::updateMovedTodo()
1244// { 1248// {
1245// // updateConfig(); 1249// // updateConfig();
1246// // emit updateTodoViews(); 1250// // emit updateTodoViews();
1247// } 1251// }
1248 1252
1249void KOAgendaView::newEvent(int gx, int gy) 1253void KOAgendaView::newEvent(int gx, int gy)
1250{ 1254{
1251 if (!mSelectedDates.count()) return; 1255 if (!mSelectedDates.count()) return;
1252 1256
1253 QDate day = mSelectedDates[gx]; 1257 QDate day = mSelectedDates[gx];
1254 1258
1255 QTime time = mAgenda->gyToTime(gy); 1259 QTime time = mAgenda->gyToTime(gy);
1256 QDateTime dt(day,time); 1260 QDateTime dt(day,time);
1257 // if ( dt < QDateTime::currentDateTime () ) 1261 // if ( dt < QDateTime::currentDateTime () )
1258 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1262 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1259 emit newEventSignal(dt); 1263 emit newEventSignal(dt);
1260} 1264}
1261 1265
1262void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1266void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1263{ 1267{
1264 if (!mSelectedDates.count()) return; 1268 if (!mSelectedDates.count()) return;
1265 1269
1266 QDate dayStart = mSelectedDates[gxStart]; 1270 QDate dayStart = mSelectedDates[gxStart];
1267 QDate dayEnd = mSelectedDates[gxEnd]; 1271 QDate dayEnd = mSelectedDates[gxEnd];
1268 1272
1269 QTime timeStart = mAgenda->gyToTime(gyStart); 1273 QTime timeStart = mAgenda->gyToTime(gyStart);
1270 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1274 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1271 1275
1272 QDateTime dtStart(dayStart,timeStart); 1276 QDateTime dtStart(dayStart,timeStart);
1273 QDateTime dtEnd(dayEnd,timeEnd); 1277 QDateTime dtEnd(dayEnd,timeEnd);
1274 1278
1275 emit newEventSignal(dtStart,dtEnd); 1279 emit newEventSignal(dtStart,dtEnd);
1276} 1280}
1277 1281
1278void KOAgendaView::newEventAllDay(int gx, int ) 1282void KOAgendaView::newEventAllDay(int gx, int )
1279{ 1283{
1280 if (!mSelectedDates.count()) return; 1284 if (!mSelectedDates.count()) return;
1281 1285
1282 QDate day = mSelectedDates[gx]; 1286 QDate day = mSelectedDates[gx];
1283 1287
1284 emit newEventSignal(day); 1288 emit newEventSignal(day);
1285} 1289}
1290void KOAgendaView::newTodoAllDay(int gx, int )
1291{
1292 if (!mSelectedDates.count()) return;
1293
1294 QDateTime day (mSelectedDates[gx] );
1295 emit newTodoSignal(day, true);
1296}
1297void KOAgendaView::newTodo(int gx, int gy )
1298{
1299 if (!mSelectedDates.count()) return;
1300 QDate dayStart = mSelectedDates[gx];
1301 QTime timeStart = mAgenda->gyToTime(gy);
1302 QDateTime dt (dayStart,timeStart);
1303 emit newTodoSignal( dt, false );
1304}
1286 1305
1287void KOAgendaView::updateEventIndicatorTop(int newY) 1306void KOAgendaView::updateEventIndicatorTop(int newY)
1288{ 1307{
1289 uint i; 1308 uint i;
1290 for(i=0;i<mMinY.size();++i) { 1309 for(i=0;i<mMinY.size();++i) {
1291 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1310 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1292 else mEventIndicatorTop->enableColumn(i,false); 1311 else mEventIndicatorTop->enableColumn(i,false);
1293 } 1312 }
1294 1313
1295 mEventIndicatorTop->update(); 1314 mEventIndicatorTop->update();
1296} 1315}
1297 1316
1298void KOAgendaView::updateEventIndicatorBottom(int newY) 1317void KOAgendaView::updateEventIndicatorBottom(int newY)
1299{ 1318{
1300 uint i; 1319 uint i;
1301 for(i=0;i<mMaxY.size();++i) { 1320 for(i=0;i<mMaxY.size();++i) {
1302 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1321 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1303 else mEventIndicatorBottom->enableColumn(i,false); 1322 else mEventIndicatorBottom->enableColumn(i,false);
1304 } 1323 }
1305 1324
1306 mEventIndicatorBottom->update(); 1325 mEventIndicatorBottom->update();
1307} 1326}
1308 1327
1309void KOAgendaView::startDrag(Event *event) 1328void KOAgendaView::startDrag(Event *event)
1310{ 1329{
1311#ifndef KORG_NODND 1330#ifndef KORG_NODND
1312 DndFactory factory( calendar() ); 1331 DndFactory factory( calendar() );
1313 ICalDrag *vd = factory.createDrag(event,this); 1332 ICalDrag *vd = factory.createDrag(event,this);
1314 if (vd->drag()) { 1333 if (vd->drag()) {
1315 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1334 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1316 } 1335 }
1317#endif 1336#endif
1318} 1337}
1319 1338
1320void KOAgendaView::readSettings() 1339void KOAgendaView::readSettings()
1321{ 1340{
1322 readSettings(KOGlobals::config()); 1341 readSettings(KOGlobals::config());
1323} 1342}
1324 1343
1325void KOAgendaView::readSettings(KConfig *config) 1344void KOAgendaView::readSettings(KConfig *config)
1326{ 1345{
1327 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1346 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1328 1347
1329 config->setGroup("Views"); 1348 config->setGroup("Views");
1330 1349
1331 //#ifndef KORG_NOSPLITTER 1350 //#ifndef KORG_NOSPLITTER
1332 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1351 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1333 if (sizes.count() == 2) { 1352 if (sizes.count() == 2) {
1334 if ( sizes[0] < 20 ) { 1353 if ( sizes[0] < 20 ) {
1335 sizes[1] = sizes[1] +20 - sizes[0]; 1354 sizes[1] = sizes[1] +20 - sizes[0];
1336 sizes[0] = 20; 1355 sizes[0] = 20;
1337 } 1356 }
1338 mSplitterAgenda->setSizes(sizes); 1357 mSplitterAgenda->setSizes(sizes);
1339 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1358 // qDebug("read %d %d ",sizes[0],sizes[1] );
1340 } 1359 }
1341 //#endif 1360 //#endif
1342 1361
1343 // updateConfig(); 1362 // updateConfig();
1344} 1363}
1345 1364
1346void KOAgendaView::writeSettings(KConfig *config) 1365void KOAgendaView::writeSettings(KConfig *config)
1347{ 1366{
1348 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1367 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1349 1368
1350 config->setGroup("Views"); 1369 config->setGroup("Views");
1351 1370
1352 //#ifndef KORG_NOSPLITTER 1371 //#ifndef KORG_NOSPLITTER
1353 QValueList<int> list = mSplitterAgenda->sizes(); 1372 QValueList<int> list = mSplitterAgenda->sizes();
1354 config->writeEntry("Separator AgendaView",list); 1373 config->writeEntry("Separator AgendaView",list);
1355 //qDebug("write %d %d ", list[0],list[1] ); 1374 //qDebug("write %d %d ", list[0],list[1] );
1356 //#endif 1375 //#endif
1357} 1376}
1358 1377
1359void KOAgendaView::setHolidayMasks() 1378void KOAgendaView::setHolidayMasks()
1360{ 1379{
1361 mHolidayMask.resize(mSelectedDates.count()); 1380 mHolidayMask.resize(mSelectedDates.count());
1362 1381
1363 uint i; 1382 uint i;
1364 for(i=0;i<mSelectedDates.count();++i) { 1383 for(i=0;i<mSelectedDates.count();++i) {
1365 QDate date = mSelectedDates[i]; 1384 QDate date = mSelectedDates[i];
1366 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1385 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1367 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1386 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1368 bool showHoliday = false; 1387 bool showHoliday = false;
1369 if ( KOPrefs::instance()->mExcludeHolidays ) { 1388 if ( KOPrefs::instance()->mExcludeHolidays ) {
1370 QPtrList<Event> events = calendar()->events( date, true ); 1389 QPtrList<Event> events = calendar()->events( date, true );
1371 Event *event; 1390 Event *event;
1372 for( event = events.first(); event; event = events.next() ) { 1391 for( event = events.first(); event; event = events.next() ) {
1373 if ( event->categories().contains("Holiday") || 1392 if ( event->categories().contains("Holiday") ||
1374 event->categories().contains(i18n("Holiday"))) { 1393 event->categories().contains(i18n("Holiday"))) {
1375 showHoliday = true; 1394 showHoliday = true;
1376 break; 1395 break;
1377 } 1396 }
1378 } 1397 }
1379 1398
1380 } 1399 }
1381 1400
1382#ifndef KORG_NOPLUGINS 1401#ifndef KORG_NOPLUGINS
1383 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1402 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1384 !KOCore::self()->holiday(date).isEmpty(); 1403 !KOCore::self()->holiday(date).isEmpty();
1385#endif 1404#endif
1386 bool showDay = showSaturday || showSunday || showHoliday; 1405 bool showDay = showSaturday || showSunday || showHoliday;
1387 1406
1388 if (showDay) { 1407 if (showDay) {
1389 mHolidayMask.at(i) = true; 1408 mHolidayMask.at(i) = true;
1390 } else { 1409 } else {
1391 mHolidayMask.at(i) = false; 1410 mHolidayMask.at(i) = false;
1392 } 1411 }
1393 } 1412 }
1394 1413
1395 mAgenda->setHolidayMask(&mHolidayMask); 1414 mAgenda->setHolidayMask(&mHolidayMask);
1396 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1415 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1397} 1416}
1398 1417
1399void KOAgendaView::setContentsPos(int y) 1418void KOAgendaView::setContentsPos(int y)
1400{ 1419{
1401 mAgenda->setContentsPos(0,y); 1420 mAgenda->setContentsPos(0,y);
1402} 1421}
1403 1422
1404void KOAgendaView::setExpandedButton( bool expanded ) 1423void KOAgendaView::setExpandedButton( bool expanded )
1405{ 1424{
1406 if ( expanded ) { 1425 if ( expanded ) {
1407 mExpandButton->setPixmap( mExpandedPixmap ); 1426 mExpandButton->setPixmap( mExpandedPixmap );
1408 } else { 1427 } else {
1409 mExpandButton->setPixmap( mNotExpandedPixmap ); 1428 mExpandButton->setPixmap( mNotExpandedPixmap );
1410 } 1429 }
1411} 1430}
1412 1431
1413void KOAgendaView::clearSelection() 1432void KOAgendaView::clearSelection()
1414{ 1433{
1415 mAgenda->deselectItem(); 1434 mAgenda->deselectItem();
1416 mAllDayAgenda->deselectItem(); 1435 mAllDayAgenda->deselectItem();
1417} 1436}
1418 1437
1419void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1438void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1420 int gxEnd, int gyEnd) 1439 int gxEnd, int gyEnd)
1421{ 1440{
1422 mTimeSpanInAllDay = true; 1441 mTimeSpanInAllDay = true;
1423 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1442 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1424} 1443}
1425 1444
1426 1445
1427 1446
1428 1447
1429void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1448void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1430 int gxEnd, int gyEnd) 1449 int gxEnd, int gyEnd)
1431{ 1450{
1432 if (!mSelectedDates.count()) return; 1451 if (!mSelectedDates.count()) return;
1433 1452
1434 QDate dayStart = mSelectedDates[gxStart]; 1453 QDate dayStart = mSelectedDates[gxStart];
1435 QDate dayEnd = mSelectedDates[gxEnd]; 1454 QDate dayEnd = mSelectedDates[gxEnd];
1436 1455
1437 QTime timeStart = mAgenda->gyToTime(gyStart); 1456 QTime timeStart = mAgenda->gyToTime(gyStart);
1438 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1457 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1439 1458
1440 QDateTime dtStart(dayStart,timeStart); 1459 QDateTime dtStart(dayStart,timeStart);
1441 QDateTime dtEnd(dayEnd,timeEnd); 1460 QDateTime dtEnd(dayEnd,timeEnd);
1442 1461
1443 mTimeSpanBegin = dtStart; 1462 mTimeSpanBegin = dtStart;
1444 mTimeSpanEnd = dtEnd; 1463 mTimeSpanEnd = dtEnd;
1445 1464
1446} 1465}
1447 1466
1448void KOAgendaView::deleteSelectedDateTime() 1467void KOAgendaView::deleteSelectedDateTime()
1449{ 1468{
1450 mTimeSpanBegin.setDate(QDate()); 1469 mTimeSpanBegin.setDate(QDate());
1451 mTimeSpanEnd.setDate(QDate()); 1470 mTimeSpanEnd.setDate(QDate());
1452 mTimeSpanInAllDay = false; 1471 mTimeSpanInAllDay = false;
1453} 1472}
1454 1473
1455void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1474void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1456{ 1475{
1457 e->ignore(); 1476 e->ignore();
1458} 1477}
1459 1478
1460void KOAgendaView::scrollOneHourUp() 1479void KOAgendaView::scrollOneHourUp()
1461{ 1480{
1462 1481
1463 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1482 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1464} 1483}
1465void KOAgendaView::scrollOneHourDown() 1484void KOAgendaView::scrollOneHourDown()
1466{ 1485{
1467 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1486 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1468} 1487}
1469 1488
1470void KOAgendaView::setStartHour( int h ) 1489void KOAgendaView::setStartHour( int h )
1471{ 1490{
1472 mAgenda->setStartHour( h ); 1491 mAgenda->setStartHour( h );
1473 1492
1474} 1493}
1475 1494
1476void KOAgendaView::updateTodo( Todo * t, int ) 1495void KOAgendaView::updateTodo( Todo * t, int )
1477{ 1496{
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index 3cf938f..01d74a1 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -1,258 +1,261 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOAGENDAVIEW_H 23#ifndef KOAGENDAVIEW_H
24#define KOAGENDAVIEW_H 24#define KOAGENDAVIEW_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef DESKTOP_VERSION 29#ifndef DESKTOP_VERSION
30#include <qksplitter.h> 30#include <qksplitter.h>
31#else 31#else
32#include <qsplitter.h> 32#include <qsplitter.h>
33#endif 33#endif
34#include <qmemarray.h> 34#include <qmemarray.h>
35 35
36#include "koeventview.h" 36#include "koeventview.h"
37 37
38 38
39class QHBox; 39class QHBox;
40class QFrame; 40class QFrame;
41class QLabel; 41class QLabel;
42class QPushButton; 42class QPushButton;
43class CalendarView; 43class CalendarView;
44class KOAgenda; 44class KOAgenda;
45class KOAgendaItem; 45class KOAgendaItem;
46class KConfig; 46class KConfig;
47class KDGanttMinimizeSplitter; 47class KDGanttMinimizeSplitter;
48class TimeLabels : public QScrollView { 48class TimeLabels : public QScrollView {
49 Q_OBJECT 49 Q_OBJECT
50 public: 50 public:
51 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); 51 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0);
52 52
53 void setCellHeight(int height); 53 void setCellHeight(int height);
54 54
55 /** Calculates the minimum width */ 55 /** Calculates the minimum width */
56 virtual int minimumWidth() const; 56 virtual int minimumWidth() const;
57 57
58 /** updates widget's internal state */ 58 /** updates widget's internal state */
59 void updateConfig(); 59 void updateConfig();
60 60
61 /** */ 61 /** */
62 void setAgenda(KOAgenda* agenda); 62 void setAgenda(KOAgenda* agenda);
63 63
64 /** */ 64 /** */
65 virtual void paintEvent(QPaintEvent* e); 65 virtual void paintEvent(QPaintEvent* e);
66 void contentsMousePressEvent ( QMouseEvent * ) ; 66 void contentsMousePressEvent ( QMouseEvent * ) ;
67 void contentsMouseReleaseEvent ( QMouseEvent * ); 67 void contentsMouseReleaseEvent ( QMouseEvent * );
68 void contentsMouseMoveEvent ( QMouseEvent * ); 68 void contentsMouseMoveEvent ( QMouseEvent * );
69 69
70 public slots: 70 public slots:
71 /** update time label positions */ 71 /** update time label positions */
72 void positionChanged(); 72 void positionChanged();
73 signals: 73 signals:
74 void scaleChanged(); 74 void scaleChanged();
75 protected: 75 protected:
76 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 76 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
77 77
78 private: 78 private:
79 int mMouseDownY; 79 int mMouseDownY;
80 QString mOrgCap; 80 QString mOrgCap;
81 int mRows; 81 int mRows;
82 int mCellHeight; 82 int mCellHeight;
83 83
84 /** */ 84 /** */
85 KOAgenda* mAgenda; 85 KOAgenda* mAgenda;
86}; 86};
87 87
88class EventIndicator : public QFrame { 88class EventIndicator : public QFrame {
89 Q_OBJECT 89 Q_OBJECT
90 public: 90 public:
91 enum Location { Top, Bottom }; 91 enum Location { Top, Bottom };
92 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 92 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
93 virtual ~EventIndicator(); 93 virtual ~EventIndicator();
94 94
95 void changeColumns(int columns); 95 void changeColumns(int columns);
96 void setPaintWidget( KDGanttMinimizeSplitter* ); 96 void setPaintWidget( KDGanttMinimizeSplitter* );
97 void setXOffset( int ); 97 void setXOffset( int );
98 void enableColumn(int column, bool enable); 98 void enableColumn(int column, bool enable);
99 99
100 protected: 100 protected:
101 void drawContents(QPainter *); 101 void drawContents(QPainter *);
102 102
103 private: 103 private:
104 int mXOffset; 104 int mXOffset;
105 KDGanttMinimizeSplitter* mPaintWidget; 105 KDGanttMinimizeSplitter* mPaintWidget;
106 int mColumns; 106 int mColumns;
107 QHBox *mTopBox; 107 QHBox *mTopBox;
108 QBoxLayout *mTopLayout; 108 QBoxLayout *mTopLayout;
109 Location mLocation; 109 Location mLocation;
110 QPixmap mPixmap; 110 QPixmap mPixmap;
111 QMemArray<bool> mEnabled; 111 QMemArray<bool> mEnabled;
112}; 112};
113 113
114/** 114/**
115 KOAgendaView is the agenda-like view used to display events in an one or 115 KOAgendaView is the agenda-like view used to display events in an one or
116 multi-day view. 116 multi-day view.
117*/ 117*/
118class KOAgendaView : public KOEventView { 118class KOAgendaView : public KOEventView {
119 Q_OBJECT 119 Q_OBJECT
120 public: 120 public:
121 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 121 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
122 virtual ~KOAgendaView(); 122 virtual ~KOAgendaView();
123 void setStartHour( int ); 123 void setStartHour( int );
124 void toggleAllDay(); 124 void toggleAllDay();
125 125
126 126
127 /** Returns maximum number of days supported by the koagendaview */ 127 /** Returns maximum number of days supported by the koagendaview */
128 virtual int maxDatesHint(); 128 virtual int maxDatesHint();
129 129
130 /** Returns number of currently shown dates. */ 130 /** Returns number of currently shown dates. */
131 virtual int currentDateCount(); 131 virtual int currentDateCount();
132 132
133 /** returns the currently selected events */ 133 /** returns the currently selected events */
134 virtual QPtrList<Incidence> selectedIncidences(); 134 virtual QPtrList<Incidence> selectedIncidences();
135 135
136 /** returns the currently selected events */ 136 /** returns the currently selected events */
137 virtual DateList selectedDates(); 137 virtual DateList selectedDates();
138 138
139 /** Remove all events from view */ 139 /** Remove all events from view */
140 void clearView(); 140 void clearView();
141 KOAgenda *agenda() { return mAgenda;} 141 KOAgenda *agenda() { return mAgenda;}
142 virtual void printPreview(CalPrinter *calPrinter, 142 virtual void printPreview(CalPrinter *calPrinter,
143 const QDate &, const QDate &); 143 const QDate &, const QDate &);
144 144
145 /** start-datetime of selection */ 145 /** start-datetime of selection */
146 QDateTime selectionStart() {return mTimeSpanBegin;} 146 QDateTime selectionStart() {return mTimeSpanBegin;}
147 /** end-datetime of selection */ 147 /** end-datetime of selection */
148 QDateTime selectionEnd() {return mTimeSpanEnd;} 148 QDateTime selectionEnd() {return mTimeSpanEnd;}
149 /** returns true if selection is for whole day */ 149 /** returns true if selection is for whole day */
150 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 150 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
151 /** make selected start/end invalid */ 151 /** make selected start/end invalid */
152 void deleteSelectedDateTime(); 152 void deleteSelectedDateTime();
153 void repaintAgenda(); 153 void repaintAgenda();
154 public slots: 154 public slots:
155 virtual void updateView(); 155 virtual void updateView();
156 virtual void updateConfig(); 156 virtual void updateConfig();
157 virtual void showDates(const QDate &start, const QDate &end); 157 virtual void showDates(const QDate &start, const QDate &end);
158 virtual void showEvents(QPtrList<Event> eventList); 158 virtual void showEvents(QPtrList<Event> eventList);
159 159
160 void updateTodo( Todo *, int ); 160 void updateTodo( Todo *, int );
161 void changeEventDisplay(Event *, int); 161 void changeEventDisplay(Event *, int);
162 162
163 void clearSelection(); 163 void clearSelection();
164 164
165 void newTodo(int gx,int gy);
165 void newEvent(int gx,int gy); 166 void newEvent(int gx,int gy);
166 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 167 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
167 void newEventAllDay(int gx, int gy); 168 void newEventAllDay(int gx, int gy);
169 void newTodoAllDay(int gx, int gy);
168 170
169 void startDrag(Event *); 171 void startDrag(Event *);
170 172
171 void readSettings(); 173 void readSettings();
172 void readSettings(KConfig *); 174 void readSettings(KConfig *);
173 void writeSettings(KConfig *); 175 void writeSettings(KConfig *);
174 176
175 void setContentsPos(int y); 177 void setContentsPos(int y);
176 178
177 void setExpandedButton( bool expanded ); 179 void setExpandedButton( bool expanded );
178 void scrollOneHourUp(); 180 void scrollOneHourUp();
179 void scrollOneHourDown(); 181 void scrollOneHourDown();
180 void addToCalSlot(Incidence *, Incidence *); 182 void addToCalSlot(Incidence *, Incidence *);
181 183
182 signals: 184 signals:
185 void newTodoSignal( QDateTime ,bool );
183 void toggleExpand(); 186 void toggleExpand();
184 void todoMoved( Todo *, int ); 187 void todoMoved( Todo *, int );
185 void incidenceChanged(Incidence * , int ); 188 void incidenceChanged(Incidence * , int );
186 // void cloneIncidenceSignal(Incidence *); 189 // void cloneIncidenceSignal(Incidence *);
187 190
188 protected: 191 protected:
189 bool mBlockUpdating; 192 bool mBlockUpdating;
190 int mUpcomingWidth; 193 int mUpcomingWidth;
191 /** Fill agenda beginning with date startDate */ 194 /** Fill agenda beginning with date startDate */
192 void fillAgenda(const QDate &startDate); 195 void fillAgenda(const QDate &startDate);
193 void resizeEvent( QResizeEvent* e ); 196 void resizeEvent( QResizeEvent* e );
194 /** Fill agenda using the current set value for the start date */ 197 /** Fill agenda using the current set value for the start date */
195 void fillAgenda(); 198 void fillAgenda();
196 199
197 /** Create labels for the selected dates. */ 200 /** Create labels for the selected dates. */
198 void createDayLabels(); 201 void createDayLabels();
199 202
200 /** 203 /**
201 Set the masks on the agenda widgets indicating, which days are holidays. 204 Set the masks on the agenda widgets indicating, which days are holidays.
202 */ 205 */
203 void setHolidayMasks(); 206 void setHolidayMasks();
204 207
205 protected slots: 208 protected slots:
206 /** Update event belonging to agenda item */ 209 /** Update event belonging to agenda item */
207 void updateEventDates(KOAgendaItem *item, int mode = -1); 210 void updateEventDates(KOAgendaItem *item, int mode = -1);
208 //void updateMovedTodo(); 211 //void updateMovedTodo();
209 212
210 void updateEventIndicatorTop(int newY); 213 void updateEventIndicatorTop(int newY);
211 void updateEventIndicatorBottom(int newY); 214 void updateEventIndicatorBottom(int newY);
212 215
213 /** Updates data for selected timespan */ 216 /** Updates data for selected timespan */
214 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 217 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
215 /** Updates data for selected timespan for all day event*/ 218 /** Updates data for selected timespan for all day event*/
216 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 219 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
217 220
218 private: 221 private:
219 // view widgets 222 // view widgets
220 QFrame *mDayLabels; 223 QFrame *mDayLabels;
221 QHBox *mDayLabelsFrame; 224 QHBox *mDayLabelsFrame;
222 QBoxLayout *mLayoutDayLabels; 225 QBoxLayout *mLayoutDayLabels;
223 QFrame *mAllDayFrame; 226 QFrame *mAllDayFrame;
224 KOAgenda *mAllDayAgenda; 227 KOAgenda *mAllDayAgenda;
225 KOAgenda *mAgenda; 228 KOAgenda *mAgenda;
226 TimeLabels *mTimeLabels; 229 TimeLabels *mTimeLabels;
227 QWidget *mDummyAllDayLeft; 230 QWidget *mDummyAllDayLeft;
228 231
229 KDGanttMinimizeSplitter* mSplitterAgenda; 232 KDGanttMinimizeSplitter* mSplitterAgenda;
230 QPushButton *mExpandButton; 233 QPushButton *mExpandButton;
231 234
232 DateList mSelectedDates; // List of dates to be displayed 235 DateList mSelectedDates; // List of dates to be displayed
233 int mViewType; 236 int mViewType;
234 237
235 bool mWeekStartsMonday; 238 bool mWeekStartsMonday;
236 int mStartHour; 239 int mStartHour;
237 240
238 KOEventPopupMenu *mAgendaPopup; 241 KOEventPopupMenu *mAgendaPopup;
239 KOEventPopupMenu *mAllDayAgendaPopup; 242 KOEventPopupMenu *mAllDayAgendaPopup;
240 243
241 EventIndicator *mEventIndicatorTop; 244 EventIndicator *mEventIndicatorTop;
242 EventIndicator *mEventIndicatorBottom; 245 EventIndicator *mEventIndicatorBottom;
243 246
244 QMemArray<int> mMinY; 247 QMemArray<int> mMinY;
245 QMemArray<int> mMaxY; 248 QMemArray<int> mMaxY;
246 249
247 QMemArray<bool> mHolidayMask; 250 QMemArray<bool> mHolidayMask;
248 251
249 QPixmap mExpandedPixmap; 252 QPixmap mExpandedPixmap;
250 QPixmap mNotExpandedPixmap; 253 QPixmap mNotExpandedPixmap;
251 QPtrList<QLabel> mDayLabelsList; 254 QPtrList<QLabel> mDayLabelsList;
252 QDateTime mTimeSpanBegin; 255 QDateTime mTimeSpanBegin;
253 QDateTime mTimeSpanEnd; 256 QDateTime mTimeSpanEnd;
254 bool mTimeSpanInAllDay; 257 bool mTimeSpanInAllDay;
255 void keyPressEvent ( QKeyEvent * e ); 258 void keyPressEvent ( QKeyEvent * e );
256}; 259};
257 260
258#endif // KOAGENDAVIEW_H 261#endif // KOAGENDAVIEW_H
diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp
index 158a7d3..b9a028b 100644
--- a/korganizer/koeditorgeneraltodo.cpp
+++ b/korganizer/koeditorgeneraltodo.cpp
@@ -6,398 +6,403 @@
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qfiledialog.h> 25#include <qfiledialog.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qbuttongroup.h> 28#include <qbuttongroup.h>
29#include <qvgroupbox.h> 29#include <qvgroupbox.h>
30#include <qwidgetstack.h> 30#include <qwidgetstack.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32 32
33#include <kglobal.h> 33#include <kglobal.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kiconloader.h> 35#include <kiconloader.h>
36#include <kmessagebox.h> 36#include <kmessagebox.h>
37#include <kdebug.h> 37#include <kdebug.h>
38#include <krestrictedline.h> 38#include <krestrictedline.h>
39#include <kstandarddirs.h> 39#include <kstandarddirs.h>
40#include <kfiledialog.h> 40#include <kfiledialog.h>
41 41
42#include <libkcal/todo.h> 42#include <libkcal/todo.h>
43 43
44#include <libkdepim/kdateedit.h> 44#include <libkdepim/kdateedit.h>
45 45
46#include "koprefs.h" 46#include "koprefs.h"
47#include "ktimeedit.h" 47#include "ktimeedit.h"
48 48
49#include "koeditorgeneraltodo.h" 49#include "koeditorgeneraltodo.h"
50#include "kolocationbox.h" 50#include "kolocationbox.h"
51 51
52KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent, 52KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent,
53 const char* name) 53 const char* name)
54 : KOEditorGeneral( parent, name) 54 : KOEditorGeneral( parent, name)
55{ 55{
56} 56}
57 57
58KOEditorGeneralTodo::~KOEditorGeneralTodo() 58KOEditorGeneralTodo::~KOEditorGeneralTodo()
59{ 59{
60} 60}
61 61
62void KOEditorGeneralTodo::finishSetup() 62void KOEditorGeneralTodo::finishSetup()
63{ 63{
64 64
65// QWidget::setTabOrder(mSummaryEdit, mLocationEdit); 65// QWidget::setTabOrder(mSummaryEdit, mLocationEdit);
66// QWidget::setTabOrder(mLocationEdit, mDueCheck); 66// QWidget::setTabOrder(mLocationEdit, mDueCheck);
67// QWidget::setTabOrder(mDueCheck, mDueDateEdit); 67// QWidget::setTabOrder(mDueCheck, mDueDateEdit);
68// QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit); 68// QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit);
69// QWidget::setTabOrder(mDueTimeEdit, mStartCheck); 69// QWidget::setTabOrder(mDueTimeEdit, mStartCheck);
70// QWidget::setTabOrder(mStartCheck, mStartDateEdit); 70// QWidget::setTabOrder(mStartCheck, mStartDateEdit);
71// QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit); 71// QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit);
72// QWidget::setTabOrder(mStartTimeEdit, mTimeButton); 72// QWidget::setTabOrder(mStartTimeEdit, mTimeButton);
73// QWidget::setTabOrder(mTimeButton, mCompletedCombo); 73// QWidget::setTabOrder(mTimeButton, mCompletedCombo);
74// QWidget::setTabOrder(mCompletedCombo, mPriorityCombo); 74// QWidget::setTabOrder(mCompletedCombo, mPriorityCombo);
75// QWidget::setTabOrder(mPriorityCombo, mAlarmButton); 75// QWidget::setTabOrder(mPriorityCombo, mAlarmButton);
76// QWidget::setTabOrder(mAlarmButton, mCategoriesButton); 76// QWidget::setTabOrder(mAlarmButton, mCategoriesButton);
77// QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo); 77// QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo);
78// QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit); 78// QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit);
79 mSummaryEdit->load(KOLocationBox::SUMMARYTODO); 79 mSummaryEdit->load(KOLocationBox::SUMMARYTODO);
80 mSummaryEdit->setFocus(); 80 mSummaryEdit->setFocus();
81} 81}
82 82
83void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout) 83void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout)
84{ 84{
85 QBoxLayout *timeLayout = new QVBoxLayout(topLayout); 85 QBoxLayout *timeLayout = new QVBoxLayout(topLayout);
86 86
87 QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, 87 QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal,
88 i18n("Date && Time"),parent); 88 i18n("Date && Time"),parent);
89 timeLayout->addWidget(timeGroupBox); 89 timeLayout->addWidget(timeGroupBox);
90 timeGroupBox->layout()->setSpacing( 0 ); 90 timeGroupBox->layout()->setSpacing( 0 );
91 timeGroupBox->layout()->setMargin( 5 ); 91 timeGroupBox->layout()->setMargin( 5 );
92 QFrame *timeBoxFrame = new QFrame(timeGroupBox); 92 QFrame *timeBoxFrame = new QFrame(timeGroupBox);
93 93
94 QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3); 94 QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3);
95 layoutTimeBox->setSpacing(topLayout->spacing()); 95 layoutTimeBox->setSpacing(topLayout->spacing());
96 layoutTimeBox->setColStretch( 1, 1 ); 96 layoutTimeBox->setColStretch( 1, 1 );
97 97
98 mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame); 98 mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame);
99 layoutTimeBox->addWidget(mDueCheck,0,0); 99 layoutTimeBox->addWidget(mDueCheck,0,0);
100 connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool))); 100 connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool)));
101 connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm())); 101 connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm()));
102 102
103 103
104 mDueDateEdit = new KDateEdit(timeBoxFrame); 104 mDueDateEdit = new KDateEdit(timeBoxFrame);
105 layoutTimeBox->addWidget(mDueDateEdit,0,1); 105 layoutTimeBox->addWidget(mDueDateEdit,0,1);
106 106
107 mDueTimeEdit = new KOTimeEdit(timeBoxFrame); 107 mDueTimeEdit = new KOTimeEdit(timeBoxFrame);
108 layoutTimeBox->addWidget(mDueTimeEdit,0,2); 108 layoutTimeBox->addWidget(mDueTimeEdit,0,2);
109 109
110 110
111 mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame); 111 mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame);
112 layoutTimeBox->addWidget(mStartCheck,1,0); 112 layoutTimeBox->addWidget(mStartCheck,1,0);
113 connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool))); 113 connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool)));
114 114
115 mStartDateEdit = new KDateEdit(timeBoxFrame); 115 mStartDateEdit = new KDateEdit(timeBoxFrame);
116 layoutTimeBox->addWidget(mStartDateEdit,1,1); 116 layoutTimeBox->addWidget(mStartDateEdit,1,1);
117 117
118 mStartTimeEdit = new KOTimeEdit(timeBoxFrame); 118 mStartTimeEdit = new KOTimeEdit(timeBoxFrame);
119 layoutTimeBox->addWidget(mStartTimeEdit,1,2); 119 layoutTimeBox->addWidget(mStartTimeEdit,1,2);
120 120
121 121
122 mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame); 122 mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame);
123 layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1); 123 layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1);
124 124
125 connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool))); 125 connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool)));
126 126
127 // some more layouting 127 // some more layouting
128 //layoutTimeBox->setColStretch(3,1); 128 //layoutTimeBox->setColStretch(3,1);
129} 129}
130 130
131 131
132void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout) 132void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout)
133{ 133{
134 mCompletedCombo = new QComboBox(parent); 134 mCompletedCombo = new QComboBox(parent);
135 // xgettext:no-c-format 135 // xgettext:no-c-format
136 mCompletedCombo->insertItem(i18n(" 0 %")); 136 mCompletedCombo->insertItem(i18n(" 0 %"));
137 // xgettext:no-c-format 137 // xgettext:no-c-format
138 mCompletedCombo->insertItem(i18n(" 20 %")); 138 mCompletedCombo->insertItem(i18n(" 20 %"));
139 // xgettext:no-c-format 139 // xgettext:no-c-format
140 mCompletedCombo->insertItem(i18n(" 40 %")); 140 mCompletedCombo->insertItem(i18n(" 40 %"));
141 // xgettext:no-c-format 141 // xgettext:no-c-format
142 mCompletedCombo->insertItem(i18n(" 60 %")); 142 mCompletedCombo->insertItem(i18n(" 60 %"));
143 // xgettext:no-c-format 143 // xgettext:no-c-format
144 mCompletedCombo->insertItem(i18n(" 80 %")); 144 mCompletedCombo->insertItem(i18n(" 80 %"));
145 // xgettext:no-c-format 145 // xgettext:no-c-format
146 mCompletedCombo->insertItem(i18n("100 %")); 146 mCompletedCombo->insertItem(i18n("100 %"));
147 connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int))); 147 connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int)));
148 topLayout->addWidget(mCompletedCombo); 148 topLayout->addWidget(mCompletedCombo);
149 149
150 mCompletedLabel = new QLabel(i18n("completed"),parent); 150 mCompletedLabel = new QLabel(i18n("completed"),parent);
151 topLayout->addWidget(mCompletedLabel); 151 topLayout->addWidget(mCompletedLabel);
152} 152}
153 153
154void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout) 154void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout)
155{ 155{
156 156
157 QHBox* h = new QHBox ( parent ); 157 QHBox* h = new QHBox ( parent );
158 topLayout->addWidget( h ); 158 topLayout->addWidget( h );
159 QLabel *priorityLabel = new QLabel(i18n("Priority:"), h); 159 QLabel *priorityLabel = new QLabel(i18n("Priority:"), h);
160 // topLayout->addWidget(priorityLabel); 160 // topLayout->addWidget(priorityLabel);
161 161
162 mPriorityCombo = new QComboBox( h ); 162 mPriorityCombo = new QComboBox( h );
163 mPriorityCombo->insertItem(i18n("1 (high)")); 163 mPriorityCombo->insertItem(i18n("1 (high)"));
164 mPriorityCombo->insertItem(i18n("2")); 164 mPriorityCombo->insertItem(i18n("2"));
165 mPriorityCombo->insertItem(i18n("3")); 165 mPriorityCombo->insertItem(i18n("3"));
166 mPriorityCombo->insertItem(i18n("4")); 166 mPriorityCombo->insertItem(i18n("4"));
167 mPriorityCombo->insertItem(i18n("5 (low)")); 167 mPriorityCombo->insertItem(i18n("5 (low)"));
168 //topLayout->addWidget(mPriorityCombo); 168 //topLayout->addWidget(mPriorityCombo);
169} 169}
170 170
171void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout) 171void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout)
172{ 172{
173 QBoxLayout *statusLayout = new QHBoxLayout(topLayout); 173 QBoxLayout *statusLayout = new QHBoxLayout(topLayout);
174 174
175 initCompletion( parent, statusLayout ); 175 initCompletion( parent, statusLayout );
176 176
177 statusLayout->addStretch( 1 ); 177 statusLayout->addStretch( 1 );
178 178
179 initPriority( parent, statusLayout ); 179 initPriority( parent, statusLayout );
180} 180}
181 181
182void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) 182void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay)
183{ 183{
184 184
185 mSummaryEdit->load(KOLocationBox::SUMMARYTODO); 185 mSummaryEdit->load(KOLocationBox::SUMMARYTODO);
186 mLocationEdit->load(KOLocationBox::LOCATION); 186 mLocationEdit->load(KOLocationBox::LOCATION);
187 KOEditorGeneral::setDefaults(allDay); 187 KOEditorGeneral::setDefaults(allDay);
188 188
189 mTimeButton->setChecked( !allDay ); 189 mTimeButton->setChecked( !allDay );
190 if(mTimeButton->isChecked()) { 190 if(mTimeButton->isChecked()) {
191 mTimeButton->setEnabled(true); 191 mTimeButton->setEnabled(true);
192 } 192 }
193 else { 193 else {
194 mTimeButton->setEnabled(false); 194 mTimeButton->setEnabled(false);
195 } 195 }
196 196
197 enableTimeEdits( !allDay ); 197 enableTimeEdits( !allDay );
198 198 if ( due.isValid() ) {
199 mDueCheck->setChecked(false); 199 mDueCheck->setChecked(true);
200 enableDueEdit(false); 200 enableDueEdit(true);
201 } else {
202 mDueCheck->setChecked(false);
203 enableDueEdit(false);
204 due = QDateTime::currentDateTime().addDays(7);
205 }
201 206
202 alarmDisable(true); 207 alarmDisable(true);
203 208
204 mStartCheck->setChecked(false); 209 mStartCheck->setChecked(false);
205 enableStartEdit(false); 210 enableStartEdit(false);
206 211
207 mDueDateEdit->setDate(due.date()); 212 mDueDateEdit->setDate(due.date());
208 mDueTimeEdit->setTime(due.time()); 213 mDueTimeEdit->setTime(due.time());
209 214 due = due.addDays(-7);
210 mStartDateEdit->setDate(QDate::currentDate()); 215 mStartDateEdit->setDate(due.date());
211 mStartTimeEdit->setTime(QTime::currentTime()); 216 mStartTimeEdit->setTime(due.time());
212 217
213 mPriorityCombo->setCurrentItem(2); 218 mPriorityCombo->setCurrentItem(2);
214 mCompletedLabel->setText(i18n("completed"));; 219 mCompletedLabel->setText(i18n("completed"));;
215 mCompletedCombo->setCurrentItem(0); 220 mCompletedCombo->setCurrentItem(0);
216} 221}
217 222
218void KOEditorGeneralTodo::readTodo(Todo *todo) 223void KOEditorGeneralTodo::readTodo(Todo *todo)
219{ 224{
220 225
221 mSummaryEdit->load(KOLocationBox::SUMMARYTODO); 226 mSummaryEdit->load(KOLocationBox::SUMMARYTODO);
222 mLocationEdit->load(KOLocationBox::LOCATION); 227 mLocationEdit->load(KOLocationBox::LOCATION);
223 KOEditorGeneral::readIncidence(todo); 228 KOEditorGeneral::readIncidence(todo);
224 229
225 QDateTime dueDT; 230 QDateTime dueDT;
226 231
227 if (todo->hasDueDate()) { 232 if (todo->hasDueDate()) {
228 enableAlarmEdit(true); 233 enableAlarmEdit(true);
229 dueDT = todo->dtDue(); 234 dueDT = todo->dtDue();
230 mDueDateEdit->setDate(todo->dtDue().date()); 235 mDueDateEdit->setDate(todo->dtDue().date());
231 mDueTimeEdit->setTime(todo->dtDue().time()); 236 mDueTimeEdit->setTime(todo->dtDue().time());
232 mDueCheck->setChecked(true); 237 mDueCheck->setChecked(true);
233 } else { 238 } else {
234 alarmDisable(true); 239 alarmDisable(true);
235 mDueDateEdit->setEnabled(false); 240 mDueDateEdit->setEnabled(false);
236 mDueTimeEdit->setEnabled(false); 241 mDueTimeEdit->setEnabled(false);
237 mDueDateEdit->setDate(QDate::currentDate()); 242 mDueDateEdit->setDate(QDate::currentDate());
238 mDueTimeEdit->setTime(QTime::currentTime()); 243 mDueTimeEdit->setTime(QTime::currentTime());
239 mDueCheck->setChecked(false); 244 mDueCheck->setChecked(false);
240 } 245 }
241 246
242 if (todo->hasStartDate()) { 247 if (todo->hasStartDate()) {
243 mStartDateEdit->setDate(todo->dtStart().date()); 248 mStartDateEdit->setDate(todo->dtStart().date());
244 mStartTimeEdit->setTime(todo->dtStart().time()); 249 mStartTimeEdit->setTime(todo->dtStart().time());
245 mStartCheck->setChecked(true); 250 mStartCheck->setChecked(true);
246 } else { 251 } else {
247 mStartDateEdit->setEnabled(false); 252 mStartDateEdit->setEnabled(false);
248 mStartTimeEdit->setEnabled(false); 253 mStartTimeEdit->setEnabled(false);
249 mStartDateEdit->setDate(QDate::currentDate()); 254 mStartDateEdit->setDate(QDate::currentDate());
250 mStartTimeEdit->setTime(QTime::currentTime()); 255 mStartTimeEdit->setTime(QTime::currentTime());
251 mStartCheck->setChecked(false); 256 mStartCheck->setChecked(false);
252 } 257 }
253 258
254 mTimeButton->setChecked( !todo->doesFloat() ); 259 mTimeButton->setChecked( !todo->doesFloat() );
255 260
256 mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); 261 mCompletedCombo->setCurrentItem(todo->percentComplete() / 20);
257 if (todo->isCompleted() && todo->hasCompletedDate()) { 262 if (todo->isCompleted() && todo->hasCompletedDate()) {
258 mCompleted = todo->completed(); 263 mCompleted = todo->completed();
259 } 264 }
260 setCompletedDate(); 265 setCompletedDate();
261 266
262 mPriorityCombo->setCurrentItem(todo->priority()-1); 267 mPriorityCombo->setCurrentItem(todo->priority()-1);
263} 268}
264 269
265void KOEditorGeneralTodo::writeTodo(Todo *todo) 270void KOEditorGeneralTodo::writeTodo(Todo *todo)
266{ 271{
267 KOEditorGeneral::writeIncidence(todo); 272 KOEditorGeneral::writeIncidence(todo);
268 273
269 // temp. until something better happens. 274 // temp. until something better happens.
270 QString tmpStr; 275 QString tmpStr;
271 276
272 todo->setHasDueDate(mDueCheck->isChecked()); 277 todo->setHasDueDate(mDueCheck->isChecked());
273 todo->setHasStartDate(mStartCheck->isChecked()); 278 todo->setHasStartDate(mStartCheck->isChecked());
274 279
275 QDate tmpDate; 280 QDate tmpDate;
276 QTime tmpTime; 281 QTime tmpTime;
277 QDateTime tmpDT; 282 QDateTime tmpDT;
278 if ( mTimeButton->isChecked() ) { 283 if ( mTimeButton->isChecked() ) {
279 todo->setFloats(false); 284 todo->setFloats(false);
280 285
281 // set due date/time 286 // set due date/time
282 tmpDate = mDueDateEdit->date(); 287 tmpDate = mDueDateEdit->date();
283 tmpTime = mDueTimeEdit->getTime(); 288 tmpTime = mDueTimeEdit->getTime();
284 tmpDT.setDate(tmpDate); 289 tmpDT.setDate(tmpDate);
285 tmpDT.setTime(tmpTime); 290 tmpDT.setTime(tmpTime);
286 todo->setDtDue(tmpDT); 291 todo->setDtDue(tmpDT);
287 292
288 // set start date/time 293 // set start date/time
289 tmpDate = mStartDateEdit->date(); 294 tmpDate = mStartDateEdit->date();
290 tmpTime = mStartTimeEdit->getTime(); 295 tmpTime = mStartTimeEdit->getTime();
291 tmpDT.setDate(tmpDate); 296 tmpDT.setDate(tmpDate);
292 tmpDT.setTime(tmpTime); 297 tmpDT.setTime(tmpTime);
293 todo->setDtStart(tmpDT); 298 todo->setDtStart(tmpDT);
294 } else { 299 } else {
295 todo->setFloats(true); 300 todo->setFloats(true);
296 301
297 // need to change this. 302 // need to change this.
298 tmpDate = mDueDateEdit->date(); 303 tmpDate = mDueDateEdit->date();
299 tmpTime.setHMS(0,0,0); 304 tmpTime.setHMS(0,0,0);
300 tmpDT.setDate(tmpDate); 305 tmpDT.setDate(tmpDate);
301 tmpDT.setTime(tmpTime); 306 tmpDT.setTime(tmpTime);
302 todo->setDtDue(tmpDT); 307 todo->setDtDue(tmpDT);
303 308
304 tmpDate = mStartDateEdit->date(); 309 tmpDate = mStartDateEdit->date();
305 tmpTime.setHMS(0,0,0); 310 tmpTime.setHMS(0,0,0);
306 tmpDT.setDate(tmpDate); 311 tmpDT.setDate(tmpDate);
307 tmpDT.setTime(tmpTime); 312 tmpDT.setTime(tmpTime);
308 todo->setDtStart(tmpDT); 313 todo->setDtStart(tmpDT);
309 } 314 }
310 315
311 todo->setPriority(mPriorityCombo->currentItem()+1); 316 todo->setPriority(mPriorityCombo->currentItem()+1);
312 317
313 // set completion state 318 // set completion state
314 todo->setPercentComplete(mCompletedCombo->currentItem() * 20); 319 todo->setPercentComplete(mCompletedCombo->currentItem() * 20);
315 320
316 if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { 321 if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) {
317 todo->setCompleted(mCompleted); 322 todo->setCompleted(mCompleted);
318 } 323 }
319 mSummaryEdit->save(KOLocationBox::SUMMARYTODO); 324 mSummaryEdit->save(KOLocationBox::SUMMARYTODO);
320} 325}
321 326
322void KOEditorGeneralTodo::enableDueEdit(bool enable) 327void KOEditorGeneralTodo::enableDueEdit(bool enable)
323{ 328{
324 mDueDateEdit->setEnabled( enable ); 329 mDueDateEdit->setEnabled( enable );
325 330
326 if(mDueCheck->isChecked() || mStartCheck->isChecked()) { 331 if(mDueCheck->isChecked() || mStartCheck->isChecked()) {
327 mTimeButton->setEnabled(true); 332 mTimeButton->setEnabled(true);
328 } 333 }
329 else { 334 else {
330 mTimeButton->setEnabled(false); 335 mTimeButton->setEnabled(false);
331 mTimeButton->setChecked(false); 336 mTimeButton->setChecked(false);
332 } 337 }
333 338
334 if (enable) { 339 if (enable) {
335 mDueTimeEdit->setEnabled( mTimeButton->isChecked() ); 340 mDueTimeEdit->setEnabled( mTimeButton->isChecked() );
336 } else { 341 } else {
337 mDueTimeEdit->setEnabled( false ); 342 mDueTimeEdit->setEnabled( false );
338 } 343 }
339} 344}
340 345
341void KOEditorGeneralTodo::enableStartEdit( bool enable ) 346void KOEditorGeneralTodo::enableStartEdit( bool enable )
342{ 347{
343 mStartDateEdit->setEnabled( enable ); 348 mStartDateEdit->setEnabled( enable );
344 349
345 if(mDueCheck->isChecked() || mStartCheck->isChecked()) { 350 if(mDueCheck->isChecked() || mStartCheck->isChecked()) {
346 mTimeButton->setEnabled(true); 351 mTimeButton->setEnabled(true);
347 } 352 }
348 else { 353 else {
349 mTimeButton->setEnabled(false); 354 mTimeButton->setEnabled(false);
350 mTimeButton->setChecked(false); 355 mTimeButton->setChecked(false);
351 } 356 }
352 357
353 if (enable) { 358 if (enable) {
354 mStartTimeEdit->setEnabled( mTimeButton->isChecked() ); 359 mStartTimeEdit->setEnabled( mTimeButton->isChecked() );
355 } else { 360 } else {
356 mStartTimeEdit->setEnabled( false ); 361 mStartTimeEdit->setEnabled( false );
357 } 362 }
358} 363}
359 364
360void KOEditorGeneralTodo::enableTimeEdits(bool enable) 365void KOEditorGeneralTodo::enableTimeEdits(bool enable)
361{ 366{
362 if(mStartCheck->isChecked()) { 367 if(mStartCheck->isChecked()) {
363 mStartTimeEdit->setEnabled( enable ); 368 mStartTimeEdit->setEnabled( enable );
364 } 369 }
365 if(mDueCheck->isChecked()) { 370 if(mDueCheck->isChecked()) {
366 mDueTimeEdit->setEnabled( enable ); 371 mDueTimeEdit->setEnabled( enable );
367 } 372 }
368} 373}
369 374
370void KOEditorGeneralTodo::showAlarm() 375void KOEditorGeneralTodo::showAlarm()
371{ 376{
372 if ( mDueCheck->isChecked() ) { 377 if ( mDueCheck->isChecked() ) {
373 alarmDisable(false); 378 alarmDisable(false);
374 } 379 }
375 else { 380 else {
376 alarmDisable(true); 381 alarmDisable(true);
377 } 382 }
378} 383}
379 384
380bool KOEditorGeneralTodo::validateInput() 385bool KOEditorGeneralTodo::validateInput()
381{ 386{
382 if (mDueCheck->isChecked()) { 387 if (mDueCheck->isChecked()) {
383 if (!mDueDateEdit->inputIsValid()) { 388 if (!mDueDateEdit->inputIsValid()) {
384 KMessageBox::sorry(0,i18n("Please specify a valid due date.")); 389 KMessageBox::sorry(0,i18n("Please specify a valid due date."));
385 return false; 390 return false;
386 } 391 }
387 } 392 }
388 393
389 if (mStartCheck->isChecked()) { 394 if (mStartCheck->isChecked()) {
390 if (!mStartDateEdit->inputIsValid()) { 395 if (!mStartDateEdit->inputIsValid()) {
391 KMessageBox::sorry(0,i18n("Please specify a valid start date.")); 396 KMessageBox::sorry(0,i18n("Please specify a valid start date."));
392 return false; 397 return false;
393 } 398 }
394 } 399 }
395 400
396 if (mStartCheck->isChecked() && mDueCheck->isChecked()) { 401 if (mStartCheck->isChecked() && mDueCheck->isChecked()) {
397 QDateTime startDate; 402 QDateTime startDate;
398 QDateTime dueDate; 403 QDateTime dueDate;
399 startDate.setDate(mStartDateEdit->date()); 404 startDate.setDate(mStartDateEdit->date());
400 dueDate.setDate(mDueDateEdit->date()); 405 dueDate.setDate(mDueDateEdit->date());
401 if (mTimeButton->isChecked()) { 406 if (mTimeButton->isChecked()) {
402 startDate.setTime(mStartTimeEdit->getTime()); 407 startDate.setTime(mStartTimeEdit->getTime());
403 dueDate.setTime(mDueTimeEdit->getTime()); 408 dueDate.setTime(mDueTimeEdit->getTime());
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index e8d5ab1..a88276e 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -118,388 +118,393 @@ void KOViewManager::writeSettings(KConfig *config)
118 } 118 }
119 if (mTimeSpanView) { 119 if (mTimeSpanView) {
120 mTimeSpanView->writeSettings(config); 120 mTimeSpanView->writeSettings(config);
121 } 121 }
122 if (mListView) { 122 if (mListView) {
123 mListView->writeSettings(config); 123 mListView->writeSettings(config);
124 } 124 }
125 if (mTodoView) { 125 if (mTodoView) {
126 mTodoView->saveLayout(config,"Todo View"); 126 mTodoView->saveLayout(config,"Todo View");
127 } 127 }
128} 128}
129 129
130void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 130void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
131{ 131{
132 132
133 //mFlagShowNextxDays = false; 133 //mFlagShowNextxDays = false;
134 //if(view == mCurrentView) return; 134 //if(view == mCurrentView) return;
135 if ( view == 0 ) { 135 if ( view == 0 ) {
136 view = mCurrentView; 136 view = mCurrentView;
137 if ( view == 0 ) 137 if ( view == 0 )
138 return; 138 return;
139 } 139 }
140 bool full = fullScreen; 140 bool full = fullScreen;
141 if(view == mCurrentView && view != mWhatsNextView ) { 141 if(view == mCurrentView && view != mWhatsNextView ) {
142 if ( mCurrentAgendaView < 0 ) 142 if ( mCurrentAgendaView < 0 )
143 return; 143 return;
144 full = mMainView->leftFrame()->isVisible(); 144 full = mMainView->leftFrame()->isVisible();
145 } else { 145 } else {
146 mCurrentView = view; 146 mCurrentView = view;
147 147
148 // bool full = fullScreen; 148 // bool full = fullScreen;
149 bool isFull = !mMainView->leftFrame()->isVisible(); 149 bool isFull = !mMainView->leftFrame()->isVisible();
150 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 150 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
151 full = true; 151 full = true;
152 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 152 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
153 full = false; 153 full = false;
154 } 154 }
155 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 155 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
156 //raiseCurrentView( full ); 156 //raiseCurrentView( full );
157 mMainView->processIncidenceSelection( 0 ); 157 mMainView->processIncidenceSelection( 0 );
158 mMainView->updateView(); 158 mMainView->updateView();
159 raiseCurrentView( full ); 159 raiseCurrentView( full );
160 mMainView->adaptNavigationUnits(); 160 mMainView->adaptNavigationUnits();
161} 161}
162 162
163void KOViewManager::raiseCurrentView( bool fullScreen ) 163void KOViewManager::raiseCurrentView( bool fullScreen )
164{ 164{
165 //qDebug("raiseCurrentView "); 165 //qDebug("raiseCurrentView ");
166 mCurrentAgendaView = 0; 166 mCurrentAgendaView = 0;
167 int wid = mMainView->width() ; 167 int wid = mMainView->width() ;
168 int hei = mMainView->height(); 168 int hei = mMainView->height();
169 if ( mCurrentView == mMonthView ) { 169 if ( mCurrentView == mMonthView ) {
170 mMainView->navigatorBar()->show(); 170 mMainView->navigatorBar()->show();
171 hei -= mMainView->navigatorBar()->sizeHint().height(); 171 hei -= mMainView->navigatorBar()->sizeHint().height();
172 //mMainView->navigatorBar()->hide(); 172 //mMainView->navigatorBar()->hide();
173 } else { 173 } else {
174 mMainView->navigatorBar()->hide(); 174 mMainView->navigatorBar()->hide();
175 } 175 }
176 if ( fullScreen ) { 176 if ( fullScreen ) {
177 mMainView->leftFrame()->hide(); 177 mMainView->leftFrame()->hide();
178 } else { 178 } else {
179 mMainView->leftFrame()->show(); 179 mMainView->leftFrame()->show();
180 if ( KOPrefs::instance()->mVerticalScreen ) 180 if ( KOPrefs::instance()->mVerticalScreen )
181 hei -= mMainView->leftFrame()->height(); 181 hei -= mMainView->leftFrame()->height();
182 else 182 else
183 wid -= mMainView->leftFrame()->width(); 183 wid -= mMainView->leftFrame()->width();
184 } 184 }
185 emit signalFullScreen( !fullScreen ); 185 emit signalFullScreen( !fullScreen );
186 if ( globalFlagBlockAgenda == 5 ) { 186 if ( globalFlagBlockAgenda == 5 ) {
187 globalFlagBlockAgenda = 4; 187 globalFlagBlockAgenda = 4;
188 globalFlagBlockAgendaItemPaint = 1; 188 globalFlagBlockAgendaItemPaint = 1;
189 } 189 }
190 mMainView->viewStack()->raiseWidget(mCurrentView); 190 mMainView->viewStack()->raiseWidget(mCurrentView);
191 if ( globalFlagBlockAgenda == 4 ) { 191 if ( globalFlagBlockAgenda == 4 ) {
192 if ( mCurrentView == mAgendaView ) { 192 if ( mCurrentView == mAgendaView ) {
193 //globalFlagBlockAgenda =1 ; 193 //globalFlagBlockAgenda =1 ;
194 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 194 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
195 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 195 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
196 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 196 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
197 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 197 mAgendaView->setStartHour( QTime::currentTime ().hour() );
198 qApp->processEvents(); 198 qApp->processEvents();
199 //qDebug("qApp->processEvents() "); 199 //qDebug("qApp->processEvents() ");
200 globalFlagBlockAgenda = 0; 200 globalFlagBlockAgenda = 0;
201 mAgendaView->repaintAgenda(); 201 mAgendaView->repaintAgenda();
202 202
203 } 203 }
204 globalFlagBlockAgenda = 0; 204 globalFlagBlockAgenda = 0;
205 } 205 }
206 emit signalAgendaView( mCurrentView == mAgendaView ); 206 emit signalAgendaView( mCurrentView == mAgendaView );
207 //qDebug("raiseCurrentView ende "); 207 //qDebug("raiseCurrentView ende ");
208 208
209} 209}
210 210
211void KOViewManager::updateView() 211void KOViewManager::updateView()
212{ 212{
213 // qDebug("KOViewManager::updateView() "); 213 // qDebug("KOViewManager::updateView() ");
214 // if we are updating mTodoView, we get endless recursion 214 // if we are updating mTodoView, we get endless recursion
215 if ( mTodoView == mCurrentView ) 215 if ( mTodoView == mCurrentView )
216 return; 216 return;
217 if ( mCurrentView ) mCurrentView->updateView(); 217 if ( mCurrentView ) mCurrentView->updateView();
218 218
219} 219}
220 220
221void KOViewManager::updateView(const QDate &start, const QDate &end) 221void KOViewManager::updateView(const QDate &start, const QDate &end)
222{ 222{
223 // kdDebug() << "KOViewManager::updateView()" << endl; 223 // kdDebug() << "KOViewManager::updateView()" << endl;
224 224
225 if (mCurrentView) mCurrentView->showDates(start, end); 225 if (mCurrentView) mCurrentView->showDates(start, end);
226 226
227 if (mTodoView) mTodoView->updateView(); 227 if (mTodoView) mTodoView->updateView();
228} 228}
229 229
230 230
231void KOViewManager::updateWNview() 231void KOViewManager::updateWNview()
232{ 232{
233 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 233 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
234 mWhatsNextView->updateView(); 234 mWhatsNextView->updateView();
235 235
236} 236}
237void KOViewManager::showWhatsNextView() 237void KOViewManager::showWhatsNextView()
238{ 238{
239 if (!mWhatsNextView) { 239 if (!mWhatsNextView) {
240 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 240 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
241 "KOViewManager::WhatsNextView"); 241 "KOViewManager::WhatsNextView");
242 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 242 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
243 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 243 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
244 addView(mWhatsNextView); 244 addView(mWhatsNextView);
245 connect(this, SIGNAL( printWNV() ), 245 connect(this, SIGNAL( printWNV() ),
246 mWhatsNextView, SLOT( printMe() ) ); 246 mWhatsNextView, SLOT( printMe() ) );
247 } 247 }
248 globalFlagBlockAgenda = 1; 248 globalFlagBlockAgenda = 1;
249 showView(mWhatsNextView, true ); 249 showView(mWhatsNextView, true );
250 //mWhatsNextView->updateView(); 250 //mWhatsNextView->updateView();
251 251
252} 252}
253 253
254void KOViewManager::showListView() 254void KOViewManager::showListView()
255{ 255{
256 if (!mListView) { 256 if (!mListView) {
257 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 257 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
258 addView(mListView); 258 addView(mListView);
259 259
260 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 260 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
261 mMainView, SLOT(showIncidence(Incidence *))); 261 mMainView, SLOT(showIncidence(Incidence *)));
262 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 262 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
263 mMainView, SLOT(editIncidence(Incidence *))); 263 mMainView, SLOT(editIncidence(Incidence *)));
264 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 264 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
265 mMainView, SLOT(deleteIncidence(Incidence *))); 265 mMainView, SLOT(deleteIncidence(Incidence *)));
266 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 266 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
267 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 267 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
268 connect( mListView, SIGNAL( signalNewEvent() ), 268 connect( mListView, SIGNAL( signalNewEvent() ),
269 mMainView, SLOT( newEvent() ) ); 269 mMainView, SLOT( newEvent() ) );
270 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 270 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
271 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 271 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
272 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 272 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
273 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 273 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
274 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 274 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
275 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 275 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
276 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 276 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
277 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 277 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
278 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 278 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
279 } 279 }
280 // bool temp = mFlagShowNextxDays; 280 // bool temp = mFlagShowNextxDays;
281 //globalFlagBlockPainting = true; 281 //globalFlagBlockPainting = true;
282 globalFlagBlockAgenda = 1; 282 globalFlagBlockAgenda = 1;
283 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 283 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
284 mMainView->setBlockShowDates( true ); 284 mMainView->setBlockShowDates( true );
285 mMainView->dateNavigator()->selectMonth(); 285 mMainView->dateNavigator()->selectMonth();
286 mMainView->setBlockShowDates( false ); 286 mMainView->setBlockShowDates( false );
287 } 287 }
288 showView(mListView, KOPrefs::instance()->mFullViewTodo); 288 showView(mListView, KOPrefs::instance()->mFullViewTodo);
289 //mFlagShowNextxDays = temp; 289 //mFlagShowNextxDays = temp;
290} 290}
291 291
292void KOViewManager::showAgendaView( bool fullScreen ) 292void KOViewManager::showAgendaView( bool fullScreen )
293{ 293{
294 294
295 mMainView->dialogManager()->hideSearchDialog(); 295 mMainView->dialogManager()->hideSearchDialog();
296 // qDebug("KOViewManager::showAgendaView "); 296 // qDebug("KOViewManager::showAgendaView ");
297 bool full; 297 bool full;
298 full = fullScreen; 298 full = fullScreen;
299 if (!mAgendaView) { 299 if (!mAgendaView) {
300 full = false; 300 full = false;
301 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 301 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
302 addView(mAgendaView); 302 addView(mAgendaView);
303#ifndef DESKTOP_VERSION 303#ifndef DESKTOP_VERSION
304 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 304 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
305#endif 305#endif
306 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 306 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
307 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 307 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
308 308
309 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 309 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
310
311
312
313 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
314 mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
310 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 315 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
311 mMainView, SLOT(newEvent(QDateTime))); 316 mMainView, SLOT(newEvent(QDateTime)));
312 // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 317 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
313 // mMainView, SLOT(newEvent(QDateTime,QDateTime))); 318 mMainView, SLOT(newEvent(QDateTime,QDateTime)));
314 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 319 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
315 mMainView, SLOT(newEvent(QDate))); 320 mMainView, SLOT(newEvent(QDate)));
316 321
317 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 322 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
318 mMainView, SLOT(editIncidence(Incidence *))); 323 mMainView, SLOT(editIncidence(Incidence *)));
319 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 324 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
320 mMainView, SLOT(showIncidence(Incidence *))); 325 mMainView, SLOT(showIncidence(Incidence *)));
321 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 326 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
322 mMainView, SLOT(deleteIncidence(Incidence *))); 327 mMainView, SLOT(deleteIncidence(Incidence *)));
323 328
324 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 329 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
325 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 330 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
326 331
327 connect(mAgendaView, SIGNAL( toggleExpand() ), 332 connect(mAgendaView, SIGNAL( toggleExpand() ),
328 mMainView, SLOT( toggleExpand() ) ); 333 mMainView, SLOT( toggleExpand() ) );
329 334
330 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), 335 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ),
331 mAgendaView, SLOT( setExpandedButton( bool ) ) ); 336 mAgendaView, SLOT( setExpandedButton( bool ) ) );
332 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 337 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
333 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 338 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
334 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 339 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
335 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 340 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
336 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 341 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
337 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 342 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
338 SLOT( updateTodo( Todo *, int ) ) ); 343 SLOT( updateTodo( Todo *, int ) ) );
339 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 344 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
340 mMainView, SIGNAL( todoModified( Todo *, int ))); 345 mMainView, SIGNAL( todoModified( Todo *, int )));
341 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 346 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
342 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 347 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
343 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 348 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
344 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 349 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
345 mAgendaView->readSettings(); 350 mAgendaView->readSettings();
346 mAgendaView->updateConfig(); 351 mAgendaView->updateConfig();
347 } 352 }
348 353
349 showView( mAgendaView, full); 354 showView( mAgendaView, full);
350 355
351} 356}
352 357
353void KOViewManager::showDayView() 358void KOViewManager::showDayView()
354{ 359{
355 mFlagShowNextxDays = false; 360 mFlagShowNextxDays = false;
356 globalFlagBlockLabel = 1; 361 globalFlagBlockLabel = 1;
357 globalFlagBlockAgenda = 1; 362 globalFlagBlockAgenda = 1;
358 if ( mCurrentAgendaView != 1 ) 363 if ( mCurrentAgendaView != 1 )
359 mCurrentAgendaView = -1; 364 mCurrentAgendaView = -1;
360 showAgendaView(); 365 showAgendaView();
361 qApp->processEvents(); 366 qApp->processEvents();
362 globalFlagBlockAgenda = 2; 367 globalFlagBlockAgenda = 2;
363 globalFlagBlockLabel = 0; 368 globalFlagBlockLabel = 0;
364 mMainView->dateNavigator()->selectDates( 1 ); 369 mMainView->dateNavigator()->selectDates( 1 );
365 mCurrentAgendaView = 1 ; 370 mCurrentAgendaView = 1 ;
366 371
367} 372}
368 373
369void KOViewManager::showWorkWeekView() 374void KOViewManager::showWorkWeekView()
370{ 375{
371 mFlagShowNextxDays = false; 376 mFlagShowNextxDays = false;
372 globalFlagBlockAgenda = 1; 377 globalFlagBlockAgenda = 1;
373 globalFlagBlockLabel = 1; 378 globalFlagBlockLabel = 1;
374 if ( mCurrentAgendaView != 5 ) 379 if ( mCurrentAgendaView != 5 )
375 mCurrentAgendaView = -1; 380 mCurrentAgendaView = -1;
376 showAgendaView(); 381 showAgendaView();
377 qApp->processEvents(); 382 qApp->processEvents();
378 globalFlagBlockAgenda = 2; 383 globalFlagBlockAgenda = 2;
379 globalFlagBlockLabel = 0; 384 globalFlagBlockLabel = 0;
380 mMainView->dateNavigator()->selectWorkWeek(); 385 mMainView->dateNavigator()->selectWorkWeek();
381 mCurrentAgendaView = 5 ; 386 mCurrentAgendaView = 5 ;
382 387
383} 388}
384 389
385void KOViewManager::showWeekView() 390void KOViewManager::showWeekView()
386{ 391{
387 /* 392 /*
388 globalFlagBlockAgenda = 2; 393 globalFlagBlockAgenda = 2;
389 qDebug("4globalFlagBlockAgenda = 2; "); 394 qDebug("4globalFlagBlockAgenda = 2; ");
390 //globalFlagBlockPainting = true; 395 //globalFlagBlockPainting = true;
391 mMainView->dateNavigator()->selectWeek(); 396 mMainView->dateNavigator()->selectWeek();
392 showAgendaView(); 397 showAgendaView();
393 */ 398 */
394 399
395 400
396 mFlagShowNextxDays = false; 401 mFlagShowNextxDays = false;
397 globalFlagBlockAgenda = 1; 402 globalFlagBlockAgenda = 1;
398 globalFlagBlockLabel = 1; 403 globalFlagBlockLabel = 1;
399 if ( mCurrentAgendaView != 7 ) 404 if ( mCurrentAgendaView != 7 )
400 mCurrentAgendaView = -1; 405 mCurrentAgendaView = -1;
401 showAgendaView(); 406 showAgendaView();
402 qApp->processEvents(); 407 qApp->processEvents();
403 globalFlagBlockAgenda = 2; 408 globalFlagBlockAgenda = 2;
404 globalFlagBlockLabel = 0; 409 globalFlagBlockLabel = 0;
405 mMainView->dateNavigator()->selectWeek(); 410 mMainView->dateNavigator()->selectWeek();
406 mCurrentAgendaView = 7 ; 411 mCurrentAgendaView = 7 ;
407} 412}
408 413
409void KOViewManager::showNextXView() 414void KOViewManager::showNextXView()
410{ 415{
411 416
412 globalFlagBlockAgenda = 1; 417 globalFlagBlockAgenda = 1;
413 if ( mCurrentAgendaView != 3 ) 418 if ( mCurrentAgendaView != 3 )
414 mCurrentAgendaView = -1; 419 mCurrentAgendaView = -1;
415 showAgendaView(KOPrefs::instance()->mFullViewMonth); 420 showAgendaView(KOPrefs::instance()->mFullViewMonth);
416 globalFlagBlockAgenda = 2; 421 globalFlagBlockAgenda = 2;
417 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 422 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
418 KOPrefs::instance()->mNextXDays ); 423 KOPrefs::instance()->mNextXDays );
419 mFlagShowNextxDays = true; 424 mFlagShowNextxDays = true;
420 mCurrentAgendaView = 3 ; 425 mCurrentAgendaView = 3 ;
421} 426}
422bool KOViewManager::showsNextDays() 427bool KOViewManager::showsNextDays()
423{ 428{
424 return mFlagShowNextxDays; 429 return mFlagShowNextxDays;
425} 430}
426void KOViewManager::showMonthView() 431void KOViewManager::showMonthView()
427{ 432{
428 if (!mMonthView) { 433 if (!mMonthView) {
429 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 434 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
430 435
431 addView(mMonthView); 436 addView(mMonthView);
432 // mMonthView->show(); 437 // mMonthView->show();
433 // SIGNALS/SLOTS FOR MONTH VIEW 438 // SIGNALS/SLOTS FOR MONTH VIEW
434 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 439 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
435 mMainView, SLOT(newEvent(QDateTime))); 440 mMainView, SLOT(newEvent(QDateTime)));
436 441
437 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 442 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
438 mMainView, SLOT(showIncidence(Incidence *))); 443 mMainView, SLOT(showIncidence(Incidence *)));
439 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 444 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
440 mMainView, SLOT(editIncidence(Incidence *))); 445 mMainView, SLOT(editIncidence(Incidence *)));
441 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 446 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
442 mMainView, SLOT(deleteIncidence(Incidence *))); 447 mMainView, SLOT(deleteIncidence(Incidence *)));
443 448
444 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 449 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
445 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 450 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
446 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 451 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
447 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 452 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
448 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 453 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
449 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 454 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
450 455
451 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 456 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
452 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 457 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
453 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 458 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
454 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 459 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
455 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 460 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
456 mMainView, SLOT ( selectWeekNum( int ) ) ); 461 mMainView, SLOT ( selectWeekNum( int ) ) );
457 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 462 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
458 mMainView, SLOT ( showDay( QDate ) ) ); 463 mMainView, SLOT ( showDay( QDate ) ) );
459 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 464 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
460 connect( mMonthView, SIGNAL(nextMonth() ), 465 connect( mMonthView, SIGNAL(nextMonth() ),
461 mMainView->navigatorBar(), SIGNAL(goNextMonth() ) ); 466 mMainView->navigatorBar(), SIGNAL(goNextMonth() ) );
462 connect( mMonthView, SIGNAL(prevMonth() ), 467 connect( mMonthView, SIGNAL(prevMonth() ),
463 mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) ); 468 mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) );
464 mMonthView->updateConfig(); 469 mMonthView->updateConfig();
465 } 470 }
466 471
467 globalFlagBlockAgenda = 1; 472 globalFlagBlockAgenda = 1;
468 //mFlagShowNextxDays = false; 473 //mFlagShowNextxDays = false;
469 // if(mMonthView == mCurrentView) return; 474 // if(mMonthView == mCurrentView) return;
470 mMainView->dateNavigator()->selectMonth(); 475 mMainView->dateNavigator()->selectMonth();
471 // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); 476 // DateList tmpList = mMainView->dateNavigator()->selectedDates( );
472 //mMonthView->showDates(tmpList.first(), tmpList.last()); 477 //mMonthView->showDates(tmpList.first(), tmpList.last());
473 478
474 showView(mMonthView, true ); 479 showView(mMonthView, true );
475 480
476} 481}
477 482
478void KOViewManager::showTodoView() 483void KOViewManager::showTodoView()
479{ 484{
480 //mFlagShowNextxDays = false; 485 //mFlagShowNextxDays = false;
481 if ( !mTodoView ) { 486 if ( !mTodoView ) {
482 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 487 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
483 "KOViewManager::TodoView" ); 488 "KOViewManager::TodoView" );
484 489
485 addView( mTodoView ); 490 addView( mTodoView );
486 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 491 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
487 492
488 // SIGNALS/SLOTS FOR TODO VIEW 493 // SIGNALS/SLOTS FOR TODO VIEW
489 connect( mTodoView, SIGNAL( newTodoSignal() ), 494 connect( mTodoView, SIGNAL( newTodoSignal() ),
490 mMainView, SLOT( newTodo() ) ); 495 mMainView, SLOT( newTodo() ) );
491 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 496 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
492 mMainView, SLOT( newSubTodo( Todo *) ) ); 497 mMainView, SLOT( newSubTodo( Todo *) ) );
493 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 498 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
494 mMainView, SLOT( showTodo( Todo * ) ) ); 499 mMainView, SLOT( showTodo( Todo * ) ) );
495 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 500 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
496 mMainView, SLOT( editTodo( Todo * ) ) ); 501 mMainView, SLOT( editTodo( Todo * ) ) );
497 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 502 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
498 mMainView, SLOT( deleteTodo( Todo * ) ) ); 503 mMainView, SLOT( deleteTodo( Todo * ) ) );
499 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 504 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
500 mMainView, SLOT( purgeCompleted() ) ); 505 mMainView, SLOT( purgeCompleted() ) );
501 506
502 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 507 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
503 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 508 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
504 509
505 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 510 connect( mMainView, SIGNAL( configChanged() ), mTodoView,