-rw-r--r-- | bin/kdepim/WhatsNew.txt | 2 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 199 | ||||
-rw-r--r-- | korganizer/komonthview.h | 10 |
3 files changed, 164 insertions, 47 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index e24ee43..3ba0841 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -10,6 +10,8 @@ the popup menu: Set alarm for selected... | |||
10 | Added to the event/todo viewer the option to send an email to | 10 | Added to the event/todo viewer the option to send an email to |
11 | all attendees or all selected (with RSVP) attendees. | 11 | all attendees or all selected (with RSVP) attendees. |
12 | 12 | ||
13 | Made the week-month mode changing in month view faster. | ||
14 | |||
13 | ********** VERSION 2.0.2 ************ | 15 | ********** VERSION 2.0.2 ************ |
14 | 16 | ||
15 | KO/Pi: | 17 | KO/Pi: |
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 9c1e4c3..daa37fd 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <qkeycode.h> | 23 | #include <qkeycode.h> |
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qwidgetstack.h> | ||
26 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
27 | #include <qtooltip.h> | 28 | #include <qtooltip.h> |
28 | #include <qpainter.h> | 29 | #include <qpainter.h> |
@@ -268,8 +269,8 @@ int MonthViewItem::width(const QListBox *lb) const | |||
268 | } | 269 | } |
269 | 270 | ||
270 | 271 | ||
271 | MonthViewCell::MonthViewCell( KOMonthView *parent) | 272 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
272 | : QWidget( parent ), | 273 | : QWidget( par ), |
273 | mMonthView( parent ) | 274 | mMonthView( parent ) |
274 | { | 275 | { |
275 | 276 | ||
@@ -766,6 +767,20 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
766 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 767 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
767 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 768 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
768 | { | 769 | { |
770 | |||
771 | clPending = true; | ||
772 | mWidStack = new QWidgetStack( this ); | ||
773 | QHBoxLayout* hb = new QHBoxLayout( this ); | ||
774 | mMonthView = new QWidget( mWidStack ); | ||
775 | mWeekView = new QWidget( mWidStack ); | ||
776 | #if QT_VERSION >= 0x030000 | ||
777 | mWidStack->addWidget(mMonthView ); | ||
778 | mWidStack->addWidget(mWeekView ); | ||
779 | #else | ||
780 | mWidStack->addWidget( mMonthView, 1 ); | ||
781 | mWidStack->addWidget( mWeekView , 1 ); | ||
782 | #endif | ||
783 | hb->addWidget( mWidStack ); | ||
769 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 784 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
770 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 785 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
771 | if ( mShowWeekView ) | 786 | if ( mShowWeekView ) |
@@ -773,10 +788,8 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
773 | updatePossible = false; | 788 | updatePossible = false; |
774 | mCells.setAutoDelete( true ); | 789 | mCells.setAutoDelete( true ); |
775 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 790 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
776 | // mDayLayout = new QGridLayout( this ); | ||
777 | // create the day of the week labels (Sun, Mon, etc) and add them to | ||
778 | // the layout. | ||
779 | mDayLabels.resize( mDaysPerWeek ); | 791 | mDayLabels.resize( mDaysPerWeek ); |
792 | mDayLabelsW.resize( mDaysPerWeek ); | ||
780 | QFont bfont = font(); | 793 | QFont bfont = font(); |
781 | if ( QApplication::desktop()->width() < 650 ) { | 794 | if ( QApplication::desktop()->width() < 650 ) { |
782 | bfont.setPointSize( bfont.pointSize() - 2 ); | 795 | bfont.setPointSize( bfont.pointSize() - 2 ); |
@@ -785,18 +798,25 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
785 | int i; | 798 | int i; |
786 | 799 | ||
787 | for( i = 0; i < mDaysPerWeek; i++ ) { | 800 | for( i = 0; i < mDaysPerWeek; i++ ) { |
788 | QLabel *label = new QLabel( this ); | 801 | QLabel *label = new QLabel( mMonthView ); |
789 | label->setFont(bfont); | 802 | label->setFont(bfont); |
790 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 803 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
791 | label->setLineWidth(1); | 804 | label->setLineWidth(1); |
792 | label->setAlignment(AlignCenter); | 805 | label->setAlignment(AlignCenter); |
793 | mDayLabels.insert( i, label ); | 806 | mDayLabels.insert( i, label ); |
807 | label = new QLabel( mWeekView ); | ||
808 | label->setFont(bfont); | ||
809 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | ||
810 | label->setLineWidth(1); | ||
811 | label->setAlignment(AlignCenter); | ||
812 | mDayLabelsW.insert( i, label ); | ||
794 | } | 813 | } |
795 | 814 | ||
796 | bfont.setBold( false ); | 815 | bfont.setBold( false ); |
797 | mWeekLabels.resize( mNumWeeks+1 ); | 816 | mWeekLabels.resize( mNumWeeks+1 ); |
817 | mWeekLabelsW.resize( 2 ); | ||
798 | for( i = 0; i < mNumWeeks+1; i++ ) { | 818 | for( i = 0; i < mNumWeeks+1; i++ ) { |
799 | KOWeekButton *label = new KOWeekButton( this ); | 819 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
800 | label->setFont(bfont); | 820 | label->setFont(bfont); |
801 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 821 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
802 | label->setFlat(true); | 822 | label->setFlat(true); |
@@ -806,13 +826,28 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
806 | //label->setAlignment(AlignCenter); | 826 | //label->setAlignment(AlignCenter); |
807 | mWeekLabels.insert( i, label ); | 827 | mWeekLabels.insert( i, label ); |
808 | } | 828 | } |
809 | mWeekLabels[mNumWeeks]->setText( i18n("")); | 829 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
810 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 830 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
831 | |||
832 | for( i = 0; i < 1+1; i++ ) { | ||
833 | KOWeekButton *label = new KOWeekButton( mWeekView ); | ||
834 | label->setFont(bfont); | ||
835 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | ||
836 | label->setFlat(true); | ||
837 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | ||
838 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | ||
839 | //label->setLineWidth(1); | ||
840 | //label->setAlignment(AlignCenter); | ||
841 | mWeekLabelsW.insert( i, label ); | ||
842 | } | ||
843 | mWeekLabelsW[1]->setText( i18n("W")); | ||
844 | |||
845 | |||
811 | int row, col; | 846 | int row, col; |
812 | mCells.resize( mNumCells ); | 847 | mCells.resize( mNumCells ); |
813 | for( row = 0; row < mNumWeeks; ++row ) { | 848 | for( row = 0; row < mNumWeeks; ++row ) { |
814 | for( col = 0; col < mDaysPerWeek; ++col ) { | 849 | for( col = 0; col < mDaysPerWeek; ++col ) { |
815 | MonthViewCell *cell = new MonthViewCell( this ); | 850 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
816 | mCells.insert( row * mDaysPerWeek + col, cell ); | 851 | mCells.insert( row * mDaysPerWeek + col, cell ); |
817 | 852 | ||
818 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 853 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
@@ -823,12 +858,34 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
823 | SIGNAL( showDaySignal( QDate ) ) ); | 858 | SIGNAL( showDaySignal( QDate ) ) ); |
824 | } | 859 | } |
825 | } | 860 | } |
861 | mCellsW.resize( mDaysPerWeek ); | ||
862 | for( col = 0; col < mDaysPerWeek; ++col ) { | ||
863 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | ||
864 | mCellsW.insert( col, cell ); | ||
865 | |||
866 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | ||
867 | SLOT( defaultAction( Incidence * ) ) ); | ||
868 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | ||
869 | SIGNAL( newEventSignal( QDateTime ) ) ); | ||
870 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | ||
871 | SIGNAL( showDaySignal( QDate ) ) ); | ||
872 | } | ||
826 | 873 | ||
827 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 874 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
828 | mContextMenu = eventPopup(); | 875 | mContextMenu = eventPopup(); |
829 | // updateConfig(); //useless here | 876 | // updateConfig(); //useless here |
830 | 877 | ||
831 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 878 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
879 | #if 0 | ||
880 | mWidStack = new QWidgetStack( this ); | ||
881 | mMonthView = new QWidget( mWidStack ); | ||
882 | mWeekView = new QWidget( mWidStack ); | ||
883 | #endif | ||
884 | if ( mShowWeekView ) | ||
885 | mWidStack->raiseWidget( mWeekView ); | ||
886 | else | ||
887 | mWidStack->raiseWidget( mMonthView ); | ||
888 | |||
832 | emit incidenceSelected( 0 ); | 889 | emit incidenceSelected( 0 ); |
833 | } | 890 | } |
834 | 891 | ||
@@ -842,20 +899,28 @@ void KOMonthView::selectDateWeekNum ( int ) | |||
842 | } | 899 | } |
843 | void KOMonthView::selectInternalWeekNum ( int n ) | 900 | void KOMonthView::selectInternalWeekNum ( int n ) |
844 | { | 901 | { |
845 | emit selectWeekNum ( n ); | ||
846 | switchView(); | 902 | switchView(); |
903 | emit selectWeekNum ( n ); | ||
847 | } | 904 | } |
848 | 905 | ||
849 | void KOMonthView::switchView() | 906 | void KOMonthView::switchView() |
850 | { | 907 | { |
908 | |||
851 | if ( selectedCell( ) ) | 909 | if ( selectedCell( ) ) |
852 | selectedCell()->deselect(); | 910 | selectedCell()->deselect(); |
853 | mShowWeekView = !mShowWeekView; | 911 | mShowWeekView = !mShowWeekView; |
854 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 912 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
855 | //emit showNavigator( !mShowWeekView ); | 913 | //emit showNavigator( !mShowWeekView ); |
914 | if ( clPending ) { | ||
856 | computeLayout(); | 915 | computeLayout(); |
857 | updateConfig(); | 916 | updateConfig(); |
858 | } | 917 | } |
918 | if ( mShowWeekView ) | ||
919 | mWidStack->raiseWidget( mWeekView ); | ||
920 | else | ||
921 | mWidStack->raiseWidget( mMonthView ); | ||
922 | clPending = false; | ||
923 | } | ||
859 | 924 | ||
860 | int KOMonthView::maxDatesHint() | 925 | int KOMonthView::maxDatesHint() |
861 | { | 926 | { |
@@ -936,24 +1001,61 @@ void KOMonthView::updateConfig() | |||
936 | void KOMonthView::updateDayLabels() | 1001 | void KOMonthView::updateDayLabels() |
937 | { | 1002 | { |
938 | 1003 | ||
1004 | QPtrVector<QLabel> *mDayLabelsT; | ||
1005 | #if 0 | ||
1006 | if (mShowWeekView ) | ||
1007 | mDayLabelsT = &mDayLabelsW; | ||
1008 | else | ||
1009 | mDayLabelsT = &mDayLabels; | ||
1010 | #endif | ||
1011 | |||
1012 | mDayLabelsT = &mDayLabelsW; | ||
939 | for (int i = 0; i < 7; i++) { | 1013 | for (int i = 0; i < 7; i++) { |
940 | if (mWeekStartsMonday) { | 1014 | if (mWeekStartsMonday) { |
941 | bool show = mShortDayLabels; | 1015 | bool show = mShortDayLabels; |
942 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) | 1016 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
943 | show = true; | 1017 | show = true; |
944 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1018 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
945 | } else { | 1019 | } else { |
946 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); | 1020 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); |
947 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | 1021 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); |
948 | 1022 | ||
949 | } | 1023 | } |
950 | } | 1024 | } |
1025 | mDayLabelsT = &mDayLabels; | ||
1026 | for (int i = 0; i < 7; i++) { | ||
1027 | if (mWeekStartsMonday) { | ||
1028 | bool show = mShortDayLabels; | ||
1029 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | ||
1030 | show = true; | ||
1031 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | ||
1032 | } else { | ||
1033 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); | ||
1034 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | ||
1035 | |||
1036 | } | ||
1037 | } | ||
1038 | |||
951 | } | 1039 | } |
952 | 1040 | ||
953 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1041 | void KOMonthView::showDates(const QDate &start, const QDate &) |
954 | { | 1042 | { |
955 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1043 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
956 | 1044 | ||
1045 | QPtrVector<MonthViewCell> *cells; | ||
1046 | QPtrVector<QLabel> *dayLabels; | ||
1047 | QPtrVector<KOWeekButton> *weekLabels; | ||
1048 | int weekNum = 6; | ||
1049 | if ( mShowWeekView ) { | ||
1050 | weekNum = 1; | ||
1051 | cells = &mCellsW; | ||
1052 | dayLabels = &mDayLabelsW; | ||
1053 | weekLabels = &mWeekLabelsW; | ||
1054 | } else { | ||
1055 | cells = &mCells; | ||
1056 | dayLabels = &mDayLabels; | ||
1057 | weekLabels = &mWeekLabels; | ||
1058 | } | ||
957 | 1059 | ||
958 | mStartDate = start; | 1060 | mStartDate = start; |
959 | 1061 | ||
@@ -965,19 +1067,19 @@ void KOMonthView::showDates(const QDate &start, const QDate &) | |||
965 | 1067 | ||
966 | bool primary = false; | 1068 | bool primary = false; |
967 | uint i; | 1069 | uint i; |
968 | for( i = 0; i < mCells.size(); ++i ) { | 1070 | for( i = 0; i < (*cells).size(); ++i ) { |
969 | QDate date = mStartDate.addDays( i ); | 1071 | QDate date = mStartDate.addDays( i ); |
970 | mCells[i]->setDate( date ); | 1072 | (*cells)[i]->setDate( date ); |
971 | 1073 | ||
972 | #ifndef KORG_NOPLUGINS | 1074 | #ifndef KORG_NOPLUGINS |
973 | // add holiday, if present | 1075 | // add holiday, if present |
974 | QString hstring(KOCore::self()->holiday(date)); | 1076 | QString hstring(KOCore::self()->holiday(date)); |
975 | mCells[i]->setHoliday( hstring ); | 1077 | (*cells)[i]->setHoliday( hstring ); |
976 | #endif | 1078 | #endif |
977 | 1079 | ||
978 | } | 1080 | } |
979 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1081 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
980 | for( i = 0; i < 6; ++i ) { | 1082 | for( i = 0; i < weekNum; ++i ) { |
981 | int wno; | 1083 | int wno; |
982 | // remember, according to ISO 8601, the first week of the year is the | 1084 | // remember, according to ISO 8601, the first week of the year is the |
983 | // first week that contains a thursday. Thus we must subtract off 4, | 1085 | // first week that contains a thursday. Thus we must subtract off 4, |
@@ -987,7 +1089,7 @@ void KOMonthView::showDates(const QDate &start, const QDate &) | |||
987 | wno = dayOfYear / 7 + 1; | 1089 | wno = dayOfYear / 7 + 1; |
988 | else | 1090 | else |
989 | wno =dayOfYear / 7; | 1091 | wno =dayOfYear / 7; |
990 | mWeekLabels[i]->setWeekNum( wno ); | 1092 | (*weekLabels)[i]->setWeekNum( wno ); |
991 | date = date.addDays( 7 ); | 1093 | date = date.addDays( 7 ); |
992 | } | 1094 | } |
993 | updateView(); | 1095 | updateView(); |
@@ -1012,13 +1114,19 @@ void KOMonthView::updateView() | |||
1012 | return; | 1114 | return; |
1013 | //QTime ti; | 1115 | //QTime ti; |
1014 | //ti.start(); | 1116 | //ti.start(); |
1117 | QPtrVector<MonthViewCell> *cells; | ||
1118 | if ( mShowWeekView ) { | ||
1119 | cells = &mCellsW; | ||
1120 | } else { | ||
1121 | cells = &mCells; | ||
1122 | } | ||
1015 | #if 1 | 1123 | #if 1 |
1016 | int i; | 1124 | int i; |
1017 | int timeSpan = mCells.size()-1; | 1125 | int timeSpan = (*cells).size()-1; |
1018 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1126 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1019 | timeSpan = 6; | 1127 | timeSpan = 6; |
1020 | for( i = 0; i < timeSpan + 1; ++i ) { | 1128 | for( i = 0; i < timeSpan + 1; ++i ) { |
1021 | mCells[i]->startUpdateCell(); | 1129 | (*cells)[i]->startUpdateCell(); |
1022 | } | 1130 | } |
1023 | 1131 | ||
1024 | QPtrList<Event> events = calendar()->events(); | 1132 | QPtrList<Event> events = calendar()->events(); |
@@ -1047,7 +1155,7 @@ void KOMonthView::updateView() | |||
1047 | int iii; | 1155 | int iii; |
1048 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1156 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1049 | for ( iii = st;iii<= end;++iii) | 1157 | for ( iii = st;iii<= end;++iii) |
1050 | mCells[iii]->insertEvent( event ); | 1158 | (*cells)[iii]->insertEvent( event ); |
1051 | } | 1159 | } |
1052 | } | 1160 | } |
1053 | } else { | 1161 | } else { |
@@ -1077,7 +1185,7 @@ void KOMonthView::updateView() | |||
1077 | if ( end > timeSpan ) end = timeSpan; | 1185 | if ( end > timeSpan ) end = timeSpan; |
1078 | int iii; | 1186 | int iii; |
1079 | for ( iii = st;iii<= end;++iii) | 1187 | for ( iii = st;iii<= end;++iii) |
1080 | mCells[iii]->insertEvent( event ); | 1188 | (*cells)[iii]->insertEvent( event ); |
1081 | } | 1189 | } |
1082 | } | 1190 | } |
1083 | } | 1191 | } |
@@ -1090,30 +1198,30 @@ void KOMonthView::updateView() | |||
1090 | if ( todo->hasDueDate() ) { | 1198 | if ( todo->hasDueDate() ) { |
1091 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1199 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1092 | if ( day >= 0 && day < timeSpan + 1) { | 1200 | if ( day >= 0 && day < timeSpan + 1) { |
1093 | mCells[day]->insertTodo( todo ); | 1201 | (*cells)[day]->insertTodo( todo ); |
1094 | } | 1202 | } |
1095 | } | 1203 | } |
1096 | } | 1204 | } |
1097 | 1205 | ||
1098 | for( i = 0; i < timeSpan+1; ++i ) { | 1206 | for( i = 0; i < timeSpan+1; ++i ) { |
1099 | mCells[i]->finishUpdateCell(); | 1207 | (*cells)[i]->finishUpdateCell(); |
1100 | } | 1208 | } |
1101 | processSelectionChange(); | 1209 | processSelectionChange(); |
1102 | mCells[0]->setFocus(); | 1210 | (*cells)[0]->setFocus(); |
1103 | 1211 | ||
1104 | 1212 | ||
1105 | #else | 1213 | #else |
1106 | // old code | 1214 | // old code |
1107 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1215 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1108 | int i; | 1216 | int i; |
1109 | for( i = 0; i < mCells.count(); ++i ) { | 1217 | for( i = 0; i < (*cells).count(); ++i ) { |
1110 | mCells[i]->updateCell(); | 1218 | (*cells)[i]->updateCell(); |
1111 | } | 1219 | } |
1112 | 1220 | ||
1113 | //qDebug("KOMonthView::updateView() "); | 1221 | //qDebug("KOMonthView::updateView() "); |
1114 | processSelectionChange(); | 1222 | processSelectionChange(); |
1115 | // qDebug("---------------------------------------------------------------------+ "); | 1223 | // qDebug("---------------------------------------------------------------------+ "); |
1116 | mCells[0]->setFocus(); | 1224 | (*cells)[0]->setFocus(); |
1117 | #endif | 1225 | #endif |
1118 | 1226 | ||
1119 | //qDebug("update time %d ", ti.elapsed()); | 1227 | //qDebug("update time %d ", ti.elapsed()); |
@@ -1122,6 +1230,10 @@ void KOMonthView::updateView() | |||
1122 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1230 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1123 | { | 1231 | { |
1124 | computeLayout(); | 1232 | computeLayout(); |
1233 | clPending = true; | ||
1234 | if ( mShowWeekView ) | ||
1235 | mCellsW[0]->setFocus(); | ||
1236 | else | ||
1125 | mCells[0]->setFocus(); | 1237 | mCells[0]->setFocus(); |
1126 | } | 1238 | } |
1127 | void KOMonthView::computeLayoutWeek() | 1239 | void KOMonthView::computeLayoutWeek() |
@@ -1156,7 +1268,7 @@ void KOMonthView::computeLayoutWeek() | |||
1156 | 1268 | ||
1157 | int colWid = wid / daysToShow; | 1269 | int colWid = wid / daysToShow; |
1158 | int lastCol = wid - ( colWid*6 ); | 1270 | int lastCol = wid - ( colWid*6 ); |
1159 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1271 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1160 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1272 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1161 | int colModulo = wid % daysToShow; | 1273 | int colModulo = wid % daysToShow; |
1162 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1274 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
@@ -1177,20 +1289,20 @@ void KOMonthView::computeLayoutWeek() | |||
1177 | ++w; | 1289 | ++w; |
1178 | } | 1290 | } |
1179 | if ( i >= 5 ) { | 1291 | if ( i >= 5 ) { |
1180 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); | 1292 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); |
1181 | x -= (w/2 ); | 1293 | x -= (w/2 ); |
1182 | } | 1294 | } |
1183 | else | 1295 | else |
1184 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1296 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); |
1185 | x += w; | 1297 | x += w; |
1186 | } | 1298 | } |
1187 | x= 0; | 1299 | x= 0; |
1188 | y= dayLabelHei; | 1300 | y= dayLabelHei; |
1189 | w = colWid; | 1301 | w = colWid; |
1190 | h = cellHei; | 1302 | h = cellHei; |
1191 | for ( i = 0; i < mCells.count(); ++i) { | 1303 | for ( i = 0; i < mCellsW.count(); ++i) { |
1192 | if ( i > 6 ) { | 1304 | if ( i > 6 ) { |
1193 | mCells[i]->hide(); | 1305 | mCellsW[i]->hide(); |
1194 | continue; | 1306 | continue; |
1195 | } | 1307 | } |
1196 | 1308 | ||
@@ -1203,17 +1315,17 @@ void KOMonthView::computeLayoutWeek() | |||
1203 | 1315 | ||
1204 | if ( i >= 5 ) { | 1316 | if ( i >= 5 ) { |
1205 | if ( i ==5 ) { | 1317 | if ( i ==5 ) { |
1206 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1318 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1207 | x -= w ;y += h/2; | 1319 | x -= w ;y += h/2; |
1208 | } else { | 1320 | } else { |
1209 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1321 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1210 | ++w; | 1322 | ++w; |
1211 | } | 1323 | } |
1212 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1324 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1213 | y -= h/2; | 1325 | y -= h/2; |
1214 | } | 1326 | } |
1215 | } else | 1327 | } else |
1216 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1328 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1217 | 1329 | ||
1218 | 1330 | ||
1219 | x += w; | 1331 | x += w; |
@@ -1224,14 +1336,11 @@ void KOMonthView::computeLayoutWeek() | |||
1224 | } | 1336 | } |
1225 | y= dayLabelHei; | 1337 | y= dayLabelHei; |
1226 | h = cellHei ; | 1338 | h = cellHei ; |
1227 | mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1339 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1228 | for ( i = 1; i < 6; i++) { | 1340 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1229 | mWeekLabels[i]->hide(); | ||
1230 | } | ||
1231 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | ||
1232 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1341 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1233 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1342 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1234 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1343 | mShortDayLabels = mDayLabelsW[0]->width() < mWidthLongDayLabel ; |
1235 | updateDayLabels(); | 1344 | updateDayLabels(); |
1236 | bool forceUpdate = !updatePossible; | 1345 | bool forceUpdate = !updatePossible; |
1237 | updatePossible = true; | 1346 | updatePossible = true; |
@@ -1300,7 +1409,6 @@ void KOMonthView::computeLayout() | |||
1300 | w = colWid; | 1409 | w = colWid; |
1301 | h = cellHei ; | 1410 | h = cellHei ; |
1302 | for ( i = 0; i < mCells.count(); ++i) { | 1411 | for ( i = 0; i < mCells.count(); ++i) { |
1303 | mCells[i]->show(); | ||
1304 | w = colWid; | 1412 | w = colWid; |
1305 | if ( ((i) % 7) >= 7-colModulo ) { | 1413 | if ( ((i) % 7) >= 7-colModulo ) { |
1306 | ++w; | 1414 | ++w; |
@@ -1331,7 +1439,6 @@ void KOMonthView::computeLayout() | |||
1331 | y= dayLabelHei; | 1439 | y= dayLabelHei; |
1332 | h = cellHei ; | 1440 | h = cellHei ; |
1333 | for ( i = 0; i < 6; i++) { | 1441 | for ( i = 0; i < 6; i++) { |
1334 | mWeekLabels[i]->show(); | ||
1335 | if ( i == (6-rowModulo)) | 1442 | if ( i == (6-rowModulo)) |
1336 | ++h; | 1443 | ++h; |
1337 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1444 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 1ed200b..b89b2bc 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qlistbox.h> | 26 | #include <qlistbox.h> |
27 | #include <qpoint.h> | 27 | #include <qpoint.h> |
28 | #include <qwidgetstack.h> | ||
28 | #include <qlayout.h> | 29 | #include <qlayout.h> |
29 | #include <qintdict.h> | 30 | #include <qintdict.h> |
30 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
@@ -125,7 +126,7 @@ class MonthViewCell : public QWidget | |||
125 | { | 126 | { |
126 | Q_OBJECT | 127 | Q_OBJECT |
127 | public: | 128 | public: |
128 | MonthViewCell( KOMonthView * ); | 129 | MonthViewCell(KOMonthView *,QWidget* ); |
129 | 130 | ||
130 | void setDate( const QDate & ); | 131 | void setDate( const QDate & ); |
131 | QDate date() const; | 132 | QDate date() const; |
@@ -256,6 +257,10 @@ class KOMonthView: public KOEventView | |||
256 | void updateDayLabels(); | 257 | void updateDayLabels(); |
257 | 258 | ||
258 | private: | 259 | private: |
260 | bool clPending; | ||
261 | QWidgetStack * mWidStack; | ||
262 | QWidget* mMonthView; | ||
263 | QWidget* mWeekView; | ||
259 | bool mShowWeekView; | 264 | bool mShowWeekView; |
260 | bool updatePossible; | 265 | bool updatePossible; |
261 | int mDaysPerWeek; | 266 | int mDaysPerWeek; |
@@ -269,6 +274,9 @@ class KOMonthView: public KOEventView | |||
269 | QPtrVector<MonthViewCell> mCells; | 274 | QPtrVector<MonthViewCell> mCells; |
270 | QPtrVector<QLabel> mDayLabels; | 275 | QPtrVector<QLabel> mDayLabels; |
271 | QPtrVector<KOWeekButton> mWeekLabels; | 276 | QPtrVector<KOWeekButton> mWeekLabels; |
277 | QPtrVector<MonthViewCell> mCellsW; | ||
278 | QPtrVector<QLabel> mDayLabelsW; | ||
279 | QPtrVector<KOWeekButton> mWeekLabelsW; | ||
272 | 280 | ||
273 | bool mShortDayLabels; | 281 | bool mShortDayLabels; |
274 | int mWidthLongDayLabel; | 282 | int mWidthLongDayLabel; |