summaryrefslogtreecommitdiff
path: root/library
authorhrw <hrw>2005-09-12 21:17:18 (UTC)
committer hrw <hrw>2005-09-12 21:17:18 (UTC)
commit2b74c3a954389db73827ba2bf0d79b835ec569f1 (patch) (unidiff)
tree3d0268c50d01836aea555803ed4f98538881eafe /library
parentc94b0601f73dabfb65525b263222d0ccdbd1544c (diff)
downloadopie-2b74c3a954389db73827ba2bf0d79b835ec569f1.zip
opie-2b74c3a954389db73827ba2bf0d79b835ec569f1.tar.gz
opie-2b74c3a954389db73827ba2bf0d79b835ec569f1.tar.bz2
libqpe/datebookmonth selector use too small fontsize on VGA screen.
- now on =>480 screen.width it will use "default_fontsize" - 2 size on smaller screen devices behavior is not changed - close bug #1695
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/datebookmonth.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/library/datebookmonth.cpp b/library/datebookmonth.cpp
index 2616b7b..ffdf335 100644
--- a/library/datebookmonth.cpp
+++ b/library/datebookmonth.cpp
@@ -408,369 +408,376 @@ DateBookMonth::DateBookMonth( QWidget *parent, const char *name, bool ac,
408 408
409DateBookMonth::~DateBookMonth() 409DateBookMonth::~DateBookMonth()
410{ 410{
411 411
412} 412}
413 413
414void DateBookMonth::setDate( int y, int m ) 414void DateBookMonth::setDate( int y, int m )
415{ 415{
416 /* only change the date if this is a different date, 416 /* only change the date if this is a different date,
417 * other wise we may mistakenly overide the day */ 417 * other wise we may mistakenly overide the day */
418 if ( (y != year) || (m != month) ) { 418 if ( (y != year) || (m != month) ) {
419 year = y; 419 year = y;
420 month = m; 420 month = m;
421 QDate nd( y, m, 1 ); 421 QDate nd( y, m, 1 );
422 if ( nd.daysInMonth() < day ) 422 if ( nd.daysInMonth() < day )
423 day = nd.daysInMonth(); 423 day = nd.daysInMonth();
424 table->setDate( year, month, day ); 424 table->setDate( year, month, day );
425 } 425 }
426} 426}
427 427
428void DateBookMonth::setDate( int y, int m, int d ) 428void DateBookMonth::setDate( int y, int m, int d )
429{ 429{
430 header->setDate( y, m); 430 header->setDate( y, m);
431 table->setDate( y, m, d); 431 table->setDate( y, m, d);
432 year = y; 432 year = y;
433 month = m; 433 month = m;
434 day = d; 434 day = d;
435} 435}
436 436
437/* called when we wish to close or pass back the date */ 437/* called when we wish to close or pass back the date */
438void DateBookMonth::finalDate(int y, int m, int d) 438void DateBookMonth::finalDate(int y, int m, int d)
439{ 439{
440 setDate( y, m, d ); 440 setDate( y, m, d );
441 441
442 emit dateClicked(y, m, d); 442 emit dateClicked(y, m, d);
443 // emit dateClicked(QDate(y, m, d).toString()); 443 // emit dateClicked(QDate(y, m, d).toString());
444 444
445 if ( autoClose && parentWidget() ) 445 if ( autoClose && parentWidget() )
446 parentWidget()->close(); 446 parentWidget()->close();
447} 447}
448 448
449void DateBookMonth::setDate( QDate d) 449void DateBookMonth::setDate( QDate d)
450{ 450{
451 setDate(d.year(), d.month(), d.day()); 451 setDate(d.year(), d.month(), d.day());
452} 452}
453 453
454void DateBookMonth::redraw() 454void DateBookMonth::redraw()
455{ 455{
456 table->setDate( year, month, day ); 456 table->setDate( year, month, day );
457 table->redraw(); 457 table->redraw();
458} 458}
459 459
460QDate DateBookMonth::selectedDate() const 460QDate DateBookMonth::selectedDate() const
461{ 461{
462 if ( !table ) 462 if ( !table )
463 return QDate::currentDate(); 463 return QDate::currentDate();
464 int y, m, d; 464 int y, m, d;
465 table->getDate( y, m, d ); 465 table->getDate( y, m, d );
466 return QDate( y, m, d ); 466 return QDate( y, m, d );
467} 467}
468 468
469void DateBookMonth::slotWeekChange( bool startOnMonday ) 469void DateBookMonth::slotWeekChange( bool startOnMonday )
470{ 470{
471 table->setWeekStart( startOnMonday ); 471 table->setWeekStart( startOnMonday );
472} 472}
473 473
474void DateBookMonth::keyPressEvent( QKeyEvent *e ) 474void DateBookMonth::keyPressEvent( QKeyEvent *e )
475{ 475{
476 switch(e->key()) { 476 switch(e->key()) {
477 case Key_Up: 477 case Key_Up:
478 setDate(QDate(year, month, day).addDays(-7)); 478 setDate(QDate(year, month, day).addDays(-7));
479 break; 479 break;
480 case Key_Down: 480 case Key_Down:
481 setDate(QDate(year, month, day).addDays(7)); 481 setDate(QDate(year, month, day).addDays(7));
482 break; 482 break;
483 case Key_Left: 483 case Key_Left:
484 setDate(QDate(year, month, day).addDays(-1)); 484 setDate(QDate(year, month, day).addDays(-1));
485 break; 485 break;
486 case Key_Right: 486 case Key_Right:
487 setDate(QDate(year, month, day).addDays(1)); 487 setDate(QDate(year, month, day).addDays(1));
488 break; 488 break;
489 case Key_Space: 489 case Key_Space:
490 qWarning("space"); 490 qWarning("space");
491 emit dateClicked(year, month, day); 491 emit dateClicked(year, month, day);
492 if ( autoClose && parentWidget() ) 492 if ( autoClose && parentWidget() )
493 parentWidget()->close(); 493 parentWidget()->close();
494 break; 494 break;
495 default: 495 default:
496 qWarning("ignore"); 496 qWarning("ignore");
497 e->ignore(); 497 e->ignore();
498 break; 498 break;
499 } 499 }
500} 500}
501 501
502//--------------------------------------------------------------------------- 502//---------------------------------------------------------------------------
503class DayItemMonthPrivate 503class DayItemMonthPrivate
504{ 504{
505public: 505public:
506 DayItemMonthPrivate() {}; 506 DayItemMonthPrivate() {};
507 ~DayItemMonthPrivate() { mDayEvents.clear(); }; 507 ~DayItemMonthPrivate() { mDayEvents.clear(); };
508 QValueList<EffectiveEvent> mDayEvents; 508 QValueList<EffectiveEvent> mDayEvents;
509}; 509};
510 510
511DayItemMonth::DayItemMonth( QTable *table, EditType et, const QString &t ) 511DayItemMonth::DayItemMonth( QTable *table, EditType et, const QString &t )
512 : QTableItem( table, et, t ) 512 : QTableItem( table, et, t )
513{ 513{
514 d = new DayItemMonthPrivate(); 514 d = new DayItemMonthPrivate();
515} 515}
516 516
517DayItemMonth::~DayItemMonth() 517DayItemMonth::~DayItemMonth()
518{ 518{
519 daysEvents.clear(); 519 daysEvents.clear();
520 delete d; 520 delete d;
521} 521}
522 522
523void DayItemMonth::setEvents( const QValueList<EffectiveEvent> &effEv ) 523void DayItemMonth::setEvents( const QValueList<EffectiveEvent> &effEv )
524{ 524{
525 d->mDayEvents = effEv; 525 d->mDayEvents = effEv;
526} 526}
527 527
528void DayItemMonth::clearEffEvents() 528void DayItemMonth::clearEffEvents()
529{ 529{
530 d->mDayEvents.clear(); 530 d->mDayEvents.clear();
531} 531}
532 532
533void DayItemMonth::paint( QPainter *p, const QColorGroup &cg, 533void DayItemMonth::paint( QPainter *p, const QColorGroup &cg,
534 const QRect &cr, bool selected ) 534 const QRect &cr, bool selected )
535{ 535{
536 p->save(); 536 p->save();
537 537
538 QColorGroup g( cg ); 538 QColorGroup g( cg );
539 g.setBrush( QColorGroup::Base, back ); 539 g.setBrush( QColorGroup::Base, back );
540 g.setColor( QColorGroup::Text, forg ); 540 g.setColor( QColorGroup::Text, forg );
541 if ( selected ) 541 if ( selected )
542 p->setPen( g.highlightedText() ); 542 p->setPen( g.highlightedText() );
543 else 543 else
544 p->setPen( g.text() ); 544 p->setPen( g.text() );
545 545
546 QValueStack<int> normalLine; 546 QValueStack<int> normalLine;
547 QValueStack<int> repeatLine; 547 QValueStack<int> repeatLine;
548 QValueStack<int> travelLine; 548 QValueStack<int> travelLine;
549 549
550 bool normalAllDay = FALSE; 550 bool normalAllDay = FALSE;
551 bool repeatAllDay = FALSE; 551 bool repeatAllDay = FALSE;
552 bool travelAllDay = FALSE; 552 bool travelAllDay = FALSE;
553 bool holidayAllDay = FALSE; 553 bool holidayAllDay = FALSE;
554 554
555 QValueListIterator<EffectiveEvent> itDays = d->mDayEvents.begin(); 555 QValueListIterator<EffectiveEvent> itDays = d->mDayEvents.begin();
556 556
557 for ( ; itDays != d->mDayEvents.end(); ++itDays ) { 557 for ( ; itDays != d->mDayEvents.end(); ++itDays ) {
558 int w = cr.width(); 558 int w = cr.width();
559 Event ev = (*itDays).event(); 559 Event ev = (*itDays).event();
560 560
561 int f = (*itDays).start().hour(); // assume Effective event 561 int f = (*itDays).start().hour(); // assume Effective event
562 int t = (*itDays).end().hour(); // is truncated. 562 int t = (*itDays).end().hour(); // is truncated.
563 563
564 if (ev.isAllDay()) { 564 if (ev.isAllDay()) {
565 if (!ev.hasRepeat()) { 565 if (!ev.hasRepeat()) {
566 normalAllDay = TRUE; 566 normalAllDay = TRUE;
567 if (!ev.isValidUid()) { 567 if (!ev.isValidUid()) {
568 holidayAllDay = TRUE; 568 holidayAllDay = TRUE;
569 } 569 }
570 } else { 570 } else {
571 repeatAllDay = TRUE; 571 repeatAllDay = TRUE;
572 } 572 }
573 } else { 573 } else {
574 int sLine, eLine; 574 int sLine, eLine;
575 if (f == 0) 575 if (f == 0)
576 sLine = 0; 576 sLine = 0;
577 else if (f < 8 ) 577 else if (f < 8 )
578 sLine = 1; 578 sLine = 1;
579 else if (f >= 17) 579 else if (f >= 17)
580 sLine = w - 4; 580 sLine = w - 4;
581 else { 581 else {
582 sLine = (f - 8) * (w - 8); 582 sLine = (f - 8) * (w - 8);
583 if (sLine) 583 if (sLine)
584 sLine /= 8; 584 sLine /= 8;
585 sLine += 4; 585 sLine += 4;
586 } 586 }
587 if (t == 23) 587 if (t == 23)
588 eLine = w; 588 eLine = w;
589 else if (t < 8) 589 else if (t < 8)
590 eLine = 4; 590 eLine = 4;
591 else if (t >= 17) 591 else if (t >= 17)
592 eLine = w - 1; 592 eLine = w - 1;
593 else { 593 else {
594 eLine = (t - 8) * (w - 8); 594 eLine = (t - 8) * (w - 8);
595 if (eLine) 595 if (eLine)
596 eLine /= 8; 596 eLine /= 8;
597 eLine += 4; 597 eLine += 4;
598 } 598 }
599 if (!ev.hasRepeat()) { 599 if (!ev.hasRepeat()) {
600 normalLine.push(sLine); 600 normalLine.push(sLine);
601 normalLine.push(eLine); 601 normalLine.push(eLine);
602 } else { 602 } else {
603 repeatLine.push(sLine); 603 repeatLine.push(sLine);
604 repeatLine.push(eLine); 604 repeatLine.push(eLine);
605 } 605 }
606 } 606 }
607 } 607 }
608 608
609 // draw the background 609 // draw the background
610 if (normalAllDay || repeatAllDay || travelAllDay || holidayAllDay) { 610 if (normalAllDay || repeatAllDay || travelAllDay || holidayAllDay) {
611 p->save(); 611 p->save();
612 612
613 if (normalAllDay) 613 if (normalAllDay)
614 if (repeatAllDay) { 614 if (repeatAllDay) {
615 p->fillRect( 0, 0, cr.width(), cr.height() / 2, 615 p->fillRect( 0, 0, cr.width(), cr.height() / 2,
616 s_colorNormalLight ); 616 s_colorNormalLight );
617 p->fillRect( 0, cr.height() / 2, cr.width(), cr.height() / 2, 617 p->fillRect( 0, cr.height() / 2, cr.width(), cr.height() / 2,
618 colorRepeatLight ); 618 colorRepeatLight );
619 } else { 619 } else {
620 if (!holidayAllDay) { 620 if (!holidayAllDay) {
621 p->fillRect( 0, 0, cr.width(), cr.height(), 621 p->fillRect( 0, 0, cr.width(), cr.height(),
622 s_colorNormalLight ); 622 s_colorNormalLight );
623 } else { 623 } else {
624 p->fillRect( 0, 0, cr.width(), cr.height(), 624 p->fillRect( 0, 0, cr.width(), cr.height(),
625 s_colorHolidayLight ); 625 s_colorHolidayLight );
626 } 626 }
627 } else if (repeatAllDay) { 627 } else if (repeatAllDay) {
628 p->fillRect( 0, 0, cr.width(), cr.height(), 628 p->fillRect( 0, 0, cr.width(), cr.height(),
629 s_colorRepeatLight ); 629 s_colorRepeatLight );
630 } 630 }
631 } else { 631 } else {
632 p->fillRect( 0, 0, cr.width(), 632 p->fillRect( 0, 0, cr.width(),
633 cr.height(), selected 633 cr.height(), selected
634 ? g.brush( QColorGroup::Highlight ) 634 ? g.brush( QColorGroup::Highlight )
635 : g.brush( QColorGroup::Base ) ); 635 : g.brush( QColorGroup::Base ) );
636 } 636 }
637 637
638 // The lines 638 // The lines
639 // now for the lines. 639 // now for the lines.
640 int h = 5; 640 int h = 5;
641 int y = cr.height() / 2 - h; 641 int y = cr.height() / 2 - h;
642 642
643 while(normalLine.count() >= 2) { 643 while(normalLine.count() >= 2) {
644 int x2 = normalLine.pop(); 644 int x2 = normalLine.pop();
645 int x1 = normalLine.pop(); 645 int x1 = normalLine.pop();
646 if (x2 < x1 + 2) 646 if (x2 < x1 + 2)
647 x2 = x1 + 2; 647 x2 = x1 + 2;
648 p->fillRect(x1, y, x2 - x1, h, colorNormal); 648 p->fillRect(x1, y, x2 - x1, h, colorNormal);
649 } 649 }
650 650
651 y += h; 651 y += h;
652 652
653 while(repeatLine.count() >= 2) { 653 while(repeatLine.count() >= 2) {
654 int x2 = repeatLine.pop(); 654 int x2 = repeatLine.pop();
655 int x1 = repeatLine.pop(); 655 int x1 = repeatLine.pop();
656 if (x2 < x1 + 2) 656 if (x2 < x1 + 2)
657 x2 = x1 + 2; 657 x2 = x1 + 2;
658 p->fillRect(x1, y, x2 - x1, h, colorRepeat); 658 p->fillRect(x1, y, x2 - x1, h, colorRepeat);
659 } 659 }
660 660
661 661
662 // Finally, draw the number. 662 // Finally, draw the number.
663 QFont f = p->font(); 663 QFont f = p->font();
664 f.setPointSize( ( f.pointSize() / 3 ) * 2 ); 664 if(qApp->desktop()->width() >= 480)
665 {
666 f.setPointSize( f.pointSize() - 2 );
667 }
668 else
669 {
670 f.setPointSize( ( f.pointSize() / 3 ) * 2 );
671 }
665 p->setFont( f ); 672 p->setFont( f );
666 QFontMetrics fm( f ); 673 QFontMetrics fm( f );
667 p->drawText( 1, 1 + fm.ascent(), QString::number( day() ) ); 674 p->drawText( 1, 1 + fm.ascent(), QString::number( day() ) );
668 675
669 p->restore(); 676 p->restore();
670} 677}
671 678
672 679
673 680
674void DayItemMonth::setType( Calendar::Day::Type t ) 681void DayItemMonth::setType( Calendar::Day::Type t )
675{ 682{
676 switch ( t ) { 683 switch ( t ) {
677 case Calendar::Day::PrevMonth: 684 case Calendar::Day::PrevMonth:
678 case Calendar::Day::NextMonth: 685 case Calendar::Day::NextMonth:
679 back = QBrush( QColor( 224, 224, 224 ) ); 686 back = QBrush( QColor( 224, 224, 224 ) );
680 forg = black; 687 forg = black;
681 break; 688 break;
682 case Calendar::Day::ThisMonth: 689 case Calendar::Day::ThisMonth:
683 back = QBrush( white ); 690 back = QBrush( white );
684 forg = black; 691 forg = black;
685 break; 692 break;
686 } 693 }
687 typ = t; 694 typ = t;
688} 695}
689 696
690 697
691 698
692DateButton::DateButton( bool longDate, QWidget *parent, const char * name ) 699DateButton::DateButton( bool longDate, QWidget *parent, const char * name )
693 :QPushButton( parent, name ) 700 :QPushButton( parent, name )
694{ 701{
695 longFormat = longDate; 702 longFormat = longDate;
696 df = DateFormat('/', DateFormat::MonthDayYear, DateFormat::MonthDayYear); 703 df = DateFormat('/', DateFormat::MonthDayYear, DateFormat::MonthDayYear);
697 setDate( QDate::currentDate() ); 704 setDate( QDate::currentDate() );
698 705
699 connect(this,SIGNAL(pressed()),this,SLOT(pickDate())); 706 connect(this,SIGNAL(pressed()),this,SLOT(pickDate()));
700 707
701 708
702} 709}
703 710
704 711
705void DateButton::pickDate() 712void DateButton::pickDate()
706{ 713{
707 static QPopupMenu *m1 = 0; 714 static QPopupMenu *m1 = 0;
708 static DateBookMonth *picker = 0; 715 static DateBookMonth *picker = 0;
709 if ( !m1 ) { 716 if ( !m1 ) {
710 m1 = new QPopupMenu( this ); 717 m1 = new QPopupMenu( this );
711 picker = new DateBookMonth( m1, 0, TRUE ); 718 picker = new DateBookMonth( m1, 0, TRUE );
712 m1->insertItem( picker ); 719 m1->insertItem( picker );
713 connect( picker, SIGNAL( dateClicked(int,int,int) ), 720 connect( picker, SIGNAL( dateClicked(int,int,int) ),
714 this, SLOT( setDate(int,int,int) ) ); 721 this, SLOT( setDate(int,int,int) ) );
715 connect( picker, SIGNAL( dateClicked(int,int,int) ), 722 connect( picker, SIGNAL( dateClicked(int,int,int) ),
716 this, SIGNAL( dateSelected(int,int,int) ) ); 723 this, SIGNAL( dateSelected(int,int,int) ) );
717 connect( m1, SIGNAL( aboutToHide() ), 724 connect( m1, SIGNAL( aboutToHide() ),
718 this, SLOT( gotHide() ) ); 725 this, SLOT( gotHide() ) );
719 } 726 }
720 picker->slotWeekChange( weekStartsMonday ); 727 picker->slotWeekChange( weekStartsMonday );
721 picker->setDate( currDate.year(), currDate.month(), currDate.day() ); 728 picker->setDate( currDate.year(), currDate.month(), currDate.day() );
722 m1->popup(mapToGlobal(QPoint(0,height()))); 729 m1->popup(mapToGlobal(QPoint(0,height())));
723 picker->setFocus(); 730 picker->setFocus();
724} 731}
725 732
726 733
727void DateButton::gotHide() 734void DateButton::gotHide()
728{ 735{
729 // we have to redo the button... 736 // we have to redo the button...
730 setDown( false ); 737 setDown( false );
731} 738}
732 739
733 740
734// void dateSelected( int year, int month, int day ); 741// void dateSelected( int year, int month, int day );
735 742
736void DateButton::setWeekStartsMonday( int b ) 743void DateButton::setWeekStartsMonday( int b )
737{ 744{
738 weekStartsMonday = b; 745 weekStartsMonday = b;
739} 746}
740 747
741void DateButton::setDate( int y, int m, int d ) 748void DateButton::setDate( int y, int m, int d )
742{ 749{
743 setDate( QDate( y,m,d) ); 750 setDate( QDate( y,m,d) );
744} 751}
745 752
746void DateButton::setDate( QDate d ) 753void DateButton::setDate( QDate d )
747{ 754{
748 currDate = d; 755 currDate = d;
749 setText( longFormat ? TimeString::longDateString( d, df ) : 756 setText( longFormat ? TimeString::longDateString( d, df ) :
750 TimeString::shortDate( d, df ) ); 757 TimeString::shortDate( d, df ) );
751 758
752} 759}
753 760
754void DateButton::setDateFormat( DateFormat f ) 761void DateButton::setDateFormat( DateFormat f )
755{ 762{
756 df = f; 763 df = f;
757 setDate( currDate ); 764 setDate( currDate );
758} 765}
759 766
760bool DateButton::customWhatsThis() const 767bool DateButton::customWhatsThis() const
761{ 768{
762 return TRUE; 769 return TRUE;
763} 770}
764 771
765 772
766// this class is only here for Sharp ROM compatibility 773// this class is only here for Sharp ROM compatibility
767// I have reverse engineered this class and it seems to 774// I have reverse engineered this class and it seems to
768// work (only qtmail seems to use it) - sandman 775// work (only qtmail seems to use it) - sandman
769// DO NOT USE IT IN NEW CODE !! 776// DO NOT USE IT IN NEW CODE !!
770 777
771DateBookMonthPopup::DateBookMonthPopup ( QWidget *w ) 778DateBookMonthPopup::DateBookMonthPopup ( QWidget *w )
772 : QPopupMenu ( w ) 779 : QPopupMenu ( w )
773{ 780{
774 m_dbm = new DateBookMonth( this, 0, TRUE ); 781 m_dbm = new DateBookMonth( this, 0, TRUE );
775 insertItem( m_dbm ); 782 insertItem( m_dbm );
776} 783}