summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-03-30 02:00:10 (UTC)
committer llornkcor <llornkcor>2002-03-30 02:00:10 (UTC)
commit4fc58d156db9197bc8299f040d4337ea85b9f0d2 (patch) (unidiff)
tree7baa553895a5ccdb35c8309b8a5c43a8f05a24ec
parente49717bf2fa15791c2437a3ac69058ac909f0c6b (diff)
downloadopie-4fc58d156db9197bc8299f040d4337ea85b9f0d2.zip
opie-4fc58d156db9197bc8299f040d4337ea85b9f0d2.tar.gz
opie-4fc58d156db9197bc8299f040d4337ea85b9f0d2.tar.bz2
fixed a workaround for an apparent bug in libqte when the listview is multi, and you try to select one item and popup the menu.., it needs extended mode selection to work
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp89
1 files changed, 43 insertions, 46 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 3e13466..956409f 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -123,25 +123,25 @@ OpieFtp::OpieFtp( )
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 Local_View->setSelectionMode(QlistView::Extended);
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( clicked( 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*)), 142// connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)),
143// this,SLOT( localListClicked(QListViewItem *)) ); 143// this,SLOT( localListClicked(QListViewItem *)) );
144 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 144 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
145 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 145 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
146 146
147 TabWidget->insertTab( tab, tr( "Local" ) ); 147 TabWidget->insertTab( tab, tr( "Local" ) );
@@ -152,24 +152,25 @@ OpieFtp::OpieFtp( )
152 tabLayout_2->setMargin( 2); 152 tabLayout_2->setMargin( 2);
153 153
154 Remote_View = new QListView( tab_2, "Remote_View" ); 154 Remote_View = new QListView( tab_2, "Remote_View" );
155 Remote_View->addColumn( tr("File"),150); 155 Remote_View->addColumn( tr("File"),150);
156 Remote_View->addColumn( tr("Size"),-1); 156 Remote_View->addColumn( tr("Size"),-1);
157 Remote_View->setColumnAlignment(1,QListView::AlignRight); 157 Remote_View->setColumnAlignment(1,QListView::AlignRight);
158 Remote_View->addColumn( tr("Date"),-1); 158 Remote_View->addColumn( tr("Date"),-1);
159 Remote_View->setColumnAlignment(2,QListView::AlignRight); 159 Remote_View->setColumnAlignment(2,QListView::AlignRight);
160 Remote_View->addColumn( tr("Dir"),-1); 160 Remote_View->addColumn( tr("Dir"),-1);
161 Remote_View->setColumnAlignment(4,QListView::AlignRight); 161 Remote_View->setColumnAlignment(4,QListView::AlignRight);
162 Remote_View->setAllColumnsShowFocus(TRUE); 162 Remote_View->setAllColumnsShowFocus(TRUE);
163 Remote_View->setMultiSelection( TRUE ); 163 Remote_View->setMultiSelection( TRUE );
164 Remote_View->setSelectionMode(QlistView::Extended);
164 165
165 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 166 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
166 167
167 connect( Remote_View, SIGNAL( clicked( QListViewItem*)), 168 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
168 this,SLOT( remoteListClicked(QListViewItem *)) ); 169 this,SLOT( remoteListClicked(QListViewItem *)) );
169 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 170 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
170 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); 171 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) );
171 172
172 tabLayout_2->addWidget( Remote_View, 0, 0 ); 173 tabLayout_2->addWidget( Remote_View, 0, 0 );
173 174
174 TabWidget->insertTab( tab_2, tr( "Remote" ) ); 175 TabWidget->insertTab( tab_2, tr( "Remote" ) );
175 176
@@ -276,24 +277,25 @@ OpieFtp::~OpieFtp()
276void OpieFtp::cleanUp() 277void OpieFtp::cleanUp()
277{ 278{
278 if(conn) 279 if(conn)
279 FtpQuit(conn); 280 FtpQuit(conn);
280 QString sfile=QDir::homeDirPath(); 281 QString sfile=QDir::homeDirPath();
281 if(sfile.right(1) != "/") 282 if(sfile.right(1) != "/")
282 sfile+="/._temp"; 283 sfile+="/._temp";
283 else 284 else
284 sfile+="._temp"; 285 sfile+="._temp";
285 QFile file( sfile); 286 QFile file( sfile);
286 if(file.exists()) 287 if(file.exists())
287 file.remove(); 288 file.remove();
289 exit(0);
288} 290}
289 291
290void OpieFtp::tabChanged(QWidget *w) 292void OpieFtp::tabChanged(QWidget *w)
291{ 293{
292 if (TabWidget->currentPageIndex() == 0) { 294 if (TabWidget->currentPageIndex() == 0) {
293 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 295 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
294 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); 296 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE);
295 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 297 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
296 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 298 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
297 } 299 }
298 if (TabWidget->currentPageIndex() == 1) { 300 if (TabWidget->currentPageIndex() == 1) {
299 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 301 currentPathCombo->lineEdit()->setText( currentRemoteDir );
@@ -385,67 +387,66 @@ void OpieFtp::connector()
385 QCopEnvelope ( "QPE/System", "notBusy()" ); 387 QCopEnvelope ( "QPE/System", "notBusy()" );
386} 388}
387 389
388void OpieFtp::disConnector() 390void OpieFtp::disConnector()
389{ 391{
390 if(conn) 392 if(conn)
391 FtpQuit(conn); 393 FtpQuit(conn);
392 setCaption("OpieFtp"); 394 setCaption("OpieFtp");
393 currentRemoteDir="/"; 395 currentRemoteDir="/";
394 Remote_View->clear(); 396 Remote_View->clear();
395 connectServerBtn->setText( tr("Connect")); 397 connectServerBtn->setText( tr("Connect"));
396 connectServerBtn->setOn(FALSE); 398 connectServerBtn->setOn(FALSE);
397
398} 399}
399 400
400void OpieFtp::localUpload() 401void OpieFtp::localUpload()
401{ 402{
402 int fsz; 403 int fsz;
403 QCopEnvelope ( "QPE/System", "busy()" ); 404 QCopEnvelope ( "QPE/System", "busy()" );
404// qApp->processEvents(); 405// qApp->processEvents();
405 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 406 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
406 QListViewItemIterator it( Local_View ); 407 QListViewItemIterator it( Local_View );
407 for ( ; it.current(); ++it ) { 408 for ( ; it.current(); ++it ) {
408 if ( it.current()->isSelected() ) { 409 if ( it.current()->isSelected() ) {
409 QString strItem = it.current()->text(0); 410 QString strItem = it.current()->text(0);
410 QString localFile = currentDir.canonicalPath()+"/"+strItem; 411 QString localFile = currentDir.canonicalPath()+"/"+strItem;
411 QString remoteFile= currentRemoteDir+strItem; 412 QString remoteFile= currentRemoteDir+strItem;
412 QFileInfo fi(localFile); 413 QFileInfo fi(localFile);
413 if( !fi.isDir()) { 414 if( !fi.isDir()) {
414 fsz=fi.size(); 415 fsz=fi.size();
415 ProgressBar->setTotalSteps(fsz); 416 ProgressBar->setTotalSteps(fsz);
416 417
417 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 418 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
418 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 419 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
419 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 420 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
420 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 421 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
421 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); 422 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
422 423
423 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 424 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
424 QString msg; 425 QString msg;
425 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); 426 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn));
426 msg.replace(QRegExp(":"),"\n"); 427 msg.replace(QRegExp(":"),"\n");
427 QMessageBox::message(tr("Note"),msg); 428 QMessageBox::message(tr("Note"),msg);
428 }
429 } else {
430 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
431 } 429 }
432 ProgressBar->reset(); 430 } else {
433 nullifyCallBack(); 431 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
434 it.current()->setSelected(FALSE); 432 }
435 } //end currentSelected 433 ProgressBar->reset();
436 } 434 nullifyCallBack();
437 TabWidget->setCurrentPage(1); 435 it.current()->setSelected(FALSE);
438 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 436 } //end currentSelected
439 QCopEnvelope ( "QPE/System", "notBusy()" ); 437 }
438 TabWidget->setCurrentPage(1);
439 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
440 QCopEnvelope ( "QPE/System", "notBusy()" );
440} 441}
441 442
442void OpieFtp::nullifyCallBack() 443void OpieFtp::nullifyCallBack()
443{ 444{
444 FtpOptions(FTPLIB_CALLBACK, NULL, conn); 445 FtpOptions(FTPLIB_CALLBACK, NULL, conn);
445 FtpOptions(FTPLIB_IDLETIME, NULL, conn); 446 FtpOptions(FTPLIB_IDLETIME, NULL, conn);
446 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); 447 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn);
447 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); 448 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn);
448} 449}
449 450
450void OpieFtp::remoteDownload() 451void OpieFtp::remoteDownload()
451{ 452{
@@ -476,25 +477,25 @@ void OpieFtp::remoteDownload()
476 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 477 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
477 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 478 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
478 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); 479 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
479 480
480 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 481 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
481 QString msg; 482 QString msg;
482 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); 483 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn));
483 msg.replace(QRegExp(":"),"\n"); 484 msg.replace(QRegExp(":"),"\n");
484 QMessageBox::message(tr("Note"),msg); 485 QMessageBox::message(tr("Note"),msg);
485 } 486 }
486 ProgressBar->reset(); 487 ProgressBar->reset();
487 nullifyCallBack(); 488 nullifyCallBack();
488 it.current()->setSelected(FALSE); 489 it.current()->setSelected(FALSE);
489 } 490 }
490 } 491 }
491 TabWidget->setCurrentPage(0); 492 TabWidget->setCurrentPage(0);
492 populateLocalView(); 493 populateLocalView();
493 QCopEnvelope ( "QPE/System", "notBusy()" ); 494 QCopEnvelope ( "QPE/System", "notBusy()" );
494} 495}
495 496
496bool OpieFtp::remoteDirList(const QString &dir) 497bool OpieFtp::remoteDirList(const QString &dir)
497{ 498{
498 QString tmp = QDir::homeDirPath(); 499 QString tmp = QDir::homeDirPath();
499 if(tmp.right(1) != "/") 500 if(tmp.right(1) != "/")
500 tmp+="/._temp"; 501 tmp+="/._temp";
@@ -513,25 +514,25 @@ bool OpieFtp::remoteDirList(const QString &dir)
513 QCopEnvelope ( "QPE/System", "notBusy()" ); 514 QCopEnvelope ( "QPE/System", "notBusy()" );
514 return true; 515 return true;
515} 516}
516 517
517bool OpieFtp::remoteChDir(const QString &dir) 518bool OpieFtp::remoteChDir(const QString &dir)
518{ 519{
519 QCopEnvelope ( "QPE/System", "busy()" ); 520 QCopEnvelope ( "QPE/System", "busy()" );
520 if (!FtpChdir( dir.latin1(), conn )) { 521 if (!FtpChdir( dir.latin1(), conn )) {
521 QString msg; 522 QString msg;
522 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); 523 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn));
523 msg.replace(QRegExp(":"),"\n"); 524 msg.replace(QRegExp(":"),"\n");
524 QMessageBox::message(tr("Note"),msg); 525 QMessageBox::message(tr("Note"),msg);
525 qDebug(msg); 526 qDebug(msg);
526 QCopEnvelope ( "QPE/System", "notBusy()" ); 527 QCopEnvelope ( "QPE/System", "notBusy()" );
527 return FALSE; 528 return FALSE;
528 } 529 }
529 QCopEnvelope ( "QPE/System", "notBusy()" ); 530 QCopEnvelope ( "QPE/System", "notBusy()" );
530 return TRUE; 531 return TRUE;
531} 532}
532 533
533void OpieFtp::populateLocalView() 534void OpieFtp::populateLocalView()
534{ 535{
535 Local_View->clear(); 536 Local_View->clear();
536 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 537 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
537 currentDir.setMatchAllDirs(TRUE); 538 currentDir.setMatchAllDirs(TRUE);
@@ -771,38 +772,34 @@ void OpieFtp::showHidden()
771 } else { 772 } else {
772 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 773 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
773 localMenu->setItemChecked(localMenu->idAt(0),FALSE); 774 localMenu->setItemChecked(localMenu->idAt(0),FALSE);
774// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 775// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
775 b=FALSE; 776 b=FALSE;
776 } 777 }
777 populateLocalView(); 778 populateLocalView();
778} 779}
779 780
780void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 781void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
781{ 782{
782// if(item) 783// if(item)
783if (mouse == 2) { 784 if (mouse == 2) {
784 showLocalMenu(item); 785 showLocalMenu(item);
785 } 786 }
786} 787}
787 788
788void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 789void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
789{ 790{
790 switch (mouse) { 791 if(mouse == 2) {
791 case 1: 792 showRemoteMenu(item);
792 break; 793 }
793 case 2:
794 showRemoteMenu(item);
795 break;
796 };
797} 794}
798 795
799void OpieFtp::showRemoteMenu(QListViewItem * item) 796void OpieFtp::showRemoteMenu(QListViewItem * item)
800{ 797{
801 QPopupMenu m;// = new QPopupMenu( Local_View ); 798 QPopupMenu m;// = new QPopupMenu( Local_View );
802 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) 799 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1)
803 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); 800 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() ));
804 else 801 else
805 m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 802 m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
806 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 803 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
807 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 804 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
808 m.insertSeparator(); 805 m.insertSeparator();