summaryrefslogtreecommitdiffabout
path: root/korganizer/koagendaview.cpp
authorzautrix <zautrix>2005-02-06 01:23:43 (UTC)
committer zautrix <zautrix>2005-02-06 01:23:43 (UTC)
commit118f5aab05c9ace5612d5c4fd69e7c5a59bed67b (patch) (unidiff)
treee097f3fecb6e2ae692b91ac29e58e6d5a51154c8 /korganizer/koagendaview.cpp
parent659f07aa44f44aebb74c83e7319021cfeb87f275 (diff)
downloadkdepimpi-118f5aab05c9ace5612d5c4fd69e7c5a59bed67b.zip
kdepimpi-118f5aab05c9ace5612d5c4fd69e7c5a59bed67b.tar.gz
kdepimpi-118f5aab05c9ace5612d5c4fd69e7c5a59bed67b.tar.bz2
better week choose
Diffstat (limited to 'korganizer/koagendaview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp72
1 files changed, 2 insertions, 70 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 36c66ea..0d36946 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -425,36 +425,7 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
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 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
429
430 mDummyAllDayRightL = new QLabel ( dummyAllDayRight );
431 QPushButton *dummyAllDayRightB = new QPushButton(dummyAllDayRight);
432 new QLabel ( dummyAllDayRight );
433 mDummyAllDayRightL->setSizePolicy( QSizePolicy( QSizePolicy::Minimum,QSizePolicy::Fixed ) );
434 dummyAllDayRightB->setFlat( true );
435 dummyAllDayRightB->setFocusPolicy(NoFocus);
436 dummyAllDayRightB->setFixedHeight( (dummyAllDayRightB->sizeHint().height()/4)*3 );
437
438 QPopupMenu * wpo = new QPopupMenu (this);
439 QPopupMenu * all = new QPopupMenu (this);
440 //wpo->insertItem( i18n("W#"), 0 );
441 int first = 1;
442 int i;
443 for ( i = 1; i < 50; ++i ) {
444 if ( !(i%10) ) {
445 all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo );
446 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) );
447 first = i;
448 wpo = new QPopupMenu (this);
449 }
450 wpo->insertItem( QString::number(i), i );
451 }
452 for ( i = 50; i < 53; ++i ) {
453 wpo->insertItem( QString::number(i), i);
454 }
455 all->insertItem( i18n("Select week %1-%2" ).arg(first).arg( i-1) ,wpo );
456 dummyAllDayRightB->setPopup( all );
457 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) );
458 429
459 // Create event context menu for all day agenda 430 // Create event context menu for all day agenda
460 mAllDayAgendaPopup = eventPopup(); 431 mAllDayAgendaPopup = eventPopup();
@@ -587,20 +558,7 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
587 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 558 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
588 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 559 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
589 560
590 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 561
591 QFontMetrics fm ( dlf );
592 QString dayTest = "30";
593 int wid = fm.width( dayTest );
594 int maxWid = dummyAllDayRight->width()-2;
595 int fontPoint = dlf.pointSize();
596 while ( wid > maxWid ) {
597 --fontPoint;
598 dlf.setPointSize( fontPoint );
599 QFontMetrics f( dlf );
600 wid = f.width( dayTest );
601 }
602 mDummyAllDayRightL->setFont( dlf );
603 mDummyAllDayRightL->setAlignment( AlignHCenter );
604} 562}
605 563
606void KOAgendaView::toggleAllDay() 564void KOAgendaView::toggleAllDay()
@@ -1108,32 +1066,6 @@ void KOAgendaView::fillAgenda()
1108 //qDebug("fillAgenda()++++ "); 1066 //qDebug("fillAgenda()++++ ");
1109 globalFlagBlockAgendaItemPaint = 1; 1067 globalFlagBlockAgendaItemPaint = 1;
1110 1068
1111 int weekNum = 0;
1112 QDate seda = mSelectedDates.first();
1113 QDate d = QDate ( seda.year(), 1,1);
1114 seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday
1115 if ( seda.addDays(6).year() != seda.year() ) {
1116 if ( seda.year() != d.year() ) {
1117 if ( d.dayOfWeek() > 4 )
1118 d = QDate ( seda.year(), 1,1);
1119 else
1120 weekNum = 1;
1121 } else {
1122 QDate dd( seda.year()+1, 1,1);
1123 if ( dd.dayOfWeek() <= 4 )
1124 weekNum = 1;
1125 }
1126 }
1127 if ( weekNum == 0 ){
1128 int dow = d.dayOfWeek();
1129 if ( dow <= 4 )
1130 d = d.addDays( 1-dow );
1131 else // 5,6,7
1132 d = d.addDays( 8-dow );
1133 // we have the first week of the year.we are on monday
1134 weekNum = d.daysTo( seda ) / 7 +1;
1135 }
1136 mDummyAllDayRightL->setText( QString::number( weekNum) );
1137 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1069 mAllDayAgenda->changeColumns(mSelectedDates.count());
1138 mAgenda->changeColumns(mSelectedDates.count()); 1070 mAgenda->changeColumns(mSelectedDates.count());
1139 qApp->processEvents(); 1071 qApp->processEvents();