author | llornkcor <llornkcor> | 2003-09-08 22:22:00 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-09-08 22:22:00 (UTC) |
commit | e485a3bd44b3cc70280e03eb8a7958a5252cdd6a (patch) (side-by-side diff) | |
tree | cce07d76c2a9060a774898af46e7c8dc8c7b3403 /noncore/apps/advancedfm/advancedfm.cpp | |
parent | b3299bab3370865e0e498fd2f7f84f3abbd17e77 (diff) | |
download | opie-e485a3bd44b3cc70280e03eb8a7958a5252cdd6a.zip opie-e485a3bd44b3cc70280e03eb8a7958a5252cdd6a.tar.gz opie-e485a3bd44b3cc70280e03eb8a7958a5252cdd6a.tar.bz2 |
changes for osplitter functionality
Diffstat (limited to 'noncore/apps/advancedfm/advancedfm.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 345 |
1 files changed, 158 insertions, 187 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(); +} |