summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-20 19:52:47 (UTC)
committer zautrix <zautrix>2005-03-20 19:52:47 (UTC)
commit64068741e3b82a34c1b8a67da412ac88841b640c (patch) (unidiff)
tree70a665bab53da7aa211f523daebbdbff08136df4
parentd998afaaf0fe1af0b9b5e3d6f4cb504e35e35025 (diff)
downloadkdepimpi-64068741e3b82a34c1b8a67da412ac88841b640c.zip
kdepimpi-64068741e3b82a34c1b8a67da412ac88841b640c.tar.gz
kdepimpi-64068741e3b82a34c1b8a67da412ac88841b640c.tar.bz2
nf
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp42
1 files changed, 20 insertions, 22 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 507f18e..f864022 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -366,527 +366,525 @@ void KODayMatrix::updateView(QDate actdate)
366 //flag to indicate if the starting day of the matrix has changed by this call 366 //flag to indicate if the starting day of the matrix has changed by this call
367 //mDayChanged = false; 367 //mDayChanged = false;
368 // if a new startdate is to be set then apply Cornelius's calculation 368 // if a new startdate is to be set then apply Cornelius's calculation
369 // of the first day to be shown 369 // of the first day to be shown
370 if (actdate != startdate) { 370 if (actdate != startdate) {
371 // reset index of selection according to shift of starting date from startdate to actdate 371 // reset index of selection according to shift of starting date from startdate to actdate
372 if (mSelStart != NOSELECTION) { 372 if (mSelStart != NOSELECTION) {
373 int tmp = actdate.daysTo(startdate); 373 int tmp = actdate.daysTo(startdate);
374 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 374 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
375 // shift selection if new one would be visible at least partly ! 375 // shift selection if new one would be visible at least partly !
376 376
377 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { 377 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
378 // nested if is required for next X display pushed from a different month - correction required 378 // nested if is required for next X display pushed from a different month - correction required
379 // otherwise, for month forward and backward, it must be avoided 379 // otherwise, for month forward and backward, it must be avoided
380 if( mSelStart > NUMDAYS || mSelStart < 0 ) 380 if( mSelStart > NUMDAYS || mSelStart < 0 )
381 mSelStart = mSelStart + tmp; 381 mSelStart = mSelStart + tmp;
382 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 382 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
383 mSelEnd = mSelEnd + tmp; 383 mSelEnd = mSelEnd + tmp;
384 } 384 }
385 } 385 }
386 startdate = actdate; 386 startdate = actdate;
387 mDayChanged = true; 387 mDayChanged = true;
388 recalculateToday(); 388 recalculateToday();
389 } 389 }
390 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 390 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
391 if ( !isVisible() ) { 391 if ( !isVisible() ) {
392 mPendingUpdateBeforeRepaint = true; 392 mPendingUpdateBeforeRepaint = true;
393 } else { 393 } else {
394#ifdef DESKTOP_VERSION 394#ifdef DESKTOP_VERSION
395 //mRepaintTimer->start( 150 ); 395 //mRepaintTimer->start( 150 );
396 mUpdateTimer->start( 150 ); 396 mUpdateTimer->start( 150 );
397#else 397#else
398 mRepaintTimer->start( 350 ); 398 mRepaintTimer->start( 350 );
399 mUpdateTimer->start( 1200 ); 399 mUpdateTimer->start( 1200 );
400#endif 400#endif
401 } 401 }
402} 402}
403void KODayMatrix::updateEvents() 403void KODayMatrix::updateEvents()
404{ 404{
405 if ( !mCalendar ) return; 405 if ( !mCalendar ) return;
406 406
407 for( int i = 0; i < NUMDAYS; i++ ) { 407 for( int i = 0; i < NUMDAYS; i++ ) {
408 // if events are set for the day then remember to draw it bold 408 // if events are set for the day then remember to draw it bold
409 QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); 409 QPtrList<Event> eventlist = mCalendar->events( days[ i ] );
410 int numEvents = eventlist.count(); 410 int numEvents = eventlist.count();
411 Event *event; 411 Event *event;
412 for( event = eventlist.first(); event != 0;event=eventlist.next()) { 412 for( event = eventlist.first(); event != 0;event=eventlist.next()) {
413 ushort recurType = event->doesRecur(); 413 ushort recurType = event->doesRecur();
414 414
415 if ( ( recurType == Recurrence::rDaily && 415 if ( ( recurType == Recurrence::rDaily &&
416 !KOPrefs::instance()->mDailyRecur ) || 416 !KOPrefs::instance()->mDailyRecur ) ||
417 ( recurType == Recurrence::rWeekly && 417 ( recurType == Recurrence::rWeekly &&
418 !KOPrefs::instance()->mWeeklyRecur ) ) { 418 !KOPrefs::instance()->mWeeklyRecur ) ) {
419 numEvents--; 419 numEvents--;
420 } 420 }
421 } 421 }
422 events[ i ] = numEvents; 422 events[ i ] = numEvents;
423 } 423 }
424} 424}
425 425
426const QDate& KODayMatrix::getDate(int offset) 426const QDate& KODayMatrix::getDate(int offset)
427{ 427{
428 if (offset < 0 || offset > NUMDAYS-1) { 428 if (offset < 0 || offset > NUMDAYS-1) {
429 qDebug("Wrong offset2 "); 429 qDebug("Wrong offset2 ");
430 return days[0]; 430 return days[0];
431 } 431 }
432 return days[offset]; 432 return days[offset];
433} 433}
434 434
435QString KODayMatrix::getHolidayLabel(int offset) 435QString 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
444int KODayMatrix::getDayIndexFrom(int x, int y) 444int 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
454void KODayMatrix::mousePressEvent (QMouseEvent* e) 454void 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 mSelEnd = mSelStart;
463 repaint(false);
462} 464}
463 465
464void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) 466void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
465{ 467{
466 if ( e->button() == LeftButton ) 468 if ( e->button() == LeftButton )
467 if ( ! mouseDown ) { 469 if ( ! mouseDown ) {
468 return; 470 return;
469 } 471 }
470 else 472 else
471 mouseDown = false; 473 mouseDown = false;
472 int tmp = getDayIndexFrom(e->x(), e->y()); 474 int tmp = getDayIndexFrom(e->x(), e->y());
473 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 475 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
474 476
475 if (mSelInit > tmp) { 477 if (mSelInit > tmp) {
476 mSelEnd = mSelInit; 478 mSelEnd = mSelInit;
477 if (tmp != mSelStart) { 479 if (tmp != mSelStart) {
478 mSelStart = tmp; 480 mSelStart = tmp;
479 repaint(false); 481 repaint(false);
480 } 482 }
481 } else { 483 } else {
482 mSelStart = mSelInit; 484 mSelStart = mSelInit;
483 485
484 //repaint only if selection has changed 486 //repaint only if selection has changed
485 if (tmp != mSelEnd) { 487 if (tmp != mSelEnd) {
486 mSelEnd = tmp; 488 mSelEnd = tmp;
487 repaint(false); 489 repaint(false);
488 } 490 }
489 } 491 }
490 492
491 DateList daylist; 493 DateList daylist;
492 if ( mSelStart < 0 ) 494 if ( mSelStart < 0 )
493 mSelStart = 0; 495 mSelStart = 0;
494 for (int i = mSelStart; i <= mSelEnd; i++) { 496 for (int i = mSelStart; i <= mSelEnd; i++) {
495 daylist.append(days[i]); 497 daylist.append(days[i]);
496 } 498 }
497 emit selected((const DateList)daylist); 499 emit selected((const DateList)daylist);
498 500
499} 501}
500 502
501void KODayMatrix::mouseMoveEvent (QMouseEvent* e) 503void KODayMatrix::mouseMoveEvent (QMouseEvent* e)
502{ 504{
503 if ( ! mouseDown ) { 505 if ( ! mouseDown ) {
504 return; 506 return;
505 } 507 }
506 int tmp = getDayIndexFrom(e->x(), e->y()); 508 int tmp = getDayIndexFrom(e->x(), e->y());
507 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 509 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
508 510
509 if (mSelInit > tmp) { 511 if (mSelInit > tmp) {
510 mSelEnd = mSelInit; 512 mSelEnd = mSelInit;
511 if (tmp != mSelStart) { 513 if (tmp != mSelStart) {
512 mSelStart = tmp; 514 mSelStart = tmp;
513 repaint(false); 515 repaint(false);
514 } 516 }
515 } else { 517 } else {
516 mSelStart = mSelInit; 518 mSelStart = mSelInit;
517 519
518 //repaint only if selection has changed 520 //repaint only if selection has changed
519 if (tmp != mSelEnd) { 521 if (tmp != mSelEnd) {
520 mSelEnd = tmp; 522 mSelEnd = tmp;
521 repaint(false); 523 repaint(false);
522 } 524 }
523 } 525 }
524} 526}
525 527
526// ---------------------------------------------------------------------------- 528// ----------------------------------------------------------------------------
527// D R A G ' N D R O P H A N D L I N G 529// D R A G ' N D R O P H A N D L I N G
528// ---------------------------------------------------------------------------- 530// ----------------------------------------------------------------------------
529 531
530void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) 532void KODayMatrix::dragEnterEvent(QDragEnterEvent *e)
531{ 533{
532#ifndef KORG_NODND 534#ifndef KORG_NODND
533 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 535 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
534 e->ignore(); 536 e->ignore();
535 return; 537 return;
536 } 538 }
537 539
538 // some visual feedback 540 // some visual feedback
539// oldPalette = palette(); 541// oldPalette = palette();
540// setPalette(my_HilitePalette); 542// setPalette(my_HilitePalette);
541// update(); 543// update();
542#endif 544#endif
543} 545}
544 546
545void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) 547void KODayMatrix::dragMoveEvent(QDragMoveEvent *e)
546{ 548{
547#ifndef KORG_NODND 549#ifndef KORG_NODND
548 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 550 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
549 e->ignore(); 551 e->ignore();
550 return; 552 return;
551 } 553 }
552 554
553 e->accept(); 555 e->accept();
554#endif 556#endif
555} 557}
556 558
557void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) 559void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/)
558{ 560{
559#ifndef KORG_NODND 561#ifndef KORG_NODND
560// setPalette(oldPalette); 562// setPalette(oldPalette);
561// update(); 563// update();
562#endif 564#endif
563} 565}
564 566
565void KODayMatrix::dropEvent(QDropEvent *e) 567void KODayMatrix::dropEvent(QDropEvent *e)
566{ 568{
567#ifndef KORG_NODND 569#ifndef KORG_NODND
568// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; 570// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl;
569 571
570 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 572 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
571 e->ignore(); 573 e->ignore();
572 return; 574 return;
573 } 575 }
574 576
575 DndFactory factory( mCalendar ); 577 DndFactory factory( mCalendar );
576 Event *event = factory.createDrop(e); 578 Event *event = factory.createDrop(e);
577 579
578 if (event) { 580 if (event) {
579 e->acceptAction(); 581 e->acceptAction();
580 582
581 Event *existingEvent = mCalendar->event(event->uid()); 583 Event *existingEvent = mCalendar->event(event->uid());
582 584
583 if(existingEvent) { 585 if(existingEvent) {
584 // uniquify event 586 // uniquify event
585 event->recreate(); 587 event->recreate();
586/* 588/*
587 KMessageBox::sorry(this, 589 KMessageBox::sorry(this,
588 i18n("Event already exists in this calendar."), 590 i18n("Event already exists in this calendar."),
589 i18n("Drop Event")); 591 i18n("Drop Event"));
590 delete event; 592 delete event;
591 return; 593 return;
592*/ 594*/
593 } 595 }
594// kdDebug() << "Drop new Event" << endl; 596// kdDebug() << "Drop new Event" << endl;
595 // Adjust date 597 // Adjust date
596 QDateTime start = event->dtStart(); 598 QDateTime start = event->dtStart();
597 QDateTime end = event->dtEnd(); 599 QDateTime end = event->dtEnd();
598 int duration = start.daysTo(end); 600 int duration = start.daysTo(end);
599 int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); 601 int idx = getDayIndexFrom(e->pos().x(), e->pos().y());
600 602
601 start.setDate(days[idx]); 603 start.setDate(days[idx]);
602 end.setDate(days[idx].addDays(duration)); 604 end.setDate(days[idx].addDays(duration));
603 605
604 event->setDtStart(start); 606 event->setDtStart(start);
605 event->setDtEnd(end); 607 event->setDtEnd(end);
606 mCalendar->addEvent(event); 608 mCalendar->addEvent(event);
607 609
608 emit eventDropped(event); 610 emit eventDropped(event);
609 } else { 611 } else {
610// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; 612// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
611 e->ignore(); 613 e->ignore();
612 } 614 }
613#endif 615#endif
614} 616}
615 617
616// ---------------------------------------------------------------------------- 618// ----------------------------------------------------------------------------
617// P A I N T E V E N T H A N D L I N G 619// P A I N T E V E N T H A N D L I N G
618// ---------------------------------------------------------------------------- 620// ----------------------------------------------------------------------------
619 621
620void KODayMatrix::paintEvent(QPaintEvent * pevent) 622void KODayMatrix::paintEvent(QPaintEvent * pevent)
621{ 623{
622 QRect sz = frameRect(); 624 QRect sz = frameRect();
623 if ( sz.width() <= 0 || sz.height() <= 0 ) 625 if ( sz.width() <= 0 || sz.height() <= 0 )
624 return; 626 return;
625 if ( mPendingUpdateBeforeRepaint ) { 627 if ( mPendingUpdateBeforeRepaint ) {
626 updateViewTimed(); 628 updateViewTimed();
627 mPendingUpdateBeforeRepaint = false; 629 mPendingUpdateBeforeRepaint = false;
628 } 630 }
629 if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) { 631 if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) {
630 myPix.resize(sz.size() ); 632 myPix.resize(sz.size() );
631 } 633 }
632 QPainter p(&myPix); 634 QPainter p(&myPix);
633 p.setFont(font()); 635 p.setFont(font());
634 636
635 637
636 int dheight = daysize.height(); 638 int dheight = daysize.height();
637 int dwidth = daysize.width(); 639 int dwidth = daysize.width();
638 int row,col; 640 int row,col;
639 int selw, selh; 641 int selw, selh;
640 int xyOff = frameWidth(); 642 int xyOff = frameWidth();
641 int colModulo = sz.width() % 7; 643 int colModulo = sz.width() % 7;
642 int rowModulo = sz.height() % 6; 644 int rowModulo = sz.height() % 6;
643 //qDebug("off %d col %d row %d ",xyOff,colModulo,rowModulo ); 645 qDebug("col %d row %d ",colModulo,rowModulo );
644 646
645 bool isRTL = KOGlobals::self()->reverseLayout(); 647 bool isRTL = KOGlobals::self()->reverseLayout();
646 648
647 // draw background and topleft frame 649 // draw background and topleft frame
648 p.fillRect(pevent->rect(), mDefaultBackColor); 650 p.fillRect(pevent->rect(), mDefaultBackColor);
649 p.setPen(mDefaultTextColor); 651 p.setPen(mDefaultTextColor);
650 p.drawRect(0, 0, sz.width()+1, sz.height()+1); 652 p.drawRect(0, 0, sz.width()+1, sz.height()+1);
651 int mSelStartT = mSelStart; 653 int mSelStartT = mSelStart;
652 int mSelEndT = mSelEnd; 654 int mSelEndT = mSelEnd;
653 if ( mSelEndT >= NUMDAYS ) 655 if ( mSelEndT >= NUMDAYS )
654 mSelEndT = NUMDAYS-1; 656 mSelEndT = NUMDAYS-1;
655 // draw selected days with highlighted background color 657 // draw selected days with highlighted background color
656 if (mSelStart != NOSELECTION) { 658 if (mSelStart != NOSELECTION) {
657 bool skip = false; 659 bool skip = false;
658 if ( ! mouseDown ) { 660 if ( ! mouseDown ) {
659 int mo = days[20].month(); 661 int mo = days[20].month();
660 //qDebug("-- %d %d ", mSelStartT, mSelEndT); 662 //qDebug("-- %d %d ", mSelStartT, mSelEndT);
661 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); 663 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() );
662 if ( days[mSelStartT].month() > mo || days[mSelEndT].month() < mo ) { 664 if ( days[mSelStartT].month() > mo || days[mSelEndT].month() < mo ) {
663 skip = true; 665 skip = true;
664 } else { 666 } else {
665 if ( days[mSelStartT].month() != mo ) { 667 if ( days[mSelStartT].month() != mo ) {
666 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); 668 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day();
667 mSelStartT += add +1; 669 mSelStartT += add +1;
668 } 670 }
669 if ( days[mSelEndT].month() != mo ) { 671 if ( days[mSelEndT].month() != mo ) {
670 int sub = days[mSelEndT].day(); 672 int sub = days[mSelEndT].day();
671 mSelEndT -= sub ; 673 mSelEndT -= sub ;
672 } 674 }
673 } 675 }
674 } 676 }
675 if ( ! skip ) { 677 if ( ! skip ) {
676 row = mSelStartT/7; 678 row = mSelStartT/7;
677 col = mSelStartT -row*7; 679 col = mSelStartT -row*7;
678 QColor selcol = KOPrefs::instance()->mHighlightColor; 680 QColor selcol = KOPrefs::instance()->mHighlightColor;
679
680
681
682 int addCol = 0; 681 int addCol = 0;
683 int addRow = 0; 682 int addRow = 0;
684 int addRow2 = 0; 683 int addRow2 = 0;
685 int addCol2 = 0; 684 int addCol2 = 0;
686#if 0
687 if ( colModulo ) {
688 if ( col >= 7 - colModulo )
689 addCol = col - 7 + colModulo;
690 }
691 if ( rowModulo ) {
692 if ( row >= 6 - rowModulo )
693 addRow = row - 5 + rowModulo;
694 }
695#endif
696
697
698
699
700
701 if (row == mSelEndT/7) { 685 if (row == mSelEndT/7) {
702 if ( rowModulo ) { 686 if ( rowModulo ) {
703 if ( row >= 6 - rowModulo ) 687 if ( row >= 6 - rowModulo )
704 addRow = row - 5 + rowModulo; 688 addRow = row - 5 + rowModulo;
705 } 689 }
706 if ( colModulo ) { 690 if ( colModulo ) {
707 int colt1 = mSelEndT%7; 691 int colt1 = mSelEndT%7;
708 //qDebug("colt1 %d ", colt1 ); 692 //qDebug("colt1 %d ", colt1 );
709 if ( colt1 >= 7 - colModulo ) 693 if ( colt1 >= 7 - colModulo )
710 addCol = colt1 - 7 + colModulo+1; 694 addCol = colt1 - 7 + colModulo+1;
711 int colt = mSelStartT%7; 695 int colt = mSelStartT%7;
712 if ( colt >= 7 - colModulo ) 696 if ( colt >= 7 - colModulo )
713 addCol2 = colt - 7 + colModulo; 697 addCol2 = colt - 7 + colModulo;
714 addCol -= addCol2; 698 addCol -= addCol2;
715 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); 699 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 );
716 } 700 }
717 // Single row selection 701 // Single row selection
718 if ( row == 0) 702 if ( row == 0)
719 addRow = 1; 703 addRow = 1;
720 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, 704 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2,
721 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); 705 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol);
722 } else { 706 } else {
723 // draw first row to the right 707 // draw first row to the right
724 if ( colModulo ) { 708 if ( colModulo ) {
725 if ( col >= 7 - colModulo ) 709 if ( col >= 7 - colModulo )
726 addCol2 = col - 7 + colModulo; 710 addCol2 = col - 7 + colModulo;
727 } 711 }
728 if ( rowModulo ) { 712 if ( rowModulo ) {
729 if ( row >= 6 - rowModulo ) 713 if ( row >= 6 - rowModulo )
730 addRow = row - 5 + rowModulo; 714 addRow = row - 5 + rowModulo;
731 } 715 }
732 if ( row == 0) 716 if ( row == 0)
733 addRow = 1; 717 addRow = 1;
734 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, (7-col)*dwidth+colModulo, 718 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, (7-col)*dwidth+colModulo,
735 dheight+1, selcol); 719 dheight+1, selcol);
736 // draw full block till last line 720 // draw full block till last line
737 selh = mSelEndT/7-row; 721 selh = mSelEndT/7-row;
738 addRow = 0; 722 addRow = 0;
739 if ( rowModulo ) { 723 if ( rowModulo ) {
740 if ( mSelEndT/7 >= 6 - rowModulo ) 724 if ( mSelEndT/7 >= 6 - rowModulo )
741 addRow = mSelEndT/7 - 5 + rowModulo; 725 addRow = mSelEndT/7 - 5 + rowModulo;
742 } 726 }
743 if (selh > 1) { 727 if (selh > 1) {
744 p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); 728 p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol);
745 } 729 }
746 // draw last block from left to mSelEndT 730 // draw last block from left to mSelEndT
747 selw = mSelEndT-7*(mSelEndT/7)+1; 731 selw = mSelEndT-7*(mSelEndT/7)+1;
748 //qDebug("esl %d ",selw ); 732 //qDebug("esl %d ",selw );
749 int add = 0; 733 int add = 0;
750 if ( colModulo ) { 734 if ( colModulo ) {
751 add = 7 - colModulo; 735 add = 7 - colModulo;
752 if ( selw > add ) 736 if ( selw > add )
753 add = selw - add; 737 add = selw - add;
754 else 738 else
755 add = 0; 739 add = 0;
756 } 740 }
757 //qDebug("add %d ", add); 741 //qDebug("add %d ", add);
758 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, 742 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow,
759 selw*dwidth+add, dheight+1, selcol); 743 selw*dwidth+add, dheight+1, selcol);
760 } 744 }
761 } 745 }
762 } 746 }
763 747
764 // iterate over all days in the matrix and draw the day label in appropriate colors 748 // iterate over all days in the matrix and draw the day label in appropriate colors
765 QColor actcol = mDefaultTextColorShaded; 749 QColor actcol = mDefaultTextColorShaded;
766 p.setPen(actcol); 750 p.setPen(actcol);
767 QPen tmppen; 751 QPen tmppen;
768 for(int i = 0; i < NUMDAYS; i++) { 752 for(int i = 0; i < NUMDAYS; i++) {
769 row = i/7; 753 row = i/7;
770 col = isRTL ? 6-(i-row*7) : i-row*7; 754 col = isRTL ? 6-(i-row*7) : i-row*7;
771 755
772 // if it is the first day of a month switch color from normal to shaded and vice versa 756 // if it is the first day of a month switch color from normal to shaded and vice versa
773 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { 757 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
774 if (actcol == mDefaultTextColorShaded) { 758 if (actcol == mDefaultTextColorShaded) {
775 actcol = mDefaultTextColor; 759 actcol = mDefaultTextColor;
776 } else { 760 } else {
777 actcol = mDefaultTextColorShaded; 761 actcol = mDefaultTextColorShaded;
778 } 762 }
779 p.setPen(actcol); 763 p.setPen(actcol);
780 } 764 }
781 if (actcol == mDefaultTextColorShaded) { 765 if (actcol == mDefaultTextColorShaded) {
782 if ( ! mouseDown ) { 766 if ( ! mouseDown ) {
783 continue; 767 continue;
784 } 768 }
785 } 769 }
786 //Reset pen color after selected days block 770 //Reset pen color after selected days block
787 if (i == mSelEndT+1) { 771 if (i == mSelEndT+1) {
788 p.setPen(actcol); 772 p.setPen(actcol);
789 } 773 }
790 774
791 // if today then draw rectangle around day 775 // if today then draw rectangle around day
792 if (today == i) { 776 if (today == i) {
793 tmppen = p.pen(); 777 tmppen = p.pen();
794 QPen mTodayPen(p.pen()); 778 QPen mTodayPen(p.pen());
795 779 if ( daysize.width() < 20 )
796 mTodayPen.setWidth(mTodayMarginWidth); 780 mTodayPen.setWidth(1);
781 else
782 mTodayPen.setWidth(mTodayMarginWidth);
797 //draw red rectangle for holidays 783 //draw red rectangle for holidays
798 if (!mHolidays[i].isNull()) { 784 if (!mHolidays[i].isNull()) {
799 if (actcol == mDefaultTextColor) { 785 if (actcol == mDefaultTextColor) {
800 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); 786 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
801 } else { 787 } else {
802 mTodayPen.setColor(mHolidayColorShaded); 788 mTodayPen.setColor(mHolidayColorShaded);
803 } 789 }
804 } 790 }
805 //draw gray rectangle for today if in selection 791 //draw gray rectangle for today if in selection
806 if (i >= mSelStartT && i <= mSelEndT) { 792 if (i >= mSelStartT && i <= mSelEndT) {
807 QColor grey("grey"); 793 QColor grey("grey");
808 mTodayPen.setColor(grey); 794 mTodayPen.setColor(grey);
809 } 795 }
810 p.setPen(mTodayPen); 796 p.setPen(mTodayPen);
811 p.drawRect(col*dwidth, row*dheight, dwidth, dheight); 797
798
799 int addCol = 0;
800 int addRow = 0;
801 if (rowModulo) {
802 if ( row >= 6 - rowModulo )
803 addRow = row - 5 + rowModulo;
804 }
805 if ( colModulo ) {
806 if ( col >= 7 - colModulo )
807 addCol = col - 6 + colModulo-1;
808 }
809 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1);
812 p.setPen(tmppen); 810 p.setPen(tmppen);
813 } 811 }
814 812
815 // if any events are on that day then draw it using a bold font 813 // if any events are on that day then draw it using a bold font
816 if (events[i] > 0) { 814 if (events[i] > 0) {
817 QFont myFont = font(); 815 QFont myFont = font();
818 myFont.setBold(true); 816 myFont.setBold(true);
819 p.setFont(myFont); 817 p.setFont(myFont);
820 } 818 }
821 819
822 // if it is a holiday then use the default holiday color 820 // if it is a holiday then use the default holiday color
823 if (!mHolidays[i].isNull()) { 821 if (!mHolidays[i].isNull()) {
824 if ( bDays.testBit(i) ) { 822 if ( bDays.testBit(i) ) {
825 p.setPen(Qt::green); 823 p.setPen(Qt::green);
826 } else { 824 } else {
827 if (actcol == mDefaultTextColor) { 825 if (actcol == mDefaultTextColor) {
828 p.setPen(KOPrefs::instance()->mHolidayColor); 826 p.setPen(KOPrefs::instance()->mHolidayColor);
829 } else { 827 } else {
830 p.setPen(mHolidayColorShaded); 828 p.setPen(mHolidayColorShaded);
831 } 829 }
832 } 830 }
833 } 831 }
834 832
835 // draw selected days with special color 833 // draw selected days with special color
836 // DO NOT specially highlight holidays in selection ! 834 // DO NOT specially highlight holidays in selection !
837 if (i >= mSelStartT && i <= mSelEndT) { 835 if (i >= mSelStartT && i <= mSelEndT) {
838 ;//p.setPen(mSelectedDaysColor); 836 ;//p.setPen(mSelectedDaysColor);
839 } 837 }
840 838
841 int addCol = 0; 839 int addCol = 0;
842 int addRow = 0; 840 int addRow = 0;
843 if ( colModulo ) { 841 if ( colModulo ) {
844 if ( col >= 7 - colModulo ) 842 if ( col >= 7 - colModulo )
845 addCol = col - 7 + colModulo; 843 addCol = col - 7 + colModulo;
846 } 844 }
847 if ( rowModulo ) { 845 if ( rowModulo ) {
848 if ( row >= 6 - rowModulo ) 846 if ( row >= 6 - rowModulo )
849 addRow = row - 5 + rowModulo; 847 addRow = row - 5 + rowModulo;
850 } 848 }
851 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); 849 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow);
852 ++addCol;//++addCol; 850 ++addCol;//++addCol;
853 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, 851 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight,
854 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); 852 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
855 853
856 // reset color to actual color 854 // reset color to actual color
857 if (!mHolidays[i].isNull()) { 855 if (!mHolidays[i].isNull()) {
858 p.setPen(actcol); 856 p.setPen(actcol);
859 } 857 }
860 // reset bold font to plain font 858 // reset bold font to plain font
861 if (events[i] > 0) { 859 if (events[i] > 0) {
862 QFont myFont = font(); 860 QFont myFont = font();
863 myFont.setBold(false); 861 myFont.setBold(false);
864 p.setFont(myFont); 862 p.setFont(myFont);
865 } 863 }
866 } 864 }
867 int off = xyOff; 865 int off = xyOff;
868 bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP); 866 bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP);
869 //qDebug("ffffffffff %d ", off); 867 //qDebug("ffffffffff %d ", off);
870} 868}
871 869
872// ---------------------------------------------------------------------------- 870// ----------------------------------------------------------------------------
873// R E SI Z E E V E N T H A N D L I N G 871// R E SI Z E E V E N T H A N D L I N G
874// ---------------------------------------------------------------------------- 872// ----------------------------------------------------------------------------
875 873
876void KODayMatrix::resizeEvent(QResizeEvent *) 874void KODayMatrix::resizeEvent(QResizeEvent *)
877{ 875{
878 QRect sz = frameRect(); 876 QRect sz = frameRect();
879 daysize.setHeight(sz.height()*7 / NUMDAYS); 877 daysize.setHeight(sz.height()*7 / NUMDAYS);
880 daysize.setWidth(sz.width() / 7); 878 daysize.setWidth(sz.width() / 7);
881} 879}
882 880
883QSize KODayMatrix::sizeHint() const 881QSize KODayMatrix::sizeHint() const
884{ 882{
885 883
886 QFontMetrics fm ( font() ); 884 QFontMetrics fm ( font() );
887 int wid = fm.width( "30") *7+3; 885 int wid = fm.width( "30") *7+3;
888 int hei = fm.height() * 6+3; 886 int hei = fm.height() * 6+3;
889 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); 887 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei);
890 return QSize ( wid, hei ); 888 return QSize ( wid, hei );
891 889
892} 890}