author | zautrix <zautrix> | 2005-06-25 02:23:09 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-25 02:23:09 (UTC) |
commit | 1d0b53abc70e66708d93b7081a21a7689b1a1303 (patch) (unidiff) | |
tree | 2a79eab02c3560af43af16162e2004adf507fb0f /korganizer/koagendaview.cpp | |
parent | ab93fa0a7cd97beada9475f6099bf6083547f0d6 (diff) | |
download | kdepimpi-1d0b53abc70e66708d93b7081a21a7689b1a1303.zip kdepimpi-1d0b53abc70e66708d93b7081a21a7689b1a1303.tar.gz kdepimpi-1d0b53abc70e66708d93b7081a21a7689b1a1303.tar.bz2 |
fixx
-rw-r--r-- | korganizer/koagendaview.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 93ff55e..c851ab5 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -577,230 +577,232 @@ void KOAgendaView::toggleAllDay() | |||
577 | mSplitterAgenda->firstHandle()->toggle(); | 577 | mSplitterAgenda->firstHandle()->toggle(); |
578 | } | 578 | } |
579 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 579 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
580 | { | 580 | { |
581 | calendar()->addIncidence( inc ); | 581 | calendar()->addIncidence( inc ); |
582 | 582 | ||
583 | if ( incOld ) { | 583 | if ( incOld ) { |
584 | if ( incOld->typeID() == todoID ) | 584 | if ( incOld->typeID() == todoID ) |
585 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 585 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
586 | else | 586 | else |
587 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 587 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
588 | } | 588 | } |
589 | 589 | ||
590 | } | 590 | } |
591 | 591 | ||
592 | KOAgendaView::~KOAgendaView() | 592 | KOAgendaView::~KOAgendaView() |
593 | { | 593 | { |
594 | delete mAllAgendaPopup; | 594 | delete mAllAgendaPopup; |
595 | //delete mAllDayAgendaPopup; | 595 | //delete mAllDayAgendaPopup; |
596 | delete KOAgendaItem::paintPix(); | 596 | delete KOAgendaItem::paintPix(); |
597 | delete KOAgendaItem::paintPixSel(); | 597 | delete KOAgendaItem::paintPixSel(); |
598 | } | 598 | } |
599 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 599 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
600 | { | 600 | { |
601 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 601 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
602 | bool uc = false; | 602 | bool uc = false; |
603 | int ow = e->oldSize().width(); | 603 | int ow = e->oldSize().width(); |
604 | int oh = e->oldSize().height(); | 604 | int oh = e->oldSize().height(); |
605 | int w = e->size().width(); | 605 | int w = e->size().width(); |
606 | int h = e->size().height(); | 606 | int h = e->size().height(); |
607 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 607 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
608 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 608 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
609 | uc = true; | 609 | uc = true; |
610 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 610 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
611 | } | 611 | } |
612 | mUpcomingWidth = e->size().width() ; | 612 | mUpcomingWidth = e->size().width() ; |
613 | if ( mBlockUpdating || uc ) { | 613 | if ( mBlockUpdating || uc ) { |
614 | mBlockUpdating = false; | 614 | mBlockUpdating = false; |
615 | //mAgenda->setMinimumSize(800 , 600 ); | 615 | //mAgenda->setMinimumSize(800 , 600 ); |
616 | //qDebug("mAgenda->resize+++++++++++++++ "); | 616 | //qDebug("mAgenda->resize+++++++++++++++ "); |
617 | updateConfig(); | 617 | updateConfig(); |
618 | //qDebug("KOAgendaView::Updating now possible "); | 618 | //qDebug("KOAgendaView::Updating now possible "); |
619 | } else | 619 | } else |
620 | createDayLabels(); | 620 | createDayLabels(); |
621 | //qDebug("resizeEvent end "); | 621 | //qDebug("resizeEvent end "); |
622 | 622 | ||
623 | } | 623 | } |
624 | void KOAgendaView::slotDaylabelClicked( int num ) | 624 | void KOAgendaView::slotDaylabelClicked( int num ) |
625 | { | 625 | { |
626 | 626 | ||
627 | QDate firstDate = mSelectedDates.first(); | 627 | QDate firstDate = mSelectedDates.first(); |
628 | if ( num == -1 ) | 628 | if ( num == -1 ) |
629 | emit showDateView( 6, firstDate ); | 629 | emit showDateView( 6, firstDate ); |
630 | else if (num >= 0 ) { | 630 | else if (num >= 0 ) { |
631 | if ( mSelectedDates.count() == 1) | 631 | if ( mSelectedDates.count() == 1) |
632 | emit showDateView( 9, firstDate.addDays( num ) ); | 632 | emit showDateView( 9, firstDate.addDays( num ) ); |
633 | else | 633 | else |
634 | emit showDateView( 3, firstDate.addDays( num ) ); | 634 | emit showDateView( 3, firstDate.addDays( num ) ); |
635 | } | 635 | } |
636 | else | 636 | else |
637 | showDateView( 10, firstDate.addDays(1) ); | 637 | showDateView( 10, firstDate.addDays(1) ); |
638 | } | 638 | } |
639 | 639 | ||
640 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 640 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
641 | { | 641 | { |
642 | 642 | ||
643 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 643 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
644 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 644 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
645 | mDayLabelsList.append( dayLabel ); | 645 | mDayLabelsList.append( dayLabel ); |
646 | mLayoutDayLabels->addWidget(dayLabel); | 646 | mLayoutDayLabels->addWidget(dayLabel); |
647 | return dayLabel ; | 647 | return dayLabel ; |
648 | } | 648 | } |
649 | 649 | ||
650 | void KOAgendaView::createDayLabels() | 650 | void KOAgendaView::createDayLabels() |
651 | { | 651 | { |
652 | 652 | ||
653 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 653 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
654 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 654 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
655 | return; | 655 | return; |
656 | 656 | ||
657 | } | 657 | } |
658 | int newHight; | 658 | int newHight; |
659 | if ( !mSelectedDates.count()) | 659 | if ( !mSelectedDates.count()) |
660 | return; | 660 | return; |
661 | 661 | ||
662 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 662 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
663 | // It would remove some flickering and gain speed (since this is called by | 663 | // It would remove some flickering and gain speed (since this is called by |
664 | // each updateView() call) | 664 | // each updateView() call) |
665 | 665 | ||
666 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; | 666 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; |
667 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 667 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
668 | if ( maxWid < 20 ) | 668 | if ( maxWid < 20 ) |
669 | maxWid = 20; | 669 | maxWid = 20; |
670 | 670 | ||
671 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 671 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
672 | QFontMetrics fm ( dlf ); | 672 | QFontMetrics fm ( dlf ); |
673 | dlf.setBold( true ); | ||
673 | int selCount = mSelectedDates.count(); | 674 | int selCount = mSelectedDates.count(); |
674 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; | 675 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; |
675 | QString dayTest = "Mon 20"; | 676 | QString dayTest = "Mon 20"; |
676 | //QString dayTest = "Mon 20"; | 677 | //QString dayTest = "Mon 20"; |
677 | int wid = fm.width( dayTest ); | 678 | int wid = fm.width( dayTest ); |
678 | //maxWid -= ( selCount * 3 ); //working for QLabels | 679 | //maxWid -= ( selCount * 3 ); //working for QLabels |
679 | if ( QApplication::desktop()->width() <= 320 ) | 680 | if ( QApplication::desktop()->width() <= 320 ) |
680 | maxWid -= ( selCount * 3 ); //working for QPushButton | 681 | maxWid -= ( selCount * 3 ); //working for QPushButton |
681 | else | 682 | else |
682 | maxWid -= ( selCount * 3 ); //working for QPushButton | 683 | maxWid -= ( selCount * 4 ); //working for QPushButton |
683 | if ( maxWid < 0 ) | 684 | if ( maxWid < 0 ) |
684 | maxWid = 20; | 685 | maxWid = 20; |
685 | int needWid = wid * selCount; | 686 | int needWid = wid * selCount; |
686 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 687 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
687 | //if ( needWid > maxWid ) | 688 | //if ( needWid > maxWid ) |
688 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 689 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
689 | while ( needWid > maxWid ) { | 690 | while ( needWid > maxWid ) { |
690 | dayTest = dayTest.left( dayTest.length() - 1 ); | 691 | dayTest = dayTest.left( dayTest.length() - 1 ); |
691 | wid = fm.width( dayTest ); | 692 | wid = fm.width( dayTest ); |
692 | needWid = wid * selCount; | 693 | needWid = wid * selCount; |
693 | } | 694 | } |
694 | int maxLen = dayTest.length(); | 695 | int maxLen = dayTest.length(); |
695 | int fontPoint = dlf.pointSize(); | 696 | int fontPoint = dlf.pointSize(); |
696 | if ( maxLen < 2 ) { | 697 | if ( maxLen < 2 ) { |
697 | int fontPoint = dlf.pointSize(); | 698 | int fontPoint = dlf.pointSize(); |
698 | while ( fontPoint > 4 ) { | 699 | while ( fontPoint > 4 ) { |
699 | --fontPoint; | 700 | --fontPoint; |
700 | dlf.setPointSize( fontPoint ); | 701 | dlf.setPointSize( fontPoint ); |
701 | QFontMetrics f( dlf ); | 702 | QFontMetrics f( dlf ); |
702 | wid = f.width( "30" ); | 703 | wid = f.width( "30" ); |
703 | needWid = wid * selCount; | 704 | needWid = wid * selCount; |
704 | if ( needWid < maxWid ) | 705 | if ( needWid < maxWid ) |
705 | break; | 706 | break; |
706 | } | 707 | } |
707 | maxLen = 2; | 708 | maxLen = 2; |
708 | } | 709 | } |
709 | //qDebug("Max len %d ", dayTest.length() ); | 710 | //qDebug("Max len %d ", dayTest.length() ); |
710 | 711 | if ( !KOPrefs::instance()->mTimeLabelsFont.bold() ) | |
712 | dlf.setBold( false ); | ||
711 | QFontMetrics tempF( dlf ); | 713 | QFontMetrics tempF( dlf ); |
712 | newHight = tempF.height(); | 714 | newHight = tempF.height(); |
713 | mDayLabels->setFont( dlf ); | 715 | mDayLabels->setFont( dlf ); |
714 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 716 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
715 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 717 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
716 | //mLayoutDayLabels->addSpacing( 2 ); | 718 | //mLayoutDayLabels->addSpacing( 2 ); |
717 | // QFont lFont = dlf; | 719 | // QFont lFont = dlf; |
718 | bool appendLabels = false; | 720 | bool appendLabels = false; |
719 | KOAgendaButton *dayLabel; | 721 | KOAgendaButton *dayLabel; |
720 | dayLabel = mDayLabelsList.first(); | 722 | dayLabel = mDayLabelsList.first(); |
721 | if ( !dayLabel ) { | 723 | if ( !dayLabel ) { |
722 | appendLabels = true; | 724 | appendLabels = true; |
723 | dayLabel = getNewDaylabel(); | 725 | dayLabel = getNewDaylabel(); |
724 | } | 726 | } |
725 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); | 727 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); |
726 | dayLabel->setFont( dlf ); | 728 | dayLabel->setFont( dlf ); |
727 | dayLabel->setNum( -1 ); | 729 | dayLabel->setNum( -1 ); |
728 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 730 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
729 | 731 | ||
730 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 732 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
731 | dayLabel->show(); | 733 | dayLabel->show(); |
732 | DateList::ConstIterator dit; | 734 | DateList::ConstIterator dit; |
733 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 735 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
734 | int counter = -1; | 736 | int counter = -1; |
735 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 737 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
736 | ++counter; | 738 | ++counter; |
737 | QDate date = *dit; | 739 | QDate date = *dit; |
738 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 740 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
739 | if ( ! appendLabels ) { | 741 | if ( ! appendLabels ) { |
740 | dayLabel = mDayLabelsList.next(); | 742 | dayLabel = mDayLabelsList.next(); |
741 | if ( !dayLabel ) | 743 | if ( !dayLabel ) |
742 | appendLabels = true; | 744 | appendLabels = true; |
743 | } | 745 | } |
744 | if ( appendLabels ) { | 746 | if ( appendLabels ) { |
745 | dayLabel = getNewDaylabel(); | 747 | dayLabel = getNewDaylabel(); |
746 | } | 748 | } |
747 | dayLabel->setMinimumWidth( 1 ); | 749 | dayLabel->setMinimumWidth( 1 ); |
748 | dayLabel->setMaximumWidth( 10240 ); | 750 | dayLabel->setMaximumWidth( 10240 ); |
749 | dayLabel->setFont( dlf ); | 751 | dayLabel->setFont( dlf ); |
750 | dayLabel->show(); | 752 | dayLabel->show(); |
751 | dayLabel->setAutoRepeat( false ); | 753 | dayLabel->setAutoRepeat( false ); |
752 | dayLabel->setNum( counter ); | 754 | dayLabel->setNum( counter ); |
753 | QString str; | 755 | QString str; |
754 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 756 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
755 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 757 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
756 | switch ( maxLen ) { | 758 | switch ( maxLen ) { |
757 | case 2: | 759 | case 2: |
758 | str = QString::number( date.day() ); | 760 | str = QString::number( date.day() ); |
759 | break; | 761 | break; |
760 | 762 | ||
761 | case 3: | 763 | case 3: |
762 | str = dayName.left( 1 ) +QString::number( date.day()); | 764 | str = dayName.left( 1 ) +QString::number( date.day()); |
763 | 765 | ||
764 | break; | 766 | break; |
765 | case 4: | 767 | case 4: |
766 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 768 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
767 | 769 | ||
768 | break; | 770 | break; |
769 | case 5: | 771 | case 5: |
770 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 772 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
771 | 773 | ||
772 | break; | 774 | break; |
773 | case 6: | 775 | case 6: |
774 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 776 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
775 | break; | 777 | break; |
776 | 778 | ||
777 | default: | 779 | default: |
778 | break; | 780 | break; |
779 | } | 781 | } |
780 | if ( oneday ) { | 782 | if ( oneday ) { |
781 | QString addString; | 783 | QString addString; |
782 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 784 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
783 | addString = i18n("Today"); | 785 | addString = i18n("Today"); |
784 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 786 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
785 | addString = i18n("Tomorrow"); | 787 | addString = i18n("Tomorrow"); |
786 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 788 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
787 | addString = i18n("Yesterday"); | 789 | addString = i18n("Yesterday"); |
788 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 790 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
789 | addString = i18n("Day before yesterday"); | 791 | addString = i18n("Day before yesterday"); |
790 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 792 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
791 | addString = i18n("Day after tomorrow"); | 793 | addString = i18n("Day after tomorrow"); |
792 | if ( !addString.isEmpty() ) { | 794 | if ( !addString.isEmpty() ) { |
793 | str = addString+", " + str; | 795 | str = addString+", " + str; |
794 | } else { | 796 | } else { |
795 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 797 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
796 | } | 798 | } |
797 | } | 799 | } |
798 | dayLabel->setText(str); | 800 | dayLabel->setText(str); |
799 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 801 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
800 | if (date == QDate::currentDate()) { | 802 | if (date == QDate::currentDate()) { |
801 | QFont bFont = dlf; | 803 | QFont bFont = dlf; |
802 | bFont.setBold( true ); | 804 | bFont.setBold( true ); |
803 | dayLabel->setFont(bFont); | 805 | dayLabel->setFont(bFont); |
804 | } | 806 | } |
805 | //dayLayout->addWidget(dayLabel); | 807 | //dayLayout->addWidget(dayLabel); |
806 | 808 | ||