-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 345 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 7 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmData.cpp | 30 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 317 | ||||
-rw-r--r-- | noncore/apps/advancedfm/filePermissions.cpp | 2 |
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 @@ -41,4 +41,6 @@ #include <qlineedit.h> +#include <qpe/qpemessagebox.h> + #include <sys/stat.h> #include <time.h> @@ -68,6 +70,5 @@ AdvancedFm::~AdvancedFm() { -void AdvancedFm::cleanUp() -{ +void AdvancedFm::cleanUp() { QString sfile=QDir::homeDirPath(); if(sfile.right(1) != "/") @@ -80,34 +81,31 @@ void AdvancedFm::cleanUp() } -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); @@ -116,6 +114,6 @@ void AdvancedFm::populateView() 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*/); @@ -134,4 +132,5 @@ void AdvancedFm::populateView() fileDate= fi->lastModified().toString(); if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { +// if(fileL == "..") fileL+="/"; isDir=TRUE; @@ -212,22 +211,24 @@ void AdvancedFm::populateView() } -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(); @@ -235,6 +236,5 @@ void AdvancedFm::ListClicked(QListViewItem *selectedItem) 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() ) @@ -242,6 +242,5 @@ void AdvancedFm::ListClicked(QListViewItem *selectedItem) } - if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) - { + if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { if(QDir(strItem).exists()) @@ -249,6 +248,5 @@ void AdvancedFm::ListClicked(QListViewItem *selectedItem) } - if( isDirectory ) - { + if( isDirectory ) { CurrentDir()->cd( strItem, TRUE); populateView(); @@ -259,10 +257,10 @@ void AdvancedFm::ListClicked(QListViewItem *selectedItem) } -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(); } @@ -275,57 +273,46 @@ void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) } -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 ¤tPath) -{ -// qDebug("%d",TabWidget->currentTab()); - if ( whichTab == 1) - { +void AdvancedFm::fillCombo(const QString ¤tPath) { + + 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 ); @@ -335,6 +322,5 @@ void AdvancedFm::fillCombo(const QString ¤tPath) } -void AdvancedFm::currentPathComboActivated(const QString & currentPath) -{ +void AdvancedFm::currentPathComboActivated(const QString & currentPath) { chdir( currentPath.latin1() ); CurrentDir()->cd( currentPath, TRUE); @@ -343,14 +329,11 @@ void AdvancedFm::currentPathComboActivated(const QString & currentPath) } -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)); @@ -360,6 +343,5 @@ QStringList AdvancedFm::getPath() } -void AdvancedFm::homeButtonPushed() -{ +void AdvancedFm::homeButtonPushed() { QString current = QDir::homeDirPath(); chdir( current.latin1() ); @@ -369,6 +351,5 @@ void AdvancedFm::homeButtonPushed() } -void AdvancedFm::docButtonPushed() -{ +void AdvancedFm::docButtonPushed() { QString current = QPEApplication::documentDir(); chdir( current.latin1() ); @@ -378,6 +359,5 @@ void AdvancedFm::docButtonPushed() } -void AdvancedFm::SDButtonPushed() -{ +void AdvancedFm::SDButtonPushed() { QString current = "/mnt/card";// this can change so fix chdir( current.latin1() ); @@ -387,6 +367,5 @@ void AdvancedFm::SDButtonPushed() } -void AdvancedFm::CFButtonPushed() -{ +void AdvancedFm::CFButtonPushed() { QString current; if(zaurusDevice) @@ -401,6 +380,5 @@ void AdvancedFm::CFButtonPushed() -void AdvancedFm::doAbout() -{ +void AdvancedFm::doAbout() { QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" "is copyright 2002-2003 by\n" @@ -409,10 +387,22 @@ void AdvancedFm::doAbout() } -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(); @@ -485,6 +475,5 @@ void AdvancedFm::keyPressEvent( QKeyEvent *e) } -void AdvancedFm::keyReleaseEvent( QKeyEvent *e) -{ +void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { if( CurrentView()->hasFocus() ) e->ignore(); @@ -492,6 +481,5 @@ void AdvancedFm::keyReleaseEvent( QKeyEvent *e) -void AdvancedFm::QPEButtonPushed() -{ +void AdvancedFm::QPEButtonPushed() { QString current = QPEApplication::qpeDir(); chdir( current.latin1() ); @@ -501,6 +489,5 @@ void AdvancedFm::QPEButtonPushed() } -void AdvancedFm::parsetab(const QString &fileName) -{ +void AdvancedFm::parsetab(const QString &fileName) { fileSystemTypeList.clear(); @@ -508,13 +495,10 @@ void AdvancedFm::parsetab(const QString &fileName) 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 @@ -529,6 +513,5 @@ void AdvancedFm::parsetab(const QString &fileName) } -QString AdvancedFm::getFileSystemType(const QString ¤tText) -{ +QString AdvancedFm::getFileSystemType(const QString ¤tText) { parsetab("/etc/mtab"); //why did TT forget filesystem type? QString current = currentText;//.right( currentText.length()-1); @@ -546,6 +529,5 @@ QString AdvancedFm::getFileSystemType(const QString ¤tText) } -QString AdvancedFm::getDiskSpace( const QString &path) -{ +QString AdvancedFm::getDiskSpace( const QString &path) { struct statfs fss; if ( !statfs( path.latin1(), &fss ) ) { @@ -565,6 +547,5 @@ QString AdvancedFm::getDiskSpace( const QString &path) -void AdvancedFm::showFileMenu() -{ +void AdvancedFm::showFileMenu() { QString curApp; curApp = CurrentView()->currentItem()->text(0); @@ -578,11 +559,8 @@ void AdvancedFm::showFileMenu() 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 ) @@ -635,16 +613,13 @@ void AdvancedFm::showFileMenu() -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; @@ -662,6 +637,5 @@ QString AdvancedFm::checkDiskSpace(const QString &path) } -void AdvancedFm::addToDocs() -{ +void AdvancedFm::addToDocs() { QStringList strListPaths = getPath(); QDir *thisDir = CurrentDir(); @@ -683,6 +657,5 @@ void AdvancedFm::addToDocs() -void AdvancedFm::customDirsToMenu() -{ +void AdvancedFm::customDirsToMenu() { Config cfg("AdvancedFm"); @@ -698,7 +671,5 @@ void AdvancedFm::customDirsToMenu() } -void AdvancedFm::dirMenuSelected(int item) -{ - qDebug("menu item %d", item); +void AdvancedFm::dirMenuSelected(int item) { switch(item) { @@ -722,6 +693,5 @@ void AdvancedFm::dirMenuSelected(int item) } -void AdvancedFm::addCustomDir() -{ +void AdvancedFm::addCustomDir() { Config cfg("AdvancedFm"); cfg.setGroup("Menu"); @@ -732,13 +702,10 @@ void AdvancedFm::addCustomDir() 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); @@ -750,6 +717,5 @@ void AdvancedFm::addCustomDir() } -void AdvancedFm::removeCustomDir() -{ +void AdvancedFm::removeCustomDir() { // qDebug("remove custom dir"); Config cfg("AdvancedFm"); @@ -762,19 +728,13 @@ void AdvancedFm::removeCustomDir() // 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); @@ -792,6 +752,5 @@ void AdvancedFm::removeCustomDir() } -void AdvancedFm::gotoCustomDir(const QString &dir) -{ +void AdvancedFm::gotoCustomDir(const QString &dir) { // qDebug("gotoCustomDir(const QString &dir) " +dir ); // QString curDir = dir; @@ -799,14 +758,10 @@ void AdvancedFm::gotoCustomDir(const QString &dir) // 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() ) @@ -820,38 +775,32 @@ void AdvancedFm::gotoCustomDir(const QString &dir) } -QDir *AdvancedFm::CurrentDir() -{ - if ( whichTab == 1) - { +QDir *AdvancedFm::CurrentDir() { + + if ( whichTab == 1) { return ¤tDir; - } - else - { + } else { return ¤tRemoteDir; } } -QDir *AdvancedFm::OtherDir() -{ - if ( whichTab == 1) - { +QDir *AdvancedFm::OtherDir() { + if ( whichTab == 1) { return ¤tRemoteDir; - } - else - { + } else { return ¤tDir; } } -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; @@ -860,17 +809,20 @@ QListView * AdvancedFm::OtherView() } -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; @@ -885,5 +837,5 @@ void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { void AdvancedFm::gotoDirectory(const QString &file) { - +// qWarning("goto dir "+file); QString curDir = file; QDir *thisDir = CurrentDir(); @@ -919,2 +871,21 @@ void AdvancedFm::findFile(const QString &fileName) { } } + +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 @@ -59,4 +59,5 @@ public: ~AdvancedFm(); protected slots: + void slotSwitchMenu(int); void selectAll(); void addToDocs(); @@ -129,6 +130,8 @@ protected: QListView *OtherView(); void setOtherTabCurrent(); + void dealWithSchmooSchmaa(QWidget *); protected slots: + void openSearch(); void dirMenuSelected(int); void showFileMenu(); @@ -153,4 +156,6 @@ protected slots: void fileBeamFinished( Ir *); +// void slotSwitchtoLocal(int); + private: MenuButton *menuButton; @@ -166,5 +171,5 @@ private: void removeCustomDir(); void gotoDirectory(const QString &); - void openSearch(); + void navigateToSelected(); void findFile(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 @@ -99,9 +99,11 @@ void AdvancedFm::init() { 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"); @@ -121,4 +123,5 @@ void AdvancedFm::init() { menuButton->insertItem( s_removeBookmark); menuButton->insertSeparator(); + menuButton->setFocusPolicy(NoFocus); customDirsToMenu(); @@ -127,5 +130,5 @@ void AdvancedFm::init() { currentPathCombo->setEditable(TRUE); currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); - + currentPathCombo->setFocusPolicy(NoFocus); layout->addWidget( lineBox ); @@ -149,4 +152,6 @@ void AdvancedFm::init() { Local_View->setMultiSelection( TRUE ); Local_View->setSelectionMode(QListView::Extended); + Local_View->setFocusPolicy(StrongFocus); + Local_View->installEventFilter( this ); QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); @@ -171,5 +176,6 @@ void AdvancedFm::init() { Remote_View->setMultiSelection( TRUE ); Remote_View->setSelectionMode(QListView::Extended); - + Remote_View->setFocusPolicy(StrongFocus); + Remote_View->installEventFilter( this ); QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); @@ -204,14 +210,9 @@ void AdvancedFm::init() { /////////////// - - 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()) { @@ -281,6 +282,7 @@ void AdvancedFm::initConnections() 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 @@ -47,59 +47,48 @@ -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(); @@ -112,10 +101,9 @@ void AdvancedFm::runThis() 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) @@ -125,16 +113,11 @@ void AdvancedFm::runThis() 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(); } @@ -143,9 +126,8 @@ void AdvancedFm::runThis() } -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); @@ -156,11 +138,9 @@ void AdvancedFm::runText() } -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(); @@ -170,6 +150,5 @@ void AdvancedFm::makeDir() } -void AdvancedFm::doDelete() -{ +void AdvancedFm::doDelete() { QStringList curFileList = getPath(); bool doMsg=true; @@ -236,10 +215,10 @@ void AdvancedFm::doDelete() 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(); @@ -253,6 +232,5 @@ void AdvancedFm::doDelete() } -void AdvancedFm::filePerms() -{ +void AdvancedFm::filePerms() { QStringList curFileList = getPath(); QString filePath; @@ -260,6 +238,5 @@ void AdvancedFm::filePerms() 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)); @@ -272,6 +249,5 @@ void AdvancedFm::filePerms() } -void AdvancedFm::doProperties() -{ +void AdvancedFm::doProperties() { #if defined(QT_QWS_OPIE) @@ -281,9 +257,8 @@ void AdvancedFm::doProperties() 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 ); @@ -295,6 +270,5 @@ void AdvancedFm::doProperties() } -void AdvancedFm::upDir() -{ +void AdvancedFm::upDir() { QDir *thisDir = CurrentDir(); QString current = thisDir->canonicalPath(); @@ -309,6 +283,5 @@ void AdvancedFm::upDir() } -void AdvancedFm::copy() -{ +void AdvancedFm::copy() { qApp->processEvents(); QStringList curFileList = getPath(); @@ -336,6 +309,5 @@ void AdvancedFm::copy() 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 @@ -345,16 +317,13 @@ void AdvancedFm::copy() 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; @@ -371,11 +340,10 @@ void AdvancedFm::copy() } } + rePopulate(); setOtherTabCurrent(); - populateView(); } } -void AdvancedFm::copyAs() -{ +void AdvancedFm::copyAs() { qApp->processEvents(); @@ -387,6 +355,5 @@ void AdvancedFm::copyAs() 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); @@ -397,16 +364,13 @@ void AdvancedFm::copyAs() 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(); @@ -426,10 +390,9 @@ void AdvancedFm::copyAs() } + rePopulate(); setOtherTabCurrent(); - populateView(); } -void AdvancedFm::copySameDir() -{ +void AdvancedFm::copySameDir() { qApp->processEvents(); QStringList curFileList = getPath(); @@ -439,6 +402,5 @@ void AdvancedFm::copySameDir() 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; @@ -448,6 +410,5 @@ void AdvancedFm::copySameDir() fileDlg->exec(); - if( fileDlg->result() == 1 ) - { + if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); @@ -455,6 +416,5 @@ void AdvancedFm::copySameDir() 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?"), @@ -475,5 +435,5 @@ void AdvancedFm::copySameDir() } - qDebug("copy "+curFile+" as "+destFile); +// qDebug("copy "+curFile+" as "+destFile); } delete fileDlg; @@ -482,17 +442,14 @@ void AdvancedFm::copySameDir() } -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(); @@ -501,5 +458,5 @@ void AdvancedFm::move() destFile+="/"; destFile += item; - qDebug("Destination file is "+destFile); +// qDebug("Destination file is "+destFile); curFile = thisDir->canonicalPath(); @@ -507,5 +464,5 @@ void AdvancedFm::move() curFile +="/"; curFile+= item; - qDebug("CurrentFile file is " + curFile); +// qDebug("CurrentFile file is " + curFile); QFile f( curFile); @@ -520,11 +477,9 @@ void AdvancedFm::move() } - 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; @@ -537,5 +492,5 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) off_t offset = 0; if(!srcFile.open( IO_ReadOnly|IO_Raw)) { - qWarning("open failed"); +// qWarning("open failed"); return success = false; } @@ -544,5 +499,5 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) fstat (read_fd, &stat_buf); if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { - qWarning("destfile open failed"); +// qWarning("destfile open failed"); return success = false; } @@ -559,5 +514,5 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) }; success = false; - qWarning(msg); +// qWarning(msg); } } else { @@ -577,6 +532,6 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) } -void AdvancedFm::runCommand() -{ +void AdvancedFm::runCommand() { + if( !CurrentView()->currentItem()) return; QDir *thisDir = CurrentDir(); @@ -590,7 +545,6 @@ void AdvancedFm::runCommand() //QString command; - if( fileDlg->result() == 1 ) - { - qDebug(fileDlg->LineEdit1->text()); + if( fileDlg->result() == 1 ) { +// qDebug(fileDlg->LineEdit1->text()); QStringList command; @@ -607,6 +561,6 @@ void AdvancedFm::runCommand() } -void AdvancedFm::runCommandStd() -{ +void AdvancedFm::runCommandStd() { + if( !CurrentView()->currentItem()) return; QString curFile; QDir *thisDir = CurrentDir(); @@ -620,6 +574,5 @@ void AdvancedFm::runCommandStd() fileDlg->exec(); - if( fileDlg->result() == 1 ) - { + if( fileDlg->result() == 1 ) { qApp->processEvents(); startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); @@ -627,6 +580,6 @@ void AdvancedFm::runCommandStd() } -void AdvancedFm::fileStatus() -{ +void AdvancedFm::fileStatus() { + if( !CurrentView()->currentItem()) return; QString curFile; curFile = CurrentView()->currentItem()->text(0); @@ -645,34 +598,27 @@ void AdvancedFm::fileStatus() -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); } @@ -680,20 +626,18 @@ void AdvancedFm::mkSym() 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()) { @@ -715,23 +659,15 @@ void AdvancedFm::doBeam() } -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; @@ -751,53 +687,44 @@ void AdvancedFm::startProcess(const QString & cmd) } -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 } @@ -806,7 +733,6 @@ bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) -void AdvancedFm::cancelRename() -{ - qDebug("cancel rename"); +void AdvancedFm::cancelRename() { +// qDebug("cancel rename"); QListView * view; view = CurrentView(); @@ -815,6 +741,5 @@ void AdvancedFm::cancelRename() delete renameBox; renameBox = 0; - if ( resetFocus ) - { + if ( resetFocus ) { view->viewport()->setFocusProxy( view); view->setFocus(); @@ -822,6 +747,6 @@ void AdvancedFm::cancelRename() } -void AdvancedFm::doRename(QListView * view) -{ +void AdvancedFm::doRename(QListView * view) { + if( !CurrentView()->currentItem()) return; QRect r = view->itemRect( view->currentItem( )); @@ -843,10 +768,9 @@ void AdvancedFm::doRename(QListView * view) renameBox->setFocus(); renameBox->show(); - } -void AdvancedFm::renameIt() -{ +void AdvancedFm::renameIt() { + if( !CurrentView()->currentItem()) return; QListView *thisView = CurrentView(); oldName = thisView->currentItem()->text(0); @@ -855,9 +779,8 @@ void AdvancedFm::renameIt() } -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() + "/"; @@ -865,6 +788,4 @@ void AdvancedFm::okRename() newName = path + newName; - if( view->currentItem() == NULL) - return; if( rename( oldName.latin1(), newName.latin1())== -1) QMessageBox::message(tr("Note"),tr("Could not rename")); @@ -878,4 +799,4 @@ void AdvancedFm::okRename() 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 @@ -32,5 +32,5 @@ filePermissions::filePermissions( QWidget* parent, const char* name, bool modal { if ( !name ) - setName( "filePermissions" ); + setName( tr("filePermissions") ); // qDebug("FilePermissions "+fileName); /* resize( 236, 210 ); |