author | zautrix <zautrix> | 2005-03-20 16:15:56 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-20 16:15:56 (UTC) |
commit | a9e08041c8978d52cfcabc84f579784af45eb8d9 (patch) (unidiff) | |
tree | 6448348326db4325938679350c58d87176d90771 | |
parent | 69d75020eea5f95b9f5d77d97ed85ec8869d32db (diff) | |
download | kdepimpi-a9e08041c8978d52cfcabc84f579784af45eb8d9.zip kdepimpi-a9e08041c8978d52cfcabc84f579784af45eb8d9.tar.gz kdepimpi-a9e08041c8978d52cfcabc84f579784af45eb8d9.tar.bz2 |
layout fix
-rw-r--r-- | korganizer/kodaymatrix.cpp | 121 | ||||
-rw-r--r-- | korganizer/kodaymatrix.h | 2 |
2 files changed, 92 insertions, 31 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 9181936..15a1cb4 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -430,380 +430,441 @@ const QDate& KODayMatrix::getDate(int offset) | |||
430 | return days[0]; | 430 | return days[0]; |
431 | } | 431 | } |
432 | return days[offset]; | 432 | return days[offset]; |
433 | } | 433 | } |
434 | 434 | ||
435 | QString KODayMatrix::getHolidayLabel(int offset) | 435 | QString KODayMatrix::getHolidayLabel(int offset) |
436 | { | 436 | { |
437 | if (offset < 0 || offset > NUMDAYS-1) { | 437 | if (offset < 0 || offset > NUMDAYS-1) { |
438 | qDebug("Wrong offset1 "); | 438 | qDebug("Wrong offset1 "); |
439 | return 0; | 439 | return 0; |
440 | } | 440 | } |
441 | return mHolidays[offset]; | 441 | return mHolidays[offset]; |
442 | } | 442 | } |
443 | 443 | ||
444 | int KODayMatrix::getDayIndexFrom(int x, int y) | 444 | int KODayMatrix::getDayIndexFrom(int x, int y) |
445 | { | 445 | { |
446 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 446 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
447 | 6 - x/daysize.width() : x/daysize.width()); | 447 | 6 - x/daysize.width() : x/daysize.width()); |
448 | } | 448 | } |
449 | 449 | ||
450 | // ---------------------------------------------------------------------------- | 450 | // ---------------------------------------------------------------------------- |
451 | // M O U S E E V E N T H A N D L I N G | 451 | // M O U S E E V E N T H A N D L I N G |
452 | // ---------------------------------------------------------------------------- | 452 | // ---------------------------------------------------------------------------- |
453 | 453 | ||
454 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 454 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
455 | { | 455 | { |
456 | 456 | ||
457 | if ( e->button() == LeftButton ) | 457 | if ( e->button() == LeftButton ) |
458 | mouseDown = true; | 458 | mouseDown = true; |
459 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 459 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
460 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 460 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
461 | mSelInit = mSelStart; | 461 | mSelInit = mSelStart; |
462 | } | 462 | } |
463 | 463 | ||
464 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 464 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
465 | { | 465 | { |
466 | if ( e->button() == LeftButton ) | 466 | if ( e->button() == LeftButton ) |
467 | if ( ! mouseDown ) { | 467 | if ( ! mouseDown ) { |
468 | return; | 468 | return; |
469 | } | 469 | } |
470 | else | 470 | else |
471 | mouseDown = false; | 471 | mouseDown = false; |
472 | int tmp = getDayIndexFrom(e->x(), e->y()); | 472 | int tmp = getDayIndexFrom(e->x(), e->y()); |
473 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 473 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
474 | 474 | ||
475 | if (mSelInit > tmp) { | 475 | if (mSelInit > tmp) { |
476 | mSelEnd = mSelInit; | 476 | mSelEnd = mSelInit; |
477 | if (tmp != mSelStart) { | 477 | if (tmp != mSelStart) { |
478 | mSelStart = tmp; | 478 | mSelStart = tmp; |
479 | repaint(false); | 479 | repaint(false); |
480 | } | 480 | } |
481 | } else { | 481 | } else { |
482 | mSelStart = mSelInit; | 482 | mSelStart = mSelInit; |
483 | 483 | ||
484 | //repaint only if selection has changed | 484 | //repaint only if selection has changed |
485 | if (tmp != mSelEnd) { | 485 | if (tmp != mSelEnd) { |
486 | mSelEnd = tmp; | 486 | mSelEnd = tmp; |
487 | repaint(false); | 487 | repaint(false); |
488 | } | 488 | } |
489 | } | 489 | } |
490 | 490 | ||
491 | DateList daylist; | 491 | DateList daylist; |
492 | if ( mSelStart < 0 ) | 492 | if ( mSelStart < 0 ) |
493 | mSelStart = 0; | 493 | mSelStart = 0; |
494 | for (int i = mSelStart; i <= mSelEnd; i++) { | 494 | for (int i = mSelStart; i <= mSelEnd; i++) { |
495 | daylist.append(days[i]); | 495 | daylist.append(days[i]); |
496 | } | 496 | } |
497 | emit selected((const DateList)daylist); | 497 | emit selected((const DateList)daylist); |
498 | 498 | ||
499 | } | 499 | } |
500 | 500 | ||
501 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 501 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
502 | { | 502 | { |
503 | if ( ! mouseDown ) { | 503 | if ( ! mouseDown ) { |
504 | return; | 504 | return; |
505 | } | 505 | } |
506 | int tmp = getDayIndexFrom(e->x(), e->y()); | 506 | int tmp = getDayIndexFrom(e->x(), e->y()); |
507 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 507 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
508 | 508 | ||
509 | if (mSelInit > tmp) { | 509 | if (mSelInit > tmp) { |
510 | mSelEnd = mSelInit; | 510 | mSelEnd = mSelInit; |
511 | if (tmp != mSelStart) { | 511 | if (tmp != mSelStart) { |
512 | mSelStart = tmp; | 512 | mSelStart = tmp; |
513 | repaint(false); | 513 | repaint(false); |
514 | } | 514 | } |
515 | } else { | 515 | } else { |
516 | mSelStart = mSelInit; | 516 | mSelStart = mSelInit; |
517 | 517 | ||
518 | //repaint only if selection has changed | 518 | //repaint only if selection has changed |
519 | if (tmp != mSelEnd) { | 519 | if (tmp != mSelEnd) { |
520 | mSelEnd = tmp; | 520 | mSelEnd = tmp; |
521 | repaint(false); | 521 | repaint(false); |
522 | } | 522 | } |
523 | } | 523 | } |
524 | } | 524 | } |
525 | 525 | ||
526 | // ---------------------------------------------------------------------------- | 526 | // ---------------------------------------------------------------------------- |
527 | // D R A G ' N D R O P H A N D L I N G | 527 | // D R A G ' N D R O P H A N D L I N G |
528 | // ---------------------------------------------------------------------------- | 528 | // ---------------------------------------------------------------------------- |
529 | 529 | ||
530 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 530 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
531 | { | 531 | { |
532 | #ifndef KORG_NODND | 532 | #ifndef KORG_NODND |
533 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 533 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
534 | e->ignore(); | 534 | e->ignore(); |
535 | return; | 535 | return; |
536 | } | 536 | } |
537 | 537 | ||
538 | // some visual feedback | 538 | // some visual feedback |
539 | // oldPalette = palette(); | 539 | // oldPalette = palette(); |
540 | // setPalette(my_HilitePalette); | 540 | // setPalette(my_HilitePalette); |
541 | // update(); | 541 | // update(); |
542 | #endif | 542 | #endif |
543 | } | 543 | } |
544 | 544 | ||
545 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 545 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
546 | { | 546 | { |
547 | #ifndef KORG_NODND | 547 | #ifndef KORG_NODND |
548 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 548 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
549 | e->ignore(); | 549 | e->ignore(); |
550 | return; | 550 | return; |
551 | } | 551 | } |
552 | 552 | ||
553 | e->accept(); | 553 | e->accept(); |
554 | #endif | 554 | #endif |
555 | } | 555 | } |
556 | 556 | ||
557 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) | 557 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) |
558 | { | 558 | { |
559 | #ifndef KORG_NODND | 559 | #ifndef KORG_NODND |
560 | // setPalette(oldPalette); | 560 | // setPalette(oldPalette); |
561 | // update(); | 561 | // update(); |
562 | #endif | 562 | #endif |
563 | } | 563 | } |
564 | 564 | ||
565 | void KODayMatrix::dropEvent(QDropEvent *e) | 565 | void KODayMatrix::dropEvent(QDropEvent *e) |
566 | { | 566 | { |
567 | #ifndef KORG_NODND | 567 | #ifndef KORG_NODND |
568 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 568 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
569 | 569 | ||
570 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 570 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
571 | e->ignore(); | 571 | e->ignore(); |
572 | return; | 572 | return; |
573 | } | 573 | } |
574 | 574 | ||
575 | DndFactory factory( mCalendar ); | 575 | DndFactory factory( mCalendar ); |
576 | Event *event = factory.createDrop(e); | 576 | Event *event = factory.createDrop(e); |
577 | 577 | ||
578 | if (event) { | 578 | if (event) { |
579 | e->acceptAction(); | 579 | e->acceptAction(); |
580 | 580 | ||
581 | Event *existingEvent = mCalendar->event(event->uid()); | 581 | Event *existingEvent = mCalendar->event(event->uid()); |
582 | 582 | ||
583 | if(existingEvent) { | 583 | if(existingEvent) { |
584 | // uniquify event | 584 | // uniquify event |
585 | event->recreate(); | 585 | event->recreate(); |
586 | /* | 586 | /* |
587 | KMessageBox::sorry(this, | 587 | KMessageBox::sorry(this, |
588 | i18n("Event already exists in this calendar."), | 588 | i18n("Event already exists in this calendar."), |
589 | i18n("Drop Event")); | 589 | i18n("Drop Event")); |
590 | delete event; | 590 | delete event; |
591 | return; | 591 | return; |
592 | */ | 592 | */ |
593 | } | 593 | } |
594 | // kdDebug() << "Drop new Event" << endl; | 594 | // kdDebug() << "Drop new Event" << endl; |
595 | // Adjust date | 595 | // Adjust date |
596 | QDateTime start = event->dtStart(); | 596 | QDateTime start = event->dtStart(); |
597 | QDateTime end = event->dtEnd(); | 597 | QDateTime end = event->dtEnd(); |
598 | int duration = start.daysTo(end); | 598 | int duration = start.daysTo(end); |
599 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); | 599 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); |
600 | 600 | ||
601 | start.setDate(days[idx]); | 601 | start.setDate(days[idx]); |
602 | end.setDate(days[idx].addDays(duration)); | 602 | end.setDate(days[idx].addDays(duration)); |
603 | 603 | ||
604 | event->setDtStart(start); | 604 | event->setDtStart(start); |
605 | event->setDtEnd(end); | 605 | event->setDtEnd(end); |
606 | mCalendar->addEvent(event); | 606 | mCalendar->addEvent(event); |
607 | 607 | ||
608 | emit eventDropped(event); | 608 | emit eventDropped(event); |
609 | } else { | 609 | } else { |
610 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; | 610 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; |
611 | e->ignore(); | 611 | e->ignore(); |
612 | } | 612 | } |
613 | #endif | 613 | #endif |
614 | } | 614 | } |
615 | 615 | ||
616 | // ---------------------------------------------------------------------------- | 616 | // ---------------------------------------------------------------------------- |
617 | // P A I N T E V E N T H A N D L I N G | 617 | // P A I N T E V E N T H A N D L I N G |
618 | // ---------------------------------------------------------------------------- | 618 | // ---------------------------------------------------------------------------- |
619 | 619 | ||
620 | void KODayMatrix::paintEvent(QPaintEvent * pevent) | 620 | void KODayMatrix::paintEvent(QPaintEvent * pevent) |
621 | { | 621 | { |
622 | if ( width() <= 0 || height() <= 0 ) | 622 | QRect sz = frameRect(); |
623 | if ( sz.width() <= 0 || sz.height() <= 0 ) | ||
623 | return; | 624 | return; |
624 | if ( mPendingUpdateBeforeRepaint ) { | 625 | if ( mPendingUpdateBeforeRepaint ) { |
625 | updateViewTimed(); | 626 | updateViewTimed(); |
626 | mPendingUpdateBeforeRepaint = false; | 627 | mPendingUpdateBeforeRepaint = false; |
627 | } | 628 | } |
628 | if ( myPix.width() != width() || myPix.height()!=height() ) { | 629 | if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) { |
629 | myPix.resize(size() ); | 630 | myPix.resize(sz.size() ); |
630 | } | 631 | } |
631 | QPainter p(&myPix); | 632 | QPainter p(&myPix); |
632 | p.setFont(font()); | 633 | p.setFont(font()); |
633 | 634 | ||
634 | QRect sz = frameRect(); | 635 | |
635 | int dheight = daysize.height(); | 636 | int dheight = daysize.height(); |
636 | int dwidth = daysize.width(); | 637 | int dwidth = daysize.width(); |
637 | int row,col; | 638 | int row,col; |
638 | int selw, selh; | 639 | int selw, selh; |
640 | int xyOff = frameWidth(); | ||
641 | int colModulo = sz.width() % 7; | ||
642 | int rowModulo = sz.height() % 6; | ||
643 | qDebug("off %d col %d row %d ",xyOff,colModulo,rowModulo ); | ||
644 | |||
639 | bool isRTL = KOGlobals::self()->reverseLayout(); | 645 | bool isRTL = KOGlobals::self()->reverseLayout(); |
640 | 646 | ||
641 | // draw background and topleft frame | 647 | // draw background and topleft frame |
642 | p.fillRect(pevent->rect(), mDefaultBackColor); | 648 | p.fillRect(pevent->rect(), mDefaultBackColor); |
643 | p.setPen(mDefaultTextColor); | 649 | p.setPen(mDefaultTextColor); |
644 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); | 650 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); |
645 | int mSelStartT = mSelStart; | 651 | int mSelStartT = mSelStart; |
646 | int mSelEndT = mSelEnd; | 652 | int mSelEndT = mSelEnd; |
647 | if ( mSelEndT >= NUMDAYS ) | 653 | if ( mSelEndT >= NUMDAYS ) |
648 | mSelEndT = NUMDAYS-1; | 654 | mSelEndT = NUMDAYS-1; |
649 | // draw selected days with highlighted background color | 655 | // draw selected days with highlighted background color |
650 | if (mSelStart != NOSELECTION) { | 656 | if (mSelStart != NOSELECTION) { |
651 | bool skip = false; | 657 | bool skip = false; |
652 | if ( ! mouseDown ) { | 658 | if ( ! mouseDown ) { |
653 | int mo = days[20].month(); | 659 | int mo = days[20].month(); |
654 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); | 660 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); |
655 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); | 661 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); |
656 | if ( days[mSelStartT].month() > mo || days[mSelEndT].month() < mo ) { | 662 | if ( days[mSelStartT].month() > mo || days[mSelEndT].month() < mo ) { |
657 | skip = true; | 663 | skip = true; |
658 | } else { | 664 | } else { |
659 | if ( days[mSelStartT].month() != mo ) { | 665 | if ( days[mSelStartT].month() != mo ) { |
660 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); | 666 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); |
661 | mSelStartT += add +1; | 667 | mSelStartT += add +1; |
662 | } | 668 | } |
663 | if ( days[mSelEndT].month() != mo ) { | 669 | if ( days[mSelEndT].month() != mo ) { |
664 | int sub = days[mSelEndT].day(); | 670 | int sub = days[mSelEndT].day(); |
665 | mSelEndT -= sub ; | 671 | mSelEndT -= sub ; |
666 | } | 672 | } |
667 | } | 673 | } |
668 | } | 674 | } |
669 | if ( ! skip ) { | 675 | if ( ! skip ) { |
670 | row = mSelStartT/7; | 676 | row = mSelStartT/7; |
671 | col = mSelStartT -row*7; | 677 | col = mSelStartT -row*7; |
672 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 678 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
673 | 679 | ||
674 | if (row == mSelEndT/7) { | 680 | |
675 | // Single row selection | 681 | |
676 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth, | 682 | int addCol = 0; |
677 | row*dheight, (mSelEndT-mSelStartT+1)*dwidth, dheight, selcol); | 683 | int addRow = 0; |
678 | } else { | 684 | #if 0 |
679 | // draw first row to the right | 685 | if ( colModulo ) { |
680 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, | 686 | if ( col >= 7 - colModulo ) |
681 | dheight, selcol); | 687 | addCol = col - 7 + colModulo; |
682 | // draw full block till last line | 688 | } |
683 | selh = mSelEndT/7-row; | 689 | if ( rowModulo ) { |
684 | if (selh > 1) { | 690 | if ( row >= 6 - rowModulo ) |
685 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); | 691 | addRow = row - 5 + rowModulo; |
686 | } | 692 | } |
687 | // draw last block from left to mSelEndT | 693 | #endif |
688 | selw = mSelEndT-7*(mSelEndT/7)+1; | 694 | |
689 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, | 695 | |
690 | selw*dwidth, dheight, selcol); | 696 | |
691 | } | 697 | |
698 | |||
699 | if (row == mSelEndT/7) { | ||
700 | if ( rowModulo ) { | ||
701 | if ( row >= 6 - rowModulo ) | ||
702 | addRow = row - 5 + rowModulo; | ||
703 | } | ||
704 | if ( colModulo ) { | ||
705 | if ( mSelEndT-mSelStartT+1 >= 7 - colModulo ) | ||
706 | addCol = mSelEndT-mSelStartT+1 - 7 + colModulo; | ||
707 | } | ||
708 | // Single row selection | ||
709 | if ( row == 0) | ||
710 | addRow = 1; | ||
711 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1, | ||
712 | row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); | ||
713 | } else { | ||
714 | // draw first row to the right | ||
715 | if ( row == 0) | ||
716 | addRow = 1; | ||
717 | p.fillRect(isRTL ? 0 : col*dwidth+1, row*dheight+addRow, (7-col)*dwidth+colModulo, | ||
718 | dheight, selcol); | ||
719 | // draw full block till last line | ||
720 | selh = mSelEndT/7-row; | ||
721 | if (selh > 1) { | ||
722 | p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight,selcol); | ||
723 | } | ||
724 | // draw last block from left to mSelEndT | ||
725 | selw = mSelEndT-7*(mSelEndT/7)+1; | ||
726 | //qDebug("esl %d ",selw ); | ||
727 | int add = 0; | ||
728 | if ( colModulo ) { | ||
729 | add = 7 - colModulo; | ||
730 | if ( selw > add ) | ||
731 | add = selw - add; | ||
732 | else | ||
733 | add = 0; | ||
734 | } | ||
735 | //qDebug("add %d ", add); | ||
736 | p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight, | ||
737 | selw*dwidth+add, dheight, selcol); | ||
738 | } | ||
692 | } | 739 | } |
693 | } | 740 | } |
694 | 741 | ||
695 | // iterate over all days in the matrix and draw the day label in appropriate colors | 742 | // iterate over all days in the matrix and draw the day label in appropriate colors |
696 | QColor actcol = mDefaultTextColorShaded; | 743 | QColor actcol = mDefaultTextColorShaded; |
697 | p.setPen(actcol); | 744 | p.setPen(actcol); |
698 | QPen tmppen; | 745 | QPen tmppen; |
699 | for(int i = 0; i < NUMDAYS; i++) { | 746 | for(int i = 0; i < NUMDAYS; i++) { |
700 | row = i/7; | 747 | row = i/7; |
701 | col = isRTL ? 6-(i-row*7) : i-row*7; | 748 | col = isRTL ? 6-(i-row*7) : i-row*7; |
702 | 749 | ||
703 | // if it is the first day of a month switch color from normal to shaded and vice versa | 750 | // if it is the first day of a month switch color from normal to shaded and vice versa |
704 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 751 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
705 | if (actcol == mDefaultTextColorShaded) { | 752 | if (actcol == mDefaultTextColorShaded) { |
706 | actcol = mDefaultTextColor; | 753 | actcol = mDefaultTextColor; |
707 | } else { | 754 | } else { |
708 | actcol = mDefaultTextColorShaded; | 755 | actcol = mDefaultTextColorShaded; |
709 | } | 756 | } |
710 | p.setPen(actcol); | 757 | p.setPen(actcol); |
711 | } | 758 | } |
712 | if (actcol == mDefaultTextColorShaded) { | 759 | if (actcol == mDefaultTextColorShaded) { |
713 | if ( ! mouseDown ) { | 760 | if ( ! mouseDown ) { |
714 | continue; | 761 | continue; |
715 | } | 762 | } |
716 | } | 763 | } |
717 | //Reset pen color after selected days block | 764 | //Reset pen color after selected days block |
718 | if (i == mSelEndT+1) { | 765 | if (i == mSelEndT+1) { |
719 | p.setPen(actcol); | 766 | p.setPen(actcol); |
720 | } | 767 | } |
721 | 768 | ||
722 | // if today then draw rectangle around day | 769 | // if today then draw rectangle around day |
723 | if (today == i) { | 770 | if (today == i) { |
724 | tmppen = p.pen(); | 771 | tmppen = p.pen(); |
725 | QPen mTodayPen(p.pen()); | 772 | QPen mTodayPen(p.pen()); |
726 | 773 | ||
727 | mTodayPen.setWidth(mTodayMarginWidth); | 774 | mTodayPen.setWidth(mTodayMarginWidth); |
728 | //draw red rectangle for holidays | 775 | //draw red rectangle for holidays |
729 | if (!mHolidays[i].isNull()) { | 776 | if (!mHolidays[i].isNull()) { |
730 | if (actcol == mDefaultTextColor) { | 777 | if (actcol == mDefaultTextColor) { |
731 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); | 778 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); |
732 | } else { | 779 | } else { |
733 | mTodayPen.setColor(mHolidayColorShaded); | 780 | mTodayPen.setColor(mHolidayColorShaded); |
734 | } | 781 | } |
735 | } | 782 | } |
736 | //draw gray rectangle for today if in selection | 783 | //draw gray rectangle for today if in selection |
737 | if (i >= mSelStartT && i <= mSelEndT) { | 784 | if (i >= mSelStartT && i <= mSelEndT) { |
738 | QColor grey("grey"); | 785 | QColor grey("grey"); |
739 | mTodayPen.setColor(grey); | 786 | mTodayPen.setColor(grey); |
740 | } | 787 | } |
741 | p.setPen(mTodayPen); | 788 | p.setPen(mTodayPen); |
742 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); | 789 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); |
743 | p.setPen(tmppen); | 790 | p.setPen(tmppen); |
744 | } | 791 | } |
745 | 792 | ||
746 | // if any events are on that day then draw it using a bold font | 793 | // if any events are on that day then draw it using a bold font |
747 | if (events[i] > 0) { | 794 | if (events[i] > 0) { |
748 | QFont myFont = font(); | 795 | QFont myFont = font(); |
749 | myFont.setBold(true); | 796 | myFont.setBold(true); |
750 | p.setFont(myFont); | 797 | p.setFont(myFont); |
751 | } | 798 | } |
752 | 799 | ||
753 | // if it is a holiday then use the default holiday color | 800 | // if it is a holiday then use the default holiday color |
754 | if (!mHolidays[i].isNull()) { | 801 | if (!mHolidays[i].isNull()) { |
755 | if ( bDays.testBit(i) ) { | 802 | if ( bDays.testBit(i) ) { |
756 | p.setPen(Qt::green); | 803 | p.setPen(Qt::green); |
757 | } else { | 804 | } else { |
758 | if (actcol == mDefaultTextColor) { | 805 | if (actcol == mDefaultTextColor) { |
759 | p.setPen(KOPrefs::instance()->mHolidayColor); | 806 | p.setPen(KOPrefs::instance()->mHolidayColor); |
760 | } else { | 807 | } else { |
761 | p.setPen(mHolidayColorShaded); | 808 | p.setPen(mHolidayColorShaded); |
762 | } | 809 | } |
763 | } | 810 | } |
764 | } | 811 | } |
765 | 812 | ||
766 | // draw selected days with special color | 813 | // draw selected days with special color |
767 | // DO NOT specially highlight holidays in selection ! | 814 | // DO NOT specially highlight holidays in selection ! |
768 | if (i >= mSelStartT && i <= mSelEndT) { | 815 | if (i >= mSelStartT && i <= mSelEndT) { |
769 | ;//p.setPen(mSelectedDaysColor); | 816 | ;//p.setPen(mSelectedDaysColor); |
770 | } | 817 | } |
771 | 818 | ||
772 | p.drawText(col*dwidth, row*dheight, dwidth, dheight, | 819 | int addCol = 0; |
820 | int addRow = 0; | ||
821 | if ( colModulo ) { | ||
822 | if ( col >= 7 - colModulo ) | ||
823 | addCol = col - 7 + colModulo; | ||
824 | } | ||
825 | if ( rowModulo ) { | ||
826 | if ( row >= 6 - rowModulo ) | ||
827 | addRow = row - 5 + rowModulo; | ||
828 | } | ||
829 | //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); | ||
830 | ++addCol;++addCol; | ||
831 | p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, | ||
773 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); | 832 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); |
774 | 833 | ||
775 | // reset color to actual color | 834 | // reset color to actual color |
776 | if (!mHolidays[i].isNull()) { | 835 | if (!mHolidays[i].isNull()) { |
777 | p.setPen(actcol); | 836 | p.setPen(actcol); |
778 | } | 837 | } |
779 | // reset bold font to plain font | 838 | // reset bold font to plain font |
780 | if (events[i] > 0) { | 839 | if (events[i] > 0) { |
781 | QFont myFont = font(); | 840 | QFont myFont = font(); |
782 | myFont.setBold(false); | 841 | myFont.setBold(false); |
783 | p.setFont(myFont); | 842 | p.setFont(myFont); |
784 | } | 843 | } |
785 | } | 844 | } |
786 | bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); | 845 | int off = xyOff; |
846 | bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP); | ||
847 | //qDebug("ffffffffff %d ", off); | ||
787 | } | 848 | } |
788 | 849 | ||
789 | // ---------------------------------------------------------------------------- | 850 | // ---------------------------------------------------------------------------- |
790 | // R E SI Z E E V E N T H A N D L I N G | 851 | // R E SI Z E E V E N T H A N D L I N G |
791 | // ---------------------------------------------------------------------------- | 852 | // ---------------------------------------------------------------------------- |
792 | 853 | ||
793 | void KODayMatrix::resizeEvent(QResizeEvent *) | 854 | void KODayMatrix::resizeEvent(QResizeEvent *) |
794 | { | 855 | { |
795 | QRect sz = frameRect(); | 856 | QRect sz = frameRect(); |
796 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 857 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
797 | daysize.setWidth(sz.width() / 7); | 858 | daysize.setWidth(sz.width() / 7); |
798 | } | 859 | } |
799 | 860 | ||
800 | QSize KODayMatrix::sizeHint() const | 861 | QSize KODayMatrix::sizeHint() const |
801 | { | 862 | { |
802 | 863 | ||
803 | QFontMetrics fm ( font() ); | 864 | QFontMetrics fm ( font() ); |
804 | int wid = fm.width( "30") *7+7; | 865 | int wid = fm.width( "30") *7+3; |
805 | int hei = fm.height() * 6+4; | 866 | int hei = fm.height() * 6+3; |
806 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); | 867 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); |
807 | return QSize ( wid, hei ); | 868 | return QSize ( wid, hei ); |
808 | 869 | ||
809 | } | 870 | } |
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h index 39946de..f4016b6 100644 --- a/korganizer/kodaymatrix.h +++ b/korganizer/kodaymatrix.h | |||
@@ -1,322 +1,322 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> | 3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef _KODAYMAT_H | 23 | #ifndef _KODAYMAT_H |
24 | #define _KODAYMAT_H | 24 | #define _KODAYMAT_H |
25 | 25 | ||
26 | #include <libkcal/calendar.h> | 26 | #include <libkcal/calendar.h> |
27 | 27 | ||
28 | #include <qstring.h> | 28 | #include <qstring.h> |
29 | #include <qframe.h> | 29 | #include <qframe.h> |
30 | #include <qcolor.h> | 30 | #include <qcolor.h> |
31 | #include <qpen.h> | 31 | #include <qpen.h> |
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qtooltip.h> | 33 | #include <qtooltip.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | #include <qbitarray.h> | 35 | #include <qbitarray.h> |
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | 37 | ||
38 | class QDragEnterEvent; | 38 | class QDragEnterEvent; |
39 | class QDragMoveEvent; | 39 | class QDragMoveEvent; |
40 | class QDragLeaveEvent; | 40 | class QDragLeaveEvent; |
41 | class QDropEvent; | 41 | class QDropEvent; |
42 | 42 | ||
43 | class KODayMatrix; | 43 | class KODayMatrix; |
44 | 44 | ||
45 | using namespace KCal; | 45 | using namespace KCal; |
46 | 46 | ||
47 | 47 | ||
48 | /** | 48 | /** |
49 | * small helper class to dynamically show tooltips inside the day matrix. | 49 | * small helper class to dynamically show tooltips inside the day matrix. |
50 | * This class asks the day matrix object for a appropriate label which | 50 | * This class asks the day matrix object for a appropriate label which |
51 | * is in our special case the name of the holiday or null if this day is no holiday. | 51 | * is in our special case the name of the holiday or null if this day is no holiday. |
52 | */ | 52 | */ |
53 | class DynamicTip : public QToolTip | 53 | class DynamicTip : public QToolTip |
54 | { | 54 | { |
55 | public: | 55 | public: |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Constructor that expects a KODayMatrix object as parent. | 58 | * Constructor that expects a KODayMatrix object as parent. |
59 | * | 59 | * |
60 | * @param parent the parent KODayMatrix control. | 60 | * @param parent the parent KODayMatrix control. |
61 | */ | 61 | */ |
62 | DynamicTip(QWidget* parent ); | 62 | DynamicTip(QWidget* parent ); |
63 | 63 | ||
64 | protected: | 64 | protected: |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * Qt's callback to ask the object to provide an approrpiate text for the | 67 | * Qt's callback to ask the object to provide an approrpiate text for the |
68 | * tooltip to be shown. | 68 | * tooltip to be shown. |
69 | * | 69 | * |
70 | * @param pos coordinates of the mouse. | 70 | * @param pos coordinates of the mouse. |
71 | */ | 71 | */ |
72 | void maybeTip( const QPoint & pos); | 72 | void maybeTip( const QPoint & pos); |
73 | 73 | ||
74 | private: | 74 | private: |
75 | 75 | ||
76 | /** the parent control this tooltip is designed for. */ | 76 | /** the parent control this tooltip is designed for. */ |
77 | KODayMatrix* matrix; | 77 | KODayMatrix* matrix; |
78 | }; | 78 | }; |
79 | 79 | ||
80 | /** | 80 | /** |
81 | * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed. | 81 | * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed. |
82 | * Cornelius thought this was a waste of memory and a lot of overhead. | 82 | * Cornelius thought this was a waste of memory and a lot of overhead. |
83 | * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame | 83 | * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame |
84 | * that draws the labels and allows for dragging selection while maintaining nearly full | 84 | * that draws the labels and allows for dragging selection while maintaining nearly full |
85 | * compatibility in behaviour with its predecessor. | 85 | * compatibility in behaviour with its predecessor. |
86 | * | 86 | * |
87 | * The following functionality has been changed: | 87 | * The following functionality has been changed: |
88 | * | 88 | * |
89 | * o when shifting events in the agenda view from one day to another the day matrix is updated now | 89 | * o when shifting events in the agenda view from one day to another the day matrix is updated now |
90 | * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date. | 90 | * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date. |
91 | * o no support for Ctrl+click to create groups of dates | 91 | * o no support for Ctrl+click to create groups of dates |
92 | * (This has not really been supported in the predecessor. It was not very intuitive nor was it | 92 | * (This has not really been supported in the predecessor. It was not very intuitive nor was it |
93 | * user friendly.) | 93 | * user friendly.) |
94 | * This feature has been replaced with dragging a selection on the matrix. The matrix will | 94 | * This feature has been replaced with dragging a selection on the matrix. The matrix will |
95 | * automatically choose the appropriate selection (e.g. you are not any longer able to select | 95 | * automatically choose the appropriate selection (e.g. you are not any longer able to select |
96 | * two distinct groups of date selections as in the old class) | 96 | * two distinct groups of date selections as in the old class) |
97 | * o now that you can select more then a week it can happen that not all selected days are | 97 | * o now that you can select more then a week it can happen that not all selected days are |
98 | * displayed in the matrix. However this is preferred to the alternative which would mean to | 98 | * displayed in the matrix. However this is preferred to the alternative which would mean to |
99 | * adjust the selection and leave some days undisplayed while scrolling through the months | 99 | * adjust the selection and leave some days undisplayed while scrolling through the months |
100 | * | 100 | * |
101 | * @short day matrix widget of the KDateNavigator | 101 | * @short day matrix widget of the KDateNavigator |
102 | * | 102 | * |
103 | * @author Eitzenberger Thomas | 103 | * @author Eitzenberger Thomas |
104 | */ | 104 | */ |
105 | class KODayMatrix: public QFrame { | 105 | class KODayMatrix: public QFrame { |
106 | 106 | ||
107 | Q_OBJECT | 107 | Q_OBJECT |
108 | 108 | ||
109 | public: | 109 | public: |
110 | 110 | ||
111 | /** constructor to create a day matrix widget. | 111 | /** constructor to create a day matrix widget. |
112 | * | 112 | * |
113 | * @param parent widget that is the parent of the day matrix. Normally this should | 113 | * @param parent widget that is the parent of the day matrix. Normally this should |
114 | * be a KDateNavigator | 114 | * be a KDateNavigator |
115 | * @param calendar instance of a calendar on which all calculations are based | 115 | * @param calendar instance of a calendar on which all calculations are based |
116 | * @param date start date of the matrix (is expected to be already fixed). It is | 116 | * @param date start date of the matrix (is expected to be already fixed). It is |
117 | * assumed that this date is the first week day to be shown in the matrix. | 117 | * assumed that this date is the first week day to be shown in the matrix. |
118 | * @param name name of the widget | 118 | * @param name name of the widget |
119 | */ | 119 | */ |
120 | KODayMatrix( QWidget *parent, const char *name ); | 120 | KODayMatrix( QWidget *parent, const char *name ); |
121 | //KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name ); | 121 | //KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name ); |
122 | 122 | ||
123 | /** destructor that deallocates all dynamically allocated private members. | 123 | /** destructor that deallocates all dynamically allocated private members. |
124 | */ | 124 | */ |
125 | ~KODayMatrix(); | 125 | ~KODayMatrix(); |
126 | 126 | ||
127 | /** updates the day matrix to start with the given date. Does all the necessary | 127 | /** updates the day matrix to start with the given date. Does all the necessary |
128 | * checks for holidays or events on a day and stores them for display later on. | 128 | * checks for holidays or events on a day and stores them for display later on. |
129 | * Does NOT update the view visually. Call repaint() for this. | 129 | * Does NOT update the view visually. Call repaint() for this. |
130 | * | 130 | * |
131 | * @param actdate recalculates the day matrix to show NUMDAYS starting from this | 131 | * @param actdate recalculates the day matrix to show NUMDAYS starting from this |
132 | * date. | 132 | * date. |
133 | */ | 133 | */ |
134 | void updateView(QDate actdate); | 134 | void updateView(QDate actdate); |
135 | void updateEvents(); | 135 | void updateEvents(); |
136 | 136 | ||
137 | /** returns the QDate object associated with day indexed by the | 137 | /** returns the QDate object associated with day indexed by the |
138 | * supplied offset. | 138 | * supplied offset. |
139 | */ | 139 | */ |
140 | const QDate& getDate(int offset); | 140 | const QDate& getDate(int offset); |
141 | void setCalendar( Calendar * ); | 141 | void setCalendar( Calendar * ); |
142 | /** returns the official name of this holy day or 0 if there is no label | 142 | /** returns the official name of this holy day or 0 if there is no label |
143 | * for this day. | 143 | * for this day. |
144 | */ | 144 | */ |
145 | QString getHolidayLabel(int offset); | 145 | QString getHolidayLabel(int offset); |
146 | 146 | ||
147 | /** adds all actual selected days from mSelStart to mSelEnd to the supplied | 147 | /** adds all actual selected days from mSelStart to mSelEnd to the supplied |
148 | * DateList. | 148 | * DateList. |
149 | */ | 149 | */ |
150 | void addSelectedDaysTo(DateList&); | 150 | void addSelectedDaysTo(DateList&); |
151 | 151 | ||
152 | /** sets the actual to be displayed selection in the day matrix starting from | 152 | /** sets the actual to be displayed selection in the day matrix starting from |
153 | * start and ending with end. Theview must be manually updated by calling | 153 | * start and ending with end. Theview must be manually updated by calling |
154 | * repaint. (?) | 154 | * repaint. (?) |
155 | */ | 155 | */ |
156 | void setSelectedDaysFrom(const QDate& start, const QDate& end); | 156 | void setSelectedDaysFrom(const QDate& start, const QDate& end); |
157 | void clearSelection(); | 157 | void clearSelection(); |
158 | 158 | ||
159 | /** Is today visible in the view? Keep this in sync with | 159 | /** Is today visible in the view? Keep this in sync with |
160 | * the values today (below) can take. | 160 | * the values today (below) can take. |
161 | */ | 161 | */ |
162 | bool isTodayVisible() const { return today>=0; } ; | 162 | bool isTodayVisible() const { return today>=0; } ; |
163 | 163 | ||
164 | /** If today is visible, then we can find out if today is | 164 | /** If today is visible, then we can find out if today is |
165 | * near the beginning or the end of the month. | 165 | * near the beginning or the end of the month. |
166 | * This is dependent on today remaining the index | 166 | * This is dependent on today remaining the index |
167 | * in the array of visible dates and going from | 167 | * in the array of visible dates and going from |
168 | * top left (0) to bottom right (41). | 168 | * top left (0) to bottom right (41). |
169 | */ | 169 | */ |
170 | bool isBeginningOfMonth() const { return today<=8; } ; | 170 | bool isBeginningOfMonth() const { return today<=8; } ; |
171 | bool isEndOfMonth() const { return today>=27; } ; | 171 | bool isEndOfMonth() const { return today>=27; } ; |
172 | QString getWhatsThisText( QPoint ) ; | 172 | QString getWhatsThisText( QPoint ) ; |
173 | QSize sizeHint() const; | 173 | QSize sizeHint() const; |
174 | 174 | QRect frameRect () const { int wid = frameWidth(); return QRect(0+wid,0+wid,width()-wid-wid,height()-wid-wid);} | |
175 | public slots: | 175 | public slots: |
176 | /** Recalculates all the flags of the days in the matrix like holidays or events | 176 | /** Recalculates all the flags of the days in the matrix like holidays or events |
177 | * on a day (Actually calls above method with the actual startdate). | 177 | * on a day (Actually calls above method with the actual startdate). |
178 | */ | 178 | */ |
179 | void updateView(); | 179 | void updateView(); |
180 | void updateViewTimed(); | 180 | void updateViewTimed(); |
181 | void repaintViewTimed(); | 181 | void repaintViewTimed(); |
182 | 182 | ||
183 | /** | 183 | /** |
184 | * Calculate which square in the matrix should be | 184 | * Calculate which square in the matrix should be |
185 | * hilighted to indicate it's today. | 185 | * hilighted to indicate it's today. |
186 | */ | 186 | */ |
187 | void recalculateToday(); | 187 | void recalculateToday(); |
188 | 188 | ||
189 | /* | 189 | /* |
190 | void setStartDate(QDate); | 190 | void setStartDate(QDate); |
191 | */ | 191 | */ |
192 | 192 | ||
193 | signals: | 193 | signals: |
194 | 194 | ||
195 | /** emitted if the user selects a block of days with the mouse by dragging a rectangle | 195 | /** emitted if the user selects a block of days with the mouse by dragging a rectangle |
196 | * inside the matrix | 196 | * inside the matrix |
197 | * | 197 | * |
198 | * @param daylist list of days that have been selected by the user | 198 | * @param daylist list of days that have been selected by the user |
199 | */ | 199 | */ |
200 | void selected( const KCal::DateList &daylist ); | 200 | void selected( const KCal::DateList &daylist ); |
201 | 201 | ||
202 | /** emitted if the user has dropped an event inside the matrix | 202 | /** emitted if the user has dropped an event inside the matrix |
203 | * | 203 | * |
204 | * @param event the dropped calendar event | 204 | * @param event the dropped calendar event |
205 | */ | 205 | */ |
206 | void eventDropped(Event *event); | 206 | void eventDropped(Event *event); |
207 | 207 | ||
208 | protected: | 208 | protected: |
209 | 209 | ||
210 | void paintEvent(QPaintEvent *ev); | 210 | void paintEvent(QPaintEvent *ev); |
211 | 211 | ||
212 | void mousePressEvent (QMouseEvent* e); | 212 | void mousePressEvent (QMouseEvent* e); |
213 | 213 | ||
214 | void mouseReleaseEvent (QMouseEvent* e); | 214 | void mouseReleaseEvent (QMouseEvent* e); |
215 | 215 | ||
216 | void mouseMoveEvent (QMouseEvent* e); | 216 | void mouseMoveEvent (QMouseEvent* e); |
217 | 217 | ||
218 | void dragEnterEvent(QDragEnterEvent *); | 218 | void dragEnterEvent(QDragEnterEvent *); |
219 | 219 | ||
220 | void dragMoveEvent(QDragMoveEvent *); | 220 | void dragMoveEvent(QDragMoveEvent *); |
221 | 221 | ||
222 | void dragLeaveEvent(QDragLeaveEvent *); | 222 | void dragLeaveEvent(QDragLeaveEvent *); |
223 | 223 | ||
224 | void dropEvent(QDropEvent *); | 224 | void dropEvent(QDropEvent *); |
225 | 225 | ||
226 | void resizeEvent(QResizeEvent *); | 226 | void resizeEvent(QResizeEvent *); |
227 | 227 | ||
228 | private: | 228 | private: |
229 | bool mouseDown; | 229 | bool mouseDown; |
230 | QBitArray bDays; | 230 | QBitArray bDays; |
231 | QPixmap myPix; | 231 | QPixmap myPix; |
232 | QTimer* mUpdateTimer; | 232 | QTimer* mUpdateTimer; |
233 | QTimer* mRepaintTimer; | 233 | QTimer* mRepaintTimer; |
234 | bool mDayChanged; | 234 | bool mDayChanged; |
235 | bool mPendingUpdateBeforeRepaint; | 235 | bool mPendingUpdateBeforeRepaint; |
236 | 236 | ||
237 | /** returns the index of the day located at the matrix's widget (x,y) position. | 237 | /** returns the index of the day located at the matrix's widget (x,y) position. |
238 | * | 238 | * |
239 | * @param x horizontal coordinate | 239 | * @param x horizontal coordinate |
240 | * @param y vertical coordinate | 240 | * @param y vertical coordinate |
241 | */ | 241 | */ |
242 | int getDayIndexFrom(int x, int y); | 242 | int getDayIndexFrom(int x, int y); |
243 | 243 | ||
244 | /** calculates a "shaded" color from the supplied color object. | 244 | /** calculates a "shaded" color from the supplied color object. |
245 | * (Copied from Cornelius's kdpdatebutton.cpp) | 245 | * (Copied from Cornelius's kdpdatebutton.cpp) |
246 | * | 246 | * |
247 | * @param color source based on which a shaded color should be calculated. | 247 | * @param color source based on which a shaded color should be calculated. |
248 | */ | 248 | */ |
249 | QColor getShadedColor(QColor color); | 249 | QColor getShadedColor(QColor color); |
250 | 250 | ||
251 | /** number of days to be displayed. For now there is no support for any other number then 42. | 251 | /** number of days to be displayed. For now there is no support for any other number then 42. |
252 | so change it at your own risk :o) */ | 252 | so change it at your own risk :o) */ |
253 | static const int NUMDAYS; | 253 | static const int NUMDAYS; |
254 | 254 | ||
255 | /** calendar instance to be queried for holidays, events, ... */ | 255 | /** calendar instance to be queried for holidays, events, ... */ |
256 | Calendar *mCalendar; | 256 | Calendar *mCalendar; |
257 | 257 | ||
258 | /** starting date of the matrix */ | 258 | /** starting date of the matrix */ |
259 | QDate startdate; | 259 | QDate startdate; |
260 | 260 | ||
261 | /** array of day labels to optimeize drawing performance. */ | 261 | /** array of day labels to optimeize drawing performance. */ |
262 | QString *daylbls; | 262 | QString *daylbls; |
263 | 263 | ||
264 | /** array of days displayed to reduce memory consumption by | 264 | /** array of days displayed to reduce memory consumption by |
265 | subsequently calling QDate::addDays(). */ | 265 | subsequently calling QDate::addDays(). */ |
266 | QDate *days; | 266 | QDate *days; |
267 | 267 | ||
268 | /** array of storing the number of events on a given day. | 268 | /** array of storing the number of events on a given day. |
269 | * used for drawing a bold font if there is at least one event on that day. | 269 | * used for drawing a bold font if there is at least one event on that day. |
270 | */ | 270 | */ |
271 | int *events; | 271 | int *events; |
272 | 272 | ||
273 | /** stores holiday names of the days shown in the matrix. */ | 273 | /** stores holiday names of the days shown in the matrix. */ |
274 | QMap<int,QString> mHolidays; | 274 | QMap<int,QString> mHolidays; |
275 | 275 | ||
276 | /** indey of today or -1 if today is not visible in the matrix. */ | 276 | /** indey of today or -1 if today is not visible in the matrix. */ |
277 | int today; | 277 | int today; |
278 | 278 | ||
279 | /** index of day where dragged selection was initiated. | 279 | /** index of day where dragged selection was initiated. |
280 | used to detect "negative" timely selections */ | 280 | used to detect "negative" timely selections */ |
281 | int mSelInit; | 281 | int mSelInit; |
282 | 282 | ||
283 | /** if mSelStart has this value it indicates that there is no | 283 | /** if mSelStart has this value it indicates that there is no |
284 | actual selection in the matrix. */ | 284 | actual selection in the matrix. */ |
285 | static const int NOSELECTION; | 285 | static const int NOSELECTION; |
286 | 286 | ||
287 | /** index of first selected day. */ | 287 | /** index of first selected day. */ |
288 | int mSelStart; | 288 | int mSelStart; |
289 | 289 | ||
290 | /** index of last selected day. */ | 290 | /** index of last selected day. */ |
291 | int mSelEnd; | 291 | int mSelEnd; |
292 | 292 | ||
293 | /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */ | 293 | /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */ |
294 | DynamicTip* mToolTip; | 294 | DynamicTip* mToolTip; |
295 | 295 | ||
296 | 296 | ||
297 | /** default background colour of the matrix. */ | 297 | /** default background colour of the matrix. */ |
298 | QColor mDefaultBackColor; | 298 | QColor mDefaultBackColor; |
299 | 299 | ||
300 | /** default text color of the matrix. */ | 300 | /** default text color of the matrix. */ |
301 | QColor mDefaultTextColor; | 301 | QColor mDefaultTextColor; |
302 | 302 | ||
303 | /** default text color for days not in the actual month. */ | 303 | /** default text color for days not in the actual month. */ |
304 | QColor mDefaultTextColorShaded; | 304 | QColor mDefaultTextColorShaded; |
305 | 305 | ||
306 | /** default text color for holidays not in the actual month. */ | 306 | /** default text color for holidays not in the actual month. */ |
307 | QColor mHolidayColorShaded; | 307 | QColor mHolidayColorShaded; |
308 | 308 | ||
309 | /** text color for selected days. */ | 309 | /** text color for selected days. */ |
310 | QColor mSelectedDaysColor; | 310 | QColor mSelectedDaysColor; |
311 | 311 | ||
312 | /** default width of the frame drawn around today if it is visible in the matrix. */ | 312 | /** default width of the frame drawn around today if it is visible in the matrix. */ |
313 | int mTodayMarginWidth; | 313 | int mTodayMarginWidth; |
314 | 314 | ||
315 | /** stores actual size of each day in the widget so that I dont need to ask this data | 315 | /** stores actual size of each day in the widget so that I dont need to ask this data |
316 | * on every repaint. | 316 | * on every repaint. |
317 | */ | 317 | */ |
318 | QRect daysize; | 318 | QRect daysize; |
319 | 319 | ||
320 | }; | 320 | }; |
321 | 321 | ||
322 | #endif | 322 | #endif |