diff options
author | Zeno Albisser <zeno.albisser@nokia.com> | 2011-02-22 14:41:59 (GMT) |
---|---|---|
committer | Zeno Albisser <zeno.albisser@nokia.com> | 2011-02-24 11:42:45 (GMT) |
commit | 3def7f4dd09f5d93f90d20eaedd17d8bd8c4a6fd (patch) | |
tree | fd47efebc5b57ba135253fdb06eaf2e3d3024468 /tests/manual | |
parent | c9071e8f9a26dee3a166579df69da11e0f6323fa (diff) | |
download | Qt-3def7f4dd09f5d93f90d20eaedd17d8bd8c4a6fd.zip Qt-3def7f4dd09f5d93f90d20eaedd17d8bd8c4a6fd.tar.gz Qt-3def7f4dd09f5d93f90d20eaedd17d8bd8c4a6fd.tar.bz2 |
Implemented QLocale::weekendStart and QLocale::weekendEnd
Reviewed-by: Denis Dzyubenko
Task-number: QTBUG-17088
Diffstat (limited to 'tests/manual')
-rw-r--r-- | tests/manual/qlocale/calendar.cpp | 45 | ||||
-rw-r--r-- | tests/manual/qlocale/calendar.h | 2 |
2 files changed, 32 insertions, 15 deletions
diff --git a/tests/manual/qlocale/calendar.cpp b/tests/manual/qlocale/calendar.cpp index b59fae6..615e44e 100644 --- a/tests/manual/qlocale/calendar.cpp +++ b/tests/manual/qlocale/calendar.cpp @@ -67,6 +67,7 @@ void CalendarWidget::localeChanged(QLocale locale) { calendar->setLocale(locale); firstDayCombo->setCurrentIndex(locale.firstDayOfWeek()-1); + updateWeekendDays(); } void CalendarWidget::firstDayChanged(int index) @@ -110,27 +111,41 @@ void CalendarWidget::maximumDateChanged(const QDate &date) minimumDateEdit->setDate(calendar->minimumDate()); } -void CalendarWidget::weekdayFormatChanged() -{ - QTextCharFormat format; +bool CalendarWidget::isWeekendDay(Qt::DayOfWeek day) { + Qt::DayOfWeek start = calendar->locale().weekendStart(); + Qt::DayOfWeek end = calendar->locale().weekendEnd(); - format.setForeground(qvariant_cast<QColor>( + if (start <= day && day <= end) + return true; + if (start > end && (day >= start || day <= end)) + return true; + return false; +} + +void CalendarWidget::updateWeekendDays() { + QTextCharFormat weekFormat, weekendFormat; + weekFormat.setForeground(qvariant_cast<QColor>( weekdayColorCombo->itemData(weekdayColorCombo->currentIndex()))); - calendar->setWeekdayTextFormat(Qt::Monday, format); - calendar->setWeekdayTextFormat(Qt::Tuesday, format); - calendar->setWeekdayTextFormat(Qt::Wednesday, format); - calendar->setWeekdayTextFormat(Qt::Thursday, format); - calendar->setWeekdayTextFormat(Qt::Friday, format); + weekendFormat.setForeground(qvariant_cast<QColor>( + weekendColorCombo->itemData(weekendColorCombo->currentIndex()))); + + calendar->setWeekdayTextFormat(Qt::Monday, isWeekendDay(Qt::Monday) ? weekendFormat : weekFormat); + calendar->setWeekdayTextFormat(Qt::Tuesday, isWeekendDay(Qt::Tuesday) ? weekendFormat : weekFormat); + calendar->setWeekdayTextFormat(Qt::Wednesday, isWeekendDay(Qt::Wednesday) ? weekendFormat : weekFormat); + calendar->setWeekdayTextFormat(Qt::Thursday, isWeekendDay(Qt::Thursday) ? weekendFormat : weekFormat); + calendar->setWeekdayTextFormat(Qt::Friday, isWeekendDay(Qt::Friday) ? weekendFormat : weekFormat); + calendar->setWeekdayTextFormat(Qt::Saturday, isWeekendDay(Qt::Saturday) ? weekendFormat : weekFormat); + calendar->setWeekdayTextFormat(Qt::Sunday, isWeekendDay(Qt::Sunday) ? weekendFormat : weekFormat); } -void CalendarWidget::weekendFormatChanged() +void CalendarWidget::weekdayFormatChanged() { - QTextCharFormat format; + updateWeekendDays(); +} - format.setForeground(qvariant_cast<QColor>( - weekendColorCombo->itemData(weekendColorCombo->currentIndex()))); - calendar->setWeekdayTextFormat(Qt::Saturday, format); - calendar->setWeekdayTextFormat(Qt::Sunday, format); +void CalendarWidget::weekendFormatChanged() +{ + updateWeekendDays(); } void CalendarWidget::reformatHeaders() diff --git a/tests/manual/qlocale/calendar.h b/tests/manual/qlocale/calendar.h index 3ac39c3..b5bb3c9 100644 --- a/tests/manual/qlocale/calendar.h +++ b/tests/manual/qlocale/calendar.h @@ -59,12 +59,14 @@ private slots: void selectedDateChanged(); void minimumDateChanged(const QDate &date); void maximumDateChanged(const QDate &date); + void updateWeekendDays(); void weekdayFormatChanged(); void weekendFormatChanged(); void reformatHeaders(); void reformatCalendarPage(); private: + bool isWeekendDay(Qt::DayOfWeek); void createPreviewGroupBox(); void createGeneralOptionsGroupBox(); void createDatesGroupBox(); |