-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 118275b..a3b29a1 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <unistd.h> | 45 | #include <unistd.h> |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | 47 | ||
48 | |||
48 | QProgressBar *ProgressBar; | 49 | QProgressBar *ProgressBar; |
49 | static netbuf *conn=NULL; | 50 | static netbuf *conn=NULL; |
50 | 51 | ||
@@ -94,7 +95,8 @@ OpieFtp::OpieFtp( ) | |||
94 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 95 | localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
95 | localMenu->insertSeparator(); | 96 | localMenu->insertSeparator(); |
96 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 97 | localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
97 | 98 | localMenu->setCheckable(TRUE); | |
99 | |||
98 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 100 | remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
99 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 101 | remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
100 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 102 | remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
@@ -201,8 +203,8 @@ OpieFtp::OpieFtp( ) | |||
201 | 203 | ||
202 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); | 204 | remotePath = new QLineEdit( "/", tab_3, "remotePath" ); |
203 | remotePath->setText( currentRemoteDir = "/"); | 205 | remotePath->setText( currentRemoteDir = "/"); |
204 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); | ||
205 | // remotePath->setText( currentRemoteDir = "/home/llornkcor/"); | 206 | // remotePath->setText( currentRemoteDir = "/home/llornkcor/"); |
207 | tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); | ||
206 | 208 | ||
207 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); | 209 | TextLabel4 = new QLabel( tab_3, "TextLabel4" ); |
208 | TextLabel4->setText( tr( "Port" ) ); | 210 | TextLabel4->setText( tr( "Port" ) ); |
@@ -236,6 +238,7 @@ OpieFtp::OpieFtp( ) | |||
236 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); | 238 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); |
237 | 239 | ||
238 | filterStr="*"; | 240 | filterStr="*"; |
241 | b=FALSE; | ||
239 | populateLocalView(); | 242 | populateLocalView(); |
240 | } | 243 | } |
241 | 244 | ||
@@ -329,7 +332,10 @@ void OpieFtp::remoteDownload() | |||
329 | QCopEnvelope ( "QPE/System", "busy()" ); | 332 | QCopEnvelope ( "QPE/System", "busy()" ); |
330 | qApp->processEvents(); | 333 | qApp->processEvents(); |
331 | QString strItem = Remote_View->currentItem()->text(0); | 334 | QString strItem = Remote_View->currentItem()->text(0); |
332 | QString localFile = currentDir.canonicalPath()+"/"+strItem; | 335 | // strItem=strItem.right(strItem.length()-1); |
336 | |||
337 | QString localFile = currentDir.canonicalPath()+strItem; | ||
338 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; | ||
333 | QString remoteFile= currentRemoteDir+strItem; | 339 | QString remoteFile= currentRemoteDir+strItem; |
334 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) | 340 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) |
335 | fsz = 0; | 341 | fsz = 0; |
@@ -456,6 +462,7 @@ void OpieFtp::populateLocalView() | |||
456 | currentDir.setMatchAllDirs(TRUE); | 462 | currentDir.setMatchAllDirs(TRUE); |
457 | currentDir.setNameFilter(filterStr); | 463 | currentDir.setNameFilter(filterStr); |
458 | QString fileL, fileS, fileDate; | 464 | QString fileL, fileS, fileDate; |
465 | bool isDir=FALSE; | ||
459 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 466 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
460 | QFileInfoListIterator it(*list); | 467 | QFileInfoListIterator it(*list); |
461 | QFileInfo *fi; | 468 | QFileInfo *fi; |
@@ -474,10 +481,18 @@ void OpieFtp::populateLocalView() | |||
474 | fileDate= fi->lastModified().toString(); | 481 | fileDate= fi->lastModified().toString(); |
475 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 482 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
476 | fileL+="/"; | 483 | fileL+="/"; |
484 | isDir=TRUE; | ||
477 | // qDebug( fileL); | 485 | // qDebug( fileL); |
478 | } | 486 | } |
479 | } | 487 | } |
480 | item= new QListViewItem( Local_View,fileL,fileS, fileDate); | 488 | if(fileL !="./") { |
489 | item = new QListViewItem( Local_View,fileL,fileS, fileDate); | ||
490 | if(isDir) | ||
491 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | ||
492 | else | ||
493 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | ||
494 | } | ||
495 | isDir=FALSE; | ||
481 | ++it; | 496 | ++it; |
482 | } | 497 | } |
483 | Local_View->setSorting( 3,FALSE); | 498 | Local_View->setSorting( 3,FALSE); |
@@ -495,28 +510,44 @@ bool OpieFtp::populateRemoteView( ) | |||
495 | QFile file( sfile); | 510 | QFile file( sfile); |
496 | Remote_View->clear(); | 511 | Remote_View->clear(); |
497 | QString s, File_Name; | 512 | QString s, File_Name; |
513 | QListViewItem *itemDir=NULL, *itemFile=NULL; | ||
498 | QString fileL, fileS, fileDate; | 514 | QString fileL, fileS, fileDate; |
499 | new QListViewItem( Remote_View, "../"); | ||
500 | if ( file.open(IO_ReadOnly)) { | 515 | if ( file.open(IO_ReadOnly)) { |
501 | QTextStream t( &file ); // use a text stream | 516 | QTextStream t( &file ); // use a text stream |
502 | while ( !t.eof()) { | 517 | while ( !t.eof()) { |
503 | s = t.readLine(); | 518 | s = t.readLine(); |
504 | fileL = s.right(s.length()-55); | 519 | fileL = s.right(s.length()-55); |
505 | fileL = fileL.stripWhiteSpace(); | 520 | fileL = fileL.stripWhiteSpace(); |
506 | if(s.left(1) == "d") | 521 | if(s.left(1) == "d") |
507 | fileL = fileL+"/"; | 522 | fileL = fileL+"/"; |
523 | // fileL = "/"+fileL+"/"; | ||
508 | fileS = s.mid( 30, 42-30); | 524 | fileS = s.mid( 30, 42-30); |
509 | fileS = fileS.stripWhiteSpace(); | 525 | fileS = fileS.stripWhiteSpace(); |
510 | fileDate = s.mid( 42, 55-42); | 526 | fileDate = s.mid( 42, 55-42); |
511 | fileDate = fileDate.stripWhiteSpace(); | 527 | fileDate = fileDate.stripWhiteSpace(); |
512 | if(fileL.find("total",0,TRUE) == -1) | 528 | if(fileL.find("total",0,TRUE) == -1) { |
513 | new QListViewItem( Remote_View, fileL, fileS, fileDate); | 529 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate); |
530 | if(s.left(1) == "d") { | ||
531 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | ||
532 | if(itemDir) | ||
533 | item->moveItem(itemDir); | ||
534 | itemDir=item; | ||
535 | } else { | ||
536 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | ||
537 | if(itemFile) | ||
538 | item->moveItem(itemFile); | ||
539 | itemFile=item; | ||
540 | } | ||
541 | } | ||
514 | } | 542 | } |
543 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); | ||
544 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); | ||
515 | file.close(); | 545 | file.close(); |
516 | if( file.exists()) | 546 | if( file.exists()) |
517 | file. remove(); | 547 | file. remove(); |
518 | } else | 548 | } else |
519 | qDebug("temp file not opened successfullly "+sfile); | 549 | qDebug("temp file not opened successfullly "+sfile); |
550 | Remote_View->setSorting( 4,TRUE); | ||
520 | 551 | ||
521 | return true; | 552 | return true; |
522 | } | 553 | } |
@@ -626,11 +657,13 @@ void OpieFtp::showHidden() | |||
626 | { | 657 | { |
627 | if (!b) { | 658 | if (!b) { |
628 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 659 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
660 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); | ||
629 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 661 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
630 | b=TRUE; | 662 | b=TRUE; |
631 | 663 | ||
632 | } else { | 664 | } else { |
633 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 665 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
666 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); | ||
634 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 667 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
635 | b=FALSE; | 668 | b=FALSE; |
636 | } | 669 | } |
@@ -686,6 +719,12 @@ void OpieFtp::showLocalMenu(QListViewItem * item) | |||
686 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 719 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
687 | m.insertSeparator(); | 720 | m.insertSeparator(); |
688 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 721 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
722 | m.setCheckable(TRUE); | ||
723 | if (b) | ||
724 | m.setItemChecked(m.idAt(0),TRUE); | ||
725 | else | ||
726 | m.setItemChecked(m.idAt(0),FALSE); | ||
727 | |||
689 | m.exec( QCursor::pos() ); | 728 | m.exec( QCursor::pos() ); |
690 | } | 729 | } |
691 | 730 | ||
@@ -837,7 +876,7 @@ void OpieFtp::localRename() | |||
837 | void OpieFtp::currentPathEditChanged() | 876 | void OpieFtp::currentPathEditChanged() |
838 | { | 877 | { |
839 | QString oldRemoteCurrentDir = currentRemoteDir; | 878 | QString oldRemoteCurrentDir = currentRemoteDir; |
840 | qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); | 879 | // qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); |
841 | if (TabWidget->currentPageIndex() == 0) { | 880 | if (TabWidget->currentPageIndex() == 0) { |
842 | if(QDir( currentPathEdit->text()).exists()) { | 881 | if(QDir( currentPathEdit->text()).exists()) { |
843 | currentDir.setPath( currentPathEdit->text() ); | 882 | currentDir.setPath( currentPathEdit->text() ); |