summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp89
-rw-r--r--korganizer/kodaymatrix.h2
2 files changed, 76 insertions, 15 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 9181936..15a1cb4 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -619,23 +619,29 @@ void KODayMatrix::dropEvent(QDropEvent *e)
619 619
620void KODayMatrix::paintEvent(QPaintEvent * pevent) 620void 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
@@ -671,23 +677,64 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
671 col = mSelStartT -row*7; 677 col = mSelStartT -row*7;
672 QColor selcol = KOPrefs::instance()->mHighlightColor; 678 QColor selcol = KOPrefs::instance()->mHighlightColor;
673 679
680
681
682 int addCol = 0;
683 int addRow = 0;
684#if 0
685 if ( colModulo ) {
686 if ( col >= 7 - colModulo )
687 addCol = col - 7 + colModulo;
688 }
689 if ( rowModulo ) {
690 if ( row >= 6 - rowModulo )
691 addRow = row - 5 + rowModulo;
692 }
693#endif
694
695
696
697
698
674 if (row == mSelEndT/7) { 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 }
675 // Single row selection 708 // Single row selection
676 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth, 709 if ( row == 0)
677 row*dheight, (mSelEndT-mSelStartT+1)*dwidth, dheight, selcol); 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);
678 } else { 713 } else {
679 // draw first row to the right 714 // draw first row to the right
680 p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, 715 if ( row == 0)
716 addRow = 1;
717 p.fillRect(isRTL ? 0 : col*dwidth+1, row*dheight+addRow, (7-col)*dwidth+colModulo,
681 dheight, selcol); 718 dheight, selcol);
682 // draw full block till last line 719 // draw full block till last line
683 selh = mSelEndT/7-row; 720 selh = mSelEndT/7-row;
684 if (selh > 1) { 721 if (selh > 1) {
685 p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); 722 p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight,selcol);
686 } 723 }
687 // draw last block from left to mSelEndT 724 // draw last block from left to mSelEndT
688 selw = mSelEndT-7*(mSelEndT/7)+1; 725 selw = mSelEndT-7*(mSelEndT/7)+1;
689 p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, 726 //qDebug("esl %d ",selw );
690 selw*dwidth, dheight, selcol); 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);
691 } 738 }
692 } 739 }
693 } 740 }
@@ -769,7 +816,19 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
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
@@ -783,7 +842,9 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
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// ----------------------------------------------------------------------------
@@ -801,8 +862,8 @@ 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
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
index 39946de..f4016b6 100644
--- a/korganizer/kodaymatrix.h
+++ b/korganizer/kodaymatrix.h
@@ -171,7 +171,7 @@ public:
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);}
175public slots: 175public 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).