From 1ebfa83d28d9eb3f48d8240e65212bbe22defb3c Mon Sep 17 00:00:00 2001 From: zautrix Date: Sun, 20 Mar 2005 01:37:34 +0000 Subject: fixes --- (limited to 'korganizer/kodaymatrix.cpp') diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 1cde616..619ae39 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp @@ -271,7 +271,11 @@ void KODayMatrix::addSelectedDaysTo(DateList& selDays) void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) { mSelStart = startdate.daysTo(start); + if ( mSelStart < 0 ) + mSelStart = 0; mSelEnd = startdate.daysTo(end); + if ( mSelEnd < 0 ) + clearSelection(); } void KODayMatrix::clearSelection() { @@ -638,32 +642,54 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) p.fillRect(pevent->rect(), mDefaultBackColor); p.setPen(mDefaultTextColor); p.drawRect(0, 0, sz.width()+1, sz.height()+1); - + int mSelStartT = mSelStart; + int mSelEndT = mSelEnd; + if ( mSelEndT >= NUMDAYS ) + mSelEndT = NUMDAYS-1; // draw selected days with highlighted background color if (mSelStart != NOSELECTION) { - - row = mSelStart/7; - col = mSelStart -row*7; + bool skip = false; + if ( ! mouseDown ) { + int mo = days[20].month(); + //qDebug("-- %d %d ", mSelStartT, mSelEndT); + //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); + if ( days[mSelStartT].month() > mo || days[mSelEndT].month() < mo ) { + skip = true; + } else { + if ( days[mSelStartT].month() != mo ) { + int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); + mSelStartT += add +1; + } + if ( days[mSelEndT].month() != mo ) { + int sub = days[mSelEndT].day(); + mSelEndT -= sub ; + } + } + } + if ( ! skip ) { + row = mSelStartT/7; + col = mSelStartT -row*7; QColor selcol = KOPrefs::instance()->mHighlightColor; - if (row == mSelEnd/7) { + if (row == mSelEndT/7) { // Single row selection - p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, - row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); + p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth, + row*dheight, (mSelEndT-mSelStartT+1)*dwidth, dheight, selcol); } else { // draw first row to the right p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, dheight, selcol); // draw full block till last line - selh = mSelEnd/7-row; + selh = mSelEndT/7-row; if (selh > 1) { p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); } - // draw last block from left to mSelEnd - selw = mSelEnd-7*(mSelEnd/7)+1; + // draw last block from left to mSelEndT + selw = mSelEndT-7*(mSelEndT/7)+1; p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, selw*dwidth, dheight, selcol); } + } } // iterate over all days in the matrix and draw the day label in appropriate colors @@ -683,9 +709,13 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) } p.setPen(actcol); } - + if (actcol == mDefaultTextColorShaded) { + if ( ! mouseDown ) { + continue; + } + } //Reset pen color after selected days block - if (i == mSelEnd+1) { + if (i == mSelEndT+1) { p.setPen(actcol); } @@ -704,7 +734,7 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) } } //draw gray rectangle for today if in selection - if (i >= mSelStart && i <= mSelEnd) { + if (i >= mSelStartT && i <= mSelEndT) { QColor grey("grey"); mTodayPen.setColor(grey); } @@ -735,7 +765,7 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) // draw selected days with special color // DO NOT specially highlight holidays in selection ! - if (i >= mSelStart && i <= mSelEnd) { + if (i >= mSelStartT && i <= mSelEndT) { ;//p.setPen(mSelectedDaysColor); } -- cgit v0.9.0.2