KDECore
klocale_mac.cpp
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2010 John Layt <john@layt.net> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #include "klocale_mac_p.h" 00021 #include "kkernel_mac.h" 00022 00023 KLocaleMacPrivate::KLocaleMacPrivate(KLocale *q_ptr, const QString &catalog, KSharedConfig::Ptr config) 00024 :KLocalePrivate(q_ptr) 00025 { 00026 // Lock in the current Mac Locale settings 00027 m_macLocale = CFLocaleCopyCurrent(); 00028 init(catalog, QString(), QString(), config, 0); 00029 } 00030 00031 KLocaleMacPrivate::KLocaleMacPrivate(KLocale *q_ptr, const QString& catalog, 00032 const QString &language, const QString &country, KConfig *config) 00033 :KLocalePrivate(q_ptr) 00034 { 00035 // Lock in the current Mac Locale settings 00036 m_macLocale = CFLocaleCopyCurrent(); 00037 init(catalog, language, country, KSharedConfig::Ptr(), config); 00038 } 00039 00040 KLocaleMacPrivate::KLocaleMacPrivate( const KLocaleMacPrivate &rhs ) 00041 :KLocalePrivate( rhs ) 00042 { 00043 KLocalePrivate::copy( rhs ); 00044 m_macLocale = rhs.m_macLocale; 00045 } 00046 00047 KLocaleMacPrivate &KLocaleMacPrivate::operator=( const KLocaleMacPrivate &rhs ) 00048 { 00049 KLocalePrivate::copy( rhs ); 00050 m_macLocale = rhs.m_macLocale; 00051 return *this; 00052 } 00053 00054 KLocaleMacPrivate::~KLocaleMacPrivate() 00055 { 00056 } 00057 00058 QString KLocaleMacPrivate::macLocaleValue( CFStringRef key ) const 00059 { 00060 return convert_CFString_to_QString( CFStringRef( CFLocaleGetValue( m_macLocale, key ) ) ); 00061 } 00062 00063 QString KLocaleMacPrivate::systemCountry() const 00064 { 00065 return macLocaleValue( kCFLocaleCountryCode ); 00066 } 00067 00068 QByteArray KLocaleMacPrivate::systemCodeset() const 00069 { 00070 return QByteArray( "UTF-8" ); 00071 } 00072 00073 /* 00074 These functions are commented out for now until all required Date/Time functions are implemented 00075 to ensure consistent behaviour, i.e. all KDE format or all Mac format, not some invalid mixture 00076 00077 QString KLocaleMacPrivate::macDateFormatterValue(CFStringRef key) const 00078 { 00079 CFDateFormatterRef formatter = CFDateFormatterCreate(kCFAllocatorDefault, m_macLocale, kCFDateFormatterNoStyle, kCFDateFormatterNoStyle); 00080 return convert_CFString_to_QString(CFStringRef(CFDateFormatterCopyProperty(formatter, key))); 00081 } 00082 00083 void KLocaleMacPrivate::initDayPeriods(const KConfigGroup &cg) 00084 { 00085 QString amText = macDateFormatterValue(kCFDateFormatterAMSymbol); 00086 QString pmText = macDateFormatterValue(kCFDateFormatterPMSymbol); 00087 00088 m_dayPeriods.clear(); 00089 m_dayPeriods.append(KDayPeriod("am", amText, amText, amText 00090 QTime(0, 0, 0), QTime(11, 59, 59, 999), 0, 12)); 00091 m_dayPeriods.append(KDayPeriod("pm", pmText, pmText, pmText, 00092 QTime(12, 0, 0), QTime(23, 59, 59, 999), 0, 12)); 00093 } 00094 */
KDE 4.6 API Reference