-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 2b25476..4e98b31 100644 --- a/noncore/applets/notesapplet/notes.cpp +++ b/noncore/applets/notesapplet/notes.cpp | |||
@@ -302,154 +302,154 @@ void NotesControl::save() { | |||
302 | // and something goes wrong when they get too long. | 302 | // and something goes wrong when they get too long. |
303 | if ( docname.length() > 40 ) | 303 | if ( docname.length() > 40 ) |
304 | docname = docname.left(40); | 304 | docname = docname.left(40); |
305 | if ( docname.isEmpty() ) | 305 | if ( docname.isEmpty() ) |
306 | docname = "Empty Text"; | 306 | docname = "Empty Text"; |
307 | // qDebug(docname); | 307 | // qDebug(docname); |
308 | 308 | ||
309 | if( oldDocName != docname) { | 309 | if( oldDocName != docname) { |
310 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 310 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
311 | QString entryName; | 311 | QString entryName; |
312 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 312 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
313 | cfg.writeEntry( entryName,docname ); | 313 | cfg.writeEntry( entryName,docname ); |
314 | cfg.writeEntry("NumberOfFiles", noOfFiles+1 ); | 314 | cfg.writeEntry("NumberOfFiles", noOfFiles+1 ); |
315 | cfg.write(); | 315 | cfg.write(); |
316 | } | 316 | } |
317 | // else | 317 | // else |
318 | // qDebug("oldname equals docname"); | 318 | // qDebug("oldname equals docname"); |
319 | 319 | ||
320 | doc = new DocLnk(docname); | 320 | doc = new DocLnk(docname); |
321 | if(QFile(doc->linkFile()).exists()) | 321 | if(QFile(doc->linkFile()).exists()) |
322 | qDebug("puppie"); | 322 | qDebug("puppie"); |
323 | doc->setType("text/plain"); | 323 | doc->setType("text/plain"); |
324 | doc->setName(docname); | 324 | doc->setName(docname); |
325 | QString temp = docname.replace( QRegExp(" "), "_" ); | 325 | QString temp = docname.replace( QRegExp(" "), "_" ); |
326 | doc->setFile( QDir::homeDirPath()+"/notes/"+temp); | 326 | doc->setFile( QDir::homeDirPath()+"/notes/"+temp); |
327 | FileManager fm; | 327 | FileManager fm; |
328 | if ( !fm.saveFile( *doc, rt ) ) { | 328 | if ( !fm.saveFile( *doc, rt ) ) { |
329 | } | 329 | } |
330 | 330 | ||
331 | oldDocName=docname; | 331 | oldDocName=docname; |
332 | edited=false; | 332 | edited=false; |
333 | // qDebug("save"); | 333 | // qDebug("save"); |
334 | if (doPopulate) | 334 | if (doPopulate) |
335 | populateBox(); | 335 | populateBox(); |
336 | } | 336 | } |
337 | cfg.writeEntry( "LastDoc",oldDocName ); | 337 | cfg.writeEntry( "LastDoc",oldDocName ); |
338 | cfg.write(); | 338 | cfg.write(); |
339 | 339 | ||
340 | } | 340 | } |
341 | } | 341 | } |
342 | 342 | ||
343 | void NotesControl::populateBox() { | 343 | void NotesControl::populateBox() { |
344 | box->clear(); | 344 | box->clear(); |
345 | // qDebug("populate"); | 345 | // qDebug("populate"); |
346 | Config cfg("Notes"); | 346 | Config cfg("Notes"); |
347 | cfg.setGroup("Docs"); | 347 | cfg.setGroup("Docs"); |
348 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 348 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
349 | QStringList list; | 349 | QStringList list; |
350 | QString entryName; | 350 | QString entryName; |
351 | for ( int i = 0; i < noOfFiles; i++ ) { | 351 | for ( int i = 0; i < noOfFiles; i++ ) { |
352 | entryName.sprintf( "File%i", i + 1 ); | 352 | entryName.sprintf( "File%i", i + 1 ); |
353 | list.append(cfg.readEntry( entryName )); | 353 | list.append(cfg.readEntry( entryName )); |
354 | } | 354 | } |
355 | list.sort(); | 355 | list.sort(); |
356 | box->insertStringList(list,-1); | 356 | box->insertStringList(list,-1); |
357 | doPopulate=false; | 357 | doPopulate=false; |
358 | update(); | 358 | update(); |
359 | } | 359 | } |
360 | 360 | ||
361 | void NotesControl::load() { | 361 | void NotesControl::load() { |
362 | 362 | ||
363 | if(!loaded) { | 363 | if(!loaded) { |
364 | Config cfg("Notes"); | 364 | Config cfg("Notes"); |
365 | cfg.setGroup("Docs"); | 365 | cfg.setGroup("Docs"); |
366 | QString lastDoc=cfg.readEntry( "LastDoc",""); | 366 | QString lastDoc=cfg.readEntry( "LastDoc","notes"); |
367 | DocLnk nf; | 367 | DocLnk nf; |
368 | nf.setType("text/plain"); | 368 | nf.setType("text/plain"); |
369 | nf.setFile(lastDoc); | 369 | nf.setFile(lastDoc); |
370 | 370 | ||
371 | loadDoc(nf); | 371 | loadDoc(nf); |
372 | loaded=true; | 372 | loaded=true; |
373 | oldDocName=lastDoc; | 373 | oldDocName=lastDoc; |
374 | cfg.writeEntry( "LastDoc",oldDocName ); | 374 | cfg.writeEntry( "LastDoc",oldDocName ); |
375 | cfg.write(); | 375 | cfg.write(); |
376 | } | 376 | } |
377 | } | 377 | } |
378 | 378 | ||
379 | void NotesControl::load(const QString & file) { | 379 | void NotesControl::load(const QString & file) { |
380 | qDebug("loading "+file); | 380 | qDebug("loading "+file); |
381 | QString name = file; | 381 | QString name = file; |
382 | QString temp; | 382 | QString temp; |
383 | if( !QFile( QDir::homeDirPath()+"/"+file).exists() ) | 383 | if( !QFile( QDir::homeDirPath()+"/"+file).exists() ) |
384 | temp = QDir::homeDirPath()+"/notes/"+ name.replace( QRegExp(" "), "_" ); | 384 | temp = QDir::homeDirPath()+"/notes/"+ name.replace( QRegExp(" "), "_" ); |
385 | else | 385 | else |
386 | temp = name; | 386 | temp = name; |
387 | if(!loaded) { | 387 | if(!loaded) { |
388 | DocLnk nf; | 388 | DocLnk nf; |
389 | nf.setType("text/plain"); | 389 | nf.setType("text/plain"); |
390 | nf.setFile( temp); | 390 | nf.setFile( temp); |
391 | 391 | if(!temp.isEmpty()) | |
392 | loadDoc(nf); | 392 | loadDoc(nf); |
393 | loaded=true; | 393 | loaded=true; |
394 | } | 394 | } |
395 | // view->setFocus(); | 395 | // view->setFocus(); |
396 | oldDocName=file; | 396 | oldDocName=file; |
397 | Config cfg("Notes"); | 397 | Config cfg("Notes"); |
398 | cfg.setGroup("Docs"); | 398 | cfg.setGroup("Docs"); |
399 | cfg.writeEntry( "LastDoc",oldDocName ); | 399 | cfg.writeEntry( "LastDoc",oldDocName ); |
400 | cfg.write(); | 400 | cfg.write(); |
401 | } | 401 | } |
402 | 402 | ||
403 | void NotesControl::loadDoc( const DocLnk &f) { | 403 | void NotesControl::loadDoc( const DocLnk &f) { |
404 | FileManager fm; | 404 | FileManager fm; |
405 | QString txt; | 405 | QString txt; |
406 | if ( !fm.loadFile( f, txt ) ) { | 406 | if ( !fm.loadFile( f, txt ) ) { |
407 | qDebug("could not load file "+f.file()); | 407 | qDebug("could not load file "+f.file()); |
408 | return; | 408 | return; |
409 | } | 409 | } |
410 | view->setText(txt); | 410 | view->setText(txt); |
411 | } | 411 | } |
412 | 412 | ||
413 | void NotesControl::slotViewEdited() { | 413 | void NotesControl::slotViewEdited() { |
414 | if(loaded) { | 414 | if(loaded) { |
415 | edited=true; | 415 | edited=true; |
416 | } | 416 | } |
417 | } | 417 | } |
418 | 418 | ||
419 | 419 | ||
420 | void NotesControl::slotShowMax() { | 420 | void NotesControl::slotShowMax() { |
421 | Config cfg("Notes"); | 421 | Config cfg("Notes"); |
422 | cfg.setGroup("Options"); | 422 | cfg.setGroup("Options"); |
423 | showMax=!showMax; | 423 | showMax=!showMax; |
424 | cfg.writeEntry("ShowMax", showMax); | 424 | cfg.writeEntry("ShowMax", showMax); |
425 | cfg.write(); | 425 | cfg.write(); |
426 | hide(); | 426 | hide(); |
427 | } | 427 | } |
428 | 428 | ||
429 | void NotesControl::slotSearch() { | 429 | void NotesControl::slotSearch() { |
430 | int boxCount = box->count(); | 430 | int boxCount = box->count(); |
431 | for(int i=0;i< boxCount;i++) { | 431 | for(int i=0;i< boxCount;i++) { |
432 | 432 | ||
433 | } | 433 | } |
434 | } | 434 | } |
435 | 435 | ||
436 | // void NotesControl::keyReleaseEvent( QKeyEvent *e) { | 436 | // void NotesControl::keyReleaseEvent( QKeyEvent *e) { |
437 | 437 | ||
438 | // switch ( e->state() ) { | 438 | // switch ( e->state() ) { |
439 | // case ControlButton: | 439 | // case ControlButton: |
440 | // if(e->key() == Key_C) { //copy | 440 | // if(e->key() == Key_C) { //copy |
441 | // qDebug("copy"); | 441 | // qDebug("copy"); |
442 | // QClipboard *cb = QApplication::clipboard(); | 442 | // QClipboard *cb = QApplication::clipboard(); |
443 | // QString text; | 443 | // QString text; |
444 | 444 | ||
445 | // // Copy text from the clipboard (paste) | 445 | // // Copy text from the clipboard (paste) |
446 | // text = cb->text(); | 446 | // text = cb->text(); |
447 | // } | 447 | // } |
448 | // if(e->key() == Key_X) { //cut | 448 | // if(e->key() == Key_X) { //cut |
449 | // } | 449 | // } |
450 | // if(e->key() == Key_V) { //paste | 450 | // if(e->key() == Key_V) { //paste |
451 | // QClipboard *cb = QApplication::clipboard(); | 451 | // QClipboard *cb = QApplication::clipboard(); |
452 | // QString text; | 452 | // QString text; |
453 | // //view | 453 | // //view |
454 | // cb->setText(); | 454 | // cb->setText(); |
455 | // } | 455 | // } |