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.cpp114
1 files changed, 81 insertions, 33 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index c0be948..90c887f 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -69,6 +69,6 @@ void AdvancedFm::showMenuHidden() {
fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
}
- rePopulate();
b = !b;
+ populateView();
}
@@ -81,5 +81,5 @@ void AdvancedFm::showHidden() {
OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
}
- rePopulate();
+ populateView();
}
@@ -147,5 +147,5 @@ void AdvancedFm::makeDir() {
thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
}
- populateView();
+ populateView();
}
@@ -192,5 +192,5 @@ void AdvancedFm::doDelete() {
QString cmd="rm -rf "+f;
startProcess( (const QString)cmd.latin1() );
- populateView();
+ populateView();
}
break;
@@ -229,5 +229,5 @@ void AdvancedFm::doDelete() {
}
}
- populateView();
+ populateView();
}
@@ -246,5 +246,5 @@ void AdvancedFm::filePerms() {
delete filePerm;
}
- populateView();
+ populateView();
}
@@ -279,5 +279,5 @@ void AdvancedFm::upDir() {
thisDir->cd( current, TRUE);
- populateView();
+ populateView();
update();
}
@@ -340,6 +340,6 @@ void AdvancedFm::copy() {
}
}
- rePopulate();
- setOtherTabCurrent();
+ setOtherTabCurrent();
+ rePopulate();
}
}
@@ -390,6 +390,6 @@ void AdvancedFm::copyAs() {
}
- rePopulate();
- setOtherTabCurrent();
+ rePopulate();
+ setOtherTabCurrent();
}
@@ -439,5 +439,5 @@ void AdvancedFm::copySameDir() {
delete fileDlg;
}
- populateView();
+ rePopulate();
}
@@ -462,30 +462,78 @@ void AdvancedFm::move() {
curFile = thisDir->canonicalPath();
if(curFile.right(1).find("/",0,TRUE) == -1)
- curFile +="/";
+ curFile +="/";
curFile+= item;
// qDebug("CurrentFile file is " + curFile);
- QFile f( 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;
+ 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;
}
+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 ) {
- 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;
@@ -634,7 +682,7 @@ void AdvancedFm::mkSym() {
startProcess( (const QString)cmd );
}
- rePopulate();
- setOtherTabCurrent();
- }
+ rePopulate();
+ setOtherTabCurrent();
+ }
}
@@ -688,5 +736,5 @@ void AdvancedFm::startProcess(const QString & cmd) {
void AdvancedFm::processEnded(OProcess *) {
- populateView();
+ rePopulate();
}
@@ -776,5 +824,5 @@ void AdvancedFm::renameIt() {
oldName = thisView->currentItem()->text(0);
doRename( thisView );
- populateView();
+ rePopulate();
}
@@ -795,5 +843,5 @@ void AdvancedFm::okRename() {
view->takeItem( view->currentItem() );
delete view->currentItem();
- populateView();
+ rePopulate();
}