From 4b507e8257243e36f40089d57099c2d668c5884d Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 5 Jan 2017 16:28:53 -0800 Subject: Add conversion functions for QTimeZone and CFTimeZone/NSTimeZone Change-Id: I3a2e18d69577296bf612e13e40414bce1daa6a71 Reviewed-by: Thiago Macieira --- src/corelib/tools/qtimezone.h | 12 ++++++++++++ src/corelib/tools/qtimezoneprivate_mac.mm | 5 +++++ src/corelib/tools/qtimezoneprivate_p.h | 12 +++++------- 3 files changed, 22 insertions(+), 7 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qtimezone.h b/src/corelib/tools/qtimezone.h index 083f87f39f..bd87139f5b 100644 --- a/src/corelib/tools/qtimezone.h +++ b/src/corelib/tools/qtimezone.h @@ -47,6 +47,11 @@ QT_REQUIRE_CONFIG(timezone); +#if (defined(Q_OS_DARWIN) || defined(Q_QDOC)) && !defined(QT_NO_SYSTEMLOCALE) +Q_FORWARD_DECLARE_CF_TYPE(CFTimeZone); +Q_FORWARD_DECLARE_OBJC_CLASS(NSTimeZone); +#endif + QT_BEGIN_NAMESPACE class QTimeZonePrivate; @@ -142,6 +147,13 @@ public: static QList windowsIdToIanaIds(const QByteArray &windowsId, QLocale::Country country); +#if (defined(Q_OS_DARWIN) || defined(Q_QDOC)) && !defined(QT_NO_SYSTEMLOCALE) + static QTimeZone fromCFTimeZone(CFTimeZoneRef timeZone); + CFTimeZoneRef toCFTimeZone() const Q_DECL_CF_RETURNS_RETAINED; + static QTimeZone fromNSTimeZone(const NSTimeZone *timeZone); + NSTimeZone *toNSTimeZone() const Q_DECL_NS_RETURNS_AUTORELEASED; +#endif + private: QTimeZone(QTimeZonePrivate &dd); #ifndef QT_NO_DATASTREAM diff --git a/src/corelib/tools/qtimezoneprivate_mac.mm b/src/corelib/tools/qtimezoneprivate_mac.mm index 5dfffeaf36..0c2dbe6fef 100644 --- a/src/corelib/tools/qtimezoneprivate_mac.mm +++ b/src/corelib/tools/qtimezoneprivate_mac.mm @@ -273,4 +273,9 @@ QList QMacTimeZonePrivate::availableTimeZoneIds() const return list; } +NSTimeZone *QMacTimeZonePrivate::nsTimeZone() const +{ + return m_nstz; +} + QT_END_NAMESPACE diff --git a/src/corelib/tools/qtimezoneprivate_p.h b/src/corelib/tools/qtimezoneprivate_p.h index c397c18aac..682edd3996 100644 --- a/src/corelib/tools/qtimezoneprivate_p.h +++ b/src/corelib/tools/qtimezoneprivate_p.h @@ -60,13 +60,9 @@ #include #endif -#ifdef Q_OS_MAC -#ifdef __OBJC__ -@class NSTimeZone; -#else -class NSTimeZone; -#endif // __OBJC__ -#endif // Q_OS_MAC +#ifdef Q_OS_DARWIN +Q_FORWARD_DECLARE_OBJC_CLASS(NSTimeZone); +#endif // Q_OS_DARWIN #ifdef Q_OS_WIN #include @@ -380,6 +376,8 @@ public: QList availableTimeZoneIds() const Q_DECL_OVERRIDE; + NSTimeZone *nsTimeZone() const; + private: void init(const QByteArray &zoneId); -- cgit v1.2.3