summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 834971a..8004771 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -247,49 +247,48 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
247 247
248 QPEMenuBar *mb = new QPEMenuBar( bar ); 248 QPEMenuBar *mb = new QPEMenuBar( bar );
249 QPopupMenu *file = new QPopupMenu( this ); 249 QPopupMenu *file = new QPopupMenu( this );
250 QPopupMenu *edit = new QPopupMenu( this ); 250 QPopupMenu *edit = new QPopupMenu( this );
251 QPopupMenu *font = new QPopupMenu( this ); 251 QPopupMenu *font = new QPopupMenu( this );
252 252
253 bar = new QPEToolBar( this ); 253 bar = new QPEToolBar( this );
254 editBar = bar; 254 editBar = bar;
255 255
256 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 256 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
257 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 257 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
258 a->addTo( bar ); 258 a->addTo( bar );
259 a->addTo( file ); 259 a->addTo( file );
260 260
261 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 261 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
262 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 262 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
263// a->addTo( bar ); 263// a->addTo( bar );
264 a->addTo( file ); 264 a->addTo( file );
265 265
266 a = new QAction( tr( "Browse" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 266 a = new QAction( tr( "Browse" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
267 connect( a, SIGNAL( activated() ), this, SLOT( newFileOpen() ) ); 267 connect( a, SIGNAL( activated() ), this, SLOT( newFileOpen() ) );
268 a->addTo( bar ); 268 a->addTo( bar );
269 a->addTo( file ); 269 a->addTo( file );
270 270
271//
272 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); 271 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
273 connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); 272 connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
274// a->addTo( bar ); 273// a->addTo( bar );
275 file->insertSeparator(); 274 file->insertSeparator();
276 a->addTo( file ); 275 a->addTo( file );
277 276
278 a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); 277 a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
279 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); 278 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) );
280 a->addTo( file ); 279 a->addTo( file );
281 280
282 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); 281 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
283 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 282 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
284 a->addTo( editBar ); 283 a->addTo( editBar );
285 a->addTo( edit ); 284 a->addTo( edit );
286 285
287 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); 286 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 );
288 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); 287 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
289 a->addTo( editBar ); 288 a->addTo( editBar );
290 a->addTo( edit ); 289 a->addTo( edit );
291 290
292 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 291 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
293 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); 292 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
294 a->addTo( editBar ); 293 a->addTo( editBar );
295 a->addTo( edit ); 294 a->addTo( edit );
@@ -383,58 +382,50 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
383// fileOpen(); 382// fileOpen();
384 383
385 editor = new QpeEditor( editorStack ); 384 editor = new QpeEditor( editorStack );
386 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 385 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
387 editorStack->addWidget( editor, get_unique_id() ); 386 editorStack->addWidget( editor, get_unique_id() );
388 387
389 resize( 200, 300 ); 388 resize( 200, 300 );
390 389
391// setFontSize(defsize,TRUE); 390// setFontSize(defsize,TRUE);
392 FontDatabase fdb; 391 FontDatabase fdb;
393 QFont defaultFont=editor->font(); 392 QFont defaultFont=editor->font();
394 QFontInfo fontInfo(defaultFont); 393 QFontInfo fontInfo(defaultFont);
395 394
396 cfg.setGroup("Font"); 395 cfg.setGroup("Font");
397 QString family = cfg.readEntry("Family", fontInfo.family()); 396 QString family = cfg.readEntry("Family", fontInfo.family());
398 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); 397 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
399 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); 398 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
400 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); 399 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
401 400
402 defaultFont = fdb.font(family,style,i_size,charSet); 401 defaultFont = fdb.font(family,style,i_size,charSet);
403 editor->setFont( defaultFont); 402 editor->setFont( defaultFont);
404 403
405 wa->setOn(wrap); 404 wa->setOn(wrap);
406 updateCaption(); 405 updateCaption();
407 if( qApp->argc() > 1 ) { 406
408 for (int i=1;i< qApp->argc();i++) { 407 fileNew();
409 QString tmp;
410 currentFileName = tmp.sprintf("%s",qApp->argv()[i]);
411 qDebug(currentFileName);
412 setDocument( currentFileName );
413 }
414 }
415 else
416 fileNew();
417} 408}
418 409
419TextEdit::~TextEdit() 410TextEdit::~TextEdit()
420{ 411{
421 saveAs(); 412 saveAs();
422 413
423 Config cfg("TextEdit"); 414 Config cfg("TextEdit");
424 cfg.setGroup("View"); 415 cfg.setGroup("View");
425 QFont f = editor->font(); 416 QFont f = editor->font();
426 cfg.writeEntry("FontSize",f.pointSize()); 417 cfg.writeEntry("FontSize",f.pointSize());
427 cfg.writeEntry("Bold",f.bold()); 418 cfg.writeEntry("Bold",f.bold());
428 cfg.writeEntry("Italic",f.italic()); 419 cfg.writeEntry("Italic",f.italic());
429 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); 420 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth);
430} 421}
431 422
432void TextEdit::zoomIn() 423void TextEdit::zoomIn()
433{ 424{
434 setFontSize(editor->font().pointSize()+1,FALSE); 425 setFontSize(editor->font().pointSize()+1,FALSE);
435} 426}
436 427
437void TextEdit::zoomOut() 428void TextEdit::zoomOut()
438{ 429{
439 setFontSize(editor->font().pointSize()-1,TRUE); 430 setFontSize(editor->font().pointSize()-1,TRUE);
440} 431}
@@ -605,49 +596,49 @@ void TextEdit::findNext()
605 editor->find( searchEdit->text(), FALSE, FALSE ); 596 editor->find( searchEdit->text(), FALSE, FALSE );
606 597
607} 598}
608 599
609void TextEdit::findClose() 600void TextEdit::findClose()
610{ 601{
611 searchVisible = FALSE; 602 searchVisible = FALSE;
612 searchBar->hide(); 603 searchBar->hide();
613} 604}
614 605
615void TextEdit::search() 606void TextEdit::search()
616{ 607{
617 editor->find( searchEdit->text(), FALSE, FALSE ); 608 editor->find( searchEdit->text(), FALSE, FALSE );
618} 609}
619 610
620void TextEdit::newFile( const DocLnk &f ) 611void TextEdit::newFile( const DocLnk &f )
621{ 612{
622 DocLnk nf = f; 613 DocLnk nf = f;
623 nf.setType("text/plain"); 614 nf.setType("text/plain");
624 clear(); 615 clear();
625 editorStack->raiseWidget( editor ); 616 editorStack->raiseWidget( editor );
626 setWState (WState_Reserved1 ); 617 setWState (WState_Reserved1 );
627 editor->setFocus(); 618 editor->setFocus();
628 doc = new DocLnk(nf); 619 doc = new DocLnk(nf);
629// updateCaption(); 620 updateCaption(currentFileName);
630} 621}
631 622
632void TextEdit::openFile( const QString &f ) 623void TextEdit::openFile( const QString &f )
633{ 624{
634 bFromDocView = TRUE; 625 bFromDocView = TRUE;
635 DocLnk nf; 626 DocLnk nf;
636 nf.setType("text/plain"); 627 nf.setType("text/plain");
637 nf.setFile(f); 628 nf.setFile(f);
638 openFile(nf); 629 openFile(nf);
639 showEditTools(); 630 showEditTools();
640 // Show filename in caption 631 // Show filename in caption
641 QString name = f; 632 QString name = f;
642 int sep = name.findRev( '/' ); 633 int sep = name.findRev( '/' );
643 if ( sep > 0 ) 634 if ( sep > 0 )
644 name = name.mid( sep+1 ); 635 name = name.mid( sep+1 );
645 updateCaption( name ); 636 updateCaption( name );
646} 637}
647 638
648void TextEdit::openFile( const DocLnk &f ) 639void TextEdit::openFile( const DocLnk &f )
649{ 640{
650// clear(); 641// clear();
651 bFromDocView = TRUE; 642 bFromDocView = TRUE;
652 FileManager fm; 643 FileManager fm;
653 QString txt; 644 QString txt;
@@ -747,60 +738,61 @@ bool TextEdit::saveAs()
747 if ( !fm.saveFile( *doc, rt ) ) { 738 if ( !fm.saveFile( *doc, rt ) ) {
748 return false; 739 return false;
749 } 740 }
750 delete doc; 741 delete doc;
751 doc = 0; 742 doc = 0;
752 editor->setEdited( false ); 743 editor->setEdited( false );
753 return true; 744 return true;
754} 745}
755 746
756void TextEdit::clear() 747void TextEdit::clear()
757{ 748{
758 delete doc; 749 delete doc;
759 doc = 0; 750 doc = 0;
760 editor->clear(); 751 editor->clear();
761} 752}
762 753
763void TextEdit::updateCaption( const QString &name ) 754void TextEdit::updateCaption( const QString &name )
764{ 755{
765 if ( !doc ) 756 if ( !doc )
766 setCaption( tr("Text Editor") ); 757 setCaption( tr("Text Editor") );
767 else { 758 else {
768 QString s = name; 759 QString s = name;
769 if ( s.isNull() ) 760 if ( s.isNull() )
770 s = doc->name(); 761 s = doc->name();
771 if ( s.isEmpty() ) { 762 if ( s.isEmpty() ) {
772 s = tr( "Unnamed" ); 763 s = tr( "Unnamed" );
773 currentFileName=s; 764 currentFileName=s;
774 } 765 }
766
775 setCaption( s + " - " + tr("Text Editor") ); 767 setCaption( s + " - " + tr("Text Editor") );
776 } 768 }
777} 769}
778 770
779void TextEdit::setDocument(const QString& fileref) 771void TextEdit::setDocument(const QString& fileref)
780{ 772{
781 bFromDocView = TRUE; 773 bFromDocView = TRUE;
782 openFile(DocLnk(fileref)); 774 openFile(DocLnk(fileref));
783// showEditTools(); 775// showEditTools();
784} 776}
785 777
786void TextEdit::closeEvent( QCloseEvent *e ) 778void TextEdit::closeEvent( QCloseEvent *e )
787{ 779{
788 if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) { 780 if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) {
789 e->ignore(); 781 e->ignore();
790 repaint(); 782 repaint();
791// fileRevert(); 783// fileRevert();
792 784
793 } else { 785 } else {
794 bFromDocView = FALSE; 786 bFromDocView = FALSE;
795 e->accept(); 787 e->accept();
796 } 788 }
797} 789}
798 790
799void TextEdit::accept() 791void TextEdit::accept()
800{ 792{
801 close(); 793 close();
802// fileOpen(); //godamn thats obnoxious! lemme out!!! 794// fileOpen(); //godamn thats obnoxious! lemme out!!!
803} 795}
804 796
805void TextEdit::changeFont() { 797void TextEdit::changeFont() {
806 FontDatabase fdb; 798 FontDatabase fdb;