summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-11-06 14:30:14 (UTC)
committer zautrix <zautrix>2004-11-06 14:30:14 (UTC)
commitf8841c92d5251f713eb7a025af8fdee52de45b3d (patch) (unidiff)
tree29c3c48e5da5b5ce05126da46475de1a0a845428
parent71eeea80d9c449bd1983c1a9207c7123e919b55f (diff)
downloadkdepimpi-f8841c92d5251f713eb7a025af8fdee52de45b3d.zip
kdepimpi-f8841c92d5251f713eb7a025af8fdee52de45b3d.tar.gz
kdepimpi-f8841c92d5251f713eb7a025af8fdee52de45b3d.tar.bz2
category utf8 fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp3
-rw-r--r--libkcal/sharpformat.cpp45
-rw-r--r--libkcal/sharpformat.h2
-rw-r--r--microkde/kconfig.cpp8
4 files changed, 10 insertions, 48 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index f8d752a..2321087 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -2300,13 +2300,14 @@ void CalendarView::manageCategories()
2300 int count = 0; 2300 int count = 0;
2301 if ( cp->addCat() ) { 2301 if ( cp->addCat() ) {
2302 count = addCategories(); 2302 count = addCategories();
2303 if ( count ) { 2303 if ( count ) {
2304 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2304 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2305 writeSettings(); 2305 writeSettings();
2306 } 2306 } else
2307 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2307 } else { 2308 } else {
2308 removeCategories(); 2309 removeCategories();
2309 updateView(); 2310 updateView();
2310 } 2311 }
2311 delete cp; 2312 delete cp;
2312} 2313}
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp
index b88e729..24b8349 100644
--- a/libkcal/sharpformat.cpp
+++ b/libkcal/sharpformat.cpp
@@ -61,13 +61,12 @@ using namespace KCal;
61//MDAY 61//MDAY
62 62
63class SharpParser : public QObject 63class SharpParser : public QObject
64{ 64{
65 public: 65 public:
66 SharpParser( Calendar *calendar ) : mCalendar( calendar ) { 66 SharpParser( Calendar *calendar ) : mCalendar( calendar ) {
67 oldCategories = 0;
68 } 67 }
69 68
70 bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) 69 bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName )
71 { 70 {
72 int i = 1; 71 int i = 1;
73 bool skip = true; 72 bool skip = true;
@@ -167,13 +166,13 @@ class SharpParser : public QObject
167 } 166 }
168 } else { 167 } else {
169 event->recurrence()->unsetRecurs(); 168 event->recurrence()->unsetRecurs();
170 } 169 }
171 170
172 QString categoryList = attList[1] ; 171 QString categoryList = attList[1] ;
173 event->setCategories( lookupCategories( categoryList ) ); 172 event->setCategories( categoryList );
174 173
175 // strange 0 semms to mean: alarm enabled 174 // strange 0 semms to mean: alarm enabled
176 if ( attList[8] == "0" ) { 175 if ( attList[8] == "0" ) {
177 Alarm *alarm; 176 Alarm *alarm;
178 if ( event->alarms().count() > 0 ) 177 if ( event->alarms().count() > 0 )
179 alarm = event->alarms().first(); 178 alarm = event->alarms().first();
@@ -221,13 +220,13 @@ class SharpParser : public QObject
221 220
222 int priority = attList[6].toInt(); 221 int priority = attList[6].toInt();
223 if ( priority == 0 ) priority = 3; 222 if ( priority == 0 ) priority = 3;
224 todo->setPriority( priority ); 223 todo->setPriority( priority );
225 224
226 QString categoryList = attList[1]; 225 QString categoryList = attList[1];
227 todo->setCategories( lookupCategories( categoryList ) ); 226 todo->setCategories( categoryList );
228 227
229 228
230 229
231 QString hasDateStr = attList[3]; // due 230 QString hasDateStr = attList[3]; // due
232 if ( !hasDateStr.isEmpty() ) { 231 if ( !hasDateStr.isEmpty() ) {
233 if ( hasDateStr.right(6) == "000000" ) { 232 if ( hasDateStr.right(6) == "000000" ) {
@@ -268,17 +267,12 @@ class SharpParser : public QObject
268 } 267 }
269 //qDebug("end "); 268 //qDebug("end ");
270 return true; 269 return true;
271 } 270 }
272 271
273 272
274 void setCategoriesList ( QStringList * c )
275 {
276 oldCategories = c;
277 }
278
279 QDateTime fromString ( QString s, bool useTz = true ) { 273 QDateTime fromString ( QString s, bool useTz = true ) {
280 QDateTime dt; 274 QDateTime dt;
281 int y,m,t,h,min,sec; 275 int y,m,t,h,min,sec;
282 y = s.mid(0,4).toInt(); 276 y = s.mid(0,4).toInt();
283 m = s.mid(4,2).toInt(); 277 m = s.mid(4,2).toInt();
284 t = s.mid(6,2).toInt(); 278 t = s.mid(6,2).toInt();
@@ -298,51 +292,20 @@ class SharpParser : public QObject
298 QDateTime dt; 292 QDateTime dt;
299 dt.setTime_t( value.toUInt() ); 293 dt.setTime_t( value.toUInt() );
300 294
301 return dt; 295 return dt;
302 } 296 }
303 297
304 QStringList lookupCategories( const QString &categoryList )
305 {
306 QStringList categoryIds = QStringList::split( ";", categoryList );
307 QStringList categories;
308 QStringList::ConstIterator it;
309 for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) {
310 QString cate = category( *it );
311 if ( oldCategories ) {
312 if ( ! oldCategories->contains( cate ) )
313 oldCategories->append( cate );
314 }
315 categories.append(cate );
316 }
317 return categories;
318 }
319
320 private: 298 private:
321 Calendar *mCalendar; 299 Calendar *mCalendar;
322 QStringList * oldCategories;
323 static QString category( const QString &id )
324 {
325 QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id );
326 if ( it == mCategoriesMap.end() ) return id;
327 else return *it;
328 }
329
330 static void setCategory( const QString &id, const QString &name )
331 {
332 mCategoriesMap.insert( id, name );
333 }
334
335 static QMap<QString,QString> mCategoriesMap;
336}; 300};
337 301
338QMap<QString,QString> SharpParser::mCategoriesMap;
339 302
340SharpFormat::SharpFormat() 303SharpFormat::SharpFormat()
341{ 304{
342 mCategories = 0; 305
343} 306}
344 307
345SharpFormat::~SharpFormat() 308SharpFormat::~SharpFormat()
346{ 309{
347} 310}
348ulong SharpFormat::getCsum( const QStringList & attList) 311ulong SharpFormat::getCsum( const QStringList & attList)
@@ -1015,13 +978,13 @@ bool SharpFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar,
1015 int start = 0; 978 int start = 0;
1016 int len = text.length(); 979 int len = text.length();
1017 int end = text.find ("\n",start)+1; 980 int end = text.find ("\n",start)+1;
1018 bool ok = true; 981 bool ok = true;
1019 start = end; 982 start = end;
1020 SharpParser handler( calendar ); 983 SharpParser handler( calendar );
1021 handler.setCategoriesList( mCategories ); 984 // handler.setCategoriesList( mCategories );
1022 while ( start > 0 ) { 985 while ( start > 0 ) {
1023 templist.clear(); 986 templist.clear();
1024 ok = true; 987 ok = true;
1025 while ( ok ) { 988 while ( ok ) {
1026 tempString = getPart( text, ok, start ); 989 tempString = getPart( text, ok, start );
1027 if ( start >= len || start == 0 ) { 990 if ( start >= len || start == 0 ) {
diff --git a/libkcal/sharpformat.h b/libkcal/sharpformat.h
index 0b13862..a71177d 100644
--- a/libkcal/sharpformat.h
+++ b/libkcal/sharpformat.h
@@ -37,24 +37,22 @@ class SharpFormat : public QObject {
37 /** Create new iCalendar format. */ 37 /** Create new iCalendar format. */
38 SharpFormat(); 38 SharpFormat();
39 virtual ~SharpFormat(); 39 virtual ~SharpFormat();
40 40
41 bool load( Calendar * ,Calendar *); 41 bool load( Calendar * ,Calendar *);
42 bool save( Calendar * ); 42 bool save( Calendar * );
43 void setCategoriesList ( QStringList * cat ){ mCategories = cat; }
44 bool fromString2Cal( Calendar *, Calendar *, const QString & , const QString & ); 43 bool fromString2Cal( Calendar *, Calendar *, const QString & , const QString & );
45 bool fromString( Calendar *, const QString & ); 44 bool fromString( Calendar *, const QString & );
46 QString toString( Calendar * ); 45 QString toString( Calendar * );
47 static ulong getCsum( const QStringList & ); 46 static ulong getCsum( const QStringList & );
48 47
49 private: 48 private:
50 QString getEventString( Event* ); 49 QString getEventString( Event* );
51 QString getTodoString( Todo* ); 50 QString getTodoString( Todo* );
52 QString dtToString( const QDateTime& dt, bool useTZ = true ); 51 QString dtToString( const QDateTime& dt, bool useTZ = true );
53 52
54 QStringList *mCategories;
55 int getNumFromRecord( QString answer,Incidence* inc ) ; 53 int getNumFromRecord( QString answer,Incidence* inc ) ;
56 QString getPart( const QString & text, bool &ok, int &start ); 54 QString getPart( const QString & text, bool &ok, int &start );
57}; 55};
58 56
59} 57}
60 58
diff --git a/microkde/kconfig.cpp b/microkde/kconfig.cpp
index 5b685d3..862166d 100644
--- a/microkde/kconfig.cpp
+++ b/microkde/kconfig.cpp
@@ -103,13 +103,13 @@ QString KConfig::readEntry( const QString &key, const QString &def )
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 QString::fromUtf8((*it).latin1());
110} 110}
111 111
112QSize KConfig::readSizeEntry( const QString &key, QSize* def ) 112QSize KConfig::readSizeEntry( const QString &key, QSize* def )
113{ 113{
114 QValueList<int> intlist = readIntListEntry(key); 114 QValueList<int> intlist = readIntListEntry(key);
115 115
@@ -132,13 +132,13 @@ QStringList KConfig::readListEntry( const QString &key )
132{ 132{
133 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); 133 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key );
134 134
135 if ( it == mStringMap.end() ) { 135 if ( it == mStringMap.end() ) {
136 return QStringList(); 136 return QStringList();
137 } 137 }
138 return QStringList::split(":", *it ); 138 return QStringList::split(":", QString::fromUtf8((*it).latin1()));
139 139
140} 140}
141 141
142bool KConfig::readBoolEntry( const QString &key, bool def ) 142bool KConfig::readBoolEntry( const QString &key, bool def )
143{ 143{
144 QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key ); 144 QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key );
@@ -210,20 +210,20 @@ void KConfig::writeEntry( const QString & key , int num )
210{ 210{
211 writeEntry( key, QString::number ( num ) ); 211 writeEntry( key, QString::number ( num ) );
212} 212}
213 213
214void KConfig::writeEntry( const QString &key, const QString &value ) 214void KConfig::writeEntry( const QString &key, const QString &value )
215{ 215{
216 mStringMap.insert( mGroup + key, value ); 216 mStringMap.insert( mGroup + key, value.utf8() );
217 217
218 mDirty = true; 218 mDirty = true;
219} 219}
220 220
221void KConfig::writeEntry( const QString &key, const QStringList &value ) 221void KConfig::writeEntry( const QString &key, const QStringList &value )
222{ 222{
223 mStringMap.insert( mGroup + key, value.join(":") ); 223 mStringMap.insert( mGroup + key, value.join(":").utf8() );
224 224
225 mDirty = true; 225 mDirty = true;
226} 226}
227 227
228void KConfig::writeEntry( const QString &key, bool value) 228void KConfig::writeEntry( const QString &key, bool value)
229{ 229{