summaryrefslogtreecommitdiff
path: root/noncore/apps
authorllornkcor <llornkcor>2003-11-07 12:37:57 (UTC)
committer llornkcor <llornkcor>2003-11-07 12:37:57 (UTC)
commitfa1e47631442d509e9c1603684bdc9e9590cf866 (patch) (side-by-side diff)
tree5411adf72ccde8c46b13b0487a2602609b081d9e /noncore/apps
parent82fdb639058354177d27b432f97e8750ac846ee6 (diff)
downloadopie-fa1e47631442d509e9c1603684bdc9e9590cf866.zip
opie-fa1e47631442d509e9c1603684bdc9e9590cf866.tar.gz
opie-fa1e47631442d509e9c1603684bdc9e9590cf866.tar.bz2
from 1.0, needs fix
Diffstat (limited to 'noncore/apps') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp7
-rw-r--r--noncore/apps/advancedfm/advancedfm.h4
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp62
3 files changed, 63 insertions, 10 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 2fc4b49..ecf471d 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -93,29 +93,32 @@ void AdvancedFm::tabChanged(QWidget *) {
viewMenu->setItemChecked(viewMenu->idAt(1), true);
}
QString fs= getFileSystemType( (const QString &) path);
setCaption(tr("AdvancedFm :: ")+fs+" :: "
+checkDiskSpace( (const QString &) path )+ tr(" kB free") );
chdir( path.latin1());
}
void AdvancedFm::populateView() {
+
+qWarning("PopulateView");
QPixmap pm;
QListView *thisView = CurrentView();
QDir *thisDir = CurrentDir();
QString path = thisDir->canonicalPath();
-// qWarning("path is "+path);
+
+qWarning("path is "+path);
thisView->clear();
thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
thisDir->setMatchAllDirs(TRUE);
thisDir->setNameFilter(filterStr);
QString fileL, fileS, fileDate;
QString fs= getFileSystemType((const QString &) path);
setCaption(tr("AdvancedFm :: ")+fs+" :: "
+checkDiskSpace((const QString &) path)+ tr(" kB free") );
bool isDir=FALSE;
const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
QFileInfoListIterator it(*list);
QFileInfo *fi;
@@ -800,25 +803,25 @@ QListView * AdvancedFm::CurrentView() {
return Remote_View;
}
}
QListView * AdvancedFm::OtherView() {
if ( whichTab == 1)
return Remote_View;
else
return Local_View;
}
void AdvancedFm::setOtherTabCurrent() {
-// qWarning("setOtherTabCurrent()");
+ qWarning("setOtherTabCurrent() %d", whichTab);
if ( whichTab == 1) {
TabWidget->setCurrentWidget(1);
} else {
TabWidget->setCurrentWidget(0);
}
OtherView()->setFocus();
OtherView()->setSelected( CurrentView()->firstChild(), true);
}
void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) {
// qDebug("qcop message "+msg );
QDataStream stream ( data, IO_ReadOnly );
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
index 5f6eabb..be574c4 100644
--- a/noncore/apps/advancedfm/advancedfm.h
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -145,25 +145,27 @@ protected slots:
void currentPathComboChanged();
void copy();
void copyAs();
void copySameDir();
void currentPathComboActivated(const QString &);
void fillCombo(const QString &);
bool copyFile( const QString & , const QString & );
void move();
void fileStatus();
void doAbout();
void doBeam();
void fileBeamFinished( Ir *);
-
+ bool copyDirectory( const QString & , const QString & );
+// void navigateToSelected();
+ bool moveDirectory( const QString & , const QString & );
// void slotSwitchtoLocal(int);
private:
MenuButton *menuButton;
QString oldName;
QTimer menuTimer;
void startProcess(const QString &);
bool eventFilter( QObject * , QEvent * );
void cancelRename();
void doRename(QListView *);
void okRename();
void customDirsToMenu();
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
@@ -59,37 +59,37 @@ void AdvancedFm::doDirChange() {
}
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);
}
- rePopulate();
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);
}
- rePopulate();
+ 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();
@@ -330,26 +330,26 @@ void AdvancedFm::copy() {
break;
};
}
f.remove();
}
if( !copyFile( curFile, destFile) ) {
QMessageBox::message("AdvancedFm",
tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) );
return;
}
}
- rePopulate();
setOtherTabCurrent();
+ rePopulate();
}
}
void AdvancedFm::copyAs() {
qApp->processEvents();
QStringList curFileList = getPath();
QString curFile, item;
InputDialog *fileDlg;
QDir *thisDir = CurrentDir();
QDir *thatDir = OtherDir();
@@ -429,25 +429,25 @@ void AdvancedFm::copySameDir() {
};
}
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;
}
- populateView();
+ 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 ) {
@@ -456,40 +456,88 @@ void AdvancedFm::move() {
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;
@@ -678,25 +726,25 @@ void AdvancedFm::startProcess(const QString & cmd) {
connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)),
this, SLOT( oprocessStderr(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 *) {
- populateView();
+ 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 ) {
@@ -766,37 +814,37 @@ void AdvancedFm::doRename(QListView * view) {
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 );
- populateView();
+ rePopulate();
}
void AdvancedFm::okRename() {
if( !CurrentView()->currentItem()) 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 = "";
view->takeItem( view->currentItem() );
delete view->currentItem();
- populateView();
+ rePopulate();
}
void AdvancedFm::openSearch() {
QMessageBox::message(tr("Note"),tr("Not Yet Implemented"));
}