-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 137 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.pro | 2 |
2 files changed, 84 insertions, 55 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index a000e9b..ebd7fc3 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp @@ -1,43 +1,47 @@ /*************************************************************************** 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 #define QTOPIA_INTERNAL_FSLP // to get access to fileproperties #include "advancedfm.h" #include "inputDialog.h" #include "filePermissions.h" #include "output.h" +#include <opie/ofileselector.h> +#include <opie/ofiledialog.h> + + #include <qpe/lnkproperties.h> #include <qpe/filemanager.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/qpemenubar.h> #include <qpe/qpetoolbar.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/config.h> #include <qpe/mimetype.h> #include <qpe/applnk.h> #include <qpe/ir.h> //#include <opie/ofileselector.h> #include <qmultilineedit.h> #include <qtextstream.h> #include <qpushbutton.h> #include <qtoolbutton.h> #include <qdatetime.h> #include <qdir.h> #include <qfile.h> #include <qstring.h> #include <qcombobox.h> @@ -68,49 +72,49 @@ #include <errno.h> AdvancedFm::AdvancedFm( ) : QMainWindow( ) { setCaption( tr( "AdvancedFm" ) ); // menuTimer( this ); QGridLayout *layout = new QGridLayout( this ); layout->setSpacing( 2); layout->setMargin( 2); connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); QPEMenuBar *menuBar = new QPEMenuBar(this); // fileMenu = new QPopupMenu( this ); fileMenu = new QPopupMenu( this ); viewMenu = new QPopupMenu( this ); layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 ); menuBar->insertItem( tr( "File" ), fileMenu); menuBar->insertItem( tr( "View" ), viewMenu); - qpeDirButton= new QPushButton(Resource::loadIconSet("go"),"",this,"QPEButton"); + qpeDirButton= new QPushButton(Resource::loadIconSet("launcher/opielogo16x16"),"",this,"QPEButton"); qpeDirButton ->setFixedSize( QSize( 20, 20 ) ); connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) ); qpeDirButton->setFlat(TRUE); layout->addMultiCellWidget( qpeDirButton , 0, 0, 2, 2); cfButton = new QPushButton(Resource::loadIconSet("cardmon/pcmcia"),"",this,"CFButton"); cfButton ->setFixedSize( QSize( 20, 20 ) ); connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) ); cfButton->setFlat(TRUE); layout->addMultiCellWidget( cfButton , 0, 0, 3, 3); sdButton = new QPushButton(Resource::loadIconSet("sdmon/sdcard"),"",this,"SDButton"); sdButton->setFixedSize( QSize( 20, 20 ) ); connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) ); sdButton->setFlat(TRUE); layout->addMultiCellWidget( sdButton , 0, 0, 4, 4); cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); cdUpButton ->setFixedSize( QSize( 20, 20 ) ); connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); cdUpButton ->setFlat(TRUE); layout->addMultiCellWidget( cdUpButton , 0, 0, 5, 5); docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); @@ -170,108 +174,123 @@ AdvancedFm::AdvancedFm( ) tabLayout->setSpacing( 2); tabLayout->setMargin( 2); Local_View = new QListView( tab, "Local_View" ); // Local_View->setResizePolicy( QListView::AutoOneFit ); 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); QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); tabLayout->addWidget( Local_View, 0, 0 ); connect( Local_View, SIGNAL( clicked( QListViewItem*)), this,SLOT( localListClicked(QListViewItem *)) ); connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( localListPressed(int, QListViewItem *, const QPoint&, int)) ); + connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); TabWidget->insertTab( tab, tr("1")); tab_2 = new QWidget( TabWidget, "tab_2" ); tabLayout_2 = new QGridLayout( tab_2 ); tabLayout_2->setSpacing( 2); tabLayout_2->setMargin( 2); Remote_View = new QListView( tab_2, "Remote_View" ); 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); QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); connect( Remote_View, SIGNAL( clicked( QListViewItem*)), this,SLOT( remoteListClicked(QListViewItem *)) ); connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) ); - connect( Remote_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); +// connect( Remote_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); tabLayout_2->addWidget( Remote_View, 0, 0 ); TabWidget->insertTab( tab_2, tr( "2")); connect(TabWidget,SIGNAL(currentChanged(QWidget *)), this,SLOT(tabChanged(QWidget*))); -// tab_3 = new QWidget( TabWidget, "tab_3" ); -// tabLayout_3 = new QGridLayout( tab_3 ); -// tabLayout_3->setSpacing( 2); -// tabLayout_3->setMargin( 2); + tab_3 = new QWidget( TabWidget, "tab_3" ); + tabLayout_3 = new QGridLayout( tab_3 ); + tabLayout_3->setSpacing( 2); + tabLayout_3->setMargin( 2); + + +// OFileDialog fileDialog; +// fileDialog; +// fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy +// fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); +// OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); -// OFileSelector *fileSelector; -// fileSelector = new OFileSelector(tab_3,0,0,"/","","*"); -// tabLayout_3->addMultiCellWidget( fileSelector, 0, 0, 0, 3 ); +QListView *fileTree; + fileTree = new QListView( tab_3, "tree" ); -// TabWidget->insertTab( tab_3, tr( "Files" ) ); + + tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); + TabWidget->insertTab( tab_3, tr( "Remote" ) ); +/////////////// + +//////////////////// + + currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); currentDir.setPath( QDir::currentDirPath()); currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); currentRemoteDir.setPath( QDir::currentDirPath()); b = TRUE; filterStr="*"; b=FALSE; connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); populateLocalView(); populateRemoteView(); + currentPathCombo->setFocus(); } AdvancedFm::~AdvancedFm() { } 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 (TabWidget->currentPageIndex() == 0) { currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); @@ -526,92 +545,92 @@ void AdvancedFm::localListClicked(QListViewItem *selectedItem) if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink // is symlink QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); if(QDir(strItem2).exists() ) { currentDir.cd(strItem2, TRUE); populateLocalView(); } } else { // not a symlink if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); currentDir.cd(strItem,FALSE); populateLocalView(); } else { currentDir.cdUp(); populateLocalView(); } if(QDir(strItem).exists()){ currentDir.cd(strItem, TRUE); populateLocalView(); } } else { strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); if( QFile::exists(strItem ) ) { - qDebug("clicked item "+strItem); - DocLnk doc( strItem, FALSE ); - doc.execute(); +// qDebug("clicked item "+strItem); +// DocLnk doc( strItem, FALSE ); +// doc.execute(); // Local_View->clearSelection(); } } //end not symlink chdir(strItem.latin1()); } } } void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { if(selectedItem) { QString strItem=selectedItem->text(0); QString strSize=selectedItem->text(1); strSize=strSize.stripWhiteSpace(); if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink // is symlink QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); if(QDir(strItem2).exists() ) { currentRemoteDir.cd(strItem2, TRUE); populateRemoteView(); } } else { // not a symlink if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); currentRemoteDir.cd(strItem,FALSE); populateRemoteView(); } else { currentRemoteDir.cdUp(); populateRemoteView(); } if(QDir(strItem).exists()){ currentRemoteDir.cd(strItem, TRUE); populateRemoteView(); } } else { strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); if( QFile::exists(strItem ) ) { - qDebug("clicked item "+strItem); - DocLnk doc( strItem, FALSE ); - doc.execute(); +// qDebug("clicked item "+strItem); +// DocLnk doc( strItem, FALSE ); +// doc.execute(); // Remote_View->clearSelection(); } } //end not symlink chdir(strItem.latin1()); } } } void AdvancedFm::doLocalCd() { localListClicked( Local_View->currentItem()); } void AdvancedFm::doRemoteCd() { localListClicked( Remote_View->currentItem()); } void AdvancedFm::showHidden() { if (b) { currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); // localMenu->setItemChecked(localMenu->idAt(0),TRUE); @@ -627,65 +646,68 @@ void AdvancedFm::showHidden() } populateLocalView(); } void AdvancedFm::showRemoteHidden() { if (b) { currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); // viewMenu->setItemChecked(localMenu->idAt(0),TRUE); // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); b=TRUE; } else { currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); // localMenu->setItemChecked(localMenu->idAt(0),FALSE); // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); b=FALSE; } populateRemoteView(); } void AdvancedFm::localListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) { - switch (mouse) { +qDebug("list pressed"); + switch (mouse) { case 1: break; case 2: - menuTimer.start( 500, TRUE ); + menuTimer.start( 750, TRUE ); + qDebug("Start menu timer\n"); break; }; } void AdvancedFm::remoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) { - switch (mouse) { + switch (mouse) { case 1: break; case 2: - menuTimer.start( 500, TRUE ); + menuTimer.start( 750, TRUE ); + qDebug("Start menu timer"); break; }; } void AdvancedFm::runThis() { // QFileInfo *fi; QString fs; if (TabWidget->currentPageIndex() == 0) { QString curFile = Local_View->currentItem()->text(0); if(curFile != "../") { fs= getFileSystemType((const QString &) currentDir.canonicalPath()); QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); 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") ) { // if( fileInfo.isExecutable() | QCopEnvelope e("QPE/System", "execute(QString)" ); e << curFile; } else { curFile = currentDir.canonicalPath()+"/"+curFile; DocLnk nf(curFile); @@ -1440,48 +1462,49 @@ void AdvancedFm::mkDir() { void AdvancedFm::rn() { if (TabWidget->currentPageIndex() == 0) localRename(); else remoteRename(); } void AdvancedFm::del() { if (TabWidget->currentPageIndex() == 0) localDelete(); else remoteDelete(); } void AdvancedFm::doAbout() { QMessageBox::message("AdvancedFm","Advanced FileManager\n" "is copyright 2002 by\n" "L.J.Potter<llornkcor@handhelds.org>\n" "and is licensed by the GPL"); } void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { + if( TabWidget->hasFocus()) switch ( e->key() ) { case Key_Delete: del(); break; case Key_H: showHidden(); break; case Key_E: runThis(); break; case Key_C: copy(); break; case Key_A: copyAs(); break; case Key_M: move(); break; case Key_R: rn(); break; case Key_I: fileStatus(); @@ -1647,107 +1670,113 @@ void AdvancedFm::doBeam() { } } } } } void AdvancedFm::fileBeamFinished( Ir *ir) { QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); } // QList<QListViewItem> * getSelectedItems( QListView * Local_View ); // QListViewItemIterator it( Local_View ); // for ( ; it.current(); ++it ) { // if ( it.current()->isSelected() ) { // QString strItem = it.current()->text(0); // QString localFile = currentDir.canonicalPath()+"/"+strItem; // QFileInfo fi(localFile); // } // } void AdvancedFm::showFileMenu() { + QString curApp; bool isLocalView = false; if (TabWidget->currentPageIndex() == 0) { isLocalView = TRUE; curApp = Local_View->currentItem()->text(0); } else { curApp = Remote_View->currentItem()->text(0); } MimeType mt( curApp ); const AppLnk* app = mt.application(); QFile fi(curApp); - QPopupMenu m; - m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); - m.insertSeparator(); +// QPopupMenu m; + QPopupMenu *m = new QPopupMenu(0); + + m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); + m->insertSeparator(); if ( QFileInfo(fi).isDir() ) { - m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); + m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); } else { if ( app ) - m.insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( runThis() ) ); + m->insertItem( app->pixmap(), tr( "Open in " + app->name() ), this, SLOT( runThis() ) ); else if( QFileInfo(fi).isExecutable() ) - m.insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); + m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); - m.insertItem( /*Resource::loadPixmap( "txt" ),*/ tr( "Open as text" ),this, SLOT( runText() ) ); + m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); } - m.insertSeparator(); + m->insertSeparator(); if(isLocalView) - m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); + m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); else - m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); + m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); - m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); - m.insertSeparator(); + m->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); + m->insertSeparator(); if(isLocalView) - m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); + m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); else - m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); + m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); - m.insertItem( tr( "Copy" ), this, SLOT( copy() )); - m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); - m.insertItem( tr( "Move" ), this, SLOT( move() )); - m.insertSeparator(); + m->insertItem( tr( "Copy" ), this, SLOT( copy() )); + m->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); + m->insertItem( tr( "Move" ), this, SLOT( move() )); + m->insertSeparator(); if(isLocalView) - m.insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); + m->insertItem( tr( "Rescan" ), this, SLOT( populateLocalView() )); else - m.insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); + m->insertItem( tr( "Rescan" ), this, SLOT( populateRemoteView() )); - m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); - m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); - m.insertSeparator(); + m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); + m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); + m->insertSeparator(); if(isLocalView) - m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); + m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); else - m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); + m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); - m.insertSeparator(); - m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); + m->insertSeparator(); + m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) //bad hack for Sharp zaurus failings - m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); - m.setCheckable(TRUE); + m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); + m->setCheckable(TRUE); if (!b) - m.setItemChecked(m.idAt(0),TRUE); + m->setItemChecked(m->idAt(0),TRUE); else - m.setItemChecked(m.idAt(0),FALSE); + m->setItemChecked(m->idAt(0),FALSE); if(Ir::supported()) - m.insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); - m.exec( QCursor::pos() ); + m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); + m->setFocus(); + m->exec( QCursor::pos() ); + if(m) delete m; } void AdvancedFm::cancelMenuTimer() { -qDebug("cancel menu timer"); + + qDebug("selectionChanged: cancel menu timer"); if( menuTimer.isActive() ) menuTimer.stop(); } diff --git a/noncore/apps/advancedfm/advancedfm.pro b/noncore/apps/advancedfm/advancedfm.pro index 25fb782..299f870 100644 --- a/noncore/apps/advancedfm/advancedfm.pro +++ b/noncore/apps/advancedfm/advancedfm.pro @@ -1,11 +1,11 @@ TEMPLATE = app CONFIG += qt warn_on release HEADERS = advancedfm.h inputDialog.h filePermissions.h output.h SOURCES = advancedfm.cpp inputDialog.cpp filePermissions.cpp output.cpp main.cpp TARGET = advancedfm REQUIRES=medium-config INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include DESTDIR = $(OPIEDIR)/bin -LIBS += -lqpe +LIBS += -lqpe -lopie |