summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-09-15 17:48:36 (UTC)
committer ulf69 <ulf69>2004-09-15 17:48:36 (UTC)
commit0af70ae5fee7b71aecf5ac742fdd65e31237eb5a (patch) (unidiff)
tree08a51756744591056fd74f3658afe940f5823265
parentc151151ccaffe54510e58731dc6d8f9d441bd31c (diff)
downloadkdepimpi-0af70ae5fee7b71aecf5ac742fdd65e31237eb5a.zip
kdepimpi-0af70ae5fee7b71aecf5ac742fdd65e31237eb5a.tar.gz
kdepimpi-0af70ae5fee7b71aecf5ac742fdd65e31237eb5a.tar.bz2
small changes to accommodate pwManager
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kconfig.cpp26
-rw-r--r--microkde/kconfig.h3
-rw-r--r--microkde/kdecore/klocale.cpp51
-rw-r--r--microkde/kdecore/klocale.h11
4 files changed, 76 insertions, 15 deletions
diff --git a/microkde/kconfig.cpp b/microkde/kconfig.cpp
index 4cbec94..ba41f6c 100644
--- a/microkde/kconfig.cpp
+++ b/microkde/kconfig.cpp
@@ -1,521 +1,547 @@
1#include <qfile.h> 1#include <qfile.h>
2#include <qtextstream.h> 2#include <qtextstream.h>
3#include <qwidget.h> 3#include <qwidget.h>
4 4
5#include "kdebug.h" 5#include "kdebug.h"
6 6
7#include "kurl.h" 7#include "kurl.h"
8#include "kstandarddirs.h" 8#include "kstandarddirs.h"
9#include "kconfig.h" 9#include "kconfig.h"
10 10
11QString KConfig::mGroup = ""; 11QString KConfig::mGroup = "";
12//QString KConfig::mGroup = "General"; 12//QString KConfig::mGroup = "General";
13 13
14KConfig::KConfig( const QString &fileName ) 14KConfig::KConfig( const QString &fileName )
15 : mFileName( fileName ), mDirty( false ) 15 : mFileName( fileName ), mDirty( false )
16{ 16{
17 17
18 mTempGroup = ""; 18 mTempGroup = "";
19 load(); 19 load();
20 20
21} 21}
22 22
23 23
24KConfig::~KConfig() 24KConfig::~KConfig()
25{ 25{
26 sync(); 26 sync();
27} 27}
28// we need the temp group for plugins on windows 28// we need the temp group for plugins on windows
29void KConfig::setTempGroup( const QString &group ) 29void KConfig::setTempGroup( const QString &group )
30{ 30{
31 mTempGroup = group; 31 mTempGroup = group;
32 32
33 if ( mTempGroup.right( 1 ) != "/" ) mTempGroup += "/"; 33 if ( mTempGroup.right( 1 ) != "/" ) mTempGroup += "/";
34} 34}
35 35
36 36
37QString KConfig::tempGroup() const { 37QString KConfig::tempGroup() const {
38 return mTempGroup; 38 return mTempGroup;
39} 39}
40 40
41void KConfig::setGroup( const QString &group ) 41void KConfig::setGroup( const QString &group )
42{ 42{
43 43
44 44
45 mGroup = group; 45 mGroup = group;
46 46
47 if ( mGroup.right( 1 ) != "/" ) mGroup += "/"; 47 if ( mGroup.right( 1 ) != "/" ) mGroup += "/";
48} 48}
49 49
50//US 50//US
51QString KConfig::group() const { 51QString KConfig::group() const {
52 return mGroup; 52 return mGroup;
53} 53}
54 54
55//US added method 55//US added method
56QValueList<int> KConfig::readIntListEntry( const QString & key) 56QValueList<int> KConfig::readIntListEntry( const QString & key)
57{ 57{
58// qDebug("KConfig::readIntListEntry key=%s:", key.latin1()); 58// qDebug("KConfig::readIntListEntry key=%s:", key.latin1());
59 59
60 QValueList<int> result; 60 QValueList<int> result;
61 61
62 QMap<QString,QString>::ConstIterator mit = mStringMap.find( mGroup + key ); 62 QMap<QString,QString>::ConstIterator mit = mStringMap.find( mGroup + key );
63 63
64 if ( mit == mStringMap.end() ) { 64 if ( mit == mStringMap.end() ) {
65 return result; 65 return result;
66 } 66 }
67 67
68 QStringList valuesAsStrings = QStringList::split(":", *mit ); 68 QStringList valuesAsStrings = QStringList::split(":", *mit );
69 bool ok = false; 69 bool ok = false;
70 bool ok2 = true; 70 bool ok2 = true;
71 int val; 71 int val;
72 72
73 for ( QStringList::Iterator sit = valuesAsStrings.begin(); sit != valuesAsStrings.end(); ++sit ) { 73 for ( QStringList::Iterator sit = valuesAsStrings.begin(); sit != valuesAsStrings.end(); ++sit ) {
74 val = (*sit).toInt(&ok); 74 val = (*sit).toInt(&ok);
75 result << val; 75 result << val;
76 if (ok == false) { 76 if (ok == false) {
77 qDebug("KConfig::readIntListEntry str=%s , int=%n:", (*sit).latin1(), &val); 77 qDebug("KConfig::readIntListEntry str=%s , int=%n:", (*sit).latin1(), &val);
78 ok2 = false; 78 ok2 = false;
79 } 79 }
80 } 80 }
81 81
82 if (ok2 == false) 82 if (ok2 == false)
83 { 83 {
84 84
85 qDebug("KConfig::readIntListEntry: error while reading one of the intvalues."); 85 qDebug("KConfig::readIntListEntry: error while reading one of the intvalues.");
86 } 86 }
87 87
88 return result; 88 return result;
89} 89}
90 90
91int KConfig::readNumEntry( const QString & key, int def ) 91int KConfig::readNumEntry( const QString & key, int def )
92{ 92{
93 QString res = readEntry(key, QString::number(def ) ); 93 QString res = readEntry(key, QString::number(def ) );
94 bool ok = false; 94 bool ok = false;
95 int result = res.toInt(&ok); 95 int result = res.toInt(&ok);
96 if ( ok ) 96 if ( ok )
97 return result; 97 return result;
98 return def; 98 return def;
99} 99}
100 100
101QString KConfig::readEntry( const QString &key, const QString &def ) 101QString KConfig::readEntry( const QString &key, const QString &def )
102{ 102{
103 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); 103 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key );
104 104
105 if ( it == mStringMap.end() ) { 105 if ( it == mStringMap.end() ) {
106 return def; 106 return def;
107 } 107 }
108 108
109 return *it; 109 return *it;
110} 110}
111 111
112QSize KConfig::readSizeEntry( const QString &key, QSize* def )
113{
114 QValueList<int> intlist = readIntListEntry(key);
115
116 if (intlist.count() < 2)
117 {
118 if (def)
119 return *def;
120 else
121 return QSize();
122 }
123
124 QSize ret;
125 ret.setWidth(intlist[0]);
126 ret.setHeight(intlist[1]);
127
128 return ret;
129}
130
112QStringList KConfig::readListEntry( const QString &key ) 131QStringList KConfig::readListEntry( const QString &key )
113{ 132{
114 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); 133 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key );
115 134
116 if ( it == mStringMap.end() ) { 135 if ( it == mStringMap.end() ) {
117 return QStringList(); 136 return QStringList();
118 } 137 }
119 return QStringList::split(":", *it ); 138 return QStringList::split(":", *it );
120 139
121} 140}
122 141
123bool KConfig::readBoolEntry( const QString &key, bool def ) 142bool KConfig::readBoolEntry( const QString &key, bool def )
124{ 143{
125 QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key ); 144 QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key );
126 145
127 if ( it == mBoolMap.end() ) { 146 if ( it == mBoolMap.end() ) {
128 return def; 147 return def;
129 } 148 }
130 149
131 return *it; 150 return *it;
132} 151}
133 152
134QColor KConfig::readColorEntry( const QString & e, QColor *def ) 153QColor KConfig::readColorEntry( const QString & e, QColor *def )
135{ 154{
136 155
137 QStringList l; 156 QStringList l;
138 l = readListEntry( e ); 157 l = readListEntry( e );
139 if (l.count() != 3 ) { 158 if (l.count() != 3 ) {
140 if ( def ) 159 if ( def )
141 return *def; 160 return *def;
142 else 161 else
143 return QColor(); 162 return QColor();
144 } 163 }
145 QColor c ( l[0].toInt(), l[1].toInt(), l[2].toInt() ); 164 QColor c ( l[0].toInt(), l[1].toInt(), l[2].toInt() );
146 return c; 165 return c;
147} 166}
148 167
149QFont KConfig::readFontEntry( const QString & e, QFont *def ) 168QFont KConfig::readFontEntry( const QString & e, QFont *def )
150{ 169{
151 QStringList font = readListEntry( e ); 170 QStringList font = readListEntry( e );
152 if ( font.isEmpty() ) 171 if ( font.isEmpty() )
153 return *def; 172 return *def;
154 QFont f; 173 QFont f;
155 f.setFamily( font[0]); 174 f.setFamily( font[0]);
156 f.setBold ( font[1] == "bold"); 175 f.setBold ( font[1] == "bold");
157 f.setPointSize ( font[2].toInt()); 176 f.setPointSize ( font[2].toInt());
158 f.setItalic( font[3] == "italic" ); 177 f.setItalic( font[3] == "italic" );
159 return f; 178 return f;
160} 179}
161 180
162QDateTime KConfig::readDateTimeEntry( const QString &key, const QDateTime *def ) 181QDateTime KConfig::readDateTimeEntry( const QString &key, const QDateTime *def )
163{ 182{
164 QMap<QString,QDateTime>::ConstIterator it = mDateTimeMap.find( mGroup + key ); 183 QMap<QString,QDateTime>::ConstIterator it = mDateTimeMap.find( mGroup + key );
165 184
166 if ( it == mDateTimeMap.end() ) { 185 if ( it == mDateTimeMap.end() ) {
167 if ( def ) return *def; 186 if ( def ) return *def;
168 else return QDateTime(); 187 else return QDateTime();
169 } 188 }
170 189
171 return *it; 190 return *it;
172} 191}
173 192
174//US added method 193//US added method
175void KConfig::writeEntry( const QString &key, const QValueList<int> &value) 194void KConfig::writeEntry( const QString &key, const QValueList<int> &value)
176{ 195{
177 QStringList valuesAsStrings; 196 QStringList valuesAsStrings;
178 197
179 QValueList<int>::ConstIterator it; 198 QValueList<int>::ConstIterator it;
180 199
181 for( it = value.begin(); it != value.end(); ++it ) 200 for( it = value.begin(); it != value.end(); ++it )
182 { 201 {
183 valuesAsStrings << QString::number(*it); 202 valuesAsStrings << QString::number(*it);
184 } 203 }
185 204
186 mStringMap.insert( mGroup + key, valuesAsStrings.join(":") ); 205 mStringMap.insert( mGroup + key, valuesAsStrings.join(":") );
187 mDirty = true; 206 mDirty = true;
188} 207}
189 208
190void KConfig::writeEntry( const QString & key , int num ) 209void KConfig::writeEntry( const QString & key , int num )
191{ 210{
192 writeEntry( key, QString::number ( num ) ); 211 writeEntry( key, QString::number ( num ) );
193} 212}
194 213
195void KConfig::writeEntry( const QString &key, const QString &value ) 214void KConfig::writeEntry( const QString &key, const QString &value )
196{ 215{
197 mStringMap.insert( mGroup + key, value ); 216 mStringMap.insert( mGroup + key, value );
198 217
199 mDirty = true; 218 mDirty = true;
200} 219}
201 220
202void KConfig::writeEntry( const QString &key, const QStringList &value ) 221void KConfig::writeEntry( const QString &key, const QStringList &value )
203{ 222{
204 mStringMap.insert( mGroup + key, value.join(":") ); 223 mStringMap.insert( mGroup + key, value.join(":") );
205 224
206 mDirty = true; 225 mDirty = true;
207} 226}
208 227
209void KConfig::writeEntry( const QString &key, bool value) 228void KConfig::writeEntry( const QString &key, bool value)
210{ 229{
211 mBoolMap.insert( mGroup + key, value ); 230 mBoolMap.insert( mGroup + key, value );
212 231
213 mDirty = true; 232 mDirty = true;
214} 233}
215 234
216void KConfig::writeEntry( const QString & e, const QColor & c ) 235void KConfig::writeEntry( const QString & e, const QColor & c )
217{ 236{
218 QStringList l; 237 QStringList l;
219 l.append( QString::number ( c.red() ) ); 238 l.append( QString::number ( c.red() ) );
220 l.append( QString::number ( c.green() ) ); 239 l.append( QString::number ( c.green() ) );
221 l.append( QString::number ( c.blue() ) ); 240 l.append( QString::number ( c.blue() ) );
222 writeEntry( e, l ); 241 writeEntry( e, l );
223} 242}
224 243
244void KConfig::writeEntry( const QString & e, const QSize & s )
245{
246 QValueList<int> intlist;
247 intlist << s.width() << s.height();
248 writeEntry( e, intlist );
249}
250
225void KConfig::writeEntry( const QString & e , const QFont & f ) 251void KConfig::writeEntry( const QString & e , const QFont & f )
226{ 252{
227 QStringList font; 253 QStringList font;
228 font.append( f.family()); 254 font.append( f.family());
229 font.append( (!f.bold ()?"nonbold":"bold") ); 255 font.append( (!f.bold ()?"nonbold":"bold") );
230 font.append( QString::number ( f.pointSize () ) ); 256 font.append( QString::number ( f.pointSize () ) );
231 font.append( !f.italic ()?"nonitalic":"italic" ); 257 font.append( !f.italic ()?"nonitalic":"italic" );
232 writeEntry( e, font ); 258 writeEntry( e, font );
233} 259}
234 260
235void KConfig::writeEntry( const QString &key, const QDateTime &dt ) 261void KConfig::writeEntry( const QString &key, const QDateTime &dt )
236{ 262{
237 mDateTimeMap.insert( mGroup + key, dt ); 263 mDateTimeMap.insert( mGroup + key, dt );
238} 264}
239 265
240void KConfig::load() 266void KConfig::load()
241{ 267{
242 268
243 269
244 QFile f( mFileName ); 270 QFile f( mFileName );
245 if ( !f.open( IO_ReadOnly ) ) { 271 if ( !f.open( IO_ReadOnly ) ) {
246 qDebug("KConfig: could not open file %s ",mFileName.latin1() ); 272 qDebug("KConfig: could not open file %s ",mFileName.latin1() );
247 return; 273 return;
248 } 274 }
249 275
250 mBoolMap.clear(); 276 mBoolMap.clear();
251 mStringMap.clear(); 277 mStringMap.clear();
252 278
253 QTextStream t( &f ); 279 QTextStream t( &f );
254 280
255 QString line = t.readLine(); 281 QString line = t.readLine();
256 282
257 while ( !line.isNull() ) { 283 while ( !line.isNull() ) {
258 QStringList tokens = QStringList::split( ",", line ); 284 QStringList tokens = QStringList::split( ",", line );
259 if ( tokens[0] == "bool" ) { 285 if ( tokens[0] == "bool" ) {
260 bool value = false; 286 bool value = false;
261 if ( tokens[2] == "1" ) value = true; 287 if ( tokens[2] == "1" ) value = true;
262 mBoolMap.insert( tokens[1], value ); 288 mBoolMap.insert( tokens[1], value );
263 } else if ( tokens[0] == "QString" ) { 289 } else if ( tokens[0] == "QString" ) {
264 QString value = tokens[2]; 290 QString value = tokens[2];
265 mStringMap.insert( tokens[1], value ); 291 mStringMap.insert( tokens[1], value );
266 } else if ( tokens[0] == "QDateTime" ) { 292 } else if ( tokens[0] == "QDateTime" ) {
267#if 0 293#if 0
268 int year = tokens[2].toInt(); 294 int year = tokens[2].toInt();
269 QDateTime dt( QDate( year, 295 QDateTime dt( QDate( year,
270 tokens[3].toInt(), 296 tokens[3].toInt(),
271 tokens[4].toInt() ), 297 tokens[4].toInt() ),
272 QTime( tokens[5].toInt(), tokens[6].toInt(), 298 QTime( tokens[5].toInt(), tokens[6].toInt(),
273 tokens[7].toInt() ) ); 299 tokens[7].toInt() ) );
274 mDateTimeMap.insert( tokens[1], dt ); 300 mDateTimeMap.insert( tokens[1], dt );
275#endif 301#endif
276 } 302 }
277 303
278 line = t.readLine(); 304 line = t.readLine();
279 } 305 }
280} 306}
281 307
282void KConfig::sync() 308void KConfig::sync()
283{ 309{
284 310
285 if ( !mDirty ) return; 311 if ( !mDirty ) return;
286 //qDebug("KConfig::sync() %s ",mFileName.latin1() ); 312 //qDebug("KConfig::sync() %s ",mFileName.latin1() );
287 //kdDebug() << "KConfig::sync(): " << mFileName << endl; 313 //kdDebug() << "KConfig::sync(): " << mFileName << endl;
288 314
289//US I took the following code from a newer version of KDE 315//US I took the following code from a newer version of KDE
290 // Create the containing dir if needed 316 // Create the containing dir if needed
291 KURL path; 317 KURL path;
292 path.setPath(mFileName); 318 path.setPath(mFileName);
293 QString dir=path.directory(); 319 QString dir=path.directory();
294 KStandardDirs::makeDir(dir); 320 KStandardDirs::makeDir(dir);
295 321
296 QFile f( mFileName ); 322 QFile f( mFileName );
297 if ( !f.open( IO_WriteOnly ) ) { 323 if ( !f.open( IO_WriteOnly ) ) {
298 324
299 qDebug("KConfig::sync() Can't open file %s ",mFileName.latin1() ); 325 qDebug("KConfig::sync() Can't open file %s ",mFileName.latin1() );
300 326
301 return; 327 return;
302 } 328 }
303 329
304 QTextStream t( &f ); 330 QTextStream t( &f );
305 331
306 QMap<QString,bool>::ConstIterator itBool; 332 QMap<QString,bool>::ConstIterator itBool;
307 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) { 333 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) {
308 t << "bool," << itBool.key() << "," << ( *itBool ? "1" : "0" ) << endl; 334 t << "bool," << itBool.key() << "," << ( *itBool ? "1" : "0" ) << endl;
309 } 335 }
310 336
311 QMap<QString,QString>::ConstIterator itString; 337 QMap<QString,QString>::ConstIterator itString;
312 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) { 338 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) {
313 t << "QString," << itString.key() << "," << (*itString ) << endl; 339 t << "QString," << itString.key() << "," << (*itString ) << endl;
314 } 340 }
315 341
316 QMap<QString,QDateTime>::ConstIterator itDateTime; 342 QMap<QString,QDateTime>::ConstIterator itDateTime;
317 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) { 343 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) {
318 QDateTime dt = *itDateTime; 344 QDateTime dt = *itDateTime;
319 t << "QDateTime," << itDateTime.key() << "," 345 t << "QDateTime," << itDateTime.key() << ","
320 << dt.date().year() << "," 346 << dt.date().year() << ","
321 << dt.date().month() << "," 347 << dt.date().month() << ","
322 << dt.date().day() << "," 348 << dt.date().day() << ","
323 << dt.time().hour() << "," 349 << dt.time().hour() << ","
324 << dt.time().minute() << "," 350 << dt.time().minute() << ","
325 << dt.time().second() << endl; 351 << dt.time().second() << endl;
326 } 352 }
327 353
328 f.close(); 354 f.close();
329 355
330 mDirty = false; 356 mDirty = false;
331} 357}
332 358
333 359
334//US I took the following deleteGroup method from a newer version from KDE. 360//US I took the following deleteGroup method from a newer version from KDE.
335/** 361/**
336 * Deletes a configuration entry group 362 * Deletes a configuration entry group
337 * 363 *
338 * If the group is not empty and bDeep is false, nothing gets 364 * If the group is not empty and bDeep is false, nothing gets
339 * deleted and false is returned. 365 * deleted and false is returned.
340 * If this group is the current group and it is deleted, the 366 * If this group is the current group and it is deleted, the
341 * current group is undefined and should be set with setGroup() 367 * current group is undefined and should be set with setGroup()
342 * before the next operation on the configuration object. 368 * before the next operation on the configuration object.
343 * 369 *
344 * @param group The name of the group 370 * @param group The name of the group
345 * returns true if we deleted at least one entry. 371 * returns true if we deleted at least one entry.
346 */ 372 */
347bool KConfig::deleteGroup( const QString& group) 373bool KConfig::deleteGroup( const QString& group)
348{ 374{
349 bool dirty = false; 375 bool dirty = false;
350 int pos; 376 int pos;
351 377
352 QMap<QString,bool>::Iterator itBool = mBoolMap.begin(); 378 QMap<QString,bool>::Iterator itBool = mBoolMap.begin();
353 QMap<QString,bool>::Iterator delBool; 379 QMap<QString,bool>::Iterator delBool;
354 380
355 while ( itBool != mBoolMap.end() ) { 381 while ( itBool != mBoolMap.end() ) {
356 pos = itBool.key().find( group ); 382 pos = itBool.key().find( group );
357 if (pos == 0) { 383 if (pos == 0) {
358 delBool = itBool; 384 delBool = itBool;
359 ++itBool; 385 ++itBool;
360 mBoolMap.remove(delBool); 386 mBoolMap.remove(delBool);
361 dirty = true; 387 dirty = true;
362 } else 388 } else
363 ++itBool; 389 ++itBool;
364 390
365 } 391 }
366 /* 392 /*
367 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) 393 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool )
368 { 394 {
369 pos = itBool.key().find( group ); 395 pos = itBool.key().find( group );
370 if (pos == 0) { 396 if (pos == 0) {
371 mBoolMap.remove(itBool); 397 mBoolMap.remove(itBool);
372 dirty = true; 398 dirty = true;
373 } 399 }
374 } 400 }
375 */ 401 */
376 QMap<QString,QString>::Iterator itString = mStringMap.begin(); 402 QMap<QString,QString>::Iterator itString = mStringMap.begin();
377 QMap<QString,QString>::Iterator delString ; 403 QMap<QString,QString>::Iterator delString ;
378 while( itString != mStringMap.end() ) { 404 while( itString != mStringMap.end() ) {
379 pos = itString.key().find( group ); 405 pos = itString.key().find( group );
380 if (pos == 0) { 406 if (pos == 0) {
381 delString = itString; 407 delString = itString;
382 ++itString; 408 ++itString;
383 mStringMap.remove(delString); 409 mStringMap.remove(delString);
384 //qDebug("delte++++++++++++++++++ "); 410 //qDebug("delte++++++++++++++++++ ");
385 dirty = true; 411 dirty = true;
386 } else 412 } else
387 ++itString; 413 ++itString;
388 414
389 } 415 }
390 /* this leads to a memory access violation 416 /* this leads to a memory access violation
391 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) 417 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString )
392 { 418 {
393 pos = itString.key().find( group ); 419 pos = itString.key().find( group );
394 if (pos == 0) { 420 if (pos == 0) {
395 mStringMap.remove(itString); 421 mStringMap.remove(itString);
396 dirty = true; 422 dirty = true;
397 } 423 }
398 } 424 }
399 */ 425 */
400 QMap<QString,QDateTime>::Iterator itDateTime= mDateTimeMap.begin(); 426 QMap<QString,QDateTime>::Iterator itDateTime= mDateTimeMap.begin();
401 QMap<QString,QDateTime>::Iterator delDateTime; 427 QMap<QString,QDateTime>::Iterator delDateTime;
402 while ( itDateTime != mDateTimeMap.end() ) { 428 while ( itDateTime != mDateTimeMap.end() ) {
403 pos = itDateTime.key().find( group ); 429 pos = itDateTime.key().find( group );
404 if (pos == 0) { 430 if (pos == 0) {
405 delDateTime = itDateTime; 431 delDateTime = itDateTime;
406 ++itDateTime; 432 ++itDateTime;
407 mDateTimeMap.remove(delDateTime); 433 mDateTimeMap.remove(delDateTime);
408 dirty = true; 434 dirty = true;
409 } else 435 } else
410 ++itDateTime; 436 ++itDateTime;
411 437
412 } 438 }
413 /* 439 /*
414 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) 440 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime )
415 { 441 {
416 pos = itDateTime.key().find( group ); 442 pos = itDateTime.key().find( group );
417 if (pos == 0) { 443 if (pos == 0) {
418 mDateTimeMap.remove(itDateTime); 444 mDateTimeMap.remove(itDateTime);
419 dirty = true; 445 dirty = true;
420 } 446 }
421 } 447 }
422 */ 448 */
423 449
424 if (dirty) 450 if (dirty)
425 mDirty = true; 451 mDirty = true;
426 452
427 return dirty; 453 return dirty;
428 454
429} 455}
430 456
431//US I took the following hasGroup method from a newer version from KDE. 457//US I took the following hasGroup method from a newer version from KDE.
432 /** 458 /**
433 * Returns true if the specified group is known about. 459 * Returns true if the specified group is known about.
434 * 460 *
435 * @param group The group to search for. 461 * @param group The group to search for.
436 * @return Whether the group exists. 462 * @return Whether the group exists.
437 */ 463 */
438bool KConfig::hasGroup(const QString &group) const 464bool KConfig::hasGroup(const QString &group) const
439{ 465{
440 QMap<QString,bool>::ConstIterator itBool; 466 QMap<QString,bool>::ConstIterator itBool;
441 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) 467 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool )
442 { 468 {
443 if (itBool.key().find( group ) == 0) { 469 if (itBool.key().find( group ) == 0) {
444 return true; 470 return true;
445 } 471 }
446 } 472 }
447 473
448 QMap<QString,QString>::ConstIterator itString; 474 QMap<QString,QString>::ConstIterator itString;
449 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) 475 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString )
450 { 476 {
451 if (itString.key().find( group ) == 0) { 477 if (itString.key().find( group ) == 0) {
452 return true; 478 return true;
453 } 479 }
454 } 480 }
455 481
456 QMap<QString,QDateTime>::ConstIterator itDateTime; 482 QMap<QString,QDateTime>::ConstIterator itDateTime;
457 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) 483 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime )
458 { 484 {
459 if (itDateTime.key().find( group ) == 0) { 485 if (itDateTime.key().find( group ) == 0) {
460 return true; 486 return true;
461 } 487 }
462 } 488 }
463 489
464 return false; 490 return false;
465} 491}
466 492
467void KConfig::deleteEntry( const QString &key) 493void KConfig::deleteEntry( const QString &key)
468{ 494{
469 bool dirty = false; 495 bool dirty = false;
470 496
471 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key ); 497 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key );
472 if ( itBool != mBoolMap.end() ) { 498 if ( itBool != mBoolMap.end() ) {
473 mBoolMap.remove(itBool); 499 mBoolMap.remove(itBool);
474 dirty = true; 500 dirty = true;
475 } 501 }
476 502
477 503
478 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key ); 504 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key );
479 if ( itString != mStringMap.end() ) { 505 if ( itString != mStringMap.end() ) {
480 mStringMap.remove(itString); 506 mStringMap.remove(itString);
481 dirty = true; 507 dirty = true;
482 } 508 }
483 509
484 510
485 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key ); 511 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key );
486 if ( itDateTime != mDateTimeMap.end() ) { 512 if ( itDateTime != mDateTimeMap.end() ) {
487 mDateTimeMap.remove(itDateTime); 513 mDateTimeMap.remove(itDateTime);
488 dirty = true; 514 dirty = true;
489 } 515 }
490 516
491 if (dirty) 517 if (dirty)
492 mDirty = true; 518 mDirty = true;
493 519
494} 520}
495 521
496//US 522//US
497QString KConfig::getFileName() 523QString KConfig::getFileName()
498{ 524{
499 return mFileName; 525 return mFileName;
500} 526}
501 527
502bool KConfig::hasKey( const QString &key) 528bool KConfig::hasKey( const QString &key)
503{ 529{
504 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key ); 530 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key );
505 if ( itBool != mBoolMap.end() ) { 531 if ( itBool != mBoolMap.end() ) {
506 return true; 532 return true;
507 } 533 }
508 534
509 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key ); 535 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key );
510 if ( itString != mStringMap.end() ) { 536 if ( itString != mStringMap.end() ) {
511 return true; 537 return true;
512 } 538 }
513 539
514 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key ); 540 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key );
515 if ( itDateTime != mDateTimeMap.end() ) { 541 if ( itDateTime != mDateTimeMap.end() ) {
516 return true; 542 return true;
517 } 543 }
518 544
519 return false; 545 return false;
520} 546}
521 547
diff --git a/microkde/kconfig.h b/microkde/kconfig.h
index a01b1a5..1a1038f 100644
--- a/microkde/kconfig.h
+++ b/microkde/kconfig.h
@@ -1,104 +1,105 @@
1#ifndef MINIKDE_KCONFIG_H 1#ifndef MINIKDE_KCONFIG_H
2#define MINIKDE_KCONFIG_H 2#define MINIKDE_KCONFIG_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qstringlist.h> 5#include <qstringlist.h>
6#include <qvaluelist.h> 6#include <qvaluelist.h>
7#include <qcolor.h> 7#include <qcolor.h>
8#include <qfont.h> 8#include <qfont.h>
9#include <qmap.h> 9#include <qmap.h>
10#include <qdatetime.h> 10#include <qdatetime.h>
11 11
12class KConfig 12class KConfig
13{ 13{
14 public: 14 public:
15 KConfig( const QString & ); 15 KConfig( const QString & );
16 ~KConfig(); 16 ~KConfig();
17 17
18 void setTempGroup( const QString &group ); 18 void setTempGroup( const QString &group );
19 QString tempGroup() const; 19 QString tempGroup() const;
20 20
21 void setGroup( const QString & ); 21 void setGroup( const QString & );
22 22
23//US 23//US
24 /** 24 /**
25 * Returns the name of the group in which we are 25 * Returns the name of the group in which we are
26 * searching for keys and from which we are retrieving entries. 26 * searching for keys and from which we are retrieving entries.
27 * 27 *
28 * @return The current group. 28 * @return The current group.
29 */ 29 */
30 QString group() const; 30 QString group() const;
31 31
32//US I took the following deleteGroup method from a newer version from KDE. 32//US I took the following deleteGroup method from a newer version from KDE.
33/** 33/**
34 * Deletes a configuration entry group 34 * Deletes a configuration entry group
35 * 35 *
36 * If the group is not empty and bDeep is false, nothing gets 36 * If the group is not empty and bDeep is false, nothing gets
37 * deleted and false is returned. 37 * deleted and false is returned.
38 * If this group is the current group and it is deleted, the 38 * If this group is the current group and it is deleted, the
39 * current group is undefined and should be set with setGroup() 39 * current group is undefined and should be set with setGroup()
40 * before the next operation on the configuration object. 40 * before the next operation on the configuration object.
41 * 41 *
42 * @param group The name of the group 42 * @param group The name of the group
43 * returns true if we deleted at least one entry. 43 * returns true if we deleted at least one entry.
44 */ 44 */
45 bool deleteGroup( const QString& group); 45 bool deleteGroup( const QString& group);
46 46
47//US I took the following hasGroup method from a newer version from KDE. 47//US I took the following hasGroup method from a newer version from KDE.
48 /** 48 /**
49 * Returns true if the specified group is known about. 49 * Returns true if the specified group is known about.
50 * 50 *
51 * @param group The group to search for. 51 * @param group The group to search for.
52 * @return Whether the group exists. 52 * @return Whether the group exists.
53 */ 53 */
54 bool hasGroup(const QString &group) const; 54 bool hasGroup(const QString &group) const;
55 55
56 56
57 QString getFileName(); 57 QString getFileName();
58 58
59//US added method readIntListEntry 59//US added method readIntListEntry
60 QValueList<int> readIntListEntry( const QString &); 60 QValueList<int> readIntListEntry( const QString &);
61 61
62 int readNumEntry( const QString &, int def=0 ); 62 int readNumEntry( const QString &, int def=0 );
63 QString readEntry( const QString &, const QString &def=QString::null ); 63 QString readEntry( const QString &, const QString &def=QString::null );
64 QStringList readListEntry( const QString & ); 64 QStringList readListEntry( const QString & );
65 bool readBoolEntry( const QString &, bool def=false ); 65 bool readBoolEntry( const QString &, bool def=false );
66 QColor readColorEntry( const QString &, QColor * ); 66 QColor readColorEntry( const QString &, QColor * );
67 QFont readFontEntry( const QString &, QFont * ); 67 QFont readFontEntry( const QString &, QFont * );
68 QDateTime readDateTimeEntry( const QString &, const QDateTime *pDefault = 0 ); 68 QDateTime readDateTimeEntry( const QString &, const QDateTime *pDefault = 0 );
69 69 QSize readSizeEntry(const QString &, QSize* );
70 bool hasKey( const QString &); 70 bool hasKey( const QString &);
71 71
72 void writeEntry( const QString &, const QValueList<int>& ); 72 void writeEntry( const QString &, const QValueList<int>& );
73 void writeEntry( const QString &, int ); 73 void writeEntry( const QString &, int );
74 void writeEntry( const QString &key , unsigned int value) { writeEntry( key, int( value ) ); } 74 void writeEntry( const QString &key , unsigned int value) { writeEntry( key, int( value ) ); }
75 void writeEntry( const char *key , unsigned int value) { writeEntry( QString( key ), value ); } 75 void writeEntry( const char *key , unsigned int value) { writeEntry( QString( key ), value ); }
76 void writeEntry( const char *key, int value ) { writeEntry( QString( key ), value ); } 76 void writeEntry( const char *key, int value ) { writeEntry( QString( key ), value ); }
77 void writeEntry( const QString &, const QString & ); 77 void writeEntry( const QString &, const QString & );
78 void writeEntry( const char *key, const QString &value ) { writeEntry( QString( key ), value ); } 78 void writeEntry( const char *key, const QString &value ) { writeEntry( QString( key ), value ); }
79 void writeEntry( const QString &, const QStringList & ); 79 void writeEntry( const QString &, const QStringList & );
80 void writeEntry( const QString &, bool ); 80 void writeEntry( const QString &, bool );
81 void writeEntry( const char *key, bool value ) { writeEntry( QString( key ), value ); } 81 void writeEntry( const char *key, bool value ) { writeEntry( QString( key ), value ); }
82 void writeEntry( const QString &, const QColor & ); 82 void writeEntry( const QString &, const QColor & );
83 void writeEntry( const QString &, const QFont & ); 83 void writeEntry( const QString &, const QFont & );
84 void writeEntry( const QString &, const QDateTime & ); 84 void writeEntry( const QString &, const QDateTime & );
85 void writeEntry( const QString &, const QSize & );
85 86
86 void deleteEntry( const QString &); 87 void deleteEntry( const QString &);
87 88
88 void load(); 89 void load();
89 void sync(); 90 void sync();
90 91
91 private: 92 private:
92 static QString mGroup; 93 static QString mGroup;
93 QString mTempGroup; 94 QString mTempGroup;
94 95
95 QString mFileName; 96 QString mFileName;
96 97
97 QMap<QString,bool> mBoolMap; 98 QMap<QString,bool> mBoolMap;
98 QMap<QString,QString> mStringMap; 99 QMap<QString,QString> mStringMap;
99 QMap<QString,QDateTime> mDateTimeMap; 100 QMap<QString,QDateTime> mDateTimeMap;
100 101
101 bool mDirty; 102 bool mDirty;
102}; 103};
103 104
104#endif 105#endif
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp
index 9d7e60b..4960b9a 100644
--- a/microkde/kdecore/klocale.cpp
+++ b/microkde/kdecore/klocale.cpp
@@ -1,884 +1,915 @@
1#include <qregexp.h> 1#include <qregexp.h>
2#include <qapplication.h> 2#include <qapplication.h>
3 3
4#include "kdebug.h" 4#include "kdebug.h"
5#include "kcalendarsystemgregorian.h" 5#include "kcalendarsystemgregorian.h"
6 6
7#include "klocale.h" 7#include "klocale.h"
8 8
9 9
10QDict<QString> *mLocaleDict = 0; 10QDict<QString> *mLocaleDict = 0;
11void setLocaleDict( QDict<QString> * dict ) 11void setLocaleDict( QDict<QString> * dict )
12{ 12{
13 mLocaleDict = dict; 13 mLocaleDict = dict;
14 14
15} 15}
16QString i18n(const char *text) 16QString i18n(const char *text)
17{ 17{
18 if ( ! mLocaleDict ) 18 if ( ! mLocaleDict )
19 return QString( text ); 19 return QString( text );
20 else { 20 else {
21 QString* ret = mLocaleDict->find(QString(text)) ; 21 QString* ret = mLocaleDict->find(QString(text)) ;
22 if ( ret == 0 ) { 22 if ( ret == 0 ) {
23 return QString( text ); 23 return QString( text );
24 } 24 }
25 else { 25 else {
26 if ( (*ret).isEmpty() ) 26 if ( (*ret).isEmpty() )
27 return QString( text ); 27 return QString( text );
28 else 28 else
29 return (*ret); 29 return (*ret);
30 } 30 }
31 } 31 }
32 32
33} 33}
34 34
35QString i18n(const char *,const char *text) 35QString i18n(const char *,const char *text)
36{ 36{
37 return i18n( text ); 37 return i18n( text );
38} 38}
39 39
40QString i18n(const char *text1, const char *textn, int num) 40QString i18n(const char *text1, const char *textn, int num)
41{ 41{
42 if ( num == 1 ) return i18n( text1 ); 42 if ( num == 1 ) return i18n( text1 );
43 else { 43 else {
44 QString text = i18n( textn ); 44 QString text = i18n( textn );
45 int pos = text.find( "%n" ); 45 int pos = text.find( "%n" );
46 if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) ); 46 if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) );
47 return text; 47 return text;
48 } 48 }
49} 49}
50 50
51inline void put_it_in( QChar *buffer, uint& index, const QString &s ) 51inline void put_it_in( QChar *buffer, uint& index, const QString &s )
52{ 52{
53 for ( uint l = 0; l < s.length(); l++ ) 53 for ( uint l = 0; l < s.length(); l++ )
54 buffer[index++] = s.at( l ); 54 buffer[index++] = s.at( l );
55} 55}
56 56
57inline void put_it_in( QChar *buffer, uint& index, int number ) 57inline void put_it_in( QChar *buffer, uint& index, int number )
58{ 58{
59 buffer[index++] = number / 10 + '0'; 59 buffer[index++] = number / 10 + '0';
60 buffer[index++] = number % 10 + '0'; 60 buffer[index++] = number % 10 + '0';
61} 61}
62 62
63static int readInt(const QString &str, uint &pos) 63static int readInt(const QString &str, uint &pos)
64{ 64{
65 if (!str.at(pos).isDigit()) return -1; 65 if (!str.at(pos).isDigit()) return -1;
66 int result = 0; 66 int result = 0;
67 for (; str.length() > pos && str.at(pos).isDigit(); pos++) 67 for (; str.length() > pos && str.at(pos).isDigit(); pos++)
68 { 68 {
69 result *= 10; 69 result *= 10;
70 result += str.at(pos).digitValue(); 70 result += str.at(pos).digitValue();
71 } 71 }
72 72
73 return result; 73 return result;
74} 74}
75 75
76KLocale::KLocale() : mCalendarSystem( 0 ) 76KLocale::KLocale() : mCalendarSystem( 0 )
77{ 77{
78 78
79 m_decimalSymbol = "."; 79 m_decimalSymbol = ".";
80 m_positiveSign = ""; 80 m_positiveSign = "";
81 m_negativeSign = "-"; 81 m_negativeSign = "-";
82 m_thousandsSeparator = ","; 82 m_thousandsSeparator = ",";
83 83
84 84
85 85
86 86
87 mWeekStartsMonday = true; 87 mWeekStartsMonday = true;
88 mHourF24Format = true; 88 mHourF24Format = true;
89 mIntDateFormat = Default; 89 mIntDateFormat = Default;
90 mIntTimeFormat = Default;
90 mLanguage = 0; 91 mLanguage = 0;
91 mDateFormat = "%a %Y %b %d"; 92 mDateFormat = "%a %Y %b %d";
92 mDateFormatShort = "%Y-%m-%d"; 93 mDateFormatShort = "%Y-%m-%d";
93 mTimeZoneList << i18n ("-11:00 US/Samoa") 94 mTimeZoneList << i18n ("-11:00 US/Samoa")
94 << i18n ("-10:00 US/Hawaii") 95 << i18n ("-10:00 US/Hawaii")
95 << i18n ("-09:00 US/Alaska") 96 << i18n ("-09:00 US/Alaska")
96 << i18n ("-08:00 US/Pacific") 97 << i18n ("-08:00 US/Pacific")
97 << i18n ("-07:00 US/Mountain") 98 << i18n ("-07:00 US/Mountain")
98 << i18n ("-06:00 US/Central") 99 << i18n ("-06:00 US/Central")
99 << i18n ("-05:00 US/Eastern") 100 << i18n ("-05:00 US/Eastern")
100 << i18n ("-04:00 Brazil/West") 101 << i18n ("-04:00 Brazil/West")
101 << i18n ("-03:00 Brazil/East") 102 << i18n ("-03:00 Brazil/East")
102 << i18n ("-02:00 Brazil/DeNoronha") 103 << i18n ("-02:00 Brazil/DeNoronha")
103 << i18n ("-01:00 Atlantic/Azores") 104 << i18n ("-01:00 Atlantic/Azores")
104 << i18n (" 00:00 Europe/London(UTC)") 105 << i18n (" 00:00 Europe/London(UTC)")
105 << i18n ("+01:00 Europe/Oslo(CET)") 106 << i18n ("+01:00 Europe/Oslo(CET)")
106 << i18n ("+02:00 Europe/Helsinki") 107 << i18n ("+02:00 Europe/Helsinki")
107 << i18n ("+03:00 Europe/Moscow") 108 << i18n ("+03:00 Europe/Moscow")
108 << i18n ("+04:00 Indian/Mauritius") 109 << i18n ("+04:00 Indian/Mauritius")
109 << i18n ("+05:00 Indian/Maldives") 110 << i18n ("+05:00 Indian/Maldives")
110 << i18n ("+06:00 Indian/Chagos") 111 << i18n ("+06:00 Indian/Chagos")
111 << i18n ("+07:00 Asia/Bangkok") 112 << i18n ("+07:00 Asia/Bangkok")
112 << i18n ("+08:00 Asia/Hongkong") 113 << i18n ("+08:00 Asia/Hongkong")
113 << i18n ("+09:00 Asia/Tokyo") 114 << i18n ("+09:00 Asia/Tokyo")
114 << i18n ("+10:00 Asia/Vladivostok") 115 << i18n ("+10:00 Asia/Vladivostok")
115 << i18n ("+11:00 Asia/Magadan") 116 << i18n ("+11:00 Asia/Magadan")
116 << i18n ("+12:00 Asia/Kamchatka") 117 << i18n ("+12:00 Asia/Kamchatka")
117 // << i18n (" xx:xx User defined offset") 118 // << i18n (" xx:xx User defined offset")
118 << i18n (" Local Time"); 119 << i18n (" Local Time");
119 mSouthDaylight = false; 120 mSouthDaylight = false;
120 mTimeZoneOffset = 0; 121 mTimeZoneOffset = 0;
121 daylightEnabled = false; 122 daylightEnabled = false;
122} 123}
123 124
124void KLocale::setDateFormat( QString s ) 125void KLocale::setDateFormat( QString s )
125{ 126{
126 mDateFormat = s; 127 mDateFormat = s;
127} 128}
128 129
129void KLocale::setDateFormatShort( QString s ) 130void KLocale::setDateFormatShort( QString s )
130{ 131{
131 mDateFormatShort = s; 132 mDateFormatShort = s;
132} 133}
133 134
134void KLocale::setHore24Format ( bool b ) 135void KLocale::setHore24Format ( bool b )
135{ 136{
136 mHourF24Format = b; 137 mHourF24Format = b;
137} 138}
138void KLocale::setWeekStartMonday( bool b ) 139void KLocale::setWeekStartMonday( bool b )
139{ 140{
140 mWeekStartsMonday = b; 141 mWeekStartsMonday = b;
141} 142}
143
142KLocale::IntDateFormat KLocale::getIntDateFormat( ) 144KLocale::IntDateFormat KLocale::getIntDateFormat( )
143{ 145{
144 return mIntDateFormat; 146 return mIntDateFormat;
145 147
146} 148}
147void KLocale::setIntDateFormat( KLocale::IntDateFormat i ) 149void KLocale::setIntDateFormat( KLocale::IntDateFormat i )
148{ 150{
149 mIntDateFormat = i; 151 mIntDateFormat = i;
150} 152}
153KLocale::IntDateFormat KLocale::getIntTimeFormat( )
154{
155 return mIntTimeFormat;
156
157}
158void KLocale::setIntTimeFormat( KLocale::IntDateFormat i )
159{
160 mIntTimeFormat = i;
161}
162
151void KLocale::setLanguage( int i ) 163void KLocale::setLanguage( int i )
152{ 164{
153 mLanguage = i; 165 mLanguage = i;
154} 166}
155QString KLocale::translate( const char *index ) const 167QString KLocale::translate( const char *index ) const
156{ 168{
157 return i18n( index ); 169 return i18n( index );
158} 170}
159 171
160QString KLocale::translate( const char *, const char *fallback) const 172QString KLocale::translate( const char *, const char *fallback) const
161{ 173{
162 return i18n( fallback ); 174 return i18n( fallback );
163} 175}
164 176
165QString KLocale::formatTime(const QTime &pTime, bool includeSecs) const 177QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const
166{ 178{
167 const QString rst = timeFormat(); 179 const QString rst = timeFormat(intIntDateFormat);
168 180
169 // only "pm/am" here can grow, the rest shrinks, but 181 // only "pm/am" here can grow, the rest shrinks, but
170 // I'm rather safe than sorry 182 // I'm rather safe than sorry
171 QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; 183 QChar *buffer = new QChar[rst.length() * 3 / 2 + 30];
172 184
173 uint index = 0; 185 uint index = 0;
174 bool escape = false; 186 bool escape = false;
175 int number = 0; 187 int number = 0;
176 188
177 for ( uint format_index = 0; format_index < rst.length(); format_index++ ) 189 for ( uint format_index = 0; format_index < rst.length(); format_index++ )
178 { 190 {
179 if ( !escape ) 191 if ( !escape )
180 { 192 {
181 if ( rst.at( format_index ).unicode() == '%' ) 193 if ( rst.at( format_index ).unicode() == '%' )
182 escape = true; 194 escape = true;
183 else 195 else
184 buffer[index++] = rst.at( format_index ); 196 buffer[index++] = rst.at( format_index );
185 } 197 }
186 else 198 else
187 { 199 {
188 switch ( rst.at( format_index ).unicode() ) 200 switch ( rst.at( format_index ).unicode() )
189 { 201 {
190 case '%': 202 case '%':
191 buffer[index++] = '%'; 203 buffer[index++] = '%';
192 break; 204 break;
193 case 'H': 205 case 'H':
194 put_it_in( buffer, index, pTime.hour() ); 206 put_it_in( buffer, index, pTime.hour() );
195 break; 207 break;
196 case 'I': 208 case 'I':
197 put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); 209 put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 );
198 break; 210 break;
199 case 'M': 211 case 'M':
200 put_it_in( buffer, index, pTime.minute() ); 212 put_it_in( buffer, index, pTime.minute() );
201 break; 213 break;
202 case 'S': 214 case 'S':
203 if (includeSecs) 215 if (includeSecs)
204 put_it_in( buffer, index, pTime.second() ); 216 put_it_in( buffer, index, pTime.second() );
205 else 217 else
206 { 218 {
207 // we remove the seperator sign before the seconds and 219 // we remove the seperator sign before the seconds and
208 // assume that works everywhere 220 // assume that works everywhere
209 --index; 221 --index;
210 break; 222 break;
211 } 223 }
212 break; 224 break;
213 case 'k': 225 case 'k':
214 number = pTime.hour(); 226 number = pTime.hour();
215 case 'l': 227 case 'l':
216 // to share the code 228 // to share the code
217 if ( rst.at( format_index ).unicode() == 'l' ) 229 if ( rst.at( format_index ).unicode() == 'l' )
218 number = (pTime.hour() + 11) % 12 + 1; 230 number = (pTime.hour() + 11) % 12 + 1;
219 if ( number / 10 ) 231 if ( number / 10 )
220 buffer[index++] = number / 10 + '0'; 232 buffer[index++] = number / 10 + '0';
221 buffer[index++] = number % 10 + '0'; 233 buffer[index++] = number % 10 + '0';
222 break; 234 break;
223 case 'p': 235 case 'p':
224 { 236 {
225 QString s; 237 QString s;
226 if ( pTime.hour() >= 12 ) 238 if ( pTime.hour() >= 12 )
227 put_it_in( buffer, index, i18n("pm") ); 239 put_it_in( buffer, index, i18n("pm") );
228 else 240 else
229 put_it_in( buffer, index, i18n("am") ); 241 put_it_in( buffer, index, i18n("am") );
230 break; 242 break;
231 } 243 }
232 default: 244 default:
233 buffer[index++] = rst.at( format_index ); 245 buffer[index++] = rst.at( format_index );
234 break; 246 break;
235 } 247 }
236 escape = false; 248 escape = false;
237 } 249 }
238 } 250 }
239 QString ret( buffer, index ); 251 QString ret( buffer, index );
240 delete [] buffer; 252 delete [] buffer;
241 return ret; 253 return ret;
242} 254}
243 255
244QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const 256QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const
245{ 257{
246 const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat); 258 const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat);
247 259
248 // I'm rather safe than sorry 260 // I'm rather safe than sorry
249 QChar *buffer = new QChar[rst.length() * 3 / 2 + 50]; 261 QChar *buffer = new QChar[rst.length() * 3 / 2 + 50];
250 262
251 unsigned int index = 0; 263 unsigned int index = 0;
252 bool escape = false; 264 bool escape = false;
253 int number = 0; 265 int number = 0;
254 266
255 for ( uint format_index = 0; format_index < rst.length(); ++format_index ) 267 for ( uint format_index = 0; format_index < rst.length(); ++format_index )
256 { 268 {
257 if ( !escape ) 269 if ( !escape )
258 { 270 {
259 if ( rst.at( format_index ).unicode() == '%' ) 271 if ( rst.at( format_index ).unicode() == '%' )
260 escape = true; 272 escape = true;
261 else 273 else
262 buffer[index++] = rst.at( format_index ); 274 buffer[index++] = rst.at( format_index );
263 } 275 }
264 else 276 else
265 { 277 {
266 switch ( rst.at( format_index ).unicode() ) 278 switch ( rst.at( format_index ).unicode() )
267 { 279 {
268 case '%': 280 case '%':
269 buffer[index++] = '%'; 281 buffer[index++] = '%';
270 break; 282 break;
271 case 'Y': 283 case 'Y':
272 put_it_in( buffer, index, pDate.year() / 100 ); 284 put_it_in( buffer, index, pDate.year() / 100 );
273 case 'y': 285 case 'y':
274 put_it_in( buffer, index, pDate.year() % 100 ); 286 put_it_in( buffer, index, pDate.year() % 100 );
275 break; 287 break;
276 case 'n': 288 case 'n':
277 number = pDate.month(); 289 number = pDate.month();
278 case 'e': 290 case 'e':
279 // to share the code 291 // to share the code
280 if ( rst.at( format_index ).unicode() == 'e' ) 292 if ( rst.at( format_index ).unicode() == 'e' )
281 number = pDate.day(); 293 number = pDate.day();
282 if ( number / 10 ) 294 if ( number / 10 )
283 buffer[index++] = number / 10 + '0'; 295 buffer[index++] = number / 10 + '0';
284 buffer[index++] = number % 10 + '0'; 296 buffer[index++] = number % 10 + '0';
285 break; 297 break;
286 case 'm': 298 case 'm':
287 put_it_in( buffer, index, pDate.month() ); 299 put_it_in( buffer, index, pDate.month() );
288 break; 300 break;
289 case 'b': 301 case 'b':
290 put_it_in( buffer, index, monthName(pDate.month(), true) ); 302 put_it_in( buffer, index, monthName(pDate.month(), true) );
291 break; 303 break;
292 case 'B': 304 case 'B':
293 put_it_in( buffer, index, monthName(pDate.month(), false) ); 305 put_it_in( buffer, index, monthName(pDate.month(), false) );
294 break; 306 break;
295 case 'd': 307 case 'd':
296 put_it_in( buffer, index, pDate.day() ); 308 put_it_in( buffer, index, pDate.day() );
297 break; 309 break;
298 case 'a': 310 case 'a':
299 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) ); 311 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) );
300 break; 312 break;
301 case 'A': 313 case 'A':
302 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) ); 314 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) );
303 break; 315 break;
304 default: 316 default:
305 buffer[index++] = rst.at( format_index ); 317 buffer[index++] = rst.at( format_index );
306 break; 318 break;
307 } 319 }
308 escape = false; 320 escape = false;
309 } 321 }
310 } 322 }
311 QString ret( buffer, index ); 323 QString ret( buffer, index );
312 delete [] buffer; 324 delete [] buffer;
313 return ret; 325 return ret;
314} 326}
315 327
316QString KLocale::formatDateTime(const QDateTime &pDateTime, 328QString KLocale::formatDateTime(const QDateTime &pDateTime,
317 bool shortFormat, 329 bool shortFormat,
318 bool includeSeconds) const 330 bool includeSeconds,
331 IntDateFormat intIntDateFormat) const
319{ 332{
320 return QString( "%1 %2") 333 return QString( "%1 %2")
321 .arg( formatDate( pDateTime.date(), shortFormat ) ) 334 .arg( formatDate( pDateTime.date(), shortFormat, intIntDateFormat ) )
322 .arg( formatTime( pDateTime.time(), includeSeconds ) ); 335 .arg( formatTime( pDateTime.time(), includeSeconds , intIntDateFormat ) );
323} 336}
324 337
325QString KLocale::formatDateTime(const QDateTime &pDateTime) const 338QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const
326{ 339{
327 return formatDateTime(pDateTime, true); 340 return formatDateTime(pDateTime, true, intIntDateFormat);
328} 341}
329 342
330QDate KLocale::readDate(const QString &intstr, bool* ok) const 343QDate KLocale::readDate(const QString &intstr, bool* ok) const
331{ 344{
332 QDate date; 345 QDate date;
333 date = readDate(intstr, true, ok); 346 date = readDate(intstr, true, ok);
334 if (date.isValid()) return date; 347 if (date.isValid()) return date;
335 return readDate(intstr, false, ok); 348 return readDate(intstr, false, ok);
336} 349}
337 350
338QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const 351QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const
339{ 352{
340 QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); 353 QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace();
341 return readDate( intstr, fmt, ok ); 354 return readDate( intstr, fmt, ok );
342} 355}
343 356
344QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const 357QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const
345{ 358{
346 //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; 359 //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl;
347 QString str = intstr.simplifyWhiteSpace().lower(); 360 QString str = intstr.simplifyWhiteSpace().lower();
348 int day = -1, month = -1; 361 int day = -1, month = -1;
349 // allow the year to be omitted if not in the format 362 // allow the year to be omitted if not in the format
350 int year = QDate::currentDate().year(); 363 int year = QDate::currentDate().year();
351 uint strpos = 0; 364 uint strpos = 0;
352 uint fmtpos = 0; 365 uint fmtpos = 0;
353 366
354 while (fmt.length() > fmtpos || str.length() > strpos) 367 while (fmt.length() > fmtpos || str.length() > strpos)
355 { 368 {
356 if ( !(fmt.length() > fmtpos && str.length() > strpos) ) 369 if ( !(fmt.length() > fmtpos && str.length() > strpos) )
357 goto error; 370 goto error;
358 371
359 QChar c = fmt.at(fmtpos++); 372 QChar c = fmt.at(fmtpos++);
360 373
361 if (c != '%') { 374 if (c != '%') {
362 if (c.isSpace()) 375 if (c.isSpace())
363 strpos++; 376 strpos++;
364 else if (c != str.at(strpos++)) 377 else if (c != str.at(strpos++))
365 goto error; 378 goto error;
366 continue; 379 continue;
367 } 380 }
368 381
369 // remove space at the begining 382 // remove space at the begining
370 if (str.length() > strpos && str.at(strpos).isSpace()) 383 if (str.length() > strpos && str.at(strpos).isSpace())
371 strpos++; 384 strpos++;
372 385
373 c = fmt.at(fmtpos++); 386 c = fmt.at(fmtpos++);
374 switch (c) 387 switch (c)
375 { 388 {
376 case 'a': 389 case 'a':
377 case 'A': 390 case 'A':
378 // this will just be ignored 391 // this will just be ignored
379 { // Cristian Tache: porting to Win: Block added because of "j" redefinition 392 { // Cristian Tache: porting to Win: Block added because of "j" redefinition
380 for (int j = 1; j < 8; j++) { 393 for (int j = 1; j < 8; j++) {
381 QString s = weekDayName(j, c == 'a').lower(); 394 QString s = weekDayName(j, c == 'a').lower();
382 int len = s.length(); 395 int len = s.length();
383 if (str.mid(strpos, len) == s) 396 if (str.mid(strpos, len) == s)
384 strpos += len; 397 strpos += len;
385 } 398 }
386 break; 399 break;
387 } 400 }
388 case 'b': 401 case 'b':
389 case 'B': 402 case 'B':
390 { // Cristian Tache: porting to Win: Block added because of "j" redefinition 403 { // Cristian Tache: porting to Win: Block added because of "j" redefinition
391 for (int j = 1; j < 13; j++) { 404 for (int j = 1; j < 13; j++) {
392 QString s = monthName(j, c == 'b').lower(); 405 QString s = monthName(j, c == 'b').lower();
393 int len = s.length(); 406 int len = s.length();
394 if (str.mid(strpos, len) == s) { 407 if (str.mid(strpos, len) == s) {
395 month = j; 408 month = j;
396 strpos += len; 409 strpos += len;
397 } 410 }
398 } 411 }
399 break; 412 break;
400 } 413 }
401 case 'd': 414 case 'd':
402 case 'e': 415 case 'e':
403 day = readInt(str, strpos); 416 day = readInt(str, strpos);
404 if (day < 1 || day > 31) 417 if (day < 1 || day > 31)
405 goto error; 418 goto error;
406 419
407 break; 420 break;
408 421
409 case 'n': 422 case 'n':
410 case 'm': 423 case 'm':
411 month = readInt(str, strpos); 424 month = readInt(str, strpos);
412 if (month < 1 || month > 12) 425 if (month < 1 || month > 12)
413 goto error; 426 goto error;
414 427
415 break; 428 break;
416 429
417 case 'Y': 430 case 'Y':
418 case 'y': 431 case 'y':
419 year = readInt(str, strpos); 432 year = readInt(str, strpos);
420 if (year < 0) 433 if (year < 0)
421 goto error; 434 goto error;
422 // Qt treats a year in the range 0-100 as 1900-1999. 435 // Qt treats a year in the range 0-100 as 1900-1999.
423 // It is nicer for the user if we treat 0-68 as 2000-2068 436 // It is nicer for the user if we treat 0-68 as 2000-2068
424 if (year < 69) 437 if (year < 69)
425 year += 2000; 438 year += 2000;
426 else if (c == 'y') 439 else if (c == 'y')
427 year += 1900; 440 year += 1900;
428 441
429 break; 442 break;
430 } 443 }
431 } 444 }
432 //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; 445 //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl;
433 if ( year != -1 && month != -1 && day != -1 ) 446 if ( year != -1 && month != -1 && day != -1 )
434 { 447 {
435 if (ok) *ok = true; 448 if (ok) *ok = true;
436 return QDate(year, month, day); 449 return QDate(year, month, day);
437 } 450 }
438 error: 451 error:
439 if (ok) *ok = false; 452 if (ok) *ok = false;
440 return QDate(); // invalid date 453 return QDate(); // invalid date
441} 454}
442 455
443QTime KLocale::readTime(const QString &intstr, bool *ok) const 456QTime KLocale::readTime(const QString &intstr, bool *ok) const
444{ 457{
445 QTime _time; 458 QTime _time;
446 _time = readTime(intstr, true, ok); 459 _time = readTime(intstr, true, ok);
447 if (_time.isValid()) return _time; 460 if (_time.isValid()) return _time;
448 return readTime(intstr, false, ok); 461 return readTime(intstr, false, ok);
449} 462}
450 463
451QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const 464QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const
452{ 465{
453 QString str = intstr.simplifyWhiteSpace().lower(); 466 QString str = intstr.simplifyWhiteSpace().lower();
454 QString Format = timeFormat().simplifyWhiteSpace(); 467 QString Format = timeFormat().simplifyWhiteSpace();
455 if (!seconds) 468 if (!seconds)
456 Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); 469 Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null);
457 470
458 int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds 471 int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds
472
459 bool g_12h = false; 473 bool g_12h = false;
460 bool pm = false; 474 bool pm = false;
461 uint strpos = 0; 475 uint strpos = 0;
462 uint Formatpos = 0; 476 uint Formatpos = 0;
463 477
464 while (Format.length() > Formatpos || str.length() > strpos) 478 while (Format.length() > Formatpos || str.length() > strpos)
465 { 479 {
466 if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; 480 if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error;
467 481
468 QChar c = Format.at(Formatpos++); 482 QChar c = Format.at(Formatpos++);
469 483
470 if (c != '%') 484 if (c != '%')
471 { 485 {
472 if (c.isSpace()) 486 if (c.isSpace())
473 strpos++; 487 strpos++;
474 else if (c != str.at(strpos++)) 488 else if (c != str.at(strpos++))
475 goto error; 489 goto error;
476 continue; 490 continue;
477 } 491 }
478 492
479 // remove space at the begining 493 // remove space at the begining
480 if (str.length() > strpos && str.at(strpos).isSpace()) 494 if (str.length() > strpos && str.at(strpos).isSpace())
481 strpos++; 495 strpos++;
482 496
483 c = Format.at(Formatpos++); 497 c = Format.at(Formatpos++);
484 switch (c) 498 switch (c)
485 { 499 {
486 case 'p': 500 case 'p':
487 { 501 {
488 QString s; 502 QString s;
489 s = i18n("pm").lower(); 503 s = i18n("pm").lower();
490 int len = s.length(); 504 int len = s.length();
491 if (str.mid(strpos, len) == s) 505 if (str.mid(strpos, len) == s)
492 { 506 {
493 pm = true; 507 pm = true;
494 strpos += len; 508 strpos += len;
495 } 509 }
496 else 510 else
497 { 511 {
498 s = i18n("am").lower(); 512 s = i18n("am").lower();
499 len = s.length(); 513 len = s.length();
500 if (str.mid(strpos, len) == s) { 514 if (str.mid(strpos, len) == s) {
501 pm = false; 515 pm = false;
502 strpos += len; 516 strpos += len;
503 } 517 }
504 else 518 else
505 goto error; 519 goto error;
506 } 520 }
507 } 521 }
508 break; 522 break;
509 523
510 case 'k': 524 case 'k':
511 case 'H': 525 case 'H':
512 g_12h = false; 526 g_12h = false;
513 hour = readInt(str, strpos); 527 hour = readInt(str, strpos);
514 if (hour < 0 || hour > 23) 528 if (hour < 0 || hour > 23)
515 goto error; 529 goto error;
516 530
517 break; 531 break;
518 532
519 case 'l': 533 case 'l':
520 case 'I': 534 case 'I':
521 g_12h = true; 535 g_12h = true;
522 hour = readInt(str, strpos); 536 hour = readInt(str, strpos);
523 if (hour < 1 || hour > 12) 537 if (hour < 1 || hour > 12)
524 goto error; 538 goto error;
525 539
526 break; 540 break;
527 541
528 case 'M': 542 case 'M':
529 minute = readInt(str, strpos); 543 minute = readInt(str, strpos);
530 if (minute < 0 || minute > 59) 544 if (minute < 0 || minute > 59)
531 goto error; 545 goto error;
532 546
533 break; 547 break;
534 548
535 case 'S': 549 case 'S':
536 second = readInt(str, strpos); 550 second = readInt(str, strpos);
537 if (second < 0 || second > 59) 551 if (second < 0 || second > 59)
538 goto error; 552 goto error;
539 553
540 break; 554 break;
541 } 555 }
542 } 556 }
543 if (g_12h) 557 if (g_12h)
544 { 558 {
545 hour %= 12; 559 hour %= 12;
546 if (pm) hour += 12; 560 if (pm) hour += 12;
547 } 561 }
548 562
549 if (ok) *ok = true; 563 if (ok) *ok = true;
550 return QTime(hour, minute, second); 564 return QTime(hour, minute, second);
551 565
552 error: 566 error:
553 if (ok) *ok = false; 567 if (ok) *ok = false;
554 return QTime(-1, -1, -1); // return invalid date if it didn't work 568 return QTime(-1, -1, -1); // return invalid date if it didn't work
555 // This will be removed in the near future, since it gives a warning on stderr. 569 // This will be removed in the near future, since it gives a warning on stderr.
556 // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. 570 // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime.
557} 571}
558 572
559bool KLocale::use12Clock() const 573bool KLocale::use12Clock() const
560{ 574{
561 return !mHourF24Format ;; 575 return !mHourF24Format ;;
562} 576}
563 577
564bool KLocale::weekStartsMonday() const 578bool KLocale::weekStartsMonday() const
565{ 579{
566 return mWeekStartsMonday; 580 return mWeekStartsMonday;
567} 581}
568 582
569int KLocale::weekStartDay() const 583int KLocale::weekStartDay() const
570{ 584{
571 if ( mWeekStartsMonday ) 585 if ( mWeekStartsMonday )
572 return 1; 586 return 1;
573 return 7; 587 return 7;
574} 588}
575 589
576QString KLocale::weekDayName(int i,bool shortName) const 590QString KLocale::weekDayName(int i,bool shortName) const
577{ 591{
578 if ( shortName ) 592 if ( shortName )
579 switch ( i ) 593 switch ( i )
580 { 594 {
581 case 1: return i18n("Monday", "Mon"); 595 case 1: return i18n("Monday", "Mon");
582 case 2: return i18n("Tuesday", "Tue"); 596 case 2: return i18n("Tuesday", "Tue");
583 case 3: return i18n("Wednesday", "Wed"); 597 case 3: return i18n("Wednesday", "Wed");
584 case 4: return i18n("Thursday", "Thu"); 598 case 4: return i18n("Thursday", "Thu");
585 case 5: return i18n("Friday", "Fri"); 599 case 5: return i18n("Friday", "Fri");
586 case 6: return i18n("Saturday", "Sat"); 600 case 6: return i18n("Saturday", "Sat");
587 case 7: return i18n("Sunday", "Sun"); 601 case 7: return i18n("Sunday", "Sun");
588 } 602 }
589 else 603 else
590 switch ( i ) 604 switch ( i )
591 { 605 {
592 case 1: return i18n("Monday"); 606 case 1: return i18n("Monday");
593 case 2: return i18n("Tuesday"); 607 case 2: return i18n("Tuesday");
594 case 3: return i18n("Wednesday"); 608 case 3: return i18n("Wednesday");
595 case 4: return i18n("Thursday"); 609 case 4: return i18n("Thursday");
596 case 5: return i18n("Friday"); 610 case 5: return i18n("Friday");
597 case 6: return i18n("Saturday"); 611 case 6: return i18n("Saturday");
598 case 7: return i18n("Sunday"); 612 case 7: return i18n("Sunday");
599 } 613 }
600 614
601 return QString::null; 615 return QString::null;
602} 616}
603 617
604QString KLocale::monthName(int i,bool shortName) const 618QString KLocale::monthName(int i,bool shortName) const
605{ 619{
606 if ( shortName ) 620 if ( shortName )
607 switch ( i ) 621 switch ( i )
608 { 622 {
609 case 1: return i18n("January", "Jan"); 623 case 1: return i18n("January", "Jan");
610 case 2: return i18n("February", "Feb"); 624 case 2: return i18n("February", "Feb");
611 case 3: return i18n("March", "Mar"); 625 case 3: return i18n("March", "Mar");
612 case 4: return i18n("April", "Apr"); 626 case 4: return i18n("April", "Apr");
613 case 5: return i18n("May short", "May"); 627 case 5: return i18n("May short", "May");
614 case 6: return i18n("June", "Jun"); 628 case 6: return i18n("June", "Jun");
615 case 7: return i18n("July", "Jul"); 629 case 7: return i18n("July", "Jul");
616 case 8: return i18n("August", "Aug"); 630 case 8: return i18n("August", "Aug");
617 case 9: return i18n("September", "Sep"); 631 case 9: return i18n("September", "Sep");
618 case 10: return i18n("October", "Oct"); 632 case 10: return i18n("October", "Oct");
619 case 11: return i18n("November", "Nov"); 633 case 11: return i18n("November", "Nov");
620 case 12: return i18n("December", "Dec"); 634 case 12: return i18n("December", "Dec");
621 } 635 }
622 else 636 else
623 switch (i) 637 switch (i)
624 { 638 {
625 case 1: return i18n("January"); 639 case 1: return i18n("January");
626 case 2: return i18n("February"); 640 case 2: return i18n("February");
627 case 3: return i18n("March"); 641 case 3: return i18n("March");
628 case 4: return i18n("April"); 642 case 4: return i18n("April");
629 case 5: return i18n("May long", "May"); 643 case 5: return i18n("May long", "May");
630 case 6: return i18n("June"); 644 case 6: return i18n("June");
631 case 7: return i18n("July"); 645 case 7: return i18n("July");
632 case 8: return i18n("August"); 646 case 8: return i18n("August");
633 case 9: return i18n("September"); 647 case 9: return i18n("September");
634 case 10: return i18n("October"); 648 case 10: return i18n("October");
635 case 11: return i18n("November"); 649 case 11: return i18n("November");
636 case 12: return i18n("December"); 650 case 12: return i18n("December");
637 } 651 }
638 652
639 return QString::null; 653 return QString::null;
640} 654}
641 655
642QString KLocale::country() const 656QString KLocale::country() const
643{ 657{
644 return QString::null; 658 return QString::null;
645} 659}
646 660
647QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const 661QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const
648{ 662{
649 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; 663 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat;
650 664
651 if ( QApplication::desktop()->width() < 480 ) { 665 if ( QApplication::desktop()->width() < 480 ) {
652 if ( dformat == Default ) 666 if ( dformat == Default )
653 return "%a %d %b %Y"; 667 return "%a %d %b %Y";
654 else if ( dformat == Format1 ) 668 else if ( dformat == Format1 )
655 return "%a %b %d %Y"; 669 return "%a %b %d %Y";
656 else if ( dformat == ISODate ) 670 else if ( dformat == ISODate )
657 return "%a %Y %b %d"; 671 return "%a %Y %b %d";
658 } else { 672 } else {
659 673
660 if ( dformat == Default ) 674 if ( dformat == Default )
661 return "%A %d %B %Y"; 675 return "%A %d %B %Y";
662 else if ( dformat == Format1 ) 676 else if ( dformat == Format1 )
663 return "%A %B %d %Y"; 677 return "%A %B %d %Y";
664 else if ( dformat == ISODate ) 678 else if ( dformat == ISODate )
665 return "%A %Y %B %d"; 679 return "%A %Y %B %d";
666 } 680 }
667 return mDateFormat ; 681 return mDateFormat ;
668} 682}
669 683
670QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const 684QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const
671{ 685{
672 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; 686 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat;
673 687
674 if ( dformat == Default ) 688 if ( dformat == Default )
675 return "%d.%m.%Y"; 689 return "%d.%m.%Y";
676 else if ( dformat == Format1 ) 690 else if ( dformat == Format1 )
677 return "%m.%d.%Y"; 691 return "%m.%d.%Y";
678 else if ( dformat == ISODate ) // = Qt::ISODate 692 else if ( dformat == ISODate ) // = Qt::ISODate
679 return "%Y-%m-%d"; 693 return "%Y-%m-%d";
680 return mDateFormatShort ; 694 return mDateFormatShort ;
681 695
682} 696}
683 697
684 698
685QString KLocale::timeFormat() const 699QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const
686{ 700{
687 if ( mHourF24Format) 701 const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat;
702
703 if ( tformat == Default )
704 if ( mHourF24Format)
705 return "%H:%M:%S";
706 else
707 return "%I:%M:%S%p";
708
709 else if ( tformat == Format1 )
710 if ( mHourF24Format)
711 return "%H:%M:%S";
712 else
713 return "%I:%M:%S%p";
714
715 else if ( tformat == ISODate ) // = Qt::ISODate
716 if ( mHourF24Format)
688 return "%H:%M:%S"; 717 return "%H:%M:%S";
689 return "%I:%M:%S%p"; 718 else
719 return "%I:%M:%S%p";
720
690} 721}
691 722
692void KLocale::insertCatalogue ( const QString & ) 723void KLocale::insertCatalogue ( const QString & )
693{ 724{
694} 725}
695 726
696KCalendarSystem *KLocale::calendar() 727KCalendarSystem *KLocale::calendar()
697{ 728{
698 if ( !mCalendarSystem ) { 729 if ( !mCalendarSystem ) {
699 mCalendarSystem = new KCalendarSystemGregorian; 730 mCalendarSystem = new KCalendarSystemGregorian;
700 } 731 }
701 732
702 return mCalendarSystem; 733 return mCalendarSystem;
703} 734}
704 735
705int KLocale::timezoneOffset( QString timeZone ) 736int KLocale::timezoneOffset( QString timeZone )
706{ 737{
707 int ret = 1001; 738 int ret = 1001;
708 int index = mTimeZoneList.findIndex( timeZone ); 739 int index = mTimeZoneList.findIndex( timeZone );
709 if ( index < 24 ) 740 if ( index < 24 )
710 ret = ( index-11 ) * 60 ; 741 ret = ( index-11 ) * 60 ;
711 return ret; 742 return ret;
712} 743}
713 744
714QStringList KLocale::timeZoneList() const 745QStringList KLocale::timeZoneList() const
715{ 746{
716 return mTimeZoneList; 747 return mTimeZoneList;
717} 748}
718void KLocale::setTimezone( const QString &timeZone ) 749void KLocale::setTimezone( const QString &timeZone )
719{ 750{
720 mTimeZoneOffset = timezoneOffset( timeZone ); 751 mTimeZoneOffset = timezoneOffset( timeZone );
721} 752}
722 753
723void KLocale::setDaylightSaving( bool b, int start , int end ) 754void KLocale::setDaylightSaving( bool b, int start , int end )
724{ 755{
725 daylightEnabled = b; 756 daylightEnabled = b;
726 daylightStart = start; 757 daylightStart = start;
727 daylightEnd = end; 758 daylightEnd = end;
728 mSouthDaylight = (end < start); 759 mSouthDaylight = (end < start);
729 // qDebug("klocale daylight %d %d %d ", b, start , end ); 760 // qDebug("klocale daylight %d %d %d ", b, start , end );
730} 761}
731 762
732int KLocale::localTimeOffset( const QDateTime &dt ) 763int KLocale::localTimeOffset( const QDateTime &dt )
733{ 764{
734 bool addDaylight = false; 765 bool addDaylight = false;
735 if ( daylightEnabled ) { 766 if ( daylightEnabled ) {
736 int d_end, d_start; 767 int d_end, d_start;
737 int dayofyear = dt.date().dayOfYear(); 768 int dayofyear = dt.date().dayOfYear();
738 int year = dt.date().year(); 769 int year = dt.date().year();
739 int add = 0; 770 int add = 0;
740 if ( QDate::leapYear(year) ) 771 if ( QDate::leapYear(year) )
741 add = 1; 772 add = 1;
742 QDate date ( year,1,1 ); 773 QDate date ( year,1,1 );
743 if ( daylightEnd > 59 ) 774 if ( daylightEnd > 59 )
744 d_end = daylightEnd +add; 775 d_end = daylightEnd +add;
745 else 776 else
746 d_end = daylightEnd; 777 d_end = daylightEnd;
747 if ( daylightStart > 59 ) 778 if ( daylightStart > 59 )
748 d_start = daylightStart +add; 779 d_start = daylightStart +add;
749 else 780 else
750 d_start = daylightStart; 781 d_start = daylightStart;
751 QDate s_date = date.addDays( d_start -1 ); 782 QDate s_date = date.addDays( d_start -1 );
752 QDate e_date = date.addDays( d_end -1 ); 783 QDate e_date = date.addDays( d_end -1 );
753 int dof = s_date.dayOfWeek(); 784 int dof = s_date.dayOfWeek();
754 if ( dof < 7 ) 785 if ( dof < 7 )
755 s_date = s_date.addDays( -dof ); 786 s_date = s_date.addDays( -dof );
756 dof = e_date.dayOfWeek(); 787 dof = e_date.dayOfWeek();
757 if ( dof < 7 ) 788 if ( dof < 7 )
758 e_date = e_date.addDays( -dof ); 789 e_date = e_date.addDays( -dof );
759 QTime startTime ( 3,0,0 ); 790 QTime startTime ( 3,0,0 );
760 QDateTime startDt( s_date, startTime ); 791 QDateTime startDt( s_date, startTime );
761 QDateTime endDt( e_date, startTime ); 792 QDateTime endDt( e_date, startTime );
762 //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( )); 793 //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( ));
763 if ( mSouthDaylight ) { 794 if ( mSouthDaylight ) {
764 if ( ! ( endDt < dt && dt < startDt) ) 795 if ( ! ( endDt < dt && dt < startDt) )
765 addDaylight = true; 796 addDaylight = true;
766 } else { 797 } else {
767 if ( startDt < dt && dt < endDt ) 798 if ( startDt < dt && dt < endDt )
768 addDaylight = true; 799 addDaylight = true;
769 800
770 801
771 } 802 }
772 } 803 }
773 int addMin = 0; 804 int addMin = 0;
774 if ( addDaylight ) 805 if ( addDaylight )
775 addMin = 60; 806 addMin = 60;
776 return mTimeZoneOffset + addMin; 807 return mTimeZoneOffset + addMin;
777} 808}
778// ****************************************************************** 809// ******************************************************************
779// added LR 810// added LR
780QString KLocale::formatNumber(double num, int precision) const 811QString KLocale::formatNumber(double num, int precision) const
781{ 812{
782 bool neg = num < 0; 813 bool neg = num < 0;
783 if (precision == -1) precision = 2; 814 if (precision == -1) precision = 2;
784 QString res = QString::number(neg?-num:num, 'f', precision); 815 QString res = QString::number(neg?-num:num, 'f', precision);
785 int pos = res.find('.'); 816 int pos = res.find('.');
786 if (pos == -1) pos = res.length(); 817 if (pos == -1) pos = res.length();
787 else res.replace(pos, 1, decimalSymbol()); 818 else res.replace(pos, 1, decimalSymbol());
788 819
789 while (0 < (pos -= 3)) 820 while (0 < (pos -= 3))
790 res.insert(pos, thousandsSeparator()); // thousand sep 821 res.insert(pos, thousandsSeparator()); // thousand sep
791 822
792 // How can we know where we should put the sign? 823 // How can we know where we should put the sign?
793 res.prepend(neg?negativeSign():positiveSign()); 824 res.prepend(neg?negativeSign():positiveSign());
794 825
795 return res; 826 return res;
796} 827}
797QString KLocale::formatNumber(const QString &numStr) const 828QString KLocale::formatNumber(const QString &numStr) const
798{ 829{
799 return formatNumber(numStr.toDouble()); 830 return formatNumber(numStr.toDouble());
800} 831}
801double KLocale::readNumber(const QString &_str, bool * ok) const 832double KLocale::readNumber(const QString &_str, bool * ok) const
802{ 833{
803 QString str = _str.stripWhiteSpace(); 834 QString str = _str.stripWhiteSpace();
804 bool neg = str.find(negativeSign()) == 0; 835 bool neg = str.find(negativeSign()) == 0;
805 if (neg) 836 if (neg)
806 str.remove( 0, negativeSign().length() ); 837 str.remove( 0, negativeSign().length() );
807 838
808 /* will hold the scientific notation portion of the number. 839 /* will hold the scientific notation portion of the number.
809 Example, with 2.34E+23, exponentialPart == "E+23" 840 Example, with 2.34E+23, exponentialPart == "E+23"
810 */ 841 */
811 QString exponentialPart; 842 QString exponentialPart;
812 int EPos; 843 int EPos;
813 844
814 EPos = str.find('E', 0, false); 845 EPos = str.find('E', 0, false);
815 846
816 if (EPos != -1) 847 if (EPos != -1)
817 { 848 {
818 exponentialPart = str.mid(EPos); 849 exponentialPart = str.mid(EPos);
819 str = str.left(EPos); 850 str = str.left(EPos);
820 } 851 }
821 852
822 int pos = str.find(decimalSymbol()); 853 int pos = str.find(decimalSymbol());
823 QString major; 854 QString major;
824 QString minor; 855 QString minor;
825 if ( pos == -1 ) 856 if ( pos == -1 )
826 major = str; 857 major = str;
827 else 858 else
828 { 859 {
829 major = str.left(pos); 860 major = str.left(pos);
830 minor = str.mid(pos + decimalSymbol().length()); 861 minor = str.mid(pos + decimalSymbol().length());
831 } 862 }
832 863
833 // Remove thousand separators 864 // Remove thousand separators
834 int thlen = thousandsSeparator().length(); 865 int thlen = thousandsSeparator().length();
835 int lastpos = 0; 866 int lastpos = 0;
836 while ( ( pos = major.find( thousandsSeparator() ) ) > 0 ) 867 while ( ( pos = major.find( thousandsSeparator() ) ) > 0 )
837 { 868 {
838 // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N 869 // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N
839 int fromEnd = major.length() - pos; 870 int fromEnd = major.length() - pos;
840 if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error 871 if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error
841 || pos - lastpos > 3 // More than 3 digits between two separators -> error 872 || pos - lastpos > 3 // More than 3 digits between two separators -> error
842 || pos == 0 // Can't start with a separator 873 || pos == 0 // Can't start with a separator
843 || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators 874 || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators
844 { 875 {
845 if (ok) *ok = false; 876 if (ok) *ok = false;
846 return 0.0; 877 return 0.0;
847 } 878 }
848 879
849 lastpos = pos; 880 lastpos = pos;
850 major.remove( pos, thlen ); 881 major.remove( pos, thlen );
851 } 882 }
852 if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator 883 if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator
853 { 884 {
854 if (ok) *ok = false; 885 if (ok) *ok = false;
855 return 0.0; 886 return 0.0;
856 } 887 }
857 888
858 QString tot; 889 QString tot;
859 if (neg) tot = '-'; 890 if (neg) tot = '-';
860 891
861 tot += major + '.' + minor + exponentialPart; 892 tot += major + '.' + minor + exponentialPart;
862 893
863 return tot.toDouble(ok); 894 return tot.toDouble(ok);
864} 895}
865QString KLocale::decimalSymbol() const 896QString KLocale::decimalSymbol() const
866{ 897{
867 898
868 return m_decimalSymbol; 899 return m_decimalSymbol;
869} 900}
870 901
871QString KLocale::thousandsSeparator() const 902QString KLocale::thousandsSeparator() const
872{ 903{
873 904
874 return m_thousandsSeparator; 905 return m_thousandsSeparator;
875} 906}
876QString KLocale::positiveSign() const 907QString KLocale::positiveSign() const
877{ 908{
878 return m_positiveSign; 909 return m_positiveSign;
879} 910}
880 911
881QString KLocale::negativeSign() const 912QString KLocale::negativeSign() const
882{ 913{
883 return m_negativeSign; 914 return m_negativeSign;
884} 915}
diff --git a/microkde/kdecore/klocale.h b/microkde/kdecore/klocale.h
index f6c0253..153b12a 100644
--- a/microkde/kdecore/klocale.h
+++ b/microkde/kdecore/klocale.h
@@ -1,112 +1,115 @@
1#ifndef MINIKDE_KLOCALE_H 1#ifndef MINIKDE_KLOCALE_H
2#define MINIKDE_KLOCALE_H 2#define MINIKDE_KLOCALE_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qstringlist.h> 5#include <qstringlist.h>
6#include <qdatetime.h> 6#include <qdatetime.h>
7#include <qdict.h> 7#include <qdict.h>
8 8
9#ifndef I18N_NOOP 9#ifndef I18N_NOOP
10#define I18N_NOOP(x) (x) 10#define I18N_NOOP(x) (x)
11#endif 11#endif
12 12
13class KCalendarSystem; 13class KCalendarSystem;
14void setLocaleDict( QDict<QString> * dict ); 14void setLocaleDict( QDict<QString> * dict );
15QString i18n(const char *text); 15QString i18n(const char *text);
16QString i18n(const char *hint, const char *text); 16QString i18n(const char *hint, const char *text);
17QString i18n(const char *text1, const char *textn, int num); 17QString i18n(const char *text1, const char *textn, int num);
18 18
19// Qt3's uic generates i18n( "msg", "comment" ) calls which conflict 19// Qt3's uic generates i18n( "msg", "comment" ) calls which conflict
20// with our i18n method. we use uic -tr tr2i18n to redirect 20// with our i18n method. we use uic -tr tr2i18n to redirect
21// to the right i18n() function 21// to the right i18n() function
22inline QString tr2i18n(const char* message, const char* =0) { 22inline QString tr2i18n(const char* message, const char* =0) {
23 return i18n( message); 23 return i18n( message);
24} 24}
25 25
26class KLocale 26class KLocale
27{ 27{
28 public: 28 public:
29 KLocale(); 29 KLocale();
30 30
31 QString formatNumber(double num, int precision = -1) const; 31 QString formatNumber(double num, int precision = -1) const;
32 QString formatNumber(const QString &numStr) const; 32 QString formatNumber(const QString &numStr) const;
33 double readNumber(const QString &numStr, bool * ok = 0) const; 33 double readNumber(const QString &numStr, bool * ok = 0) const;
34 34
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) const; 47 QString formatTime(const QTime &pTime, bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const;
48 QString formatDateTime(const QDateTime &pDateTime) 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) 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 56
57 bool use12Clock() const; 57 bool use12Clock() const;
58 bool weekStartsMonday() const; 58 bool weekStartsMonday() const;
59 int weekStartDay() const; 59 int weekStartDay() const;
60 60
61 QString weekDayName(int,bool=false) const; 61 QString weekDayName(int,bool=false) const;
62 QString monthName(int,bool=false) const; 62 QString monthName(int,bool=false) const;
63 63
64 QString country() const; 64 QString country() const;
65 65
66 QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const; 66 QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const;
67 QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const; 67 QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const;
68 QString timeFormat() const; 68 QString timeFormat(IntDateFormat intIntDateFormat = Undefined) const;
69 69
70 void insertCatalogue ( const QString & ); 70 void insertCatalogue ( const QString & );
71 71
72 KCalendarSystem *calendar(); 72 KCalendarSystem *calendar();
73 void setHore24Format ( bool ); 73 void setHore24Format ( bool );
74 void setWeekStartMonday( bool ); 74 void setWeekStartMonday( bool );
75 void setIntDateFormat( IntDateFormat ); 75 void setIntDateFormat( IntDateFormat );
76 void setIntTimeFormat( IntDateFormat );
76 IntDateFormat getIntDateFormat( ); 77 IntDateFormat getIntDateFormat( );
78 IntDateFormat getIntTimeFormat( );
77 void setLanguage( int ); 79 void setLanguage( int );
78 void setDateFormat( QString ); 80 void setDateFormat( QString );
79 void setDateFormatShort( QString ); 81 void setDateFormatShort( QString );
80 82
81 QString m_decimalSymbol; 83 QString m_decimalSymbol;
82 QString m_thousandsSeparator; 84 QString m_thousandsSeparator;
83 QString m_currencySymbol; 85 QString m_currencySymbol;
84 QString m_monetaryDecimalSymbol; 86 QString m_monetaryDecimalSymbol;
85 QString m_monetaryThousandsSeparator; 87 QString m_monetaryThousandsSeparator;
86 QString m_positiveSign; 88 QString m_positiveSign;
87 QString m_negativeSign; 89 QString m_negativeSign;
88 90
89 int timezoneOffset( QString ); 91 int timezoneOffset( QString );
90 QStringList timeZoneList() const; 92 QStringList timeZoneList() const;
91 void setDaylightSaving( bool, int , int ); 93 void setDaylightSaving( bool, int , int );
92 int localTimeOffset(const QDateTime &); 94 int localTimeOffset(const QDateTime &);
93 void setTimezone( const QString &timeZone ); 95 void setTimezone( const QString &timeZone );
94 private: 96 private:
95 QTime readTime(const QString &str, bool seconds, bool *ok) const; 97 QTime readTime(const QString &str, bool seconds, bool *ok) const;
96 QDate readDate(const QString &str, bool shortFormat, bool *ok) const; 98 QDate readDate(const QString &str, bool shortFormat, bool *ok) const;
97 KCalendarSystem *mCalendarSystem; 99 KCalendarSystem *mCalendarSystem;
98 bool mWeekStartsMonday; 100 bool mWeekStartsMonday;
99 bool mHourF24Format; 101 bool mHourF24Format;
100 IntDateFormat mIntDateFormat; 102 IntDateFormat mIntDateFormat;
103 IntDateFormat mIntTimeFormat;
101 int mLanguage; 104 int mLanguage;
102 QString mDateFormat; 105 QString mDateFormat;
103 QString mDateFormatShort; 106 QString mDateFormatShort;
104 QStringList mTimeZoneList; 107 QStringList mTimeZoneList;
105 bool daylightEnabled; 108 bool daylightEnabled;
106 int mDaylightTZoffset; 109 int mDaylightTZoffset;
107 int mNondaylightTZoffset; 110 int mNondaylightTZoffset;
108 bool mSouthDaylight; 111 bool mSouthDaylight;
109 int daylightStart, daylightEnd, mTimeZoneOffset; 112 int daylightStart, daylightEnd, mTimeZoneOffset;
110}; 113};
111 114
112#endif 115#endif