author | llornkcor <llornkcor> | 2002-08-30 12:16:14 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-08-30 12:16:14 (UTC) |
commit | 73ccaa41947cd22902b96c18f3b96a6f9f3e565c (patch) (unidiff) | |
tree | dbddb746c97da59cd0af50e24ac2ef71603ee553 | |
parent | 146dfec7bdcac24df009b434d0f4683c53ce7552 (diff) | |
download | opie-73ccaa41947cd22902b96c18f3b96a6f9f3e565c.zip opie-73ccaa41947cd22902b96c18f3b96a6f9f3e565c.tar.gz opie-73ccaa41947cd22902b96c18f3b96a6f9f3e565c.tar.bz2 |
fixed canceling saveas dialog return
-rw-r--r-- | core/apps/textedit/textedit.cpp | 158 |
1 files changed, 67 insertions, 91 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 107695a..d61da2a 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -365,4 +365,10 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
365 | nAdvanced->addTo( font ); | 365 | nAdvanced->addTo( font ); |
366 | if(cfg.readBoolEntry("AdvancedFeatures")) | 366 | |
367 | nAdvanced->setOn(TRUE); | 367 | if(cfg.readBoolEntry("AdvancedFeatures")) { |
368 | qDebug("using advanced features"); | ||
369 | useAdvancedFeatures = true; | ||
370 | nAdvanced->setOn(TRUE); | ||
371 | } else | ||
372 | useAdvancedFeatures = false; | ||
373 | |||
368 | font->insertSeparator(); | 374 | font->insertSeparator(); |
@@ -436,4 +442,6 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
436 | 442 | ||
437 | void TextEdit::cleanUp() | 443 | TextEdit::~TextEdit() { |
438 | { | 444 | } |
445 | |||
446 | void TextEdit::cleanUp() { | ||
439 | // save(); | 447 | // save(); |
@@ -447,11 +455,12 @@ void TextEdit::cleanUp() | |||
447 | cfg.writeEntry( "FileView", viewSelection ); | 455 | cfg.writeEntry( "FileView", viewSelection ); |
448 | |||
449 | } | 456 | } |
450 | 457 | ||
451 | TextEdit::~TextEdit() | 458 | |
452 | { | 459 | void TextEdit::accept() { |
460 | if(edited1) | ||
461 | saveAs(); | ||
462 | exit(0); | ||
453 | } | 463 | } |
454 | 464 | ||
455 | void TextEdit::zoomIn() | 465 | void TextEdit::zoomIn() { |
456 | { | ||
457 | setFontSize(editor->font().pointSize()+1,FALSE); | 466 | setFontSize(editor->font().pointSize()+1,FALSE); |
@@ -459,4 +468,3 @@ void TextEdit::zoomIn() | |||
459 | 468 | ||
460 | void TextEdit::zoomOut() | 469 | void TextEdit::zoomOut() { |
461 | { | ||
462 | setFontSize(editor->font().pointSize()-1,TRUE); | 470 | setFontSize(editor->font().pointSize()-1,TRUE); |
@@ -465,4 +473,3 @@ void TextEdit::zoomOut() | |||
465 | 473 | ||
466 | void TextEdit::setFontSize(int sz, bool round_down_not_up) | 474 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { |
467 | { | ||
468 | int s=10; | 475 | int s=10; |
@@ -491,4 +498,3 @@ void TextEdit::setFontSize(int sz, bool round_down_not_up) | |||
491 | 498 | ||
492 | void TextEdit::setBold(bool y) | 499 | void TextEdit::setBold(bool y) { |
493 | { | ||
494 | QFont f = editor->font(); | 500 | QFont f = editor->font(); |
@@ -498,4 +504,3 @@ void TextEdit::setBold(bool y) | |||
498 | 504 | ||
499 | void TextEdit::setItalic(bool y) | 505 | void TextEdit::setItalic(bool y) { |
500 | { | ||
501 | QFont f = editor->font(); | 506 | QFont f = editor->font(); |
@@ -505,4 +510,3 @@ void TextEdit::setItalic(bool y) | |||
505 | 510 | ||
506 | void TextEdit::setWordWrap(bool y) | 511 | void TextEdit::setWordWrap(bool y) { |
507 | { | ||
508 | bool state = editor->edited(); | 512 | bool state = editor->edited(); |
@@ -512,4 +516,3 @@ void TextEdit::setWordWrap(bool y) | |||
512 | 516 | ||
513 | void TextEdit::fileNew() | 517 | void TextEdit::fileNew() { |
514 | { | ||
515 | // if( !bFromDocView ) { | 518 | // if( !bFromDocView ) { |
@@ -520,4 +523,3 @@ void TextEdit::fileNew() | |||
520 | 523 | ||
521 | void TextEdit::fileOpen() | 524 | void TextEdit::fileOpen() { |
522 | { | ||
523 | Config cfg("TextEdit"); | 525 | Config cfg("TextEdit"); |
@@ -539,4 +541,3 @@ void TextEdit::fileOpen() | |||
539 | 541 | ||
540 | void TextEdit::doSearchBar() | 542 | void TextEdit::doSearchBar() { |
541 | { | ||
542 | Config cfg("TextEdit"); | 543 | Config cfg("TextEdit"); |
@@ -548,4 +549,3 @@ void TextEdit::doSearchBar() | |||
548 | #if 0 | 549 | #if 0 |
549 | void TextEdit::slotFind() | 550 | void TextEdit::slotFind() { |
550 | { | ||
551 | FindDialog frmFind( tr("Text Editor"), this ); | 551 | FindDialog frmFind( tr("Text Editor"), this ); |
@@ -567,4 +567,3 @@ void TextEdit::slotFind() | |||
567 | 567 | ||
568 | void TextEdit::fileRevert() | 568 | void TextEdit::fileRevert() { |
569 | { | ||
570 | clear(); | 569 | clear(); |
@@ -573,4 +572,3 @@ void TextEdit::fileRevert() | |||
573 | 572 | ||
574 | void TextEdit::editCut() | 573 | void TextEdit::editCut() { |
575 | { | ||
576 | #ifndef QT_NO_CLIPBOARD | 574 | #ifndef QT_NO_CLIPBOARD |
@@ -580,4 +578,3 @@ void TextEdit::editCut() | |||
580 | 578 | ||
581 | void TextEdit::editCopy() | 579 | void TextEdit::editCopy() { |
582 | { | ||
583 | #ifndef QT_NO_CLIPBOARD | 580 | #ifndef QT_NO_CLIPBOARD |
@@ -587,4 +584,3 @@ void TextEdit::editCopy() | |||
587 | 584 | ||
588 | void TextEdit::editPaste() | 585 | void TextEdit::editPaste() { |
589 | { | ||
590 | #ifndef QT_NO_CLIPBOARD | 586 | #ifndef QT_NO_CLIPBOARD |
@@ -594,4 +590,3 @@ void TextEdit::editPaste() | |||
594 | 590 | ||
595 | void TextEdit::editFind() | 591 | void TextEdit::editFind() { |
596 | { | ||
597 | searchBar->show(); | 592 | searchBar->show(); |
@@ -605,4 +600,3 @@ void TextEdit::editFind() | |||
605 | 600 | ||
606 | void TextEdit::findNext() | 601 | void TextEdit::findNext() { |
607 | { | ||
608 | editor->find( searchEdit->text(), FALSE, FALSE ); | 602 | editor->find( searchEdit->text(), FALSE, FALSE ); |
@@ -611,4 +605,3 @@ void TextEdit::findNext() | |||
611 | 605 | ||
612 | void TextEdit::findClose() | 606 | void TextEdit::findClose() { |
613 | { | ||
614 | searchVisible = FALSE; | 607 | searchVisible = FALSE; |
@@ -621,4 +614,3 @@ void TextEdit::findClose() | |||
621 | 614 | ||
622 | void TextEdit::search() | 615 | void TextEdit::search() { |
623 | { | ||
624 | editor->find( searchEdit->text(), FALSE, FALSE ); | 616 | editor->find( searchEdit->text(), FALSE, FALSE ); |
@@ -626,4 +618,3 @@ void TextEdit::search() | |||
626 | 618 | ||
627 | void TextEdit::newFile( const DocLnk &f ) | 619 | void TextEdit::newFile( const DocLnk &f ) { |
628 | { | ||
629 | DocLnk nf = f; | 620 | DocLnk nf = f; |
@@ -640,4 +631,3 @@ void TextEdit::newFile( const DocLnk &f ) | |||
640 | 631 | ||
641 | void TextEdit::openFile( const QString &f ) | 632 | void TextEdit::openFile( const QString &f ) { |
642 | { | ||
643 | qDebug("filename is "+ f); | 633 | qDebug("filename is "+ f); |
@@ -680,4 +670,3 @@ void TextEdit::openFile( const QString &f ) | |||
680 | 670 | ||
681 | void TextEdit::openFile( const DocLnk &f ) | 671 | void TextEdit::openFile( const DocLnk &f ) { |
682 | { | ||
683 | // clear(); | 672 | // clear(); |
@@ -705,4 +694,3 @@ void TextEdit::openFile( const DocLnk &f ) | |||
705 | 694 | ||
706 | void TextEdit::showEditTools() | 695 | void TextEdit::showEditTools() { |
707 | { | ||
708 | // if ( !doc ) | 696 | // if ( !doc ) |
@@ -720,4 +708,3 @@ void TextEdit::showEditTools() | |||
720 | unprompted save */ | 708 | unprompted save */ |
721 | bool TextEdit::save() | 709 | bool TextEdit::save() { |
722 | { | ||
723 | QString file = doc->file(); | 710 | QString file = doc->file(); |
@@ -773,11 +760,10 @@ bool TextEdit::save() | |||
773 | prompted save */ | 760 | prompted save */ |
774 | bool TextEdit::saveAs() | 761 | bool TextEdit::saveAs() { |
775 | { | 762 | qDebug("saveAsFile "+currentFileName); |
776 | // qDebug("saveAsFile "+currentFileName); | 763 | // case of nothing to save... |
777 | // case of nothing to save... | 764 | if ( !doc ) { |
778 | if ( !doc )//|| !bFromDocView) | 765 | //|| !bFromDocView) |
779 | { | 766 | qDebug("no doc"); |
780 | qDebug("no doc"); | 767 | return true; |
781 | return true; | 768 | } |
782 | } | ||
783 | if ( !editor->edited() ) { | 769 | if ( !editor->edited() ) { |
@@ -792,3 +778,3 @@ bool TextEdit::saveAs() | |||
792 | if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) { | 778 | if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) { |
793 | qDebug("do silly TT filename thing"); | 779 | // qDebug("do silly TT filename thing"); |
794 | if ( doc->name().isEmpty() ) { | 780 | if ( doc->name().isEmpty() ) { |
@@ -820,3 +806,5 @@ bool TextEdit::saveAs() | |||
820 | map.insert(tr("All"), text ); | 806 | map.insert(tr("All"), text ); |
807 | |||
821 | QString str = OFileDialog::getSaveFileName( 2,"/", QString::null, map); | 808 | QString str = OFileDialog::getSaveFileName( 2,"/", QString::null, map); |
809 | |||
822 | if(!str.isEmpty() ) { | 810 | if(!str.isEmpty() ) { |
@@ -850,18 +838,19 @@ bool TextEdit::saveAs() | |||
850 | 838 | ||
851 | if( filePerm) | 839 | if( filePerm) |
852 | delete filePerm; | 840 | delete filePerm; |
853 | } | 841 | } |
854 | } | 842 | } |
843 | editor->setEdited( false); | ||
844 | edited1 = false; | ||
845 | edited = false; | ||
846 | if(caption().left(1)=="*") | ||
847 | setCaption(caption().right(caption().length()-1)); | ||
848 | |||
849 | return true; | ||
855 | } | 850 | } |
856 | editor->setEdited(TRUE); | 851 | qDebug("returning false"); |
857 | edited1=FALSE; | 852 | return false; |
858 | edited=TRUE; | ||
859 | if(caption().left(1)=="*") | ||
860 | setCaption(caption().right(caption().length()-1)); | ||
861 | |||
862 | return true; | ||
863 | } //end saveAs | 853 | } //end saveAs |
864 | 854 | ||
865 | void TextEdit::clear() | 855 | void TextEdit::clear() { |
866 | { | ||
867 | delete doc; | 856 | delete doc; |
@@ -871,4 +860,3 @@ void TextEdit::clear() | |||
871 | 860 | ||
872 | void TextEdit::updateCaption( const QString &name ) | 861 | void TextEdit::updateCaption( const QString &name ) { |
873 | { | ||
874 | if ( !doc ) | 862 | if ( !doc ) |
@@ -889,4 +877,3 @@ void TextEdit::updateCaption( const QString &name ) | |||
889 | 877 | ||
890 | void TextEdit::setDocument(const QString& fileref) | 878 | void TextEdit::setDocument(const QString& fileref) { |
891 | { | ||
892 | bFromDocView = TRUE; | 879 | bFromDocView = TRUE; |
@@ -899,4 +886,3 @@ void TextEdit::setDocument(const QString& fileref) | |||
899 | 886 | ||
900 | void TextEdit::closeEvent( QCloseEvent *e ) | 887 | void TextEdit::closeEvent( QCloseEvent *e ) { |
901 | { | ||
902 | bFromDocView = FALSE; | 888 | bFromDocView = FALSE; |
@@ -905,11 +891,2 @@ void TextEdit::closeEvent( QCloseEvent *e ) | |||
905 | 891 | ||
906 | void TextEdit::accept() | ||
907 | { | ||
908 | //if(caption() !="Unnamed") | ||
909 | if(edited1) | ||
910 | saveAs(); | ||
911 | exit(0); | ||
912 | |||
913 | } | ||
914 | |||
915 | void TextEdit::changeFont() { | 892 | void TextEdit::changeFont() { |
@@ -938,4 +915,3 @@ void TextEdit::changeFont() { | |||
938 | 915 | ||
939 | void TextEdit::editDelete() | 916 | void TextEdit::editDelete() { |
940 | { | ||
941 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!"),tr("Yes"),tr("No"),0,0,1) ) { | 917 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!"),tr("Yes"),tr("No"),0,0,1) ) { |