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 | |||
@@ -364,6 +364,12 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
364 | nAdvanced->setToggleAction(TRUE); | 364 | nAdvanced->setToggleAction(TRUE); |
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(); |
369 | 375 | ||
@@ -435,6 +441,8 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
435 | } | 441 | } |
436 | 442 | ||
437 | void TextEdit::cleanUp() | 443 | TextEdit::~TextEdit() { |
438 | { | 444 | } |
445 | |||
446 | void TextEdit::cleanUp() { | ||
439 | // save(); | 447 | // save(); |
440 | Config cfg("TextEdit"); | 448 | Config cfg("TextEdit"); |
@@ -446,24 +454,23 @@ void TextEdit::cleanUp() | |||
446 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); | 454 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); |
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); |
458 | } | 467 | } |
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); |
463 | } | 471 | } |
464 | 472 | ||
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; |
469 | for (int i=0; i<nfontsizes; i++) { | 476 | for (int i=0; i<nfontsizes; i++) { |
@@ -490,6 +497,5 @@ void TextEdit::setFontSize(int sz, bool round_down_not_up) | |||
490 | } | 497 | } |
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(); |
495 | f.setBold(y); | 501 | f.setBold(y); |
@@ -497,6 +503,5 @@ void TextEdit::setBold(bool y) | |||
497 | } | 503 | } |
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(); |
502 | f.setItalic(y); | 507 | f.setItalic(y); |
@@ -504,6 +509,5 @@ void TextEdit::setItalic(bool y) | |||
504 | } | 509 | } |
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(); |
509 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 513 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
@@ -511,6 +515,5 @@ void TextEdit::setWordWrap(bool y) | |||
511 | } | 515 | } |
512 | 516 | ||
513 | void TextEdit::fileNew() | 517 | void TextEdit::fileNew() { |
514 | { | ||
515 | // if( !bFromDocView ) { | 518 | // if( !bFromDocView ) { |
516 | // saveAs(); | 519 | // saveAs(); |
@@ -519,6 +522,5 @@ void TextEdit::fileNew() | |||
519 | } | 522 | } |
520 | 523 | ||
521 | void TextEdit::fileOpen() | 524 | void TextEdit::fileOpen() { |
522 | { | ||
523 | Config cfg("TextEdit"); | 525 | Config cfg("TextEdit"); |
524 | cfg.setGroup("View"); | 526 | cfg.setGroup("View"); |
@@ -538,6 +540,5 @@ void TextEdit::fileOpen() | |||
538 | } | 540 | } |
539 | 541 | ||
540 | void TextEdit::doSearchBar() | 542 | void TextEdit::doSearchBar() { |
541 | { | ||
542 | Config cfg("TextEdit"); | 543 | Config cfg("TextEdit"); |
543 | cfg.setGroup("View"); | 544 | cfg.setGroup("View"); |
@@ -547,6 +548,5 @@ void TextEdit::doSearchBar() | |||
547 | 548 | ||
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 ); |
552 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 552 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
@@ -566,12 +566,10 @@ void TextEdit::slotFind() | |||
566 | #endif | 566 | #endif |
567 | 567 | ||
568 | void TextEdit::fileRevert() | 568 | void TextEdit::fileRevert() { |
569 | { | ||
570 | clear(); | 569 | clear(); |
571 | fileOpen(); | 570 | fileOpen(); |
572 | } | 571 | } |
573 | 572 | ||
574 | void TextEdit::editCut() | 573 | void TextEdit::editCut() { |
575 | { | ||
576 | #ifndef QT_NO_CLIPBOARD | 574 | #ifndef QT_NO_CLIPBOARD |
577 | editor->cut(); | 575 | editor->cut(); |
@@ -579,6 +577,5 @@ void TextEdit::editCut() | |||
579 | } | 577 | } |
580 | 578 | ||
581 | void TextEdit::editCopy() | 579 | void TextEdit::editCopy() { |
582 | { | ||
583 | #ifndef QT_NO_CLIPBOARD | 580 | #ifndef QT_NO_CLIPBOARD |
584 | editor->copy(); | 581 | editor->copy(); |
@@ -586,6 +583,5 @@ void TextEdit::editCopy() | |||
586 | } | 583 | } |
587 | 584 | ||
588 | void TextEdit::editPaste() | 585 | void TextEdit::editPaste() { |
589 | { | ||
590 | #ifndef QT_NO_CLIPBOARD | 586 | #ifndef QT_NO_CLIPBOARD |
591 | editor->paste(); | 587 | editor->paste(); |
@@ -593,6 +589,5 @@ void TextEdit::editPaste() | |||
593 | } | 589 | } |
594 | 590 | ||
595 | void TextEdit::editFind() | 591 | void TextEdit::editFind() { |
596 | { | ||
597 | searchBar->show(); | 592 | searchBar->show(); |
598 | searchVisible = TRUE; | 593 | searchVisible = TRUE; |
@@ -604,12 +599,10 @@ void TextEdit::editFind() | |||
604 | } | 599 | } |
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 ); |
609 | 603 | ||
610 | } | 604 | } |
611 | 605 | ||
612 | void TextEdit::findClose() | 606 | void TextEdit::findClose() { |
613 | { | ||
614 | searchVisible = FALSE; | 607 | searchVisible = FALSE; |
615 | searchBar->hide(); | 608 | searchBar->hide(); |
@@ -620,11 +613,9 @@ void TextEdit::findClose() | |||
620 | } | 613 | } |
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 ); |
625 | } | 617 | } |
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; |
630 | nf.setType("text/plain"); | 621 | nf.setType("text/plain"); |
@@ -639,6 +630,5 @@ void TextEdit::newFile( const DocLnk &f ) | |||
639 | } | 630 | } |
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); |
644 | QString filer; | 634 | QString filer; |
@@ -679,6 +669,5 @@ void TextEdit::openFile( const QString &f ) | |||
679 | } | 669 | } |
680 | 670 | ||
681 | void TextEdit::openFile( const DocLnk &f ) | 671 | void TextEdit::openFile( const DocLnk &f ) { |
682 | { | ||
683 | // clear(); | 672 | // clear(); |
684 | // bFromDocView = TRUE; | 673 | // bFromDocView = TRUE; |
@@ -704,6 +693,5 @@ void TextEdit::openFile( const DocLnk &f ) | |||
704 | } | 693 | } |
705 | 694 | ||
706 | void TextEdit::showEditTools() | 695 | void TextEdit::showEditTools() { |
707 | { | ||
708 | // if ( !doc ) | 696 | // if ( !doc ) |
709 | // close(); | 697 | // close(); |
@@ -719,6 +707,5 @@ void TextEdit::showEditTools() | |||
719 | /*! | 707 | /*! |
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(); |
724 | qDebug("saver file "+file); | 711 | qDebug("saver file "+file); |
@@ -772,13 +759,12 @@ bool TextEdit::save() | |||
772 | /*! | 759 | /*! |
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() ) { |
784 | delete doc; | 770 | delete doc; |
@@ -791,5 +777,5 @@ bool TextEdit::saveAs() | |||
791 | 777 | ||
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() ) { |
795 | QString pt = rt.simplifyWhiteSpace(); | 781 | QString pt = rt.simplifyWhiteSpace(); |
@@ -819,5 +805,7 @@ bool TextEdit::saveAs() | |||
819 | text << "*"; | 805 | text << "*"; |
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() ) { |
823 | QString fileNm=str; | 811 | QString fileNm=str; |
@@ -849,20 +837,21 @@ bool TextEdit::saveAs() | |||
849 | filePerm->exec(); | 837 | filePerm->exec(); |
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; |
868 | doc = 0; | 857 | doc = 0; |
@@ -870,6 +859,5 @@ void TextEdit::clear() | |||
870 | } | 859 | } |
871 | 860 | ||
872 | void TextEdit::updateCaption( const QString &name ) | 861 | void TextEdit::updateCaption( const QString &name ) { |
873 | { | ||
874 | if ( !doc ) | 862 | if ( !doc ) |
875 | setCaption( tr("Text Editor") ); | 863 | setCaption( tr("Text Editor") ); |
@@ -888,6 +876,5 @@ void TextEdit::updateCaption( const QString &name ) | |||
888 | } | 876 | } |
889 | 877 | ||
890 | void TextEdit::setDocument(const QString& fileref) | 878 | void TextEdit::setDocument(const QString& fileref) { |
891 | { | ||
892 | bFromDocView = TRUE; | 879 | bFromDocView = TRUE; |
893 | openFile(fileref); | 880 | openFile(fileref); |
@@ -898,19 +885,9 @@ void TextEdit::setDocument(const QString& fileref) | |||
898 | } | 885 | } |
899 | 886 | ||
900 | void TextEdit::closeEvent( QCloseEvent *e ) | 887 | void TextEdit::closeEvent( QCloseEvent *e ) { |
901 | { | ||
902 | bFromDocView = FALSE; | 888 | bFromDocView = FALSE; |
903 | e->accept(); | 889 | e->accept(); |
904 | } | 890 | } |
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() { |
916 | FontDatabase fdb; | 893 | FontDatabase fdb; |
@@ -937,6 +914,5 @@ void TextEdit::changeFont() { | |||
937 | } | 914 | } |
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) ) { |
942 | case 0: | 918 | case 0: |