-rw-r--r-- | korganizer/kodaymatrix.cpp | 14 |
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 | |||
@@ -429,35 +429,45 @@ const QDate& KODayMatrix::getDate(int offset) | |||
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 | ||
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 | 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 | ||
454 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 464 | void 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); |
@@ -629,33 +639,33 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) | |||
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(); |