summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp149
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
@@ -187,17 +187,17 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
187 QPEToolBar *bar = new QPEToolBar( this ); 187 QPEToolBar *bar = new QPEToolBar( this );
188 bar->setHorizontalStretchable( true ); 188 bar->setHorizontalStretchable( true );
189 menu = bar; 189 menu = bar;
190 190
191 QPEMenuBar *mb = new QPEMenuBar( bar ); 191 QPEMenuBar *mb = new QPEMenuBar( bar );
192 QPopupMenu *file = new QPopupMenu( this ); 192 QPopupMenu *file = new QPopupMenu( this );
193 QPopupMenu *edit = new QPopupMenu( this ); 193 QPopupMenu *edit = new QPopupMenu( this );
194 QPopupMenu *advancedMenu = new QPopupMenu(this); 194 QPopupMenu *advancedMenu = new QPopupMenu(this);
195 195
196 font = new QPopupMenu( this ); 196 font = new QPopupMenu( this );
197 197
198 bar = new QPEToolBar( this ); 198 bar = new QPEToolBar( this );
199 editBar = bar; 199 editBar = bar;
200 200
201 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), 201 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ),
202 QString::null, 0, this, 0 ); 202 QString::null, 0, this, 0 );
203 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 203 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
@@ -242,17 +242,17 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
242 242
243 243
244#ifndef QT_NO_CLIPBOARD 244#ifndef QT_NO_CLIPBOARD
245 a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), 245 a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ),
246 QString::null, 0, this, 0 ); 246 QString::null, 0, this, 0 );
247 connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); 247 connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) );
248 a->addTo( edit ); 248 a->addTo( edit );
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" ),
252 QString::null, 0, this, 0 ); 252 QString::null, 0, this, 0 );
253 connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); 253 connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) );
254 edit->insertSeparator(); 254 edit->insertSeparator();
255 a->addTo( edit ); 255 a->addTo( edit );
256 256
257 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), 257 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ),
258 QString::null, 0, this, 0 ); 258 QString::null, 0, this, 0 );
@@ -269,17 +269,17 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
269 zout->addTo( font ); 269 zout->addTo( font );
270 270
271 font->insertSeparator(); 271 font->insertSeparator();
272 272
273 font->insertItem(tr("Font"), this, SLOT(changeFont()) ); 273 font->insertItem(tr("Font"), this, SLOT(changeFont()) );
274 274
275 font->insertSeparator(); 275 font->insertSeparator();
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"),
279 QString::null, 0, this, 0 ); 279 QString::null, 0, this, 0 );
280 connect( wa, SIGNAL( toggled(bool) ), 280 connect( wa, SIGNAL( toggled(bool) ),
281 this, SLOT( setWordWrap(bool) ) ); 281 this, SLOT( setWordWrap(bool) ) );
282 wa->setToggleAction(true); 282 wa->setToggleAction(true);
283 wa->addTo( advancedMenu); 283 wa->addTo( advancedMenu);
284 284
285 nStart = new QAction( tr("Start with new file"), 285 nStart = new QAction( tr("Start with new file"),
@@ -319,17 +319,17 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
319 searchBarAction->addTo( advancedMenu); 319 searchBarAction->addTo( advancedMenu);
320 320
321 nAutoSave = new QAction( tr("Auto Save 5 min."), 321 nAutoSave = new QAction( tr("Auto Save 5 min."),
322 QString::null, 0, this, 0 ); 322 QString::null, 0, this, 0 );
323 connect( nAutoSave, SIGNAL( toggled(bool) ), 323 connect( nAutoSave, SIGNAL( toggled(bool) ),
324 this, SLOT( doTimer(bool) ) ); 324 this, SLOT( doTimer(bool) ) );
325 nAutoSave->setToggleAction(true); 325 nAutoSave->setToggleAction(true);
326 nAutoSave->addTo( advancedMenu); 326 nAutoSave->addTo( advancedMenu);
327 327
328 328
329 font->insertSeparator(); 329 font->insertSeparator();
330 330
331 font->insertItem(tr("About"), this, SLOT( doAbout()) ); 331 font->insertItem(tr("About"), this, SLOT( doAbout()) );
332 332
333 mb->insertItem( tr( "File" ), file ); 333 mb->insertItem( tr( "File" ), file );
334 mb->insertItem( tr( "Edit" ), edit ); 334 mb->insertItem( tr( "Edit" ), edit );
335 mb->insertItem( tr( "View" ), font ); 335 mb->insertItem( tr( "View" ), font );
@@ -378,47 +378,46 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
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 );
411 setWordWrap ( wrap ); 410 setWordWrap ( wrap );
412 411
413///////////////// 412/////////////////
414 if( qApp->argc() > 1) { 413 if( qApp->argc() > 1) {
415 currentFileName=qApp->argv()[1]; 414 currentFileName=qApp->argv()[1];
416 415
417 QFileInfo fi(currentFileName); 416 QFileInfo fi(currentFileName);
418 417
419 if(fi.baseName().left(1) == "") { 418 if(fi.baseName().left(1) == "") {
420 openDotFile(currentFileName); 419 openDotFile(currentFileName);
421 } else { 420 } else {
422 openFile(currentFileName); 421 openFile(currentFileName);
423 } 422 }
424 } else { 423 } else {
@@ -441,41 +440,41 @@ void TextEdit::closeEvent(QCloseEvent *) {
441 { 440 {
442 case 1: 441 case 1:
443 { 442 {
444 saveAs(); 443 saveAs();
445 qApp->quit(); 444 qApp->quit();
446 } 445 }
447 break; 446 break;
448 447
449 case 2: 448 case 2:
450 { 449 {
451 qApp->quit(); 450 qApp->quit();
452 } 451 }
453 break; 452 break;
454 453
455 case -1: 454 case -1:
456 break; 455 break;
457 }; 456 };
458 } 457 }
459 else 458 else
460 qApp->quit(); 459 qApp->quit();
461 460
462} 461}
463 462
464void TextEdit::cleanUp() { 463void TextEdit::cleanUp() {
465 464
466 Config cfg ( "TextEdit" ); 465 Config cfg ( "TextEdit" );
467 cfg. setGroup ( "Font" ); 466 cfg. setGroup ( "Font" );
468 QFont f = editor->font(); 467 QFont f = editor->font();
469 cfg.writeEntry ( "Family", f. family ( )); 468 cfg.writeEntry ( "Family", f. family ( ));
470 cfg.writeEntry ( "Size", f. pointSize ( )); 469 cfg.writeEntry ( "Size", f. pointSize ( ));
471 cfg.writeEntry ( "Weight", f. weight ( )); 470 cfg.writeEntry ( "Weight", f. weight ( ));
472 cfg.writeEntry ( "Italic", f. italic ( )); 471 cfg.writeEntry ( "Italic", f. italic ( ));
473 472
474 cfg.setGroup ( "View" ); 473 cfg.setGroup ( "View" );
475 cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); 474 cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth );
476 cfg.writeEntry ( "FileView", viewSelection ); 475 cfg.writeEntry ( "FileView", viewSelection );
477 476
478 cfg.writeEntry ( "PromptExit", promptExit ); 477 cfg.writeEntry ( "PromptExit", promptExit );
479 cfg.writeEntry ( "OpenDesktop", openDesktop ); 478 cfg.writeEntry ( "OpenDesktop", openDesktop );
480 cfg.writeEntry ( "FilePermissions", filePerms ); 479 cfg.writeEntry ( "FilePermissions", filePerms );
481 cfg.writeEntry ( "SearchBar", useSearchBar ); 480 cfg.writeEntry ( "SearchBar", useSearchBar );
@@ -554,17 +553,17 @@ void TextEdit::setSearchBar(bool b) {
554 Config cfg("TextEdit"); 553 Config cfg("TextEdit");
555 cfg.setGroup("View"); 554 cfg.setGroup("View");
556 cfg.writeEntry ( "SearchBar", b ); 555 cfg.writeEntry ( "SearchBar", b );
557 searchBarAction->setOn(b); 556 searchBarAction->setOn(b);
558 if(b) 557 if(b)
559 searchBar->show(); 558 searchBar->show();
560 else 559 else
561 searchBar->hide(); 560 searchBar->hide();
562 editor->setFocus(); 561 editor->setFocus();
563} 562}
564 563
565void TextEdit::fileNew() { 564void TextEdit::fileNew() {
566// if( !bFromDocView ) { 565// if( !bFromDocView ) {
567// saveAs(); 566// saveAs();
568// } 567// }
569 newFile(DocLnk()); 568 newFile(DocLnk());
570} 569}
@@ -670,17 +669,17 @@ void TextEdit::newFile( const DocLnk &f ) {
670 qDebug("newFile "+currentFileName); 669 qDebug("newFile "+currentFileName);
671 updateCaption( currentFileName); 670 updateCaption( currentFileName);
672// editor->setEdited( false); 671// editor->setEdited( false);
673} 672}
674 673
675void TextEdit::openDotFile( const QString &f ) { 674void TextEdit::openDotFile( const QString &f ) {
676 if(!currentFileName.isEmpty()) { 675 if(!currentFileName.isEmpty()) {
677 currentFileName=f; 676 currentFileName=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 }
@@ -690,60 +689,68 @@ void TextEdit::openDotFile( const QString &f ) {
690 edited=false; 689 edited=false;
691 690
692 691
693 } 692 }
694 updateCaption( currentFileName); 693 updateCaption( currentFileName);
695} 694}
696 695
697void TextEdit::openFile( const QString &f ) { 696void 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>
705file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), 705file.<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}
743 750
744void TextEdit::openFile( const DocLnk &f ) { 751void 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();
@@ -813,17 +820,17 @@ bool TextEdit::save() {
813 QFile f(file); 820 QFile f(file);
814 if( f.open(IO_WriteOnly)) { 821 if( f.open(IO_WriteOnly)) {
815 QCString crt = rt.utf8(); 822 QCString crt = rt.utf8();
816 f.writeBlock(crt,crt.length()); 823 f.writeBlock(crt,crt.length());
817 } else { 824 } else {
818 QMessageBox::message(tr("Text Edit"),tr("Write Failed")); 825 QMessageBox::message(tr("Text Edit"),tr("Write Failed"));
819 return false; 826 return false;
820 } 827 }
821 828
822 } 829 }
823 editor->setEdited( false); 830 editor->setEdited( false);
824 edited1=false; 831 edited1=false;
825 edited=false; 832 edited=false;
826 if(caption().left(1)=="*") 833 if(caption().left(1)=="*")
827 setCaption(caption().right(caption().length()-1)); 834 setCaption(caption().right(caption().length()-1));
828 835
829 836
@@ -836,31 +843,31 @@ bool TextEdit::save() {
836 843
837/*! 844/*!
838 prompted save */ 845 prompted save */
839bool TextEdit::saveAs() { 846bool TextEdit::saveAs() {
840 847
841 if(caption() == tr("Text Editor")) 848 if(caption() == tr("Text Editor"))
842 return false; 849 return false;
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()) {
846// //|| !bFromDocView) 853// //|| !bFromDocView)
847// qDebug("no doc"); 854// qDebug("no doc");
848// return true; 855// return true;
849// } 856// }
850// if ( !editor->edited() ) { 857// if ( !editor->edited() ) {
851// delete doc; 858// delete doc;
852// doc = 0; 859// doc = 0;
853// return true; 860// return true;
854// } 861// }
855 862
856 QString rt = editor->text(); 863 QString rt = editor->text();
857 qDebug(currentFileName); 864 qDebug(currentFileName);
858 865
859 if( currentFileName.isEmpty() 866 if( currentFileName.isEmpty()
860 || currentFileName == tr("Unnamed") 867 || currentFileName == tr("Unnamed")
861 || currentFileName == tr("Text Editor")) { 868 || currentFileName == tr("Text Editor")) {
862 qDebug("do silly TT filename thing"); 869 qDebug("do silly TT filename thing");
863// if ( doc && doc->name().isEmpty() ) { 870// if ( doc && doc->name().isEmpty() ) {
864 QString pt = rt.simplifyWhiteSpace(); 871 QString pt = rt.simplifyWhiteSpace();
865 int i = pt.find( ' ' ); 872 int i = pt.find( ' ' );
866 QString docname = pt; 873 QString docname = pt;
@@ -907,17 +914,17 @@ bool TextEdit::saveAs() {
907 else 914 else
908 str=currentFileName; 915 str=currentFileName;
909 if(!str.isEmpty()) { 916 if(!str.isEmpty()) {
910 QString fileNm=str; 917 QString fileNm=str;
911 918
912 qDebug("saving filename "+fileNm); 919 qDebug("saving filename "+fileNm);
913 QFileInfo fi(fileNm); 920 QFileInfo fi(fileNm);
914 currentFileName=fi.fileName(); 921 currentFileName=fi.fileName();
915 if(doc) 922 if(doc)
916// QString file = doc->file(); 923// QString file = doc->file();
917// doc->removeFiles(); 924// doc->removeFiles();
918 delete doc; 925 delete doc;
919 DocLnk nf; 926 DocLnk nf;
920 nf.setType("text/plain"); 927 nf.setType("text/plain");
921 nf.setFile( fileNm); 928 nf.setFile( fileNm);
922 doc = new DocLnk(nf); 929 doc = new DocLnk(nf);
923// editor->setText(rt); 930// editor->setText(rt);
@@ -942,31 +949,31 @@ bool TextEdit::saveAs() {
942 delete filePerm; 949 delete filePerm;
943 } 950 }
944// } 951// }
945 editor->setEdited( false); 952 editor->setEdited( false);
946 edited1 = false; 953 edited1 = false;
947 edited = false; 954 edited = false;
948 if(caption().left(1)=="*") 955 if(caption().left(1)=="*")
949 setCaption(caption().right(caption().length()-1)); 956 setCaption(caption().right(caption().length()-1));
950 957
951 return true; 958 return true;
952 } 959 }
953 qDebug("returning false"); 960 qDebug("returning false");
954 return false; 961 return false;
955} //end saveAs 962} //end saveAs
956 963
957void TextEdit::clear() { 964void TextEdit::clear() {
958 delete doc; 965 delete doc;
959 doc = 0; 966 doc = 0;
960 editor->clear(); 967 editor->clear();
961} 968}
962 969
963void TextEdit::updateCaption( const QString &name ) { 970void TextEdit::updateCaption( const QString &name ) {
964 971
965 if ( name.isEmpty() ) 972 if ( name.isEmpty() )
966 setCaption( tr("Text Editor") ); 973 setCaption( tr("Text Editor") );
967 else { 974 else {
968 QString s = name; 975 QString s = name;
969 if ( s.isNull() ) 976 if ( s.isNull() )
970 s = doc->name(); 977 s = doc->name();
971 if ( s.isEmpty() ) { 978 if ( s.isEmpty() ) {
972 s = tr( "Unnamed" ); 979 s = tr( "Unnamed" );
@@ -1024,17 +1031,17 @@ void TextEdit::editDelete() {
1024 tr("Yes"),tr("No"),0,0,1) ) { 1031 tr("Yes"),tr("No"),0,0,1) ) {
1025 case 0: 1032 case 0:
1026 if(doc) { 1033 if(doc) {
1027 doc->removeFiles(); 1034 doc->removeFiles();
1028 clear(); 1035 clear();
1029 setCaption( tr("Text Editor") ); 1036 setCaption( tr("Text Editor") );
1030 } 1037 }
1031 break; 1038 break;
1032 case 1: 1039 case 1:
1033 // exit 1040 // exit
1034 break; 1041 break;
1035 }; 1042 };
1036} 1043}
1037 1044
1038void TextEdit::changeStartConfig( bool b ) { 1045void TextEdit::changeStartConfig( bool b ) {
1039 startWithNew=b; 1046 startWithNew=b;
1040 Config cfg("TextEdit"); 1047 Config cfg("TextEdit");
@@ -1051,47 +1058,47 @@ void TextEdit::editorChanged() {
1051 } 1058 }
1052 edited=true; 1059 edited=true;
1053} 1060}
1054 1061
1055void TextEdit::receive(const QCString&msg, const QByteArray &) { 1062void TextEdit::receive(const QCString&msg, const QByteArray &) {
1056 qDebug("QCop "+msg); 1063 qDebug("QCop "+msg);
1057 if ( msg == "setDocument(QString)" ) { 1064 if ( msg == "setDocument(QString)" ) {
1058 qDebug("bugger all"); 1065 qDebug("bugger all");
1059 1066
1060 } 1067 }
1061 1068
1062} 1069}
1063 1070
1064void TextEdit::doAbout() { 1071void TextEdit::doAbout() {
1065 QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" 1072 QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>"
1066 "2000 Trolltech AS, and<BR>" 1073 "2000 Trolltech AS, and<BR>"
1067 "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" 1074 "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>"
1068 "and is licensed under the GPL")); 1075 "and is licensed under the GPL"));
1069} 1076}
1070 1077
1071void TextEdit::doPrompt(bool b) { 1078void TextEdit::doPrompt(bool b) {
1072 promptExit=b; 1079 promptExit=b;
1073 Config cfg("TextEdit"); 1080 Config cfg("TextEdit");
1074 cfg.setGroup ( "View" ); 1081 cfg.setGroup ( "View" );
1075 cfg.writeEntry ( "PromptExit", b); 1082 cfg.writeEntry ( "PromptExit", b);
1076} 1083}
1077 1084
1078void TextEdit::doDesktop(bool b) { 1085void TextEdit::doDesktop(bool b) {
1079 openDesktop=b; 1086 openDesktop=b;
1080 Config cfg("TextEdit"); 1087 Config cfg("TextEdit");
1081 cfg.setGroup ( "View" ); 1088 cfg.setGroup ( "View" );
1082 cfg.writeEntry ( "OpenDesktop", b); 1089 cfg.writeEntry ( "OpenDesktop", b);
1083} 1090}
1084 1091
1085void TextEdit::doFilePerms(bool b) { 1092void TextEdit::doFilePerms(bool b) {
1086 filePerms=b; 1093 filePerms=b;
1087 Config cfg("TextEdit"); 1094 Config cfg("TextEdit");
1088 cfg.setGroup ( "View" ); 1095 cfg.setGroup ( "View" );
1089 cfg.writeEntry ( "FilePermissions", b); 1096 cfg.writeEntry ( "FilePermissions", b);
1090} 1097}
1091 1098
1092void TextEdit::editPasteTimeDate() { 1099void TextEdit::editPasteTimeDate() {
1093#ifndef QT_NO_CLIPBOARD 1100#ifndef QT_NO_CLIPBOARD
1094 QClipboard *cb = QApplication::clipboard(); 1101 QClipboard *cb = QApplication::clipboard();
1095 QDateTime dt = QDateTime::currentDateTime(); 1102 QDateTime dt = QDateTime::currentDateTime();
1096 cb->setText( dt.toString()); 1103 cb->setText( dt.toString());
1097 editor->paste(); 1104 editor->paste();
@@ -1107,17 +1114,17 @@ int TextEdit::savePrompt()
1107 (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) 1114 (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) )
1108 { 1115 {
1109 case 0: 1116 case 0:
1110 { 1117 {
1111 return 1; 1118 return 1;
1112 } 1119 }
1113 break; 1120 break;
1114 1121
1115 case 1: 1122 case 1:
1116 { 1123 {
1117 return 2; 1124 return 2;
1118 } 1125 }
1119 break; 1126 break;
1120 1127
1121 case 2: 1128 case 2:
1122 { 1129 {
1123 return -1; 1130 return -1;
@@ -1145,23 +1152,23 @@ void TextEdit::timerCrank()
1145 setTimer(); 1152 setTimer();
1146 } 1153 }
1147} 1154}
1148 1155
1149void TextEdit::doTimer(bool b) 1156void TextEdit::doTimer(bool b)
1150{ 1157{
1151 Config cfg("TextEdit"); 1158 Config cfg("TextEdit");
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);
1156 if(b) 1163 if(b)
1157 { 1164 {
1158// qDebug("doTimer true"); 1165// qDebug("doTimer true");
1159 setTimer(); 1166 setTimer();
1160 } 1167 }
1161// else 1168// else
1162// qDebug("doTimer false"); 1169// qDebug("doTimer false");
1163} 1170}
1164 1171
1165void TextEdit::setTimer() 1172void TextEdit::setTimer()
1166{ 1173{
1167if(featureAutoSave) 1174if(featureAutoSave)
@@ -1173,32 +1180,32 @@ if(featureAutoSave)
1173 } 1180 }
1174} 1181}
1175 1182
1176void TextEdit::gotoLine() { 1183void TextEdit::gotoLine() {
1177 if( editor->length() < 1) 1184 if( editor->length() < 1)
1178 return; 1185 return;
1179 QWidget *d = QApplication::desktop(); 1186 QWidget *d = QApplication::desktop();
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));
1183 gotoEdit->setFrame(true); 1190 gotoEdit->setFrame(true);
1184 gotoEdit->show(); 1191 gotoEdit->show();
1185 connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto())); 1192 connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto()));
1186} 1193}
1187 1194
1188void TextEdit::doGoto() { 1195void TextEdit::doGoto() {
1189 QString number = gotoEdit->text(); 1196 QString number = gotoEdit->text();
1190 gotoEdit->hide(); 1197 gotoEdit->hide();
1191 1198
1192 if(gotoEdit) { 1199 if(gotoEdit) {
1193 delete gotoEdit; 1200 delete gotoEdit;
1194 gotoEdit = 0; 1201 gotoEdit = 0;
1195 } 1202 }
1196 1203
1197 bool ok; 1204 bool ok;
1198 int lineNumber = number.toInt(&ok, 10); 1205 int lineNumber = number.toInt(&ok, 10);
1199 if( editor->numLines() < lineNumber) 1206 if( editor->numLines() < lineNumber)
1200 QMessageBox::message(tr("Text Edit"),tr("Not enough lines")); 1207 QMessageBox::message(tr("Text Edit"),tr("Not enough lines"));
1201 else 1208 else
1202 { 1209 {
1203 editor->setCursorPosition(lineNumber, 0, false); 1210 editor->setCursorPosition(lineNumber, 0, false);
1204 } 1211 }