author | harlekin <harlekin> | 2003-02-14 21:52:13 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-02-14 21:52:13 (UTC) |
commit | 643c8058bbd67a8fedfd98cb895419cadde04e78 (patch) (unidiff) | |
tree | 3ce591efee390539d170fd98affb8333d62eb0d8 | |
parent | fc117979a54fca11e591395b130cfef307deb66f (diff) | |
download | opie-643c8058bbd67a8fedfd98cb895419cadde04e78.zip opie-643c8058bbd67a8fedfd98cb895419cadde04e78.tar.gz opie-643c8058bbd67a8fedfd98cb895419cadde04e78.tar.bz2 |
save some space in dayview, for further answers read bug #665
-rw-r--r-- | core/pim/datebook/datebookday.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index 325b902..aaf3e16 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp | |||
@@ -408,390 +408,393 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
408 | 408 | ||
409 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; | 409 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; |
410 | } | 410 | } |
411 | 411 | ||
412 | 412 | ||
413 | for ( int i = 0; i < wCount; i++) { | 413 | for ( int i = 0; i < wCount; i++) { |
414 | DateBookDayWidget *w = widgetList.at(i); | 414 | DateBookDayWidget *w = widgetList.at(i); |
415 | QRect geom = w->geometry(); | 415 | QRect geom = w->geometry(); |
416 | 416 | ||
417 | geom.setX( 0 ); | 417 | geom.setX( 0 ); |
418 | 418 | ||
419 | wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); | 419 | wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); |
420 | 420 | ||
421 | geom.setWidth( wd ); | 421 | geom.setWidth( wd ); |
422 | 422 | ||
423 | while ( intersects( w, geom ) ) { | 423 | while ( intersects( w, geom ) ) { |
424 | geom.moveBy( wd + 2 + 1, 0 ); | 424 | geom.moveBy( wd + 2 + 1, 0 ); |
425 | } | 425 | } |
426 | w->setGeometry( geom ); | 426 | w->setGeometry( geom ); |
427 | } | 427 | } |
428 | 428 | ||
429 | if (jumpToCurTime && this->date() == QDate::currentDate()) | 429 | if (jumpToCurTime && this->date() == QDate::currentDate()) |
430 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | 430 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour |
431 | else | 431 | else |
432 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 432 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
433 | 433 | ||
434 | 434 | ||
435 | } else { | 435 | } else { |
436 | 436 | ||
437 | 437 | ||
438 | int hours[24]; | 438 | int hours[24]; |
439 | memset( hours, 0, 24*sizeof( int ) ); | 439 | memset( hours, 0, 24*sizeof( int ) ); |
440 | bool overFlow = FALSE; | 440 | bool overFlow = FALSE; |
441 | for ( int i = 0; i < wCount; i++ ) { | 441 | for ( int i = 0; i < wCount; i++ ) { |
442 | DateBookDayWidget *w = widgetList.at(i); | 442 | DateBookDayWidget *w = widgetList.at(i); |
443 | int start = w->event().start().hour(); | 443 | int start = w->event().start().hour(); |
444 | QTime e = w->event().end(); | 444 | QTime e = w->event().end(); |
445 | int end = e.hour(); | 445 | int end = e.hour(); |
446 | if ( e.minute() < 5 ) | 446 | if ( e.minute() < 5 ) |
447 | end--; | 447 | end--; |
448 | if ( end < start ) | 448 | if ( end < start ) |
449 | end = start; | 449 | end = start; |
450 | while( start <= end ) { | 450 | while( start <= end ) { |
451 | hours[start]++; | 451 | hours[start]++; |
452 | if ( hours[start] >= 10 ) | 452 | if ( hours[start] >= 10 ) |
453 | overFlow = TRUE; | 453 | overFlow = TRUE; |
454 | ++start; | 454 | ++start; |
455 | } | 455 | } |
456 | if ( overFlow ) | 456 | if ( overFlow ) |
457 | break; | 457 | break; |
458 | } | 458 | } |
459 | for ( int i = 0; i < 24; i++ ) { | 459 | for ( int i = 0; i < 24; i++ ) { |
460 | n = QMAX( n, hours[i] ); | 460 | n = QMAX( n, hours[i] ); |
461 | } | 461 | } |
462 | wid = ( view->columnWidth(0)-1 ) / n; | 462 | wid = ( view->columnWidth(0)-1 ) / n; |
463 | 463 | ||
464 | bool used[24*10]; | 464 | bool used[24*10]; |
465 | memset( used, FALSE, 24*10*sizeof( bool ) ); | 465 | memset( used, FALSE, 24*10*sizeof( bool ) ); |
466 | 466 | ||
467 | for ( int i = 0; i < wCount; i++ ) { | 467 | for ( int i = 0; i < wCount; i++ ) { |
468 | DateBookDayWidget *w = widgetList.at(i); | 468 | DateBookDayWidget *w = widgetList.at(i); |
469 | int xp = place( w, used, n ); | 469 | int xp = place( w, used, n ); |
470 | if ( xp != -1 ) { | 470 | if ( xp != -1 ) { |
471 | QRect geom = w->geometry(); | 471 | QRect geom = w->geometry(); |
472 | geom.setX( xp*(wid+2) ); | 472 | geom.setX( xp*(wid+2) ); |
473 | geom.setWidth( wid ); | 473 | geom.setWidth( wid ); |
474 | w->setGeometry( geom ); | 474 | w->setGeometry( geom ); |
475 | } | 475 | } |
476 | } | 476 | } |
477 | 477 | ||
478 | if (jumpToCurTime && this->date() == QDate::currentDate()) | 478 | if (jumpToCurTime && this->date() == QDate::currentDate()) |
479 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | 479 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour |
480 | else | 480 | else |
481 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 481 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
482 | } | 482 | } |
483 | 483 | ||
484 | timeMarker->setTime( QTime::currentTime() );//display timeMarker | 484 | timeMarker->setTime( QTime::currentTime() );//display timeMarker |
485 | timeMarker->raise(); //on top of all widgets | 485 | timeMarker->raise(); //on top of all widgets |
486 | if (this->date() == QDate::currentDate()) //only show timeMarker on current day | 486 | if (this->date() == QDate::currentDate()) //only show timeMarker on current day |
487 | timeMarker->show(); else timeMarker->hide(); | 487 | timeMarker->show(); else timeMarker->hide(); |
488 | 488 | ||
489 | setUpdatesEnabled( TRUE ); | 489 | setUpdatesEnabled( TRUE ); |
490 | return; | 490 | return; |
491 | } | 491 | } |
492 | 492 | ||
493 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) | 493 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) |
494 | { | 494 | { |
495 | int i = 0; | 495 | int i = 0; |
496 | DateBookDayWidget *w = widgetList.at(i); | 496 | DateBookDayWidget *w = widgetList.at(i); |
497 | int wCount = widgetList.count(); | 497 | int wCount = widgetList.count(); |
498 | while ( i < wCount && w != item ) { | 498 | while ( i < wCount && w != item ) { |
499 | if ( w->geometry().intersects( geom ) ) { | 499 | if ( w->geometry().intersects( geom ) ) { |
500 | return w; | 500 | return w; |
501 | } | 501 | } |
502 | w = widgetList.at(++i); | 502 | w = widgetList.at(++i); |
503 | } | 503 | } |
504 | 504 | ||
505 | return 0; | 505 | return 0; |
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 | + strCat + "</i><br>"; | 601 | if ( !strCat.isEmpty() ) { |
602 | text += strCat + "</i><br>"; | ||
603 | } | ||
602 | if (ev.event().type() == Event::Normal ) | 604 | if (ev.event().type() == Event::Normal ) |
603 | setEventText( text ); | 605 | setEventText( text ); |
604 | else | 606 | else |
605 | setAllDayText( text ); | 607 | setAllDayText( text ); |
606 | 608 | ||
607 | text += "<br><br>" + strNote; | 609 | text += "<br><br>" + strNote; |
608 | 610 | ||
609 | setBackgroundMode( PaletteBase ); | 611 | setBackgroundMode( PaletteBase ); |
610 | 612 | ||
611 | QTime start = ev.start(); | 613 | QTime start = ev.start(); |
612 | QTime end = ev.end(); | 614 | QTime end = ev.end(); |
613 | int y = start.hour()*60+start.minute(); | 615 | int y = start.hour()*60+start.minute(); |
614 | int h = end.hour()*60+end.minute()-y; | 616 | int h = end.hour()*60+end.minute()-y; |
615 | int rh = dateBook->dayView()->rowHeight(0); | 617 | int rh = dateBook->dayView()->rowHeight(0); |
616 | y = y*rh/60; | 618 | y = y*rh/60; |
617 | h = h*rh/60; | 619 | h = h*rh/60; |
618 | if ( h < 3 ) | 620 | if ( h < 3 ) { |
619 | h = 3; | 621 | h = 3; |
622 | } | ||
620 | geom.setY( y ); | 623 | geom.setY( y ); |
621 | geom.setHeight( h ); | 624 | geom.setHeight( h ); |
622 | geom.setX( 0 ); | 625 | geom.setX( 0 ); |
623 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); | 626 | geom.setWidth(dateBook->dayView()->columnWidth(0)-1); |
624 | 627 | ||
625 | } | 628 | } |
626 | void DateBookDayWidget::setAllDayText( QString &text ) { | 629 | void DateBookDayWidget::setAllDayText( QString &text ) { |
627 | text += "<b>" + tr("This is an all day event.") + "</b><br>"; | 630 | text += "<b>" + tr("This is an all day event.") + "</b><br>"; |
628 | } | 631 | } |
629 | void DateBookDayWidget::setEventText( QString& text ) { | 632 | void DateBookDayWidget::setEventText( QString& text ) { |
630 | bool whichClock = dateBook->dayView()->whichClock(); | 633 | bool whichClock = dateBook->dayView()->whichClock(); |
631 | text += "<b>" + tr("Start") + "</b>: "; | 634 | text += "<b>" + tr("Time") + "</b>: "; |
632 | if ( ev.startDate() != ev.date() ) { | 635 | if ( ev.startDate() != ev.date() ) { |
633 | // multi-day event. Show start date | 636 | // multi-day event. Show start date |
634 | text += TimeString::longDateString( ev.startDate() ); | 637 | text += TimeString::longDateString( ev.startDate() ); |
635 | } else { | 638 | } else { |
636 | // Show start time. | 639 | // Show start time. |
637 | text += TimeString::timeString( ev.start(), whichClock, FALSE ); | 640 | text += TimeString::timeString( ev.start(), whichClock, FALSE ); |
638 | } | 641 | } |
639 | 642 | ||
640 | text += "<br><b>" + tr("End") + "</b>: "; | 643 | text += "<b>" + tr(" - ") + "</b>"; |
641 | if ( ev.endDate() != ev.date() ) { | 644 | if ( ev.endDate() != ev.date() ) { |
642 | // multi-day event. Show end date | 645 | // multi-day event. Show end date |
643 | text += TimeString::longDateString( ev.endDate() ); | 646 | text += TimeString::longDateString( ev.endDate() ); |
644 | } else { | 647 | } else { |
645 | // Show end time. | 648 | // Show end time. |
646 | text += TimeString::timeString( ev.end(), whichClock, FALSE ); | 649 | text += TimeString::timeString( ev.end(), whichClock, FALSE ); |
647 | } | 650 | } |
648 | 651 | ||
649 | } | 652 | } |
650 | 653 | ||
651 | DateBookDayWidget::~DateBookDayWidget() | 654 | DateBookDayWidget::~DateBookDayWidget() |
652 | { | 655 | { |
653 | } | 656 | } |
654 | 657 | ||
655 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) | 658 | void DateBookDayWidget::paintEvent( QPaintEvent *e ) |
656 | { | 659 | { |
657 | QPainter p( this ); | 660 | QPainter p( this ); |
658 | 661 | ||
659 | if (dateBook->getSelectedWidget() == this) | 662 | if (dateBook->getSelectedWidget() == this) |
660 | { | 663 | { |
661 | p.setBrush( QColor( 155, 240, 230 ) ); // selected item | 664 | p.setBrush( QColor( 155, 240, 230 ) ); // selected item |
662 | } else | 665 | } else |
663 | { | 666 | { |
664 | if (dateBook->date() == QDate::currentDate()) | 667 | if (dateBook->date() == QDate::currentDate()) |
665 | { | 668 | { |
666 | QTime curTime = QTime::currentTime(); | 669 | QTime curTime = QTime::currentTime(); |
667 | 670 | ||
668 | if (ev.end() < curTime) | 671 | if (ev.end() < curTime) |
669 | { | 672 | { |
670 | p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive | 673 | p.setBrush( QColor( 180, 180, 180 ) ); // grey, inactive |
671 | } else | 674 | } else |
672 | { | 675 | { |
673 | //change color in dependence of the time till the event starts | 676 | //change color in dependence of the time till the event starts |
674 | int duration = curTime.secsTo(ev.start()); | 677 | int duration = curTime.secsTo(ev.start()); |
675 | if (duration < 0) duration = 0; | 678 | if (duration < 0) duration = 0; |
676 | int colChange = duration*160/86400; //86400: secs per day, 160: max color shift | 679 | int colChange = duration*160/86400; //86400: secs per day, 160: max color shift |
677 | 680 | ||
678 | p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue | 681 | p.setBrush( QColor( 200-colChange, 200-colChange, 255 ) ); //blue |
679 | } | 682 | } |
680 | } else | 683 | } else |
681 | { | 684 | { |
682 | p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) | 685 | p.setBrush( QColor( 220, 220, 220 ) ); //light grey, inactive (not current date) |
683 | //perhaps make a distinction between future/past dates | 686 | //perhaps make a distinction between future/past dates |
684 | } | 687 | } |
685 | } | 688 | } |
686 | 689 | ||
687 | p.setPen( QColor(100, 100, 100) ); | 690 | p.setPen( QColor(100, 100, 100) ); |
688 | p.drawRect(rect()); | 691 | p.drawRect(rect()); |
689 | 692 | ||
690 | // p.drawRect(0,0, 5, height()); | 693 | // p.drawRect(0,0, 5, height()); |
691 | 694 | ||
692 | int y = 0; | 695 | int y = 0; |
693 | int d = 0; | 696 | int d = 0; |
694 | 697 | ||
695 | if ( ev.event().hasAlarm() ) { | 698 | if ( ev.event().hasAlarm() ) { |
696 | p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); | 699 | p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) ); |
697 | y = 20; | 700 | y = 20; |
698 | d = 20; | 701 | d = 20; |
699 | } | 702 | } |
700 | 703 | ||
701 | if ( ev.event().hasRepeat() ) { | 704 | if ( ev.event().hasRepeat() ) { |
702 | p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); | 705 | p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) ); |
703 | d = 20; | 706 | d = 20; |
704 | y += 20; | 707 | y += 20; |
705 | } | 708 | } |
706 | 709 | ||
707 | QSimpleRichText rt( text, font() ); | 710 | QSimpleRichText rt( text, font() ); |
708 | rt.setWidth( geom.width() - d - 6 ); | 711 | rt.setWidth( geom.width() - d - 6 ); |
709 | rt.draw( &p, 7, 0, e->region(), colorGroup() ); | 712 | rt.draw( &p, 7, 0, e->region(), colorGroup() ); |
710 | } | 713 | } |
711 | 714 | ||
712 | void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) | 715 | void DateBookDayWidget::mousePressEvent( QMouseEvent *e ) |
713 | { | 716 | { |
714 | DateBookDayWidget *item; | 717 | DateBookDayWidget *item; |
715 | 718 | ||
716 | item = dateBook->getSelectedWidget(); | 719 | item = dateBook->getSelectedWidget(); |
717 | if (item) item->update(); | 720 | if (item) item->update(); |
718 | 721 | ||
719 | dateBook->setSelectedWidget(this); | 722 | dateBook->setSelectedWidget(this); |
720 | update(); | 723 | update(); |
721 | dateBook->repaint(); | 724 | dateBook->repaint(); |
722 | 725 | ||
723 | QPopupMenu m; | 726 | QPopupMenu m; |
724 | m.insertItem( tr( "Edit" ), 1 ); | 727 | m.insertItem( tr( "Edit" ), 1 ); |
725 | m.insertItem( tr( "Delete" ), 2 ); | 728 | m.insertItem( tr( "Delete" ), 2 ); |
726 | if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); | 729 | if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 ); |
727 | int r = m.exec( e->globalPos() ); | 730 | int r = m.exec( e->globalPos() ); |
728 | if ( r == 1 ) { | 731 | if ( r == 1 ) { |
729 | emit editMe( ev.event() ); | 732 | emit editMe( ev.event() ); |
730 | } else if ( r == 2 ) { | 733 | } else if ( r == 2 ) { |
731 | emit deleteMe( ev.event() ); | 734 | emit deleteMe( ev.event() ); |
732 | } else if ( r == 3 ) { | 735 | } else if ( r == 3 ) { |
733 | emit beamMe( ev.event() ); | 736 | emit beamMe( ev.event() ); |
734 | } | 737 | } |
735 | } | 738 | } |
736 | 739 | ||
737 | void DateBookDayWidget::setGeometry( const QRect &r ) | 740 | void DateBookDayWidget::setGeometry( const QRect &r ) |
738 | { | 741 | { |
739 | geom = r; | 742 | geom = r; |
740 | setFixedSize( r.width()+1, r.height()+1 ); | 743 | setFixedSize( r.width()+1, r.height()+1 ); |
741 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); | 744 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); |
742 | show(); | 745 | show(); |
743 | } | 746 | } |
744 | 747 | ||
745 | 748 | ||
746 | //--------------------------------------------------------------------------------------------- | 749 | //--------------------------------------------------------------------------------------------- |
747 | //--------------------------------------------------------------------------------------------- | 750 | //--------------------------------------------------------------------------------------------- |
748 | 751 | ||
749 | 752 | ||
750 | DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) | 753 | DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db ) |
751 | : QWidget( db->dayView()->viewport() ), dateBook( db ) | 754 | : QWidget( db->dayView()->viewport() ), dateBook( db ) |
752 | { | 755 | { |
753 | setBackgroundMode( PaletteBase ); | 756 | setBackgroundMode( PaletteBase ); |
754 | } | 757 | } |
755 | 758 | ||
756 | DateBookDayTimeMarker::~DateBookDayTimeMarker() | 759 | DateBookDayTimeMarker::~DateBookDayTimeMarker() |
757 | { | 760 | { |
758 | } | 761 | } |
759 | 762 | ||
760 | void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) | 763 | void DateBookDayTimeMarker::paintEvent( QPaintEvent */*e*/ ) |
761 | { | 764 | { |
762 | QPainter p( this ); | 765 | QPainter p( this ); |
763 | p.setBrush( QColor( 255, 0, 0 ) ); | 766 | p.setBrush( QColor( 255, 0, 0 ) ); |
764 | 767 | ||
765 | QPen pen; | 768 | QPen pen; |
766 | pen.setStyle(NoPen); | 769 | pen.setStyle(NoPen); |
767 | 770 | ||
768 | p.setPen( pen ); | 771 | p.setPen( pen ); |
769 | p.drawRect(rect()); | 772 | p.drawRect(rect()); |
770 | } | 773 | } |
771 | 774 | ||
772 | void DateBookDayTimeMarker::setTime( const QTime &t ) | 775 | void DateBookDayTimeMarker::setTime( const QTime &t ) |
773 | { | 776 | { |
774 | int y = t.hour()*60+t.minute(); | 777 | int y = t.hour()*60+t.minute(); |
775 | int rh = dateBook->dayView()->rowHeight(0); | 778 | int rh = dateBook->dayView()->rowHeight(0); |
776 | y = y*rh/60; | 779 | y = y*rh/60; |
777 | 780 | ||
778 | geom.setX( 0 ); | 781 | geom.setX( 0 ); |
779 | 782 | ||
780 | int x = dateBook->dayView()->columnWidth(0)-1; | 783 | int x = dateBook->dayView()->columnWidth(0)-1; |
781 | geom.setWidth( x ); | 784 | geom.setWidth( x ); |
782 | 785 | ||
783 | geom.setY( y ); | 786 | geom.setY( y ); |
784 | geom.setHeight( 1 ); | 787 | geom.setHeight( 1 ); |
785 | 788 | ||
786 | setGeometry( geom ); | 789 | setGeometry( geom ); |
787 | 790 | ||
788 | time = t; | 791 | time = t; |
789 | } | 792 | } |
790 | 793 | ||
791 | void DateBookDayTimeMarker::setGeometry( const QRect &r ) | 794 | void DateBookDayTimeMarker::setGeometry( const QRect &r ) |
792 | { | 795 | { |
793 | geom = r; | 796 | geom = r; |
794 | setFixedSize( r.width()+1, r.height()+1 ); | 797 | setFixedSize( r.width()+1, r.height()+1 ); |
795 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); | 798 | dateBook->dayView()->moveChild( this, r.x(), r.y()-1 ); |
796 | show(); | 799 | show(); |
797 | } | 800 | } |