-rw-r--r-- | core/pim/datebook/datebookday.cpp | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index aaf3e16..a6a1be3 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp | |||
@@ -506,274 +506,269 @@ DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const | |||
506 | } | 506 | } |
507 | 507 | ||
508 | 508 | ||
509 | QDate DateBookDay::date() const | 509 | QDate DateBookDay::date() const |
510 | { | 510 | { |
511 | return currDate; | 511 | return currDate; |
512 | } | 512 | } |
513 | 513 | ||
514 | void DateBookDay::setStartViewTime( int startHere ) | 514 | void DateBookDay::setStartViewTime( int startHere ) |
515 | { | 515 | { |
516 | startTime = startHere; | 516 | startTime = startHere; |
517 | dayView()->clearSelection(); | 517 | dayView()->clearSelection(); |
518 | QTableSelection ts; | 518 | QTableSelection ts; |
519 | 519 | ||
520 | if (jumpToCurTime && this->date() == QDate::currentDate())//this should probably be in datebook.cpp where it's called? | 520 | if (jumpToCurTime && this->date() == QDate::currentDate())//this should probably be in datebook.cpp where it's called? |
521 | { | 521 | { |
522 | ts.init( QTime::currentTime().hour(), 0); | 522 | ts.init( QTime::currentTime().hour(), 0); |
523 | ts.expandTo( QTime::currentTime().hour(), 0); | 523 | ts.expandTo( QTime::currentTime().hour(), 0); |
524 | } else | 524 | } else |
525 | { | 525 | { |
526 | ts.init( startTime, 0 ); | 526 | ts.init( startTime, 0 ); |
527 | ts.expandTo( startTime, 0 ); | 527 | ts.expandTo( startTime, 0 ); |
528 | } | 528 | } |
529 | 529 | ||
530 | dayView()->addSelection( ts ); | 530 | dayView()->addSelection( ts ); |
531 | } | 531 | } |
532 | 532 | ||
533 | int DateBookDay::startViewTime() const | 533 | int DateBookDay::startViewTime() const |
534 | { | 534 | { |
535 | return startTime; | 535 | return startTime; |
536 | } | 536 | } |
537 | 537 | ||
538 | void DateBookDay::slotWeekChanged( bool bStartOnMonday ) | 538 | void DateBookDay::slotWeekChanged( bool bStartOnMonday ) |
539 | { | 539 | { |
540 | header->setStartOfWeek( bStartOnMonday ); | 540 | header->setStartOfWeek( bStartOnMonday ); |
541 | // redraw(); | 541 | // redraw(); |
542 | } | 542 | } |
543 | 543 | ||
544 | void DateBookDay::keyPressEvent(QKeyEvent *e) | 544 | void DateBookDay::keyPressEvent(QKeyEvent *e) |
545 | { | 545 | { |
546 | switch(e->key()) { | 546 | switch(e->key()) { |
547 | case Key_Up: | 547 | case Key_Up: |
548 | view->moveUp(); | 548 | view->moveUp(); |
549 | break; | 549 | break; |
550 | case Key_Down: | 550 | case Key_Down: |
551 | view->moveDown(); | 551 | view->moveDown(); |
552 | break; | 552 | break; |
553 | case Key_Left: | 553 | case Key_Left: |
554 | setDate(QDate(currDate).addDays(-1)); | 554 | setDate(QDate(currDate).addDays(-1)); |
555 | break; | 555 | break; |
556 | case Key_Right: | 556 | case Key_Right: |
557 | setDate(QDate(currDate).addDays(1)); | 557 | setDate(QDate(currDate).addDays(1)); |
558 | break; | 558 | break; |
559 | default: | 559 | default: |
560 | e->ignore(); | 560 | e->ignore(); |
561 | } | 561 | } |
562 | } | 562 | } |
563 | 563 | ||
564 | //=========================================================================== | 564 | //=========================================================================== |
565 | 565 | ||
566 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, | 566 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, |
567 | DateBookDay *db ) | 567 | DateBookDay *db ) |
568 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) | 568 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) |
569 | { | 569 | { |
570 | 570 | ||
571 | 571 | ||
572 | // why would someone use "<"? Oh well, fix it up... | 572 | // why would someone use "<"? Oh well, fix it up... |
573 | // I wonder what other things may be messed up... | 573 | // I wonder what other things may be messed up... |
574 | QString strDesc = ev.description(); | 574 | QString strDesc = ev.description(); |
575 | int where = strDesc.find( "<" ); | 575 | int where = strDesc.find( "<" ); |
576 | while ( where != -1 ) { | 576 | while ( where != -1 ) { |
577 | strDesc.remove( where, 1 ); | 577 | strDesc.remove( where, 1 ); |
578 | strDesc.insert( where, "<" ); | 578 | strDesc.insert( where, "<" ); |
579 | where = strDesc.find( "<", where ); | 579 | where = strDesc.find( "<", where ); |
580 | } | 580 | } |
581 | 581 | ||
582 | QString strCat; | 582 | QString strCat; |
583 | // ### Fix later... | 583 | // ### Fix later... |
584 | // QString strCat = ev.category(); | 584 | // QString strCat = ev.category(); |
585 | // where = strCat.find( "<" ); | 585 | // where = strCat.find( "<" ); |
586 | // while ( where != -1 ) { | 586 | // while ( where != -1 ) { |
587 | // strCat.remove( where, 1 ); | 587 | // strCat.remove( where, 1 ); |
588 | // strCat.insert( where, "<" ); | 588 | // strCat.insert( where, "<" ); |
589 | // where = strCat.find( "<", where ); | 589 | // where = strCat.find( "<", where ); |
590 | // } | 590 | // } |
591 | 591 | ||
592 | QString strNote = ev.notes(); | 592 | QString strNote = ev.notes(); |
593 | where = strNote.find( "<" ); | 593 | where = strNote.find( "<" ); |
594 | while ( where != -1 ) { | 594 | while ( where != -1 ) { |
595 | strNote.remove( where, 1 ); | 595 | strNote.remove( where, 1 ); |
596 | strNote.insert( where, "<" ); | 596 | strNote.insert( where, "<" ); |
597 | where = strNote.find( "<", where ); | 597 | where = strNote.find( "<", where ); |
598 | } | 598 | } |
599 | 599 | ||
600 | text = "<b>" + strDesc + "</b><br>" + "<i>"; | 600 | text = "<b>" + strDesc + "</b><br>" + "<i>"; |
601 | if ( !strCat.isEmpty() ) { | 601 | if ( !strCat.isEmpty() ) { |
602 | text += strCat + "</i><br>"; | 602 | text += strCat + "</i><br>"; |
603 | } | 603 | } |
604 | if (ev.event().type() == Event::Normal ) | 604 | if (ev.event().type() == Event::Normal ) |
605 | setEventText( text ); | 605 | setEventText( text ); |
606 | else | 606 | else |
607 | setAllDayText( text ); | 607 | setAllDayText( text ); |
608 | 608 | ||
609 | text += "<br><br>" + strNote; | 609 | text += "<br><br>" + strNote; |
610 | 610 | ||
611 | setBackgroundMode( PaletteBase ); | 611 | setBackgroundMode( PaletteBase ); |
612 | 612 | ||
613 | QTime start = ev.start(); | 613 | QTime start = ev.start(); |
614 | QTime end = ev.end(); | 614 | QTime end = ev.end(); |
615 | int y = start.hour()*60+start.minute(); | 615 | int y = start.hour()*60+start.minute(); |
616 | int h = end.hour()*60+end.minute()-y; | 616 | int h = end.hour()*60+end.minute()-y; |
617 | int rh = dateBook->dayView()->rowHeight(0); | 617 | int rh = dateBook->dayView()->rowHeight(0); |
618 | y = y*rh/60; | 618 | y = y*rh/60; |
619 | h = h*rh/60; | 619 | h = h*rh/60; |
620 | if ( h < 3 ) { | 620 | if ( h < 3 ) { |
621 | h = 3; | 621 | h = 3; |
622 | } | 622 | } |
623 | geom.setY( y ); | 623 | geom.setY( y ); |
624 | geom.setHeight( h ); | 624 | geom.setHeight( h ); |
625 | geom.setX( 0 ); | 625 | geom.setX( 0 ); |
626 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); | 626 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); |
627 | 627 | ||
628 | } | 628 | } |
629 | void DateBookDayWidget::setAllDayText( QString &text ) { | 629 | void DateBookDayWidget::setAllDayText( QString &text ) { |
630 | text += "<b>" + tr("This is an all day event.") + "</b><br>"; | 630 | text += "<b>" + tr("This is an all day event.") + "</b><br>"; |
631 | } | 631 | } |
632 | void DateBookDayWidget::setEventText( QString& text ) { | 632 | void DateBookDayWidget::setEventText( QString& text ) { |
633 | bool whichClock = dateBook->dayView()->whichClock(); | 633 | bool whichClock = dateBook->dayView()->whichClock(); |
634 | text += "<b>" + tr("Time") + "</b>: "; | 634 | if ( ev.startDate() != ev.endDate() ) { |
635 | if ( ev.startDate() != ev.date() ) { | 635 | text += "<b>" + tr("Start") + "</b>: "; |
636 | // multi-day event. Show start date | 636 | text += TimeString::timeString( ev.event().start().time(), whichClock, FALSE ); |
637 | text += TimeString::longDateString( ev.startDate() ); | 637 | text += " - " + TimeString::longDateString( ev.startDate() ) + "<br>"; |
638 | text += "<b>" + tr("End") + "</b>: "; | ||
639 | text += TimeString::timeString( ev.event().end().time(), whichClock, FALSE ); | ||
640 | text += " - " + TimeString::longDateString( ev.endDate() ) + "<br>"; | ||
638 | } else { | 641 | } else { |
639 | // Show start time. | 642 | text += "<b>" + tr("Time") + "</b>: "; |
640 | text += TimeString::timeString( ev.start(), whichClock, FALSE ); | 643 | text += TimeString::timeString( ev.start(), whichClock, FALSE ); |
641 | } | 644 | text += "<b>" + tr(" - ") + "</b>"; |
642 | |||
643 | text += "<b>" + tr(" - ") + "</b>"; | ||
644 | if ( ev.endDate() != ev.date() ) { | ||
645 | // multi-day event. Show end date | ||
646 | text += TimeString::longDateString( ev.endDate() ); | ||
647 | } else { | ||
648 | // Show end time. | ||
649 | text += TimeString::timeString( ev.end(), whichClock, FALSE ); | 645 | text += TimeString::timeString( ev.end(), whichClock, FALSE ); |
650 | } | 646 | } |
651 | |||
652 | } | 647 | } |
653 | 648 | ||
654 | DateBookDayWidget::~DateBookDayWidget() | 649 | DateBookDayWidget::~DateBookDayWidget() |
655 | { | 650 | { |
656 | } | 651 | } |
657 | 652 | ||
658 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) | 653 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) |
659 | { | 654 | { |
660 | QPainter p( this ); | 655 | QPainter p( this ); |
661 | 656 | ||
662 | if (dateBook->getSelectedWidget() == this) | 657 | if (dateBook->getSelectedWidget() == this) |
663 | { | 658 | { |
664 | p.setBrush( QColor( 155, 240, 230 ) ); // selected item | 659 | p.setBrush( QColor( 155, 240, 230 ) ); // selected item |
665 | } else | 660 | } else |
666 | { | 661 | { |
667 | if (dateBook->date() == QDate::currentDate()) | 662 | if (dateBook->date() == QDate::currentDate()) |
668 | { | 663 | { |
669 | QTime curTime = QTime::currentTime(); | 664 | QTime curTime = QTime::currentTime(); |
670 | 665 | ||
671 | if (ev.end() < curTime) | 666 | if (ev.end() < curTime) |
672 | { | 667 | { |
673 | p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive | 668 | p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive |
674 | } else | 669 | } else |
675 | { | 670 | { |
676 | //change color in dependence of the time till the event starts | 671 | //change color in dependence of the time till the event starts |
677 | int duration = curTime.secsTo(ev.start()); | 672 | int duration = curTime.secsTo(ev.start()); |
678 | if (duration < 0) duration = 0; | 673 | if (duration < 0) duration = 0; |
679 | int colChange = duration*160/86400; //86400: secs per day, 160: max color shift | 674 | int colChange = duration*160/86400; //86400: secs per day, 160: max color shift |
680 | 675 | ||
681 | p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue | 676 | p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue |
682 | } | 677 | } |
683 | } else | 678 | } else |
684 | { | 679 | { |
685 | p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) | 680 | p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) |
686 | //perhaps make a distinction between future/past dates | 681 | //perhaps make a distinction between future/past dates |
687 | } | 682 | } |
688 | } | 683 | } |
689 | 684 | ||
690 | p.setPen( QColor(100, 100, 100) ); | 685 | p.setPen( QColor(100, 100, 100) ); |
691 | p.drawRect(rect()); | 686 | p.drawRect(rect()); |
692 | 687 | ||
693 | // p.drawRect(0,0, 5, height()); | 688 | // p.drawRect(0,0, 5, height()); |
694 | 689 | ||
695 | int y = 0; | 690 | int y = 0; |
696 | int d = 0; | 691 | int d = 0; |
697 | 692 | ||
698 | if ( ev.event().hasAlarm() ) { | 693 | if ( ev.event().hasAlarm() ) { |
699 | p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); | 694 | p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); |
700 | y = 20; | 695 | y = 20; |
701 | d = 20; | 696 | d = 20; |
702 | } | 697 | } |
703 | 698 | ||
704 | if ( ev.event().hasRepeat() ) { | 699 | if ( ev.event().hasRepeat() ) { |
705 | p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); | 700 | p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); |
706 | d = 20; | 701 | d = 20; |
707 | y += 20; | 702 | y += 20; |
708 | } | 703 | } |
709 | 704 | ||
710 | QSimpleRichText rt( text, font() ); | 705 | QSimpleRichText rt( text, font() ); |
711 | rt.setWidth( geom.width() - d - 6 ); | 706 | rt.setWidth( geom.width() - d - 6 ); |
712 | rt.draw( &p, 7, 0, e->region(), colorGroup() ); | 707 | rt.draw( &p, 7, 0, e->region(), colorGroup() ); |
713 | } | 708 | } |
714 | 709 | ||
715 | void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) | 710 | void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) |
716 | { | 711 | { |
717 | DateBookDayWidget *item; | 712 | DateBookDayWidget *item; |
718 | 713 | ||
719 | item = dateBook->getSelectedWidget(); | 714 | item = dateBook->getSelectedWidget(); |
720 | if (item) item->update(); | 715 | if (item) item->update(); |
721 | 716 | ||
722 | dateBook->setSelectedWidget(this); | 717 | dateBook->setSelectedWidget(this); |
723 | update(); | 718 | update(); |
724 | dateBook->repaint(); | 719 | dateBook->repaint(); |
725 | 720 | ||
726 | QPopupMenu m; | 721 | QPopupMenu m; |
727 | m.insertItem( tr( "Edit" ), 1 ); | 722 | m.insertItem( tr( "Edit" ), 1 ); |
728 | m.insertItem( tr( "Delete" ), 2 ); | 723 | m.insertItem( tr( "Delete" ), 2 ); |
729 | if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); | 724 | if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); |
730 | int r = m.exec( e->globalPos() ); | 725 | int r = m.exec( e->globalPos() ); |
731 | if ( r == 1 ) { | 726 | if ( r == 1 ) { |
732 | emit editMe( ev.event() ); | 727 | emit editMe( ev.event() ); |
733 | } else if ( r == 2 ) { | 728 | } else if ( r == 2 ) { |
734 | emit deleteMe( ev.event() ); | 729 | emit deleteMe( ev.event() ); |
735 | } else if ( r == 3 ) { | 730 | } else if ( r == 3 ) { |
736 | emit beamMe( ev.event() ); | 731 | emit beamMe( ev.event() ); |
737 | } | 732 | } |
738 | } | 733 | } |
739 | 734 | ||
740 | void DateBookDayWidget::setGeometry( const QRect &r ) | 735 | void DateBookDayWidget::setGeometry( const QRect &r ) |
741 | { | 736 | { |
742 | geom = r; | 737 | geom = r; |
743 | setFixedSize( r.width()+1, r.height()+1 ); | 738 | setFixedSize( r.width()+1, r.height()+1 ); |
744 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); | 739 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); |
745 | show(); | 740 | show(); |
746 | } | 741 | } |
747 | 742 | ||
748 | 743 | ||
749 | //--------------------------------------------------------------------------------------------- | 744 | //--------------------------------------------------------------------------------------------- |
750 | //--------------------------------------------------------------------------------------------- | 745 | //--------------------------------------------------------------------------------------------- |
751 | 746 | ||
752 | 747 | ||
753 | DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) | 748 | DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) |
754 | : QWidget( db->dayView()->viewport() ), dateBook( db ) | 749 | : QWidget( db->dayView()->viewport() ), dateBook( db ) |
755 | { | 750 | { |
756 | setBackgroundMode( PaletteBase ); | 751 | setBackgroundMode( PaletteBase ); |
757 | } | 752 | } |
758 | 753 | ||
759 | DateBookDayTimeMarker::~DateBookDayTimeMarker() | 754 | DateBookDayTimeMarker::~DateBookDayTimeMarker() |
760 | { | 755 | { |
761 | } | 756 | } |
762 | 757 | ||
763 | void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) | 758 | void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) |
764 | { | 759 | { |
765 | QPainter p( this ); | 760 | QPainter p( this ); |
766 | p.setBrush( QColor( 255, 0, 0 ) ); | 761 | p.setBrush( QColor( 255, 0, 0 ) ); |
767 | 762 | ||
768 | QPen pen; | 763 | QPen pen; |
769 | pen.setStyle(NoPen); | 764 | pen.setStyle(NoPen); |
770 | 765 | ||
771 | p.setPen( pen ); | 766 | p.setPen( pen ); |
772 | p.drawRect(rect()); | 767 | p.drawRect(rect()); |
773 | } | 768 | } |
774 | 769 | ||
775 | void DateBookDayTimeMarker::setTime( const QTime &t ) | 770 | void DateBookDayTimeMarker::setTime( const QTime &t ) |
776 | { | 771 | { |
777 | int y = t.hour()*60+t.minute(); | 772 | int y = t.hour()*60+t.minute(); |
778 | int rh = dateBook->dayView()->rowHeight(0); | 773 | int rh = dateBook->dayView()->rowHeight(0); |
779 | y = y*rh/60; | 774 | y = y*rh/60; |