summaryrefslogtreecommitdiff
path: root/core/apps/textedit
authorllornkcor <llornkcor>2002-11-09 20:52:24 (UTC)
committer llornkcor <llornkcor>2002-11-09 20:52:24 (UTC)
commitc1f59c3404e9c0312e3d0418d5286b12d2e98d92 (patch) (unidiff)
treea7700be7ae3af4656c365c664e4db9822fdf7e3a /core/apps/textedit
parentb9cd525928755b78fe5041c4ea9d674a457dfa0d (diff)
downloadopie-c1f59c3404e9c0312e3d0418d5286b12d2e98d92.zip
opie-c1f59c3404e9c0312e3d0418d5286b12d2e98d92.tar.gz
opie-c1f59c3404e9c0312e3d0418d5286b12d2e98d92.tar.bz2
fixes and options. commandline now works a bit more sane, and makes new file if not found
Diffstat (limited to 'core/apps/textedit') (more/less context) (show whitespace changes)
-rw-r--r--core/apps/textedit/main.cpp4
-rw-r--r--core/apps/textedit/textedit.cpp120
-rw-r--r--core/apps/textedit/textedit.h6
3 files changed, 106 insertions, 24 deletions
diff --git a/core/apps/textedit/main.cpp b/core/apps/textedit/main.cpp
index d0d37d2..4f27667 100644
--- a/core/apps/textedit/main.cpp
+++ b/core/apps/textedit/main.cpp
@@ -30,4 +30,4 @@ int main( int argc, char **argv )
30 a.showMainDocumentWidget(&e); 30 a.showMainDocumentWidget(&e);
31 if ( argc == 3 && argv[1] == QCString("-f") ) 31// if ( argc == 3 && argv[1] == QCString("-f") )
32 e.openFile(argv[2]); 32// e.openFile(argv[2]);
33 33
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index e3b8361..464671a 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -45,2 +45,3 @@
45 45
46#include <qtextstream.h>
46#include <qdatetime.h> 47#include <qdatetime.h>
@@ -61,3 +62,3 @@
61#include <qlayout.h> 62#include <qlayout.h>
62 63#include <qapplication.h>
63#include <unistd.h> 64#include <unistd.h>
@@ -173,4 +174,3 @@ public:
173 QpeEditor( QWidget *parent, const char * name = 0 ) 174 QpeEditor( QWidget *parent, const char * name = 0 )
174 : QMultiLineEdit( parent, name ) 175 : QMultiLineEdit( parent, name ) {
175 {
176 clearTableFlags(); 176 clearTableFlags();
@@ -226,5 +226,3 @@ void QpeEditor::find ( const QString &txt, bool caseSensitive,
226 } 226 }
227
228 } 227 }
229
230} 228}
@@ -359,2 +357,8 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
359 357
358 searchBarAction = new QAction( tr("Search Bar Open"), QString::null, 0, this, 0 );
359 connect( searchBarAction, SIGNAL( toggled(bool) ), this, SLOT( setSearchBar(bool) ) );
360 searchBarAction->setToggleAction(TRUE);
361 searchBarAction->addTo( advancedMenu);
362
363
360 font->insertSeparator(); 364 font->insertSeparator();
@@ -412,3 +416,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
412 416
413 updateCaption(); 417// updateCaption();
414 418
@@ -419,3 +423,8 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
419 filePerms = cfg. readBoolEntry ( "FilePermissions", false ); 423 filePerms = cfg. readBoolEntry ( "FilePermissions", false );
424 useSearchBar = cfg.readBoolEntry ( "SearchBar", false );
420 425
426 if(useSearchBar) {
427 searchBarAction->setOn(true);
428 } else{
429 }
421 if(promptExit ) nAdvanced->setOn ( true ); 430 if(promptExit ) nAdvanced->setOn ( true );
@@ -428,3 +437,17 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
428 437
438 if( qApp->argc() > 0) {
439 currentFileName=qApp->argv()[1];
440// qDebug("<<<<<<<<<<<<<<<<<<<<<<<< "+currentFileName);
441 QFileInfo fi(currentFileName);
442
443 if(fi.baseName().left(1) == "") {
444 openDotFile(currentFileName);
445 } else {
446
447 nStart->setOn(TRUE);
448 openFile(currentFileName);
449 }
450 } else
429 if(cfg.readEntry("startNew","TRUE") == "TRUE") { 451 if(cfg.readEntry("startNew","TRUE") == "TRUE") {
452
430 nStart->setOn(TRUE); 453 nStart->setOn(TRUE);
@@ -432,2 +455,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
432 } else { 455 } else {
456
433 fileOpen(); 457 fileOpen();
@@ -461,2 +485,3 @@ void TextEdit::cleanUp() {
461 cfg. writeEntry ( "FilePermissions", filePerms ); 485 cfg. writeEntry ( "FilePermissions", filePerms );
486 cfg.writeEntry ( "SearchBar", useSearchBar );
462} 487}
@@ -522,2 +547,15 @@ void TextEdit::setWordWrap(bool y) {
522 547
548void TextEdit::setSearchBar(bool b) {
549 useSearchBar=b;
550 Config cfg("TextEdit");
551 cfg.setGroup("View");
552 cfg.writeEntry ( "SearchBar", b );
553 searchBarAction->setOn(b);
554 if(b)
555 searchBar->show();
556 else
557 searchBar->hide();
558 editor->setFocus();
559}
560
523void TextEdit::fileNew() { 561void TextEdit::fileNew() {
@@ -548,6 +586,6 @@ void TextEdit::fileOpen() {
548void TextEdit::doSearchBar() { 586void TextEdit::doSearchBar() {
549 Config cfg("TextEdit"); 587 if(!useSearchBar)
550 cfg.setGroup("View");
551 if(cfg.readEntry("SearchBar","Closed") != "Opened")
552 searchBar->hide(); 588 searchBar->hide();
589 else
590 searchBar->show();
553} 591}
@@ -600,5 +638,5 @@ void TextEdit::editFind() {
600 searchEdit->setFocus(); 638 searchEdit->setFocus();
601 Config cfg("TextEdit"); 639// Config cfg("TextEdit");
602 cfg.setGroup("View"); 640// cfg.setGroup("View");
603 cfg.writeEntry("SearchBar","Opened"); 641// cfg.writeEntry("SearchBar","Opened");
604 642
@@ -614,6 +652,6 @@ void TextEdit::findClose() {
614 searchBar->hide(); 652 searchBar->hide();
615 Config cfg("TextEdit"); 653// Config cfg("TextEdit");
616 cfg.setGroup("View"); 654// cfg.setGroup("View");
617 cfg.writeEntry("SearchBar","Closed"); 655// cfg.writeEntry("SearchBar","Closed");
618 cfg.write(); 656// cfg.write();
619} 657}
@@ -637,2 +675,24 @@ void TextEdit::newFile( const DocLnk &f ) {
637 675
676void TextEdit::openDotFile( const QString &f ) {
677 if(!currentFileName.isEmpty()) {
678 currentFileName=f;
679
680 qDebug("openFile dotfile " + currentFileName);
681 QString txt;
682 QFile file(f);
683 file.open(IO_ReadWrite);
684 QTextStream t(&file);
685 while ( !t.atEnd()) {
686 txt+=t.readLine();
687 }
688 editor->setText(txt);
689 editor->setEdited( FALSE);
690 edited1=FALSE;
691 edited=FALSE;
692
693
694 }
695 updateCaption( currentFileName);
696}
697
638void TextEdit::openFile( const QString &f ) { 698void TextEdit::openFile( const QString &f ) {
@@ -640,2 +700,3 @@ void TextEdit::openFile( const QString &f ) {
640 QString filer; 700 QString filer;
701 QFileInfo fi( f);
641// bFromDocView = TRUE; 702// bFromDocView = TRUE;
@@ -654,2 +715,5 @@ file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"),
654 } 715 }
716 } else if(fi.baseName().left(1) == "") {
717 currentFileName=f;
718 openDotFile(currentFileName);
655 } else { 719 } else {
@@ -665,7 +729,8 @@ file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"),
665 currentFileName=filer; 729 currentFileName=filer;
666 QFileInfo fi( currentFileName); 730
667 nf.setName(fi.baseName()); 731 nf.setName(fi.baseName());
732 openFile(nf);
733
668 qDebug("openFile string "+currentFileName); 734 qDebug("openFile string "+currentFileName);
669 735
670 openFile(nf);
671 showEditTools(); 736 showEditTools();
@@ -878,3 +943,4 @@ void TextEdit::clear() {
878void TextEdit::updateCaption( const QString &name ) { 943void TextEdit::updateCaption( const QString &name ) {
879 if ( !doc ) 944
945 if ( name.isEmpty() )
880 setCaption( tr("Text Editor") ); 946 setCaption( tr("Text Editor") );
@@ -895,2 +961,11 @@ void TextEdit::updateCaption( const QString &name ) {
895void TextEdit::setDocument(const QString& fileref) { 961void TextEdit::setDocument(const QString& fileref) {
962 if(fileref != "Unnamed") {
963 currentFileName=fileref;
964 qDebug("setDocument");
965 QFileInfo fi(currentFileName);
966 qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName);
967 if(fi.baseName().left(1) == "") {
968// openDotFile(currentFileName);
969 } else {
970 qDebug("setDoc open");
896 bFromDocView = TRUE; 971 bFromDocView = TRUE;
@@ -900,3 +975,7 @@ void TextEdit::setDocument(const QString& fileref) {
900 edited=TRUE; 975 edited=TRUE;
901 doSearchBar(); 976
977// doSearchBar();
978 }
979 }
980 updateCaption( currentFileName);
902} 981}
@@ -1002 +1081,2 @@ void TextEdit::editPasteTimeDate() {
1002} 1081}
1082
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index 4848051..a95e742 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -59,3 +59,3 @@ public:
59 QPopupMenu *font; 59 QPopupMenu *font;
60 QAction *nStart, *nFileDlgOpt, *nAdvanced, *desktopAction, *filePermAction; 60 QAction *nStart, *nFileDlgOpt, *nAdvanced, *desktopAction, *filePermAction, *searchBarAction;
61 bool edited, edited1; 61 bool edited, edited1;
@@ -67,3 +67,3 @@ void receive(const QCString&, const QByteArray&);
67protected: 67protected:
68 bool fileIs, useAdvancedFeatures, promptExit, openDesktop, filePerms; 68 bool fileIs, useAdvancedFeatures, promptExit, openDesktop, filePerms, useSearchBar;
69 void closeEvent( QCloseEvent *e ); 69 void closeEvent( QCloseEvent *e );
@@ -108,4 +108,6 @@ private slots:
108 void setWordWrap(bool y); 108 void setWordWrap(bool y);
109 void setSearchBar(bool);
109 110
110private: 111private:
112 void openDotFile(const QString &);
111 void colorChanged( const QColor &c ); 113 void colorChanged( const QColor &c );