From 5962bd47ba62744f847872f14bfc9f0b09b4a7e6 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 9 Mar 2011 11:51:01 +0100 Subject: Narrow day name on Windows Added narrow day name support available on Windows Vista and newer. Reviewed-by: Zeno Albisser --- src/corelib/tools/qlocale_win.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp index 905ecd9..eae23e0 100644 --- a/src/corelib/tools/qlocale_win.cpp +++ b/src/corelib/tools/qlocale_win.cpp @@ -67,6 +67,15 @@ static QString winIso3116CtryName(LCID id = LOCALE_USER_DEFAULT); #ifndef MUI_LANGUAGE_NAME #define MUI_LANGUAGE_NAME 0x8 #endif +#ifndef LOCALE_SSHORTESTDAYNAME1 +# define LOCALE_SSHORTESTDAYNAME1 0x0060 +# define LOCALE_SSHORTESTDAYNAME2 0x0061 +# define LOCALE_SSHORTESTDAYNAME3 0x0062 +# define LOCALE_SSHORTESTDAYNAME4 0x0063 +# define LOCALE_SSHORTESTDAYNAME5 0x0064 +# define LOCALE_SSHORTESTDAYNAME6 0x0065 +# define LOCALE_SSHORTESTDAYNAME7 0x0066 +#endif struct QSystemLocalePrivate { @@ -257,11 +266,19 @@ QVariant QSystemLocalePrivate::dayName(int day, QLocale::FormatType type) LOCALE_SDAYNAME3, LOCALE_SDAYNAME4, LOCALE_SDAYNAME5, LOCALE_SDAYNAME6, LOCALE_SDAYNAME7 }; + static const LCTYPE narrow_day_map[] + = { LOCALE_SSHORTESTDAYNAME1, LOCALE_SSHORTESTDAYNAME2, + LOCALE_SSHORTESTDAYNAME3, LOCALE_SSHORTESTDAYNAME4, + LOCALE_SSHORTESTDAYNAME5, LOCALE_SSHORTESTDAYNAME6, + LOCALE_SSHORTESTDAYNAME7 }; + day -= 1; - LCTYPE lctype = (type == QLocale::ShortFormat || type == QLocale::NarrowFormat) - ? short_day_map[day] : long_day_map[day]; - return getLocaleInfo(lctype); + if (type == QLocale::LongFormat) + return getLocaleInfo(long_day_map[day]); + else if (type == QLocale::NarrowFormat && QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) + return getLocaleInfo(narrow_day_map[day]); + return getLocaleInfo(short_day_map[day]); } QVariant QSystemLocalePrivate::monthName(int month, QLocale::FormatType type) -- cgit v0.12