-rw-r--r-- | core/apps/textedit/fileSaver.cpp | 16 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 52 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 2 |
3 files changed, 42 insertions, 28 deletions
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp index d01daee..88608cc 100644 --- a/core/apps/textedit/fileSaver.cpp +++ b/core/apps/textedit/fileSaver.cpp @@ -24,17 +24,19 @@ fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName ) : QDialog( parent, name, modal, fl ) { if ( !name ) setName( "fileSaver" ); resize( 236, 280 ); setCaption(tr( "Save file" ) ); -// filterStr=currentFileName; + QFileInfo fi(currentFileName); + QString tmpFileName=fi.fileName(); +// qDebug( tmpFileName); dirLabel = new QLabel(this, "DirLabel"); dirLabel->setText(currentDir.canonicalPath()); dirLabel->setGeometry(10,4,230,30); ListView = new QListView( this, "ListView" ); ListView->addColumn( tr( "Name" ) ); ListView->setColumnWidth(0,140); @@ -44,21 +46,26 @@ fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl // ListView->setMultiSelection(true); // ListView->setSelectionMode(QListView::Extended); ListView->setAllColumnsShowFocus( TRUE ); ListView->setGeometry( QRect( 10, 35, 220, 160 ) ); fileEdit= new QLineEdit(this); fileEdit->setGeometry( QRect( 10, 230, 200, 25)); - fileEdit->setText(currentFileName); - // signals and slots connections + + fileEdit->setText( tmpFileName); + + // signals and slots connections connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); - currentDir.setPath(QDir::currentDirPath() ); + +// tmpFileName=fi.FilePath(); +// qDebug( tmpFileName); + currentDir.setPath( QDir::currentDirPath() ); populateList(); } fileSaver::~fileSaver() { } @@ -155,10 +162,11 @@ void fileSaver::listClicked(QListViewItem *selectedItem) void fileSaver::OnOK() { // reject(); } void fileSaver::accept() { selectedFileName = fileEdit->text(); selectedFileName = currentDir.canonicalPath()+ selectedFileName; + qDebug("goint to save "+selectedFileName); reject(); } diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 14bc496..429c195 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp @@ -480,17 +480,19 @@ void TextEdit::setWordWrap(bool y) { bool state = editor->edited(); editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); editor->setEdited( state ); } void TextEdit::fileNew() { - save(); + if( !bFromDocView ) { + save(); + } newFile(DocLnk()); } void TextEdit::fileOpen() { // if ( !save() ) { // if ( QMessageBox::critical( this, tr( "Out of space" ), // tr( "Text Editor was unable to\n" @@ -507,37 +509,38 @@ void TextEdit::fileOpen() // } // } menu->hide(); editBar->hide(); searchBar->hide(); clearWState (WState_Reserved1 ); editorStack->raiseWidget( fileSelector ); fileSelector->reread(); - updateCaption(); + updateCaption(currentFileName); } void TextEdit::newFileOpen() { fileBrowser *browseForFiles; browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*"); - browseForFiles->exec(); - QString selFile= browseForFiles->selectedFileName; - QStringList fileList=browseForFiles->fileList; - qDebug(selFile); - QStringList::ConstIterator f; - QString fileTemp; - for ( f = fileList.begin(); f != fileList.end(); f++ ) { - fileTemp = *f; - fileTemp.right( fileTemp.length()-5); - QString fileName = fileTemp; - if( fileName != "Unnamed" || fileName != "Empty Text" ) { - currentFileName = fileName; - qDebug("please open "+currentFileName); - openFile(fileName ); + if( browseForFiles->exec()!= 0 ) { + QString selFile= browseForFiles->selectedFileName; + QStringList fileList=browseForFiles->fileList; + qDebug(selFile); + QStringList::ConstIterator f; + QString fileTemp; + for ( f = fileList.begin(); f != fileList.end(); f++ ) { + fileTemp = *f; + fileTemp.right( fileTemp.length()-5); + QString fileName = fileTemp; + if( fileName != "Unnamed" || fileName != "Empty Text" ) { + currentFileName = fileName; +// qDebug("please open "+currentFileName); + openFile(fileName ); + } } } delete browseForFiles; } #if 0 void TextEdit::slotFind() @@ -614,17 +617,17 @@ void TextEdit::newFile( const DocLnk &f ) { DocLnk nf = f; nf.setType("text/plain"); clear(); editorStack->raiseWidget( editor ); setWState (WState_Reserved1 ); editor->setFocus(); doc = new DocLnk(nf); - updateCaption(); +// updateCaption(); } void TextEdit::openFile( const QString &f ) { bFromDocView = TRUE; DocLnk nf; nf.setType("text/plain"); nf.setFile(f); @@ -636,63 +639,65 @@ void TextEdit::openFile( const QString &f ) if ( sep > 0 ) name = name.mid( sep+1 ); updateCaption( name ); } void TextEdit::openFile( const DocLnk &f ) { // clear(); + bFromDocView = TRUE; FileManager fm; QString txt; if ( !fm.loadFile( f, txt ) ) { // ####### could be a new file qDebug( "Cannot open file" ); //return; } fileNew(); if ( doc ) delete doc; doc = new DocLnk(f); editor->setText(txt); editor->setEdited(FALSE); - updateCaption(); + updateCaption(currentFileName); } void TextEdit::showEditTools() { // if ( !doc ) // close(); // clear(); fileSelector->hide(); menu->show(); editBar->show(); if ( searchVisible ) searchBar->show(); - updateCaption(); +// updateCaption(); editorStack->raiseWidget( editor ); setWState (WState_Reserved1 ); } bool TextEdit::save() { // case of nothing to save... if ( !doc || !bFromDocView) return true; if ( !editor->edited() ) { delete doc; doc = 0; return true; } QString rt = editor->text(); - - if(currentFileName.isEmpty() || currentFileName == "Unnamed") { + qDebug(currentFileName); + + if( currentFileName.isEmpty() || currentFileName == "Unnamed") { if ( doc->name().isEmpty() ) { QString pt = rt.simplifyWhiteSpace(); int i = pt.find( ' ' ); QString docname = pt; if ( i > 0 ) docname = pt.left( i ); // remove "." at the beginning @@ -706,21 +711,22 @@ bool TextEdit::save() docname = "Empty Text"; doc->setName(docname); currentFileName=docname; } } fileSaver *fileSaveDlg; fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName); - fileSaveDlg->exec(); + if( fileSaveDlg->exec() != 0 ) { QString fileNm=fileSaveDlg->selectedFileName; qDebug("save filename "+fileNm); doc->setName(fileNm); - updateCaption(); + updateCaption(fileNm); + } delete fileSaveDlg; FileManager fm; if ( !fm.saveFile( *doc, rt ) ) { return false; } delete doc; doc = 0; diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h index 4e469cc..4bfb260 100644 --- a/core/apps/textedit/textedit.h +++ b/core/apps/textedit/textedit.h @@ -50,17 +50,17 @@ public: void openFile( const QString & ); protected: void closeEvent( QCloseEvent *e ); private slots: void setDocument(const QString&); - void changeFont(); + void changeFont(); void fileNew(); void fileRevert(); void fileOpen(); void newFileOpen(); bool save(); void editCut(); void editCopy(); |