-rw-r--r-- | korganizer/koagendaview.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 93ff55e..c851ab5 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -481,422 +481,424 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | |||
481 | 481 | ||
482 | // Update widgets to reflect user preferences | 482 | // Update widgets to reflect user preferences |
483 | // updateConfig(); | 483 | // updateConfig(); |
484 | 484 | ||
485 | // createDayLabels(); | 485 | // createDayLabels(); |
486 | 486 | ||
487 | // these blank widgets make the All Day Event box line up with the agenda | 487 | // these blank widgets make the All Day Event box line up with the agenda |
488 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 488 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
489 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 489 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
490 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 490 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
491 | 491 | ||
492 | // Scrolling | 492 | // Scrolling |
493 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 493 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
494 | mTimeLabels, SLOT(positionChanged())); | 494 | mTimeLabels, SLOT(positionChanged())); |
495 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 495 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
496 | SLOT(setContentsPos(int))); | 496 | SLOT(setContentsPos(int))); |
497 | 497 | ||
498 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); | 498 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); |
499 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); | 499 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); |
500 | 500 | ||
501 | // Create/Show/Edit/Delete Event | 501 | // Create/Show/Edit/Delete Event |
502 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 502 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
503 | SLOT(newEvent(int,int))); | 503 | SLOT(newEvent(int,int))); |
504 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 504 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
505 | SLOT(newTodo(int,int))); | 505 | SLOT(newTodo(int,int))); |
506 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 506 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
507 | SLOT(newEvent(int,int,int,int))); | 507 | SLOT(newEvent(int,int,int,int))); |
508 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 508 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
509 | SLOT(newEventAllDay(int,int))); | 509 | SLOT(newEventAllDay(int,int))); |
510 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 510 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
511 | SLOT(newTodoAllDay(int,int))); | 511 | SLOT(newTodoAllDay(int,int))); |
512 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 512 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
513 | SLOT(newEventAllDay(int,int))); | 513 | SLOT(newEventAllDay(int,int))); |
514 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 514 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
515 | SLOT(newTimeSpanSelected(int,int,int,int))); | 515 | SLOT(newTimeSpanSelected(int,int,int,int))); |
516 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 516 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
517 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 517 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
518 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 518 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
519 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 519 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
520 | 520 | ||
521 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 521 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
522 | SIGNAL(editIncidenceSignal(Incidence *))); | 522 | SIGNAL(editIncidenceSignal(Incidence *))); |
523 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 523 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
524 | SIGNAL(editIncidenceSignal(Incidence *))); | 524 | SIGNAL(editIncidenceSignal(Incidence *))); |
525 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 525 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
526 | SIGNAL(showIncidenceSignal(Incidence *))); | 526 | SIGNAL(showIncidenceSignal(Incidence *))); |
527 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 527 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
528 | SIGNAL(showIncidenceSignal(Incidence *))); | 528 | SIGNAL(showIncidenceSignal(Incidence *))); |
529 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 529 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
530 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 530 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
531 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 531 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
532 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 532 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
533 | 533 | ||
534 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 534 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
535 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 535 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
536 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 536 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
537 | SLOT(updateEventDates(KOAgendaItem *, int))); | 537 | SLOT(updateEventDates(KOAgendaItem *, int))); |
538 | 538 | ||
539 | // event indicator update | 539 | // event indicator update |
540 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 540 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
541 | SLOT(updateEventIndicatorTop(int))); | 541 | SLOT(updateEventIndicatorTop(int))); |
542 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 542 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
543 | SLOT(updateEventIndicatorBottom(int))); | 543 | SLOT(updateEventIndicatorBottom(int))); |
544 | // drag signals | 544 | // drag signals |
545 | /* | 545 | /* |
546 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 546 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
547 | SLOT(startDrag(Event *))); | 547 | SLOT(startDrag(Event *))); |
548 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 548 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
549 | SLOT(startDrag(Event *))); | 549 | SLOT(startDrag(Event *))); |
550 | */ | 550 | */ |
551 | // synchronize selections | 551 | // synchronize selections |
552 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 552 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
553 | mAllDayAgenda, SLOT( deselectItem() ) ); | 553 | mAllDayAgenda, SLOT( deselectItem() ) ); |
554 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 554 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
555 | mAgenda, SLOT( deselectItem() ) ); | 555 | mAgenda, SLOT( deselectItem() ) ); |
556 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 556 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
557 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 557 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
558 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 558 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
559 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 559 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
560 | connect( mAgenda, SIGNAL( resizedSignal() ), | 560 | connect( mAgenda, SIGNAL( resizedSignal() ), |
561 | SLOT( updateConfig( ) ) ); | 561 | SLOT( updateConfig( ) ) ); |
562 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 562 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
563 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 563 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
564 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 564 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
565 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 565 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
566 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 566 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
567 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 567 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
568 | 568 | ||
569 | connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); | 569 | connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); |
570 | connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); | 570 | connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); |
571 | 571 | ||
572 | } | 572 | } |
573 | 573 | ||
574 | void KOAgendaView::toggleAllDay() | 574 | void KOAgendaView::toggleAllDay() |
575 | { | 575 | { |
576 | if ( mSplitterAgenda->firstHandle() ) | 576 | if ( mSplitterAgenda->firstHandle() ) |
577 | mSplitterAgenda->firstHandle()->toggle(); | 577 | mSplitterAgenda->firstHandle()->toggle(); |
578 | } | 578 | } |
579 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 579 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
580 | { | 580 | { |
581 | calendar()->addIncidence( inc ); | 581 | calendar()->addIncidence( inc ); |
582 | 582 | ||
583 | if ( incOld ) { | 583 | if ( incOld ) { |
584 | if ( incOld->typeID() == todoID ) | 584 | if ( incOld->typeID() == todoID ) |
585 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 585 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
586 | else | 586 | else |
587 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 587 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
588 | } | 588 | } |
589 | 589 | ||
590 | } | 590 | } |
591 | 591 | ||
592 | KOAgendaView::~KOAgendaView() | 592 | KOAgendaView::~KOAgendaView() |
593 | { | 593 | { |
594 | delete mAllAgendaPopup; | 594 | delete mAllAgendaPopup; |
595 | //delete mAllDayAgendaPopup; | 595 | //delete mAllDayAgendaPopup; |
596 | delete KOAgendaItem::paintPix(); | 596 | delete KOAgendaItem::paintPix(); |
597 | delete KOAgendaItem::paintPixSel(); | 597 | delete KOAgendaItem::paintPixSel(); |
598 | } | 598 | } |
599 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 599 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
600 | { | 600 | { |
601 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 601 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
602 | bool uc = false; | 602 | bool uc = false; |
603 | int ow = e->oldSize().width(); | 603 | int ow = e->oldSize().width(); |
604 | int oh = e->oldSize().height(); | 604 | int oh = e->oldSize().height(); |
605 | int w = e->size().width(); | 605 | int w = e->size().width(); |
606 | int h = e->size().height(); | 606 | int h = e->size().height(); |
607 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 607 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
608 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 608 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
609 | uc = true; | 609 | uc = true; |
610 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 610 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
611 | } | 611 | } |
612 | mUpcomingWidth = e->size().width() ; | 612 | mUpcomingWidth = e->size().width() ; |
613 | if ( mBlockUpdating || uc ) { | 613 | if ( mBlockUpdating || uc ) { |
614 | mBlockUpdating = false; | 614 | mBlockUpdating = false; |
615 | //mAgenda->setMinimumSize(800 , 600 ); | 615 | //mAgenda->setMinimumSize(800 , 600 ); |
616 | //qDebug("mAgenda->resize+++++++++++++++ "); | 616 | //qDebug("mAgenda->resize+++++++++++++++ "); |
617 | updateConfig(); | 617 | updateConfig(); |
618 | //qDebug("KOAgendaView::Updating now possible "); | 618 | //qDebug("KOAgendaView::Updating now possible "); |
619 | } else | 619 | } else |
620 | createDayLabels(); | 620 | createDayLabels(); |
621 | //qDebug("resizeEvent end "); | 621 | //qDebug("resizeEvent end "); |
622 | 622 | ||
623 | } | 623 | } |
624 | void KOAgendaView::slotDaylabelClicked( int num ) | 624 | void KOAgendaView::slotDaylabelClicked( int num ) |
625 | { | 625 | { |
626 | 626 | ||
627 | QDate firstDate = mSelectedDates.first(); | 627 | QDate firstDate = mSelectedDates.first(); |
628 | if ( num == -1 ) | 628 | if ( num == -1 ) |
629 | emit showDateView( 6, firstDate ); | 629 | emit showDateView( 6, firstDate ); |
630 | else if (num >= 0 ) { | 630 | else if (num >= 0 ) { |
631 | if ( mSelectedDates.count() == 1) | 631 | if ( mSelectedDates.count() == 1) |
632 | emit showDateView( 9, firstDate.addDays( num ) ); | 632 | emit showDateView( 9, firstDate.addDays( num ) ); |
633 | else | 633 | else |
634 | emit showDateView( 3, firstDate.addDays( num ) ); | 634 | emit showDateView( 3, firstDate.addDays( num ) ); |
635 | } | 635 | } |
636 | else | 636 | else |
637 | showDateView( 10, firstDate.addDays(1) ); | 637 | showDateView( 10, firstDate.addDays(1) ); |
638 | } | 638 | } |
639 | 639 | ||
640 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 640 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
641 | { | 641 | { |
642 | 642 | ||
643 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 643 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
644 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 644 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
645 | mDayLabelsList.append( dayLabel ); | 645 | mDayLabelsList.append( dayLabel ); |
646 | mLayoutDayLabels->addWidget(dayLabel); | 646 | mLayoutDayLabels->addWidget(dayLabel); |
647 | return dayLabel ; | 647 | return dayLabel ; |
648 | } | 648 | } |
649 | 649 | ||
650 | void KOAgendaView::createDayLabels() | 650 | void KOAgendaView::createDayLabels() |
651 | { | 651 | { |
652 | 652 | ||
653 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 653 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
654 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 654 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
655 | return; | 655 | return; |
656 | 656 | ||
657 | } | 657 | } |
658 | int newHight; | 658 | int newHight; |
659 | if ( !mSelectedDates.count()) | 659 | if ( !mSelectedDates.count()) |
660 | return; | 660 | return; |
661 | 661 | ||
662 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 662 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
663 | // It would remove some flickering and gain speed (since this is called by | 663 | // It would remove some flickering and gain speed (since this is called by |
664 | // each updateView() call) | 664 | // each updateView() call) |
665 | 665 | ||
666 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; | 666 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; |
667 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 667 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
668 | if ( maxWid < 20 ) | 668 | if ( maxWid < 20 ) |
669 | maxWid = 20; | 669 | maxWid = 20; |
670 | 670 | ||
671 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 671 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
672 | QFontMetrics fm ( dlf ); | 672 | QFontMetrics fm ( dlf ); |
673 | dlf.setBold( true ); | ||
673 | int selCount = mSelectedDates.count(); | 674 | int selCount = mSelectedDates.count(); |
674 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; | 675 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; |
675 | QString dayTest = "Mon 20"; | 676 | QString dayTest = "Mon 20"; |
676 | //QString dayTest = "Mon 20"; | 677 | //QString dayTest = "Mon 20"; |
677 | int wid = fm.width( dayTest ); | 678 | int wid = fm.width( dayTest ); |
678 | //maxWid -= ( selCount * 3 ); //working for QLabels | 679 | //maxWid -= ( selCount * 3 ); //working for QLabels |
679 | if ( QApplication::desktop()->width() <= 320 ) | 680 | if ( QApplication::desktop()->width() <= 320 ) |
680 | maxWid -= ( selCount * 3 ); //working for QPushButton | 681 | maxWid -= ( selCount * 3 ); //working for QPushButton |
681 | else | 682 | else |
682 | maxWid -= ( selCount * 3 ); //working for QPushButton | 683 | maxWid -= ( selCount * 4 ); //working for QPushButton |
683 | if ( maxWid < 0 ) | 684 | if ( maxWid < 0 ) |
684 | maxWid = 20; | 685 | maxWid = 20; |
685 | int needWid = wid * selCount; | 686 | int needWid = wid * selCount; |
686 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 687 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
687 | //if ( needWid > maxWid ) | 688 | //if ( needWid > maxWid ) |
688 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 689 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
689 | while ( needWid > maxWid ) { | 690 | while ( needWid > maxWid ) { |
690 | dayTest = dayTest.left( dayTest.length() - 1 ); | 691 | dayTest = dayTest.left( dayTest.length() - 1 ); |
691 | wid = fm.width( dayTest ); | 692 | wid = fm.width( dayTest ); |
692 | needWid = wid * selCount; | 693 | needWid = wid * selCount; |
693 | } | 694 | } |
694 | int maxLen = dayTest.length(); | 695 | int maxLen = dayTest.length(); |
695 | int fontPoint = dlf.pointSize(); | 696 | int fontPoint = dlf.pointSize(); |
696 | if ( maxLen < 2 ) { | 697 | if ( maxLen < 2 ) { |
697 | int fontPoint = dlf.pointSize(); | 698 | int fontPoint = dlf.pointSize(); |
698 | while ( fontPoint > 4 ) { | 699 | while ( fontPoint > 4 ) { |
699 | --fontPoint; | 700 | --fontPoint; |
700 | dlf.setPointSize( fontPoint ); | 701 | dlf.setPointSize( fontPoint ); |
701 | QFontMetrics f( dlf ); | 702 | QFontMetrics f( dlf ); |
702 | wid = f.width( "30" ); | 703 | wid = f.width( "30" ); |
703 | needWid = wid * selCount; | 704 | needWid = wid * selCount; |
704 | if ( needWid < maxWid ) | 705 | if ( needWid < maxWid ) |
705 | break; | 706 | break; |
706 | } | 707 | } |
707 | maxLen = 2; | 708 | maxLen = 2; |
708 | } | 709 | } |
709 | //qDebug("Max len %d ", dayTest.length() ); | 710 | //qDebug("Max len %d ", dayTest.length() ); |
710 | 711 | if ( !KOPrefs::instance()->mTimeLabelsFont.bold() ) | |
712 | dlf.setBold( false ); | ||
711 | QFontMetrics tempF( dlf ); | 713 | QFontMetrics tempF( dlf ); |
712 | newHight = tempF.height(); | 714 | newHight = tempF.height(); |
713 | mDayLabels->setFont( dlf ); | 715 | mDayLabels->setFont( dlf ); |
714 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 716 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
715 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 717 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
716 | //mLayoutDayLabels->addSpacing( 2 ); | 718 | //mLayoutDayLabels->addSpacing( 2 ); |
717 | // QFont lFont = dlf; | 719 | // QFont lFont = dlf; |
718 | bool appendLabels = false; | 720 | bool appendLabels = false; |
719 | KOAgendaButton *dayLabel; | 721 | KOAgendaButton *dayLabel; |
720 | dayLabel = mDayLabelsList.first(); | 722 | dayLabel = mDayLabelsList.first(); |
721 | if ( !dayLabel ) { | 723 | if ( !dayLabel ) { |
722 | appendLabels = true; | 724 | appendLabels = true; |
723 | dayLabel = getNewDaylabel(); | 725 | dayLabel = getNewDaylabel(); |
724 | } | 726 | } |
725 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); | 727 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); |
726 | dayLabel->setFont( dlf ); | 728 | dayLabel->setFont( dlf ); |
727 | dayLabel->setNum( -1 ); | 729 | dayLabel->setNum( -1 ); |
728 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 730 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
729 | 731 | ||
730 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 732 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
731 | dayLabel->show(); | 733 | dayLabel->show(); |
732 | DateList::ConstIterator dit; | 734 | DateList::ConstIterator dit; |
733 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 735 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
734 | int counter = -1; | 736 | int counter = -1; |
735 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 737 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
736 | ++counter; | 738 | ++counter; |
737 | QDate date = *dit; | 739 | QDate date = *dit; |
738 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 740 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
739 | if ( ! appendLabels ) { | 741 | if ( ! appendLabels ) { |
740 | dayLabel = mDayLabelsList.next(); | 742 | dayLabel = mDayLabelsList.next(); |
741 | if ( !dayLabel ) | 743 | if ( !dayLabel ) |
742 | appendLabels = true; | 744 | appendLabels = true; |
743 | } | 745 | } |
744 | if ( appendLabels ) { | 746 | if ( appendLabels ) { |
745 | dayLabel = getNewDaylabel(); | 747 | dayLabel = getNewDaylabel(); |
746 | } | 748 | } |
747 | dayLabel->setMinimumWidth( 1 ); | 749 | dayLabel->setMinimumWidth( 1 ); |
748 | dayLabel->setMaximumWidth( 10240 ); | 750 | dayLabel->setMaximumWidth( 10240 ); |
749 | dayLabel->setFont( dlf ); | 751 | dayLabel->setFont( dlf ); |
750 | dayLabel->show(); | 752 | dayLabel->show(); |
751 | dayLabel->setAutoRepeat( false ); | 753 | dayLabel->setAutoRepeat( false ); |
752 | dayLabel->setNum( counter ); | 754 | dayLabel->setNum( counter ); |
753 | QString str; | 755 | QString str; |
754 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 756 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
755 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 757 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
756 | switch ( maxLen ) { | 758 | switch ( maxLen ) { |
757 | case 2: | 759 | case 2: |
758 | str = QString::number( date.day() ); | 760 | str = QString::number( date.day() ); |
759 | break; | 761 | break; |
760 | 762 | ||
761 | case 3: | 763 | case 3: |
762 | str = dayName.left( 1 ) +QString::number( date.day()); | 764 | str = dayName.left( 1 ) +QString::number( date.day()); |
763 | 765 | ||
764 | break; | 766 | break; |
765 | case 4: | 767 | case 4: |
766 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 768 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
767 | 769 | ||
768 | break; | 770 | break; |
769 | case 5: | 771 | case 5: |
770 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 772 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
771 | 773 | ||
772 | break; | 774 | break; |
773 | case 6: | 775 | case 6: |
774 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 776 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
775 | break; | 777 | break; |
776 | 778 | ||
777 | default: | 779 | default: |
778 | break; | 780 | break; |
779 | } | 781 | } |
780 | if ( oneday ) { | 782 | if ( oneday ) { |
781 | QString addString; | 783 | QString addString; |
782 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 784 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
783 | addString = i18n("Today"); | 785 | addString = i18n("Today"); |
784 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 786 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
785 | addString = i18n("Tomorrow"); | 787 | addString = i18n("Tomorrow"); |
786 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 788 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
787 | addString = i18n("Yesterday"); | 789 | addString = i18n("Yesterday"); |
788 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 790 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
789 | addString = i18n("Day before yesterday"); | 791 | addString = i18n("Day before yesterday"); |
790 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 792 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
791 | addString = i18n("Day after tomorrow"); | 793 | addString = i18n("Day after tomorrow"); |
792 | if ( !addString.isEmpty() ) { | 794 | if ( !addString.isEmpty() ) { |
793 | str = addString+", " + str; | 795 | str = addString+", " + str; |
794 | } else { | 796 | } else { |
795 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 797 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
796 | } | 798 | } |
797 | } | 799 | } |
798 | dayLabel->setText(str); | 800 | dayLabel->setText(str); |
799 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 801 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
800 | if (date == QDate::currentDate()) { | 802 | if (date == QDate::currentDate()) { |
801 | QFont bFont = dlf; | 803 | QFont bFont = dlf; |
802 | bFont.setBold( true ); | 804 | bFont.setBold( true ); |
803 | dayLabel->setFont(bFont); | 805 | dayLabel->setFont(bFont); |
804 | } | 806 | } |
805 | //dayLayout->addWidget(dayLabel); | 807 | //dayLayout->addWidget(dayLabel); |
806 | 808 | ||
807 | #ifndef KORG_NOPLUGINS | 809 | #ifndef KORG_NOPLUGINS |
808 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 810 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
809 | CalendarDecoration *it; | 811 | CalendarDecoration *it; |
810 | for(it = cds.first(); it; it = cds.next()) { | 812 | for(it = cds.first(); it; it = cds.next()) { |
811 | QString text = it->shortText( date ); | 813 | QString text = it->shortText( date ); |
812 | if ( !text.isEmpty() ) { | 814 | if ( !text.isEmpty() ) { |
813 | QLabel *label = new QLabel(text,mDayLabels); | 815 | QLabel *label = new QLabel(text,mDayLabels); |
814 | label->setAlignment(AlignCenter); | 816 | label->setAlignment(AlignCenter); |
815 | dayLayout->addWidget(label); | 817 | dayLayout->addWidget(label); |
816 | } | 818 | } |
817 | } | 819 | } |
818 | 820 | ||
819 | for(it = cds.first(); it; it = cds.next()) { | 821 | for(it = cds.first(); it; it = cds.next()) { |
820 | QWidget *wid = it->smallWidget(mDayLabels,date); | 822 | QWidget *wid = it->smallWidget(mDayLabels,date); |
821 | if ( wid ) { | 823 | if ( wid ) { |
822 | // wid->setHeight(20); | 824 | // wid->setHeight(20); |
823 | dayLayout->addWidget(wid); | 825 | dayLayout->addWidget(wid); |
824 | } | 826 | } |
825 | } | 827 | } |
826 | #endif | 828 | #endif |
827 | } | 829 | } |
828 | if ( ! appendLabels ) { | 830 | if ( ! appendLabels ) { |
829 | dayLabel = mDayLabelsList.next(); | 831 | dayLabel = mDayLabelsList.next(); |
830 | if ( !dayLabel ) | 832 | if ( !dayLabel ) |
831 | appendLabels = true; | 833 | appendLabels = true; |
832 | } | 834 | } |
833 | if ( appendLabels ) { | 835 | if ( appendLabels ) { |
834 | dayLabel = getNewDaylabel(); | 836 | dayLabel = getNewDaylabel(); |
835 | } | 837 | } |
836 | //dayLabel->hide();//test only | 838 | //dayLabel->hide();//test only |
837 | 839 | ||
838 | dayLabel->setText(">"); | 840 | dayLabel->setText(">"); |
839 | dayLabel->setFont( dlf ); | 841 | dayLabel->setFont( dlf ); |
840 | dayLabel->setAutoRepeat( true ); | 842 | dayLabel->setAutoRepeat( true ); |
841 | dayLabel->show(); | 843 | dayLabel->show(); |
842 | dayLabel->setNum( -2 ); | 844 | dayLabel->setNum( -2 ); |
843 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); | 845 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); |
844 | 846 | ||
845 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 847 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
846 | if ( !appendLabels ) { | 848 | if ( !appendLabels ) { |
847 | dayLabel = mDayLabelsList.next(); | 849 | dayLabel = mDayLabelsList.next(); |
848 | while ( dayLabel ) { | 850 | while ( dayLabel ) { |
849 | //qDebug("!dayLabel %d",dayLabel ); | 851 | //qDebug("!dayLabel %d",dayLabel ); |
850 | dayLabel->hide(); | 852 | dayLabel->hide(); |
851 | dayLabel = mDayLabelsList.next(); | 853 | dayLabel = mDayLabelsList.next(); |
852 | } | 854 | } |
853 | } | 855 | } |
854 | 856 | ||
855 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); | 857 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); |
856 | } | 858 | } |
857 | 859 | ||
858 | int KOAgendaView::maxDatesHint() | 860 | int KOAgendaView::maxDatesHint() |
859 | { | 861 | { |
860 | // Not sure about the max number of events, so return 0 for now. | 862 | // Not sure about the max number of events, so return 0 for now. |
861 | return 0; | 863 | return 0; |
862 | } | 864 | } |
863 | 865 | ||
864 | int KOAgendaView::currentDateCount() | 866 | int KOAgendaView::currentDateCount() |
865 | { | 867 | { |
866 | return mSelectedDates.count(); | 868 | return mSelectedDates.count(); |
867 | } | 869 | } |
868 | 870 | ||
869 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 871 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
870 | { | 872 | { |
871 | QPtrList<Incidence> selected; | 873 | QPtrList<Incidence> selected; |
872 | Incidence *incidence; | 874 | Incidence *incidence; |
873 | 875 | ||
874 | incidence = mAgenda->selectedIncidence(); | 876 | incidence = mAgenda->selectedIncidence(); |
875 | if (incidence) selected.append(incidence); | 877 | if (incidence) selected.append(incidence); |
876 | 878 | ||
877 | incidence = mAllDayAgenda->selectedIncidence(); | 879 | incidence = mAllDayAgenda->selectedIncidence(); |
878 | if (incidence) selected.append(incidence); | 880 | if (incidence) selected.append(incidence); |
879 | 881 | ||
880 | return selected; | 882 | return selected; |
881 | } | 883 | } |
882 | 884 | ||
883 | DateList KOAgendaView::selectedDates() | 885 | DateList KOAgendaView::selectedDates() |
884 | { | 886 | { |
885 | DateList selected; | 887 | DateList selected; |
886 | QDate qd; | 888 | QDate qd; |
887 | 889 | ||
888 | qd = mAgenda->selectedIncidenceDate(); | 890 | qd = mAgenda->selectedIncidenceDate(); |
889 | if (qd.isValid()) selected.append(qd); | 891 | if (qd.isValid()) selected.append(qd); |
890 | 892 | ||
891 | qd = mAllDayAgenda->selectedIncidenceDate(); | 893 | qd = mAllDayAgenda->selectedIncidenceDate(); |
892 | if (qd.isValid()) selected.append(qd); | 894 | if (qd.isValid()) selected.append(qd); |
893 | 895 | ||
894 | return selected; | 896 | return selected; |
895 | } | 897 | } |
896 | 898 | ||
897 | 899 | ||
898 | void KOAgendaView::updateView() | 900 | void KOAgendaView::updateView() |
899 | { | 901 | { |
900 | if ( mBlockUpdating ) | 902 | if ( mBlockUpdating ) |
901 | return; | 903 | return; |
902 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 904 | // kdDebug() << "KOAgendaView::updateView()" << endl; |