summaryrefslogtreecommitdiffabout
path: root/korganizer/koagendaview.cpp
Unidiff
Diffstat (limited to 'korganizer/koagendaview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp47
1 files changed, 44 insertions, 3 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index c018dc7..f8301f8 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -419,30 +419,30 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
419 else 419 else
420 widebut = (widebut*3) / 2; 420 widebut = (widebut*3) / 2;
421 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 421 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
422 // QSizePolicy::Fixed ) ); 422 // QSizePolicy::Fixed ) );
423 mExpandButton->setFixedSize( widebut, widebut); 423 mExpandButton->setFixedSize( widebut, widebut);
424 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 424 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
425 mExpandButton->setFocusPolicy(NoFocus); 425 mExpandButton->setFocusPolicy(NoFocus);
426 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 426 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
427 mAllDayAgenda->setFocusPolicy(NoFocus); 427 mAllDayAgenda->setFocusPolicy(NoFocus);
428 QVBox *dummyAllDayRight = new QVBox(mAllDayFrame); 428 QVBox *dummyAllDayRight = new QVBox(mAllDayFrame);
429 429
430 QPushButton *dummyAllDayRightB = new QPushButton(dummyAllDayRight); 430 QPushButton *dummyAllDayRightB = new QPushButton(dummyAllDayRight);
431 QLabel * dummyAllDayRightL = new QLabel ( dummyAllDayRight ); 431 mDummyAllDayRightL = new QLabel ( dummyAllDayRight );
432 432
433 dummyAllDayRightB->setFlat( true ); 433 dummyAllDayRightB->setFlat( true );
434 dummyAllDayRightB->setFocusPolicy(NoFocus); 434 dummyAllDayRightB->setFocusPolicy(NoFocus);
435 // dummyAllDayRightB->setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding )); 435 // dummyAllDayRightB->setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding ));
436 //dummyAllDayRightB->setFixedHeight( dummyAllDayRightB->sizeHint().height()/2 ); 436 dummyAllDayRightB->setFixedHeight( (dummyAllDayRightB->sizeHint().height()/4)*3 );
437 QPopupMenu * wpo = new QPopupMenu (this); 437 QPopupMenu * wpo = new QPopupMenu (this);
438 wpo->insertItem( i18n("W#"), 0 ); 438 wpo->insertItem( i18n("W#"), 0 );
439 int i; 439 int i;
440 for ( i = 1; i < 53; i++ ) 440 for ( i = 1; i < 53; i++ )
441 wpo->insertItem( QString::number( i ),i ); 441 wpo->insertItem( QString::number( i ),i );
442 //Qt bug - we must add some empty fields... 442 //Qt bug - we must add some empty fields...
443 for ( i = 53; i < 54; ++i ) { 443 for ( i = 53; i < 54; ++i ) {
444 wpo->insertItem( "", 52 ); 444 wpo->insertItem( "", 52 );
445 } 445 }
446 dummyAllDayRightB->setPopup( wpo ); 446 dummyAllDayRightB->setPopup( wpo );
447 447
448 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) ); 448 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) );
@@ -569,24 +569,37 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
569 SIGNAL( incidenceSelected( Incidence * ) ) ); 569 SIGNAL( incidenceSelected( Incidence * ) ) );
570 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 570 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
571 SIGNAL( incidenceSelected( Incidence * ) ) ); 571 SIGNAL( incidenceSelected( Incidence * ) ) );
572 connect( mAgenda, SIGNAL( resizedSignal() ), 572 connect( mAgenda, SIGNAL( resizedSignal() ),
573 SLOT( updateConfig( ) ) ); 573 SLOT( updateConfig( ) ) );
574 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 574 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
575 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 575 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
576 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 576 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
577 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 577 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
578 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 578 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
579 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 579 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
580 580
581 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
582 QFontMetrics fm ( dlf );
583 QString dayTest = "30";
584 int wid = fm.width( dayTest );
585 int maxWid = dummyAllDayRight->width();
586 int fontPoint = dlf.pointSize();
587 while ( wid > maxWid ) {
588 --fontPoint;
589 dlf.setPointSize( fontPoint );
590 QFontMetrics f( dlf );
591 wid = f.width( dayTest );
592 }
593 mDummyAllDayRightL->setFont( dlf );
581 594
582} 595}
583 596
584void KOAgendaView::toggleAllDay() 597void KOAgendaView::toggleAllDay()
585{ 598{
586 if ( mSplitterAgenda->firstHandle() ) 599 if ( mSplitterAgenda->firstHandle() )
587 mSplitterAgenda->firstHandle()->toggle(); 600 mSplitterAgenda->firstHandle()->toggle();
588} 601}
589void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 602void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
590{ 603{
591 calendar()->addIncidence( inc ); 604 calendar()->addIncidence( inc );
592 605
@@ -909,25 +922,26 @@ void KOAgendaView::updateView()
909 922
910} 923}
911 924
912 925
913/* 926/*
914 Update configuration settings for the agenda view. This method is not 927 Update configuration settings for the agenda view. This method is not
915 complete. 928 complete.
916*/ 929*/
917void KOAgendaView::updateConfig() 930void KOAgendaView::updateConfig()
918{ 931{
919 if ( mBlockUpdating ) 932 if ( mBlockUpdating )
920 return; 933 return;
921 // kdDebug() << "KOAgendaView::updateConfig()" << endl; 934
935
922 936
923 // update config for children 937 // update config for children
924 mTimeLabels->updateConfig(); 938 mTimeLabels->updateConfig();
925 mAgenda->storePosition(); 939 mAgenda->storePosition();
926 mAgenda->updateConfig(); 940 mAgenda->updateConfig();
927 mAllDayAgenda->updateConfig(); 941 mAllDayAgenda->updateConfig();
928 // widget synchronization 942 // widget synchronization
929 //TODO: find a better way, maybe signal/slot 943 //TODO: find a better way, maybe signal/slot
930 mTimeLabels->positionChanged(); 944 mTimeLabels->positionChanged();
931 945
932 // for some reason, this needs to be called explicitly 946 // for some reason, this needs to be called explicitly
933 mTimeLabels->repaint(); 947 mTimeLabels->repaint();
@@ -1075,24 +1089,51 @@ void KOAgendaView::fillAgenda()
1075 if ( globalFlagBlockStartup ) 1089 if ( globalFlagBlockStartup )
1076 return; 1090 return;
1077 if ( globalFlagBlockAgenda == 1 ) 1091 if ( globalFlagBlockAgenda == 1 )
1078 return; 1092 return;
1079 //if ( globalFlagBlockAgenda == 2 ) 1093 //if ( globalFlagBlockAgenda == 2 )
1080 //globalFlagBlockAgenda = 0; 1094 //globalFlagBlockAgenda = 0;
1081 // globalFlagBlockPainting = false; 1095 // globalFlagBlockPainting = false;
1082 if ( globalFlagBlockAgenda == 0 ) 1096 if ( globalFlagBlockAgenda == 0 )
1083 globalFlagBlockAgenda = 1; 1097 globalFlagBlockAgenda = 1;
1084 // clearView(); 1098 // clearView();
1085 //qDebug("fillAgenda()++++ "); 1099 //qDebug("fillAgenda()++++ ");
1086 globalFlagBlockAgendaItemPaint = 1; 1100 globalFlagBlockAgendaItemPaint = 1;
1101
1102 int weekNum = 0;
1103 QDate seda = mSelectedDates.first();
1104 QDate d = QDate ( seda.year(), 1,1);
1105 seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday
1106 if ( seda.addDays(6).year() != seda.year() ) {
1107 if ( seda.year() != d.year() ) {
1108 if ( d.dayOfWeek() > 4 )
1109 d = QDate ( seda.year(), 1,1);
1110 else
1111 weekNum = 1;
1112 } else {
1113 QDate dd( seda.year()+1, 1,1);
1114 if ( dd.dayOfWeek() <= 4 )
1115 weekNum = 1;
1116 }
1117 }
1118 if ( weekNum == 0 ){
1119 int dow = d.dayOfWeek();
1120 if ( dow <= 4 )
1121 d = d.addDays( 1-dow );
1122 else // 5,6,7
1123 d = d.addDays( 8-dow );
1124 // we have the first week of the year.we are on monday
1125 weekNum = d.daysTo( seda ) / 7 +1;
1126 }
1127 mDummyAllDayRightL->setText( QString::number( weekNum) );
1087 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1128 mAllDayAgenda->changeColumns(mSelectedDates.count());
1088 mAgenda->changeColumns(mSelectedDates.count()); 1129 mAgenda->changeColumns(mSelectedDates.count());
1089 qApp->processEvents(); 1130 qApp->processEvents();
1090 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1131 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1091 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1132 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1092 setHolidayMasks(); 1133 setHolidayMasks();
1093 1134
1094 //mAgenda->hideUnused(); 1135 //mAgenda->hideUnused();
1095 //mAllDayAgenda->hideUnused(); 1136 //mAllDayAgenda->hideUnused();
1096 1137
1097 // mAgenda->blockNextRepaint( false ); 1138 // mAgenda->blockNextRepaint( false );
1098 // mAgenda->viewport()->repaint(); 1139 // mAgenda->viewport()->repaint();