-rw-r--r-- | core/apps/textedit/textedit.cpp | 24 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 5 |
2 files changed, 23 insertions, 6 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index b276cbb..0af18da 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -297,102 +297,111 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
297 | a->addTo( edit ); | 297 | a->addTo( edit ); |
298 | 298 | ||
299 | int defsize; | 299 | int defsize; |
300 | bool defb, defi, wrap; | 300 | bool defb, defi, wrap; |
301 | 301 | ||
302 | Config cfg("TextEdit"); | 302 | Config cfg("TextEdit"); |
303 | cfg.setGroup("View"); | 303 | cfg.setGroup("View"); |
304 | defsize = cfg.readNumEntry("FontSize",10); | 304 | defsize = cfg.readNumEntry("FontSize",10); |
305 | defb = cfg.readBoolEntry("Bold",FALSE); | 305 | defb = cfg.readBoolEntry("Bold",FALSE); |
306 | defi = cfg.readBoolEntry("Italic",FALSE); | 306 | defi = cfg.readBoolEntry("Italic",FALSE); |
307 | wrap = cfg.readBoolEntry("Wrap",TRUE); | 307 | wrap = cfg.readBoolEntry("Wrap",TRUE); |
308 | 308 | ||
309 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 309 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
310 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 310 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
311 | zin->addTo( font ); | 311 | zin->addTo( font ); |
312 | 312 | ||
313 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 313 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
314 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 314 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
315 | zout->addTo( font ); | 315 | zout->addTo( font ); |
316 | 316 | ||
317 | font->insertSeparator(); | 317 | font->insertSeparator(); |
318 | 318 | ||
319 | #if 0 | 319 | #if 0 |
320 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); | 320 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); |
321 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); | 321 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); |
322 | ba->setToggleAction(TRUE); | 322 | ba->setToggleAction(TRUE); |
323 | ba->addTo( font ); | 323 | ba->addTo( font ); |
324 | 324 | ||
325 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); | 325 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); |
326 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); | 326 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); |
327 | ia->setToggleAction(TRUE); | 327 | ia->setToggleAction(TRUE); |
328 | ia->addTo( font ); | 328 | ia->addTo( font ); |
329 | 329 | ||
330 | ba->setOn(defb); | 330 | ba->setOn(defb); |
331 | ia->setOn(defi); | 331 | ia->setOn(defi); |
332 | 332 | ||
333 | font->insertSeparator(); | 333 | font->insertSeparator(); |
334 | #endif | 334 | #endif |
335 | 335 | ||
336 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); | 336 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); |
337 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); | 337 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); |
338 | wa->setToggleAction(TRUE); | 338 | wa->setToggleAction(TRUE); |
339 | wa->addTo( font ); | 339 | wa->addTo( font ); |
340 | 340 | ||
341 | font->insertSeparator(); | 341 | font->insertSeparator(); |
342 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); | 342 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); |
343 | 343 | ||
344 | font->insertSeparator(); | 344 | font->insertSeparator(); |
345 | |||
345 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); | 346 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); |
346 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); | 347 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); |
347 | nStart->setToggleAction(TRUE); | 348 | nStart->setToggleAction(TRUE); |
348 | nStart->addTo( font ); | 349 | nStart->addTo( font ); |
350 | |||
351 | nAdvanced = new QAction( tr("Advanced features"), QString::null, 0, this, 0 ); | ||
352 | connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doAdvanced(bool) ) ); | ||
353 | nAdvanced->setToggleAction(TRUE); | ||
354 | nAdvanced->addTo( font ); | ||
355 | if(cfg.readBoolEntry("AdvancedFeatures")) | ||
356 | nAdvanced->setOn(TRUE); | ||
349 | font->insertSeparator(); | 357 | font->insertSeparator(); |
350 | font->insertItem(tr("About"), this, SLOT( doAbout()) ); | 358 | |
359 | font->insertItem(tr("About"), this, SLOT( doAbout()) ); | ||
351 | 360 | ||
352 | mb->insertItem( tr( "File" ), file ); | 361 | mb->insertItem( tr( "File" ), file ); |
353 | mb->insertItem( tr( "Edit" ), edit ); | 362 | mb->insertItem( tr( "Edit" ), edit ); |
354 | mb->insertItem( tr( "View" ), font ); | 363 | mb->insertItem( tr( "View" ), font ); |
355 | 364 | ||
356 | searchBar = new QPEToolBar(this); | 365 | searchBar = new QPEToolBar(this); |
357 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 366 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
358 | 367 | ||
359 | searchBar->setHorizontalStretchable( TRUE ); | 368 | searchBar->setHorizontalStretchable( TRUE ); |
360 | 369 | ||
361 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 370 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
362 | searchBar->setStretchableWidget( searchEdit ); | 371 | searchBar->setStretchableWidget( searchEdit ); |
363 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 372 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
364 | this, SLOT( search() ) ); | 373 | this, SLOT( search() ) ); |
365 | 374 | ||
366 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | 375 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); |
367 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 376 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
368 | a->addTo( searchBar ); | 377 | a->addTo( searchBar ); |
369 | a->addTo( edit ); | 378 | a->addTo( edit ); |
370 | 379 | ||
371 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 380 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
372 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 381 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
373 | a->addTo( searchBar ); | 382 | a->addTo( searchBar ); |
374 | 383 | ||
375 | edit->insertSeparator(); | 384 | edit->insertSeparator(); |
376 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 385 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
377 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 386 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
378 | a->addTo( edit ); | 387 | a->addTo( edit ); |
379 | 388 | ||
380 | searchBar->hide(); | 389 | searchBar->hide(); |
381 | 390 | ||
382 | editor = new QpeEditor( this ); | 391 | editor = new QpeEditor( this ); |
383 | setCentralWidget( editor ); | 392 | setCentralWidget( editor ); |
384 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 393 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
385 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); | 394 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); |
386 | 395 | ||
387 | // resize( 200, 300 ); | 396 | // resize( 200, 300 ); |
388 | 397 | ||
389 | // setFontSize(defsize,TRUE); | 398 | // setFontSize(defsize,TRUE); |
390 | FontDatabase fdb; | 399 | FontDatabase fdb; |
391 | QFont defaultFont=editor->font(); | 400 | QFont defaultFont=editor->font(); |
392 | QFontInfo fontInfo(defaultFont); | 401 | QFontInfo fontInfo(defaultFont); |
393 | 402 | ||
394 | cfg.setGroup("Font"); | 403 | cfg.setGroup("Font"); |
395 | QString family = cfg.readEntry("Family", fontInfo.family()); | 404 | QString family = cfg.readEntry("Family", fontInfo.family()); |
396 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 405 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
397 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 406 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
398 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 407 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
@@ -578,97 +587,97 @@ void TextEdit::editFind() | |||
578 | searchVisible = TRUE; | 587 | searchVisible = TRUE; |
579 | searchEdit->setFocus(); | 588 | searchEdit->setFocus(); |
580 | Config cfg("TextEdit"); | 589 | Config cfg("TextEdit"); |
581 | cfg.setGroup("View"); | 590 | cfg.setGroup("View"); |
582 | cfg.writeEntry("SearchBar","Opened"); | 591 | cfg.writeEntry("SearchBar","Opened"); |
583 | 592 | ||
584 | } | 593 | } |
585 | 594 | ||
586 | void TextEdit::findNext() | 595 | void TextEdit::findNext() |
587 | { | 596 | { |
588 | editor->find( searchEdit->text(), FALSE, FALSE ); | 597 | editor->find( searchEdit->text(), FALSE, FALSE ); |
589 | 598 | ||
590 | } | 599 | } |
591 | 600 | ||
592 | void TextEdit::findClose() | 601 | void TextEdit::findClose() |
593 | { | 602 | { |
594 | searchVisible = FALSE; | 603 | searchVisible = FALSE; |
595 | searchBar->hide(); | 604 | searchBar->hide(); |
596 | Config cfg("TextEdit"); | 605 | Config cfg("TextEdit"); |
597 | cfg.setGroup("View"); | 606 | cfg.setGroup("View"); |
598 | cfg.writeEntry("SearchBar","Closed"); | 607 | cfg.writeEntry("SearchBar","Closed"); |
599 | cfg.write(); | 608 | cfg.write(); |
600 | } | 609 | } |
601 | 610 | ||
602 | void TextEdit::search() | 611 | void TextEdit::search() |
603 | { | 612 | { |
604 | editor->find( searchEdit->text(), FALSE, FALSE ); | 613 | editor->find( searchEdit->text(), FALSE, FALSE ); |
605 | } | 614 | } |
606 | 615 | ||
607 | void TextEdit::newFile( const DocLnk &f ) | 616 | void TextEdit::newFile( const DocLnk &f ) |
608 | { | 617 | { |
609 | DocLnk nf = f; | 618 | DocLnk nf = f; |
610 | nf.setType("text/plain"); | 619 | nf.setType("text/plain"); |
611 | clear(); | 620 | clear(); |
612 | setWState (WState_Reserved1 ); | 621 | setWState (WState_Reserved1 ); |
613 | editor->setFocus(); | 622 | editor->setFocus(); |
614 | doc = new DocLnk(nf); | 623 | doc = new DocLnk(nf); |
615 | currentFileName = "Unnamed"; | 624 | currentFileName = "Unnamed"; |
616 | qDebug("newFile "+currentFileName); | 625 | qDebug("newFile "+currentFileName); |
617 | updateCaption( currentFileName); | 626 | updateCaption( currentFileName); |
618 | // editor->setEdited( FALSE); | 627 | // editor->setEdited( FALSE); |
619 | } | 628 | } |
620 | 629 | ||
621 | void TextEdit::openFile( const QString &f ) | 630 | void TextEdit::openFile( const QString &f ) |
622 | { | 631 | { |
623 | qDebug("filename is "+ f); | 632 | qDebug("filename is "+ f); |
624 | QString filer; | 633 | QString filer; |
625 | // bFromDocView = TRUE; | 634 | // bFromDocView = TRUE; |
626 | if(f.find(".desktop",0,TRUE) != -1) { | 635 | if(f.find(".desktop",0,TRUE) != -1 && useAdvancedFeatures) { |
627 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 636 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
628 | tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"), | 637 | tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"), |
629 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) { | 638 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) { |
630 | case 0: | 639 | case 0: |
631 | filer = f; | 640 | filer = f; |
632 | break; | 641 | break; |
633 | case 1: | 642 | case 1: |
634 | DocLnk sf(f); | 643 | DocLnk sf(f); |
635 | filer = sf.file(); | 644 | filer = sf.file(); |
636 | break; | 645 | break; |
637 | } | 646 | } |
638 | } else { | 647 | } else { |
639 | filer = f; | 648 | filer = f; |
640 | fileIs = TRUE; | 649 | fileIs = TRUE; |
641 | } | 650 | } |
642 | 651 | ||
643 | DocLnk nf; | 652 | DocLnk nf; |
644 | nf.setType("text/plain"); | 653 | nf.setType("text/plain"); |
645 | nf.setFile(filer); | 654 | nf.setFile(filer); |
646 | currentFileName=filer; | 655 | currentFileName=filer; |
647 | QFileInfo fi( currentFileName); | 656 | QFileInfo fi( currentFileName); |
648 | nf.setName(fi.baseName()); | 657 | nf.setName(fi.baseName()); |
649 | qDebug("openFile string "+currentFileName); | 658 | qDebug("openFile string "+currentFileName); |
650 | 659 | ||
651 | openFile(nf); | 660 | openFile(nf); |
652 | showEditTools(); | 661 | showEditTools(); |
653 | // Show filename in caption | 662 | // Show filename in caption |
654 | QString name = filer; | 663 | QString name = filer; |
655 | int sep = name.findRev( '/' ); | 664 | int sep = name.findRev( '/' ); |
656 | if ( sep > 0 ) | 665 | if ( sep > 0 ) |
657 | name = name.mid( sep+1 ); | 666 | name = name.mid( sep+1 ); |
658 | updateCaption( name ); | 667 | updateCaption( name ); |
659 | } | 668 | } |
660 | 669 | ||
661 | void TextEdit::openFile( const DocLnk &f ) | 670 | void TextEdit::openFile( const DocLnk &f ) |
662 | { | 671 | { |
663 | // clear(); | 672 | // clear(); |
664 | // bFromDocView = TRUE; | 673 | // bFromDocView = TRUE; |
665 | FileManager fm; | 674 | FileManager fm; |
666 | QString txt; | 675 | QString txt; |
667 | currentFileName=f.file(); | 676 | currentFileName=f.file(); |
668 | qDebug("openFile doclnk " + currentFileName); | 677 | qDebug("openFile doclnk " + currentFileName); |
669 | if ( !fm.loadFile( f, txt ) ) { | 678 | if ( !fm.loadFile( f, txt ) ) { |
670 | // ####### could be a new file | 679 | // ####### could be a new file |
671 | qDebug( "Cannot open file" ); | 680 | qDebug( "Cannot open file" ); |
672 | } | 681 | } |
673 | // fileNew(); | 682 | // fileNew(); |
674 | if ( doc ) | 683 | if ( doc ) |
@@ -778,104 +787,104 @@ bool TextEdit::saveAs() | |||
778 | if ( i > 0 ) | 787 | if ( i > 0 ) |
779 | docname = pt.left( i ); | 788 | docname = pt.left( i ); |
780 | // remove "." at the beginning | 789 | // remove "." at the beginning |
781 | while( docname.startsWith( "." ) ) | 790 | while( docname.startsWith( "." ) ) |
782 | docname = docname.mid( 1 ); | 791 | docname = docname.mid( 1 ); |
783 | docname.replace( QRegExp("/"), "_" ); | 792 | docname.replace( QRegExp("/"), "_" ); |
784 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. | 793 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. |
785 | if ( docname.length() > 40 ) | 794 | if ( docname.length() > 40 ) |
786 | docname = docname.left(40); | 795 | docname = docname.left(40); |
787 | if ( docname.isEmpty() ) | 796 | if ( docname.isEmpty() ) |
788 | docname = tr("Unnamed"); | 797 | docname = tr("Unnamed"); |
789 | doc->setName(docname); | 798 | doc->setName(docname); |
790 | currentFileName=docname; | 799 | currentFileName=docname; |
791 | } | 800 | } |
792 | } | 801 | } |
793 | 802 | ||
794 | QMap<QString, QStringList> map; | 803 | QMap<QString, QStringList> map; |
795 | map.insert(tr("All"), QStringList() ); | 804 | map.insert(tr("All"), QStringList() ); |
796 | QStringList text; | 805 | QStringList text; |
797 | text << "text/*"; | 806 | text << "text/*"; |
798 | map.insert(tr("Text"), text ); | 807 | map.insert(tr("Text"), text ); |
799 | text << "*"; | 808 | text << "*"; |
800 | map.insert(tr("All"), text ); | 809 | map.insert(tr("All"), text ); |
801 | QString str = OFileDialog::getSaveFileName( 2,"/", QString::null, map); | 810 | QString str = OFileDialog::getSaveFileName( 2,"/", QString::null, map); |
802 | if(!str.isEmpty() ) { | 811 | if(!str.isEmpty() ) { |
803 | QString fileNm=str; | 812 | QString fileNm=str; |
804 | 813 | ||
805 | qDebug("saving filename "+fileNm); | 814 | qDebug("saving filename "+fileNm); |
806 | QFileInfo fi(fileNm); | 815 | QFileInfo fi(fileNm); |
807 | currentFileName=fi.fileName(); | 816 | currentFileName=fi.fileName(); |
808 | if(doc) { | 817 | if(doc) { |
809 | // QString file = doc->file(); | 818 | // QString file = doc->file(); |
810 | // doc->removeFiles(); | 819 | // doc->removeFiles(); |
811 | delete doc; | 820 | delete doc; |
812 | DocLnk nf; | 821 | DocLnk nf; |
813 | nf.setType("text/plain"); | 822 | nf.setType("text/plain"); |
814 | nf.setFile( fileNm); | 823 | nf.setFile( fileNm); |
815 | doc = new DocLnk(nf); | 824 | doc = new DocLnk(nf); |
816 | // editor->setText(rt); | 825 | // editor->setText(rt); |
817 | // qDebug("openFile doclnk "+currentFileName); | 826 | // qDebug("openFile doclnk "+currentFileName); |
818 | doc->setName( currentFileName); | 827 | doc->setName( currentFileName); |
819 | updateCaption( currentFileName); | 828 | updateCaption( currentFileName); |
820 | 829 | ||
821 | FileManager fm; | 830 | FileManager fm; |
822 | if ( !fm.saveFile( *doc, rt ) ) { | 831 | if ( !fm.saveFile( *doc, rt ) ) { |
823 | return false; | 832 | return false; |
824 | } | 833 | } |
825 | 834 | ||
826 | // if( fileSaveDlg->filePermCheck->isChecked() ) { | 835 | if( useAdvancedFfeatures ) { |
827 | filePermissions *filePerm; | 836 | filePermissions *filePerm; |
828 | filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm); | 837 | filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm); |
829 | filePerm->exec(); | 838 | filePerm->exec(); |
830 | 839 | ||
831 | if( filePerm) | 840 | if( filePerm) |
832 | delete filePerm; | 841 | delete filePerm; |
833 | // } | 842 | } |
834 | } | 843 | } |
835 | } | 844 | } |
836 | editor->setEdited(TRUE); | 845 | editor->setEdited(TRUE); |
837 | edited1=FALSE; | 846 | edited1=FALSE; |
838 | edited=TRUE; | 847 | edited=TRUE; |
839 | if(caption().left(1)=="*") | 848 | if(caption().left(1)=="*") |
840 | setCaption(caption().right(caption().length()-1)); | 849 | setCaption(caption().right(caption().length()-1)); |
841 | 850 | ||
842 | return true; | 851 | return true; |
843 | } //end saveAs | 852 | } //end saveAs |
844 | 853 | ||
845 | void TextEdit::clear() | 854 | void TextEdit::clear() |
846 | { | 855 | { |
847 | delete doc; | 856 | delete doc; |
848 | doc = 0; | 857 | doc = 0; |
849 | editor->clear(); | 858 | editor->clear(); |
850 | } | 859 | } |
851 | 860 | ||
852 | void TextEdit::updateCaption( const QString &name ) | 861 | void TextEdit::updateCaption( const QString &name ) |
853 | { | 862 | { |
854 | if ( !doc ) | 863 | if ( !doc ) |
855 | setCaption( tr("Text Editor") ); | 864 | setCaption( tr("Text Editor") ); |
856 | else { | 865 | else { |
857 | QString s = name; | 866 | QString s = name; |
858 | if ( s.isNull() ) | 867 | if ( s.isNull() ) |
859 | s = doc->name(); | 868 | s = doc->name(); |
860 | if ( s.isEmpty() ) { | 869 | if ( s.isEmpty() ) { |
861 | s = tr( "Unnamed" ); | 870 | s = tr( "Unnamed" ); |
862 | currentFileName=s; | 871 | currentFileName=s; |
863 | } | 872 | } |
864 | if(s.left(1) == "/") | 873 | if(s.left(1) == "/") |
865 | s = s.right(s.length()-1); | 874 | s = s.right(s.length()-1); |
866 | setCaption( s + " - " + tr("Text Editor") ); | 875 | setCaption( s + " - " + tr("Text Editor") ); |
867 | } | 876 | } |
868 | } | 877 | } |
869 | 878 | ||
870 | void TextEdit::setDocument(const QString& fileref) | 879 | void TextEdit::setDocument(const QString& fileref) |
871 | { | 880 | { |
872 | bFromDocView = TRUE; | 881 | bFromDocView = TRUE; |
873 | openFile(fileref); | 882 | openFile(fileref); |
874 | editor->setEdited(TRUE); | 883 | editor->setEdited(TRUE); |
875 | edited1=FALSE; | 884 | edited1=FALSE; |
876 | edited=TRUE; | 885 | edited=TRUE; |
877 | doSearchBar(); | 886 | doSearchBar(); |
878 | } | 887 | } |
879 | 888 | ||
880 | void TextEdit::closeEvent( QCloseEvent *e ) | 889 | void TextEdit::closeEvent( QCloseEvent *e ) |
881 | { | 890 | { |
@@ -921,48 +930,55 @@ void TextEdit::editDelete() | |||
921 | 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) ) { | 930 | 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) ) { |
922 | case 0: | 931 | case 0: |
923 | if(doc) { | 932 | if(doc) { |
924 | doc->removeFiles(); | 933 | doc->removeFiles(); |
925 | clear(); | 934 | clear(); |
926 | setCaption( tr("Text Editor") ); | 935 | setCaption( tr("Text Editor") ); |
927 | } | 936 | } |
928 | break; | 937 | break; |
929 | case 1: | 938 | case 1: |
930 | // exit | 939 | // exit |
931 | break; | 940 | break; |
932 | }; | 941 | }; |
933 | } | 942 | } |
934 | 943 | ||
935 | void TextEdit::changeStartConfig( bool b ) { | 944 | void TextEdit::changeStartConfig( bool b ) { |
936 | 945 | ||
937 | Config cfg("TextEdit"); | 946 | Config cfg("TextEdit"); |
938 | cfg.setGroup("View"); | 947 | cfg.setGroup("View"); |
939 | if(b) { | 948 | if(b) { |
940 | qDebug("bool"); | 949 | qDebug("bool"); |
941 | cfg.writeEntry("startNew","TRUE"); | 950 | cfg.writeEntry("startNew","TRUE"); |
942 | } else { | 951 | } else { |
943 | cfg.writeEntry("startNew","FALSE"); | 952 | cfg.writeEntry("startNew","FALSE"); |
944 | } | 953 | } |
945 | update(); | 954 | update(); |
946 | } | 955 | } |
947 | 956 | ||
948 | void TextEdit::editorChanged() { | 957 | void TextEdit::editorChanged() { |
949 | if(editor->edited() && edited && !edited1) { | 958 | if(editor->edited() && edited && !edited1) { |
950 | setCaption( "*"+caption()); | 959 | setCaption( "*"+caption()); |
951 | edited1=TRUE; | 960 | edited1=TRUE; |
952 | } | 961 | } |
953 | edited=TRUE; | 962 | edited=TRUE; |
954 | } | 963 | } |
955 | 964 | ||
956 | void TextEdit::receive(const QCString&msg, const QByteArray&) { | 965 | void TextEdit::receive(const QCString&msg, const QByteArray&) { |
957 | qDebug("QCop "+msg); | 966 | qDebug("QCop "+msg); |
958 | if ( msg == "setDocument(QString)" ) { | 967 | if ( msg == "setDocument(QString)" ) { |
959 | qDebug("bugger all"); | 968 | qDebug("bugger all"); |
960 | } | 969 | } |
961 | 970 | ||
962 | } | 971 | } |
963 | void TextEdit::doAbout() { | 972 | void TextEdit::doAbout() { |
964 | QMessageBox::about(0,"Text Edit","Text Edit is copyright\n" | 973 | QMessageBox::about(0,"Text Edit","Text Edit is copyright\n" |
965 | "2000 Trolltech AS, and\n" | 974 | "2000 Trolltech AS, and\n" |
966 | "2002 by L.J.Potter \nljp@llornkcor.com\n" | 975 | "2002 by L.J.Potter \nljp@llornkcor.com\n" |
967 | "and is licensed under the GPL"); | 976 | "and is licensed under the GPL"); |
968 | } | 977 | } |
978 | |||
979 | void TextEdit::doAdvanced(bool b) { | ||
980 | useAdvancedFeatures=b; | ||
981 | Config cfg("TextEdit"); | ||
982 | cfg.setGroup("View"); | ||
983 | cfg.writeEntry("AdvancedFeatures",b); | ||
984 | } | ||
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h index 764d852..aec6427 100644 --- a/core/apps/textedit/textedit.h +++ b/core/apps/textedit/textedit.h | |||
@@ -12,108 +12,109 @@ | |||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // additions made by L.J. Potter Sun 02-17-2002 22:27:46 | 20 | // additions made by L.J. Potter Sun 02-17-2002 22:27:46 |
21 | 21 | ||
22 | #ifndef TEXTEDIT_H | 22 | #ifndef TEXTEDIT_H |
23 | #define TEXTEDIT_H | 23 | #define TEXTEDIT_H |
24 | 24 | ||
25 | #define QTEXTEDIT_OPEN_API | 25 | #define QTEXTEDIT_OPEN_API |
26 | 26 | ||
27 | //#include "fileBrowser.h" | 27 | //#include "fileBrowser.h" |
28 | //#include "fileSaver.h" | 28 | //#include "fileSaver.h" |
29 | 29 | ||
30 | #include <qpe/filemanager.h> | 30 | #include <qpe/filemanager.h> |
31 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
32 | 32 | ||
33 | #include <opie/ofileselector.h> | 33 | #include <opie/ofileselector.h> |
34 | 34 | ||
35 | #include <qmainwindow.h> | 35 | #include <qmainwindow.h> |
36 | #include <qmultilineedit.h> | 36 | #include <qmultilineedit.h> |
37 | #include <qlist.h> | 37 | #include <qlist.h> |
38 | #include <qmap.h> | 38 | #include <qmap.h> |
39 | 39 | ||
40 | class QAction; | 40 | class QAction; |
41 | class QWidgetStack; | 41 | class QWidgetStack; |
42 | class QToolButton; | 42 | class QToolButton; |
43 | class QPopupMenu; | 43 | class QPopupMenu; |
44 | class QToolBar; | 44 | class QToolBar; |
45 | class QLineEdit; | 45 | class QLineEdit; |
46 | class QAction; | 46 | class QAction; |
47 | class FileSelector; | 47 | class FileSelector; |
48 | class QpeEditor; | 48 | class QpeEditor; |
49 | class QPopupMenu; | 49 | class QPopupMenu; |
50 | 50 | ||
51 | class TextEdit : public QMainWindow | 51 | class TextEdit : public QMainWindow |
52 | { | 52 | { |
53 | Q_OBJECT | 53 | Q_OBJECT |
54 | 54 | ||
55 | public: | 55 | public: |
56 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 56 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
57 | ~TextEdit(); | 57 | ~TextEdit(); |
58 | 58 | ||
59 | QPopupMenu *font; | 59 | QPopupMenu *font; |
60 | QAction *nStart, *nFileDlgOpt; | 60 | QAction *nStart, *nFileDlgOpt, *nAdvanced; |
61 | bool edited, edited1; | 61 | bool edited, edited1; |
62 | void openFile( const QString & ); | 62 | void openFile( const QString & ); |
63 | QCopChannel * channel; | 63 | QCopChannel * channel; |
64 | public slots: | 64 | public slots: |
65 | void editorChanged(); | 65 | void editorChanged(); |
66 | void receive(const QCString&, const QByteArray&); | 66 | void receive(const QCString&, const QByteArray&); |
67 | protected: | 67 | protected: |
68 | bool fileIs; | 68 | bool fileIs, useAdvancedFeatures; |
69 | void closeEvent( QCloseEvent *e ); | 69 | void closeEvent( QCloseEvent *e ); |
70 | void doSearchBar(); | 70 | void doSearchBar(); |
71 | private slots: | 71 | private slots: |
72 | void doAdvanced(bool); | ||
72 | void doAbout(); | 73 | void doAbout(); |
73 | void setDocument(const QString&); | 74 | void setDocument(const QString&); |
74 | void changeFont(); | 75 | void changeFont(); |
75 | void fileNew(); | 76 | void fileNew(); |
76 | void fileRevert(); | 77 | void fileRevert(); |
77 | void fileOpen(); | 78 | void fileOpen(); |
78 | void changeStartConfig(bool); | 79 | void changeStartConfig(bool); |
79 | bool save(); | 80 | bool save(); |
80 | bool saveAs(); | 81 | bool saveAs(); |
81 | void cleanUp(); | 82 | void cleanUp(); |
82 | 83 | ||
83 | 84 | ||
84 | void editCut(); | 85 | void editCut(); |
85 | void editCopy(); | 86 | void editCopy(); |
86 | void editPaste(); | 87 | void editPaste(); |
87 | void editFind(); | 88 | void editFind(); |
88 | void editDelete(); | 89 | void editDelete(); |
89 | 90 | ||
90 | void findNext(); | 91 | void findNext(); |
91 | void findClose(); | 92 | void findClose(); |
92 | 93 | ||
93 | void search(); | 94 | void search(); |
94 | void accept(); | 95 | void accept(); |
95 | 96 | ||
96 | void newFile( const DocLnk & ); | 97 | void newFile( const DocLnk & ); |
97 | void openFile( const DocLnk & ); | 98 | void openFile( const DocLnk & ); |
98 | void showEditTools(); | 99 | void showEditTools(); |
99 | 100 | ||
100 | void zoomIn(); | 101 | void zoomIn(); |
101 | void zoomOut(); | 102 | void zoomOut(); |
102 | void setBold(bool y); | 103 | void setBold(bool y); |
103 | void setItalic(bool y); | 104 | void setItalic(bool y); |
104 | void setWordWrap(bool y); | 105 | void setWordWrap(bool y); |
105 | 106 | ||
106 | private: | 107 | private: |
107 | void colorChanged( const QColor &c ); | 108 | void colorChanged( const QColor &c ); |
108 | void clear(); | 109 | void clear(); |
109 | void updateCaption( const QString &name=QString::null ); | 110 | void updateCaption( const QString &name=QString::null ); |
110 | void setFontSize(int sz, bool round_down_not_up); | 111 | void setFontSize(int sz, bool round_down_not_up); |
111 | 112 | ||
112 | private: | 113 | private: |
113 | // fileSaver *fileSaveDlg; | 114 | // fileSaver *fileSaveDlg; |
114 | // fileBrowser *browseForFiles; | 115 | // fileBrowser *browseForFiles; |
115 | QpeEditor* editor; | 116 | QpeEditor* editor; |
116 | QToolBar *menu, *editBar, *searchBar; | 117 | QToolBar *menu, *editBar, *searchBar; |
117 | QLineEdit *searchEdit; | 118 | QLineEdit *searchEdit; |
118 | DocLnk *doc; | 119 | DocLnk *doc; |
119 | bool searchVisible; | 120 | bool searchVisible; |