Changeset View
Changeset View
Standalone View
Standalone View
src/kdatetable.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 37 | public: | |||
---|---|---|---|---|---|
49 | 49 | | |||
50 | void setDate(const QDate &date); | 50 | void setDate(const QDate &date); | ||
51 | void nextMonth(); | 51 | void nextMonth(); | ||
52 | void previousMonth(); | 52 | void previousMonth(); | ||
53 | void beginningOfMonth(); | 53 | void beginningOfMonth(); | ||
54 | void endOfMonth(); | 54 | void endOfMonth(); | ||
55 | void beginningOfWeek(); | 55 | void beginningOfWeek(); | ||
56 | void endOfWeek(); | 56 | void endOfWeek(); | ||
57 | QColor appropriateRedColor(QColor backgroundColor); | ||||
57 | 58 | | |||
58 | KDateTable *q; | 59 | KDateTable *q; | ||
59 | 60 | | |||
60 | /** | 61 | /** | ||
61 | * The currently selected date. | 62 | * The currently selected date. | ||
62 | */ | 63 | */ | ||
63 | QDate m_date; | 64 | QDate m_date; | ||
64 | 65 | | |||
▲ Show 20 Lines • Show All 204 Lines • ▼ Show 20 Line(s) | 269 | if (cellWeekDay >= locale().weekdays().first() || | |||
269 | cellWeekDay <= locale().weekdays().last()) { | 270 | cellWeekDay <= locale().weekdays().last()) { | ||
270 | workingDay = true; | 271 | workingDay = true; | ||
271 | } | 272 | } | ||
272 | } | 273 | } | ||
273 | 274 | | |||
274 | if (row == 0) { | 275 | if (row == 0) { | ||
275 | 276 | | |||
276 | //We are drawing a header cell | 277 | //We are drawing a header cell | ||
278 | cellBackgroundColor = palette().color(QPalette::Window); | ||||
277 | 279 | | |||
278 | //If not a normal working day, then use "do not work today" color | 280 | //If not a normal working day, then use "do not work today" color | ||
279 | if (workingDay) { | 281 | if (workingDay) { | ||
280 | cellTextColor = palette().color(QPalette::WindowText); | 282 | cellTextColor = palette().color(QPalette::WindowText); | ||
281 | } else { | 283 | } else { | ||
282 | cellTextColor = Qt::darkRed; | 284 | cellTextColor = d->appropriateRedColor(cellBackgroundColor); | ||
283 | } | 285 | } | ||
284 | cellBackgroundColor = palette().color(QPalette::Window); | 286 | cellBackgroundColor = palette().color(QPalette::Window); | ||
285 | 287 | | |||
286 | //Set the text to the short day name and bold it | 288 | //Set the text to the short day name and bold it | ||
287 | cellFont.setBold(true); | 289 | cellFont.setBold(true); | ||
288 | cellText = locale().dayName(cellWeekDay, QLocale::ShortFormat); | 290 | cellText = locale().dayName(cellWeekDay, QLocale::ShortFormat); | ||
289 | 291 | | |||
290 | } else { | 292 | } else { | ||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | 362 | if (!selectedDay) { | |||
361 | cellBackgroundColor = mode.bgColor; | 363 | cellBackgroundColor = mode.bgColor; | ||
362 | } | 364 | } | ||
363 | } | 365 | } | ||
364 | cellTextColor = mode.fgColor; | 366 | cellTextColor = mode.fgColor; | ||
365 | } | 367 | } | ||
366 | 368 | | |||
367 | //If the cell day is the day of religious observance, then always color text red unless Custom overrides | 369 | //If the cell day is the day of religious observance, then always color text red unless Custom overrides | ||
368 | if (! customDay && dayOfPray) { | 370 | if (! customDay && dayOfPray) { | ||
369 | cellTextColor = Qt::darkRed; | 371 | cellTextColor = d->appropriateRedColor(cellBackgroundColor); | ||
370 | } | 372 | } | ||
371 | 373 | | |||
372 | } | 374 | } | ||
373 | } | 375 | } | ||
374 | 376 | | |||
375 | //Draw the background | 377 | //Draw the background | ||
376 | if (row == 0) { | 378 | if (row == 0) { | ||
377 | painter->setPen(cellBackgroundColor); | 379 | painter->setPen(cellBackgroundColor); | ||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | |||||
449 | 451 | | |||
450 | // JPL Do these make the assumption that first day of week is weekday 1? As it may not be. | 452 | // JPL Do these make the assumption that first day of week is weekday 1? As it may not be. | ||
451 | void KDateTable::KDateTablePrivate::endOfWeek() | 453 | void KDateTable::KDateTablePrivate::endOfWeek() | ||
452 | { | 454 | { | ||
453 | // setDate does validity checking for us | 455 | // setDate does validity checking for us | ||
454 | q->setDate(m_date.addDays(7 - m_date.dayOfWeek())); | 456 | q->setDate(m_date.addDays(7 - m_date.dayOfWeek())); | ||
455 | } | 457 | } | ||
456 | 458 | | |||
459 | QColor KDateTable::KDateTablePrivate::appropriateRedColor(QColor backgroundColor) | ||||
460 | { | ||||
461 | if (backgroundColor.lightnessF() < 0.3) { | ||||
462 | return Qt::red; | ||||
463 | } else { | ||||
464 | return Qt::red; | ||||
465 | } | ||||
466 | } | ||||
467 | | ||||
468 | | ||||
457 | void KDateTable::keyPressEvent(QKeyEvent *e) | 469 | void KDateTable::keyPressEvent(QKeyEvent *e) | ||
458 | { | 470 | { | ||
459 | switch (e->key()) { | 471 | switch (e->key()) { | ||
460 | case Qt::Key_Up: | 472 | case Qt::Key_Up: | ||
461 | // setDate does validity checking for us | 473 | // setDate does validity checking for us | ||
462 | setDate(d->m_date.addDays(- d->m_numDayColumns)); | 474 | setDate(d->m_date.addDays(- d->m_numDayColumns)); | ||
463 | break; | 475 | break; | ||
464 | case Qt::Key_Down: | 476 | case Qt::Key_Down: | ||
▲ Show 20 Lines • Show All 242 Lines • Show Last 20 Lines |