diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-06-18 14:11:26 +0200 |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-06-18 14:12:24 +0200 |
commit | 2b32e8a7504a98950b486df6ee6f2f126c162e6c (patch) | |
tree | eedf2aef3d9f67292729b7b9bf9eaa5ac0557e7c /examples/widgets | |
parent | f41887f827cb5011ffb2215d70679b9421745c94 (diff) | |
download | qt4-tools-2b32e8a7504a98950b486df6ee6f2f126c162e6c.tar.gz |
Demo: fixed colors in the calendar when May 1st is a Friday
Task-number: 255114
Diffstat (limited to 'examples/widgets')
-rw-r--r-- | examples/widgets/calendarwidget/window.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/examples/widgets/calendarwidget/window.cpp b/examples/widgets/calendarwidget/window.cpp index 7672a05782..c31ea0cce7 100644 --- a/examples/widgets/calendarwidget/window.cpp +++ b/examples/widgets/calendarwidget/window.cpp @@ -167,22 +167,22 @@ void Window::reformatHeaders() //! [8] void Window::reformatCalendarPage() { - QTextCharFormat mayFirstFormat; - if (mayFirstCheckBox->isChecked()) - mayFirstFormat.setForeground(Qt::red); - - QTextCharFormat firstFridayFormat; - if (firstFridayCheckBox->isChecked()) + if (firstFridayCheckBox->isChecked()) { + QDate firstFriday(calendar->yearShown(), calendar->monthShown(), 1); + while (firstFriday.dayOfWeek() != Qt::Friday) + firstFriday = firstFriday.addDays(1); + QTextCharFormat firstFridayFormat; firstFridayFormat.setForeground(Qt::blue); + calendar->setDateTextFormat(firstFriday, firstFridayFormat); + } - QDate date(calendar->yearShown(), calendar->monthShown(), 1); - - calendar->setDateTextFormat(QDate(date.year(), 5, 1), mayFirstFormat); - - date.setDate(date.year(), date.month(), 1); - while (date.dayOfWeek() != Qt::Friday) - date = date.addDays(1); - calendar->setDateTextFormat(date, firstFridayFormat); + //May First in Red takes precedence + if (mayFirstCheckBox->isChecked()) { + const QDate mayFirst(calendar->yearShown(), 5, 1); + QTextCharFormat mayFirstFormat; + mayFirstFormat.setForeground(Qt::red); + calendar->setDateTextFormat(mayFirst, mayFirstFormat); + } } //! [8] |