summaryrefslogtreecommitdiffabout
path: root/microkde
Unidiff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdecore/klocale.cpp4
-rw-r--r--microkde/kdecore/klocale.h1
2 files changed, 5 insertions, 0 deletions
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp
index 673d845..3674f28 100644
--- a/microkde/kdecore/klocale.cpp
+++ b/microkde/kdecore/klocale.cpp
@@ -119,96 +119,100 @@ KLocale::KLocale() : mCalendarSystem( 0 )
119 << i18n (" Local Time"); 119 << i18n (" Local Time");
120 mSouthDaylight = false; 120 mSouthDaylight = false;
121 mTimeZoneOffset = 0; 121 mTimeZoneOffset = 0;
122 daylightEnabled = false; 122 daylightEnabled = false;
123} 123}
124 124
125void KLocale::setDateFormat( QString s ) 125void KLocale::setDateFormat( QString s )
126{ 126{
127 mDateFormat = s; 127 mDateFormat = s;
128} 128}
129 129
130void KLocale::setDateFormatShort( QString s ) 130void KLocale::setDateFormatShort( QString s )
131{ 131{
132 mDateFormatShort = s; 132 mDateFormatShort = s;
133} 133}
134 134
135void KLocale::setHore24Format ( bool b ) 135void KLocale::setHore24Format ( bool b )
136{ 136{
137 mHourF24Format = b; 137 mHourF24Format = b;
138} 138}
139void KLocale::setWeekStartMonday( bool b ) 139void KLocale::setWeekStartMonday( bool b )
140{ 140{
141 mWeekStartsMonday = b; 141 mWeekStartsMonday = b;
142} 142}
143 143
144KLocale::IntDateFormat KLocale::getIntDateFormat( ) 144KLocale::IntDateFormat KLocale::getIntDateFormat( )
145{ 145{
146 return mIntDateFormat; 146 return mIntDateFormat;
147 147
148} 148}
149void KLocale::setIntDateFormat( KLocale::IntDateFormat i ) 149void KLocale::setIntDateFormat( KLocale::IntDateFormat i )
150{ 150{
151 mIntDateFormat = i; 151 mIntDateFormat = i;
152} 152}
153KLocale::IntDateFormat KLocale::getIntTimeFormat( ) 153KLocale::IntDateFormat KLocale::getIntTimeFormat( )
154{ 154{
155 return mIntTimeFormat; 155 return mIntTimeFormat;
156 156
157} 157}
158void KLocale::setIntTimeFormat( KLocale::IntDateFormat i ) 158void KLocale::setIntTimeFormat( KLocale::IntDateFormat i )
159{ 159{
160 mIntTimeFormat = i; 160 mIntTimeFormat = i;
161} 161}
162 162
163void KLocale::setLanguage( int i ) 163void KLocale::setLanguage( int i )
164{ 164{
165 mLanguage = i; 165 mLanguage = i;
166} 166}
167int KLocale::language( )
168{
169 return mLanguage;
170}
167QString KLocale::translate( const char *index ) const 171QString KLocale::translate( const char *index ) const
168{ 172{
169 return i18n( index ); 173 return i18n( index );
170} 174}
171 175
172QString KLocale::translate( const char *, const char *fallback) const 176QString KLocale::translate( const char *, const char *fallback) const
173{ 177{
174 return i18n( fallback ); 178 return i18n( fallback );
175} 179}
176 180
177QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const 181QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const
178{ 182{
179 const QString rst = timeFormat(intIntDateFormat); 183 const QString rst = timeFormat(intIntDateFormat);
180 184
181 // only "pm/am" here can grow, the rest shrinks, but 185 // only "pm/am" here can grow, the rest shrinks, but
182 // I'm rather safe than sorry 186 // I'm rather safe than sorry
183 QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; 187 QChar *buffer = new QChar[rst.length() * 3 / 2 + 30];
184 188
185 uint index = 0; 189 uint index = 0;
186 bool escape = false; 190 bool escape = false;
187 int number = 0; 191 int number = 0;
188 192
189 for ( uint format_index = 0; format_index < rst.length(); format_index++ ) 193 for ( uint format_index = 0; format_index < rst.length(); format_index++ )
190 { 194 {
191 if ( !escape ) 195 if ( !escape )
192 { 196 {
193 if ( rst.at( format_index ).unicode() == '%' ) 197 if ( rst.at( format_index ).unicode() == '%' )
194 escape = true; 198 escape = true;
195 else 199 else
196 buffer[index++] = rst.at( format_index ); 200 buffer[index++] = rst.at( format_index );
197 } 201 }
198 else 202 else
199 { 203 {
200 switch ( rst.at( format_index ).unicode() ) 204 switch ( rst.at( format_index ).unicode() )
201 { 205 {
202 case '%': 206 case '%':
203 buffer[index++] = '%'; 207 buffer[index++] = '%';
204 break; 208 break;
205 case 'H': 209 case 'H':
206 put_it_in( buffer, index, pTime.hour() ); 210 put_it_in( buffer, index, pTime.hour() );
207 break; 211 break;
208 case 'I': 212 case 'I':
209 put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); 213 put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 );
210 break; 214 break;
211 case 'M': 215 case 'M':
212 put_it_in( buffer, index, pTime.minute() ); 216 put_it_in( buffer, index, pTime.minute() );
213 break; 217 break;
214 case 'S': 218 case 'S':
diff --git a/microkde/kdecore/klocale.h b/microkde/kdecore/klocale.h
index be9442c..14660d6 100644
--- a/microkde/kdecore/klocale.h
+++ b/microkde/kdecore/klocale.h
@@ -35,84 +35,85 @@ class KLocale
35 QString decimalSymbol() const; 35 QString decimalSymbol() const;
36 QString thousandsSeparator() const; 36 QString thousandsSeparator() const;
37 QString positiveSign() const; 37 QString positiveSign() const;
38 QString negativeSign() const; 38 QString negativeSign() const;
39 39
40 40
41 QString translate( const char *index ) const; 41 QString translate( const char *index ) const;
42 QString translate( const char *index, const char *fallback) const; 42 QString translate( const char *index, const char *fallback) const;
43 43
44 enum IntDateFormat { Undefined=-1, Default=0, Format1=1, ISODate=2, Userdefined=3 }; 44 enum IntDateFormat { Undefined=-1, Default=0, Format1=1, ISODate=2, Userdefined=3 };
45 45
46 QString formatDate(const QDate &pDate, bool shortFormat = false, IntDateFormat intIntDateFormat = Undefined) const; 46 QString formatDate(const QDate &pDate, bool shortFormat = false, IntDateFormat intIntDateFormat = Undefined) const;
47 QString formatTime(const QTime &pTime, bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const; 47 QString formatTime(const QTime &pTime, bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const;
48 QString formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat = Undefined) const; 48 QString formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat = Undefined) const;
49 QString formatDateTime(const QDateTime &pDateTime, 49 QString formatDateTime(const QDateTime &pDateTime,
50 bool shortFormat, 50 bool shortFormat,
51 bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const; 51 bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const;
52 52
53 QDate readDate(const QString &str, bool* ok = 0) const; 53 QDate readDate(const QString &str, bool* ok = 0) const;
54 QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const; 54 QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const;
55 QTime readTime(const QString &str, bool* ok = 0) const; 55 QTime readTime(const QString &str, bool* ok = 0) const;
56 QDate readDate(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const; 56 QDate readDate(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const;
57 57
58 QDateTime readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const; 58 QDateTime readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const;
59 59
60 bool use12Clock() const; 60 bool use12Clock() const;
61 bool weekStartsMonday() const; 61 bool weekStartsMonday() const;
62 int weekStartDay() const; 62 int weekStartDay() const;
63 63
64 QString weekDayName(int,bool=false) const; 64 QString weekDayName(int,bool=false) const;
65 QString monthName(int,bool=false) const; 65 QString monthName(int,bool=false) const;
66 66
67 QString country() const; 67 QString country() const;
68 68
69 QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const; 69 QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const;
70 QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const; 70 QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const;
71 QString timeFormat(IntDateFormat intIntDateFormat = Undefined) const; 71 QString timeFormat(IntDateFormat intIntDateFormat = Undefined) const;
72 72
73 void insertCatalogue ( const QString & ); 73 void insertCatalogue ( const QString & );
74 74
75 KCalendarSystem *calendar(); 75 KCalendarSystem *calendar();
76 void setHore24Format ( bool ); 76 void setHore24Format ( bool );
77 void setWeekStartMonday( bool ); 77 void setWeekStartMonday( bool );
78 void setIntDateFormat( IntDateFormat ); 78 void setIntDateFormat( IntDateFormat );
79 void setIntTimeFormat( IntDateFormat ); 79 void setIntTimeFormat( IntDateFormat );
80 IntDateFormat getIntDateFormat( ); 80 IntDateFormat getIntDateFormat( );
81 IntDateFormat getIntTimeFormat( ); 81 IntDateFormat getIntTimeFormat( );
82 void setLanguage( int ); 82 void setLanguage( int );
83 int language();
83 void setDateFormat( QString ); 84 void setDateFormat( QString );
84 void setDateFormatShort( QString ); 85 void setDateFormatShort( QString );
85 86
86 QString m_decimalSymbol; 87 QString m_decimalSymbol;
87 QString m_thousandsSeparator; 88 QString m_thousandsSeparator;
88 QString m_currencySymbol; 89 QString m_currencySymbol;
89 QString m_monetaryDecimalSymbol; 90 QString m_monetaryDecimalSymbol;
90 QString m_monetaryThousandsSeparator; 91 QString m_monetaryThousandsSeparator;
91 QString m_positiveSign; 92 QString m_positiveSign;
92 QString m_negativeSign; 93 QString m_negativeSign;
93 94
94 int timezoneOffset( QString ); 95 int timezoneOffset( QString );
95 QStringList timeZoneList() const; 96 QStringList timeZoneList() const;
96 void setDaylightSaving( bool, int , int ); 97 void setDaylightSaving( bool, int , int );
97 int localTimeOffset(const QDateTime &); 98 int localTimeOffset(const QDateTime &);
98 void setTimezone( const QString &timeZone , bool oddTZ); 99 void setTimezone( const QString &timeZone , bool oddTZ);
99 private: 100 private:
100 QTime readTime(const QString &str, bool seconds, bool *ok) const; 101 QTime readTime(const QString &str, bool seconds, bool *ok) const;
101 QDate readDate(const QString &str, bool shortFormat, bool *ok) const; 102 QDate readDate(const QString &str, bool shortFormat, bool *ok) const;
102 KCalendarSystem *mCalendarSystem; 103 KCalendarSystem *mCalendarSystem;
103 bool mWeekStartsMonday; 104 bool mWeekStartsMonday;
104 bool mHourF24Format; 105 bool mHourF24Format;
105 IntDateFormat mIntDateFormat; 106 IntDateFormat mIntDateFormat;
106 IntDateFormat mIntTimeFormat; 107 IntDateFormat mIntTimeFormat;
107 int mLanguage; 108 int mLanguage;
108 QString mDateFormat; 109 QString mDateFormat;
109 QString mDateFormatShort; 110 QString mDateFormatShort;
110 QStringList mTimeZoneList; 111 QStringList mTimeZoneList;
111 bool daylightEnabled; 112 bool daylightEnabled;
112 int mDaylightTZoffset; 113 int mDaylightTZoffset;
113 int mNondaylightTZoffset; 114 int mNondaylightTZoffset;
114 bool mSouthDaylight; 115 bool mSouthDaylight;
115 int daylightStart, daylightEnd, mTimeZoneOffset; 116 int daylightStart, daylightEnd, mTimeZoneOffset;
116}; 117};
117 118
118#endif 119#endif