-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 149 |
1 files changed, 76 insertions, 73 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index bd513c0..b5fcccf 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp @@ -298,53 +298,53 @@ void AdvancedFm::populateLocalView() // qDebug("Symlink detected "+symLink); QFileInfo sym( symLink); fileS.sprintf( "%10li", sym.size() ); fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); fileDate = sym.lastModified().toString(); } else { fileS.sprintf( "%10li", fi->size() ); fileL.sprintf( "%s",fi->fileName().data() ); fileDate= fi->lastModified().toString(); if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { fileL+="/"; isDir=TRUE; // qDebug( fileL); } } if(fileL !="./" && fi->exists()) { item= new QListViewItem( Local_View, fileL, fileS , fileDate); if(isDir || fileL.find("/",0,TRUE) != -1) { if( !QDir( fi->filePath() ).isReadable()) pm = Resource::loadPixmap( "lockedfolder" ); else pm= Resource::loadPixmap( "folder" ); item->setPixmap( 0,pm ); } else { - if(fi->isExecutable()) { - pm = Resource::loadPixmap( "exec"); - item->setPixmap( 0,pm); - } - else if( !fi->isReadable() ) { +// if(fi->isExecutable()) { +// pm = Resource::loadPixmap( "exec"); +// item->setPixmap( 0,pm); +// } + if( !fi->isReadable() ) { pm = Resource::loadPixmap( "locked" ); item->setPixmap( 0,pm); } else { MimeType mt(fi->filePath()); pm=mt.pixmap(); //sets the correct pixmap for mimetype if(pm.isNull()) pm = Resource::loadPixmap( "UnknownDocument-14" ); item->setPixmap( 0,pm); } } if( fileL.find("->",0,TRUE) != -1) { // overlay link image pm= Resource::loadPixmap( "folder" ); QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); QPainter painter( &pm ); painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); pm.setMask( pm.createHeuristicMask( FALSE ) ); item->setPixmap( 0, pm); } } isDir=FALSE; ++it; } @@ -414,53 +414,53 @@ void AdvancedFm::populateRemoteView() fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); fileDate = sym.lastModified().toString(); } else { // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); fileS.sprintf( "%10li", fi->size() ); fileL.sprintf( "%s",fi->fileName().data() ); fileDate= fi->lastModified().toString(); if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { fileL+="/"; isDir=TRUE; // qDebug( fileL); } } if(fileL !="./" && fi->exists()) { item= new QListViewItem( Remote_View, fileL, fileS, fileDate); QPixmap pm; if(isDir || fileL.find("/",0,TRUE) != -1) { if( !QDir( fi->filePath() ).isReadable()) pm = Resource::loadPixmap( "lockedfolder" ); else pm= Resource::loadPixmap( "folder" ); item->setPixmap( 0,pm ); } else { - if(fi->isExecutable()) { - pm = Resource::loadPixmap( "exec"); - item->setPixmap( 0,pm); - } - else if( !fi->isReadable() ) { +// if(fi->isExecutable()) { +// pm = Resource::loadPixmap( "exec"); +// item->setPixmap( 0,pm); +// } + if( !fi->isReadable() ) { pm = Resource::loadPixmap( "locked" ); item->setPixmap( 0,pm); } else { MimeType mt(fi->filePath()); pm=mt.pixmap(); //sets the correct pixmap for mimetype if(pm.isNull()) pm = Resource::loadPixmap( "UnknownDocument-14" ); item->setPixmap( 0,pm); } } if( fileL.find("->",0,TRUE) != -1) { // overlay link image pm= Resource::loadPixmap( "folder" ); QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); QPainter painter( &pm ); painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); pm.setMask( pm.createHeuristicMask( FALSE ) ); item->setPixmap( 0, pm); } } isDir=FALSE; ++it; } if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { @@ -695,78 +695,78 @@ void AdvancedFm::showRemoteMenu(QListViewItem * item) 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) { QString curFile = Local_View->currentItem()->text(0); QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); - if(fileInfo.isExecutable()) { - QCopEnvelope e("QPE/System", "execute(QString)" ); - e << curFile; - } else { +// if(fileInfo.isExecutable()) { +// QCopEnvelope e("QPE/System", "execute(QString)" ); +// e << curFile; +// } else { curFile = currentDir.canonicalPath()+"/"+curFile; DocLnk nf(curFile); QString execStr = nf.exec(); qDebug( execStr); if( execStr.isEmpty() ) { } else { nf.execute(); } - } +// } // MimeType mt( curFile); } else { QString curFile = Remote_View->currentItem()->text(0); QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); - if(fileInfo.isExecutable()) { - QCopEnvelope e("QPE/System", "execute(QString)" ); - e << curFile; - } else { +// if(fileInfo.isExecutable()) { +// QCopEnvelope e("QPE/System", "execute(QString)" ); +// e << curFile; +// } else { curFile = currentRemoteDir.canonicalPath()+"/"+curFile; DocLnk nf(curFile); QString execStr = nf.exec(); qDebug(execStr); if( execStr.isEmpty() ) { } else { nf.execute(); } - } +// } // MimeType mt( curFile); } } void AdvancedFm::runText() { if (TabWidget->currentPageIndex() == 0) { QString curFile = Local_View->currentItem()->text(0); curFile = currentDir.canonicalPath()+"/"+curFile; QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); e << curFile; } else { QString curFile = Remote_View->currentItem()->text(0); curFile = currentRemoteDir.canonicalPath()+"/"+curFile; DocLnk nf(curFile); QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); e << curFile; } } void AdvancedFm::localMakDir() { InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); fileDlg->exec(); @@ -1025,49 +1025,49 @@ void AdvancedFm::doProperties() { DocLnk lnk( (filePath+*it)); LnkProperties prop( &lnk ); // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); prop.showMaximized(); prop.exec(); } } QStringList AdvancedFm::getPath() { QStringList strList; if (TabWidget->currentPageIndex() == 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 { 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); + strList << 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) { @@ -1118,145 +1118,139 @@ void AdvancedFm::upDir() 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() { QStringList curFileList = getPath(); QString curFile; 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(); - if(curFile.right(1).find("/",0,TRUE) == -1) - curFile +="/"; - curFile +=(*it); + QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); +// if(destFile.right(1).find("/",0,TRUE) == -1) +// destFile+="/"; +// destFile +=(*it); + + curFile = currentDir.canonicalPath()+"/"+(*it); +// if(curFile.right(1).find("/",0,TRUE) == -1) +// curFile +="/"; +// curFile +=(*it); + QFile f(destFile); if( f.exists()) f.remove(); - if(!copyFile(destFile, curFile) ) + if(!copyFile(destFile, curFile) ) { + QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); qWarning("nothin doing"); + } } populateRemoteView(); TabWidget->setCurrentPage(1); } else { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { - QString destFile = currentDir.canonicalPath(); - if(destFile.right(1).find("/",0,TRUE) == -1) - destFile+="/"; - destFile +=(*it); - curFile = currentRemoteDir.canonicalPath(); - if(curFile.right(1).find("/",0,TRUE) == -1) - curFile +="/"; - curFile +=(*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"); + 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(); 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(); - if(curFile.right(1).find("/",0,TRUE) == -1) - curFile +="/"; - curFile+=(*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(); - if(destFile.right(1).find("/",0,TRUE) == -1) - destFile+="/"; - destFile +=(*it); + destFile = currentRemoteDir.canonicalPath()+"/"+(*it); QFile f(destFile); if( f.exists()) f.remove(); - if(!copyFile(destFile, curFile) ) + 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(); - if(curFile.right(1).find("/",0,TRUE) == -1) - curFile +="/"; - curFile+=(*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(); - if(destFile.right(1).find("/",0,TRUE) == -1) - destFile+="/"; - destFile +=(*it); + destFile = currentDir.canonicalPath()+"/"+(*it); QFile f(destFile); if( f.exists()) f.remove(); - if(!copyFile(destFile, curFile) ) - qWarning("nothin doing"); + if(!copyFile(destFile, curFile) ) { + QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile); + qWarning("nothin doing"); + } } } populateLocalView(); TabWidget->setCurrentPage(0); } } } void AdvancedFm::move() { QStringList curFileList = getPath(); QString curFile; // qDebug(curFile); QString destFile; 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) @@ -1513,56 +1507,65 @@ void AdvancedFm::keyReleaseEvent( QKeyEvent *e) 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; + QStringList curFileList = getPath(); + 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(); + for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { + + QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); + QString curFile = currentDir.canonicalPath()+"/"+(*it); + cmd = "ln -s "+curFile+" "+destName; + qDebug(cmd); + system(cmd.latin1() ); + } + populateRemoteView(); + TabWidget->setCurrentPage(1); } 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(); + for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { + + QString destName = currentDir.canonicalPath()+"/"+(*it); + QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); + + cmd = "ln -s "+curFile+" "+destName; + qDebug(cmd); + system(cmd.latin1() ); + } + populateLocalView(); + TabWidget->setCurrentPage(0); } } void AdvancedFm::QPEButtonPushed() { QString current = QPEApplication::qpeDir(); chdir( current.latin1() ); if (TabWidget->currentPageIndex() == 0) { currentDir.cd( current, TRUE); populateLocalView(); } else { currentRemoteDir.cd( current, TRUE); populateRemoteView(); } update(); } |