summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm
authormickeyl <mickeyl>2004-04-04 13:54:40 (UTC)
committer mickeyl <mickeyl>2004-04-04 13:54:40 (UTC)
commit16cf79e90b5217f8d4bfce2a0fa817ae4b73db36 (patch) (side-by-side diff)
tree0701eae15aa606a0211a2fccfde0eafdac69357c /noncore/apps/advancedfm
parent8d2d2664e5f544b8292806e617deb7a0e4170dc0 (diff)
downloadopie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.zip
opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.gz
opie-16cf79e90b5217f8d4bfce2a0fa817ae4b73db36.tar.bz2
convert to Opie Debugging Framework
Diffstat (limited to 'noncore/apps/advancedfm') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp44
-rw-r--r--noncore/apps/advancedfm/advancedfm.pro24
-rw-r--r--noncore/apps/advancedfm/advancedfmData.cpp12
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp1681
-rw-r--r--noncore/apps/advancedfm/filePermissions.cpp2
-rw-r--r--noncore/apps/advancedfm/output.cpp23
6 files changed, 888 insertions, 898 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index a60d6ce..a47edd8 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -71,7 +71,7 @@ void AdvancedFm::cleanUp() {
}
void AdvancedFm::tabChanged(QWidget *) {
-// qWarning("tab changed");
+// owarn << "tab changed" << oendl;
QString path = CurrentDir()->canonicalPath();
currentPathCombo->lineEdit()->setText( path );
@@ -93,13 +93,13 @@ void AdvancedFm::tabChanged(QWidget *) {
void AdvancedFm::populateView() {
-// qWarning("PopulateView");
+// owarn << "PopulateView" << oendl;
QPixmap pm;
QListView *thisView = CurrentView();
QDir *thisDir = CurrentDir();
QString path = thisDir->canonicalPath();
-//qWarning("path is "+path);
+//owarn << "path is "+path << oendl;
thisView->clear();
thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
thisDir->setMatchAllDirs(TRUE);
@@ -160,7 +160,7 @@ void AdvancedFm::populateView() {
}
}
if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) {
- // qDebug(" overlay link image");
+ // odebug << " overlay link image" << oendl;
pm= Resource::loadPixmap( "advancedfm/symlink" );
// pm= Resource::loadPixmap( "folder" );
// QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
@@ -184,7 +184,7 @@ void AdvancedFm::populateView() {
if((dir = opendir( path.latin1())) != NULL)
while ((mydirent = readdir(dir)) != NULL) {
lstat( mydirent->d_name, &buf);
-// qDebug(mydirent->d_name);
+// odebug << mydirent->d_name << oendl;
fileL.sprintf("%s", mydirent->d_name);
devT = buf.st_dev;
fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
@@ -209,7 +209,7 @@ void AdvancedFm::rePopulate() {
populateView();
// int tmpTab = whichTab;
-// // qDebug("%d", tmpTab);
+// // odebug << "" << tmpTab << "" << oendl;
// for(int i =1; i < 3; i++) {
// TabWidget->setCurrentWidget(i - 1);
@@ -219,10 +219,10 @@ void AdvancedFm::rePopulate() {
}
void AdvancedFm::ListClicked(QListViewItem *selectedItem) {
-//qWarning("listclicked");
+//owarn << "listclicked" << oendl;
if(selectedItem) {
QString strItem=selectedItem->text(0);
-// qWarning(strItem);
+// owarn << strItem << oendl;
QString strSize=selectedItem->text(1);
strSize=strSize.stripWhiteSpace();
bool isDirectory = false;
@@ -267,13 +267,13 @@ void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , in
void AdvancedFm::switchToLocalTab() {
-//qWarning("switch to local view");
+//owarn << "switch to local view" << oendl;
TabWidget->setCurrentWidget(0);
Local_View->setFocus();
}
void AdvancedFm::switchToRemoteTab() {
-//qWarning("switch to local view");
+//owarn << "switch to local view" << oendl;
TabWidget->setCurrentWidget(1);
Remote_View->setFocus();
}
@@ -329,7 +329,7 @@ QStringList AdvancedFm::getPath() {
for ( ; it.current(); ++it ) {
if ( it.current()->isSelected() ) {
strList << it.current()->text(0);
-// qDebug(it.current()->text(0));
+// odebug << it.current()->text(0) << oendl;
}
}
return strList;
@@ -380,7 +380,7 @@ void AdvancedFm::doAbout() {
}
void AdvancedFm::keyPressEvent( QKeyEvent *e) {
-// qWarning("key %d", e->key());
+// owarn << "key " << e->key() << "" << oendl;
// if( CurrentView()->hasFocus() )
{
switch ( e->key() ) {
@@ -638,7 +638,7 @@ void AdvancedFm::addToDocs() {
QString curFile;
for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
curFile = thisDir->canonicalPath()+"/"+(*it);
-// qDebug(curFile);
+// odebug << curFile << oendl;
QFileInfo fi(curFile);
DocLnk f;
// curFile.replace(QRegExp("\\..*"),"");
@@ -711,7 +711,7 @@ void AdvancedFm::addCustomDir() {
}
void AdvancedFm::removeCustomDir() {
-// qDebug("remove custom dir");
+// odebug << "remove custom dir" << oendl;
Config cfg("AdvancedFm");
cfg.setGroup("Menu");
QString dir;
@@ -746,7 +746,7 @@ void AdvancedFm::removeCustomDir() {
}
void AdvancedFm::gotoCustomDir(const QString &dir) {
-// qDebug("gotoCustomDir(const QString &dir) " +dir );
+// odebug << "gotoCustomDir(const QString &dir) " +dir << oendl;
// QString curDir = dir;
// QDir *thisDir = CurrentDir();
// if( curDir.isEmpty()) {
@@ -787,10 +787,10 @@ QDir *AdvancedFm::OtherDir() {
QListView * AdvancedFm::CurrentView() {
if ( whichTab == 1) {
-// qWarning("CurrentView Tab 1");
+// owarn << "CurrentView Tab 1" << oendl;
return Local_View;
} else {
-// qWarning("CurrentView Tab 2");
+// owarn << "CurrentView Tab 2" << oendl;
return Remote_View;
}
}
@@ -803,7 +803,7 @@ QListView * AdvancedFm::OtherView() {
}
void AdvancedFm::setOtherTabCurrent() {
-// qWarning("setOtherTabCurrent() %d", whichTab);
+// owarn << "setOtherTabCurrent() " << whichTab << "" << oendl;
if ( whichTab == 1) {
TabWidget->setCurrentWidget(1);
} else {
@@ -814,10 +814,10 @@ void AdvancedFm::setOtherTabCurrent() {
}
void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) {
-// qDebug("qcop message "+msg );
+// odebug << "qcop message "+msg << oendl;
QDataStream stream ( data, IO_ReadOnly );
if ( msg == "openDirectory(QString)" ) {
-// qDebug("received");
+// odebug << "received" << oendl;
QString file;
stream >> file;
gotoDirectory( (const QString &) file);
@@ -830,7 +830,7 @@ void AdvancedFm::setDocument(const QString &file) {
}
void AdvancedFm::gotoDirectory(const QString &file) {
-// qWarning("goto dir "+file);
+// owarn << "goto dir "+file << oendl;
QString curDir = file;
QDir *thisDir = CurrentDir();
if(QDir( curDir).exists() ) {
@@ -866,7 +866,7 @@ void AdvancedFm::findFile(const QString &fileName) {
}
void AdvancedFm::slotSwitchMenu(int ) {
-// qDebug("Switch %d", item);
+// odebug << "Switch " << item << "" << oendl;
// viewMenu->setItemChecked(item, true);
}
diff --git a/noncore/apps/advancedfm/advancedfm.pro b/noncore/apps/advancedfm/advancedfm.pro
index 716343d..f1c518e 100644
--- a/noncore/apps/advancedfm/advancedfm.pro
+++ b/noncore/apps/advancedfm/advancedfm.pro
@@ -1,31 +1,11 @@
TEMPLATE = app
-CONFIG += qt warn_on quick-app
-# CONFIG += qt warn_on
+CONFIG += qt warn_on quick-app
HEADERS = advancedfm.h filePermissions.h output.h
SOURCES = advancedfm.cpp advancedfmData.cpp advancedfmMenu.cpp filePermissions.cpp output.cpp main.cpp
TARGET = advancedfm
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe -lopiecore2 -lopieui2
-
-TRANSLATIONS = ../../../i18n/de/advancedfm.ts \
- ../../../i18n/nl/advancedfm.ts \
- ../../../i18n/da/advancedfm.ts \
- ../../../i18n/xx/advancedfm.ts \
- ../../../i18n/en/advancedfm.ts \
- ../../../i18n/es/advancedfm.ts \
- ../../../i18n/fr/advancedfm.ts \
- ../../../i18n/hu/advancedfm.ts \
- ../../../i18n/ja/advancedfm.ts \
- ../../../i18n/ko/advancedfm.ts \
- ../../../i18n/no/advancedfm.ts \
- ../../../i18n/pl/advancedfm.ts \
- ../../../i18n/pt/advancedfm.ts \
- ../../../i18n/pt_BR/advancedfm.ts \
- ../../../i18n/sl/advancedfm.ts \
- ../../../i18n/zh_CN/advancedfm.ts \
- ../../../i18n/zh_TW/advancedfm.ts
-
+LIBS += -lqpe -lopiecore2 -lopieui2
!contains(CONFIG,quick-app) {
DESTDIR = $(OPIEDIR)/bin
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp
index 2997c55..29335f8 100644
--- a/noncore/apps/advancedfm/advancedfmData.cpp
+++ b/noncore/apps/advancedfm/advancedfmData.cpp
@@ -11,11 +11,16 @@
***************************************************************************/
#include "advancedfm.h"
+/* OPIE */
+#include <opie2/odebug.h>
#include <qpe/storage.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <qpe/menubutton.h>
+using namespace Opie::Core;
+using namespace Opie::Ui;
+/* QT */
#include <qlayout.h>
#include <qhbox.h>
#include <qmenubar.h>
@@ -24,10 +29,9 @@
#include <qlineedit.h>
#include <qlistview.h>
+/* STD */
#include <sys/utsname.h>
-
-using namespace Opie::Ui;
void AdvancedFm::init() {
b = false;
setCaption( tr( "AdvancedFm" ) );
@@ -219,11 +223,11 @@ void AdvancedFm::init() {
if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) {
- qDebug("not have sd");
+ odebug << "not have sd" << oendl;
sdButton->hide();
}
if( !StorageInfo::hasCf() ) {
- qDebug("not have cf");
+ odebug << "not have cf" << oendl;
cfButton->hide();
}
currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 81a4318..d34f330 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -1,839 +1,842 @@
-/***************************************************************************
- AdvancedFm.cpp
- -------------------
- ** 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. *
- ***************************************************************************/
-#include "advancedfm.h"
-#include "output.h"
-#include "filePermissions.h"
-
-#include <qpe/lnkproperties.h>
-#include <qpe/qpeapplication.h>
-#include <qpe/applnk.h>
-
-#include <qmessagebox.h>
-
-
-#include <qpopupmenu.h>
-#include <qlistview.h>
-
-#include <errno.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <sys/sendfile.h>
-#include <fcntl.h>
-
-
-using namespace Opie::Core;
-using namespace Opie::Core;
-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)+"/";
-// qWarning(pathItem);
- gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) );
- }
-}
-
-void AdvancedFm::showMenuHidden() {
- if (b) {
- CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
- OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
- fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
- } else {
- CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
- OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
- fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
- }
- b = !b;
- populateView();
-}
-
-void AdvancedFm::showHidden() {
- if (b) {
- CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
- OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
- } else {
- CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
- OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
- }
- populateView();
-}
-
-QString AdvancedFm::dealWithSymName(const QString &fileName) {
- QString strItem = fileName;
- return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
-}
-
-void AdvancedFm::runThis() {
- if( !CurrentView()->currentItem()) return;
- QString fs;
- QDir *thisDir = CurrentDir();
-
- QString curFile = CurrentView()->currentItem()->text(0);
- QString path = thisDir->canonicalPath();
-
- if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
-
- curFile = dealWithSymName((const QString&)curFile);
-
- if(curFile != "../") {
-
- fs = getFileSystemType((const QString &) path);
- QFileInfo fileInfo( path + "/" + curFile);
-// qDebug( fileInfo.owner());
-
- 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();
-// qDebug( execStr);
- if( execStr.isEmpty() ) {
- } else {
- nf.execute();
- }
- }
- }
-}
-
-void AdvancedFm::runText() {
- if( !CurrentView()->currentItem()) return;
- QString curFile = CurrentView()->currentItem()->text(0);
- if(curFile != "../") {
- if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
- curFile = dealWithSymName((const QString&)curFile);
- curFile = CurrentDir()->canonicalPath()+"/"+curFile;
- QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
- e << curFile;
- }
-}
-
-void AdvancedFm::makeDir() {
- InputDialog *fileDlg;
- fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
- fileDlg->exec();
- if( fileDlg->result() == 1 ) {
- QDir *thisDir = CurrentDir();
- QString filename = fileDlg->LineEdit1->text();
- thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
- }
- populateView();
-}
-
-void AdvancedFm::doDelete() {
- 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;
- };
- }
-
- 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() ) {
- //if file is a directory
-
- switch ( QMessageBox::warning( this, tr("Delete Directory?"),
- tr("Really delete %1\nand all it's contents ?" ).arg( f ) ,
- tr("Yes"), tr("No"), 0, 0, 1) ) {
- case 0:
- {
- f=f.left(f.length()-1);
- QString cmd="rm -rf "+f;
- startProcess( (const QString)cmd.latin1() );
- populateView();
- }
- break;
- case 1:
- // exit
- break;
- };
-
- } else {
- if(doMsg) {
- switch ( QMessageBox::warning(this,tr("Delete"),
- tr("Really delete\n%1?").arg( myFile ),
- tr("Yes"), tr("No"), 0, 0, 1) ) {
- case 1:
- return;
- break;
- };
- }
-
- QString cmd="rm "+f;
- QFile file(f);
- QFileInfo fi(myFile);
- if( fi.fileName().find("../",0,TRUE)==-1) {
-// qDebug("remove link files "+myFile);
-
-// DocLnk lnk(f);
- DocLnk *lnk;
- lnk = new DocLnk(f);
-// qDebug("Deleting doclnk " + lnk->linkFile());
- if(lnk->isValid())
- lnk->removeLinkFile();
- // delete lnk;
- file.remove();
- }
- }
- }
- }
- populateView();
-}
-
-void AdvancedFm::filePerms() {
- QStringList curFileList = getPath();
- QString filePath;
-
- filePath = CurrentDir()->canonicalPath()+"/";
-
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
- filePermissions *filePerm;
- filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
- QPEApplication::execDialog( filePerm );
- if( filePerm )
- delete filePerm;
- }
- populateView();
-}
-
-void AdvancedFm::doProperties() {
-#if defined(QT_QWS_OPIE)
-
- QStringList curFileList = getPath();
-
- QString filePath;
- filePath = CurrentDir()->canonicalPath()+"/";
-
-// qDebug("%d",curFileList.count());
-
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
-// qDebug((filePath+*it));
- DocLnk lnk( (filePath+*it));
- LnkProperties prop( &lnk );
- QPEApplication::execDialog( &prop );
- }
-#endif
-
-}
-
-void AdvancedFm::upDir() {
- QDir *thisDir = CurrentDir();
- QString current = thisDir->canonicalPath();
- QDir dir(current);
- dir.cdUp();
- current = dir.canonicalPath();
- chdir( current.latin1() );
- thisDir->cd( current, TRUE);
-
- populateView();
- update();
-}
-
-void AdvancedFm::copy() {
- qApp->processEvents();
- QStringList curFileList = getPath();
-
- QDir *thisDir = CurrentDir();
- QDir *thatDir = OtherDir();
-
- 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("Copy"),msg
- ,tr("Yes"),tr("No"),0,0,1) )
- {
- case 0:
- doMsg=false;
- break;
- case 1:
- return;
- break;
- };
- }
-
- QString curFile, item, destFile;
- 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));
-
- curFile = thisDir->canonicalPath()+"/"+ item;
- destFile = thatDir->canonicalPath()+"/"+ item;
-
-// qDebug("Destination file is "+destFile);
-// qDebug("CurrentFile file is " + curFile);
-
- QFile f(destFile);
- if( f.exists()) {
- if(doMsg) {
- switch ( QMessageBox::warning(this,tr("File Exists!"),
- tr("%1 exists. Ok to overwrite?").arg( item ),
- tr("Yes"),tr("No"),0,0,1) ) {
- case 1:
- return;
- break;
- };
- }
- f.remove();
- }
-
- if( !copyFile( curFile, destFile) ) {
- QMessageBox::message("AdvancedFm",
- tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) );
- return;
- }
- }
- setOtherTabCurrent();
- rePopulate();
- }
-}
-
-void AdvancedFm::copyAs() {
- qApp->processEvents();
-
- QStringList curFileList = getPath();
- QString curFile, item;
- InputDialog *fileDlg;
-
- QDir *thisDir = CurrentDir();
- QDir *thatDir = OtherDir();
-
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
- QString destFile;
- item=(*it);
- curFile = thisDir->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 = thatDir->canonicalPath()+"/"+filename;
-
- QFile f( destFile);
- if( f.exists()) {
- 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( curFile, destFile) ) {
- QMessageBox::message("AdvancedFm",tr("Could not copy\n")
- +curFile +tr("to\n")+destFile);
- return;
- }
- }
- delete fileDlg;
-
- }
- rePopulate();
- setOtherTabCurrent();
-}
-
-void AdvancedFm::copySameDir() {
- qApp->processEvents();
- QStringList curFileList = getPath();
- QString curFile, item, destFile;
- InputDialog *fileDlg;
-
- QDir *thisDir = CurrentDir();
-
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
- item=(*it);
- curFile = thisDir->canonicalPath()+"/"+ item;
-
- fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
- fileDlg->setInputText((const QString &) destFile );
- fileDlg->exec();
-
- if( fileDlg->result() == 1 ) {
-
- QString filename = fileDlg->LineEdit1->text();
- destFile = thisDir->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( curFile,destFile) ) {
- QMessageBox::message("AdvancedFm",tr("Could not copy\n")
- +curFile +tr("to\n")+destFile);
- return;
- }
-
-// qDebug("copy "+curFile+" as "+destFile);
- }
- delete fileDlg;
- }
- rePopulate();
-}
-
-void AdvancedFm::move() {
- qApp->processEvents();
-
- QStringList curFileList = getPath();
- if( curFileList.count() > 0) {
- QString curFile, destFile, item;
-
- QDir *thisDir = CurrentDir();
- QDir *thatDir = OtherDir();
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
- item=(*it);
- QString destFile = thatDir->canonicalPath();
-
- if(destFile.right(1).find("/",0,TRUE) == -1)
- destFile+="/";
- destFile += item;
-// qDebug("Destination file is "+destFile);
-
- curFile = thisDir->canonicalPath();
- if(curFile.right(1).find("/",0,TRUE) == -1)
- curFile +="/";
- curFile+= item;
-// qDebug("CurrentFile file is " + curFile);
-
- if(QFileInfo(curFile).isDir()) {
- moveDirectory( curFile, destFile );
- rePopulate();
- return;
- }
-
- QFile f( curFile);
- if( f.exists()) {
- if( !copyFile( curFile, destFile) ) {
- QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
- return;
- } else
- QFile::remove(curFile);
- }
- }
-
- }
- rePopulate();
- setOtherTabCurrent();
-}
-
-bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) {
- int err = 0;
- if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src;
- err = system((const char*)cmd);
- } else
- err = -1;
-
- if(err!=0) {
- QMessageBox::message(tr("Note"),tr("Could not move\n") + src);
- return false;
- }
- return true;
-}
-
-bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) {
-
- QString cmd = "/bin/cp -fpR " + src + " " + dest;
- qWarning(cmd);
- int err = system( (const char *) cmd );
- if ( err != 0 ) {
- QMessageBox::message("AdvancedFm",
- tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) );
- return false;
- }
-
- return true;
-}
-
-
-bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
-
-
- if(QFileInfo(src).isDir()) {
- if( copyDirectory( src, dest )) {
- setOtherTabCurrent();
- populateView();
- return true;
- }
- else
- return false;
- }
-
-
- bool success = true;
- struct stat status;
- QFile srcFile(src);
- QFile destFile(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)) {
-// qWarning("open failed");
- return success = false;
- }
- read_fd = srcFile.handle();
- if(read_fd != -1) {
- fstat (read_fd, &stat_buf);
- if( !destFile.open( IO_WriteOnly|IO_Raw ) ) {
-// qWarning("destfile open failed");
- 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) {
- QString msg;
- switch(err) {
- 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;
-// qWarning(msg);
- }
- } else {
- success = false;
- }
- } else {
- success = false;
- }
- srcFile.close();
- destFile.close();
- // Set file permissions
- if( stat( (const char *) src, &status ) == 0 ) {
- chmod( (const char *) dest, status.st_mode );
- }
-
- return success;
-}
-
-void AdvancedFm::runCommand() {
- if( !CurrentView()->currentItem()) return;
- QDir *thisDir = CurrentDir();
-
- QString curFile;
- curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0);
-
- InputDialog *fileDlg;
- fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
- fileDlg->setInputText(curFile);
- fileDlg->exec();
- //QString command;
-
- if( fileDlg->result() == 1 ) {
-// qDebug(fileDlg->LineEdit1->text());
- QStringList command;
-
- command << "/bin/sh";
- command << "-c";
- command << fileDlg->LineEdit1->text();
- Output *outDlg;
- outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
- QPEApplication::execDialog( outDlg );
- qApp->processEvents();
-
- }
-}
-
-void AdvancedFm::runCommandStd() {
- if( !CurrentView()->currentItem()) return;
- QString curFile;
- QDir *thisDir = CurrentDir();
- QListView *thisView = CurrentView();
- if( thisView->currentItem())
- curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0);
-
- InputDialog *fileDlg;
- fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
- fileDlg->setInputText(curFile);
- fileDlg->exec();
-
- if( fileDlg->result() == 1 ) {
- qApp->processEvents();
- startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
- }
-}
-
-void AdvancedFm::fileStatus() {
- if( !CurrentView()->currentItem()) return;
- QString curFile;
- curFile = CurrentView()->currentItem()->text(0);
-
- QStringList command;
- command << "/bin/sh";
- command << "-c";
- command << "stat -l "+ curFile;
-
- Output *outDlg;
- outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
- QPEApplication::execDialog( outDlg );
- qApp->processEvents();
-}
-
-
-void AdvancedFm::mkDir() {
- makeDir();
-}
-
-void AdvancedFm::rn() {
- renameIt();
-}
-
-void AdvancedFm::del() {
- doDelete();
-}
-
-void AdvancedFm::mkSym() {
- QString cmd;
- QStringList curFileList = getPath();
- if( curFileList.count() > 0) {
- QDir *thisDir = CurrentDir();
- QDir * thatDir = OtherDir();
-
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
-
- QString destName = thatDir->canonicalPath()+"/"+(*it);
- if(destName.right(1) == "/") {
- destName = destName.left( destName.length() -1);
- }
-
- QString curFile = thisDir->canonicalPath()+"/"+(*it);
-
- if( curFile.right(1) == "/") {
- curFile = curFile.left( curFile.length() -1);
- }
-
- cmd = "ln -s "+curFile+" "+destName;
-// qDebug(cmd);
- startProcess( (const QString)cmd );
- }
- rePopulate();
- setOtherTabCurrent();
- }
-}
-
-void AdvancedFm::doBeam() {
- Ir ir;
- if(!ir.supported()) {
- } else {
- QStringList curFileList = getPath();
- if( curFileList.count() > 0) {
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
- QString curFile = (*it);
- QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile;
- if( curFilePath.right(1) == "/") {
- curFilePath = curFilePath.left( curFilePath.length() -1);
- }
- Ir *file = new Ir(this, "IR");
- connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*)));
- file->send( curFilePath, curFile );
- }
- }
- }
-}
-
-void AdvancedFm::fileBeamFinished( Ir *) {
- QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
-}
-
-void AdvancedFm::selectAll() {
- QListView *thisView = CurrentView();
- thisView->selectAll(true);
- thisView->setSelected( thisView->firstChild(),false);
-}
-
-void AdvancedFm::startProcess(const QString & cmd) {
- QStringList command;
- OProcess *process;
- process = new OProcess();
- connect(process, SIGNAL(processExited(Opie::Core::OProcess*)),
- this, SLOT( processEnded(Opie::Core::OProcess*)));
-
- connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)),
- this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int)));
-
- command << "/bin/sh";
- command << "-c";
- command << cmd.latin1();
- *process << command;
- if(!process->start(OProcess::NotifyOnExit, OProcess::All) )
- qDebug("could not start process");
-}
-
-void AdvancedFm::processEnded(OProcess *) {
- rePopulate();
-}
-
-void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) {
-// qWarning("received stderrt %d bytes", buflen);
-
- QString lineStr = buffer;
- QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") );
-}
-
-bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) {
- if ( o->inherits( "QLineEdit" ) ) {
- if ( e->type() == QEvent::KeyPress ) {
- QKeyEvent *ke = (QKeyEvent*)e;
- if ( ke->key() == Key_Return ||
- ke->key() == Key_Enter ) {
- okRename();
- return true;
- }
- else if ( ke->key() == Key_Escape ) {
- cancelRename();
- return true;
- }
- }
- else if ( e->type() == QEvent::FocusOut ) {
- cancelRename();
- return true;
- }
- }
- if ( o->inherits( "QListView" ) ) {
- if ( e->type() == QEvent::FocusIn ) {
- if( o == Local_View) { //keep track of which view
- whichTab=1;
- }
- else {
- whichTab=2;
- }
- }
- OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection
- }
-
- return QWidget::eventFilter( o, e );
-}
-
-
-void AdvancedFm::cancelRename() {
-// qDebug("cancel rename");
- QListView * view;
- view = CurrentView();
-
- bool resetFocus = view->viewport()->focusProxy() == renameBox;
- delete renameBox;
- renameBox = 0;
- if ( resetFocus ) {
- view->viewport()->setFocusProxy( view);
- view->setFocus();
- }
-}
-
-void AdvancedFm::doRename(QListView * view) {
- if( !CurrentView()->currentItem()) return;
-
- QRect r = view->itemRect( view->currentItem( ));
- r = QRect( view->viewportToContents( r.topLeft() ), r.size() );
- r.setX( view->contentsX() );
-
- if ( r.width() > view->visibleWidth() )
- r.setWidth( view->visibleWidth() );
-
- renameBox = new QLineEdit( view->viewport(), "qt_renamebox" );
- renameBox->setFrame(true);
-
- renameBox->setText( view->currentItem()->text(0) );
-
- renameBox->selectAll();
- renameBox->installEventFilter( this );
-
- view->addChild( renameBox, r.x(), r.y() );
-
- renameBox->resize( r.size() );
-
- view->viewport()->setFocusProxy( renameBox );
-
- renameBox->setFocus();
- renameBox->show();
-}
-
-
-void AdvancedFm::renameIt() {
- if( !CurrentView()->currentItem()) return;
-
- QListView *thisView = CurrentView();
- oldName = thisView->currentItem()->text(0);
- doRename( thisView );
-}
-
-void AdvancedFm::okRename() {
- if( !renameBox) return;
-
- QString newName = renameBox->text();
- cancelRename();
- QListView * view = CurrentView();
- QString path = CurrentDir()->canonicalPath() + "/";
- oldName = path + oldName;
- newName = path + newName;
- if( rename( oldName.latin1(), newName.latin1())== -1)
- QMessageBox::message(tr("Note"),tr("Could not rename"));
- else
- oldName = "";
- QListViewItem *item = view->currentItem();
- view->takeItem( item );
- delete item;
- rePopulate();
-}
-
-void AdvancedFm::openSearch() {
- QMessageBox::message(tr("Note"),tr("Not Yet Implemented"));
-}
+/***************************************************************************
+ AdvancedFm.cpp
+ -------------------
+ ** 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. *
+ ***************************************************************************/
+
+#include "advancedfm.h"
+#include "output.h"
+#include "filePermissions.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+#include <qpe/lnkproperties.h>
+#include <qpe/qpeapplication.h>
+#include <qpe/applnk.h>
+using namespace Opie::Core;
+
+/* QT*/
+
+#include <qmessagebox.h>
+#include <qpopupmenu.h>
+#include <qlistview.h>
+
+/* STD */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <sys/sendfile.h>
+#include <fcntl.h>
+
+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;
+ gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) );
+ }
+}
+
+void AdvancedFm::showMenuHidden() {
+ if (b) {
+ CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
+ OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
+ fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
+ } else {
+ CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
+ OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
+ fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
+ }
+ b = !b;
+ populateView();
+}
+
+void AdvancedFm::showHidden() {
+ if (b) {
+ CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
+ OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
+ } else {
+ CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
+ OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
+ }
+ populateView();
+}
+
+QString AdvancedFm::dealWithSymName(const QString &fileName) {
+ QString strItem = fileName;
+ return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
+}
+
+void AdvancedFm::runThis() {
+ if( !CurrentView()->currentItem()) return;
+ QString fs;
+ QDir *thisDir = CurrentDir();
+
+ QString curFile = CurrentView()->currentItem()->text(0);
+ QString path = thisDir->canonicalPath();
+
+ if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
+
+ curFile = dealWithSymName((const QString&)curFile);
+
+ if(curFile != "../") {
+
+ fs = getFileSystemType((const QString &) path);
+ QFileInfo fileInfo( path + "/" + curFile);
+// 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;
+ if( execStr.isEmpty() ) {
+ } else {
+ nf.execute();
+ }
+ }
+ }
+}
+
+void AdvancedFm::runText() {
+ if( !CurrentView()->currentItem()) return;
+ QString curFile = CurrentView()->currentItem()->text(0);
+ if(curFile != "../") {
+ if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
+ curFile = dealWithSymName((const QString&)curFile);
+ curFile = CurrentDir()->canonicalPath()+"/"+curFile;
+ QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
+ e << curFile;
+ }
+}
+
+void AdvancedFm::makeDir() {
+ InputDialog *fileDlg;
+ fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
+ fileDlg->exec();
+ if( fileDlg->result() == 1 ) {
+ QDir *thisDir = CurrentDir();
+ QString filename = fileDlg->LineEdit1->text();
+ thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
+ }
+ populateView();
+}
+
+void AdvancedFm::doDelete() {
+ 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;
+ };
+ }
+
+ 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() ) {
+ //if file is a directory
+
+ switch ( QMessageBox::warning( this, tr("Delete Directory?"),
+ tr("Really delete %1\nand all it's contents ?" ).arg( f ) ,
+ tr("Yes"), tr("No"), 0, 0, 1) ) {
+ case 0:
+ {
+ f=f.left(f.length()-1);
+ QString cmd="rm -rf "+f;
+ startProcess( (const QString)cmd.latin1() );
+ populateView();
+ }
+ break;
+ case 1:
+ // exit
+ break;
+ };
+
+ } else {
+ if(doMsg) {
+ switch ( QMessageBox::warning(this,tr("Delete"),
+ tr("Really delete\n%1?").arg( myFile ),
+ tr("Yes"), tr("No"), 0, 0, 1) ) {
+ case 1:
+ return;
+ break;
+ };
+ }
+
+ QString cmd="rm "+f;
+ QFile file(f);
+ QFileInfo fi(myFile);
+ if( fi.fileName().find("../",0,TRUE)==-1) {
+// odebug << "remove link files "+myFile << oendl;
+
+// DocLnk lnk(f);
+ DocLnk *lnk;
+ lnk = new DocLnk(f);
+// odebug << "Deleting doclnk " + lnk->linkFile() << oendl;
+ if(lnk->isValid())
+ lnk->removeLinkFile();
+ // delete lnk;
+ file.remove();
+ }
+ }
+ }
+ }
+ populateView();
+}
+
+void AdvancedFm::filePerms() {
+ QStringList curFileList = getPath();
+ QString filePath;
+
+ filePath = CurrentDir()->canonicalPath()+"/";
+
+ for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
+ filePermissions *filePerm;
+ filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
+ QPEApplication::execDialog( filePerm );
+ if( filePerm )
+ delete filePerm;
+ }
+ populateView();
+}
+
+void AdvancedFm::doProperties() {
+#if defined(QT_QWS_OPIE)
+
+ QStringList curFileList = getPath();
+
+ QString filePath;
+ filePath = CurrentDir()->canonicalPath()+"/";
+
+// odebug << "" << curFileList.count() << "" << oendl;
+
+ for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
+// odebug << (filePath+*it) << oendl;
+ DocLnk lnk( (filePath+*it));
+ LnkProperties prop( &lnk );
+ QPEApplication::execDialog( &prop );
+ }
+#endif
+
+}
+
+void AdvancedFm::upDir() {
+ QDir *thisDir = CurrentDir();
+ QString current = thisDir->canonicalPath();
+ QDir dir(current);
+ dir.cdUp();
+ current = dir.canonicalPath();
+ chdir( current.latin1() );
+ thisDir->cd( current, TRUE);
+
+ populateView();
+ update();
+}
+
+void AdvancedFm::copy() {
+ qApp->processEvents();
+ QStringList curFileList = getPath();
+
+ QDir *thisDir = CurrentDir();
+ QDir *thatDir = OtherDir();
+
+ 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("Copy"),msg
+ ,tr("Yes"),tr("No"),0,0,1) )
+ {
+ case 0:
+ doMsg=false;
+ break;
+ case 1:
+ return;
+ break;
+ };
+ }
+
+ QString curFile, item, destFile;
+ 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));
+
+ curFile = thisDir->canonicalPath()+"/"+ item;
+ destFile = thatDir->canonicalPath()+"/"+ item;
+
+// 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("%1 exists. Ok to overwrite?").arg( item ),
+ tr("Yes"),tr("No"),0,0,1) ) {
+ case 1:
+ return;
+ break;
+ };
+ }
+ f.remove();
+ }
+
+ if( !copyFile( curFile, destFile) ) {
+ QMessageBox::message("AdvancedFm",
+ tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) );
+ return;
+ }
+ }
+ setOtherTabCurrent();
+ rePopulate();
+ }
+}
+
+void AdvancedFm::copyAs() {
+ qApp->processEvents();
+
+ QStringList curFileList = getPath();
+ QString curFile, item;
+ InputDialog *fileDlg;
+
+ QDir *thisDir = CurrentDir();
+ QDir *thatDir = OtherDir();
+
+ for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
+ QString destFile;
+ item=(*it);
+ curFile = thisDir->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 = thatDir->canonicalPath()+"/"+filename;
+
+ QFile f( destFile);
+ if( f.exists()) {
+ 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( curFile, destFile) ) {
+ QMessageBox::message("AdvancedFm",tr("Could not copy\n")
+ +curFile +tr("to\n")+destFile);
+ return;
+ }
+ }
+ delete fileDlg;
+
+ }
+ rePopulate();
+ setOtherTabCurrent();
+}
+
+void AdvancedFm::copySameDir() {
+ qApp->processEvents();
+ QStringList curFileList = getPath();
+ QString curFile, item, destFile;
+ InputDialog *fileDlg;
+
+ QDir *thisDir = CurrentDir();
+
+ for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
+ item=(*it);
+ curFile = thisDir->canonicalPath()+"/"+ item;
+
+ fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
+ fileDlg->setInputText((const QString &) destFile );
+ fileDlg->exec();
+
+ if( fileDlg->result() == 1 ) {
+
+ QString filename = fileDlg->LineEdit1->text();
+ destFile = thisDir->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( curFile,destFile) ) {
+ QMessageBox::message("AdvancedFm",tr("Could not copy\n")
+ +curFile +tr("to\n")+destFile);
+ return;
+ }
+
+// odebug << "copy "+curFile+" as "+destFile << oendl;
+ }
+ delete fileDlg;
+ }
+ rePopulate();
+}
+
+void AdvancedFm::move() {
+ qApp->processEvents();
+
+ QStringList curFileList = getPath();
+ if( curFileList.count() > 0) {
+ QString curFile, destFile, item;
+
+ QDir *thisDir = CurrentDir();
+ QDir *thatDir = OtherDir();
+ for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
+ item=(*it);
+ QString destFile = thatDir->canonicalPath();
+
+ if(destFile.right(1).find("/",0,TRUE) == -1)
+ destFile+="/";
+ destFile += item;
+// 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;
+
+ if(QFileInfo(curFile).isDir()) {
+ moveDirectory( curFile, destFile );
+ rePopulate();
+ return;
+ }
+
+ QFile f( curFile);
+ if( f.exists()) {
+ if( !copyFile( curFile, destFile) ) {
+ QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
+ return;
+ } else
+ QFile::remove(curFile);
+ }
+ }
+
+ }
+ rePopulate();
+ setOtherTabCurrent();
+}
+
+bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) {
+ int err = 0;
+ if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src;
+ err = system((const char*)cmd);
+ } else
+ err = -1;
+
+ if(err!=0) {
+ QMessageBox::message(tr("Note"),tr("Could not move\n") + src);
+ return false;
+ }
+ return true;
+}
+
+bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) {
+
+ QString cmd = "/bin/cp -fpR " + src + " " + dest;
+ owarn << cmd << oendl;
+ int err = system( (const char *) cmd );
+ if ( err != 0 ) {
+ QMessageBox::message("AdvancedFm",
+ tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) );
+ return false;
+ }
+
+ return true;
+}
+
+
+bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
+
+
+ if(QFileInfo(src).isDir()) {
+ if( copyDirectory( src, dest )) {
+ setOtherTabCurrent();
+ populateView();
+ return true;
+ }
+ else
+ return false;
+ }
+
+
+ bool success = true;
+ struct stat status;
+ QFile srcFile(src);
+ QFile destFile(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;
+ 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;
+ 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) {
+ QString msg;
+ switch(err) {
+ 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;
+ }
+ } else {
+ success = false;
+ }
+ } else {
+ success = false;
+ }
+ srcFile.close();
+ destFile.close();
+ // Set file permissions
+ if( stat( (const char *) src, &status ) == 0 ) {
+ chmod( (const char *) dest, status.st_mode );
+ }
+
+ return success;
+}
+
+void AdvancedFm::runCommand() {
+ if( !CurrentView()->currentItem()) return;
+ QDir *thisDir = CurrentDir();
+
+ QString curFile;
+ curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0);
+
+ InputDialog *fileDlg;
+ 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;
+ QStringList command;
+
+ command << "/bin/sh";
+ command << "-c";
+ command << fileDlg->LineEdit1->text();
+ Output *outDlg;
+ outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
+ QPEApplication::execDialog( outDlg );
+ qApp->processEvents();
+
+ }
+}
+
+void AdvancedFm::runCommandStd() {
+ if( !CurrentView()->currentItem()) return;
+ QString curFile;
+ QDir *thisDir = CurrentDir();
+ QListView *thisView = CurrentView();
+ if( thisView->currentItem())
+ curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0);
+
+ InputDialog *fileDlg;
+ fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
+ fileDlg->setInputText(curFile);
+ fileDlg->exec();
+
+ if( fileDlg->result() == 1 ) {
+ qApp->processEvents();
+ startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
+ }
+}
+
+void AdvancedFm::fileStatus() {
+ if( !CurrentView()->currentItem()) return;
+ QString curFile;
+ curFile = CurrentView()->currentItem()->text(0);
+
+ QStringList command;
+ command << "/bin/sh";
+ command << "-c";
+ command << "stat -l "+ curFile;
+
+ Output *outDlg;
+ outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
+ QPEApplication::execDialog( outDlg );
+ qApp->processEvents();
+}
+
+
+void AdvancedFm::mkDir() {
+ makeDir();
+}
+
+void AdvancedFm::rn() {
+ renameIt();
+}
+
+void AdvancedFm::del() {
+ doDelete();
+}
+
+void AdvancedFm::mkSym() {
+ QString cmd;
+ QStringList curFileList = getPath();
+ if( curFileList.count() > 0) {
+ QDir *thisDir = CurrentDir();
+ QDir * thatDir = OtherDir();
+
+ for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
+
+ QString destName = thatDir->canonicalPath()+"/"+(*it);
+ if(destName.right(1) == "/") {
+ destName = destName.left( destName.length() -1);
+ }
+
+ QString curFile = thisDir->canonicalPath()+"/"+(*it);
+
+ if( curFile.right(1) == "/") {
+ curFile = curFile.left( curFile.length() -1);
+ }
+
+ cmd = "ln -s "+curFile+" "+destName;
+// odebug << cmd << oendl;
+ startProcess( (const QString)cmd );
+ }
+ rePopulate();
+ setOtherTabCurrent();
+ }
+}
+
+void AdvancedFm::doBeam() {
+ Ir ir;
+ if(!ir.supported()) {
+ } else {
+ QStringList curFileList = getPath();
+ if( curFileList.count() > 0) {
+ for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
+ QString curFile = (*it);
+ QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile;
+ if( curFilePath.right(1) == "/") {
+ curFilePath = curFilePath.left( curFilePath.length() -1);
+ }
+ Ir *file = new Ir(this, "IR");
+ connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*)));
+ file->send( curFilePath, curFile );
+ }
+ }
+ }
+}
+
+void AdvancedFm::fileBeamFinished( Ir *) {
+ QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
+}
+
+void AdvancedFm::selectAll() {
+ QListView *thisView = CurrentView();
+ thisView->selectAll(true);
+ thisView->setSelected( thisView->firstChild(),false);
+}
+
+void AdvancedFm::startProcess(const QString & cmd) {
+ QStringList command;
+ OProcess *process;
+ process = new OProcess();
+ connect(process, SIGNAL(processExited(Opie::Core::OProcess*)),
+ this, SLOT( processEnded(Opie::Core::OProcess*)));
+
+ connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)),
+ this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int)));
+
+ command << "/bin/sh";
+ command << "-c";
+ command << cmd.latin1();
+ *process << command;
+ if(!process->start(OProcess::NotifyOnExit, OProcess::All) )
+ odebug << "could not start process" << oendl;
+}
+
+void AdvancedFm::processEnded(OProcess *) {
+ rePopulate();
+}
+
+void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) {
+// owarn << "received stderrt " << buflen << " bytes" << oendl;
+
+ QString lineStr = buffer;
+ QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") );
+}
+
+bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) {
+ if ( o->inherits( "QLineEdit" ) ) {
+ if ( e->type() == QEvent::KeyPress ) {
+ QKeyEvent *ke = (QKeyEvent*)e;
+ if ( ke->key() == Key_Return ||
+ ke->key() == Key_Enter ) {
+ okRename();
+ return true;
+ }
+ else if ( ke->key() == Key_Escape ) {
+ cancelRename();
+ return true;
+ }
+ }
+ else if ( e->type() == QEvent::FocusOut ) {
+ cancelRename();
+ return true;
+ }
+ }
+ if ( o->inherits( "QListView" ) ) {
+ if ( e->type() == QEvent::FocusIn ) {
+ if( o == Local_View) { //keep track of which view
+ whichTab=1;
+ }
+ else {
+ whichTab=2;
+ }
+ }
+ OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection
+ }
+
+ return QWidget::eventFilter( o, e );
+}
+
+
+void AdvancedFm::cancelRename() {
+// odebug << "cancel rename" << oendl;
+ QListView * view;
+ view = CurrentView();
+
+ bool resetFocus = view->viewport()->focusProxy() == renameBox;
+ delete renameBox;
+ renameBox = 0;
+ if ( resetFocus ) {
+ view->viewport()->setFocusProxy( view);
+ view->setFocus();
+ }
+}
+
+void AdvancedFm::doRename(QListView * view) {
+ if( !CurrentView()->currentItem()) return;
+
+ QRect r = view->itemRect( view->currentItem( ));
+ r = QRect( view->viewportToContents( r.topLeft() ), r.size() );
+ r.setX( view->contentsX() );
+
+ if ( r.width() > view->visibleWidth() )
+ r.setWidth( view->visibleWidth() );
+
+ renameBox = new QLineEdit( view->viewport(), "qt_renamebox" );
+ renameBox->setFrame(true);
+
+ renameBox->setText( view->currentItem()->text(0) );
+
+ renameBox->selectAll();
+ renameBox->installEventFilter( this );
+
+ view->addChild( renameBox, r.x(), r.y() );
+
+ renameBox->resize( r.size() );
+
+ view->viewport()->setFocusProxy( renameBox );
+
+ renameBox->setFocus();
+ renameBox->show();
+}
+
+
+void AdvancedFm::renameIt() {
+ if( !CurrentView()->currentItem()) return;
+
+ QListView *thisView = CurrentView();
+ oldName = thisView->currentItem()->text(0);
+ doRename( thisView );
+}
+
+void AdvancedFm::okRename() {
+ if( !renameBox) return;
+
+ QString newName = renameBox->text();
+ cancelRename();
+ QListView * view = CurrentView();
+ QString path = CurrentDir()->canonicalPath() + "/";
+ oldName = path + oldName;
+ newName = path + newName;
+ if( rename( oldName.latin1(), newName.latin1())== -1)
+ QMessageBox::message(tr("Note"),tr("Could not rename"));
+ else
+ oldName = "";
+ QListViewItem *item = view->currentItem();
+ view->takeItem( item );
+ delete item;
+ rePopulate();
+}
+
+void AdvancedFm::openSearch() {
+ QMessageBox::message(tr("Note"),tr("Not Yet Implemented"));
+}
diff --git a/noncore/apps/advancedfm/filePermissions.cpp b/noncore/apps/advancedfm/filePermissions.cpp
index 9698de7..b7d48e8 100644
--- a/noncore/apps/advancedfm/filePermissions.cpp
+++ b/noncore/apps/advancedfm/filePermissions.cpp
@@ -32,7 +32,7 @@ filePermissions::filePermissions( QWidget* parent, const char* name, bool modal
{
if ( !name )
setName( tr("filePermissions") );
-// qDebug("FilePermissions "+fileName);
+// odebug << "FilePermissions "+fileName << oendl;
/* resize( 236, 210 );
setMaximumSize( QSize( 236, 210 ) );
*/ setCaption( tr( "Set File Permissions" ) );
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp
index 6906298..8c585f4 100644
--- a/noncore/apps/advancedfm/output.cpp
+++ b/noncore/apps/advancedfm/output.cpp
@@ -5,19 +5,22 @@
****************************************************************************/
#include "output.h"
+/* OPIE */
+#include <opie2/odebug.h>
#include <qpe/qpeapplication.h>
#include <qpe/applnk.h>
+using namespace Opie::Core;
+/* QT */
#include <qfile.h>
#include <qmultilineedit.h>
#include <qpushbutton.h>
#include <qlayout.h>
+/* STD */
#include <errno.h>
/* XPM */
-using namespace Opie::Core;
-using namespace Opie::Core;
static char * filesave_xpm[] = {
"16 16 78 1",
" c None",
@@ -121,7 +124,7 @@ Output::Output( const QStringList commands, QWidget* parent, const char* name,
QStringList cmmds;
// cmmds=QStringList::split( " ", commands, false);
cmmds=commands;
-// qDebug("count %d", cmmds.count());
+// odebug << "count " << cmmds.count() << "" << oendl;
if ( !name )
setName( tr("Output"));
resize( 196, 269 );
@@ -157,7 +160,7 @@ Output::Output( const QStringList commands, QWidget* parent, const char* name,
// * proc << commands.latin1();
for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) {
- qDebug( "%s", (*it).latin1() );
+ odebug << "" << (*it).latin1() << "" << oendl;
* proc << (*it).latin1();
}
@@ -186,7 +189,7 @@ void Output::saveOutput() {
filename+="/";
QString name = fileDlg->LineEdit1->text();
filename+="text/plain/"+name;
- qDebug(filename);
+ odebug << filename << oendl;
QFile f(filename);
f.open( IO_WriteOnly);
@@ -196,16 +199,16 @@ void Output::saveOutput() {
lnk.setFile(filename); //sets File property
lnk.setType("text/plain");
if(!lnk.writeLink()) {
- qDebug("Writing doclink did not work");
+ odebug << "Writing doclink did not work" << oendl;
}
} else
- qWarning("Could not write file");
+ owarn << "Could not write file" << oendl;
f.close();
}
}
void Output::commandStdout(OProcess*, char *buffer, int buflen) {
- qWarning("received stdout %d bytes", buflen);
+ owarn << "received stdout " << buflen << " bytes" << oendl;
// QByteArray data(buflen);
// data.fill(*buffer, buflen);
@@ -222,13 +225,13 @@ void Output::commandStdout(OProcess*, char *buffer, int buflen) {
void Output::commandStdin( const QByteArray &data) {
- qWarning("received stdin %d bytes", data.size());
+ owarn << "received stdin " << data.size() << " bytes" << oendl;
// recieved data from the io layer goes to sz
proc->writeStdin(data.data(), data.size());
}
void Output::commandStderr(OProcess*, char *buffer, int buflen) {
- qWarning("received stderrt %d bytes", buflen);
+ owarn << "received stderrt " << buflen << " bytes" << oendl;
QString lineStr = buffer;
// lineStr=lineStr.left(lineStr.length()-1);