summaryrefslogtreecommitdiffabout
path: root/korganizer/koagendaview.cpp
Unidiff
Diffstat (limited to 'korganizer/koagendaview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 5a63b35..f811fba 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -414,385 +414,385 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
414 int heibut = mExpandButton->sizeHint().height()+4; 414 int heibut = mExpandButton->sizeHint().height()+4;
415 if ( heibut > widebut ) 415 if ( heibut > widebut )
416 widebut = heibut ; 416 widebut = heibut ;
417 417
418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
419 // QSizePolicy::Fixed ) ); 419 // QSizePolicy::Fixed ) );
420 mExpandButton->setFixedSize( widebut, widebut); 420 mExpandButton->setFixedSize( widebut, widebut);
421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
422 mExpandButton->setFocusPolicy(NoFocus); 422 mExpandButton->setFocusPolicy(NoFocus);
423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
424 mAllDayAgenda->setFocusPolicy(NoFocus); 424 mAllDayAgenda->setFocusPolicy(NoFocus);
425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
426 426
427 // Create event context menu for all day agenda 427 // Create event context menu for all day agenda
428 //mAllDayAgendaPopup = eventPopup(); 428 //mAllDayAgendaPopup = eventPopup();
429 429
430 // Create agenda frame 430 // Create agenda frame
431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
432 // QHBox *agendaFrame = new QHBox(splitterAgenda); 432 // QHBox *agendaFrame = new QHBox(splitterAgenda);
433 433
434 // create event indicator bars 434 // create event indicator bars
435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
436#ifndef DESKTOP_VERSION 436#ifndef DESKTOP_VERSION
437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
438#endif 438#endif
439 mDayLabelsFrame = new QHBox(agendaFrame); 439 mDayLabelsFrame = new QHBox(agendaFrame);
440 //topLayout->addWidget(mDayLabelsFrame); 440 //topLayout->addWidget(mDayLabelsFrame);
441 mDayLabels = new QFrame (mDayLabelsFrame); 441 mDayLabels = new QFrame (mDayLabelsFrame);
442 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 442 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
444 agendaLayout->addWidget(mEventIndicatorTop,1,1); 444 agendaLayout->addWidget(mEventIndicatorTop,1,1);
445 445
446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
447 agendaFrame); 447 agendaFrame);
448 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 448 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
449 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 449 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
450 agendaLayout->addWidget(dummyAgendaRight,1,2); 450 agendaLayout->addWidget(dummyAgendaRight,1,2);
451 451
452 // Create time labels 452 // Create time labels
453 mTimeLabels = new TimeLabels(24,agendaFrame); 453 mTimeLabels = new TimeLabels(24,agendaFrame);
454 agendaLayout->addWidget(mTimeLabels,2,0); 454 agendaLayout->addWidget(mTimeLabels,2,0);
455 connect(mTimeLabels,SIGNAL( scaleChanged()), 455 connect(mTimeLabels,SIGNAL( scaleChanged()),
456 this,SLOT(updateConfig())); 456 this,SLOT(updateConfig()));
457 457
458 // Create agenda 458 // Create agenda
459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
461 agendaLayout->setColStretch(1,1); 461 agendaLayout->setColStretch(1,1);
462 mAgenda->setFocusPolicy(NoFocus); 462 mAgenda->setFocusPolicy(NoFocus);
463 // Create event context menu for agenda 463 // Create event context menu for agenda
464 mAllAgendaPopup = eventPopup(); 464 mAllAgendaPopup = eventPopup();
465 465
466#if 0 466#if 0
467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
468 i18n("Toggle Alarm"),mAgenda, 468 i18n("Toggle Alarm"),mAgenda,
469 SLOT(popupAlarm()),true); 469 SLOT(popupAlarm()),true);
470 470
471#endif 471#endif
472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
474 474
475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
477 477
478 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)), 478 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)),
479 this,SLOT(categoryChanged(Incidence *))); 479 this,SLOT(categoryChanged(Incidence *)));
480 480
481 481
482 mAgenda->setPopup( mAllAgendaPopup ); 482 mAgenda->setPopup( mAllAgendaPopup );
483 mAllDayAgenda->setPopup( mAllAgendaPopup ); 483 mAllDayAgenda->setPopup( mAllAgendaPopup );
484 // make connections between dependent widgets 484 // make connections between dependent widgets
485 mTimeLabels->setAgenda(mAgenda); 485 mTimeLabels->setAgenda(mAgenda);
486 486
487 // Update widgets to reflect user preferences 487 // Update widgets to reflect user preferences
488 // updateConfig(); 488 // updateConfig();
489 489
490 // createDayLabels(); 490 // createDayLabels();
491 491
492 // these blank widgets make the All Day Event box line up with the agenda 492 // these blank widgets make the All Day Event box line up with the agenda
493 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 493 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
494 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 494 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
495 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 495 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
496 496
497 // Scrolling 497 // Scrolling
498 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 498 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
499 mTimeLabels, SLOT(positionChanged())); 499 mTimeLabels, SLOT(positionChanged()));
500 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 500 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
501 SLOT(setContentsPos(int))); 501 SLOT(setContentsPos(int)));
502 502
503 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 503 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
504 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 504 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
505 505
506 // Create/Show/Edit/Delete Event 506 // Create/Show/Edit/Delete Event
507 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 507 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
508 SLOT(newEvent(int,int))); 508 SLOT(newEvent(int,int)));
509 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 509 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
510 SLOT(newTodo(int,int))); 510 SLOT(newTodo(int,int)));
511 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 511 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
512 SLOT(newEvent(int,int,int,int))); 512 SLOT(newEvent(int,int,int,int)));
513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
514 SLOT(newEventAllDay(int,int))); 514 SLOT(newEventAllDay(int,int)));
515 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 515 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
516 SLOT(newTodoAllDay(int,int))); 516 SLOT(newTodoAllDay(int,int)));
517 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 517 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
518 SLOT(newEventAllDay(int,int))); 518 SLOT(newEventAllDay(int,int)));
519 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 519 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
520 SLOT(newTimeSpanSelected(int,int,int,int))); 520 SLOT(newTimeSpanSelected(int,int,int,int)));
521 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 521 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
522 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 522 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
523 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 523 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
524 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 524 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
525 525
526 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 526 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
527 SIGNAL(editIncidenceSignal(Incidence *))); 527 SIGNAL(editIncidenceSignal(Incidence *)));
528 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 528 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
529 SIGNAL(editIncidenceSignal(Incidence *))); 529 SIGNAL(editIncidenceSignal(Incidence *)));
530 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 530 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
531 SIGNAL(showIncidenceSignal(Incidence *))); 531 SIGNAL(showIncidenceSignal(Incidence *)));
532 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 532 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
533 SIGNAL(showIncidenceSignal(Incidence *))); 533 SIGNAL(showIncidenceSignal(Incidence *)));
534 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 534 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
535 SIGNAL(deleteIncidenceSignal(Incidence *))); 535 SIGNAL(deleteIncidenceSignal(Incidence *)));
536 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 536 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
537 SIGNAL(deleteIncidenceSignal(Incidence *))); 537 SIGNAL(deleteIncidenceSignal(Incidence *)));
538 538
539 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 539 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
540 SLOT(updateEventDates(KOAgendaItem *, int ))); 540 SLOT(updateEventDates(KOAgendaItem *, int )));
541 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 541 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
542 SLOT(updateEventDates(KOAgendaItem *, int))); 542 SLOT(updateEventDates(KOAgendaItem *, int)));
543 543
544 // event indicator update 544 // event indicator update
545 connect(mAgenda,SIGNAL(lowerYChanged(int)), 545 connect(mAgenda,SIGNAL(lowerYChanged(int)),
546 SLOT(updateEventIndicatorTop(int))); 546 SLOT(updateEventIndicatorTop(int)));
547 connect(mAgenda,SIGNAL(upperYChanged(int)), 547 connect(mAgenda,SIGNAL(upperYChanged(int)),
548 SLOT(updateEventIndicatorBottom(int))); 548 SLOT(updateEventIndicatorBottom(int)));
549 // drag signals 549 // drag signals
550 /* 550 /*
551 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 551 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
552 SLOT(startDrag(Event *))); 552 SLOT(startDrag(Event *)));
553 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 553 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
554 SLOT(startDrag(Event *))); 554 SLOT(startDrag(Event *)));
555 */ 555 */
556 // synchronize selections 556 // synchronize selections
557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
558 mAllDayAgenda, SLOT( deselectItem() ) ); 558 mAllDayAgenda, SLOT( deselectItem() ) );
559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
560 mAgenda, SLOT( deselectItem() ) ); 560 mAgenda, SLOT( deselectItem() ) );
561 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 561 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
562 SIGNAL( incidenceSelected( Incidence * ) ) ); 562 SIGNAL( incidenceSelected( Incidence * ) ) );
563 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 563 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
564 SIGNAL( incidenceSelected( Incidence * ) ) ); 564 SIGNAL( incidenceSelected( Incidence * ) ) );
565 connect( mAgenda, SIGNAL( resizedSignal() ), 565 connect( mAgenda, SIGNAL( resizedSignal() ),
566 SLOT( updateConfig( ) ) ); 566 SLOT( updateConfig( ) ) );
567 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 567 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
568 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 568 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
569 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 569 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
570 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 570 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
571 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 571 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
572 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 572 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
573 573
574 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); 574 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) );
575 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); 575 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) );
576 576
577} 577}
578 578
579void KOAgendaView::toggleAllDay() 579void KOAgendaView::toggleAllDay()
580{ 580{
581 if ( mSplitterAgenda->firstHandle() ) 581 if ( mSplitterAgenda->firstHandle() )
582 mSplitterAgenda->firstHandle()->toggle(); 582 mSplitterAgenda->firstHandle()->toggle();
583} 583}
584void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 584void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
585{ 585{
586 calendar()->addIncidence( inc ); 586 calendar()->addIncidence( inc );
587 587
588 if ( incOld ) { 588 if ( incOld ) {
589 if ( incOld->typeID() == todoID ) 589 if ( incOld->typeID() == todoID )
590 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 590 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
591 else 591 else
592 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 592 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
593 } 593 }
594 594
595} 595}
596void KOAgendaView::categoryChanged(Incidence * inc) 596void KOAgendaView::categoryChanged(Incidence * inc)
597{ 597{
598 mAgenda->categoryChanged( inc ); 598 mAgenda->categoryChanged( inc );
599 mAllDayAgenda->categoryChanged( inc ); 599 mAllDayAgenda->categoryChanged( inc );
600} 600}
601KOAgendaView::~KOAgendaView() 601KOAgendaView::~KOAgendaView()
602{ 602{
603 delete mAllAgendaPopup; 603 delete mAllAgendaPopup;
604 //delete mAllDayAgendaPopup; 604 //delete mAllDayAgendaPopup;
605 delete KOAgendaItem::paintPix(); 605 delete KOAgendaItem::paintPix();
606 delete KOAgendaItem::paintPixSel(); 606 delete KOAgendaItem::paintPixAllday();
607} 607}
608void KOAgendaView::resizeEvent( QResizeEvent* e ) 608void KOAgendaView::resizeEvent( QResizeEvent* e )
609{ 609{
610 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 610 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
611 bool uc = false; 611 bool uc = false;
612 int ow = e->oldSize().width(); 612 int ow = e->oldSize().width();
613 int oh = e->oldSize().height(); 613 int oh = e->oldSize().height();
614 int w = e->size().width(); 614 int w = e->size().width();
615 int h = e->size().height(); 615 int h = e->size().height();
616 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 616 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
617 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 617 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
618 uc = true; 618 uc = true;
619 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 619 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
620 } 620 }
621 mUpcomingWidth = e->size().width() ; 621 mUpcomingWidth = e->size().width() ;
622 if ( mBlockUpdating || uc ) { 622 if ( mBlockUpdating || uc ) {
623 mBlockUpdating = false; 623 mBlockUpdating = false;
624 //mAgenda->setMinimumSize(800 , 600 ); 624 //mAgenda->setMinimumSize(800 , 600 );
625 //qDebug("mAgenda->resize+++++++++++++++ "); 625 //qDebug("mAgenda->resize+++++++++++++++ ");
626 updateConfig(); 626 updateConfig();
627 //qDebug("KOAgendaView::Updating now possible "); 627 //qDebug("KOAgendaView::Updating now possible ");
628 } else 628 } else
629 createDayLabels(); 629 createDayLabels();
630 //qDebug("resizeEvent end "); 630 //qDebug("resizeEvent end ");
631 631
632} 632}
633void KOAgendaView::slotDaylabelClicked( int num ) 633void KOAgendaView::slotDaylabelClicked( int num )
634{ 634{
635 635
636 QDate firstDate = mSelectedDates.first(); 636 QDate firstDate = mSelectedDates.first();
637 if ( num == -1 ) 637 if ( num == -1 )
638 emit showDateView( 6, firstDate ); 638 emit showDateView( 6, firstDate );
639 else if (num >= 0 ) { 639 else if (num >= 0 ) {
640 if ( mSelectedDates.count() == 1) 640 if ( mSelectedDates.count() == 1)
641 emit showDateView( 9, firstDate.addDays( num ) ); 641 emit showDateView( 9, firstDate.addDays( num ) );
642 else 642 else
643 emit showDateView( 3, firstDate.addDays( num ) ); 643 emit showDateView( 3, firstDate.addDays( num ) );
644 } 644 }
645 else 645 else
646 showDateView( 10, firstDate.addDays(1) ); 646 showDateView( 10, firstDate.addDays(1) );
647} 647}
648 648
649KOAgendaButton* KOAgendaView::getNewDaylabel() 649KOAgendaButton* KOAgendaView::getNewDaylabel()
650{ 650{
651 651
652 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 652 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
653 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 653 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
654 mDayLabelsList.append( dayLabel ); 654 mDayLabelsList.append( dayLabel );
655 mLayoutDayLabels->addWidget(dayLabel); 655 mLayoutDayLabels->addWidget(dayLabel);
656 return dayLabel ; 656 return dayLabel ;
657} 657}
658 658
659void KOAgendaView::createDayLabels() 659void KOAgendaView::createDayLabels()
660{ 660{
661 661
662 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 662 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
663 // qDebug(" KOAgendaView::createDayLabels() blocked "); 663 // qDebug(" KOAgendaView::createDayLabels() blocked ");
664 return; 664 return;
665 665
666 } 666 }
667 int newHight; 667 int newHight;
668 if ( !mSelectedDates.count()) 668 if ( !mSelectedDates.count())
669 return; 669 return;
670 670
671 // ### Before deleting and recreating we could check if mSelectedDates changed... 671 // ### Before deleting and recreating we could check if mSelectedDates changed...
672 // It would remove some flickering and gain speed (since this is called by 672 // It would remove some flickering and gain speed (since this is called by
673 // each updateView() call) 673 // each updateView() call)
674 674
675 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 675 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
676 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 676 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
677 if ( maxWid < 20 ) 677 if ( maxWid < 20 )
678 maxWid = 20; 678 maxWid = 20;
679 679
680 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 680 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
681 QFontMetrics fm ( dlf ); 681 QFontMetrics fm ( dlf );
682 dlf.setBold( true ); 682 dlf.setBold( true );
683 int selCount = mSelectedDates.count(); 683 int selCount = mSelectedDates.count();
684 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; 684 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
685 QString dayTest = "Mon 20"; 685 QString dayTest = "Mon 20";
686 //QString dayTest = "Mon 20"; 686 //QString dayTest = "Mon 20";
687 int wid = fm.width( dayTest ); 687 int wid = fm.width( dayTest );
688 //maxWid -= ( selCount * 3 ); //working for QLabels 688 //maxWid -= ( selCount * 3 ); //working for QLabels
689 if ( QApplication::desktop()->width() <= 320 ) 689 if ( QApplication::desktop()->width() <= 320 )
690 maxWid -= ( selCount * 3 ); //working for QPushButton 690 maxWid -= ( selCount * 3 ); //working for QPushButton
691 else 691 else
692 maxWid -= ( selCount * 4 ); //working for QPushButton 692 maxWid -= ( selCount * 4 ); //working for QPushButton
693 if ( maxWid < 0 ) 693 if ( maxWid < 0 )
694 maxWid = 20; 694 maxWid = 20;
695 int needWid = wid * selCount; 695 int needWid = wid * selCount;
696 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 696 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
697 //if ( needWid > maxWid ) 697 //if ( needWid > maxWid )
698 // qDebug("DAYLABELS TOOOOOOO BIG "); 698 // qDebug("DAYLABELS TOOOOOOO BIG ");
699 while ( needWid > maxWid ) { 699 while ( needWid > maxWid ) {
700 dayTest = dayTest.left( dayTest.length() - 1 ); 700 dayTest = dayTest.left( dayTest.length() - 1 );
701 wid = fm.width( dayTest ); 701 wid = fm.width( dayTest );
702 needWid = wid * selCount; 702 needWid = wid * selCount;
703 } 703 }
704 int maxLen = dayTest.length(); 704 int maxLen = dayTest.length();
705 int fontPoint = dlf.pointSize(); 705 int fontPoint = dlf.pointSize();
706 if ( maxLen < 2 ) { 706 if ( maxLen < 2 ) {
707 int fontPoint = dlf.pointSize(); 707 int fontPoint = dlf.pointSize();
708 while ( fontPoint > 4 ) { 708 while ( fontPoint > 4 ) {
709 --fontPoint; 709 --fontPoint;
710 dlf.setPointSize( fontPoint ); 710 dlf.setPointSize( fontPoint );
711 QFontMetrics f( dlf ); 711 QFontMetrics f( dlf );
712 wid = f.width( "30" ); 712 wid = f.width( "30" );
713 needWid = wid * selCount; 713 needWid = wid * selCount;
714 if ( needWid < maxWid ) 714 if ( needWid < maxWid )
715 break; 715 break;
716 } 716 }
717 maxLen = 2; 717 maxLen = 2;
718 } 718 }
719 //qDebug("Max len %d ", dayTest.length() ); 719 //qDebug("Max len %d ", dayTest.length() );
720 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() ) 720 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() )
721 dlf.setBold( false ); 721 dlf.setBold( false );
722 QFontMetrics tempF( dlf ); 722 QFontMetrics tempF( dlf );
723 newHight = tempF.height(); 723 newHight = tempF.height();
724 mDayLabels->setFont( dlf ); 724 mDayLabels->setFont( dlf );
725 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 725 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
726 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 726 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
727 //mLayoutDayLabels->addSpacing( 2 ); 727 //mLayoutDayLabels->addSpacing( 2 );
728 // QFont lFont = dlf; 728 // QFont lFont = dlf;
729 bool appendLabels = false; 729 bool appendLabels = false;
730 KOAgendaButton *dayLabel; 730 KOAgendaButton *dayLabel;
731 dayLabel = mDayLabelsList.first(); 731 dayLabel = mDayLabelsList.first();
732 if ( !dayLabel ) { 732 if ( !dayLabel ) {
733 appendLabels = true; 733 appendLabels = true;
734 dayLabel = getNewDaylabel(); 734 dayLabel = getNewDaylabel();
735 } 735 }
736 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 736 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
737 dayLabel->setFont( dlf ); 737 dayLabel->setFont( dlf );
738 dayLabel->setNum( -1 ); 738 dayLabel->setNum( -1 );
739 //dayLabel->setAlignment(QLabel::AlignHCenter); 739 //dayLabel->setAlignment(QLabel::AlignHCenter);
740 740
741 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 741 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
742 dayLabel->show(); 742 dayLabel->show();
743 DateList::ConstIterator dit; 743 DateList::ConstIterator dit;
744 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 744 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
745 int counter = -1; 745 int counter = -1;
746 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 746 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
747 ++counter; 747 ++counter;
748 QDate date = *dit; 748 QDate date = *dit;
749 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 749 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
750 if ( ! appendLabels ) { 750 if ( ! appendLabels ) {
751 dayLabel = mDayLabelsList.next(); 751 dayLabel = mDayLabelsList.next();
752 if ( !dayLabel ) 752 if ( !dayLabel )
753 appendLabels = true; 753 appendLabels = true;
754 } 754 }
755 if ( appendLabels ) { 755 if ( appendLabels ) {
756 dayLabel = getNewDaylabel(); 756 dayLabel = getNewDaylabel();
757 } 757 }
758 dayLabel->setMinimumWidth( 1 ); 758 dayLabel->setMinimumWidth( 1 );
759 dayLabel->setMaximumWidth( 10240 ); 759 dayLabel->setMaximumWidth( 10240 );
760 dayLabel->setFont( dlf ); 760 dayLabel->setFont( dlf );
761 dayLabel->show(); 761 dayLabel->show();
762 dayLabel->setAutoRepeat( false ); 762 dayLabel->setAutoRepeat( false );
763 dayLabel->setNum( counter ); 763 dayLabel->setNum( counter );
764 QString str; 764 QString str;
765 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 765 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
766 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 766 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
767 switch ( maxLen ) { 767 switch ( maxLen ) {
768 case 2: 768 case 2:
769 str = QString::number( date.day() ); 769 str = QString::number( date.day() );
770 break; 770 break;
771 771
772 case 3: 772 case 3:
773 str = dayName.left( 1 ) +QString::number( date.day()); 773 str = dayName.left( 1 ) +QString::number( date.day());
774 774
775 break; 775 break;
776 case 4: 776 case 4:
777 str = dayName.left( 1 ) + " " +QString::number( date.day()); 777 str = dayName.left( 1 ) + " " +QString::number( date.day());
778 778
779 break; 779 break;
780 case 5: 780 case 5:
781 str = dayName.left( 2 ) + " " +QString::number( date.day()); 781 str = dayName.left( 2 ) + " " +QString::number( date.day());
782 782
783 break; 783 break;
784 case 6: 784 case 6:
785 str = dayName.left( 3 ) + " " +QString::number( date.day()); 785 str = dayName.left( 3 ) + " " +QString::number( date.day());
786 break; 786 break;
787 787
788 default: 788 default:
789 break; 789 break;
790 } 790 }
791 if ( oneday ) { 791 if ( oneday ) {
792 QString addString; 792 QString addString;
793 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 793 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
794 addString = i18n("Today"); 794 addString = i18n("Today");
795 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 795 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
796 addString = i18n("Tomorrow"); 796 addString = i18n("Tomorrow");
797 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 797 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
798 addString = i18n("Yesterday"); 798 addString = i18n("Yesterday");