summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt2
-rw-r--r--korganizer/komonthview.cpp207
-rw-r--r--korganizer/komonthview.h10
3 files changed, 168 insertions, 51 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
@@ -9,8 +9,10 @@ the popup menu: Set alarm for selected...
9 9
10Added to the event/todo viewer the option to send an email to 10Added to the event/todo viewer the option to send an email to
11all attendees or all selected (with RSVP) attendees. 11all attendees or all selected (with RSVP) attendees.
12 12
13Made the week-month mode changing in month view faster.
14
13********** VERSION 2.0.2 ************ 15********** VERSION 2.0.2 ************
14 16
15KO/Pi: 17KO/Pi:
16Fixed the layout problem of the day label buttons 18Fixed the layout problem of the day label buttons
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 9c1e4c3..daa37fd 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -22,8 +22,9 @@
22#include <qfontmetrics.h> 22#include <qfontmetrics.h>
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>
29#include <qwhatsthis.h> 30#include <qwhatsthis.h>
@@ -267,10 +268,10 @@ int MonthViewItem::width(const QListBox *lb) const
267 return( x + lb->fontMetrics().width( text() ) + 1 ); 268 return( x + lb->fontMetrics().width( text() ) + 1 );
268} 269}
269 270
270 271
271MonthViewCell::MonthViewCell( KOMonthView *parent) 272MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
272 : QWidget( parent ), 273 : QWidget( par ),
273 mMonthView( parent ) 274 mMonthView( parent )
274{ 275{
275 276
276 QVBoxLayout *topLayout = new QVBoxLayout( this ); 277 QVBoxLayout *topLayout = new QVBoxLayout( this );
@@ -765,39 +766,58 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
765 : KOEventView( calendar, parent, name ), 766 : KOEventView( calendar, parent, 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 )
772 mWeekStartsMonday = true; 787 mWeekStartsMonday = true;
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 );
783 } 796 }
784 bfont.setBold( true ); 797 bfont.setBold( true );
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);
803 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 823 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
@@ -805,15 +825,30 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
805 //label->setLineWidth(1); 825 //label->setLineWidth(1);
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 * ) ),
819 SLOT( defaultAction( Incidence * ) ) ); 854 SLOT( defaultAction( Incidence * ) ) );
@@ -822,14 +857,36 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
822 connect( cell, SIGNAL( showDaySignal( QDate ) ), 857 connect( cell, SIGNAL( showDaySignal( QDate ) ),
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
835KOMonthView::~KOMonthView() 892KOMonthView::~KOMonthView()
@@ -841,21 +898,29 @@ void KOMonthView::selectDateWeekNum ( int )
841 898
842} 899}
843void KOMonthView::selectInternalWeekNum ( int n ) 900void KOMonthView::selectInternalWeekNum ( int n )
844{ 901{
845 emit selectWeekNum ( n );
846 switchView(); 902 switchView();
903 emit selectWeekNum ( n );
847} 904}
848 905
849void KOMonthView::switchView() 906void 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 );
856 computeLayout(); 914 if ( clPending ) {
857 updateConfig(); 915 computeLayout();
916 updateConfig();
917 }
918 if ( mShowWeekView )
919 mWidStack->raiseWidget( mWeekView );
920 else
921 mWidStack->raiseWidget( mMonthView );
922 clPending = false;
858} 923}
859 924
860int KOMonthView::maxDatesHint() 925int KOMonthView::maxDatesHint()
861{ 926{
@@ -905,9 +970,9 @@ void KOMonthView::updateConfig()
905 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 970 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
906 971
907 if ( mShowWeekView ) { 972 if ( mShowWeekView ) {
908 mWeekStartsMonday = true; 973 mWeekStartsMonday = true;
909 } 974 }
910 QFontMetrics fontmetric(mDayLabels[0]->font()); 975 QFontMetrics fontmetric(mDayLabels[0]->font());
911 mWidthLongDayLabel = 0; 976 mWidthLongDayLabel = 0;
912 977
913 for (int i = 0; i < 7; i++) { 978 for (int i = 0; i < 7; i++) {
@@ -935,26 +1000,63 @@ void KOMonthView::updateConfig()
935 1000
936void KOMonthView::updateDayLabels() 1001void 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;
1013 for (int i = 0; i < 7; i++) {
1014 if (mWeekStartsMonday) {
1015 bool show = mShortDayLabels;
1016 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1017 show = true;
1018 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1019 } else {
1020 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
1021 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
1022
1023 }
1024 }
1025 mDayLabelsT = &mDayLabels;
939 for (int i = 0; i < 7; i++) { 1026 for (int i = 0; i < 7; i++) {
940 if (mWeekStartsMonday) { 1027 if (mWeekStartsMonday) {
941 bool show = mShortDayLabels; 1028 bool show = mShortDayLabels;
942 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) 1029 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
943 show = true; 1030 show = true;
944 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1031 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
945 } else { 1032 } else {
946 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); 1033 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
947 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 1034 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
948 1035
949 } 1036 }
950 } 1037 }
1038
951} 1039}
952 1040
953void KOMonthView::showDates(const QDate &start, const QDate &) 1041void 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
960 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1062 int startWeekDay = mWeekStartsMonday ? 1 : 7;
@@ -964,21 +1066,21 @@ void KOMonthView::showDates(const QDate &start, const QDate &)
964 } 1066 }
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,
984 // not just 1. 1086 // not just 1.
@@ -986,9 +1088,9 @@ void KOMonthView::showDates(const QDate &start, const QDate &)
986 if (dayOfYear % 7 != 0) 1088 if (dayOfYear % 7 != 0)
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();
994} 1096}
@@ -1011,15 +1113,21 @@ void KOMonthView::updateView()
1011 if ( !updatePossible ) 1113 if ( !updatePossible )
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();
1025 Event *event; 1133 Event *event;
@@ -1046,9 +1154,9 @@ void KOMonthView::updateView()
1046 if ( end > timeSpan ) end = timeSpan; 1154 if ( end > timeSpan ) end = timeSpan;
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 {
1054 if ( invalid ) 1162 if ( invalid )
@@ -1076,9 +1184,9 @@ void KOMonthView::updateView()
1076 if ( st < 0 ) st = 0; 1184 if ( st < 0 ) st = 0;
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 }
1084 } 1192 }
@@ -1089,41 +1197,45 @@ void KOMonthView::updateView()
1089 //insertTodo( todo ); 1197 //insertTodo( todo );
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());
1120} 1228}
1121 1229
1122void KOMonthView::resizeEvent(QResizeEvent * e) 1230void KOMonthView::resizeEvent(QResizeEvent * e)
1123{ 1231{
1124 computeLayout(); 1232 computeLayout();
1125 mCells[0]->setFocus(); 1233 clPending = true;
1234 if ( mShowWeekView )
1235 mCellsW[0]->setFocus();
1236 else
1237 mCells[0]->setFocus();
1126} 1238}
1127void KOMonthView::computeLayoutWeek() 1239void KOMonthView::computeLayoutWeek()
1128{ 1240{
1129 1241
@@ -1155,9 +1267,9 @@ void KOMonthView::computeLayoutWeek()
1155 wid -= weeklabelwid; 1267 wid -= weeklabelwid;
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;
1163 //qDebug("rowmod %d ", rowModulo); 1275 //qDebug("rowmod %d ", rowModulo);
@@ -1176,22 +1288,22 @@ void KOMonthView::computeLayoutWeek()
1176 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1288 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
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
1197 w = colWid; 1309 w = colWid;
@@ -1202,19 +1314,19 @@ void KOMonthView::computeLayoutWeek()
1202 ++h; 1314 ++h;
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;
1220 if ( x + w/2 > wid ) { 1332 if ( x + w/2 > wid ) {
@@ -1223,16 +1335,13 @@ void KOMonthView::computeLayoutWeek()
1223 } 1335 }
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;
1238 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1347 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
@@ -1299,9 +1408,8 @@ void KOMonthView::computeLayout()
1299 y= dayLabelHei; 1408 y= dayLabelHei;
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;
1307 } 1415 }
@@ -1330,9 +1438,8 @@ void KOMonthView::computeLayout()
1330 } 1438 }
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);
1338 y += h; 1445 y += h;
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 1ed200b..b89b2bc 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -24,8 +24,9 @@
24#include <qframe.h> 24#include <qframe.h>
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>
31#include <qvaluelist.h> 32#include <qvaluelist.h>
@@ -124,9 +125,9 @@ class KOMonthView;
124class MonthViewCell : public QWidget 125class 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;
132 133
@@ -255,8 +256,12 @@ class KOMonthView: public KOEventView
255 void viewChanged(); 256 void viewChanged();
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;
262 int mNumWeeks; 267 int mNumWeeks;
@@ -268,8 +273,11 @@ class KOMonthView: public KOEventView
268 273
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;
275 283