author | llornkcor <llornkcor> | 2002-06-01 23:30:12 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-06-01 23:30:12 (UTC) |
commit | 7b145de0bf5dfe015e3c53fb4058315857e725a3 (patch) (unidiff) | |
tree | 6000c8844b749537bdf69c0b4cf124dda4eddb6b | |
parent | 4a8e6f982a1033b7f2b0406a238503f9acb9a7c5 (diff) | |
download | opie-7b145de0bf5dfe015e3c53fb4058315857e725a3.zip opie-7b145de0bf5dfe015e3c53fb4058315857e725a3.tar.gz opie-7b145de0bf5dfe015e3c53fb4058315857e725a3.tar.bz2 |
buf gix
-rw-r--r-- | core/apps/textedit/fileSaver.cpp | 3 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 16 |
2 files changed, 13 insertions, 6 deletions
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp index b1ddc0b..209a258 100644 --- a/core/apps/textedit/fileSaver.cpp +++ b/core/apps/textedit/fileSaver.cpp | |||
@@ -159,85 +159,86 @@ void fileSaver::populateList() | |||
159 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 159 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
160 | item->setPixmap( 0, pm); | 160 | item->setPixmap( 0, pm); |
161 | } | 161 | } |
162 | } | 162 | } |
163 | isDir=FALSE; | 163 | isDir=FALSE; |
164 | ++it; | 164 | ++it; |
165 | } | 165 | } |
166 | ListView->setSorting( 2, FALSE); | 166 | ListView->setSorting( 2, FALSE); |
167 | dirLabel->setText(currentDir.canonicalPath()); | 167 | dirLabel->setText(currentDir.canonicalPath()); |
168 | 168 | ||
169 | 169 | ||
170 | } | 170 | } |
171 | 171 | ||
172 | void fileSaver::upDir() | 172 | void fileSaver::upDir() |
173 | { | 173 | { |
174 | // qDebug(currentDir.canonicalPath()); | 174 | // qDebug(currentDir.canonicalPath()); |
175 | } | 175 | } |
176 | 176 | ||
177 | void fileSaver::listDoubleClicked(QListViewItem *selectedItem) | 177 | void fileSaver::listDoubleClicked(QListViewItem *selectedItem) |
178 | { | 178 | { |
179 | } | 179 | } |
180 | 180 | ||
181 | void fileSaver::listClicked(QListViewItem *selectedItem) | 181 | void fileSaver::listClicked(QListViewItem *selectedItem) |
182 | { | 182 | { |
183 | if(selectedItem != NULL) { | ||
183 | QString strItem=selectedItem->text(0); | 184 | QString strItem=selectedItem->text(0); |
184 | QString strSize=selectedItem->text(1); | 185 | QString strSize=selectedItem->text(1); |
185 | // qDebug("strItem is "+strItem); | 186 | // qDebug("strItem is "+strItem); |
186 | strSize.stripWhiteSpace(); | 187 | strSize.stripWhiteSpace(); |
187 | // qDebug(strSize); | 188 | // qDebug(strSize); |
188 | 189 | ||
189 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 190 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
190 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); | 191 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); |
191 | // qDebug("strItem symlink is "+strItem2); | 192 | // qDebug("strItem symlink is "+strItem2); |
192 | if(QDir(strItem2).exists() ) { | 193 | if(QDir(strItem2).exists() ) { |
193 | currentDir.cd(strItem2, TRUE); | 194 | currentDir.cd(strItem2, TRUE); |
194 | populateList(); | 195 | populateList(); |
195 | } | 196 | } |
196 | } else { // not a symlink | 197 | } else { // not a symlink |
197 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 198 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
198 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 199 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
199 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 200 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
200 | currentDir.cd(strItem,FALSE); | 201 | currentDir.cd(strItem,FALSE); |
201 | // qDebug("Path is "+strItem); | 202 | // qDebug("Path is "+strItem); |
202 | populateList(); | 203 | populateList(); |
203 | } else { | 204 | } else { |
204 | currentDir.cdUp(); | 205 | currentDir.cdUp(); |
205 | populateList(); | 206 | populateList(); |
206 | } | 207 | } |
207 | if(QDir(strItem).exists()){ | 208 | if(QDir(strItem).exists()){ |
208 | currentDir.cd(strItem, TRUE); | 209 | currentDir.cd(strItem, TRUE); |
209 | populateList(); | 210 | populateList(); |
210 | } | 211 | } |
211 | } // else | 212 | } // else |
212 | // if( QFile::exists(strItem ) ) { | 213 | // if( QFile::exists(strItem ) ) { |
213 | // qDebug("We found our files!!"); | 214 | // qDebug("We found our files!!"); |
214 | 215 | ||
215 | // OnOK(); | 216 | // OnOK(); |
216 | } //end not symlink | 217 | } //end not symlink |
217 | chdir(strItem.latin1()); | 218 | chdir(strItem.latin1()); |
218 | 219 | ||
219 | 220 | } | |
220 | } | 221 | } |
221 | 222 | ||
222 | 223 | ||
223 | void fileSaver::closeEvent( QCloseEvent *e ) | 224 | void fileSaver::closeEvent( QCloseEvent *e ) |
224 | { | 225 | { |
225 | if(e->isAccepted()) { | 226 | if(e->isAccepted()) { |
226 | e->accept(); | 227 | e->accept(); |
227 | } else { | 228 | } else { |
228 | qDebug("not accepted"); | 229 | qDebug("not accepted"); |
229 | done(-1); | 230 | done(-1); |
230 | } | 231 | } |
231 | } | 232 | } |
232 | 233 | ||
233 | void fileSaver::accept() { | 234 | void fileSaver::accept() { |
234 | selectedFileName = fileEdit->text(); | 235 | selectedFileName = fileEdit->text(); |
235 | QString path = currentDir.canonicalPath()+"/" + selectedFileName; | 236 | QString path = currentDir.canonicalPath()+"/" + selectedFileName; |
236 | if( path.find("//",0,TRUE) ==-1 ) { | 237 | if( path.find("//",0,TRUE) ==-1 ) { |
237 | selectedFileName = path; | 238 | selectedFileName = path; |
238 | } else { | 239 | } else { |
239 | selectedFileName = currentDir.canonicalPath()+selectedFileName; | 240 | selectedFileName = currentDir.canonicalPath()+selectedFileName; |
240 | } | 241 | } |
241 | qDebug("going to save "+selectedFileName); | 242 | qDebug("going to save "+selectedFileName); |
242 | done(1); | 243 | done(1); |
243 | } | 244 | } |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index f89ed6d..f99f259 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -489,49 +489,49 @@ void TextEdit::setItalic(bool y) | |||
489 | 489 | ||
490 | void TextEdit::setWordWrap(bool y) | 490 | void TextEdit::setWordWrap(bool y) |
491 | { | 491 | { |
492 | bool state = editor->edited(); | 492 | bool state = editor->edited(); |
493 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 493 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
494 | editor->setEdited( state ); | 494 | editor->setEdited( state ); |
495 | } | 495 | } |
496 | 496 | ||
497 | void TextEdit::fileNew() | 497 | void TextEdit::fileNew() |
498 | { | 498 | { |
499 | // if( !bFromDocView ) { | 499 | // if( !bFromDocView ) { |
500 | // saveAs(); | 500 | // saveAs(); |
501 | // } | 501 | // } |
502 | newFile(DocLnk()); | 502 | newFile(DocLnk()); |
503 | } | 503 | } |
504 | 504 | ||
505 | void TextEdit::fileOpen() | 505 | void TextEdit::fileOpen() |
506 | { | 506 | { |
507 | Config cfg("TextEdit"); | 507 | Config cfg("TextEdit"); |
508 | cfg.setGroup("View"); | 508 | cfg.setGroup("View"); |
509 | bool b=FALSE; | 509 | bool b=FALSE; |
510 | // if(cfg.readEntry("useOldFileDialog") == "TRUE") | 510 | // if(cfg.readEntry("useOldFileDialog") == "TRUE") |
511 | // b=TRUE; | 511 | // b=TRUE; |
512 | // if(!b) { | 512 | // if(!b) { |
513 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); | 513 | QString str = OFileDialog::getOpenFileName( 2,"/");//,"", "*", this ); |
514 | if(!str.isEmpty() ) | 514 | if(!str.isEmpty() ) |
515 | openFile( str ); | 515 | openFile( str ); |
516 | // } else { | 516 | // } else { |
517 | // QString str; | 517 | // QString str; |
518 | // browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "*"); // | 518 | // browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "*"); // |
519 | // browseForFiles->setFileView( viewSelection ); | 519 | // browseForFiles->setFileView( viewSelection ); |
520 | // browseForFiles->showMaximized(); | 520 | // browseForFiles->showMaximized(); |
521 | // // if( result != -1 ) | 521 | // // if( result != -1 ) |
522 | 522 | ||
523 | // if( browseForFiles->exec() != -1 ) { | 523 | // if( browseForFiles->exec() != -1 ) { |
524 | // QString selFile = browseForFiles->selectedFileName; | 524 | // QString selFile = browseForFiles->selectedFileName; |
525 | // QStringList fileList = browseForFiles->fileList; | 525 | // QStringList fileList = browseForFiles->fileList; |
526 | // qDebug(selFile); | 526 | // qDebug(selFile); |
527 | // QStringList::ConstIterator f; | 527 | // QStringList::ConstIterator f; |
528 | // QString fileTemp; | 528 | // QString fileTemp; |
529 | // for ( f = fileList.begin(); f != fileList.end(); f++ ) { | 529 | // for ( f = fileList.begin(); f != fileList.end(); f++ ) { |
530 | // fileTemp = *f; | 530 | // fileTemp = *f; |
531 | // fileTemp.right( fileTemp.length()-5); | 531 | // fileTemp.right( fileTemp.length()-5); |
532 | // QString fileName = fileTemp; | 532 | // QString fileName = fileTemp; |
533 | // if( fileName != "Unnamed" || fileName != "Empty Text" ) { | 533 | // if( fileName != "Unnamed" || fileName != "Empty Text" ) { |
534 | // currentFileName = fileName; | 534 | // currentFileName = fileName; |
535 | // qDebug("please open "+currentFileName); | 535 | // qDebug("please open "+currentFileName); |
536 | // openFile(currentFileName ); | 536 | // openFile(currentFileName ); |
537 | // } | 537 | // } |
@@ -727,48 +727,49 @@ void TextEdit::showEditTools() | |||
727 | // updateCaption(); | 727 | // updateCaption(); |
728 | setWState (WState_Reserved1 ); | 728 | setWState (WState_Reserved1 ); |
729 | } | 729 | } |
730 | 730 | ||
731 | /*! | 731 | /*! |
732 | unprompted save */ | 732 | unprompted save */ |
733 | bool TextEdit::save() | 733 | bool TextEdit::save() |
734 | { | 734 | { |
735 | QString file = doc->file(); | 735 | QString file = doc->file(); |
736 | qDebug("saver file "+file); | 736 | qDebug("saver file "+file); |
737 | QString name= doc->name(); | 737 | QString name= doc->name(); |
738 | qDebug("File named "+name); | 738 | qDebug("File named "+name); |
739 | QString rt = editor->text(); | 739 | QString rt = editor->text(); |
740 | if( !rt.isEmpty() ) { | 740 | if( !rt.isEmpty() ) { |
741 | if(name.isEmpty()) { | 741 | if(name.isEmpty()) { |
742 | saveAs(); | 742 | saveAs(); |
743 | } else { | 743 | } else { |
744 | currentFileName= name ; | 744 | currentFileName= name ; |
745 | qDebug("saveFile "+currentFileName); | 745 | qDebug("saveFile "+currentFileName); |
746 | 746 | ||
747 | struct stat buf; | 747 | struct stat buf; |
748 | mode_t mode; | 748 | mode_t mode; |
749 | stat(file.latin1(), &buf); | 749 | stat(file.latin1(), &buf); |
750 | mode = buf.st_mode; | 750 | mode = buf.st_mode; |
751 | |||
751 | if(!fileIs) { | 752 | if(!fileIs) { |
752 | doc->setName( name); | 753 | doc->setName( name); |
753 | FileManager fm; | 754 | FileManager fm; |
754 | if ( !fm.saveFile( *doc, rt ) ) { | 755 | if ( !fm.saveFile( *doc, rt ) ) { |
755 | return false; | 756 | return false; |
756 | } | 757 | } |
757 | } else { | 758 | } else { |
758 | qDebug("regular save file"); | 759 | qDebug("regular save file"); |
759 | QFile f(file); | 760 | QFile f(file); |
760 | if( f.open(IO_WriteOnly)) { | 761 | if( f.open(IO_WriteOnly)) { |
761 | f.writeBlock(rt,rt.length()); | 762 | f.writeBlock(rt,rt.length()); |
762 | } else { | 763 | } else { |
763 | QMessageBox::message("Text Edit","Write Failed"); | 764 | QMessageBox::message("Text Edit","Write Failed"); |
764 | return false; | 765 | return false; |
765 | } | 766 | } |
766 | 767 | ||
767 | } | 768 | } |
768 | editor->setEdited( FALSE); | 769 | editor->setEdited( FALSE); |
769 | edited1=FALSE; | 770 | edited1=FALSE; |
770 | edited=FALSE; | 771 | edited=FALSE; |
771 | if(caption().left(1)=="*") | 772 | if(caption().left(1)=="*") |
772 | setCaption(caption().right(caption().length()-1)); | 773 | setCaption(caption().right(caption().length()-1)); |
773 | 774 | ||
774 | 775 | ||
@@ -801,53 +802,58 @@ bool TextEdit::saveAs() | |||
801 | 802 | ||
802 | if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) { | 803 | if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) { |
803 | qDebug("do silly TT filename thing"); | 804 | qDebug("do silly TT filename thing"); |
804 | if ( doc->name().isEmpty() ) { | 805 | if ( doc->name().isEmpty() ) { |
805 | QString pt = rt.simplifyWhiteSpace(); | 806 | QString pt = rt.simplifyWhiteSpace(); |
806 | int i = pt.find( ' ' ); | 807 | int i = pt.find( ' ' ); |
807 | QString docname = pt; | 808 | QString docname = pt; |
808 | if ( i > 0 ) | 809 | if ( i > 0 ) |
809 | docname = pt.left( i ); | 810 | docname = pt.left( i ); |
810 | // remove "." at the beginning | 811 | // remove "." at the beginning |
811 | while( docname.startsWith( "." ) ) | 812 | while( docname.startsWith( "." ) ) |
812 | docname = docname.mid( 1 ); | 813 | docname = docname.mid( 1 ); |
813 | docname.replace( QRegExp("/"), "_" ); | 814 | docname.replace( QRegExp("/"), "_" ); |
814 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. | 815 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. |
815 | if ( docname.length() > 40 ) | 816 | if ( docname.length() > 40 ) |
816 | docname = docname.left(40); | 817 | docname = docname.left(40); |
817 | if ( docname.isEmpty() ) | 818 | if ( docname.isEmpty() ) |
818 | docname = tr("Unnamed"); | 819 | docname = tr("Unnamed"); |
819 | doc->setName(docname); | 820 | doc->setName(docname); |
820 | currentFileName=docname; | 821 | currentFileName=docname; |
821 | } | 822 | } |
822 | } | 823 | } |
823 | 824 | ||
824 | 825 | ||
825 | fileSaveDlg=new fileSaver(this,tr("Save File As?"),TRUE, 0, currentFileName); | 826 | // QString str = OFileDialog::getSaveFileName( 2,"/");//,"", "*", this ); |
826 | qDebug("wanna save filename "+currentFileName); | 827 | // if(!str.isEmpty() ) { |
827 | fileSaveDlg->exec(); | 828 | // openFile( str ); |
828 | if( fileSaveDlg->result() == 1 ) { | 829 | |
830 | fileSaveDlg=new fileSaver(this,tr("Save File As?"),TRUE, 0, currentFileName); | ||
831 | qDebug("wanna save filename "+currentFileName); | ||
832 | fileSaveDlg->exec(); | ||
833 | if( fileSaveDlg->result() == 1 ) { | ||
829 | QString fileNm=fileSaveDlg->selectedFileName; | 834 | QString fileNm=fileSaveDlg->selectedFileName; |
835 | // QString fileNm=srt; | ||
830 | qDebug("saving filename "+fileNm); | 836 | qDebug("saving filename "+fileNm); |
831 | QFileInfo fi(fileNm); | 837 | QFileInfo fi(fileNm); |
832 | currentFileName=fi.fileName(); | 838 | currentFileName=fi.fileName(); |
833 | if(doc) { | 839 | if(doc) { |
834 | // QString file = doc->file(); | 840 | // QString file = doc->file(); |
835 | // doc->removeFiles(); | 841 | // doc->removeFiles(); |
836 | delete doc; | 842 | delete doc; |
837 | DocLnk nf; | 843 | DocLnk nf; |
838 | nf.setType("text/plain"); | 844 | nf.setType("text/plain"); |
839 | nf.setFile( fileNm); | 845 | nf.setFile( fileNm); |
840 | doc = new DocLnk(nf); | 846 | doc = new DocLnk(nf); |
841 | // editor->setText(rt); | 847 | // editor->setText(rt); |
842 | // qDebug("openFile doclnk "+currentFileName); | 848 | // qDebug("openFile doclnk "+currentFileName); |
843 | doc->setName( currentFileName); | 849 | doc->setName( currentFileName); |
844 | updateCaption( currentFileName); | 850 | updateCaption( currentFileName); |
845 | 851 | ||
846 | FileManager fm; | 852 | FileManager fm; |
847 | if ( !fm.saveFile( *doc, rt ) ) { | 853 | if ( !fm.saveFile( *doc, rt ) ) { |
848 | return false; | 854 | return false; |
849 | } | 855 | } |
850 | if( fileSaveDlg->filePermCheck->isChecked() ) { | 856 | if( fileSaveDlg->filePermCheck->isChecked() ) { |
851 | filePermissions *filePerm; | 857 | filePermissions *filePerm; |
852 | filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm); | 858 | filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm); |
853 | filePerm->exec(); | 859 | filePerm->exec(); |