-rw-r--r-- | korganizer/koagendaview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 667ff2a..1627dba 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -477,385 +477,385 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | |||
477 | 477 | ||
478 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 478 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
479 | i18n("Toggle Alarm"),mAgenda, | 479 | i18n("Toggle Alarm"),mAgenda, |
480 | SLOT(popupAlarm()),true); | 480 | SLOT(popupAlarm()),true); |
481 | 481 | ||
482 | 482 | ||
483 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 483 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
484 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 484 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
485 | 485 | ||
486 | // make connections between dependent widgets | 486 | // make connections between dependent widgets |
487 | mTimeLabels->setAgenda(mAgenda); | 487 | mTimeLabels->setAgenda(mAgenda); |
488 | 488 | ||
489 | // Update widgets to reflect user preferences | 489 | // Update widgets to reflect user preferences |
490 | // updateConfig(); | 490 | // updateConfig(); |
491 | 491 | ||
492 | // createDayLabels(); | 492 | // createDayLabels(); |
493 | 493 | ||
494 | // these blank widgets make the All Day Event box line up with the agenda | 494 | // these blank widgets make the All Day Event box line up with the agenda |
495 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 495 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
496 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 496 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
497 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 497 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
498 | 498 | ||
499 | // Scrolling | 499 | // Scrolling |
500 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 500 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
501 | mTimeLabels, SLOT(positionChanged())); | 501 | mTimeLabels, SLOT(positionChanged())); |
502 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 502 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
503 | SLOT(setContentsPos(int))); | 503 | SLOT(setContentsPos(int))); |
504 | 504 | ||
505 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); | 505 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); |
506 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); | 506 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); |
507 | 507 | ||
508 | // Create/Show/Edit/Delete Event | 508 | // Create/Show/Edit/Delete Event |
509 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 509 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
510 | SLOT(newEvent(int,int))); | 510 | SLOT(newEvent(int,int))); |
511 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 511 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
512 | SLOT(newTodo(int,int))); | 512 | SLOT(newTodo(int,int))); |
513 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 513 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
514 | SLOT(newEvent(int,int,int,int))); | 514 | SLOT(newEvent(int,int,int,int))); |
515 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 515 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
516 | SLOT(newEventAllDay(int,int))); | 516 | SLOT(newEventAllDay(int,int))); |
517 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 517 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
518 | SLOT(newTodoAllDay(int,int))); | 518 | SLOT(newTodoAllDay(int,int))); |
519 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 519 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
520 | SLOT(newEventAllDay(int,int))); | 520 | SLOT(newEventAllDay(int,int))); |
521 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 521 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
522 | SLOT(newTimeSpanSelected(int,int,int,int))); | 522 | SLOT(newTimeSpanSelected(int,int,int,int))); |
523 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 523 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
524 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 524 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
525 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 525 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
526 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 526 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
527 | 527 | ||
528 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 528 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
529 | SIGNAL(editIncidenceSignal(Incidence *))); | 529 | SIGNAL(editIncidenceSignal(Incidence *))); |
530 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 530 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
531 | SIGNAL(editIncidenceSignal(Incidence *))); | 531 | SIGNAL(editIncidenceSignal(Incidence *))); |
532 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 532 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
533 | SIGNAL(showIncidenceSignal(Incidence *))); | 533 | SIGNAL(showIncidenceSignal(Incidence *))); |
534 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 534 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
535 | SIGNAL(showIncidenceSignal(Incidence *))); | 535 | SIGNAL(showIncidenceSignal(Incidence *))); |
536 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 536 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
537 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 537 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
538 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 538 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
539 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 539 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
540 | 540 | ||
541 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 541 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
542 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 542 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
543 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 543 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
544 | SLOT(updateEventDates(KOAgendaItem *, int))); | 544 | SLOT(updateEventDates(KOAgendaItem *, int))); |
545 | 545 | ||
546 | // event indicator update | 546 | // event indicator update |
547 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 547 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
548 | SLOT(updateEventIndicatorTop(int))); | 548 | SLOT(updateEventIndicatorTop(int))); |
549 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 549 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
550 | SLOT(updateEventIndicatorBottom(int))); | 550 | SLOT(updateEventIndicatorBottom(int))); |
551 | // drag signals | 551 | // drag signals |
552 | /* | 552 | /* |
553 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 553 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
554 | SLOT(startDrag(Event *))); | 554 | SLOT(startDrag(Event *))); |
555 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 555 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
556 | SLOT(startDrag(Event *))); | 556 | SLOT(startDrag(Event *))); |
557 | */ | 557 | */ |
558 | // synchronize selections | 558 | // synchronize selections |
559 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 559 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
560 | mAllDayAgenda, SLOT( deselectItem() ) ); | 560 | mAllDayAgenda, SLOT( deselectItem() ) ); |
561 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 561 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
562 | mAgenda, SLOT( deselectItem() ) ); | 562 | mAgenda, SLOT( deselectItem() ) ); |
563 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 563 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
564 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 564 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
565 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 565 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
566 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 566 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
567 | connect( mAgenda, SIGNAL( resizedSignal() ), | 567 | connect( mAgenda, SIGNAL( resizedSignal() ), |
568 | SLOT( updateConfig( ) ) ); | 568 | SLOT( updateConfig( ) ) ); |
569 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 569 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
570 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 570 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
571 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 571 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
572 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 572 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
573 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 573 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
574 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 574 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
575 | 575 | ||
576 | 576 | ||
577 | } | 577 | } |
578 | 578 | ||
579 | void KOAgendaView::toggleAllDay() | 579 | void KOAgendaView::toggleAllDay() |
580 | { | 580 | { |
581 | if ( mSplitterAgenda->firstHandle() ) | 581 | if ( mSplitterAgenda->firstHandle() ) |
582 | mSplitterAgenda->firstHandle()->toggle(); | 582 | mSplitterAgenda->firstHandle()->toggle(); |
583 | } | 583 | } |
584 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 584 | void 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->type() == "Todo" ) | 589 | if ( incOld->type() == "Todo" ) |
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 | } |
596 | 596 | ||
597 | KOAgendaView::~KOAgendaView() | 597 | KOAgendaView::~KOAgendaView() |
598 | { | 598 | { |
599 | delete mAgendaPopup; | 599 | delete mAgendaPopup; |
600 | delete mAllDayAgendaPopup; | 600 | delete mAllDayAgendaPopup; |
601 | delete KOAgendaItem::paintPix(); | 601 | delete KOAgendaItem::paintPix(); |
602 | delete KOAgendaItem::paintPixSel(); | 602 | delete KOAgendaItem::paintPixSel(); |
603 | } | 603 | } |
604 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 604 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
605 | { | 605 | { |
606 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 606 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
607 | bool uc = false; | 607 | bool uc = false; |
608 | int ow = e->oldSize().width(); | 608 | int ow = e->oldSize().width(); |
609 | int oh = e->oldSize().height(); | 609 | int oh = e->oldSize().height(); |
610 | int w = e->size().width(); | 610 | int w = e->size().width(); |
611 | int h = e->size().height(); | 611 | int h = e->size().height(); |
612 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 612 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
613 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 613 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
614 | uc = true; | 614 | uc = true; |
615 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 615 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
616 | } | 616 | } |
617 | mUpcomingWidth = e->size().width() ; | 617 | mUpcomingWidth = e->size().width() ; |
618 | if ( mBlockUpdating || uc ) { | 618 | if ( mBlockUpdating || uc ) { |
619 | mBlockUpdating = false; | 619 | mBlockUpdating = false; |
620 | //mAgenda->setMinimumSize(800 , 600 ); | 620 | //mAgenda->setMinimumSize(800 , 600 ); |
621 | //qDebug("mAgenda->resize+++++++++++++++ "); | 621 | //qDebug("mAgenda->resize+++++++++++++++ "); |
622 | updateConfig(); | 622 | updateConfig(); |
623 | //qDebug("KOAgendaView::Updating now possible "); | 623 | //qDebug("KOAgendaView::Updating now possible "); |
624 | } else | 624 | } else |
625 | createDayLabels(); | 625 | createDayLabels(); |
626 | //qDebug("resizeEvent end "); | 626 | //qDebug("resizeEvent end "); |
627 | 627 | ||
628 | } | 628 | } |
629 | void KOAgendaView::slotDaylabelClicked( int num ) | 629 | void KOAgendaView::slotDaylabelClicked( int num ) |
630 | { | 630 | { |
631 | 631 | ||
632 | QDate firstDate = mSelectedDates.first(); | 632 | QDate firstDate = mSelectedDates.first(); |
633 | if ( num == -1 ) | 633 | if ( num == -1 ) |
634 | emit showDateView( 6, firstDate ); | 634 | emit showDateView( 6, firstDate ); |
635 | else if (num >= 0 ) { | 635 | else if (num >= 0 ) { |
636 | if ( mSelectedDates.count() == 1) | 636 | if ( mSelectedDates.count() == 1) |
637 | emit showDateView( 9, firstDate.addDays( num ) ); | 637 | emit showDateView( 9, firstDate.addDays( num ) ); |
638 | else | 638 | else |
639 | emit showDateView( 3, firstDate.addDays( num ) ); | 639 | emit showDateView( 3, firstDate.addDays( num ) ); |
640 | } | 640 | } |
641 | else | 641 | else |
642 | showDateView( 10, firstDate.addDays(1) ); | 642 | showDateView( 10, firstDate.addDays(1) ); |
643 | } | 643 | } |
644 | 644 | ||
645 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 645 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
646 | { | 646 | { |
647 | 647 | ||
648 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 648 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
649 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 649 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
650 | mDayLabelsList.append( dayLabel ); | 650 | mDayLabelsList.append( dayLabel ); |
651 | mLayoutDayLabels->addWidget(dayLabel); | 651 | mLayoutDayLabels->addWidget(dayLabel); |
652 | return dayLabel ; | 652 | return dayLabel ; |
653 | } | 653 | } |
654 | 654 | ||
655 | void KOAgendaView::createDayLabels() | 655 | void KOAgendaView::createDayLabels() |
656 | { | 656 | { |
657 | 657 | ||
658 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 658 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
659 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 659 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
660 | return; | 660 | return; |
661 | 661 | ||
662 | } | 662 | } |
663 | int newHight; | 663 | int newHight; |
664 | 664 | ||
665 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 665 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
666 | // It would remove some flickering and gain speed (since this is called by | 666 | // It would remove some flickering and gain speed (since this is called by |
667 | // each updateView() call) | 667 | // each updateView() call) |
668 | 668 | ||
669 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; | 669 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; |
670 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 670 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
671 | if ( maxWid < 0 ) | 671 | if ( maxWid < 0 ) |
672 | maxWid = 20; | 672 | maxWid = 20; |
673 | 673 | ||
674 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 674 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
675 | QFontMetrics fm ( dlf ); | 675 | QFontMetrics fm ( dlf ); |
676 | int selCount = mSelectedDates.count(); | 676 | int selCount = mSelectedDates.count(); |
677 | QString dayTest = "Mon 20"; | 677 | QString dayTest = "Mon 20"; |
678 | //QString dayTest = "Mon 20"; | 678 | //QString dayTest = "Mon 20"; |
679 | int wid = fm.width( dayTest ); | 679 | int wid = fm.width( dayTest ); |
680 | //maxWid -= ( selCount * 3 ); //working for QLabels | 680 | //maxWid -= ( selCount * 3 ); //working for QLabels |
681 | maxWid -= ( selCount * 3 ); //working for QPushButton | 681 | maxWid -= ( selCount * 3 ); //working for QPushButton |
682 | if ( maxWid < 0 ) | 682 | if ( maxWid < 0 ) |
683 | maxWid = 20; | 683 | maxWid = 20; |
684 | int needWid = wid * selCount; | 684 | int needWid = wid * selCount; |
685 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 685 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
686 | //if ( needWid > maxWid ) | 686 | //if ( needWid > maxWid ) |
687 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 687 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
688 | while ( needWid > maxWid ) { | 688 | while ( needWid > maxWid ) { |
689 | dayTest = dayTest.left( dayTest.length() - 1 ); | 689 | dayTest = dayTest.left( dayTest.length() - 1 ); |
690 | wid = fm.width( dayTest ); | 690 | wid = fm.width( dayTest ); |
691 | needWid = wid * selCount; | 691 | needWid = wid * selCount; |
692 | } | 692 | } |
693 | int maxLen = dayTest.length(); | 693 | int maxLen = dayTest.length(); |
694 | int fontPoint = dlf.pointSize(); | 694 | int fontPoint = dlf.pointSize(); |
695 | if ( maxLen < 2 ) { | 695 | if ( maxLen < 2 ) { |
696 | int fontPoint = dlf.pointSize(); | 696 | int fontPoint = dlf.pointSize(); |
697 | while ( fontPoint > 4 ) { | 697 | while ( fontPoint > 4 ) { |
698 | --fontPoint; | 698 | --fontPoint; |
699 | dlf.setPointSize( fontPoint ); | 699 | dlf.setPointSize( fontPoint ); |
700 | QFontMetrics f( dlf ); | 700 | QFontMetrics f( dlf ); |
701 | wid = f.width( "30" ); | 701 | wid = f.width( "30" ); |
702 | needWid = wid * selCount; | 702 | needWid = wid * selCount; |
703 | if ( needWid < maxWid ) | 703 | if ( needWid < maxWid ) |
704 | break; | 704 | break; |
705 | } | 705 | } |
706 | maxLen = 2; | 706 | maxLen = 2; |
707 | } | 707 | } |
708 | //qDebug("Max len %d ", dayTest.length() ); | 708 | //qDebug("Max len %d ", dayTest.length() ); |
709 | 709 | ||
710 | QFontMetrics tempF( dlf ); | 710 | QFontMetrics tempF( dlf ); |
711 | newHight = tempF.height(); | 711 | newHight = tempF.height(); |
712 | mDayLabels->setFont( dlf ); | 712 | mDayLabels->setFont( dlf ); |
713 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 713 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
714 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 714 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
715 | //mLayoutDayLabels->addSpacing( 2 ); | 715 | //mLayoutDayLabels->addSpacing( 2 ); |
716 | // QFont lFont = dlf; | 716 | // QFont lFont = dlf; |
717 | bool appendLabels = false; | 717 | bool appendLabels = false; |
718 | KOAgendaButton *dayLabel; | 718 | KOAgendaButton *dayLabel; |
719 | dayLabel = mDayLabelsList.first(); | 719 | dayLabel = mDayLabelsList.first(); |
720 | if ( !dayLabel ) { | 720 | if ( !dayLabel ) { |
721 | appendLabels = true; | 721 | appendLabels = true; |
722 | dayLabel = getNewDaylabel(); | 722 | dayLabel = getNewDaylabel(); |
723 | } | 723 | } |
724 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); | 724 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); |
725 | dayLabel->setFont( dlf ); | 725 | dayLabel->setFont( dlf ); |
726 | dayLabel->setNum( -1 ); | 726 | dayLabel->setNum( -1 ); |
727 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 727 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
728 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 728 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
729 | dayLabel->show(); | 729 | dayLabel->show(); |
730 | DateList::ConstIterator dit; | 730 | DateList::ConstIterator dit; |
731 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 731 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
732 | int counter = -1; | 732 | int counter = -1; |
733 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 733 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
734 | ++counter; | 734 | ++counter; |
735 | QDate date = *dit; | 735 | QDate date = *dit; |
736 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 736 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
737 | if ( ! appendLabels ) { | 737 | if ( ! appendLabels ) { |
738 | dayLabel = mDayLabelsList.next(); | 738 | dayLabel = mDayLabelsList.next(); |
739 | if ( !dayLabel ) | 739 | if ( !dayLabel ) |
740 | appendLabels = true; | 740 | appendLabels = true; |
741 | } | 741 | } |
742 | if ( appendLabels ) { | 742 | if ( appendLabels ) { |
743 | dayLabel = getNewDaylabel(); | 743 | dayLabel = getNewDaylabel(); |
744 | } | 744 | } |
745 | dayLabel->setMinimumWidth( 1 ); | 745 | dayLabel->setMinimumWidth( 1 ); |
746 | dayLabel->setMaximumWidth( 10240 ); | 746 | dayLabel->setMaximumWidth( 10240 ); |
747 | dayLabel->setFont( dlf ); | 747 | dayLabel->setFont( dlf ); |
748 | dayLabel->show(); | 748 | dayLabel->show(); |
749 | dayLabel->setAutoRepeat( false ); | 749 | dayLabel->setAutoRepeat( false ); |
750 | dayLabel->setNum( counter ); | 750 | dayLabel->setNum( counter ); |
751 | QString str; | 751 | QString str; |
752 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 752 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
753 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 753 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
754 | switch ( maxLen ) { | 754 | switch ( maxLen ) { |
755 | case 2: | 755 | case 2: |
756 | str = QString::number( date.day() ); | 756 | str = QString::number( date.day() ); |
757 | break; | 757 | break; |
758 | 758 | ||
759 | case 3: | 759 | case 3: |
760 | str = dayName.left( 1 ) +QString::number( date.day()); | 760 | str = dayName.left( 1 ) +QString::number( date.day()); |
761 | 761 | ||
762 | break; | 762 | break; |
763 | case 4: | 763 | case 4: |
764 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 764 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
765 | 765 | ||
766 | break; | 766 | break; |
767 | case 5: | 767 | case 5: |
768 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 768 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
769 | 769 | ||
770 | break; | 770 | break; |
771 | case 6: | 771 | case 6: |
772 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 772 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
773 | break; | 773 | break; |
774 | 774 | ||
775 | default: | 775 | default: |
776 | break; | 776 | break; |
777 | } | 777 | } |
778 | if ( oneday ) { | 778 | if ( oneday ) { |
779 | QString addString; | 779 | QString addString; |
780 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 780 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
781 | addString = i18n("Today"); | 781 | addString = i18n("Today"); |
782 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 782 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
783 | addString = i18n("Tomorrow"); | 783 | addString = i18n("Tomorrow"); |
784 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 784 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
785 | addString = i18n("Yesterday"); | 785 | addString = i18n("Yesterday"); |
786 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 786 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
787 | addString = i18n("Day before yesterday"); | 787 | addString = i18n("Day before yesterday"); |
788 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 788 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
789 | addString = i18n("Day after tomorrow"); | 789 | addString = i18n("Day after tomorrow"); |
790 | if ( !addString.isEmpty() ) { | 790 | if ( !addString.isEmpty() ) { |
791 | str = addString+", " + str; | 791 | str = addString+", " + str; |
792 | } else { | 792 | } else { |
793 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 793 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
794 | } | 794 | } |
795 | } | 795 | } |
796 | dayLabel->setText(str); | 796 | dayLabel->setText(str); |
797 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 797 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
798 | if (date == QDate::currentDate()) { | 798 | if (date == QDate::currentDate()) { |
799 | QFont bFont = dlf; | 799 | QFont bFont = dlf; |
800 | bFont.setBold( true ); | 800 | bFont.setBold( true ); |
801 | dayLabel->setFont(bFont); | 801 | dayLabel->setFont(bFont); |
802 | } | 802 | } |
803 | //dayLayout->addWidget(dayLabel); | 803 | //dayLayout->addWidget(dayLabel); |
804 | 804 | ||
805 | #ifndef KORG_NOPLUGINS | 805 | #ifndef KORG_NOPLUGINS |
806 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 806 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
807 | CalendarDecoration *it; | 807 | CalendarDecoration *it; |
808 | for(it = cds.first(); it; it = cds.next()) { | 808 | for(it = cds.first(); it; it = cds.next()) { |
809 | QString text = it->shortText( date ); | 809 | QString text = it->shortText( date ); |
810 | if ( !text.isEmpty() ) { | 810 | if ( !text.isEmpty() ) { |
811 | QLabel *label = new QLabel(text,mDayLabels); | 811 | QLabel *label = new QLabel(text,mDayLabels); |
812 | label->setAlignment(AlignCenter); | 812 | label->setAlignment(AlignCenter); |
813 | dayLayout->addWidget(label); | 813 | dayLayout->addWidget(label); |
814 | } | 814 | } |
815 | } | 815 | } |
816 | 816 | ||
817 | for(it = cds.first(); it; it = cds.next()) { | 817 | for(it = cds.first(); it; it = cds.next()) { |
818 | QWidget *wid = it->smallWidget(mDayLabels,date); | 818 | QWidget *wid = it->smallWidget(mDayLabels,date); |
819 | if ( wid ) { | 819 | if ( wid ) { |
820 | // wid->setHeight(20); | 820 | // wid->setHeight(20); |
821 | dayLayout->addWidget(wid); | 821 | dayLayout->addWidget(wid); |
822 | } | 822 | } |
823 | } | 823 | } |
824 | #endif | 824 | #endif |
825 | } | 825 | } |
826 | if ( ! appendLabels ) { | 826 | if ( ! appendLabels ) { |
827 | dayLabel = mDayLabelsList.next(); | 827 | dayLabel = mDayLabelsList.next(); |
828 | if ( !dayLabel ) | 828 | if ( !dayLabel ) |
829 | appendLabels = true; | 829 | appendLabels = true; |
830 | } | 830 | } |
831 | if ( appendLabels ) { | 831 | if ( appendLabels ) { |
832 | dayLabel = getNewDaylabel(); | 832 | dayLabel = getNewDaylabel(); |
833 | } | 833 | } |
834 | //dayLabel->hide();//test only | 834 | //dayLabel->hide();//test only |
835 | qDebug("fremwidd %d ", mAgenda->frameWidth()); | 835 | qDebug("fremwidd %d ", mAgenda->frameWidth()); |
836 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()- (mAgenda->frameWidth()*2) ) % mSelectedDates.count() ; | 836 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()- (mAgenda->frameWidth()*2) ) % mSelectedDates.count() ; |
837 | if ( offset < 0 ) offset = 0; | 837 | if ( offset < 0 ) offset = 0; |
838 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 838 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
839 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); | 839 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); |
840 | dayLabel->setFont( dlf ); | 840 | dayLabel->setFont( dlf ); |
841 | dayLabel->setAutoRepeat( true ); | 841 | dayLabel->setAutoRepeat( true ); |
842 | dayLabel->show(); | 842 | dayLabel->show(); |
843 | dayLabel->setNum( -2 ); | 843 | dayLabel->setNum( -2 ); |
844 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 844 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
845 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 845 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
846 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 846 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
847 | if ( !appendLabels ) { | 847 | if ( !appendLabels ) { |
848 | dayLabel = mDayLabelsList.next(); | 848 | dayLabel = mDayLabelsList.next(); |
849 | while ( dayLabel ) { | 849 | while ( dayLabel ) { |
850 | //qDebug("!dayLabel %d",dayLabel ); | 850 | //qDebug("!dayLabel %d",dayLabel ); |
851 | dayLabel->hide(); | 851 | dayLabel->hide(); |
852 | dayLabel = mDayLabelsList.next(); | 852 | dayLabel = mDayLabelsList.next(); |
853 | } | 853 | } |
854 | } | 854 | } |
855 | 855 | ||
856 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); | 856 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); |
857 | } | 857 | } |
858 | 858 | ||
859 | int KOAgendaView::maxDatesHint() | 859 | int KOAgendaView::maxDatesHint() |
860 | { | 860 | { |
861 | // Not sure about the max number of events, so return 0 for now. | 861 | // Not sure about the max number of events, so return 0 for now. |