Diffstat (limited to 'core/apps/textedit/textedit.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/apps/textedit/textedit.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 6f96574..1c95a97 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -548,62 +548,60 @@ void TextEdit::setWordWrap(bool y) { | |||
548 | 548 | ||
549 | void TextEdit::setSearchBar(bool b) { | 549 | void TextEdit::setSearchBar(bool b) { |
550 | useSearchBar=b; | 550 | useSearchBar=b; |
551 | Config cfg("TextEdit"); | 551 | Config cfg("TextEdit"); |
552 | cfg.setGroup("View"); | 552 | cfg.setGroup("View"); |
553 | cfg.writeEntry ( "SearchBar", b ); | 553 | cfg.writeEntry ( "SearchBar", b ); |
554 | searchBarAction->setOn(b); | 554 | searchBarAction->setOn(b); |
555 | if(b) | 555 | if(b) |
556 | searchBar->show(); | 556 | searchBar->show(); |
557 | else | 557 | else |
558 | searchBar->hide(); | 558 | searchBar->hide(); |
559 | editor->setFocus(); | 559 | editor->setFocus(); |
560 | } | 560 | } |
561 | 561 | ||
562 | void TextEdit::fileNew() { | 562 | void TextEdit::fileNew() { |
563 | // if( !bFromDocView ) { | 563 | // if( !bFromDocView ) { |
564 | // saveAs(); | 564 | // saveAs(); |
565 | // } | 565 | // } |
566 | newFile(DocLnk()); | 566 | newFile(DocLnk()); |
567 | } | 567 | } |
568 | 568 | ||
569 | void TextEdit::fileOpen() { | 569 | void TextEdit::fileOpen() { |
570 | Config cfg("TextEdit"); | 570 | Config cfg("TextEdit"); |
571 | cfg. setGroup ( "View" ); | 571 | cfg. setGroup ( "View" ); |
572 | QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir()); | ||
573 | QMap<QString, QStringList> map; | 572 | QMap<QString, QStringList> map; |
574 | map.insert(tr("All"), QStringList() ); | 573 | map.insert(tr("All"), QStringList() ); |
575 | QStringList text; | 574 | QStringList text; |
576 | text << "text/*"; | 575 | text << "text/*"; |
577 | map.insert(tr("Text"), text ); | 576 | map.insert(tr("Text"), text ); |
578 | text << "*"; | 577 | text << "*"; |
579 | map.insert(tr("All"), text ); | 578 | map.insert(tr("All"), text ); |
580 | QString str = OFileDialog::getOpenFileName( 2, | 579 | QString str = OFileDialog::getOpenFileName( 2, |
581 | dir , | 580 | QString::null , |
582 | QString::null, map); | 581 | QString::null, map); |
583 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) | 582 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) |
584 | { | 583 | { |
585 | cfg.writeEntry("LastOpenDirectory", QFileInfo(str).dirPath(false)); | ||
586 | openFile( str ); | 584 | openFile( str ); |
587 | } | 585 | } |
588 | else | 586 | else |
589 | updateCaption(); | 587 | updateCaption(); |
590 | } | 588 | } |
591 | 589 | ||
592 | void TextEdit::doSearchBar() { | 590 | void TextEdit::doSearchBar() { |
593 | if(!useSearchBar) | 591 | if(!useSearchBar) |
594 | searchBar->hide(); | 592 | searchBar->hide(); |
595 | else | 593 | else |
596 | searchBar->show(); | 594 | searchBar->show(); |
597 | } | 595 | } |
598 | 596 | ||
599 | #if 0 | 597 | #if 0 |
600 | void TextEdit::slotFind() { | 598 | void TextEdit::slotFind() { |
601 | FindDialog frmFind( tr("Text Editor"), this ); | 599 | FindDialog frmFind( tr("Text Editor"), this ); |
602 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), | 600 | connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), |
603 | editor, SLOT(slotDoFind( const QString&,bool,bool))); | 601 | editor, SLOT(slotDoFind( const QString&,bool,bool))); |
604 | 602 | ||
605 | //case sensitive, backwards, [category] | 603 | //case sensitive, backwards, [category] |
606 | 604 | ||
607 | connect( editor, SIGNAL(notFound()), | 605 | connect( editor, SIGNAL(notFound()), |
608 | &frmFind, SLOT(slotNotFound()) ); | 606 | &frmFind, SLOT(slotNotFound()) ); |
609 | connect( editor, SIGNAL(searchWrapped()), | 607 | connect( editor, SIGNAL(searchWrapped()), |
@@ -955,95 +953,95 @@ bool TextEdit::saveAs() { | |||
955 | qDebug("returning false"); | 953 | qDebug("returning false"); |
956 | return false; | 954 | return false; |
957 | } //end saveAs | 955 | } //end saveAs |
958 | 956 | ||
959 | void TextEdit::clear() { | 957 | void TextEdit::clear() { |
960 | delete doc; | 958 | delete doc; |
961 | doc = 0; | 959 | doc = 0; |
962 | editor->clear(); | 960 | editor->clear(); |
963 | } | 961 | } |
964 | 962 | ||
965 | void TextEdit::updateCaption( const QString &name ) { | 963 | void TextEdit::updateCaption( const QString &name ) { |
966 | 964 | ||
967 | if ( name.isEmpty() ) | 965 | if ( name.isEmpty() ) |
968 | setCaption( tr("Text Editor") ); | 966 | setCaption( tr("Text Editor") ); |
969 | else { | 967 | else { |
970 | QString s = name; | 968 | QString s = name; |
971 | if ( s.isNull() ) | 969 | if ( s.isNull() ) |
972 | s = doc->name(); | 970 | s = doc->name(); |
973 | if ( s.isEmpty() ) { | 971 | if ( s.isEmpty() ) { |
974 | s = tr( "Unnamed" ); | 972 | s = tr( "Unnamed" ); |
975 | currentFileName=s; | 973 | currentFileName=s; |
976 | } | 974 | } |
977 | // if(s.left(1) == "/") | 975 | // if(s.left(1) == "/") |
978 | // s = s.right(s.length()-1); | 976 | // s = s.right(s.length()-1); |
979 | setCaption( s + " - " + tr("Text Editor") ); | 977 | setCaption( tr("%1 - Text Editor").arg( s ) ); |
980 | } | 978 | } |
981 | } | 979 | } |
982 | 980 | ||
983 | void TextEdit::setDocument(const QString& fileref) { | 981 | void TextEdit::setDocument(const QString& fileref) { |
984 | if(fileref != "Unnamed") { | 982 | if(fileref != "Unnamed") { |
985 | currentFileName=fileref; | 983 | currentFileName=fileref; |
986 | qDebug("setDocument"); | 984 | qDebug("setDocument"); |
987 | QFileInfo fi(currentFileName); | 985 | QFileInfo fi(currentFileName); |
988 | qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); | 986 | qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); |
989 | if( (fi.baseName().left(1)).isEmpty() ) { | 987 | if( (fi.baseName().left(1)).isEmpty() ) { |
990 | openDotFile(currentFileName); | 988 | openDotFile(currentFileName); |
991 | 989 | ||
992 | } else { | 990 | } else { |
993 | qDebug("setDoc open"); | 991 | qDebug("setDoc open"); |
994 | bFromDocView = true; | 992 | bFromDocView = true; |
995 | openFile(fileref); | 993 | openFile(fileref); |
996 | editor->setEdited(true); | 994 | editor->setEdited(true); |
997 | edited1=false; | 995 | edited1=false; |
998 | edited=true; | 996 | edited=true; |
999 | // fromSetDocument=false; | 997 | // fromSetDocument=false; |
1000 | // doSearchBar(); | 998 | // doSearchBar(); |
1001 | } | 999 | } |
1002 | } | 1000 | } |
1003 | updateCaption( currentFileName); | 1001 | updateCaption( currentFileName); |
1004 | } | 1002 | } |
1005 | 1003 | ||
1006 | void TextEdit::changeFont() { | 1004 | void TextEdit::changeFont() { |
1007 | QDialog *d = new QDialog ( this, "FontDialog", true ); | 1005 | QDialog *d = new QDialog ( this, "FontDialog", true ); |
1008 | d-> setCaption ( tr( "Choose font" )); | 1006 | d-> setCaption ( tr( "Choose font" )); |
1009 | QBoxLayout *lay = new QVBoxLayout ( d ); | 1007 | QBoxLayout *lay = new QVBoxLayout ( d ); |
1010 | OFontSelector *ofs = new OFontSelector ( true, d ); | 1008 | OFontSelector *ofs = new OFontSelector ( true, d ); |
1011 | lay-> addWidget ( ofs ); | 1009 | lay-> addWidget ( ofs ); |
1012 | ofs-> setSelectedFont ( editor-> font ( )); | 1010 | ofs-> setSelectedFont ( editor-> font ( )); |
1013 | 1011 | ||
1014 | d-> showMaximized ( ); | 1012 | d-> showMaximized ( ); |
1015 | if ( d-> exec ( ) == QDialog::Accepted ) | 1013 | if ( d-> exec ( ) == QDialog::Accepted ) |
1016 | editor-> setFont ( ofs-> selectedFont ( )); | 1014 | editor-> setFont ( ofs-> selectedFont ( )); |
1017 | delete d; | 1015 | delete d; |
1018 | 1016 | ||
1019 | } | 1017 | } |
1020 | 1018 | ||
1021 | void TextEdit::editDelete() { | 1019 | void TextEdit::editDelete() { |
1022 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 1020 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
1023 | tr("Do you really want<BR>to <B>delete</B> " | 1021 | tr("Do you really want<BR>to <B>delete</B> " |
1024 | "the current file\nfrom the disk?<BR>This is " | 1022 | "the current file\nfrom the disk?<BR>This is " |
1025 | "<B>irreversable!!</B>"), | 1023 | "<B>irreversable!</B>"), |
1026 | tr("Yes"),tr("No"),0,0,1) ) { | 1024 | tr("Yes"),tr("No"),0,0,1) ) { |
1027 | case 0: | 1025 | case 0: |
1028 | if(doc) { | 1026 | if(doc) { |
1029 | doc->removeFiles(); | 1027 | doc->removeFiles(); |
1030 | clear(); | 1028 | clear(); |
1031 | setCaption( tr("Text Editor") ); | 1029 | setCaption( tr("Text Editor") ); |
1032 | } | 1030 | } |
1033 | break; | 1031 | break; |
1034 | case 1: | 1032 | case 1: |
1035 | // exit | 1033 | // exit |
1036 | break; | 1034 | break; |
1037 | }; | 1035 | }; |
1038 | } | 1036 | } |
1039 | 1037 | ||
1040 | void TextEdit::changeStartConfig( bool b ) { | 1038 | void TextEdit::changeStartConfig( bool b ) { |
1041 | startWithNew=b; | 1039 | startWithNew=b; |
1042 | Config cfg("TextEdit"); | 1040 | Config cfg("TextEdit"); |
1043 | cfg.setGroup("View"); | 1041 | cfg.setGroup("View"); |
1044 | cfg.writeEntry("startNew",b); | 1042 | cfg.writeEntry("startNew",b); |
1045 | update(); | 1043 | update(); |
1046 | } | 1044 | } |
1047 | 1045 | ||
1048 | void TextEdit::editorChanged() { | 1046 | void TextEdit::editorChanged() { |
1049 | // qDebug("editor changed"); | 1047 | // qDebug("editor changed"); |