summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2011-03-09 10:51:01 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2011-03-17 16:38:08 (GMT)
commit5962bd47ba62744f847872f14bfc9f0b09b4a7e6 (patch)
treebf7ed7c3a3799a6a644a43dc67aece8a95d355ac
parentbb86e77cc437b92d49692bb7026c57626d77079f (diff)
downloadQt-5962bd47ba62744f847872f14bfc9f0b09b4a7e6.zip
Qt-5962bd47ba62744f847872f14bfc9f0b09b4a7e6.tar.gz
Qt-5962bd47ba62744f847872f14bfc9f0b09b4a7e6.tar.bz2
Narrow day name on Windows
Added narrow day name support available on Windows Vista and newer. Reviewed-by: Zeno Albisser
-rw-r--r--src/corelib/tools/qlocale_win.cpp23
1 files 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)