author | llornkcor <llornkcor> | 2002-02-19 01:29:58 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-19 01:29:58 (UTC) |
commit | 994691c1659fdac4980b0319aa8fab1c98ef3c73 (patch) (unidiff) | |
tree | a7fa94deb3cbd4c7cda17f184eed634bbc0caac4 | |
parent | fe66103c21d3337bb6c7fc7ad112cbdedd255d67 (diff) | |
download | opie-994691c1659fdac4980b0319aa8fab1c98ef3c73.zip opie-994691c1659fdac4980b0319aa8fab1c98ef3c73.tar.gz opie-994691c1659fdac4980b0319aa8fab1c98ef3c73.tar.bz2 |
bug- saveas
-rw-r--r-- | core/apps/textedit/textedit.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 019ffee..197b28b 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -472,228 +472,230 @@ void TextEdit::setBold(bool y) | |||
472 | 472 | ||
473 | void TextEdit::setItalic(bool y) | 473 | void TextEdit::setItalic(bool y) |
474 | { | 474 | { |
475 | QFont f = editor->font(); | 475 | QFont f = editor->font(); |
476 | f.setItalic(y); | 476 | f.setItalic(y); |
477 | editor->setFont(f); | 477 | editor->setFont(f); |
478 | } | 478 | } |
479 | 479 | ||
480 | void TextEdit::setWordWrap(bool y) | 480 | void TextEdit::setWordWrap(bool y) |
481 | { | 481 | { |
482 | bool state = editor->edited(); | 482 | bool state = editor->edited(); |
483 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 483 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
484 | editor->setEdited( state ); | 484 | editor->setEdited( state ); |
485 | } | 485 | } |
486 | 486 | ||
487 | void TextEdit::fileNew() | 487 | void TextEdit::fileNew() |
488 | { | 488 | { |
489 | if( !bFromDocView ) { | 489 | if( !bFromDocView ) { |
490 | saveAs(); | 490 | saveAs(); |
491 | } | 491 | } |
492 | newFile(DocLnk()); | 492 | newFile(DocLnk()); |
493 | } | 493 | } |
494 | 494 | ||
495 | void TextEdit::fileOpen() | 495 | void TextEdit::fileOpen() |
496 | { | 496 | { |
497 | // if ( !save() ) { | 497 | // if ( !save() ) { |
498 | // if ( QMessageBox::critical( this, tr( "Out of space" ), | 498 | // if ( QMessageBox::critical( this, tr( "Out of space" ), |
499 | // tr( "Text Editor was unable to\n" | 499 | // tr( "Text Editor was unable to\n" |
500 | // "save your changes.\n" | 500 | // "save your changes.\n" |
501 | // "Free some space and try again.\n" | 501 | // "Free some space and try again.\n" |
502 | // "\nContinue anyway?" ), | 502 | // "\nContinue anyway?" ), |
503 | // QMessageBox::Yes|QMessageBox::Escape, | 503 | // QMessageBox::Yes|QMessageBox::Escape, |
504 | // QMessageBox::No|QMessageBox::Default ) | 504 | // QMessageBox::No|QMessageBox::Default ) |
505 | // != QMessageBox::Yes ) | 505 | // != QMessageBox::Yes ) |
506 | // return; | 506 | // return; |
507 | // else { | 507 | // else { |
508 | // delete doc; | 508 | // delete doc; |
509 | // doc = 0; | 509 | // doc = 0; |
510 | // } | 510 | // } |
511 | // } | 511 | // } |
512 | menu->hide(); | 512 | menu->hide(); |
513 | editBar->hide(); | 513 | editBar->hide(); |
514 | searchBar->hide(); | 514 | searchBar->hide(); |
515 | clearWState (WState_Reserved1 ); | 515 | clearWState (WState_Reserved1 ); |
516 | editorStack->raiseWidget( fileSelector ); | 516 | editorStack->raiseWidget( fileSelector ); |
517 | fileSelector->reread(); | 517 | fileSelector->reread(); |
518 | updateCaption(); | 518 | updateCaption(); |
519 | } | 519 | } |
520 | 520 | ||
521 | void TextEdit::newFileOpen() | 521 | void TextEdit::newFileOpen() |
522 | { | 522 | { |
523 | browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*"); | 523 | browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*"); |
524 | if( browseForFiles->exec() != -1 ) { | 524 | if( browseForFiles->exec() != -1 ) { |
525 | QString selFile= browseForFiles->selectedFileName; | 525 | QString selFile= browseForFiles->selectedFileName; |
526 | QStringList fileList=browseForFiles->fileList; | 526 | QStringList fileList=browseForFiles->fileList; |
527 | qDebug(selFile); | 527 | qDebug(selFile); |
528 | QStringList::ConstIterator f; | 528 | QStringList::ConstIterator f; |
529 | QString fileTemp; | 529 | QString fileTemp; |
530 | for ( f = fileList.begin(); f != fileList.end(); f++ ) { | 530 | for ( f = fileList.begin(); f != fileList.end(); f++ ) { |
531 | fileTemp = *f; | 531 | fileTemp = *f; |
532 | fileTemp.right( fileTemp.length()-5); | 532 | fileTemp.right( fileTemp.length()-5); |
533 | QString fileName = fileTemp; | 533 | QString fileName = fileTemp; |
534 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { | 534 | if( fileName != "Unnamed" || fileName != "Empty Text" ) { |
535 | currentFileName = fileName; | 535 | currentFileName = fileName; |
536 | // qDebug("please open "+currentFileName); | 536 | qDebug("please open "+currentFileName); |
537 | openFile(fileName ); | 537 | openFile(fileName ); |
538 | } | 538 | } |
539 | } | 539 | } |
540 | } | 540 | } |
541 | delete browseForFiles; | 541 | delete browseForFiles; |
542 | editor->setEdited( true ); | 542 | editor->setEdited( true ); |
543 | } | 543 | } |
544 | 544 | ||
545 | #if 0 | 545 | #if 0 |
546 | void TextEdit::slotFind() | 546 | void TextEdit::slotFind() |
547 | { | 547 | { |
548 | FindDialog frmFind( "Text Editor", this ); | 548 | FindDialog frmFind( "Text Editor", this ); |
549 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 549 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
550 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 550 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
551 | 551 | ||
552 | //case sensitive, backwards, [category] | 552 | //case sensitive, backwards, [category] |
553 | 553 | ||
554 | connect( editor, SIGNAL(notFound()), | 554 | connect( editor, SIGNAL(notFound()), |
555 | &frmFind, SLOT(slotNotFound()) ); | 555 | &frmFind, SLOT(slotNotFound()) ); |
556 | connect( editor, SIGNAL(searchWrapped()), | 556 | connect( editor, SIGNAL(searchWrapped()), |
557 | &frmFind, SLOT(slotWrapAround()) ); | 557 | &frmFind, SLOT(slotWrapAround()) ); |
558 | 558 | ||
559 | frmFind.exec(); | 559 | frmFind.exec(); |
560 | 560 | ||
561 | 561 | ||
562 | } | 562 | } |
563 | #endif | 563 | #endif |
564 | 564 | ||
565 | void TextEdit::fileRevert() | 565 | void TextEdit::fileRevert() |
566 | { | 566 | { |
567 | clear(); | 567 | clear(); |
568 | fileOpen(); | 568 | fileOpen(); |
569 | } | 569 | } |
570 | 570 | ||
571 | void TextEdit::editCut() | 571 | void TextEdit::editCut() |
572 | { | 572 | { |
573 | #ifndef QT_NO_CLIPBOARD | 573 | #ifndef QT_NO_CLIPBOARD |
574 | editor->cut(); | 574 | editor->cut(); |
575 | #endif | 575 | #endif |
576 | } | 576 | } |
577 | 577 | ||
578 | void TextEdit::editCopy() | 578 | void TextEdit::editCopy() |
579 | { | 579 | { |
580 | #ifndef QT_NO_CLIPBOARD | 580 | #ifndef QT_NO_CLIPBOARD |
581 | editor->copy(); | 581 | editor->copy(); |
582 | #endif | 582 | #endif |
583 | } | 583 | } |
584 | 584 | ||
585 | void TextEdit::editPaste() | 585 | void TextEdit::editPaste() |
586 | { | 586 | { |
587 | #ifndef QT_NO_CLIPBOARD | 587 | #ifndef QT_NO_CLIPBOARD |
588 | editor->paste(); | 588 | editor->paste(); |
589 | #endif | 589 | #endif |
590 | } | 590 | } |
591 | 591 | ||
592 | void TextEdit::editFind() | 592 | void TextEdit::editFind() |
593 | { | 593 | { |
594 | searchBar->show(); | 594 | searchBar->show(); |
595 | searchVisible = TRUE; | 595 | searchVisible = TRUE; |
596 | searchEdit->setFocus(); | 596 | searchEdit->setFocus(); |
597 | } | 597 | } |
598 | 598 | ||
599 | void TextEdit::findNext() | 599 | void TextEdit::findNext() |
600 | { | 600 | { |
601 | editor->find( searchEdit->text(), FALSE, FALSE ); | 601 | editor->find( searchEdit->text(), FALSE, FALSE ); |
602 | 602 | ||
603 | } | 603 | } |
604 | 604 | ||
605 | void TextEdit::findClose() | 605 | void TextEdit::findClose() |
606 | { | 606 | { |
607 | searchVisible = FALSE; | 607 | searchVisible = FALSE; |
608 | searchBar->hide(); | 608 | searchBar->hide(); |
609 | } | 609 | } |
610 | 610 | ||
611 | void TextEdit::search() | 611 | void TextEdit::search() |
612 | { | 612 | { |
613 | editor->find( searchEdit->text(), FALSE, FALSE ); | 613 | editor->find( searchEdit->text(), FALSE, FALSE ); |
614 | } | 614 | } |
615 | 615 | ||
616 | void TextEdit::newFile( const DocLnk &f ) | 616 | void TextEdit::newFile( const DocLnk &f ) |
617 | { | 617 | { |
618 | DocLnk nf = f; | 618 | DocLnk nf = f; |
619 | nf.setType("text/plain"); | 619 | nf.setType("text/plain"); |
620 | clear(); | 620 | clear(); |
621 | editorStack->raiseWidget( editor ); | 621 | editorStack->raiseWidget( editor ); |
622 | setWState (WState_Reserved1 ); | 622 | setWState (WState_Reserved1 ); |
623 | editor->setFocus(); | 623 | editor->setFocus(); |
624 | doc = new DocLnk(nf); | 624 | doc = new DocLnk(nf); |
625 | qDebug("newFile "+currentFileName); | 625 | qDebug("newFile "+currentFileName); |
626 | updateCaption(currentFileName); | 626 | updateCaption(currentFileName); |
627 | } | 627 | } |
628 | 628 | ||
629 | void TextEdit::openFile( const QString &f ) | 629 | void TextEdit::openFile( const QString &f ) |
630 | { | 630 | { |
631 | bFromDocView = TRUE; | 631 | bFromDocView = TRUE; |
632 | DocLnk nf; | 632 | DocLnk nf; |
633 | nf.setType("text/plain"); | 633 | nf.setType("text/plain"); |
634 | nf.setFile(f); | 634 | nf.setFile(f); |
635 | currentFileName=f; | 635 | currentFileName=f; |
636 | QFileInfo fi( currentFileName); | ||
637 | nf.setName(fi.baseName()); | ||
636 | qDebug("openFile string"+currentFileName); | 638 | qDebug("openFile string"+currentFileName); |
637 | 639 | ||
638 | openFile(nf); | 640 | openFile(nf); |
639 | showEditTools(); | 641 | showEditTools(); |
640 | // Show filename in caption | 642 | // Show filename in caption |
641 | QString name = f; | 643 | QString name = f; |
642 | int sep = name.findRev( '/' ); | 644 | int sep = name.findRev( '/' ); |
643 | if ( sep > 0 ) | 645 | if ( sep > 0 ) |
644 | name = name.mid( sep+1 ); | 646 | name = name.mid( sep+1 ); |
645 | updateCaption( name ); | 647 | updateCaption( name ); |
646 | } | 648 | } |
647 | 649 | ||
648 | void TextEdit::openFile( const DocLnk &f ) | 650 | void TextEdit::openFile( const DocLnk &f ) |
649 | { | 651 | { |
650 | // clear(); | 652 | // clear(); |
651 | bFromDocView = TRUE; | 653 | bFromDocView = TRUE; |
652 | FileManager fm; | 654 | FileManager fm; |
653 | QString txt; | 655 | QString txt; |
654 | currentFileName=f.name(); | 656 | currentFileName=f.name(); |
655 | qDebug("openFile doclnk " + currentFileName); | 657 | qDebug("openFile doclnk " + currentFileName); |
656 | if ( !fm.loadFile( f, txt ) ) { | 658 | if ( !fm.loadFile( f, txt ) ) { |
657 | // ####### could be a new file | 659 | // ####### could be a new file |
658 | qDebug( "Cannot open file" ); | 660 | qDebug( "Cannot open file" ); |
659 | 661 | ||
660 | //return; | 662 | //return; |
661 | } | 663 | } |
662 | 664 | ||
663 | fileNew(); | 665 | fileNew(); |
664 | if ( doc ) | 666 | if ( doc ) |
665 | delete doc; | 667 | delete doc; |
666 | doc = new DocLnk(f); | 668 | doc = new DocLnk(f); |
667 | editor->setText(txt); | 669 | editor->setText(txt); |
668 | editor->setEdited( false); | 670 | editor->setEdited( false); |
669 | qDebug("openFile doclnk "+currentFileName); | 671 | qDebug("openFile doclnk "+currentFileName); |
670 | doc->setName(currentFileName); | 672 | doc->setName(currentFileName); |
671 | updateCaption(); | 673 | updateCaption(); |
672 | } | 674 | } |
673 | 675 | ||
674 | void TextEdit::showEditTools() | 676 | void TextEdit::showEditTools() |
675 | { | 677 | { |
676 | // if ( !doc ) | 678 | // if ( !doc ) |
677 | // close(); | 679 | // close(); |
678 | // clear(); | 680 | // clear(); |
679 | fileSelector->hide(); | 681 | fileSelector->hide(); |
680 | menu->show(); | 682 | menu->show(); |
681 | editBar->show(); | 683 | editBar->show(); |
682 | if ( searchVisible ) | 684 | if ( searchVisible ) |
683 | searchBar->show(); | 685 | searchBar->show(); |
684 | // updateCaption(); | 686 | // updateCaption(); |
685 | editorStack->raiseWidget( editor ); | 687 | editorStack->raiseWidget( editor ); |
686 | setWState (WState_Reserved1 ); | 688 | setWState (WState_Reserved1 ); |
687 | } | 689 | } |
688 | 690 | ||
689 | /*! | 691 | /*! |
690 | unprompted save */ | 692 | unprompted save */ |
691 | bool TextEdit::save() | 693 | bool TextEdit::save() |
692 | { | 694 | { |
693 | QString file = doc->file(); | 695 | QString file = doc->file(); |
694 | QString name= doc->name(); | 696 | QString name= doc->name(); |
695 | QString rt = editor->text(); | 697 | QString rt = editor->text(); |
696 | currentFileName= name ; | 698 | currentFileName= name ; |
697 | qDebug("saveFile "+currentFileName); | 699 | qDebug("saveFile "+currentFileName); |
698 | 700 | ||
699 | doc->setName( name); | 701 | doc->setName( name); |