-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 162 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 1 |
2 files changed, 156 insertions, 7 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 9e38d14..f97ae99 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp @@ -1176,43 +1176,63 @@ void AdvancedFm::copy() QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); // if(destFile.right(1).find("/",0,TRUE) == -1) // destFile+="/"; // destFile +=(*it); curFile = currentDir.canonicalPath()+"/"+(*it); // if(curFile.right(1).find("/",0,TRUE) == -1) // curFile +="/"; // curFile +=(*it); QFile f(destFile); - if( f.exists()) + 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(destFile, curFile) ) { QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); 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); QFile f(destFile); - if( f.exists()) + 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(destFile, curFile) ) { QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); qWarning("nothin doing"); } } populateLocalView(); TabWidget->setCurrentPage(0); } } } @@ -1228,112 +1248,239 @@ void AdvancedFm::copyAs() for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { QString destFile; curFile = currentDir.canonicalPath()+"/"+(*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()+"/"+(*it); QFile f(destFile); - if( f.exists()) + 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(destFile, curFile) ) { QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); 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; fileDlg->setInputText((const QString &) destFile); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); destFile = currentDir.canonicalPath()+"/"+(*it); QFile f(destFile); - if( f.exists()) + 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(destFile, curFile) ) { QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); qWarning("nothin doing"); } + } } populateLocalView(); TabWidget->setCurrentPage(0); } } } + +} + +void AdvancedFm::copySameDir() { + QStringList curFileList = getPath(); + if( curFileList.count() > 0) { + QString curFile; + InputDialog *fileDlg; + + if (TabWidget->currentPageIndex() == 0) { + for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { + QString destFile; + curFile = currentDir.canonicalPath()+"/"+(*it); + fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); +// 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 = currentDir.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: + qDebug(""); + f.remove(); + break; + case 1: + return; + break; + }; + } + if(!copyFile(destFile, curFile) ) { + QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); + qWarning("nothin doing"); + } + + qDebug("copy "+curFile+" as "+destFile); + } + delete fileDlg; + } + populateRemoteView(); + TabWidget->setCurrentPage(1); + } else { + if (TabWidget->currentPageIndex() == 0) { + for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { + + curFile = currentRemoteDir.canonicalPath()+"/"+(*it); + fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); + QString destFile; + fileDlg->setInputText((const QString &) destFile); + fileDlg->exec(); + if( fileDlg->result() == 1 ) { + QString filename = fileDlg->LineEdit1->text(); + destFile = currentDir.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(destFile, curFile) ) { + QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); + qWarning("nothin doing"); + } + qDebug("copy "+curFile+" as "+destFile); + } + delete fileDlg; + } + populateLocalView(); + TabWidget->setCurrentPage(0); + } + } + } + } void AdvancedFm::move() { QStringList curFileList = getPath(); if( curFileList.count() > 0) { QString curFile; // qDebug(curFile); QString destFile; if (TabWidget->currentPageIndex() == 0) { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++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()) + 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( 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(); if(destFile.right(1).find("/",0,TRUE) == -1) destFile+="/"; destFile +=(*it); qDebug("Destination file is "+destFile); curFile = currentDir.canonicalPath(); if(curFile.right(1).find("/",0,TRUE) == -1) curFile +="/"; curFile+=(*it); QFile f(destFile); - if( f.exists()) + 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(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 ]; @@ -1746,24 +1893,25 @@ void AdvancedFm::showFileMenu() { m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); m->insertSeparator(); if(isLocalView) m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); else m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); m->insertItem( tr( "Copy" ), this, SLOT( copy() )); m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); + m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); m->insertItem( tr( "Move" ), this, SLOT( move() )); m->insertSeparator(); if(isLocalView) m->insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); else m->insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); m->insertSeparator(); diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h index 7335773..7665fe9 100644 --- a/noncore/apps/advancedfm/advancedfm.h +++ b/noncore/apps/advancedfm/advancedfm.h @@ -115,24 +115,25 @@ protected: protected slots: 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: QTimer menuTimer; }; |