-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 65 |
1 files changed, 50 insertions, 15 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index faa03dc..bd513c0 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp @@ -813,49 +813,48 @@ void AdvancedFm::localDelete() populateLocalView(); } break; case 1: // exit break; }; } else { switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f +" ?",tr("Yes"),tr("No"),0,0,1) ) { case 0: { QString cmd="rm "+f; QFile file(f); file.remove(); // system( cmd.latin1()); populateLocalView(); } break; case 1: // exit break; }; } - } } void AdvancedFm::remoteDelete() { QStringList curFileList = getPath(); 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)); QString f = currentDir.canonicalPath(); if(f.right(1).find("/",0,TRUE) == -1) f+="/"; f+=myFile; if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to 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; system( cmd.latin1()); @@ -1119,157 +1118,193 @@ void AdvancedFm::upDir() current = dir.canonicalPath(); chdir( current.latin1() ); currentDir.cd( current, TRUE); populateLocalView(); update(); } else { QString current = currentRemoteDir.canonicalPath(); QDir dir(current); dir.cdUp(); current = dir.canonicalPath(); chdir( current.latin1() ); currentRemoteDir.cd( current, TRUE); populateRemoteView(); update(); } } void AdvancedFm::copy() { QStringList curFileList = getPath(); QString curFile; if (TabWidget->currentPageIndex() == 0) { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { - QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); - curFile = currentDir.canonicalPath()+"/"+(*it); + QString destFile = currentRemoteDir.canonicalPath(); + if(destFile.right(1).find("/",0,TRUE) == -1) + destFile+="/"; + destFile +=(*it); + curFile = currentDir.canonicalPath(); + if(curFile.right(1).find("/",0,TRUE) == -1) + curFile +="/"; + curFile +=(*it); QFile f(destFile); if( f.exists()) f.remove(); if(!copyFile(destFile, curFile) ) qWarning("nothin doing"); } populateRemoteView(); TabWidget->setCurrentPage(1); } else { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { - QString destFile = currentDir.canonicalPath()+"/"+(*it); - curFile = currentRemoteDir.canonicalPath()+"/"+(*it); + QString destFile = currentDir.canonicalPath(); + if(destFile.right(1).find("/",0,TRUE) == -1) + destFile+="/"; + destFile +=(*it); + curFile = currentRemoteDir.canonicalPath(); + if(curFile.right(1).find("/",0,TRUE) == -1) + curFile +="/"; + curFile +=(*it); QFile f(destFile); if( f.exists()) f.remove(); if(!copyFile(destFile, curFile) ) qWarning("nothin doing"); } populateLocalView(); TabWidget->setCurrentPage(0); } } void AdvancedFm::copyAs() { QStringList curFileList = getPath(); QString curFile; InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); if (TabWidget->currentPageIndex() == 0) { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { - QString destFile = *it; - curFile = currentDir.canonicalPath()+"/"+(*it); + QString destFile; + curFile = currentDir.canonicalPath(); + if(curFile.right(1).find("/",0,TRUE) == -1) + curFile +="/"; + curFile+=(*it); // InputDialog *fileDlg; // fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); fileDlg->setInputText((const QString &) destFile ); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); - destFile = currentRemoteDir.canonicalPath()+"/"+destFile; + destFile = currentRemoteDir.canonicalPath(); + if(destFile.right(1).find("/",0,TRUE) == -1) + destFile+="/"; + destFile +=(*it); QFile f(destFile); if( f.exists()) f.remove(); if(!copyFile(destFile, curFile) ) qWarning("nothin doing"); } } populateRemoteView(); TabWidget->setCurrentPage(1); } else { if (TabWidget->currentPageIndex() == 0) { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { - curFile = currentDir.canonicalPath()+"/"+(*it); - QString destFile = *it; + curFile = currentDir.canonicalPath(); + if(curFile.right(1).find("/",0,TRUE) == -1) + curFile +="/"; + curFile+=(*it); + QString destFile; fileDlg->setInputText((const QString &) destFile); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); - destFile = currentDir.canonicalPath()+"/"+destFile; + destFile = currentDir.canonicalPath(); + if(destFile.right(1).find("/",0,TRUE) == -1) + destFile+="/"; + destFile +=(*it); QFile f(destFile); if( f.exists()) f.remove(); if(!copyFile(destFile, curFile) ) qWarning("nothin doing"); } } populateLocalView(); TabWidget->setCurrentPage(0); } } } void AdvancedFm::move() { QStringList curFileList = getPath(); QString curFile; // qDebug(curFile); QString destFile; if (TabWidget->currentPageIndex() == 0) { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { - QString destFile = currentRemoteDir.canonicalPath() + "/" + *it; - curFile = currentDir.canonicalPath()+"/"+(*it); + QString destFile = currentRemoteDir.canonicalPath(); + if(destFile.right(1).find("/",0,TRUE) == -1) + destFile+="/"; + destFile +=(*it); + curFile = currentDir.canonicalPath(); qDebug("Destination file is "+destFile); + if(curFile.right(1).find("/",0,TRUE) == -1) + curFile +="/"; + curFile+=(*it); QFile f(destFile); if( f.exists()) f.remove(); if(!copyFile( destFile, curFile) ) { QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); return; } QFile::remove(curFile); } TabWidget->setCurrentPage(1); } else { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { - QString destFile = currentRemoteDir.canonicalPath() + "/" + *it; + QString destFile = currentRemoteDir.canonicalPath(); + if(destFile.right(1).find("/",0,TRUE) == -1) + destFile+="/"; + destFile +=(*it); qDebug("Destination file is "+destFile); - curFile = currentDir.canonicalPath()+"/"+(*it); + curFile = currentDir.canonicalPath(); + if(curFile.right(1).find("/",0,TRUE) == -1) + curFile +="/"; + curFile+=(*it); QFile f(destFile); if( f.exists()) f.remove(); if(!copyFile(destFile, curFile) ) { QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); return; } QFile::remove(curFile); TabWidget->setCurrentPage(0); } } populateRemoteView(); populateLocalView(); } bool AdvancedFm::copyFile( const QString & dest, const QString & src ) { char bf[ 50000 ]; int bytesRead; bool success = TRUE; struct stat status; QFile s( src ); |