summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp9
-rw-r--r--core/apps/textedit/textedit.h2
2 files changed, 8 insertions, 3 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index f56d5d3..1a1b186 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -352,49 +352,48 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
352 352
353 searchBar->setHorizontalStretchable( TRUE ); 353 searchBar->setHorizontalStretchable( TRUE );
354 354
355 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 355 searchEdit = new QLineEdit( searchBar, "searchEdit" );
356 searchBar->setStretchableWidget( searchEdit ); 356 searchBar->setStretchableWidget( searchEdit );
357 connect( searchEdit, SIGNAL( textChanged( const QString & ) ), 357 connect( searchEdit, SIGNAL( textChanged( const QString & ) ),
358 this, SLOT( search() ) ); 358 this, SLOT( search() ) );
359 359
360 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); 360 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 );
361 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 361 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
362 a->addTo( searchBar ); 362 a->addTo( searchBar );
363 a->addTo( edit ); 363 a->addTo( edit );
364 364
365 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 365 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
366 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 366 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
367 a->addTo( searchBar ); 367 a->addTo( searchBar );
368 368
369 edit->insertSeparator(); 369 edit->insertSeparator();
370 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 370 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
371 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); 371 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) );
372 a->addTo( edit ); 372 a->addTo( edit );
373 373
374 searchBar->hide(); 374 searchBar->hide();
375 375
376
377 editor = new QpeEditor( this ); 376 editor = new QpeEditor( this );
378 setCentralWidget( editor ); 377 setCentralWidget( editor );
379 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 378 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
380 connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); 379 connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) );
381 380
382 resize( 200, 300 ); 381 resize( 200, 300 );
383 382
384// setFontSize(defsize,TRUE); 383// setFontSize(defsize,TRUE);
385 FontDatabase fdb; 384 FontDatabase fdb;
386 QFont defaultFont=editor->font(); 385 QFont defaultFont=editor->font();
387 QFontInfo fontInfo(defaultFont); 386 QFontInfo fontInfo(defaultFont);
388 387
389 cfg.setGroup("Font"); 388 cfg.setGroup("Font");
390 QString family = cfg.readEntry("Family", fontInfo.family()); 389 QString family = cfg.readEntry("Family", fontInfo.family());
391 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); 390 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
392 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); 391 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
393 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); 392 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
394 393
395 defaultFont = fdb.font(family,style,i_size,charSet); 394 defaultFont = fdb.font(family,style,i_size,charSet);
396 editor->setFont( defaultFont); 395 editor->setFont( defaultFont);
397 396
398 wa->setOn(wrap); 397 wa->setOn(wrap);
399 updateCaption(); 398 updateCaption();
400 399
@@ -500,52 +499,57 @@ void TextEdit::fileOpen()
500 if( browseForFiles->exec() != -1 ) { 499 if( browseForFiles->exec() != -1 ) {
501 QString selFile= browseForFiles->selectedFileName; 500 QString selFile= browseForFiles->selectedFileName;
502 QStringList fileList=browseForFiles->fileList; 501 QStringList fileList=browseForFiles->fileList;
503 qDebug(selFile); 502 qDebug(selFile);
504 QStringList::ConstIterator f; 503 QStringList::ConstIterator f;
505 QString fileTemp; 504 QString fileTemp;
506 for ( f = fileList.begin(); f != fileList.end(); f++ ) { 505 for ( f = fileList.begin(); f != fileList.end(); f++ ) {
507 fileTemp = *f; 506 fileTemp = *f;
508 fileTemp.right( fileTemp.length()-5); 507 fileTemp.right( fileTemp.length()-5);
509 QString fileName = fileTemp; 508 QString fileName = fileTemp;
510 if( fileName != "Unnamed" || fileName != "Empty Text" ) { 509 if( fileName != "Unnamed" || fileName != "Empty Text" ) {
511 currentFileName = fileName; 510 currentFileName = fileName;
512 qDebug("please open "+currentFileName); 511 qDebug("please open "+currentFileName);
513 openFile(fileName ); 512 openFile(fileName );
514 } 513 }
515 } 514 }
516 viewSelection = browseForFiles->SelectionCombo->currentItem(); 515 viewSelection = browseForFiles->SelectionCombo->currentItem();
517 } 516 }
518 delete browseForFiles; 517 delete browseForFiles;
519 editor->setEdited( FALSE); 518 editor->setEdited( FALSE);
520 edited1=FALSE; 519 edited1=FALSE;
521 edited=FALSE; 520 edited=FALSE;
522 if(caption().left(1)=="*") 521 if(caption().left(1)=="*")
523 setCaption(caption().right(caption().length()-1)); 522 setCaption(caption().right(caption().length()-1));
523 doSearchBar();
524}
525
526void TextEdit::doSearchBar()
527{
524 Config cfg("TextEdit"); 528 Config cfg("TextEdit");
525 cfg.setGroup("View"); 529 cfg.setGroup("View");
526 if(cfg.readEntry("SearchBar","Closed") != "Opened") 530 if(cfg.readEntry("SearchBar","Closed") != "Opened")
527 searchBar->hide(); 531 searchBar->hide();
528} 532}
529 533
530#if 0 534#if 0
531void TextEdit::slotFind() 535void TextEdit::slotFind()
532{ 536{
533 FindDialog frmFind( "Text Editor", this ); 537 FindDialog frmFind( "Text Editor", this );
534 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 538 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
535 editor, SLOT(slotDoFind( const QString&,bool,bool))); 539 editor, SLOT(slotDoFind( const QString&,bool,bool)));
536 540
537 //case sensitive, backwards, [category] 541 //case sensitive, backwards, [category]
538 542
539 connect( editor, SIGNAL(notFound()), 543 connect( editor, SIGNAL(notFound()),
540 &frmFind, SLOT(slotNotFound()) ); 544 &frmFind, SLOT(slotNotFound()) );
541 connect( editor, SIGNAL(searchWrapped()), 545 connect( editor, SIGNAL(searchWrapped()),
542 &frmFind, SLOT(slotWrapAround()) ); 546 &frmFind, SLOT(slotWrapAround()) );
543 547
544 frmFind.exec(); 548 frmFind.exec();
545 549
546 550
547} 551}
548#endif 552#endif
549 553
550void TextEdit::fileRevert() 554void TextEdit::fileRevert()
551{ 555{
@@ -828,48 +832,49 @@ void TextEdit::updateCaption( const QString &name )
828 if ( s.isNull() ) 832 if ( s.isNull() )
829 s = doc->name(); 833 s = doc->name();
830 if ( s.isEmpty() ) { 834 if ( s.isEmpty() ) {
831 s = tr( "Unnamed" ); 835 s = tr( "Unnamed" );
832 currentFileName=s; 836 currentFileName=s;
833 } 837 }
834 838
835 setCaption( s + " - " + tr("Text Editor") ); 839 setCaption( s + " - " + tr("Text Editor") );
836 } 840 }
837} 841}
838 842
839void TextEdit::setDocument(const QString& fileref) 843void TextEdit::setDocument(const QString& fileref)
840{ 844{
841 bFromDocView = TRUE; 845 bFromDocView = TRUE;
842 qDebug("setDocument "+fileref); 846 qDebug("setDocument "+fileref);
843 bFromDocView = TRUE; 847 bFromDocView = TRUE;
844 if(fileref.find(".desktop",0,TRUE) == -1) { 848 if(fileref.find(".desktop",0,TRUE) == -1) {
845 openFile(fileref); 849 openFile(fileref);
846 } else { 850 } else {
847 openFile(DocLnk(fileref)); 851 openFile(DocLnk(fileref));
848 } 852 }
849 editor->setEdited(TRUE); 853 editor->setEdited(TRUE);
850 edited1=FALSE; 854 edited1=FALSE;
851 edited=TRUE; 855 edited=TRUE;
856 doSearchBar();
852} 857}
853 858
854void TextEdit::closeEvent( QCloseEvent *e ) 859void TextEdit::closeEvent( QCloseEvent *e )
855{ 860{
856 bFromDocView = FALSE; 861 bFromDocView = FALSE;
857 e->accept(); 862 e->accept();
858} 863}
859 864
860void TextEdit::accept() 865void TextEdit::accept()
861 { 866 {
862 QString file = doc->file(); 867 QString file = doc->file();
863 if (file.find("_.txt",0,TRUE) ==-1) 868 if (file.find("_.txt",0,TRUE) ==-1)
864 save(); 869 save();
865 else { 870 else {
866 QFile(file).remove(); 871 QFile(file).remove();
867 } 872 }
868 exit(0); 873 exit(0);
869 874
870} 875}
871 876
872void TextEdit::changeFont() { 877void TextEdit::changeFont() {
873 FontDatabase fdb; 878 FontDatabase fdb;
874 QFont defaultFont=editor->font(); 879 QFont defaultFont=editor->font();
875 QFontInfo fontInfo(defaultFont); 880 QFontInfo fontInfo(defaultFont);
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index a70b581..70cf068 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -40,49 +40,49 @@ class QToolButton;
40class QPopupMenu; 40class QPopupMenu;
41class QToolBar; 41class QToolBar;
42class QLineEdit; 42class QLineEdit;
43class QAction; 43class QAction;
44class FileSelector; 44class FileSelector;
45class QpeEditor; 45class QpeEditor;
46class QPopupMenu; 46class QPopupMenu;
47 47
48class TextEdit : public QMainWindow 48class TextEdit : public QMainWindow
49{ 49{
50 Q_OBJECT 50 Q_OBJECT
51 51
52public: 52public:
53 TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 53 TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
54 ~TextEdit(); 54 ~TextEdit();
55 QPopupMenu *font; 55 QPopupMenu *font;
56 QAction *nStart; 56 QAction *nStart;
57 bool edited, edited1; 57 bool edited, edited1;
58 void openFile( const QString & ); 58 void openFile( const QString & );
59public slots: 59public slots:
60 void editorChanged(); 60 void editorChanged();
61 61
62protected: 62protected:
63 void closeEvent( QCloseEvent *e ); 63 void closeEvent( QCloseEvent *e );
64 64 void doSearchBar();
65private slots: 65private slots:
66 void setDocument(const QString&); 66 void setDocument(const QString&);
67 void changeFont(); 67 void changeFont();
68 void fileNew(); 68 void fileNew();
69 void fileRevert(); 69 void fileRevert();
70 void fileOpen(); 70 void fileOpen();
71 void changeStartConfig(bool); 71 void changeStartConfig(bool);
72 bool save(); 72 bool save();
73 bool saveAs(); 73 bool saveAs();
74 void cleanUp(); 74 void cleanUp();
75 75
76 76
77 void editCut(); 77 void editCut();
78 void editCopy(); 78 void editCopy();
79 void editPaste(); 79 void editPaste();
80 void editFind(); 80 void editFind();
81 void editDelete(); 81 void editDelete();
82 82
83 void findNext(); 83 void findNext();
84 void findClose(); 84 void findClose();
85 85
86 void search(); 86 void search();
87 void accept(); 87 void accept();
88 88