-rw-r--r-- | core/apps/textedit/textedit.cpp | 149 |
1 files changed, 78 insertions, 71 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 | |||
@@ -194,3 +194,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
194 | QPopupMenu *advancedMenu = new QPopupMenu(this); | 194 | QPopupMenu *advancedMenu = new QPopupMenu(this); |
195 | 195 | ||
196 | font = new QPopupMenu( this ); | 196 | font = new QPopupMenu( this ); |
@@ -249,3 +249,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
249 | #endif | 249 | #endif |
250 | 250 | ||
251 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), | 251 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), |
@@ -276,3 +276,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
276 | font->insertItem(tr("Advanced Features"), advancedMenu); | 276 | font->insertItem(tr("Advanced Features"), advancedMenu); |
277 | 277 | ||
278 | QAction *wa = new QAction( tr("Wrap lines"), | 278 | QAction *wa = new QAction( tr("Wrap lines"), |
@@ -326,3 +326,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
326 | nAutoSave->addTo( advancedMenu); | 326 | nAutoSave->addTo( advancedMenu); |
327 | 327 | ||
328 | 328 | ||
@@ -385,3 +385,2 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
385 | editor-> setFont ( defaultFont ); | 385 | editor-> setFont ( defaultFont ); |
386 | |||
387 | // updateCaption(); | 386 | // updateCaption(); |
@@ -396,3 +395,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
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); |
@@ -407,3 +406,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
407 | // } | 406 | // } |
408 | 407 | ||
409 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); | 408 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); |
@@ -415,3 +414,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
415 | currentFileName=qApp->argv()[1]; | 414 | currentFileName=qApp->argv()[1]; |
416 | 415 | ||
417 | QFileInfo fi(currentFileName); | 416 | QFileInfo fi(currentFileName); |
@@ -448,3 +447,3 @@ void TextEdit::closeEvent(QCloseEvent *) { | |||
448 | 447 | ||
449 | case 2: | 448 | case 2: |
450 | { | 449 | { |
@@ -454,3 +453,3 @@ void TextEdit::closeEvent(QCloseEvent *) { | |||
454 | 453 | ||
455 | case -1: | 454 | case -1: |
456 | break; | 455 | break; |
@@ -460,3 +459,3 @@ void TextEdit::closeEvent(QCloseEvent *) { | |||
460 | qApp->quit(); | 459 | qApp->quit(); |
461 | 460 | ||
462 | } | 461 | } |
@@ -464,3 +463,3 @@ void TextEdit::closeEvent(QCloseEvent *) { | |||
464 | void TextEdit::cleanUp() { | 463 | void TextEdit::cleanUp() { |
465 | 464 | ||
466 | Config cfg ( "TextEdit" ); | 465 | Config cfg ( "TextEdit" ); |
@@ -472,3 +471,3 @@ void TextEdit::cleanUp() { | |||
472 | cfg.writeEntry ( "Italic", f. italic ( )); | 471 | cfg.writeEntry ( "Italic", f. italic ( )); |
473 | 472 | ||
474 | cfg.setGroup ( "View" ); | 473 | cfg.setGroup ( "View" ); |
@@ -561,3 +560,3 @@ void TextEdit::setSearchBar(bool b) { | |||
561 | searchBar->hide(); | 560 | searchBar->hide(); |
562 | editor->setFocus(); | 561 | editor->setFocus(); |
563 | } | 562 | } |
@@ -677,3 +676,3 @@ void TextEdit::openDotFile( const QString &f ) { | |||
677 | currentFileName=f; | 676 | currentFileName=f; |
678 | 677 | ||
679 | qDebug("openFile dotfile " + currentFileName); | 678 | qDebug("openFile dotfile " + currentFileName); |
@@ -697,46 +696,54 @@ void TextEdit::openDotFile( const QString &f ) { | |||
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 ) |
703 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 702 | { |
704 | tr("Text Editor has detected<BR>you selected a <B>.desktop</B> | 703 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
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 | filer = f; | 708 | case 0: //desktop |
709 | break; | 709 | filer = f; |
710 | case 1: | 710 | break; |
711 | DocLnk sf(f); | 711 | case 1: //linked |
712 | filer = sf.file(); | 712 | DocLnk sf(f); |
713 | break; | 713 | filer = sf.file(); |
714 | } | 714 | break; |
715 | } else if(fi.baseName().left(1) == "") { | 715 | }; |
716 | currentFileName=f; | 716 | } |
717 | openDotFile(currentFileName); | 717 | else if(fi.baseName().left(1) == "") |
718 | } else { | 718 | { |
719 | DocLnk sf(f); | 719 | qDebug("opening dotfile"); |
720 | filer = sf.file(); | 720 | currentFileName=f; |
721 | if(filer.right(1) == "/") | 721 | openDotFile(currentFileName); |
722 | filer = f; | 722 | return; |
723 | 723 | } | |
724 | DocLnk nf; | 724 | else |
725 | nf.setType("text/plain"); | 725 | { |
726 | nf.setFile(filer); | 726 | DocLnk sf(f); |
727 | currentFileName=filer; | 727 | filer = sf.file(); |
728 | if(filer.right(1) == "/") | ||
729 | filer = f; | ||
730 | } | ||
728 | 731 | ||
729 | nf.setName(fi.baseName()); | 732 | DocLnk nf; |
730 | openFile(nf); | 733 | nf.setType("text/plain"); |
734 | nf.setFile(filer); | ||
735 | currentFileName=filer; | ||
731 | 736 | ||
732 | qDebug("openFile string "+currentFileName); | 737 | nf.setName(fi.baseName()); |
738 | openFile(nf); | ||
733 | 739 | ||
734 | } | 740 | qDebug("openFile string "+currentFileName); |
735 | showEditTools(); | 741 | |
736 | // Show filename in caption | 742 | showEditTools(); |
737 | QString name = filer; | 743 | // Show filename in caption |
738 | int sep = name.findRev( '/' ); | 744 | QString name = filer; |
739 | if ( sep > 0 ) | 745 | int sep = name.findRev( '/' ); |
740 | name = name.mid( sep+1 ); | 746 | if ( sep > 0 ) |
741 | updateCaption( name ); | 747 | name = name.mid( sep+1 ); |
748 | updateCaption( name ); | ||
742 | } | 749 | } |
@@ -820,3 +827,3 @@ bool TextEdit::save() { | |||
820 | } | 827 | } |
821 | 828 | ||
822 | } | 829 | } |
@@ -843,3 +850,3 @@ bool TextEdit::saveAs() { | |||
843 | qDebug("saveAsFile " + currentFileName); | 850 | qDebug("saveAsFile " + currentFileName); |
844 | // case of nothing to save... | 851 | // case of nothing to save... |
845 | // if ( !doc && !currentFileName.isEmpty()) { | 852 | // if ( !doc && !currentFileName.isEmpty()) { |
@@ -857,3 +864,3 @@ bool TextEdit::saveAs() { | |||
857 | qDebug(currentFileName); | 864 | qDebug(currentFileName); |
858 | 865 | ||
859 | if( currentFileName.isEmpty() | 866 | if( currentFileName.isEmpty() |
@@ -914,3 +921,3 @@ bool TextEdit::saveAs() { | |||
914 | currentFileName=fi.fileName(); | 921 | currentFileName=fi.fileName(); |
915 | if(doc) | 922 | if(doc) |
916 | // QString file = doc->file(); | 923 | // QString file = doc->file(); |
@@ -949,3 +956,3 @@ bool TextEdit::saveAs() { | |||
949 | setCaption(caption().right(caption().length()-1)); | 956 | setCaption(caption().right(caption().length()-1)); |
950 | 957 | ||
951 | return true; | 958 | return true; |
@@ -963,3 +970,3 @@ void TextEdit::clear() { | |||
963 | void TextEdit::updateCaption( const QString &name ) { | 970 | void TextEdit::updateCaption( const QString &name ) { |
964 | 971 | ||
965 | if ( name.isEmpty() ) | 972 | if ( name.isEmpty() ) |
@@ -1031,3 +1038,3 @@ void TextEdit::editDelete() { | |||
1031 | break; | 1038 | break; |
1032 | case 1: | 1039 | case 1: |
1033 | // exit | 1040 | // exit |
@@ -1058,3 +1065,3 @@ void TextEdit::receive(const QCString&msg, const QByteArray &) { | |||
1058 | qDebug("bugger all"); | 1065 | qDebug("bugger all"); |
1059 | 1066 | ||
1060 | } | 1067 | } |
@@ -1074,3 +1081,3 @@ void TextEdit::doPrompt(bool b) { | |||
1074 | cfg.setGroup ( "View" ); | 1081 | cfg.setGroup ( "View" ); |
1075 | cfg.writeEntry ( "PromptExit", b); | 1082 | cfg.writeEntry ( "PromptExit", b); |
1076 | } | 1083 | } |
@@ -1081,3 +1088,3 @@ void TextEdit::doDesktop(bool b) { | |||
1081 | cfg.setGroup ( "View" ); | 1088 | cfg.setGroup ( "View" ); |
1082 | cfg.writeEntry ( "OpenDesktop", b); | 1089 | cfg.writeEntry ( "OpenDesktop", b); |
1083 | } | 1090 | } |
@@ -1088,3 +1095,3 @@ void TextEdit::doFilePerms(bool b) { | |||
1088 | cfg.setGroup ( "View" ); | 1095 | cfg.setGroup ( "View" ); |
1089 | cfg.writeEntry ( "FilePermissions", b); | 1096 | cfg.writeEntry ( "FilePermissions", b); |
1090 | } | 1097 | } |
@@ -1114,3 +1121,3 @@ int TextEdit::savePrompt() | |||
1114 | 1121 | ||
1115 | case 1: | 1122 | case 1: |
1116 | { | 1123 | { |
@@ -1152,4 +1159,4 @@ void TextEdit::doTimer(bool b) | |||
1152 | cfg.setGroup ( "View" ); | 1159 | cfg.setGroup ( "View" ); |
1153 | cfg.writeEntry ( "autosave", b); | 1160 | cfg.writeEntry ( "autosave", b); |
1154 | featureAutoSave = b; | 1161 | featureAutoSave = b; |
1155 | nAutoSave->setOn(b); | 1162 | nAutoSave->setOn(b); |
@@ -1158,3 +1165,3 @@ void TextEdit::doTimer(bool b) | |||
1158 | // qDebug("doTimer true"); | 1165 | // qDebug("doTimer true"); |
1159 | setTimer(); | 1166 | setTimer(); |
1160 | } | 1167 | } |
@@ -1180,3 +1187,3 @@ void TextEdit::gotoLine() { | |||
1180 | gotoEdit = new QLineEdit( 0, "Goto line"); | 1187 | gotoEdit = new QLineEdit( 0, "Goto line"); |
1181 | 1188 | ||
1182 | gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2)); | 1189 | gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2)); |
@@ -1195,3 +1202,3 @@ void TextEdit::doGoto() { | |||
1195 | } | 1202 | } |
1196 | 1203 | ||
1197 | bool ok; | 1204 | bool ok; |