summaryrefslogtreecommitdiff
path: root/core
authorllornkcor <llornkcor>2002-11-09 23:11:09 (UTC)
committer llornkcor <llornkcor>2002-11-09 23:11:09 (UTC)
commit0c81c6287771d5ad416c2ddf0ae32ad5ce18c116 (patch) (unidiff)
tree9e565161740031ed63f51ce09377b7e2ef2bb4a7 /core
parentc1f59c3404e9c0312e3d0418d5286b12d2e98d92 (diff)
downloadopie-0c81c6287771d5ad416c2ddf0ae32ad5ce18c116.zip
opie-0c81c6287771d5ad416c2ddf0ae32ad5ce18c116.tar.gz
opie-0c81c6287771d5ad416c2ddf0ae32ad5ce18c116.tar.bz2
various fixes.. saveAs and quit stuff
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp281
-rw-r--r--core/apps/textedit/textedit.h4
2 files changed, 137 insertions, 148 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 464671a..1c3b393 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -194,12 +194,12 @@ private:
194void QpeEditor::find ( const QString &txt, bool caseSensitive, 194void QpeEditor::find ( const QString &txt, bool caseSensitive,
195 bool backwards ) 195 bool backwards )
196{ 196{
197 static bool wrap = FALSE; 197 static bool wrap = false;
198 int line, col; 198 int line, col;
199 if ( wrap ) { 199 if ( wrap ) {
200 if ( !backwards ) 200 if ( !backwards )
201 line = col = 0; 201 line = col = 0;
202 wrap = FALSE; 202 wrap = false;
203 // emit searchWrapped(); 203 // emit searchWrapped();
204 } else { 204 } else {
205 getCursorPosition( &line, &col ); 205 getCursorPosition( &line, &col );
@@ -208,17 +208,17 @@ void QpeEditor::find ( const QString &txt, bool caseSensitive,
208 if ( !backwards ) { 208 if ( !backwards ) {
209 for ( ; ; ) { 209 for ( ; ; ) {
210 if ( line >= numLines() ) { 210 if ( line >= numLines() ) {
211 wrap = TRUE; 211 wrap = true;
212 //emit notFound(); 212 //emit notFound();
213 break; 213 break;
214 } 214 }
215 int findCol = getString( line )->find( txt, col, caseSensitive ); 215 int findCol = getString( line )->find( txt, col, caseSensitive );
216 if ( findCol >= 0 ) { 216 if ( findCol >= 0 ) {
217 setCursorPosition( line, findCol, FALSE ); 217 setCursorPosition( line, findCol, false );
218 col = findCol + txt.length(); 218 col = findCol + txt.length();
219 setCursorPosition( line, col, TRUE ); 219 setCursorPosition( line, col, true );
220 220
221 //found = TRUE; 221 //found = true;
222 break; 222 break;
223 } 223 }
224 line++; 224 line++;
@@ -239,12 +239,12 @@ static const int nfontsizes = 6;
239static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; 239static const int fontsize[nfontsizes] = {8,10,12,14,18,24};
240 240
241TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) 241TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
242 : QMainWindow( parent, name, f ), bFromDocView( FALSE ) 242 : QMainWindow( parent, name, f ), bFromDocView( false )
243{ 243{
244 doc = 0; 244 doc = 0;
245 edited=FALSE; 245 edited=false;
246 edited1=FALSE; 246 edited1=false;
247 setToolBarsMovable( FALSE ); 247 setToolBarsMovable( false );
248 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 248 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
249 249
250 channel = new QCopChannel( "QPE/Application/textedit", this ); 250 channel = new QCopChannel( "QPE/Application/textedit", this );
@@ -254,7 +254,7 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
254 setIcon( Resource::loadPixmap( "TextEditor" ) ); 254 setIcon( Resource::loadPixmap( "TextEditor" ) );
255 255
256 QPEToolBar *bar = new QPEToolBar( this ); 256 QPEToolBar *bar = new QPEToolBar( this );
257 bar->setHorizontalStretchable( TRUE ); 257 bar->setHorizontalStretchable( true );
258 menu = bar; 258 menu = bar;
259 259
260 QPEMenuBar *mb = new QPEMenuBar( bar ); 260 QPEMenuBar *mb = new QPEMenuBar( bar );
@@ -332,32 +332,32 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
332 332
333 QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); 333 QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 );
334 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); 334 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) );
335 wa->setToggleAction(TRUE); 335 wa->setToggleAction(true);
336 wa->addTo( advancedMenu); 336 wa->addTo( advancedMenu);
337 337
338 nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); 338 nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 );
339 connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); 339 connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) );
340 nStart->setToggleAction(TRUE); 340 nStart->setToggleAction(true);
341 nStart->addTo( advancedMenu ); 341 nStart->addTo( advancedMenu );
342 342
343 nAdvanced = new QAction( tr("Prompt on Exit"), QString::null, 0, this, 0 ); 343 nAdvanced = new QAction( tr("Prompt on Exit"), QString::null, 0, this, 0 );
344 connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doPrompt(bool) ) ); 344 connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doPrompt(bool) ) );
345 nAdvanced->setToggleAction(TRUE); 345 nAdvanced->setToggleAction(true);
346 nAdvanced->addTo( advancedMenu ); 346 nAdvanced->addTo( advancedMenu );
347 347
348 desktopAction = new QAction( tr("Always open linked file"), QString::null, 0, this, 0 ); 348 desktopAction = new QAction( tr("Always open linked file"), QString::null, 0, this, 0 );
349 connect( desktopAction, SIGNAL( toggled(bool) ), this, SLOT( doDesktop(bool) ) ); 349 connect( desktopAction, SIGNAL( toggled(bool) ), this, SLOT( doDesktop(bool) ) );
350 desktopAction->setToggleAction(TRUE); 350 desktopAction->setToggleAction(true);
351 desktopAction->addTo( advancedMenu); 351 desktopAction->addTo( advancedMenu);
352 352
353 filePermAction = new QAction( tr("File Permissions"), QString::null, 0, this, 0 ); 353 filePermAction = new QAction( tr("File Permissions"), QString::null, 0, this, 0 );
354 connect( filePermAction, SIGNAL( toggled(bool) ), this, SLOT( doFilePerms(bool) ) ); 354 connect( filePermAction, SIGNAL( toggled(bool) ), this, SLOT( doFilePerms(bool) ) );
355 filePermAction->setToggleAction(TRUE); 355 filePermAction->setToggleAction(true);
356 filePermAction->addTo( advancedMenu); 356 filePermAction->addTo( advancedMenu);
357 357
358 searchBarAction = new QAction( tr("Search Bar Open"), QString::null, 0, this, 0 ); 358 searchBarAction = new QAction( tr("Search Bar Open"), QString::null, 0, this, 0 );
359 connect( searchBarAction, SIGNAL( toggled(bool) ), this, SLOT( setSearchBar(bool) ) ); 359 connect( searchBarAction, SIGNAL( toggled(bool) ), this, SLOT( setSearchBar(bool) ) );
360 searchBarAction->setToggleAction(TRUE); 360 searchBarAction->setToggleAction(true);
361 searchBarAction->addTo( advancedMenu); 361 searchBarAction->addTo( advancedMenu);
362 362
363 363
@@ -370,9 +370,9 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
370 mb->insertItem( tr( "View" ), font ); 370 mb->insertItem( tr( "View" ), font );
371 371
372 searchBar = new QPEToolBar(this); 372 searchBar = new QPEToolBar(this);
373 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); 373 addToolBar( searchBar, "Search", QMainWindow::Top, true );
374 374
375 searchBar->setHorizontalStretchable( TRUE ); 375 searchBar->setHorizontalStretchable( true );
376 376
377 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 377 searchEdit = new QLineEdit( searchBar, "searchEdit" );
378 searchBar->setStretchableWidget( searchEdit ); 378 searchBar->setStretchableWidget( searchEdit );
@@ -422,51 +422,54 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
422 openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); 422 openDesktop = cfg.readBoolEntry ( "OpenDesktop", true );
423 filePerms = cfg.readBoolEntry ( "FilePermissions", false ); 423 filePerms = cfg.readBoolEntry ( "FilePermissions", false );
424 useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); 424 useSearchBar = cfg.readBoolEntry ( "SearchBar", false );
425 425 startWithNew = cfg.readBoolEntry ( "startNew", true);
426 if(useSearchBar) { 426
427 searchBarAction->setOn(true); 427 if(useSearchBar) searchBarAction->setOn(true);
428 } else{ 428 if(promptExit ) nAdvanced->setOn( true );
429 } 429 if(openDesktop) desktopAction->setOn( true );
430 if(promptExit ) nAdvanced->setOn ( true ); 430 if(filePerms) filePermAction->setOn( true );
431 if(openDesktop) desktopAction->setOn ( true ); 431 if(startWithNew) nStart->setOn( true );
432 if(filePerms) filePermAction->setOn ( true );
433 432
434 bool wrap = cfg. readBoolEntry ( "Wrap", true ); 433 bool wrap = cfg. readBoolEntry ( "Wrap", true );
435 wa-> setOn ( wrap ); 434 wa-> setOn ( wrap );
436 setWordWrap ( wrap ); 435 setWordWrap ( wrap );
437 436
438 if( qApp->argc() > 0) { 437 if( qApp->argc() > 1) {
439 currentFileName=qApp->argv()[1]; 438 currentFileName=qApp->argv()[1];
440// qDebug("<<<<<<<<<<<<<<<<<<<<<<<< "+currentFileName); 439// qDebug("<<<<<<<<<<<<<<<<<<<<<<<< "+currentFileName+" %d",qApp->argc());
441 QFileInfo fi(currentFileName); 440 QFileInfo fi(currentFileName);
442
443 if(fi.baseName().left(1) == "") {
444 openDotFile(currentFileName);
445 } else {
446
447 nStart->setOn(TRUE);
448 openFile(currentFileName);
449 }
450 } else
451 if(cfg.readEntry("startNew","TRUE") == "TRUE") {
452 441
453 nStart->setOn(TRUE); 442 if(fi.baseName().left(1) == "") {
454 fileNew(); 443 openDotFile(currentFileName);
444 } else {
445 openFile(currentFileName);
446 }
455 } else { 447 } else {
456 448// qDebug("Do other thing");
457 fileOpen(); 449 if(startWithNew) {
450 openDotFile("");
451// fileNew();
452 } else {
453 fileOpen();
454 }
458 } 455 }
459 456
460 viewSelection = cfg.readNumEntry( "FileView", 0 ); 457 viewSelection = cfg.readNumEntry( "FileView", 0 );
461} 458}
462 459
463TextEdit::~TextEdit() { 460TextEdit::~TextEdit() {
464 if( edited1 & promptExit ) 461// qDebug("destr");
465 saveAs(); 462}
463
464void TextEdit::closeEvent(QCloseEvent *) {
465// qDebug("closing here");
466 if( edited1 && promptExit)
467 saveAs();
468 qApp->quit();
466} 469}
467 470
468void TextEdit::cleanUp() { 471void TextEdit::cleanUp() {
469 qDebug("cleanUp");// save(); 472// qDebug("cleanUp");// save();
470 473
471 Config cfg ( "TextEdit" ); 474 Config cfg ( "TextEdit" );
472 cfg. setGroup ( "Font" ); 475 cfg. setGroup ( "Font" );
@@ -477,28 +480,31 @@ void TextEdit::cleanUp() {
477 cfg.writeEntry ( "Italic", f. italic ( )); 480 cfg.writeEntry ( "Italic", f. italic ( ));
478 481
479 cfg.setGroup ( "View" ); 482 cfg.setGroup ( "View" );
480 cfg.writeEntry ( "Wrap", editor-> wordWrap ( ) == QMultiLineEdit::WidgetWidth ); 483 cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth );
481 cfg.writeEntry ( "FileView", viewSelection ); 484 cfg.writeEntry ( "FileView", viewSelection );
482 485
483 cfg.writeEntry ( "PromptExit", promptExit ); 486 cfg.writeEntry ( "PromptExit", promptExit );
484 cfg.writeEntry ( "OpenDesktop", openDesktop ); 487 cfg.writeEntry ( "OpenDesktop", openDesktop );
485 cfg.writeEntry ( "FilePermissions", filePerms ); 488 cfg.writeEntry ( "FilePermissions", filePerms );
486 cfg.writeEntry ( "SearchBar", useSearchBar ); 489 cfg.writeEntry ( "SearchBar", useSearchBar );
490 cfg.writeEntry ( "startNew", startWithNew );
491
487} 492}
488 493
489 494
490void TextEdit::accept() { 495void TextEdit::accept() {
491 if( edited1) 496// qDebug("accept");
492 saveAs(); 497 if( edited1)
493 exit(0); 498 saveAs();
499 qApp->quit();
494} 500}
495 501
496void TextEdit::zoomIn() { 502void TextEdit::zoomIn() {
497 setFontSize(editor->font().pointSize()+1,FALSE); 503 setFontSize(editor->font().pointSize()+1,false);
498} 504}
499 505
500void TextEdit::zoomOut() { 506void TextEdit::zoomOut() {
501 setFontSize(editor->font().pointSize()-1,TRUE); 507 setFontSize(editor->font().pointSize()-1,true);
502} 508}
503 509
504 510
@@ -566,10 +572,6 @@ void TextEdit::fileNew() {
566} 572}
567 573
568void TextEdit::fileOpen() { 574void TextEdit::fileOpen() {
569 Config cfg("TextEdit");
570 cfg.setGroup("View");
571 // bool b=FALSE;
572
573 QMap<QString, QStringList> map; 575 QMap<QString, QStringList> map;
574 map.insert(tr("All"), QStringList() ); 576 map.insert(tr("All"), QStringList() );
575 QStringList text; 577 QStringList text;
@@ -577,10 +579,13 @@ void TextEdit::fileOpen() {
577 map.insert(tr("Text"), text ); 579 map.insert(tr("Text"), text );
578 text << "*"; 580 text << "*";
579 map.insert(tr("All"), text ); 581 map.insert(tr("All"), text );
580 QString str = OFileDialog::getOpenFileName( 2, QPEApplication::documentDir(), QString::null, map); 582 QString str = OFileDialog::getOpenFileName( 2,
583 QPEApplication::documentDir(),
584 QString::null, map);
581 if(!str.isEmpty() ) 585 if(!str.isEmpty() )
582 openFile( str ); 586 openFile( str );
583 587 else
588 updateCaption();
584} 589}
585 590
586void TextEdit::doSearchBar() { 591void TextEdit::doSearchBar() {
@@ -634,30 +639,20 @@ void TextEdit::editPaste() {
634 639
635void TextEdit::editFind() { 640void TextEdit::editFind() {
636 searchBar->show(); 641 searchBar->show();
637 searchVisible = TRUE;
638 searchEdit->setFocus(); 642 searchEdit->setFocus();
639// Config cfg("TextEdit");
640// cfg.setGroup("View");
641// cfg.writeEntry("SearchBar","Opened");
642
643} 643}
644 644
645void TextEdit::findNext() { 645void TextEdit::findNext() {
646 editor->find( searchEdit->text(), FALSE, FALSE ); 646 editor->find( searchEdit->text(), false, false );
647 647
648} 648}
649 649
650void TextEdit::findClose() { 650void TextEdit::findClose() {
651 searchVisible = FALSE;
652 searchBar->hide(); 651 searchBar->hide();
653// Config cfg("TextEdit");
654// cfg.setGroup("View");
655// cfg.writeEntry("SearchBar","Closed");
656// cfg.write();
657} 652}
658 653
659void TextEdit::search() { 654void TextEdit::search() {
660 editor->find( searchEdit->text(), FALSE, FALSE ); 655 editor->find( searchEdit->text(), false, false );
661} 656}
662 657
663void TextEdit::newFile( const DocLnk &f ) { 658void TextEdit::newFile( const DocLnk &f ) {
@@ -670,7 +665,7 @@ void TextEdit::newFile( const DocLnk &f ) {
670 currentFileName = "Unnamed"; 665 currentFileName = "Unnamed";
671 qDebug("newFile "+currentFileName); 666 qDebug("newFile "+currentFileName);
672 updateCaption( currentFileName); 667 updateCaption( currentFileName);
673// editor->setEdited( FALSE); 668// editor->setEdited( false);
674} 669}
675 670
676void TextEdit::openDotFile( const QString &f ) { 671void TextEdit::openDotFile( const QString &f ) {
@@ -686,9 +681,9 @@ void TextEdit::openDotFile( const QString &f ) {
686 txt+=t.readLine(); 681 txt+=t.readLine();
687 } 682 }
688 editor->setText(txt); 683 editor->setText(txt);
689 editor->setEdited( FALSE); 684 editor->setEdited( false);
690 edited1=FALSE; 685 edited1=false;
691 edited=FALSE; 686 edited=false;
692 687
693 688
694 } 689 }
@@ -699,8 +694,8 @@ void TextEdit::openFile( const QString &f ) {
699 qDebug("filename is "+ f); 694 qDebug("filename is "+ f);
700 QString filer; 695 QString filer;
701 QFileInfo fi( f); 696 QFileInfo fi( f);
702// bFromDocView = TRUE; 697// bFromDocView = true;
703 if(f.find(".desktop",0,TRUE) != -1 && !openDesktop) { 698 if(f.find(".desktop",0,true) != -1 && !openDesktop) {
704 switch ( QMessageBox::warning(this,tr("Text Editor"), 699 switch ( QMessageBox::warning(this,tr("Text Editor"),
705 tr("Text Editor has detected<BR>you selected a <B>.desktop</B> 700 tr("Text Editor has detected<BR>you selected a <B>.desktop</B>
706file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), 701file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"),
@@ -744,7 +739,7 @@ file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"),
744 739
745void TextEdit::openFile( const DocLnk &f ) { 740void TextEdit::openFile( const DocLnk &f ) {
746// clear(); 741// clear();
747// bFromDocView = TRUE; 742// bFromDocView = true;
748 FileManager fm; 743 FileManager fm;
749 QString txt; 744 QString txt;
750 currentFileName=f.file(); 745 currentFileName=f.file();
@@ -758,23 +753,21 @@ void TextEdit::openFile( const DocLnk &f ) {
758 delete doc; 753 delete doc;
759 doc = new DocLnk(f); 754 doc = new DocLnk(f);
760 editor->setText(txt); 755 editor->setText(txt);
761 editor->setEdited( FALSE); 756 editor->setEdited( false);
762 edited1=FALSE; 757 edited1=false;
763 edited=FALSE; 758 edited=false;
764 759
765 doc->setName(currentFileName); 760 doc->setName(currentFileName);
766 updateCaption(); 761 updateCaption();
767} 762}
768 763
769void TextEdit::showEditTools() { 764void TextEdit::showEditTools() {
770// if ( !doc )
771// close();
772// clear();
773 menu->show(); 765 menu->show();
774 editBar->show(); 766 editBar->show();
775 if ( searchVisible ) 767 if(!useSearchBar)
768 searchBar->hide();
769 else
776 searchBar->show(); 770 searchBar->show();
777// updateCaption();
778 setWState (WState_Reserved1 ); 771 setWState (WState_Reserved1 );
779} 772}
780 773
@@ -816,9 +809,9 @@ bool TextEdit::save() {
816 } 809 }
817 810
818 } 811 }
819 editor->setEdited( FALSE); 812 editor->setEdited( false);
820 edited1=FALSE; 813 edited1=false;
821 edited=FALSE; 814 edited=false;
822 if(caption().left(1)=="*") 815 if(caption().left(1)=="*")
823 setCaption(caption().right(caption().length()-1)); 816 setCaption(caption().right(caption().length()-1));
824 817
@@ -835,16 +828,16 @@ bool TextEdit::save() {
835bool TextEdit::saveAs() { 828bool TextEdit::saveAs() {
836 qDebug("saveAsFile " + currentFileName); 829 qDebug("saveAsFile " + currentFileName);
837 // case of nothing to save... 830 // case of nothing to save...
838 if ( !doc ) { 831// if ( !doc && !currentFileName.isEmpty()) {
839//|| !bFromDocView) 832// //|| !bFromDocView)
840 qDebug("no doc"); 833// qDebug("no doc");
841 return true; 834// return true;
842 } 835// }
843 if ( !editor->edited() ) { 836// if ( !editor->edited() ) {
844 delete doc; 837// delete doc;
845 doc = 0; 838// doc = 0;
846 return true; 839// return true;
847 } 840// }
848 841
849 QString rt = editor->text(); 842 QString rt = editor->text();
850 qDebug(currentFileName); 843 qDebug(currentFileName);
@@ -852,28 +845,31 @@ bool TextEdit::saveAs() {
852 if( currentFileName.isEmpty() 845 if( currentFileName.isEmpty()
853 || currentFileName == tr("Unnamed") 846 || currentFileName == tr("Unnamed")
854 || currentFileName == tr("Text Editor")) { 847 || currentFileName == tr("Text Editor")) {
855// qDebug("do silly TT filename thing"); 848 qDebug("do silly TT filename thing");
856 if ( doc->name().isEmpty() ) { 849// if ( doc && doc->name().isEmpty() ) {
857 QString pt = rt.simplifyWhiteSpace(); 850 QString pt = rt.simplifyWhiteSpace();
858 int i = pt.find( ' ' ); 851 int i = pt.find( ' ' );
859 QString docname = pt; 852 QString docname = pt;
860 if ( i > 0 ) 853 if ( i > 0 )
861 docname = pt.left( i ); 854 docname = pt.left( i );
862 // remove "." at the beginning 855 // remove "." at the beginning
863 while( docname.startsWith( "." ) ) 856 while( docname.startsWith( "." ) )
864 docname = docname.mid( 1 ); 857 docname = docname.mid( 1 );
865 docname.replace( QRegExp("/"), "_" ); 858 docname.replace( QRegExp("/"), "_" );
866 // cut the length. filenames longer than that 859 // cut the length. filenames longer than that
867 //don't make sense and something goes wrong when they get too long. 860 //don't make sense and something goes wrong when they get too long.
868 if ( docname.length() > 40 ) 861 if ( docname.length() > 40 )
869 docname = docname.left(40); 862 docname = docname.left(40);
870 if ( docname.isEmpty() ) 863 if ( docname.isEmpty() )
871 docname = tr("Unnamed"); 864 docname = tr("Unnamed");
872 doc->setName(docname); 865 if(doc) doc->setName(docname);
873 currentFileName=docname; 866 currentFileName=docname;
874 } 867// }
868// else
869// qDebug("hmmmmmm");
875 } 870 }
876 871
872
877 QMap<QString, QStringList> map; 873 QMap<QString, QStringList> map;
878 map.insert(tr("All"), QStringList() ); 874 map.insert(tr("All"), QStringList() );
879 QStringList text; 875 QStringList text;
@@ -881,18 +877,23 @@ bool TextEdit::saveAs() {
881 map.insert(tr("Text"), text ); 877 map.insert(tr("Text"), text );
882 text << "*"; 878 text << "*";
883 map.insert(tr("All"), text ); 879 map.insert(tr("All"), text );
884// if(currentFileName 880
881 QFileInfo cuFi( currentFileName);
882 QString filee = cuFi.fileName();
883 QString dire = cuFi.dirPath();
884 if(dire==".")
885 dire = QPEApplication::documentDir();
885 QString str = OFileDialog::getSaveFileName( 2, 886 QString str = OFileDialog::getSaveFileName( 2,
886 QPEApplication::documentDir(), 887 dire,
887 currentFileName, map); 888 filee, map);
888 889
889 if(!str.isEmpty() ) { 890 if(!str.isEmpty()) {
890 QString fileNm=str; 891 QString fileNm=str;
891 892
892 qDebug("saving filename "+fileNm); 893 qDebug("saving filename "+fileNm);
893 QFileInfo fi(fileNm); 894 QFileInfo fi(fileNm);
894 currentFileName=fi.fileName(); 895 currentFileName=fi.fileName();
895 if(doc) { 896 if(doc)
896// QString file = doc->file(); 897// QString file = doc->file();
897// doc->removeFiles(); 898// doc->removeFiles();
898 delete doc; 899 delete doc;
@@ -901,7 +902,7 @@ bool TextEdit::saveAs() {
901 nf.setFile( fileNm); 902 nf.setFile( fileNm);
902 doc = new DocLnk(nf); 903 doc = new DocLnk(nf);
903// editor->setText(rt); 904// editor->setText(rt);
904// qDebug("openFile doclnk "+currentFileName); 905 qDebug("Saving file as "+currentFileName);
905 doc->setName( currentFileName); 906 doc->setName( currentFileName);
906 updateCaption( currentFileName); 907 updateCaption( currentFileName);
907 908
@@ -921,7 +922,7 @@ bool TextEdit::saveAs() {
921 if( filePerm) 922 if( filePerm)
922 delete filePerm; 923 delete filePerm;
923 } 924 }
924 } 925// }
925 editor->setEdited( false); 926 editor->setEdited( false);
926 edited1 = false; 927 edited1 = false;
927 edited = false; 928 edited = false;
@@ -968,11 +969,11 @@ void TextEdit::setDocument(const QString& fileref) {
968// openDotFile(currentFileName); 969// openDotFile(currentFileName);
969 } else { 970 } else {
970 qDebug("setDoc open"); 971 qDebug("setDoc open");
971 bFromDocView = TRUE; 972 bFromDocView = true;
972 openFile(fileref); 973 openFile(fileref);
973 editor->setEdited(TRUE); 974 editor->setEdited(true);
974 edited1=FALSE; 975 edited1=false;
975 edited=TRUE; 976 edited=true;
976 977
977// doSearchBar(); 978// doSearchBar();
978 } 979 }
@@ -980,11 +981,6 @@ void TextEdit::setDocument(const QString& fileref) {
980 updateCaption( currentFileName); 981 updateCaption( currentFileName);
981} 982}
982 983
983void TextEdit::closeEvent( QCloseEvent *e ) {
984 bFromDocView = FALSE;
985 e->accept();
986}
987
988void TextEdit::changeFont() { 984void TextEdit::changeFont() {
989 QDialog *d = new QDialog ( this, "FontDialog", true ); 985 QDialog *d = new QDialog ( this, "FontDialog", true );
990 d-> setCaption ( tr( "Choose font" )); 986 d-> setCaption ( tr( "Choose font" ));
@@ -1016,24 +1012,19 @@ void TextEdit::editDelete() {
1016} 1012}
1017 1013
1018void TextEdit::changeStartConfig( bool b ) { 1014void TextEdit::changeStartConfig( bool b ) {
1019 1015 startWithNew=b;
1020 Config cfg("TextEdit"); 1016 Config cfg("TextEdit");
1021 cfg.setGroup("View"); 1017 cfg.setGroup("View");
1022 if(b) { 1018 cfg.writeEntry("startNew",b);
1023 qDebug("bool");
1024 cfg.writeEntry("startNew","TRUE");
1025 } else {
1026 cfg.writeEntry("startNew","FALSE");
1027 }
1028 update(); 1019 update();
1029} 1020}
1030 1021
1031void TextEdit::editorChanged() { 1022void TextEdit::editorChanged() {
1032 if(editor->edited() && edited && !edited1) { 1023 if(editor->edited() && edited && !edited1) {
1033 setCaption( "*"+caption()); 1024 setCaption( "*"+caption());
1034 edited1=TRUE; 1025 edited1=true;
1035 } 1026 }
1036 edited=TRUE; 1027 edited=true;
1037} 1028}
1038 1029
1039void TextEdit::receive(const QCString&msg, const QByteArray&) { 1030void TextEdit::receive(const QCString&msg, const QByteArray&) {
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index a95e742..bb7d693 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -65,7 +65,6 @@ public slots:
65 void editorChanged(); 65 void editorChanged();
66void receive(const QCString&, const QByteArray&); 66void receive(const QCString&, const QByteArray&);
67protected: 67protected:
68 bool fileIs, useAdvancedFeatures, promptExit, openDesktop, filePerms, useSearchBar;
69 void closeEvent( QCloseEvent *e ); 68 void closeEvent( QCloseEvent *e );
70 void doSearchBar(); 69 void doSearchBar();
71private slots: 70private slots:
@@ -114,7 +113,6 @@ private:
114 void clear(); 113 void clear();
115 void updateCaption( const QString &name=QString::null ); 114 void updateCaption( const QString &name=QString::null );
116 void setFontSize(int sz, bool round_down_not_up); 115 void setFontSize(int sz, bool round_down_not_up);
117
118private: 116private:
119// fileSaver *fileSaveDlg; 117// fileSaver *fileSaveDlg;
120// fileBrowser *browseForFiles; 118// fileBrowser *browseForFiles;
@@ -123,7 +121,7 @@ private:
123 QPopupMenu *advancedMenu; 121 QPopupMenu *advancedMenu;
124 QLineEdit *searchEdit; 122 QLineEdit *searchEdit;
125 DocLnk *doc; 123 DocLnk *doc;
126 bool searchVisible; 124 bool fileIs, useAdvancedFeatures, promptExit, openDesktop, filePerms, useSearchBar, startWithNew;
127 bool bFromDocView; 125 bool bFromDocView;
128 int viewSelection; 126 int viewSelection;
129 QAction *zin, *zout; 127 QAction *zin, *zout;