-rw-r--r-- | korganizer/komonthview.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 9b9e164..6ae4c6f 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -745,98 +745,100 @@ void MonthViewCell::newEvent() | |||
745 | emit newEventSignal( dt ); | 745 | emit newEventSignal( dt ); |
746 | } | 746 | } |
747 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 747 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
748 | { | 748 | { |
749 | static QListBoxItem * lastClicked = 0; | 749 | static QListBoxItem * lastClicked = 0; |
750 | if ( item == 0 ) { | 750 | if ( item == 0 ) { |
751 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 751 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
752 | emit newEventSignal( dt ); | 752 | emit newEventSignal( dt ); |
753 | return; | 753 | return; |
754 | } | 754 | } |
755 | /* | 755 | /* |
756 | if ( lastClicked ) | 756 | if ( lastClicked ) |
757 | if ( ! item ) { | 757 | if ( ! item ) { |
758 | if ( lastClicked->listBox() != item->listBox() ) | 758 | if ( lastClicked->listBox() != item->listBox() ) |
759 | lastClicked->listBox()->clearSelection(); | 759 | lastClicked->listBox()->clearSelection(); |
760 | } | 760 | } |
761 | */ | 761 | */ |
762 | 762 | ||
763 | mMonthView->setSelectedCell( this ); | 763 | mMonthView->setSelectedCell( this ); |
764 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); | 764 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); |
765 | select(); | 765 | select(); |
766 | } | 766 | } |
767 | 767 | ||
768 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 768 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
769 | { | 769 | { |
770 | if ( !item ) return; | 770 | if ( !item ) return; |
771 | 771 | ||
772 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 772 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
773 | Incidence *incidence = eventItem->incidence(); | 773 | Incidence *incidence = eventItem->incidence(); |
774 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 774 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
775 | } | 775 | } |
776 | 776 | ||
777 | void MonthViewCell::selection( QListBoxItem *item ) | 777 | void MonthViewCell::selection( QListBoxItem *item ) |
778 | { | 778 | { |
779 | if ( !item ) return; | 779 | if ( !item ) return; |
780 | 780 | ||
781 | mMonthView->setSelectedCell( this ); | 781 | mMonthView->setSelectedCell( this ); |
782 | } | 782 | } |
783 | 783 | ||
784 | 784 | ||
785 | // ******************************************************************************* | 785 | // ******************************************************************************* |
786 | // ******************************************************************************* | 786 | // ******************************************************************************* |
787 | // ******************************************************************************* | 787 | // ******************************************************************************* |
788 | 788 | ||
789 | 789 | ||
790 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 790 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
791 | : KOEventView( calendar, parent, name ), | 791 | : KOEventView( calendar, parent, name ), |
792 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 792 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
793 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 793 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
794 | { | 794 | { |
795 | mShortDayLabelsM = false; | ||
796 | mShortDayLabelsW = false; | ||
795 | skipResize = false; | 797 | skipResize = false; |
796 | clPending = true; | 798 | clPending = true; |
797 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 799 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
798 | mWidStack = new QWidgetStack( this ); | 800 | mWidStack = new QWidgetStack( this ); |
799 | QVBoxLayout* hb = new QVBoxLayout( this ); | 801 | QVBoxLayout* hb = new QVBoxLayout( this ); |
800 | mMonthView = new QWidget( mWidStack ); | 802 | mMonthView = new QWidget( mWidStack ); |
801 | mWeekView = new QWidget( mWidStack ); | 803 | mWeekView = new QWidget( mWidStack ); |
802 | #if QT_VERSION >= 0x030000 | 804 | #if QT_VERSION >= 0x030000 |
803 | mWidStack->addWidget(mMonthView ); | 805 | mWidStack->addWidget(mMonthView ); |
804 | mWidStack->addWidget(mWeekView ); | 806 | mWidStack->addWidget(mWeekView ); |
805 | #else | 807 | #else |
806 | mWidStack->addWidget( mMonthView, 1 ); | 808 | mWidStack->addWidget( mMonthView, 1 ); |
807 | mWidStack->addWidget( mWeekView , 1 ); | 809 | mWidStack->addWidget( mWeekView , 1 ); |
808 | #endif | 810 | #endif |
809 | hb->addWidget( mNavigatorBar ); | 811 | hb->addWidget( mNavigatorBar ); |
810 | hb->addWidget( mWidStack ); | 812 | hb->addWidget( mWidStack ); |
811 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 813 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
812 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 814 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
813 | if ( mShowWeekView ) | 815 | if ( mShowWeekView ) |
814 | mWeekStartsMonday = true; | 816 | mWeekStartsMonday = true; |
815 | updatePossible = false; | 817 | updatePossible = false; |
816 | //updatePossible = true; | 818 | //updatePossible = true; |
817 | mCells.setAutoDelete( true ); | 819 | mCells.setAutoDelete( true ); |
818 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 820 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
819 | mDayLabels.resize( mDaysPerWeek ); | 821 | mDayLabels.resize( mDaysPerWeek ); |
820 | mDayLabelsW.resize( mDaysPerWeek ); | 822 | mDayLabelsW.resize( mDaysPerWeek ); |
821 | QFont bfont = font(); | 823 | QFont bfont = font(); |
822 | if ( QApplication::desktop()->width() < 650 ) { | 824 | if ( QApplication::desktop()->width() < 650 ) { |
823 | bfont.setPointSize( bfont.pointSize() - 2 ); | 825 | bfont.setPointSize( bfont.pointSize() - 2 ); |
824 | } | 826 | } |
825 | bfont.setBold( true ); | 827 | bfont.setBold( true ); |
826 | int i; | 828 | int i; |
827 | 829 | ||
828 | for( i = 0; i < mDaysPerWeek; i++ ) { | 830 | for( i = 0; i < mDaysPerWeek; i++ ) { |
829 | QLabel *label = new QLabel( mMonthView ); | 831 | QLabel *label = new QLabel( mMonthView ); |
830 | label->setFont(bfont); | 832 | label->setFont(bfont); |
831 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 833 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
832 | label->setLineWidth(1); | 834 | label->setLineWidth(1); |
833 | label->setAlignment(AlignCenter); | 835 | label->setAlignment(AlignCenter); |
834 | mDayLabels.insert( i, label ); | 836 | mDayLabels.insert( i, label ); |
835 | label = new QLabel( mWeekView ); | 837 | label = new QLabel( mWeekView ); |
836 | label->setFont(bfont); | 838 | label->setFont(bfont); |
837 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 839 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
838 | label->setLineWidth(1); | 840 | label->setLineWidth(1); |
839 | label->setAlignment(AlignCenter); | 841 | label->setAlignment(AlignCenter); |
840 | mDayLabelsW.insert( i, label ); | 842 | mDayLabelsW.insert( i, label ); |
841 | } | 843 | } |
842 | 844 | ||
@@ -1005,116 +1007,116 @@ void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | |||
1005 | } | 1007 | } |
1006 | 1008 | ||
1007 | void KOMonthView::updateConfig() | 1009 | void KOMonthView::updateConfig() |
1008 | { | 1010 | { |
1009 | 1011 | ||
1010 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1012 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1011 | 1013 | ||
1012 | if ( mShowWeekView ) { | 1014 | if ( mShowWeekView ) { |
1013 | mWeekStartsMonday = true; | 1015 | mWeekStartsMonday = true; |
1014 | } | 1016 | } |
1015 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1017 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1016 | mWidthLongDayLabel = 0; | 1018 | mWidthLongDayLabel = 0; |
1017 | 1019 | ||
1018 | for (int i = 0; i < 7; i++) { | 1020 | for (int i = 0; i < 7; i++) { |
1019 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1021 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1020 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1022 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1021 | } | 1023 | } |
1022 | bool temp = mShowSatSunComp ; | 1024 | bool temp = mShowSatSunComp ; |
1023 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1025 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1024 | if ( ! mShowWeekView ) { | 1026 | if ( ! mShowWeekView ) { |
1025 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1027 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1026 | computeLayout(); | 1028 | computeLayout(); |
1027 | } | 1029 | } |
1028 | updateDayLabels(); | 1030 | updateDayLabels(); |
1029 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1031 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1030 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1032 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1031 | //resizeEvent( 0 ); | 1033 | //resizeEvent( 0 ); |
1032 | for (uint i = 0; i < mCells.count(); ++i) { | 1034 | for (uint i = 0; i < mCells.count(); ++i) { |
1033 | mCells[i]->updateConfig(); | 1035 | mCells[i]->updateConfig(); |
1034 | } | 1036 | } |
1035 | 1037 | ||
1036 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1038 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1037 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1039 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1038 | } | 1040 | } |
1039 | #ifdef DESKTOP_VERSION | 1041 | #ifdef DESKTOP_VERSION |
1040 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1042 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1041 | #endif | 1043 | #endif |
1042 | updateView(); | 1044 | updateView(); |
1043 | } | 1045 | } |
1044 | 1046 | ||
1045 | void KOMonthView::updateDayLabels() | 1047 | void KOMonthView::updateDayLabels() |
1046 | { | 1048 | { |
1047 | 1049 | ||
1048 | QPtrVector<QLabel> *mDayLabelsT; | 1050 | QPtrVector<QLabel> *mDayLabelsT; |
1049 | 1051 | ||
1050 | mDayLabelsT = &mDayLabelsW; | 1052 | mDayLabelsT = &mDayLabelsW; |
1051 | for (int i = 0; i < 7; i++) { | 1053 | for (int i = 0; i < 7; i++) { |
1052 | if (mWeekStartsMonday) { | 1054 | if (mWeekStartsMonday) { |
1053 | bool show = mShortDayLabels; | 1055 | bool show = mShortDayLabelsW; |
1054 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1056 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1055 | show = true; | 1057 | show = true; |
1056 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1058 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1057 | } else { | 1059 | } else { |
1058 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); | 1060 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); |
1059 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | 1061 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); |
1060 | 1062 | ||
1061 | } | 1063 | } |
1062 | } | 1064 | } |
1063 | mDayLabelsT = &mDayLabels; | 1065 | mDayLabelsT = &mDayLabels; |
1064 | for (int i = 0; i < 7; i++) { | 1066 | for (int i = 0; i < 7; i++) { |
1065 | if (mWeekStartsMonday) { | 1067 | if (mWeekStartsMonday) { |
1066 | bool show = mShortDayLabels; | 1068 | bool show = mShortDayLabelsM; |
1067 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1069 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1068 | show = true; | 1070 | show = true; |
1069 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1071 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1070 | } else { | 1072 | } else { |
1071 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); | 1073 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1072 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | 1074 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1073 | 1075 | ||
1074 | } | 1076 | } |
1075 | } | 1077 | } |
1076 | 1078 | ||
1077 | } | 1079 | } |
1078 | 1080 | ||
1079 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1081 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1080 | { | 1082 | { |
1081 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1083 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1082 | 1084 | ||
1083 | QPtrVector<MonthViewCell> *cells; | 1085 | QPtrVector<MonthViewCell> *cells; |
1084 | QPtrVector<QLabel> *dayLabels; | 1086 | QPtrVector<QLabel> *dayLabels; |
1085 | QPtrVector<KOWeekButton> *weekLabels; | 1087 | QPtrVector<KOWeekButton> *weekLabels; |
1086 | int weekNum = 6; | 1088 | int weekNum = 6; |
1087 | if ( mShowWeekView ) { | 1089 | if ( mShowWeekView ) { |
1088 | weekNum = 1; | 1090 | weekNum = 1; |
1089 | cells = &mCellsW; | 1091 | cells = &mCellsW; |
1090 | dayLabels = &mDayLabelsW; | 1092 | dayLabels = &mDayLabelsW; |
1091 | weekLabels = &mWeekLabelsW; | 1093 | weekLabels = &mWeekLabelsW; |
1092 | } else { | 1094 | } else { |
1093 | cells = &mCells; | 1095 | cells = &mCells; |
1094 | dayLabels = &mDayLabels; | 1096 | dayLabels = &mDayLabels; |
1095 | weekLabels = &mWeekLabels; | 1097 | weekLabels = &mWeekLabels; |
1096 | } | 1098 | } |
1097 | 1099 | ||
1098 | mStartDate = start; | 1100 | mStartDate = start; |
1099 | 1101 | ||
1100 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1102 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1101 | 1103 | ||
1102 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1104 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1103 | mStartDate = mStartDate.addDays( -1 ); | 1105 | mStartDate = mStartDate.addDays( -1 ); |
1104 | } | 1106 | } |
1105 | 1107 | ||
1106 | bool primary = false; | 1108 | bool primary = false; |
1107 | uint i; | 1109 | uint i; |
1108 | for( i = 0; i < (*cells).size(); ++i ) { | 1110 | for( i = 0; i < (*cells).size(); ++i ) { |
1109 | QDate date = mStartDate.addDays( i ); | 1111 | QDate date = mStartDate.addDays( i ); |
1110 | (*cells)[i]->setDate( date ); | 1112 | (*cells)[i]->setDate( date ); |
1111 | 1113 | ||
1112 | #ifndef KORG_NOPLUGINS | 1114 | #ifndef KORG_NOPLUGINS |
1113 | // add holiday, if present | 1115 | // add holiday, if present |
1114 | QString hstring(KOCore::self()->holiday(date)); | 1116 | QString hstring(KOCore::self()->holiday(date)); |
1115 | (*cells)[i]->setHoliday( hstring ); | 1117 | (*cells)[i]->setHoliday( hstring ); |
1116 | #endif | 1118 | #endif |
1117 | 1119 | ||
1118 | } | 1120 | } |
1119 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1121 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1120 | for( i = 0; i < weekNum; ++i ) { | 1122 | for( i = 0; i < weekNum; ++i ) { |
@@ -1341,97 +1343,97 @@ void KOMonthView::computeLayoutWeek() | |||
1341 | else | 1343 | else |
1342 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); | 1344 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); |
1343 | x += w; | 1345 | x += w; |
1344 | } | 1346 | } |
1345 | x= 0; | 1347 | x= 0; |
1346 | y= dayLabelHei; | 1348 | y= dayLabelHei; |
1347 | w = colWid; | 1349 | w = colWid; |
1348 | h = cellHei; | 1350 | h = cellHei; |
1349 | for ( i = 0; i < mCellsW.count(); ++i) { | 1351 | for ( i = 0; i < mCellsW.count(); ++i) { |
1350 | if ( i > 6 ) { | 1352 | if ( i > 6 ) { |
1351 | mCellsW[i]->hide(); | 1353 | mCellsW[i]->hide(); |
1352 | continue; | 1354 | continue; |
1353 | } | 1355 | } |
1354 | 1356 | ||
1355 | w = colWid; | 1357 | w = colWid; |
1356 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1358 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1357 | ++w; | 1359 | ++w; |
1358 | } | 1360 | } |
1359 | if ( i == (daysToShow-1-rowModulo)*7) | 1361 | if ( i == (daysToShow-1-rowModulo)*7) |
1360 | ++h; | 1362 | ++h; |
1361 | 1363 | ||
1362 | if ( i >= 5 ) { | 1364 | if ( i >= 5 ) { |
1363 | if ( i ==5 ) { | 1365 | if ( i ==5 ) { |
1364 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1366 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1365 | x -= w ;y += h/2; | 1367 | x -= w ;y += h/2; |
1366 | } else { | 1368 | } else { |
1367 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1369 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1368 | ++w; | 1370 | ++w; |
1369 | } | 1371 | } |
1370 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1372 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1371 | y -= h/2; | 1373 | y -= h/2; |
1372 | } | 1374 | } |
1373 | } else | 1375 | } else |
1374 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1376 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1375 | 1377 | ||
1376 | 1378 | ||
1377 | x += w; | 1379 | x += w; |
1378 | if ( x + w/2 > wid ) { | 1380 | if ( x + w/2 > wid ) { |
1379 | x = 0; | 1381 | x = 0; |
1380 | y += h+dayLabelHei ; | 1382 | y += h+dayLabelHei ; |
1381 | } | 1383 | } |
1382 | } | 1384 | } |
1383 | y= dayLabelHei; | 1385 | y= dayLabelHei; |
1384 | h = cellHei ; | 1386 | h = cellHei ; |
1385 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1387 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1386 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1388 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1387 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1389 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1388 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1390 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1389 | mShortDayLabels = mDayLabelsW[0]->width() < mWidthLongDayLabel ; | 1391 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; |
1390 | updateDayLabels(); | 1392 | updateDayLabels(); |
1391 | //bool forceUpdate = !updatePossible; | 1393 | //bool forceUpdate = !updatePossible; |
1392 | updatePossible = true; | 1394 | updatePossible = true; |
1393 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1395 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1394 | //if ( forceUpdate ) | 1396 | //if ( forceUpdate ) |
1395 | // updateView(); | 1397 | // updateView(); |
1396 | } | 1398 | } |
1397 | void KOMonthView::computeLayout() | 1399 | void KOMonthView::computeLayout() |
1398 | { | 1400 | { |
1399 | 1401 | ||
1400 | 1402 | ||
1401 | static int lastWid = 0; | 1403 | static int lastWid = 0; |
1402 | static int lastHei = 0; | 1404 | static int lastHei = 0; |
1403 | 1405 | ||
1404 | if ( mShowWeekView ){ | 1406 | if ( mShowWeekView ){ |
1405 | computeLayoutWeek(); | 1407 | computeLayoutWeek(); |
1406 | return; | 1408 | return; |
1407 | } | 1409 | } |
1408 | int daysToShow = 7; | 1410 | int daysToShow = 7; |
1409 | bool combinedSatSun = false; | 1411 | bool combinedSatSun = false; |
1410 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1412 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1411 | daysToShow = 6; | 1413 | daysToShow = 6; |
1412 | combinedSatSun = true; | 1414 | combinedSatSun = true; |
1413 | } | 1415 | } |
1414 | int tWid = topLevelWidget()->size().width(); | 1416 | int tWid = topLevelWidget()->size().width(); |
1415 | int tHei = topLevelWidget()->size().height(); | 1417 | int tHei = topLevelWidget()->size().height(); |
1416 | 1418 | ||
1417 | int wid = width();//e | 1419 | int wid = width();//e |
1418 | int hei = height()-1-mNavigatorBar->height(); | 1420 | int hei = height()-1-mNavigatorBar->height(); |
1419 | 1421 | ||
1420 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { | 1422 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { |
1421 | return; | 1423 | return; |
1422 | } | 1424 | } |
1423 | if ( lastWid == width() && lastHei == height() ){ | 1425 | if ( lastWid == width() && lastHei == height() ){ |
1424 | return; | 1426 | return; |
1425 | } | 1427 | } |
1426 | 1428 | ||
1427 | lastWid = width(); | 1429 | lastWid = width(); |
1428 | lastHei = height(); | 1430 | lastHei = height(); |
1429 | //qDebug("KOMonthView::computeLayout() MMM ------------------------------------ "); | 1431 | //qDebug("KOMonthView::computeLayout() MMM ------------------------------------ "); |
1430 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1432 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1431 | int weeklabelwid = fm.width( "888" ); | 1433 | int weeklabelwid = fm.width( "888" ); |
1432 | wid -= weeklabelwid; | 1434 | wid -= weeklabelwid; |
1433 | 1435 | ||
1434 | int colWid = wid / daysToShow; | 1436 | int colWid = wid / daysToShow; |
1435 | int lastCol = wid - ( colWid*6 ); | 1437 | int lastCol = wid - ( colWid*6 ); |
1436 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1438 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1437 | int cellHei = (hei - dayLabelHei) /6; | 1439 | int cellHei = (hei - dayLabelHei) /6; |
@@ -1457,97 +1459,97 @@ void KOMonthView::computeLayout() | |||
1457 | } else | 1459 | } else |
1458 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1460 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1459 | x += w; | 1461 | x += w; |
1460 | } | 1462 | } |
1461 | x= 0; | 1463 | x= 0; |
1462 | y= dayLabelHei; | 1464 | y= dayLabelHei; |
1463 | w = colWid; | 1465 | w = colWid; |
1464 | h = cellHei ; | 1466 | h = cellHei ; |
1465 | for ( i = 0; i < mCells.count(); ++i) { | 1467 | for ( i = 0; i < mCells.count(); ++i) { |
1466 | //qDebug("iii %d ", i); | 1468 | //qDebug("iii %d ", i); |
1467 | w = colWid; | 1469 | w = colWid; |
1468 | if ( ((i) % 7) >= 7-colModulo ) { | 1470 | if ( ((i) % 7) >= 7-colModulo ) { |
1469 | ++w; | 1471 | ++w; |
1470 | } | 1472 | } |
1471 | if ( i == (6-rowModulo)*7) | 1473 | if ( i == (6-rowModulo)*7) |
1472 | ++h; | 1474 | ++h; |
1473 | if ( combinedSatSun ) { | 1475 | if ( combinedSatSun ) { |
1474 | if ( (i)%7 >= daysToShow-1 ) { | 1476 | if ( (i)%7 >= daysToShow-1 ) { |
1475 | if ( (i)%7 == daysToShow-1 ) { | 1477 | if ( (i)%7 == daysToShow-1 ) { |
1476 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1478 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1477 | x -= w ;y += h/2; | 1479 | x -= w ;y += h/2; |
1478 | } else { | 1480 | } else { |
1479 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1481 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1480 | y -= h/2; | 1482 | y -= h/2; |
1481 | } | 1483 | } |
1482 | } else | 1484 | } else |
1483 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1485 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1484 | 1486 | ||
1485 | } | 1487 | } |
1486 | else | 1488 | else |
1487 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1489 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1488 | x += w; | 1490 | x += w; |
1489 | if ( x + w/2 > wid ) { | 1491 | if ( x + w/2 > wid ) { |
1490 | x = 0; | 1492 | x = 0; |
1491 | y += h; | 1493 | y += h; |
1492 | } | 1494 | } |
1493 | } | 1495 | } |
1494 | y= dayLabelHei; | 1496 | y= dayLabelHei; |
1495 | h = cellHei ; | 1497 | h = cellHei ; |
1496 | for ( i = 0; i < 6; i++) { | 1498 | for ( i = 0; i < 6; i++) { |
1497 | if ( i == (6-rowModulo)) | 1499 | if ( i == (6-rowModulo)) |
1498 | ++h; | 1500 | ++h; |
1499 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1501 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1500 | y += h; | 1502 | y += h; |
1501 | } | 1503 | } |
1502 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1504 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1503 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1505 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1504 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1506 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1505 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1507 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; |
1506 | updateDayLabels(); | 1508 | updateDayLabels(); |
1507 | //bool forceUpdate = !updatePossible; | 1509 | //bool forceUpdate = !updatePossible; |
1508 | updatePossible = true; | 1510 | updatePossible = true; |
1509 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1511 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1510 | } | 1512 | } |
1511 | 1513 | ||
1512 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1514 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1513 | { | 1515 | { |
1514 | mContextMenu->showIncidencePopup(incidence); | 1516 | mContextMenu->showIncidencePopup(incidence); |
1515 | /* | 1517 | /* |
1516 | if( incidence && incidence->type() == "Event" ) { | 1518 | if( incidence && incidence->type() == "Event" ) { |
1517 | Event *event = static_cast<Event *>(incidence); | 1519 | Event *event = static_cast<Event *>(incidence); |
1518 | mContextMenu->showEventPopup(event); | 1520 | mContextMenu->showEventPopup(event); |
1519 | } else { | 1521 | } else { |
1520 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1522 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1521 | } | 1523 | } |
1522 | */ | 1524 | */ |
1523 | } | 1525 | } |
1524 | MonthViewCell * KOMonthView::selectedCell( ) | 1526 | MonthViewCell * KOMonthView::selectedCell( ) |
1525 | { | 1527 | { |
1526 | return mSelectedCell; | 1528 | return mSelectedCell; |
1527 | } | 1529 | } |
1528 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1530 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1529 | { | 1531 | { |
1530 | // qDebug("KOMonthView::setSelectedCell "); | 1532 | // qDebug("KOMonthView::setSelectedCell "); |
1531 | if ( mSelectedCell && mSelectedCell != cell ) { | 1533 | if ( mSelectedCell && mSelectedCell != cell ) { |
1532 | MonthViewCell * mvc = mSelectedCell; | 1534 | MonthViewCell * mvc = mSelectedCell; |
1533 | mSelectedCell = cell; | 1535 | mSelectedCell = cell; |
1534 | mvc->deselect(); | 1536 | mvc->deselect(); |
1535 | } else | 1537 | } else |
1536 | mSelectedCell = cell; | 1538 | mSelectedCell = cell; |
1537 | // if ( mSelectedCell ) | 1539 | // if ( mSelectedCell ) |
1538 | // mSelectedCell->select(); | 1540 | // mSelectedCell->select(); |
1539 | if ( !mSelectedCell ) | 1541 | if ( !mSelectedCell ) |
1540 | emit incidenceSelected( 0 ); | 1542 | emit incidenceSelected( 0 ); |
1541 | else | 1543 | else |
1542 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1544 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1543 | } | 1545 | } |
1544 | 1546 | ||
1545 | void KOMonthView::processSelectionChange() | 1547 | void KOMonthView::processSelectionChange() |
1546 | { | 1548 | { |
1547 | QPtrList<Incidence> incidences = selectedIncidences(); | 1549 | QPtrList<Incidence> incidences = selectedIncidences(); |
1548 | if (incidences.count() > 0) { | 1550 | if (incidences.count() > 0) { |
1549 | emit incidenceSelected( incidences.first() ); | 1551 | emit incidenceSelected( incidences.first() ); |
1550 | } else { | 1552 | } else { |
1551 | emit incidenceSelected( 0 ); | 1553 | emit incidenceSelected( 0 ); |
1552 | } | 1554 | } |
1553 | } | 1555 | } |