author | zautrix <zautrix> | 2004-11-06 14:30:14 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-11-06 14:30:14 (UTC) |
commit | f8841c92d5251f713eb7a025af8fdee52de45b3d (patch) (unidiff) | |
tree | 29c3c48e5da5b5ce05126da46475de1a0a845428 | |
parent | 71eeea80d9c449bd1983c1a9207c7123e919b55f (diff) | |
download | kdepimpi-f8841c92d5251f713eb7a025af8fdee52de45b3d.zip kdepimpi-f8841c92d5251f713eb7a025af8fdee52de45b3d.tar.gz kdepimpi-f8841c92d5251f713eb7a025af8fdee52de45b3d.tar.bz2 |
category utf8 fixes
-rw-r--r-- | korganizer/calendarview.cpp | 3 | ||||
-rw-r--r-- | libkcal/sharpformat.cpp | 45 | ||||
-rw-r--r-- | libkcal/sharpformat.h | 2 | ||||
-rw-r--r-- | microkde/kconfig.cpp | 8 |
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 | |||
@@ -2282,49 +2282,50 @@ int CalendarView::addCategories() | |||
2282 | catList.sort(); | 2282 | catList.sort(); |
2283 | KOPrefs::instance()->mCustomCategories = catList; | 2283 | KOPrefs::instance()->mCustomCategories = catList; |
2284 | return count; | 2284 | return count; |
2285 | } | 2285 | } |
2286 | 2286 | ||
2287 | void CalendarView::manageCategories() | 2287 | void CalendarView::manageCategories() |
2288 | { | 2288 | { |
2289 | KOCatPrefs* cp = new KOCatPrefs(); | 2289 | KOCatPrefs* cp = new KOCatPrefs(); |
2290 | cp->show(); | 2290 | cp->show(); |
2291 | int w =cp->sizeHint().width() ; | 2291 | int w =cp->sizeHint().width() ; |
2292 | int h = cp->sizeHint().height() ; | 2292 | int h = cp->sizeHint().height() ; |
2293 | int dw = QApplication::desktop()->width(); | 2293 | int dw = QApplication::desktop()->width(); |
2294 | int dh = QApplication::desktop()->height(); | 2294 | int dh = QApplication::desktop()->height(); |
2295 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2295 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2296 | if ( !cp->exec() ) { | 2296 | if ( !cp->exec() ) { |
2297 | delete cp; | 2297 | delete cp; |
2298 | return; | 2298 | return; |
2299 | } | 2299 | } |
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 | } |
2313 | 2314 | ||
2314 | void CalendarView::beamIncidence(Incidence * Inc) | 2315 | void CalendarView::beamIncidence(Incidence * Inc) |
2315 | { | 2316 | { |
2316 | QPtrList<Incidence> delSel ; | 2317 | QPtrList<Incidence> delSel ; |
2317 | delSel.append(Inc); | 2318 | delSel.append(Inc); |
2318 | beamIncidenceList( delSel ); | 2319 | beamIncidenceList( delSel ); |
2319 | } | 2320 | } |
2320 | void CalendarView::beamCalendar() | 2321 | void CalendarView::beamCalendar() |
2321 | { | 2322 | { |
2322 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2323 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2323 | //qDebug("beamCalendar() "); | 2324 | //qDebug("beamCalendar() "); |
2324 | beamIncidenceList( delSel ); | 2325 | beamIncidenceList( delSel ); |
2325 | } | 2326 | } |
2326 | void CalendarView::beamFilteredCalendar() | 2327 | void CalendarView::beamFilteredCalendar() |
2327 | { | 2328 | { |
2328 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2329 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2329 | //qDebug("beamFilteredCalendar() "); | 2330 | //qDebug("beamFilteredCalendar() "); |
2330 | beamIncidenceList( delSel ); | 2331 | beamIncidenceList( delSel ); |
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index b88e729..24b8349 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp | |||
@@ -43,49 +43,48 @@ | |||
43 | 43 | ||
44 | #include "sharpformat.h" | 44 | #include "sharpformat.h" |
45 | #include "syncdefines.h" | 45 | #include "syncdefines.h" |
46 | 46 | ||
47 | using namespace KCal; | 47 | using namespace KCal; |
48 | 48 | ||
49 | //CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY | 49 | //CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY |
50 | // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 50 | // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
51 | 51 | ||
52 | //ARSD silentalarm = 0 | 52 | //ARSD silentalarm = 0 |
53 | // 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly | 53 | // 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly |
54 | // 12 RFRQ | 54 | // 12 RFRQ |
55 | // 13 RPOS pos = 4. monday in month | 55 | // 13 RPOS pos = 4. monday in month |
56 | // 14 RDYS days: 1 mon/ 2 tue .. 64 sun | 56 | // 14 RDYS days: 1 mon/ 2 tue .. 64 sun |
57 | // 15 REND 0 = no end/ 1 = end | 57 | // 15 REND 0 = no end/ 1 = end |
58 | // 16 REDT rec end dt | 58 | // 16 REDT rec end dt |
59 | //ALSD | 59 | //ALSD |
60 | //ALED | 60 | //ALED |
61 | //MDAY | 61 | //MDAY |
62 | 62 | ||
63 | class SharpParser : public QObject | 63 | class 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; |
74 | int max = attList.count() -2; | 73 | int max = attList.count() -2; |
75 | while ( i < max ) { | 74 | while ( i < max ) { |
76 | if ( !attList[i].isEmpty() ) { | 75 | if ( !attList[i].isEmpty() ) { |
77 | skip = false; | 76 | skip = false; |
78 | break; | 77 | break; |
79 | } | 78 | } |
80 | ++i ; | 79 | ++i ; |
81 | } | 80 | } |
82 | if ( skip ) | 81 | if ( skip ) |
83 | return false; | 82 | return false; |
84 | ulong cSum = SharpFormat::getCsum(attList ); | 83 | ulong cSum = SharpFormat::getCsum(attList ); |
85 | 84 | ||
86 | if ( qName == "Event" ) { | 85 | if ( qName == "Event" ) { |
87 | Event *event; | 86 | Event *event; |
88 | event = existingCalendar->event( "Sharp_DTM",attList[0] ); | 87 | event = existingCalendar->event( "Sharp_DTM",attList[0] ); |
89 | if ( event ) | 88 | if ( event ) |
90 | event = (Event*)event->clone(); | 89 | event = (Event*)event->clone(); |
91 | else | 90 | else |
@@ -149,49 +148,49 @@ class SharpParser : public QObject | |||
149 | else | 148 | else |
150 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); | 149 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); |
151 | r->addMonthlyDay( startDate.day() ); | 150 | r->addMonthlyDay( startDate.day() ); |
152 | } else if ( rtype == "2" ) { | 151 | } else if ( rtype == "2" ) { |
153 | if ( hasEndDate ) | 152 | if ( hasEndDate ) |
154 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 153 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
155 | else | 154 | else |
156 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); | 155 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); |
157 | QBitArray days( 7 ); | 156 | QBitArray days( 7 ); |
158 | days.fill( false ); | 157 | days.fill( false ); |
159 | days.setBit( startDate.dayOfWeek() - 1 ); | 158 | days.setBit( startDate.dayOfWeek() - 1 ); |
160 | r->addMonthlyPos( pos, days ); | 159 | r->addMonthlyPos( pos, days ); |
161 | } else if ( rtype == "4" ) { | 160 | } else if ( rtype == "4" ) { |
162 | if ( hasEndDate ) | 161 | if ( hasEndDate ) |
163 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 162 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
164 | else | 163 | else |
165 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); | 164 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); |
166 | r->addYearlyNum( startDate.month() ); | 165 | r->addYearlyNum( startDate.month() ); |
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(); |
180 | else { | 179 | else { |
181 | alarm = new Alarm( event ); | 180 | alarm = new Alarm( event ); |
182 | event->addAlarm( alarm ); | 181 | event->addAlarm( alarm ); |
183 | alarm->setType( Alarm::Audio ); | 182 | alarm->setType( Alarm::Audio ); |
184 | } | 183 | } |
185 | //alarm->setType( Alarm::Audio ); | 184 | //alarm->setType( Alarm::Audio ); |
186 | alarm->setEnabled( true ); | 185 | alarm->setEnabled( true ); |
187 | int alarmOffset = attList[9].toInt(); | 186 | int alarmOffset = attList[9].toInt(); |
188 | alarm->setStartOffset( alarmOffset * -60 ); | 187 | alarm->setStartOffset( alarmOffset * -60 ); |
189 | } else { | 188 | } else { |
190 | Alarm *alarm; | 189 | Alarm *alarm; |
191 | if ( event->alarms().count() > 0 ) { | 190 | if ( event->alarms().count() > 0 ) { |
192 | alarm = event->alarms().first(); | 191 | alarm = event->alarms().first(); |
193 | alarm->setType( Alarm::Audio ); | 192 | alarm->setType( Alarm::Audio ); |
194 | alarm->setStartOffset( -60*15 ); | 193 | alarm->setStartOffset( -60*15 ); |
195 | alarm->setEnabled( false ); | 194 | alarm->setEnabled( false ); |
196 | } | 195 | } |
197 | } | 196 | } |
@@ -203,164 +202,128 @@ class SharpParser : public QObject | |||
203 | todo = existingCalendar->todo( "Sharp_DTM", attList[0] ); | 202 | todo = existingCalendar->todo( "Sharp_DTM", attList[0] ); |
204 | if (todo ) | 203 | if (todo ) |
205 | todo = (Todo*)todo->clone(); | 204 | todo = (Todo*)todo->clone(); |
206 | else | 205 | else |
207 | todo = new Todo; | 206 | todo = new Todo; |
208 | 207 | ||
209 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 | 208 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 |
210 | // 0 1 2 3 4 5 6 7 8 | 209 | // 0 1 2 3 4 5 6 7 8 |
211 | //1,,,,,1,4,Loch zumachen,"" | 210 | //1,,,,,1,4,Loch zumachen,"" |
212 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " | 211 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " |
213 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes | 212 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes |
214 | 213 | ||
215 | todo->setID( "Sharp_DTM", attList[0]); | 214 | todo->setID( "Sharp_DTM", attList[0]); |
216 | todo->setCsum( "Sharp_DTM", QString::number( cSum )); | 215 | todo->setCsum( "Sharp_DTM", QString::number( cSum )); |
217 | todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 216 | todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
218 | 217 | ||
219 | todo->setSummary( attList[7] ); | 218 | todo->setSummary( attList[7] ); |
220 | todo->setDescription( attList[8]); | 219 | todo->setDescription( attList[8]); |
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" ) { |
234 | todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); | 233 | todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); |
235 | todo->setFloats( true ); | 234 | todo->setFloats( true ); |
236 | } | 235 | } |
237 | else { | 236 | else { |
238 | todo->setDtDue( fromString( hasDateStr ) ); | 237 | todo->setDtDue( fromString( hasDateStr ) ); |
239 | todo->setFloats( false ); | 238 | todo->setFloats( false ); |
240 | } | 239 | } |
241 | 240 | ||
242 | todo->setHasDueDate( true ); | 241 | todo->setHasDueDate( true ); |
243 | } | 242 | } |
244 | hasDateStr = attList[2];//start | 243 | hasDateStr = attList[2];//start |
245 | if ( !hasDateStr.isEmpty() ) { | 244 | if ( !hasDateStr.isEmpty() ) { |
246 | 245 | ||
247 | todo->setDtStart( fromString( hasDateStr ) ); | 246 | todo->setDtStart( fromString( hasDateStr ) ); |
248 | todo->setHasStartDate( true); | 247 | todo->setHasStartDate( true); |
249 | } else | 248 | } else |
250 | todo->setHasStartDate( false ); | 249 | todo->setHasStartDate( false ); |
251 | hasDateStr = attList[4];//completed | 250 | hasDateStr = attList[4];//completed |
252 | if ( !hasDateStr.isEmpty() ) { | 251 | if ( !hasDateStr.isEmpty() ) { |
253 | todo->setCompleted(fromString( hasDateStr ) ); | 252 | todo->setCompleted(fromString( hasDateStr ) ); |
254 | } | 253 | } |
255 | QString completedStr = attList[5]; | 254 | QString completedStr = attList[5]; |
256 | if ( completedStr == "0" ) | 255 | if ( completedStr == "0" ) |
257 | todo->setCompleted( true ); | 256 | todo->setCompleted( true ); |
258 | else | 257 | else |
259 | todo->setCompleted( false ); | 258 | todo->setCompleted( false ); |
260 | mCalendar->addTodo( todo ); | 259 | mCalendar->addTodo( todo ); |
261 | 260 | ||
262 | } else if ( qName == "Category" ) { | 261 | } else if ( qName == "Category" ) { |
263 | /* | 262 | /* |
264 | QString id = attributes.value( "id" ); | 263 | QString id = attributes.value( "id" ); |
265 | QString name = attributes.value( "name" ); | 264 | QString name = attributes.value( "name" ); |
266 | setCategory( id, name ); | 265 | setCategory( id, name ); |
267 | */ | 266 | */ |
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(); |
285 | h = s.mid(9,2).toInt(); | 279 | h = s.mid(9,2).toInt(); |
286 | min = s.mid(11,2).toInt(); | 280 | min = s.mid(11,2).toInt(); |
287 | sec = s.mid(13,2).toInt(); | 281 | sec = s.mid(13,2).toInt(); |
288 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); | 282 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); |
289 | int offset = KGlobal::locale()->localTimeOffset( dt ); | 283 | int offset = KGlobal::locale()->localTimeOffset( dt ); |
290 | if ( useTz ) | 284 | if ( useTz ) |
291 | dt = dt.addSecs ( offset*60); | 285 | dt = dt.addSecs ( offset*60); |
292 | return dt; | 286 | return dt; |
293 | 287 | ||
294 | } | 288 | } |
295 | protected: | 289 | protected: |
296 | QDateTime toDateTime( const QString &value ) | 290 | QDateTime toDateTime( const QString &value ) |
297 | { | 291 | { |
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 | ||
338 | QMap<QString,QString> SharpParser::mCategoriesMap; | ||
339 | 302 | ||
340 | SharpFormat::SharpFormat() | 303 | SharpFormat::SharpFormat() |
341 | { | 304 | { |
342 | mCategories = 0; | 305 | |
343 | } | 306 | } |
344 | 307 | ||
345 | SharpFormat::~SharpFormat() | 308 | SharpFormat::~SharpFormat() |
346 | { | 309 | { |
347 | } | 310 | } |
348 | ulong SharpFormat::getCsum( const QStringList & attList) | 311 | ulong SharpFormat::getCsum( const QStringList & attList) |
349 | { | 312 | { |
350 | int max = attList.count() -1; | 313 | int max = attList.count() -1; |
351 | ulong cSum = 0; | 314 | ulong cSum = 0; |
352 | int j,k,i; | 315 | int j,k,i; |
353 | int add; | 316 | int add; |
354 | for ( i = 1; i < max ; ++i ) { | 317 | for ( i = 1; i < max ; ++i ) { |
355 | QString s = attList[i]; | 318 | QString s = attList[i]; |
356 | if ( ! s.isEmpty() ){ | 319 | if ( ! s.isEmpty() ){ |
357 | j = s.length(); | 320 | j = s.length(); |
358 | for ( k = 0; k < j; ++k ) { | 321 | for ( k = 0; k < j; ++k ) { |
359 | int mul = k +1; | 322 | int mul = k +1; |
360 | add = s[k].unicode (); | 323 | add = s[k].unicode (); |
361 | if ( k < 16 ) | 324 | if ( k < 16 ) |
362 | mul = mul * mul; | 325 | mul = mul * mul; |
363 | add = add * mul *i*i*i; | 326 | add = add * mul *i*i*i; |
364 | cSum += add; | 327 | cSum += add; |
365 | } | 328 | } |
366 | } | 329 | } |
@@ -997,49 +960,49 @@ QString SharpFormat::getPart( const QString & text, bool &ok, int &start ) | |||
997 | } | 960 | } |
998 | // qDebug(" nl < kom ", nl); | 961 | // qDebug(" nl < kom ", nl); |
999 | retval = text.mid( start, nl-start); | 962 | retval = text.mid( start, nl-start); |
1000 | ok = false; | 963 | ok = false; |
1001 | start = nl+1; | 964 | start = nl+1; |
1002 | return retval; | 965 | return retval; |
1003 | } | 966 | } |
1004 | } | 967 | } |
1005 | } | 968 | } |
1006 | bool SharpFormat::fromString( Calendar *calendar, const QString & text) | 969 | bool SharpFormat::fromString( Calendar *calendar, const QString & text) |
1007 | { | 970 | { |
1008 | return false; | 971 | return false; |
1009 | } | 972 | } |
1010 | bool SharpFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, const QString & text, const QString & type) | 973 | bool SharpFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, const QString & text, const QString & type) |
1011 | { | 974 | { |
1012 | // qDebug("test %s ", text.latin1()); | 975 | // qDebug("test %s ", text.latin1()); |
1013 | QStringList templist; | 976 | QStringList templist; |
1014 | QString tempString; | 977 | QString tempString; |
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 ) { |
1028 | start = 0; | 991 | start = 0; |
1029 | ok = false; | 992 | ok = false; |
1030 | } | 993 | } |
1031 | if ( tempString.right(1) =="\n" ) | 994 | if ( tempString.right(1) =="\n" ) |
1032 | tempString = tempString.left( tempString.length()-1); | 995 | tempString = tempString.left( tempString.length()-1); |
1033 | //if ( ok ) | 996 | //if ( ok ) |
1034 | templist.append( tempString ); | 997 | templist.append( tempString ); |
1035 | //qDebug("%d ---%s---", templist.count(),tempString.latin1() ); | 998 | //qDebug("%d ---%s---", templist.count(),tempString.latin1() ); |
1036 | } | 999 | } |
1037 | handler.startElement( existingCalendar, templist, type ); | 1000 | handler.startElement( existingCalendar, templist, type ); |
1038 | } | 1001 | } |
1039 | 1002 | ||
1040 | return false; | 1003 | return false; |
1041 | } | 1004 | } |
1042 | 1005 | ||
1043 | QString SharpFormat::toString( Calendar * ) | 1006 | QString SharpFormat::toString( Calendar * ) |
1044 | { | 1007 | { |
1045 | return QString::null; | 1008 | return QString::null; |
diff --git a/libkcal/sharpformat.h b/libkcal/sharpformat.h index 0b13862..a71177d 100644 --- a/libkcal/sharpformat.h +++ b/libkcal/sharpformat.h | |||
@@ -19,43 +19,41 @@ | |||
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | #ifndef SHARPFORMAT_H | 21 | #ifndef SHARPFORMAT_H |
22 | #define SHARPAFORMAT_H | 22 | #define SHARPAFORMAT_H |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | 25 | ||
26 | #include "scheduler.h" | 26 | #include "scheduler.h" |
27 | 27 | ||
28 | #include "calformat.h" | 28 | #include "calformat.h" |
29 | 29 | ||
30 | namespace KCal { | 30 | namespace KCal { |
31 | 31 | ||
32 | /** | 32 | /** |
33 | This class implements the calendar format used by Sharp. | 33 | This class implements the calendar format used by Sharp. |
34 | */ | 34 | */ |
35 | class SharpFormat : public QObject { | 35 | class SharpFormat : public QObject { |
36 | public: | 36 | public: |
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 | ||
61 | #endif | 59 | #endif |
diff --git a/microkde/kconfig.cpp b/microkde/kconfig.cpp index 5b685d3..862166d 100644 --- a/microkde/kconfig.cpp +++ b/microkde/kconfig.cpp | |||
@@ -85,78 +85,78 @@ QValueList<int> KConfig::readIntListEntry( const QString & key) | |||
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 | ||
91 | int KConfig::readNumEntry( const QString & key, int def ) | 91 | int 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 | ||
101 | QString KConfig::readEntry( const QString &key, const QString &def ) | 101 | QString 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 QString::fromUtf8((*it).latin1()); |
110 | } | 110 | } |
111 | 111 | ||
112 | QSize KConfig::readSizeEntry( const QString &key, QSize* def ) | 112 | QSize KConfig::readSizeEntry( const QString &key, QSize* def ) |
113 | { | 113 | { |
114 | QValueList<int> intlist = readIntListEntry(key); | 114 | QValueList<int> intlist = readIntListEntry(key); |
115 | 115 | ||
116 | if (intlist.count() < 2) | 116 | if (intlist.count() < 2) |
117 | { | 117 | { |
118 | if (def) | 118 | if (def) |
119 | return *def; | 119 | return *def; |
120 | else | 120 | else |
121 | return QSize(); | 121 | return QSize(); |
122 | } | 122 | } |
123 | 123 | ||
124 | QSize ret; | 124 | QSize ret; |
125 | ret.setWidth(intlist[0]); | 125 | ret.setWidth(intlist[0]); |
126 | ret.setHeight(intlist[1]); | 126 | ret.setHeight(intlist[1]); |
127 | 127 | ||
128 | return ret; | 128 | return ret; |
129 | } | 129 | } |
130 | 130 | ||
131 | QStringList KConfig::readListEntry( const QString &key ) | 131 | 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 | ||
142 | bool KConfig::readBoolEntry( const QString &key, bool def ) | 142 | bool 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 ); |
145 | 145 | ||
146 | if ( it == mBoolMap.end() ) { | 146 | if ( it == mBoolMap.end() ) { |
147 | return def; | 147 | return def; |
148 | } | 148 | } |
149 | 149 | ||
150 | return *it; | 150 | return *it; |
151 | } | 151 | } |
152 | 152 | ||
153 | QColor KConfig::readColorEntry( const QString & e, QColor *def ) | 153 | QColor KConfig::readColorEntry( const QString & e, QColor *def ) |
154 | { | 154 | { |
155 | 155 | ||
156 | QStringList l; | 156 | QStringList l; |
157 | l = readListEntry( e ); | 157 | l = readListEntry( e ); |
158 | if (l.count() != 3 ) { | 158 | if (l.count() != 3 ) { |
159 | if ( def ) | 159 | if ( def ) |
160 | return *def; | 160 | return *def; |
161 | else | 161 | else |
162 | return QColor(); | 162 | return QColor(); |
@@ -192,56 +192,56 @@ QDateTime KConfig::readDateTimeEntry( const QString &key, const QDateTime *def ) | |||
192 | 192 | ||
193 | //US added method | 193 | //US added method |
194 | void KConfig::writeEntry( const QString &key, const QValueList<int> &value) | 194 | void KConfig::writeEntry( const QString &key, const QValueList<int> &value) |
195 | { | 195 | { |
196 | QStringList valuesAsStrings; | 196 | QStringList valuesAsStrings; |
197 | 197 | ||
198 | QValueList<int>::ConstIterator it; | 198 | QValueList<int>::ConstIterator it; |
199 | 199 | ||
200 | for( it = value.begin(); it != value.end(); ++it ) | 200 | for( it = value.begin(); it != value.end(); ++it ) |
201 | { | 201 | { |
202 | valuesAsStrings << QString::number(*it); | 202 | valuesAsStrings << QString::number(*it); |
203 | } | 203 | } |
204 | 204 | ||
205 | mStringMap.insert( mGroup + key, valuesAsStrings.join(":") ); | 205 | mStringMap.insert( mGroup + key, valuesAsStrings.join(":") ); |
206 | mDirty = true; | 206 | mDirty = true; |
207 | } | 207 | } |
208 | 208 | ||
209 | void KConfig::writeEntry( const QString & key , int num ) | 209 | 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 | ||
214 | void KConfig::writeEntry( const QString &key, const QString &value ) | 214 | void 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 | ||
221 | void KConfig::writeEntry( const QString &key, const QStringList &value ) | 221 | void 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 | ||
228 | void KConfig::writeEntry( const QString &key, bool value) | 228 | void KConfig::writeEntry( const QString &key, bool value) |
229 | { | 229 | { |
230 | mBoolMap.insert( mGroup + key, value ); | 230 | mBoolMap.insert( mGroup + key, value ); |
231 | 231 | ||
232 | mDirty = true; | 232 | mDirty = true; |
233 | } | 233 | } |
234 | 234 | ||
235 | void KConfig::writeEntry( const QString & e, const QColor & c ) | 235 | void KConfig::writeEntry( const QString & e, const QColor & c ) |
236 | { | 236 | { |
237 | QStringList l; | 237 | QStringList l; |
238 | l.append( QString::number ( c.red() ) ); | 238 | l.append( QString::number ( c.red() ) ); |
239 | l.append( QString::number ( c.green() ) ); | 239 | l.append( QString::number ( c.green() ) ); |
240 | l.append( QString::number ( c.blue() ) ); | 240 | l.append( QString::number ( c.blue() ) ); |
241 | writeEntry( e, l ); | 241 | writeEntry( e, l ); |
242 | } | 242 | } |
243 | 243 | ||
244 | void KConfig::writeEntry( const QString & e, const QSize & s ) | 244 | void KConfig::writeEntry( const QString & e, const QSize & s ) |
245 | { | 245 | { |
246 | QValueList<int> intlist; | 246 | QValueList<int> intlist; |
247 | intlist << s.width() << s.height(); | 247 | intlist << s.width() << s.height(); |