author | llornkcor <llornkcor> | 2002-02-18 14:52:54 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-18 14:52:54 (UTC) |
commit | 00f89d28e669140eb50f1f220c389f88fba1105c (patch) (unidiff) | |
tree | deb87bb87d855bbacddc79d8a0a79edfb1cf1cd8 | |
parent | 9741205aa0b0892b870d2b7df7c5dd7e25b0bb18 (diff) | |
download | opie-00f89d28e669140eb50f1f220c389f88fba1105c.zip opie-00f89d28e669140eb50f1f220c389f88fba1105c.tar.gz opie-00f89d28e669140eb50f1f220c389f88fba1105c.tar.bz2 |
fixed filesave and fileopen cancel
-rw-r--r-- | core/apps/textedit/fileSaver.cpp | 16 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 52 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 2 |
3 files changed, 42 insertions, 28 deletions
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp index d01daee..88608cc 100644 --- a/core/apps/textedit/fileSaver.cpp +++ b/core/apps/textedit/fileSaver.cpp | |||
@@ -29,7 +29,9 @@ fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl | |||
29 | setName( "fileSaver" ); | 29 | setName( "fileSaver" ); |
30 | resize( 236, 280 ); | 30 | resize( 236, 280 ); |
31 | setCaption(tr( "Save file" ) ); | 31 | setCaption(tr( "Save file" ) ); |
32 | // filterStr=currentFileName; | 32 | QFileInfo fi(currentFileName); |
33 | QString tmpFileName=fi.fileName(); | ||
34 | // qDebug( tmpFileName); | ||
33 | 35 | ||
34 | dirLabel = new QLabel(this, "DirLabel"); | 36 | dirLabel = new QLabel(this, "DirLabel"); |
35 | dirLabel->setText(currentDir.canonicalPath()); | 37 | dirLabel->setText(currentDir.canonicalPath()); |
@@ -49,11 +51,16 @@ fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl | |||
49 | 51 | ||
50 | fileEdit= new QLineEdit(this); | 52 | fileEdit= new QLineEdit(this); |
51 | fileEdit->setGeometry( QRect( 10, 230, 200, 25)); | 53 | fileEdit->setGeometry( QRect( 10, 230, 200, 25)); |
52 | fileEdit->setText(currentFileName); | 54 | |
53 | // signals and slots connections | 55 | fileEdit->setText( tmpFileName); |
56 | |||
57 | // signals and slots connections | ||
54 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); | 58 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); |
55 | connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 59 | connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
56 | currentDir.setPath(QDir::currentDirPath() ); | 60 | |
61 | // tmpFileName=fi.FilePath(); | ||
62 | // qDebug( tmpFileName); | ||
63 | currentDir.setPath( QDir::currentDirPath() ); | ||
57 | populateList(); | 64 | populateList(); |
58 | } | 65 | } |
59 | 66 | ||
@@ -160,5 +167,6 @@ void fileSaver::OnOK() | |||
160 | void fileSaver::accept() { | 167 | void fileSaver::accept() { |
161 | selectedFileName = fileEdit->text(); | 168 | selectedFileName = fileEdit->text(); |
162 | selectedFileName = currentDir.canonicalPath()+ selectedFileName; | 169 | selectedFileName = currentDir.canonicalPath()+ selectedFileName; |
170 | qDebug("goint to save "+selectedFileName); | ||
163 | reject(); | 171 | reject(); |
164 | } | 172 | } |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 14bc496..429c195 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -485,7 +485,9 @@ void TextEdit::setWordWrap(bool y) | |||
485 | 485 | ||
486 | void TextEdit::fileNew() | 486 | void TextEdit::fileNew() |
487 | { | 487 | { |
488 | save(); | 488 | if( !bFromDocView ) { |
489 | save(); | ||
490 | } | ||
489 | newFile(DocLnk()); | 491 | newFile(DocLnk()); |
490 | } | 492 | } |
491 | 493 | ||
@@ -512,27 +514,28 @@ void TextEdit::fileOpen() | |||
512 | clearWState (WState_Reserved1 ); | 514 | clearWState (WState_Reserved1 ); |
513 | editorStack->raiseWidget( fileSelector ); | 515 | editorStack->raiseWidget( fileSelector ); |
514 | fileSelector->reread(); | 516 | fileSelector->reread(); |
515 | updateCaption(); | 517 | updateCaption(currentFileName); |
516 | } | 518 | } |
517 | 519 | ||
518 | void TextEdit::newFileOpen() | 520 | void TextEdit::newFileOpen() |
519 | { | 521 | { |
520 | fileBrowser *browseForFiles; | 522 | fileBrowser *browseForFiles; |
521 | browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*"); | 523 | browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*"); |
522 | browseForFiles->exec(); | 524 | if( browseForFiles->exec()!= 0 ) { |
523 | QString selFile= browseForFiles->selectedFileName; | 525 | QString selFile= browseForFiles->selectedFileName; |
524 | QStringList fileList=browseForFiles->fileList; | 526 | QStringList fileList=browseForFiles->fileList; |
525 | qDebug(selFile); | 527 | qDebug(selFile); |
526 | QStringList::ConstIterator f; | 528 | QStringList::ConstIterator f; |
527 | QString fileTemp; | 529 | QString fileTemp; |
528 | for ( f = fileList.begin(); f != fileList.end(); f++ ) { | 530 | for ( f = fileList.begin(); f != fileList.end(); f++ ) { |
529 | fileTemp = *f; | 531 | fileTemp = *f; |
530 | fileTemp.right( fileTemp.length()-5); | 532 | fileTemp.right( fileTemp.length()-5); |
531 | QString fileName = fileTemp; | 533 | QString fileName = fileTemp; |
532 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { | 534 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { |
533 | currentFileName = fileName; | 535 | currentFileName = fileName; |
534 | qDebug("please open "+currentFileName); | 536 | // qDebug("please open "+currentFileName); |
535 | openFile(fileName ); | 537 | openFile(fileName ); |
538 | } | ||
536 | } | 539 | } |
537 | } | 540 | } |
538 | delete browseForFiles; | 541 | delete browseForFiles; |
@@ -619,7 +622,7 @@ void TextEdit::newFile( const DocLnk &f ) | |||
619 | setWState (WState_Reserved1 ); | 622 | setWState (WState_Reserved1 ); |
620 | editor->setFocus(); | 623 | editor->setFocus(); |
621 | doc = new DocLnk(nf); | 624 | doc = new DocLnk(nf); |
622 | updateCaption(); | 625 | // updateCaption(); |
623 | } | 626 | } |
624 | 627 | ||
625 | void TextEdit::openFile( const QString &f ) | 628 | void TextEdit::openFile( const QString &f ) |
@@ -641,6 +644,7 @@ void TextEdit::openFile( const QString &f ) | |||
641 | void TextEdit::openFile( const DocLnk &f ) | 644 | void TextEdit::openFile( const DocLnk &f ) |
642 | { | 645 | { |
643 | // clear(); | 646 | // clear(); |
647 | bFromDocView = TRUE; | ||
644 | FileManager fm; | 648 | FileManager fm; |
645 | QString txt; | 649 | QString txt; |
646 | if ( !fm.loadFile( f, txt ) ) { | 650 | if ( !fm.loadFile( f, txt ) ) { |
@@ -656,7 +660,7 @@ void TextEdit::openFile( const DocLnk &f ) | |||
656 | doc = new DocLnk(f); | 660 | doc = new DocLnk(f); |
657 | editor->setText(txt); | 661 | editor->setText(txt); |
658 | editor->setEdited(FALSE); | 662 | editor->setEdited(FALSE); |
659 | updateCaption(); | 663 | updateCaption(currentFileName); |
660 | } | 664 | } |
661 | 665 | ||
662 | void TextEdit::showEditTools() | 666 | void TextEdit::showEditTools() |
@@ -669,7 +673,7 @@ void TextEdit::showEditTools() | |||
669 | editBar->show(); | 673 | editBar->show(); |
670 | if ( searchVisible ) | 674 | if ( searchVisible ) |
671 | searchBar->show(); | 675 | searchBar->show(); |
672 | updateCaption(); | 676 | // updateCaption(); |
673 | editorStack->raiseWidget( editor ); | 677 | editorStack->raiseWidget( editor ); |
674 | setWState (WState_Reserved1 ); | 678 | setWState (WState_Reserved1 ); |
675 | } | 679 | } |
@@ -686,8 +690,9 @@ bool TextEdit::save() | |||
686 | } | 690 | } |
687 | 691 | ||
688 | QString rt = editor->text(); | 692 | QString rt = editor->text(); |
689 | 693 | qDebug(currentFileName); | |
690 | if(currentFileName.isEmpty() || currentFileName == "Unnamed") { | 694 | |
695 | if( currentFileName.isEmpty() || currentFileName == "Unnamed") { | ||
691 | 696 | ||
692 | if ( doc->name().isEmpty() ) { | 697 | if ( doc->name().isEmpty() ) { |
693 | QString pt = rt.simplifyWhiteSpace(); | 698 | QString pt = rt.simplifyWhiteSpace(); |
@@ -711,11 +716,12 @@ bool TextEdit::save() | |||
711 | 716 | ||
712 | fileSaver *fileSaveDlg; | 717 | fileSaver *fileSaveDlg; |
713 | fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName); | 718 | fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName); |
714 | fileSaveDlg->exec(); | 719 | if( fileSaveDlg->exec() != 0 ) { |
715 | QString fileNm=fileSaveDlg->selectedFileName; | 720 | QString fileNm=fileSaveDlg->selectedFileName; |
716 | qDebug("save filename "+fileNm); | 721 | qDebug("save filename "+fileNm); |
717 | doc->setName(fileNm); | 722 | doc->setName(fileNm); |
718 | updateCaption(); | 723 | updateCaption(fileNm); |
724 | } | ||
719 | delete fileSaveDlg; | 725 | delete fileSaveDlg; |
720 | 726 | ||
721 | FileManager fm; | 727 | FileManager fm; |
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h index 4e469cc..4bfb260 100644 --- a/core/apps/textedit/textedit.h +++ b/core/apps/textedit/textedit.h | |||
@@ -55,7 +55,7 @@ protected: | |||
55 | 55 | ||
56 | private slots: | 56 | private slots: |
57 | void setDocument(const QString&); | 57 | void setDocument(const QString&); |
58 | void changeFont(); | 58 | void changeFont(); |
59 | void fileNew(); | 59 | void fileNew(); |
60 | void fileRevert(); | 60 | void fileRevert(); |
61 | void fileOpen(); | 61 | void fileOpen(); |