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 | |||
@@ -2114,385 +2114,386 @@ void CalendarView::changeEventDisplay(Event *which, int action) | |||
2114 | 2114 | ||
2115 | void CalendarView::updateTodoViews() | 2115 | void CalendarView::updateTodoViews() |
2116 | { | 2116 | { |
2117 | 2117 | ||
2118 | mTodoList->updateView(); | 2118 | mTodoList->updateView(); |
2119 | mViewManager->currentView()->updateView(); | 2119 | mViewManager->currentView()->updateView(); |
2120 | 2120 | ||
2121 | } | 2121 | } |
2122 | 2122 | ||
2123 | 2123 | ||
2124 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2124 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2125 | { | 2125 | { |
2126 | mTodoList->updateView(); | 2126 | mTodoList->updateView(); |
2127 | mViewManager->updateView(start, end); | 2127 | mViewManager->updateView(start, end); |
2128 | //mDateNavigator->updateView(); | 2128 | //mDateNavigator->updateView(); |
2129 | } | 2129 | } |
2130 | 2130 | ||
2131 | void CalendarView::updateView() | 2131 | void CalendarView::updateView() |
2132 | { | 2132 | { |
2133 | DateList tmpList = mNavigator->selectedDates(); | 2133 | DateList tmpList = mNavigator->selectedDates(); |
2134 | 2134 | ||
2135 | // We assume that the navigator only selects consecutive days. | 2135 | // We assume that the navigator only selects consecutive days. |
2136 | updateView( tmpList.first(), tmpList.last() ); | 2136 | updateView( tmpList.first(), tmpList.last() ); |
2137 | } | 2137 | } |
2138 | 2138 | ||
2139 | void CalendarView::updateUnmanagedViews() | 2139 | void CalendarView::updateUnmanagedViews() |
2140 | { | 2140 | { |
2141 | mDateNavigator->updateDayMatrix(); | 2141 | mDateNavigator->updateDayMatrix(); |
2142 | } | 2142 | } |
2143 | 2143 | ||
2144 | int CalendarView::msgItemDelete() | 2144 | int CalendarView::msgItemDelete() |
2145 | { | 2145 | { |
2146 | return KMessageBox::warningContinueCancel(this, | 2146 | return KMessageBox::warningContinueCancel(this, |
2147 | i18n("This item will be\npermanently deleted."), | 2147 | i18n("This item will be\npermanently deleted."), |
2148 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2148 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2149 | } | 2149 | } |
2150 | 2150 | ||
2151 | 2151 | ||
2152 | void CalendarView::edit_cut() | 2152 | void CalendarView::edit_cut() |
2153 | { | 2153 | { |
2154 | Event *anEvent=0; | 2154 | Event *anEvent=0; |
2155 | 2155 | ||
2156 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2156 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2157 | 2157 | ||
2158 | if (mViewManager->currentView()->isEventView()) { | 2158 | if (mViewManager->currentView()->isEventView()) { |
2159 | if ( incidence && incidence->type() == "Event" ) { | 2159 | if ( incidence && incidence->type() == "Event" ) { |
2160 | anEvent = static_cast<Event *>(incidence); | 2160 | anEvent = static_cast<Event *>(incidence); |
2161 | } | 2161 | } |
2162 | } | 2162 | } |
2163 | 2163 | ||
2164 | if (!anEvent) { | 2164 | if (!anEvent) { |
2165 | KNotifyClient::beep(); | 2165 | KNotifyClient::beep(); |
2166 | return; | 2166 | return; |
2167 | } | 2167 | } |
2168 | DndFactory factory( mCalendar ); | 2168 | DndFactory factory( mCalendar ); |
2169 | factory.cutEvent(anEvent); | 2169 | factory.cutEvent(anEvent); |
2170 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2170 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2171 | } | 2171 | } |
2172 | 2172 | ||
2173 | void CalendarView::edit_copy() | 2173 | void CalendarView::edit_copy() |
2174 | { | 2174 | { |
2175 | Event *anEvent=0; | 2175 | Event *anEvent=0; |
2176 | 2176 | ||
2177 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2177 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2178 | 2178 | ||
2179 | if (mViewManager->currentView()->isEventView()) { | 2179 | if (mViewManager->currentView()->isEventView()) { |
2180 | if ( incidence && incidence->type() == "Event" ) { | 2180 | if ( incidence && incidence->type() == "Event" ) { |
2181 | anEvent = static_cast<Event *>(incidence); | 2181 | anEvent = static_cast<Event *>(incidence); |
2182 | } | 2182 | } |
2183 | } | 2183 | } |
2184 | 2184 | ||
2185 | if (!anEvent) { | 2185 | if (!anEvent) { |
2186 | KNotifyClient::beep(); | 2186 | KNotifyClient::beep(); |
2187 | return; | 2187 | return; |
2188 | } | 2188 | } |
2189 | DndFactory factory( mCalendar ); | 2189 | DndFactory factory( mCalendar ); |
2190 | factory.copyEvent(anEvent); | 2190 | factory.copyEvent(anEvent); |
2191 | } | 2191 | } |
2192 | 2192 | ||
2193 | void CalendarView::edit_paste() | 2193 | void CalendarView::edit_paste() |
2194 | { | 2194 | { |
2195 | QDate date = mNavigator->selectedDates().first(); | 2195 | QDate date = mNavigator->selectedDates().first(); |
2196 | 2196 | ||
2197 | DndFactory factory( mCalendar ); | 2197 | DndFactory factory( mCalendar ); |
2198 | Event *pastedEvent = factory.pasteEvent( date ); | 2198 | Event *pastedEvent = factory.pasteEvent( date ); |
2199 | 2199 | ||
2200 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2200 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2201 | } | 2201 | } |
2202 | 2202 | ||
2203 | void CalendarView::edit_options() | 2203 | void CalendarView::edit_options() |
2204 | { | 2204 | { |
2205 | mDialogManager->showOptionsDialog(); | 2205 | mDialogManager->showOptionsDialog(); |
2206 | //writeSettings(); | 2206 | //writeSettings(); |
2207 | } | 2207 | } |
2208 | 2208 | ||
2209 | void CalendarView::slotSelectPickerDate( QDate d) | 2209 | void CalendarView::slotSelectPickerDate( QDate d) |
2210 | { | 2210 | { |
2211 | mDateFrame->hide(); | 2211 | mDateFrame->hide(); |
2212 | if ( mDatePickerMode == 1 ) { | 2212 | if ( mDatePickerMode == 1 ) { |
2213 | mNavigator->slotDaySelect( d ); | 2213 | mNavigator->slotDaySelect( d ); |
2214 | } else if ( mDatePickerMode == 2 ) { | 2214 | } else if ( mDatePickerMode == 2 ) { |
2215 | if ( mMoveIncidence->type() == "Todo" ) { | 2215 | if ( mMoveIncidence->type() == "Todo" ) { |
2216 | Todo * to = (Todo *) mMoveIncidence; | 2216 | Todo * to = (Todo *) mMoveIncidence; |
2217 | QTime tim; | 2217 | QTime tim; |
2218 | if ( to->hasDueDate() ) | 2218 | if ( to->hasDueDate() ) |
2219 | tim = to->dtDue().time(); | 2219 | tim = to->dtDue().time(); |
2220 | else { | 2220 | else { |
2221 | tim = QTime ( 0,0,0 ); | 2221 | tim = QTime ( 0,0,0 ); |
2222 | to->setFloats( true ); | 2222 | to->setFloats( true ); |
2223 | to->setHasDueDate( true ); | 2223 | to->setHasDueDate( true ); |
2224 | } | 2224 | } |
2225 | QDateTime dt ( d,tim ); | 2225 | QDateTime dt ( d,tim ); |
2226 | to->setDtDue( dt ); | 2226 | to->setDtDue( dt ); |
2227 | todoChanged( to ); | 2227 | todoChanged( to ); |
2228 | } else { | 2228 | } else { |
2229 | QTime tim = mMoveIncidence->dtStart().time(); | 2229 | QTime tim = mMoveIncidence->dtStart().time(); |
2230 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2230 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2231 | QDateTime dt ( d,tim ); | 2231 | QDateTime dt ( d,tim ); |
2232 | mMoveIncidence->setDtStart( dt ); | 2232 | mMoveIncidence->setDtStart( dt ); |
2233 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2233 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2234 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2234 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2235 | } | 2235 | } |
2236 | 2236 | ||
2237 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2237 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2238 | } | 2238 | } |
2239 | } | 2239 | } |
2240 | 2240 | ||
2241 | void CalendarView::removeCategories() | 2241 | void CalendarView::removeCategories() |
2242 | { | 2242 | { |
2243 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2243 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2244 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2244 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2245 | QStringList catIncList; | 2245 | QStringList catIncList; |
2246 | QStringList newCatList; | 2246 | QStringList newCatList; |
2247 | Incidence* inc = incList.first(); | 2247 | Incidence* inc = incList.first(); |
2248 | int i; | 2248 | int i; |
2249 | int count = 0; | 2249 | int count = 0; |
2250 | while ( inc ) { | 2250 | while ( inc ) { |
2251 | newCatList.clear(); | 2251 | newCatList.clear(); |
2252 | catIncList = inc->categories() ; | 2252 | catIncList = inc->categories() ; |
2253 | for( i = 0; i< catIncList.count(); ++i ) { | 2253 | for( i = 0; i< catIncList.count(); ++i ) { |
2254 | if ( catList.contains (catIncList[i])) | 2254 | if ( catList.contains (catIncList[i])) |
2255 | newCatList.append( catIncList[i] ); | 2255 | newCatList.append( catIncList[i] ); |
2256 | } | 2256 | } |
2257 | newCatList.sort(); | 2257 | newCatList.sort(); |
2258 | inc->setCategories( newCatList.join(",") ); | 2258 | inc->setCategories( newCatList.join(",") ); |
2259 | inc = incList.next(); | 2259 | inc = incList.next(); |
2260 | } | 2260 | } |
2261 | } | 2261 | } |
2262 | 2262 | ||
2263 | int CalendarView::addCategories() | 2263 | int CalendarView::addCategories() |
2264 | { | 2264 | { |
2265 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2265 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2266 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2266 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2267 | QStringList catIncList; | 2267 | QStringList catIncList; |
2268 | Incidence* inc = incList.first(); | 2268 | Incidence* inc = incList.first(); |
2269 | int i; | 2269 | int i; |
2270 | int count = 0; | 2270 | int count = 0; |
2271 | while ( inc ) { | 2271 | while ( inc ) { |
2272 | catIncList = inc->categories() ; | 2272 | catIncList = inc->categories() ; |
2273 | for( i = 0; i< catIncList.count(); ++i ) { | 2273 | for( i = 0; i< catIncList.count(); ++i ) { |
2274 | if ( !catList.contains (catIncList[i])) { | 2274 | if ( !catList.contains (catIncList[i])) { |
2275 | catList.append( catIncList[i] ); | 2275 | catList.append( catIncList[i] ); |
2276 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2276 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2277 | ++count; | 2277 | ++count; |
2278 | } | 2278 | } |
2279 | } | 2279 | } |
2280 | inc = incList.next(); | 2280 | inc = incList.next(); |
2281 | } | 2281 | } |
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 ); |
2331 | } | 2332 | } |
2332 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2333 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2333 | { | 2334 | { |
2334 | if ( beamDialog->exec () == QDialog::Rejected ) | 2335 | if ( beamDialog->exec () == QDialog::Rejected ) |
2335 | return; | 2336 | return; |
2336 | #ifdef DESKTOP_VERSION | 2337 | #ifdef DESKTOP_VERSION |
2337 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2338 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2338 | #else | 2339 | #else |
2339 | QString fn = "/tmp/kopibeamfile"; | 2340 | QString fn = "/tmp/kopibeamfile"; |
2340 | #endif | 2341 | #endif |
2341 | QString mes; | 2342 | QString mes; |
2342 | bool createbup = true; | 2343 | bool createbup = true; |
2343 | if ( createbup ) { | 2344 | if ( createbup ) { |
2344 | QString description = "\n"; | 2345 | QString description = "\n"; |
2345 | CalendarLocal* cal = new CalendarLocal(); | 2346 | CalendarLocal* cal = new CalendarLocal(); |
2346 | if ( beamDialog->beamLocal() ) | 2347 | if ( beamDialog->beamLocal() ) |
2347 | cal->setLocalTime(); | 2348 | cal->setLocalTime(); |
2348 | else | 2349 | else |
2349 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2350 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2350 | Incidence *incidence = delSel.first(); | 2351 | Incidence *incidence = delSel.first(); |
2351 | bool addText = false; | 2352 | bool addText = false; |
2352 | if ( delSel.count() < 10 ) | 2353 | if ( delSel.count() < 10 ) |
2353 | addText = true; | 2354 | addText = true; |
2354 | else { | 2355 | else { |
2355 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2356 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2356 | } | 2357 | } |
2357 | while ( incidence ) { | 2358 | while ( incidence ) { |
2358 | Incidence *in = incidence->clone(); | 2359 | Incidence *in = incidence->clone(); |
2359 | if ( ! in->summary().isEmpty() ) { | 2360 | if ( ! in->summary().isEmpty() ) { |
2360 | in->setDescription(""); | 2361 | in->setDescription(""); |
2361 | } else { | 2362 | } else { |
2362 | in->setSummary( in->description().left(20)); | 2363 | in->setSummary( in->description().left(20)); |
2363 | in->setDescription(""); | 2364 | in->setDescription(""); |
2364 | } | 2365 | } |
2365 | if ( addText ) | 2366 | if ( addText ) |
2366 | description += in->summary() + "\n"; | 2367 | description += in->summary() + "\n"; |
2367 | cal->addIncidence( in ); | 2368 | cal->addIncidence( in ); |
2368 | incidence = delSel.next(); | 2369 | incidence = delSel.next(); |
2369 | } | 2370 | } |
2370 | if ( beamDialog->beamVcal() ) { | 2371 | if ( beamDialog->beamVcal() ) { |
2371 | fn += ".vcs"; | 2372 | fn += ".vcs"; |
2372 | FileStorage storage( cal, fn, new VCalFormat ); | 2373 | FileStorage storage( cal, fn, new VCalFormat ); |
2373 | storage.save(); | 2374 | storage.save(); |
2374 | } else { | 2375 | } else { |
2375 | fn += ".ics"; | 2376 | fn += ".ics"; |
2376 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2377 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2377 | storage.save(); | 2378 | storage.save(); |
2378 | } | 2379 | } |
2379 | delete cal; | 2380 | delete cal; |
2380 | mes = i18n("KO/Pi: Ready for beaming"); | 2381 | mes = i18n("KO/Pi: Ready for beaming"); |
2381 | topLevelWidget()->setCaption(mes); | 2382 | topLevelWidget()->setCaption(mes); |
2382 | KApplication::convert2latin1( fn ); | 2383 | KApplication::convert2latin1( fn ); |
2383 | #ifndef DESKTOP_VERSION | 2384 | #ifndef DESKTOP_VERSION |
2384 | Ir *ir = new Ir( this ); | 2385 | Ir *ir = new Ir( this ); |
2385 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2386 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2386 | ir->send( fn, description, "text/x-vCalendar" ); | 2387 | ir->send( fn, description, "text/x-vCalendar" ); |
2387 | #endif | 2388 | #endif |
2388 | } | 2389 | } |
2389 | } | 2390 | } |
2390 | void CalendarView::beamDone( Ir *ir ) | 2391 | void CalendarView::beamDone( Ir *ir ) |
2391 | { | 2392 | { |
2392 | #ifndef DESKTOP_VERSION | 2393 | #ifndef DESKTOP_VERSION |
2393 | delete ir; | 2394 | delete ir; |
2394 | #endif | 2395 | #endif |
2395 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2396 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2396 | topLevelWidget()->raise(); | 2397 | topLevelWidget()->raise(); |
2397 | } | 2398 | } |
2398 | 2399 | ||
2399 | void CalendarView::moveIncidence(Incidence * inc ) | 2400 | void CalendarView::moveIncidence(Incidence * inc ) |
2400 | { | 2401 | { |
2401 | if ( !inc ) return; | 2402 | if ( !inc ) return; |
2402 | // qDebug("showDatePickerForIncidence( ) "); | 2403 | // qDebug("showDatePickerForIncidence( ) "); |
2403 | if ( mDateFrame->isVisible() ) | 2404 | if ( mDateFrame->isVisible() ) |
2404 | mDateFrame->hide(); | 2405 | mDateFrame->hide(); |
2405 | else { | 2406 | else { |
2406 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2407 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2407 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2408 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2408 | int dw = QApplication::desktop()->width(); | 2409 | int dw = QApplication::desktop()->width(); |
2409 | int dh = QApplication::desktop()->height(); | 2410 | int dh = QApplication::desktop()->height(); |
2410 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2411 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2411 | mDateFrame->show(); | 2412 | mDateFrame->show(); |
2412 | } | 2413 | } |
2413 | mDatePickerMode = 2; | 2414 | mDatePickerMode = 2; |
2414 | mMoveIncidence = inc ; | 2415 | mMoveIncidence = inc ; |
2415 | QDate da; | 2416 | QDate da; |
2416 | if ( mMoveIncidence->type() == "Todo" ) { | 2417 | if ( mMoveIncidence->type() == "Todo" ) { |
2417 | Todo * to = (Todo *) mMoveIncidence; | 2418 | Todo * to = (Todo *) mMoveIncidence; |
2418 | if ( to->hasDueDate() ) | 2419 | if ( to->hasDueDate() ) |
2419 | da = to->dtDue().date(); | 2420 | da = to->dtDue().date(); |
2420 | else | 2421 | else |
2421 | da = QDate::currentDate(); | 2422 | da = QDate::currentDate(); |
2422 | } else { | 2423 | } else { |
2423 | da = mMoveIncidence->dtStart().date(); | 2424 | da = mMoveIncidence->dtStart().date(); |
2424 | } | 2425 | } |
2425 | mDatePicker->setDate( da ); | 2426 | mDatePicker->setDate( da ); |
2426 | } | 2427 | } |
2427 | void CalendarView::showDatePicker( ) | 2428 | void CalendarView::showDatePicker( ) |
2428 | { | 2429 | { |
2429 | //qDebug("CalendarView::showDatePicker( ) "); | 2430 | //qDebug("CalendarView::showDatePicker( ) "); |
2430 | if ( mDateFrame->isVisible() ) | 2431 | if ( mDateFrame->isVisible() ) |
2431 | mDateFrame->hide(); | 2432 | mDateFrame->hide(); |
2432 | else { | 2433 | else { |
2433 | int w =mDatePicker->sizeHint().width() ; | 2434 | int w =mDatePicker->sizeHint().width() ; |
2434 | int h = mDatePicker->sizeHint().height() ; | 2435 | int h = mDatePicker->sizeHint().height() ; |
2435 | int dw = QApplication::desktop()->width(); | 2436 | int dw = QApplication::desktop()->width(); |
2436 | int dh = QApplication::desktop()->height(); | 2437 | int dh = QApplication::desktop()->height(); |
2437 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2438 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2438 | mDateFrame->show(); | 2439 | mDateFrame->show(); |
2439 | } | 2440 | } |
2440 | mDatePickerMode = 1; | 2441 | mDatePickerMode = 1; |
2441 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2442 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2442 | } | 2443 | } |
2443 | 2444 | ||
2444 | void CalendarView::showEventEditor() | 2445 | void CalendarView::showEventEditor() |
2445 | { | 2446 | { |
2446 | #ifdef DESKTOP_VERSION | 2447 | #ifdef DESKTOP_VERSION |
2447 | mEventEditor->show(); | 2448 | mEventEditor->show(); |
2448 | #else | 2449 | #else |
2449 | mEventEditor->showMaximized(); | 2450 | mEventEditor->showMaximized(); |
2450 | #endif | 2451 | #endif |
2451 | } | 2452 | } |
2452 | void CalendarView::showTodoEditor() | 2453 | void CalendarView::showTodoEditor() |
2453 | { | 2454 | { |
2454 | #ifdef DESKTOP_VERSION | 2455 | #ifdef DESKTOP_VERSION |
2455 | mTodoEditor->show(); | 2456 | mTodoEditor->show(); |
2456 | #else | 2457 | #else |
2457 | mTodoEditor->showMaximized(); | 2458 | mTodoEditor->showMaximized(); |
2458 | #endif | 2459 | #endif |
2459 | } | 2460 | } |
2460 | 2461 | ||
2461 | void CalendarView::cloneIncidence() | 2462 | void CalendarView::cloneIncidence() |
2462 | { | 2463 | { |
2463 | Incidence *incidence = currentSelection(); | 2464 | Incidence *incidence = currentSelection(); |
2464 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2465 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2465 | if ( incidence ) { | 2466 | if ( incidence ) { |
2466 | cloneIncidence(incidence); | 2467 | cloneIncidence(incidence); |
2467 | } | 2468 | } |
2468 | } | 2469 | } |
2469 | void CalendarView::moveIncidence() | 2470 | void CalendarView::moveIncidence() |
2470 | { | 2471 | { |
2471 | Incidence *incidence = currentSelection(); | 2472 | Incidence *incidence = currentSelection(); |
2472 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2473 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2473 | if ( incidence ) { | 2474 | if ( incidence ) { |
2474 | moveIncidence(incidence); | 2475 | moveIncidence(incidence); |
2475 | } | 2476 | } |
2476 | } | 2477 | } |
2477 | void CalendarView::beamIncidence() | 2478 | void CalendarView::beamIncidence() |
2478 | { | 2479 | { |
2479 | Incidence *incidence = currentSelection(); | 2480 | Incidence *incidence = currentSelection(); |
2480 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2481 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2481 | if ( incidence ) { | 2482 | if ( incidence ) { |
2482 | beamIncidence(incidence); | 2483 | beamIncidence(incidence); |
2483 | } | 2484 | } |
2484 | } | 2485 | } |
2485 | void CalendarView::toggleCancelIncidence() | 2486 | void CalendarView::toggleCancelIncidence() |
2486 | { | 2487 | { |
2487 | Incidence *incidence = currentSelection(); | 2488 | Incidence *incidence = currentSelection(); |
2488 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2489 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2489 | if ( incidence ) { | 2490 | if ( incidence ) { |
2490 | cancelIncidence(incidence); | 2491 | cancelIncidence(incidence); |
2491 | } | 2492 | } |
2492 | } | 2493 | } |
2493 | 2494 | ||
2494 | 2495 | ||
2495 | void CalendarView::cancelIncidence(Incidence * inc ) | 2496 | void CalendarView::cancelIncidence(Incidence * inc ) |
2496 | { | 2497 | { |
2497 | inc->setCancelled( ! inc->cancelled() ); | 2498 | inc->setCancelled( ! inc->cancelled() ); |
2498 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2499 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index b88e729..24b8349 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp | |||
@@ -1,534 +1,497 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <qdatetime.h> | 22 | #include <qdatetime.h> |
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qclipboard.h> | 28 | #include <qclipboard.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qtextcodec.h> | 31 | #include <qtextcodec.h> |
32 | #include <qxml.h> | 32 | #include <qxml.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | 34 | ||
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kglobal.h> | 37 | #include <kglobal.h> |
38 | 38 | ||
39 | #include "calendar.h" | 39 | #include "calendar.h" |
40 | #include "alarm.h" | 40 | #include "alarm.h" |
41 | #include "recurrence.h" | 41 | #include "recurrence.h" |
42 | #include "calendarlocal.h" | 42 | #include "calendarlocal.h" |
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 |
92 | event = new Event; | 91 | event = new Event; |
93 | event->setID("Sharp_DTM", attList[0] ); | 92 | event->setID("Sharp_DTM", attList[0] ); |
94 | event->setCsum( "Sharp_DTM", QString::number( cSum )); | 93 | event->setCsum( "Sharp_DTM", QString::number( cSum )); |
95 | event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); | 94 | event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); |
96 | 95 | ||
97 | event->setSummary( attList[2] ); | 96 | event->setSummary( attList[2] ); |
98 | event->setLocation( attList[3] ); | 97 | event->setLocation( attList[3] ); |
99 | event->setDescription( attList[4] ); | 98 | event->setDescription( attList[4] ); |
100 | if ( attList[7] == "1" ) { | 99 | if ( attList[7] == "1" ) { |
101 | event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) )); | 100 | event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) )); |
102 | event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 ))); | 101 | event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 ))); |
103 | event->setFloats( true ); | 102 | event->setFloats( true ); |
104 | } else { | 103 | } else { |
105 | event->setFloats( false ); | 104 | event->setFloats( false ); |
106 | event->setDtStart( fromString( attList[5] ) ); | 105 | event->setDtStart( fromString( attList[5] ) ); |
107 | event->setDtEnd( fromString( attList[6] )); | 106 | event->setDtEnd( fromString( attList[6] )); |
108 | } | 107 | } |
109 | 108 | ||
110 | QString rtype = attList[11]; | 109 | QString rtype = attList[11]; |
111 | if ( rtype != "255" ) { | 110 | if ( rtype != "255" ) { |
112 | // qDebug("recurs "); | 111 | // qDebug("recurs "); |
113 | QDate startDate = event->dtStart().date(); | 112 | QDate startDate = event->dtStart().date(); |
114 | 113 | ||
115 | QString freqStr = attList[12]; | 114 | QString freqStr = attList[12]; |
116 | int freq = freqStr.toInt(); | 115 | int freq = freqStr.toInt(); |
117 | 116 | ||
118 | QString hasEndDateStr = attList[15] ; | 117 | QString hasEndDateStr = attList[15] ; |
119 | bool hasEndDate = hasEndDateStr == "1"; | 118 | bool hasEndDate = hasEndDateStr == "1"; |
120 | 119 | ||
121 | QString endDateStr = attList[16]; | 120 | QString endDateStr = attList[16]; |
122 | QDate endDate = fromString( endDateStr ).date(); | 121 | QDate endDate = fromString( endDateStr ).date(); |
123 | 122 | ||
124 | QString weekDaysStr = attList[14]; | 123 | QString weekDaysStr = attList[14]; |
125 | uint weekDaysNum = weekDaysStr.toInt(); | 124 | uint weekDaysNum = weekDaysStr.toInt(); |
126 | 125 | ||
127 | QBitArray weekDays( 7 ); | 126 | QBitArray weekDays( 7 ); |
128 | int i; | 127 | int i; |
129 | int bb = 1; | 128 | int bb = 1; |
130 | for( i = 1; i <= 7; ++i ) { | 129 | for( i = 1; i <= 7; ++i ) { |
131 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); | 130 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); |
132 | bb = 2 << (i-1); | 131 | bb = 2 << (i-1); |
133 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); | 132 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); |
134 | } | 133 | } |
135 | // qDebug("next "); | 134 | // qDebug("next "); |
136 | QString posStr = attList[13]; | 135 | QString posStr = attList[13]; |
137 | int pos = posStr.toInt(); | 136 | int pos = posStr.toInt(); |
138 | Recurrence *r = event->recurrence(); | 137 | Recurrence *r = event->recurrence(); |
139 | 138 | ||
140 | if ( rtype == "0" ) { | 139 | if ( rtype == "0" ) { |
141 | if ( hasEndDate ) r->setDaily( freq, endDate ); | 140 | if ( hasEndDate ) r->setDaily( freq, endDate ); |
142 | else r->setDaily( freq, -1 ); | 141 | else r->setDaily( freq, -1 ); |
143 | } else if ( rtype == "1" ) { | 142 | } else if ( rtype == "1" ) { |
144 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); | 143 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); |
145 | else r->setWeekly( freq, weekDays, -1 ); | 144 | else r->setWeekly( freq, weekDays, -1 ); |
146 | } else if ( rtype == "3" ) { | 145 | } else if ( rtype == "3" ) { |
147 | if ( hasEndDate ) | 146 | if ( hasEndDate ) |
148 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 147 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
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 | } |
198 | 197 | ||
199 | mCalendar->addEvent( event); | 198 | mCalendar->addEvent( event); |
200 | } else if ( qName == "Todo" ) { | 199 | } else if ( qName == "Todo" ) { |
201 | Todo *todo; | 200 | Todo *todo; |
202 | 201 | ||
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 | } |
367 | } | 330 | } |
368 | return cSum; | 331 | return cSum; |
369 | 332 | ||
370 | } | 333 | } |
371 | #include <stdlib.h> | 334 | #include <stdlib.h> |
372 | #define DEBUGMODE false | 335 | #define DEBUGMODE false |
373 | //#define DEBUGMODE true | 336 | //#define DEBUGMODE true |
374 | bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) | 337 | bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) |
375 | { | 338 | { |
376 | 339 | ||
377 | 340 | ||
378 | bool debug = DEBUGMODE; | 341 | bool debug = DEBUGMODE; |
379 | QString text; | 342 | QString text; |
380 | QString codec = "utf8"; | 343 | QString codec = "utf8"; |
381 | QLabel status ( i18n("Reading events ..."), 0 ); | 344 | QLabel status ( i18n("Reading events ..."), 0 ); |
382 | 345 | ||
383 | int w = status.sizeHint().width()+20 ; | 346 | int w = status.sizeHint().width()+20 ; |
384 | if ( w < 200 ) w = 200; | 347 | if ( w < 200 ) w = 200; |
385 | int h = status.sizeHint().height()+20 ; | 348 | int h = status.sizeHint().height()+20 ; |
386 | int dw = QApplication::desktop()->width(); | 349 | int dw = QApplication::desktop()->width(); |
387 | int dh = QApplication::desktop()->height(); | 350 | int dh = QApplication::desktop()->height(); |
388 | status.setCaption(i18n("Reading DTM Data") ); | 351 | status.setCaption(i18n("Reading DTM Data") ); |
389 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 352 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
390 | status.show(); | 353 | status.show(); |
391 | status.raise(); | 354 | status.raise(); |
392 | qApp->processEvents(); | 355 | qApp->processEvents(); |
393 | QString fileName; | 356 | QString fileName; |
394 | if ( ! debug ) { | 357 | if ( ! debug ) { |
395 | fileName = "/tmp/kopitempout"; | 358 | fileName = "/tmp/kopitempout"; |
396 | QString command ="db2file datebook -r -c "+ codec + " > " + fileName; | 359 | QString command ="db2file datebook -r -c "+ codec + " > " + fileName; |
397 | system ( command.latin1() ); | 360 | system ( command.latin1() ); |
398 | } else { | 361 | } else { |
399 | fileName = "/tmp/events.txt"; | 362 | fileName = "/tmp/events.txt"; |
400 | 363 | ||
401 | } | 364 | } |
402 | QFile file( fileName ); | 365 | QFile file( fileName ); |
403 | if (!file.open( IO_ReadOnly ) ) { | 366 | if (!file.open( IO_ReadOnly ) ) { |
404 | return false; | 367 | return false; |
405 | 368 | ||
406 | } | 369 | } |
407 | QTextStream ts( &file ); | 370 | QTextStream ts( &file ); |
408 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 371 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
409 | text = ts.read(); | 372 | text = ts.read(); |
410 | file.close(); | 373 | file.close(); |
411 | status.setText( i18n("Processing events ...") ); | 374 | status.setText( i18n("Processing events ...") ); |
412 | status.raise(); | 375 | status.raise(); |
413 | qApp->processEvents(); | 376 | qApp->processEvents(); |
414 | fromString2Cal( calendar, existngCal, text, "Event" ); | 377 | fromString2Cal( calendar, existngCal, text, "Event" ); |
415 | status.setText( i18n("Reading todos ...") ); | 378 | status.setText( i18n("Reading todos ...") ); |
416 | qApp->processEvents(); | 379 | qApp->processEvents(); |
417 | if ( ! debug ) { | 380 | if ( ! debug ) { |
418 | fileName = "/tmp/kopitempout"; | 381 | fileName = "/tmp/kopitempout"; |
419 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; | 382 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; |
420 | system ( command.latin1() ); | 383 | system ( command.latin1() ); |
421 | } else { | 384 | } else { |
422 | fileName = "/tmp/todo.txt"; | 385 | fileName = "/tmp/todo.txt"; |
423 | } | 386 | } |
424 | file.setName( fileName ); | 387 | file.setName( fileName ); |
425 | if (!file.open( IO_ReadOnly ) ) { | 388 | if (!file.open( IO_ReadOnly ) ) { |
426 | return false; | 389 | return false; |
427 | 390 | ||
428 | } | 391 | } |
429 | ts.setDevice( &file ); | 392 | ts.setDevice( &file ); |
430 | text = ts.read(); | 393 | text = ts.read(); |
431 | file.close(); | 394 | file.close(); |
432 | 395 | ||
433 | status.setText( i18n("Processing todos ...") ); | 396 | status.setText( i18n("Processing todos ...") ); |
434 | status.raise(); | 397 | status.raise(); |
435 | qApp->processEvents(); | 398 | qApp->processEvents(); |
436 | fromString2Cal( calendar, existngCal, text, "Todo" ); | 399 | fromString2Cal( calendar, existngCal, text, "Todo" ); |
437 | return true; | 400 | return true; |
438 | } | 401 | } |
439 | int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) | 402 | int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) |
440 | { | 403 | { |
441 | int retval = -1; | 404 | int retval = -1; |
442 | QStringList templist; | 405 | QStringList templist; |
443 | QString tempString; | 406 | QString tempString; |
444 | int start = 0; | 407 | int start = 0; |
445 | int len = answer.length(); | 408 | int len = answer.length(); |
446 | int end = answer.find ("\n",start)+1; | 409 | int end = answer.find ("\n",start)+1; |
447 | bool ok = true; | 410 | bool ok = true; |
448 | start = end; | 411 | start = end; |
449 | int ccc = 0; | 412 | int ccc = 0; |
450 | while ( start > 0 ) { | 413 | while ( start > 0 ) { |
451 | templist.clear(); | 414 | templist.clear(); |
452 | ok = true; | 415 | ok = true; |
453 | int loopCount = 0; | 416 | int loopCount = 0; |
454 | while ( ok ) { | 417 | while ( ok ) { |
455 | ++loopCount; | 418 | ++loopCount; |
456 | if ( loopCount > 25 ) { | 419 | if ( loopCount > 25 ) { |
457 | qDebug("KO: Error in while loop"); | 420 | qDebug("KO: Error in while loop"); |
458 | ok = false; | 421 | ok = false; |
459 | start = 0; | 422 | start = 0; |
460 | break; | 423 | break; |
461 | } | 424 | } |
462 | if ( ok ) | 425 | if ( ok ) |
463 | tempString = getPart( answer, ok, start ); | 426 | tempString = getPart( answer, ok, start ); |
464 | if ( start >= len || start == 0 ) { | 427 | if ( start >= len || start == 0 ) { |
465 | start = 0; | 428 | start = 0; |
466 | ok = false; | 429 | ok = false; |
467 | } | 430 | } |
468 | if ( tempString.right(1) =="\n" ) | 431 | if ( tempString.right(1) =="\n" ) |
469 | tempString = tempString.left( tempString.length()-1); | 432 | tempString = tempString.left( tempString.length()-1); |
470 | 433 | ||
471 | templist.append( tempString ); | 434 | templist.append( tempString ); |
472 | } | 435 | } |
473 | ++ccc; | 436 | ++ccc; |
474 | if ( ccc == 2 && loopCount < 25 ) { | 437 | if ( ccc == 2 && loopCount < 25 ) { |
475 | start = 0; | 438 | start = 0; |
476 | bool ok; | 439 | bool ok; |
477 | int newnum = templist[0].toInt( &ok ); | 440 | int newnum = templist[0].toInt( &ok ); |
478 | if ( ok && newnum > 0) { | 441 | if ( ok && newnum > 0) { |
479 | retval = newnum; | 442 | retval = newnum; |
480 | inc->setID( "Sharp_DTM",templist[0] ); | 443 | inc->setID( "Sharp_DTM",templist[0] ); |
481 | inc->setCsum( "Sharp_DTM", QString::number( getCsum( templist ) )); | 444 | inc->setCsum( "Sharp_DTM", QString::number( getCsum( templist ) )); |
482 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 445 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
483 | } | 446 | } |
484 | if ( ok && newnum == -1 ) { | 447 | if ( ok && newnum == -1 ) { |
485 | qDebug("Error writing back %s ", inc->summary().latin1()); | 448 | qDebug("Error writing back %s ", inc->summary().latin1()); |
486 | } | 449 | } |
487 | } | 450 | } |
488 | } | 451 | } |
489 | //qDebug("getNumFromRecord returning : %d ", retval); | 452 | //qDebug("getNumFromRecord returning : %d ", retval); |
490 | return retval; | 453 | return retval; |
491 | } | 454 | } |
492 | bool SharpFormat::save( Calendar *calendar) | 455 | bool SharpFormat::save( Calendar *calendar) |
493 | { | 456 | { |
494 | 457 | ||
495 | QLabel status ( i18n("Processing/adding events ..."), 0 ); | 458 | QLabel status ( i18n("Processing/adding events ..."), 0 ); |
496 | int w = status.sizeHint().width()+20 ; | 459 | int w = status.sizeHint().width()+20 ; |
497 | if ( w < 200 ) w = 200; | 460 | if ( w < 200 ) w = 200; |
498 | int h = status.sizeHint().height()+20 ; | 461 | int h = status.sizeHint().height()+20 ; |
499 | int dw = QApplication::desktop()->width(); | 462 | int dw = QApplication::desktop()->width(); |
500 | int dh = QApplication::desktop()->height(); | 463 | int dh = QApplication::desktop()->height(); |
501 | status.setCaption(i18n("Writing DTM Data") ); | 464 | status.setCaption(i18n("Writing DTM Data") ); |
502 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 465 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
503 | status.show(); | 466 | status.show(); |
504 | status.raise(); | 467 | status.raise(); |
505 | qApp->processEvents(); | 468 | qApp->processEvents(); |
506 | bool debug = DEBUGMODE; | 469 | bool debug = DEBUGMODE; |
507 | QString codec = "utf8"; | 470 | QString codec = "utf8"; |
508 | QString answer; | 471 | QString answer; |
509 | QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; | 472 | QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; |
510 | QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; | 473 | QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; |
511 | QString command; | 474 | QString command; |
512 | QPtrList<Event> er = calendar->rawEvents(); | 475 | QPtrList<Event> er = calendar->rawEvents(); |
513 | Event* ev = er.first(); | 476 | Event* ev = er.first(); |
514 | QString fileName = "/tmp/kopitempout"; | 477 | QString fileName = "/tmp/kopitempout"; |
515 | int i = 0; | 478 | int i = 0; |
516 | QString changeString = ePrefix; | 479 | QString changeString = ePrefix; |
517 | QString deleteString = ePrefix; | 480 | QString deleteString = ePrefix; |
518 | bool deleteEnt = false; | 481 | bool deleteEnt = false; |
519 | bool changeEnt = false; | 482 | bool changeEnt = false; |
520 | QString message = i18n("Processing event # "); | 483 | QString message = i18n("Processing event # "); |
521 | int procCount = 0; | 484 | int procCount = 0; |
522 | while ( ev ) { | 485 | while ( ev ) { |
523 | //qDebug("i %d ", ++i); | 486 | //qDebug("i %d ", ++i); |
524 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 487 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
525 | status.setText ( message + QString::number ( ++procCount ) ); | 488 | status.setText ( message + QString::number ( ++procCount ) ); |
526 | qApp->processEvents(); | 489 | qApp->processEvents(); |
527 | QString eString = getEventString( ev ); | 490 | QString eString = getEventString( ev ); |
528 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 491 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
529 | // deleting empty strings does not work. | 492 | // deleting empty strings does not work. |
530 | // we write first and x and then delete the record with the x | 493 | // we write first and x and then delete the record with the x |
531 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); | 494 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); |
532 | changeString += eString + "\n"; | 495 | changeString += eString + "\n"; |
533 | deleteString += eString + "\n"; | 496 | deleteString += eString + "\n"; |
534 | deleteEnt = true; | 497 | deleteEnt = true; |
@@ -829,218 +792,218 @@ QString SharpFormat::getEventString( Event* event ) | |||
829 | 792 | ||
830 | list.append( "0" ); | 793 | list.append( "0" ); |
831 | break; | 794 | break; |
832 | case Recurrence::rMonthlyDay:// 3 | 795 | case Recurrence::rMonthlyDay:// 3 |
833 | list.append( "3" ); | 796 | list.append( "3" ); |
834 | list.append( QString::number( rec->frequency()) );//12 | 797 | list.append( QString::number( rec->frequency()) );//12 |
835 | list.append( "0" ); | 798 | list.append( "0" ); |
836 | list.append( "0" ); | 799 | list.append( "0" ); |
837 | writeEndDate = true; | 800 | writeEndDate = true; |
838 | break; | 801 | break; |
839 | case Recurrence::rYearlyMonth://4 | 802 | case Recurrence::rYearlyMonth://4 |
840 | list.append( "4" ); | 803 | list.append( "4" ); |
841 | list.append( QString::number( rec->frequency()) );//12 | 804 | list.append( QString::number( rec->frequency()) );//12 |
842 | list.append( "0" ); | 805 | list.append( "0" ); |
843 | list.append( "0" ); | 806 | list.append( "0" ); |
844 | writeEndDate = true; | 807 | writeEndDate = true; |
845 | break; | 808 | break; |
846 | 809 | ||
847 | default: | 810 | default: |
848 | list.append( "255" ); | 811 | list.append( "255" ); |
849 | list.append( QString() ); | 812 | list.append( QString() ); |
850 | list.append( "0" ); | 813 | list.append( "0" ); |
851 | list.append( QString() ); | 814 | list.append( QString() ); |
852 | list.append( "0" ); | 815 | list.append( "0" ); |
853 | list.append( "20991231T000000" ); | 816 | list.append( "20991231T000000" ); |
854 | break; | 817 | break; |
855 | } | 818 | } |
856 | if ( writeEndDate ) { | 819 | if ( writeEndDate ) { |
857 | 820 | ||
858 | if ( rec->endDate().isValid() ) { // 15 + 16 | 821 | if ( rec->endDate().isValid() ) { // 15 + 16 |
859 | list.append( "1" ); | 822 | list.append( "1" ); |
860 | list.append( dtToString( rec->endDate()) ); | 823 | list.append( dtToString( rec->endDate()) ); |
861 | } else { | 824 | } else { |
862 | list.append( "0" ); | 825 | list.append( "0" ); |
863 | list.append( "20991231T000000" ); | 826 | list.append( "20991231T000000" ); |
864 | } | 827 | } |
865 | 828 | ||
866 | } | 829 | } |
867 | if ( event->doesFloat () ) { | 830 | if ( event->doesFloat () ) { |
868 | list.append( dtToString( event->dtStart(), false ).left( 8 )); | 831 | list.append( dtToString( event->dtStart(), false ).left( 8 )); |
869 | list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6 | 832 | list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6 |
870 | 833 | ||
871 | } | 834 | } |
872 | else { | 835 | else { |
873 | list.append( QString() ); | 836 | list.append( QString() ); |
874 | list.append( QString() ); | 837 | list.append( QString() ); |
875 | 838 | ||
876 | } | 839 | } |
877 | if (event->dtStart().date() == event->dtEnd().date() ) | 840 | if (event->dtStart().date() == event->dtEnd().date() ) |
878 | list.append( "0" ); | 841 | list.append( "0" ); |
879 | else | 842 | else |
880 | list.append( "1" ); | 843 | list.append( "1" ); |
881 | 844 | ||
882 | 845 | ||
883 | for(QStringList::Iterator it=list.begin(); | 846 | for(QStringList::Iterator it=list.begin(); |
884 | it!=list.end(); ++it){ | 847 | it!=list.end(); ++it){ |
885 | QString& s = (*it); | 848 | QString& s = (*it); |
886 | s.replace(QRegExp("\""), "\"\""); | 849 | s.replace(QRegExp("\""), "\"\""); |
887 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ | 850 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ |
888 | s.prepend('\"'); | 851 | s.prepend('\"'); |
889 | s.append('\"'); | 852 | s.append('\"'); |
890 | } else if(s.isEmpty() && !s.isNull()){ | 853 | } else if(s.isEmpty() && !s.isNull()){ |
891 | s = "\"\""; | 854 | s = "\"\""; |
892 | } | 855 | } |
893 | } | 856 | } |
894 | return list.join(","); | 857 | return list.join(","); |
895 | 858 | ||
896 | 859 | ||
897 | } | 860 | } |
898 | QString SharpFormat::getTodoString( Todo* todo ) | 861 | QString SharpFormat::getTodoString( Todo* todo ) |
899 | { | 862 | { |
900 | QStringList list; | 863 | QStringList list; |
901 | list.append( todo->getID("Sharp_DTM") ); | 864 | list.append( todo->getID("Sharp_DTM") ); |
902 | list.append( todo->categories().join(",") ); | 865 | list.append( todo->categories().join(",") ); |
903 | 866 | ||
904 | if ( todo->hasStartDate() ) { | 867 | if ( todo->hasStartDate() ) { |
905 | list.append( dtToString( todo->dtStart()) ); | 868 | list.append( dtToString( todo->dtStart()) ); |
906 | } else | 869 | } else |
907 | list.append( QString() ); | 870 | list.append( QString() ); |
908 | 871 | ||
909 | if ( todo->hasDueDate() ) { | 872 | if ( todo->hasDueDate() ) { |
910 | QTime tim; | 873 | QTime tim; |
911 | if ( todo->doesFloat()) { | 874 | if ( todo->doesFloat()) { |
912 | list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; | 875 | list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; |
913 | } else { | 876 | } else { |
914 | list.append( dtToString(todo->dtDue() ) ); | 877 | list.append( dtToString(todo->dtDue() ) ); |
915 | } | 878 | } |
916 | } else | 879 | } else |
917 | list.append( QString() ); | 880 | list.append( QString() ); |
918 | 881 | ||
919 | if ( todo->isCompleted() ) { | 882 | if ( todo->isCompleted() ) { |
920 | list.append( dtToString( todo->completed()) ); | 883 | list.append( dtToString( todo->completed()) ); |
921 | list.append( "0" ); // yes 0 == completed | 884 | list.append( "0" ); // yes 0 == completed |
922 | } else { | 885 | } else { |
923 | list.append( dtToString( todo->completed()) ); | 886 | list.append( dtToString( todo->completed()) ); |
924 | list.append( "1" ); | 887 | list.append( "1" ); |
925 | } | 888 | } |
926 | list.append( QString::number( todo->priority() )); | 889 | list.append( QString::number( todo->priority() )); |
927 | if( ! todo->summary().isEmpty() ) | 890 | if( ! todo->summary().isEmpty() ) |
928 | list.append( todo->summary() ); | 891 | list.append( todo->summary() ); |
929 | else | 892 | else |
930 | list.append( "" ); | 893 | list.append( "" ); |
931 | if (! todo->description().isEmpty() ) | 894 | if (! todo->description().isEmpty() ) |
932 | list.append( todo->description() ); | 895 | list.append( todo->description() ); |
933 | else | 896 | else |
934 | list.append( "" ); | 897 | list.append( "" ); |
935 | for(QStringList::Iterator it=list.begin(); | 898 | for(QStringList::Iterator it=list.begin(); |
936 | it!=list.end(); ++it){ | 899 | it!=list.end(); ++it){ |
937 | QString& s = (*it); | 900 | QString& s = (*it); |
938 | s.replace(QRegExp("\""), "\"\""); | 901 | s.replace(QRegExp("\""), "\"\""); |
939 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ | 902 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ |
940 | s.prepend('\"'); | 903 | s.prepend('\"'); |
941 | s.append('\"'); | 904 | s.append('\"'); |
942 | } else if(s.isEmpty() && !s.isNull()){ | 905 | } else if(s.isEmpty() && !s.isNull()){ |
943 | s = "\"\""; | 906 | s = "\"\""; |
944 | } | 907 | } |
945 | } | 908 | } |
946 | return list.join(","); | 909 | return list.join(","); |
947 | } | 910 | } |
948 | QString SharpFormat::getPart( const QString & text, bool &ok, int &start ) | 911 | QString SharpFormat::getPart( const QString & text, bool &ok, int &start ) |
949 | { | 912 | { |
950 | //qDebug("start %d ", start); | 913 | //qDebug("start %d ", start); |
951 | 914 | ||
952 | QString retval =""; | 915 | QString retval =""; |
953 | if ( text.at(start) == '"' ) { | 916 | if ( text.at(start) == '"' ) { |
954 | if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) { | 917 | if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) { |
955 | start = start +2; | 918 | start = start +2; |
956 | if ( text.mid( start,1) == "," ) { | 919 | if ( text.mid( start,1) == "," ) { |
957 | start += 1; | 920 | start += 1; |
958 | } | 921 | } |
959 | retval = ""; | 922 | retval = ""; |
960 | if ( text.mid( start,1) == "\n" ) { | 923 | if ( text.mid( start,1) == "\n" ) { |
961 | start += 1; | 924 | start += 1; |
962 | ok = false; | 925 | ok = false; |
963 | } | 926 | } |
964 | return retval; | 927 | return retval; |
965 | } | 928 | } |
966 | int hk = start+1; | 929 | int hk = start+1; |
967 | hk = text.find ('"',hk); | 930 | hk = text.find ('"',hk); |
968 | while ( text.at(hk+1) == '"' ) | 931 | while ( text.at(hk+1) == '"' ) |
969 | hk = text.find ('"',hk+2); | 932 | hk = text.find ('"',hk+2); |
970 | retval = text.mid( start+1, hk-start-1); | 933 | retval = text.mid( start+1, hk-start-1); |
971 | start = hk+1; | 934 | start = hk+1; |
972 | retval.replace( QRegExp("\"\""), "\""); | 935 | retval.replace( QRegExp("\"\""), "\""); |
973 | if ( text.mid( start,1) == "," ) { | 936 | if ( text.mid( start,1) == "," ) { |
974 | start += 1; | 937 | start += 1; |
975 | } | 938 | } |
976 | if ( text.mid( start,1) == "\n" ) { | 939 | if ( text.mid( start,1) == "\n" ) { |
977 | start += 1; | 940 | start += 1; |
978 | ok = false; | 941 | ok = false; |
979 | } | 942 | } |
980 | //qDebug("retval***%s*** ",retval.latin1() ); | 943 | //qDebug("retval***%s*** ",retval.latin1() ); |
981 | return retval; | 944 | return retval; |
982 | 945 | ||
983 | } else { | 946 | } else { |
984 | int nl = text.find ("\n",start); | 947 | int nl = text.find ("\n",start); |
985 | int kom = text.find (',',start); | 948 | int kom = text.find (',',start); |
986 | if ( kom < nl ) { | 949 | if ( kom < nl ) { |
987 | // qDebug("kom < nl %d ", kom); | 950 | // qDebug("kom < nl %d ", kom); |
988 | retval = text.mid(start, kom-start); | 951 | retval = text.mid(start, kom-start); |
989 | start = kom+1; | 952 | start = kom+1; |
990 | return retval; | 953 | return retval; |
991 | } else { | 954 | } else { |
992 | if ( nl == kom ) { | 955 | if ( nl == kom ) { |
993 | // qDebug(" nl == kom "); | 956 | // qDebug(" nl == kom "); |
994 | start = 0; | 957 | start = 0; |
995 | ok = false; | 958 | ok = false; |
996 | return "0"; | 959 | return "0"; |
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; |
1046 | } | 1009 | } |
diff --git a/libkcal/sharpformat.h b/libkcal/sharpformat.h index 0b13862..a71177d 100644 --- a/libkcal/sharpformat.h +++ b/libkcal/sharpformat.h | |||
@@ -1,61 +1,59 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
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 | |||
@@ -1,415 +1,415 @@ | |||
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 | ||
11 | QString KConfig::mGroup = ""; | 11 | QString KConfig::mGroup = ""; |
12 | //QString KConfig::mGroup = "General"; | 12 | //QString KConfig::mGroup = "General"; |
13 | 13 | ||
14 | KConfig::KConfig( const QString &fileName ) | 14 | KConfig::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 | ||
24 | KConfig::~KConfig() | 24 | KConfig::~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 |
29 | void KConfig::setTempGroup( const QString &group ) | 29 | void 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 | ||
37 | QString KConfig::tempGroup() const { | 37 | QString KConfig::tempGroup() const { |
38 | return mTempGroup; | 38 | return mTempGroup; |
39 | } | 39 | } |
40 | 40 | ||
41 | void KConfig::setGroup( const QString &group ) | 41 | void 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 |
51 | QString KConfig::group() const { | 51 | QString KConfig::group() const { |
52 | return mGroup; | 52 | return mGroup; |
53 | } | 53 | } |
54 | 54 | ||
55 | //US added method | 55 | //US added method |
56 | QValueList<int> KConfig::readIntListEntry( const QString & key) | 56 | QValueList<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 | ||
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(); |
163 | } | 163 | } |
164 | QColor c ( l[0].toInt(), l[1].toInt(), l[2].toInt() ); | 164 | QColor c ( l[0].toInt(), l[1].toInt(), l[2].toInt() ); |
165 | return c; | 165 | return c; |
166 | } | 166 | } |
167 | 167 | ||
168 | QFont KConfig::readFontEntry( const QString & e, QFont *def ) | 168 | QFont KConfig::readFontEntry( const QString & e, QFont *def ) |
169 | { | 169 | { |
170 | QStringList font = readListEntry( e ); | 170 | QStringList font = readListEntry( e ); |
171 | if ( font.isEmpty() ) | 171 | if ( font.isEmpty() ) |
172 | return *def; | 172 | return *def; |
173 | QFont f; | 173 | QFont f; |
174 | f.setFamily( font[0]); | 174 | f.setFamily( font[0]); |
175 | f.setBold ( font[1] == "bold"); | 175 | f.setBold ( font[1] == "bold"); |
176 | f.setPointSize ( font[2].toInt()); | 176 | f.setPointSize ( font[2].toInt()); |
177 | f.setItalic( font[3] == "italic" ); | 177 | f.setItalic( font[3] == "italic" ); |
178 | return f; | 178 | return f; |
179 | } | 179 | } |
180 | 180 | ||
181 | QDateTime KConfig::readDateTimeEntry( const QString &key, const QDateTime *def ) | 181 | QDateTime KConfig::readDateTimeEntry( const QString &key, const QDateTime *def ) |
182 | { | 182 | { |
183 | QMap<QString,QDateTime>::ConstIterator it = mDateTimeMap.find( mGroup + key ); | 183 | QMap<QString,QDateTime>::ConstIterator it = mDateTimeMap.find( mGroup + key ); |
184 | 184 | ||
185 | if ( it == mDateTimeMap.end() ) { | 185 | if ( it == mDateTimeMap.end() ) { |
186 | if ( def ) return *def; | 186 | if ( def ) return *def; |
187 | else return QDateTime(); | 187 | else return QDateTime(); |
188 | } | 188 | } |
189 | 189 | ||
190 | return *it; | 190 | return *it; |
191 | } | 191 | } |
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(); |
248 | writeEntry( e, intlist ); | 248 | writeEntry( e, intlist ); |
249 | } | 249 | } |
250 | 250 | ||
251 | void KConfig::writeEntry( const QString & e , const QFont & f ) | 251 | void KConfig::writeEntry( const QString & e , const QFont & f ) |
252 | { | 252 | { |
253 | QStringList font; | 253 | QStringList font; |
254 | font.append( f.family()); | 254 | font.append( f.family()); |
255 | font.append( (!f.bold ()?"nonbold":"bold") ); | 255 | font.append( (!f.bold ()?"nonbold":"bold") ); |
256 | font.append( QString::number ( f.pointSize () ) ); | 256 | font.append( QString::number ( f.pointSize () ) ); |
257 | font.append( !f.italic ()?"nonitalic":"italic" ); | 257 | font.append( !f.italic ()?"nonitalic":"italic" ); |
258 | writeEntry( e, font ); | 258 | writeEntry( e, font ); |
259 | } | 259 | } |
260 | 260 | ||
261 | void KConfig::writeEntry( const QString &key, const QDateTime &dt ) | 261 | void KConfig::writeEntry( const QString &key, const QDateTime &dt ) |
262 | { | 262 | { |
263 | mDateTimeMap.insert( mGroup + key, dt ); | 263 | mDateTimeMap.insert( mGroup + key, dt ); |
264 | } | 264 | } |
265 | 265 | ||
266 | void KConfig::load() | 266 | void KConfig::load() |
267 | { | 267 | { |
268 | 268 | ||
269 | 269 | ||
270 | QFile f( mFileName ); | 270 | QFile f( mFileName ); |
271 | if ( !f.open( IO_ReadOnly ) ) { | 271 | if ( !f.open( IO_ReadOnly ) ) { |
272 | //qDebug("KConfig: could not open file %s ",mFileName.latin1() ); | 272 | //qDebug("KConfig: could not open file %s ",mFileName.latin1() ); |
273 | return; | 273 | return; |
274 | } | 274 | } |
275 | 275 | ||
276 | mBoolMap.clear(); | 276 | mBoolMap.clear(); |
277 | mStringMap.clear(); | 277 | mStringMap.clear(); |
278 | 278 | ||
279 | QTextStream t( &f ); | 279 | QTextStream t( &f ); |
280 | 280 | ||
281 | QString line = t.readLine(); | 281 | QString line = t.readLine(); |
282 | 282 | ||
283 | while ( !line.isNull() ) { | 283 | while ( !line.isNull() ) { |
284 | QStringList tokens = QStringList::split( ",", line ); | 284 | QStringList tokens = QStringList::split( ",", line ); |
285 | if ( tokens[0] == "bool" ) { | 285 | if ( tokens[0] == "bool" ) { |
286 | bool value = false; | 286 | bool value = false; |
287 | if ( tokens[2] == "1" ) value = true; | 287 | if ( tokens[2] == "1" ) value = true; |
288 | mBoolMap.insert( tokens[1], value ); | 288 | mBoolMap.insert( tokens[1], value ); |
289 | } else if ( tokens[0] == "QString" ) { | 289 | } else if ( tokens[0] == "QString" ) { |
290 | QString value = tokens[2]; | 290 | QString value = tokens[2]; |
291 | mStringMap.insert( tokens[1], value ); | 291 | mStringMap.insert( tokens[1], value ); |
292 | } else if ( tokens[0] == "QDateTime" ) { | 292 | } else if ( tokens[0] == "QDateTime" ) { |
293 | #if 0 | 293 | #if 0 |
294 | int year = tokens[2].toInt(); | 294 | int year = tokens[2].toInt(); |
295 | QDateTime dt( QDate( year, | 295 | QDateTime dt( QDate( year, |
296 | tokens[3].toInt(), | 296 | tokens[3].toInt(), |
297 | tokens[4].toInt() ), | 297 | tokens[4].toInt() ), |
298 | QTime( tokens[5].toInt(), tokens[6].toInt(), | 298 | QTime( tokens[5].toInt(), tokens[6].toInt(), |
299 | tokens[7].toInt() ) ); | 299 | tokens[7].toInt() ) ); |
300 | mDateTimeMap.insert( tokens[1], dt ); | 300 | mDateTimeMap.insert( tokens[1], dt ); |
301 | #endif | 301 | #endif |
302 | } | 302 | } |
303 | 303 | ||
304 | line = t.readLine(); | 304 | line = t.readLine(); |
305 | } | 305 | } |
306 | } | 306 | } |
307 | 307 | ||
308 | void KConfig::sync() | 308 | void KConfig::sync() |
309 | { | 309 | { |
310 | 310 | ||
311 | if ( !mDirty ) return; | 311 | if ( !mDirty ) return; |
312 | //qDebug("KConfig::sync() %s ",mFileName.latin1() ); | 312 | //qDebug("KConfig::sync() %s ",mFileName.latin1() ); |
313 | //kdDebug() << "KConfig::sync(): " << mFileName << endl; | 313 | //kdDebug() << "KConfig::sync(): " << mFileName << endl; |
314 | 314 | ||
315 | //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 |
316 | // Create the containing dir if needed | 316 | // Create the containing dir if needed |
317 | KURL path; | 317 | KURL path; |
318 | path.setPath(mFileName); | 318 | path.setPath(mFileName); |
319 | QString dir=path.directory(); | 319 | QString dir=path.directory(); |
320 | KStandardDirs::makeDir(dir); | 320 | KStandardDirs::makeDir(dir); |
321 | 321 | ||
322 | QFile f( mFileName ); | 322 | QFile f( mFileName ); |
323 | if ( !f.open( IO_WriteOnly ) ) { | 323 | if ( !f.open( IO_WriteOnly ) ) { |
324 | 324 | ||
325 | qDebug("KConfig::sync() Can't open file %s ",mFileName.latin1() ); | 325 | qDebug("KConfig::sync() Can't open file %s ",mFileName.latin1() ); |
326 | 326 | ||
327 | return; | 327 | return; |
328 | } | 328 | } |
329 | 329 | ||
330 | QTextStream t( &f ); | 330 | QTextStream t( &f ); |
331 | 331 | ||
332 | QMap<QString,bool>::ConstIterator itBool; | 332 | QMap<QString,bool>::ConstIterator itBool; |
333 | for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) { | 333 | for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) { |
334 | t << "bool," << itBool.key() << "," << ( *itBool ? "1" : "0" ) << endl; | 334 | t << "bool," << itBool.key() << "," << ( *itBool ? "1" : "0" ) << endl; |
335 | } | 335 | } |
336 | 336 | ||
337 | QMap<QString,QString>::ConstIterator itString; | 337 | QMap<QString,QString>::ConstIterator itString; |
338 | for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) { | 338 | for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) { |
339 | t << "QString," << itString.key() << "," << (*itString ) << endl; | 339 | t << "QString," << itString.key() << "," << (*itString ) << endl; |
340 | } | 340 | } |
341 | 341 | ||
342 | QMap<QString,QDateTime>::ConstIterator itDateTime; | 342 | QMap<QString,QDateTime>::ConstIterator itDateTime; |
343 | for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) { | 343 | for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) { |
344 | QDateTime dt = *itDateTime; | 344 | QDateTime dt = *itDateTime; |
345 | t << "QDateTime," << itDateTime.key() << "," | 345 | t << "QDateTime," << itDateTime.key() << "," |
346 | << dt.date().year() << "," | 346 | << dt.date().year() << "," |
347 | << dt.date().month() << "," | 347 | << dt.date().month() << "," |
348 | << dt.date().day() << "," | 348 | << dt.date().day() << "," |
349 | << dt.time().hour() << "," | 349 | << dt.time().hour() << "," |
350 | << dt.time().minute() << "," | 350 | << dt.time().minute() << "," |
351 | << dt.time().second() << endl; | 351 | << dt.time().second() << endl; |
352 | } | 352 | } |
353 | 353 | ||
354 | f.close(); | 354 | f.close(); |
355 | 355 | ||
356 | mDirty = false; | 356 | mDirty = false; |
357 | } | 357 | } |
358 | 358 | ||
359 | 359 | ||
360 | //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. |
361 | /** | 361 | /** |
362 | * Deletes a configuration entry group | 362 | * Deletes a configuration entry group |
363 | * | 363 | * |
364 | * 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 |
365 | * deleted and false is returned. | 365 | * deleted and false is returned. |
366 | * 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 |
367 | * current group is undefined and should be set with setGroup() | 367 | * current group is undefined and should be set with setGroup() |
368 | * before the next operation on the configuration object. | 368 | * before the next operation on the configuration object. |
369 | * | 369 | * |
370 | * @param group The name of the group | 370 | * @param group The name of the group |
371 | * returns true if we deleted at least one entry. | 371 | * returns true if we deleted at least one entry. |
372 | */ | 372 | */ |
373 | bool KConfig::deleteGroup( const QString& group) | 373 | bool KConfig::deleteGroup( const QString& group) |
374 | { | 374 | { |
375 | bool dirty = false; | 375 | bool dirty = false; |
376 | int pos; | 376 | int pos; |
377 | 377 | ||
378 | QMap<QString,bool>::Iterator itBool = mBoolMap.begin(); | 378 | QMap<QString,bool>::Iterator itBool = mBoolMap.begin(); |
379 | QMap<QString,bool>::Iterator delBool; | 379 | QMap<QString,bool>::Iterator delBool; |
380 | 380 | ||
381 | while ( itBool != mBoolMap.end() ) { | 381 | while ( itBool != mBoolMap.end() ) { |
382 | pos = itBool.key().find( group ); | 382 | pos = itBool.key().find( group ); |
383 | if (pos == 0) { | 383 | if (pos == 0) { |
384 | delBool = itBool; | 384 | delBool = itBool; |
385 | ++itBool; | 385 | ++itBool; |
386 | mBoolMap.remove(delBool); | 386 | mBoolMap.remove(delBool); |
387 | dirty = true; | 387 | dirty = true; |
388 | } else | 388 | } else |
389 | ++itBool; | 389 | ++itBool; |
390 | 390 | ||
391 | } | 391 | } |
392 | /* | 392 | /* |
393 | for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) | 393 | for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) |
394 | { | 394 | { |
395 | pos = itBool.key().find( group ); | 395 | pos = itBool.key().find( group ); |
396 | if (pos == 0) { | 396 | if (pos == 0) { |
397 | mBoolMap.remove(itBool); | 397 | mBoolMap.remove(itBool); |
398 | dirty = true; | 398 | dirty = true; |
399 | } | 399 | } |
400 | } | 400 | } |
401 | */ | 401 | */ |
402 | QMap<QString,QString>::Iterator itString = mStringMap.begin(); | 402 | QMap<QString,QString>::Iterator itString = mStringMap.begin(); |
403 | QMap<QString,QString>::Iterator delString ; | 403 | QMap<QString,QString>::Iterator delString ; |
404 | while( itString != mStringMap.end() ) { | 404 | while( itString != mStringMap.end() ) { |
405 | pos = itString.key().find( group ); | 405 | pos = itString.key().find( group ); |
406 | if (pos == 0) { | 406 | if (pos == 0) { |
407 | delString = itString; | 407 | delString = itString; |
408 | ++itString; | 408 | ++itString; |
409 | mStringMap.remove(delString); | 409 | mStringMap.remove(delString); |
410 | //qDebug("delte++++++++++++++++++ "); | 410 | //qDebug("delte++++++++++++++++++ "); |
411 | dirty = true; | 411 | dirty = true; |
412 | } else | 412 | } else |
413 | ++itString; | 413 | ++itString; |
414 | 414 | ||
415 | } | 415 | } |