-rw-r--r-- | noncore/unsupported/filebrowser/filebrowser.cpp | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/noncore/unsupported/filebrowser/filebrowser.cpp b/noncore/unsupported/filebrowser/filebrowser.cpp index 10e50f0..7dabdb6 100644 --- a/noncore/unsupported/filebrowser/filebrowser.cpp +++ b/noncore/unsupported/filebrowser/filebrowser.cpp | |||
@@ -497,114 +497,114 @@ bool FileView::copyFile( const QString & dest, const QString & src ) | |||
497 | if( s.open( IO_ReadOnly | IO_Raw ) && | 497 | if( s.open( IO_ReadOnly | IO_Raw ) && |
498 | d.open( IO_WriteOnly | IO_Raw ) ) | 498 | d.open( IO_WriteOnly | IO_Raw ) ) |
499 | { | 499 | { |
500 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == | 500 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == |
501 | sizeof( bf ) ) | 501 | sizeof( bf ) ) |
502 | { | 502 | { |
503 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 503 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
504 | success = FALSE; | 504 | success = FALSE; |
505 | break; | 505 | break; |
506 | } | 506 | } |
507 | } | 507 | } |
508 | if( success && (bytesRead > 0) ){ | 508 | if( success && (bytesRead > 0) ){ |
509 | d.writeBlock( bf, bytesRead ); | 509 | d.writeBlock( bf, bytesRead ); |
510 | } | 510 | } |
511 | } else { | 511 | } else { |
512 | success = FALSE; | 512 | success = FALSE; |
513 | } | 513 | } |
514 | 514 | ||
515 | // Set file permissions | 515 | // Set file permissions |
516 | if( stat( (const char *) src, &status ) == 0 ){ | 516 | if( stat( (const char *) src, &status ) == 0 ){ |
517 | chmod( (const char *) dest, status.st_mode ); | 517 | chmod( (const char *) dest, status.st_mode ); |
518 | } | 518 | } |
519 | 519 | ||
520 | return success; | 520 | return success; |
521 | } | 521 | } |
522 | 522 | ||
523 | void FileView::cut() | 523 | void FileView::cut() |
524 | { | 524 | { |
525 | int err; | 525 | int err; |
526 | // ##### a better inmplementation might be to rename the CUT file | 526 | // ##### a better inmplementation might be to rename the CUT file |
527 | // ##### to ".QPE-FILEBROWSER-MOVING" rather than copying it. | 527 | // ##### to ".QPE-FILEBROWSER-MOVING" rather than copying it. |
528 | QString cmd, dest, basename, cd = "/tmp/qpemoving"; | 528 | QString cmd, dest, basename, cd = "/tmp/qpemoving"; |
529 | QStringList newflist; | 529 | QStringList newflist; |
530 | newflist.clear(); | 530 | newflist.clear(); |
531 | 531 | ||
532 | cmd = "rm -rf " + cd; | 532 | cmd = "rm -rf " + cd; |
533 | system ( (const char *) cmd ); | 533 | system ( (const char *) cmd ); |
534 | cmd = "mkdir " + cd; | 534 | cmd = "mkdir " + cd; |
535 | system( (const char *) cmd ); | 535 | system( (const char *) cmd ); |
536 | 536 | ||
537 | // get the names of the files to cut | 537 | // get the names of the files to cut |
538 | FileItem * item; | 538 | FileItem * item; |
539 | 539 | ||
540 | if((item = (FileItem *) firstChild()) == 0) return; | 540 | if((item = (FileItem *) firstChild()) == 0) return; |
541 | 541 | ||
542 | flist.clear(); | 542 | flist.clear(); |
543 | while( item ){ | 543 | while( item ){ |
544 | if( ite | 544 | if( ite |
545 | // ##### a better inmplementation might be to rename the CUT file | 545 | // ##### a better inmplementation might be to rename the CUT file |
546 | // ##### to ".QPE-FILEBROWSER-MOVING" rather than copying it. | 546 | // ##### to ".QPE-FILEBROWSER-MOVING" rather than copying it. |
547 | QString cmd, dest, basename, cd = "/tmp/qpemoving"; | 547 | QString cmd, dest, basename, cd = "/tmp/qpemoving"; |
548 | QStringList newflist; | 548 | QStringList newflist; |
549 | newflist.clear(); | 549 | newflist.clear(); |
550 | 550 | ||
551 | cmd = "rm -rf " + cd; | 551 | cmd = "rm -rf " + cd; |
552 | system ( (const char *) cmd ); | 552 | system ( (const char *) cmd ); |
553 | cmd = "mkdir " + cd; | 553 | cmd = "mkdir " + cd; |
554 | system( (const char *) cmd ); | 554 | system( (const char *) cmd ); |
555 | 555 | ||
556 | // get the names of the files to cut | 556 | // get the names of the files to cut |
557 | FileItem * item; | 557 | FileItem * item; |
558 | 558 | ||
559 | if((item = (FileItem *) firstChild()) == 0) return; | 559 | if((item = (FileItem *) firstChild()) == 0) return; |
560 | 560 | ||
561 | flist.clear(); | 561 | flist.clear(); |
562 | while( item ){ | 562 | while( item ){ |
563 | if( item->isSelected() /*&& !item->isDir()*/ ){ | 563 | if( item->isSelected() /*&& !item->isDir()*/ ){ |
564 | flist += item->getFilePath(); | 564 | flist += item->getFilePath(); |
565 | } | 565 | } |
566 | item = (FileItem *) item->nextSibling(); | 566 | item = (FileItem *) item->nextSibling(); |
567 | } | 567 | } |
568 | 568 | ||
569 | // move these files into a tmp dir | 569 | // move these files into a tmp dir |
570 | for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) { | 570 | for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) { |
571 | basename = (*it).mid((*it).findRev("/") + 1, (*it).length()); | 571 | basename = (*it).mid((*it).findRev("/") + 1, (*it).length()); |
572 | 572 | ||
573 | dest = cd + "/" + basename; | 573 | dest = cd + "/" + basename; |
574 | 574 | ||
575 | newflist += dest; | 575 | newflist += dest; |
576 | 576 | ||
577 | cmd = "/bin/mv -f \"" + (*it) +"\" " + "\"" + dest + "\""; | 577 | cmd = "/bin/mv -f \"" + (*it) +"\" " + "\"" + dest + "\""; |
578 | err = system( (const char *) cmd ); | 578 | err = system( (const char *) cmd ); |
579 | 579 | ||
580 | if ( err != 0 ) { | 580 | if ( err != 0 ) { |
581 | QMessageBox::warning( this, tr("Cut file"), tr("Cut failed!"), | 581 | QMessageBox::warning( this, tr("Cut file"), tr("Cut failed!"), |
582 | tr("Ok") ); | 582 | tr("Ok") ); |
583 | break; | 583 | break; |
584 | } else { | 584 | } else { |
585 | updateDir(); | 585 | updateDir(); |
586 | QListViewItem * im = firstChild(); | 586 | QListViewItem * im = firstChild(); |
587 | basename = dest.mid( dest.findRev("/") + 1, dest.length() ); | 587 | basename = dest.mid( dest.findRev("/") + 1, dest.length() ); |
588 | 588 | ||
589 | while( im ){ | 589 | while( im ){ |
590 | if( im->text(0) == basename ){ | 590 | if( im->text(0) == basename ){ |
591 | setCurrentItem( im ); | 591 | setCurrentItem( im ); |
592 | ensureItemVisible( im ); | 592 | ensureItemVisible( im ); |
593 | break; | 593 | break; |
594 | } | 594 | } |
595 | im = im->nextSibling(); | 595 | im = im->nextSibling(); |
596 | } | 596 | } |
597 | } | 597 | } |
598 | } | 598 | } |
599 | 599 | ||
600 | // update the filelist to point to tmp dir so paste works nicely | 600 | // update the filelist to point to tmp dir so paste works nicely |
601 | flist = newflist; | 601 | flist = newflist; |
602 | } | 602 | } |
603 | 603 | ||
604 | void FileView::del() | 604 | void FileView::del() |
605 | { | 605 | { |
606 | FileItem * i; | 606 | FileItem * i; |
607 | QStringList fl; | 607 | QStringList fl; |
608 | QString cmd; | 608 | QString cmd; |
609 | int err; | 609 | int err; |
610 | 610 | ||
@@ -1063,67 +1063,67 @@ void FileView::chPerm() { | |||
1063 | 1063 | ||
1064 | void FileBrowser::updateShowHidden() | 1064 | void FileBrowser::updateShowHidden() |
1065 | { | 1065 | { |
1066 | bool valShowHidden=viewMenu->isItemChecked( viewMenu->idAt( 0 ) ); | 1066 | bool valShowHidden=viewMenu->isItemChecked( viewMenu->idAt( 0 ) ); |
1067 | valShowHidden=!valShowHidden; | 1067 | valShowHidden=!valShowHidden; |
1068 | viewMenu->setItemChecked( viewMenu->idAt( 0 ), valShowHidden ); | 1068 | viewMenu->setItemChecked( viewMenu->idAt( 0 ), valShowHidden ); |
1069 | fileView->setShowHidden(valShowHidden); | 1069 | fileView->setShowHidden(valShowHidden); |
1070 | 1070 | ||
1071 | Config cfg("Filebrowser"); | 1071 | Config cfg("Filebrowser"); |
1072 | cfg.setGroup("View"); | 1072 | cfg.setGroup("View"); |
1073 | cfg.writeEntry("Hidden",valShowHidden?"TRUE":"FALSE"); | 1073 | cfg.writeEntry("Hidden",valShowHidden?"TRUE":"FALSE"); |
1074 | 1074 | ||
1075 | fileView->updateDir(); | 1075 | fileView->updateDir(); |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | void FileBrowser::updateShowSymlinks() | 1078 | void FileBrowser::updateShowSymlinks() |
1079 | { | 1079 | { |
1080 | bool valShowSymlinks=viewMenu->isItemChecked( viewMenu->idAt( 1 ) ); | 1080 | bool valShowSymlinks=viewMenu->isItemChecked( viewMenu->idAt( 1 ) ); |
1081 | valShowSymlinks=!valShowSymlinks; | 1081 | valShowSymlinks=!valShowSymlinks; |
1082 | viewMenu->setItemChecked( viewMenu->idAt( 1 ), valShowSymlinks ); | 1082 | viewMenu->setItemChecked( viewMenu->idAt( 1 ), valShowSymlinks ); |
1083 | fileView->setShowSymlinks(valShowSymlinks); | 1083 | fileView->setShowSymlinks(valShowSymlinks); |
1084 | 1084 | ||
1085 | Config cfg("Filebrowser"); | 1085 | Config cfg("Filebrowser"); |
1086 | cfg.setGroup("View"); | 1086 | cfg.setGroup("View"); |
1087 | cfg.writeEntry("Symlinks",valShowSymlinks?"TRUE":"FALSE"); | 1087 | cfg.writeEntry("Symlinks",valShowSymlinks?"TRUE":"FALSE"); |
1088 | 1088 | ||
1089 | fileView->updateDir(); | 1089 | fileView->updateDir(); |
1090 | } | 1090 | } |
1091 | 1091 | ||
1092 | void FileBrowser::updateShowThumbnails() | 1092 | void FileBrowser::updateShowThumbnails() |
1093 | { | 1093 | { |
1094 | bool valShowThumbnails=viewMenu->isItemChecked( viewMenu->idAt( 2 ) ); | 1094 | bool valShowThumbnails=viewMenu->isItemChecked( viewMenu->idAt( 2 ) ); |
1095 | valShowThumbnails=!valShowThumbnails; | 1095 | valShowThumbnails=!valShowThumbnails; |
1096 | viewMenu->setItemChecked( viewMenu->idAt( 2 ), valShowThumbnails ); | 1096 | viewMenu->setItemChecked( viewMenu->idAt( 2 ), valShowThumbnails ); |
1097 | fileView->setShowThumbnails(valShowThumbnails); | 1097 | fileView->setShowThumbnails(valShowThumbnails); |
1098 | 1098 | ||
1099 | Config cfg("Filebrowser"); | 1099 | Config cfg("Filebrowser"); |
1100 | cfg.setGroup("View"); | 1100 | cfg.setGroup("View"); |
1101 | cfg.writeEntry("Thumbnails",valShowThumbnails?"TRUE":"FALSE"); | 1101 | cfg.writeEntry("Thumbnails",valShowThumbnails?"TRUE":"FALSE"); |
1102 | 1102 | ||
1103 | fileView->updateDir(); | 1103 | fileView->updateDir(); |
1104 | } | 1104 | } |
1105 | 1105 | ||
1106 | void FileBrowser::cleanUp() { | 1106 | void FileBrowser::cleanUp() { |
1107 | QString cmdr = "rm -rf /tmp/filebrowserThumbnailCache"; | 1107 | QString cmdr = "rm -rf /tmp/filebrowserThumbnailCache"; |
1108 | // qDebug("exit"); | 1108 | // qDebug("exit"); |
1109 | system(cmdr.latin1()); | 1109 | system(cmdr.latin1()); |
1110 | } | 1110 | } |
1111 | 1111 | ||
1112 | { | 1112 | { |
1113 | bool valShowThumbnails=viewMenu->isItemChecked( viewMenu->idAt( 2 ) ); | 1113 | bool valShowThumbnails=viewMenu->isItemChecked( viewMenu->idAt( 2 ) ); |
1114 | valShowThumbnails=!valShowThumbnails; | 1114 | valShowThumbnails=!valShowThumbnails; |
1115 | viewMenu->setItemChecked( viewMenu->idAt( 2 ), valShowThumbnails ); | 1115 | viewMenu->setItemChecked( viewMenu->idAt( 2 ), valShowThumbnails ); |
1116 | fileView->setShowThumbnails(valShowThumbnails); | 1116 | fileView->setShowThumbnails(valShowThumbnails); |
1117 | 1117 | ||
1118 | Config cfg("Filebrowser"); | 1118 | Config cfg("Filebrowser"); |
1119 | cfg.setGroup("View"); | 1119 | cfg.setGroup("View"); |
1120 | cfg.writeEntry("Thumbnails",valShowThumbnails?"TRUE":"FALSE"); | 1120 | cfg.writeEntry("Thumbnails",valShowThumbnails?"TRUE":"FALSE"); |
1121 | 1121 | ||
1122 | fileView->updateDir(); | 1122 | fileView->updateDir(); |
1123 | } | 1123 | } |
1124 | 1124 | ||
1125 | void FileBrowser::cleanUp() { | 1125 | void FileBrowser::cleanUp() { |
1126 | QString cmdr = "rm -rf /tmp/filebrowserThumbnailCache"; | 1126 | QString cmdr = "rm -rf /tmp/filebrowserThumbnailCache"; |
1127 | // qDebug("exit"); | 1127 | // qDebug("exit"); |
1128 | system(cmdr.latin1()); | 1128 | system(cmdr.latin1()); |
1129 | } | 1129 | } |