summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-02-28 17:44:25 (UTC)
committer llornkcor <llornkcor>2003-02-28 17:44:25 (UTC)
commit92c322fc6500de8c33409e0cecb25bf655bee8bc (patch) (unidiff)
tree1c032dcc5ed8d61fb77e7e006adfa7414414c7e4
parent592904b2664c6fa3dbb4590b80a8552475995366 (diff)
downloadopie-92c322fc6500de8c33409e0cecb25bf655bee8bc.zip
opie-92c322fc6500de8c33409e0cecb25bf655bee8bc.tar.gz
opie-92c322fc6500de8c33409e0cecb25bf655bee8bc.tar.bz2
allow open file to remember last directory
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index ce868d6..2f62789 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -510,140 +510,146 @@ void TextEdit::setFontSize(int sz, bool round_down_not_up) {
510 if ( fontsize[i] < sz ) 510 if ( fontsize[i] < sz )
511 s = fontsize[i]; 511 s = fontsize[i];
512 } else { 512 } else {
513 if ( fontsize[i] > sz ) { 513 if ( fontsize[i] > sz ) {
514 s = fontsize[i]; 514 s = fontsize[i];
515 break; 515 break;
516 } 516 }
517 } 517 }
518 } 518 }
519 519
520 QFont f = editor->font(); 520 QFont f = editor->font();
521 f.setPointSize(s); 521 f.setPointSize(s);
522 editor->setFont(f); 522 editor->setFont(f);
523 523
524 zin->setEnabled(s != fontsize[nfontsizes-1]); 524 zin->setEnabled(s != fontsize[nfontsizes-1]);
525 zout->setEnabled(s != fontsize[0]); 525 zout->setEnabled(s != fontsize[0]);
526} 526}
527 527
528void TextEdit::setBold(bool y) { 528void TextEdit::setBold(bool y) {
529 QFont f = editor->font(); 529 QFont f = editor->font();
530 f.setBold(y); 530 f.setBold(y);
531 editor->setFont(f); 531 editor->setFont(f);
532} 532}
533 533
534void TextEdit::setItalic(bool y) { 534void TextEdit::setItalic(bool y) {
535 QFont f = editor->font(); 535 QFont f = editor->font();
536 f.setItalic(y); 536 f.setItalic(y);
537 editor->setFont(f); 537 editor->setFont(f);
538} 538}
539 539
540void TextEdit::setWordWrap(bool y) { 540void TextEdit::setWordWrap(bool y) {
541 bool state = editor->edited(); 541 bool state = editor->edited();
542 QString captionStr = caption(); 542 QString captionStr = caption();
543 bool b1 = edited1; 543 bool b1 = edited1;
544 bool b2 = edited; 544 bool b2 = edited;
545 545
546 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); 546 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
547 editor->setEdited( state ); 547 editor->setEdited( state );
548 edited1=b1; 548 edited1=b1;
549 edited=b2; 549 edited=b2;
550 setCaption(captionStr); 550 setCaption(captionStr);
551} 551}
552 552
553void TextEdit::setSearchBar(bool b) { 553void TextEdit::setSearchBar(bool b) {
554 useSearchBar=b; 554 useSearchBar=b;
555 Config cfg("TextEdit"); 555 Config cfg("TextEdit");
556 cfg.setGroup("View"); 556 cfg.setGroup("View");
557 cfg.writeEntry ( "SearchBar", b ); 557 cfg.writeEntry ( "SearchBar", b );
558 searchBarAction->setOn(b); 558 searchBarAction->setOn(b);
559 if(b) 559 if(b)
560 searchBar->show(); 560 searchBar->show();
561 else 561 else
562 searchBar->hide(); 562 searchBar->hide();
563 editor->setFocus(); 563 editor->setFocus();
564} 564}
565 565
566void TextEdit::fileNew() { 566void TextEdit::fileNew() {
567// if( !bFromDocView ) { 567// if( !bFromDocView ) {
568// saveAs(); 568// saveAs();
569// } 569// }
570 newFile(DocLnk()); 570 newFile(DocLnk());
571} 571}
572 572
573void TextEdit::fileOpen() { 573void TextEdit::fileOpen() {
574 Config cfg("TextEdit");
575 cfg. setGroup ( "View" );
576 QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir());
574 QMap<QString, QStringList> map; 577 QMap<QString, QStringList> map;
575 map.insert(tr("All"), QStringList() ); 578 map.insert(tr("All"), QStringList() );
576 QStringList text; 579 QStringList text;
577 text << "text/*"; 580 text << "text/*";
578 map.insert(tr("Text"), text ); 581 map.insert(tr("Text"), text );
579 text << "*"; 582 text << "*";
580 map.insert(tr("All"), text ); 583 map.insert(tr("All"), text );
581 QString str = OFileDialog::getOpenFileName( 2, 584 QString str = OFileDialog::getOpenFileName( 2,
582 QPEApplication::documentDir(), 585 dir ,
583 QString::null, map); 586 QString::null, map);
584 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) 587 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() )
585 openFile( str ); 588 {
589 cfg.writeEntry("LastOpenDirectory", QFileInfo(str).dirPath(false));
590 openFile( str );
591 }
586 else 592 else
587 updateCaption(); 593 updateCaption();
588} 594}
589 595
590void TextEdit::doSearchBar() { 596void TextEdit::doSearchBar() {
591 if(!useSearchBar) 597 if(!useSearchBar)
592 searchBar->hide(); 598 searchBar->hide();
593 else 599 else
594 searchBar->show(); 600 searchBar->show();
595} 601}
596 602
597#if 0 603#if 0
598void TextEdit::slotFind() { 604void TextEdit::slotFind() {
599 FindDialog frmFind( tr("Text Editor"), this ); 605 FindDialog frmFind( tr("Text Editor"), this );
600 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 606 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
601 editor, SLOT(slotDoFind( const QString&,bool,bool))); 607 editor, SLOT(slotDoFind( const QString&,bool,bool)));
602 608
603 //case sensitive, backwards, [category] 609 //case sensitive, backwards, [category]
604 610
605 connect( editor, SIGNAL(notFound()), 611 connect( editor, SIGNAL(notFound()),
606 &frmFind, SLOT(slotNotFound()) ); 612 &frmFind, SLOT(slotNotFound()) );
607 connect( editor, SIGNAL(searchWrapped()), 613 connect( editor, SIGNAL(searchWrapped()),
608 &frmFind, SLOT(slotWrapAround()) ); 614 &frmFind, SLOT(slotWrapAround()) );
609 615
610 frmFind.exec(); 616 frmFind.exec();
611 617
612 618
613} 619}
614#endif 620#endif
615 621
616void TextEdit::fileRevert() { 622void TextEdit::fileRevert() {
617 clear(); 623 clear();
618 fileOpen(); 624 fileOpen();
619} 625}
620 626
621void TextEdit::editCut() { 627void TextEdit::editCut() {
622#ifndef QT_NO_CLIPBOARD 628#ifndef QT_NO_CLIPBOARD
623 editor->cut(); 629 editor->cut();
624#endif 630#endif
625} 631}
626 632
627void TextEdit::editCopy() { 633void TextEdit::editCopy() {
628#ifndef QT_NO_CLIPBOARD 634#ifndef QT_NO_CLIPBOARD
629 editor->copy(); 635 editor->copy();
630#endif 636#endif
631} 637}
632 638
633void TextEdit::editPaste() { 639void TextEdit::editPaste() {
634#ifndef QT_NO_CLIPBOARD 640#ifndef QT_NO_CLIPBOARD
635 editor->paste(); 641 editor->paste();
636#endif 642#endif
637} 643}
638 644
639void TextEdit::editFind() { 645void TextEdit::editFind() {
640 searchBar->show(); 646 searchBar->show();
641 searchEdit->setFocus(); 647 searchEdit->setFocus();
642} 648}
643 649
644void TextEdit::findNext() { 650void TextEdit::findNext() {
645 editor->find( searchEdit->text(), false, false ); 651 editor->find( searchEdit->text(), false, false );
646 652
647} 653}
648 654
649void TextEdit::findClose() { 655void TextEdit::findClose() {