summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-06-18 12:11:26 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-06-18 12:12:24 (GMT)
commit2b32e8a7504a98950b486df6ee6f2f126c162e6c (patch)
treeeedf2aef3d9f67292729b7b9bf9eaa5ac0557e7c /examples
parentf41887f827cb5011ffb2215d70679b9421745c94 (diff)
downloadQt-2b32e8a7504a98950b486df6ee6f2f126c162e6c.zip
Qt-2b32e8a7504a98950b486df6ee6f2f126c162e6c.tar.gz
Qt-2b32e8a7504a98950b486df6ee6f2f126c162e6c.tar.bz2
Demo: fixed colors in the calendar when May 1st is a Friday
Task-number: 255114
Diffstat (limited to 'examples')
-rw-r--r--examples/widgets/calendarwidget/window.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/examples/widgets/calendarwidget/window.cpp b/examples/widgets/calendarwidget/window.cpp
index 7672a05..c31ea0c 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]