author | llornkcor <llornkcor> | 2003-03-23 14:39:42 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-03-23 14:39:42 (UTC) |
commit | 376aa038c75b3fbccdcb2e81d5b2ac3de787a447 (patch) (side-by-side diff) | |
tree | dfbcd8cfd1a6c37eb5d3b0f8f003a0c41154fd59 /noncore/apps | |
parent | 47d6402958e3d95a49a116552979407b4b731670 (diff) | |
download | opie-376aa038c75b3fbccdcb2e81d5b2ac3de787a447.zip opie-376aa038c75b3fbccdcb2e81d5b2ac3de787a447.tar.gz opie-376aa038c75b3fbccdcb2e81d5b2ac3de787a447.tar.bz2 |
add stderr messagebox to oprocess
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 198 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 862 |
2 files changed, 538 insertions, 522 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h index 3250a66..f31956c 100644 --- a/noncore/apps/advancedfm/advancedfm.h +++ b/noncore/apps/advancedfm/advancedfm.h @@ -15,6 +15,7 @@ #define QT_QWS_OPIE //#include <opie/otabwidget.h> +#include <opie/oprocess.h> #include <qpe/ir.h> #include <qvariant.h> @@ -52,119 +53,120 @@ class Ir; class AdvancedFm : public QMainWindow { - Q_OBJECT + Q_OBJECT public: - AdvancedFm(); - ~AdvancedFm(); + AdvancedFm(); + ~AdvancedFm(); protected slots: - void selectAll(); - void addToDocs(); - void doDirChange(); - void mkDir(); - void del(); - void rn(); - void populateView(); - void rePopulate(); - void showHidden(); - void showMenuHidden(); - void writeConfig(); - void readConfig(); - void ListClicked(QListViewItem *); - void ListPressed( int, QListViewItem *, const QPoint&, int); - void makeDir(); - void doDelete(); - void tabChanged(QWidget*); - void cleanUp(); - void renameIt(); - void runThis(); - void runText(); - void filePerms(); - void doProperties(); - void runCommand(); - void runCommandStd(); - QStringList getPath(); - void mkSym(); - void switchToLocalTab(); - void switchToRemoteTab(); + void selectAll(); + void addToDocs(); + void doDirChange(); + void mkDir(); + void del(); + void rn(); + void populateView(); + void rePopulate(); + void showHidden(); + void showMenuHidden(); + void writeConfig(); + void readConfig(); + void ListClicked(QListViewItem *); + void ListPressed( int, QListViewItem *, const QPoint&, int); + void makeDir(); + void doDelete(); + void tabChanged(QWidget*); + void cleanUp(); + void renameIt(); + void runThis(); + void runText(); + void filePerms(); + void doProperties(); + void runCommand(); + void runCommandStd(); + QStringList getPath(); + void mkSym(); + void switchToLocalTab(); + void switchToRemoteTab(); protected: - OTabWidget *TabWidget; - int whichTab; + OTabWidget *TabWidget; + int whichTab; // QTabWidget *TabWidget; - QWidget *tab, *tab_2, *tab_3; - QListView *Local_View, *Remote_View; + QWidget *tab, *tab_2, *tab_3; + QListView *Local_View, *Remote_View; - QLineEdit *currentPathEdit; - QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu /*, *customDirMenu*/; - QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; + QLineEdit *currentPathEdit; + QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu /*, *customDirMenu*/; + QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; - QDir currentDir, currentRemoteDir; - QComboBox *currentPathCombo; - QString filterStr, s_addBookmark, s_removeBookmark; - QListViewItem * item; - bool b; - QStringList fileSystemTypeList, fsList; - int currentServerConfig; - bool zaurusDevice; - QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; - QStringList remoteDirPathStringList, localDirPathStringList; - QLineEdit *renameBox; + QDir currentDir, currentRemoteDir; + QComboBox *currentPathCombo; + QString filterStr, s_addBookmark, s_removeBookmark; + QListViewItem * item; + bool b; + QStringList fileSystemTypeList, fsList; + int currentServerConfig; + bool zaurusDevice; + QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; + QStringList remoteDirPathStringList, localDirPathStringList; + QLineEdit *renameBox; - void init(); - void initConnections(); - void keyReleaseEvent( QKeyEvent *); - void keyPressEvent( QKeyEvent *); - QString getFileSystemType(const QString &); - QString getDiskSpace(const QString &); - void parsetab(const QString &fileName); - QString checkDiskSpace(const QString &); - QString dealWithSymName(const QString &); - QDir *CurrentDir(); - QDir *OtherDir(); - QListView *CurrentView(); - QListView *OtherView(); - void setOtherTabCurrent(); + void init(); + void initConnections(); + void keyReleaseEvent( QKeyEvent *); + void keyPressEvent( QKeyEvent *); + QString getFileSystemType(const QString &); + QString getDiskSpace(const QString &); + void parsetab(const QString &fileName); + QString checkDiskSpace(const QString &); + QString dealWithSymName(const QString &); + QDir *CurrentDir(); + QDir *OtherDir(); + QListView *CurrentView(); + QListView *OtherView(); + void setOtherTabCurrent(); protected slots: - void dirMenuSelected(int); - void showFileMenu(); - void cancelMenuTimer(); - void homeButtonPushed(); - void docButtonPushed(); - void SDButtonPushed(); - void CFButtonPushed(); - void QPEButtonPushed(); - void upDir(); - void currentPathComboChanged(); - void copy(); - void copyAs(); - void copySameDir(); - void currentPathComboActivated(const QString &); - void fillCombo(const QString &); - bool copyFile( const QString & , const QString & ); - void move(); - void fileStatus(); - void doAbout(); - void doBeam(); - void fileBeamFinished( Ir *); + void dirMenuSelected(int); + void showFileMenu(); + void cancelMenuTimer(); + void homeButtonPushed(); + void docButtonPushed(); + void SDButtonPushed(); + void CFButtonPushed(); + void QPEButtonPushed(); + void upDir(); + void currentPathComboChanged(); + void copy(); + void copyAs(); + void copySameDir(); + void currentPathComboActivated(const QString &); + void fillCombo(const QString &); + bool copyFile( const QString & , const QString & ); + void move(); + void fileStatus(); + void doAbout(); + void doBeam(); + void fileBeamFinished( Ir *); private: - MenuButton *menuButton; - QString oldName; - QTimer menuTimer; - void startProcess(const QString &); - bool eventFilter( QObject * , QEvent * ); - void cancelRename(); - void doRename(QListView *); - void okRename(); - void customDirsToMenu(); - void addCustomDir(); - void removeCustomDir(); + MenuButton *menuButton; + QString oldName; + QTimer menuTimer; + void startProcess(const QString &); + bool eventFilter( QObject * , QEvent * ); + void cancelRename(); + void doRename(QListView *); + void okRename(); + void customDirsToMenu(); + void addCustomDir(); + void removeCustomDir(); private slots: - void processEnded(); - void gotoCustomDir(const QString &); + void processEnded(OProcess *); + void oprocessStderr(OProcess *, char *, int); + void gotoCustomDir(const QString &); }; #endif // ADVANCEDFM_H diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index a82d69a..eac13f6 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp @@ -54,20 +54,20 @@ void AdvancedFm::doDirChange() void AdvancedFm::showMenuHidden() { if (b) - { - CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); - OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); - fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); + { + CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); + OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); + fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); // b=FALSE; - } - else - { - CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); - OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); - fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); + } + else + { + CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); + OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); + fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); // b=TRUE; - } + } rePopulate(); // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); if(b) b = false; else b = true; @@ -76,20 +76,20 @@ void AdvancedFm::showMenuHidden() void AdvancedFm::showHidden() { if (b) - { - CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); - OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); + { + CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); + OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); // b=FALSE; - } - else - { - CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); - OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); + } + else + { + CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); + OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); // b=TRUE; - } + } rePopulate(); } @@ -101,53 +101,53 @@ QString AdvancedFm::dealWithSymName(const QString &fileName) void AdvancedFm::runThis() { - QString fs; - QDir *thisDir = CurrentDir(); - - QString curFile = CurrentView()->currentItem()->text(0); - QString path = thisDir->canonicalPath(); - - if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink - - curFile = dealWithSymName((const QString&)curFile); - - if(curFile != "../") - { - - fs = getFileSystemType((const QString &) path); - QFileInfo fileInfo( path + "/" + curFile); - qDebug( fileInfo.owner()); - - if( (fileInfo.permission( QFileInfo::ExeUser) - | fileInfo.permission( QFileInfo::ExeGroup) - | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { - | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { - QCopEnvelope e("QPE/System", "execute(QString)" ); - e << curFile; - } - else - { - curFile = path + "/" + curFile; - DocLnk nf(curFile); - QString execStr = nf.exec(); - qDebug( execStr); - if( execStr.isEmpty() ) - { - } - else - { - nf.execute(); - } - } - } + QString fs; + QDir *thisDir = CurrentDir(); + + QString curFile = CurrentView()->currentItem()->text(0); + QString path = thisDir->canonicalPath(); + + if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink + + curFile = dealWithSymName((const QString&)curFile); + + if(curFile != "../") + { + + fs = getFileSystemType((const QString &) path); + QFileInfo fileInfo( path + "/" + curFile); + qDebug( fileInfo.owner()); + + if( (fileInfo.permission( QFileInfo::ExeUser) + | fileInfo.permission( QFileInfo::ExeGroup) + | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { + | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { + QCopEnvelope e("QPE/System", "execute(QString)" ); + e << curFile; + } + else + { + curFile = path + "/" + curFile; + DocLnk nf(curFile); + QString execStr = nf.exec(); + qDebug( execStr); + if( execStr.isEmpty() ) + { + } + else + { + nf.execute(); + } + } + } } void AdvancedFm::runText() { - QString curFile = CurrentView()->currentItem()->text(0); - if(curFile != "../") - { - if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink + QString curFile = CurrentView()->currentItem()->text(0); + if(curFile != "../") + { + if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink curFile = dealWithSymName((const QString&)curFile); curFile = CurrentDir()->canonicalPath()+"/"+curFile; QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); @@ -161,10 +161,10 @@ void AdvancedFm::makeDir() fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); fileDlg->exec(); if( fileDlg->result() == 1 ) - { - QDir *thisDir = CurrentDir(); - QString filename = fileDlg->LineEdit1->text(); - thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); + { + QDir *thisDir = CurrentDir(); + QString filename = fileDlg->LineEdit1->text(); + thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); } populateView(); } @@ -176,14 +176,14 @@ void AdvancedFm::doDelete() bool doMsg=true; int count = curFileList.count(); if( count > 0) - { + { if(count > 1 ) - { + { QString msg; msg=tr("Really delete\n%1 files?").arg(count); switch ( QMessageBox::warning(this,tr("Delete"),msg ,tr("Yes"),tr("No"),0,0,1) ) - { + { case 0: doMsg=false; break; @@ -195,7 +195,7 @@ void AdvancedFm::doDelete() QString myFile; for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) - { + { myFile = (*it); if( myFile.find(" -> ",0,TRUE) != -1) myFile = myFile.left( myFile.find(" -> ",0,TRUE)); @@ -205,13 +205,13 @@ void AdvancedFm::doDelete() f += "/"; f += myFile; if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) - { + { switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f + "\nand all it's contents ?" ,tr("Yes"),tr("No"),0,0,1) ) - { + { case 0: - { + { f=f.left(f.length()-1); QString cmd="rm -rf "+f; startProcess( (const QString)cmd.latin1() ); @@ -244,21 +244,21 @@ void AdvancedFm::doDelete() void AdvancedFm::filePerms() { - QStringList curFileList = getPath(); + QStringList curFileList = getPath(); QString filePath; - filePath = CurrentDir()->canonicalPath()+"/"; + filePath = CurrentDir()->canonicalPath()+"/"; for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) - { - filePermissions *filePerm; - filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); - filePerm->showMaximized(); - filePerm->exec(); - if( filePerm) - delete filePerm; - } - populateView(); + { + filePermissions *filePerm; + filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); + filePerm->showMaximized(); + filePerm->exec(); + if( filePerm) + delete filePerm; + } + populateView(); } void AdvancedFm::doProperties() @@ -270,10 +270,10 @@ void AdvancedFm::doProperties() QString filePath; filePath = CurrentDir()->canonicalPath()+"/"; - qDebug("%d",curFileList.count()); + qDebug("%d",curFileList.count()); for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) - { + { qDebug((filePath+*it)); DocLnk lnk( (filePath+*it)); LnkProperties prop( &lnk ); @@ -286,16 +286,16 @@ void AdvancedFm::doProperties() void AdvancedFm::upDir() { - QDir *thisDir = CurrentDir(); - QString current = thisDir->canonicalPath(); - QDir dir(current); - dir.cdUp(); - current = dir.canonicalPath(); - chdir( current.latin1() ); + QDir *thisDir = CurrentDir(); + QString current = thisDir->canonicalPath(); + QDir dir(current); + dir.cdUp(); + current = dir.canonicalPath(); + chdir( current.latin1() ); thisDir->cd( current, TRUE); populateView(); - update(); + update(); } void AdvancedFm::copy() @@ -304,65 +304,65 @@ void AdvancedFm::copy() QStringList curFileList = getPath(); QDir *thisDir = CurrentDir(); - QDir *thatDir = OtherDir(); + QDir *thatDir = OtherDir(); bool doMsg=true; - int count=curFileList.count(); - if( count > 0) { - if(count > 1 ){ - QString msg; - msg=tr("Really copy\n%1 files?").arg(count); - switch ( QMessageBox::warning(this,tr("Delete"),msg - ,tr("Yes"),tr("No"),0,0,1) ) - { - case 0: - doMsg=false; - break; - case 1: - return; - break; - }; - } + int count=curFileList.count(); + if( count > 0) { + if(count > 1 ){ + QString msg; + msg=tr("Really copy\n%1 files?").arg(count); + switch ( QMessageBox::warning(this,tr("Delete"),msg + ,tr("Yes"),tr("No"),0,0,1) ) + { + case 0: + doMsg=false; + break; + case 1: + return; + break; + }; + } QString curFile, item, destFile; - for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) - { - item=(*it); - if(item.find("->",0,TRUE)) //symlink - item = item.left(item.find("->",0,TRUE)); - - curFile = thisDir->canonicalPath()+"/"+ item; - destFile = thatDir->canonicalPath()+"/"+ item; - - qDebug("Destination file is "+destFile); - qDebug("CurrentFile file is " + curFile); - - QFile f(destFile); - if( f.exists()) - { - if(doMsg) - { - switch ( QMessageBox::warning(this,tr("File Exists!"), - tr("%1 exists. Ok to overwrite?").arg( item ), - tr("Yes"),tr("No"),0,0,1) ) - { - case 1: - return; - break; + for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) + { + item=(*it); + if(item.find("->",0,TRUE)) //symlink + item = item.left(item.find("->",0,TRUE)); + + curFile = thisDir->canonicalPath()+"/"+ item; + destFile = thatDir->canonicalPath()+"/"+ item; + + qDebug("Destination file is "+destFile); + qDebug("CurrentFile file is " + curFile); + + QFile f(destFile); + if( f.exists()) + { + if(doMsg) + { + switch ( QMessageBox::warning(this,tr("File Exists!"), + tr("%1 exists. Ok to overwrite?").arg( item ), + tr("Yes"),tr("No"),0,0,1) ) + { + case 1: + return; + break; }; } - f.remove(); + f.remove(); } - if( !copyFile( curFile, destFile) ) - { - QMessageBox::message("AdvancedFm", - tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); - return; - } + if( !copyFile( curFile, destFile) ) + { + QMessageBox::message("AdvancedFm", + tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); + return; + } } - setOtherTabCurrent(); - populateView(); + setOtherTabCurrent(); + populateView(); } } @@ -374,12 +374,12 @@ void AdvancedFm::copyAs() QString curFile, item; InputDialog *fileDlg; - QDir *thisDir = CurrentDir(); - QDir *thatDir = OtherDir(); + QDir *thisDir = CurrentDir(); + QDir *thatDir = OtherDir(); - for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) - { - QString destFile; + for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) + { + QString destFile; item=(*it); curFile = thisDir->canonicalPath()+"/"+(*it); fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); @@ -388,37 +388,37 @@ void AdvancedFm::copyAs() fileDlg->exec(); if( fileDlg->result() == 1 ) - { - QString filename = fileDlg->LineEdit1->text(); - destFile = thatDir->canonicalPath()+"/"+filename; - - QFile f( destFile); - if( f.exists()) - { - switch (QMessageBox::warning(this,tr("File Exists!"), - item+tr("\nexists. Ok to overwrite?"), - tr("Yes"),tr("No"),0,0,1) ) - { - case 0: - f.remove(); - break; - case 1: - return; - break; - }; - } - if( !copyFile( curFile, destFile) ) - { - QMessageBox::message("AdvancedFm",tr("Could not copy\n") - +curFile +tr("to\n")+destFile); - return; - } - } + { + QString filename = fileDlg->LineEdit1->text(); + destFile = thatDir->canonicalPath()+"/"+filename; + + QFile f( destFile); + if( f.exists()) + { + switch (QMessageBox::warning(this,tr("File Exists!"), + item+tr("\nexists. Ok to overwrite?"), + tr("Yes"),tr("No"),0,0,1) ) + { + case 0: + f.remove(); + break; + case 1: + return; + break; + }; + } + if( !copyFile( curFile, destFile) ) + { + QMessageBox::message("AdvancedFm",tr("Could not copy\n") + +curFile +tr("to\n")+destFile); + return; + } + } delete fileDlg; } - setOtherTabCurrent(); - populateView(); + setOtherTabCurrent(); + populateView(); } void AdvancedFm::copySameDir() @@ -428,11 +428,11 @@ void AdvancedFm::copySameDir() QString curFile, item, destFile; InputDialog *fileDlg; - QDir *thisDir = CurrentDir(); + QDir *thisDir = CurrentDir(); - for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) - { - item=(*it); + for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) + { + item=(*it); curFile = thisDir->canonicalPath()+"/"+ item; fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); @@ -440,38 +440,38 @@ void AdvancedFm::copySameDir() fileDlg->exec(); if( fileDlg->result() == 1 ) - { - - QString filename = fileDlg->LineEdit1->text(); - destFile = thisDir->canonicalPath()+"/"+filename; - - QFile f(destFile); - if( f.exists()) - { - switch (QMessageBox::warning(this,tr("Delete"), - destFile+tr(" already exists.\nDo you really want to delete it?"), - tr("Yes"),tr("No"),0,0,1) ) { - case 0: - - f.remove(); - break; - case 1: - return; - break; - }; - } - if(!copyFile( curFile,destFile) ) - { - QMessageBox::message("AdvancedFm",tr("Could not copy\n") - +curFile +tr("to\n")+destFile); - return; - } - - qDebug("copy "+curFile+" as "+destFile); - } + { + + QString filename = fileDlg->LineEdit1->text(); + destFile = thisDir->canonicalPath()+"/"+filename; + + QFile f(destFile); + if( f.exists()) + { + switch (QMessageBox::warning(this,tr("Delete"), + destFile+tr(" already exists.\nDo you really want to delete it?"), + tr("Yes"),tr("No"),0,0,1) ) { + case 0: + + f.remove(); + break; + case 1: + return; + break; + }; + } + if(!copyFile( curFile,destFile) ) + { + QMessageBox::message("AdvancedFm",tr("Could not copy\n") + +curFile +tr("to\n")+destFile); + return; + } + + qDebug("copy "+curFile+" as "+destFile); + } delete fileDlg; } - populateView(); + populateView(); } void AdvancedFm::move() @@ -480,42 +480,42 @@ void AdvancedFm::move() QStringList curFileList = getPath(); if( curFileList.count() > 0) - { - QString curFile, destFile, item; - - QDir *thisDir = CurrentDir(); - QDir *thatDir = OtherDir(); - for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) - { - item=(*it); - QString destFile = thatDir->canonicalPath(); - - if(destFile.right(1).find("/",0,TRUE) == -1) - destFile+="/"; - destFile += item; - qDebug("Destination file is "+destFile); - - curFile = thisDir->canonicalPath(); - if(curFile.right(1).find("/",0,TRUE) == -1) - curFile +="/"; - curFile+= item; - qDebug("CurrentFile file is " + curFile); - - QFile f( curFile); - if( f.exists()) { - if( !copyFile( curFile, destFile) ) - { - QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); - return; - } else - QFile::remove(curFile); - } - } - - } - setOtherTabCurrent(); - populateView(); -// populateLocalView(); + { + QString curFile, destFile, item; + + QDir *thisDir = CurrentDir(); + QDir *thatDir = OtherDir(); + for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) + { + item=(*it); + QString destFile = thatDir->canonicalPath(); + + if(destFile.right(1).find("/",0,TRUE) == -1) + destFile+="/"; + destFile += item; + qDebug("Destination file is "+destFile); + + curFile = thisDir->canonicalPath(); + if(curFile.right(1).find("/",0,TRUE) == -1) + curFile +="/"; + curFile+= item; + qDebug("CurrentFile file is " + curFile); + + QFile f( curFile); + if( f.exists()) { + if( !copyFile( curFile, destFile) ) + { + QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); + return; + } else + QFile::remove(curFile); + } + } + + } + setOtherTabCurrent(); + populateView(); +// populateLocalView(); } bool AdvancedFm::copyFile( const QString & src, const QString & dest ) @@ -529,59 +529,59 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) QFile d( dest ); if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) - { - while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) - { - if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ - success = FALSE; - break; - } - } - if( success && (bytesRead > 0) ) - { - d.writeBlock( bf, bytesRead ); - } - } - else - { - success = FALSE; - } - - // Set file permissions + { + while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) + { + if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ + success = FALSE; + break; + } + } + if( success && (bytesRead > 0) ) + { + d.writeBlock( bf, bytesRead ); + } + } + else + { + success = FALSE; + } + + // Set file permissions if( stat( (const char *) src, &status ) == 0 ) - { - chmod( (const char *) dest, status.st_mode ); - } + { + chmod( (const char *) dest, status.st_mode ); + } return success; } void AdvancedFm::runCommand() { - QDir *thisDir = CurrentDir(); - - QString curFile; - curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); + QDir *thisDir = CurrentDir(); - InputDialog *fileDlg; - fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); - fileDlg->setInputText(curFile); - fileDlg->exec(); - //QString command; + QString curFile; + curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); - if( fileDlg->result() == 1 ) - { - qDebug(fileDlg->LineEdit1->text()); - QStringList command; + InputDialog *fileDlg; + fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); + fileDlg->setInputText(curFile); + fileDlg->exec(); + //QString command; - command << "/bin/sh"; - command << "-c"; - command << fileDlg->LineEdit1->text(); - Output *outDlg; - outDlg = new Output( command, this, tr("AdvancedFm Output"), true); - outDlg->showMaximized(); - outDlg->exec(); - qApp->processEvents(); + if( fileDlg->result() == 1 ) + { + qDebug(fileDlg->LineEdit1->text()); + QStringList command; + + command << "/bin/sh"; + command << "-c"; + command << fileDlg->LineEdit1->text(); + Output *outDlg; + outDlg = new Output( command, this, tr("AdvancedFm Output"), true); + outDlg->showMaximized(); + outDlg->exec(); + qApp->processEvents(); } } @@ -589,10 +589,10 @@ void AdvancedFm::runCommand() void AdvancedFm::runCommandStd() { QString curFile; - QDir *thisDir = CurrentDir(); - QListView *thisView = CurrentView(); - if( thisView->currentItem()) - curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); + QDir *thisDir = CurrentDir(); + QListView *thisView = CurrentView(); + if( thisView->currentItem()) + curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); @@ -600,27 +600,27 @@ void AdvancedFm::runCommandStd() fileDlg->exec(); if( fileDlg->result() == 1 ) - { + { qApp->processEvents(); startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); - } + } } void AdvancedFm::fileStatus() { QString curFile; - curFile = CurrentView()->currentItem()->text(0); + curFile = CurrentView()->currentItem()->text(0); - QStringList command; - command << "/bin/sh"; - command << "-c"; - command << "stat -l "+ curFile; + QStringList command; + command << "/bin/sh"; + command << "-c"; + command << "stat -l "+ curFile; - Output *outDlg; - outDlg = new Output( command, this, tr("AdvancedFm Output"), true); - outDlg->showMaximized(); - outDlg->exec(); - qApp->processEvents(); + Output *outDlg; + outDlg = new Output( command, this, tr("AdvancedFm Output"), true); + outDlg->showMaximized(); + outDlg->exec(); + qApp->processEvents(); } @@ -631,7 +631,7 @@ void AdvancedFm::mkDir() void AdvancedFm::rn() { - renameIt(); + renameIt(); } void AdvancedFm::del() @@ -641,63 +641,63 @@ void AdvancedFm::del() void AdvancedFm::mkSym() { - QString cmd; - QStringList curFileList = getPath(); - if( curFileList.count() > 0) - { - QDir *thisDir = CurrentDir(); - QDir * thatDir = OtherDir(); + QString cmd; + QStringList curFileList = getPath(); + if( curFileList.count() > 0) + { + QDir *thisDir = CurrentDir(); + QDir * thatDir = OtherDir(); - for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) - { + for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) + { - QString destName = thatDir->canonicalPath()+"/"+(*it); - if(destName.right(1) == "/") - { - destName = destName.left( destName.length() -1); - } + QString destName = thatDir->canonicalPath()+"/"+(*it); + if(destName.right(1) == "/") + { + destName = destName.left( destName.length() -1); + } - QString curFile = thisDir->canonicalPath()+"/"+(*it); + QString curFile = thisDir->canonicalPath()+"/"+(*it); - if( curFile.right(1) == "/") - { - curFile = curFile.left( curFile.length() -1); - } + if( curFile.right(1) == "/") + { + curFile = curFile.left( curFile.length() -1); + } - cmd = "ln -s "+curFile+" "+destName; - qDebug(cmd); - startProcess( (const QString)cmd ); - } - setOtherTabCurrent(); - populateView(); - } + cmd = "ln -s "+curFile+" "+destName; + qDebug(cmd); + startProcess( (const QString)cmd ); + } + setOtherTabCurrent(); + populateView(); + } } void AdvancedFm::doBeam() { Ir ir; if(!ir.supported()) - { - } - else - { - QStringList curFileList = getPath(); - if( curFileList.count() > 0) - { - for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) - { - - QString curFile = CurrentDir()->canonicalPath()+"/"+(*it); - if( curFile.right(1) == "/") - { - curFile = curFile.left( curFile.length() -1); - } - Ir *file = new Ir(this, "IR"); - connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); - file->send( curFile, curFile ); - } - } - } + { + } + else + { + QStringList curFileList = getPath(); + if( curFileList.count() > 0) + { + for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) + { + + QString curFile = CurrentDir()->canonicalPath()+"/"+(*it); + if( curFile.right(1) == "/") + { + curFile = curFile.left( curFile.length() -1); + } + Ir *file = new Ir(this, "IR"); + connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); + file->send( curFile, curFile ); + } + } + } } @@ -709,9 +709,9 @@ void AdvancedFm::fileBeamFinished( Ir *) void AdvancedFm::selectAll() { // if (TabWidget->getCurrentTab() == 0) { - QListView *thisView = CurrentView(); - thisView->selectAll(true); - thisView->setSelected( thisView->firstChild(),false); + QListView *thisView = CurrentView(); + thisView->selectAll(true); + thisView->setSelected( thisView->firstChild(),false); // } else { // Remote_View->selectAll(true); // Remote_View->setSelected( Remote_View->firstChild(),false); @@ -720,77 +720,91 @@ void AdvancedFm::selectAll() void AdvancedFm::startProcess(const QString & cmd) { - QStringList command; - OProcess *process; - process = new OProcess(); - connect(process, SIGNAL(processExited(OProcess *)), - this, SLOT( processEnded())); + QStringList command; + OProcess *process; + process = new OProcess(); + connect(process, SIGNAL(processExited(OProcess *)), + this, SLOT( processEnded(OProcess *))); + + connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), + this, SLOT( oprocessStderr(OProcess *, char *, int))); - command << "/bin/sh"; - command << "-c"; - command << cmd.latin1(); - *process << command; - if(!process->start(OProcess::NotifyOnExit) ) - qDebug("could not start process"); + command << "/bin/sh"; + command << "-c"; + command << cmd.latin1(); + *process << command; + if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) + qDebug("could not start process"); } -void AdvancedFm::processEnded() +void AdvancedFm::processEnded(OProcess *) { // populateLocalView(); populateView(); } +void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int buflen) { + qWarning("received stderrt %d bytes", buflen); + + QString lineStr = buffer; +// lineStr=lineStr.left(lineStr.length()-1); + QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); + +// OutputEdit->append(lineStr); +// OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); +} + bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { - if ( o->inherits( "QLineEdit" ) ) - { - if ( e->type() == QEvent::KeyPress ) - { - QKeyEvent *ke = (QKeyEvent*)e; - if ( ke->key() == Key_Return || - ke->key() == Key_Enter ) - { - okRename(); - return true; + if ( o->inherits( "QLineEdit" ) ) + { + if ( e->type() == QEvent::KeyPress ) + { + QKeyEvent *ke = (QKeyEvent*)e; + if ( ke->key() == Key_Return || + ke->key() == Key_Enter ) + { + okRename(); + return true; } - else if ( ke->key() == Key_Escape ) - { - cancelRename(); - return true; - } + else if ( ke->key() == Key_Escape ) + { + cancelRename(); + return true; + } } - else if ( e->type() == QEvent::FocusOut ) - { - cancelRename(); - return true; - } + else if ( e->type() == QEvent::FocusOut ) + { + cancelRename(); + return true; + } } - if ( o->inherits( "QListView" ) ) - { - if ( e->type() == QEvent::FocusOut ) - { - printf("focusIn\n"); + if ( o->inherits( "QListView" ) ) + { + if ( e->type() == QEvent::FocusOut ) + { + printf("focusIn\n"); } } - return QWidget::eventFilter( o, e ); + return QWidget::eventFilter( o, e ); } void AdvancedFm::cancelRename() { - qDebug("cancel rename"); - QListView * view; - view = CurrentView(); - - bool resetFocus = view->viewport()->focusProxy() == renameBox; - delete renameBox; - renameBox = 0; - if ( resetFocus ) - { - view->viewport()->setFocusProxy( view); - view->setFocus(); + qDebug("cancel rename"); + QListView * view; + view = CurrentView(); + + bool resetFocus = view->viewport()->focusProxy() == renameBox; + delete renameBox; + renameBox = 0; + if ( resetFocus ) + { + view->viewport()->setFocusProxy( view); + view->setFocus(); } } @@ -821,7 +835,7 @@ void AdvancedFm::doRename(QListView * view) void AdvancedFm::renameIt() { - QListView *thisView = CurrentView(); + QListView *thisView = CurrentView(); oldName = thisView->currentItem()->text(0); doRename( thisView ); populateView(); @@ -829,22 +843,22 @@ void AdvancedFm::renameIt() void AdvancedFm::okRename() { - QString newName = renameBox->text(); - cancelRename(); -// int tabs=0; - QListView * view = CurrentView(); - QString path = CurrentDir()->canonicalPath() + "/"; - oldName = path + oldName; - newName = path + newName; - - if( view->currentItem() == NULL) - return; - if( rename( oldName.latin1(), newName.latin1())== -1) - QMessageBox::message(tr("Note"),tr("Could not rename")); - else - oldName = ""; - - view->takeItem( view->currentItem() ); - delete view->currentItem(); - populateView(); + QString newName = renameBox->text(); + cancelRename(); +// int tabs=0; + QListView * view = CurrentView(); + QString path = CurrentDir()->canonicalPath() + "/"; + oldName = path + oldName; + newName = path + newName; + + if( view->currentItem() == NULL) + return; + if( rename( oldName.latin1(), newName.latin1())== -1) + QMessageBox::message(tr("Note"),tr("Could not rename")); + else + oldName = ""; + + view->takeItem( view->currentItem() ); + delete view->currentItem(); + populateView(); } |