author | zecke <zecke> | 2002-10-12 21:18:46 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-12 21:18:46 (UTC) |
commit | 9b33ff5f74c30a5a4905093715a6f345edee26ab (patch) (side-by-side diff) | |
tree | eb0155744adb8c0901e27e001c7e09fc8c789369 /noncore/apps/opie-console/transferdialog.cpp | |
parent | 3eb9678dfab4d152858b7f72c7f0c057fe393541 (diff) | |
download | opie-9b33ff5f74c30a5a4905093715a6f345edee26ab.zip opie-9b33ff5f74c30a5a4905093715a6f345edee26ab.tar.gz opie-9b33ff5f74c30a5a4905093715a6f345edee26ab.tar.bz2 |
Calmed down... 2nd try after merge
Use MetaFactory cuase it's so nice and avoids thousands of if() else if
stuff
Fix a bug in filetransfer where cancel after exit leaded to a crash cause
of bogus adresses in the QSocketNotifiers..
Diffstat (limited to 'noncore/apps/opie-console/transferdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/transferdialog.cpp | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp index d639de6..ba06199 100644 --- a/noncore/apps/opie-console/transferdialog.cpp +++ b/noncore/apps/opie-console/transferdialog.cpp @@ -1,49 +1,62 @@ -#include "transferdialog.h" +#include <qlayout.h> +#include <qcombobox.h> +#include <qlabel.h> +#include <qlineedit.h> +#include <qpushbutton.h> +#include <qmessagebox.h> +#include <qprogressbar.h> + +#include <opie/ofiledialog.h> #include "filetransfer.h" #include "io_serial.h" +#include "metafactory.h" +#include "mainwindow.h" + +#include "transferdialog.h" + -#include "qlayout.h" -#include "qcombobox.h" -#include "qlabel.h" -#include "qlineedit.h" -#include "qpushbutton.h" -#include "qmessagebox.h" -#include "qprogressbar.h" -#include "opie/ofiledialog.h" -TransferDialog::TransferDialog(QWidget *parent, const char *name) -: QDialog(/*parent, name*/NULL, NULL, true) + + + +TransferDialog::TransferDialog(MainWindow *parent, const char *name) +: QDialog(/*parent, name*/0l, 0l, true), m_win(parent) { + m_lay = 0l; QVBoxLayout *vbox; QHBoxLayout *hbox, *hbox2; QLabel *file, *mode, *progress, *status; QPushButton *selector; - transfer = NULL; file = new QLabel(QObject::tr("Send file"), this); mode = new QLabel(QObject::tr("Transfer mode"), this); progress = new QLabel(QObject::tr("Progress"), this); status = new QLabel(QObject::tr("Status"), this); statusbar = new QLabel(QObject::tr("ready"), this); statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); protocol = new QComboBox(this); - protocol->insertItem("XModem"); - protocol->insertItem("YModem"); - protocol->insertItem("ZModem"); + /* use the fscking MetaFactory + * because we invented it for that fscking reason + * I'm really getting UPSET!!!! + */ + QStringList list = m_win->factory()->fileTransferLayers(); + for (QStringList::Iterator it =list.begin(); it != list.end(); ++it ) { + protocol->insertItem( (*it) ); + } filename = new QLineEdit(this); progressbar = new QProgressBar(this); progressbar->setProgress(0); selector = new QPushButton("...", this); ok = new QPushButton(QObject::tr("Start transfer"), this); cancel = new QPushButton(QObject::tr("Cancel"), this); vbox = new QVBoxLayout(this, 2); vbox->add(file); @@ -67,66 +80,61 @@ TransferDialog::TransferDialog(QWidget *parent, const char *name) connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); } TransferDialog::~TransferDialog() { } void TransferDialog::slotFilename() { QString f; - + f = OFileDialog::getOpenFileName(0); if(!f.isNull()) filename->setText(f); } void TransferDialog::slotTransfer() { if(filename->text().isEmpty()) { QMessageBox::information(this, QObject::tr("Attention"), QObject::tr("No file has been specified.")); return; } ok->setEnabled(false); statusbar->setText(QObject::tr("Sending...")); - FileTransfer::Type transfermode = FileTransfer::SX; - if(protocol->currentText() == "YModem") transfermode == FileTransfer::SY; - if(protocol->currentText() == "ZModem") transfermode == FileTransfer::SZ; - - // dummy profile - Profile profile("Dummy", "serial", "vt102", Profile::White, Profile::Black, Profile::VT102); + m_lay = m_win->factory()->newFileTransfer( protocol->currentText(), + m_win->currentSession()->layer() ); + m_lay->sendFile(filename->text()); - transfer = new FileTransfer(transfermode, new IOSerial(profile)); - transfer->sendFile(filename->text()); - connect(transfer, SIGNAL(progress(const QString&, int, int, int, int, int)), SLOT(slotProgress(const QString&, int, int, int, int, int))); - connect(transfer, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); - connect(transfer, SIGNAL(sent()), SLOT(slotSent())); + connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)), SLOT(slotProgress(const QString&, int, int, int, int, int))); + connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); + connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); } void TransferDialog::slotCancel() { ok->setEnabled(true); - if(transfer) + if(m_lay) { - transfer->cancel(); - delete transfer; - transfer = NULL; + m_lay->cancel(); + delete m_lay; + m_lay = 0l; QMessageBox::information(this, QObject::tr("Cancelled"), QObject::tr("The file transfer has been cancelled.")); } else { close(); } } void TransferDialog::slotProgress(const QString& file, int progress, int speed, int hours, int minutes, int seconds) { |