summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-02-19 00:32:58 (UTC)
committer llornkcor <llornkcor>2002-02-19 00:32:58 (UTC)
commit2308c4db692821721bbe82f93fd60f275f4cccdc (patch) (unidiff)
treef037b4f4fd40201e5328132e643dca83bdf12651
parent7e308434f08fe6e8257a5c6b11a62e3ee3934d3b (diff)
downloadopie-2308c4db692821721bbe82f93fd60f275f4cccdc.zip
opie-2308c4db692821721bbe82f93fd60f275f4cccdc.tar.gz
opie-2308c4db692821721bbe82f93fd60f275f4cccdc.tar.bz2
fixed several silly bugs having to do with Doclnk stuff..
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp11
-rw-r--r--core/apps/textedit/fileSaver.cpp24
-rw-r--r--core/apps/textedit/fileSaver.h5
-rw-r--r--core/apps/textedit/textedit.cpp102
-rw-r--r--core/apps/textedit/textedit.h7
5 files changed, 112 insertions, 37 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
index 82ccf2c..bb420e6 100644
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -105,17 +105,17 @@ void fileBrowser::listDoubleClicked(QListViewItem *selectedItem)
105{ 105{
106} 106}
107 107
108// you may want to switch these 2 functions. I like single clicks 108// you may want to switch these 2 functions. I like single clicks
109void fileBrowser::listClicked(QListViewItem *selectedItem) 109void fileBrowser::listClicked(QListViewItem *selectedItem)
110{ 110{
111 QString strItem=selectedItem->text(0); 111 QString strItem=selectedItem->text(0);
112 QString strSize=selectedItem->text(1); 112 QString strSize=selectedItem->text(1);
113// qDebug("strItem is "+strItem); 113// qDebug("strItem is "+strItem);
114 strSize.stripWhiteSpace(); 114 strSize.stripWhiteSpace();
115// qDebug(strSize); 115// qDebug(strSize);
116 116
117 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 117 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
118 // is symlink 118 // is symlink
119 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); 119 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
120// qDebug("strItem symlink is "+strItem2); 120// qDebug("strItem symlink is "+strItem2);
121 if(QDir(strItem2).exists() ) { 121 if(QDir(strItem2).exists() ) {
@@ -132,29 +132,32 @@ void fileBrowser::listClicked(QListViewItem *selectedItem)
132 } else { 132 } else {
133 currentDir.cdUp(); 133 currentDir.cdUp();
134 populateList(); 134 populateList();
135 } 135 }
136 if(QDir(strItem).exists()){ 136 if(QDir(strItem).exists()){
137 currentDir.cd(strItem, TRUE); 137 currentDir.cd(strItem, TRUE);
138 populateList(); 138 populateList();
139 } 139 }
140 } else 140 } else {
141 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
141 if( QFile::exists(strItem ) ) { 142 if( QFile::exists(strItem ) ) {
142// qDebug("We found our files!!"); 143//currentDir.canonicalPath()
144 qDebug("We found our files!!"+strItem);
143 OnOK(); 145 OnOK();
146 }
144 } //end not symlink 147 } //end not symlink
145 chdir(strItem.latin1()); 148 chdir(strItem.latin1());
146 } 149 }
147} 150}
148 151
149void fileBrowser::OnOK() 152void fileBrowser::OnOK()
150{ 153{
151 QListViewItemIterator it1( ListView); 154 QListViewItemIterator it1( ListView);
152 for ( ; it1.current(); ++it1 ) { 155 for ( ; it1.current(); ++it1 ) {
153 if ( it1.current()->isSelected() ) { 156 if ( it1.current()->isSelected() ) {
154 selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); 157 selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0));
155// qDebug("selected filename is "+selectedFileName); 158 qDebug("selected filename is "+selectedFileName);
156 fileList.append( selectedFileName ); 159 fileList.append( selectedFileName );
157 } 160 }
158 } 161 }
159 accept(); 162 accept();
160} 163}
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp
index 88608cc..af51fc3 100644
--- a/core/apps/textedit/fileSaver.cpp
+++ b/core/apps/textedit/fileSaver.cpp
@@ -45,17 +45,17 @@ fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl
45 ListView->setColumnWidth(1,59); 45 ListView->setColumnWidth(1,59);
46// ListView->setMultiSelection(true); 46// ListView->setMultiSelection(true);
47// ListView->setSelectionMode(QListView::Extended); 47// ListView->setSelectionMode(QListView::Extended);
48 48
49 ListView->setAllColumnsShowFocus( TRUE ); 49 ListView->setAllColumnsShowFocus( TRUE );
50 ListView->setGeometry( QRect( 10, 35, 220, 160 ) ); 50 ListView->setGeometry( QRect( 10, 35, 220, 160 ) );
51 51
52 fileEdit= new QLineEdit(this); 52 fileEdit= new QLineEdit(this);
53 fileEdit->setGeometry( QRect( 10, 230, 200, 25)); 53 fileEdit->setGeometry( QRect( 10, 200, 200, 22));
54 54
55 fileEdit->setText( tmpFileName); 55 fileEdit->setText( tmpFileName);
56 56
57 // signals and slots connections 57 // signals and slots connections
58 connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); 58 connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) );
59 connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); 59 connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
60 60
61// tmpFileName=fi.FilePath(); 61// tmpFileName=fi.FilePath();
@@ -142,31 +142,41 @@ void fileSaver::listClicked(QListViewItem *selectedItem)
142 } else { 142 } else {
143 currentDir.cdUp(); 143 currentDir.cdUp();
144 populateList(); 144 populateList();
145 } 145 }
146 if(QDir(strItem).exists()){ 146 if(QDir(strItem).exists()){
147 currentDir.cd(strItem, TRUE); 147 currentDir.cd(strItem, TRUE);
148 populateList(); 148 populateList();
149 } 149 }
150 } // else 150 } // else
151// if( QFile::exists(strItem ) ) { 151// if( QFile::exists(strItem ) ) {
152// qDebug("We found our files!!"); 152// qDebug("We found our files!!");
153 153
154// OnOK(); 154// OnOK();
155 } //end not symlink 155 } //end not symlink
156 chdir(strItem.latin1()); 156 chdir(strItem.latin1());
157 157
158 158
159} 159}
160 160
161 161
162void fileSaver::OnOK() 162void fileSaver::closeEvent( QCloseEvent *e )
163{ 163{
164// reject(); 164 if(e->isAccepted()) {
165 e->accept();
166 } else {
167 qDebug("not accepted");
168 done(-1);
169 }
165} 170}
166 171
167void fileSaver::accept() { 172void fileSaver::accept() {
168 selectedFileName = fileEdit->text(); 173 selectedFileName = fileEdit->text();
169 selectedFileName = currentDir.canonicalPath()+ selectedFileName; 174 QString path = currentDir.canonicalPath()+"/" + selectedFileName;
170 qDebug("goint to save "+selectedFileName); 175 if( path.find("//",0,TRUE) ==-1 ) {
171 reject(); 176 selectedFileName = path;
177 } else {
178 selectedFileName = currentDir.canonicalPath()+selectedFileName;
179 }
180 qDebug("going to save "+selectedFileName);
181 done(1);
172} 182}
diff --git a/core/apps/textedit/fileSaver.h b/core/apps/textedit/fileSaver.h
index f496270..4a38a65 100644
--- a/core/apps/textedit/fileSaver.h
+++ b/core/apps/textedit/fileSaver.h
@@ -52,20 +52,21 @@ public:
52 QStringList fileList; 52 QStringList fileList;
53 53
54QListViewItem * item; 54QListViewItem * item;
55public slots: 55public slots:
56 56
57private: 57private:
58 58
59private slots: 59private slots:
60 void accept(); 60 void accept();
61 void upDir(); 61 void upDir();
62 void listDoubleClicked(QListViewItem *); 62 void listDoubleClicked(QListViewItem *);
63 void listClicked(QListViewItem *); 63 void listClicked(QListViewItem *);
64 void OnOK(); 64 void closeEvent( QCloseEvent * );
65
65protected slots: 66protected slots:
66 67
67protected: 68protected:
68 69
69}; 70};
70 71
71#endif // FILESAVER_H 72#endif // FILESAVER_H
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 8004771..e41c69d 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -294,16 +294,17 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
294 a->addTo( edit ); 294 a->addTo( edit );
295 295
296 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 296 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
297 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); 297 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) );
298 edit->insertSeparator(); 298 edit->insertSeparator();
299 a->addTo( bar ); 299 a->addTo( bar );
300 a->addTo( edit ); 300 a->addTo( edit );
301 301
302
302 int defsize; 303 int defsize;
303 bool defb, defi, wrap; 304 bool defb, defi, wrap;
304 305
305 Config cfg("TextEdit"); 306 Config cfg("TextEdit");
306 cfg.setGroup("View"); 307 cfg.setGroup("View");
307 defsize = cfg.readNumEntry("FontSize",10); 308 defsize = cfg.readNumEntry("FontSize",10);
308 defb = cfg.readBoolEntry("Bold",FALSE); 309 defb = cfg.readBoolEntry("Bold",FALSE);
309 defi = cfg.readBoolEntry("Italic",FALSE); 310 defi = cfg.readBoolEntry("Italic",FALSE);
@@ -363,16 +364,21 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
363 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 364 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
364 a->addTo( searchBar ); 365 a->addTo( searchBar );
365 a->addTo( edit ); 366 a->addTo( edit );
366 367
367 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 368 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
368 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 369 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
369 a->addTo( searchBar ); 370 a->addTo( searchBar );
370 371
372 edit->insertSeparator();
373 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "delete" ), QString::null, 0, this, 0 );
374 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) );
375 a->addTo( edit );
376
371 searchBar->hide(); 377 searchBar->hide();
372 378
373 editorStack = new QWidgetStack( this ); 379 editorStack = new QWidgetStack( this );
374 setCentralWidget( editorStack ); 380 setCentralWidget( editorStack );
375 381
376 searchVisible = FALSE; 382 searchVisible = FALSE;
377 383
378 fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //buggy 384 fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //buggy
@@ -404,17 +410,17 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
404 wa->setOn(wrap); 410 wa->setOn(wrap);
405 updateCaption(); 411 updateCaption();
406 412
407 fileNew(); 413 fileNew();
408} 414}
409 415
410TextEdit::~TextEdit() 416TextEdit::~TextEdit()
411{ 417{
412 saveAs(); 418// saveAs();
413 419
414 Config cfg("TextEdit"); 420 Config cfg("TextEdit");
415 cfg.setGroup("View"); 421 cfg.setGroup("View");
416 QFont f = editor->font(); 422 QFont f = editor->font();
417 cfg.writeEntry("FontSize",f.pointSize()); 423 cfg.writeEntry("FontSize",f.pointSize());
418 cfg.writeEntry("Bold",f.bold()); 424 cfg.writeEntry("Bold",f.bold());
419 cfg.writeEntry("Italic",f.italic()); 425 cfg.writeEntry("Italic",f.italic());
420 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); 426 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth);
@@ -504,24 +510,23 @@ void TextEdit::fileOpen()
504// } 510// }
505// } 511// }
506 menu->hide(); 512 menu->hide();
507 editBar->hide(); 513 editBar->hide();
508 searchBar->hide(); 514 searchBar->hide();
509 clearWState (WState_Reserved1 ); 515 clearWState (WState_Reserved1 );
510 editorStack->raiseWidget( fileSelector ); 516 editorStack->raiseWidget( fileSelector );
511 fileSelector->reread(); 517 fileSelector->reread();
512 updateCaption(currentFileName); 518 updateCaption();
513} 519}
514 520
515void TextEdit::newFileOpen() 521void TextEdit::newFileOpen()
516{ 522{
517 fileBrowser *browseForFiles;
518 browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*"); 523 browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*");
519 if( browseForFiles->exec()!= 0 ) { 524 if( browseForFiles->exec() != -1 ) {
520 QString selFile= browseForFiles->selectedFileName; 525 QString selFile= browseForFiles->selectedFileName;
521 QStringList fileList=browseForFiles->fileList; 526 QStringList fileList=browseForFiles->fileList;
522 qDebug(selFile); 527 qDebug(selFile);
523 QStringList::ConstIterator f; 528 QStringList::ConstIterator f;
524 QString fileTemp; 529 QString fileTemp;
525 for ( f = fileList.begin(); f != fileList.end(); f++ ) { 530 for ( f = fileList.begin(); f != fileList.end(); f++ ) {
526 fileTemp = *f; 531 fileTemp = *f;
527 fileTemp.right( fileTemp.length()-5); 532 fileTemp.right( fileTemp.length()-5);
@@ -529,17 +534,17 @@ void TextEdit::newFileOpen()
529 if( fileName != "Unnamed" || fileName != "Empty Text" ) { 534 if( fileName != "Unnamed" || fileName != "Empty Text" ) {
530 currentFileName = fileName; 535 currentFileName = fileName;
531// qDebug("please open "+currentFileName); 536// qDebug("please open "+currentFileName);
532 openFile(fileName ); 537 openFile(fileName );
533 } 538 }
534 } 539 }
535 } 540 }
536 delete browseForFiles; 541 delete browseForFiles;
537 542 editor->setEdited( true );
538} 543}
539 544
540#if 0 545#if 0
541void TextEdit::slotFind() 546void TextEdit::slotFind()
542{ 547{
543 FindDialog frmFind( "Text Editor", this ); 548 FindDialog frmFind( "Text Editor", this );
544 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 549 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
545 editor, SLOT(slotDoFind( const QString&,bool,bool))); 550 editor, SLOT(slotDoFind( const QString&,bool,bool)));
@@ -612,55 +617,63 @@ void TextEdit::newFile( const DocLnk &f )
612{ 617{
613 DocLnk nf = f; 618 DocLnk nf = f;
614 nf.setType("text/plain"); 619 nf.setType("text/plain");
615 clear(); 620 clear();
616 editorStack->raiseWidget( editor ); 621 editorStack->raiseWidget( editor );
617 setWState (WState_Reserved1 ); 622 setWState (WState_Reserved1 );
618 editor->setFocus(); 623 editor->setFocus();
619 doc = new DocLnk(nf); 624 doc = new DocLnk(nf);
625 qDebug("newFile "+currentFileName);
620 updateCaption(currentFileName); 626 updateCaption(currentFileName);
621} 627}
622 628
623void TextEdit::openFile( const QString &f ) 629void TextEdit::openFile( const QString &f )
624{ 630{
625 bFromDocView = TRUE; 631 bFromDocView = TRUE;
626 DocLnk nf; 632 DocLnk nf;
627 nf.setType("text/plain"); 633 nf.setType("text/plain");
628 nf.setFile(f); 634 nf.setFile(f);
635 currentFileName=f;
636 qDebug("openFile string"+currentFileName);
637
629 openFile(nf); 638 openFile(nf);
630 showEditTools(); 639 showEditTools();
631 // Show filename in caption 640 // Show filename in caption
632 QString name = f; 641 QString name = f;
633 int sep = name.findRev( '/' ); 642 int sep = name.findRev( '/' );
634 if ( sep > 0 ) 643 if ( sep > 0 )
635 name = name.mid( sep+1 ); 644 name = name.mid( sep+1 );
636 updateCaption( name ); 645 updateCaption( name );
637} 646}
638 647
639void TextEdit::openFile( const DocLnk &f ) 648void TextEdit::openFile( const DocLnk &f )
640{ 649{
641// clear(); 650// clear();
642 bFromDocView = TRUE; 651 bFromDocView = TRUE;
643 FileManager fm; 652 FileManager fm;
644 QString txt; 653 QString txt;
654 currentFileName=f.name();
655 qDebug("openFile doclnk " + currentFileName);
645 if ( !fm.loadFile( f, txt ) ) { 656 if ( !fm.loadFile( f, txt ) ) {
646 // ####### could be a new file 657 // ####### could be a new file
647 qDebug( "Cannot open file" ); 658 qDebug( "Cannot open file" );
648 659
649 //return; 660 //return;
650 } 661 }
651 662
652 fileNew(); 663 fileNew();
653 if ( doc ) 664 if ( doc )
654 delete doc; 665 delete doc;
655 doc = new DocLnk(f); 666 doc = new DocLnk(f);
656 editor->setText(txt); 667 editor->setText(txt);
657 editor->setEdited(FALSE); 668 editor->setEdited( false);
658 updateCaption(currentFileName); 669 qDebug("openFile doclnk "+currentFileName);
670 doc->setName(currentFileName);
671 updateCaption();
659} 672}
660 673
661void TextEdit::showEditTools() 674void TextEdit::showEditTools()
662{ 675{
663// if ( !doc ) 676// if ( !doc )
664// close(); 677// close();
665// clear(); 678// clear();
666 fileSelector->hide(); 679 fileSelector->hide();
@@ -668,84 +681,111 @@ void TextEdit::showEditTools()
668 editBar->show(); 681 editBar->show();
669 if ( searchVisible ) 682 if ( searchVisible )
670 searchBar->show(); 683 searchBar->show();
671// updateCaption(); 684// updateCaption();
672 editorStack->raiseWidget( editor ); 685 editorStack->raiseWidget( editor );
673 setWState (WState_Reserved1 ); 686 setWState (WState_Reserved1 );
674} 687}
675 688
689/*!
690 unprompted save */
676bool TextEdit::save() 691bool TextEdit::save()
677{ 692{
693 qDebug("saveFile "+currentFileName);
694
678 QString rt = editor->text(); 695 QString rt = editor->text();
679 doc->setName( currentFileName); 696 doc->setName( currentFileName);
680 FileManager fm; 697 FileManager fm;
681 if ( !fm.saveFile( *doc, rt ) ) { 698 if ( !fm.saveFile( *doc, rt ) ) {
682 return false; 699 return false;
683 } 700 }
684 delete doc; 701// if(doc)
685 doc = 0; 702// delete doc;
703// doc = 0;
686 editor->setEdited( false ); 704 editor->setEdited( false );
687 return true; 705 return true;
688
689} 706}
690 707
708/*!
709 prompted save */
691bool TextEdit::saveAs() 710bool TextEdit::saveAs()
692{ 711{
693 // case of nothing to save... 712 qDebug("saveAsFile "+currentFileName);
694 if ( !doc || !bFromDocView) 713
695 return true; 714 // case of nothing to save... /// there's always something to save
715// if ( !doc )//|| !bFromDocView)
716// {
717// qDebug("no doc");
718// return true;
719// }
696 if ( !editor->edited() ) { 720 if ( !editor->edited() ) {
697 delete doc; 721 delete doc;
698 doc = 0; 722 doc = 0;
699 return true; 723 return true;
700 } 724 }
701 725
702 QString rt = editor->text(); 726 QString rt = editor->text();
703 qDebug(currentFileName); 727 qDebug(currentFileName);
704 728
705 if( currentFileName.isEmpty() || currentFileName == "Unnamed") { 729 if( currentFileName.isEmpty() || currentFileName == "Unnamed") {
706 730 qDebug("do silly TT filename thing");
707 if ( doc->name().isEmpty() ) { 731 if ( doc->name().isEmpty() ) {
708 QString pt = rt.simplifyWhiteSpace(); 732 QString pt = rt.simplifyWhiteSpace();
709 int i = pt.find( ' ' ); 733 int i = pt.find( ' ' );
710 QString docname = pt; 734 QString docname = pt;
711 if ( i > 0 ) 735 if ( i > 0 )
712 docname = pt.left( i ); 736 docname = pt.left( i );
713 // remove "." at the beginning 737 // remove "." at the beginning
714 while( docname.startsWith( "." ) ) 738 while( docname.startsWith( "." ) )
715 docname = docname.mid( 1 ); 739 docname = docname.mid( 1 );
716 docname.replace( QRegExp("/"), "_" ); 740 docname.replace( QRegExp("/"), "_" );
717 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. 741 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long.
718 if ( docname.length() > 40 ) 742 if ( docname.length() > 40 )
719 docname = docname.left(40); 743 docname = docname.left(40);
720 if ( docname.isEmpty() ) 744 if ( docname.isEmpty() )
721 docname = "Empty Text"; 745 docname = "Unnamed";
722 doc->setName(docname); 746 doc->setName(docname);
723 currentFileName=docname; 747 currentFileName=docname;
724 } 748 }
725 } 749 }
726 750
727 fileSaver *fileSaveDlg;
728 fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName); 751 fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName);
729 if( fileSaveDlg->exec() != 0 ) { 752 qDebug("wanna save filename "+currentFileName);
753 fileSaveDlg->exec();
754 if( fileSaveDlg->result() == 1 ) {
730 QString fileNm=fileSaveDlg->selectedFileName; 755 QString fileNm=fileSaveDlg->selectedFileName;
731 qDebug("save filename "+fileNm); 756 qDebug("saving filename "+fileNm);
732 doc->setName(fileNm); 757 QFileInfo fi(fileNm);
733 updateCaption(fileNm); 758 currentFileName=fi.fileName();
759 if(doc) {
760 qDebug("doclnk exists");
761// QString file = doc->file();
762// doc->removeFiles();
763 delete doc;
764 DocLnk nf;
765 nf.setType("text/plain");
766 nf.setFile( fileNm);
767 doc = new DocLnk(nf);
768// editor->setText(rt);
769 qDebug("openFile doclnk "+currentFileName);
734 } 770 }
735 delete fileSaveDlg; 771 doc->setName( currentFileName);
736 772 updateCaption( currentFileName);
773
737 FileManager fm; 774 FileManager fm;
738 if ( !fm.saveFile( *doc, rt ) ) { 775 if ( !fm.saveFile( *doc, rt ) ) {
739 return false; 776 return false;
740 } 777 }
741 delete doc; 778// delete doc;
742 doc = 0; 779// doc = 0;
743 editor->setEdited( false ); 780 editor->setEdited( false );
781 }
782 if(fileSaveDlg)
783 delete fileSaveDlg;
744 return true; 784 return true;
745} 785}
746 786
747void TextEdit::clear() 787void TextEdit::clear()
748{ 788{
749 delete doc; 789 delete doc;
750 doc = 0; 790 doc = 0;
751 editor->clear(); 791 editor->clear();
@@ -813,8 +853,22 @@ void TextEdit::changeFont() {
813 fontDlg->exec(); 853 fontDlg->exec();
814 854
815 QFont myFont=fontDlg->selectedFont; 855 QFont myFont=fontDlg->selectedFont;
816 editor->setFont( myFont); 856 editor->setFont( myFont);
817 delete fontDlg; 857 delete fontDlg;
818 858
819} 859}
820 860
861void TextEdit::editDelete()
862{
863 switch ( QMessageBox::warning(this,"Text Editor","Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!","Yes","No",0,0,1) ) {
864 case 0:
865 if(doc) {
866 doc->removeFiles();
867 clear();
868 }
869 break;
870 case 1:
871 // exit
872 break;
873 };
874}
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index f9eb241..781061a 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -19,16 +19,19 @@
19**********************************************************************/ 19**********************************************************************/
20// additions made by L.J. Potter Sun 02-17-2002 22:27:46 20// additions made by L.J. Potter Sun 02-17-2002 22:27:46
21 21
22#ifndef TEXTEDIT_H 22#ifndef TEXTEDIT_H
23#define TEXTEDIT_H 23#define TEXTEDIT_H
24 24
25#define QTEXTEDIT_OPEN_API 25#define QTEXTEDIT_OPEN_API
26 26
27#include "fileBrowser.h"
28#include "fileSaver.h"
29
27#include <qpe/filemanager.h> 30#include <qpe/filemanager.h>
28 31
29#include <qmainwindow.h> 32#include <qmainwindow.h>
30#include <qmultilineedit.h> 33#include <qmultilineedit.h>
31#include <qlist.h> 34#include <qlist.h>
32#include <qmap.h> 35#include <qmap.h>
33 36
34class QWidgetStack; 37class QWidgetStack;
@@ -63,16 +66,17 @@ private slots:
63 bool save(); 66 bool save();
64 bool saveAs(); 67 bool saveAs();
65 68
66 69
67 void editCut(); 70 void editCut();
68 void editCopy(); 71 void editCopy();
69 void editPaste(); 72 void editPaste();
70 void editFind(); 73 void editFind();
74 void editDelete();
71 75
72 void findNext(); 76 void findNext();
73 void findClose(); 77 void findClose();
74 78
75 void search(); 79 void search();
76 void accept(); 80 void accept();
77 81
78 void newFile( const DocLnk & ); 82 void newFile( const DocLnk & );
@@ -89,16 +93,19 @@ private:
89 void colorChanged( const QColor &c ); 93 void colorChanged( const QColor &c );
90 void clear(); 94 void clear();
91 void updateCaption( const QString &name=QString::null ); 95 void updateCaption( const QString &name=QString::null );
92 void setFontSize(int sz, bool round_down_not_up); 96 void setFontSize(int sz, bool round_down_not_up);
93 97
94private: 98private:
95 QWidgetStack *editorStack; 99 QWidgetStack *editorStack;
96 FileSelector *fileSelector; 100 FileSelector *fileSelector;
101 fileSaver *fileSaveDlg;
102 fileBrowser *browseForFiles;
103
97 QpeEditor* editor; 104 QpeEditor* editor;
98 QToolBar *menu, *editBar, *searchBar; 105 QToolBar *menu, *editBar, *searchBar;
99 QLineEdit *searchEdit; 106 QLineEdit *searchEdit;
100 DocLnk *doc; 107 DocLnk *doc;
101 bool searchVisible; 108 bool searchVisible;
102 bool bFromDocView; 109 bool bFromDocView;
103 QAction *zin, *zout; 110 QAction *zin, *zout;
104 QString currentFileName; 111 QString currentFileName;