summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index f864022..ae0a051 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -349,195 +349,205 @@ void KODayMatrix::updateViewTimed()
349 !holiStr.isEmpty()) { 349 !holiStr.isEmpty()) {
350 mHolidays[i] = holiStr; 350 mHolidays[i] = holiStr;
351 } else { 351 } else {
352 mHolidays[i] = QString::null; 352 mHolidays[i] = QString::null;
353 } 353 }
354 } 354 }
355 if ( ! mPendingUpdateBeforeRepaint ) 355 if ( ! mPendingUpdateBeforeRepaint )
356 repaint(false); 356 repaint(false);
357} 357}
358void KODayMatrix::updateView(QDate actdate) 358void KODayMatrix::updateView(QDate actdate)
359{ 359{
360 360
361 if ( ! actdate.isValid() ) { 361 if ( ! actdate.isValid() ) {
362 //qDebug("date not valid "); 362 //qDebug("date not valid ");
363 return; 363 return;
364 } 364 }
365 mDayChanged = false; 365 mDayChanged = false;
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 int colModulo = (width()-2) % 7;
447 int rowModulo = (height()-2) % 6;
448#if 0
446 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? 449 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ?
447 6 - x/daysize.width() : x/daysize.width()); 450 6 - x/daysize.width() : x/daysize.width());
451#endif
452 int xVal = (x-colModulo/2-2)/daysize.width();
453 int yVal = (y-rowModulo/2-2)/daysize.height();
454
455
456 return 7*(yVal) + xVal;
457
448} 458}
449 459
450// ---------------------------------------------------------------------------- 460// ----------------------------------------------------------------------------
451// M O U S E E V E N T H A N D L I N G 461// M O U S E E V E N T H A N D L I N G
452// ---------------------------------------------------------------------------- 462// ----------------------------------------------------------------------------
453 463
454void KODayMatrix::mousePressEvent (QMouseEvent* e) 464void KODayMatrix::mousePressEvent (QMouseEvent* e)
455{ 465{
456 466
457 if ( e->button() == LeftButton ) 467 if ( e->button() == LeftButton )
458 mouseDown = true; 468 mouseDown = true;
459 mSelStart = getDayIndexFrom(e->x(), e->y()); 469 mSelStart = getDayIndexFrom(e->x(), e->y());
460 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; 470 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1;
461 mSelInit = mSelStart; 471 mSelInit = mSelStart;
462 mSelEnd = mSelStart; 472 mSelEnd = mSelStart;
463 repaint(false); 473 repaint(false);
464} 474}
465 475
466void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) 476void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
467{ 477{
468 if ( e->button() == LeftButton ) 478 if ( e->button() == LeftButton )
469 if ( ! mouseDown ) { 479 if ( ! mouseDown ) {
470 return; 480 return;
471 } 481 }
472 else 482 else
473 mouseDown = false; 483 mouseDown = false;
474 int tmp = getDayIndexFrom(e->x(), e->y()); 484 int tmp = getDayIndexFrom(e->x(), e->y());
475 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 485 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
476 486
477 if (mSelInit > tmp) { 487 if (mSelInit > tmp) {
478 mSelEnd = mSelInit; 488 mSelEnd = mSelInit;
479 if (tmp != mSelStart) { 489 if (tmp != mSelStart) {
480 mSelStart = tmp; 490 mSelStart = tmp;
481 repaint(false); 491 repaint(false);
482 } 492 }
483 } else { 493 } else {
484 mSelStart = mSelInit; 494 mSelStart = mSelInit;
485 495
486 //repaint only if selection has changed 496 //repaint only if selection has changed
487 if (tmp != mSelEnd) { 497 if (tmp != mSelEnd) {
488 mSelEnd = tmp; 498 mSelEnd = tmp;
489 repaint(false); 499 repaint(false);
490 } 500 }
491 } 501 }
492 502
493 DateList daylist; 503 DateList daylist;
494 if ( mSelStart < 0 ) 504 if ( mSelStart < 0 )
495 mSelStart = 0; 505 mSelStart = 0;
496 for (int i = mSelStart; i <= mSelEnd; i++) { 506 for (int i = mSelStart; i <= mSelEnd; i++) {
497 daylist.append(days[i]); 507 daylist.append(days[i]);
498 } 508 }
499 emit selected((const DateList)daylist); 509 emit selected((const DateList)daylist);
500 510
501} 511}
502 512
503void KODayMatrix::mouseMoveEvent (QMouseEvent* e) 513void KODayMatrix::mouseMoveEvent (QMouseEvent* e)
504{ 514{
505 if ( ! mouseDown ) { 515 if ( ! mouseDown ) {
506 return; 516 return;
507 } 517 }
508 int tmp = getDayIndexFrom(e->x(), e->y()); 518 int tmp = getDayIndexFrom(e->x(), e->y());
509 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 519 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
510 520
511 if (mSelInit > tmp) { 521 if (mSelInit > tmp) {
512 mSelEnd = mSelInit; 522 mSelEnd = mSelInit;
513 if (tmp != mSelStart) { 523 if (tmp != mSelStart) {
514 mSelStart = tmp; 524 mSelStart = tmp;
515 repaint(false); 525 repaint(false);
516 } 526 }
517 } else { 527 } else {
518 mSelStart = mSelInit; 528 mSelStart = mSelInit;
519 529
520 //repaint only if selection has changed 530 //repaint only if selection has changed
521 if (tmp != mSelEnd) { 531 if (tmp != mSelEnd) {
522 mSelEnd = tmp; 532 mSelEnd = tmp;
523 repaint(false); 533 repaint(false);
524 } 534 }
525 } 535 }
526} 536}
527 537
528// ---------------------------------------------------------------------------- 538// ----------------------------------------------------------------------------
529// D R A G ' N D R O P H A N D L I N G 539// D R A G ' N D R O P H A N D L I N G
530// ---------------------------------------------------------------------------- 540// ----------------------------------------------------------------------------
531 541
532void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) 542void KODayMatrix::dragEnterEvent(QDragEnterEvent *e)
533{ 543{
534#ifndef KORG_NODND 544#ifndef KORG_NODND
535 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 545 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
536 e->ignore(); 546 e->ignore();
537 return; 547 return;
538 } 548 }
539 549
540 // some visual feedback 550 // some visual feedback
541// oldPalette = palette(); 551// oldPalette = palette();
542// setPalette(my_HilitePalette); 552// setPalette(my_HilitePalette);
543// update(); 553// update();
@@ -549,193 +559,193 @@ void KODayMatrix::dragMoveEvent(QDragMoveEvent *e)
549#ifndef KORG_NODND 559#ifndef KORG_NODND
550 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 560 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
551 e->ignore(); 561 e->ignore();
552 return; 562 return;
553 } 563 }
554 564
555 e->accept(); 565 e->accept();
556#endif 566#endif
557} 567}
558 568
559void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) 569void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/)
560{ 570{
561#ifndef KORG_NODND 571#ifndef KORG_NODND
562// setPalette(oldPalette); 572// setPalette(oldPalette);
563// update(); 573// update();
564#endif 574#endif
565} 575}
566 576
567void KODayMatrix::dropEvent(QDropEvent *e) 577void KODayMatrix::dropEvent(QDropEvent *e)
568{ 578{
569#ifndef KORG_NODND 579#ifndef KORG_NODND
570// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; 580// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl;
571 581
572 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 582 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
573 e->ignore(); 583 e->ignore();
574 return; 584 return;
575 } 585 }
576 586
577 DndFactory factory( mCalendar ); 587 DndFactory factory( mCalendar );
578 Event *event = factory.createDrop(e); 588 Event *event = factory.createDrop(e);
579 589
580 if (event) { 590 if (event) {
581 e->acceptAction(); 591 e->acceptAction();
582 592
583 Event *existingEvent = mCalendar->event(event->uid()); 593 Event *existingEvent = mCalendar->event(event->uid());
584 594
585 if(existingEvent) { 595 if(existingEvent) {
586 // uniquify event 596 // uniquify event
587 event->recreate(); 597 event->recreate();
588/* 598/*
589 KMessageBox::sorry(this, 599 KMessageBox::sorry(this,
590 i18n("Event already exists in this calendar."), 600 i18n("Event already exists in this calendar."),
591 i18n("Drop Event")); 601 i18n("Drop Event"));
592 delete event; 602 delete event;
593 return; 603 return;
594*/ 604*/
595 } 605 }
596// kdDebug() << "Drop new Event" << endl; 606// kdDebug() << "Drop new Event" << endl;
597 // Adjust date 607 // Adjust date
598 QDateTime start = event->dtStart(); 608 QDateTime start = event->dtStart();
599 QDateTime end = event->dtEnd(); 609 QDateTime end = event->dtEnd();
600 int duration = start.daysTo(end); 610 int duration = start.daysTo(end);
601 int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); 611 int idx = getDayIndexFrom(e->pos().x(), e->pos().y());
602 612
603 start.setDate(days[idx]); 613 start.setDate(days[idx]);
604 end.setDate(days[idx].addDays(duration)); 614 end.setDate(days[idx].addDays(duration));
605 615
606 event->setDtStart(start); 616 event->setDtStart(start);
607 event->setDtEnd(end); 617 event->setDtEnd(end);
608 mCalendar->addEvent(event); 618 mCalendar->addEvent(event);
609 619
610 emit eventDropped(event); 620 emit eventDropped(event);
611 } else { 621 } else {
612// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; 622// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
613 e->ignore(); 623 e->ignore();
614 } 624 }
615#endif 625#endif
616} 626}
617 627
618// ---------------------------------------------------------------------------- 628// ----------------------------------------------------------------------------
619// P A I N T E V E N T H A N D L I N G 629// P A I N T E V E N T H A N D L I N G
620// ---------------------------------------------------------------------------- 630// ----------------------------------------------------------------------------
621 631
622void KODayMatrix::paintEvent(QPaintEvent * pevent) 632void KODayMatrix::paintEvent(QPaintEvent * pevent)
623{ 633{
624 QRect sz = frameRect(); 634 QRect sz = frameRect();
625 if ( sz.width() <= 0 || sz.height() <= 0 ) 635 if ( sz.width() <= 0 || sz.height() <= 0 )
626 return; 636 return;
627 if ( mPendingUpdateBeforeRepaint ) { 637 if ( mPendingUpdateBeforeRepaint ) {
628 updateViewTimed(); 638 updateViewTimed();
629 mPendingUpdateBeforeRepaint = false; 639 mPendingUpdateBeforeRepaint = false;
630 } 640 }
631 if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) { 641 if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) {
632 myPix.resize(sz.size() ); 642 myPix.resize(sz.size() );
633 } 643 }
634 QPainter p(&myPix); 644 QPainter p(&myPix);
635 p.setFont(font()); 645 p.setFont(font());
636 646
637 647
638 int dheight = daysize.height(); 648 int dheight = daysize.height();
639 int dwidth = daysize.width(); 649 int dwidth = daysize.width();
640 int row,col; 650 int row,col;
641 int selw, selh; 651 int selw, selh;
642 int xyOff = frameWidth(); 652 int xyOff = frameWidth();
643 int colModulo = sz.width() % 7; 653 int colModulo = sz.width() % 7;
644 int rowModulo = sz.height() % 6; 654 int rowModulo = sz.height() % 6;
645 qDebug("col %d row %d ",colModulo,rowModulo ); 655 //qDebug("col %d row %d ",colModulo,rowModulo );
646 656
647 bool isRTL = KOGlobals::self()->reverseLayout(); 657 bool isRTL = KOGlobals::self()->reverseLayout();
648 658
649 // draw background and topleft frame 659 // draw background and topleft frame
650 p.fillRect(pevent->rect(), mDefaultBackColor); 660 p.fillRect(pevent->rect(), mDefaultBackColor);
651 p.setPen(mDefaultTextColor); 661 p.setPen(mDefaultTextColor);
652 p.drawRect(0, 0, sz.width()+1, sz.height()+1); 662 p.drawRect(0, 0, sz.width()+1, sz.height()+1);
653 int mSelStartT = mSelStart; 663 int mSelStartT = mSelStart;
654 int mSelEndT = mSelEnd; 664 int mSelEndT = mSelEnd;
655 if ( mSelEndT >= NUMDAYS ) 665 if ( mSelEndT >= NUMDAYS )
656 mSelEndT = NUMDAYS-1; 666 mSelEndT = NUMDAYS-1;
657 // draw selected days with highlighted background color 667 // draw selected days with highlighted background color
658 if (mSelStart != NOSELECTION) { 668 if (mSelStart != NOSELECTION) {
659 bool skip = false; 669 bool skip = false;
660 if ( ! mouseDown ) { 670 if ( ! mouseDown ) {
661 int mo = days[20].month(); 671 int mo = days[20].month();
662 //qDebug("-- %d %d ", mSelStartT, mSelEndT); 672 //qDebug("-- %d %d ", mSelStartT, mSelEndT);
663 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); 673 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() );
664 if ( days[mSelStartT].month() > mo || days[mSelEndT].month() < mo ) { 674 if ( days[mSelStartT].month() > mo || days[mSelEndT].month() < mo ) {
665 skip = true; 675 skip = true;
666 } else { 676 } else {
667 if ( days[mSelStartT].month() != mo ) { 677 if ( days[mSelStartT].month() != mo ) {
668 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); 678 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day();
669 mSelStartT += add +1; 679 mSelStartT += add +1;
670 } 680 }
671 if ( days[mSelEndT].month() != mo ) { 681 if ( days[mSelEndT].month() != mo ) {
672 int sub = days[mSelEndT].day(); 682 int sub = days[mSelEndT].day();
673 mSelEndT -= sub ; 683 mSelEndT -= sub ;
674 } 684 }
675 } 685 }
676 } 686 }
677 if ( ! skip ) { 687 if ( ! skip ) {
678 row = mSelStartT/7; 688 row = mSelStartT/7;
679 col = mSelStartT -row*7; 689 col = mSelStartT -row*7;
680 QColor selcol = KOPrefs::instance()->mHighlightColor; 690 QColor selcol = KOPrefs::instance()->mHighlightColor;
681 int addCol = 0; 691 int addCol = 0;
682 int addRow = 0; 692 int addRow = 0;
683 int addRow2 = 0; 693 int addRow2 = 0;
684 int addCol2 = 0; 694 int addCol2 = 0;
685 if (row == mSelEndT/7) { 695 if (row == mSelEndT/7) {
686 if ( rowModulo ) { 696 if ( rowModulo ) {
687 if ( row >= 6 - rowModulo ) 697 if ( row >= 6 - rowModulo )
688 addRow = row - 5 + rowModulo; 698 addRow = row - 5 + rowModulo;
689 } 699 }
690 if ( colModulo ) { 700 if ( colModulo ) {
691 int colt1 = mSelEndT%7; 701 int colt1 = mSelEndT%7;
692 //qDebug("colt1 %d ", colt1 ); 702 //qDebug("colt1 %d ", colt1 );
693 if ( colt1 >= 7 - colModulo ) 703 if ( colt1 >= 7 - colModulo )
694 addCol = colt1 - 7 + colModulo+1; 704 addCol = colt1 - 7 + colModulo+1;
695 int colt = mSelStartT%7; 705 int colt = mSelStartT%7;
696 if ( colt >= 7 - colModulo ) 706 if ( colt >= 7 - colModulo )
697 addCol2 = colt - 7 + colModulo; 707 addCol2 = colt - 7 + colModulo;
698 addCol -= addCol2; 708 addCol -= addCol2;
699 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); 709 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 );
700 } 710 }
701 // Single row selection 711 // Single row selection
702 if ( row == 0) 712 if ( row == 0)
703 addRow = 1; 713 addRow = 1;
704 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, 714 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2,
705 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); 715 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol);
706 } else { 716 } else {
707 // draw first row to the right 717 // draw first row to the right
708 if ( colModulo ) { 718 if ( colModulo ) {
709 if ( col >= 7 - colModulo ) 719 if ( col >= 7 - colModulo )
710 addCol2 = col - 7 + colModulo; 720 addCol2 = col - 7 + colModulo;
711 } 721 }
712 if ( rowModulo ) { 722 if ( rowModulo ) {
713 if ( row >= 6 - rowModulo ) 723 if ( row >= 6 - rowModulo )
714 addRow = row - 5 + rowModulo; 724 addRow = row - 5 + rowModulo;
715 } 725 }
716 if ( row == 0) 726 if ( row == 0)
717 addRow = 1; 727 addRow = 1;
718 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, (7-col)*dwidth+colModulo, 728 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, (7-col)*dwidth+colModulo,
719 dheight+1, selcol); 729 dheight+1, selcol);
720 // draw full block till last line 730 // draw full block till last line
721 selh = mSelEndT/7-row; 731 selh = mSelEndT/7-row;
722 addRow = 0; 732 addRow = 0;
723 if ( rowModulo ) { 733 if ( rowModulo ) {
724 if ( mSelEndT/7 >= 6 - rowModulo ) 734 if ( mSelEndT/7 >= 6 - rowModulo )
725 addRow = mSelEndT/7 - 5 + rowModulo; 735 addRow = mSelEndT/7 - 5 + rowModulo;
726 } 736 }
727 if (selh > 1) { 737 if (selh > 1) {
728 p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); 738 p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol);
729 } 739 }
730 // draw last block from left to mSelEndT 740 // draw last block from left to mSelEndT
731 selw = mSelEndT-7*(mSelEndT/7)+1; 741 selw = mSelEndT-7*(mSelEndT/7)+1;
732 //qDebug("esl %d ",selw ); 742 //qDebug("esl %d ",selw );
733 int add = 0; 743 int add = 0;
734 if ( colModulo ) { 744 if ( colModulo ) {
735 add = 7 - colModulo; 745 add = 7 - colModulo;
736 if ( selw > add ) 746 if ( selw > add )
737 add = selw - add; 747 add = selw - add;
738 else 748 else
739 add = 0; 749 add = 0;
740 } 750 }
741 //qDebug("add %d ", add); 751 //qDebug("add %d ", add);