-rw-r--r-- | korganizer/kodaymatrix.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index a2e0ae0..3ee1fa7 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp @@ -275,33 +275,40 @@ void KODayMatrix::addSelectedDaysTo(DateList& selDays) for (int i = NUMDAYS; i < mSelEnd; i++) { selDays.append(days[0].addDays(i)); } // apply normal routine to selection being entirely within matrix limits } else { for (int i = i0; i <= mSelEnd; i++) { selDays.append(days[i]); } } } -void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) +bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) { + bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); mSelStart = startdate.daysTo(start); if ( mSelStart < 0 ) mSelStart = 0; mSelEnd = startdate.daysTo(end); - //qDebug("SELECTION %d %d ", mSelStart ,mSelEnd ); - if ( mSelEnd < 0 ) + if ( mSelEnd > NUMDAYS-1 ) + mSelEnd = NUMDAYS-1; + if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { clearSelection(); + if ( noSel ) + return false; + } + + return true; } void KODayMatrix::clearSelection() { mSelEnd = mSelStart = NOSELECTION; } void KODayMatrix::recalculateToday() { today = -1; for (int i=0; i<NUMDAYS; i++) { events[i] = 0; @@ -690,37 +697,40 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) if (mSelStart != NOSELECTION) { 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() ); int startMo = days[mSelStartT].month(); int endMo = days[mSelEndT].month(); if ( startMo == 12 && mo == 1 && endMo <= 2 ) startMo = 1; if ( endMo == 1 && mo == 12 ) endMo = 12; + if ( mo == 12 && startMo == 1 ) + startMo = 13; if ( (startMo > mo || endMo < 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 ; } } } + //qDebug("SKIP %d ", skip); if ( ! skip ) { row = mSelStartT/7; col = mSelStartT -row*7; QColor selcol = KOPrefs::instance()->mHighlightColor; int addCol = 0; int addRow = 0; int addRow2 = 0; int addCol2 = 0; if (row == mSelEndT/7) { if ( rowModulo ) { if ( row >= 6 - rowModulo ) addRow = row - 5 + rowModulo; |