summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/advancedfmMenu.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp161
1 files changed, 79 insertions, 82 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 78f9da2..18bbd43 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -10,15 +10,12 @@
* (at your option) any later version. *
***************************************************************************/
#include "advancedfm.h"
#include "output.h"
#include "filePermissions.h"
-#include <opie/otabwidget.h>
-#include <opie/oprocess.h>
-
#include <qpe/lnkproperties.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/applnk.h>
#include <qpe/ir.h>
@@ -66,24 +63,24 @@ void AdvancedFm::showMenuHidden() {
} 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();
+ 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();
+ populateView();
}
QString AdvancedFm::dealWithSymName(const QString &fileName) {
QString strItem = fileName;
return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
}
@@ -143,13 +140,13 @@ void AdvancedFm::makeDir() {
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QDir *thisDir = CurrentDir();
QString filename = fileDlg->LineEdit1->text();
thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
}
- populateView();
+ populateView();
}
void AdvancedFm::doDelete() {
QStringList curFileList = getPath();
bool doMsg=true;
int count = curFileList.count();
@@ -180,21 +177,21 @@ void AdvancedFm::doDelete() {
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?"),
+ 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();
+ populateView();
}
break;
case 1:
// exit
break;
};
@@ -206,32 +203,32 @@ void AdvancedFm::doDelete() {
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();
+ populateView();
}
void AdvancedFm::filePerms() {
QStringList curFileList = getPath();
QString filePath;
@@ -241,13 +238,13 @@ void AdvancedFm::filePerms() {
filePermissions *filePerm;
filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
QPEApplication::execDialog( filePerm );
if( filePerm )
delete filePerm;
}
- populateView();
+ populateView();
}
void AdvancedFm::doProperties() {
#if defined(QT_QWS_OPIE)
QStringList curFileList = getPath();
@@ -273,13 +270,13 @@ void AdvancedFm::upDir() {
QDir dir(current);
dir.cdUp();
current = dir.canonicalPath();
chdir( current.latin1() );
thisDir->cd( current, TRUE);
- populateView();
+ populateView();
update();
}
void AdvancedFm::copy() {
qApp->processEvents();
QStringList curFileList = getPath();
@@ -334,14 +331,14 @@ void AdvancedFm::copy() {
if( !copyFile( curFile, destFile) ) {
QMessageBox::message("AdvancedFm",
tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) );
return;
}
}
- setOtherTabCurrent();
- rePopulate();
+ setOtherTabCurrent();
+ rePopulate();
}
}
void AdvancedFm::copyAs() {
qApp->processEvents();
@@ -384,14 +381,14 @@ void AdvancedFm::copyAs() {
return;
}
}
delete fileDlg;
}
- rePopulate();
- setOtherTabCurrent();
+ rePopulate();
+ setOtherTabCurrent();
}
void AdvancedFm::copySameDir() {
qApp->processEvents();
QStringList curFileList = getPath();
QString curFile, item, destFile;
@@ -433,13 +430,13 @@ void AdvancedFm::copySameDir() {
}
// qDebug("copy "+curFile+" as "+destFile);
}
delete fileDlg;
}
- rePopulate();
+ rePopulate();
}
void AdvancedFm::move() {
qApp->processEvents();
QStringList curFileList = getPath();
@@ -456,86 +453,86 @@ void AdvancedFm::move() {
destFile+="/";
destFile += item;
// qDebug("Destination file is "+destFile);
curFile = thisDir->canonicalPath();
if(curFile.right(1).find("/",0,TRUE) == -1)
- curFile +="/";
+ curFile +="/";
curFile+= item;
// qDebug("CurrentFile file is " + curFile);
if(QFileInfo(curFile).isDir()) {
- moveDirectory( curFile, destFile );
- rePopulate();
- return;
+ moveDirectory( curFile, destFile );
+ rePopulate();
+ return;
}
- QFile f( curFile);
+ QFile f( curFile);
if( f.exists()) {
- if( !copyFile( curFile, destFile) ) {
- QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
- return;
+ if( !copyFile( curFile, destFile) ) {
+ QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
+ return;
} else
- QFile::remove(curFile);
+ QFile::remove(curFile);
}
- }
+ }
}
- rePopulate();
- setOtherTabCurrent();
+ 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;
+ 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;
+ 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;
- }
+ 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;
+ 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;
+
+ 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;
@@ -544,13 +541,13 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
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();
+ 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. ";
@@ -674,15 +671,15 @@ void AdvancedFm::mkSym() {
}
cmd = "ln -s "+curFile+" "+destName;
// qDebug(cmd);
startProcess( (const QString)cmd );
}
- rePopulate();
- setOtherTabCurrent();
- }
+ rePopulate();
+ setOtherTabCurrent();
+ }
}
void AdvancedFm::doBeam() {
Ir ir;
if(!ir.supported()) {
} else {
@@ -728,13 +725,13 @@ void AdvancedFm::startProcess(const QString & cmd) {
*process << command;
if(!process->start(OProcess::NotifyOnExit, OProcess::All) )
qDebug("could not start process");
}
void AdvancedFm::processEnded(OProcess *) {
- rePopulate();
+ rePopulate();
}
void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) {
// qWarning("received stderrt %d bytes", buflen);
QString lineStr = buffer;
@@ -794,57 +791,57 @@ 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() )
+ 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() );
+ renameBox->resize( r.size() );
- view->viewport()->setFocusProxy( renameBox );
+ view->viewport()->setFocusProxy( renameBox );
- renameBox->setFocus();
+ renameBox->setFocus();
renameBox->show();
}
void AdvancedFm::renameIt() {
- if( !CurrentView()->currentItem()) return;
+ if( !CurrentView()->currentItem()) return;
- QListView *thisView = CurrentView();
+ QListView *thisView = CurrentView();
oldName = thisView->currentItem()->text(0);
doRename( thisView );
}
void AdvancedFm::okRename() {
if( !CurrentView()->currentItem()) return;
QString newName = renameBox->text();
- cancelRename();
- QListView * view = CurrentView();
+ 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 = "";
view->takeItem( view->currentItem() );
delete view->currentItem();
- rePopulate();
+ rePopulate();
}
void AdvancedFm::openSearch() {
QMessageBox::message(tr("Note"),tr("Not Yet Implemented"));
}