author | llornkcor <llornkcor> | 2004-09-25 06:51:24 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-09-25 06:51:24 (UTC) |
commit | 3d4aef2df9828aedccf5d576ecbc8aad6621362e (patch) (side-by-side diff) | |
tree | 435f8e3b658ef45d8e95d29a305d20c62e01c24e | |
parent | 448e2835ff7b84162022b62f8570935739a167bb (diff) | |
download | opie-3d4aef2df9828aedccf5d576ecbc8aad6621362e.zip opie-3d4aef2df9828aedccf5d576ecbc8aad6621362e.tar.gz opie-3d4aef2df9828aedccf5d576ecbc8aad6621362e.tar.bz2 |
not hardcoded path
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 41 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 1 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmData.cpp | 2 |
3 files changed, 7 insertions, 37 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index ec7a08a..f1be471 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp @@ -1,63 +1,66 @@ /*************************************************************************** AdvancedFm.cpp ------------------- ** Created: Sat Mar 9 23:33:09 2002 copyright : (C) 2002 by ljp email : ljp@llornkcor.com * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #define DEVELOPERS_VERSION #include "advancedfm.h" #include <opie2/odebug.h> + +#include <opie2/ostorageinfo.h> + #include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qpe/mimetype.h> #include <qpe/applnk.h> #include <qpe/resource.h> #include <qpe/menubutton.h> #include <qcombobox.h> #include <qpopupmenu.h> #include <qlistview.h> #include <qmessagebox.h> #include <qlineedit.h> #include <sys/stat.h> #include <time.h> #include <dirent.h> #include <fcntl.h> #include <sys/vfs.h> #include <mntent.h> using namespace Opie::Ui; AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags ) : QMainWindow( ) { init(); renameBox = 0; unknownXpm = Resource::loadImage("UnknownDocument").smoothScale(AppLnk::smallIconSize(),AppLnk::smallIconSize() ); initConnections(); rePopulate(); channel = new QCopChannel( "QPE/Application/advancedfm", this ); connect(channel,SIGNAL(received(const QCString&,const QByteArray&)),this,SLOT(qcopReceive(const QCString&,const QByteArray&))); switchToLocalTab(); } AdvancedFm::~AdvancedFm() { } void AdvancedFm::cleanUp() { QString sfile=QDir::homeDirPath(); if(sfile.right(1) != "/") sfile+="/._temp"; else sfile+="._temp"; QFile file( sfile); @@ -165,246 +168,229 @@ void AdvancedFm::populateView() { // odebug << " overlay link image" << oendl; pm= Resource::loadPixmap( "advancedfm/symlink" ); // pm= Resource::loadPixmap( "folder" ); // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); // QPainter painter( &pm ); // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); // pm.setMask( pm.createHeuristicMask( FALSE ) ); } item->setPixmap( 0,pm); } isDir=FALSE; ++it; } if( path.find("dev",0,TRUE) != -1) { struct stat buf; dev_t devT; DIR *dir; struct dirent *mydirent; if((dir = opendir( path.latin1())) != NULL) while ((mydirent = readdir(dir)) != NULL) { lstat( mydirent->d_name, &buf); // odebug << mydirent->d_name << oendl; fileL.sprintf("%s", mydirent->d_name); devT = buf.st_dev; fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); fileDate.sprintf("%s", ctime( &buf.st_mtime)); if( fileL.find(".") == -1 ) { item= new QListViewItem( thisView, fileL, fileS, fileDate); pm = unknownXpm; item->setPixmap( 0,pm); } } closedir(dir); } thisView->setSorting( 3,FALSE); fillCombo( (const QString &) path ); } void AdvancedFm::rePopulate() { // qDebug("repopulate views"); populateView(); setOtherTabCurrent(); populateView(); - -// int tmpTab = whichTab; -// // odebug << "" << tmpTab << "" << oendl; - -// for(int i =1; i < 3; i++) { -// TabWidget->setCurrentWidget(i - 1); -// populateView(); -// } -// TabWidget->setCurrentWidget( tmpTab - 1); } void AdvancedFm::ListClicked(QListViewItem *selectedItem) { -// if ( TabWidget->currentWidget() == tab) -// qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked local"); -// else -// qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked remote"); - - if(selectedItem) { QString strItem=selectedItem->text(0); // owarn << strItem << oendl; 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 strItem2 = dealWithSymName((const QString&)strItem); if(QDir(strItem2).exists() ) strItem = strItem2; } if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { if(QDir(strItem).exists()) isDirectory = true; } if( isDirectory ) { CurrentDir()->cd( strItem, TRUE); populateView(); CurrentView()->ensureItemVisible( CurrentView()->firstChild()); } chdir( strItem.latin1()); } } void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { Q_UNUSED(item); switch (mouse) { case 1: { if(renameBox != 0 ) { cancelRename(); } } break; // case 2: // menuTimer.start( 50, TRUE ); // break; }; } void AdvancedFm::refreshCurrentTab() { populateView(); // if ( TabWidget->currentWidget() == tab) { - } void AdvancedFm::switchToLocalTab() { TabWidget->setCurrentWidget(0); // Local_View->setFocus(); whichTab = 1; } void AdvancedFm::switchToRemoteTab() { TabWidget->setCurrentWidget(1); // Remote_View->setFocus(); whichTab = 2; } void AdvancedFm::currentPathComboChanged() { QString pDir = currentPathCombo->lineEdit()->text(); if(QDir(pDir).exists()) { CurrentDir()->setPath(pDir ); populateView(); } else { QMessageBox::message(tr("Note"),tr("<p>%1 does not exist</p>").arg(pDir)); } } void AdvancedFm::fillCombo(const QString ¤tPath) { if ( TabWidget->currentWidget() == tab) { // if ( whichTab == 1) { currentPathCombo->lineEdit()->setText( currentPath); if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { currentPathCombo->clear(); localDirPathStringList.prepend( currentPath ); currentPathCombo->insertStringList( localDirPathStringList,-1); } } else { currentPathCombo->lineEdit()->setText( currentPath); if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { currentPathCombo->clear(); remoteDirPathStringList.prepend( currentPath ); currentPathCombo->insertStringList( remoteDirPathStringList,-1); } } } QStringList AdvancedFm::getPath() { QStringList strList; QListView *thisView=CurrentView(); QList<QListViewItem> * getSelectedItems( QListView * thisView ); QListViewItemIterator it( thisView ); for ( ; it.current(); ++it ) { if ( it.current()->isSelected() ) { strList << it.current()->text(0); // odebug << it.current()->text(0) << oendl; } } return strList; } void AdvancedFm::changeTo(const QString dir) { chdir( dir.latin1()); CurrentDir()->cd(dir, TRUE); populateView(); update(); } void AdvancedFm::homeButtonPushed() { changeTo(QDir::homeDirPath()); } void AdvancedFm::docButtonPushed() { changeTo(QPEApplication::documentDir()); } void AdvancedFm::SDButtonPushed() { - changeTo("/mnt/card");// this can change so fix + Opie::Core::OStorageInfo info; + changeTo(info.sdPath()); } void AdvancedFm::CFButtonPushed() { - if(zaurusDevice) - changeTo("/mnt/cf"); //zaurus - else - changeTo("/mnt/hda"); //ipaq + Opie::Core::OStorageInfo info; + changeTo(info.cfPath()); } void AdvancedFm::QPEButtonPushed() { changeTo(QPEApplication::qpeDir()); } void AdvancedFm::doAbout() { QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); } void AdvancedFm::keyPressEvent( QKeyEvent *e) { Q_UNUSED(e); } void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { // if( CurrentView()->hasFocus() ) // e->ignore(); if( currentPathCombo->lineEdit()->hasFocus()) { // qDebug("shout!"); } else if( e->key() == Key_Left ) upDir(); else if( e->key() == Key_Return || e->key() == Key_Enter) navigateToSelected(); else if( e->key() == Key_Tab) setOtherTabCurrent(); else if( e->key() == Key_Delete ) del(); else if( e->key() == Key_A) copyAs(); else if( e->key() == Key_C) copy(); else if( e->key() == Key_E) runThis(); else if( e->key() == Key_G) currentPathCombo->lineEdit()->setFocus(); else if( e->key() == Key_H ) showHidden(); else if( e->key() == Key_I) fileStatus(); else if( e->key() == Key_M) move(); else if( e->key() == Key_N ) mkDir(); else if( e->key() == Key_P) filePerms(); else if( e->key() == Key_R ) @@ -725,74 +711,61 @@ QDir *AdvancedFm::OtherDir() { } else { return ¤tDir; } } QListView * AdvancedFm::CurrentView() { // if ( TabWidget->currentWidget() == tab) { if ( whichTab == 1) { // qDebug("CurrentView: local"); return Local_View; } else { // owarn << "CurrentView Tab 2" << oendl; // qDebug("CurrentView: remote"); return Remote_View; } } QListView * AdvancedFm::OtherView() { if ( whichTab == 1) return Remote_View; else return Local_View; } void AdvancedFm::setOtherTabCurrent() { // qDebug("setOtherTabCurrent() %d",whichTab); if ( whichTab == 1) { TabWidget->setCurrentWidget(1); } else { TabWidget->setCurrentWidget(0); } // OtherView()->setFocus(); OtherView()->setSelected( CurrentView()->firstChild(), true); } void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { // odebug << "qcop message "+msg << oendl; QDataStream stream ( data, IO_ReadOnly ); if ( msg == "openDirectory(QString)" ) { // odebug << "received" << oendl; QString file; stream >> file; changeTo( (const QString &) file); } } void AdvancedFm::setDocument(const QString &file) { changeTo( file); - } -void AdvancedFm::findFile(const QString &fileName) { - QFileInfo fi(fileName); - QListView *thisView = CurrentView(); - 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 item) { Q_UNUSED(item); // qDebug( "Switch %d",item); // viewMenu->setItemChecked(item, true); } void AdvancedFm::navigateToSelected() { if( !CurrentView()->currentItem()) return; doDirChange(); } diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h index 6f7eb96..42f3bc6 100644 --- a/noncore/apps/advancedfm/advancedfm.h +++ b/noncore/apps/advancedfm/advancedfm.h @@ -132,61 +132,60 @@ protected slots: void switchToLocalTab(); void switchToRemoteTab(); void refreshCurrentTab(); void openSearch(); void dirMenuSelected(int); void showFileMenu(); void homeButtonPushed(); void docButtonPushed(); void SDButtonPushed(); void CFButtonPushed(); void QPEButtonPushed(); void upDir(); void currentPathComboChanged(); void copy(); void copyTimer(); void copyAs(); void copyAsTimer(); void copySameDir(); void copySameDirTimer(); void move(); void moveTimer(); void fillCombo(const QString &); bool copyFile( const QString & , const QString & ); void fileStatus(); void doAbout(); void doBeam(); void fileBeamFinished( Ir *); bool copyDirectory( const QString & , const QString & ); // void navigateToSelected(); bool moveDirectory( const QString & , const QString & ); // void slotSwitchtoLocal(int); private: MenuButton *menuButton; QString oldName, localViewDir, remoteViewDir; void startProcess(const QString &); bool eventFilter( QObject * , QEvent * ); void cancelRename(); void doRename(QListView *); void okRename(); void customDirsToMenu(); void addCustomDir(); void removeCustomDir(); void navigateToSelected(); - void findFile(const QString &); private slots: void processEnded(Opie::Core::OProcess *); void oprocessStderr(Opie::Core::OProcess *, char *, int); void gotoCustomDir(const QString &); void qcopReceive(const QCString&, const QByteArray&); void setDocument(const QString &); // void doMenu(int }; #endif // ADVANCEDFM_H diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp index 1047c5a..9be0ceb 100644 --- a/noncore/apps/advancedfm/advancedfmData.cpp +++ b/noncore/apps/advancedfm/advancedfmData.cpp @@ -11,98 +11,96 @@ ***************************************************************************/ #include "advancedfm.h" /* OPIE */ #include <opie2/odebug.h> #include <qpe/storage.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/menubutton.h> using namespace Opie::Core; using namespace Opie::Ui; /* QT */ #include <qlayout.h> #include <qhbox.h> #include <qmenubar.h> #include <qcombobox.h> #include <qtoolbutton.h> #include <qlineedit.h> #include <qlistview.h> /* STD */ #include <sys/utsname.h> void AdvancedFm::init() { b = false; setCaption( tr( "AdvancedFm" ) ); QVBoxLayout *layout = new QVBoxLayout( this ); layout->setSpacing( 2); layout->setMargin( 0); // squeeze QMenuBar *menuBar = new QMenuBar(this); menuBar->setMargin( 0 ); // squeeze fileMenu = new QPopupMenu( this ); viewMenu = new QPopupMenu( this ); // customDirMenu = new QPopupMenu( this ); layout->addWidget( menuBar ); menuBar->insertItem( tr( "File" ), fileMenu); menuBar->insertItem( tr( "View" ), viewMenu); cdUpButton = new QToolButton( 0,"cdUpButton"); cdUpButton->setPixmap(Resource::loadPixmap("up")); cdUpButton->setAutoRaise( true ); menuBar->insertItem( cdUpButton ); - - qpeDirButton= new QToolButton( 0,"QPEButton"); qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); qpeDirButton->setAutoRaise( true ); menuBar->insertItem( qpeDirButton ); cfButton = new QToolButton( 0, "CFButton"); cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); cfButton->setAutoRaise( true ); menuBar->insertItem( cfButton ); sdButton = new QToolButton( 0, "SDButton"); sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard")); sdButton->setAutoRaise( true ); menuBar->insertItem( sdButton ); docButton = new QToolButton( 0,"docsButton"); docButton->setPixmap(Resource::loadPixmap("DocsIcon")); docButton->setAutoRaise( true ); menuBar->insertItem( docButton ); homeButton = new QToolButton( 0, "homeButton"); homeButton->setPixmap(Resource::loadPixmap("home")); homeButton->setAutoRaise( true ); menuBar->insertItem( homeButton ); fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); fileMenu->insertSeparator(); fileMenu->insertItem( tr( "File Search" ), this, SLOT( openSearch() )); fileMenu->insertSeparator(); fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); 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 View 1" ), this, SLOT( switchToLocalTab())); viewMenu->insertItem( tr( "Switch to View 2" ), this, SLOT( switchToRemoteTab())); viewMenu->insertItem( tr( "Refresh" ), this, SLOT( refreshCurrentTab())); // viewMenu->insertSeparator(); // viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); viewMenu->setCheckable(true); viewMenu->setItemChecked( viewMenu->idAt(0), true); |