summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 869a433..a000e9b 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -1308,446 +1308,446 @@ void AdvancedFm::move() {
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 );
}
} else {
success = FALSE;
}
// Set file permissions
if( stat( (const char *) src, &status ) == 0 ){
chmod( (const char *) dest, status.st_mode );
}
return success;
}
void AdvancedFm::runCommand() {
QString curFile;
if (TabWidget->currentPageIndex() == 0) {
if( Local_View->currentItem())
curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
} else {
if(Remote_View->currentItem())
curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->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 ) {
command = fileDlg->LineEdit1->text();
// int err=0;
Output *outDlg;
outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
outDlg->showMaximized();
outDlg->show();
qApp->processEvents();
FILE *fp;
char line[130];
sleep(1);
// if(command.find("2>",0,TRUE) != -1)
command +=" 2>&1";
fp = popen( (const char *) command, "r");
if ( !fp ) {
qDebug("Could not execute '" + command + "'! err=%d", fp);
QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") );
pclose(fp);
return;
} else {
while ( fgets( line, sizeof line, fp)) {
QString lineStr = line;
lineStr=lineStr.left(lineStr.length()-1);
outDlg->OutputEdit->append(lineStr);
outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
}
}
}
}
void AdvancedFm::runCommandStd() {
QString curFile;
if (TabWidget->currentPageIndex() == 0) {
if( Local_View->currentItem())
curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
} else {
if(Remote_View->currentItem())
curFile = currentRemoteDir.canonicalPath() +"/"+ Remote_View->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 ) {
qApp->processEvents();
command = fileDlg->LineEdit1->text() + " &";
system(command.latin1());
}
}
void AdvancedFm::fileStatus() {
QString curFile;
if (TabWidget->currentPageIndex() == 0) {
curFile = Local_View->currentItem()->text(0);
} else {
curFile = Remote_View->currentItem()->text(0);
}
QString command = " stat -l "+ curFile +" 2>&1";
// int err=0;
Output *outDlg;
outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
outDlg->showMaximized();
outDlg->show();
qApp->processEvents();
FILE *fp;
char line[130];
sleep(1);
fp = popen( (const char *) command, "r");
if ( !fp ) {
qDebug("Could not execute '" + command + "'! err=%d", fp);
QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") );
pclose(fp);
return;
} else {
while ( fgets( line, sizeof line, fp)) {
outDlg->OutputEdit->append(line);
outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
}
}
}
void AdvancedFm::mkDir() {
if (TabWidget->currentPageIndex() == 0)
localMakDir();
else
remoteMakDir();
}
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;
QStringList curFileList = getPath();
if( curFileList.count() > 0) {
if (TabWidget->currentPageIndex() == 0) {
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
QString destName = currentRemoteDir.canonicalPath()+"/"+(*it);
if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
QString curFile = currentDir.canonicalPath()+"/"+(*it);
if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
cmd = "ln -s "+curFile+" "+destName;
qDebug(cmd);
system(cmd.latin1() );
}
populateRemoteView();
TabWidget->setCurrentPage(1);
} else {
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
QString destName = currentDir.canonicalPath()+"/"+(*it);
if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
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();
}
void AdvancedFm::parsetab(const QString &fileName) {
fileSystemTypeList.clear();
fsList.clear();
struct mntent *me;
// if(fileName == "/etc/mtab") {
FILE *mntfp = setmntent( fileName.latin1(), "r" );
if ( mntfp ) {
while ( (me = getmntent( mntfp )) != 0 ) {
QString deviceName = me->mnt_fsname;
QString filesystemType = me->mnt_type;
QString mountDir = me->mnt_dir;
if(deviceName != "none") {
if( fsList.contains(filesystemType) == 0
& filesystemType.find("proc",0,TRUE) == -1
& filesystemType.find("cramfs",0,TRUE) == -1
& filesystemType.find("auto",0,TRUE) == -1)
fsList << filesystemType;
// deviceList << deviceName;
// qDebug(mountDir+"::"+filesystemType);
fileSystemTypeList << mountDir+"::"+filesystemType;
}
}
}
endmntent( mntfp );
}
QString AdvancedFm::getFileSystemType(const QString &currentText) {
parsetab("/etc/mtab"); //why did TT forget filesystem type?
QString current = currentText;//.right( currentText.length()-1);
QString baseFs;
for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
QString temp = (*it);
QString path = temp.left(temp.find("::",0,TRUE) );
path = path.right( path.length()-1);
if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) {
return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
}
}
return baseFs;
}
void AdvancedFm::doBeam() {
Ir ir;
if(!ir.supported()){
} else {
QStringList curFileList = getPath();
if( curFileList.count() > 0) {
if (TabWidget->currentPageIndex() == 0) {
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
QString curFile = currentDir.canonicalPath()+"/"+(*it);
if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
Ir *file = new Ir(this, "IR");
connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
file->send( curFile, curFile );
}
} else {
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
Ir *file = new Ir(this, "IR");
connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
file->send( curFile, curFile );
}
}
}
}
}
void AdvancedFm::fileBeamFinished( Ir *ir) {
QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
}
// QList<QListViewItem> * getSelectedItems( QListView * Local_View );
// QListViewItemIterator it( Local_View );
// for ( ; it.current(); ++it ) {
// if ( it.current()->isSelected() ) {
// QString strItem = it.current()->text(0);
// QString localFile = currentDir.canonicalPath()+"/"+strItem;
// QFileInfo fi(localFile);
// }
// }
void AdvancedFm::showFileMenu() {
QString curApp;
bool isLocalView = false;
if (TabWidget->currentPageIndex() == 0) {
isLocalView = TRUE;
curApp = Local_View->currentItem()->text(0);
} else {
curApp = Remote_View->currentItem()->text(0);
}
MimeType mt( curApp );
const AppLnk* app = mt.application();
QFile fi(curApp);
QPopupMenu m;
m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
m.insertSeparator();
if ( QFileInfo(fi).isDir() ) {
m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
} else {
if ( app )
- m.insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( run() ) );
+ m.insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( runThis() ) );
else if( QFileInfo(fi).isExecutable() )
- m.insertItem( tr( "Execute" ), this, SLOT( run() ) );
+ m.insertItem( tr( "Execute" ), this, SLOT( runThis() ) );
m.insertItem( /*Resource::loadPixmap( "txt" ),*/ tr( "Open as text" ),this, SLOT( runText() ) );
}
m.insertSeparator();
if(isLocalView)
m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
else
m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
m.insertSeparator();
if(isLocalView)
m.insertItem( tr( "Rename" ), this, SLOT( localRename() ));
else
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();
if(isLocalView)
m.insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() ));
else
m.insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() ));
m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
m.insertSeparator();
if(isLocalView)
m.insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
else
m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
m.insertSeparator();
m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings
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);
if(Ir::supported())
m.insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
m.exec( QCursor::pos() );
}
void AdvancedFm::cancelMenuTimer()
{
qDebug("cancel menu timer");
if( menuTimer.isActive() )
menuTimer.stop();
}