-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 153 |
1 files changed, 84 insertions, 69 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index fd6b028..907a812 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp @@ -103,3 +103,3 @@ OpieFtp::OpieFtp( ) localMenu->setCheckable(TRUE); - + remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); @@ -127,3 +127,3 @@ OpieFtp::OpieFtp( ) // Local_View->setResizePolicy( QListView::AutoOneFit ); - Local_View->addColumn( tr("File"),120); + Local_View->addColumn( tr("File"),150); Local_View->addColumn( tr("Size"),-1); @@ -133,2 +133,4 @@ OpieFtp::OpieFtp( ) Local_View->setAllColumnsShowFocus(TRUE); + Local_View->setMultiSelection( TRUE ); + QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); @@ -137,3 +139,3 @@ OpieFtp::OpieFtp( ) - connect( Local_View, SIGNAL( clicked( QListViewItem*)), + connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), this,SLOT( localListClicked(QListViewItem *)) ); @@ -150,3 +152,3 @@ OpieFtp::OpieFtp( ) Remote_View = new QListView( tab_2, "Remote_View" ); - Remote_View->addColumn( tr("File"),120); + Remote_View->addColumn( tr("File"),150); Remote_View->addColumn( tr("Size"),-1); @@ -158,5 +160,7 @@ OpieFtp::OpieFtp( ) Remote_View->setAllColumnsShowFocus(TRUE); + Remote_View->setMultiSelection( TRUE ); + QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); - connect( Remote_View, SIGNAL( clicked( QListViewItem*)), + connect( Remote_View, SIGNAL( doubleClicked( QListViewItem*)), this,SLOT( remoteListClicked(QListViewItem *)) ); @@ -401,3 +405,3 @@ void OpieFtp::disConnector() connectServerBtn->setOn(FALSE); - + } @@ -408,31 +412,38 @@ void OpieFtp::localUpload() QCopEnvelope ( "QPE/System", "busy()" ); -// qApp->processEvents(); - QString strItem = Local_View->currentItem()->text(0); - QString localFile = currentDir.canonicalPath()+"/"+strItem; - QString remoteFile= currentRemoteDir+strItem; - QFileInfo fi(localFile); - if( !fi.isDir()) { - fsz=fi.size(); - ProgressBar->setTotalSteps(fsz); - - FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); - FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); - FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); - FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); - qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); - - if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { - QString msg; - msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); - msg.replace(QRegExp(":"),"\n"); - QMessageBox::message(tr("Note"),msg); +// qApp->processEvents(); + QList<QListViewItem> * getSelectedItems( QListView * Local_View ); + QListViewItemIterator it( Local_View ); + for ( ; it.current(); ++it ) { + if ( it.current()->isSelected() ) { + QString strItem = it.current()->text(0); + QString localFile = currentDir.canonicalPath()+"/"+strItem; + QString remoteFile= currentRemoteDir+strItem; + QFileInfo fi(localFile); + if( !fi.isDir()) { + fsz=fi.size(); + ProgressBar->setTotalSteps(fsz); + + FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); + FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); + FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); + FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); + qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); + + if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { + QString msg; + msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); + msg.replace(QRegExp(":"),"\n"); + QMessageBox::message(tr("Note"),msg); + } + } else { + QMessageBox::message(tr("Note"),tr("Cannot upload directories")); + } + ProgressBar->reset(); + nullifyCallBack(); + it.current()->setSelected(FALSE); + } //end currentSelected } - ProgressBar->reset(); - nullifyCallBack(); - } else { - QMessageBox::message(tr("Note"),tr("Cannot upload directories")); - } - TabWidget->setCurrentPage(1); - remoteDirList( (const QString &)currentRemoteDir); //this also calls populate - QCopEnvelope ( "QPE/System", "notBusy()" ); + TabWidget->setCurrentPage(1); + remoteDirList( (const QString &)currentRemoteDir); //this also calls populate + QCopEnvelope ( "QPE/System", "notBusy()" ); } @@ -445,3 +456,2 @@ void OpieFtp::nullifyCallBack() FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); - } @@ -453,31 +463,38 @@ void OpieFtp::remoteDownload() QCopEnvelope ( "QPE/System", "busy()" ); - QString strItem = Remote_View->currentItem()->text(0); -// strItem=strItem.right(strItem.length()-1); - QString localFile = currentDir.canonicalPath(); - if(localFile.right(1).find("/",0,TRUE) == -1) - localFile += "/"; - localFile += strItem; + QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); + QListViewItemIterator it( Remote_View ); + for ( ; it.current(); ++it ) { + if ( it.current()->isSelected() ) { + QString strItem = it.current()->text(0); +// strItem=strItem.right(strItem.length()-1); + QString localFile = currentDir.canonicalPath(); + if(localFile.right(1).find("/",0,TRUE) == -1) + localFile += "/"; + localFile += strItem; // QString localFile = currentDir.canonicalPath()+"/"+strItem; - QString remoteFile= currentRemoteDir+strItem; - if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) - fsz = 0; - QString temp; - temp.sprintf( remoteFile+" "+" %dkb", fsz); - - ProgressBar->setTotalSteps(fsz); - FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); - FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); - FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); - FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); - qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); - - if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { - QString msg; - msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); - msg.replace(QRegExp(":"),"\n"); - QMessageBox::message(tr("Note"),msg); + QString remoteFile= currentRemoteDir+strItem; + if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) + fsz = 0; + QString temp; + temp.sprintf( remoteFile+" "+" %dkb", fsz); + + ProgressBar->setTotalSteps(fsz); + FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); + FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); + FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); + FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); + qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); + + if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { + QString msg; + 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); + } } - ProgressBar->reset(); - nullifyCallBack(); TabWidget->setCurrentPage(0); @@ -559,5 +576,5 @@ void OpieFtp::populateLocalView() if(isDir || fileL.find("/",0,TRUE) != -1) { - if( !QDir( fi->filePath() ).isReadable()) + if( !QDir( fi->filePath() ).isReadable()) pm = Resource::loadPixmap( "lockedfolder" ); - else + else pm= Resource::loadPixmap( "folder" ); @@ -569,3 +586,3 @@ void OpieFtp::populateLocalView() MimeType mt(fi->filePath()); - pm=mt.pixmap(); + pm=mt.pixmap(); //sets the correct pixmap for mimetype if(pm.isNull()) @@ -591,3 +608,2 @@ void OpieFtp::populateLocalView() fillCombo( (const QString &)currentDir); - } @@ -645,3 +661,3 @@ bool OpieFtp::populateRemoteView( ) Remote_View->setSorting( 4,TRUE); - return true; + return true; } @@ -761,3 +777,3 @@ void OpieFtp::showHidden() b=TRUE; - + } else { @@ -858,3 +874,3 @@ void OpieFtp::localDelete() }; - + } else { @@ -913,3 +929,2 @@ void OpieFtp::remoteDelete() remoteDirList( (const QString &)currentRemoteDir); //this also calls populate - } |