author | llornkcor <llornkcor> | 2002-07-11 16:36:34 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-07-11 16:36:34 (UTC) |
commit | 1651f048bb129b8e748a01c514d84c8626e0f1e2 (patch) (side-by-side diff) | |
tree | 9b2783cfbb8b754a5aae098b2f4ae165b65f340c /noncore | |
parent | f568737c20bea96fb79d85681a72e142ec05d66f (diff) | |
download | opie-1651f048bb129b8e748a01c514d84c8626e0f1e2.zip opie-1651f048bb129b8e748a01c514d84c8626e0f1e2.tar.gz opie-1651f048bb129b8e748a01c514d84c8626e0f1e2.tar.bz2 |
added messageboc when copy, or move fileif file exists to ask ok to delete, added copy same dir to menu
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 314 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 1 |
2 files changed, 232 insertions, 83 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 @@ -96,3 +96,3 @@ AdvancedFm::AdvancedFm( ) qpeDirButton= new QToolButton(this,"QPEButton"); - qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); + qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); // qpeDirButton= new QPushButton(Resource::loadIconSet("launcher/opielogo16x16"),"",this,"QPEButton"); @@ -104,3 +104,3 @@ AdvancedFm::AdvancedFm( ) cfButton = new QToolButton( this,"CFButton"); - cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); + cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); // cfButton = new QPushButton(Resource::loadIconSet("cardmon/pcmcia"),"",this,"CFButton"); @@ -112,3 +112,3 @@ AdvancedFm::AdvancedFm( ) sdButton = new QToolButton( this,"SDButton"); - sdButton->setPixmap(Resource::loadPixmap("sdmon/sdcard")); + sdButton->setPixmap(Resource::loadPixmap("sdmon/sdcard")); // sdButton = new QPushButton(Resource::loadIconSet("sdmon/sdcard"),"",this,"SDButton"); @@ -120,3 +120,3 @@ AdvancedFm::AdvancedFm( ) cdUpButton = new QToolButton( this,"cdUpButton"); - cdUpButton->setPixmap(Resource::loadPixmap("up")); + cdUpButton->setPixmap(Resource::loadPixmap("up")); // cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); @@ -128,3 +128,3 @@ AdvancedFm::AdvancedFm( ) docButton = new QToolButton( this,"docsButton"); - docButton->setPixmap(Resource::loadPixmap("DocsIcon")); + docButton->setPixmap(Resource::loadPixmap("DocsIcon")); // docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); @@ -136,3 +136,3 @@ AdvancedFm::AdvancedFm( ) homeButton = new QToolButton( this,"homeButton"); - homeButton->setPixmap(Resource::loadPixmap("home")); + homeButton->setPixmap(Resource::loadPixmap("home")); // homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); @@ -1187,4 +1187,14 @@ void AdvancedFm::copy() 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) ) { @@ -1204,4 +1214,14 @@ void AdvancedFm::copy() 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) ) { @@ -1215,3 +1235,3 @@ void AdvancedFm::copy() } -} + } } @@ -1222,58 +1242,165 @@ void AdvancedFm::copyAs() if( curFileList.count() > 0) { - QString curFile; - InputDialog *fileDlg; - fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); + 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; - curFile = currentDir.canonicalPath()+"/"+(*it); + if (TabWidget->currentPageIndex() == 0) { + 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); + 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()) - f.remove(); - if(!copyFile(destFile, curFile) ) { - QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); - qWarning("nothin doing"); + 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"); + } } } + 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()) { + 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; - 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); + 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()+"/"+(*it); + QString filename = fileDlg->LineEdit1->text(); + destFile = currentDir.canonicalPath()+"/"+filename; QFile f(destFile); - if( f.exists()) - f.remove(); + 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"); + 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); } - populateLocalView(); - TabWidget->setCurrentPage(0); } - } -} -} + } +} + void AdvancedFm::move() { @@ -1282,9 +1409,9 @@ void AdvancedFm::move() { if( curFileList.count() > 0) { - QString curFile; + QString curFile; // qDebug(curFile); - QString destFile; + QString destFile; - if (TabWidget->currentPageIndex() == 0) { - for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { - QString destFile = currentRemoteDir.canonicalPath(); + 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) @@ -1292,21 +1419,31 @@ void AdvancedFm::move() { destFile +=(*it); - curFile = currentDir.canonicalPath(); - qDebug("Destination file is "+destFile); - if(curFile.right(1).find("/",0,TRUE) == -1) - curFile +="/"; - curFile+=(*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 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(tr("Note"),tr("Could not move\n"+curFile)); + return; + } + QFile::remove(curFile); + } } - QFile::remove(curFile); - } - TabWidget->setCurrentPage(1); - } else { - for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { - QString destFile = currentRemoteDir.canonicalPath(); + 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) @@ -1314,23 +1451,33 @@ void AdvancedFm::move() { destFile +=(*it); - qDebug("Destination file is "+destFile); - curFile = currentDir.canonicalPath(); - if(curFile.right(1).find("/",0,TRUE) == -1) - curFile +="/"; - curFile+=(*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()) - f.remove(); - if(!copyFile(destFile, curFile) ) { - QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); - return; + 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(tr("Note"),tr("Could not move\n"+curFile)); + return; + } + } + QFile::remove(curFile); + TabWidget->setCurrentPage(0); + } } - QFile::remove(curFile); - TabWidget->setCurrentPage(0); + populateRemoteView(); + populateLocalView(); } - } - populateRemoteView(); - populateLocalView(); } - } @@ -1757,2 +1904,3 @@ void AdvancedFm::showFileMenu() { m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); + m->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); m->insertItem( tr( "Move" ), this, SLOT( move() )); 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 @@ -126,2 +126,3 @@ protected slots: void copyAs(); + void copySameDir(); void currentPathComboActivated(const QString &); |