summaryrefslogtreecommitdiffabout
path: root/korganizer/komonthview.cpp
Unidiff
Diffstat (limited to 'korganizer/komonthview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/komonthview.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 6646b98..4cff23a 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -563,117 +563,116 @@ void MonthViewCell::insertTodo(Todo *todo)
563} 563}
564void MonthViewCell::finishUpdateCell() 564void MonthViewCell::finishUpdateCell()
565{ 565{
566#ifdef DESKTOP_VERSION 566#ifdef DESKTOP_VERSION
567 if (mToolTip != "") 567 if (mToolTip != "")
568 QToolTip::add(this,mToolTip,toolTipGroup(),""); 568 QToolTip::add(this,mToolTip,toolTipGroup(),"");
569#endif 569#endif
570 570
571 //setMyPalette(); 571 //setMyPalette();
572 setMyPalette(); 572 setMyPalette();
573 QString text; 573 QString text;
574 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 574 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
575 if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 575 if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
576 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 576 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
577 mLabel->resize( mLabelBigSize ); 577 mLabel->resize( mLabelBigSize );
578 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 578 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
579 } else { 579 } else {
580 mLabel->resize( mLabelSize ); 580 mLabel->resize( mLabelSize );
581 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 581 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
582 } 582 }
583 583
584 mLabel->setText( text ); 584 mLabel->setText( text );
585 resizeEvent( 0 ); 585 resizeEvent( 0 );
586} 586}
587void MonthViewCell::updateCell() 587void MonthViewCell::updateCell()
588{ 588{
589 if ( !mMonthView->isUpdatePossible() ) 589 if ( !mMonthView->isUpdatePossible() )
590 return; 590 return;
591 startUpdateCell(); 591 startUpdateCell();
592 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 592 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
593 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 593 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
594 Event *event; 594 Event *event;
595 for( event = events.first(); event; event = events.next() ) { // for event 595 for( event = events.first(); event; event = events.next() ) { // for event
596 insertEvent(event); 596 insertEvent(event);
597 } 597 }
598 // insert due todos 598 // insert due todos
599 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 599 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
600 Todo *todo; 600 Todo *todo;
601 for(todo = todos.first(); todo; todo = todos.next()) { 601 for(todo = todos.first(); todo; todo = todos.next()) {
602 insertTodo( todo ); 602 insertTodo( todo );
603 } 603 }
604 finishUpdateCell(); 604 finishUpdateCell();
605 // if ( isVisible()) 605 // if ( isVisible())
606 //qApp->processEvents(); 606 //qApp->processEvents();
607} 607}
608 608
609void MonthViewCell::updateConfig() 609void MonthViewCell::updateConfig()
610{ 610{
611 qDebug("MonthViewCell::updateConfig() ");
612 setFont( KOPrefs::instance()->mMonthViewFont ); 611 setFont( KOPrefs::instance()->mMonthViewFont );
613 612
614 QFontMetrics fm( font() ); 613 QFontMetrics fm( font() );
615 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 614 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
616 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 615 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
617 mHolidayPalette = mStandardPalette; 616 mHolidayPalette = mStandardPalette;
618 mPrimaryPalette = mStandardPalette; 617 mPrimaryPalette = mStandardPalette;
619 mNonPrimaryPalette = mStandardPalette; 618 mNonPrimaryPalette = mStandardPalette;
620 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 619 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
621 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 620 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
622 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 621 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
623 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 622 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
624 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 623 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
625 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 624 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
626 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 625 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
627 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 626 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
628 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 627 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
629 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 628 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
630 } 629 }
631 updateCell(); 630 //updateCell();
632} 631}
633 632
634void MonthViewCell::enableScrollBars( bool enabled ) 633void MonthViewCell::enableScrollBars( bool enabled )
635{ 634{
636 if ( enabled ) { 635 if ( enabled ) {
637 mItemList->setVScrollBarMode(QScrollView::Auto); 636 mItemList->setVScrollBarMode(QScrollView::Auto);
638 mItemList->setHScrollBarMode(QScrollView::Auto); 637 mItemList->setHScrollBarMode(QScrollView::Auto);
639 } else { 638 } else {
640 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 639 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
641 mItemList->setHScrollBarMode(QScrollView::AlwaysOff); 640 mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
642 } 641 }
643} 642}
644 643
645Incidence *MonthViewCell::selectedIncidence() 644Incidence *MonthViewCell::selectedIncidence()
646{ 645{
647 int index = mItemList->currentItem(); 646 int index = mItemList->currentItem();
648 if ( index < 0 ) return 0; 647 if ( index < 0 ) return 0;
649 648
650 MonthViewItem *item = 649 MonthViewItem *item =
651 static_cast<MonthViewItem *>( mItemList->item( index ) ); 650 static_cast<MonthViewItem *>( mItemList->item( index ) );
652 651
653 if ( !item ) return 0; 652 if ( !item ) return 0;
654 653
655 return item->incidence(); 654 return item->incidence();
656} 655}
657 656
658QDate MonthViewCell::selectedIncidenceDate() 657QDate MonthViewCell::selectedIncidenceDate()
659{ 658{
660 QDate qd; 659 QDate qd;
661 int index = mItemList->currentItem(); 660 int index = mItemList->currentItem();
662 if ( index < 0 ) return qd; 661 if ( index < 0 ) return qd;
663 662
664 MonthViewItem *item = 663 MonthViewItem *item =
665 static_cast<MonthViewItem *>( mItemList->item( index ) ); 664 static_cast<MonthViewItem *>( mItemList->item( index ) );
666 665
667 if ( !item ) return qd; 666 if ( !item ) return qd;
668 667
669 return item->incidenceDate(); 668 return item->incidenceDate();
670} 669}
671 670
672void MonthViewCell::deselect() 671void MonthViewCell::deselect()
673{ 672{
674 mItemList->clearSelection(); 673 mItemList->clearSelection();
675 enableScrollBars( false ); 674 enableScrollBars( false );
676 // updateCell(); 675 // updateCell();
677} 676}
678void MonthViewCell::select() 677void MonthViewCell::select()
679{ 678{
@@ -852,96 +851,97 @@ QPtrList<Incidence> KOMonthView::selectedIncidences()
852} 851}
853 852
854DateList KOMonthView::selectedDates() 853DateList KOMonthView::selectedDates()
855{ 854{
856 DateList selected; 855 DateList selected;
857 856
858 if ( mSelectedCell ) { 857 if ( mSelectedCell ) {
859 QDate qd = mSelectedCell->selectedIncidenceDate(); 858 QDate qd = mSelectedCell->selectedIncidenceDate();
860 if ( qd.isValid() ) selected.append( qd ); 859 if ( qd.isValid() ) selected.append( qd );
861 } 860 }
862 861
863 return selected; 862 return selected;
864} 863}
865 864
866void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 865void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
867 const QDate &td) 866 const QDate &td)
868{ 867{
869#ifndef KORG_NOPRINTER 868#ifndef KORG_NOPRINTER
870 calPrinter->preview(CalPrinter::Month, fd, td); 869 calPrinter->preview(CalPrinter::Month, fd, td);
871#endif 870#endif
872} 871}
873 872
874void KOMonthView::updateConfig() 873void KOMonthView::updateConfig()
875{ 874{
876 875
877 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 876 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
878 877
879 QFontMetrics fontmetric(mDayLabels[0]->font()); 878 QFontMetrics fontmetric(mDayLabels[0]->font());
880 mWidthLongDayLabel = 0; 879 mWidthLongDayLabel = 0;
881 880
882 for (int i = 0; i < 7; i++) { 881 for (int i = 0; i < 7; i++) {
883 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 882 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
884 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 883 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
885 } 884 }
886 bool temp = mShowSatSunComp ; 885 bool temp = mShowSatSunComp ;
887 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 886 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
888 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 887 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
889 computeLayout(); 888 computeLayout();
890 updateDayLabels(); 889 updateDayLabels();
891 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 890 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
892 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 891 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
893 //resizeEvent( 0 ); 892 //resizeEvent( 0 );
894 for (uint i = 0; i < mCells.count(); ++i) { 893 for (uint i = 0; i < mCells.count(); ++i) {
895 mCells[i]->updateConfig(); 894 mCells[i]->updateConfig();
896 } 895 }
897#ifdef DESKTOP_VERSION 896#ifdef DESKTOP_VERSION
898 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 897 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
899#endif 898#endif
899 updateView();
900} 900}
901 901
902void KOMonthView::updateDayLabels() 902void KOMonthView::updateDayLabels()
903{ 903{
904 904
905 for (int i = 0; i < 7; i++) { 905 for (int i = 0; i < 7; i++) {
906 if (mWeekStartsMonday) { 906 if (mWeekStartsMonday) {
907 bool show = mShortDayLabels; 907 bool show = mShortDayLabels;
908 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) 908 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() )
909 show = true; 909 show = true;
910 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 910 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
911 } else { 911 } else {
912 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); 912 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
913 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 913 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
914 914
915 } 915 }
916 } 916 }
917} 917}
918 918
919void KOMonthView::showDates(const QDate &start, const QDate &) 919void KOMonthView::showDates(const QDate &start, const QDate &)
920{ 920{
921 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 921 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
922 922
923 923
924 mStartDate = start; 924 mStartDate = start;
925 925
926 int startWeekDay = mWeekStartsMonday ? 1 : 7; 926 int startWeekDay = mWeekStartsMonday ? 1 : 7;
927 927
928 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 928 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
929 mStartDate = mStartDate.addDays( -1 ); 929 mStartDate = mStartDate.addDays( -1 );
930 } 930 }
931 931
932 bool primary = false; 932 bool primary = false;
933 uint i; 933 uint i;
934 for( i = 0; i < mCells.size(); ++i ) { 934 for( i = 0; i < mCells.size(); ++i ) {
935 QDate date = mStartDate.addDays( i ); 935 QDate date = mStartDate.addDays( i );
936 mCells[i]->setDate( date ); 936 mCells[i]->setDate( date );
937 937
938#ifndef KORG_NOPLUGINS 938#ifndef KORG_NOPLUGINS
939 // add holiday, if present 939 // add holiday, if present
940 QString hstring(KOCore::self()->holiday(date)); 940 QString hstring(KOCore::self()->holiday(date));
941 mCells[i]->setHoliday( hstring ); 941 mCells[i]->setHoliday( hstring );
942#endif 942#endif
943 943
944 } 944 }
945 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 945 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
946 for( i = 0; i < 6; ++i ) { 946 for( i = 0; i < 6; ++i ) {
947 int wno; 947 int wno;