author | llornkcor <llornkcor> | 2002-02-19 00:32:58 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-19 00:32:58 (UTC) |
commit | 2308c4db692821721bbe82f93fd60f275f4cccdc (patch) (unidiff) | |
tree | f037b4f4fd40201e5328132e643dca83bdf12651 /core/apps/textedit | |
parent | 7e308434f08fe6e8257a5c6b11a62e3ee3934d3b (diff) | |
download | opie-2308c4db692821721bbe82f93fd60f275f4cccdc.zip opie-2308c4db692821721bbe82f93fd60f275f4cccdc.tar.gz opie-2308c4db692821721bbe82f93fd60f275f4cccdc.tar.bz2 |
fixed several silly bugs having to do with Doclnk stuff..
-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 11 | ||||
-rw-r--r-- | core/apps/textedit/fileSaver.cpp | 24 | ||||
-rw-r--r-- | core/apps/textedit/fileSaver.h | 5 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 102 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 7 |
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 | |||
@@ -112,3 +112,3 @@ void fileBrowser::listClicked(QListViewItem *selectedItem) | |||
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(); |
@@ -139,6 +139,9 @@ void fileBrowser::listClicked(QListViewItem *selectedItem) | |||
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 |
@@ -154,3 +157,3 @@ void fileBrowser::OnOK() | |||
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 ); |
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 | |||
@@ -52,3 +52,3 @@ fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl | |||
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 | ||
@@ -149,3 +149,3 @@ void fileSaver::listClicked(QListViewItem *selectedItem) | |||
149 | } | 149 | } |
150 | } // else | 150 | } // else |
151 | // if( QFile::exists(strItem ) ) { | 151 | // if( QFile::exists(strItem ) ) { |
@@ -161,5 +161,10 @@ void fileSaver::listClicked(QListViewItem *selectedItem) | |||
161 | 161 | ||
162 | void fileSaver::OnOK() | 162 | void 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 | } |
@@ -168,5 +173,10 @@ void 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 | |||
@@ -59,3 +59,3 @@ private: | |||
59 | private slots: | 59 | private slots: |
60 | void accept(); | 60 | void accept(); |
61 | void upDir(); | 61 | void upDir(); |
@@ -63,3 +63,4 @@ private slots: | |||
63 | void listClicked(QListViewItem *); | 63 | void listClicked(QListViewItem *); |
64 | void OnOK(); | 64 | void closeEvent( QCloseEvent * ); |
65 | |||
65 | protected slots: | 66 | protected slots: |
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 | |||
@@ -301,2 +301,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
301 | 301 | ||
302 | |||
302 | int defsize; | 303 | int defsize; |
@@ -370,2 +371,7 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
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(); |
@@ -411,3 +417,3 @@ TextEdit::~TextEdit() | |||
411 | { | 417 | { |
412 | saveAs(); | 418 | // saveAs(); |
413 | 419 | ||
@@ -511,3 +517,3 @@ void TextEdit::fileOpen() | |||
511 | fileSelector->reread(); | 517 | fileSelector->reread(); |
512 | updateCaption(currentFileName); | 518 | updateCaption(); |
513 | } | 519 | } |
@@ -516,5 +522,4 @@ void 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; |
@@ -536,3 +541,3 @@ void TextEdit::newFileOpen() | |||
536 | delete browseForFiles; | 541 | delete browseForFiles; |
537 | 542 | editor->setEdited( true ); | |
538 | } | 543 | } |
@@ -619,2 +624,3 @@ void TextEdit::newFile( const DocLnk &f ) | |||
619 | doc = new DocLnk(nf); | 624 | doc = new DocLnk(nf); |
625 | qDebug("newFile "+currentFileName); | ||
620 | updateCaption(currentFileName); | 626 | updateCaption(currentFileName); |
@@ -628,2 +634,5 @@ void TextEdit::openFile( const QString &f ) | |||
628 | nf.setFile(f); | 634 | nf.setFile(f); |
635 | currentFileName=f; | ||
636 | qDebug("openFile string"+currentFileName); | ||
637 | |||
629 | openFile(nf); | 638 | openFile(nf); |
@@ -644,2 +653,4 @@ void TextEdit::openFile( const DocLnk &f ) | |||
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 ) ) { |
@@ -656,4 +667,6 @@ void TextEdit::openFile( const 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 | } |
@@ -675,4 +688,8 @@ void TextEdit::showEditTools() | |||
675 | 688 | ||
689 | /*! | ||
690 | unprompted save */ | ||
676 | bool TextEdit::save() | 691 | bool TextEdit::save() |
677 | { | 692 | { |
693 | qDebug("saveFile "+currentFileName); | ||
694 | |||
678 | QString rt = editor->text(); | 695 | QString rt = editor->text(); |
@@ -683,14 +700,21 @@ bool TextEdit::save() | |||
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 */ | ||
691 | bool TextEdit::saveAs() | 710 | bool 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() ) { |
@@ -705,3 +729,3 @@ bool TextEdit::saveAs() | |||
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() ) { |
@@ -720,3 +744,3 @@ bool TextEdit::saveAs() | |||
720 | if ( docname.isEmpty() ) | 744 | if ( docname.isEmpty() ) |
721 | docname = "Empty Text"; | 745 | docname = "Unnamed"; |
722 | doc->setName(docname); | 746 | doc->setName(docname); |
@@ -726,12 +750,25 @@ bool TextEdit::saveAs() | |||
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; |
@@ -740,5 +777,8 @@ bool TextEdit::saveAs() | |||
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; |
@@ -820 +860,15 @@ void TextEdit::changeFont() { | |||
820 | 860 | ||
861 | void 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 | |||
@@ -26,2 +26,5 @@ | |||
26 | 26 | ||
27 | #include "fileBrowser.h" | ||
28 | #include "fileSaver.h" | ||
29 | |||
27 | #include <qpe/filemanager.h> | 30 | #include <qpe/filemanager.h> |
@@ -70,2 +73,3 @@ private slots: | |||
70 | void editFind(); | 73 | void editFind(); |
74 | void editDelete(); | ||
71 | 75 | ||
@@ -96,2 +100,5 @@ private: | |||
96 | FileSelector *fileSelector; | 100 | FileSelector *fileSelector; |
101 | fileSaver *fileSaveDlg; | ||
102 | fileBrowser *browseForFiles; | ||
103 | |||
97 | QpeEditor* editor; | 104 | QpeEditor* editor; |