author | zautrix <zautrix> | 2005-01-31 23:43:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-31 23:43:35 (UTC) |
commit | fce3fd8accec495a2deda6fe3cd55375fac46432 (patch) (unidiff) | |
tree | 24231254fa729b1b546f0475759fcba24455e1f5 /korganizer/kodaymatrix.cpp | |
parent | 336678d691a8c3346c92a4e561ac7938ed532003 (diff) | |
download | kdepimpi-fce3fd8accec495a2deda6fe3cd55375fac46432.zip kdepimpi-fce3fd8accec495a2deda6fe3cd55375fac46432.tar.gz kdepimpi-fce3fd8accec495a2deda6fe3cd55375fac46432.tar.bz2 |
mf
-rw-r--r-- | korganizer/kodaymatrix.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index ca896b5..549ef2a 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -167,173 +167,166 @@ void KODayMatrix::addSelectedDaysTo(DateList& selDays) | |||
167 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 167 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
168 | if (mSelEnd > NUMDAYS-1) { | 168 | if (mSelEnd > NUMDAYS-1) { |
169 | for (int i = i0; i <= NUMDAYS-1; i++) { | 169 | for (int i = i0; i <= NUMDAYS-1; i++) { |
170 | selDays.append(days[i]); | 170 | selDays.append(days[i]); |
171 | } | 171 | } |
172 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 172 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
173 | selDays.append(days[0].addDays(i)); | 173 | selDays.append(days[0].addDays(i)); |
174 | } | 174 | } |
175 | 175 | ||
176 | // apply normal routine to selection being entirely within matrix limits | 176 | // apply normal routine to selection being entirely within matrix limits |
177 | } else { | 177 | } else { |
178 | for (int i = i0; i <= mSelEnd; i++) { | 178 | for (int i = i0; i <= mSelEnd; i++) { |
179 | selDays.append(days[i]); | 179 | selDays.append(days[i]); |
180 | } | 180 | } |
181 | } | 181 | } |
182 | } | 182 | } |
183 | 183 | ||
184 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 184 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
185 | { | 185 | { |
186 | mSelStart = startdate.daysTo(start); | 186 | mSelStart = startdate.daysTo(start); |
187 | mSelEnd = startdate.daysTo(end); | 187 | mSelEnd = startdate.daysTo(end); |
188 | } | 188 | } |
189 | 189 | ||
190 | 190 | ||
191 | void KODayMatrix::recalculateToday() | 191 | void KODayMatrix::recalculateToday() |
192 | { | 192 | { |
193 | today = -1; | 193 | today = -1; |
194 | for (int i=0; i<NUMDAYS; i++) { | 194 | for (int i=0; i<NUMDAYS; i++) { |
195 | events[i] = 0; | 195 | events[i] = 0; |
196 | days[i] = startdate.addDays(i); | 196 | days[i] = startdate.addDays(i); |
197 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 197 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
198 | 198 | ||
199 | // if today is in the currently displayed month, hilight today | 199 | // if today is in the currently displayed month, hilight today |
200 | if (days[i].year() == QDate::currentDate().year() && | 200 | if (days[i].year() == QDate::currentDate().year() && |
201 | days[i].month() == QDate::currentDate().month() && | 201 | days[i].month() == QDate::currentDate().month() && |
202 | days[i].day() == QDate::currentDate().day()) { | 202 | days[i].day() == QDate::currentDate().day()) { |
203 | today = i; | 203 | today = i; |
204 | } | 204 | } |
205 | } | 205 | } |
206 | // qDebug(QString("Today is visible at %1.").arg(today)); | 206 | // qDebug(QString("Today is visible at %1.").arg(today)); |
207 | } | 207 | } |
208 | 208 | ||
209 | void KODayMatrix::updateView() | 209 | void KODayMatrix::updateView() |
210 | { | 210 | { |
211 | updateView(startdate); | 211 | updateView(startdate); |
212 | } | 212 | } |
213 | void KODayMatrix::repaintViewTimed() | 213 | void KODayMatrix::repaintViewTimed() |
214 | { | 214 | { |
215 | qDebug("KODayMatrix::repaintViewTimed "); | ||
216 | mRepaintTimer->stop(); | 215 | mRepaintTimer->stop(); |
217 | repaint(false); | 216 | repaint(false); |
218 | } | 217 | } |
219 | void KODayMatrix::updateViewTimed() | 218 | void KODayMatrix::updateViewTimed() |
220 | { | 219 | { |
221 | 220 | ||
222 | mUpdateTimer->stop(); | 221 | mUpdateTimer->stop(); |
223 | qDebug("KODayMatrix::updateView(QDate actdate)"); | ||
224 | for(int i = 0; i < NUMDAYS; i++) { | 222 | for(int i = 0; i < NUMDAYS; i++) { |
225 | |||
226 | // if events are set for the day then remember to draw it bold | 223 | // if events are set for the day then remember to draw it bold |
227 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 224 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
228 | Event *event; | 225 | Event *event; |
229 | int numEvents = eventlist.count(); | 226 | int numEvents = eventlist.count(); |
230 | 227 | QString holiStr = ""; | |
231 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 228 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
232 | ushort recurType = event->recurrence()->doesRecur(); | 229 | ushort recurType = event->recurrence()->doesRecur(); |
233 | |||
234 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 230 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
235 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 231 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
236 | numEvents--; | 232 | numEvents--; |
237 | } | 233 | } |
234 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { | ||
235 | if ( !holiStr.isEmpty() ) | ||
236 | holiStr += "\n"; | ||
237 | holiStr += event->summary(); | ||
238 | } | ||
238 | } | 239 | } |
239 | events[i] = numEvents; | 240 | events[i] = numEvents; |
240 | |||
241 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 241 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
242 | #ifndef KORG_NOPLUGINS | ||
243 | QString holiStr = KOCore::self()->holiday(days[i]); | ||
244 | #else | ||
245 | QString holiStr = QString::null; | ||
246 | #endif | ||
247 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 242 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
248 | !holiStr.isEmpty()) { | 243 | !holiStr.isEmpty()) { |
249 | if (holiStr.isNull()) holiStr = ""; | ||
250 | mHolidays[i] = holiStr; | 244 | mHolidays[i] = holiStr; |
251 | |||
252 | } else { | 245 | } else { |
253 | mHolidays[i] = QString::null; | 246 | mHolidays[i] = QString::null; |
254 | } | 247 | } |
255 | } | 248 | } |
256 | if ( ! mPendingUpdateBeforeRepaint ) | 249 | if ( ! mPendingUpdateBeforeRepaint ) |
257 | repaint(false); | 250 | repaint(false); |
258 | } | 251 | } |
259 | void KODayMatrix::updateView(QDate actdate) | 252 | void KODayMatrix::updateView(QDate actdate) |
260 | { | 253 | { |
261 | 254 | ||
262 | if ( ! actdate.isValid() ) { | 255 | if ( ! actdate.isValid() ) { |
263 | //qDebug("date not valid "); | 256 | //qDebug("date not valid "); |
264 | return; | 257 | return; |
265 | } | 258 | } |
266 | mDayChanged = false; | 259 | mDayChanged = false; |
267 | //flag to indicate if the starting day of the matrix has changed by this call | 260 | //flag to indicate if the starting day of the matrix has changed by this call |
268 | //mDayChanged = false; | 261 | //mDayChanged = false; |
269 | // if a new startdate is to be set then apply Cornelius's calculation | 262 | // if a new startdate is to be set then apply Cornelius's calculation |
270 | // of the first day to be shown | 263 | // of the first day to be shown |
271 | if (actdate != startdate) { | 264 | if (actdate != startdate) { |
272 | // reset index of selection according to shift of starting date from startdate to actdate | 265 | // reset index of selection according to shift of starting date from startdate to actdate |
273 | if (mSelStart != NOSELECTION) { | 266 | if (mSelStart != NOSELECTION) { |
274 | int tmp = actdate.daysTo(startdate); | 267 | int tmp = actdate.daysTo(startdate); |
275 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 268 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
276 | // shift selection if new one would be visible at least partly ! | 269 | // shift selection if new one would be visible at least partly ! |
277 | 270 | ||
278 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 271 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
279 | // nested if is required for next X display pushed from a different month - correction required | 272 | // nested if is required for next X display pushed from a different month - correction required |
280 | // otherwise, for month forward and backward, it must be avoided | 273 | // otherwise, for month forward and backward, it must be avoided |
281 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 274 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
282 | mSelStart = mSelStart + tmp; | 275 | mSelStart = mSelStart + tmp; |
283 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 276 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
284 | mSelEnd = mSelEnd + tmp; | 277 | mSelEnd = mSelEnd + tmp; |
285 | } | 278 | } |
286 | } | 279 | } |
287 | startdate = actdate; | 280 | startdate = actdate; |
288 | mDayChanged = true; | 281 | mDayChanged = true; |
289 | recalculateToday(); | 282 | recalculateToday(); |
290 | } | 283 | } |
291 | qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 284 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
292 | if ( !isVisible() ) { | 285 | if ( !isVisible() ) { |
293 | mPendingUpdateBeforeRepaint = true; | 286 | mPendingUpdateBeforeRepaint = true; |
294 | } else { | 287 | } else { |
295 | #ifdef DESKTOP_VERSION | 288 | #ifdef DESKTOP_VERSION |
296 | //mRepaintTimer->start( 250 ); | 289 | //mRepaintTimer->start( 250 ); |
297 | mUpdateTimer->start( 250 ); | 290 | mUpdateTimer->start( 250 ); |
298 | #else | 291 | #else |
299 | mRepaintTimer->start( 350 ); | 292 | mRepaintTimer->start( 350 ); |
300 | mUpdateTimer->start( 2000 ); | 293 | mUpdateTimer->start( 2000 ); |
301 | #endif | 294 | #endif |
302 | } | 295 | } |
303 | } | 296 | } |
304 | 297 | ||
305 | const QDate& KODayMatrix::getDate(int offset) | 298 | const QDate& KODayMatrix::getDate(int offset) |
306 | { | 299 | { |
307 | if (offset < 0 || offset > NUMDAYS-1) { | 300 | if (offset < 0 || offset > NUMDAYS-1) { |
308 | qDebug("Wrong offset2 "); | 301 | qDebug("Wrong offset2 "); |
309 | return days[0]; | 302 | return days[0]; |
310 | } | 303 | } |
311 | return days[offset]; | 304 | return days[offset]; |
312 | } | 305 | } |
313 | 306 | ||
314 | QString KODayMatrix::getHolidayLabel(int offset) | 307 | QString KODayMatrix::getHolidayLabel(int offset) |
315 | { | 308 | { |
316 | if (offset < 0 || offset > NUMDAYS-1) { | 309 | if (offset < 0 || offset > NUMDAYS-1) { |
317 | qDebug("Wrong offset1 "); | 310 | qDebug("Wrong offset1 "); |
318 | return 0; | 311 | return 0; |
319 | } | 312 | } |
320 | return mHolidays[offset]; | 313 | return mHolidays[offset]; |
321 | } | 314 | } |
322 | 315 | ||
323 | int KODayMatrix::getDayIndexFrom(int x, int y) | 316 | int KODayMatrix::getDayIndexFrom(int x, int y) |
324 | { | 317 | { |
325 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 318 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
326 | 6 - x/daysize.width() : x/daysize.width()); | 319 | 6 - x/daysize.width() : x/daysize.width()); |
327 | } | 320 | } |
328 | 321 | ||
329 | // ---------------------------------------------------------------------------- | 322 | // ---------------------------------------------------------------------------- |
330 | // M O U S E E V E N T H A N D L I N G | 323 | // M O U S E E V E N T H A N D L I N G |
331 | // ---------------------------------------------------------------------------- | 324 | // ---------------------------------------------------------------------------- |
332 | 325 | ||
333 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 326 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
334 | { | 327 | { |
335 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 328 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
336 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 329 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
337 | mSelInit = mSelStart; | 330 | mSelInit = mSelStart; |
338 | } | 331 | } |
339 | 332 | ||
@@ -442,102 +435,106 @@ void KODayMatrix::dropEvent(QDropEvent *e) | |||
442 | 435 | ||
443 | DndFactory factory( mCalendar ); | 436 | DndFactory factory( mCalendar ); |
444 | Event *event = factory.createDrop(e); | 437 | Event *event = factory.createDrop(e); |
445 | 438 | ||
446 | if (event) { | 439 | if (event) { |
447 | e->acceptAction(); | 440 | e->acceptAction(); |
448 | 441 | ||
449 | Event *existingEvent = mCalendar->event(event->uid()); | 442 | Event *existingEvent = mCalendar->event(event->uid()); |
450 | 443 | ||
451 | if(existingEvent) { | 444 | if(existingEvent) { |
452 | // uniquify event | 445 | // uniquify event |
453 | event->recreate(); | 446 | event->recreate(); |
454 | /* | 447 | /* |
455 | KMessageBox::sorry(this, | 448 | KMessageBox::sorry(this, |
456 | i18n("Event already exists in this calendar."), | 449 | i18n("Event already exists in this calendar."), |
457 | i18n("Drop Event")); | 450 | i18n("Drop Event")); |
458 | delete event; | 451 | delete event; |
459 | return; | 452 | return; |
460 | */ | 453 | */ |
461 | } | 454 | } |
462 | // kdDebug() << "Drop new Event" << endl; | 455 | // kdDebug() << "Drop new Event" << endl; |
463 | // Adjust date | 456 | // Adjust date |
464 | QDateTime start = event->dtStart(); | 457 | QDateTime start = event->dtStart(); |
465 | QDateTime end = event->dtEnd(); | 458 | QDateTime end = event->dtEnd(); |
466 | int duration = start.daysTo(end); | 459 | int duration = start.daysTo(end); |
467 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); | 460 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); |
468 | 461 | ||
469 | start.setDate(days[idx]); | 462 | start.setDate(days[idx]); |
470 | end.setDate(days[idx].addDays(duration)); | 463 | end.setDate(days[idx].addDays(duration)); |
471 | 464 | ||
472 | event->setDtStart(start); | 465 | event->setDtStart(start); |
473 | event->setDtEnd(end); | 466 | event->setDtEnd(end); |
474 | mCalendar->addEvent(event); | 467 | mCalendar->addEvent(event); |
475 | 468 | ||
476 | emit eventDropped(event); | 469 | emit eventDropped(event); |
477 | } else { | 470 | } else { |
478 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; | 471 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; |
479 | e->ignore(); | 472 | e->ignore(); |
480 | } | 473 | } |
481 | #endif | 474 | #endif |
482 | } | 475 | } |
483 | 476 | ||
484 | // ---------------------------------------------------------------------------- | 477 | // ---------------------------------------------------------------------------- |
485 | // P A I N T E V E N T H A N D L I N G | 478 | // P A I N T E V E N T H A N D L I N G |
486 | // ---------------------------------------------------------------------------- | 479 | // ---------------------------------------------------------------------------- |
487 | 480 | ||
488 | void KODayMatrix::paintEvent(QPaintEvent * pevent) | 481 | void KODayMatrix::paintEvent(QPaintEvent * pevent) |
489 | { | 482 | { |
490 | //kdDebug() << "KODayMatrix::paintEvent() BEGIN" << endl; | 483 | if ( width() <= 0 || height() <= 0 ) |
484 | return; | ||
491 | if ( mPendingUpdateBeforeRepaint ) { | 485 | if ( mPendingUpdateBeforeRepaint ) { |
492 | updateViewTimed(); | 486 | updateViewTimed(); |
493 | mPendingUpdateBeforeRepaint = false; | 487 | mPendingUpdateBeforeRepaint = false; |
494 | } | 488 | } |
495 | QPainter p(this); | 489 | if ( myPix.width() != width() || myPix.height()!=height() ) { |
490 | myPix.resize(size() ); | ||
491 | } | ||
492 | QPainter p(&myPix); | ||
496 | 493 | ||
497 | QRect sz = frameRect(); | 494 | QRect sz = frameRect(); |
498 | int dheight = daysize.height(); | 495 | int dheight = daysize.height(); |
499 | int dwidth = daysize.width(); | 496 | int dwidth = daysize.width(); |
500 | int row,col; | 497 | int row,col; |
501 | int selw, selh; | 498 | int selw, selh; |
502 | bool isRTL = KOGlobals::self()->reverseLayout(); | 499 | bool isRTL = KOGlobals::self()->reverseLayout(); |
503 | 500 | ||
504 | // draw background and topleft frame | 501 | // draw background and topleft frame |
505 | p.fillRect(pevent->rect(), mDefaultBackColor); | 502 | p.fillRect(pevent->rect(), mDefaultBackColor); |
506 | p.setPen(mDefaultTextColor); | 503 | p.setPen(mDefaultTextColor); |
507 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); | 504 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); |
508 | 505 | ||
509 | // draw selected days with highlighted background color | 506 | // draw selected days with highlighted background color |
510 | if (mSelStart != NOSELECTION) { | 507 | if (mSelStart != NOSELECTION) { |
511 | 508 | ||
512 | row = mSelStart/7; | 509 | row = mSelStart/7; |
513 | col = mSelStart -row*7; | 510 | col = mSelStart -row*7; |
514 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 511 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
515 | 512 | ||
516 | if (row == mSelEnd/7) { | 513 | if (row == mSelEnd/7) { |
517 | // Single row selection | 514 | // Single row selection |
518 | p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, | 515 | p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, |
519 | row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); | 516 | row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); |
520 | } else { | 517 | } else { |
521 | // draw first row to the right | 518 | // draw first row to the right |
522 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, | 519 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, |
523 | dheight, selcol); | 520 | dheight, selcol); |
524 | // draw full block till last line | 521 | // draw full block till last line |
525 | selh = mSelEnd/7-row; | 522 | selh = mSelEnd/7-row; |
526 | if (selh > 1) { | 523 | if (selh > 1) { |
527 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); | 524 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); |
528 | } | 525 | } |
529 | // draw last block from left to mSelEnd | 526 | // draw last block from left to mSelEnd |
530 | selw = mSelEnd-7*(mSelEnd/7)+1; | 527 | selw = mSelEnd-7*(mSelEnd/7)+1; |
531 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, | 528 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, |
532 | selw*dwidth, dheight, selcol); | 529 | selw*dwidth, dheight, selcol); |
533 | } | 530 | } |
534 | } | 531 | } |
535 | 532 | ||
536 | // iterate over all days in the matrix and draw the day label in appropriate colors | 533 | // iterate over all days in the matrix and draw the day label in appropriate colors |
537 | QColor actcol = mDefaultTextColorShaded; | 534 | QColor actcol = mDefaultTextColorShaded; |
538 | p.setPen(actcol); | 535 | p.setPen(actcol); |
539 | QPen tmppen; | 536 | QPen tmppen; |
540 | for(int i = 0; i < NUMDAYS; i++) { | 537 | for(int i = 0; i < NUMDAYS; i++) { |
541 | row = i/7; | 538 | row = i/7; |
542 | col = isRTL ? 6-(i-row*7) : i-row*7; | 539 | col = isRTL ? 6-(i-row*7) : i-row*7; |
543 | 540 | ||
@@ -571,60 +568,61 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) | |||
571 | } | 568 | } |
572 | } | 569 | } |
573 | //draw gray rectangle for today if in selection | 570 | //draw gray rectangle for today if in selection |
574 | if (i >= mSelStart && i <= mSelEnd) { | 571 | if (i >= mSelStart && i <= mSelEnd) { |
575 | QColor grey("grey"); | 572 | QColor grey("grey"); |
576 | mTodayPen.setColor(grey); | 573 | mTodayPen.setColor(grey); |
577 | } | 574 | } |
578 | p.setPen(mTodayPen); | 575 | p.setPen(mTodayPen); |
579 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); | 576 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); |
580 | p.setPen(tmppen); | 577 | p.setPen(tmppen); |
581 | } | 578 | } |
582 | 579 | ||
583 | // if any events are on that day then draw it using a bold font | 580 | // if any events are on that day then draw it using a bold font |
584 | if (events[i] > 0) { | 581 | if (events[i] > 0) { |
585 | QFont myFont = font(); | 582 | QFont myFont = font(); |
586 | myFont.setBold(true); | 583 | myFont.setBold(true); |
587 | p.setFont(myFont); | 584 | p.setFont(myFont); |
588 | } | 585 | } |
589 | 586 | ||
590 | // if it is a holiday then use the default holiday color | 587 | // if it is a holiday then use the default holiday color |
591 | if (!mHolidays[i].isNull()) { | 588 | if (!mHolidays[i].isNull()) { |
592 | if (actcol == mDefaultTextColor) { | 589 | if (actcol == mDefaultTextColor) { |
593 | p.setPen(KOPrefs::instance()->mHolidayColor); | 590 | p.setPen(KOPrefs::instance()->mHolidayColor); |
594 | } else { | 591 | } else { |
595 | p.setPen(mHolidayColorShaded); | 592 | p.setPen(mHolidayColorShaded); |
596 | } | 593 | } |
597 | } | 594 | } |
598 | 595 | ||
599 | // draw selected days with special color | 596 | // draw selected days with special color |
600 | // DO NOT specially highlight holidays in selection ! | 597 | // DO NOT specially highlight holidays in selection ! |
601 | if (i >= mSelStart && i <= mSelEnd) { | 598 | if (i >= mSelStart && i <= mSelEnd) { |
602 | p.setPen(mSelectedDaysColor); | 599 | p.setPen(mSelectedDaysColor); |
603 | } | 600 | } |
604 | 601 | ||
605 | p.drawText(col*dwidth, row*dheight, dwidth, dheight, | 602 | p.drawText(col*dwidth, row*dheight, dwidth, dheight, |
606 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); | 603 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); |
607 | 604 | ||
608 | // reset color to actual color | 605 | // reset color to actual color |
609 | if (!mHolidays[i].isNull()) { | 606 | if (!mHolidays[i].isNull()) { |
610 | p.setPen(actcol); | 607 | p.setPen(actcol); |
611 | } | 608 | } |
612 | // reset bold font to plain font | 609 | // reset bold font to plain font |
613 | if (events[i] > 0) { | 610 | if (events[i] > 0) { |
614 | QFont myFont = font(); | 611 | QFont myFont = font(); |
615 | myFont.setBold(false); | 612 | myFont.setBold(false); |
616 | p.setFont(myFont); | 613 | p.setFont(myFont); |
617 | } | 614 | } |
618 | } | 615 | } |
616 | bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); | ||
619 | } | 617 | } |
620 | 618 | ||
621 | // ---------------------------------------------------------------------------- | 619 | // ---------------------------------------------------------------------------- |
622 | // R E SI Z E E V E N T H A N D L I N G | 620 | // R E SI Z E E V E N T H A N D L I N G |
623 | // ---------------------------------------------------------------------------- | 621 | // ---------------------------------------------------------------------------- |
624 | 622 | ||
625 | void KODayMatrix::resizeEvent(QResizeEvent *) | 623 | void KODayMatrix::resizeEvent(QResizeEvent *) |
626 | { | 624 | { |
627 | QRect sz = frameRect(); | 625 | QRect sz = frameRect(); |
628 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 626 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
629 | daysize.setWidth(sz.width() / 7); | 627 | daysize.setWidth(sz.width() / 7); |
630 | } | 628 | } |