-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 30 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 62 |
2 files changed, 48 insertions, 44 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 9aa0c77..8cc5d7b 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp @@ -66,31 +66,27 @@ void AdvancedFm::cleanUp() { QFile file( sfile); if(file.exists()) file.remove(); } void AdvancedFm::tabChanged(QWidget *wd) { -// qDebug("tabChanged"); if(wd == tab) { whichTab = 1; viewMenu->setItemChecked(viewMenu->idAt(0), true); viewMenu->setItemChecked(viewMenu->idAt(1), false); // qDebug("tabchanged: LOCAL VIEW SHOWN"); } + else if(wd == tab_2) { whichTab = 2; viewMenu->setItemChecked(viewMenu->idAt(0), false); viewMenu->setItemChecked(viewMenu->idAt(1), true); // qDebug("tabchanged: REMOTE VIEW SHOWN"); } qApp->processEvents(); QString path = CurrentDir()->canonicalPath(); -// qDebug(path); - if ( TabWidget->currentWidget() == tab) { - } else { - } chdir( path.latin1()); currentPathCombo->lineEdit()->setText(path); } @@ -263,21 +259,21 @@ void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , in void AdvancedFm::refreshCurrentTab() { populateView(); // if ( TabWidget->currentWidget() == tab) { } void AdvancedFm::switchToLocalTab() { - TabWidget->setCurrentWidget(0); -// Local_View->setFocus(); - whichTab = 1; + TabWidget->setCurrentWidget(tab); + Local_View->setFocus(); +// whichTab = 1; } void AdvancedFm::switchToRemoteTab() { - TabWidget->setCurrentWidget(1); -// Remote_View->setFocus(); - whichTab = 2; + TabWidget->setCurrentWidget(tab_2); + Remote_View->setFocus(); +// whichTab = 2; } void AdvancedFm::currentPathComboChanged() { QString pDir = currentPathCombo->lineEdit()->text(); if(QDir(pDir).exists()) { CurrentDir()->setPath(pDir ); @@ -755,15 +751,21 @@ void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { void AdvancedFm::setDocument(const QString &file) { changeTo( file); } void AdvancedFm::slotSwitchMenu(int item) { - Q_UNUSED(item); -// qDebug( "Switch %d",item); - // viewMenu->setItemChecked(item, true); + if(item == -23) { + switchToLocalTab(); + tabChanged( tab); + } + + if(item == -24) { + switchToRemoteTab(); + tabChanged( tab_2); + } } void AdvancedFm::navigateToSelected() { if( !CurrentView()->currentItem()) return; doDirChange(); } diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 171e7c4..4802771 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp @@ -41,13 +41,13 @@ void AdvancedFm::doDirChange() { QString pathItem = CurrentView()->currentItem()->text(0); if( pathItem == "../") { ListClicked( CurrentView()->currentItem()); } else { if( pathItem.find(" -> ",0,TRUE) != -1) pathItem = dealWithSymName((const QString&)pathItem)+"/"; -// owarn << pathItem << oendl; +// owarn << pathItem << oendl; changeTo( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); } } void AdvancedFm::showMenuHidden() { if (b) { @@ -92,25 +92,25 @@ void AdvancedFm::runThis() { curFile = dealWithSymName((const QString&)curFile); if(curFile != "../") { fs = getFileSystemType((const QString &) path); QFileInfo fileInfo( path + "/" + curFile); -// odebug << fileInfo.owner() << oendl; +// odebug << fileInfo.owner() << oendl; if( (fileInfo.permission( QFileInfo::ExeUser) | fileInfo.permission( QFileInfo::ExeGroup) | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { QCopEnvelope e("QPE/System", "execute(QString)" ); e << curFile; } else { curFile = path + "/" + curFile; DocLnk nf(curFile); QString execStr = nf.exec(); -// odebug << execStr << oendl; +// odebug << execStr << oendl; if( execStr.isEmpty() ) { } else { nf.execute(); } } } @@ -202,18 +202,18 @@ void AdvancedFm::doDelete() { } QString cmd="rm "+f; QFile file(f); QFileInfo fi(myFile); if( fi.fileName().find("../",0,TRUE)==-1) { -// odebug << "remove link files "+myFile << oendl; +// odebug << "remove link files "+myFile << oendl; // DocLnk lnk(f); DocLnk *lnk; lnk = new DocLnk(f); -// odebug << "Deleting doclnk " + lnk->linkFile() << oendl; +// odebug << "Deleting doclnk " + lnk->linkFile() << oendl; if(lnk->isValid()) lnk->removeLinkFile(); // delete lnk; file.remove(); } } @@ -243,16 +243,16 @@ void AdvancedFm::doProperties() { QStringList curFileList = getPath(); QString filePath; filePath = CurrentDir()->canonicalPath()+"/"; -// odebug << "" << curFileList.count() << "" << oendl; +// odebug << "" << curFileList.count() << "" << oendl; for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { -// odebug << (filePath+*it) << oendl; +// odebug << (filePath+*it) << oendl; DocLnk lnk( (filePath+*it)); LnkProperties prop( &lnk ); QPEApplication::execDialog( &prop ); } #endif @@ -299,14 +299,14 @@ void AdvancedFm::copy() { if(item.find("->",0,TRUE)) //symlink item = item.left(item.find("->",0,TRUE)); curFile = thisDir->canonicalPath()+"/"+ item; destFile = thatDir->canonicalPath()+"/"+ item; -// odebug << "Destination file is "+destFile << oendl; -// odebug << "CurrentFile file is " + curFile << oendl; +// odebug << "Destination file is "+destFile << oendl; +// odebug << "CurrentFile file is " + curFile << oendl; QFile f(destFile); if( f.exists()) { if(doMsg) { switch ( QMessageBox::warning(this,tr("File Exists!"), tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), @@ -423,13 +423,13 @@ void AdvancedFm::copySameDir() { } if(!copyFile( curFile,destFile) ) { QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); return; } -// odebug << "copy "+curFile+" as "+destFile << oendl; +// odebug << "copy "+curFile+" as "+destFile << oendl; } delete fileDlg; } rePopulate(); } @@ -449,19 +449,19 @@ void AdvancedFm::move() { item=(*it); QString destFile = thatDir->canonicalPath(); if(destFile.right(1).find("/",0,TRUE) == -1) destFile+="/"; destFile += item; -// odebug << "Destination file is "+destFile << oendl; +// odebug << "Destination file is "+destFile << oendl; curFile = thisDir->canonicalPath(); if(curFile.right(1).find("/",0,TRUE) == -1) curFile +="/"; curFile+= item; -// odebug << "CurrentFile file is " + curFile << oendl; +// odebug << "CurrentFile file is " + curFile << oendl; if(QFileInfo(curFile).isDir()) { moveDirectory( curFile, destFile ); rePopulate(); return; } @@ -501,13 +501,13 @@ bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { return true; } bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { QString cmd = "/bin/cp -fpR " + src + " " + dest; - owarn << cmd << oendl; + owarn << cmd << oendl; int err = system( (const char *) cmd ); if ( err != 0 ) { QMessageBox::message("AdvancedFm", tr( "<p>Could not copy %1 to %2</p>").arg( src ).arg( dest ) ); return false; } @@ -534,20 +534,20 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { int err=0; int read_fd=0; int write_fd=0; struct stat stat_buf; off_t offset = 0; if(!srcFile.open( IO_ReadOnly|IO_Raw)) { -// owarn << "open failed" << oendl; +// owarn << "open failed" << oendl; return success = false; } read_fd = srcFile.handle(); if(read_fd != -1) { fstat (read_fd, &stat_buf); if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { -// owarn << "destfile open failed" << oendl; +// owarn << "destfile open failed" << oendl; return success = false; } write_fd = destFile.handle(); if(write_fd != -1) { err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); if( err == -1) { @@ -556,13 +556,13 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; case EINVAL: msg = "Descriptor is not valid or locked. "; case ENOMEM: msg = "Insufficient memory to read from in_fd."; case EIO: msg = "Unspecified error while reading from in_fd."; }; success = false; -// owarn << msg << oendl; +// owarn << msg << oendl; } } else { success = false; } } else { success = false; @@ -588,13 +588,13 @@ void AdvancedFm::runCommand() { fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); fileDlg->setInputText(curFile); fileDlg->exec(); //QString command; if( fileDlg->result() == 1 ) { -// odebug << fileDlg->LineEdit1->text() << oendl; +// odebug << fileDlg->LineEdit1->text() << oendl; QStringList command; command << "/bin/sh"; command << "-c"; command << fileDlg->LineEdit1->text(); Output *outDlg; @@ -671,13 +671,13 @@ void AdvancedFm::mkSym() { if( curFile.right(1) == "/") { curFile = curFile.left( curFile.length() -1); } cmd = "ln -s "+curFile+" "+destName; -// odebug << cmd << oendl; +// odebug << cmd << oendl; startProcess( (const QString)cmd ); } rePopulate(); setOtherTabCurrent(); } } @@ -721,21 +721,21 @@ void AdvancedFm::startProcess(const QString & cmd) { command << "/bin/sh"; command << "-c"; command << cmd.latin1(); *process << command; if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) - odebug << "could not start process" << oendl; + odebug << "could not start process" << oendl; } void AdvancedFm::processEnded(OProcess *) { rePopulate(); } void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { -// owarn << "received stderrt " << buflen << " bytes" << oendl; +// owarn << "received stderrt " << buflen << " bytes" << oendl; QString lineStr = buffer; QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); } bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { @@ -754,31 +754,33 @@ bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { } else if ( e->type() == QEvent::FocusOut ) { cancelRename(); return true; } } -/* if ( o->inherits( "QListView" ) ) { + if ( o->inherits( "QListView" ) ) { if ( e->type() == QEvent::FocusIn ) { -// if( o == Local_View) { //keep track of which view -// qDebug("local view"); -// whichTab = 1; -// } else { -// whichTab = 2; -// qDebug("remote view"); -// } + if( o == Local_View) { //keep track of which view + whichTab = 1; + viewMenu->setItemChecked(viewMenu->idAt(0), true); + viewMenu->setItemChecked(viewMenu->idAt(1), false); + } else { + whichTab = 2; + viewMenu->setItemChecked(viewMenu->idAt(0), false); + viewMenu->setItemChecked(viewMenu->idAt(1), true); + } } OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection } -*/ + return QWidget::eventFilter( o, e ); } void AdvancedFm::cancelRename() { -// odebug << "cancel rename" << oendl; +// odebug << "cancel rename" << oendl; QListView * view; view = CurrentView(); bool resetFocus = view->viewport()->focusProxy() == renameBox; delete renameBox; renameBox = 0; |