-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 @@ -449,210 +449,210 @@ void FileView::paste() (const char *) basename ); } } // // Copy a directory recursively using the "cp" command - // may have to be changed // if( QFileInfo( (*it) ).isDir() ){ cmd = "/bin/cp -fpR \"" + (*it) +"\" " + "\"" + dest + "\""; err = system( (const char *) cmd ); } else if( !copyFile( dest, (*it) ) ){ err = -1; } else { err = 0; } if ( err != 0 ) { QMessageBox::warning( this, tr("Paste file"), tr("Paste failed!"), tr("Ok") ); break; } else { updateDir(); QListViewItem * i = firstChild(); basename = dest.mid( dest.findRev("/") + 1, dest.length() ); while( i ){ if( i->text(0) == basename ){ setCurrentItem( i ); ensureItemVisible( i ); break; } i = i->nextSibling(); } } } } bool FileView::copyFile( const QString & dest, const QString & src ) { char bf[ 50000 ]; int bytesRead; bool success = TRUE; struct stat status; QFile s( src ); QFile d( dest ); if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ success = FALSE; break; } } if( success && (bytesRead > 0) ){ d.writeBlock( bf, bytesRead ); } } else { success = FALSE; } // Set file permissions if( stat( (const char *) src, &status ) == 0 ){ chmod( (const char *) dest, status.st_mode ); } return success; } void FileView::cut() { int err; // ##### a better inmplementation might be to rename the CUT file // ##### to ".QPE-FILEBROWSER-MOVING" rather than copying it. QString cmd, dest, basename, cd = "/tmp/qpemoving"; QStringList newflist; newflist.clear(); cmd = "rm -rf " + cd; system ( (const char *) cmd ); cmd = "mkdir " + cd; system( (const char *) cmd ); // get the names of the files to cut FileItem * item; if((item = (FileItem *) firstChild()) == 0) return; flist.clear(); while( item ){ if( ite - // ##### a better inmplementation might be to rename the CUT file
- // ##### to ".QPE-FILEBROWSER-MOVING" rather than copying it.
- QString cmd, dest, basename, cd = "/tmp/qpemoving";
- QStringList newflist;
- newflist.clear();
-
- cmd = "rm -rf " + cd;
- system ( (const char *) cmd );
- cmd = "mkdir " + cd;
- system( (const char *) cmd );
-
-// get the names of the files to cut
- FileItem * item;
-
- if((item = (FileItem *) firstChild()) == 0) return;
-
- flist.clear();
- while( item ){
+ // ##### a better inmplementation might be to rename the CUT file + // ##### to ".QPE-FILEBROWSER-MOVING" rather than copying it. + QString cmd, dest, basename, cd = "/tmp/qpemoving"; + QStringList newflist; + newflist.clear(); + + cmd = "rm -rf " + cd; + system ( (const char *) cmd ); + cmd = "mkdir " + cd; + system( (const char *) cmd ); + +// get the names of the files to cut + FileItem * item; + + if((item = (FileItem *) firstChild()) == 0) return; + + flist.clear(); + while( item ){ if( item->isSelected() /*&& !item->isDir()*/ ){ flist += item->getFilePath(); } item = (FileItem *) item->nextSibling(); } // move these files into a tmp dir for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) { basename = (*it).mid((*it).findRev("/") + 1, (*it).length()); dest = cd + "/" + basename; newflist += dest; cmd = "/bin/mv -f \"" + (*it) +"\" " + "\"" + dest + "\""; err = system( (const char *) cmd ); if ( err != 0 ) { QMessageBox::warning( this, tr("Cut file"), tr("Cut failed!"), tr("Ok") ); break; } else { updateDir(); QListViewItem * im = firstChild(); basename = dest.mid( dest.findRev("/") + 1, dest.length() ); while( im ){ if( im->text(0) == basename ){ setCurrentItem( im ); ensureItemVisible( im ); break; } im = im->nextSibling(); } } } // update the filelist to point to tmp dir so paste works nicely flist = newflist; } void FileView::del() { FileItem * i; QStringList fl; QString cmd; int err; if((i = (FileItem *) firstChild()) == 0) return; while( i ){ if( i->isSelected() ){ fl += i->getFilePath(); } i = (FileItem *) i->nextSibling(); } if( fl.count() < 1 ) return; if( QMessageBox::warning( this, tr("Delete"), tr("Are you sure?"), tr("Yes"), tr("No") ) == 0) { // // Dependant upon the "rm" command - will probably have to be replaced // for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { cmd = "/bin/rm -rf \"" + (*it) + "\""; err = system( (const char *) cmd ); if ( err != 0 ) { QMessageBox::warning( this, tr("Delete"), tr("Delete failed!"), tr("Ok") ); break; } } updateDir(); } } void FileView::newFolder() { int t = 1; FileItem * i; QString nd = currentDir + "/NewFolder"; while( QFile( nd ).exists() ){ nd.sprintf( "%s/NewFolder (%d)", (const char *) currentDir, t++ ); } if( mkdir( (const char *) nd, 0777 ) != 0){ QMessageBox::warning( this, tr( "New folder" ), tr( "Folder creation failed!" ), tr( "Ok" ) ); return; } updateDir(); if((i = (FileItem *) firstChild()) == 0) return; @@ -1015,115 +1015,115 @@ void FileBrowser::sortType() fileView->sort(); sortMenu->setItemChecked( sortMenu->idAt( 0 ), FALSE ); sortMenu->setItemChecked( sortMenu->idAt( 1 ), FALSE ); sortMenu->setItemChecked( sortMenu->idAt( 2 ), FALSE ); sortMenu->setItemChecked( sortMenu->idAt( 3 ), TRUE ); } void FileBrowser::updateSorting() { sortMenu->setItemChecked( sortMenu->idAt( 5 ), !sortMenu->isItemChecked( sortMenu->idAt( 5 ) ) ); if ( sortMenu->isItemChecked( sortMenu->idAt( 0 ) ) ) sortName(); else if ( sortMenu->isItemChecked( sortMenu->idAt( 1 ) ) ) sortSize(); else if ( sortMenu->isItemChecked( sortMenu->idAt( 2 ) ) ) sortDate(); else sortType(); } void FileView::chPerm() { FileItem * i; QStringList fl; QString cmd; if((i = (FileItem *) firstChild()) == 0) return; while( i ){ if( i->isSelected() ){ fl += i->getFilePath(); } i = (FileItem *) i->nextSibling(); } if( fl.count() < 1 ) return; if( QMessageBox::warning( this, tr("Change permissions"), tr("Are you sure?"), tr("Yes"), tr("No") ) == 0) { for ( QStringList::Iterator it = fl.begin(); it != fl.end(); ++it ) { filePermissions *filePerm; filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(*it)); filePerm->exec(); if( filePerm) delete filePerm; break; } updateDir(); } } void FileBrowser::updateShowHidden() { bool valShowHidden=viewMenu->isItemChecked( viewMenu->idAt( 0 ) ); valShowHidden=!valShowHidden; viewMenu->setItemChecked( viewMenu->idAt( 0 ), valShowHidden ); fileView->setShowHidden(valShowHidden); Config cfg("Filebrowser"); cfg.setGroup("View"); cfg.writeEntry("Hidden",valShowHidden?"TRUE":"FALSE"); fileView->updateDir(); } void FileBrowser::updateShowSymlinks() { bool valShowSymlinks=viewMenu->isItemChecked( viewMenu->idAt( 1 ) ); valShowSymlinks=!valShowSymlinks; viewMenu->setItemChecked( viewMenu->idAt( 1 ), valShowSymlinks ); fileView->setShowSymlinks(valShowSymlinks); Config cfg("Filebrowser"); cfg.setGroup("View"); cfg.writeEntry("Symlinks",valShowSymlinks?"TRUE":"FALSE"); fileView->updateDir(); } void FileBrowser::updateShowThumbnails() { bool valShowThumbnails=viewMenu->isItemChecked( viewMenu->idAt( 2 ) ); valShowThumbnails=!valShowThumbnails; viewMenu->setItemChecked( viewMenu->idAt( 2 ), valShowThumbnails ); fileView->setShowThumbnails(valShowThumbnails); Config cfg("Filebrowser"); cfg.setGroup("View"); cfg.writeEntry("Thumbnails",valShowThumbnails?"TRUE":"FALSE"); fileView->updateDir(); } void FileBrowser::cleanUp() { QString cmdr = "rm -rf /tmp/filebrowserThumbnailCache"; // qDebug("exit"); system(cmdr.latin1()); } -
-{
- bool valShowThumbnails=viewMenu->isItemChecked( viewMenu->idAt( 2 ) );
- valShowThumbnails=!valShowThumbnails;
- viewMenu->setItemChecked( viewMenu->idAt( 2 ), valShowThumbnails );
- fileView->setShowThumbnails(valShowThumbnails);
-
- Config cfg("Filebrowser");
- cfg.setGroup("View");
- cfg.writeEntry("Thumbnails",valShowThumbnails?"TRUE":"FALSE");
-
- fileView->updateDir();
-}
-
-void FileBrowser::cleanUp() {
- QString cmdr = "rm -rf /tmp/filebrowserThumbnailCache";
-// qDebug("exit");
- system(cmdr.latin1());
-}
+ +{ + bool valShowThumbnails=viewMenu->isItemChecked( viewMenu->idAt( 2 ) ); + valShowThumbnails=!valShowThumbnails; + viewMenu->setItemChecked( viewMenu->idAt( 2 ), valShowThumbnails ); + fileView->setShowThumbnails(valShowThumbnails); + + Config cfg("Filebrowser"); + cfg.setGroup("View"); + cfg.writeEntry("Thumbnails",valShowThumbnails?"TRUE":"FALSE"); + + fileView->updateDir(); +} + +void FileBrowser::cleanUp() { + QString cmdr = "rm -rf /tmp/filebrowserThumbnailCache"; +// qDebug("exit"); + system(cmdr.latin1()); +} |