summaryrefslogtreecommitdiff
path: root/core
authorllornkcor <llornkcor>2002-04-10 19:08:30 (UTC)
committer llornkcor <llornkcor>2002-04-10 19:08:30 (UTC)
commit11d754ffa429875b526c49f125d8a844c5cda3d8 (patch) (unidiff)
tree4b2fa1f980e62dad5a0ae465c95eb627df32cdd9 /core
parent5504a71f3e65673a3eea23051d0043f2b483276b (diff)
downloadopie-11d754ffa429875b526c49f125d8a844c5cda3d8.zip
opie-11d754ffa429875b526c49f125d8a844c5cda3d8.tar.gz
opie-11d754ffa429875b526c49f125d8a844c5cda3d8.tar.bz2
bug fix
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp28
-rw-r--r--core/apps/textedit/textedit.cpp99
-rw-r--r--core/apps/textedit/textedit.h7
3 files changed, 73 insertions, 61 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
index bc99348..f322513 100644
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -45,13 +45,13 @@ static int get_unique_id()
45} 45}
46 46
47fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString mimeFilter ) 47fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString mimeFilter )
48 : QDialog( parent, name, modal, fl ) 48 : QDialog( parent, name, modal, fl )
49{ 49{
50 if ( !name ) 50 if ( !name )
51 setName( tr("fileBrowser") ); 51 setName( "fileBrowser" );
52 setCaption(tr( name ) ); 52 setCaption(tr( name ) );
53// mimeType = mimeFilter; 53// mimeType = mimeFilter;
54// MimeType mt( mimeType); 54// MimeType mt( mimeType);
55// if( mt.extension().isEmpty()) 55// if( mt.extension().isEmpty())
56// QStringList filterList; 56// QStringList filterList;
57// filterList=QStringList::split(";",mimeFilter,FALSE); 57// filterList=QStringList::split(";",mimeFilter,FALSE);
@@ -117,13 +117,13 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
117// ListView->setMinimumSize( QSize( 100, 25 ) ); 117// ListView->setMinimumSize( QSize( 100, 25 ) );
118 ListView->addColumn( tr( "Name" ) ); 118 ListView->addColumn( tr( "Name" ) );
119 ListView->setColumnWidth(0,120); 119 ListView->setColumnWidth(0,120);
120 ListView->setSorting( 2, FALSE); 120 ListView->setSorting( 2, FALSE);
121 ListView->addColumn( tr( "Size" ) ); 121 ListView->addColumn( tr( "Size" ) );
122 ListView->setColumnWidth(1,-1); 122 ListView->setColumnWidth(1,-1);
123 ListView->addColumn( tr("Date"),-1); 123 ListView->addColumn( "Date",-1);
124 124
125 ListView->setColumnWidthMode(0,QListView::Manual); 125 ListView->setColumnWidthMode(0,QListView::Manual);
126 ListView->setColumnAlignment(1,QListView::AlignRight); 126 ListView->setColumnAlignment(1,QListView::AlignRight);
127 ListView->setColumnAlignment(2,QListView::AlignRight); 127 ListView->setColumnAlignment(2,QListView::AlignRight);
128 ListView->setAllColumnsShowFocus( TRUE ); 128 ListView->setAllColumnsShowFocus( TRUE );
129 129
@@ -131,13 +131,13 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags
131 connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 131 connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
132 this, SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 132 this, SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
133 133
134 connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); 134 connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
135 135
136 FileStack->addWidget( ListView, get_unique_id() ); 136 FileStack->addWidget( ListView, get_unique_id() );
137 137mimeType="text/plain";
138 fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy 138 fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy
139// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); 139// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
140// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 140// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
141 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), 141 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ),
142 this, SLOT( docOpen( const DocLnk & ) ) ); 142 this, SLOT( docOpen( const DocLnk & ) ) );
143 layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 ); 143 layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 );
@@ -345,20 +345,20 @@ void fileBrowser::docButtonPushed() {
345 update(); 345 update();
346 346
347} 347}
348 348
349void fileBrowser::selectionChanged( const QString &select ) 349void fileBrowser::selectionChanged( const QString &select )
350{ 350{
351 if ( select == tr("Documents")) { 351 if ( select == "Documents") {
352 FileStack->raiseWidget( fileSelector ); 352 FileStack->raiseWidget( fileSelector );
353 dirPathCombo->hide(); 353 dirPathCombo->hide();
354 cdUpButton->hide(); 354 cdUpButton->hide();
355 docButton->hide(); 355 docButton->hide();
356 homeButton->hide(); 356 homeButton->hide();
357 } else { 357 } else {
358 if ( select == tr("All files") ) 358 if ( select == "All files" )
359 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); 359 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All);
360 else 360 else
361 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 361 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
362 362
363 populateList(); 363 populateList();
364 update(); 364 update();
@@ -409,56 +409,56 @@ void fileBrowser::showListMenu(QListViewItem *item) {
409void fileBrowser::doCd() { 409void fileBrowser::doCd() {
410 listClicked( ListView->currentItem()); 410 listClicked( ListView->currentItem());
411} 411}
412 412
413void fileBrowser::makDir() { 413void fileBrowser::makDir() {
414 InputDialog *fileDlg; 414 InputDialog *fileDlg;
415 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 415 fileDlg = new InputDialog(this,"Make Directory",TRUE, 0);
416 fileDlg->exec(); 416 fileDlg->exec();
417 if( fileDlg->result() == 1 ) { 417 if( fileDlg->result() == 1 ) {
418 QString filename = fileDlg->LineEdit1->text(); 418 QString filename = fileDlg->LineEdit1->text();
419 qDebug("Make dir"); 419 qDebug("Make dir");
420 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 420 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
421 } 421 }
422 populateList(); 422 populateList();
423} 423}
424 424
425void fileBrowser::localRename() { 425void fileBrowser::localRename() {
426 QString curFile = ListView->currentItem()->text(0); 426 QString curFile = ListView->currentItem()->text(0);
427 InputDialog *fileDlg; 427 InputDialog *fileDlg;
428 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 428 fileDlg = new InputDialog(this,"Rename",TRUE, 0);
429 fileDlg->setTextEdit((const QString &) curFile); 429 fileDlg->setTextEdit((const QString &) curFile);
430 fileDlg->exec(); 430 fileDlg->exec();
431 if( fileDlg->result() == 1 ) { 431 if( fileDlg->result() == 1 ) {
432 QString oldname = currentDir.canonicalPath() + "/" + curFile; 432 QString oldname = currentDir.canonicalPath() + "/" + curFile;
433 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 433 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
434 if( rename(oldname.latin1(), newName.latin1())== -1) 434 if( rename(oldname.latin1(), newName.latin1())== -1)
435 QMessageBox::message(tr("Note"),tr("Could not rename")); 435 QMessageBox::message("Note","Could not rename");
436 } 436 }
437 populateList(); 437 populateList();
438} 438}
439 439
440void fileBrowser::localDelete() { 440void fileBrowser::localDelete() {
441 QString f = ListView->currentItem()->text(0); 441 QString f = ListView->currentItem()->text(0);
442 if(QDir(f).exists() ) { 442 if(QDir(f).exists() ) {
443 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ 443 switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+
444 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { 444 " ?\nIt must be empty","Yes","No",0,0,1) ) {
445 case 0: { 445 case 0: {
446 f=currentDir.canonicalPath()+"/"+f; 446 f=currentDir.canonicalPath()+"/"+f;
447 QString cmd="rmdir "+f; 447 QString cmd="rmdir "+f;
448 system( cmd.latin1()); 448 system( cmd.latin1());
449 populateList(); 449 populateList();
450 } 450 }
451 break; 451 break;
452 case 1: 452 case 1:
453 // exit 453 // exit
454 break; 454 break;
455 }; 455 };
456 } else { 456 } else {
457 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f 457 switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f
458 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 458 +" ?","Yes","No",0,0,1) ) {
459 case 0: { 459 case 0: {
460 f=currentDir.canonicalPath()+"/"+f; 460 f=currentDir.canonicalPath()+"/"+f;
461 QString cmd="rm "+f; 461 QString cmd="rm "+f;
462 system( cmd.latin1()); 462 system( cmd.latin1());
463 populateList(); 463 populateList();
464 } 464 }
@@ -490,13 +490,13 @@ void fileBrowser::updateMimeTypeMenu() {
490 connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&))); 490 connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&)));
491} 491}
492 492
493void fileBrowser::showType(const QString &t) { 493void fileBrowser::showType(const QString &t) {
494 494
495 qDebug(t); 495 qDebug(t);
496 if(t.find(tr("All"),0,TRUE) != -1) { 496 if(t.find("All",0,TRUE) != -1) {
497 filterStr = "*"; 497 filterStr = "*";
498 } else { 498 } else {
499 QStringList list = mimetypes.grep( t,TRUE); 499 QStringList list = mimetypes.grep( t,TRUE);
500 QString ext; 500 QString ext;
501 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 501 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
502 mimeType =(*it); 502 mimeType =(*it);
@@ -602,13 +602,13 @@ void fileBrowser::fillCombo(const QString &currentPath) {
602 602
603 603
604InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 604InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
605 : QDialog( parent, name, modal, fl ) 605 : QDialog( parent, name, modal, fl )
606{ 606{
607 if ( !name ) 607 if ( !name )
608 setName( tr("InputDialog") ); 608 setName( "InputDialog" );
609 resize( 234, 50 ); 609 resize( 234, 50 );
610 setMaximumSize( QSize( 240, 50 ) ); 610 setMaximumSize( QSize( 240, 50 ) );
611 setCaption( tr(name ) ); 611 setCaption( tr(name ) );
612 612
613 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 613 LineEdit1 = new QLineEdit( this, "LineEdit1" );
614 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); 614 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) );
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 6804918..943fecd 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -32,12 +32,13 @@
32#include <qpe/applnk.h> 32#include <qpe/applnk.h>
33#include <qpe/resource.h> 33#include <qpe/resource.h>
34#include <qpe/config.h> 34#include <qpe/config.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#include <qpe/qpemenubar.h> 36#include <qpe/qpemenubar.h>
37#include <qpe/qpetoolbar.h> 37#include <qpe/qpetoolbar.h>
38#include <qpe/qcopenvelope_qws.h>
38//#include <qpe/finddialog.h> 39//#include <qpe/finddialog.h>
39 40
40#include <qstringlist.h> 41#include <qstringlist.h>
41#include <qaction.h> 42#include <qaction.h>
42#include <qcolordialog.h> 43#include <qcolordialog.h>
43#include <qfileinfo.h> 44#include <qfileinfo.h>
@@ -235,12 +236,16 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
235 doc = 0; 236 doc = 0;
236 edited=FALSE; 237 edited=FALSE;
237 edited1=FALSE; 238 edited1=FALSE;
238 setToolBarsMovable( FALSE ); 239 setToolBarsMovable( FALSE );
239 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 240 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
240 241
242 channel = new QCopChannel( "QPE/Application/textedit", this );
243 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
244 this, SLOT(receive(const QCString&, const QByteArray&)) );
245
241 setIcon( Resource::loadPixmap( "TextEditor" ) ); 246 setIcon( Resource::loadPixmap( "TextEditor" ) );
242 247
243 QPEToolBar *bar = new QPEToolBar( this ); 248 QPEToolBar *bar = new QPEToolBar( this );
244 bar->setHorizontalStretchable( TRUE ); 249 bar->setHorizontalStretchable( TRUE );
245 menu = bar; 250 menu = bar;
246 251
@@ -394,19 +399,19 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
394 defaultFont = fdb.font(family,style,i_size,charSet); 399 defaultFont = fdb.font(family,style,i_size,charSet);
395 editor->setFont( defaultFont); 400 editor->setFont( defaultFont);
396 401
397 wa->setOn(wrap); 402 wa->setOn(wrap);
398 updateCaption(); 403 updateCaption();
399 404
400 cfg.setGroup("View"); 405 cfg.setGroup("View");
401 if(cfg.readEntry("startNew","TRUE") == "TRUE") { 406 if(cfg.readEntry("startNew","TRUE") == "TRUE") {
402 nStart->setOn(TRUE); 407 nStart->setOn(TRUE);
403 fileNew(); 408 fileNew();
404 } else { 409 } else {
405 fileOpen(); 410 fileOpen();
406 } 411 }
407 viewSelection = cfg.readNumEntry( "FileView", 0 ); 412 viewSelection = cfg.readNumEntry( "FileView", 0 );
408} 413}
409 414
410void TextEdit::cleanUp() 415void TextEdit::cleanUp()
411{ 416{
412// save(); 417// save();
@@ -482,23 +487,25 @@ void TextEdit::setWordWrap(bool y)
482 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); 487 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
483 editor->setEdited( state ); 488 editor->setEdited( state );
484} 489}
485 490
486void TextEdit::fileNew() 491void TextEdit::fileNew()
487{ 492{
488 if( !bFromDocView ) { 493// if( !bFromDocView ) {
489 saveAs(); 494// saveAs();
490 } 495// }
491 newFile(DocLnk()); 496 newFile(DocLnk());
492} 497}
493 498
494void TextEdit::fileOpen() 499void TextEdit::fileOpen()
495{ 500{
496 browseForFiles=new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); // 501 browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); //
497 browseForFiles->setFileView( viewSelection ); 502 browseForFiles->setFileView( viewSelection );
498 browseForFiles->showMaximized(); 503 browseForFiles->showMaximized();
504// if( result != -1 )
505
499 if( browseForFiles->exec() != -1 ) { 506 if( browseForFiles->exec() != -1 ) {
500 QString selFile = browseForFiles->selectedFileName; 507 QString selFile = browseForFiles->selectedFileName;
501 QStringList fileList = browseForFiles->fileList; 508 QStringList fileList = browseForFiles->fileList;
502 qDebug(selFile); 509 qDebug(selFile);
503 QStringList::ConstIterator f; 510 QStringList::ConstIterator f;
504 QString fileTemp; 511 QString fileTemp;
@@ -615,63 +622,61 @@ void TextEdit::newFile( const DocLnk &f )
615 DocLnk nf = f; 622 DocLnk nf = f;
616 nf.setType("text/plain"); 623 nf.setType("text/plain");
617 clear(); 624 clear();
618 setWState (WState_Reserved1 ); 625 setWState (WState_Reserved1 );
619 editor->setFocus(); 626 editor->setFocus();
620 doc = new DocLnk(nf); 627 doc = new DocLnk(nf);
628 currentFileName = "Unnamed";
621 qDebug("newFile "+currentFileName); 629 qDebug("newFile "+currentFileName);
622 updateCaption(currentFileName); 630 updateCaption( currentFileName);
631// editor->setEdited( FALSE);
623} 632}
624 633
625void TextEdit::openFile( const QString &f ) 634void TextEdit::openFile( const QString &f )
626{ 635{
627 636
628 bFromDocView = TRUE; 637// bFromDocView = TRUE;
629 DocLnk nf; 638 DocLnk nf;
630 nf.setType("text/plain"); 639 nf.setType("text/plain");
631 nf.setFile(f); 640 nf.setFile(f);
632 currentFileName=f; 641 currentFileName=f;
633 QFileInfo fi( currentFileName); 642 QFileInfo fi( currentFileName);
634 nf.setName(fi.baseName()); 643 nf.setName(fi.baseName());
635 qDebug("openFile string"+currentFileName); 644 qDebug("openFile string"+currentFileName);
636 645
637 openFile(nf); 646 openFile(nf);
638 showEditTools(); 647 showEditTools();
639 // Show filename in caption 648 // Show filename in caption
640 QString name = f; 649 QString name = f;
641 int sep = name.findRev( '/' ); 650 int sep = name.findRev( '/' );
642 if ( sep > 0 ) 651 if ( sep > 0 )
643 name = name.mid( sep+1 ); 652 name = name.mid( sep+1 );
644 updateCaption( name ); 653 updateCaption( name );
645} 654}
646 655
647void TextEdit::openFile( const DocLnk &f ) 656void TextEdit::openFile( const DocLnk &f )
648{ 657{
649// clear(); 658// clear();
650 bFromDocView = TRUE; 659// bFromDocView = TRUE;
651 FileManager fm; 660 FileManager fm;
652 QString txt; 661 QString txt;
653 currentFileName=f.name(); 662 currentFileName=f.name();
654 qDebug("openFile doclnk " + currentFileName); 663 qDebug("openFile doclnk " + currentFileName);
655 if ( !fm.loadFile( f, txt ) ) { 664 if ( !fm.loadFile( f, txt ) ) {
656 // ####### could be a new file 665 // ####### could be a new file
657 qDebug( "Cannot open file" ); 666 qDebug( "Cannot open file" );
658
659 //return;
660 } 667 }
661 668// fileNew();
662 fileNew();
663 if ( doc ) 669 if ( doc )
664 delete doc; 670 delete doc;
665 doc = new DocLnk(f); 671 doc = new DocLnk(f);
666 editor->setText(txt); 672 editor->setText(txt);
667 editor->setEdited( FALSE); 673 editor->setEdited( FALSE);
668 edited1=FALSE; 674 edited1=FALSE;
669 edited=FALSE; 675 edited=FALSE;
670 676
671 qDebug("openFile doclnk "+currentFileName);
672 doc->setName(currentFileName); 677 doc->setName(currentFileName);
673 updateCaption(); 678 updateCaption();
674} 679}
675 680
676void TextEdit::showEditTools() 681void TextEdit::showEditTools()
677{ 682{
@@ -688,15 +693,15 @@ void TextEdit::showEditTools()
688 693
689/*! 694/*!
690 unprompted save */ 695 unprompted save */
691bool TextEdit::save() 696bool TextEdit::save()
692{ 697{
693 QString file = doc->file(); 698 QString file = doc->file();
694 qDebug(file); 699 qDebug("saver file "+file);
695 QString name= doc->name(); 700 QString name= doc->name();
696 qDebug(name); 701 qDebug("File named "+name);
697 QString rt = editor->text(); 702 QString rt = editor->text();
698 if( !rt.isEmpty() ) { 703 if( !rt.isEmpty() ) {
699 if(name.isEmpty()) { 704 if(name.isEmpty()) {
700 saveAs(); 705 saveAs();
701 } else { 706 } else {
702 currentFileName= name ; 707 currentFileName= name ;
@@ -728,29 +733,28 @@ bool TextEdit::save()
728 733
729/*! 734/*!
730 prompted save */ 735 prompted save */
731bool TextEdit::saveAs() 736bool TextEdit::saveAs()
732{ 737{
733// qDebug("saveAsFile "+currentFileName); 738// qDebug("saveAsFile "+currentFileName);
734 739 // case of nothing to save...
735 // case of nothing to save... /// there's always something to save 740 if ( !doc )//|| !bFromDocView)
736// if ( !doc )//|| !bFromDocView) 741 {
737// { 742 qDebug("no doc");
738// qDebug("no doc"); 743 return true;
739// return true; 744 }
740// }
741 if ( !editor->edited() ) { 745 if ( !editor->edited() ) {
742 delete doc; 746 delete doc;
743 doc = 0; 747 doc = 0;
744 return true; 748 return true;
745 } 749 }
746 750
747 QString rt = editor->text(); 751 QString rt = editor->text();
748 qDebug(currentFileName); 752 qDebug(currentFileName);
749 753
750 if( currentFileName.isEmpty() || currentFileName == tr("Unnamed")) { 754 if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) {
751 qDebug("do silly TT filename thing"); 755 qDebug("do silly TT filename thing");
752 if ( doc->name().isEmpty() ) { 756 if ( doc->name().isEmpty() ) {
753 QString pt = rt.simplifyWhiteSpace(); 757 QString pt = rt.simplifyWhiteSpace();
754 int i = pt.find( ' ' ); 758 int i = pt.find( ' ' );
755 QString docname = pt; 759 QString docname = pt;
756 if ( i > 0 ) 760 if ( i > 0 )
@@ -811,13 +815,13 @@ bool TextEdit::saveAs()
811 if(caption().left(1)=="*") 815 if(caption().left(1)=="*")
812 setCaption(caption().right(caption().length()-1)); 816 setCaption(caption().right(caption().length()-1));
813 817
814 if(fileSaveDlg) 818 if(fileSaveDlg)
815 delete fileSaveDlg; 819 delete fileSaveDlg;
816 return true; 820 return true;
817} 821} //end saveAs
818 822
819void TextEdit::clear() 823void TextEdit::clear()
820{ 824{
821 delete doc; 825 delete doc;
822 doc = 0; 826 doc = 0;
823 editor->clear(); 827 editor->clear();
@@ -832,26 +836,26 @@ void TextEdit::updateCaption( const QString &name )
832 if ( s.isNull() ) 836 if ( s.isNull() )
833 s = doc->name(); 837 s = doc->name();
834 if ( s.isEmpty() ) { 838 if ( s.isEmpty() ) {
835 s = tr( "Unnamed" ); 839 s = tr( "Unnamed" );
836 currentFileName=s; 840 currentFileName=s;
837 } 841 }
838 842 if(s.left(1) == "/")
843 s = s.right(s.length()-1);
839 setCaption( s + " - " + tr("Text Editor") ); 844 setCaption( s + " - " + tr("Text Editor") );
840 } 845 }
841} 846}
842 847
843void TextEdit::setDocument(const QString& fileref) 848void TextEdit::setDocument(const QString& fileref)
844{ 849{
845 bFromDocView = TRUE; 850 bFromDocView = TRUE;
846 qDebug("setDocument "+fileref);
847 bFromDocView = TRUE;
848 if(fileref.find(".desktop",0,TRUE) == -1) { 851 if(fileref.find(".desktop",0,TRUE) == -1) {
849 openFile(fileref); 852 openFile(fileref);
850 } else { 853 } else {
851 openFile(DocLnk(fileref)); 854 qDebug("is desktop file");
855 openFile(DocLnk(fileref));
852 } 856 }
853 editor->setEdited(TRUE); 857 editor->setEdited(TRUE);
854 edited1=FALSE; 858 edited1=FALSE;
855 edited=TRUE; 859 edited=TRUE;
856 doSearchBar(); 860 doSearchBar();
857} 861}
@@ -861,18 +865,15 @@ void TextEdit::closeEvent( QCloseEvent *e )
861 bFromDocView = FALSE; 865 bFromDocView = FALSE;
862 e->accept(); 866 e->accept();
863} 867}
864 868
865void TextEdit::accept() 869void TextEdit::accept()
866 { 870 {
867 QString file = doc->file(); 871 //if(caption() !="Unnamed")
868 if (file.find("_.txt",0,TRUE) ==-1) 872 if(edited1)
869 save(); 873 saveAs();
870 else {
871 QFile(file).remove();
872 }
873 exit(0); 874 exit(0);
874 875
875} 876}
876 877
877void TextEdit::changeFont() { 878void TextEdit::changeFont() {
878 FontDatabase fdb; 879 FontDatabase fdb;
@@ -931,6 +932,14 @@ void TextEdit::editorChanged() {
931 if(editor->edited() && edited && !edited1) { 932 if(editor->edited() && edited && !edited1) {
932 setCaption( "*"+caption()); 933 setCaption( "*"+caption());
933 edited1=TRUE; 934 edited1=TRUE;
934 } 935 }
935 edited=TRUE; 936 edited=TRUE;
936} 937}
938
939void TextEdit::receive(const QCString&msg, const QByteArray&) {
940 qDebug("QCop "+msg);
941 if ( msg == "setDocument(QString)" ) {
942 qDebug("bugger all");
943 }
944
945}
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index af69518..61fa2a0 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -25,12 +25,15 @@
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>
32
33#include <opie/ofileselector.h>
31 34
32#include <qmainwindow.h> 35#include <qmainwindow.h>
33#include <qmultilineedit.h> 36#include <qmultilineedit.h>
34#include <qlist.h> 37#include <qlist.h>
35#include <qmap.h> 38#include <qmap.h>
36 39
@@ -54,15 +57,16 @@ public:
54 ~TextEdit(); 57 ~TextEdit();
55 58
56 QPopupMenu *font; 59 QPopupMenu *font;
57 QAction *nStart; 60 QAction *nStart;
58 bool edited, edited1; 61 bool edited, edited1;
59 void openFile( const QString & ); 62 void openFile( const QString & );
63 QCopChannel * channel;
60public slots: 64public slots:
61 void editorChanged(); 65 void editorChanged();
62 66void receive(const QCString&, const QByteArray&);
63protected: 67protected:
64 void closeEvent( QCloseEvent *e ); 68 void closeEvent( QCloseEvent *e );
65 void doSearchBar(); 69 void doSearchBar();
66private slots: 70private slots:
67 void setDocument(const QString&); 71 void setDocument(const QString&);
68 void changeFont(); 72 void changeFont();
@@ -103,13 +107,12 @@ private:
103 void updateCaption( const QString &name=QString::null ); 107 void updateCaption( const QString &name=QString::null );
104 void setFontSize(int sz, bool round_down_not_up); 108 void setFontSize(int sz, bool round_down_not_up);
105 109
106private: 110private:
107 fileSaver *fileSaveDlg; 111 fileSaver *fileSaveDlg;
108 fileBrowser *browseForFiles; 112 fileBrowser *browseForFiles;
109
110 QpeEditor* editor; 113 QpeEditor* editor;
111 QToolBar *menu, *editBar, *searchBar; 114 QToolBar *menu, *editBar, *searchBar;
112 QLineEdit *searchEdit; 115 QLineEdit *searchEdit;
113 DocLnk *doc; 116 DocLnk *doc;
114 bool searchVisible; 117 bool searchVisible;
115 bool bFromDocView; 118 bool bFromDocView;