summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp42
1 files changed, 32 insertions, 10 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 15a1cb4..507f18e 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -619,143 +619,165 @@ void KODayMatrix::dropEvent(QDropEvent *e)
619 619
620void KODayMatrix::paintEvent(QPaintEvent * pevent) 620void KODayMatrix::paintEvent(QPaintEvent * pevent)
621{ 621{
622 QRect sz = frameRect(); 622 QRect sz = frameRect();
623 if ( sz.width() <= 0 || sz.height() <= 0 ) 623 if ( sz.width() <= 0 || sz.height() <= 0 )
624 return; 624 return;
625 if ( mPendingUpdateBeforeRepaint ) { 625 if ( mPendingUpdateBeforeRepaint ) {
626 updateViewTimed(); 626 updateViewTimed();
627 mPendingUpdateBeforeRepaint = false; 627 mPendingUpdateBeforeRepaint = false;
628 } 628 }
629 if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) { 629 if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) {
630 myPix.resize(sz.size() ); 630 myPix.resize(sz.size() );
631 } 631 }
632 QPainter p(&myPix); 632 QPainter p(&myPix);
633 p.setFont(font()); 633 p.setFont(font());
634 634
635 635
636 int dheight = daysize.height(); 636 int dheight = daysize.height();
637 int dwidth = daysize.width(); 637 int dwidth = daysize.width();
638 int row,col; 638 int row,col;
639 int selw, selh; 639 int selw, selh;
640 int xyOff = frameWidth(); 640 int xyOff = frameWidth();
641 int colModulo = sz.width() % 7; 641 int colModulo = sz.width() % 7;
642 int rowModulo = sz.height() % 6; 642 int rowModulo = sz.height() % 6;
643 qDebug("off %d col %d row %d ",xyOff,colModulo,rowModulo ); 643 //qDebug("off %d col %d row %d ",xyOff,colModulo,rowModulo );
644 644
645 bool isRTL = KOGlobals::self()->reverseLayout(); 645 bool isRTL = KOGlobals::self()->reverseLayout();
646 646
647 // draw background and topleft frame 647 // draw background and topleft frame
648 p.fillRect(pevent->rect(), mDefaultBackColor); 648 p.fillRect(pevent->rect(), mDefaultBackColor);
649 p.setPen(mDefaultTextColor); 649 p.setPen(mDefaultTextColor);
650 p.drawRect(0, 0, sz.width()+1, sz.height()+1); 650 p.drawRect(0, 0, sz.width()+1, sz.height()+1);
651 int mSelStartT = mSelStart; 651 int mSelStartT = mSelStart;
652 int mSelEndT = mSelEnd; 652 int mSelEndT = mSelEnd;
653 if ( mSelEndT >= NUMDAYS ) 653 if ( mSelEndT >= NUMDAYS )
654 mSelEndT = NUMDAYS-1; 654 mSelEndT = NUMDAYS-1;
655 // draw selected days with highlighted background color 655 // draw selected days with highlighted background color
656 if (mSelStart != NOSELECTION) { 656 if (mSelStart != NOSELECTION) {
657 bool skip = false; 657 bool skip = false;
658 if ( ! mouseDown ) { 658 if ( ! mouseDown ) {
659 int mo = days[20].month(); 659 int mo = days[20].month();
660 //qDebug("-- %d %d ", mSelStartT, mSelEndT); 660 //qDebug("-- %d %d ", mSelStartT, mSelEndT);
661 //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() );
662 if ( days[mSelStartT].month() > mo || days[mSelEndT].month() < mo ) { 662 if ( days[mSelStartT].month() > mo || days[mSelEndT].month() < mo ) {
663 skip = true; 663 skip = true;
664 } else { 664 } else {
665 if ( days[mSelStartT].month() != mo ) { 665 if ( days[mSelStartT].month() != mo ) {
666 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); 666 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day();
667 mSelStartT += add +1; 667 mSelStartT += add +1;
668 } 668 }
669 if ( days[mSelEndT].month() != mo ) { 669 if ( days[mSelEndT].month() != mo ) {
670 int sub = days[mSelEndT].day(); 670 int sub = days[mSelEndT].day();
671 mSelEndT -= sub ; 671 mSelEndT -= sub ;
672 } 672 }
673 } 673 }
674 } 674 }
675 if ( ! skip ) { 675 if ( ! skip ) {
676 row = mSelStartT/7; 676 row = mSelStartT/7;
677 col = mSelStartT -row*7; 677 col = mSelStartT -row*7;
678 QColor selcol = KOPrefs::instance()->mHighlightColor; 678 QColor selcol = KOPrefs::instance()->mHighlightColor;
679 679
680 680
681 681
682 int addCol = 0; 682 int addCol = 0;
683 int addRow = 0; 683 int addRow = 0;
684 int addRow2 = 0;
685 int addCol2 = 0;
684#if 0 686#if 0
685 if ( colModulo ) { 687 if ( colModulo ) {
686 if ( col >= 7 - colModulo ) 688 if ( col >= 7 - colModulo )
687 addCol = col - 7 + colModulo; 689 addCol = col - 7 + colModulo;
688 } 690 }
689 if ( rowModulo ) { 691 if ( rowModulo ) {
690 if ( row >= 6 - rowModulo ) 692 if ( row >= 6 - rowModulo )
691 addRow = row - 5 + rowModulo; 693 addRow = row - 5 + rowModulo;
692 } 694 }
693#endif 695#endif
694 696
695 697
696 698
697 699
698 700
699 if (row == mSelEndT/7) { 701 if (row == mSelEndT/7) {
700 if ( rowModulo ) { 702 if ( rowModulo ) {
701 if ( row >= 6 - rowModulo ) 703 if ( row >= 6 - rowModulo )
702 addRow = row - 5 + rowModulo; 704 addRow = row - 5 + rowModulo;
703 } 705 }
704 if ( colModulo ) { 706 if ( colModulo ) {
705 if ( mSelEndT-mSelStartT+1 >= 7 - colModulo ) 707 int colt1 = mSelEndT%7;
706 addCol = mSelEndT-mSelStartT+1 - 7 + colModulo; 708 //qDebug("colt1 %d ", colt1 );
709 if ( colt1 >= 7 - colModulo )
710 addCol = colt1 - 7 + colModulo+1;
711 int colt = mSelStartT%7;
712 if ( colt >= 7 - colModulo )
713 addCol2 = colt - 7 + colModulo;
714 addCol -= addCol2;
715 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 );
707 } 716 }
708 // Single row selection 717 // Single row selection
709 if ( row == 0) 718 if ( row == 0)
710 addRow = 1; 719 addRow = 1;
711 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1, 720 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2,
712 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); 721 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol);
713 } else { 722 } else {
714 // draw first row to the right 723 // draw first row to the right
724 if ( colModulo ) {
725 if ( col >= 7 - colModulo )
726 addCol2 = col - 7 + colModulo;
727 }
728 if ( rowModulo ) {
729 if ( row >= 6 - rowModulo )
730 addRow = row - 5 + rowModulo;
731 }
715 if ( row == 0) 732 if ( row == 0)
716 addRow = 1; 733 addRow = 1;
717 p.fillRect(isRTL ? 0 : col*dwidth+1, row*dheight+addRow, (7-col)*dwidth+colModulo, 734 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, (7-col)*dwidth+colModulo,
718 dheight, selcol); 735 dheight+1, selcol);
719 // draw full block till last line 736 // draw full block till last line
720 selh = mSelEndT/7-row; 737 selh = mSelEndT/7-row;
738 addRow = 0;
739 if ( rowModulo ) {
740 if ( mSelEndT/7 >= 6 - rowModulo )
741 addRow = mSelEndT/7 - 5 + rowModulo;
742 }
721 if (selh > 1) { 743 if (selh > 1) {
722 p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight,selcol); 744 p.fillRect(1, (row+1)*dheight, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol);
723 } 745 }
724 // draw last block from left to mSelEndT 746 // draw last block from left to mSelEndT
725 selw = mSelEndT-7*(mSelEndT/7)+1; 747 selw = mSelEndT-7*(mSelEndT/7)+1;
726 //qDebug("esl %d ",selw ); 748 //qDebug("esl %d ",selw );
727 int add = 0; 749 int add = 0;
728 if ( colModulo ) { 750 if ( colModulo ) {
729 add = 7 - colModulo; 751 add = 7 - colModulo;
730 if ( selw > add ) 752 if ( selw > add )
731 add = selw - add; 753 add = selw - add;
732 else 754 else
733 add = 0; 755 add = 0;
734 } 756 }
735 //qDebug("add %d ", add); 757 //qDebug("add %d ", add);
736 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight, 758 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow,
737 selw*dwidth+add, dheight, selcol); 759 selw*dwidth+add, dheight+1, selcol);
738 } 760 }
739 } 761 }
740 } 762 }
741 763
742 // iterate over all days in the matrix and draw the day label in appropriate colors 764 // iterate over all days in the matrix and draw the day label in appropriate colors
743 QColor actcol = mDefaultTextColorShaded; 765 QColor actcol = mDefaultTextColorShaded;
744 p.setPen(actcol); 766 p.setPen(actcol);
745 QPen tmppen; 767 QPen tmppen;
746 for(int i = 0; i < NUMDAYS; i++) { 768 for(int i = 0; i < NUMDAYS; i++) {
747 row = i/7; 769 row = i/7;
748 col = isRTL ? 6-(i-row*7) : i-row*7; 770 col = isRTL ? 6-(i-row*7) : i-row*7;
749 771
750 // if it is the first day of a month switch color from normal to shaded and vice versa 772 // if it is the first day of a month switch color from normal to shaded and vice versa
751 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { 773 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
752 if (actcol == mDefaultTextColorShaded) { 774 if (actcol == mDefaultTextColorShaded) {
753 actcol = mDefaultTextColor; 775 actcol = mDefaultTextColor;
754 } else { 776 } else {
755 actcol = mDefaultTextColorShaded; 777 actcol = mDefaultTextColorShaded;
756 } 778 }
757 p.setPen(actcol); 779 p.setPen(actcol);
758 } 780 }
759 if (actcol == mDefaultTextColorShaded) { 781 if (actcol == mDefaultTextColorShaded) {
760 if ( ! mouseDown ) { 782 if ( ! mouseDown ) {
761 continue; 783 continue;
@@ -806,49 +828,49 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
806 p.setPen(KOPrefs::instance()->mHolidayColor); 828 p.setPen(KOPrefs::instance()->mHolidayColor);
807 } else { 829 } else {
808 p.setPen(mHolidayColorShaded); 830 p.setPen(mHolidayColorShaded);
809 } 831 }
810 } 832 }
811 } 833 }
812 834
813 // draw selected days with special color 835 // draw selected days with special color
814 // DO NOT specially highlight holidays in selection ! 836 // DO NOT specially highlight holidays in selection !
815 if (i >= mSelStartT && i <= mSelEndT) { 837 if (i >= mSelStartT && i <= mSelEndT) {
816 ;//p.setPen(mSelectedDaysColor); 838 ;//p.setPen(mSelectedDaysColor);
817 } 839 }
818 840
819 int addCol = 0; 841 int addCol = 0;
820 int addRow = 0; 842 int addRow = 0;
821 if ( colModulo ) { 843 if ( colModulo ) {
822 if ( col >= 7 - colModulo ) 844 if ( col >= 7 - colModulo )
823 addCol = col - 7 + colModulo; 845 addCol = col - 7 + colModulo;
824 } 846 }
825 if ( rowModulo ) { 847 if ( rowModulo ) {
826 if ( row >= 6 - rowModulo ) 848 if ( row >= 6 - rowModulo )
827 addRow = row - 5 + rowModulo; 849 addRow = row - 5 + rowModulo;
828 } 850 }
829 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); 851 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow);
830 ++addCol;++addCol; 852 ++addCol;//++addCol;
831 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, 853 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight,
832 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); 854 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
833 855
834 // reset color to actual color 856 // reset color to actual color
835 if (!mHolidays[i].isNull()) { 857 if (!mHolidays[i].isNull()) {
836 p.setPen(actcol); 858 p.setPen(actcol);
837 } 859 }
838 // reset bold font to plain font 860 // reset bold font to plain font
839 if (events[i] > 0) { 861 if (events[i] > 0) {
840 QFont myFont = font(); 862 QFont myFont = font();
841 myFont.setBold(false); 863 myFont.setBold(false);
842 p.setFont(myFont); 864 p.setFont(myFont);
843 } 865 }
844 } 866 }
845 int off = xyOff; 867 int off = xyOff;
846 bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP); 868 bitBlt (this, off, off, &myPix, 0 ,0,width(), height() ,CopyROP);
847 //qDebug("ffffffffff %d ", off); 869 //qDebug("ffffffffff %d ", off);
848} 870}
849 871
850// ---------------------------------------------------------------------------- 872// ----------------------------------------------------------------------------
851// R E SI Z E E V E N T H A N D L I N G 873// R E SI Z E E V E N T H A N D L I N G
852// ---------------------------------------------------------------------------- 874// ----------------------------------------------------------------------------
853 875
854void KODayMatrix::resizeEvent(QResizeEvent *) 876void KODayMatrix::resizeEvent(QResizeEvent *)