summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp345
-rw-r--r--noncore/apps/advancedfm/advancedfm.h7
-rw-r--r--noncore/apps/advancedfm/advancedfmData.cpp30
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp317
-rw-r--r--noncore/apps/advancedfm/filePermissions.cpp2
5 files changed, 300 insertions, 401 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
index 91318f1..2fc4b49 100644
--- a/noncore/apps/advancedfm/advancedfm.cpp
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -35,16 +35,18 @@
#include <qlistview.h>
#include <qlabel.h>
#include <qwidget.h>
#include <qlayout.h>
#include <qimage.h>
#include <qmessagebox.h>
#include <qlineedit.h>
+#include <qpe/qpemessagebox.h>
+
#include <sys/stat.h>
#include <time.h>
#include <dirent.h>
#include <fcntl.h>
#include <sys/vfs.h>
#include <mntent.h>
AdvancedFm::AdvancedFm( )
@@ -62,82 +64,79 @@ AdvancedFm::AdvancedFm( )
connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
this, SLOT( qcopReceive(const QCString&, const QByteArray&)) );
}
AdvancedFm::~AdvancedFm() {
}
-void AdvancedFm::cleanUp()
-{
+void AdvancedFm::cleanUp() {
QString sfile=QDir::homeDirPath();
if(sfile.right(1) != "/")
sfile+="/._temp";
else
sfile+="._temp";
QFile file( sfile);
if(file.exists())
file.remove();
}
-void AdvancedFm::tabChanged(QWidget *w)
-{
- if( w == tab)
- whichTab = 1;
- else
- whichTab = 2;
-
-// qDebug("tab changed %d", whichTab );
-
+void AdvancedFm::tabChanged(QWidget *) {
+// qWarning("tab changed");
QString path = CurrentDir()->canonicalPath();
currentPathCombo->lineEdit()->setText( path );
- viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
- viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
+ if(whichTab == 1) {
+ viewMenu->setItemChecked(viewMenu->idAt(0), true);
+ viewMenu->setItemChecked(viewMenu->idAt(1), false);
+ } else {
+ viewMenu->setItemChecked(viewMenu->idAt(0), false);
+ viewMenu->setItemChecked(viewMenu->idAt(1), true);
+ }
QString fs= getFileSystemType( (const QString &) path);
- setCaption("AdvancedFm :: "+fs+" :: "
- +checkDiskSpace( (const QString &) path )+ " kB free" );
+ setCaption(tr("AdvancedFm :: ")+fs+" :: "
+ +checkDiskSpace( (const QString &) path )+ tr(" kB free") );
chdir( path.latin1());
}
-void AdvancedFm::populateView()
-{
+void AdvancedFm::populateView() {
QPixmap pm;
QListView *thisView = CurrentView();
QDir *thisDir = CurrentDir();
QString path = thisDir->canonicalPath();
-
+// 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("AdvancedFm :: "+fs+" :: "
- +checkDiskSpace((const QString &) path)+" kB free" );
+ 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;
while ( (fi=it.current()) ) {
if (fi->isSymLink() ) {
QString symLink=fi->readLink();
QFileInfo sym( symLink);
fileS.sprintf( "%10i", sym.size() );
fileL = fi->fileName() +" -> " + sym.filePath().data();
fileDate = sym.lastModified().toString();
} else {
fileS.sprintf( "%10i", fi->size() );
fileL = fi->fileName();
fileDate= fi->lastModified().toString();
if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) {
+// if(fileL == "..")
fileL+="/";
isDir=TRUE;
}
}
QFileInfo fileInfo( path + "/" + fileL);
if(fileL !="./" && fi->exists()) {
item = new QListViewItem( thisView, fileL, fileS , fileDate);
@@ -206,219 +205,210 @@ void AdvancedFm::populateView()
closedir(dir);
}
thisView->setSorting( 3,FALSE);
fillCombo( (const QString &) path );
}
-void AdvancedFm::rePopulate()
-{
- int tmpTab = whichTab;
- qDebug("%d", tmpTab);
-
- for(int i =1; i < 3; i++)
- {
- TabWidget->setCurrentWidget(i - 1);
+void AdvancedFm::rePopulate() {
populateView();
- }
- TabWidget->setCurrentWidget( tmpTab - 1);
+ setOtherTabCurrent();
+ populateView();
+
+// int tmpTab = whichTab;
+// // qDebug("%d", tmpTab);
+
+// for(int i =1; i < 3; i++) {
+// TabWidget->setCurrentWidget(i - 1);
+// populateView();
+// }
+// TabWidget->setCurrentWidget( tmpTab - 1);
}
-void AdvancedFm::ListClicked(QListViewItem *selectedItem)
-{
- if(selectedItem)
- {
+void AdvancedFm::ListClicked(QListViewItem *selectedItem) {
+//qWarning("listclicked");
+ if(selectedItem) {
QString strItem=selectedItem->text(0);
+// qWarning(strItem);
QString strSize=selectedItem->text(1);
strSize=strSize.stripWhiteSpace();
bool isDirectory = false;
QString strItem2;
- if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink
- {
+ if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink
strItem2 = dealWithSymName((const QString&)strItem);
if(QDir(strItem2).exists() )
strItem = strItem2;
}
- if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 )
- {
+ if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
if(QDir(strItem).exists())
isDirectory = true;
}
- if( isDirectory )
- {
+ if( isDirectory ) {
CurrentDir()->cd( strItem, TRUE);
populateView();
CurrentView()->ensureItemVisible( CurrentView()->firstChild());
}
chdir( strItem.latin1());
}
}
-void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) {
+void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) {
+ dealWithSchmooSchmaa( item->listView());
switch (mouse) {
case 1:
{
- if(renameBox != 0 )
- {
+ if(renameBox != 0 ) {
cancelRename();
}
}
break;
case 2:
menuTimer.start( 500, TRUE );
break;
};
}
-void AdvancedFm::switchToLocalTab()
-{
+
+void AdvancedFm::switchToLocalTab() {
+//qWarning("switch to local view");
TabWidget->setCurrentWidget(0);
Local_View->setFocus();
}
-void AdvancedFm::switchToRemoteTab()
-{
+void AdvancedFm::switchToRemoteTab() {
+//qWarning("switch to local view");
TabWidget->setCurrentWidget(1);
Remote_View->setFocus();
}
-void AdvancedFm::readConfig()
-{
+void AdvancedFm::readConfig() {
Config cfg("AdvancedFm");
}
-void AdvancedFm::writeConfig()
-{
+void AdvancedFm::writeConfig() {
Config cfg("AdvancedFm");
}
-void AdvancedFm::currentPathComboChanged()
-{
- if(QDir( currentPathCombo->lineEdit()->text()).exists())
- {
+void AdvancedFm::currentPathComboChanged() {
+ if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
CurrentDir()->setPath( currentPathCombo->lineEdit()->text() );
populateView();
- }
- else
- {
+ } else {
QMessageBox::message(tr("Note"),tr("That directory does not exist"));
}
}
-void AdvancedFm::fillCombo(const QString &currentPath)
-{
-// qDebug("%d",TabWidget->currentTab());
- if ( whichTab == 1)
- {
+void AdvancedFm::fillCombo(const QString &currentPath) {
+
+ if ( whichTab == 1) {
currentPathCombo->lineEdit()->setText( currentPath);
- if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() )
- {
+ if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
currentPathCombo->clear();
localDirPathStringList.prepend( currentPath );
currentPathCombo->insertStringList( localDirPathStringList,-1);
}
- }
- else
- {
+ } else {
currentPathCombo->lineEdit()->setText( currentPath);
- if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() )
- {
+ if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
currentPathCombo->clear();
remoteDirPathStringList.prepend( currentPath );
currentPathCombo->insertStringList( remoteDirPathStringList,-1);
}
}
}
-void AdvancedFm::currentPathComboActivated(const QString & currentPath)
-{
+void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
chdir( currentPath.latin1() );
CurrentDir()->cd( currentPath, TRUE);
populateView();
update();
}
-QStringList AdvancedFm::getPath()
-{
+QStringList AdvancedFm::getPath() {
QStringList strList;
QListView *thisView=CurrentView();
QList<QListViewItem> * getSelectedItems( QListView * thisView );
QListViewItemIterator it( thisView );
- for ( ; it.current(); ++it )
- {
- if ( it.current()->isSelected() )
- {
+ for ( ; it.current(); ++it ) {
+ if ( it.current()->isSelected() ) {
strList << it.current()->text(0);
// qDebug(it.current()->text(0));
}
}
return strList;
}
-void AdvancedFm::homeButtonPushed()
-{
+void AdvancedFm::homeButtonPushed() {
QString current = QDir::homeDirPath();
chdir( current.latin1() );
CurrentDir()->cd( current, TRUE);
populateView();
update();
}
-void AdvancedFm::docButtonPushed()
-{
+void AdvancedFm::docButtonPushed() {
QString current = QPEApplication::documentDir();
chdir( current.latin1() );
CurrentDir()->cd( current, TRUE);
populateView();
update();
}
-void AdvancedFm::SDButtonPushed()
-{
+void AdvancedFm::SDButtonPushed() {
QString current = "/mnt/card";// this can change so fix
chdir( current.latin1() );
CurrentDir()->cd( current, TRUE);
populateView();
update();
}
-void AdvancedFm::CFButtonPushed()
-{
+void AdvancedFm::CFButtonPushed() {
QString current;
if(zaurusDevice)
current= "/mnt/cf"; //zaurus
else
current = "/mnt/hda"; //ipaq
chdir( current.latin1() );
CurrentDir()->cd( current, TRUE);
populateView();
update();
}
-void AdvancedFm::doAbout()
-{
+void AdvancedFm::doAbout() {
QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n"
"is copyright 2002-2003 by\n"
"L.J.Potter<llornkcor@handhelds.org>\n"
"and is licensed by the GPL"));
}
-void AdvancedFm::keyPressEvent( QKeyEvent *e)
-{
-// e->accept();
- if( CurrentView()->hasFocus() )
+void AdvancedFm::keyPressEvent( QKeyEvent *e) {
+// qWarning("key %d", e->key());
+// if( CurrentView()->hasFocus() )
{
switch ( e->key() ) {
+ case Key_Left:
+ upDir();
+ break;
+ case Key_Next:
+ break;
+ case Key_Return:
+ case Key_Enter:
+ navigateToSelected();
+ break;
+ case Key_Tab: {
+ setOtherTabCurrent();
+ }
+ break;
case Key_Delete:
del();
break;
case Key_A:
copyAs();
break;
case Key_C:
copy();
@@ -479,79 +469,71 @@ void AdvancedFm::keyPressEvent( QKeyEvent *e)
break;
case Key_0:
break;
};
e->accept();
}
}
-void AdvancedFm::keyReleaseEvent( QKeyEvent *e)
-{
+void AdvancedFm::keyReleaseEvent( QKeyEvent *e) {
if( CurrentView()->hasFocus() )
e->ignore();
}
-void AdvancedFm::QPEButtonPushed()
-{
+void AdvancedFm::QPEButtonPushed() {
QString current = QPEApplication::qpeDir();
chdir( current.latin1() );
CurrentDir()->cd( current, TRUE);
populateView();
update();
}
-void AdvancedFm::parsetab(const QString &fileName)
-{
+void AdvancedFm::parsetab(const QString &fileName) {
fileSystemTypeList.clear();
fsList.clear();
struct mntent *me;
FILE *mntfp = setmntent( fileName.latin1(), "r" );
- if ( mntfp )
- {
- while ( (me = getmntent( mntfp )) != 0 )
- {
+ 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(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;
fileSystemTypeList << mountDir+"::"+filesystemType;
}
}
}
endmntent( mntfp );
}
-QString AdvancedFm::getFileSystemType(const QString &currentText)
-{
+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;
}
-QString AdvancedFm::getDiskSpace( const QString &path)
-{
+QString AdvancedFm::getDiskSpace( const QString &path) {
struct statfs fss;
if ( !statfs( path.latin1(), &fss ) ) {
int blkSize = fss.f_bsize;
// int totalBlks = fs.f_blocks;
int availBlks = fss.f_bavail;
long mult = blkSize / 1024;
long div = 1024 / blkSize;
@@ -559,36 +541,32 @@ QString AdvancedFm::getDiskSpace( const QString &path)
if ( !div ) div = 1;
return QString::number(availBlks * mult / div);
}
return "";
}
-void AdvancedFm::showFileMenu()
-{
+void AdvancedFm::showFileMenu() {
QString curApp;
curApp = CurrentView()->currentItem()->text(0);
MimeType mt( curApp );
const AppLnk* app = mt.application();
QFile fi(curApp);
QPopupMenu *m = new QPopupMenu(0);
QPopupMenu *n = new QPopupMenu(0);
// QPopupMenu *o = new QPopupMenu(0);
m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
- if ( QFileInfo(fi).isDir() )
- {
+ if ( QFileInfo(fi).isDir() ) {
m->insertSeparator();
m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() ));
- }
- else
- {
+ } else {
if ( app )
m->insertItem( app->pixmap(), tr( "Open in "
+ app->name() ), this, SLOT( runThis() ) );
else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this
m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) );
m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) );
}
@@ -629,45 +607,41 @@ void AdvancedFm::showFileMenu()
m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() ));
m->setFocus();
m->exec( QPoint( 4,QCursor::pos().y()) );
if(m) delete m;
}
-void AdvancedFm::cancelMenuTimer()
-{
-// qDebug("selectionChanged: cancel menu timer");
+void AdvancedFm::cancelMenuTimer() {
+
if( menuTimer.isActive() )
menuTimer.stop();
}
-QString AdvancedFm::checkDiskSpace(const QString &path)
-{
+QString AdvancedFm::checkDiskSpace(const QString &path) {
struct statfs fss;
- if ( !statfs( path.latin1(), &fss ) )
- {
+ if ( !statfs( path.latin1(), &fss ) ) {
int blkSize = fss.f_bsize;
// int totalBlks = fs.f_blocks;
int availBlks = fss.f_bavail;
long mult = blkSize / 1024;
long div = 1024 / blkSize;
if ( !mult ) mult = 1;
if ( !div ) div = 1;
return QString::number(availBlks * mult / div);
}
return "";
}
-void AdvancedFm::addToDocs()
-{
+void AdvancedFm::addToDocs() {
QStringList strListPaths = getPath();
QDir *thisDir = CurrentDir();
if( strListPaths.count() > 0) {
QString curFile;
for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) {
curFile = thisDir->canonicalPath()+"/"+(*it);
// qDebug(curFile);
@@ -677,34 +651,31 @@ void AdvancedFm::addToDocs()
f.setName(fi.baseName() );
f.setFile( curFile);
f.writeLink();
}
}
}
-void AdvancedFm::customDirsToMenu()
-{
+void AdvancedFm::customDirsToMenu() {
Config cfg("AdvancedFm");
cfg.setGroup("Menu");
QStringList list = cfg.readListEntry( "CustomDir", ',');
menuButton->insertItems(list );
// for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
// {
// customDirMenu->insertItem(*it );
// }
}
-void AdvancedFm::dirMenuSelected(int item)
-{
- qDebug("menu item %d", item);
+void AdvancedFm::dirMenuSelected(int item) {
switch(item)
{
case -21:
case 0:
addCustomDir();
break;
case -22:
@@ -716,180 +687,161 @@ void AdvancedFm::dirMenuSelected(int item)
// gotoCustomDir( menuButton->text(item));
// gotoCustomDir( customDirMenu->text(item));
}
break;
};
}
-void AdvancedFm::addCustomDir()
-{
+void AdvancedFm::addCustomDir() {
Config cfg("AdvancedFm");
cfg.setGroup("Menu");
QString dir;
QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
dir = CurrentDir()->canonicalPath();
bool addIt=true;
- for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
- {
- if( dir == (*it))
- {
+ for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
+ if( dir == (*it)) {
addIt=false;
}
}
- if(addIt)
- {
+ if(addIt) {
menuButton->insertItem(dir);
// customDirMenu->insertItem(dir);
list << dir;
}
cfg.writeEntry("CustomDir", list, ',');
cfg.write();
}
-void AdvancedFm::removeCustomDir()
-{
+void AdvancedFm::removeCustomDir() {
// qDebug("remove custom dir");
Config cfg("AdvancedFm");
cfg.setGroup("Menu");
QString dir;
QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)',');
QStringList list2;
dir = CurrentDir()->canonicalPath();
int ramble=2;
// int ramble=-24;
//first remove list
- if(list.grep(dir,true).isEmpty())
- {
+ if(list.grep(dir,true).isEmpty()) {
QMessageBox::message(tr( "AdvancedFm" ),
tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!"));
- }
- else
- {
- for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
- {
- if((*it) != dir)//current item is not our current dir, so add it to temp list
- {
+ } else {
+ for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
+ if((*it) != dir) {
+//current item is not our current dir, so add it to temp list
list2 <<(*it);
- }
- else
- {
+ } else {
// customDirMenu->removeItem( ramble);
menuButton->remove( ramble);
}
ramble++;
// ramble--;
}
cfg.writeEntry("CustomDir", list2, ',');
cfg.write();
}
// customDirsToMenu();
}
-void AdvancedFm::gotoCustomDir(const QString &dir)
-{
+void AdvancedFm::gotoCustomDir(const QString &dir) {
// qDebug("gotoCustomDir(const QString &dir) " +dir );
// QString curDir = dir;
// QDir *thisDir = CurrentDir();
// if( curDir.isEmpty()) {
// }
- if( dir == s_addBookmark)
- {
+ if( dir == s_addBookmark) {
addCustomDir();
}
- if( dir == s_removeBookmark)
- {
+ if( dir == s_removeBookmark) {
removeCustomDir( );
- }
- else
- {
+ } else {
gotoDirectory( dir);
// if(QDir( curDir).exists() )
// {
// thisDir->setPath( curDir );
// chdir( curDir.latin1() );
// thisDir->cd( curDir, TRUE);
// populateView();
// }
}
}
-QDir *AdvancedFm::CurrentDir()
-{
- if ( whichTab == 1)
- {
+QDir *AdvancedFm::CurrentDir() {
+
+ if ( whichTab == 1) {
return &currentDir;
- }
- else
- {
+ } else {
return &currentRemoteDir;
}
}
-QDir *AdvancedFm::OtherDir()
-{
- if ( whichTab == 1)
- {
+QDir *AdvancedFm::OtherDir() {
+ if ( whichTab == 1) {
return &currentRemoteDir;
- }
- else
- {
+ } else {
return &currentDir;
}
}
-QListView * AdvancedFm::CurrentView()
-{
- if ( whichTab == 1)
+QListView * AdvancedFm::CurrentView() {
+ if ( whichTab == 1) {
+// qWarning("CurrentView Tab 1");
return Local_View;
- else
+ } else {
+// qWarning("CurrentView Tab 2");
return Remote_View;
}
+}
-QListView * AdvancedFm::OtherView()
-{
+QListView * AdvancedFm::OtherView() {
if ( whichTab == 1)
return Remote_View;
else
return Local_View;
}
-void AdvancedFm::setOtherTabCurrent()
-{
- if ( whichTab == 1)
+void AdvancedFm::setOtherTabCurrent() {
+// qWarning("setOtherTabCurrent()");
+ if ( whichTab == 1) {
TabWidget->setCurrentWidget(1);
- else
+ } else {
TabWidget->setCurrentWidget(0);
}
+ OtherView()->setFocus();
+ OtherView()->setSelected( CurrentView()->firstChild(), true);
+}
void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) {
- qDebug("qcop message "+msg );
+// qDebug("qcop message "+msg );
QDataStream stream ( data, IO_ReadOnly );
if ( msg == "openDirectory(QString)" ) {
- qDebug("received");
+// qDebug("received");
QString file;
stream >> file;
gotoDirectory( (const QString &) file);
}
}
void AdvancedFm::setDocument(const QString &file) {
gotoDirectory( file);
}
void AdvancedFm::gotoDirectory(const QString &file) {
-
+// qWarning("goto dir "+file);
QString curDir = file;
QDir *thisDir = CurrentDir();
if(QDir( curDir).exists() ) {
thisDir->setPath( curDir );
chdir( curDir.latin1() );
thisDir->cd( curDir, TRUE);
populateView();
}
@@ -913,8 +865,27 @@ void AdvancedFm::findFile(const QString &fileName) {
QListViewItemIterator it( thisView );
for ( ; it.current(); ++it ) {
if(it.current()->text(0) == fi.fileName()) {
it.current()->setSelected(true);
thisView->ensureItemVisible(it.current());
}
}
}
+
+void AdvancedFm::slotSwitchMenu(int ) {
+// qDebug("Switch %d", item);
+ // viewMenu->setItemChecked(item, true);
+}
+
+void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) {
+ tabChanged( w);
+ if( w == Local_View) {
+ Remote_View->clearFocus();
+ } else {
+ Local_View->clearFocus();
+ }
+}
+
+void AdvancedFm::navigateToSelected() {
+ if( !CurrentView()->currentItem()) return;
+ doDirChange();
+}
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
index 5e2c769..5f6eabb 100644
--- a/noncore/apps/advancedfm/advancedfm.h
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -53,16 +53,17 @@ class Ir;
class AdvancedFm : public QMainWindow
{
Q_OBJECT
public:
AdvancedFm();
~AdvancedFm();
protected slots:
+ void slotSwitchMenu(int);
void selectAll();
void addToDocs();
void doDirChange();
void mkDir();
void del();
void rn();
void populateView();
void rePopulate();
@@ -123,18 +124,20 @@ protected:
void parsetab(const QString &fileName);
QString checkDiskSpace(const QString &);
QString dealWithSymName(const QString &);
QDir *CurrentDir();
QDir *OtherDir();
QListView *CurrentView();
QListView *OtherView();
void setOtherTabCurrent();
+ void dealWithSchmooSchmaa(QWidget *);
protected slots:
+ void openSearch();
void dirMenuSelected(int);
void showFileMenu();
void cancelMenuTimer();
void homeButtonPushed();
void docButtonPushed();
void SDButtonPushed();
void CFButtonPushed();
void QPEButtonPushed();
@@ -147,30 +150,32 @@ protected slots:
void fillCombo(const QString &);
bool copyFile( const QString & , const QString & );
void move();
void fileStatus();
void doAbout();
void doBeam();
void fileBeamFinished( Ir *);
+// 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();
void addCustomDir();
void removeCustomDir();
void gotoDirectory(const QString &);
- void openSearch();
+ void navigateToSelected();
void findFile(const QString &);
private slots:
void processEnded(OProcess *);
void oprocessStderr(OProcess *, char *, int);
void gotoCustomDir(const QString &);
void qcopReceive(const QCString&, const QByteArray&);
void setDocument(const QString &);
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp
index 463b202..ddaa39a 100644
--- a/noncore/apps/advancedfm/advancedfmData.cpp
+++ b/noncore/apps/advancedfm/advancedfmData.cpp
@@ -93,21 +93,23 @@ void AdvancedFm::init() {
fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() ));
fileMenu->insertSeparator();
fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() ));
fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() ));
fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() ));
fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() ));
fileMenu->setCheckable(TRUE);
- viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() ));
- viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() ));
+ viewMenu->insertItem( tr( "Switch to View 1" ), this, SLOT( switchToLocalTab()));
+ viewMenu->insertItem( tr( "Switch to View 2" ), this, SLOT( switchToRemoteTab()));
// viewMenu->insertSeparator();
// viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() ));
- viewMenu->setCheckable(TRUE);
+ viewMenu->setCheckable(true);
+ viewMenu->setItemChecked( viewMenu->idAt(0), true);
+ viewMenu->setItemChecked( viewMenu->idAt(1), false);
s_addBookmark = tr("Bookmark Directory");
s_removeBookmark = tr("Remove Current Directory from Bookmarks");
// menuButton->insertItem("");
// customDirMenu->insertItem(tr("Add This Directory"));
// customDirMenu->insertItem(tr("Remove This Directory"));
@@ -115,23 +117,24 @@ void AdvancedFm::init() {
menuButton = new MenuButton( lineBox );
menuButton->setUseLabel(false);
menuButton->setMaximumWidth( 20 );
menuButton->insertItem( s_addBookmark);
menuButton->insertItem( s_removeBookmark);
menuButton->insertSeparator();
+ menuButton->setFocusPolicy(NoFocus);
customDirsToMenu();
currentPathCombo = new QComboBox( FALSE, lineBox, "currentPathCombo" );
currentPathCombo->setEditable(TRUE);
currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
-
+ currentPathCombo->setFocusPolicy(NoFocus);
layout->addWidget( lineBox );
TabWidget = new OSplitter( Horizontal, this, "TabWidget" );
// TabWidget = new QTabWidget( this, "TabWidget" );
layout->addWidget( TabWidget, 4 );
tab = new QWidget( TabWidget, "tab" );
@@ -143,16 +146,18 @@ void AdvancedFm::init() {
Local_View->addColumn( tr("File"),130);
Local_View->addColumn( tr("Size"),-1);
Local_View->setColumnAlignment(1,QListView::AlignRight);
Local_View->addColumn( tr("Date"),-1);
Local_View->setColumnAlignment(2,QListView::AlignRight);
Local_View->setAllColumnsShowFocus(TRUE);
Local_View->setMultiSelection( TRUE );
Local_View->setSelectionMode(QListView::Extended);
+ Local_View->setFocusPolicy(StrongFocus);
+ Local_View->installEventFilter( this );
QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
tabLayout->addWidget( Local_View, 0, 0 );
TabWidget->addWidget( tab,"advancedfm/smFileBrowser.png", tr("1"));
// TabWidget->insertTab( tab, tr("1"));
@@ -165,17 +170,18 @@ void AdvancedFm::init() {
Remote_View->addColumn( tr("File"),130);
Remote_View->addColumn( tr("Size"),-1);
Remote_View->setColumnAlignment(1,QListView::AlignRight);
Remote_View->addColumn( tr("Date"),-1);
Remote_View->setColumnAlignment(2,QListView::AlignRight);
Remote_View->setAllColumnsShowFocus(TRUE);
Remote_View->setMultiSelection( TRUE );
Remote_View->setSelectionMode(QListView::Extended);
-
+ Remote_View->setFocusPolicy(StrongFocus);
+ Remote_View->installEventFilter( this );
QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
tabLayout_2->addWidget( Remote_View, 0, 0 );
TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2"));
TabWidget->setSizeChange( 370 );
// TabWidget->insertTab( tab_2, tr( "2"));
@@ -198,26 +204,21 @@ void AdvancedFm::init() {
tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 );
TabWidget->insertTab( tab_3, tr( "Remote" ) );
*/
///////////////
-
- struct utsname name; /* check for embedix kernel running on the zaurus*/
- if (uname(&name) != -1) {
- QString release=name.release;
- if(release.find("embedix",0,TRUE) !=-1) {
+ if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
zaurusDevice=TRUE;
- } else {
+ else
zaurusDevice=FALSE;
- }
- }
+
if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) {
qDebug("not have sd");
sdButton->hide();
}
if( !StorageInfo::hasCf() ) {
qDebug("not have cf");
cfButton->hide();
@@ -275,12 +276,13 @@ void AdvancedFm::initConnections()
connect( TabWidget,SIGNAL(currentChanged(QWidget *)),
this,SLOT(tabChanged(QWidget*)));
connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) );
connect( menuButton, SIGNAL( selected(const QString &)), SLOT(gotoCustomDir(const QString&)));
// connect( menuButton, SIGNAL( selected( int)), SLOT( dirMenuSelected(int)));
-
+ connect( viewMenu, SIGNAL( activated(int )), this, SLOT(slotSwitchMenu(int )));
// connect( customDirMenu, SIGNAL( activated(int)), this, SLOT( dirMenuSelected(int)));
}
+
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 544350c..c0be948 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -41,141 +41,120 @@
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <dirent.h>
#include <sys/sendfile.h>
#include <fcntl.h>
-void AdvancedFm::doDirChange()
-{
+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)
- {
+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);
-// b=FALSE;
-
- }
- else
- {
+ } 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=TRUE;
}
rePopulate();
-// if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true");
b = !b;
}
-void AdvancedFm::showHidden()
-{
- if (b)
- {
+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);
-// fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
-// b=FALSE;
-
- }
- else
- {
+ } 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=TRUE;
}
rePopulate();
}
-QString AdvancedFm::dealWithSymName(const QString &fileName)
-{
+QString AdvancedFm::dealWithSymName(const QString &fileName) {
QString strItem = fileName;
return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
}
-void AdvancedFm::runThis()
-{
+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 != "../")
- {
+ if(curFile != "../") {
fs = getFileSystemType((const QString &) path);
QFileInfo fileInfo( path + "/" + curFile);
- qDebug( fileInfo.owner());
+// 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
- {
+ } else {
curFile = path + "/" + curFile;
DocLnk nf(curFile);
QString execStr = nf.exec();
- qDebug( execStr);
- if( execStr.isEmpty() )
- {
- }
- else
- {
+// qDebug( execStr);
+ if( execStr.isEmpty() ) {
+ } else {
nf.execute();
}
}
}
}
-void AdvancedFm::runText()
-{
+void AdvancedFm::runText() {
+ if( !CurrentView()->currentItem()) return;
QString curFile = CurrentView()->currentItem()->text(0);
- if(curFile != "../")
- {
+ 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()
-{
+void AdvancedFm::makeDir() {
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
fileDlg->exec();
- if( fileDlg->result() == 1 )
- {
+ if( fileDlg->result() == 1 ) {
QDir *thisDir = CurrentDir();
QString filename = fileDlg->LineEdit1->text();
thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
}
populateView();
}
-void AdvancedFm::doDelete()
-{
+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
@@ -230,91 +209,85 @@ void AdvancedFm::doDelete()
break;
};
}
QString cmd="rm "+f;
QFile file(f);
QFileInfo fi(myFile);
if( fi.fileName().find("../",0,TRUE)==-1) {
- qDebug("remove link files "+myFile);
+// qDebug("remove link files "+myFile);
// DocLnk lnk(f);
DocLnk *lnk;
lnk = new DocLnk(f);
- qDebug("Deleting doclnk " + lnk->linkFile());
+// qDebug("Deleting doclnk " + lnk->linkFile());
if(lnk->isValid())
lnk->removeLinkFile();
// delete lnk;
file.remove();
}
}
}
}
populateView();
}
-void AdvancedFm::filePerms()
-{
+void AdvancedFm::filePerms() {
QStringList curFileList = getPath();
QString filePath;
filePath = CurrentDir()->canonicalPath()+"/";
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
- {
+ for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
filePermissions *filePerm;
filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
filePerm->showMaximized();
filePerm->exec();
if( filePerm)
delete filePerm;
}
populateView();
}
-void AdvancedFm::doProperties()
-{
+void AdvancedFm::doProperties() {
#if defined(QT_QWS_OPIE)
QStringList curFileList = getPath();
QString filePath;
filePath = CurrentDir()->canonicalPath()+"/";
- qDebug("%d",curFileList.count());
+// qDebug("%d",curFileList.count());
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
- {
- qDebug((filePath+*it));
+ for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
+// qDebug((filePath+*it));
DocLnk lnk( (filePath+*it));
LnkProperties prop( &lnk );
prop.showMaximized();
prop.exec();
}
#endif
}
-void AdvancedFm::upDir()
-{
+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()
-{
+void AdvancedFm::copy() {
qApp->processEvents();
QStringList curFileList = getPath();
QDir *thisDir = CurrentDir();
QDir *thatDir = OtherDir();
bool doMsg=true;
int count=curFileList.count();
@@ -330,89 +303,80 @@ void AdvancedFm::copy()
break;
case 1:
return;
break;
};
}
QString curFile, item, destFile;
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
- {
+ 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);
+// qDebug("Destination file is "+destFile);
+// qDebug("CurrentFile file is " + curFile);
QFile f(destFile);
- if( f.exists())
- {
- if(doMsg)
- {
+ 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) )
- {
+ 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;
}
}
+ rePopulate();
setOtherTabCurrent();
- populateView();
}
}
-void AdvancedFm::copyAs()
-{
+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 )
- {
+ 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 )
- {
+ if( fileDlg->result() == 1 ) {
QString filename = fileDlg->LineEdit1->text();
destFile = thatDir->canonicalPath()+"/"+filename;
QFile f( destFile);
- if( f.exists())
- {
+ if( f.exists()) {
switch (QMessageBox::warning(this,tr("File Exists!"),
item+tr("\nexists. Ok to overwrite?"),
- tr("Yes"),tr("No"),0,0,1) )
- {
+ tr("Yes"),tr("No"),0,0,1) ) {
case 0:
f.remove();
break;
case 1:
return;
break;
};
}
@@ -420,47 +384,43 @@ void AdvancedFm::copyAs()
QMessageBox::message("AdvancedFm",tr("Could not copy\n")
+curFile +tr("to\n")+destFile);
return;
}
}
delete fileDlg;
}
+ rePopulate();
setOtherTabCurrent();
- populateView();
}
-void AdvancedFm::copySameDir()
-{
+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 )
- {
+ 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 )
- {
+ if( fileDlg->result() == 1 ) {
QString filename = fileDlg->LineEdit1->text();
destFile = thisDir->canonicalPath()+"/"+filename;
QFile f(destFile);
- if( f.exists())
- {
+ 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:
@@ -469,101 +429,96 @@ 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);
+// qDebug("copy "+curFile+" as "+destFile);
}
delete fileDlg;
}
populateView();
}
-void AdvancedFm::move()
-{
+void AdvancedFm::move() {
qApp->processEvents();
QStringList curFileList = getPath();
- if( curFileList.count() > 0)
- {
+ if( curFileList.count() > 0) {
QString curFile, destFile, item;
QDir *thisDir = CurrentDir();
QDir *thatDir = OtherDir();
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
- {
+ 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);
+// qDebug("Destination file is "+destFile);
curFile = thisDir->canonicalPath();
if(curFile.right(1).find("/",0,TRUE) == -1)
curFile +="/";
curFile+= item;
- qDebug("CurrentFile file is " + curFile);
+// qDebug("CurrentFile file is " + curFile);
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);
}
}
}
- populateView();
+ rePopulate();
setOtherTabCurrent();
- populateView();
}
-bool AdvancedFm::copyFile( const QString & src, const QString & dest )
-{
+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;
int write_fd=0;
struct stat stat_buf;
off_t offset = 0;
if(!srcFile.open( IO_ReadOnly|IO_Raw)) {
- qWarning("open failed");
+// 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");
+// 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);
+// qWarning(msg);
}
} else {
success = false;
}
} else {
success = false;
}
srcFile.close();
@@ -571,135 +526,124 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest )
// Set file permissions
if( stat( (const char *) src, &status ) == 0 ) {
chmod( (const char *) dest, status.st_mode );
}
return success;
}
-void AdvancedFm::runCommand()
-{
+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());
+ 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);
outDlg->showMaximized();
outDlg->exec();
qApp->processEvents();
}
}
-void AdvancedFm::runCommandStd()
-{
+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 )
- {
+ if( fileDlg->result() == 1 ) {
qApp->processEvents();
startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
}
}
-void AdvancedFm::fileStatus()
-{
+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);
outDlg->showMaximized();
outDlg->exec();
qApp->processEvents();
}
-void AdvancedFm::mkDir()
-{
+void AdvancedFm::mkDir() {
makeDir();
}
-void AdvancedFm::rn()
-{
+void AdvancedFm::rn() {
renameIt();
}
-void AdvancedFm::del()
-{
+void AdvancedFm::del() {
doDelete();
}
-void AdvancedFm::mkSym()
-{
+void AdvancedFm::mkSym() {
QString cmd;
QStringList curFileList = getPath();
- if( curFileList.count() > 0)
- {
+ if( curFileList.count() > 0) {
QDir *thisDir = CurrentDir();
QDir * thatDir = OtherDir();
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
- {
+ for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
QString destName = thatDir->canonicalPath()+"/"+(*it);
- if(destName.right(1) == "/")
- {
+ if(destName.right(1) == "/") {
destName = destName.left( destName.length() -1);
}
QString curFile = thisDir->canonicalPath()+"/"+(*it);
- if( curFile.right(1) == "/")
- {
+ if( curFile.right(1) == "/") {
curFile = curFile.left( curFile.length() -1);
}
cmd = "ln -s "+curFile+" "+destName;
- qDebug(cmd);
+// qDebug(cmd);
startProcess( (const QString)cmd );
}
+ rePopulate();
setOtherTabCurrent();
- populateView();
}
}
-void AdvancedFm::doBeam()
-{
+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;
@@ -709,35 +653,27 @@ void AdvancedFm::doBeam()
Ir *file = new Ir(this, "IR");
connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
file->send( curFilePath, curFile );
}
}
}
}
-void AdvancedFm::fileBeamFinished( Ir *)
-{
+void AdvancedFm::fileBeamFinished( Ir *) {
QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
}
-void AdvancedFm::selectAll()
-{
-// if (TabWidget->currentTab() == 0) {
+void AdvancedFm::selectAll() {
QListView *thisView = CurrentView();
thisView->selectAll(true);
thisView->setSelected( thisView->firstChild(),false);
-// } else {
-// Remote_View->selectAll(true);
-// Remote_View->setSelected( Remote_View->firstChild(),false);
-// }
}
-void AdvancedFm::startProcess(const QString & cmd)
-{
+void AdvancedFm::startProcess(const QString & cmd) {
QStringList command;
OProcess *process;
process = new OProcess();
connect(process, SIGNAL(processExited(OProcess *)),
this, SLOT( processEnded(OProcess *)));
connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)),
this, SLOT( oprocessStderr(OProcess *, char *, int)));
@@ -745,89 +681,78 @@ void AdvancedFm::startProcess(const QString & cmd)
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 *)
-{
-// populateLocalView();
+void AdvancedFm::processEnded(OProcess *) {
populateView();
}
-void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int buflen) {
- qWarning("received stderrt %d bytes", buflen);
+void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) {
+// qWarning("received stderrt %d bytes", buflen);
QString lineStr = buffer;
-// lineStr=lineStr.left(lineStr.length()-1);
QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") );
-
-// OutputEdit->append(lineStr);
-// OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
}
-bool AdvancedFm::eventFilter( QObject * o, QEvent * e )
-{
- if ( o->inherits( "QLineEdit" ) )
- {
- if ( e->type() == QEvent::KeyPress )
- {
+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 )
- {
+ ke->key() == Key_Enter ) {
okRename();
return true;
}
- else if ( ke->key() == Key_Escape )
- {
+ else if ( ke->key() == Key_Escape ) {
cancelRename();
return true;
}
}
- else if ( e->type() == QEvent::FocusOut )
- {
+ else if ( e->type() == QEvent::FocusOut ) {
cancelRename();
return true;
}
}
- if ( o->inherits( "QListView" ) )
- {
- if ( e->type() == QEvent::FocusOut )
- {
- printf("focusIn\n");
-
+ 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");
+void AdvancedFm::cancelRename() {
+// qDebug("cancel rename");
QListView * view;
view = CurrentView();
bool resetFocus = view->viewport()->focusProxy() == renameBox;
delete renameBox;
renameBox = 0;
- if ( resetFocus )
- {
+ if ( resetFocus ) {
view->viewport()->setFocusProxy( view);
view->setFocus();
}
}
-void AdvancedFm::doRename(QListView * view)
-{
+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" );
@@ -837,45 +762,41 @@ void AdvancedFm::doRename(QListView * view)
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()
-{
+void AdvancedFm::renameIt() {
+ if( !CurrentView()->currentItem()) return;
QListView *thisView = CurrentView();
oldName = thisView->currentItem()->text(0);
doRename( thisView );
populateView();
}
-void AdvancedFm::okRename()
-{
+void AdvancedFm::okRename() {
+ if( !CurrentView()->currentItem()) return;
QString newName = renameBox->text();
cancelRename();
-// int tabs=0;
QListView * view = CurrentView();
QString path = CurrentDir()->canonicalPath() + "/";
oldName = path + oldName;
newName = path + newName;
- if( view->currentItem() == NULL)
- return;
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();
}
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 4de6d12..9698de7 100644
--- a/noncore/apps/advancedfm/filePermissions.cpp
+++ b/noncore/apps/advancedfm/filePermissions.cpp
@@ -26,17 +26,17 @@
#include <sys/types.h>
#include <pwd.h>
#include <grp.h>
filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName )
: QDialog( parent, name, modal, fl )
{
if ( !name )
- setName( "filePermissions" );
+ setName( tr("filePermissions") );
// qDebug("FilePermissions "+fileName);
/* resize( 236, 210 );
setMaximumSize( QSize( 236, 210 ) );
*/ setCaption( tr( "Set File Permissions" ) );
TextLabel1 = new QLabel( this, "TextLabel1" );
TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) );
TextLabel1->setText( tr( "Set file permissions for:" ) );