diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-06-07 14:59:48 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-06-07 14:59:48 (GMT) |
commit | f6909d47b981720cb87cb96454cdf9ea493383ee (patch) | |
tree | 44f13b6dd6af56c4f12b43597a1f8e8a94c6cbf9 /src/corelib/tools | |
parent | cdb80e13ebd06b5e163891a9d6c888c2b4e78747 (diff) | |
parent | dadb47e632d65ce886295e7848856d4030d6e7de (diff) | |
download | Qt-f6909d47b981720cb87cb96454cdf9ea493383ee.zip Qt-f6909d47b981720cb87cb96454cdf9ea493383ee.tar.gz Qt-f6909d47b981720cb87cb96454cdf9ea493383ee.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-symbian-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-symbian-staging: (25 commits)
Horizontal lines appearing under entered characters
Move qts60plugindeployment rule to correct scope
Skipping tst_QEventLoop::processEventsExcludeSocket for qws
Fixed compile of tst_qscriptextensionplugin on some Windows configurations
QS60Style: Checked state is not shown on highlighted itemview item
Removing unused code after introduction of round robin scheduler
tst_qeventloop runs the event loop to ensure socket messages arrive
Schedule Symbian active objects with a round robin scheduler
Fix the build break for QUrl autotest on Symbian
Fixed def files for WINSCW
Fixed def files for ARMV5
Fix the build break for QStyleSheetStyle autotest on Symbian
Fix bug about daylight saving missing on Symbian platfrom.
Fix the build break caused by the missing parameter for QSKIP macro.
Document the Symbian main window size issue at application start.
QS60Style: icon is not shown correctly in a menu item in all cases
QS60Style: Remove 3.x specific code from style
Fix Coverity issues found from QS60Style
Removed qts60plugin references also from config.profiles
Remove s60 plugin dll from the iby file too.
...
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qdatetime.cpp | 60 | ||||
-rw-r--r-- | src/corelib/tools/qlocale.cpp | 4 | ||||
-rw-r--r-- | src/corelib/tools/qlocale_symbian.cpp | 86 | ||||
-rw-r--r-- | src/corelib/tools/tools.pri | 5 |
4 files changed, 60 insertions, 95 deletions
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 4303731..a6fee43 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -75,6 +75,7 @@ #if defined(Q_OS_SYMBIAN) #include <e32std.h> +#include <tz.h> #endif QT_BEGIN_NAMESPACE @@ -4029,23 +4030,32 @@ static QDateTimePrivate::Spec utcToLocal(QDate &date, QTime &time) #elif defined(Q_OS_SYMBIAN) // months and days are zero index based _LIT(KUnixEpoch, "19700000:000000.000000"); - TTimeIntervalSeconds utcOffset = User::UTCOffset(); TTimeIntervalSeconds tTimeIntervalSecsSince1Jan1970UTC(secsSince1Jan1970UTC); TTime epochTTime; TInt err = epochTTime.Set(KUnixEpoch); tm res; if(err == KErrNone) { TTime utcTTime = epochTTime + tTimeIntervalSecsSince1Jan1970UTC; - utcTTime = utcTTime + utcOffset; - TDateTime utcDateTime = utcTTime.DateTime(); - res.tm_sec = utcDateTime.Second(); - res.tm_min = utcDateTime.Minute(); - res.tm_hour = utcDateTime.Hour(); - res.tm_mday = utcDateTime.Day() + 1; // non-zero based index for tm struct - res.tm_mon = utcDateTime.Month(); - res.tm_year = utcDateTime.Year() - 1900; - res.tm_isdst = 0; - brokenDown = &res; + TRAP(err, + RTz tz; + User::LeaveIfError(tz.Connect()); + CleanupClosePushL(tz); + res.tm_isdst = tz.IsDaylightSavingOnL(*tz.GetTimeZoneIdL(),utcTTime); + User::LeaveIfError(tz.ConvertToLocalTime(utcTTime)); + CleanupStack::PopAndDestroy(&tz)); + if (KErrNone == err) { + TDateTime localDateTime = utcTTime.DateTime(); + res.tm_sec = localDateTime.Second(); + res.tm_min = localDateTime.Minute(); + res.tm_hour = localDateTime.Hour(); + res.tm_mday = localDateTime.Day() + 1; // non-zero based index for tm struct + res.tm_mon = localDateTime.Month(); + res.tm_year = localDateTime.Year() - 1900; + // Symbian's timezone server doesn't know how to handle DST before year 1997 + if (res.tm_year < 97) + res.tm_isdst = -1; + brokenDown = &res; + } } #elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) // use the reentrant version of localtime() where available @@ -4120,23 +4130,27 @@ static void localToUtc(QDate &date, QTime &time, int isdst) #elif defined(Q_OS_SYMBIAN) // months and days are zero index based _LIT(KUnixEpoch, "19700000:000000.000000"); - TTimeIntervalSeconds utcOffset = TTimeIntervalSeconds(0 - User::UTCOffset().Int()); TTimeIntervalSeconds tTimeIntervalSecsSince1Jan1970UTC(secsSince1Jan1970UTC); TTime epochTTime; TInt err = epochTTime.Set(KUnixEpoch); tm res; if(err == KErrNone) { - TTime utcTTime = epochTTime + tTimeIntervalSecsSince1Jan1970UTC; - utcTTime = utcTTime + utcOffset; - TDateTime utcDateTime = utcTTime.DateTime(); - res.tm_sec = utcDateTime.Second(); - res.tm_min = utcDateTime.Minute(); - res.tm_hour = utcDateTime.Hour(); - res.tm_mday = utcDateTime.Day() + 1; // non-zero based index for tm struct - res.tm_mon = utcDateTime.Month(); - res.tm_year = utcDateTime.Year() - 1900; - res.tm_isdst = (int)isdst; - brokenDown = &res; + TTime localTTime = epochTTime + tTimeIntervalSecsSince1Jan1970UTC; + RTz tz; + if (KErrNone == tz.Connect()) { + if (KErrNone == tz.ConvertToUniversalTime(localTTime)) { + TDateTime utcDateTime = localTTime.DateTime(); + res.tm_sec = utcDateTime.Second(); + res.tm_min = utcDateTime.Minute(); + res.tm_hour = utcDateTime.Hour(); + res.tm_mday = utcDateTime.Day() + 1; // non-zero based index for tm struct + res.tm_mon = utcDateTime.Month(); + res.tm_year = utcDateTime.Year() - 1900; + res.tm_isdst = (int)isdst; + brokenDown = &res; + } + tz.Close(); + } } #elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) // use the reentrant version of gmtime() where available diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index cde93d6..eb1b7d5 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -76,7 +76,6 @@ QT_BEGIN_NAMESPACE #if defined(Q_OS_SYMBIAN) void qt_symbianUpdateSystemPrivate(); -void qt_symbianInitSystemLocale(); #endif #ifndef QT_NO_SYSTEMLOCALE @@ -470,9 +469,6 @@ static const QSystemLocale *systemLocale() { if (_systemLocale) return _systemLocale; -#if defined(Q_OS_SYMBIAN) - qt_symbianInitSystemLocale(); -#endif return QSystemLocale_globalSystemLocale(); } diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp index a4f6cc8..cdf0ab1 100644 --- a/src/corelib/tools/qlocale_symbian.cpp +++ b/src/corelib/tools/qlocale_symbian.cpp @@ -50,6 +50,7 @@ #include <e32const.h> #include <e32base.h> #include <e32property.h> +#include <numberconversion.h> #include <bacntf.h> #include "private/qcore_symbian_p.h" #include "private/qcoreapplication_p.h" @@ -60,27 +61,6 @@ QT_BEGIN_NAMESPACE static TExtendedLocale _s60Locale; -// Type definitions for runtime resolved function pointers -typedef void (*FormatFunc)(TTime&, TDes&, const TDesC&, const TLocale&); -typedef TPtrC (*FormatSpecFunc)(TExtendedLocale&); - -// Runtime resolved functions -static FormatFunc ptrTimeFormatL = NULL; -static FormatSpecFunc ptrGetTimeFormatSpec = NULL; -static FormatSpecFunc ptrGetLongDateFormatSpec = NULL; -static FormatSpecFunc ptrGetShortDateFormatSpec = NULL; - -// Default functions if functions cannot be resolved -static void defaultTimeFormatL(TTime&, TDes& des, const TDesC&, const TLocale&) -{ - des.Zero(); -} - -static TPtrC defaultFormatSpec(TExtendedLocale&) -{ - return TPtrC(KNullDesC); -} - /* Definition of struct for mapping Symbian to ISO locale */ @@ -699,9 +679,9 @@ static QString symbianDateFormat(bool short_format) TPtrC dateFormat; if (short_format) { - dateFormat.Set(ptrGetShortDateFormatSpec(_s60Locale)); + dateFormat.Set(_s60Locale.GetShortDateFormatSpec()); } else { - dateFormat.Set(ptrGetLongDateFormatSpec(_s60Locale)); + dateFormat.Set(_s60Locale.GetLongDateFormatSpec()); } return s60ToQtFormat(qt_TDesC2QString(dateFormat)); @@ -713,7 +693,7 @@ static QString symbianDateFormat(bool short_format) */ static QString symbianTimeFormat() { - return s60ToQtFormat(qt_TDesC2QString(ptrGetTimeFormatSpec(_s60Locale))); + return s60ToQtFormat(qt_TDesC2QString(_s60Locale.GetTimeFormatSpec())); } /*! @@ -737,17 +717,20 @@ static QString symbianDateToString(const QDate &date, bool short_format) TPtrC dateFormat; if (short_format) { - dateFormat.Set(ptrGetShortDateFormatSpec(_s60Locale)); + dateFormat.Set(_s60Locale.GetShortDateFormatSpec()); } else { - dateFormat.Set(ptrGetLongDateFormatSpec(_s60Locale)); + dateFormat.Set(_s60Locale.GetLongDateFormatSpec()); } - TRAPD(err, ptrTimeFormatL(timeStr, buffer, dateFormat, *_s60Locale.GetLocale());) + TLocale *formatLocale = _s60Locale.GetLocale(); + TRAPD(err, timeStr.FormatL(buffer, dateFormat, *formatLocale);) - if (err == KErrNone) + if (err == KErrNone) { + NumberConversion::ConvertDigits(buffer, formatLocale->DigitType()); return qt_TDes2QString(buffer); - else + } else { return QString(); + } } /*! @@ -767,17 +750,15 @@ static QString symbianTimeToString(const QTime &time) TTime timeStr(dateTime); TBuf<KMaxTimeFormatSpec*2> buffer; - TRAPD(err, ptrTimeFormatL( - timeStr, - buffer, - ptrGetTimeFormatSpec(_s60Locale), - *_s60Locale.GetLocale()); - ) + TLocale *formatLocale = _s60Locale.GetLocale(); + TRAPD(err, timeStr.FormatL(buffer, _s60Locale.GetTimeFormatSpec(), *formatLocale);) - if (err == KErrNone) + if (err == KErrNone) { + NumberConversion::ConvertDigits(buffer, formatLocale->DigitType()); return qt_TDes2QString(buffer); - else + } else { return QString(); + } } /*! @@ -802,37 +783,6 @@ void qt_symbianUpdateSystemPrivate() _s60Locale.LoadSystemSettings(); } -void qt_symbianInitSystemLocale() -{ - static QBasicAtomicInt initDone = Q_BASIC_ATOMIC_INITIALIZER(0); - if (initDone == 2) - return; - if (initDone.testAndSetRelaxed(0, 1)) { - // Initialize platform version dependent function pointers - ptrTimeFormatL = reinterpret_cast<FormatFunc> - (qt_resolveS60PluginFunc(S60Plugin_TimeFormatL)); - ptrGetTimeFormatSpec = reinterpret_cast<FormatSpecFunc> - (qt_resolveS60PluginFunc(S60Plugin_GetTimeFormatSpec)); - ptrGetLongDateFormatSpec = reinterpret_cast<FormatSpecFunc> - (qt_resolveS60PluginFunc(S60Plugin_GetLongDateFormatSpec)); - ptrGetShortDateFormatSpec = reinterpret_cast<FormatSpecFunc> - (qt_resolveS60PluginFunc(S60Plugin_GetShortDateFormatSpec)); - if (!ptrTimeFormatL) - ptrTimeFormatL = &defaultTimeFormatL; - if (!ptrGetTimeFormatSpec) - ptrGetTimeFormatSpec = &defaultFormatSpec; - if (!ptrGetLongDateFormatSpec) - ptrGetLongDateFormatSpec = &defaultFormatSpec; - if (!ptrGetShortDateFormatSpec) - ptrGetShortDateFormatSpec = &defaultFormatSpec; - bool ret = initDone.testAndSetRelease(1, 2); - Q_ASSERT(ret); - Q_UNUSED(ret); - } - while(initDone != 2) - QThread::yieldCurrentThread(); -} - QLocale QSystemLocale::fallbackLocale() const { TLanguage lang = User::Language(); diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index 0c2cf16..3dfce4b 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -122,3 +122,8 @@ INCLUDEPATH += ../3rdparty/md5 \ # Note: libm should be present by default becaue this is C++ !macx-icc:!vxworks:!symbian:unix:LIBS_PRIVATE += -lm +symbian { + # QLocale Symbian implementation needs this + LIBS += -lnumberconversion +} + |