-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index a9ba3c2..a378170 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -250,97 +250,97 @@ void AdvancedFm::cleanUp() | |||
250 | QString sfile=QDir::homeDirPath(); | 250 | QString sfile=QDir::homeDirPath(); |
251 | if(sfile.right(1) != "/") | 251 | if(sfile.right(1) != "/") |
252 | sfile+="/._temp"; | 252 | sfile+="/._temp"; |
253 | else | 253 | else |
254 | sfile+="._temp"; | 254 | sfile+="._temp"; |
255 | QFile file( sfile); | 255 | QFile file( sfile); |
256 | if(file.exists()) | 256 | if(file.exists()) |
257 | file.remove(); | 257 | file.remove(); |
258 | } | 258 | } |
259 | 259 | ||
260 | void AdvancedFm::tabChanged(QWidget *w) | 260 | void AdvancedFm::tabChanged(QWidget *w) |
261 | { | 261 | { |
262 | if (TabWidget->currentPageIndex() == 0) { | 262 | if (TabWidget->currentPageIndex() == 0) { |
263 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 263 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
264 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); | 264 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); |
265 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); | 265 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); |
266 | } | 266 | } |
267 | if (TabWidget->currentPageIndex() == 1) { | 267 | if (TabWidget->currentPageIndex() == 1) { |
268 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); | 268 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); |
269 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); | 269 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); |
270 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); | 270 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); |
271 | } | 271 | } |
272 | } | 272 | } |
273 | 273 | ||
274 | 274 | ||
275 | void AdvancedFm::populateLocalView() | 275 | void AdvancedFm::populateLocalView() |
276 | { | 276 | { |
277 | QPixmap pm; | 277 | QPixmap pm; |
278 | Local_View->clear(); | 278 | Local_View->clear(); |
279 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 279 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
280 | currentDir.setMatchAllDirs(TRUE); | 280 | currentDir.setMatchAllDirs(TRUE); |
281 | currentDir.setNameFilter(filterStr); | 281 | currentDir.setNameFilter(filterStr); |
282 | QString fileL, fileS, fileDate; | 282 | QString fileL, fileS, fileDate; |
283 | // qDebug(currentDir.canonicalPath()); | 283 | // qDebug(currentDir.canonicalPath()); |
284 | // struct stat buf; | 284 | // struct stat buf; |
285 | // mode_t mode; | 285 | // mode_t mode; |
286 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 286 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
287 | setCaption("AdvancedFm :: "+fs); | 287 | setCaption("AdvancedFm :: "+fs); |
288 | bool isDir=FALSE; | 288 | bool isDir=FALSE; |
289 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 289 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
290 | QFileInfoListIterator it(*list); | 290 | QFileInfoListIterator it(*list); |
291 | QFileInfo *fi; | 291 | QFileInfo *fi; |
292 | while ( (fi=it.current()) ) { | 292 | while ( (fi=it.current()) ) { |
293 | if (fi->isSymLink() ) { | 293 | if (fi->isSymLink() ) { |
294 | QString symLink=fi->readLink(); | 294 | QString symLink=fi->readLink(); |
295 | // qDebug("Symlink detected "+symLink); | 295 | // qDebug("Symlink detected "+symLink); |
296 | QFileInfo sym( symLink); | 296 | QFileInfo sym( symLink); |
297 | fileS.sprintf( "%10li", sym.size() ); | 297 | fileS.sprintf( "%10li", sym.size() ); |
298 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 298 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); |
299 | fileDate = sym.lastModified().toString(); | 299 | fileDate = sym.lastModified().toString(); |
300 | } else { | 300 | } else { |
301 | fileS.sprintf( "%10li", fi->size() ); | 301 | fileS.sprintf( "%10li", fi->size() ); |
302 | fileL.sprintf( "%s",fi->fileName().data() ); | 302 | fileL.sprintf( "%s",fi->fileName().data() ); |
303 | fileDate= fi->lastModified().toString(); | 303 | fileDate= fi->lastModified().toString(); |
304 | if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 304 | if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
305 | fileL+="/"; | 305 | fileL+="/"; |
306 | isDir=TRUE; | 306 | isDir=TRUE; |
307 | // qDebug( fileL); | 307 | // qDebug( fileL); |
308 | } | 308 | } |
309 | } | 309 | } |
310 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); | 310 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); |
311 | if(fileL !="./" && fi->exists()) { | 311 | if(fileL !="./" && fi->exists()) { |
312 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); | 312 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); |
313 | 313 | ||
314 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 314 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
315 | 315 | ||
316 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 316 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
317 | pm = Resource::loadPixmap( "lockedfolder" ); | 317 | pm = Resource::loadPixmap( "lockedfolder" ); |
318 | else | 318 | else |
319 | pm= Resource::loadPixmap( "folder" ); | 319 | pm= Resource::loadPixmap( "folder" ); |
320 | // item->setPixmap( 0,pm ); | 320 | // item->setPixmap( 0,pm ); |
321 | } else if( (fileInfo.permission( QFileInfo::ExeUser) | 321 | } else if( (fileInfo.permission( QFileInfo::ExeUser) |
322 | | fileInfo.permission( QFileInfo::ExeGroup) | 322 | | fileInfo.permission( QFileInfo::ExeGroup) |
323 | | fileInfo.permission( QFileInfo::ExeOther)) & fs.find("vfat",0,TRUE) == -1) { | 323 | | fileInfo.permission( QFileInfo::ExeOther)) & fs.find("vfat",0,TRUE) == -1) { |
324 | pm = Resource::loadPixmap( "exec"); | 324 | pm = Resource::loadPixmap( "exec"); |
325 | // else { //is exec | 325 | // else { //is exec |
326 | // pm = Resource::loadPixmap( "exec"); | 326 | // pm = Resource::loadPixmap( "exec"); |
327 | // } | 327 | // } |
328 | // // item->setPixmap( 0,pm); | 328 | // // item->setPixmap( 0,pm); |
329 | } else if( !fi->isReadable() ) { | 329 | } else if( !fi->isReadable() ) { |
330 | pm = Resource::loadPixmap( "locked" ); | 330 | pm = Resource::loadPixmap( "locked" ); |
331 | // item->setPixmap( 0,pm); | 331 | // item->setPixmap( 0,pm); |
332 | } else { //everything else goes by mimetype | 332 | } else { //everything else goes by mimetype |
333 | MimeType mt(fi->filePath()); | 333 | MimeType mt(fi->filePath()); |
334 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 334 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
335 | if(pm.isNull()) | 335 | if(pm.isNull()) |
336 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 336 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
337 | // item->setPixmap( 0,pm); | 337 | // item->setPixmap( 0,pm); |
338 | } | 338 | } |
339 | item->setPixmap( 0,pm); | 339 | item->setPixmap( 0,pm); |
340 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { | 340 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { |
341 | // overlay link image | 341 | // overlay link image |
342 | pm= Resource::loadPixmap( "folder" ); | 342 | pm= Resource::loadPixmap( "folder" ); |
343 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 343 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
344 | QPainter painter( &pm ); | 344 | QPainter painter( &pm ); |
345 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 345 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
346 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 346 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
@@ -371,124 +371,123 @@ void AdvancedFm::populateLocalView() | |||
371 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 371 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
372 | // fileS.sprintf("%d,%d", devT, devT); | 372 | // fileS.sprintf("%d,%d", devT, devT); |
373 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 373 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
374 | if( fileL.find(".") == -1 ){ | 374 | if( fileL.find(".") == -1 ){ |
375 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); | 375 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); |
376 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 376 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
377 | item->setPixmap( 0,pm); | 377 | item->setPixmap( 0,pm); |
378 | } | 378 | } |
379 | } | 379 | } |
380 | 380 | ||
381 | closedir(dir); | 381 | closedir(dir); |
382 | } | 382 | } |
383 | 383 | ||
384 | Local_View->setSorting( 3,FALSE); | 384 | Local_View->setSorting( 3,FALSE); |
385 | fillCombo( (const QString &) currentDir.canonicalPath()); | 385 | fillCombo( (const QString &) currentDir.canonicalPath()); |
386 | } | 386 | } |
387 | 387 | ||
388 | 388 | ||
389 | void AdvancedFm::populateRemoteView() | 389 | void AdvancedFm::populateRemoteView() |
390 | { | 390 | { |
391 | // QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 391 | // QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
392 | // QListViewItemIterator it( Remote_View ); | 392 | // QListViewItemIterator it( Remote_View ); |
393 | // for ( ; it.current(); ++it ) { | 393 | // for ( ; it.current(); ++it ) { |
394 | // if ( it.current()->isSelected() ) { | 394 | // if ( it.current()->isSelected() ) { |
395 | // QString strItem = it.current()->text(0); | 395 | // QString strItem = it.current()->text(0); |
396 | // QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem; | 396 | // QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem; |
397 | // QFileInfo fi(localFile); | 397 | // QFileInfo fi(localFile); |
398 | // } | 398 | // } |
399 | // } | 399 | // } |
400 | QPixmap pm; | 400 | QPixmap pm; |
401 | Remote_View->clear(); | 401 | Remote_View->clear(); |
402 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 402 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
403 | currentRemoteDir.setMatchAllDirs(TRUE); | 403 | currentRemoteDir.setMatchAllDirs(TRUE); |
404 | currentRemoteDir.setNameFilter(filterStr); | 404 | currentRemoteDir.setNameFilter(filterStr); |
405 | QString fileL, fileS, fileDate; | 405 | QString fileL, fileS, fileDate; |
406 | 406 | ||
407 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 407 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
408 | setCaption("AdvancedFm :: "+fs); | 408 | setCaption("AdvancedFm :: "+fs); |
409 | bool isDir=FALSE; | 409 | bool isDir=FALSE; |
410 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 410 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
411 | QFileInfoListIterator it(*list); | 411 | QFileInfoListIterator it(*list); |
412 | QFileInfo *fi; | 412 | QFileInfo *fi; |
413 | while ( (fi=it.current()) ) { | 413 | while ( (fi=it.current()) ) { |
414 | if (fi->isSymLink() ){ | 414 | if (fi->isSymLink() ){ |
415 | QString symLink=fi->readLink(); | 415 | QString symLink=fi->readLink(); |
416 | // qDebug("Symlink detected "+symLink); | 416 | // qDebug("Symlink detected "+symLink); |
417 | QFileInfo sym( symLink); | 417 | QFileInfo sym( symLink); |
418 | fileS.sprintf( "%10li", sym.size() ); | 418 | fileS.sprintf( "%10li", sym.size() ); |
419 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 419 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); |
420 | fileDate = sym.lastModified().toString(); | 420 | fileDate = sym.lastModified().toString(); |
421 | } else { | 421 | } else { |
422 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 422 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
423 | fileS.sprintf( "%10li", fi->size() ); | 423 | fileS.sprintf( "%10li", fi->size() ); |
424 | fileL.sprintf( "%s",fi->fileName().data() ); | 424 | fileL.sprintf( "%s",fi->fileName().data() ); |
425 | fileDate= fi->lastModified().toString(); | 425 | fileDate= fi->lastModified().toString(); |
426 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { | 426 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { |
427 | fileL+="/"; | 427 | fileL+="/"; |
428 | isDir=TRUE; | 428 | isDir=TRUE; |
429 | // qDebug( fileL); | 429 | // qDebug( fileL); |
430 | } | 430 | } |
431 | } | 431 | } |
432 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); | 432 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); |
433 | if(fileL !="./" && fi->exists()) { | 433 | if(fileL !="./" && fi->exists()) { |
434 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 434 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
435 | QPixmap pm; | 435 | QPixmap pm; |
436 | 436 | ||
437 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 437 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
438 | if( !QDir( fi->filePath() ).isReadable()) | 438 | if( !QDir( fi->filePath() ).isReadable()) |
439 | pm = Resource::loadPixmap( "lockedfolder" ); | 439 | pm = Resource::loadPixmap( "lockedfolder" ); |
440 | else | 440 | else |
441 | pm= Resource::loadPixmap( "folder" ); | 441 | pm= Resource::loadPixmap( "folder" ); |
442 | // item->setPixmap( 0,pm ); | 442 | // item->setPixmap( 0,pm ); |
443 | } else if( (fileInfo.permission( QFileInfo::ExeUser) | 443 | } else if( (fileInfo.permission( QFileInfo::ExeUser) |
444 | | fileInfo.permission( QFileInfo::ExeGroup) | 444 | | fileInfo.permission( QFileInfo::ExeGroup) |
445 | | fileInfo.permission( QFileInfo::ExeOther)) & fs.find("vfat",0,TRUE) == -1) { | 445 | | fileInfo.permission( QFileInfo::ExeOther)) & fs.find("vfat",0,TRUE) == -1) { |
446 | pm = Resource::loadPixmap( "exec"); | ||
447 | ///// } else if(fileInfo.isExecutable()){ //is exec <<<< BROKEN!! | 446 | ///// } else if(fileInfo.isExecutable()){ //is exec <<<< BROKEN!! |
448 | pm = Resource::loadPixmap( "exec"); | 447 | pm = Resource::loadPixmap( "exec"); |
449 | // item->setPixmap( 0,pm); | 448 | // item->setPixmap( 0,pm); |
450 | } else if( !fi->isReadable() ) { | 449 | } else if( !fi->isReadable() ) { |
451 | pm = Resource::loadPixmap( "locked" ); | 450 | pm = Resource::loadPixmap( "locked" ); |
452 | // item->setPixmap( 0,pm); | 451 | // item->setPixmap( 0,pm); |
453 | } else { | 452 | } else { |
454 | MimeType mt(fi->filePath()); | 453 | MimeType mt(fi->filePath()); |
455 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 454 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
456 | if(pm.isNull()) | 455 | if(pm.isNull()) |
457 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 456 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
458 | // item->setPixmap( 0,pm); | 457 | // item->setPixmap( 0,pm); |
459 | } | 458 | } |
460 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { | 459 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { |
461 | // overlay link image | 460 | // overlay link image |
462 | pm= Resource::loadPixmap( "folder" ); | 461 | pm= Resource::loadPixmap( "folder" ); |
463 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 462 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
464 | QPainter painter( &pm ); | 463 | QPainter painter( &pm ); |
465 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 464 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
466 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 465 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
467 | // item->setPixmap( 0, pm); | 466 | // item->setPixmap( 0, pm); |
468 | } | 467 | } |
469 | item->setPixmap( 0, pm); | 468 | item->setPixmap( 0, pm); |
470 | } | 469 | } |
471 | isDir=FALSE; | 470 | isDir=FALSE; |
472 | ++it; | 471 | ++it; |
473 | } | 472 | } |
474 | 473 | ||
475 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { | 474 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { |
476 | struct stat buf; | 475 | struct stat buf; |
477 | // struct stat st; | 476 | // struct stat st; |
478 | // mode_t mode; | 477 | // mode_t mode; |
479 | DIR *dir; | 478 | DIR *dir; |
480 | // int fd = 0; | 479 | // int fd = 0; |
481 | struct dirent *mydirent; | 480 | struct dirent *mydirent; |
482 | // int i = 1; | 481 | // int i = 1; |
483 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) | 482 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) |
484 | while ((mydirent = readdir(dir)) != NULL) { | 483 | while ((mydirent = readdir(dir)) != NULL) { |
485 | lstat( mydirent->d_name, &buf); | 484 | lstat( mydirent->d_name, &buf); |
486 | qDebug(mydirent->d_name); | 485 | qDebug(mydirent->d_name); |
487 | // mode = buf.st_mode; | 486 | // mode = buf.st_mode; |
488 | fileL.sprintf("%s", mydirent->d_name); | 487 | fileL.sprintf("%s", mydirent->d_name); |
489 | // fileS.sprintf("%d, %d", ); //this isn't correct | 488 | // fileS.sprintf("%d, %d", ); //this isn't correct |
490 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); | 489 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); |
491 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 490 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
492 | if( fileL.find(".") == -1 ){ | 491 | if( fileL.find(".") == -1 ){ |
493 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 492 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
494 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 493 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
@@ -1302,100 +1301,100 @@ void AdvancedFm::move() { | |||
1302 | if(!copyFile(destFile, curFile) ) { | 1301 | if(!copyFile(destFile, curFile) ) { |
1303 | QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); | 1302 | QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); |
1304 | return; | 1303 | return; |
1305 | } | 1304 | } |
1306 | QFile::remove(curFile); | 1305 | QFile::remove(curFile); |
1307 | TabWidget->setCurrentPage(0); | 1306 | TabWidget->setCurrentPage(0); |
1308 | } | 1307 | } |
1309 | } | 1308 | } |
1310 | populateRemoteView(); | 1309 | populateRemoteView(); |
1311 | populateLocalView(); | 1310 | populateLocalView(); |
1312 | } | 1311 | } |
1313 | 1312 | ||
1314 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) | 1313 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) |
1315 | { | 1314 | { |
1316 | char bf[ 50000 ]; | 1315 | char bf[ 50000 ]; |
1317 | int bytesRead; | 1316 | int bytesRead; |
1318 | bool success = TRUE; | 1317 | bool success = TRUE; |
1319 | struct stat status; | 1318 | struct stat status; |
1320 | 1319 | ||
1321 | QFile s( src ); | 1320 | QFile s( src ); |
1322 | QFile d( dest ); | 1321 | QFile d( dest ); |
1323 | 1322 | ||
1324 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { | 1323 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { |
1325 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { | 1324 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { |
1326 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 1325 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
1327 | success = FALSE; | 1326 | success = FALSE; |
1328 | break; | 1327 | break; |
1329 | } | 1328 | } |
1330 | } | 1329 | } |
1331 | if( success && (bytesRead > 0) ){ | 1330 | if( success && (bytesRead > 0) ){ |
1332 | d.writeBlock( bf, bytesRead ); | 1331 | d.writeBlock( bf, bytesRead ); |
1333 | } | 1332 | } |
1334 | } else { | 1333 | } else { |
1335 | success = FALSE; | 1334 | success = FALSE; |
1336 | } | 1335 | } |
1337 | 1336 | ||
1338 | // Set file permissions | 1337 | // Set file permissions |
1339 | if( stat( (const char *) src, &status ) == 0 ){ | 1338 | if( stat( (const char *) src, &status ) == 0 ){ |
1340 | chmod( (const char *) dest, status.st_mode ); | 1339 | chmod( (const char *) dest, status.st_mode ); |
1341 | } | 1340 | } |
1342 | 1341 | ||
1343 | return success; | 1342 | return success; |
1344 | } | 1343 | } |
1345 | 1344 | ||
1346 | void AdvancedFm::runCommand() { | 1345 | void AdvancedFm::runCommand() { |
1347 | QString curFile; | 1346 | QString curFile; |
1348 | if (TabWidget->currentPageIndex() == 0) { | 1347 | if (TabWidget->currentPageIndex() == 0) { |
1349 | if( Local_View->currentItem()) | 1348 | if( Local_View->currentItem()) |
1350 | curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); | 1349 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
1351 | } else { | 1350 | } else { |
1352 | if(Remote_View->currentItem()) | 1351 | if(Remote_View->currentItem()) |
1353 | curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); | 1352 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); |
1354 | } | 1353 | } |
1355 | 1354 | ||
1356 | InputDialog *fileDlg; | 1355 | InputDialog *fileDlg; |
1357 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 1356 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
1358 | fileDlg->setInputText(curFile); | 1357 | fileDlg->setInputText(curFile); |
1359 | fileDlg->exec(); | 1358 | fileDlg->exec(); |
1360 | QString command; | 1359 | QString command; |
1361 | if( fileDlg->result() == 1 ) { | 1360 | if( fileDlg->result() == 1 ) { |
1362 | command = fileDlg->LineEdit1->text(); | 1361 | command = fileDlg->LineEdit1->text(); |
1363 | 1362 | ||
1364 | // int err=0; | 1363 | // int err=0; |
1365 | Output *outDlg; | 1364 | Output *outDlg; |
1366 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | 1365 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
1367 | outDlg->showMaximized(); | 1366 | outDlg->showMaximized(); |
1368 | outDlg->show(); | 1367 | outDlg->show(); |
1369 | qApp->processEvents(); | 1368 | qApp->processEvents(); |
1370 | FILE *fp; | 1369 | FILE *fp; |
1371 | char line[130]; | 1370 | char line[130]; |
1372 | sleep(1); | 1371 | sleep(1); |
1373 | // if(command.find("2>",0,TRUE) != -1) | 1372 | // if(command.find("2>",0,TRUE) != -1) |
1374 | command +=" 2>&1"; | 1373 | command +=" 2>&1"; |
1375 | fp = popen( (const char *) command, "r"); | 1374 | fp = popen( (const char *) command, "r"); |
1376 | if ( !fp ) { | 1375 | if ( !fp ) { |
1377 | qDebug("Could not execute '" + command + "'! err=%d", fp); | 1376 | qDebug("Could not execute '" + command + "'! err=%d", fp); |
1378 | QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); | 1377 | QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); |
1379 | pclose(fp); | 1378 | pclose(fp); |
1380 | return; | 1379 | return; |
1381 | } else { | 1380 | } else { |
1382 | while ( fgets( line, sizeof line, fp)) { | 1381 | while ( fgets( line, sizeof line, fp)) { |
1383 | QString lineStr = line; | 1382 | QString lineStr = line; |
1384 | lineStr=lineStr.left(lineStr.length()-1); | 1383 | lineStr=lineStr.left(lineStr.length()-1); |
1385 | outDlg->OutputEdit->append(lineStr); | 1384 | outDlg->OutputEdit->append(lineStr); |
1386 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 1385 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
1387 | } | 1386 | } |
1388 | } | 1387 | } |
1389 | } | 1388 | } |
1390 | } | 1389 | } |
1391 | 1390 | ||
1392 | void AdvancedFm::runCommandStd() { | 1391 | void AdvancedFm::runCommandStd() { |
1393 | QString curFile; | 1392 | QString curFile; |
1394 | if (TabWidget->currentPageIndex() == 0) { | 1393 | if (TabWidget->currentPageIndex() == 0) { |
1395 | if( Local_View->currentItem()) | 1394 | if( Local_View->currentItem()) |
1396 | curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); | 1395 | curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); |
1397 | } else { | 1396 | } else { |
1398 | if(Remote_View->currentItem()) | 1397 | if(Remote_View->currentItem()) |
1399 | curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); | 1398 | curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); |
1400 | } | 1399 | } |
1401 | 1400 | ||