author | zautrix <zautrix> | 2005-02-06 01:23:43 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-06 01:23:43 (UTC) |
commit | 118f5aab05c9ace5612d5c4fd69e7c5a59bed67b (patch) (unidiff) | |
tree | e097f3fecb6e2ae692b91ac29e58e6d5a51154c8 /korganizer/koagendaview.cpp | |
parent | 659f07aa44f44aebb74c83e7319021cfeb87f275 (diff) | |
download | kdepimpi-118f5aab05c9ace5612d5c4fd69e7c5a59bed67b.zip kdepimpi-118f5aab05c9ace5612d5c4fd69e7c5a59bed67b.tar.gz kdepimpi-118f5aab05c9ace5612d5c4fd69e7c5a59bed67b.tar.bz2 |
better week choose
-rw-r--r-- | korganizer/koagendaview.cpp | 72 |
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 | |||
@@ -404,78 +404,49 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | |||
404 | mAllDayFrame = new QHBox(mSplitterAgenda); | 404 | mAllDayFrame = new QHBox(mSplitterAgenda); |
405 | mAllDayFrame->setFocusPolicy(NoFocus); | 405 | mAllDayFrame->setFocusPolicy(NoFocus); |
406 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 406 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
407 | agendaFrame->setFocusPolicy(NoFocus); | 407 | agendaFrame->setFocusPolicy(NoFocus); |
408 | 408 | ||
409 | #endif | 409 | #endif |
410 | 410 | ||
411 | // Create all-day agenda widget | 411 | // Create all-day agenda widget |
412 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); | 412 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); |
413 | 413 | ||
414 | mExpandButton = new QPushButton(mDummyAllDayLeft); | 414 | mExpandButton = new QPushButton(mDummyAllDayLeft); |
415 | mExpandButton->setPixmap( mNotExpandedPixmap ); | 415 | mExpandButton->setPixmap( mNotExpandedPixmap ); |
416 | int widebut = mExpandButton->sizeHint().width(); | 416 | int widebut = mExpandButton->sizeHint().width(); |
417 | if ( QApplication::desktop()->width() < 480 ) | 417 | if ( QApplication::desktop()->width() < 480 ) |
418 | widebut = widebut*2; | 418 | widebut = widebut*2; |
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 | 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(); |
461 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 432 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
462 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 433 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
463 | 434 | ||
464 | // Create agenda frame | 435 | // Create agenda frame |
465 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); | 436 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); |
466 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 437 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
467 | 438 | ||
468 | // create event indicator bars | 439 | // create event indicator bars |
469 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 440 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
470 | agendaLayout->addWidget(mEventIndicatorTop,0,1); | 441 | agendaLayout->addWidget(mEventIndicatorTop,0,1); |
471 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 442 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
472 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 443 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
473 | agendaFrame); | 444 | agendaFrame); |
474 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); | 445 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); |
475 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 446 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
476 | agendaLayout->addWidget(dummyAgendaRight,0,2); | 447 | agendaLayout->addWidget(dummyAgendaRight,0,2); |
477 | 448 | ||
478 | // Create time labels | 449 | // Create time labels |
479 | mTimeLabels = new TimeLabels(24,agendaFrame); | 450 | mTimeLabels = new TimeLabels(24,agendaFrame); |
480 | agendaLayout->addWidget(mTimeLabels,1,0); | 451 | agendaLayout->addWidget(mTimeLabels,1,0); |
481 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 452 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
@@ -566,62 +537,49 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | |||
566 | /* | 537 | /* |
567 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 538 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
568 | SLOT(startDrag(Event *))); | 539 | SLOT(startDrag(Event *))); |
569 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 540 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
570 | SLOT(startDrag(Event *))); | 541 | SLOT(startDrag(Event *))); |
571 | */ | 542 | */ |
572 | // synchronize selections | 543 | // synchronize selections |
573 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 544 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
574 | mAllDayAgenda, SLOT( deselectItem() ) ); | 545 | mAllDayAgenda, SLOT( deselectItem() ) ); |
575 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 546 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
576 | mAgenda, SLOT( deselectItem() ) ); | 547 | mAgenda, SLOT( deselectItem() ) ); |
577 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 548 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
578 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 549 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
579 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 550 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
580 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 551 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
581 | connect( mAgenda, SIGNAL( resizedSignal() ), | 552 | connect( mAgenda, SIGNAL( resizedSignal() ), |
582 | SLOT( updateConfig( ) ) ); | 553 | SLOT( updateConfig( ) ) ); |
583 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 554 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
584 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 555 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
585 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 556 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
586 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 557 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
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 | ||
606 | void KOAgendaView::toggleAllDay() | 564 | void KOAgendaView::toggleAllDay() |
607 | { | 565 | { |
608 | if ( mSplitterAgenda->firstHandle() ) | 566 | if ( mSplitterAgenda->firstHandle() ) |
609 | mSplitterAgenda->firstHandle()->toggle(); | 567 | mSplitterAgenda->firstHandle()->toggle(); |
610 | } | 568 | } |
611 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 569 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
612 | { | 570 | { |
613 | calendar()->addIncidence( inc ); | 571 | calendar()->addIncidence( inc ); |
614 | 572 | ||
615 | if ( incOld ) { | 573 | if ( incOld ) { |
616 | if ( incOld->type() == "Todo" ) | 574 | if ( incOld->type() == "Todo" ) |
617 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 575 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
618 | else | 576 | else |
619 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 577 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
620 | } | 578 | } |
621 | 579 | ||
622 | } | 580 | } |
623 | 581 | ||
624 | KOAgendaView::~KOAgendaView() | 582 | KOAgendaView::~KOAgendaView() |
625 | { | 583 | { |
626 | delete mAgendaPopup; | 584 | delete mAgendaPopup; |
627 | delete mAllDayAgendaPopup; | 585 | delete mAllDayAgendaPopup; |
@@ -1087,74 +1045,48 @@ void KOAgendaView::changeEventDisplay(Event *, int) | |||
1087 | fillAgenda(); | 1045 | fillAgenda(); |
1088 | } | 1046 | } |
1089 | 1047 | ||
1090 | void KOAgendaView::fillAgenda(const QDate &) | 1048 | void KOAgendaView::fillAgenda(const QDate &) |
1091 | { | 1049 | { |
1092 | // qDebug("KOAgendaView::fillAgenda "); | 1050 | // qDebug("KOAgendaView::fillAgenda "); |
1093 | fillAgenda(); | 1051 | fillAgenda(); |
1094 | } | 1052 | } |
1095 | 1053 | ||
1096 | void KOAgendaView::fillAgenda() | 1054 | void KOAgendaView::fillAgenda() |
1097 | { | 1055 | { |
1098 | if ( globalFlagBlockStartup ) | 1056 | if ( globalFlagBlockStartup ) |
1099 | return; | 1057 | return; |
1100 | if ( globalFlagBlockAgenda == 1 ) | 1058 | if ( globalFlagBlockAgenda == 1 ) |
1101 | return; | 1059 | return; |
1102 | //if ( globalFlagBlockAgenda == 2 ) | 1060 | //if ( globalFlagBlockAgenda == 2 ) |
1103 | //globalFlagBlockAgenda = 0; | 1061 | //globalFlagBlockAgenda = 0; |
1104 | // globalFlagBlockPainting = false; | 1062 | // globalFlagBlockPainting = false; |
1105 | if ( globalFlagBlockAgenda == 0 ) | 1063 | if ( globalFlagBlockAgenda == 0 ) |
1106 | globalFlagBlockAgenda = 1; | 1064 | globalFlagBlockAgenda = 1; |
1107 | // clearView(); | 1065 | // clearView(); |
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(); |
1140 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1072 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1141 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1073 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1142 | setHolidayMasks(); | 1074 | setHolidayMasks(); |
1143 | 1075 | ||
1144 | //mAgenda->hideUnused(); | 1076 | //mAgenda->hideUnused(); |
1145 | //mAllDayAgenda->hideUnused(); | 1077 | //mAllDayAgenda->hideUnused(); |
1146 | 1078 | ||
1147 | // mAgenda->blockNextRepaint( false ); | 1079 | // mAgenda->blockNextRepaint( false ); |
1148 | // mAgenda->viewport()->repaint(); | 1080 | // mAgenda->viewport()->repaint(); |
1149 | // mAgenda->blockNextRepaint( true ); | 1081 | // mAgenda->blockNextRepaint( true ); |
1150 | mMinY.resize(mSelectedDates.count()); | 1082 | mMinY.resize(mSelectedDates.count()); |
1151 | mMaxY.resize(mSelectedDates.count()); | 1083 | mMaxY.resize(mSelectedDates.count()); |
1152 | 1084 | ||
1153 | QPtrList<Event> dayEvents; | 1085 | QPtrList<Event> dayEvents; |
1154 | 1086 | ||
1155 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1087 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1156 | // Therefore, gtodoset all of them. | 1088 | // Therefore, gtodoset all of them. |
1157 | QPtrList<Todo> todos = calendar()->todos(); | 1089 | QPtrList<Todo> todos = calendar()->todos(); |
1158 | 1090 | ||
1159 | mAgenda->setDateList(mSelectedDates); | 1091 | mAgenda->setDateList(mSelectedDates); |
1160 | 1092 | ||