-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 @@ -91,53 +91,53 @@ AdvancedFm::AdvancedFm( ) layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 ); menuBar->insertItem( tr( "File" ), fileMenu); menuBar->insertItem( tr( "View" ), viewMenu); 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"); qpeDirButton ->setFixedSize( QSize( 20, 20 ) ); connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) ); //qpeDirButton->setFlat(TRUE); layout->addMultiCellWidget( qpeDirButton , 0, 0, 2, 2); 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"); cfButton ->setFixedSize( QSize( 20, 20 ) ); connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) ); //cfButton->setFlat(TRUE); layout->addMultiCellWidget( cfButton , 0, 0, 3, 3); 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"); sdButton->setFixedSize( QSize( 20, 20 ) ); connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) ); // sdButton->setFlat(TRUE); layout->addMultiCellWidget( sdButton , 0, 0, 4, 4); cdUpButton = new QToolButton( this,"cdUpButton"); - cdUpButton->setPixmap(Resource::loadPixmap("up")); + cdUpButton->setPixmap(Resource::loadPixmap("up")); // cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); cdUpButton ->setFixedSize( QSize( 20, 20 ) ); connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); //cdUpButton ->setFlat(TRUE); layout->addMultiCellWidget( cdUpButton , 0, 0, 5, 5); docButton = new QToolButton( this,"docsButton"); - docButton->setPixmap(Resource::loadPixmap("DocsIcon")); + docButton->setPixmap(Resource::loadPixmap("DocsIcon")); // docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); docButton->setFixedSize( QSize( 20, 20 ) ); connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); // docButton->setFlat(TRUE); layout->addMultiCellWidget( docButton, 0, 0, 6, 6); homeButton = new QToolButton( this,"homeButton"); - homeButton->setPixmap(Resource::loadPixmap("home")); + homeButton->setPixmap(Resource::loadPixmap("home")); // homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); homeButton->setFixedSize( QSize( 20, 20 ) ); connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); // homeButton->setFlat(TRUE); layout->addMultiCellWidget( homeButton, 0, 0, 7, 7); // fileMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); @@ -1182,14 +1182,24 @@ void AdvancedFm::copy() 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(); @@ -1199,143 +1209,280 @@ void AdvancedFm::copy() 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); } -} + } } void AdvancedFm::copyAs() { QStringList curFileList = getPath(); 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() { QStringList curFileList = getPath(); 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) destFile+="/"; 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) destFile+="/"; 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(); } - } bool AdvancedFm::copyFile( const QString & dest, const QString & src ) { char bf[ 50000 ]; int bytesRead; bool success = TRUE; @@ -1752,12 +1899,13 @@ void AdvancedFm::showFileMenu() { 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 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 @@ -121,12 +121,13 @@ protected slots: 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(); |