-rw-r--r-- | library/datebookmonth.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/library/datebookmonth.cpp b/library/datebookmonth.cpp index 4a9dcbd..e8be313 100644 --- a/library/datebookmonth.cpp +++ b/library/datebookmonth.cpp | |||
@@ -559,192 +559,204 @@ void DayItemMonth::paint( QPainter *p, const QColorGroup &cg, | |||
559 | 559 | ||
560 | if (ev.isAllDay()) { | 560 | if (ev.isAllDay()) { |
561 | if (!ev.hasRepeat()) | 561 | if (!ev.hasRepeat()) |
562 | normalAllDay = TRUE; | 562 | normalAllDay = TRUE; |
563 | else | 563 | else |
564 | repeatAllDay = TRUE; | 564 | repeatAllDay = TRUE; |
565 | } else { | 565 | } else { |
566 | int sLine, eLine; | 566 | int sLine, eLine; |
567 | if (f == 0) | 567 | if (f == 0) |
568 | sLine = 0; | 568 | sLine = 0; |
569 | else if (f < 8 ) | 569 | else if (f < 8 ) |
570 | sLine = 1; | 570 | sLine = 1; |
571 | else if (f >= 17) | 571 | else if (f >= 17) |
572 | sLine = w - 4; | 572 | sLine = w - 4; |
573 | else { | 573 | else { |
574 | sLine = (f - 8) * (w - 8); | 574 | sLine = (f - 8) * (w - 8); |
575 | if (sLine) | 575 | if (sLine) |
576 | sLine /= 8; | 576 | sLine /= 8; |
577 | sLine += 4; | 577 | sLine += 4; |
578 | } | 578 | } |
579 | if (t == 23) | 579 | if (t == 23) |
580 | eLine = w; | 580 | eLine = w; |
581 | else if (t < 8) | 581 | else if (t < 8) |
582 | eLine = 4; | 582 | eLine = 4; |
583 | else if (t >= 17) | 583 | else if (t >= 17) |
584 | eLine = w - 1; | 584 | eLine = w - 1; |
585 | else { | 585 | else { |
586 | eLine = (t - 8) * (w - 8); | 586 | eLine = (t - 8) * (w - 8); |
587 | if (eLine) | 587 | if (eLine) |
588 | eLine /= 8; | 588 | eLine /= 8; |
589 | eLine += 4; | 589 | eLine += 4; |
590 | } | 590 | } |
591 | if (!ev.hasRepeat()) { | 591 | if (!ev.hasRepeat()) { |
592 | normalLine.push(sLine); | 592 | normalLine.push(sLine); |
593 | normalLine.push(eLine); | 593 | normalLine.push(eLine); |
594 | } else { | 594 | } else { |
595 | repeatLine.push(sLine); | 595 | repeatLine.push(sLine); |
596 | repeatLine.push(eLine); | 596 | repeatLine.push(eLine); |
597 | } | 597 | } |
598 | } | 598 | } |
599 | } | 599 | } |
600 | 600 | ||
601 | // draw the background | 601 | // draw the background |
602 | if (normalAllDay || repeatAllDay || travelAllDay) { | 602 | if (normalAllDay || repeatAllDay || travelAllDay) { |
603 | p->save(); | 603 | p->save(); |
604 | 604 | ||
605 | if (normalAllDay) | 605 | if (normalAllDay) |
606 | if (repeatAllDay) { | 606 | if (repeatAllDay) { |
607 | p->fillRect( 0, 0, cr.width(), cr.height() / 2, | 607 | p->fillRect( 0, 0, cr.width(), cr.height() / 2, |
608 | colorNormalLight ); | 608 | colorNormalLight ); |
609 | p->fillRect( 0, cr.height() / 2, cr.width(), cr.height() / 2, | 609 | p->fillRect( 0, cr.height() / 2, cr.width(), cr.height() / 2, |
610 | colorRepeatLight ); | 610 | colorRepeatLight ); |
611 | } else | 611 | } else |
612 | p->fillRect( 0, 0, cr.width(), cr.height(), | 612 | p->fillRect( 0, 0, cr.width(), cr.height(), |
613 | colorNormalLight ); | 613 | colorNormalLight ); |
614 | else if (repeatAllDay) | 614 | else if (repeatAllDay) |
615 | p->fillRect( 0, 0, cr.width(), cr.height(), | 615 | p->fillRect( 0, 0, cr.width(), cr.height(), |
616 | colorRepeatLight ); | 616 | colorRepeatLight ); |
617 | } else { | 617 | } else { |
618 | p->fillRect( 0, 0, cr.width(), | 618 | p->fillRect( 0, 0, cr.width(), |
619 | cr.height(), selected | 619 | cr.height(), selected |
620 | ? g.brush( QColorGroup::Highlight ) | 620 | ? g.brush( QColorGroup::Highlight ) |
621 | : g.brush( QColorGroup::Base ) ); | 621 | : g.brush( QColorGroup::Base ) ); |
622 | } | 622 | } |
623 | 623 | ||
624 | // The lines | 624 | // The lines |
625 | // now for the lines. | 625 | // now for the lines. |
626 | int h = 5; | 626 | int h = 5; |
627 | int y = cr.height() / 2 - h; | 627 | int y = cr.height() / 2 - h; |
628 | 628 | ||
629 | while(normalLine.count() >= 2) { | 629 | while(normalLine.count() >= 2) { |
630 | int x2 = normalLine.pop(); | 630 | int x2 = normalLine.pop(); |
631 | int x1 = normalLine.pop(); | 631 | int x1 = normalLine.pop(); |
632 | if (x2 < x1 + 2) | 632 | if (x2 < x1 + 2) |
633 | x2 = x1 + 2; | 633 | x2 = x1 + 2; |
634 | p->fillRect(x1, y, x2 - x1, h, colorNormal); | 634 | p->fillRect(x1, y, x2 - x1, h, colorNormal); |
635 | } | 635 | } |
636 | 636 | ||
637 | y += h; | 637 | y += h; |
638 | 638 | ||
639 | while(repeatLine.count() >= 2) { | 639 | while(repeatLine.count() >= 2) { |
640 | int x2 = repeatLine.pop(); | 640 | int x2 = repeatLine.pop(); |
641 | int x1 = repeatLine.pop(); | 641 | int x1 = repeatLine.pop(); |
642 | if (x2 < x1 + 2) | 642 | if (x2 < x1 + 2) |
643 | x2 = x1 + 2; | 643 | x2 = x1 + 2; |
644 | p->fillRect(x1, y, x2 - x1, h, colorRepeat); | 644 | p->fillRect(x1, y, x2 - x1, h, colorRepeat); |
645 | } | 645 | } |
646 | 646 | ||
647 | 647 | ||
648 | // Finally, draw the number. | 648 | // Finally, draw the number. |
649 | QFont f = p->font(); | 649 | QFont f = p->font(); |
650 | f.setPointSize( ( f.pointSize() / 3 ) * 2 ); | 650 | f.setPointSize( ( f.pointSize() / 3 ) * 2 ); |
651 | p->setFont( f ); | 651 | p->setFont( f ); |
652 | QFontMetrics fm( f ); | 652 | QFontMetrics fm( f ); |
653 | p->drawText( 1, 1 + fm.ascent(), QString::number( day() ) ); | 653 | p->drawText( 1, 1 + fm.ascent(), QString::number( day() ) ); |
654 | 654 | ||
655 | p->restore(); | 655 | p->restore(); |
656 | } | 656 | } |
657 | 657 | ||
658 | 658 | ||
659 | 659 | ||
660 | void DayItemMonth::setType( Calendar::Day::Type t ) | 660 | void DayItemMonth::setType( Calendar::Day::Type t ) |
661 | { | 661 | { |
662 | switch ( t ) { | 662 | switch ( t ) { |
663 | case Calendar::Day::PrevMonth: | 663 | case Calendar::Day::PrevMonth: |
664 | case Calendar::Day::NextMonth: | 664 | case Calendar::Day::NextMonth: |
665 | back = QBrush( QColor( 224, 224, 224 ) ); | 665 | back = QBrush( QColor( 224, 224, 224 ) ); |
666 | forg = black; | 666 | forg = black; |
667 | break; | 667 | break; |
668 | case Calendar::Day::ThisMonth: | 668 | case Calendar::Day::ThisMonth: |
669 | back = QBrush( white ); | 669 | back = QBrush( white ); |
670 | forg = black; | 670 | forg = black; |
671 | break; | 671 | break; |
672 | } | 672 | } |
673 | typ = t; | 673 | typ = t; |
674 | } | 674 | } |
675 | 675 | ||
676 | 676 | ||
677 | 677 | ||
678 | DateButton::DateButton( bool longDate, QWidget *parent, const char * name ) | 678 | DateButton::DateButton( bool longDate, QWidget *parent, const char * name ) |
679 | :QPushButton( parent, name ) | 679 | :QPushButton( parent, name ) |
680 | { | 680 | { |
681 | longFormat = longDate; | 681 | longFormat = longDate; |
682 | df = DateFormat('/', DateFormat::MonthDayYear, DateFormat::MonthDayYear); | 682 | df = DateFormat('/', DateFormat::MonthDayYear, DateFormat::MonthDayYear); |
683 | setDate( QDate::currentDate() ); | 683 | setDate( QDate::currentDate() ); |
684 | 684 | ||
685 | connect(this,SIGNAL(pressed()),this,SLOT(pickDate())); | 685 | connect(this,SIGNAL(pressed()),this,SLOT(pickDate())); |
686 | 686 | ||
687 | 687 | ||
688 | } | 688 | } |
689 | 689 | ||
690 | 690 | ||
691 | void DateButton::pickDate() | 691 | void DateButton::pickDate() |
692 | { | 692 | { |
693 | static QPopupMenu *m1 = 0; | 693 | static QPopupMenu *m1 = 0; |
694 | static DateBookMonth *picker = 0; | 694 | static DateBookMonth *picker = 0; |
695 | if ( !m1 ) { | 695 | if ( !m1 ) { |
696 | m1 = new QPopupMenu( this ); | 696 | m1 = new QPopupMenu( this ); |
697 | picker = new DateBookMonth( m1, 0, TRUE ); | 697 | picker = new DateBookMonth( m1, 0, TRUE ); |
698 | m1->insertItem( picker ); | 698 | m1->insertItem( picker ); |
699 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), | 699 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), |
700 | this, SLOT( setDate( int, int, int ) ) ); | 700 | this, SLOT( setDate( int, int, int ) ) ); |
701 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), | 701 | connect( picker, SIGNAL( dateClicked( int, int, int ) ), |
702 | this, SIGNAL( dateSelected( int, int, int ) ) ); | 702 | this, SIGNAL( dateSelected( int, int, int ) ) ); |
703 | connect( m1, SIGNAL( aboutToHide() ), | 703 | connect( m1, SIGNAL( aboutToHide() ), |
704 | this, SLOT( gotHide() ) ); | 704 | this, SLOT( gotHide() ) ); |
705 | } | 705 | } |
706 | picker->slotWeekChange( weekStartsMonday ); | 706 | picker->slotWeekChange( weekStartsMonday ); |
707 | picker->setDate( currDate.year(), currDate.month(), currDate.day() ); | 707 | picker->setDate( currDate.year(), currDate.month(), currDate.day() ); |
708 | m1->popup(mapToGlobal(QPoint(0,height()))); | 708 | m1->popup(mapToGlobal(QPoint(0,height()))); |
709 | picker->setFocus(); | 709 | picker->setFocus(); |
710 | } | 710 | } |
711 | 711 | ||
712 | 712 | ||
713 | void DateButton::gotHide() | 713 | void DateButton::gotHide() |
714 | { | 714 | { |
715 | // we have to redo the button... | 715 | // we have to redo the button... |
716 | setDown( false ); | 716 | setDown( false ); |
717 | } | 717 | } |
718 | 718 | ||
719 | 719 | ||
720 | // void dateSelected( int year, int month, int day ); | 720 | // void dateSelected( int year, int month, int day ); |
721 | 721 | ||
722 | void DateButton::setWeekStartsMonday( int b ) | 722 | void DateButton::setWeekStartsMonday( int b ) |
723 | { | 723 | { |
724 | weekStartsMonday = b; | 724 | weekStartsMonday = b; |
725 | } | 725 | } |
726 | 726 | ||
727 | void DateButton::setDate( int y, int m, int d ) | 727 | void DateButton::setDate( int y, int m, int d ) |
728 | { | 728 | { |
729 | setDate( QDate( y,m,d) ); | 729 | setDate( QDate( y,m,d) ); |
730 | } | 730 | } |
731 | 731 | ||
732 | void DateButton::setDate( QDate d ) | 732 | void DateButton::setDate( QDate d ) |
733 | { | 733 | { |
734 | currDate = d; | 734 | currDate = d; |
735 | setText( longFormat ? TimeString::longDateString( d, df ) : | 735 | setText( longFormat ? TimeString::longDateString( d, df ) : |
736 | TimeString::shortDate( d, df ) ); | 736 | TimeString::shortDate( d, df ) ); |
737 | 737 | ||
738 | } | 738 | } |
739 | 739 | ||
740 | void DateButton::setDateFormat( DateFormat f ) | 740 | void DateButton::setDateFormat( DateFormat f ) |
741 | { | 741 | { |
742 | df = f; | 742 | df = f; |
743 | setDate( currDate ); | 743 | setDate( currDate ); |
744 | } | 744 | } |
745 | 745 | ||
746 | bool DateButton::customWhatsThis() const | 746 | bool DateButton::customWhatsThis() const |
747 | { | 747 | { |
748 | return TRUE; | 748 | return TRUE; |
749 | } | 749 | } |
750 | 750 | ||
751 | |||
752 | // this class is only here for Sharp ROM compatibility | ||
753 | // I have reverse engineered this class and it seems to | ||
754 | // work (only qtmail seems to use it) - sandman | ||
755 | // DO NOT USE IT IN NEW CODE !! | ||
756 | |||
757 | DateBookMonthPopup::DateBookMonthPopup ( QWidget *w ) | ||
758 | : QPopupMenu ( w ) | ||
759 | { | ||
760 | m_dbm = new DateBookMonth( this, 0, TRUE ); | ||
761 | insertItem( m_dbm ); | ||
762 | } | ||