summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-09 23:11:09 (UTC)
committer llornkcor <llornkcor>2002-11-09 23:11:09 (UTC)
commit0c81c6287771d5ad416c2ddf0ae32ad5ce18c116 (patch) (unidiff)
tree9e565161740031ed63f51ce09377b7e2ef2bb4a7
parentc1f59c3404e9c0312e3d0418d5286b12d2e98d92 (diff)
downloadopie-0c81c6287771d5ad416c2ddf0ae32ad5ce18c116.zip
opie-0c81c6287771d5ad416c2ddf0ae32ad5ce18c116.tar.gz
opie-0c81c6287771d5ad416c2ddf0ae32ad5ce18c116.tar.bz2
various fixes.. saveAs and quit stuff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp215
-rw-r--r--core/apps/textedit/textedit.h4
2 files changed, 104 insertions, 115 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 464671a..1c3b393 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -196,3 +196,3 @@ void QpeEditor::find ( const QString &txt, bool caseSensitive,
196{ 196{
197 static bool wrap = FALSE; 197 static bool wrap = false;
198 int line, col; 198 int line, col;
@@ -201,3 +201,3 @@ void QpeEditor::find ( const QString &txt, bool caseSensitive,
201 line = col = 0; 201 line = col = 0;
202 wrap = FALSE; 202 wrap = false;
203 // emit searchWrapped(); 203 // emit searchWrapped();
@@ -210,3 +210,3 @@ void QpeEditor::find ( const QString &txt, bool caseSensitive,
210 if ( line >= numLines() ) { 210 if ( line >= numLines() ) {
211 wrap = TRUE; 211 wrap = true;
212 //emit notFound(); 212 //emit notFound();
@@ -216,7 +216,7 @@ void QpeEditor::find ( const QString &txt, bool caseSensitive,
216 if ( findCol >= 0 ) { 216 if ( findCol >= 0 ) {
217 setCursorPosition( line, findCol, FALSE ); 217 setCursorPosition( line, findCol, false );
218 col = findCol + txt.length(); 218 col = findCol + txt.length();
219 setCursorPosition( line, col, TRUE ); 219 setCursorPosition( line, col, true );
220 220
221 //found = TRUE; 221 //found = true;
222 break; 222 break;
@@ -241,8 +241,8 @@ static const int fontsize[nfontsizes] = {8,10,12,14,18,24};
241TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) 241TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
242 : QMainWindow( parent, name, f ), bFromDocView( FALSE ) 242 : QMainWindow( parent, name, f ), bFromDocView( false )
243{ 243{
244 doc = 0; 244 doc = 0;
245 edited=FALSE; 245 edited=false;
246 edited1=FALSE; 246 edited1=false;
247 setToolBarsMovable( FALSE ); 247 setToolBarsMovable( false );
248 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 248 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
@@ -256,3 +256,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
256 QPEToolBar *bar = new QPEToolBar( this ); 256 QPEToolBar *bar = new QPEToolBar( this );
257 bar->setHorizontalStretchable( TRUE ); 257 bar->setHorizontalStretchable( true );
258 menu = bar; 258 menu = bar;
@@ -334,3 +334,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
334 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); 334 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) );
335 wa->setToggleAction(TRUE); 335 wa->setToggleAction(true);
336 wa->addTo( advancedMenu); 336 wa->addTo( advancedMenu);
@@ -339,3 +339,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
339 connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); 339 connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) );
340 nStart->setToggleAction(TRUE); 340 nStart->setToggleAction(true);
341 nStart->addTo( advancedMenu ); 341 nStart->addTo( advancedMenu );
@@ -344,3 +344,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
344 connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doPrompt(bool) ) ); 344 connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doPrompt(bool) ) );
345 nAdvanced->setToggleAction(TRUE); 345 nAdvanced->setToggleAction(true);
346 nAdvanced->addTo( advancedMenu ); 346 nAdvanced->addTo( advancedMenu );
@@ -349,3 +349,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
349 connect( desktopAction, SIGNAL( toggled(bool) ), this, SLOT( doDesktop(bool) ) ); 349 connect( desktopAction, SIGNAL( toggled(bool) ), this, SLOT( doDesktop(bool) ) );
350 desktopAction->setToggleAction(TRUE); 350 desktopAction->setToggleAction(true);
351 desktopAction->addTo( advancedMenu); 351 desktopAction->addTo( advancedMenu);
@@ -354,3 +354,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
354 connect( filePermAction, SIGNAL( toggled(bool) ), this, SLOT( doFilePerms(bool) ) ); 354 connect( filePermAction, SIGNAL( toggled(bool) ), this, SLOT( doFilePerms(bool) ) );
355 filePermAction->setToggleAction(TRUE); 355 filePermAction->setToggleAction(true);
356 filePermAction->addTo( advancedMenu); 356 filePermAction->addTo( advancedMenu);
@@ -359,3 +359,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
359 connect( searchBarAction, SIGNAL( toggled(bool) ), this, SLOT( setSearchBar(bool) ) ); 359 connect( searchBarAction, SIGNAL( toggled(bool) ), this, SLOT( setSearchBar(bool) ) );
360 searchBarAction->setToggleAction(TRUE); 360 searchBarAction->setToggleAction(true);
361 searchBarAction->addTo( advancedMenu); 361 searchBarAction->addTo( advancedMenu);
@@ -372,5 +372,5 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
372 searchBar = new QPEToolBar(this); 372 searchBar = new QPEToolBar(this);
373 addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); 373 addToolBar( searchBar, "Search", QMainWindow::Top, true );
374 374
375 searchBar->setHorizontalStretchable( TRUE ); 375 searchBar->setHorizontalStretchable( true );
376 376
@@ -424,7 +424,5 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
424 useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); 424 useSearchBar = cfg.readBoolEntry ( "SearchBar", false );
425 startWithNew = cfg.readBoolEntry ( "startNew", true);
425 426
426 if(useSearchBar) { 427 if(useSearchBar) searchBarAction->setOn(true);
427 searchBarAction->setOn(true);
428 } else{
429 }
430 if(promptExit ) nAdvanced->setOn ( true ); 428 if(promptExit ) nAdvanced->setOn ( true );
@@ -432,2 +430,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
432 if(filePerms) filePermAction->setOn ( true ); 430 if(filePerms) filePermAction->setOn ( true );
431 if(startWithNew) nStart->setOn( true );
433 432
@@ -437,5 +436,5 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
437 436
438 if( qApp->argc() > 0) { 437 if( qApp->argc() > 1) {
439 currentFileName=qApp->argv()[1]; 438 currentFileName=qApp->argv()[1];
440// qDebug("<<<<<<<<<<<<<<<<<<<<<<<< "+currentFileName); 439// qDebug("<<<<<<<<<<<<<<<<<<<<<<<< "+currentFileName+" %d",qApp->argc());
441 QFileInfo fi(currentFileName); 440 QFileInfo fi(currentFileName);
@@ -445,15 +444,13 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
445 } else { 444 } else {
446
447 nStart->setOn(TRUE);
448 openFile(currentFileName); 445 openFile(currentFileName);
449 } 446 }
450 } else
451 if(cfg.readEntry("startNew","TRUE") == "TRUE") {
452
453 nStart->setOn(TRUE);
454 fileNew();
455 } else { 447 } else {
456 448// qDebug("Do other thing");
449 if(startWithNew) {
450 openDotFile("");
451// fileNew();
452 } else {
457 fileOpen(); 453 fileOpen();
458 } 454 }
455 }
459 456
@@ -463,4 +460,10 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
463TextEdit::~TextEdit() { 460TextEdit::~TextEdit() {
464 if( edited1 & promptExit ) 461// qDebug("destr");
462}
463
464void TextEdit::closeEvent(QCloseEvent *) {
465// qDebug("closing here");
466 if( edited1 && promptExit)
465 saveAs(); 467 saveAs();
468 qApp->quit();
466} 469}
@@ -468,3 +471,3 @@ TextEdit::~TextEdit() {
468void TextEdit::cleanUp() { 471void TextEdit::cleanUp() {
469 qDebug("cleanUp");// save(); 472// qDebug("cleanUp");// save();
470 473
@@ -486,2 +489,4 @@ void TextEdit::cleanUp() {
486 cfg.writeEntry ( "SearchBar", useSearchBar ); 489 cfg.writeEntry ( "SearchBar", useSearchBar );
490 cfg.writeEntry ( "startNew", startWithNew );
491
487} 492}
@@ -490,5 +495,6 @@ void TextEdit::cleanUp() {
490void TextEdit::accept() { 495void TextEdit::accept() {
496// qDebug("accept");
491 if( edited1) 497 if( edited1)
492 saveAs(); 498 saveAs();
493 exit(0); 499 qApp->quit();
494} 500}
@@ -496,3 +502,3 @@ void TextEdit::accept() {
496void TextEdit::zoomIn() { 502void TextEdit::zoomIn() {
497 setFontSize(editor->font().pointSize()+1,FALSE); 503 setFontSize(editor->font().pointSize()+1,false);
498} 504}
@@ -500,3 +506,3 @@ void TextEdit::zoomIn() {
500void TextEdit::zoomOut() { 506void TextEdit::zoomOut() {
501 setFontSize(editor->font().pointSize()-1,TRUE); 507 setFontSize(editor->font().pointSize()-1,true);
502} 508}
@@ -568,6 +574,2 @@ void TextEdit::fileNew() {
568void TextEdit::fileOpen() { 574void TextEdit::fileOpen() {
569 Config cfg("TextEdit");
570 cfg.setGroup("View");
571 // bool b=FALSE;
572
573 QMap<QString, QStringList> map; 575 QMap<QString, QStringList> map;
@@ -579,6 +581,9 @@ void TextEdit::fileOpen() {
579 map.insert(tr("All"), text ); 581 map.insert(tr("All"), text );
580 QString str = OFileDialog::getOpenFileName( 2, QPEApplication::documentDir(), QString::null, map); 582 QString str = OFileDialog::getOpenFileName( 2,
583 QPEApplication::documentDir(),
584 QString::null, map);
581 if(!str.isEmpty() ) 585 if(!str.isEmpty() )
582 openFile( str ); 586 openFile( str );
583 587 else
588 updateCaption();
584} 589}
@@ -636,8 +641,3 @@ void TextEdit::editFind() {
636 searchBar->show(); 641 searchBar->show();
637 searchVisible = TRUE;
638 searchEdit->setFocus(); 642 searchEdit->setFocus();
639// Config cfg("TextEdit");
640// cfg.setGroup("View");
641// cfg.writeEntry("SearchBar","Opened");
642
643} 643}
@@ -645,3 +645,3 @@ void TextEdit::editFind() {
645void TextEdit::findNext() { 645void TextEdit::findNext() {
646 editor->find( searchEdit->text(), FALSE, FALSE ); 646 editor->find( searchEdit->text(), false, false );
647 647
@@ -650,8 +650,3 @@ void TextEdit::findNext() {
650void TextEdit::findClose() { 650void TextEdit::findClose() {
651 searchVisible = FALSE;
652 searchBar->hide(); 651 searchBar->hide();
653// Config cfg("TextEdit");
654// cfg.setGroup("View");
655// cfg.writeEntry("SearchBar","Closed");
656// cfg.write();
657} 652}
@@ -659,3 +654,3 @@ void TextEdit::findClose() {
659void TextEdit::search() { 654void TextEdit::search() {
660 editor->find( searchEdit->text(), FALSE, FALSE ); 655 editor->find( searchEdit->text(), false, false );
661} 656}
@@ -672,3 +667,3 @@ void TextEdit::newFile( const DocLnk &f ) {
672 updateCaption( currentFileName); 667 updateCaption( currentFileName);
673// editor->setEdited( FALSE); 668// editor->setEdited( false);
674} 669}
@@ -688,5 +683,5 @@ void TextEdit::openDotFile( const QString &f ) {
688 editor->setText(txt); 683 editor->setText(txt);
689 editor->setEdited( FALSE); 684 editor->setEdited( false);
690 edited1=FALSE; 685 edited1=false;
691 edited=FALSE; 686 edited=false;
692 687
@@ -701,4 +696,4 @@ void TextEdit::openFile( const QString &f ) {
701 QFileInfo fi( f); 696 QFileInfo fi( f);
702// bFromDocView = TRUE; 697// bFromDocView = true;
703 if(f.find(".desktop",0,TRUE) != -1 && !openDesktop) { 698 if(f.find(".desktop",0,true) != -1 && !openDesktop) {
704 switch ( QMessageBox::warning(this,tr("Text Editor"), 699 switch ( QMessageBox::warning(this,tr("Text Editor"),
@@ -746,3 +741,3 @@ void TextEdit::openFile( const DocLnk &f ) {
746// clear(); 741// clear();
747// bFromDocView = TRUE; 742// bFromDocView = true;
748 FileManager fm; 743 FileManager fm;
@@ -760,5 +755,5 @@ void TextEdit::openFile( const DocLnk &f ) {
760 editor->setText(txt); 755 editor->setText(txt);
761 editor->setEdited( FALSE); 756 editor->setEdited( false);
762 edited1=FALSE; 757 edited1=false;
763 edited=FALSE; 758 edited=false;
764 759
@@ -769,10 +764,8 @@ void TextEdit::openFile( const DocLnk &f ) {
769void TextEdit::showEditTools() { 764void TextEdit::showEditTools() {
770// if ( !doc )
771// close();
772// clear();
773 menu->show(); 765 menu->show();
774 editBar->show(); 766 editBar->show();
775 if ( searchVisible ) 767 if(!useSearchBar)
768 searchBar->hide();
769 else
776 searchBar->show(); 770 searchBar->show();
777// updateCaption();
778 setWState (WState_Reserved1 ); 771 setWState (WState_Reserved1 );
@@ -818,5 +811,5 @@ bool TextEdit::save() {
818 } 811 }
819 editor->setEdited( FALSE); 812 editor->setEdited( false);
820 edited1=FALSE; 813 edited1=false;
821 edited=FALSE; 814 edited=false;
822 if(caption().left(1)=="*") 815 if(caption().left(1)=="*")
@@ -837,12 +830,12 @@ bool TextEdit::saveAs() {
837 // case of nothing to save... 830 // case of nothing to save...
838 if ( !doc ) { 831// if ( !doc && !currentFileName.isEmpty()) {
839//|| !bFromDocView) 832// //|| !bFromDocView)
840 qDebug("no doc"); 833// qDebug("no doc");
841 return true; 834// return true;
842 } 835// }
843 if ( !editor->edited() ) { 836// if ( !editor->edited() ) {
844 delete doc; 837// delete doc;
845 doc = 0; 838// doc = 0;
846 return true; 839// return true;
847 } 840// }
848 841
@@ -854,4 +847,4 @@ bool TextEdit::saveAs() {
854 || currentFileName == tr("Text Editor")) { 847 || currentFileName == tr("Text Editor")) {
855// qDebug("do silly TT filename thing"); 848 qDebug("do silly TT filename thing");
856 if ( doc->name().isEmpty() ) { 849// if ( doc && doc->name().isEmpty() ) {
857 QString pt = rt.simplifyWhiteSpace(); 850 QString pt = rt.simplifyWhiteSpace();
@@ -871,6 +864,9 @@ bool TextEdit::saveAs() {
871 docname = tr("Unnamed"); 864 docname = tr("Unnamed");
872 doc->setName(docname); 865 if(doc) doc->setName(docname);
873 currentFileName=docname; 866 currentFileName=docname;
867// }
868// else
869// qDebug("hmmmmmm");
874 } 870 }
875 } 871
876 872
@@ -883,6 +879,11 @@ bool TextEdit::saveAs() {
883 map.insert(tr("All"), text ); 879 map.insert(tr("All"), text );
884// if(currentFileName 880
881 QFileInfo cuFi( currentFileName);
882 QString filee = cuFi.fileName();
883 QString dire = cuFi.dirPath();
884 if(dire==".")
885 dire = QPEApplication::documentDir();
885 QString str = OFileDialog::getSaveFileName( 2, 886 QString str = OFileDialog::getSaveFileName( 2,
886 QPEApplication::documentDir(), 887 dire,
887 currentFileName, map); 888 filee, map);
888 889
@@ -894,3 +895,3 @@ bool TextEdit::saveAs() {
894 currentFileName=fi.fileName(); 895 currentFileName=fi.fileName();
895 if(doc) { 896 if(doc)
896// QString file = doc->file(); 897// QString file = doc->file();
@@ -903,3 +904,3 @@ bool TextEdit::saveAs() {
903// editor->setText(rt); 904// editor->setText(rt);
904// qDebug("openFile doclnk "+currentFileName); 905 qDebug("Saving file as "+currentFileName);
905 doc->setName( currentFileName); 906 doc->setName( currentFileName);
@@ -923,3 +924,3 @@ bool TextEdit::saveAs() {
923 } 924 }
924 } 925// }
925 editor->setEdited( false); 926 editor->setEdited( false);
@@ -970,7 +971,7 @@ void TextEdit::setDocument(const QString& fileref) {
970 qDebug("setDoc open"); 971 qDebug("setDoc open");
971 bFromDocView = TRUE; 972 bFromDocView = true;
972 openFile(fileref); 973 openFile(fileref);
973 editor->setEdited(TRUE); 974 editor->setEdited(true);
974 edited1=FALSE; 975 edited1=false;
975 edited=TRUE; 976 edited=true;
976 977
@@ -982,7 +983,2 @@ void TextEdit::setDocument(const QString& fileref) {
982 983
983void TextEdit::closeEvent( QCloseEvent *e ) {
984 bFromDocView = FALSE;
985 e->accept();
986}
987
988void TextEdit::changeFont() { 984void TextEdit::changeFont() {
@@ -1018,11 +1014,6 @@ void TextEdit::editDelete() {
1018void TextEdit::changeStartConfig( bool b ) { 1014void TextEdit::changeStartConfig( bool b ) {
1019 1015 startWithNew=b;
1020 Config cfg("TextEdit"); 1016 Config cfg("TextEdit");
1021 cfg.setGroup("View"); 1017 cfg.setGroup("View");
1022 if(b) { 1018 cfg.writeEntry("startNew",b);
1023 qDebug("bool");
1024 cfg.writeEntry("startNew","TRUE");
1025 } else {
1026 cfg.writeEntry("startNew","FALSE");
1027 }
1028 update(); 1019 update();
@@ -1033,5 +1024,5 @@ void TextEdit::editorChanged() {
1033 setCaption( "*"+caption()); 1024 setCaption( "*"+caption());
1034 edited1=TRUE; 1025 edited1=true;
1035 } 1026 }
1036 edited=TRUE; 1027 edited=true;
1037} 1028}
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index a95e742..bb7d693 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -67,3 +67,2 @@ void receive(const QCString&, const QByteArray&);
67protected: 67protected:
68 bool fileIs, useAdvancedFeatures, promptExit, openDesktop, filePerms, useSearchBar;
69 void closeEvent( QCloseEvent *e ); 68 void closeEvent( QCloseEvent *e );
@@ -116,3 +115,2 @@ private:
116 void setFontSize(int sz, bool round_down_not_up); 115 void setFontSize(int sz, bool round_down_not_up);
117
118private: 116private:
@@ -125,3 +123,3 @@ private:
125 DocLnk *doc; 123 DocLnk *doc;
126 bool searchVisible; 124 bool fileIs, useAdvancedFeatures, promptExit, openDesktop, filePerms, useSearchBar, startWithNew;
127 bool bFromDocView; 125 bool bFromDocView;