ProgressBarDialog::ProgressBarDialog( QWidget *parent ) : QDialog(parent) { setupUi( this ); // layout()->setSizeConstraint( QLayout::SetFixedSize ); timer = new QTimer( this ); connect( timer, SIGNAL(timeout()), this, SLOT(slot_update()) ); timer->start(); progressbar->setMinimum( 0 ); progressbar->setMaximum( 100 ); progressbar->setValue( 0 ); connect( cancelButton, SIGNAL(clicked()), this, SLOT(slot_cancel()) ); }
//-----CFileDlg::slot_ft----------------------------------------------------- void CFileDlg::slot_ft() { // Read out any pending events char buf[32]; read(ftman->Pipe(), buf, 32); QTextCodec *codec = UserCodec::codecForProtoUser(m_szId, m_nPPID); CFileTransferEvent *e = NULL; while ( (e = ftman->PopFileTransferEvent()) != NULL) { switch(e->Command()) { case FT_STARTxBATCH: { setCaption(QString(tr("Licq - File Transfer (%1)")).arg(codec->toUnicode(ftman->RemoteName()))); nfoTotalFiles->setText(QString("%1 / %2").arg(1).arg(ftman->BatchFiles())); nfoBatchSize->setText(encodeFSize(ftman->BatchSize())); barBatchTransfer->setTotalSteps(ftman->BatchSize() / 1024); barBatchTransfer->setProgress(0); break; } case FT_CONFIRMxFILE: { // Use this opportunity to encode the filename ftman->StartReceivingFile(QFile::encodeName(codec->toUnicode(ftman->FileName())).data()); break; } case FT_STARTxFILE: { nfoTotalFiles->setText(QString("%1 / %2").arg(ftman->CurrentFile()).arg(ftman->BatchFiles())); nfoTransferFileName->setText(QFile::decodeName(ftman->FileName())); nfoLocalFileName->setText(QFile::decodeName(ftman->PathName())); nfoFileSize->setText(encodeFSize(ftman->FileSize())); barTransfer->setTotalSteps(ftman->FileSize() / 1024); if (ftman->Direction() == D_RECEIVER) mleStatus->append(tr("Receiving file...")); else mleStatus->append(tr("Sending file...")); break; } case FT_UPDATE: { slot_update(); break; } case FT_DONExFILE: { slot_update(); if (ftman->Direction() == D_RECEIVER) mleStatus->append(tr("Received %1 from %2 successfully.").arg(QFile::decodeName(e->Data())).arg(codec->toUnicode(ftman->RemoteName()))); else mleStatus->append(tr("Sent %1 to %2 successfully.").arg(QFile::decodeName(e->Data())).arg(codec->toUnicode(ftman->RemoteName()))); break; } case FT_DONExBATCH: { mleStatus->append(tr("File transfer complete.")); btnCancel->setText(tr("OK")); if( btnOpen && btnOpenDir && ftman->Direction() == D_RECEIVER) { btnOpen->show(); btnOpenDir->show(); } ftman->CloseFileTransfer(); break; } case FT_ERRORxCLOSED: { btnCancel->setText(tr("Close")); mleStatus->append(tr("Remote side disconnected.")); ftman->CloseFileTransfer(); WarnUser(this, tr("Remote side disconnected.")); break; } case FT_ERRORxFILE: { btnCancel->setText(tr("Close")); mleStatus->append(tr("File I/O error: %1.").arg(QFile::decodeName(ftman->PathName()))); ftman->CloseFileTransfer(); WarnUser(this, tr("File I/O Error:\n%1\n\nSee Network Window for details.") .arg(QFile::decodeName(ftman->PathName()))); break; } case FT_ERRORxHANDSHAKE: { btnCancel->setText(tr("Close")); mleStatus->appendNoNewLine(tr("Handshaking error.\n")); ftman->CloseFileTransfer(); WarnUser(this, tr("Handshake Error.\nSee Network Window for details.")); break; } case FT_ERRORxCONNECT: { btnCancel->setText(tr("Close")); mleStatus->appendNoNewLine(tr("Connection error.\n")); ftman->CloseFileTransfer(); WarnUser(this, tr("Unable to reach remote host.\nSee Network Window for details.")); break; } case FT_ERRORxBIND: { btnCancel->setText(tr("Close")); mleStatus->appendNoNewLine(tr("Bind error.\n")); ftman->CloseFileTransfer(); WarnUser(this, tr("Unable to bind to a port.\nSee Network Window for details.")); break; } case FT_ERRORxRESOURCES: { btnCancel->setText(tr("Close")); mleStatus->appendNoNewLine(tr("Not enough resources.\n")); ftman->CloseFileTransfer(); WarnUser(this, tr("Unable to create a thread.\nSee Network Window for details.")); break; } } delete e; } }