Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 197 |
1 files changed, 98 insertions, 99 deletions
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 @@ -272,7 +272,10 @@ void AdvancedFm::upDir() { } +void AdvancedFm::copyTimer() { + QTimer::singleShot(125,this,SLOT(copy())); +} + void AdvancedFm::copy() { - qApp->processEvents(); - QStringList curFileList = getPath(); + QStringList curFileList = getPath(); QDir *thisDir = CurrentDir(); @@ -313,6 +316,6 @@ void AdvancedFm::copy() { 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("<p>%1 already exists. Ok to overwrite?</P>").arg(item), + tr("Yes"),tr("No"),0,0,1)) { case 1: return; @@ -325,13 +328,16 @@ void AdvancedFm::copy() { 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(); + rePopulate(); } } +void AdvancedFm::copyAsTimer() { + QTimer::singleShot(125,this,SLOT(copyAs())); +} + void AdvancedFm::copyAs() { @@ -347,5 +353,5 @@ void AdvancedFm::copyAs() { 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 ); @@ -359,5 +365,5 @@ void AdvancedFm::copyAs() { 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: @@ -370,6 +376,5 @@ void AdvancedFm::copyAs() { } 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; } @@ -379,9 +384,13 @@ void AdvancedFm::copyAs() { } rePopulate(); - setOtherTabCurrent(); +// setOtherTabCurrent(); qApp->processEvents(); } +void AdvancedFm::copySameDirTimer() { + QTimer::singleShot(125,this,SLOT(copySameDir())); +} + void AdvancedFm::copySameDir() { qApp->processEvents(); @@ -408,5 +417,5 @@ void AdvancedFm::copySameDir() { 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: @@ -420,6 +429,5 @@ void AdvancedFm::copySameDir() { } 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; } @@ -432,6 +440,9 @@ void AdvancedFm::copySameDir() { } +void AdvancedFm::moveTimer() { + QTimer::singleShot(125,this,SLOT(move())); +} + void AdvancedFm::move() { - qApp->processEvents(); QStringList curFileList = getPath(); @@ -461,6 +472,5 @@ void AdvancedFm::move() { return; } - - QFile f( curFile); + QFile f( curFile); if( f.exists()) { if( !copyFile( curFile, destFile) ) { @@ -468,11 +478,11 @@ void AdvancedFm::move() { return; } else - QFile::remove(curFile); + QFile::remove(curFile); } } } - rePopulate(); - setOtherTabCurrent(); + rePopulate(); +// setOtherTabCurrent(); } @@ -507,65 +517,63 @@ bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { - - - if(QFileInfo(src).isDir()) { - if( copyDirectory( src, dest )) { - setOtherTabCurrent(); - populateView(); - 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)) { + if(QFileInfo(src).isDir()) { + if( copyDirectory( src, dest )) { +// 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 ) ) { + return success = false; + } + read_fd = srcFile.handle(); + if(read_fd != -1) { + fstat (read_fd, &stat_buf); + if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { // owarn << "destfile open failed" << oendl; - return success = false; - } - write_fd = destFile.handle(); - if(write_fd != -1) { - err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); - if( err == -1) { - QString msg; - switch(err) { - case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; - case EINVAL: msg = "Descriptor is not valid or locked. "; - case ENOMEM: msg = "Insufficient memory to read from in_fd."; - case EIO: msg = "Unspecified error while reading from in_fd."; - }; - success = false; + return success = false; + } + write_fd = destFile.handle(); + if(write_fd != -1) { + err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); + if( err == -1) { + QString msg; + switch(err) { + case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; + case EINVAL: msg = "Descriptor is not valid or locked. "; + case ENOMEM: msg = "Insufficient memory to read from in_fd."; + case EIO: msg = "Unspecified error while reading from in_fd."; + }; + success = false; // owarn << msg << oendl; - } - } else { - success = false; - } - } else { - success = false; - } - srcFile.close(); - destFile.close(); - // Set file permissions - if( stat( QFile::encodeName(src), &status ) == 0 ) { - chmod( QFile::encodeName(dest), status.st_mode ); + } + } else { + success = false; + } + } else { + success = false; + } + srcFile.close(); + destFile.close(); + // Set file permissions + if( stat( QFile::encodeName(src), &status ) == 0 ) { + chmod( QFile::encodeName(dest), status.st_mode ); } - return success; + return success; } @@ -709,9 +717,7 @@ void AdvancedFm::startProcess(const QString & cmd) { 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"; @@ -755,11 +761,11 @@ bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { 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 @@ -790,23 +796,16 @@ void AdvancedFm::doRename(QListView * view) { r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); r.setX( view->contentsX() ); - - if ( r.width() > view->visibleWidth() ) + 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->resize( r.size() ); + view->viewport()->setFocusProxy( renameBox ); + renameBox->setFocus(); renameBox->show(); } |