summaryrefslogtreecommitdiff
path: root/noncore/net/opieftp/opieftp.cpp
authorllornkcor <llornkcor>2002-03-28 02:18:16 (UTC)
committer llornkcor <llornkcor>2002-03-28 02:18:16 (UTC)
commita2cd4f6515e590ef2e818929843e2923b75beef5 (patch) (unidiff)
tree918bcd4c46acd2c63ea7fa7ad40c212e1002e457 /noncore/net/opieftp/opieftp.cpp
parentd360439051f476cd847c4d8cec27a52addcd72a2 (diff)
downloadopie-a2cd4f6515e590ef2e818929843e2923b75beef5.zip
opie-a2cd4f6515e590ef2e818929843e2923b75beef5.tar.gz
opie-a2cd4f6515e590ef2e818929843e2923b75beef5.tar.bz2
wishy-washy on single vs double click
Diffstat (limited to 'noncore/net/opieftp/opieftp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 907a812..efcaf84 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -116,74 +116,76 @@ OpieFtp::OpieFtp( )
116 TabWidget = new QTabWidget( this, "TabWidget" ); 116 TabWidget = new QTabWidget( this, "TabWidget" );
117 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 ); 117 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 );
118 118
119 TabWidget->setTabShape(QTabWidget::Triangular); 119 TabWidget->setTabShape(QTabWidget::Triangular);
120 120
121 tab = new QWidget( TabWidget, "tab" ); 121 tab = new QWidget( TabWidget, "tab" );
122 tabLayout = new QGridLayout( tab ); 122 tabLayout = new QGridLayout( tab );
123 tabLayout->setSpacing( 2); 123 tabLayout->setSpacing( 2);
124 tabLayout->setMargin( 2); 124 tabLayout->setMargin( 2);
125 125
126 Local_View = new QListView( tab, "Local_View" ); 126 Local_View = new QListView( tab, "Local_View" );
127// Local_View->setResizePolicy( QListView::AutoOneFit ); 127// Local_View->setResizePolicy( QListView::AutoOneFit );
128 Local_View->addColumn( tr("File"),150); 128 Local_View->addColumn( tr("File"),150);
129 Local_View->addColumn( tr("Size"),-1); 129 Local_View->addColumn( tr("Size"),-1);
130 Local_View->setColumnAlignment(1,QListView::AlignRight); 130 Local_View->setColumnAlignment(1,QListView::AlignRight);
131 Local_View->addColumn( tr("Date"),-1); 131 Local_View->addColumn( tr("Date"),-1);
132 Local_View->setColumnAlignment(2,QListView::AlignRight); 132 Local_View->setColumnAlignment(2,QListView::AlignRight);
133 Local_View->setAllColumnsShowFocus(TRUE); 133 Local_View->setAllColumnsShowFocus(TRUE);
134 Local_View->setMultiSelection( TRUE ); 134 Local_View->setMultiSelection( TRUE );
135 135
136 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 136 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
137 137
138 tabLayout->addWidget( Local_View, 0, 0 ); 138 tabLayout->addWidget( Local_View, 0, 0 );
139 139
140 connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), 140 connect( Local_View, SIGNAL( clicked( QListViewItem*)),
141 this,SLOT( localListClicked(QListViewItem *)) ); 141 this,SLOT( localListClicked(QListViewItem *)) );
142// connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)),
143// this,SLOT( localListClicked(QListViewItem *)) );
142 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 144 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
143 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 145 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
144 146
145 TabWidget->insertTab( tab, tr( "Local" ) ); 147 TabWidget->insertTab( tab, tr( "Local" ) );
146 148
147 tab_2 = new QWidget( TabWidget, "tab_2" ); 149 tab_2 = new QWidget( TabWidget, "tab_2" );
148 tabLayout_2 = new QGridLayout( tab_2 ); 150 tabLayout_2 = new QGridLayout( tab_2 );
149 tabLayout_2->setSpacing( 2); 151 tabLayout_2->setSpacing( 2);
150 tabLayout_2->setMargin( 2); 152 tabLayout_2->setMargin( 2);
151 153
152 Remote_View = new QListView( tab_2, "Remote_View" ); 154 Remote_View = new QListView( tab_2, "Remote_View" );
153 Remote_View->addColumn( tr("File"),150); 155 Remote_View->addColumn( tr("File"),150);
154 Remote_View->addColumn( tr("Size"),-1); 156 Remote_View->addColumn( tr("Size"),-1);
155 Remote_View->setColumnAlignment(1,QListView::AlignRight); 157 Remote_View->setColumnAlignment(1,QListView::AlignRight);
156 Remote_View->addColumn( tr("Date"),-1); 158 Remote_View->addColumn( tr("Date"),-1);
157 Remote_View->setColumnAlignment(2,QListView::AlignRight); 159 Remote_View->setColumnAlignment(2,QListView::AlignRight);
158 Remote_View->addColumn( tr("Dir"),-1); 160 Remote_View->addColumn( tr("Dir"),-1);
159 Remote_View->setColumnAlignment(4,QListView::AlignRight); 161 Remote_View->setColumnAlignment(4,QListView::AlignRight);
160 Remote_View->setAllColumnsShowFocus(TRUE); 162 Remote_View->setAllColumnsShowFocus(TRUE);
161 Remote_View->setMultiSelection( TRUE ); 163 Remote_View->setMultiSelection( TRUE );
162 164
163 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 165 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
164 166
165 connect( Remote_View, SIGNAL( doubleClicked( QListViewItem*)), 167 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
166 this,SLOT( remoteListClicked(QListViewItem *)) ); 168 this,SLOT( remoteListClicked(QListViewItem *)) );
167 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 169 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
168 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); 170 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) );
169 171
170 tabLayout_2->addWidget( Remote_View, 0, 0 ); 172 tabLayout_2->addWidget( Remote_View, 0, 0 );
171 173
172 TabWidget->insertTab( tab_2, tr( "Remote" ) ); 174 TabWidget->insertTab( tab_2, tr( "Remote" ) );
173 175
174 tab_3 = new QWidget( TabWidget, "tab_3" ); 176 tab_3 = new QWidget( TabWidget, "tab_3" );
175 tabLayout_3 = new QGridLayout( tab_3 ); 177 tabLayout_3 = new QGridLayout( tab_3 );
176 tabLayout_3->setSpacing( 2); 178 tabLayout_3->setSpacing( 2);
177 tabLayout_3->setMargin( 2); 179 tabLayout_3->setMargin( 2);
178 180
179 TextLabel1 = new QLabel( tab_3, "TextLabel1" ); 181 TextLabel1 = new QLabel( tab_3, "TextLabel1" );
180 TextLabel1->setText( tr( "Username" ) ); 182 TextLabel1->setText( tr( "Username" ) );
181 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); 183 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 );
182 184
183 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); 185 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" );
184 UsernameComboBox->setEditable(TRUE); 186 UsernameComboBox->setEditable(TRUE);
185 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); 187 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 );
186 188
187 TextLabel2 = new QLabel( tab_3, "TextLabel2" ); 189 TextLabel2 = new QLabel( tab_3, "TextLabel2" );
188 TextLabel2->setText( tr( "Password" ) ); 190 TextLabel2->setText( tr( "Password" ) );
189 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); 191 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 );
@@ -419,49 +421,49 @@ void OpieFtp::localUpload()
419 QString localFile = currentDir.canonicalPath()+"/"+strItem; 421 QString localFile = currentDir.canonicalPath()+"/"+strItem;
420 QString remoteFile= currentRemoteDir+strItem; 422 QString remoteFile= currentRemoteDir+strItem;
421 QFileInfo fi(localFile); 423 QFileInfo fi(localFile);
422 if( !fi.isDir()) { 424 if( !fi.isDir()) {
423 fsz=fi.size(); 425 fsz=fi.size();
424 ProgressBar->setTotalSteps(fsz); 426 ProgressBar->setTotalSteps(fsz);
425 427
426 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 428 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
427 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 429 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
428 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 430 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
429 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 431 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
430 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); 432 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
431 433
432 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 434 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
433 QString msg; 435 QString msg;
434 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); 436 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn));
435 msg.replace(QRegExp(":"),"\n"); 437 msg.replace(QRegExp(":"),"\n");
436 QMessageBox::message(tr("Note"),msg); 438 QMessageBox::message(tr("Note"),msg);
437 } 439 }
438 } else { 440 } else {
439 QMessageBox::message(tr("Note"),tr("Cannot upload directories")); 441 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
440 } 442 }
441 ProgressBar->reset(); 443 ProgressBar->reset();
442 nullifyCallBack(); 444 nullifyCallBack();
443 it.current()->setSelected(FALSE); 445 it.current()->setSelected(FALSE);
444 } //end currentSelected 446 } //end currentSelected
445 } 447 }
446 TabWidget->setCurrentPage(1); 448 TabWidget->setCurrentPage(1);
447 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 449 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
448 QCopEnvelope ( "QPE/System", "notBusy()" ); 450 QCopEnvelope ( "QPE/System", "notBusy()" );
449} 451}
450 452
451void OpieFtp::nullifyCallBack() 453void OpieFtp::nullifyCallBack()
452{ 454{
453 FtpOptions(FTPLIB_CALLBACK, NULL, conn); 455 FtpOptions(FTPLIB_CALLBACK, NULL, conn);
454 FtpOptions(FTPLIB_IDLETIME, NULL, conn); 456 FtpOptions(FTPLIB_IDLETIME, NULL, conn);
455 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); 457 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn);
456 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); 458 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn);
457} 459}
458 460
459void OpieFtp::remoteDownload() 461void OpieFtp::remoteDownload()
460{ 462{
461// qApp->processEvents(); 463// qApp->processEvents();
462 int fsz; 464 int fsz;
463 QCopEnvelope ( "QPE/System", "busy()" ); 465 QCopEnvelope ( "QPE/System", "busy()" );
464 466
465 QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); 467 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
466 QListViewItemIterator it( Remote_View ); 468 QListViewItemIterator it( Remote_View );
467 for ( ; it.current(); ++it ) { 469 for ( ; it.current(); ++it ) {
@@ -473,49 +475,49 @@ void OpieFtp::remoteDownload()
473 localFile += "/"; 475 localFile += "/";
474 localFile += strItem; 476 localFile += strItem;
475// QString localFile = currentDir.canonicalPath()+"/"+strItem; 477// QString localFile = currentDir.canonicalPath()+"/"+strItem;
476 QString remoteFile= currentRemoteDir+strItem; 478 QString remoteFile= currentRemoteDir+strItem;
477 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) 479 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn))
478 fsz = 0; 480 fsz = 0;
479 QString temp; 481 QString temp;
480 temp.sprintf( remoteFile+" "+" %dkb", fsz); 482 temp.sprintf( remoteFile+" "+" %dkb", fsz);
481 483
482 ProgressBar->setTotalSteps(fsz); 484 ProgressBar->setTotalSteps(fsz);
483 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 485 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
484 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 486 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
485 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 487 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
486 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 488 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
487 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); 489 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
488 490
489 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 491 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
490 QString msg; 492 QString msg;
491 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); 493 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn));
492 msg.replace(QRegExp(":"),"\n"); 494 msg.replace(QRegExp(":"),"\n");
493 QMessageBox::message(tr("Note"),msg); 495 QMessageBox::message(tr("Note"),msg);
494 } 496 }
495 ProgressBar->reset(); 497 ProgressBar->reset();
496 nullifyCallBack(); 498 nullifyCallBack();
497 it.current()->setSelected(FALSE); 499 it.current()->setSelected(FALSE);
498 } 500 }
499 } 501 }
500 TabWidget->setCurrentPage(0); 502 TabWidget->setCurrentPage(0);
501 populateLocalView(); 503 populateLocalView();
502 QCopEnvelope ( "QPE/System", "notBusy()" ); 504 QCopEnvelope ( "QPE/System", "notBusy()" );
503} 505}
504 506
505bool OpieFtp::remoteDirList(const QString &dir) 507bool OpieFtp::remoteDirList(const QString &dir)
506{ 508{
507 QString tmp = QDir::homeDirPath(); 509 QString tmp = QDir::homeDirPath();
508 if(tmp.right(1) != "/") 510 if(tmp.right(1) != "/")
509 tmp+="/._temp"; 511 tmp+="/._temp";
510 else 512 else
511 tmp+="._temp"; 513 tmp+="._temp";
512// qDebug("Listing remote dir "+tmp); 514// qDebug("Listing remote dir "+tmp);
513 QCopEnvelope ( "QPE/System", "busy()" ); 515 QCopEnvelope ( "QPE/System", "busy()" );
514 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { 516 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
515 QString msg; 517 QString msg;
516 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); 518 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) );
517 msg.replace(QRegExp(":"),"\n"); 519 msg.replace(QRegExp(":"),"\n");
518 QMessageBox::message(tr("Note"),msg); 520 QMessageBox::message(tr("Note"),msg);
519 return false; 521 return false;
520 } 522 }
521 populateRemoteView() ; 523 populateRemoteView() ;
@@ -728,49 +730,49 @@ void OpieFtp::localListClicked(QListViewItem *selectedItem)
728 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 730 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
729 // is symlink 731 // is symlink
730 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 732 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
731 if(QDir(strItem2).exists() ) { 733 if(QDir(strItem2).exists() ) {
732 currentDir.cd(strItem2, TRUE); 734 currentDir.cd(strItem2, TRUE);
733 populateLocalView(); 735 populateLocalView();
734 } 736 }
735 } else { // not a symlink 737 } else { // not a symlink
736 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 738 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
737 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 739 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
738 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 740 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
739 currentDir.cd(strItem,FALSE); 741 currentDir.cd(strItem,FALSE);
740 populateLocalView(); 742 populateLocalView();
741 } else { 743 } else {
742 currentDir.cdUp(); 744 currentDir.cdUp();
743 populateLocalView(); 745 populateLocalView();
744 } 746 }
745 if(QDir(strItem).exists()){ 747 if(QDir(strItem).exists()){
746 currentDir.cd(strItem, TRUE); 748 currentDir.cd(strItem, TRUE);
747 populateLocalView(); 749 populateLocalView();
748 } 750 }
749 } else { 751 } else {
750 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 752 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
751 if( QFile::exists(strItem ) ) { 753 if( QFile::exists(strItem ) ) {
752 qDebug("upload "+strItem); 754 // qDebug("upload "+strItem);
753 } 755 }
754 } //end not symlink 756 } //end not symlink
755 chdir(strItem.latin1()); 757 chdir(strItem.latin1());
756 } 758 }
757 } 759 }
758} 760}
759 761
760void OpieFtp::doLocalCd() 762void OpieFtp::doLocalCd()
761{ 763{
762 localListClicked( Local_View->currentItem()); 764 localListClicked( Local_View->currentItem());
763} 765}
764 766
765void OpieFtp:: doRemoteCd() 767void OpieFtp:: doRemoteCd()
766{ 768{
767 remoteListClicked( Remote_View->currentItem()); 769 remoteListClicked( Remote_View->currentItem());
768 770
769} 771}
770 772
771void OpieFtp::showHidden() 773void OpieFtp::showHidden()
772{ 774{
773 if (!b) { 775 if (!b) {
774 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 776 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
775 localMenu->setItemChecked(localMenu->idAt(0),TRUE); 777 localMenu->setItemChecked(localMenu->idAt(0),TRUE);
776// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 778// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);