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