summaryrefslogtreecommitdiffabout
Unidiff
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
@@ -106,12 +106,31 @@ QString KConfig::readEntry( const QString &key, const QString &def )
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();
@@ -219,12 +238,19 @@ void KConfig::writeEntry( const QString & e, const QColor & c )
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 () ) );
diff --git a/microkde/kconfig.h b/microkde/kconfig.h
index a01b1a5..1a1038f 100644
--- a/microkde/kconfig.h
+++ b/microkde/kconfig.h
@@ -63,13 +63,13 @@ class KConfig
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 ); }
@@ -79,12 +79,13 @@ class KConfig
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
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
@@ -84,12 +84,13 @@ KLocale::KLocale() : mCalendarSystem( 0 )
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")
@@ -136,21 +137,32 @@ void KLocale::setHore24Format ( bool b )
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{
@@ -159,15 +171,15 @@ QString KLocale::translate( const char *index ) const
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;
@@ -312,22 +324,23 @@ QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat
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);
@@ -453,12 +466,13 @@ QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const
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)
@@ -679,17 +693,34 @@ QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const
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
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
@@ -41,17 +41,17 @@ class KLocale
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;
@@ -62,21 +62,23 @@ class KLocale
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;
@@ -95,12 +97,13 @@ class KLocale
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;