summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-03-17 04:00:20 (UTC)
committer llornkcor <llornkcor>2002-03-17 04:00:20 (UTC)
commit578725ca25862c0b06b1991a7bc8ffc2ad8ae13e (patch) (unidiff)
tree2217cff7ce86563ea688fc8138835230ea95c5c0
parent624a283591094628425c94fedfdd62941ad7c853 (diff)
downloadopie-578725ca25862c0b06b1991a7bc8ffc2ad8ae13e.zip
opie-578725ca25862c0b06b1991a7bc8ffc2ad8ae13e.tar.gz
opie-578725ca25862c0b06b1991a7bc8ffc2ad8ae13e.tar.bz2
added icons, and fixed remote dir list sorting
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp57
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
@@ -42,12 +42,13 @@
42#include <qlineedit.h> 42#include <qlineedit.h>
43#include <qregexp.h> 43#include <qregexp.h>
44 44
45#include <unistd.h> 45#include <unistd.h>
46#include <stdlib.h> 46#include <stdlib.h>
47 47
48
48QProgressBar *ProgressBar; 49QProgressBar *ProgressBar;
49static netbuf *conn=NULL; 50static netbuf *conn=NULL;
50 51
51static int log_progress(netbuf *ctl, int xfered, void *arg) 52static int log_progress(netbuf *ctl, int xfered, void *arg)
52{ 53{
53 int fsz = *(int *)arg; 54 int fsz = *(int *)arg;
@@ -91,13 +92,14 @@ OpieFtp::OpieFtp( )
91 localMenu->insertSeparator(); 92 localMenu->insertSeparator();
92 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 93 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
93 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 94 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
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() ));
101 remoteMenu->insertSeparator(); 103 remoteMenu->insertSeparator();
102 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 104 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
103 105
@@ -198,14 +200,14 @@ OpieFtp::OpieFtp( )
198 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); 200 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
199 TextLabel5->setText( tr( "Remote path" ) ); 201 TextLabel5->setText( tr( "Remote path" ) );
200 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); 202 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 );
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" ) );
209 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); 211 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 );
210 212
211 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); 213 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
@@ -233,12 +235,13 @@ OpieFtp::OpieFtp( )
233 connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); 235 connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged()));
234 236
235 ProgressBar = new QProgressBar( this, "ProgressBar" ); 237 ProgressBar = new QProgressBar( this, "ProgressBar" );
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
242OpieFtp::~OpieFtp() 245OpieFtp::~OpieFtp()
243{ 246{
244} 247}
@@ -326,13 +329,16 @@ void OpieFtp::nullifyCallBack()
326void OpieFtp::remoteDownload() 329void OpieFtp::remoteDownload()
327{ 330{
328 int fsz; 331 int fsz;
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;
336 QString temp; 342 QString temp;
337 temp.sprintf( remoteFile+" "+" %dkb", fsz); 343 temp.sprintf( remoteFile+" "+" %dkb", fsz);
338 344
@@ -453,12 +459,13 @@ void OpieFtp::populateLocalView()
453{ 459{
454 Local_View->clear(); 460 Local_View->clear();
455 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 461 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
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;
462 while ( (fi=it.current()) ) { 469 while ( (fi=it.current()) ) {
463 if (fi->isSymLink() ){ 470 if (fi->isSymLink() ){
464 QString symLink=fi->readLink(); 471 QString symLink=fi->readLink();
@@ -471,16 +478,24 @@ void OpieFtp::populateLocalView()
471// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 478// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
472 fileS.sprintf( "%10li", fi->size() ); 479 fileS.sprintf( "%10li", fi->size() );
473 fileL.sprintf( "%s",fi->fileName().data() ); 480 fileL.sprintf( "%s",fi->fileName().data() );
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);
484 currentPathEdit->setText( currentDir.canonicalPath() ); 499 currentPathEdit->setText( currentDir.canonicalPath() );
485} 500}
486 501
@@ -492,34 +507,50 @@ bool OpieFtp::populateRemoteView( )
492 sfile+="/._temp"; 507 sfile+="/._temp";
493 else 508 else
494 sfile+="._temp"; 509 sfile+="._temp";
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}
523 554
524void OpieFtp::remoteListClicked(QListViewItem *selectedItem) 555void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
525{ 556{
@@ -623,17 +654,19 @@ void OpieFtp:: doRemoteCd()
623} 654}
624 655
625void OpieFtp::showHidden() 656void 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 }
637 populateLocalView(); 670 populateLocalView();
638} 671}
639 672
@@ -683,12 +716,18 @@ void OpieFtp::showLocalMenu(QListViewItem * item)
683 else 716 else
684 m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 717 m.insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
685 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 718 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
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
692void OpieFtp::localMakDir() 731void OpieFtp::localMakDir()
693{ 732{
694 InputDialog *fileDlg; 733 InputDialog *fileDlg;
@@ -834,13 +873,13 @@ void OpieFtp::localRename()
834 populateLocalView(); 873 populateLocalView();
835} 874}
836 875
837void OpieFtp::currentPathEditChanged() 876void 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() );
844 populateLocalView(); 883 populateLocalView();
845 } else { 884 } else {
846 QMessageBox::message("Note","That directory does not exist"); 885 QMessageBox::message("Note","That directory does not exist");