summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2011-02-24 17:21:08 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2011-02-24 17:21:08 (GMT)
commitc64c722945df4b56d51de4b7d629129ff98f2d9e (patch)
treeeec26de18b3d4f6de46c3e9924be0894b906b57e /tests
parent2cbeb6c08cb7c79d6126f75c2cbc470679d671e1 (diff)
parent87bffe501cf21cbdc3394435f397cbc0da9c50d6 (diff)
downloadQt-c64c722945df4b56d51de4b7d629129ff98f2d9e.zip
Qt-c64c722945df4b56d51de4b7d629129ff98f2d9e.tar.gz
Qt-c64c722945df4b56d51de4b7d629129ff98f2d9e.tar.bz2
Merge branch 'master-i18n' of scm.dev.nokia.troll.no:qt/qt-earth-team into master-i18n
Conflicts: src/corelib/tools/qlocale.cpp
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qlocale/tst_qlocale.cpp11
-rw-r--r--tests/manual/qlocale/calendar.cpp45
-rw-r--r--tests/manual/qlocale/calendar.h2
3 files changed, 43 insertions, 15 deletions
diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp
index afcc69f..d1b7193 100644
--- a/tests/auto/qlocale/tst_qlocale.cpp
+++ b/tests/auto/qlocale/tst_qlocale.cpp
@@ -143,6 +143,7 @@ private slots:
void currency();
void quoteString();
void uiLanguages();
+ void weekendDays();
private:
QString m_decimal, m_thousand, m_sdate, m_ldate, m_time;
@@ -1124,6 +1125,9 @@ void tst_QLocale::macDefaultLocale()
QCOMPARE(locale.dayName(7), QString("Sunday"));
QCOMPARE(locale.monthName(1), QString("January"));
QCOMPARE(locale.monthName(12), QString("December"));
+ QCOMPARE(locale.firstDayOfWeek(), Qt::Sunday);
+ QCOMPARE(locale.weekendStart(), Qt::Saturday);
+ QCOMPARE(locale.weekendEnd(), Qt::Sunday);
QCOMPARE(locale.quoteString("string"), QString::fromUtf8("\xe2\x80\x9c" "string" "\xe2\x80\x9d"));
QCOMPARE(locale.quoteString("string", QLocale::AlternateQuotation), QString::fromUtf8("\xe2\x80\x98" "string" "\xe2\x80\x99"));
@@ -2188,5 +2192,12 @@ void tst_QLocale::uiLanguages()
QCOMPARE(ru_RU.uiLanguages().at(0), QLatin1String("ru_RU"));
}
+void tst_QLocale::weekendDays()
+{
+ const QLocale c(QLocale::C);
+ QCOMPARE(c.weekendStart(), Qt::Saturday);
+ QCOMPARE(c.weekendEnd(), Qt::Sunday);
+}
+
QTEST_APPLESS_MAIN(tst_QLocale)
#include "tst_qlocale.moc"
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();