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 | |||
@@ -271,9 +271,12 @@ void AdvancedFm::upDir() { | |||
271 | update(); | 271 | update(); |
272 | } | 272 | } |
273 | 273 | ||
274 | void AdvancedFm::copyTimer() { | ||
275 | QTimer::singleShot(125,this,SLOT(copy())); | ||
276 | } | ||
277 | |||
274 | void AdvancedFm::copy() { | 278 | void AdvancedFm::copy() { |
275 | qApp->processEvents(); | 279 | QStringList curFileList = getPath(); |
276 | QStringList curFileList = getPath(); | ||
277 | 280 | ||
278 | QDir *thisDir = CurrentDir(); | 281 | QDir *thisDir = CurrentDir(); |
279 | QDir *thatDir = OtherDir(); | 282 | QDir *thatDir = OtherDir(); |
@@ -312,8 +315,8 @@ void AdvancedFm::copy() { | |||
312 | if( f.exists()) { | 315 | if( f.exists()) { |
313 | if(doMsg) { | 316 | if(doMsg) { |
314 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 317 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
315 | tr("%1 exists. Ok to overwrite?").arg( item ), | 318 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), |
316 | tr("Yes"),tr("No"),0,0,1) ) { | 319 | tr("Yes"),tr("No"),0,0,1)) { |
317 | case 1: | 320 | case 1: |
318 | return; | 321 | return; |
319 | break; | 322 | break; |
@@ -324,15 +327,18 @@ void AdvancedFm::copy() { | |||
324 | 327 | ||
325 | if( !copyFile( curFile, destFile) ) { | 328 | if( !copyFile( curFile, destFile) ) { |
326 | QMessageBox::message("AdvancedFm", | 329 | QMessageBox::message("AdvancedFm", |
327 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); | 330 | tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
328 | return; | 331 | return; |
329 | } | 332 | } |
330 | } | 333 | } |
331 | setOtherTabCurrent(); | 334 | rePopulate(); |
332 | rePopulate(); | ||
333 | } | 335 | } |
334 | } | 336 | } |
335 | 337 | ||
338 | void AdvancedFm::copyAsTimer() { | ||
339 | QTimer::singleShot(125,this,SLOT(copyAs())); | ||
340 | } | ||
341 | |||
336 | void AdvancedFm::copyAs() { | 342 | void AdvancedFm::copyAs() { |
337 | 343 | ||
338 | QStringList curFileList = getPath(); | 344 | QStringList curFileList = getPath(); |
@@ -346,7 +352,7 @@ void AdvancedFm::copyAs() { | |||
346 | QString destFile; | 352 | QString destFile; |
347 | item=(*it); | 353 | item=(*it); |
348 | curFile = thisDir->canonicalPath()+"/"+(*it); | 354 | curFile = thisDir->canonicalPath()+"/"+(*it); |
349 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); | 355 | fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0); |
350 | 356 | ||
351 | fileDlg->setInputText((const QString &) destFile ); | 357 | fileDlg->setInputText((const QString &) destFile ); |
352 | fileDlg->exec(); | 358 | fileDlg->exec(); |
@@ -358,7 +364,7 @@ void AdvancedFm::copyAs() { | |||
358 | QFile f( destFile); | 364 | QFile f( destFile); |
359 | if( f.exists()) { | 365 | if( f.exists()) { |
360 | switch (QMessageBox::warning(this,tr("File Exists!"), | 366 | switch (QMessageBox::warning(this,tr("File Exists!"), |
361 | item+tr("\nexists. Ok to overwrite?"), | 367 | tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item), |
362 | tr("Yes"),tr("No"),0,0,1) ) { | 368 | tr("Yes"),tr("No"),0,0,1) ) { |
363 | case 0: | 369 | case 0: |
364 | f.remove(); | 370 | f.remove(); |
@@ -369,8 +375,7 @@ void AdvancedFm::copyAs() { | |||
369 | }; | 375 | }; |
370 | } | 376 | } |
371 | if( !copyFile( curFile, destFile) ) { | 377 | if( !copyFile( curFile, destFile) ) { |
372 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 378 | QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
373 | +curFile +tr("to\n")+destFile); | ||
374 | return; | 379 | return; |
375 | } | 380 | } |
376 | } | 381 | } |
@@ -378,11 +383,15 @@ void AdvancedFm::copyAs() { | |||
378 | 383 | ||
379 | } | 384 | } |
380 | rePopulate(); | 385 | rePopulate(); |
381 | setOtherTabCurrent(); | 386 | // setOtherTabCurrent(); |
382 | qApp->processEvents(); | 387 | qApp->processEvents(); |
383 | 388 | ||
384 | } | 389 | } |
385 | 390 | ||
391 | void AdvancedFm::copySameDirTimer() { | ||
392 | QTimer::singleShot(125,this,SLOT(copySameDir())); | ||
393 | } | ||
394 | |||
386 | void AdvancedFm::copySameDir() { | 395 | void AdvancedFm::copySameDir() { |
387 | qApp->processEvents(); | 396 | qApp->processEvents(); |
388 | QStringList curFileList = getPath(); | 397 | QStringList curFileList = getPath(); |
@@ -407,7 +416,7 @@ void AdvancedFm::copySameDir() { | |||
407 | QFile f(destFile); | 416 | QFile f(destFile); |
408 | if( f.exists()) { | 417 | if( f.exists()) { |
409 | switch (QMessageBox::warning(this,tr("Delete"), | 418 | switch (QMessageBox::warning(this,tr("Delete"), |
410 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 419 | tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), |
411 | tr("Yes"),tr("No"),0,0,1) ) { | 420 | tr("Yes"),tr("No"),0,0,1) ) { |
412 | case 0: | 421 | case 0: |
413 | 422 | ||
@@ -419,8 +428,7 @@ void AdvancedFm::copySameDir() { | |||
419 | }; | 428 | }; |
420 | } | 429 | } |
421 | if(!copyFile( curFile,destFile) ) { | 430 | if(!copyFile( curFile,destFile) ) { |
422 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 431 | QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
423 | +curFile +tr("to\n")+destFile); | ||
424 | return; | 432 | return; |
425 | } | 433 | } |
426 | 434 | ||
@@ -431,8 +439,11 @@ void AdvancedFm::copySameDir() { | |||
431 | rePopulate(); | 439 | rePopulate(); |
432 | } | 440 | } |
433 | 441 | ||
442 | void AdvancedFm::moveTimer() { | ||
443 | QTimer::singleShot(125,this,SLOT(move())); | ||
444 | } | ||
445 | |||
434 | void AdvancedFm::move() { | 446 | void AdvancedFm::move() { |
435 | qApp->processEvents(); | ||
436 | 447 | ||
437 | QStringList curFileList = getPath(); | 448 | QStringList curFileList = getPath(); |
438 | if( curFileList.count() > 0) { | 449 | if( curFileList.count() > 0) { |
@@ -460,20 +471,19 @@ void AdvancedFm::move() { | |||
460 | rePopulate(); | 471 | rePopulate(); |
461 | return; | 472 | return; |
462 | } | 473 | } |
463 | 474 | QFile f( curFile); | |
464 | QFile f( curFile); | ||
465 | if( f.exists()) { | 475 | if( f.exists()) { |
466 | if( !copyFile( curFile, destFile) ) { | 476 | if( !copyFile( curFile, destFile) ) { |
467 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 477 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
468 | return; | 478 | return; |
469 | } else | 479 | } else |
470 | QFile::remove(curFile); | 480 | QFile::remove(curFile); |
471 | } | 481 | } |
472 | } | 482 | } |
473 | 483 | ||
474 | } | 484 | } |
475 | rePopulate(); | 485 | rePopulate(); |
476 | setOtherTabCurrent(); | 486 | //setOtherTabCurrent(); |
477 | } | 487 | } |
478 | 488 | ||
479 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { | 489 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { |
@@ -506,67 +516,65 @@ bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { | |||
506 | 516 | ||
507 | 517 | ||
508 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | 518 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { |
509 | 519 | if(QFileInfo(src).isDir()) { | |
510 | 520 | if( copyDirectory( src, dest )) { | |
511 | if(QFileInfo(src).isDir()) { | 521 | // setOtherTabCurrent(); |
512 | if( copyDirectory( src, dest )) { | 522 | rePopulate(); |
513 | setOtherTabCurrent(); | 523 | return true; |
514 | populateView(); | 524 | } |
515 | return true; | 525 | else |
516 | } | 526 | return false; |
517 | else | 527 | } |
518 | return false; | 528 | |
519 | } | 529 | |
520 | 530 | bool success = true; | |
521 | 531 | struct stat status; | |
522 | bool success = true; | 532 | QFile srcFile(src); |
523 | struct stat status; | 533 | QFile destFile(dest); |
524 | QFile srcFile(src); | 534 | int err=0; |
525 | QFile destFile(dest); | 535 | int read_fd=0; |
526 | int err=0; | 536 | int write_fd=0; |
527 | int read_fd=0; | 537 | struct stat stat_buf; |
528 | int write_fd=0; | 538 | off_t offset = 0; |
529 | struct stat stat_buf; | 539 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { |
530 | off_t offset = 0; | ||
531 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { | ||
532 | // owarn << "open failed" << oendl; | 540 | // owarn << "open failed" << oendl; |
533 | return success = false; | 541 | return success = false; |
534 | } | 542 | } |
535 | read_fd = srcFile.handle(); | 543 | read_fd = srcFile.handle(); |
536 | if(read_fd != -1) { | 544 | if(read_fd != -1) { |
537 | fstat (read_fd, &stat_buf); | 545 | fstat (read_fd, &stat_buf); |
538 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { | 546 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { |
539 | // owarn << "destfile open failed" << oendl; | 547 | // owarn << "destfile open failed" << oendl; |
540 | return success = false; | 548 | return success = false; |
541 | } | 549 | } |
542 | write_fd = destFile.handle(); | 550 | write_fd = destFile.handle(); |
543 | if(write_fd != -1) { | 551 | if(write_fd != -1) { |
544 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); | 552 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); |
545 | if( err == -1) { | 553 | if( err == -1) { |
546 | QString msg; | 554 | QString msg; |
547 | switch(err) { | 555 | switch(err) { |
548 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; | 556 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; |
549 | case EINVAL: msg = "Descriptor is not valid or locked. "; | 557 | case EINVAL: msg = "Descriptor is not valid or locked. "; |
550 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; | 558 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; |
551 | case EIO: msg = "Unspecified error while reading from in_fd."; | 559 | case EIO: msg = "Unspecified error while reading from in_fd."; |
552 | }; | 560 | }; |
553 | success = false; | 561 | success = false; |
554 | // owarn << msg << oendl; | 562 | // owarn << msg << oendl; |
555 | } | 563 | } |
556 | } else { | 564 | } else { |
557 | success = false; | 565 | success = false; |
558 | } | 566 | } |
559 | } else { | 567 | } else { |
560 | success = false; | 568 | success = false; |
561 | } | 569 | } |
562 | srcFile.close(); | 570 | srcFile.close(); |
563 | destFile.close(); | 571 | destFile.close(); |
564 | // Set file permissions | 572 | // Set file permissions |
565 | if( stat( QFile::encodeName(src), &status ) == 0 ) { | 573 | if( stat( QFile::encodeName(src), &status ) == 0 ) { |
566 | chmod( QFile::encodeName(dest), status.st_mode ); | 574 | chmod( QFile::encodeName(dest), status.st_mode ); |
567 | } | 575 | } |
568 | 576 | ||
569 | return success; | 577 | return success; |
570 | } | 578 | } |
571 | 579 | ||
572 | void AdvancedFm::runCommand() { | 580 | void AdvancedFm::runCommand() { |
@@ -708,11 +716,9 @@ void AdvancedFm::startProcess(const QString & cmd) { | |||
708 | QStringList command; | 716 | QStringList command; |
709 | OProcess *process; | 717 | OProcess *process; |
710 | process = new OProcess(); | 718 | process = new OProcess(); |
711 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), | 719 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), this, SLOT( processEnded(Opie::Core::OProcess*))); |
712 | this, SLOT( processEnded(Opie::Core::OProcess*))); | ||
713 | 720 | ||
714 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), | 721 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); |
715 | this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); | ||
716 | 722 | ||
717 | command << "/bin/sh"; | 723 | command << "/bin/sh"; |
718 | command << "-c"; | 724 | command << "-c"; |
@@ -754,13 +760,13 @@ bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { | |||
754 | } | 760 | } |
755 | if ( o->inherits( "QListView" ) ) { | 761 | if ( o->inherits( "QListView" ) ) { |
756 | if ( e->type() == QEvent::FocusIn ) { | 762 | if ( e->type() == QEvent::FocusIn ) { |
757 | if( o == Local_View) { //keep track of which view | 763 | // if( o == Local_View) { //keep track of which view |
758 | qDebug("local view"); | 764 | // qDebug("local view"); |
759 | whichTab = 1; | 765 | // whichTab = 1; |
760 | } else { | 766 | // } else { |
761 | whichTab = 2; | 767 | // whichTab = 2; |
762 | qDebug("remote view"); | 768 | // qDebug("remote view"); |
763 | } | 769 | // } |
764 | } | 770 | } |
765 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection | 771 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection |
766 | } | 772 | } |
@@ -789,25 +795,18 @@ void AdvancedFm::doRename(QListView * view) { | |||
789 | QRect r = view->itemRect( view->currentItem( )); | 795 | QRect r = view->itemRect( view->currentItem( )); |
790 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 796 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
791 | r.setX( view->contentsX() ); | 797 | r.setX( view->contentsX() ); |
792 | 798 | if ( r.width() > view->visibleWidth() ) | |
793 | if ( r.width() > view->visibleWidth() ) | ||
794 | r.setWidth( view->visibleWidth() ); | 799 | r.setWidth( view->visibleWidth() ); |
795 | 800 | ||
796 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 801 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
797 | renameBox->setFrame(true); | 802 | renameBox->setFrame(true); |
798 | |||
799 | renameBox->setText( view->currentItem()->text(0) ); | 803 | renameBox->setText( view->currentItem()->text(0) ); |
800 | |||
801 | renameBox->selectAll(); | 804 | renameBox->selectAll(); |
802 | renameBox->installEventFilter( this ); | 805 | renameBox->installEventFilter( this ); |
803 | |||
804 | view->addChild( renameBox, r.x(), r.y() ); | 806 | view->addChild( renameBox, r.x(), r.y() ); |
805 | 807 | renameBox->resize( r.size() ); | |
806 | renameBox->resize( r.size() ); | 808 | view->viewport()->setFocusProxy( renameBox ); |
807 | 809 | renameBox->setFocus(); | |
808 | view->viewport()->setFocusProxy( renameBox ); | ||
809 | |||
810 | renameBox->setFocus(); | ||
811 | renameBox->show(); | 810 | renameBox->show(); |
812 | } | 811 | } |
813 | 812 | ||