-rw-r--r-- | korganizer/koagendaview.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index d8a2134..c1b149f 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -528,384 +528,386 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | |||
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 | #ifndef DESKTOP_VERSION | 576 | #ifndef DESKTOP_VERSION |
577 | connect( mAllDayAgenda, SIGNAL( updateViewSignal() ),this, SLOT( fillAgenda()) ); | 577 | connect( mAllDayAgenda, SIGNAL( updateViewSignal() ),this, SLOT( fillAgenda()) ); |
578 | connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) ); | 578 | connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) ); |
579 | connect( mAllDayAgenda, SIGNAL( sendPing() ),this, SLOT( startIdleTimeout()) ); | 579 | connect( mAllDayAgenda, SIGNAL( sendPing() ),this, SLOT( startIdleTimeout()) ); |
580 | connect( mAgenda, SIGNAL( sendPing() ), this, SLOT( startIdleTimeout()) ); | 580 | connect( mAgenda, SIGNAL( sendPing() ), this, SLOT( startIdleTimeout()) ); |
581 | mIdleTimer = new QTimer ( this );; | 581 | mIdleTimer = new QTimer ( this );; |
582 | connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout())); | 582 | connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout())); |
583 | #endif | 583 | #endif |
584 | } | 584 | } |
585 | void KOAgendaView::startIdleTimeout() | 585 | void KOAgendaView::startIdleTimeout() |
586 | { | 586 | { |
587 | #ifndef DESKTOP_VERSION | 587 | #ifndef DESKTOP_VERSION |
588 | mIdleStart = QDateTime::currentDateTime(); | 588 | mIdleStart = QDateTime::currentDateTime(); |
589 | mIdleTimer->start( IDLETIMEOUT * 1000 ); | 589 | mIdleTimer->start( IDLETIMEOUT * 1000 ); |
590 | #endif | 590 | #endif |
591 | } | 591 | } |
592 | void KOAgendaView::slotIdleTimeout() | 592 | void KOAgendaView::slotIdleTimeout() |
593 | { | 593 | { |
594 | #ifndef DESKTOP_VERSION | 594 | #ifndef DESKTOP_VERSION |
595 | //qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) ); | 595 | //qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) ); |
596 | int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() ); | 596 | int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() ); |
597 | mIdleTimer->stop(); | 597 | mIdleTimer->stop(); |
598 | bool isActice = topLevelWidget()->isActiveWindow(); | 598 | bool isActice = topLevelWidget()->isActiveWindow(); |
599 | //qDebug("KO: Active Window %d %d", isActice, isVisible()); | 599 | //qDebug("KO: Active Window %d %d", isActice, isVisible()); |
600 | // we do nothing if we wake up from a suspend | 600 | // we do nothing if we wake up from a suspend |
601 | if ( secsfromstart > IDLETIMEOUT + 30 && isActice ) { | 601 | if ( secsfromstart > IDLETIMEOUT + 30 && isActice ) { |
602 | qDebug("KO: Wakeup from suspend "); | 602 | qDebug("KO: Wakeup from suspend "); |
603 | startIdleTimeout(); | 603 | startIdleTimeout(); |
604 | return; | 604 | return; |
605 | } | 605 | } |
606 | qDebug("KO: Downsizing Pixmaps %s",QDateTime::currentDateTime().toString().latin1()); | 606 | qDebug("KO: Downsizing Pixmaps %s",QDateTime::currentDateTime().toString().latin1()); |
607 | mAgenda->shrinkPixmap(); | 607 | mAgenda->shrinkPixmap(); |
608 | mAllDayAgenda->shrinkPixmap(); | 608 | mAllDayAgenda->shrinkPixmap(); |
609 | KOAgendaItem::paintPix()->resize( 20,20); | 609 | KOAgendaItem::paintPix()->resize( 20,20); |
610 | KOAgendaItem::paintPixAllday()->resize( 20,20); | 610 | KOAgendaItem::paintPixAllday()->resize( 20,20); |
611 | #endif | 611 | #endif |
612 | 612 | ||
613 | } | 613 | } |
614 | void KOAgendaView::toggleAllDay() | 614 | void KOAgendaView::toggleAllDay() |
615 | { | 615 | { |
616 | if ( mSplitterAgenda->firstHandle() ) | 616 | if ( mSplitterAgenda->firstHandle() ) |
617 | mSplitterAgenda->firstHandle()->toggle(); | 617 | mSplitterAgenda->firstHandle()->toggle(); |
618 | } | 618 | } |
619 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 619 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
620 | { | 620 | { |
621 | calendar()->addIncidence( inc ); | 621 | calendar()->addIncidence( inc ); |
622 | 622 | ||
623 | if ( incOld ) { | 623 | if ( incOld ) { |
624 | if ( incOld->typeID() == todoID ) | 624 | if ( incOld->typeID() == todoID ) |
625 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 625 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
626 | else | 626 | else |
627 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 627 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
628 | } | 628 | } |
629 | 629 | ||
630 | } | 630 | } |
631 | void KOAgendaView::categoryChanged(Incidence * inc) | 631 | void KOAgendaView::categoryChanged(Incidence * inc) |
632 | { | 632 | { |
633 | mAgenda->categoryChanged( inc ); | 633 | mAgenda->categoryChanged( inc ); |
634 | mAllDayAgenda->categoryChanged( inc ); | 634 | mAllDayAgenda->categoryChanged( inc ); |
635 | } | 635 | } |
636 | KOAgendaView::~KOAgendaView() | 636 | KOAgendaView::~KOAgendaView() |
637 | { | 637 | { |
638 | delete mAllAgendaPopup; | 638 | delete mAllAgendaPopup; |
639 | //delete mAllDayAgendaPopup; | 639 | //delete mAllDayAgendaPopup; |
640 | delete KOAgendaItem::paintPix(); | 640 | delete KOAgendaItem::paintPix(); |
641 | delete KOAgendaItem::paintPixAllday(); | 641 | delete KOAgendaItem::paintPixAllday(); |
642 | } | 642 | } |
643 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 643 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
644 | { | 644 | { |
645 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 645 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
646 | bool uc = false; | 646 | bool uc = false; |
647 | int ow = e->oldSize().width(); | 647 | int ow = e->oldSize().width(); |
648 | int oh = e->oldSize().height(); | 648 | int oh = e->oldSize().height(); |
649 | int w = e->size().width(); | 649 | int w = e->size().width(); |
650 | int h = e->size().height(); | 650 | int h = e->size().height(); |
651 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 651 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
652 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 652 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
653 | uc = true; | 653 | uc = true; |
654 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 654 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
655 | } | 655 | } |
656 | mUpcomingWidth = e->size().width() ; | 656 | mUpcomingWidth = e->size().width() ; |
657 | if ( mBlockUpdating || uc ) { | 657 | if ( mBlockUpdating || uc ) { |
658 | mBlockUpdating = false; | 658 | mBlockUpdating = false; |
659 | //mAgenda->setMinimumSize(800 , 600 ); | 659 | //mAgenda->setMinimumSize(800 , 600 ); |
660 | //qDebug("mAgenda->resize+++++++++++++++ "); | 660 | //qDebug("mAgenda->resize+++++++++++++++ "); |
661 | updateConfig(); | 661 | updateConfig(); |
662 | //qDebug("KOAgendaView::Updating now possible "); | 662 | //qDebug("KOAgendaView::Updating now possible "); |
663 | } else | 663 | } else |
664 | createDayLabels(); | 664 | createDayLabels(); |
665 | //qDebug("resizeEvent end "); | 665 | //qDebug("resizeEvent end "); |
666 | 666 | ||
667 | } | 667 | } |
668 | void KOAgendaView::slotDaylabelClicked( int num ) | 668 | void KOAgendaView::slotDaylabelClicked( int num ) |
669 | { | 669 | { |
670 | 670 | ||
671 | QDate firstDate = mSelectedDates.first(); | 671 | QDate firstDate = mSelectedDates.first(); |
672 | if ( num == -1 ) | 672 | if ( num == -1 ) |
673 | emit showDateView( 6, firstDate ); | 673 | emit showDateView( 6, firstDate ); |
674 | else if (num >= 0 ) { | 674 | else if (num >= 0 ) { |
675 | if ( mSelectedDates.count() == 1) | 675 | if ( mSelectedDates.count() == 1) |
676 | emit showDateView( 9, firstDate.addDays( num ) ); | 676 | emit showDateView( 9, firstDate.addDays( num ) ); |
677 | else | 677 | else |
678 | emit showDateView( 3, firstDate.addDays( num ) ); | 678 | emit showDateView( 3, firstDate.addDays( num ) ); |
679 | } | 679 | } |
680 | else | 680 | else |
681 | showDateView( 10, firstDate.addDays(1) ); | 681 | showDateView( 10, firstDate.addDays(1) ); |
682 | } | 682 | } |
683 | 683 | ||
684 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 684 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
685 | { | 685 | { |
686 | 686 | ||
687 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 687 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
688 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 688 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
689 | mDayLabelsList.append( dayLabel ); | 689 | mDayLabelsList.append( dayLabel ); |
690 | mLayoutDayLabels->addWidget(dayLabel); | 690 | mLayoutDayLabels->addWidget(dayLabel); |
691 | return dayLabel ; | 691 | return dayLabel ; |
692 | } | 692 | } |
693 | 693 | ||
694 | void KOAgendaView::createDayLabels() | 694 | void KOAgendaView::createDayLabels() |
695 | { | 695 | { |
696 | 696 | ||
697 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 697 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
698 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 698 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
699 | return; | 699 | return; |
700 | 700 | ||
701 | } | 701 | } |
702 | int newHight; | 702 | int newHight; |
703 | if ( !mSelectedDates.count()) | 703 | if ( !mSelectedDates.count()) |
704 | return; | 704 | return; |
705 | 705 | ||
706 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 706 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
707 | // It would remove some flickering and gain speed (since this is called by | 707 | // It would remove some flickering and gain speed (since this is called by |
708 | // each updateView() call) | 708 | // each updateView() call) |
709 | 709 | ||
710 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; | 710 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; |
711 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 711 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
712 | if ( maxWid < 20 ) | 712 | if ( maxWid < 20 ) |
713 | maxWid = 20; | 713 | maxWid = 20; |
714 | 714 | ||
715 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 715 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
716 | QFontMetrics fm ( dlf ); | 716 | QFontMetrics fm ( dlf ); |
717 | dlf.setBold( true ); | 717 | dlf.setBold( true ); |
718 | int selCount = mSelectedDates.count(); | 718 | int selCount = mSelectedDates.count(); |
719 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; | 719 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; |
720 | if ( widModulo < 0 || widModulo > selCount ) | ||
721 | widModulo = 0; | ||
720 | QString dayTest = "Mon 20"; | 722 | QString dayTest = "Mon 20"; |
721 | //QString dayTest = "Mon 20"; | 723 | //QString dayTest = "Mon 20"; |
722 | int wid = fm.width( dayTest ); | 724 | int wid = fm.width( dayTest ); |
723 | //maxWid -= ( selCount * 3 ); //working for QLabels | 725 | //maxWid -= ( selCount * 3 ); //working for QLabels |
724 | if ( QApplication::desktop()->width() <= 320 ) | 726 | if ( QApplication::desktop()->width() <= 320 ) |
725 | maxWid -= ( selCount * 3 ); //working for QPushButton | 727 | maxWid -= ( selCount * 3 ); //working for QPushButton |
726 | else | 728 | else |
727 | maxWid -= ( selCount * 4 ); //working for QPushButton | 729 | maxWid -= ( selCount * 4 ); //working for QPushButton |
728 | if ( maxWid < 0 ) | 730 | if ( maxWid < 0 ) |
729 | maxWid = 20; | 731 | maxWid = 20; |
730 | int needWid = wid * selCount; | 732 | int needWid = wid * selCount; |
731 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 733 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
732 | //if ( needWid > maxWid ) | 734 | //if ( needWid > maxWid ) |
733 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 735 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
734 | while ( needWid > maxWid ) { | 736 | while ( needWid > maxWid ) { |
735 | dayTest = dayTest.left( dayTest.length() - 1 ); | 737 | dayTest = dayTest.left( dayTest.length() - 1 ); |
736 | wid = fm.width( dayTest ); | 738 | wid = fm.width( dayTest ); |
737 | needWid = wid * selCount; | 739 | needWid = wid * selCount; |
738 | } | 740 | } |
739 | int maxLen = dayTest.length(); | 741 | int maxLen = dayTest.length(); |
740 | int fontPoint = dlf.pointSize(); | 742 | int fontPoint = dlf.pointSize(); |
741 | if ( maxLen < 2 ) { | 743 | if ( maxLen < 2 ) { |
742 | int fontPoint = dlf.pointSize(); | 744 | int fontPoint = dlf.pointSize(); |
743 | while ( fontPoint > 4 ) { | 745 | while ( fontPoint > 4 ) { |
744 | --fontPoint; | 746 | --fontPoint; |
745 | dlf.setPointSize( fontPoint ); | 747 | dlf.setPointSize( fontPoint ); |
746 | QFontMetrics f( dlf ); | 748 | QFontMetrics f( dlf ); |
747 | wid = f.width( "30" ); | 749 | wid = f.width( "30" ); |
748 | needWid = wid * selCount; | 750 | needWid = wid * selCount; |
749 | if ( needWid < maxWid ) | 751 | if ( needWid < maxWid ) |
750 | break; | 752 | break; |
751 | } | 753 | } |
752 | maxLen = 2; | 754 | maxLen = 2; |
753 | } | 755 | } |
754 | //qDebug("Max len %d ", dayTest.length() ); | 756 | //qDebug("Max len %d ", dayTest.length() ); |
755 | if ( !KOPrefs::instance()->mTimeLabelsFont.bold() ) | 757 | if ( !KOPrefs::instance()->mTimeLabelsFont.bold() ) |
756 | dlf.setBold( false ); | 758 | dlf.setBold( false ); |
757 | QFontMetrics tempF( dlf ); | 759 | QFontMetrics tempF( dlf ); |
758 | newHight = tempF.height(); | 760 | newHight = tempF.height(); |
759 | mDayLabels->setFont( dlf ); | 761 | mDayLabels->setFont( dlf ); |
760 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 762 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
761 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 763 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
762 | //mLayoutDayLabels->addSpacing( 2 ); | 764 | //mLayoutDayLabels->addSpacing( 2 ); |
763 | // QFont lFont = dlf; | 765 | // QFont lFont = dlf; |
764 | bool appendLabels = false; | 766 | bool appendLabels = false; |
765 | KOAgendaButton *dayLabel; | 767 | KOAgendaButton *dayLabel; |
766 | dayLabel = mDayLabelsList.first(); | 768 | dayLabel = mDayLabelsList.first(); |
767 | if ( !dayLabel ) { | 769 | if ( !dayLabel ) { |
768 | appendLabels = true; | 770 | appendLabels = true; |
769 | dayLabel = getNewDaylabel(); | 771 | dayLabel = getNewDaylabel(); |
770 | } | 772 | } |
771 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); | 773 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); |
772 | dayLabel->setFont( dlf ); | 774 | dayLabel->setFont( dlf ); |
773 | dayLabel->setNum( -1 ); | 775 | dayLabel->setNum( -1 ); |
774 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 776 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
775 | 777 | ||
776 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 778 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
777 | dayLabel->show(); | 779 | dayLabel->show(); |
778 | DateList::ConstIterator dit; | 780 | DateList::ConstIterator dit; |
779 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 781 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
780 | int counter = -1; | 782 | int counter = -1; |
781 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 783 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
782 | ++counter; | 784 | ++counter; |
783 | QDate date = *dit; | 785 | QDate date = *dit; |
784 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 786 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
785 | if ( ! appendLabels ) { | 787 | if ( ! appendLabels ) { |
786 | dayLabel = mDayLabelsList.next(); | 788 | dayLabel = mDayLabelsList.next(); |
787 | if ( !dayLabel ) | 789 | if ( !dayLabel ) |
788 | appendLabels = true; | 790 | appendLabels = true; |
789 | } | 791 | } |
790 | if ( appendLabels ) { | 792 | if ( appendLabels ) { |
791 | dayLabel = getNewDaylabel(); | 793 | dayLabel = getNewDaylabel(); |
792 | } | 794 | } |
793 | dayLabel->setMinimumWidth( 1 ); | 795 | dayLabel->setMinimumWidth( 1 ); |
794 | dayLabel->setMaximumWidth( 10240 ); | 796 | dayLabel->setMaximumWidth( 10240 ); |
795 | dayLabel->setFont( dlf ); | 797 | dayLabel->setFont( dlf ); |
796 | dayLabel->show(); | 798 | dayLabel->show(); |
797 | dayLabel->setAutoRepeat( false ); | 799 | dayLabel->setAutoRepeat( false ); |
798 | dayLabel->setNum( counter ); | 800 | dayLabel->setNum( counter ); |
799 | QString str; | 801 | QString str; |
800 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 802 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
801 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 803 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
802 | switch ( maxLen ) { | 804 | switch ( maxLen ) { |
803 | case 2: | 805 | case 2: |
804 | str = QString::number( date.day() ); | 806 | str = QString::number( date.day() ); |
805 | break; | 807 | break; |
806 | 808 | ||
807 | case 3: | 809 | case 3: |
808 | str = dayName.left( 1 ) +QString::number( date.day()); | 810 | str = dayName.left( 1 ) +QString::number( date.day()); |
809 | 811 | ||
810 | break; | 812 | break; |
811 | case 4: | 813 | case 4: |
812 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 814 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
813 | 815 | ||
814 | break; | 816 | break; |
815 | case 5: | 817 | case 5: |
816 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 818 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
817 | 819 | ||
818 | break; | 820 | break; |
819 | case 6: | 821 | case 6: |
820 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 822 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
821 | break; | 823 | break; |
822 | 824 | ||
823 | default: | 825 | default: |
824 | break; | 826 | break; |
825 | } | 827 | } |
826 | if ( oneday ) { | 828 | if ( oneday ) { |
827 | QString addString; | 829 | QString addString; |
828 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 830 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
829 | addString = i18n("Today"); | 831 | addString = i18n("Today"); |
830 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 832 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
831 | addString = i18n("Tomorrow"); | 833 | addString = i18n("Tomorrow"); |
832 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 834 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
833 | addString = i18n("Yesterday"); | 835 | addString = i18n("Yesterday"); |
834 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 836 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
835 | addString = i18n("Day before yesterday"); | 837 | addString = i18n("Day before yesterday"); |
836 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 838 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
837 | addString = i18n("Day after tomorrow"); | 839 | addString = i18n("Day after tomorrow"); |
838 | if ( !addString.isEmpty() ) { | 840 | if ( !addString.isEmpty() ) { |
839 | if ( QApplication::desktop()->width() < 640 ) | 841 | if ( QApplication::desktop()->width() < 640 ) |
840 | str = addString+", " + str; | 842 | str = addString+", " + str; |
841 | else | 843 | else |
842 | str = addString+", "+ KGlobal::locale()->formatDate( date, false); | 844 | str = addString+", "+ KGlobal::locale()->formatDate( date, false); |
843 | } else { | 845 | } else { |
844 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 846 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
845 | } | 847 | } |
846 | } | 848 | } |
847 | dayLabel->setText(str); | 849 | dayLabel->setText(str); |
848 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 850 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
849 | if (date == QDate::currentDate()) { | 851 | if (date == QDate::currentDate()) { |
850 | QFont bFont = dlf; | 852 | QFont bFont = dlf; |
851 | bFont.setBold( true ); | 853 | bFont.setBold( true ); |
852 | dayLabel->setFont(bFont); | 854 | dayLabel->setFont(bFont); |
853 | } | 855 | } |
854 | //dayLayout->addWidget(dayLabel); | 856 | //dayLayout->addWidget(dayLabel); |
855 | 857 | ||
856 | #ifndef KORG_NOPLUGINS | 858 | #ifndef KORG_NOPLUGINS |
857 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 859 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
858 | CalendarDecoration *it; | 860 | CalendarDecoration *it; |
859 | for(it = cds.first(); it; it = cds.next()) { | 861 | for(it = cds.first(); it; it = cds.next()) { |
860 | QString text = it->shortText( date ); | 862 | QString text = it->shortText( date ); |
861 | if ( !text.isEmpty() ) { | 863 | if ( !text.isEmpty() ) { |
862 | QLabel *label = new QLabel(text,mDayLabels); | 864 | QLabel *label = new QLabel(text,mDayLabels); |
863 | label->setAlignment(AlignCenter); | 865 | label->setAlignment(AlignCenter); |
864 | dayLayout->addWidget(label); | 866 | dayLayout->addWidget(label); |
865 | } | 867 | } |
866 | } | 868 | } |
867 | 869 | ||
868 | for(it = cds.first(); it; it = cds.next()) { | 870 | for(it = cds.first(); it; it = cds.next()) { |
869 | QWidget *wid = it->smallWidget(mDayLabels,date); | 871 | QWidget *wid = it->smallWidget(mDayLabels,date); |
870 | if ( wid ) { | 872 | if ( wid ) { |
871 | // wid->setHeight(20); | 873 | // wid->setHeight(20); |
872 | dayLayout->addWidget(wid); | 874 | dayLayout->addWidget(wid); |
873 | } | 875 | } |
874 | } | 876 | } |
875 | #endif | 877 | #endif |
876 | } | 878 | } |
877 | if ( ! appendLabels ) { | 879 | if ( ! appendLabels ) { |
878 | dayLabel = mDayLabelsList.next(); | 880 | dayLabel = mDayLabelsList.next(); |
879 | if ( !dayLabel ) | 881 | if ( !dayLabel ) |
880 | appendLabels = true; | 882 | appendLabels = true; |
881 | } | 883 | } |
882 | if ( appendLabels ) { | 884 | if ( appendLabels ) { |
883 | dayLabel = getNewDaylabel(); | 885 | dayLabel = getNewDaylabel(); |
884 | } | 886 | } |
885 | //dayLabel->hide();//test only | 887 | //dayLabel->hide();//test only |
886 | 888 | ||
887 | dayLabel->setText(">"); | 889 | dayLabel->setText(">"); |
888 | dayLabel->setFont( dlf ); | 890 | dayLabel->setFont( dlf ); |
889 | dayLabel->setAutoRepeat( true ); | 891 | dayLabel->setAutoRepeat( true ); |
890 | dayLabel->show(); | 892 | dayLabel->show(); |
891 | dayLabel->setNum( -2 ); | 893 | dayLabel->setNum( -2 ); |
892 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); | 894 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); |
893 | 895 | ||
894 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 896 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
895 | if ( !appendLabels ) { | 897 | if ( !appendLabels ) { |
896 | dayLabel = mDayLabelsList.next(); | 898 | dayLabel = mDayLabelsList.next(); |
897 | while ( dayLabel ) { | 899 | while ( dayLabel ) { |
898 | //qDebug("!dayLabel %d",dayLabel ); | 900 | //qDebug("!dayLabel %d",dayLabel ); |
899 | dayLabel->hide(); | 901 | dayLabel->hide(); |
900 | dayLabel = mDayLabelsList.next(); | 902 | dayLabel = mDayLabelsList.next(); |
901 | } | 903 | } |
902 | } | 904 | } |
903 | 905 | ||
904 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); | 906 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); |
905 | } | 907 | } |
906 | 908 | ||
907 | int KOAgendaView::maxDatesHint() | 909 | int KOAgendaView::maxDatesHint() |
908 | { | 910 | { |
909 | // Not sure about the max number of events, so return 0 for now. | 911 | // Not sure about the max number of events, so return 0 for now. |
910 | return 0; | 912 | return 0; |
911 | } | 913 | } |