-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 1 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmData.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 220 |
3 files changed, 139 insertions, 83 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h index 12ebbf2..7bccce9 100644 --- a/noncore/apps/advancedfm/advancedfm.h +++ b/noncore/apps/advancedfm/advancedfm.h @@ -51,48 +51,49 @@ class Ir; class AdvancedFm : public QMainWindow { Q_OBJECT public: AdvancedFm(); ~AdvancedFm(); OTabWidget *TabWidget; // QTabWidget *TabWidget; QWidget *tab, *tab_2, *tab_3; QListView *Local_View, *Remote_View; QLineEdit *currentPathEdit; QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu; QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; QDir currentDir, currentRemoteDir; QComboBox *currentPathCombo; QString filterStr; QListViewItem * item; bool b; QStringList fileSystemTypeList, fsList; int currentServerConfig; protected slots: + void selectAll(); void addToDocs(); void doLocalCd(); void doRemoteCd(); // void copy(); void mkDir(); void del(); void rn(); void populateLocalView(); void populateRemoteView(); void showHidden(); void showMenuHidden(); void showRemoteHidden(); void writeConfig(); void readConfig(); void localListClicked(QListViewItem *); void remoteListClicked(QListViewItem *); void localListPressed( int, QListViewItem *, const QPoint&, int); void remoteListPressed( int, QListViewItem *, const QPoint&, int); void localMakDir(); void localDelete(); void remoteMakDir(); void remoteDelete(); /* bool remoteDirList(const QString &); */ /* bool remoteChDir(const QString &); */ diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp index 7188640..f0a0a35 100644 --- a/noncore/apps/advancedfm/advancedfmData.cpp +++ b/noncore/apps/advancedfm/advancedfmData.cpp @@ -66,48 +66,49 @@ void AdvancedFm::init() { cdUpButton = new QToolButton( this,"cdUpButton"); cdUpButton->setPixmap(Resource::loadPixmap("up")); cdUpButton ->setFixedSize( QSize( 20, 20 ) ); layout->addMultiCellWidget( cdUpButton , 0, 0, 5, 5); docButton = new QToolButton( this,"docsButton"); docButton->setPixmap(Resource::loadPixmap("DocsIcon")); docButton->setFixedSize( QSize( 20, 20 ) ); layout->addMultiCellWidget( docButton, 0, 0, 6, 6); homeButton = new QToolButton( this,"homeButton"); homeButton->setPixmap(Resource::loadPixmap("home")); homeButton->setFixedSize( QSize( 20, 20 ) ); layout->addMultiCellWidget( homeButton, 0, 0, 7, 7); fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); fileMenu->insertSeparator(); fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); fileMenu->insertSeparator(); + fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() )); fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); fileMenu->setCheckable(TRUE); viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); viewMenu->insertSeparator(); viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); viewMenu->setCheckable(TRUE); currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); currentPathCombo->setEditable(TRUE); layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7); currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); layout->addMultiCellWidget( currentPathCombo, 1, 1, 0, 7); TabWidget = new OTabWidget( this, "TabWidget",/* OTabWidget::Global | */OTabWidget::IconTab); // TabWidget = new QTabWidget( this, "TabWidget" ); layout->addMultiCellWidget( TabWidget, 2, 2, 0, 7); diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 27a119f..bef701a 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp @@ -178,142 +178,174 @@ void AdvancedFm::runText() { void AdvancedFm::localMakDir() { InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); } populateLocalView(); } void AdvancedFm::remoteMakDir() { InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); } populateRemoteView(); } void AdvancedFm::localDelete() { QStringList curFileList = getPath(); - if(curFileList.count() > 0) { - QString myFile; + 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; + case 1: + return; + break; + }; + } + + 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+ + 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; system( cmd.latin1()); populateLocalView(); } break; case 1: // exit break; }; } else { - switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f + if(doMsg) { + switch ( QMessageBox::warning(this,tr("Delete"),tr("Really 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; + case 1: + return; + break; }; + } + QString cmd="rm "+f; + QFile file(f); + if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) + file.remove(); + // system( cmd.latin1()); } } } + populateLocalView(); } void AdvancedFm::remoteDelete() { - QStringList curFileList = getPath(); - if( curFileList.count() > 0) { - 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 = currentRemoteDir.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()); - populateRemoteView(); + QStringList curFileList = getPath(); + 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; + case 1: + return; + break; + }; } - 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()); - populateRemoteView(); + 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 = currentRemoteDir.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 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; + system( cmd.latin1()); + populateRemoteView(); + } + break; + case 1: + // exit + break; + }; + + } else { + if(doMsg) { + switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f + +" ?",tr("Yes"),tr("No"),0,0,1) ) { + case 1: + return; + break; + }; + } + QString cmd="rm "+f; + QFile file(f); + if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) + file.remove(); + // system( cmd.latin1()); + } } - break; - case 1: - // exit - break; - }; - } } - } + populateRemoteView(); } void AdvancedFm::localRename() { QString curFile = Local_View->currentItem()->text(0); qDebug("currentItem "+curFile); if( curFile !="../") { InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); fileDlg->setInputText((const QString &)curFile); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString oldname = currentDir.canonicalPath() + "/" + curFile; QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text(); //+".playlist"; if( rename(oldname.latin1(), newName.latin1())== -1) QMessageBox::message(tr("Note"),tr("Could not rename")); } populateLocalView(); } } void AdvancedFm::remoteRename() { QString curFile = Remote_View->currentItem()->text(0); @@ -388,187 +420,199 @@ void AdvancedFm::upDir() { if (TabWidget->getCurrentTab() == 0) { QString current = currentDir.canonicalPath(); QDir dir(current); dir.cdUp(); 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() { qApp->processEvents(); QStringList curFileList = getPath(); - if( curFileList.count() > 0) { + 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; + }; + } + QString curFile, item, destFile; if (TabWidget->getCurrentTab() == 0) { - for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { + 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)); destFile = currentRemoteDir.canonicalPath()+"/"+ item; qDebug("Destination file is "+destFile); curFile = currentDir.canonicalPath()+"/"+ item; qDebug("CurrentFile file is " + curFile); 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); + if(doMsg) { + switch ( QMessageBox::warning(this,tr("File Exists!"), + item+tr("\nexists. Ok to overwrite?"), + tr("Yes"),tr("No"),0,0,1) ) { + case 1: + return; + break; + }; + } + f.remove(); + } + if(!copyFile(destFile, curFile) ) { + QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); return; } } populateRemoteView(); TabWidget->setCurrentTab(1); } else { 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)); destFile = currentDir.canonicalPath()+"/"+ item; qDebug("Destination file is "+destFile); curFile = currentRemoteDir.canonicalPath()+"/"+ item;; qDebug("CurrentFile file is " + curFile); QFile f(destFile); if( f.exists()) { - switch ( QMessageBox::warning(this,tr("Delete"), - destFile+tr(" already exists\nDo you really want to delete it?"), + 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; }; + f.remove(); } if(!copyFile(destFile, curFile) ) { QMessageBox::message("AdvancedFm",tr("Could not copy\n") +curFile +tr("to\n")+destFile); return; } } populateLocalView(); TabWidget->setCurrentTab(0); } } } void AdvancedFm::copyAs() { qApp->processEvents(); QStringList curFileList = getPath(); QString curFile; InputDialog *fileDlg; if (TabWidget->getCurrentTab() == 0) { qDebug("tab 1"); for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { QString destFile; curFile = currentDir.canonicalPath()+"/"+(*it); fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); fileDlg->setInputText((const QString &) destFile ); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); destFile = currentRemoteDir.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?"), + 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(destFile, curFile) ) { QMessageBox::message("AdvancedFm",tr("Could not copy\n") +curFile +tr("to\n")+destFile); return; } } delete fileDlg; } populateRemoteView(); TabWidget->setCurrentTab(1); } else { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { curFile = currentRemoteDir.canonicalPath()+"/"+(*it); fileDlg = new InputDialog( this,tr("Copy "+curFile+" 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?"), + 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(destFile, curFile) ) { QMessageBox::message("AdvancedFm",tr("Could not copy\n") +curFile +tr("to\n")+destFile); return; } } delete fileDlg; } populateLocalView(); TabWidget->setCurrentTab(0); } } @@ -941,24 +985,34 @@ void AdvancedFm::doBeam() { connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); file->send( curFile, curFile ); } } else { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { QString curFile = currentRemoteDir.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 ); } } } } } void AdvancedFm::fileBeamFinished( Ir *) { QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); } + +void AdvancedFm::selectAll() { + if (TabWidget->getCurrentTab() == 0) { + Local_View->selectAll(true); + Local_View->setSelected( Local_View->firstChild(),false); + } else { + Remote_View->selectAll(true); + Remote_View->setSelected( Remote_View->firstChild(),false); + } +} |