author | llornkcor <llornkcor> | 2002-04-27 22:47:48 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-27 22:47:48 (UTC) |
commit | 8e3c0aa915801b862f97ba7a7598ef5f3bd350aa (patch) (side-by-side diff) | |
tree | 6fed799512ebdcd4c78a56097c49d354de648690 | |
parent | 392596c06dedf8ddaea7c55745460e631073d15a (diff) | |
download | opie-8e3c0aa915801b862f97ba7a7598ef5f3bd350aa.zip opie-8e3c0aa915801b862f97ba7a7598ef5f3bd350aa.tar.gz opie-8e3c0aa915801b862f97ba7a7598ef5f3bd350aa.tar.bz2 |
fixed some bugs, added multi select, added symlink handling and keyboard shortcuts, but listview steals the event to move selection according to alpha. delete works
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 267 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 6 |
2 files changed, 230 insertions, 43 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 5f47b9b..bb932c5 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp @@ -129,75 +129,77 @@ AdvancedFm::AdvancedFm( ) 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); TabWidget = new QTabWidget( this, "TabWidget" ); layout->addMultiCellWidget( TabWidget, 1, 1, 0, 6); tab = new QWidget( TabWidget, "tab" ); tabLayout = new QGridLayout( tab ); tabLayout->setSpacing( 2); tabLayout->setMargin( 2); Local_View = new QListView( tab, "Local_View" ); // Local_View->setResizePolicy( QListView::AutoOneFit ); Local_View->addColumn( tr("File"),130); Local_View->addColumn( tr("Size"),-1); Local_View->setColumnAlignment(1,QListView::AlignRight); Local_View->addColumn( tr("Date"),-1); Local_View->setColumnAlignment(2,QListView::AlignRight); Local_View->setAllColumnsShowFocus(TRUE); -// Local_View->setMultiSelection( TRUE ); -// Local_View->setSelectionMode(QListView::Extended); + Local_View->setMultiSelection( TRUE ); + Local_View->setSelectionMode(QListView::Extended); + QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); tabLayout->addWidget( Local_View, 0, 0 ); connect( Local_View, SIGNAL( clicked( QListViewItem*)), this,SLOT( localListClicked(QListViewItem *)) ); connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( localListPressed(int, QListViewItem *, const QPoint&, int)) ); TabWidget->insertTab( tab, tr("1")); tab_2 = new QWidget( TabWidget, "tab_2" ); tabLayout_2 = new QGridLayout( tab_2 ); tabLayout_2->setSpacing( 2); tabLayout_2->setMargin( 2); Remote_View = new QListView( tab_2, "Remote_View" ); Remote_View->addColumn( tr("File"),130); Remote_View->addColumn( tr("Size"),-1); Remote_View->setColumnAlignment(1,QListView::AlignRight); Remote_View->addColumn( tr("Date"),-1); Remote_View->setColumnAlignment(2,QListView::AlignRight); Remote_View->setAllColumnsShowFocus(TRUE); -// Remote_View->setMultiSelection( TRUE ); -// Remote_View->setSelectionMode(QListView::Extended); + Remote_View->setMultiSelection( TRUE ); + Remote_View->setSelectionMode(QListView::Extended); + QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); connect( Remote_View, SIGNAL( clicked( QListViewItem*)), this,SLOT( remoteListClicked(QListViewItem *)) ); connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) ); tabLayout_2->addWidget( Remote_View, 0, 0 ); TabWidget->insertTab( tab_2, tr( "2")); connect(TabWidget,SIGNAL(currentChanged(QWidget *)), this,SLOT(tabChanged(QWidget*))); // tab_3 = new QWidget( TabWidget, "tab_3" ); // tabLayout_3 = new QGridLayout( tab_3 ); // tabLayout_3->setSpacing( 2); // tabLayout_3->setMargin( 2); // OFileSelector *fileSelector; // fileSelector = new OFileSelector(tab_3,0,0,"/","","*"); // tabLayout_3->addMultiCellWidget( fileSelector, 0, 0, 0, 3 ); // TabWidget->insertTab( tab_3, tr( "Files" ) ); @@ -348,48 +350,49 @@ void AdvancedFm::populateLocalView() while ((mydirent = readdir(dir)) != NULL) { lstat( mydirent->d_name, &buf); qDebug(mydirent->d_name); // mode = buf.st_mode; fileL.sprintf("%s", mydirent->d_name); // fileS.sprintf("%d, %d", ); //this isn't correct devT = buf.st_dev; fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); // fileS.sprintf("%d,%d", devT, devT); fileDate.sprintf("%s", ctime( &buf.st_mtime)); if( fileL.find(".") == -1 ){ item= new QListViewItem( Local_View, fileL, fileS, fileDate); pm = Resource::loadPixmap( "UnknownDocument-14" ); item->setPixmap( 0,pm); } } closedir(dir); } Local_View->setSorting( 3,FALSE); fillCombo( (const QString &) currentDir.canonicalPath()); } + void AdvancedFm::populateRemoteView() { // QList<QListViewItem> * getSelectedItems( QListView * Local_View ); // QListViewItemIterator it( Remote_View ); // for ( ; it.current(); ++it ) { // if ( it.current()->isSelected() ) { // QString strItem = it.current()->text(0); // QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem; // QFileInfo fi(localFile); // } // } QPixmap pm; Remote_View->clear(); currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); currentRemoteDir.setMatchAllDirs(TRUE); currentRemoteDir.setNameFilter(filterStr); QString fileL, fileS, fileDate; bool isDir=FALSE; const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); QFileInfoListIterator it(*list); QFileInfo *fi; while ( (fi=it.current()) ) { if (fi->isSymLink() ){ QString symLink=fi->readLink(); @@ -543,59 +546,62 @@ void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); if( QFile::exists(strItem ) ) { // qDebug("upload "+strItem); } } //end not symlink chdir(strItem.latin1()); } } } void AdvancedFm::doLocalCd() { localListClicked( Local_View->currentItem()); } void AdvancedFm::doRemoteCd() { localListClicked( Remote_View->currentItem()); } void AdvancedFm::showHidden() { if (b) { currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); + fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); // localMenu->setItemChecked(localMenu->idAt(0),TRUE); // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); - b=TRUE; + b=FALSE; } else { currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); + fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); // localMenu->setItemChecked(localMenu->idAt(0),FALSE); // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); - b=FALSE; + b=TRUE; } populateLocalView(); + } void AdvancedFm::showRemoteHidden() { if (b) { currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); // viewMenu->setItemChecked(localMenu->idAt(0),TRUE); // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); b=TRUE; } else { currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); // localMenu->setItemChecked(localMenu->idAt(0),FALSE); // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); b=FALSE; } populateRemoteView(); } void AdvancedFm::localListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) { switch (mouse) { case 1: break; @@ -609,81 +615,85 @@ void AdvancedFm::localListPressed( int mouse, QListViewItem *item, const QPoint void AdvancedFm::remoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) { switch (mouse) { case 1: break; case 2: showRemoteMenu(item); Remote_View->clearSelection(); break; }; } void AdvancedFm::showLocalMenu(QListViewItem * item) { if(item) { QPopupMenu m; m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); m.insertSeparator(); if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); else m.insertItem( tr( "Open" ), this, SLOT( runThis() )); m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); + m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); + m.insertSeparator(); m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); m.insertItem( tr( "Copy" ), this, SLOT( copy() )); m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); m.insertItem( tr( "Move" ), this, SLOT( move() )); m.insertSeparator(); m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); m.insertSeparator(); m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); m.insertSeparator(); m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); m.setCheckable(TRUE); if (!b) m.setItemChecked(m.idAt(0),TRUE); else m.setItemChecked(m.idAt(0),FALSE); m.exec( QCursor::pos() ); } } void AdvancedFm::showRemoteMenu(QListViewItem * item) { if(item) { QPopupMenu m; m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); m.insertSeparator(); if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); else m.insertItem( tr( "Open" ), this, SLOT( runThis() )); m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); + m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); + m.insertSeparator(); 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( "Move" ), this, SLOT( move() )); m.insertSeparator(); m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); m.insertSeparator(); m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); m.insertSeparator(); m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); m.setCheckable(TRUE); if (!b) m.setItemChecked(m.idAt(0),TRUE); else m.setItemChecked(m.idAt(0),FALSE); m.exec( QCursor::pos() ); } } void AdvancedFm::runThis() { // QFileInfo *fi; if (TabWidget->currentPageIndex() == 0) { @@ -731,156 +741,175 @@ 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() { - QString f = Local_View->currentItem()->text(0); - if(QDir(f).exists() ) { - switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ - tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { + 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()+"/"+myFile; + if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { + switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+" ?" + ,tr("Yes"),tr("No"),0,0,1) ) { case 0: { - f=currentDir.canonicalPath()+"/"+f; - QString cmd="rmdir "+f; + QString cmd="rmdir -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 +" ?",tr("Yes"),tr("No"),0,0,1) ) { case 0: { - f=currentDir.canonicalPath()+"/"+f; QString cmd="rm "+f; - system( cmd.latin1()); + QFile file(f); + file.remove(); +// system( cmd.latin1()); populateLocalView(); } break; case 1: // exit break; }; } + + } } void AdvancedFm::remoteDelete() { - QString f = Remote_View->currentItem()->text(0); - if(QDir(f).exists() ) { - switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ - tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { + 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 = currentRemoteDir.canonicalPath()+"/"+myFile; + if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { + switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+" ?", + tr("Yes"),tr("No"),0,0,1) ) { case 0: { - f = currentRemoteDir.canonicalPath()+"/"+f; - QString cmd="rmdir "+f; + QString cmd="rmdir -rf "+f; system( cmd.latin1()); populateRemoteView(); } 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: { - f = currentRemoteDir.canonicalPath()+"/"+f; QString cmd="rm "+f; - system( cmd.latin1()); + QFile file(f); + file.remove(); +// system( cmd.latin1()); populateRemoteView(); } break; case 1: // exit break; }; } } +} void AdvancedFm::localRename() { QString curFile = Local_View->currentItem()->text(0); 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 = Local_View->currentItem()->text(0); InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); fileDlg->setInputText((const QString &)curFile); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; if( rename(oldname.latin1(), newName.latin1())== -1) QMessageBox::message(tr("Note"),tr("Could not rename")); } populateRemoteView(); } void AdvancedFm::switchToLocalTab() { TabWidget->setCurrentPage(0); + Local_View->setFocus(); } void AdvancedFm::switchToRemoteTab() { TabWidget->setCurrentPage(1); + Remote_View->setFocus(); } void AdvancedFm::readConfig() { Config cfg("AdvancedFm"); } void AdvancedFm::writeConfig() { Config cfg("AdvancedFm"); } void AdvancedFm::currentPathComboChanged() { if (TabWidget->currentPageIndex() == 0) { if(QDir( currentPathCombo->lineEdit()->text()).exists()) { currentDir.setPath( currentPathCombo->lineEdit()->text() ); populateLocalView(); } else { QMessageBox::message(tr("Note"),tr("That directory does not exist")); } } if (TabWidget->currentPageIndex() == 0) { if(QDir( currentPathCombo->lineEdit()->text()).exists()) { @@ -905,73 +934,108 @@ void AdvancedFm::fillCombo(const QString ¤tPath) { currentPathCombo->lineEdit()->setText( currentPath); if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { currentPathCombo->clear(); remoteDirPathStringList.prepend( currentPath ); currentPathCombo->insertStringList( remoteDirPathStringList,-1); } } } void AdvancedFm::currentPathComboActivated(const QString & currentPath) { if (TabWidget->currentPageIndex() == 0) { chdir( currentPath.latin1() ); currentDir.cd( currentPath, TRUE); populateLocalView(); update(); } else { chdir( currentPath.latin1() ); currentRemoteDir.cd( currentPath, TRUE); populateRemoteView(); update(); } } void AdvancedFm::filePerms() { - QString curFile = getPath(); + + QStringList curFileList = getPath(); + QString filePath; + + if (TabWidget->currentPageIndex() == 0) { + filePath = currentDir.canonicalPath()+"/"; + } else { + filePath= currentRemoteDir.canonicalPath()+"/"; + } + + for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { filePermissions *filePerm; - filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(curFile)); + filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); filePerm->showMaximized(); filePerm->exec(); if( filePerm) delete filePerm; } +} void AdvancedFm::doProperties() { - - DocLnk lnk( getPath()); + QStringList curFileList = getPath(); + QString filePath; + if (TabWidget->currentPageIndex() == 0) { + filePath = currentDir.canonicalPath()+"/"; + } else { + filePath= currentRemoteDir.canonicalPath()+"/"; + } + for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { + DocLnk lnk( (filePath+*it)); LnkProperties prop( &lnk ); // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); prop.showMaximized(); prop.exec(); } +} -QString AdvancedFm::getPath() { +QStringList AdvancedFm::getPath() { + QStringList strList; if (TabWidget->currentPageIndex() == 0) { - return currentDir.canonicalPath()+"/"+ Local_View->currentItem()->text(0); + QList<QListViewItem> * getSelectedItems( QListView * Local_View ); + QListViewItemIterator it( Local_View ); + for ( ; it.current(); ++it ) { + if ( it.current()->isSelected() ) { + strList << it.current()->text(0); + } + } + return strList; } else { - return currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); + QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); + QListViewItemIterator it( Remote_View ); + for ( ; it.current(); ++it ) { + if ( it.current()->isSelected() ) { + strList << currentDir.canonicalPath()+"/"+ it.current()->text(0); } } + return strList; + } + return ""; +} void AdvancedFm::homeButtonPushed() { QString current = QDir::homeDirPath(); chdir( current.latin1() ); if (TabWidget->currentPageIndex() == 0) { currentDir.cd( current, TRUE); populateLocalView(); } else { currentRemoteDir.cd( current, TRUE); populateRemoteView(); } update(); } void AdvancedFm::docButtonPushed() { QString current = QPEApplication::documentDir(); chdir( current.latin1() ); if (TabWidget->currentPageIndex() == 0) { currentDir.cd( current, TRUE); populateLocalView(); } else { currentRemoteDir.cd( current, TRUE); populateRemoteView(); } @@ -1011,143 +1075,174 @@ void AdvancedFm::upDir() { if (TabWidget->currentPageIndex() == 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() { - QString curFile = getPath(); + QStringList curFileList = getPath(); + QString curFile; if (TabWidget->currentPageIndex() == 0) { - QString destFile = currentRemoteDir.canonicalPath()+"/"+Local_View->currentItem()->text(0); + for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { + + QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); + curFile = currentDir.canonicalPath()+"/"+(*it); QFile f(destFile); if( f.exists()) f.remove(); if(!copyFile(destFile, curFile) ) qWarning("nothin doing"); + } populateRemoteView(); TabWidget->setCurrentPage(1); + } else { - QString destFile = currentDir.canonicalPath()+"/"+Remote_View->currentItem()->text(0); + 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()) f.remove(); if(!copyFile(destFile, curFile) ) qWarning("nothin doing"); + } populateLocalView(); TabWidget->setCurrentPage(0); } } void AdvancedFm::copyAs() { - QString curFile = getPath(); - if (TabWidget->currentPageIndex() == 0) { - QString destFile = Local_View->currentItem()->text(0); + 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); +// 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; QFile f(destFile); if( f.exists()) f.remove(); if(!copyFile(destFile, curFile) ) qWarning("nothin doing"); } + } + populateRemoteView(); TabWidget->setCurrentPage(1); } else { - QString destFile = Remote_View->currentItem()->text(0); - 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 ) { + + curFile = currentDir.canonicalPath()+"/"+(*it); + QString destFile = *it; fileDlg->setInputText((const QString &) destFile); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); destFile = currentDir.canonicalPath()+"/"+destFile; QFile f(destFile); if( f.exists()) f.remove(); if(!copyFile(destFile, curFile) ) qWarning("nothin doing"); } + } populateLocalView(); TabWidget->setCurrentPage(0); } } +} void AdvancedFm::move() { - QString curFile = getPath(); + + QStringList curFileList = getPath(); + QString curFile; // qDebug(curFile); QString destFile; + if (TabWidget->currentPageIndex() == 0) { - QString destFile = currentRemoteDir.canonicalPath() + "/" + Local_View->currentItem()->text(0); + for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { + QString destFile = currentRemoteDir.canonicalPath() + "/" + *it; + curFile = currentDir.canonicalPath()+"/"+(*it); qDebug("Destination file is "+destFile); 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 { - QString destFile = currentDir.canonicalPath() + "/" + Remote_View->currentItem()->text(0); + for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { + QString destFile = currentRemoteDir.canonicalPath() + "/" + *it; qDebug("Destination file is "+destFile); + curFile = currentDir.canonicalPath()+"/"+(*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 ); QFile d( dest ); if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ success = FALSE; break; } } if( success && (bytesRead > 0) ){ d.writeBlock( bf, bytesRead ); } @@ -1272,24 +1367,114 @@ void AdvancedFm::mkDir() { } void AdvancedFm::rn() { if (TabWidget->currentPageIndex() == 0) localRename(); else remoteRename(); } void AdvancedFm::del() { if (TabWidget->currentPageIndex() == 0) localDelete(); else remoteDelete(); } void AdvancedFm::doAbout() { QMessageBox::message("AdvancedFm","Advanced FileManager\n" "is copyright 2002 by\n" "L.J.Potter<llornkcor@handhelds.org>\n" "and is licensed by the GPL"); } + +void AdvancedFm::keyReleaseEvent( QKeyEvent *e) +{ + switch ( e->key() ) { + case Key_Delete: + del(); + break; + case Key_H: + showHidden(); + break; + case Key_E: + runThis(); + break; + case Key_C: + copy(); + break; + case Key_A: + copyAs(); + break; + case Key_M: + move(); + break; + case Key_R: + rn(); + break; + case Key_I: + fileStatus(); + break; + case Key_U: + upDir(); + break; + case Key_P: + filePerms(); + break; + case Key_N: + mkDir(); + break; + case Key_1: + switchToLocalTab(); + break; + case Key_2: + switchToRemoteTab(); + break; + case Key_3: + CFButtonPushed(); + break; + case Key_4: + SDButtonPushed(); + break; + case Key_5: + homeButtonPushed(); + break; + case Key_6: + docButtonPushed(); + break; + case Key_7: + break; + case Key_8: + break; + case Key_9: + break; + case Key_0: + break; + + + + } + +} + +void AdvancedFm::mkSym() { + QString cmd; + if (TabWidget->currentPageIndex() == 0) { + QString curFile = Local_View->currentItem()->text(0); + if(curFile.right(1) == "/") curFile = curFile.left(curFile.length() - 1); + QString destName = currentRemoteDir.canonicalPath()+"/"+curFile; + curFile = currentDir.canonicalPath()+"/"+curFile; + cmd = "ln -s "+curFile+" "+destName; + system(cmd.latin1() ); + populateRemoteView(); + } else { + QString curFile = Remote_View->currentItem()->text(0); + if(curFile.right(1) == "/") curFile = curFile.left(curFile.length() - 1); + QString destName = currentDir.canonicalPath()+"/"+curFile; + curFile = currentRemoteDir.canonicalPath()+"/"+curFile; + cmd = "ln -s "+curFile+" "+destName; + system(cmd.latin1() ); + populateLocalView(); + } +} diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h index a5f26a7..c00713f 100644 --- a/noncore/apps/advancedfm/advancedfm.h +++ b/noncore/apps/advancedfm/advancedfm.h @@ -1,44 +1,45 @@ /*************************************************************************** opieftp.h ------------------- ** Created: Sat Mar 9 23:33:09 2002 copyright : (C) 2002 by ljp email : ljp@llornkcor.com * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #ifndef ADVANCEDFM_H #define ADVANCEDFM_H #include <qvariant.h> #include <qdialog.h> #include <qmainwindow.h> #include <qdir.h> #include <qstring.h> #include <qpoint.h> +#include <qstringlist.h> class QVBoxLayout; class QHBoxLayout; class QGridLayout; class QComboBox; class QListView; class QListviewItem; class QLabel; class QProgressBar; class QSpinBox; class QTabWidget; class QWidget; class QPEToolBar; class QPEMenuBar; class QPopupMenu; class QFile; class QListViewItem; class QLineEdit; class QPushButton; class AdvancedFm : public QMainWindow { Q_OBJECT public: @@ -72,50 +73,51 @@ protected slots: void showHidden(); 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 &); */ void tabChanged(QWidget*); void cleanUp(); void remoteRename(); void localRename(); void runThis(); void runText(); void filePerms(); void doProperties(); void runCommand(); void runCommandStd(); - QString getPath(); + QStringList getPath(); + void mkSym(); void switchToLocalTab(); void switchToRemoteTab(); protected: QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; QStringList remoteDirPathStringList, localDirPathStringList; - + void keyReleaseEvent( QKeyEvent *); protected slots: void homeButtonPushed(); void docButtonPushed(); void SDButtonPushed(); void CFButtonPushed(); void upDir(); void currentPathComboChanged(); void copy(); void copyAs(); void currentPathComboActivated(const QString &); void fillCombo(const QString &); bool copyFile( const QString & , const QString & ); void move(); void fileStatus(); void doAbout(); }; #endif // ADVANCEDFM_H |