-rw-r--r-- | library/global.cpp | 63 |
1 files changed, 31 insertions, 32 deletions
diff --git a/library/global.cpp b/library/global.cpp index f7a0767..7bdd0b1 100644 --- a/library/global.cpp +++ b/library/global.cpp | |||
@@ -187,97 +187,96 @@ static QString dictDir() | |||
187 | \section1 Quoting | 187 | \section1 Quoting |
188 | 188 | ||
189 | The shellQuote() function quotes a string suitable for passing to a | 189 | The shellQuote() function quotes a string suitable for passing to a |
190 | shell. The stringQuote() function backslash escapes '\' and '"' | 190 | shell. The stringQuote() function backslash escapes '\' and '"' |
191 | characters. | 191 | characters. |
192 | 192 | ||
193 | \section1 Hardware | 193 | \section1 Hardware |
194 | 194 | ||
195 | The implementation of the writeHWClock() function depends on the AlarmServer | 195 | The implementation of the writeHWClock() function depends on the AlarmServer |
196 | implementation. If the AlarmServer is using atd the clock will be synced to | 196 | implementation. If the AlarmServer is using atd the clock will be synced to |
197 | hardware. If opie-alarm is used the hardware clock will be synced before | 197 | hardware. If opie-alarm is used the hardware clock will be synced before |
198 | suspending the device. opie-alarm is used by iPAQ and Zaurii implementation | 198 | suspending the device. opie-alarm is used by iPAQ and Zaurii implementation |
199 | 199 | ||
200 | \ingroup qtopiaemb | 200 | \ingroup qtopiaemb |
201 | */ | 201 | */ |
202 | 202 | ||
203 | /*! | 203 | /*! |
204 | \internal | 204 | \internal |
205 | */ | 205 | */ |
206 | Global::Global() | 206 | Global::Global() |
207 | { | 207 | { |
208 | } | 208 | } |
209 | 209 | ||
210 | /*! | 210 | /*! |
211 | Returns the unchangeable QDawg that contains general | 211 | Returns the unchangeable QDawg that contains general |
212 | words for the current locale. | 212 | words for the current locale. |
213 | 213 | ||
214 | \sa addedDawg() | 214 | \sa addedDawg() |
215 | */ | 215 | */ |
216 | const QDawg& Global::fixedDawg() | 216 | const QDawg& Global::fixedDawg() |
217 | { | 217 | { |
218 | if ( !fixed_dawg ) { | 218 | if ( !fixed_dawg ) { |
219 | if ( !docDirCreated ) | 219 | if ( !docDirCreated ) |
220 | createDocDir(); | 220 | createDocDir(); |
221 | 221 | ||
222 | fixed_dawg = new QDawg; | 222 | fixed_dawg = new QDawg; |
223 | QString dawgfilename = dictDir() + "/dawg"; | 223 | QString dawgfilename = dictDir() + "/dawg"; |
224 | QString words_lang; | 224 | QString words_lang; |
225 | QStringList langs = Global::languageList(); | 225 | QStringList langs = Global::languageList(); |
226 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { | 226 | for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { |
227 | QString lang = *it; | 227 | QString lang = *it; |
228 | words_lang = dictDir() + "/words." + lang; | 228 | words_lang = dictDir() + "/words." + lang; |
229 | QString dawgfilename_lang = dawgfilename + "." + lang; | 229 | QString dawgfilename_lang = dawgfilename + "." + lang; |
230 | if ( QFile::exists(dawgfilename_lang) || | 230 | if ( QFile::exists(dawgfilename_lang) || |
231 | QFile::exists(words_lang) ) { | 231 | QFile::exists(words_lang) ) { |
232 | dawgfilename = dawgfilename_lang; | 232 | dawgfilename = dawgfilename_lang; |
233 | break; | 233 | break; |
234 | } | 234 | } |
235 | } | ||
236 | QFile dawgfile(dawgfilename); | ||
237 | |||
238 | if ( !dawgfile.exists() ) { | ||
239 | QString fn = dictDir() + "/words"; | ||
240 | if ( QFile::exists(words_lang) ) | ||
241 | fn = words_lang; | ||
242 | QFile in(fn); | ||
243 | if ( in.open(IO_ReadOnly) ) { | ||
244 | fixed_dawg->createFromWords(&in); | ||
245 | dawgfile.open(IO_WriteOnly); | ||
246 | fixed_dawg->write(&dawgfile); | ||
247 | dawgfile.close(); | ||
248 | } | 235 | } |
249 | } else { | 236 | QFile dawgfile(dawgfilename); |
250 | fixed_dawg->readFile(dawgfilename); | 237 | |
251 | } | 238 | if ( !dawgfile.exists() ) { |
239 | QString fn = dictDir() + "/words"; | ||
240 | if ( QFile::exists(words_lang) ) | ||
241 | fn = words_lang; | ||
242 | QFile in(fn); | ||
243 | if ( in.open(IO_ReadOnly) ) { | ||
244 | fixed_dawg->createFromWords(&in); | ||
245 | if (dawgfile.open(IO_WriteOnly)) | ||
246 | fixed_dawg->write(&dawgfile); | ||
247 | dawgfile.close(); | ||
248 | } | ||
249 | } else | ||
250 | fixed_dawg->readFile(dawgfilename); | ||
252 | } | 251 | } |
253 | 252 | ||
254 | return *fixed_dawg; | 253 | return *fixed_dawg; |
255 | } | 254 | } |
256 | 255 | ||
257 | /*! | 256 | /*! |
258 | Returns the changeable QDawg that contains general | 257 | Returns the changeable QDawg that contains general |
259 | words for the current locale. | 258 | words for the current locale. |
260 | 259 | ||
261 | \sa fixedDawg() | 260 | \sa fixedDawg() |
262 | */ | 261 | */ |
263 | const QDawg& Global::addedDawg() | 262 | const QDawg& Global::addedDawg() |
264 | { | 263 | { |
265 | return dawg("local"); | 264 | return dawg("local"); |
266 | } | 265 | } |
267 | 266 | ||
268 | /*! | 267 | /*! |
269 | Returns the QDawg with the given \a name. | 268 | Returns the QDawg with the given \a name. |
270 | This is an application-specific word list. | 269 | This is an application-specific word list. |
271 | 270 | ||
272 | \a name should not contain "/". | 271 | \a name should not contain "/". |
273 | */ | 272 | */ |
274 | const QDawg& Global::dawg(const QString& name) | 273 | const QDawg& Global::dawg(const QString& name) |
275 | { | 274 | { |
276 | createDocDir(); | 275 | createDocDir(); |
277 | if ( !named_dawg ) | 276 | if ( !named_dawg ) |
278 | named_dawg = new QDict<QDawg>; | 277 | named_dawg = new QDict<QDawg>; |
279 | QDawg* r = named_dawg->find(name); | 278 | QDawg* r = named_dawg->find(name); |
280 | if ( !r ) { | 279 | if ( !r ) { |
281 | r = new QDawg; | 280 | r = new QDawg; |
282 | named_dawg->insert(name,r); | 281 | named_dawg->insert(name,r); |
283 | QString dawgfilename = applicationFileName("Dictionary", name ) + ".dawg"; | 282 | QString dawgfilename = applicationFileName("Dictionary", name ) + ".dawg"; |