author | llornkcor <llornkcor> | 2004-09-25 01:51:26 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-09-25 01:51:26 (UTC) |
commit | 40e681bf20db4f1e02212ae6e42a349ee000cf14 (patch) (side-by-side diff) | |
tree | 86eea5377011775ff87ca50e1fd125ff8f30622f | |
parent | 0fe000754035c737ff0de97e5b2bd2cf03c16337 (diff) | |
download | opie-40e681bf20db4f1e02212ae6e42a349ee000cf14.zip opie-40e681bf20db4f1e02212ae6e42a349ee000cf14.tar.gz opie-40e681bf20db4f1e02212ae6e42a349ee000cf14.tar.bz2 |
fix stuff
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 79 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 77 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.pro | 2 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmData.cpp | 60 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 73 |
5 files changed, 138 insertions, 153 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 4de7d38..02898de 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp @@ -29,102 +29,99 @@ #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(); whichTab = 1; populateView(); // rePopulate(); // currentPathCombo->setFocus(); channel = new QCopChannel( "QPE/Application/advancedfm", this ); - connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), - this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); + connect(channel,SIGNAL(received(const QCString&,const QByteArray&)),this,SLOT(qcopReceive(const QCString&,const QByteArray&))); // if( CurrentView() == Local_View) // qDebug("LOCAL VIEW"); // else // qDebug("REMOTE VIEW"); switchToLocalTab(); } 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 *wd) { - if(wd == tab) - odebug << "LOCAL VIEW SHOWN"<< oendl; - else if(wd == tab_2) - odebug<< "REMOTE VIEW SHOWN"<< oendl; - +// qDebug("tabChanged"); + if(wd == tab) { + whichTab = 1; +// qDebug("tabchanged: LOCAL VIEW SHOWN"); + } + else if(wd == tab_2) { + whichTab = 2; +// qDebug("tabchanged: REMOTE VIEW SHOWN"); + } + qApp->processEvents(); QString path = CurrentDir()->canonicalPath(); - currentPathCombo->lineEdit()->setText( path ); - +// qDebug(path); if ( TabWidget->currentWidget() == tab) { -// 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(tr("AdvancedFm :: ")+fs+" :: " +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); chdir( path.latin1()); - if( wd == Local_View) { - Remote_View->clearFocus(); - } else { - Local_View->clearFocus(); - } - + currentPathCombo->lineEdit()->setText(path); } void AdvancedFm::populateView() { QPixmap pm; QListView *thisView = CurrentView(); QDir *thisDir = CurrentDir(); QString path = thisDir->canonicalPath(); 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(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() ) { @@ -197,67 +194,68 @@ void AdvancedFm::populateView() { 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 ( 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); @@ -271,56 +269,60 @@ void AdvancedFm::ListClicked(QListViewItem *selectedItem) { 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() { + qDebug("switchToLocal "); TabWidget->setCurrentWidget(0); Local_View->setFocus(); + whichTab = 1; } void AdvancedFm::switchToRemoteTab() { + qDebug("switchToRemoteTab() "); TabWidget->setCurrentWidget(1); Remote_View->setFocus(); + whichTab = 2; } void AdvancedFm::readConfig() { Config cfg("AdvancedFm"); } void AdvancedFm::writeConfig() { Config cfg("AdvancedFm"); } void AdvancedFm::currentPathComboChanged() { if(QDir( currentPathCombo->lineEdit()->text()).exists()) { CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); populateView(); } else { QMessageBox::message(tr("Note"),tr("That directory does not exist")); } } void AdvancedFm::fillCombo(const QString ¤tPath) { if ( TabWidget->currentWidget() == tab) { // if ( whichTab == 1) { currentPathCombo->lineEdit()->setText( currentPath); @@ -377,52 +379,49 @@ void AdvancedFm::docButtonPushed() { } void AdvancedFm::SDButtonPushed() { QString current = "/mnt/card";// this can change so fix chdir( current.latin1() ); CurrentDir()->cd( current, TRUE); populateView(); update(); } 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() { - 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")); + 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) { // owarn << "key " << e->key() << "" << oendl; // 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: @@ -561,67 +560,66 @@ QString AdvancedFm::getDiskSpace( const QString &path) { return QString::number(availBlks * mult / div); } return ""; } 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() ) { m->insertSeparator(); m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); } 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() ) //damn opie doesnt like this m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); } m->insertItem(tr("Actions"),n); n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); n->insertSeparator(); n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); - n->insertItem( tr( "Copy" ), this, SLOT( copy() )); - n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); - n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); - n->insertItem( tr( "Move" ), this, SLOT( move() )); + n->insertItem(tr("Copy"),this,SLOT(copyTimer())); + n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); + n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); + n->insertItem(tr("Move"),this,SLOT(moveTimer())); n->insertSeparator(); n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); m->insertSeparator(); m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); #if defined(QT_QWS_OPIE) m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); #endif m->setCheckable(TRUE); if (!b) m->setItemChecked(m->idAt(0),TRUE); else m->setItemChecked(m->idAt(0),FALSE); if(Ir::supported()) m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); m->setFocus(); @@ -767,138 +765,133 @@ void AdvancedFm::removeCustomDir() { void AdvancedFm::gotoCustomDir(const QString &dir) { // odebug << "gotoCustomDir(const QString &dir) " +dir << oendl; // QString curDir = dir; // QDir *thisDir = CurrentDir(); // if( curDir.isEmpty()) { // } if( dir == s_addBookmark) { addCustomDir(); } if( dir == s_removeBookmark) { removeCustomDir( ); } else { gotoDirectory( dir); // if(QDir( curDir).exists() ) // { // thisDir->setPath( curDir ); // chdir( curDir.latin1() ); // thisDir->cd( curDir, TRUE); // populateView(); // } } } QDir *AdvancedFm::CurrentDir() { - - if ( TabWidget->currentWidget() == tab) - qDebug("CurrentTab is Local"); - else - qDebug("CurrentTab is Remote"); - if ( whichTab == 1) { +// qDebug("CurrentTab is Local"); return ¤tDir; } else { +// qDebug("CurrentTab is Remote"); return ¤tRemoteDir; } } QDir *AdvancedFm::OtherDir() { // if ( TabWidget->currentWidget() == tab) { if ( whichTab == 1) { return ¤tRemoteDir; } else { return ¤tDir; } } QListView * AdvancedFm::CurrentView() { - if ( TabWidget->currentWidget() == tab) - odebug << "CurrentView local" << oendl; - // 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); +// 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; gotoDirectory( (const QString &) file); } } void AdvancedFm::setDocument(const QString &file) { gotoDirectory( file); } void AdvancedFm::gotoDirectory(const QString &file) { - qDebug("goto dir "+file); +// qDebug("goto dir "+file); QString curDir = file; QDir *thisDir = CurrentDir(); if(QDir( curDir).exists() ) { thisDir->setPath( curDir ); chdir( curDir.latin1() ); thisDir->cd( curDir, TRUE); populateView(); } else if(QFileInfo(curDir).exists()) { QFileInfo fileInfo(curDir); curDir=fileInfo.dirPath(); if(QDir( curDir).exists() ) { thisDir->setPath( curDir ); chdir( curDir.latin1() ); thisDir->cd( curDir, TRUE); populateView(); } findFile(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 ) { -// odebug << "Switch " << item << "" << oendl; +void AdvancedFm::slotSwitchMenu(int 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 def6fe2..2234b3c 100644 --- a/noncore/apps/advancedfm/advancedfm.h +++ b/noncore/apps/advancedfm/advancedfm.h @@ -36,151 +36,160 @@ class QHBoxLayout; class QGridLayout; class QComboBox; class QListView; class QListviewItem; class QLabel; class QProgressBar; class QSpinBox; class QWidget; class QPopupMenu; class QFile; class QListViewItem; class QLineEdit; class MenuButton; class QToolButton; class Ir; class AdvancedFm : public QMainWindow { Q_OBJECT public: static QString appName() { return QString::fromLatin1("advancedfm"); } AdvancedFm(QWidget *p = 0, const char* name = 0, WFlags fl = 0); ~AdvancedFm(); -protected slots: - void slotSwitchMenu(int); - void selectAll(); - void addToDocs(); - void doDirChange(); - void mkDir(); - void del(); - void rn(); - void populateView(); - void rePopulate(); - void showHidden(); - void showMenuHidden(); - void writeConfig(); - void readConfig(); - void ListClicked(QListViewItem *); - void ListPressed( int, QListViewItem *, const QPoint&, int); - void makeDir(); - void doDelete(); - void tabChanged(QWidget*); - void cleanUp(); - void renameIt(); - void runThis(); - void runText(); - void filePerms(); - void doProperties(); - void runCommand(); - void runCommandStd(); - QStringList getPath(); - void mkSym(); - void switchToLocalTab(); - void switchToRemoteTab(); - void refreshCurrentTab(); protected: Opie::Ui::OSplitter *TabWidget; QCopChannel * channel; QPixmap unknownXpm; int whichTab; // QTabWidget *TabWidget; QWidget *tab, *tab_2, *tab_3; QListView *Local_View, *Remote_View; QLineEdit *currentPathEdit; QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu /*, *customDirMenu*/; QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; QDir currentDir, currentRemoteDir; QComboBox *currentPathCombo; QString filterStr, s_addBookmark, s_removeBookmark; QListViewItem * item; bool b; QStringList fileSystemTypeList, fsList; int currentServerConfig; bool zaurusDevice; QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; QStringList remoteDirPathStringList, localDirPathStringList; QLineEdit *renameBox; void init(); void initConnections(); void keyReleaseEvent( QKeyEvent *); void keyPressEvent( QKeyEvent *); QString getFileSystemType(const QString &); QString getDiskSpace(const QString &); void parsetab(const QString &fileName); QString checkDiskSpace(const QString &); QString dealWithSymName(const QString &); QDir *CurrentDir(); QDir *OtherDir(); QListView *CurrentView(); QListView *OtherView(); void setOtherTabCurrent(); +//protected signals: +// void newPath(QString); + protected slots: + void slotSwitchMenu(int); + void selectAll(); + void addToDocs(); + void doDirChange(); + void mkDir(); + void del(); + void rn(); + void populateView(); + void rePopulate(); + void showHidden(); + void showMenuHidden(); + void writeConfig(); + void readConfig(); + void ListClicked(QListViewItem *); + void ListPressed( int, QListViewItem *, const QPoint&, int); + void makeDir(); + void doDelete(); + void tabChanged(QWidget*); + void cleanUp(); + void renameIt(); + void runThis(); + void runText(); + void filePerms(); + void doProperties(); + void runCommand(); + void runCommandStd(); + QStringList getPath(); + void mkSym(); + 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 currentPathComboActivated(const QString &); void fillCombo(const QString &); bool copyFile( const QString & , const QString & ); - void move(); 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; + 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 gotoDirectory(const QString &); 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/advancedfm.pro b/noncore/apps/advancedfm/advancedfm.pro index 0644edb..713f61c 100644 --- a/noncore/apps/advancedfm/advancedfm.pro +++ b/noncore/apps/advancedfm/advancedfm.pro @@ -1,15 +1,15 @@ TEMPLATE = app -CONFIG += qt warn_on quick-app +CONFIG += qte warn_on quick-app HEADERS = advancedfm.h filePermissions.h output.h SOURCES = advancedfm.cpp advancedfmData.cpp advancedfmMenu.cpp filePermissions.cpp output.cpp main.cpp TARGET = advancedfm INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lqte -lopiecore2 -lopieui2 !contains(CONFIG,quick-app) { DESTDIR = $(OPIEDIR)/bin DEFINES += NOQUICKLAUNCH } include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp index 1802571..d2e1d8e 100644 --- a/noncore/apps/advancedfm/advancedfmData.cpp +++ b/noncore/apps/advancedfm/advancedfmData.cpp @@ -227,70 +227,54 @@ void AdvancedFm::init() { odebug << "not have sd" << oendl; sdButton->hide(); } if( !StorageInfo::hasCf() ) { odebug << "not have cf" << oendl; cfButton->hide(); } 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="*"; showMenuHidden(); TabWidget->setCurrentWidget(0); } void AdvancedFm::initConnections() { - connect( qApp,SIGNAL( aboutToQuit()), - this, SLOT( cleanUp()) ); - connect( qpeDirButton ,SIGNAL(released()), - this,SLOT( QPEButtonPushed()) ); - connect( cfButton ,SIGNAL(released()), - this,SLOT( CFButtonPushed()) ); - connect( sdButton ,SIGNAL(released()), - this,SLOT( SDButtonPushed()) ); - connect( cdUpButton ,SIGNAL(released()), - this,SLOT( upDir()) ); - connect( docButton,SIGNAL(released()), - this,SLOT( docButtonPushed()) ); - connect( homeButton,SIGNAL(released()), - this,SLOT( homeButtonPushed()) ); - connect( currentPathCombo, SIGNAL( activated(const QString&) ), - this, SLOT( currentPathComboActivated(const QString&) ) ); - - connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), - this,SLOT(currentPathComboChanged())); - - connect( Local_View, SIGNAL( clicked(QListViewItem*)), - this,SLOT( ListClicked(QListViewItem*)) ); - - connect( Local_View, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), - this,SLOT( ListPressed(int,QListViewItem*,const QPoint&,int)) ); - - connect( Remote_View, SIGNAL( clicked(QListViewItem*)), - this,SLOT( ListClicked(QListViewItem*)) ); - connect( Remote_View, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), - this,SLOT( ListPressed(int,QListViewItem*,const QPoint&,int)) ); - - connect( TabWidget,SIGNAL(currentChanged(QWidget*)), - this,SLOT(tabChanged(QWidget*))); - - connect( Remote_View, SIGNAL(rightButtonPressed(QListViewItem*, const QPoint&, int)), - this, SLOT(showFileMenu())); - connect( Local_View, SIGNAL(rightButtonPressed(QListViewItem*, const QPoint&,int)), - this, SLOT(showFileMenu())); + connect(qApp,SIGNAL(aboutToQuit()),this,SLOT(cleanUp())); + connect( qpeDirButton ,SIGNAL(released()),this,SLOT( QPEButtonPushed()) ); + connect( cfButton ,SIGNAL(released()), this,SLOT( CFButtonPushed()) ); + connect( sdButton ,SIGNAL(released()), this,SLOT( SDButtonPushed()) ); + connect( cdUpButton ,SIGNAL(released()), this,SLOT( upDir()) ); + connect( docButton,SIGNAL(released()), this,SLOT( docButtonPushed()) ); + connect( homeButton,SIGNAL(released()), this,SLOT( homeButtonPushed()) ); + connect( currentPathCombo, SIGNAL( activated(const QString&) ), this, SLOT( currentPathComboActivated(const QString&) ) ); + + connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), this,SLOT(currentPathComboChanged())); + + connect( Local_View, SIGNAL( clicked(QListViewItem*)), this,SLOT( ListClicked(QListViewItem*)) ); + + connect( Local_View, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), this,SLOT( ListPressed(int,QListViewItem*,const QPoint&,int)) ); + + connect( Remote_View, SIGNAL( clicked(QListViewItem*)), this,SLOT( ListClicked(QListViewItem*)) ); + connect( Remote_View, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), this,SLOT( ListPressed(int,QListViewItem*,const QPoint&,int)) ); + + connect( TabWidget,SIGNAL(currentChanged(QWidget*)), this,SLOT(tabChanged(QWidget*))); + + connect( Remote_View, SIGNAL(rightButtonPressed(QListViewItem*, const QPoint&, int)), this, SLOT(showFileMenu())); + connect( Local_View, SIGNAL(rightButtonPressed(QListViewItem*, const QPoint&,int)), this, 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 8d04c68..5a46579 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp @@ -250,289 +250,297 @@ void AdvancedFm::doProperties() { for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { // odebug << (filePath+*it) << oendl; DocLnk lnk( (filePath+*it)); LnkProperties prop( &lnk ); QPEApplication::execDialog( &prop ); } #endif } 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::copyTimer() { + QTimer::singleShot(125,this,SLOT(copy())); +} + void AdvancedFm::copy() { - qApp->processEvents(); QStringList curFileList = getPath(); QDir *thisDir = CurrentDir(); QDir *thatDir = OtherDir(); bool doMsg=true; int count=curFileList.count(); if( count > 0) { if(count > 1 ){ QString msg; msg=tr("Really copy\n%1 files?").arg(count); switch ( QMessageBox::warning(this,tr("Copy"),msg ,tr("Yes"),tr("No"),0,0,1) ) { case 0: doMsg=false; break; case 1: return; break; }; } QString curFile, item, destFile; 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; // odebug << "Destination file is "+destFile << oendl; // odebug << "CurrentFile file is " + curFile << oendl; QFile f(destFile); if( f.exists()) { if(doMsg) { switch ( QMessageBox::warning(this,tr("File Exists!"), - tr("%1 exists. Ok to overwrite?").arg( item ), + tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), 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 ) ); + tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); return; } } - setOtherTabCurrent(); rePopulate(); } } +void AdvancedFm::copyAsTimer() { + QTimer::singleShot(125,this,SLOT(copyAs())); +} + void AdvancedFm::copyAs() { QStringList curFileList = getPath(); QString curFile, item; InputDialog *fileDlg; QDir *thisDir = CurrentDir(); QDir *thatDir = OtherDir(); 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 = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0); fileDlg->setInputText((const QString &) destFile ); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text(); destFile = thatDir->canonicalPath()+"/"+filename; QFile f( destFile); if( f.exists()) { switch (QMessageBox::warning(this,tr("File Exists!"), - item+tr("\nexists. Ok to overwrite?"), + tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item), tr("Yes"),tr("No"),0,0,1) ) { case 0: f.remove(); break; case 1: return; break; }; } if( !copyFile( curFile, destFile) ) { - QMessageBox::message("AdvancedFm",tr("Could not copy\n") - +curFile +tr("to\n")+destFile); + QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); return; } } delete fileDlg; } rePopulate(); - setOtherTabCurrent(); +// setOtherTabCurrent(); qApp->processEvents(); } +void AdvancedFm::copySameDirTimer() { + QTimer::singleShot(125,this,SLOT(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 ) { 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 ) { QString filename = fileDlg->LineEdit1->text(); destFile = thisDir->canonicalPath()+"/"+filename; QFile f(destFile); if( f.exists()) { switch (QMessageBox::warning(this,tr("Delete"), - destFile+tr(" already exists.\nDo you really want to delete it?"), + tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), tr("Yes"),tr("No"),0,0,1) ) { case 0: f.remove(); break; case 1: return; break; }; } if(!copyFile( curFile,destFile) ) { - QMessageBox::message("AdvancedFm",tr("Could not copy\n") - +curFile +tr("to\n")+destFile); + QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); return; } // odebug << "copy "+curFile+" as "+destFile << oendl; } delete fileDlg; } rePopulate(); } +void AdvancedFm::moveTimer() { + QTimer::singleShot(125,this,SLOT(move())); +} + void AdvancedFm::move() { - qApp->processEvents(); QStringList curFileList = getPath(); if( curFileList.count() > 0) { QString curFile, destFile, item; QDir *thisDir = CurrentDir(); QDir *thatDir = OtherDir(); 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; // odebug << "Destination file is "+destFile << oendl; curFile = thisDir->canonicalPath(); if(curFile.right(1).find("/",0,TRUE) == -1) curFile +="/"; curFile+= item; // odebug << "CurrentFile file is " + curFile << oendl; if(QFileInfo(curFile).isDir()) { moveDirectory( curFile, destFile ); rePopulate(); return; } - 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); } } } rePopulate(); - setOtherTabCurrent(); +// setOtherTabCurrent(); } bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { int err = 0; if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src; err = system((const char*)cmd); } else err = -1; if(err!=0) { QMessageBox::message(tr("Note"),tr("Could not move\n") + src); return false; } return true; } bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { QString cmd = "/bin/cp -fpR " + src + " " + dest; owarn << cmd << oendl; int err = system( (const char *) cmd ); if ( err != 0 ) { QMessageBox::message("AdvancedFm", tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) ); return false; } return true; } bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { - - if(QFileInfo(src).isDir()) { if( copyDirectory( src, dest )) { - setOtherTabCurrent(); - populateView(); +// setOtherTabCurrent(); + rePopulate(); return true; } else return false; } 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)) { // owarn << "open failed" << oendl; return success = false; } read_fd = srcFile.handle(); if(read_fd != -1) { fstat (read_fd, &stat_buf); if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { @@ -687,147 +695,138 @@ void AdvancedFm::doBeam() { curFilePath = curFilePath.left( curFilePath.length() -1); } Ir *file = new Ir(this, "IR"); connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); file->send( curFilePath, curFile ); } } } } void AdvancedFm::fileBeamFinished( Ir *) { QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); } void AdvancedFm::selectAll() { QListView *thisView = CurrentView(); thisView->selectAll(true); thisView->setSelected( thisView->firstChild(),false); } void AdvancedFm::startProcess(const QString & cmd) { QStringList command; OProcess *process; process = new OProcess(); - connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), - this, SLOT( processEnded(Opie::Core::OProcess*))); + connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), this, SLOT( processEnded(Opie::Core::OProcess*))); - connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), - this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); + connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); command << "/bin/sh"; command << "-c"; command << cmd.latin1(); *process << command; if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) odebug << "could not start process" << oendl; } void AdvancedFm::processEnded(OProcess *) { rePopulate(); } void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { // owarn << "received stderrt " << buflen << " bytes" << oendl; QString lineStr = buffer; QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); } 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 ) { okRename(); return true; } else if ( ke->key() == Key_Escape ) { cancelRename(); return true; } } else if ( e->type() == QEvent::FocusOut ) { cancelRename(); return true; } } if ( o->inherits( "QListView" ) ) { if ( e->type() == QEvent::FocusIn ) { - if( o == Local_View) { //keep track of which view - qDebug("local view"); - whichTab = 1; - } else { - whichTab = 2; - qDebug("remote view"); - } +// if( o == Local_View) { //keep track of which view +// qDebug("local view"); +// whichTab = 1; +// } else { +// whichTab = 2; +// qDebug("remote view"); +// } } OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection } return QWidget::eventFilter( o, e ); } void AdvancedFm::cancelRename() { // odebug << "cancel rename" << oendl; QListView * view; view = CurrentView(); bool resetFocus = view->viewport()->focusProxy() == renameBox; delete renameBox; renameBox = 0; if ( resetFocus ) { view->viewport()->setFocusProxy( view); view->setFocus(); } } 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" ); renameBox->setFrame(true); - renameBox->setText( view->currentItem()->text(0) ); - 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() { if( !CurrentView()->currentItem()) return; QListView *thisView = CurrentView(); oldName = thisView->currentItem()->text(0); doRename( thisView ); } void AdvancedFm::okRename() { if( !renameBox) return; QString newName = renameBox->text(); cancelRename(); QListView * view = CurrentView(); QString path = CurrentDir()->canonicalPath() + "/"; oldName = path + oldName; newName = path + newName; if( rename( oldName.latin1(), newName.latin1())== -1) QMessageBox::message(tr("Note"),tr("Could not rename")); |