-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 | |||
@@ -656,128 +656,130 @@ void KOAgendaView::resizeEvent( QResizeEvent* e ) | |||
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; |