-rw-r--r-- | core/pim/datebook/datebookday.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index 8232a51..0b213e9 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp | |||
@@ -421,195 +421,197 @@ void DateBookDay::relayoutPage( bool fromResize ) | |||
421 | QValueList<int> intersectedWidgets; | 421 | QValueList<int> intersectedWidgets; |
422 | 422 | ||
423 | //find all widgets intersecting with widgetList.at(i) | 423 | //find all widgets intersecting with widgetList.at(i) |
424 | for ( int j = 0; j < wCount; j++) { | 424 | for ( int j = 0; j < wCount; j++) { |
425 | if (i != j) | 425 | if (i != j) |
426 | if (geometries[j].intersects(geometries[i])) | 426 | if (geometries[j].intersects(geometries[i])) |
427 | intersectedWidgets.append(j); | 427 | intersectedWidgets.append(j); |
428 | } | 428 | } |
429 | 429 | ||
430 | //for each of these intersecting widgets find out how many widgets are they intersecting with | 430 | //for each of these intersecting widgets find out how many widgets are they intersecting with |
431 | for ( uint j = 0; j < intersectedWidgets.count(); j++) | 431 | for ( uint j = 0; j < intersectedWidgets.count(); j++) |
432 | { | 432 | { |
433 | QArray<int> inter(wCount); | 433 | QArray<int> inter(wCount); |
434 | inter[j]=1; | 434 | inter[j]=1; |
435 | 435 | ||
436 | if (intersectedWidgets[j] != -1) | 436 | if (intersectedWidgets[j] != -1) |
437 | for ( uint k = j; k < intersectedWidgets.count(); k++) { | 437 | for ( uint k = j; k < intersectedWidgets.count(); k++) { |
438 | if (j != k && intersectedWidgets[k] != -1) | 438 | if (j != k && intersectedWidgets[k] != -1) |
439 | if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { | 439 | if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { |
440 | inter[j]++; | 440 | inter[j]++; |
441 | intersectedWidgets[k] = -1; | 441 | intersectedWidgets[k] = -1; |
442 | } | 442 | } |
443 | if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; | 443 | if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; |
444 | } | 444 | } |
445 | } | 445 | } |
446 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; | 446 | if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; |
447 | } | 447 | } |
448 | 448 | ||
449 | 449 | ||
450 | for ( int i = 0; i < wCount; i++) { | 450 | for ( int i = 0; i < wCount; i++) { |
451 | DateBookDayWidget *w = widgetList.at(i); | 451 | DateBookDayWidget *w = widgetList.at(i); |
452 | QRect geom = w->geometry(); | 452 | QRect geom = w->geometry(); |
453 | geom.setX( 0 ); | 453 | geom.setX( 0 ); |
454 | wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); | 454 | wd = (view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); |
455 | geom.setWidth( wd ); | 455 | geom.setWidth( wd ); |
456 | while ( intersects( w, geom ) ) { | 456 | while ( intersects( w, geom ) ) { |
457 | geom.moveBy( wd + 2 + 1, 0 ); | 457 | geom.moveBy( wd + 2 + 1, 0 ); |
458 | } | 458 | } |
459 | w->setGeometry( geom ); | 459 | w->setGeometry( geom ); |
460 | } | 460 | } |
461 | 461 | ||
462 | if (jumpToCurTime && this->date() == QDate::currentDate()) { | 462 | if (jumpToCurTime && this->date() == QDate::currentDate()) { |
463 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | 463 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour |
464 | } else { | 464 | } else { |
465 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 465 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
466 | } | 466 | } |
467 | } else { | 467 | } else { |
468 | int hours[24]; | 468 | int hours[24]; |
469 | memset( hours, 0, 24*sizeof( int ) ); | 469 | memset( hours, 0, 24*sizeof( int ) ); |
470 | bool overFlow = FALSE; | 470 | bool overFlow = FALSE; |
471 | for ( int i = 0; i < wCount; i++ ) { | 471 | for ( int i = 0; i < wCount; i++ ) { |
472 | DateBookDayWidget *w = widgetList.at(i); | 472 | DateBookDayWidget *w = widgetList.at(i); |
473 | int start = w->event().start().hour(); | 473 | int start = w->event().start().hour(); |
474 | QTime e = w->event().end(); | 474 | QTime e = w->event().end(); |
475 | int end = e.hour(); | 475 | int end = e.hour(); |
476 | if ( e.minute() < 5 ) | 476 | if ( e.minute() < 5 ) |
477 | end--; | 477 | end--; |
478 | if ( end < start ) | 478 | if ( end < start ) |
479 | end = start; | 479 | end = start; |
480 | while( start <= end ) { | 480 | while( start <= end ) { |
481 | hours[start]++; | 481 | hours[start]++; |
482 | if ( hours[start] >= 10 ) | 482 | if ( hours[start] >= 10 ) |
483 | overFlow = TRUE; | 483 | overFlow = TRUE; |
484 | ++start; | 484 | ++start; |
485 | } | 485 | } |
486 | if ( overFlow ) | 486 | if ( overFlow ) |
487 | break; | 487 | break; |
488 | } | 488 | } |
489 | for ( int i = 0; i < 24; i++ ) { | 489 | for ( int i = 0; i < 24; i++ ) { |
490 | n = QMAX( n, hours[i] ); | 490 | n = QMAX( n, hours[i] ); |
491 | } | 491 | } |
492 | wid = ( view->columnWidth(0)-1 ) / n; | 492 | wid = ( view->columnWidth(0)-1 ) / n; |
493 | 493 | ||
494 | bool used[24*10]; | 494 | bool used[24*10]; |
495 | memset( used, FALSE, 24*10*sizeof( bool ) ); | 495 | memset( used, FALSE, 24*10*sizeof( bool ) ); |
496 | 496 | ||
497 | for ( int i = 0; i < wCount; i++ ) { | 497 | for ( int i = 0; i < wCount; i++ ) { |
498 | DateBookDayWidget *w = widgetList.at(i); | 498 | DateBookDayWidget *w = widgetList.at(i); |
499 | int xp = place( w, used, n ); | 499 | int xp = place( w, used, n ); |
500 | if ( xp != -1 ) { | 500 | if ( xp != -1 ) { |
501 | QRect geom = w->geometry(); | 501 | QRect geom = w->geometry(); |
502 | geom.setX( xp*(wid+2) ); | 502 | geom.setX( xp*(wid+2) ); |
503 | geom.setWidth( wid ); | 503 | geom.setWidth( wid ); |
504 | w->setGeometry( geom ); | 504 | w->setGeometry( geom ); |
505 | } | 505 | } |
506 | } | 506 | } |
507 | 507 | ||
508 | if (jumpToCurTime && this->date() == QDate::currentDate()) { | 508 | if (jumpToCurTime && this->date() == QDate::currentDate()) { |
509 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour | 509 | view->setContentsPos( 0, QTime::currentTime().hour() * view->rowHeight(0) ); //set listview to current hour |
510 | } else { | 510 | } else { |
511 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); | 511 | view->setContentsPos( 0, startTime * view->rowHeight(0) ); |
512 | } | 512 | } |
513 | } | 513 | } |
514 | 514 | ||
515 | timeMarker->setTime( QTime::currentTime() );//display timeMarker | 515 | timeMarker->setTime( QTime::currentTime() );//display timeMarker |
516 | timeMarker->raise(); //on top of all widgets | 516 | timeMarker->raise(); //on top of all widgets |
517 | if (this->date() == QDate::currentDate()) //only show timeMarker on current day | 517 | if (this->date() == QDate::currentDate()) { //only show timeMarker on current day |
518 | timeMarker->show(); else timeMarker->hide(); | 518 | timeMarker->show(); |
519 | 519 | } else { | |
520 | timeMarker->hide(); | ||
521 | } | ||
520 | setUpdatesEnabled( TRUE ); | 522 | setUpdatesEnabled( TRUE ); |
521 | return; | 523 | return; |
522 | } | 524 | } |
523 | 525 | ||
524 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) | 526 | DateBookDayWidget *DateBookDay::intersects( const DateBookDayWidget *item, const QRect &geom ) |
525 | { | 527 | { |
526 | int i = 0; | 528 | int i = 0; |
527 | DateBookDayWidget *w = widgetList.at(i); | 529 | DateBookDayWidget *w = widgetList.at(i); |
528 | int wCount = widgetList.count(); | 530 | int wCount = widgetList.count(); |
529 | while ( i < wCount && w != item ) { | 531 | while ( i < wCount && w != item ) { |
530 | if ( w->geometry().intersects( geom ) ) { | 532 | if ( w->geometry().intersects( geom ) ) { |
531 | return w; | 533 | return w; |
532 | } | 534 | } |
533 | w = widgetList.at(++i); | 535 | w = widgetList.at(++i); |
534 | } | 536 | } |
535 | 537 | ||
536 | return 0; | 538 | return 0; |
537 | } | 539 | } |
538 | 540 | ||
539 | 541 | ||
540 | QDate DateBookDay::date() const | 542 | QDate DateBookDay::date() const |
541 | { | 543 | { |
542 | return currDate; | 544 | return currDate; |
543 | } | 545 | } |
544 | 546 | ||
545 | void DateBookDay::setStartViewTime( int startHere ) | 547 | void DateBookDay::setStartViewTime( int startHere ) |
546 | { | 548 | { |
547 | startTime = startHere; | 549 | startTime = startHere; |
548 | dayView()->clearSelection(); | 550 | dayView()->clearSelection(); |
549 | QTableSelection ts; | 551 | QTableSelection ts; |
550 | 552 | ||
551 | if (jumpToCurTime && this->date() == QDate::currentDate()) {//this should probably be in datebook.cpp where it's called? | 553 | if (jumpToCurTime && this->date() == QDate::currentDate()) {//this should probably be in datebook.cpp where it's called? |
552 | ts.init( QTime::currentTime().hour(), 0); | 554 | ts.init( QTime::currentTime().hour(), 0); |
553 | ts.expandTo( QTime::currentTime().hour(), 0); | 555 | ts.expandTo( QTime::currentTime().hour(), 0); |
554 | } else { | 556 | } else { |
555 | ts.init( startTime, 0 ); | 557 | ts.init( startTime, 0 ); |
556 | ts.expandTo( startTime, 0 ); | 558 | ts.expandTo( startTime, 0 ); |
557 | } | 559 | } |
558 | 560 | ||
559 | dayView()->addSelection( ts ); | 561 | dayView()->addSelection( ts ); |
560 | } | 562 | } |
561 | 563 | ||
562 | int DateBookDay::startViewTime() const | 564 | int DateBookDay::startViewTime() const |
563 | { | 565 | { |
564 | return startTime; | 566 | return startTime; |
565 | } | 567 | } |
566 | 568 | ||
567 | void DateBookDay::slotWeekChanged( bool bStartOnMonday ) | 569 | void DateBookDay::slotWeekChanged( bool bStartOnMonday ) |
568 | { | 570 | { |
569 | header->setStartOfWeek( bStartOnMonday ); | 571 | header->setStartOfWeek( bStartOnMonday ); |
570 | //redraw(); | 572 | //redraw(); |
571 | } | 573 | } |
572 | 574 | ||
573 | void DateBookDay::keyPressEvent(QKeyEvent *e) | 575 | void DateBookDay::keyPressEvent(QKeyEvent *e) |
574 | { | 576 | { |
575 | switch(e->key()) { | 577 | switch(e->key()) { |
576 | case Key_Up: | 578 | case Key_Up: |
577 | view->moveUp(); | 579 | view->moveUp(); |
578 | break; | 580 | break; |
579 | case Key_Down: | 581 | case Key_Down: |
580 | view->moveDown(); | 582 | view->moveDown(); |
581 | break; | 583 | break; |
582 | case Key_Left: | 584 | case Key_Left: |
583 | setDate(QDate(currDate).addDays(-1)); | 585 | setDate(QDate(currDate).addDays(-1)); |
584 | break; | 586 | break; |
585 | case Key_Right: | 587 | case Key_Right: |
586 | setDate(QDate(currDate).addDays(1)); | 588 | setDate(QDate(currDate).addDays(1)); |
587 | break; | 589 | break; |
588 | default: | 590 | default: |
589 | e->ignore(); | 591 | e->ignore(); |
590 | } | 592 | } |
591 | } | 593 | } |
592 | 594 | ||
593 | //=========================================================================== | 595 | //=========================================================================== |
594 | 596 | ||
595 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ) | 597 | DateBookDayWidget::DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db ) |
596 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) | 598 | : QWidget( db->dayView()->viewport() ), ev( e ), dateBook( db ) |
597 | { | 599 | { |
598 | // why would someone use "<"? Oh well, fix it up... | 600 | // why would someone use "<"? Oh well, fix it up... |
599 | // I wonder what other things may be messed up... | 601 | // I wonder what other things may be messed up... |
600 | QString strDesc = ev.description(); | 602 | QString strDesc = ev.description(); |
601 | int where = strDesc.find( "<" ); | 603 | int where = strDesc.find( "<" ); |
602 | while ( where != -1 ) { | 604 | while ( where != -1 ) { |
603 | strDesc.remove( where, 1 ); | 605 | strDesc.remove( where, 1 ); |
604 | strDesc.insert( where, "<" ); | 606 | strDesc.insert( where, "<" ); |
605 | where = strDesc.find( "<", where ); | 607 | where = strDesc.find( "<", where ); |
606 | } | 608 | } |
607 | 609 | ||
608 | QString strCat; | 610 | QString strCat; |
609 | // ### Fix later... | 611 | // ### Fix later... |
610 | // QString strCat = ev.category(); | 612 | // QString strCat = ev.category(); |
611 | // where = strCat.find( "<" ); | 613 | // where = strCat.find( "<" ); |
612 | // while ( where != -1 ) { | 614 | // while ( where != -1 ) { |
613 | // strCat.remove( where, 1 ); | 615 | // strCat.remove( where, 1 ); |
614 | // strCat.insert( where, "<" ); | 616 | // strCat.insert( where, "<" ); |
615 | // where = strCat.find( "<", where ); | 617 | // where = strCat.find( "<", where ); |