-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 256 |
1 files changed, 141 insertions, 115 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index fb57193..7f5d71c 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp @@ -152,14 +152,16 @@ OpieFtp::OpieFtp( ) Local_View->addColumn( tr("File"),150); Local_View->addColumn( tr("Size"),-1); Local_View->setColumnAlignment(1,QListView::AlignRight); Local_View->addColumn( tr("Date"),-1); Local_View->setColumnAlignment(2,QListView::AlignRight); Local_View->setAllColumnsShowFocus(TRUE); - Local_View->setMultiSelection( TRUE ); + + Local_View->setMultiSelection( TRUE); Local_View->setSelectionMode(QListView::Extended); + Local_View->setFocusPolicy(QWidget::ClickFocus); QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); tabLayout->addWidget( Local_View, 0, 0 ); connect( Local_View, SIGNAL( clicked( QListViewItem*)), @@ -182,14 +184,16 @@ OpieFtp::OpieFtp( ) Remote_View->setColumnAlignment(1,QListView::AlignRight); Remote_View->addColumn( tr("Date"),-1); Remote_View->setColumnAlignment(2,QListView::AlignRight); Remote_View->addColumn( tr("Dir"),-1); Remote_View->setColumnAlignment(4,QListView::AlignRight); Remote_View->setAllColumnsShowFocus(TRUE); - Remote_View->setMultiSelection( TRUE ); + + Remote_View->setMultiSelection( FALSE); Remote_View->setSelectionMode(QListView::Extended); + Remote_View->setFocusPolicy(QWidget::ClickFocus); QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); connect( Remote_View, SIGNAL( clicked( QListViewItem*)), this,SLOT( remoteListClicked(QListViewItem *)) ); connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), @@ -375,13 +379,13 @@ void OpieFtp::connectorBtnToggled(bool On) } } void OpieFtp::connector() { -// QCopEnvelope ( "QPE/System", "busy()" ); + QCopEnvelope ( "QPE/System", "busy()" ); // qApp->processEvents(); currentRemoteDir=remotePath->text(); if(ServerComboBox->currentText().isEmpty()) { QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); TabWidget->setCurrentPage(2); ServerComboBox->setFocus(); @@ -418,13 +422,13 @@ void OpieFtp::connector() return ; } remoteDirList("/") ; setCaption(ftp_host); writeConfig(); connectServerBtn->setText( tr("Disconnect")); -// QCopEnvelope ( "QPE/System", "notBusy()" ); + QCopEnvelope ( "QPE/System", "notBusy()" ); } void OpieFtp::disConnector() { if(conn) FtpQuit(conn); @@ -466,19 +470,22 @@ void OpieFtp::localUpload() } } else { QMessageBox::message(tr("Note"),tr("Cannot upload directories")); } ProgressBar->reset(); nullifyCallBack(); - } //end currentSelected it.current()->setSelected(FALSE); + } //end currentSelected + } + for ( ; it.current(); ++it ) { + Local_View->clearSelection(); } + Local_View->clearFocus(); TabWidget->setCurrentPage(1); remoteDirList( (const QString &)currentRemoteDir); //this also calls populate -// QCopEnvelope ( "QPE/System", "notBusy()" ); - + QCopEnvelope ( "QPE/System", "notBusy()" ); } void OpieFtp::nullifyCallBack() { FtpOptions(FTPLIB_CALLBACK, NULL, conn); FtpOptions(FTPLIB_IDLETIME, NULL, conn); @@ -487,13 +494,13 @@ void OpieFtp::nullifyCallBack() } void OpieFtp::remoteDownload() { // qApp->processEvents(); int fsz; -// QCopEnvelope ( "QPE/System", "busy()" ); + QCopEnvelope ( "QPE/System", "busy()" ); QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); QListViewItemIterator it( Remote_View ); for ( ; it.current(); ++it ) { if ( it.current()->isSelected() ) { QString strItem = it.current()->text(0); @@ -521,55 +528,58 @@ void OpieFtp::remoteDownload() msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); } ProgressBar->reset(); nullifyCallBack(); - } it.current()->setSelected(FALSE); + } + } + for ( ; it.current(); ++it ) { + Remote_View->clearSelection(); } + Remote_View->setFocus(); TabWidget->setCurrentPage(0); populateLocalView(); -// QCopEnvelope ( "QPE/System", "notBusy()" ); - + QCopEnvelope ( "QPE/System", "notBusy()" ); } bool OpieFtp::remoteDirList(const QString &dir) { QString tmp = QDir::homeDirPath(); if(tmp.right(1) != "/") tmp+="/._temp"; else tmp+="._temp"; // qDebug("Listing remote dir "+tmp); -// QCopEnvelope ( "QPE/System", "busy()" ); + QCopEnvelope ( "QPE/System", "busy()" ); if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { QString msg; msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); return false; } populateRemoteView() ; -// QCopEnvelope ( "QPE/System", "notBusy()" ); + QCopEnvelope ( "QPE/System", "notBusy()" ); return true; } bool OpieFtp::remoteChDir(const QString &dir) { -// QCopEnvelope ( "QPE/System", "busy()" ); + QCopEnvelope ( "QPE/System", "busy()" ); if (!FtpChdir( dir.latin1(), conn )) { QString msg; msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); // qDebug(msg); -// QCopEnvelope ( "QPE/System", "notBusy()" ); + QCopEnvelope ( "QPE/System", "notBusy()" ); return FALSE; } -// QCopEnvelope ( "QPE/System", "notBusy()" ); + QCopEnvelope ( "QPE/System", "notBusy()" ); return TRUE; } void OpieFtp::populateLocalView() { Local_View->clear(); @@ -634,13 +644,12 @@ void OpieFtp::populateLocalView() isDir=FALSE; ++it; } Local_View->setSorting( 3,FALSE); currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); fillCombo( (const QString &)currentDir); - } bool OpieFtp::populateRemoteView( ) { // qDebug("populate remoteview"); QString sfile=QDir::homeDirPath(); @@ -735,13 +744,13 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem) // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); } else { currentRemoteDir = currentRemoteDir+strItem; } } else { -// QCopEnvelope ( "QPE/System", "notBusy()" ); + QCopEnvelope ( "QPE/System", "notBusy()" ); return; } } remoteDirList( (const QString &)currentRemoteDir); //this also calls populate if(currentRemoteDir.right(1) !="/") currentRemoteDir +="/"; @@ -787,13 +796,12 @@ void OpieFtp::localListClicked(QListViewItem *selectedItem) return; } } //end not symlink chdir(strItem.latin1()); } } - } void OpieFtp::doLocalCd() { localListClicked( Local_View->currentItem()); } @@ -835,45 +843,49 @@ void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &p showRemoteMenu(item); } } void OpieFtp::showRemoteMenu(QListViewItem * item) { - QPopupMenu m;// = new QPopupMenu( Local_View ); + QPopupMenu * m;// = new QPopupMenu( Local_View ); + m = new QPopupMenu(this); if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) - m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); + m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); else - m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); - m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); - m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); - m.insertSeparator(); - m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); - m.exec( QCursor::pos() ); + m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); + m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); + m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); + m->insertSeparator(); + m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); + m->exec( QCursor::pos() ); + delete m; } void OpieFtp::showLocalMenu(QListViewItem * item) { - QPopupMenu m; - m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); - m.insertSeparator(); + QPopupMenu *m; + m = new QPopupMenu( this); + m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); + m->insertSeparator(); if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) - m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); + m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); else - m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); - m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); - m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); - m.insertSeparator(); - m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); - m.setCheckable(TRUE); + m->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); + m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); + m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); + m->insertSeparator(); + m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); + m->setCheckable(TRUE); if (b) - m.setItemChecked(m.idAt(0),TRUE); + m->setItemChecked(m->idAt(0),TRUE); else - m.setItemChecked(m.idAt(0),FALSE); + m->setItemChecked(m->idAt(0),FALSE); - m.exec( QCursor::pos() ); + m->exec( QCursor::pos() ); + delete m; } void OpieFtp::localMakDir() { InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); @@ -884,122 +896,138 @@ void OpieFtp::localMakDir() } populateLocalView(); } void OpieFtp::localDelete() { - QString f = Local_View->currentItem()->text(0); - if(QDir(f).exists() ) { - switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ - tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { - case 0: { - f=currentDir.canonicalPath()+"/"+f; - QString cmd="rmdir "+f; - system( cmd.latin1()); - populateLocalView(); - } - break; - case 1: - // exit - break; - }; + QList<QListViewItem> * getSelectedItems( QListView * Local_View ); + QListViewItemIterator it( Local_View ); + for ( ; it.current(); ++it ) { + if ( it.current()->isSelected() ) { + QString f = it.current()->text(0); + it.current()->setSelected(FALSE); + +// QString f = Local_View->currentItem()->text(0); + if(QDir(f).exists() ) { + switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ + tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { + case 0: { + f=currentDir.canonicalPath()+"/"+f; + QString cmd="rmdir "+f; + system( cmd.latin1()); + } + break; + case 1: + // exit + break; + }; - } else { - switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f - +" ?",tr("Yes"),tr("No"),0,0,1) ) { - case 0: { - f=currentDir.canonicalPath()+"/"+f; - QString cmd="rm "+f; - system( cmd.latin1()); - populateLocalView(); - } - break; - case 1: - // exit - break; - }; + } else { + switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f + +" ?",tr("Yes"),tr("No"),0,0,1) ) { + case 0: { + f=currentDir.canonicalPath()+"/"+f; + QString cmd="rm "+f; + system( cmd.latin1()); + } + break; + case 1: + // exit + break; + }; + } + } } + populateLocalView(); + } void OpieFtp::remoteMakDir() { InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = fileDlg->LineEdit1->text();//+".playlist"; QString tmp=currentRemoteDir+filename; -// QCopEnvelope ( "QPE/System", "busy()" ); + QCopEnvelope ( "QPE/System", "busy()" ); if(FtpMkdir( tmp.latin1(), conn) == 0) { QString msg; msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); } -// QCopEnvelope ( "QPE/System", "notBusy()" ); + QCopEnvelope ( "QPE/System", "notBusy()" ); remoteDirList( (const QString &)currentRemoteDir); //this also calls populate } } void OpieFtp::remoteDelete() { - QString f = Remote_View->currentItem()->text(0); -// QCopEnvelope ( "QPE/System", "busy()" ); - if( f.right(1) =="/") { - QString path= currentRemoteDir+f; - switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" - ,tr("Yes"),tr("No"),0,0,1) ) { - case 0: { - f=currentDir.canonicalPath()+"/"+f; - if(FtpRmdir( path.latin1(), conn) ==0) { - QString msg; - msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); - msg.replace(QRegExp(":"),"\n"); - QMessageBox::message(tr("Note"),msg); - } - remoteDirList( (const QString &)currentRemoteDir); //this also calls populate - } - break; - }; - } else { - switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" - ,tr("Yes"),tr("No"),0,0,1) ) { - case 0: { - QString path= currentRemoteDir+f; - if(FtpDelete( path.latin1(), conn)==0) { - QString msg; - msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); - msg.replace(QRegExp(":"),"\n"); - QMessageBox::message(tr("Note"),msg); - } - remoteDirList( (const QString &)currentRemoteDir); //this also calls populate - } - break; - }; + QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); + QListViewItemIterator it( Remote_View ); + for ( ; it.current(); ++it ) { + if ( it.current()->isSelected() ) { + QString f = it.current()->text(0); +// QString f = Remote_View->currentItem()->text(0); + QCopEnvelope ( "QPE/System", "busy()" ); + if( f.right(1) =="/") { + QString path= currentRemoteDir+f; + switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" + ,tr("Yes"),tr("No"),0,0,1) ) { + case 0: { + f=currentDir.canonicalPath()+"/"+f; + if(FtpRmdir( path.latin1(), conn) ==0) { + QString msg; + msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); + msg.replace(QRegExp(":"),"\n"); + QMessageBox::message(tr("Note"),msg); + } + remoteDirList( (const QString &)currentRemoteDir); //this also calls populate + } + break; + }; + } else { + switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" + ,tr("Yes"),tr("No"),0,0,1) ) { + case 0: { + QString path= currentRemoteDir+f; + if(FtpDelete( path.latin1(), conn)==0) { + QString msg; + msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); + msg.replace(QRegExp(":"),"\n"); + QMessageBox::message(tr("Note"),msg); + } + remoteDirList( (const QString &)currentRemoteDir); //this also calls populate + } + break; + }; + } + } } -// QCopEnvelope ( "QPE/System", "notBusy()" ); + QCopEnvelope ( "QPE/System", "notBusy()" ); } void OpieFtp::remoteRename() { QString curFile = Remote_View->currentItem()->text(0); InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); fileDlg->setTextEdit((const QString &)curFile); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString oldName = currentRemoteDir +"/"+ curFile; QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; -// QCopEnvelope ( "QPE/System", "busy()" ); + QCopEnvelope ( "QPE/System", "busy()" ); if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { QString msg; msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); } -// QCopEnvelope ( "QPE/System", "notBusy()" ); + QCopEnvelope ( "QPE/System", "notBusy()" ); remoteDirList( (const QString &)currentRemoteDir); //this also calls populate } } void OpieFtp::localRename() { @@ -1262,13 +1290,13 @@ void OpieFtp::upDir() currentRemoteDir=path; remoteDirList( (const QString &)currentRemoteDir); //this also calls populate if(currentRemoteDir.right(1) !="/") currentRemoteDir +="/"; currentPathCombo->lineEdit()->setText( currentRemoteDir); fillRemoteCombo( (const QString &)currentRemoteDir); - populateRemoteView( ); + } } void OpieFtp::docButtonPushed() { QString current = QPEApplication::documentDir(); chdir( current.latin1() ); @@ -1276,14 +1304,12 @@ void OpieFtp::docButtonPushed() { populateLocalView(); update(); } void OpieFtp::homeButtonPushed() { - if (TabWidget->currentPageIndex() == 0) { - QString current = QDir::homeDirPath(); - chdir( current.latin1() ); - currentDir.cd( current, TRUE); - populateLocalView(); - update(); - } + QString current = QDir::homeDirPath(); + chdir( current.latin1() ); + currentDir.cd( current, TRUE); + populateLocalView(); + update(); } |