author | llornkcor <llornkcor> | 2002-04-28 13:40:18 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-28 13:40:18 (UTC) |
commit | caae6c7deade10081709daa8a0de8ad548b6e30d (patch) (unidiff) | |
tree | 7bbc4d3b832101dd17a07ae1940ecca44a555eef | |
parent | 495103fd36f52dad3a564b924326519c9f52ccaf (diff) | |
download | opie-caae6c7deade10081709daa8a0de8ad548b6e30d.zip opie-caae6c7deade10081709daa8a0de8ad548b6e30d.tar.gz opie-caae6c7deade10081709daa8a0de8ad548b6e30d.tar.bz2 |
changed remove dir function to be recursive and more dangerous
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index ab31c91..faa03dc 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -289,1074 +289,1084 @@ void AdvancedFm::populateLocalView() | |||
289 | // qDebug(currentDir.canonicalPath()); | 289 | // qDebug(currentDir.canonicalPath()); |
290 | 290 | ||
291 | bool isDir=FALSE; | 291 | bool isDir=FALSE; |
292 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 292 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
293 | QFileInfoListIterator it(*list); | 293 | QFileInfoListIterator it(*list); |
294 | QFileInfo *fi; | 294 | QFileInfo *fi; |
295 | while ( (fi=it.current()) ) { | 295 | while ( (fi=it.current()) ) { |
296 | if (fi->isSymLink() ) { | 296 | if (fi->isSymLink() ) { |
297 | QString symLink=fi->readLink(); | 297 | QString symLink=fi->readLink(); |
298 | // qDebug("Symlink detected "+symLink); | 298 | // qDebug("Symlink detected "+symLink); |
299 | QFileInfo sym( symLink); | 299 | QFileInfo sym( symLink); |
300 | fileS.sprintf( "%10li", sym.size() ); | 300 | fileS.sprintf( "%10li", sym.size() ); |
301 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 301 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
302 | fileDate = sym.lastModified().toString(); | 302 | fileDate = sym.lastModified().toString(); |
303 | } else { | 303 | } else { |
304 | fileS.sprintf( "%10li", fi->size() ); | 304 | fileS.sprintf( "%10li", fi->size() ); |
305 | fileL.sprintf( "%s",fi->fileName().data() ); | 305 | fileL.sprintf( "%s",fi->fileName().data() ); |
306 | fileDate= fi->lastModified().toString(); | 306 | fileDate= fi->lastModified().toString(); |
307 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 307 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
308 | fileL+="/"; | 308 | fileL+="/"; |
309 | isDir=TRUE; | 309 | isDir=TRUE; |
310 | // qDebug( fileL); | 310 | // qDebug( fileL); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | if(fileL !="./" && fi->exists()) { | 313 | if(fileL !="./" && fi->exists()) { |
314 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); | 314 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); |
315 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 315 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
316 | if( !QDir( fi->filePath() ).isReadable()) | 316 | if( !QDir( fi->filePath() ).isReadable()) |
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 { | 321 | } else { |
322 | if(fi->isExecutable()) { | 322 | if(fi->isExecutable()) { |
323 | pm = Resource::loadPixmap( "exec"); | 323 | pm = Resource::loadPixmap( "exec"); |
324 | item->setPixmap( 0,pm); | 324 | item->setPixmap( 0,pm); |
325 | } | 325 | } |
326 | else if( !fi->isReadable() ) { | 326 | else if( !fi->isReadable() ) { |
327 | pm = Resource::loadPixmap( "locked" ); | 327 | pm = Resource::loadPixmap( "locked" ); |
328 | item->setPixmap( 0,pm); | 328 | item->setPixmap( 0,pm); |
329 | 329 | ||
330 | } | 330 | } |
331 | else { | 331 | else { |
332 | MimeType mt(fi->filePath()); | 332 | MimeType mt(fi->filePath()); |
333 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 333 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
334 | if(pm.isNull()) | 334 | if(pm.isNull()) |
335 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 335 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
336 | item->setPixmap( 0,pm); | 336 | item->setPixmap( 0,pm); |
337 | } | 337 | } |
338 | } | 338 | } |
339 | if( fileL.find("->",0,TRUE) != -1) { | 339 | if( fileL.find("->",0,TRUE) != -1) { |
340 | // overlay link image | 340 | // overlay link image |
341 | pm= Resource::loadPixmap( "folder" ); | 341 | pm= Resource::loadPixmap( "folder" ); |
342 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 342 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
343 | QPainter painter( &pm ); | 343 | QPainter painter( &pm ); |
344 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 344 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
345 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 345 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
346 | item->setPixmap( 0, pm); | 346 | item->setPixmap( 0, pm); |
347 | } | 347 | } |
348 | } isDir=FALSE; | 348 | } isDir=FALSE; |
349 | ++it; | 349 | ++it; |
350 | } | 350 | } |
351 | 351 | ||
352 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { | 352 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { |
353 | struct stat buf; | 353 | struct stat buf; |
354 | struct stat st; | 354 | struct stat st; |
355 | dev_t devT; | 355 | dev_t devT; |
356 | mode_t mode; | 356 | mode_t mode; |
357 | DIR *dir; | 357 | DIR *dir; |
358 | int fd = 0; | 358 | int fd = 0; |
359 | struct dirent *mydirent; | 359 | struct dirent *mydirent; |
360 | int i = 1; | 360 | int i = 1; |
361 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) | 361 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) |
362 | while ((mydirent = readdir(dir)) != NULL) { | 362 | while ((mydirent = readdir(dir)) != NULL) { |
363 | lstat( mydirent->d_name, &buf); | 363 | lstat( mydirent->d_name, &buf); |
364 | qDebug(mydirent->d_name); | 364 | qDebug(mydirent->d_name); |
365 | // mode = buf.st_mode; | 365 | // mode = buf.st_mode; |
366 | fileL.sprintf("%s", mydirent->d_name); | 366 | fileL.sprintf("%s", mydirent->d_name); |
367 | // fileS.sprintf("%d, %d", ); //this isn't correct | 367 | // fileS.sprintf("%d, %d", ); //this isn't correct |
368 | devT = buf.st_dev; | 368 | devT = buf.st_dev; |
369 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 369 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
370 | // fileS.sprintf("%d,%d", devT, devT); | 370 | // fileS.sprintf("%d,%d", devT, devT); |
371 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 371 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
372 | if( fileL.find(".") == -1 ){ | 372 | if( fileL.find(".") == -1 ){ |
373 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); | 373 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); |
374 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 374 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
375 | item->setPixmap( 0,pm); | 375 | item->setPixmap( 0,pm); |
376 | } | 376 | } |
377 | } | 377 | } |
378 | 378 | ||
379 | closedir(dir); | 379 | closedir(dir); |
380 | } | 380 | } |
381 | 381 | ||
382 | Local_View->setSorting( 3,FALSE); | 382 | Local_View->setSorting( 3,FALSE); |
383 | fillCombo( (const QString &) currentDir.canonicalPath()); | 383 | fillCombo( (const QString &) currentDir.canonicalPath()); |
384 | } | 384 | } |
385 | 385 | ||
386 | 386 | ||
387 | void AdvancedFm::populateRemoteView() | 387 | void AdvancedFm::populateRemoteView() |
388 | { | 388 | { |
389 | // QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 389 | // QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
390 | // QListViewItemIterator it( Remote_View ); | 390 | // QListViewItemIterator it( Remote_View ); |
391 | // for ( ; it.current(); ++it ) { | 391 | // for ( ; it.current(); ++it ) { |
392 | // if ( it.current()->isSelected() ) { | 392 | // if ( it.current()->isSelected() ) { |
393 | // QString strItem = it.current()->text(0); | 393 | // QString strItem = it.current()->text(0); |
394 | // QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem; | 394 | // QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem; |
395 | // QFileInfo fi(localFile); | 395 | // QFileInfo fi(localFile); |
396 | // } | 396 | // } |
397 | // } | 397 | // } |
398 | QPixmap pm; | 398 | QPixmap pm; |
399 | Remote_View->clear(); | 399 | Remote_View->clear(); |
400 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 400 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
401 | currentRemoteDir.setMatchAllDirs(TRUE); | 401 | currentRemoteDir.setMatchAllDirs(TRUE); |
402 | currentRemoteDir.setNameFilter(filterStr); | 402 | currentRemoteDir.setNameFilter(filterStr); |
403 | QString fileL, fileS, fileDate; | 403 | QString fileL, fileS, fileDate; |
404 | bool isDir=FALSE; | 404 | bool isDir=FALSE; |
405 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 405 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
406 | QFileInfoListIterator it(*list); | 406 | QFileInfoListIterator it(*list); |
407 | QFileInfo *fi; | 407 | QFileInfo *fi; |
408 | while ( (fi=it.current()) ) { | 408 | while ( (fi=it.current()) ) { |
409 | if (fi->isSymLink() ){ | 409 | if (fi->isSymLink() ){ |
410 | QString symLink=fi->readLink(); | 410 | QString symLink=fi->readLink(); |
411 | // qDebug("Symlink detected "+symLink); | 411 | // qDebug("Symlink detected "+symLink); |
412 | QFileInfo sym( symLink); | 412 | QFileInfo sym( symLink); |
413 | fileS.sprintf( "%10li", sym.size() ); | 413 | fileS.sprintf( "%10li", sym.size() ); |
414 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 414 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
415 | fileDate = sym.lastModified().toString(); | 415 | fileDate = sym.lastModified().toString(); |
416 | } else { | 416 | } else { |
417 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 417 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
418 | fileS.sprintf( "%10li", fi->size() ); | 418 | fileS.sprintf( "%10li", fi->size() ); |
419 | fileL.sprintf( "%s",fi->fileName().data() ); | 419 | fileL.sprintf( "%s",fi->fileName().data() ); |
420 | fileDate= fi->lastModified().toString(); | 420 | fileDate= fi->lastModified().toString(); |
421 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { | 421 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { |
422 | fileL+="/"; | 422 | fileL+="/"; |
423 | isDir=TRUE; | 423 | isDir=TRUE; |
424 | // qDebug( fileL); | 424 | // qDebug( fileL); |
425 | } | 425 | } |
426 | } | 426 | } |
427 | if(fileL !="./" && fi->exists()) { | 427 | if(fileL !="./" && fi->exists()) { |
428 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 428 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
429 | QPixmap pm; | 429 | QPixmap pm; |
430 | 430 | ||
431 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 431 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
432 | if( !QDir( fi->filePath() ).isReadable()) | 432 | if( !QDir( fi->filePath() ).isReadable()) |
433 | pm = Resource::loadPixmap( "lockedfolder" ); | 433 | pm = Resource::loadPixmap( "lockedfolder" ); |
434 | else | 434 | else |
435 | pm= Resource::loadPixmap( "folder" ); | 435 | pm= Resource::loadPixmap( "folder" ); |
436 | item->setPixmap( 0,pm ); | 436 | item->setPixmap( 0,pm ); |
437 | } else { | 437 | } else { |
438 | if(fi->isExecutable()) { | 438 | if(fi->isExecutable()) { |
439 | pm = Resource::loadPixmap( "exec"); | 439 | pm = Resource::loadPixmap( "exec"); |
440 | item->setPixmap( 0,pm); | 440 | item->setPixmap( 0,pm); |
441 | } | 441 | } |
442 | else if( !fi->isReadable() ) { | 442 | else if( !fi->isReadable() ) { |
443 | pm = Resource::loadPixmap( "locked" ); | 443 | pm = Resource::loadPixmap( "locked" ); |
444 | item->setPixmap( 0,pm); | 444 | item->setPixmap( 0,pm); |
445 | } else { | 445 | } else { |
446 | MimeType mt(fi->filePath()); | 446 | MimeType mt(fi->filePath()); |
447 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 447 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
448 | if(pm.isNull()) | 448 | if(pm.isNull()) |
449 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 449 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
450 | item->setPixmap( 0,pm); | 450 | item->setPixmap( 0,pm); |
451 | } | 451 | } |
452 | } | 452 | } |
453 | if( fileL.find("->",0,TRUE) != -1) { | 453 | if( fileL.find("->",0,TRUE) != -1) { |
454 | // overlay link image | 454 | // overlay link image |
455 | pm= Resource::loadPixmap( "folder" ); | 455 | pm= Resource::loadPixmap( "folder" ); |
456 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 456 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
457 | QPainter painter( &pm ); | 457 | QPainter painter( &pm ); |
458 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 458 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
459 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 459 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
460 | item->setPixmap( 0, pm); | 460 | item->setPixmap( 0, pm); |
461 | } | 461 | } |
462 | } isDir=FALSE; | 462 | } isDir=FALSE; |
463 | ++it; | 463 | ++it; |
464 | } | 464 | } |
465 | 465 | ||
466 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { | 466 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { |
467 | struct stat buf; | 467 | struct stat buf; |
468 | struct stat st; | 468 | struct stat st; |
469 | mode_t mode; | 469 | mode_t mode; |
470 | DIR *dir; | 470 | DIR *dir; |
471 | int fd = 0; | 471 | int fd = 0; |
472 | struct dirent *mydirent; | 472 | struct dirent *mydirent; |
473 | int i = 1; | 473 | int i = 1; |
474 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) | 474 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) |
475 | while ((mydirent = readdir(dir)) != NULL) { | 475 | while ((mydirent = readdir(dir)) != NULL) { |
476 | lstat( mydirent->d_name, &buf); | 476 | lstat( mydirent->d_name, &buf); |
477 | qDebug(mydirent->d_name); | 477 | qDebug(mydirent->d_name); |
478 | // mode = buf.st_mode; | 478 | // mode = buf.st_mode; |
479 | fileL.sprintf("%s", mydirent->d_name); | 479 | fileL.sprintf("%s", mydirent->d_name); |
480 | // fileS.sprintf("%d, %d", ); //this isn't correct | 480 | // fileS.sprintf("%d, %d", ); //this isn't correct |
481 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); | 481 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); |
482 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 482 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
483 | if( fileL.find(".") == -1 ){ | 483 | if( fileL.find(".") == -1 ){ |
484 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 484 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
485 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 485 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
486 | item->setPixmap( 0,pm); | 486 | item->setPixmap( 0,pm); |
487 | } | 487 | } |
488 | } | 488 | } |
489 | 489 | ||
490 | closedir(dir); | 490 | closedir(dir); |
491 | } | 491 | } |
492 | 492 | ||
493 | Remote_View->setSorting( 3,FALSE); | 493 | Remote_View->setSorting( 3,FALSE); |
494 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); | 494 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); |
495 | } | 495 | } |
496 | 496 | ||
497 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) | 497 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) |
498 | { | 498 | { |
499 | if(selectedItem) { | 499 | if(selectedItem) { |
500 | QString strItem=selectedItem->text(0); | 500 | QString strItem=selectedItem->text(0); |
501 | QString strSize=selectedItem->text(1); | 501 | QString strSize=selectedItem->text(1); |
502 | strSize=strSize.stripWhiteSpace(); | 502 | strSize=strSize.stripWhiteSpace(); |
503 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 503 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
504 | // is symlink | 504 | // is symlink |
505 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 505 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
506 | if(QDir(strItem2).exists() ) { | 506 | if(QDir(strItem2).exists() ) { |
507 | currentDir.cd(strItem2, TRUE); | 507 | currentDir.cd(strItem2, TRUE); |
508 | populateLocalView(); | 508 | populateLocalView(); |
509 | } | 509 | } |
510 | } else { // not a symlink | 510 | } else { // not a symlink |
511 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 511 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
512 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 512 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
513 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 513 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
514 | currentDir.cd(strItem,FALSE); | 514 | currentDir.cd(strItem,FALSE); |
515 | populateLocalView(); | 515 | populateLocalView(); |
516 | } else { | 516 | } else { |
517 | currentDir.cdUp(); | 517 | currentDir.cdUp(); |
518 | populateLocalView(); | 518 | populateLocalView(); |
519 | } | 519 | } |
520 | if(QDir(strItem).exists()){ | 520 | if(QDir(strItem).exists()){ |
521 | currentDir.cd(strItem, TRUE); | 521 | currentDir.cd(strItem, TRUE); |
522 | populateLocalView(); | 522 | populateLocalView(); |
523 | } | 523 | } |
524 | } else { | 524 | } else { |
525 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 525 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
526 | if( QFile::exists(strItem ) ) { | 526 | if( QFile::exists(strItem ) ) { |
527 | // qDebug("upload "+strItem); | 527 | // qDebug("upload "+strItem); |
528 | } | 528 | } |
529 | } //end not symlink | 529 | } //end not symlink |
530 | chdir(strItem.latin1()); | 530 | chdir(strItem.latin1()); |
531 | } | 531 | } |
532 | } | 532 | } |
533 | } | 533 | } |
534 | 534 | ||
535 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) | 535 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) |
536 | { | 536 | { |
537 | if(selectedItem) { | 537 | if(selectedItem) { |
538 | QString strItem=selectedItem->text(0); | 538 | QString strItem=selectedItem->text(0); |
539 | QString strSize=selectedItem->text(1); | 539 | QString strSize=selectedItem->text(1); |
540 | strSize=strSize.stripWhiteSpace(); | 540 | strSize=strSize.stripWhiteSpace(); |
541 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 541 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
542 | // is symlink | 542 | // is symlink |
543 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 543 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
544 | if(QDir(strItem2).exists() ) { | 544 | if(QDir(strItem2).exists() ) { |
545 | currentRemoteDir.cd(strItem2, TRUE); | 545 | currentRemoteDir.cd(strItem2, TRUE); |
546 | populateRemoteView(); | 546 | populateRemoteView(); |
547 | } | 547 | } |
548 | } else { // not a symlink | 548 | } else { // not a symlink |
549 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 549 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
550 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { | 550 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { |
551 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); | 551 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); |
552 | currentRemoteDir.cd(strItem,FALSE); | 552 | currentRemoteDir.cd(strItem,FALSE); |
553 | populateRemoteView(); | 553 | populateRemoteView(); |
554 | } else { | 554 | } else { |
555 | currentRemoteDir.cdUp(); | 555 | currentRemoteDir.cdUp(); |
556 | populateRemoteView(); | 556 | populateRemoteView(); |
557 | } | 557 | } |
558 | if(QDir(strItem).exists()){ | 558 | if(QDir(strItem).exists()){ |
559 | currentRemoteDir.cd(strItem, TRUE); | 559 | currentRemoteDir.cd(strItem, TRUE); |
560 | populateRemoteView(); | 560 | populateRemoteView(); |
561 | } | 561 | } |
562 | } else { | 562 | } else { |
563 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); | 563 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); |
564 | if( QFile::exists(strItem ) ) { | 564 | if( QFile::exists(strItem ) ) { |
565 | // qDebug("upload "+strItem); | 565 | // qDebug("upload "+strItem); |
566 | } | 566 | } |
567 | } //end not symlink | 567 | } //end not symlink |
568 | chdir(strItem.latin1()); | 568 | chdir(strItem.latin1()); |
569 | } | 569 | } |
570 | } | 570 | } |
571 | } | 571 | } |
572 | 572 | ||
573 | void AdvancedFm::doLocalCd() | 573 | void AdvancedFm::doLocalCd() |
574 | { | 574 | { |
575 | localListClicked( Local_View->currentItem()); | 575 | localListClicked( Local_View->currentItem()); |
576 | } | 576 | } |
577 | 577 | ||
578 | void AdvancedFm::doRemoteCd() | 578 | void AdvancedFm::doRemoteCd() |
579 | { | 579 | { |
580 | localListClicked( Remote_View->currentItem()); | 580 | localListClicked( Remote_View->currentItem()); |
581 | } | 581 | } |
582 | 582 | ||
583 | void AdvancedFm::showHidden() | 583 | void AdvancedFm::showHidden() |
584 | { | 584 | { |
585 | if (b) { | 585 | if (b) { |
586 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 586 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
587 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 587 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
588 | // localMenu->setItemChecked(localMenu->idAt(0),TRUE); | 588 | // localMenu->setItemChecked(localMenu->idAt(0),TRUE); |
589 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 589 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
590 | b=FALSE; | 590 | b=FALSE; |
591 | 591 | ||
592 | } else { | 592 | } else { |
593 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 593 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
594 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 594 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
595 | // localMenu->setItemChecked(localMenu->idAt(0),FALSE); | 595 | // localMenu->setItemChecked(localMenu->idAt(0),FALSE); |
596 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 596 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
597 | b=TRUE; | 597 | b=TRUE; |
598 | } | 598 | } |
599 | populateLocalView(); | 599 | populateLocalView(); |
600 | 600 | ||
601 | } | 601 | } |
602 | 602 | ||
603 | void AdvancedFm::showRemoteHidden() | 603 | void AdvancedFm::showRemoteHidden() |
604 | { | 604 | { |
605 | if (b) { | 605 | if (b) { |
606 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 606 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
607 | // viewMenu->setItemChecked(localMenu->idAt(0),TRUE); | 607 | // viewMenu->setItemChecked(localMenu->idAt(0),TRUE); |
608 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 608 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
609 | b=TRUE; | 609 | b=TRUE; |
610 | 610 | ||
611 | } else { | 611 | } else { |
612 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 612 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
613 | // localMenu->setItemChecked(localMenu->idAt(0),FALSE); | 613 | // localMenu->setItemChecked(localMenu->idAt(0),FALSE); |
614 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 614 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
615 | b=FALSE; | 615 | b=FALSE; |
616 | } | 616 | } |
617 | populateRemoteView(); | 617 | populateRemoteView(); |
618 | } | 618 | } |
619 | 619 | ||
620 | void AdvancedFm::localListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 620 | void AdvancedFm::localListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
621 | { | 621 | { |
622 | switch (mouse) { | 622 | switch (mouse) { |
623 | case 1: | 623 | case 1: |
624 | break; | 624 | break; |
625 | case 2: | 625 | case 2: |
626 | showLocalMenu(item); | 626 | showLocalMenu(item); |
627 | Local_View->clearSelection(); | 627 | Local_View->clearSelection(); |
628 | break; | 628 | break; |
629 | }; | 629 | }; |
630 | } | 630 | } |
631 | 631 | ||
632 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 632 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
633 | { | 633 | { |
634 | switch (mouse) { | 634 | switch (mouse) { |
635 | case 1: | 635 | case 1: |
636 | break; | 636 | break; |
637 | case 2: | 637 | case 2: |
638 | showRemoteMenu(item); | 638 | showRemoteMenu(item); |
639 | Remote_View->clearSelection(); | 639 | Remote_View->clearSelection(); |
640 | break; | 640 | break; |
641 | }; | 641 | }; |
642 | } | 642 | } |
643 | 643 | ||
644 | void AdvancedFm::showLocalMenu(QListViewItem * item) | 644 | void AdvancedFm::showLocalMenu(QListViewItem * item) |
645 | { | 645 | { |
646 | if(item) { | 646 | if(item) { |
647 | QPopupMenu m; | 647 | QPopupMenu m; |
648 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 648 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
649 | m.insertSeparator(); | 649 | m.insertSeparator(); |
650 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) | 650 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) |
651 | m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 651 | m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
652 | else | 652 | else |
653 | m.insertItem( tr( "Open" ), this, SLOT( runThis() )); | 653 | m.insertItem( tr( "Open" ), this, SLOT( runThis() )); |
654 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); | 654 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); |
655 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 655 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
656 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 656 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
657 | m.insertSeparator(); | 657 | m.insertSeparator(); |
658 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 658 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
659 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); | 659 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); |
660 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 660 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
661 | m.insertItem( tr( "Move" ), this, SLOT( move() )); | 661 | m.insertItem( tr( "Move" ), this, SLOT( move() )); |
662 | m.insertSeparator(); | 662 | m.insertSeparator(); |
663 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 663 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
664 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 664 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
665 | m.insertSeparator(); | 665 | m.insertSeparator(); |
666 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 666 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
667 | m.insertSeparator(); | 667 | m.insertSeparator(); |
668 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 668 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
669 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 669 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
670 | m.setCheckable(TRUE); | 670 | m.setCheckable(TRUE); |
671 | if (!b) | 671 | if (!b) |
672 | m.setItemChecked(m.idAt(0),TRUE); | 672 | m.setItemChecked(m.idAt(0),TRUE); |
673 | else | 673 | else |
674 | m.setItemChecked(m.idAt(0),FALSE); | 674 | m.setItemChecked(m.idAt(0),FALSE); |
675 | m.exec( QCursor::pos() ); | 675 | m.exec( QCursor::pos() ); |
676 | } | 676 | } |
677 | } | 677 | } |
678 | 678 | ||
679 | void AdvancedFm::showRemoteMenu(QListViewItem * item) | 679 | void AdvancedFm::showRemoteMenu(QListViewItem * item) |
680 | { | 680 | { |
681 | if(item) { | 681 | if(item) { |
682 | QPopupMenu m; | 682 | QPopupMenu m; |
683 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); | 683 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); |
684 | m.insertSeparator(); | 684 | m.insertSeparator(); |
685 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) | 685 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) |
686 | m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); | 686 | m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); |
687 | else | 687 | else |
688 | m.insertItem( tr( "Open" ), this, SLOT( runThis() )); | 688 | m.insertItem( tr( "Open" ), this, SLOT( runThis() )); |
689 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); | 689 | m.insertItem( tr( "Open as Text" ), this, SLOT( runText() )); |
690 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 690 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
691 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 691 | m.insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
692 | m.insertSeparator(); | 692 | m.insertSeparator(); |
693 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 693 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
694 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); | 694 | m.insertItem( tr( "Copy" ), this, SLOT( copy() )); |
695 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 695 | m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
696 | m.insertItem( tr( "Move" ), this, SLOT( move() )); | 696 | m.insertItem( tr( "Move" ), this, SLOT( move() )); |
697 | m.insertSeparator(); | 697 | m.insertSeparator(); |
698 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 698 | m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
699 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 699 | m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
700 | m.insertSeparator(); | 700 | m.insertSeparator(); |
701 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 701 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
702 | m.insertSeparator(); | 702 | m.insertSeparator(); |
703 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 703 | m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
704 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 704 | m.insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
705 | m.setCheckable(TRUE); | 705 | m.setCheckable(TRUE); |
706 | if (!b) | 706 | if (!b) |
707 | m.setItemChecked(m.idAt(0),TRUE); | 707 | m.setItemChecked(m.idAt(0),TRUE); |
708 | else | 708 | else |
709 | m.setItemChecked(m.idAt(0),FALSE); | 709 | m.setItemChecked(m.idAt(0),FALSE); |
710 | m.exec( QCursor::pos() ); | 710 | m.exec( QCursor::pos() ); |
711 | } | 711 | } |
712 | } | 712 | } |
713 | 713 | ||
714 | void AdvancedFm::runThis() { | 714 | void AdvancedFm::runThis() { |
715 | // QFileInfo *fi; | 715 | // QFileInfo *fi; |
716 | if (TabWidget->currentPageIndex() == 0) { | 716 | if (TabWidget->currentPageIndex() == 0) { |
717 | QString curFile = Local_View->currentItem()->text(0); | 717 | QString curFile = Local_View->currentItem()->text(0); |
718 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); | 718 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile); |
719 | if(fileInfo.isExecutable()) { | 719 | if(fileInfo.isExecutable()) { |
720 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 720 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
721 | e << curFile; | 721 | e << curFile; |
722 | } else { | 722 | } else { |
723 | curFile = currentDir.canonicalPath()+"/"+curFile; | 723 | curFile = currentDir.canonicalPath()+"/"+curFile; |
724 | DocLnk nf(curFile); | 724 | DocLnk nf(curFile); |
725 | QString execStr = nf.exec(); | 725 | QString execStr = nf.exec(); |
726 | qDebug( execStr); | 726 | qDebug( execStr); |
727 | if( execStr.isEmpty() ) { | 727 | if( execStr.isEmpty() ) { |
728 | } else { | 728 | } else { |
729 | nf.execute(); | 729 | nf.execute(); |
730 | } | 730 | } |
731 | } | 731 | } |
732 | // MimeType mt( curFile); | 732 | // MimeType mt( curFile); |
733 | } else { | 733 | } else { |
734 | QString curFile = Remote_View->currentItem()->text(0); | 734 | QString curFile = Remote_View->currentItem()->text(0); |
735 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); | 735 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile); |
736 | if(fileInfo.isExecutable()) { | 736 | if(fileInfo.isExecutable()) { |
737 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 737 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
738 | e << curFile; | 738 | e << curFile; |
739 | } else { | 739 | } else { |
740 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | 740 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; |
741 | DocLnk nf(curFile); | 741 | DocLnk nf(curFile); |
742 | QString execStr = nf.exec(); | 742 | QString execStr = nf.exec(); |
743 | qDebug(execStr); | 743 | qDebug(execStr); |
744 | if( execStr.isEmpty() ) { | 744 | if( execStr.isEmpty() ) { |
745 | } else { | 745 | } else { |
746 | nf.execute(); | 746 | nf.execute(); |
747 | } | 747 | } |
748 | } | 748 | } |
749 | // MimeType mt( curFile); | 749 | // MimeType mt( curFile); |
750 | } | 750 | } |
751 | } | 751 | } |
752 | 752 | ||
753 | void AdvancedFm::runText() { | 753 | void AdvancedFm::runText() { |
754 | if (TabWidget->currentPageIndex() == 0) { | 754 | if (TabWidget->currentPageIndex() == 0) { |
755 | QString curFile = Local_View->currentItem()->text(0); | 755 | QString curFile = Local_View->currentItem()->text(0); |
756 | curFile = currentDir.canonicalPath()+"/"+curFile; | 756 | curFile = currentDir.canonicalPath()+"/"+curFile; |
757 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 757 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
758 | e << curFile; | 758 | e << curFile; |
759 | } else { | 759 | } else { |
760 | QString curFile = Remote_View->currentItem()->text(0); | 760 | QString curFile = Remote_View->currentItem()->text(0); |
761 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; | 761 | curFile = currentRemoteDir.canonicalPath()+"/"+curFile; |
762 | DocLnk nf(curFile); | 762 | DocLnk nf(curFile); |
763 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 763 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
764 | e << curFile; | 764 | e << curFile; |
765 | } | 765 | } |
766 | } | 766 | } |
767 | 767 | ||
768 | void AdvancedFm::localMakDir() | 768 | void AdvancedFm::localMakDir() |
769 | { | 769 | { |
770 | InputDialog *fileDlg; | 770 | InputDialog *fileDlg; |
771 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 771 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
772 | fileDlg->exec(); | 772 | fileDlg->exec(); |
773 | if( fileDlg->result() == 1 ) { | 773 | if( fileDlg->result() == 1 ) { |
774 | QString filename = fileDlg->LineEdit1->text(); | 774 | QString filename = fileDlg->LineEdit1->text(); |
775 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 775 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
776 | } | 776 | } |
777 | populateLocalView(); | 777 | populateLocalView(); |
778 | } | 778 | } |
779 | 779 | ||
780 | void AdvancedFm::remoteMakDir() | 780 | void AdvancedFm::remoteMakDir() |
781 | { | 781 | { |
782 | InputDialog *fileDlg; | 782 | InputDialog *fileDlg; |
783 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 783 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
784 | fileDlg->exec(); | 784 | fileDlg->exec(); |
785 | if( fileDlg->result() == 1 ) { | 785 | if( fileDlg->result() == 1 ) { |
786 | QString filename = fileDlg->LineEdit1->text(); | 786 | QString filename = fileDlg->LineEdit1->text(); |
787 | currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); | 787 | currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename); |
788 | } | 788 | } |
789 | populateRemoteView(); | 789 | populateRemoteView(); |
790 | } | 790 | } |
791 | 791 | ||
792 | void AdvancedFm::localDelete() | 792 | void AdvancedFm::localDelete() |
793 | { | 793 | { |
794 | QStringList curFileList = getPath(); | 794 | QStringList curFileList = getPath(); |
795 | QString myFile; | 795 | QString myFile; |
796 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 796 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
797 | myFile = (*it); | 797 | myFile = (*it); |
798 | if( myFile.find(" -> ",0,TRUE) != -1) | 798 | if( myFile.find(" -> ",0,TRUE) != -1) |
799 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 799 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
800 | 800 | ||
801 | QString f = currentDir.canonicalPath()+"/"+myFile; | 801 | QString f = currentDir.canonicalPath(); |
802 | if(f.right(1).find("/",0,TRUE) == -1) | ||
803 | f+="/"; | ||
804 | f+=myFile; | ||
802 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 805 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
803 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+" ?" | 806 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ |
807 | "\nand all it's contents ?" | ||
804 | ,tr("Yes"),tr("No"),0,0,1) ) { | 808 | ,tr("Yes"),tr("No"),0,0,1) ) { |
805 | case 0: { | 809 | case 0: { |
806 | QString cmd="rmdir -rf "+f; | 810 | f=f.left(f.length()-1); |
811 | QString cmd="rm -rf "+f; | ||
807 | system( cmd.latin1()); | 812 | system( cmd.latin1()); |
808 | populateLocalView(); | 813 | populateLocalView(); |
809 | } | 814 | } |
810 | break; | 815 | break; |
811 | case 1: | 816 | case 1: |
812 | // exit | 817 | // exit |
813 | break; | 818 | break; |
814 | }; | 819 | }; |
815 | 820 | ||
816 | } else { | 821 | } else { |
817 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 822 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
818 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 823 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
819 | case 0: { | 824 | case 0: { |
820 | QString cmd="rm "+f; | 825 | QString cmd="rm "+f; |
821 | QFile file(f); | 826 | QFile file(f); |
822 | file.remove(); | 827 | file.remove(); |
823 | // system( cmd.latin1()); | 828 | // system( cmd.latin1()); |
824 | populateLocalView(); | 829 | populateLocalView(); |
825 | } | 830 | } |
826 | break; | 831 | break; |
827 | case 1: | 832 | case 1: |
828 | // exit | 833 | // exit |
829 | break; | 834 | break; |
830 | }; | 835 | }; |
831 | } | 836 | } |
832 | 837 | ||
833 | } | 838 | } |
834 | } | 839 | } |
835 | 840 | ||
836 | void AdvancedFm::remoteDelete() | 841 | void AdvancedFm::remoteDelete() |
837 | { | 842 | { |
838 | QStringList curFileList = getPath(); | 843 | QStringList curFileList = getPath(); |
839 | QString myFile; | 844 | QString myFile; |
840 | 845 | ||
841 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 846 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
842 | myFile = (*it); | 847 | myFile = (*it); |
843 | if(myFile.find(" -> ",0,TRUE) != -1) | 848 | if(myFile.find(" -> ",0,TRUE) != -1) |
844 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); | 849 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); |
845 | QString f = currentRemoteDir.canonicalPath()+"/"+myFile; | 850 | QString f = currentDir.canonicalPath(); |
851 | if(f.right(1).find("/",0,TRUE) == -1) | ||
852 | f+="/"; | ||
853 | f+=myFile; | ||
846 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 854 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
847 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+" ?", | 855 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ |
856 | "\nand all it's contents ?", | ||
848 | tr("Yes"),tr("No"),0,0,1) ) { | 857 | tr("Yes"),tr("No"),0,0,1) ) { |
849 | case 0: { | 858 | case 0: { |
850 | QString cmd="rmdir -rf "+f; | 859 | f=f.left(f.length()-1); |
860 | QString cmd="rm -rf "+f; | ||
851 | system( cmd.latin1()); | 861 | system( cmd.latin1()); |
852 | populateRemoteView(); | 862 | populateRemoteView(); |
853 | } | 863 | } |
854 | break; | 864 | break; |
855 | case 1: | 865 | case 1: |
856 | // exit | 866 | // exit |
857 | break; | 867 | break; |
858 | }; | 868 | }; |
859 | 869 | ||
860 | } else { | 870 | } else { |
861 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 871 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
862 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 872 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
863 | case 0: { | 873 | case 0: { |
864 | QString cmd="rm "+f; | 874 | QString cmd="rm "+f; |
865 | QFile file(f); | 875 | QFile file(f); |
866 | file.remove(); | 876 | file.remove(); |
867 | // system( cmd.latin1()); | 877 | // system( cmd.latin1()); |
868 | populateRemoteView(); | 878 | populateRemoteView(); |
869 | } | 879 | } |
870 | break; | 880 | break; |
871 | case 1: | 881 | case 1: |
872 | // exit | 882 | // exit |
873 | break; | 883 | break; |
874 | }; | 884 | }; |
875 | } | 885 | } |
876 | } | 886 | } |
877 | } | 887 | } |
878 | 888 | ||
879 | void AdvancedFm::localRename() | 889 | void AdvancedFm::localRename() |
880 | { | 890 | { |
881 | QString curFile = Local_View->currentItem()->text(0); | 891 | QString curFile = Local_View->currentItem()->text(0); |
882 | InputDialog *fileDlg; | 892 | InputDialog *fileDlg; |
883 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 893 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
884 | fileDlg->setInputText((const QString &)curFile); | 894 | fileDlg->setInputText((const QString &)curFile); |
885 | fileDlg->exec(); | 895 | fileDlg->exec(); |
886 | if( fileDlg->result() == 1 ) { | 896 | if( fileDlg->result() == 1 ) { |
887 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 897 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
888 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 898 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
889 | if( rename(oldname.latin1(), newName.latin1())== -1) | 899 | if( rename(oldname.latin1(), newName.latin1())== -1) |
890 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 900 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
891 | } | 901 | } |
892 | populateLocalView(); | 902 | populateLocalView(); |
893 | } | 903 | } |
894 | 904 | ||
895 | void AdvancedFm::remoteRename() | 905 | void AdvancedFm::remoteRename() |
896 | { | 906 | { |
897 | QString curFile = Local_View->currentItem()->text(0); | 907 | QString curFile = Local_View->currentItem()->text(0); |
898 | InputDialog *fileDlg; | 908 | InputDialog *fileDlg; |
899 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 909 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
900 | fileDlg->setInputText((const QString &)curFile); | 910 | fileDlg->setInputText((const QString &)curFile); |
901 | fileDlg->exec(); | 911 | fileDlg->exec(); |
902 | if( fileDlg->result() == 1 ) { | 912 | if( fileDlg->result() == 1 ) { |
903 | QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; | 913 | QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile; |
904 | QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 914 | QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
905 | if( rename(oldname.latin1(), newName.latin1())== -1) | 915 | if( rename(oldname.latin1(), newName.latin1())== -1) |
906 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 916 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
907 | } | 917 | } |
908 | populateRemoteView(); | 918 | populateRemoteView(); |
909 | } | 919 | } |
910 | 920 | ||
911 | void AdvancedFm::switchToLocalTab() | 921 | void AdvancedFm::switchToLocalTab() |
912 | { | 922 | { |
913 | TabWidget->setCurrentPage(0); | 923 | TabWidget->setCurrentPage(0); |
914 | Local_View->setFocus(); | 924 | Local_View->setFocus(); |
915 | } | 925 | } |
916 | 926 | ||
917 | void AdvancedFm::switchToRemoteTab() | 927 | void AdvancedFm::switchToRemoteTab() |
918 | { | 928 | { |
919 | TabWidget->setCurrentPage(1); | 929 | TabWidget->setCurrentPage(1); |
920 | Remote_View->setFocus(); | 930 | Remote_View->setFocus(); |
921 | } | 931 | } |
922 | 932 | ||
923 | void AdvancedFm::readConfig() | 933 | void AdvancedFm::readConfig() |
924 | { | 934 | { |
925 | Config cfg("AdvancedFm"); | 935 | Config cfg("AdvancedFm"); |
926 | } | 936 | } |
927 | 937 | ||
928 | void AdvancedFm::writeConfig() | 938 | void AdvancedFm::writeConfig() |
929 | { | 939 | { |
930 | Config cfg("AdvancedFm"); | 940 | Config cfg("AdvancedFm"); |
931 | } | 941 | } |
932 | 942 | ||
933 | void AdvancedFm::currentPathComboChanged() | 943 | void AdvancedFm::currentPathComboChanged() |
934 | { | 944 | { |
935 | if (TabWidget->currentPageIndex() == 0) { | 945 | if (TabWidget->currentPageIndex() == 0) { |
936 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 946 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
937 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); | 947 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); |
938 | populateLocalView(); | 948 | populateLocalView(); |
939 | } else { | 949 | } else { |
940 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 950 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
941 | } | 951 | } |
942 | } | 952 | } |
943 | if (TabWidget->currentPageIndex() == 0) { | 953 | if (TabWidget->currentPageIndex() == 0) { |
944 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 954 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
945 | currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); | 955 | currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); |
946 | populateRemoteView(); | 956 | populateRemoteView(); |
947 | } else { | 957 | } else { |
948 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 958 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
949 | } | 959 | } |
950 | } | 960 | } |
951 | } | 961 | } |
952 | 962 | ||
953 | void AdvancedFm::fillCombo(const QString ¤tPath) { | 963 | void AdvancedFm::fillCombo(const QString ¤tPath) { |
954 | 964 | ||
955 | if (TabWidget->currentPageIndex() == 0) { | 965 | if (TabWidget->currentPageIndex() == 0) { |
956 | currentPathCombo->lineEdit()->setText( currentPath); | 966 | currentPathCombo->lineEdit()->setText( currentPath); |
957 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 967 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
958 | currentPathCombo->clear(); | 968 | currentPathCombo->clear(); |
959 | localDirPathStringList.prepend( currentPath ); | 969 | localDirPathStringList.prepend( currentPath ); |
960 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 970 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
961 | } | 971 | } |
962 | } else { | 972 | } else { |
963 | currentPathCombo->lineEdit()->setText( currentPath); | 973 | currentPathCombo->lineEdit()->setText( currentPath); |
964 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 974 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
965 | currentPathCombo->clear(); | 975 | currentPathCombo->clear(); |
966 | remoteDirPathStringList.prepend( currentPath ); | 976 | remoteDirPathStringList.prepend( currentPath ); |
967 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 977 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
968 | } | 978 | } |
969 | } | 979 | } |
970 | } | 980 | } |
971 | 981 | ||
972 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { | 982 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { |
973 | if (TabWidget->currentPageIndex() == 0) { | 983 | if (TabWidget->currentPageIndex() == 0) { |
974 | chdir( currentPath.latin1() ); | 984 | chdir( currentPath.latin1() ); |
975 | currentDir.cd( currentPath, TRUE); | 985 | currentDir.cd( currentPath, TRUE); |
976 | populateLocalView(); | 986 | populateLocalView(); |
977 | update(); | 987 | update(); |
978 | } else { | 988 | } else { |
979 | chdir( currentPath.latin1() ); | 989 | chdir( currentPath.latin1() ); |
980 | currentRemoteDir.cd( currentPath, TRUE); | 990 | currentRemoteDir.cd( currentPath, TRUE); |
981 | populateRemoteView(); | 991 | populateRemoteView(); |
982 | update(); | 992 | update(); |
983 | } | 993 | } |
984 | } | 994 | } |
985 | 995 | ||
986 | void AdvancedFm::filePerms() { | 996 | void AdvancedFm::filePerms() { |
987 | 997 | ||
988 | QStringList curFileList = getPath(); | 998 | QStringList curFileList = getPath(); |
989 | QString filePath; | 999 | QString filePath; |
990 | 1000 | ||
991 | if (TabWidget->currentPageIndex() == 0) { | 1001 | if (TabWidget->currentPageIndex() == 0) { |
992 | filePath = currentDir.canonicalPath()+"/"; | 1002 | filePath = currentDir.canonicalPath()+"/"; |
993 | } else { | 1003 | } else { |
994 | filePath= currentRemoteDir.canonicalPath()+"/"; | 1004 | filePath= currentRemoteDir.canonicalPath()+"/"; |
995 | } | 1005 | } |
996 | 1006 | ||
997 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1007 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
998 | filePermissions *filePerm; | 1008 | filePermissions *filePerm; |
999 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 1009 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
1000 | filePerm->showMaximized(); | 1010 | filePerm->showMaximized(); |
1001 | filePerm->exec(); | 1011 | filePerm->exec(); |
1002 | if( filePerm) | 1012 | if( filePerm) |
1003 | delete filePerm; | 1013 | delete filePerm; |
1004 | } | 1014 | } |
1005 | } | 1015 | } |
1006 | 1016 | ||
1007 | void AdvancedFm::doProperties() { | 1017 | void AdvancedFm::doProperties() { |
1008 | QStringList curFileList = getPath(); | 1018 | QStringList curFileList = getPath(); |
1009 | QString filePath; | 1019 | QString filePath; |
1010 | if (TabWidget->currentPageIndex() == 0) { | 1020 | if (TabWidget->currentPageIndex() == 0) { |
1011 | filePath = currentDir.canonicalPath()+"/"; | 1021 | filePath = currentDir.canonicalPath()+"/"; |
1012 | } else { | 1022 | } else { |
1013 | filePath= currentRemoteDir.canonicalPath()+"/"; | 1023 | filePath= currentRemoteDir.canonicalPath()+"/"; |
1014 | } | 1024 | } |
1015 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1025 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1016 | DocLnk lnk( (filePath+*it)); | 1026 | DocLnk lnk( (filePath+*it)); |
1017 | LnkProperties prop( &lnk ); | 1027 | LnkProperties prop( &lnk ); |
1018 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 1028 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
1019 | prop.showMaximized(); | 1029 | prop.showMaximized(); |
1020 | prop.exec(); | 1030 | prop.exec(); |
1021 | } | 1031 | } |
1022 | } | 1032 | } |
1023 | 1033 | ||
1024 | QStringList AdvancedFm::getPath() { | 1034 | QStringList AdvancedFm::getPath() { |
1025 | QStringList strList; | 1035 | QStringList strList; |
1026 | if (TabWidget->currentPageIndex() == 0) { | 1036 | if (TabWidget->currentPageIndex() == 0) { |
1027 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 1037 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
1028 | QListViewItemIterator it( Local_View ); | 1038 | QListViewItemIterator it( Local_View ); |
1029 | for ( ; it.current(); ++it ) { | 1039 | for ( ; it.current(); ++it ) { |
1030 | if ( it.current()->isSelected() ) { | 1040 | if ( it.current()->isSelected() ) { |
1031 | strList << it.current()->text(0); | 1041 | strList << it.current()->text(0); |
1032 | } | 1042 | } |
1033 | } | 1043 | } |
1034 | return strList; | 1044 | return strList; |
1035 | } else { | 1045 | } else { |
1036 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 1046 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
1037 | QListViewItemIterator it( Remote_View ); | 1047 | QListViewItemIterator it( Remote_View ); |
1038 | for ( ; it.current(); ++it ) { | 1048 | for ( ; it.current(); ++it ) { |
1039 | if ( it.current()->isSelected() ) { | 1049 | if ( it.current()->isSelected() ) { |
1040 | strList << currentDir.canonicalPath()+"/"+ it.current()->text(0); | 1050 | strList << currentDir.canonicalPath()+"/"+ it.current()->text(0); |
1041 | } | 1051 | } |
1042 | } | 1052 | } |
1043 | return strList; | 1053 | return strList; |
1044 | } | 1054 | } |
1045 | return ""; | 1055 | return ""; |
1046 | } | 1056 | } |
1047 | 1057 | ||
1048 | void AdvancedFm::homeButtonPushed() { | 1058 | void AdvancedFm::homeButtonPushed() { |
1049 | QString current = QDir::homeDirPath(); | 1059 | QString current = QDir::homeDirPath(); |
1050 | chdir( current.latin1() ); | 1060 | chdir( current.latin1() ); |
1051 | if (TabWidget->currentPageIndex() == 0) { | 1061 | if (TabWidget->currentPageIndex() == 0) { |
1052 | currentDir.cd( current, TRUE); | 1062 | currentDir.cd( current, TRUE); |
1053 | populateLocalView(); | 1063 | populateLocalView(); |
1054 | } else { | 1064 | } else { |
1055 | currentRemoteDir.cd( current, TRUE); | 1065 | currentRemoteDir.cd( current, TRUE); |
1056 | populateRemoteView(); | 1066 | populateRemoteView(); |
1057 | } | 1067 | } |
1058 | update(); | 1068 | update(); |
1059 | } | 1069 | } |
1060 | 1070 | ||
1061 | void AdvancedFm::docButtonPushed() { | 1071 | void AdvancedFm::docButtonPushed() { |
1062 | QString current = QPEApplication::documentDir(); | 1072 | QString current = QPEApplication::documentDir(); |
1063 | chdir( current.latin1() ); | 1073 | chdir( current.latin1() ); |
1064 | if (TabWidget->currentPageIndex() == 0) { | 1074 | if (TabWidget->currentPageIndex() == 0) { |
1065 | currentDir.cd( current, TRUE); | 1075 | currentDir.cd( current, TRUE); |
1066 | populateLocalView(); | 1076 | populateLocalView(); |
1067 | } else { | 1077 | } else { |
1068 | currentRemoteDir.cd( current, TRUE); | 1078 | currentRemoteDir.cd( current, TRUE); |
1069 | populateRemoteView(); | 1079 | populateRemoteView(); |
1070 | } | 1080 | } |
1071 | update(); | 1081 | update(); |
1072 | } | 1082 | } |
1073 | 1083 | ||
1074 | void AdvancedFm::SDButtonPushed() { | 1084 | void AdvancedFm::SDButtonPushed() { |
1075 | QString current = "/mnt/card"; | 1085 | QString current = "/mnt/card"; |
1076 | chdir( current.latin1() ); | 1086 | chdir( current.latin1() ); |
1077 | if (TabWidget->currentPageIndex() == 0) { | 1087 | if (TabWidget->currentPageIndex() == 0) { |
1078 | currentDir.cd( current, TRUE); | 1088 | currentDir.cd( current, TRUE); |
1079 | populateLocalView(); | 1089 | populateLocalView(); |
1080 | } else { | 1090 | } else { |
1081 | currentRemoteDir.cd( current, TRUE); | 1091 | currentRemoteDir.cd( current, TRUE); |
1082 | populateRemoteView(); | 1092 | populateRemoteView(); |
1083 | } | 1093 | } |
1084 | update(); | 1094 | update(); |
1085 | 1095 | ||
1086 | } | 1096 | } |
1087 | 1097 | ||
1088 | void AdvancedFm::CFButtonPushed() { | 1098 | void AdvancedFm::CFButtonPushed() { |
1089 | QString current = "/mnt/cf"; | 1099 | QString current = "/mnt/cf"; |
1090 | chdir( current.latin1() ); | 1100 | chdir( current.latin1() ); |
1091 | if (TabWidget->currentPageIndex() == 0) { | 1101 | if (TabWidget->currentPageIndex() == 0) { |
1092 | currentDir.cd( current, TRUE); | 1102 | currentDir.cd( current, TRUE); |
1093 | populateLocalView(); | 1103 | populateLocalView(); |
1094 | } else { | 1104 | } else { |
1095 | currentRemoteDir.cd( current, TRUE); | 1105 | currentRemoteDir.cd( current, TRUE); |
1096 | populateRemoteView(); | 1106 | populateRemoteView(); |
1097 | } | 1107 | } |
1098 | update(); | 1108 | update(); |
1099 | 1109 | ||
1100 | } | 1110 | } |
1101 | 1111 | ||
1102 | 1112 | ||
1103 | void AdvancedFm::upDir() | 1113 | void AdvancedFm::upDir() |
1104 | { | 1114 | { |
1105 | if (TabWidget->currentPageIndex() == 0) { | 1115 | if (TabWidget->currentPageIndex() == 0) { |
1106 | QString current = currentDir.canonicalPath(); | 1116 | QString current = currentDir.canonicalPath(); |
1107 | QDir dir(current); | 1117 | QDir dir(current); |
1108 | dir.cdUp(); | 1118 | dir.cdUp(); |
1109 | current = dir.canonicalPath(); | 1119 | current = dir.canonicalPath(); |
1110 | chdir( current.latin1() ); | 1120 | chdir( current.latin1() ); |
1111 | currentDir.cd( current, TRUE); | 1121 | currentDir.cd( current, TRUE); |
1112 | populateLocalView(); | 1122 | populateLocalView(); |
1113 | update(); | 1123 | update(); |
1114 | } else { | 1124 | } else { |
1115 | QString current = currentRemoteDir.canonicalPath(); | 1125 | QString current = currentRemoteDir.canonicalPath(); |
1116 | QDir dir(current); | 1126 | QDir dir(current); |
1117 | dir.cdUp(); | 1127 | dir.cdUp(); |
1118 | current = dir.canonicalPath(); | 1128 | current = dir.canonicalPath(); |
1119 | chdir( current.latin1() ); | 1129 | chdir( current.latin1() ); |
1120 | currentRemoteDir.cd( current, TRUE); | 1130 | currentRemoteDir.cd( current, TRUE); |
1121 | populateRemoteView(); | 1131 | populateRemoteView(); |
1122 | update(); | 1132 | update(); |
1123 | } | 1133 | } |
1124 | } | 1134 | } |
1125 | 1135 | ||
1126 | void AdvancedFm::copy() | 1136 | void AdvancedFm::copy() |
1127 | { | 1137 | { |
1128 | QStringList curFileList = getPath(); | 1138 | QStringList curFileList = getPath(); |
1129 | QString curFile; | 1139 | QString curFile; |
1130 | if (TabWidget->currentPageIndex() == 0) { | 1140 | if (TabWidget->currentPageIndex() == 0) { |
1131 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1141 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1132 | 1142 | ||
1133 | QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1143 | QString destFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1134 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1144 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1135 | QFile f(destFile); | 1145 | QFile f(destFile); |
1136 | if( f.exists()) | 1146 | if( f.exists()) |
1137 | f.remove(); | 1147 | f.remove(); |
1138 | if(!copyFile(destFile, curFile) ) | 1148 | if(!copyFile(destFile, curFile) ) |
1139 | qWarning("nothin doing"); | 1149 | qWarning("nothin doing"); |
1140 | } | 1150 | } |
1141 | populateRemoteView(); | 1151 | populateRemoteView(); |
1142 | TabWidget->setCurrentPage(1); | 1152 | TabWidget->setCurrentPage(1); |
1143 | 1153 | ||
1144 | } else { | 1154 | } else { |
1145 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1155 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1146 | 1156 | ||
1147 | QString destFile = currentDir.canonicalPath()+"/"+(*it); | 1157 | QString destFile = currentDir.canonicalPath()+"/"+(*it); |
1148 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 1158 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
1149 | QFile f(destFile); | 1159 | QFile f(destFile); |
1150 | if( f.exists()) | 1160 | if( f.exists()) |
1151 | f.remove(); | 1161 | f.remove(); |
1152 | if(!copyFile(destFile, curFile) ) | 1162 | if(!copyFile(destFile, curFile) ) |
1153 | qWarning("nothin doing"); | 1163 | qWarning("nothin doing"); |
1154 | } | 1164 | } |
1155 | populateLocalView(); | 1165 | populateLocalView(); |
1156 | TabWidget->setCurrentPage(0); | 1166 | TabWidget->setCurrentPage(0); |
1157 | } | 1167 | } |
1158 | } | 1168 | } |
1159 | 1169 | ||
1160 | void AdvancedFm::copyAs() | 1170 | void AdvancedFm::copyAs() |
1161 | { | 1171 | { |
1162 | QStringList curFileList = getPath(); | 1172 | QStringList curFileList = getPath(); |
1163 | QString curFile; | 1173 | QString curFile; |
1164 | InputDialog *fileDlg; | 1174 | InputDialog *fileDlg; |
1165 | fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); | 1175 | fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); |
1166 | 1176 | ||
1167 | if (TabWidget->currentPageIndex() == 0) { | 1177 | if (TabWidget->currentPageIndex() == 0) { |
1168 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1178 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1169 | QString destFile = *it; | 1179 | QString destFile = *it; |
1170 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1180 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1171 | // InputDialog *fileDlg; | 1181 | // InputDialog *fileDlg; |
1172 | // fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); | 1182 | // fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0); |
1173 | fileDlg->setInputText((const QString &) destFile ); | 1183 | fileDlg->setInputText((const QString &) destFile ); |
1174 | fileDlg->exec(); | 1184 | fileDlg->exec(); |
1175 | if( fileDlg->result() == 1 ) { | 1185 | if( fileDlg->result() == 1 ) { |
1176 | QString filename = fileDlg->LineEdit1->text(); | 1186 | QString filename = fileDlg->LineEdit1->text(); |
1177 | destFile = currentRemoteDir.canonicalPath()+"/"+destFile; | 1187 | destFile = currentRemoteDir.canonicalPath()+"/"+destFile; |
1178 | 1188 | ||
1179 | QFile f(destFile); | 1189 | QFile f(destFile); |
1180 | if( f.exists()) | 1190 | if( f.exists()) |
1181 | f.remove(); | 1191 | f.remove(); |
1182 | if(!copyFile(destFile, curFile) ) | 1192 | if(!copyFile(destFile, curFile) ) |
1183 | qWarning("nothin doing"); | 1193 | qWarning("nothin doing"); |
1184 | } | 1194 | } |
1185 | } | 1195 | } |
1186 | 1196 | ||
1187 | populateRemoteView(); | 1197 | populateRemoteView(); |
1188 | TabWidget->setCurrentPage(1); | 1198 | TabWidget->setCurrentPage(1); |
1189 | } else { | 1199 | } else { |
1190 | if (TabWidget->currentPageIndex() == 0) { | 1200 | if (TabWidget->currentPageIndex() == 0) { |
1191 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1201 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1192 | 1202 | ||
1193 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1203 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1194 | QString destFile = *it; | 1204 | QString destFile = *it; |
1195 | fileDlg->setInputText((const QString &) destFile); | 1205 | fileDlg->setInputText((const QString &) destFile); |
1196 | fileDlg->exec(); | 1206 | fileDlg->exec(); |
1197 | if( fileDlg->result() == 1 ) { | 1207 | if( fileDlg->result() == 1 ) { |
1198 | QString filename = fileDlg->LineEdit1->text(); | 1208 | QString filename = fileDlg->LineEdit1->text(); |
1199 | destFile = currentDir.canonicalPath()+"/"+destFile; | 1209 | destFile = currentDir.canonicalPath()+"/"+destFile; |
1200 | 1210 | ||
1201 | QFile f(destFile); | 1211 | QFile f(destFile); |
1202 | if( f.exists()) | 1212 | if( f.exists()) |
1203 | f.remove(); | 1213 | f.remove(); |
1204 | if(!copyFile(destFile, curFile) ) | 1214 | if(!copyFile(destFile, curFile) ) |
1205 | qWarning("nothin doing"); | 1215 | qWarning("nothin doing"); |
1206 | } | 1216 | } |
1207 | } | 1217 | } |
1208 | populateLocalView(); | 1218 | populateLocalView(); |
1209 | TabWidget->setCurrentPage(0); | 1219 | TabWidget->setCurrentPage(0); |
1210 | } | 1220 | } |
1211 | } | 1221 | } |
1212 | } | 1222 | } |
1213 | 1223 | ||
1214 | void AdvancedFm::move() { | 1224 | void AdvancedFm::move() { |
1215 | 1225 | ||
1216 | QStringList curFileList = getPath(); | 1226 | QStringList curFileList = getPath(); |
1217 | QString curFile; | 1227 | QString curFile; |
1218 | // qDebug(curFile); | 1228 | // qDebug(curFile); |
1219 | QString destFile; | 1229 | QString destFile; |
1220 | 1230 | ||
1221 | if (TabWidget->currentPageIndex() == 0) { | 1231 | if (TabWidget->currentPageIndex() == 0) { |
1222 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1232 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1223 | QString destFile = currentRemoteDir.canonicalPath() + "/" + *it; | 1233 | QString destFile = currentRemoteDir.canonicalPath() + "/" + *it; |
1224 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1234 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1225 | qDebug("Destination file is "+destFile); | 1235 | qDebug("Destination file is "+destFile); |
1226 | 1236 | ||
1227 | QFile f(destFile); | 1237 | QFile f(destFile); |
1228 | if( f.exists()) | 1238 | if( f.exists()) |
1229 | f.remove(); | 1239 | f.remove(); |
1230 | if(!copyFile( destFile, curFile) ) { | 1240 | if(!copyFile( destFile, curFile) ) { |
1231 | QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); | 1241 | QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); |
1232 | return; | 1242 | return; |
1233 | } | 1243 | } |
1234 | QFile::remove(curFile); | 1244 | QFile::remove(curFile); |
1235 | } | 1245 | } |
1236 | TabWidget->setCurrentPage(1); | 1246 | TabWidget->setCurrentPage(1); |
1237 | } else { | 1247 | } else { |
1238 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 1248 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
1239 | QString destFile = currentRemoteDir.canonicalPath() + "/" + *it; | 1249 | QString destFile = currentRemoteDir.canonicalPath() + "/" + *it; |
1240 | qDebug("Destination file is "+destFile); | 1250 | qDebug("Destination file is "+destFile); |
1241 | curFile = currentDir.canonicalPath()+"/"+(*it); | 1251 | curFile = currentDir.canonicalPath()+"/"+(*it); |
1242 | 1252 | ||
1243 | QFile f(destFile); | 1253 | QFile f(destFile); |
1244 | if( f.exists()) | 1254 | if( f.exists()) |
1245 | f.remove(); | 1255 | f.remove(); |
1246 | if(!copyFile(destFile, curFile) ) { | 1256 | if(!copyFile(destFile, curFile) ) { |
1247 | QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); | 1257 | QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile)); |
1248 | return; | 1258 | return; |
1249 | } | 1259 | } |
1250 | QFile::remove(curFile); | 1260 | QFile::remove(curFile); |
1251 | TabWidget->setCurrentPage(0); | 1261 | TabWidget->setCurrentPage(0); |
1252 | } | 1262 | } |
1253 | } | 1263 | } |
1254 | populateRemoteView(); | 1264 | populateRemoteView(); |
1255 | populateLocalView(); | 1265 | populateLocalView(); |
1256 | } | 1266 | } |
1257 | 1267 | ||
1258 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) | 1268 | bool AdvancedFm::copyFile( const QString & dest, const QString & src ) |
1259 | { | 1269 | { |
1260 | char bf[ 50000 ]; | 1270 | char bf[ 50000 ]; |
1261 | int bytesRead; | 1271 | int bytesRead; |
1262 | bool success = TRUE; | 1272 | bool success = TRUE; |
1263 | struct stat status; | 1273 | struct stat status; |
1264 | 1274 | ||
1265 | QFile s( src ); | 1275 | QFile s( src ); |
1266 | QFile d( dest ); | 1276 | QFile d( dest ); |
1267 | 1277 | ||
1268 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { | 1278 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { |
1269 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { | 1279 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { |
1270 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 1280 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
1271 | success = FALSE; | 1281 | success = FALSE; |
1272 | break; | 1282 | break; |
1273 | } | 1283 | } |
1274 | } | 1284 | } |
1275 | if( success && (bytesRead > 0) ){ | 1285 | if( success && (bytesRead > 0) ){ |
1276 | d.writeBlock( bf, bytesRead ); | 1286 | d.writeBlock( bf, bytesRead ); |
1277 | } | 1287 | } |
1278 | } else { | 1288 | } else { |
1279 | success = FALSE; | 1289 | success = FALSE; |
1280 | } | 1290 | } |
1281 | 1291 | ||
1282 | // Set file permissions | 1292 | // Set file permissions |
1283 | if( stat( (const char *) src, &status ) == 0 ){ | 1293 | if( stat( (const char *) src, &status ) == 0 ){ |
1284 | chmod( (const char *) dest, status.st_mode ); | 1294 | chmod( (const char *) dest, status.st_mode ); |
1285 | } | 1295 | } |
1286 | 1296 | ||
1287 | return success; | 1297 | return success; |
1288 | } | 1298 | } |
1289 | 1299 | ||
1290 | void AdvancedFm::runCommand() { | 1300 | void AdvancedFm::runCommand() { |
1291 | QString curFile; | 1301 | QString curFile; |
1292 | if (TabWidget->currentPageIndex() == 0) { | 1302 | if (TabWidget->currentPageIndex() == 0) { |
1293 | if( Local_View->currentItem()) | 1303 | if( Local_View->currentItem()) |
1294 | curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); | 1304 | curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); |
1295 | } else { | 1305 | } else { |
1296 | if(Remote_View->currentItem()) | 1306 | if(Remote_View->currentItem()) |
1297 | curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); | 1307 | curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); |
1298 | } | 1308 | } |
1299 | 1309 | ||
1300 | InputDialog *fileDlg; | 1310 | InputDialog *fileDlg; |
1301 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 1311 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
1302 | fileDlg->setInputText(curFile); | 1312 | fileDlg->setInputText(curFile); |
1303 | fileDlg->exec(); | 1313 | fileDlg->exec(); |
1304 | QString command; | 1314 | QString command; |
1305 | if( fileDlg->result() == 1 ) { | 1315 | if( fileDlg->result() == 1 ) { |
1306 | command = fileDlg->LineEdit1->text(); | 1316 | command = fileDlg->LineEdit1->text(); |
1307 | 1317 | ||
1308 | int err=0; | 1318 | int err=0; |
1309 | Output *outDlg; | 1319 | Output *outDlg; |
1310 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | 1320 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
1311 | outDlg->showMaximized(); | 1321 | outDlg->showMaximized(); |
1312 | outDlg->show(); | 1322 | outDlg->show(); |
1313 | qApp->processEvents(); | 1323 | qApp->processEvents(); |
1314 | FILE *fp; | 1324 | FILE *fp; |
1315 | char line[130]; | 1325 | char line[130]; |
1316 | sleep(1); | 1326 | sleep(1); |
1317 | // if(command.find("2>",0,TRUE) != -1) | 1327 | // if(command.find("2>",0,TRUE) != -1) |
1318 | command +=" 2>&1"; | 1328 | command +=" 2>&1"; |
1319 | fp = popen( (const char *) command, "r"); | 1329 | fp = popen( (const char *) command, "r"); |
1320 | if ( !fp ) { | 1330 | if ( !fp ) { |
1321 | qDebug("Could not execute '" + command + "'! err=%d", fp); | 1331 | qDebug("Could not execute '" + command + "'! err=%d", fp); |
1322 | QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); | 1332 | QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") ); |
1323 | pclose(fp); | 1333 | pclose(fp); |
1324 | return; | 1334 | return; |
1325 | } else { | 1335 | } else { |
1326 | while ( fgets( line, sizeof line, fp)) { | 1336 | while ( fgets( line, sizeof line, fp)) { |
1327 | QString lineStr = line; | 1337 | QString lineStr = line; |
1328 | lineStr=lineStr.left(lineStr.length()-1); | 1338 | lineStr=lineStr.left(lineStr.length()-1); |
1329 | outDlg->OutputEdit->append(lineStr); | 1339 | outDlg->OutputEdit->append(lineStr); |
1330 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 1340 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
1331 | } | 1341 | } |
1332 | } | 1342 | } |
1333 | } | 1343 | } |
1334 | } | 1344 | } |
1335 | 1345 | ||
1336 | void AdvancedFm::runCommandStd() { | 1346 | void AdvancedFm::runCommandStd() { |
1337 | QString curFile; | 1347 | QString curFile; |
1338 | if (TabWidget->currentPageIndex() == 0) { | 1348 | if (TabWidget->currentPageIndex() == 0) { |
1339 | if( Local_View->currentItem()) | 1349 | if( Local_View->currentItem()) |
1340 | curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); | 1350 | curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0); |
1341 | } else { | 1351 | } else { |
1342 | if(Remote_View->currentItem()) | 1352 | if(Remote_View->currentItem()) |
1343 | curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); | 1353 | curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0); |
1344 | } | 1354 | } |
1345 | 1355 | ||
1346 | InputDialog *fileDlg; | 1356 | InputDialog *fileDlg; |
1347 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 1357 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
1348 | fileDlg->setInputText(curFile); | 1358 | fileDlg->setInputText(curFile); |
1349 | fileDlg->exec(); | 1359 | fileDlg->exec(); |
1350 | QString command; | 1360 | QString command; |
1351 | if( fileDlg->result() == 1 ) { | 1361 | if( fileDlg->result() == 1 ) { |
1352 | qApp->processEvents(); | 1362 | qApp->processEvents(); |
1353 | command = fileDlg->LineEdit1->text() + " &"; | 1363 | command = fileDlg->LineEdit1->text() + " &"; |
1354 | system(command.latin1()); | 1364 | system(command.latin1()); |
1355 | } | 1365 | } |
1356 | } | 1366 | } |
1357 | 1367 | ||
1358 | void AdvancedFm::fileStatus() { | 1368 | void AdvancedFm::fileStatus() { |
1359 | QString curFile; | 1369 | QString curFile; |
1360 | if (TabWidget->currentPageIndex() == 0) { | 1370 | if (TabWidget->currentPageIndex() == 0) { |
1361 | curFile = Local_View->currentItem()->text(0); | 1371 | curFile = Local_View->currentItem()->text(0); |
1362 | } else { | 1372 | } else { |