-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 2 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 58 |
2 files changed, 45 insertions, 15 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index d09f484..b9bd1b9 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp @@ -139,17 +139,17 @@ void DateNavigatorContainer::setBaseDates() KCal::DateList dateList = mNavigatorView->selectedDates(); if ( dateList.isEmpty() ) { kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; } QDate baseDate = dateList.first(); KDateNavigator *n; bool doRepaint = false; // skip first repaint for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { - baseDate = baseDate.addDays( baseDate.daysInMonth () ); + baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); n->setBaseDate( baseDate, doRepaint ); doRepaint = true; } } void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) { #if 0 diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 1cde616..619ae39 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp @@ -266,17 +266,21 @@ void KODayMatrix::addSelectedDaysTo(DateList& selDays) selDays.append(days[i]); } } } 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() { mSelEnd = mSelStart = NOSELECTION; } void KODayMatrix::recalculateToday() @@ -633,42 +637,64 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) int row,col; int selw, selh; bool isRTL = KOGlobals::self()->reverseLayout(); // draw background and topleft frame 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 QColor actcol = mDefaultTextColorShaded; p.setPen(actcol); QPen tmppen; for(int i = 0; i < NUMDAYS; i++) { row = i/7; @@ -678,19 +704,23 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { if (actcol == mDefaultTextColorShaded) { actcol = mDefaultTextColor; } else { actcol = mDefaultTextColorShaded; } 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); } // if today then draw rectangle around day if (today == i) { tmppen = p.pen(); QPen mTodayPen(p.pen()); @@ -699,17 +729,17 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) if (!mHolidays[i].isNull()) { if (actcol == mDefaultTextColor) { mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); } else { mTodayPen.setColor(mHolidayColorShaded); } } //draw gray rectangle for today if in selection - if (i >= mSelStart && i <= mSelEnd) { + if (i >= mSelStartT && i <= mSelEndT) { QColor grey("grey"); mTodayPen.setColor(grey); } p.setPen(mTodayPen); p.drawRect(col*dwidth, row*dheight, dwidth, dheight); p.setPen(tmppen); } @@ -730,17 +760,17 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) } else { p.setPen(mHolidayColorShaded); } } } // 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); } p.drawText(col*dwidth, row*dheight, dwidth, dheight, Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); // reset color to actual color if (!mHolidays[i].isNull()) { |