-rw-r--r-- | noncore/applets/notesapplet/notes.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp index f2dbabf..92fdb0a 100644 --- a/noncore/applets/notesapplet/notes.cpp +++ b/noncore/applets/notesapplet/notes.cpp | |||
@@ -265,109 +265,109 @@ void NotesControl::focusOutEvent ( QFocusEvent * e) { | |||
265 | QWidget::focusOutEvent(e); | 265 | QWidget::focusOutEvent(e); |
266 | } | 266 | } |
267 | 267 | ||
268 | void NotesControl::save() { | 268 | void NotesControl::save() { |
269 | Config cfg("Notes"); | 269 | Config cfg("Notes"); |
270 | cfg.setGroup("Docs"); | 270 | cfg.setGroup("Docs"); |
271 | if( edited) { | 271 | if( edited) { |
272 | QString rt = view->text(); | 272 | QString rt = view->text(); |
273 | if(!rt.isEmpty()) { | 273 | if(!rt.isEmpty()) { |
274 | QString pt = rt.simplifyWhiteSpace(); | 274 | QString pt = rt.simplifyWhiteSpace(); |
275 | int i = pt.find( ' ' ); | 275 | int i = pt.find( ' ' ); |
276 | QString docname = pt; | 276 | QString docname = pt; |
277 | if ( i > 0 ) | 277 | if ( i > 0 ) |
278 | docname = pt.left( i ); | 278 | docname = pt.left( i ); |
279 | // remove "." at the beginning | 279 | // remove "." at the beginning |
280 | while( docname.startsWith( "." ) ) | 280 | while( docname.startsWith( "." ) ) |
281 | docname = docname.mid( 1 ); | 281 | docname = docname.mid( 1 ); |
282 | docname.replace( QRegExp("/"), "_" ); | 282 | docname.replace( QRegExp("/"), "_" ); |
283 | // cut the length. filenames longer than that don't make sense | 283 | // cut the length. filenames longer than that don't make sense |
284 | // and something goes wrong when they get too long. | 284 | // and something goes wrong when they get too long. |
285 | if ( docname.length() > 40 ) | 285 | if ( docname.length() > 40 ) |
286 | docname = docname.left(40); | 286 | docname = docname.left(40); |
287 | if ( docname.isEmpty() ) | 287 | if ( docname.isEmpty() ) |
288 | docname = "Empty Text"; | 288 | docname = "Empty Text"; |
289 | qDebug(docname); | 289 | qDebug(docname); |
290 | 290 | ||
291 | if( oldDocName != docname) { | 291 | if( oldDocName != docname) { |
292 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 292 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
293 | QString entryName; | 293 | QString entryName; |
294 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 294 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
295 | cfg.writeEntry( entryName,docname ); | 295 | cfg.writeEntry( entryName,docname ); |
296 | cfg.writeEntry("NumberOfFiles", noOfFiles+1 ); | 296 | cfg.writeEntry("NumberOfFiles", noOfFiles+1 ); |
297 | cfg.write(); | 297 | cfg.write(); |
298 | } | 298 | } |
299 | else | 299 | else |
300 | qDebug("oldname equals docname"); | 300 | qDebug("oldname equals docname"); |
301 | doc = new DocLnk(docname); | 301 | doc = new DocLnk(docname); |
302 | 302 | ||
303 | doc->setType("text/plain"); | 303 | doc->setType("text/plain"); |
304 | doc->setFile(docname); | 304 | doc->setFile(docname); |
305 | doc->setName(docname); | 305 | doc->setName(docname); |
306 | 306 | ||
307 | FileManager fm; | 307 | FileManager fm; |
308 | if ( !fm.saveFile( *doc, rt ) ) { | 308 | if ( !fm.saveFile( *doc, rt ) ) { |
309 | } | 309 | } |
310 | 310 | ||
311 | oldDocName=docname; | 311 | oldDocName=docname; |
312 | edited=false; | 312 | edited=false; |
313 | qDebug("save"); | 313 | // qDebug("save"); |
314 | if (doPopulate) | 314 | if (doPopulate) |
315 | populateBox(); | 315 | populateBox(); |
316 | } | 316 | } |
317 | cfg.writeEntry( "LastDoc",oldDocName ); | 317 | cfg.writeEntry( "LastDoc",oldDocName ); |
318 | cfg.write(); | 318 | cfg.write(); |
319 | 319 | ||
320 | } | 320 | } |
321 | } | 321 | } |
322 | 322 | ||
323 | void NotesControl::populateBox() { | 323 | void NotesControl::populateBox() { |
324 | box->clear(); | 324 | box->clear(); |
325 | qDebug("populate"); | 325 | // qDebug("populate"); |
326 | Config cfg("Notes"); | 326 | Config cfg("Notes"); |
327 | cfg.setGroup("Docs"); | 327 | cfg.setGroup("Docs"); |
328 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 328 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
329 | QStringList list; | 329 | QStringList list; |
330 | QString entryName; | 330 | QString entryName; |
331 | for ( int i = 0; i < noOfFiles; i++ ) { | 331 | for ( int i = 0; i < noOfFiles; i++ ) { |
332 | entryName.sprintf( "File%i", i + 1 ); | 332 | entryName.sprintf( "File%i", i + 1 ); |
333 | list.append(cfg.readEntry( entryName )); | 333 | list.append(cfg.readEntry( entryName )); |
334 | } | 334 | } |
335 | list.sort(); | 335 | list.sort(); |
336 | box->insertStringList(list,-1); | 336 | box->insertStringList(list,-1); |
337 | doPopulate=false; | 337 | doPopulate=false; |
338 | update(); | 338 | update(); |
339 | } | 339 | } |
340 | 340 | ||
341 | void NotesControl::load() { | 341 | void NotesControl::load() { |
342 | 342 | ||
343 | if(!loaded) { | 343 | if(!loaded) { |
344 | Config cfg("Notes"); | 344 | Config cfg("Notes"); |
345 | cfg.setGroup("Docs"); | 345 | cfg.setGroup("Docs"); |
346 | QString lastDoc=cfg.readEntry( "LastDoc",""); | 346 | QString lastDoc=cfg.readEntry( "LastDoc",""); |
347 | DocLnk nf; | 347 | DocLnk nf; |
348 | nf.setType("text/plain"); | 348 | nf.setType("text/plain"); |
349 | nf.setFile(lastDoc); | 349 | nf.setFile(lastDoc); |
350 | 350 | ||
351 | loadDoc(nf); | 351 | loadDoc(nf); |
352 | loaded=true; | 352 | loaded=true; |
353 | oldDocName=lastDoc; | 353 | oldDocName=lastDoc; |
354 | cfg.writeEntry( "LastDoc",oldDocName ); | 354 | cfg.writeEntry( "LastDoc",oldDocName ); |
355 | cfg.write(); | 355 | cfg.write(); |
356 | } | 356 | } |
357 | } | 357 | } |
358 | 358 | ||
359 | void NotesControl::load(const QString & file) { | 359 | void NotesControl::load(const QString & file) { |
360 | qDebug("loading "+file); | 360 | qDebug("loading "+file); |
361 | if(!loaded) { | 361 | if(!loaded) { |
362 | DocLnk nf; | 362 | DocLnk nf; |
363 | nf.setType("text/plain"); | 363 | nf.setType("text/plain"); |
364 | nf.setFile( file); | 364 | nf.setFile( file); |
365 | 365 | ||
366 | loadDoc(nf); | 366 | loadDoc(nf); |
367 | loaded=true; | 367 | loaded=true; |
368 | } | 368 | } |
369 | // view->setFocus(); | 369 | // view->setFocus(); |
370 | oldDocName=file; | 370 | oldDocName=file; |
371 | Config cfg("Notes"); | 371 | Config cfg("Notes"); |
372 | cfg.setGroup("Docs"); | 372 | cfg.setGroup("Docs"); |
373 | cfg.writeEntry( "LastDoc",oldDocName ); | 373 | cfg.writeEntry( "LastDoc",oldDocName ); |