-rw-r--r-- | core/apps/textedit/textedit.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 5edf102..59a605a 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -362,49 +362,48 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
362 | a->addTo( edit ); | 362 | a->addTo( edit ); |
363 | 363 | ||
364 | searchBar->hide(); | 364 | searchBar->hide(); |
365 | 365 | ||
366 | editor = new QpeEditor( this ); | 366 | editor = new QpeEditor( this ); |
367 | setCentralWidget( editor ); | 367 | setCentralWidget( editor ); |
368 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 368 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
369 | connect( editor, SIGNAL( textChanged() ), | 369 | connect( editor, SIGNAL( textChanged() ), |
370 | this, SLOT( editorChanged() ) ); | 370 | this, SLOT( editorChanged() ) ); |
371 | 371 | ||
372 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); | 372 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); |
373 | 373 | ||
374 | Config cfg("TextEdit"); | 374 | Config cfg("TextEdit"); |
375 | cfg. setGroup ( "Font" ); | 375 | cfg. setGroup ( "Font" ); |
376 | 376 | ||
377 | QFont defaultFont = editor-> font ( ); | 377 | QFont defaultFont = editor-> font ( ); |
378 | 378 | ||
379 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); | 379 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); |
380 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); | 380 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); |
381 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); | 381 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); |
382 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); | 382 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); |
383 | 383 | ||
384 | defaultFont = QFont ( family, size, weight, italic ); | 384 | defaultFont = QFont ( family, size, weight, italic ); |
385 | editor-> setFont ( defaultFont ); | 385 | editor-> setFont ( defaultFont ); |
386 | |||
387 | // updateCaption(); | 386 | // updateCaption(); |
388 | 387 | ||
389 | cfg.setGroup ( "View" ); | 388 | cfg.setGroup ( "View" ); |
390 | 389 | ||
391 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); | 390 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); |
392 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); | 391 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); |
393 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); | 392 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); |
394 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); | 393 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); |
395 | startWithNew = cfg.readBoolEntry ( "startNew", true); | 394 | startWithNew = cfg.readBoolEntry ( "startNew", true); |
396 | featureAutoSave = cfg.readBoolEntry( "autosave", false); | 395 | featureAutoSave = cfg.readBoolEntry( "autosave", false); |
397 | 396 | ||
398 | if(useSearchBar) searchBarAction->setOn(true); | 397 | if(useSearchBar) searchBarAction->setOn(true); |
399 | if(promptExit) nAdvanced->setOn( true ); | 398 | if(promptExit) nAdvanced->setOn( true ); |
400 | if(openDesktop) desktopAction->setOn( true ); | 399 | if(openDesktop) desktopAction->setOn( true ); |
401 | if(filePerms) filePermAction->setOn( true ); | 400 | if(filePerms) filePermAction->setOn( true ); |
402 | if(startWithNew) nStart->setOn( true ); | 401 | if(startWithNew) nStart->setOn( true ); |
403 | if(featureAutoSave) nAutoSave->setOn(true); | 402 | if(featureAutoSave) nAutoSave->setOn(true); |
404 | 403 | ||
405 | // { | 404 | // { |
406 | // doTimer(true); | 405 | // doTimer(true); |
407 | // } | 406 | // } |
408 | 407 | ||
409 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); | 408 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); |
410 | wa-> setOn ( wrap ); | 409 | wa-> setOn ( wrap ); |
@@ -678,81 +677,89 @@ void TextEdit::openDotFile( const QString &f ) { | |||
678 | 677 | ||
679 | qDebug("openFile dotfile " + currentFileName); | 678 | qDebug("openFile dotfile " + currentFileName); |
680 | QString txt; | 679 | QString txt; |
681 | QFile file(f); | 680 | QFile file(f); |
682 | file.open(IO_ReadWrite); | 681 | file.open(IO_ReadWrite); |
683 | QTextStream t(&file); | 682 | QTextStream t(&file); |
684 | while ( !t.atEnd()) { | 683 | while ( !t.atEnd()) { |
685 | txt+=t.readLine()+"\n"; | 684 | txt+=t.readLine()+"\n"; |
686 | } | 685 | } |
687 | editor->setText(txt); | 686 | editor->setText(txt); |
688 | editor->setEdited( false); | 687 | editor->setEdited( false); |
689 | edited1=false; | 688 | edited1=false; |
690 | edited=false; | 689 | edited=false; |
691 | 690 | ||
692 | 691 | ||
693 | } | 692 | } |
694 | updateCaption( currentFileName); | 693 | updateCaption( currentFileName); |
695 | } | 694 | } |
696 | 695 | ||
697 | void TextEdit::openFile( const QString &f ) { | 696 | void TextEdit::openFile( const QString &f ) { |
698 | qDebug("filename is "+ f); | 697 | qDebug("filename is "+ f); |
699 | QString filer; | 698 | QString filer; |
700 | QFileInfo fi( f); | 699 | QFileInfo fi( f); |
701 | // bFromDocView = true; | 700 | // bFromDocView = true; |
702 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) { | 701 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) |
702 | { | ||
703 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 703 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
704 | tr("Text Editor has detected<BR>you selected a <B>.desktop</B> | 704 | tr("Text Editor has detected<BR>you selected a <B>.desktop</B> |
705 | file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), | 705 | file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), |
706 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) { | 706 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) |
707 | case 0: | 707 | { |
708 | case 0: //desktop | ||
708 | filer = f; | 709 | filer = f; |
709 | break; | 710 | break; |
710 | case 1: | 711 | case 1: //linked |
711 | DocLnk sf(f); | 712 | DocLnk sf(f); |
712 | filer = sf.file(); | 713 | filer = sf.file(); |
713 | break; | 714 | break; |
715 | }; | ||
714 | } | 716 | } |
715 | } else if(fi.baseName().left(1) == "") { | 717 | else if(fi.baseName().left(1) == "") |
718 | { | ||
719 | qDebug("opening dotfile"); | ||
716 | currentFileName=f; | 720 | currentFileName=f; |
717 | openDotFile(currentFileName); | 721 | openDotFile(currentFileName); |
718 | } else { | 722 | return; |
723 | } | ||
724 | else | ||
725 | { | ||
719 | DocLnk sf(f); | 726 | DocLnk sf(f); |
720 | filer = sf.file(); | 727 | filer = sf.file(); |
721 | if(filer.right(1) == "/") | 728 | if(filer.right(1) == "/") |
722 | filer = f; | 729 | filer = f; |
730 | } | ||
723 | 731 | ||
724 | DocLnk nf; | 732 | DocLnk nf; |
725 | nf.setType("text/plain"); | 733 | nf.setType("text/plain"); |
726 | nf.setFile(filer); | 734 | nf.setFile(filer); |
727 | currentFileName=filer; | 735 | currentFileName=filer; |
728 | 736 | ||
729 | nf.setName(fi.baseName()); | 737 | nf.setName(fi.baseName()); |
730 | openFile(nf); | 738 | openFile(nf); |
731 | 739 | ||
732 | qDebug("openFile string "+currentFileName); | 740 | qDebug("openFile string "+currentFileName); |
733 | 741 | ||
734 | } | ||
735 | showEditTools(); | 742 | showEditTools(); |
736 | // Show filename in caption | 743 | // Show filename in caption |
737 | QString name = filer; | 744 | QString name = filer; |
738 | int sep = name.findRev( '/' ); | 745 | int sep = name.findRev( '/' ); |
739 | if ( sep > 0 ) | 746 | if ( sep > 0 ) |
740 | name = name.mid( sep+1 ); | 747 | name = name.mid( sep+1 ); |
741 | updateCaption( name ); | 748 | updateCaption( name ); |
742 | } | 749 | } |
743 | 750 | ||
744 | void TextEdit::openFile( const DocLnk &f ) { | 751 | void TextEdit::openFile( const DocLnk &f ) { |
745 | // clear(); | 752 | // clear(); |
746 | // bFromDocView = true; | 753 | // bFromDocView = true; |
747 | FileManager fm; | 754 | FileManager fm; |
748 | QString txt; | 755 | QString txt; |
749 | currentFileName=f.file(); | 756 | currentFileName=f.file(); |
750 | qDebug("openFile doclnk " + currentFileName); | 757 | qDebug("openFile doclnk " + currentFileName); |
751 | if ( !fm.loadFile( f, txt ) ) { | 758 | if ( !fm.loadFile( f, txt ) ) { |
752 | // ####### could be a new file | 759 | // ####### could be a new file |
753 | qDebug( "Cannot open file" ); | 760 | qDebug( "Cannot open file" ); |
754 | } | 761 | } |
755 | // fileNew(); | 762 | // fileNew(); |
756 | if ( doc ) | 763 | if ( doc ) |
757 | delete doc; | 764 | delete doc; |
758 | doc = new DocLnk(f); | 765 | doc = new DocLnk(f); |