Diffstat (limited to 'noncore/apps/opie-console/transferdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/transferdialog.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp index 30e7caf..d494a6c 100644 --- a/noncore/apps/opie-console/transferdialog.cpp +++ b/noncore/apps/opie-console/transferdialog.cpp | |||
@@ -32,205 +32,205 @@ TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const ch | |||
32 | group = new QButtonGroup(QObject::tr("Transfer mode"), this); | 32 | group = new QButtonGroup(QObject::tr("Transfer mode"), this); |
33 | mode_send = new QRadioButton(QObject::tr("Send"), group); | 33 | mode_send = new QRadioButton(QObject::tr("Send"), group); |
34 | mode_receive = new QRadioButton(QObject::tr("Receive"), group); | 34 | mode_receive = new QRadioButton(QObject::tr("Receive"), group); |
35 | group->insert(mode_send, id_send); | 35 | group->insert(mode_send, id_send); |
36 | group->insert(mode_receive, id_receive); | 36 | group->insert(mode_receive, id_receive); |
37 | vbox2 = new QVBoxLayout(group, 2); | 37 | vbox2 = new QVBoxLayout(group, 2); |
38 | vbox2->addSpacing(10); | 38 | vbox2->addSpacing(10); |
39 | hbox3 = new QHBoxLayout(vbox2, 2); | 39 | hbox3 = new QHBoxLayout(vbox2, 2); |
40 | hbox3->add(mode_send); | 40 | hbox3->add(mode_send); |
41 | hbox3->add(mode_receive); | 41 | hbox3->add(mode_receive); |
42 | mode_send->setChecked(true); | 42 | mode_send->setChecked(true); |
43 | m_transfermode = id_send; | 43 | m_transfermode = id_send; |
44 | 44 | ||
45 | file = new QLabel(QObject::tr("Send file"), this); | 45 | file = new QLabel(QObject::tr("Send file"), this); |
46 | mode = new QLabel(QObject::tr("Transfer protocol"), this); | 46 | mode = new QLabel(QObject::tr("Transfer protocol"), this); |
47 | progress = new QLabel(QObject::tr("Progress"), this); | 47 | progress = new QLabel(QObject::tr("Progress"), this); |
48 | status = new QLabel(QObject::tr("Status"), this); | 48 | status = new QLabel(QObject::tr("Status"), this); |
49 | 49 | ||
50 | statusbar = new QLabel(QObject::tr("Ready"), this); | 50 | statusbar = new QLabel(QObject::tr("Ready"), this); |
51 | statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); | 51 | statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
52 | 52 | ||
53 | protocol = new QComboBox(this); | 53 | protocol = new QComboBox(this); |
54 | QStringList list = m_win->factory()->fileTransferLayers(); | 54 | QStringList list = m_win->factory()->fileTransferLayers(); |
55 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) | 55 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) |
56 | protocol->insertItem((*it)); | 56 | protocol->insertItem((*it)); |
57 | 57 | ||
58 | filename = new QLineEdit(this); | 58 | filename = new QLineEdit(this); |
59 | 59 | ||
60 | progressbar = new QProgressBar(this); | 60 | progressbar = new QProgressBar(this); |
61 | progressbar->setProgress(0); | 61 | progressbar->setProgress(0); |
62 | 62 | ||
63 | selector = new QPushButton("...", this); | 63 | selector = new QPushButton("...", this); |
64 | ok = new QPushButton(QObject::tr("Start transfer"), this); | 64 | ok = new QPushButton(QObject::tr("Start transfer"), this); |
65 | cancel = new QPushButton(QObject::tr("Cancel"), this); | 65 | cancel = new QPushButton(QObject::tr("Cancel"), this); |
66 | 66 | ||
67 | vbox = new QVBoxLayout(this, 2); | 67 | vbox = new QVBoxLayout(this, 2); |
68 | vbox->add(group); | 68 | vbox->add(group); |
69 | vbox->add(file); | 69 | vbox->add(file); |
70 | hbox = new QHBoxLayout(vbox, 0); | 70 | hbox = new QHBoxLayout(vbox, 0); |
71 | hbox->add(filename); | 71 | hbox->add(filename); |
72 | hbox->add(selector); | 72 | hbox->add(selector); |
73 | vbox->add(mode); | 73 | vbox->add(mode); |
74 | vbox->add(protocol); | 74 | vbox->add(protocol); |
75 | vbox->add(progress); | 75 | vbox->add(progress); |
76 | vbox->add(progressbar); | 76 | vbox->add(progressbar); |
77 | vbox->add(status); | 77 | vbox->add(status); |
78 | vbox->add(statusbar); | 78 | vbox->add(statusbar); |
79 | vbox->addStretch(1); | 79 | vbox->addStretch(1); |
80 | hbox2 = new QHBoxLayout(vbox, 2); | 80 | hbox2 = new QHBoxLayout(vbox, 2); |
81 | hbox2->add(ok); | 81 | hbox2->add(ok); |
82 | hbox2->add(cancel); | 82 | hbox2->add(cancel); |
83 | 83 | ||
84 | setCaption(QObject::tr("File transfer")); | 84 | setCaption(QObject::tr("File transfer")); |
85 | show(); | 85 | show(); |
86 | 86 | ||
87 | connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); | 87 | connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); |
88 | connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); | 88 | connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); |
89 | connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); | 89 | connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); |
90 | connect(group, SIGNAL(clicked(int)), SLOT(slotMode(int))); | 90 | connect(group, SIGNAL(clicked(int)), SLOT(slotMode(int))); |
91 | } | 91 | } |
92 | 92 | ||
93 | TransferDialog::~TransferDialog() | 93 | TransferDialog::~TransferDialog() |
94 | { | 94 | { |
95 | } | 95 | } |
96 | 96 | ||
97 | void TransferDialog::slotFilename() | 97 | void TransferDialog::slotFilename() |
98 | { | 98 | { |
99 | QString f; | 99 | QString f; |
100 | 100 | ||
101 | f = Opie::OFileDialog::getOpenFileName(0); | 101 | f = Opie::OFileDialog::getOpenFileName(0); |
102 | if(!f.isNull()) filename->setText(f); | 102 | if(!f.isNull()) filename->setText(f); |
103 | } | 103 | } |
104 | 104 | ||
105 | void TransferDialog::slotTransfer() | 105 | void TransferDialog::slotTransfer() |
106 | { | 106 | { |
107 | if((m_transfermode == id_send) && (filename->text().isEmpty())) | 107 | if((m_transfermode == id_send) && (filename->text().isEmpty())) |
108 | { | 108 | { |
109 | QMessageBox::information(this, | 109 | QMessageBox::information(this, |
110 | QObject::tr("Attention"), | 110 | QObject::tr("Attention"), |
111 | QObject::tr("No file has been specified.")); | 111 | QObject::tr("No file has been specified.")); |
112 | return; | 112 | return; |
113 | } | 113 | } |
114 | 114 | ||
115 | ok->setEnabled(false); | 115 | ok->setEnabled(false); |
116 | 116 | ||
117 | cleanup(); | 117 | cleanup(); |
118 | m_autocleanup = 0; | 118 | m_autocleanup = 0; |
119 | 119 | ||
120 | if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending...")); | 120 | if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending...")); |
121 | else statusbar->setText(QObject::tr("Receiving...")); | 121 | else statusbar->setText(QObject::tr("Receiving...")); |
122 | 122 | ||
123 | if(m_transfermode == id_send) | 123 | if(m_transfermode == id_send) |
124 | { | 124 | { |
125 | m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer()); | 125 | m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer()); |
126 | m_lay->sendFile(filename->text()); | 126 | m_lay->sendFile(filename->text()); |
127 | 127 | ||
128 | connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)), | 128 | connect(m_lay, SIGNAL(progress(const QString&,int,int,int,int,int)), |
129 | SLOT(slotProgress(const QString&, int, int, int, int, int))); | 129 | SLOT(slotProgress(const QString&,int,int,int,int,int))); |
130 | connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); | 130 | connect(m_lay, SIGNAL(error(int,const QString&)), SLOT(slotError(int,const QString&))); |
131 | connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); | 131 | connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); |
132 | } | 132 | } |
133 | else | 133 | else |
134 | { | 134 | { |
135 | m_recvlay = m_win->factory()->newReceive(protocol->currentText(), m_win->currentSession()->layer()); | 135 | m_recvlay = m_win->factory()->newReceive(protocol->currentText(), m_win->currentSession()->layer()); |
136 | m_recvlay->receive(); | 136 | m_recvlay->receive(); |
137 | 137 | ||
138 | connect(m_recvlay, SIGNAL(progress(const QString&, int, int, int, int, int)), | 138 | connect(m_recvlay, SIGNAL(progress(const QString&,int,int,int,int,int)), |
139 | SLOT(slotProgress(const QString&, int, int, int, int, int))); | 139 | SLOT(slotProgress(const QString&,int,int,int,int,int))); |
140 | connect(m_recvlay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); | 140 | connect(m_recvlay, SIGNAL(error(int,const QString&)), SLOT(slotError(int,const QString&))); |
141 | connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&))); | 141 | connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&))); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | void TransferDialog::cleanup() | 145 | void TransferDialog::cleanup() |
146 | { | 146 | { |
147 | if(m_lay) | 147 | if(m_lay) |
148 | { | 148 | { |
149 | m_lay->cancel(); | 149 | m_lay->cancel(); |
150 | delete m_lay; | 150 | delete m_lay; |
151 | m_lay = 0l; | 151 | m_lay = 0l; |
152 | } | 152 | } |
153 | if(m_recvlay) | 153 | if(m_recvlay) |
154 | { | 154 | { |
155 | m_recvlay->cancel(); | 155 | m_recvlay->cancel(); |
156 | delete m_recvlay; | 156 | delete m_recvlay; |
157 | m_recvlay = 0l; | 157 | m_recvlay = 0l; |
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
161 | void TransferDialog::slotCancel() | 161 | void TransferDialog::slotCancel() |
162 | { | 162 | { |
163 | ok->setEnabled(true); | 163 | ok->setEnabled(true); |
164 | statusbar->setText(QObject::tr("Ready")); | 164 | statusbar->setText(QObject::tr("Ready")); |
165 | 165 | ||
166 | if((m_lay) || (m_recvlay)) | 166 | if((m_lay) || (m_recvlay)) |
167 | { | 167 | { |
168 | cleanup(); | 168 | cleanup(); |
169 | if(m_autocleanup) | 169 | if(m_autocleanup) |
170 | { | 170 | { |
171 | m_running = false; | 171 | m_running = false; |
172 | close(); | 172 | close(); |
173 | } | 173 | } |
174 | else | 174 | else |
175 | { | 175 | { |
176 | QMessageBox::information(this, | 176 | QMessageBox::information(this, |
177 | QObject::tr("Cancelled"), | 177 | QObject::tr("Cancelled"), |
178 | QObject::tr("The file transfer has been cancelled.")); | 178 | QObject::tr("The file transfer has been cancelled.")); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | else | 181 | else |
182 | { | 182 | { |
183 | m_running = false; | 183 | m_running = false; |
184 | close(); | 184 | close(); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | void TransferDialog::slotProgress(const QString& , int progress, int , int , int, int ) | 188 | void TransferDialog::slotProgress(const QString& , int progress, int , int , int, int ) |
189 | { | 189 | { |
190 | progressbar->setProgress(progress); | 190 | progressbar->setProgress(progress); |
191 | } | 191 | } |
192 | 192 | ||
193 | void TransferDialog::slotError(int error, const QString& ) | 193 | void TransferDialog::slotError(int error, const QString& ) |
194 | { | 194 | { |
195 | statusbar->setText(QObject::tr("Ready")); | 195 | statusbar->setText(QObject::tr("Ready")); |
196 | 196 | ||
197 | switch(error) | 197 | switch(error) |
198 | { | 198 | { |
199 | case FileTransferLayer::NotSupported: | 199 | case FileTransferLayer::NotSupported: |
200 | QMessageBox::critical(this, | 200 | QMessageBox::critical(this, |
201 | QObject::tr("Error"), | 201 | QObject::tr("Error"), |
202 | QObject::tr("Operation not supported.")); | 202 | QObject::tr("Operation not supported.")); |
203 | break; | 203 | break; |
204 | case FileTransferLayer::StartError: | 204 | case FileTransferLayer::StartError: |
205 | QMessageBox::critical(this, | 205 | QMessageBox::critical(this, |
206 | QObject::tr("Error"), | 206 | QObject::tr("Error"), |
207 | QObject::tr("Transfer could not be started.")); | 207 | QObject::tr("Transfer could not be started.")); |
208 | break; | 208 | break; |
209 | case FileTransferLayer::NoError: | 209 | case FileTransferLayer::NoError: |
210 | QMessageBox::critical(this, | 210 | QMessageBox::critical(this, |
211 | QObject::tr("Error"), | 211 | QObject::tr("Error"), |
212 | QObject::tr("No error.")); | 212 | QObject::tr("No error.")); |
213 | break; | 213 | break; |
214 | case FileTransferLayer::Undefined: | 214 | case FileTransferLayer::Undefined: |
215 | QMessageBox::critical(this, | 215 | QMessageBox::critical(this, |
216 | QObject::tr("Error"), | 216 | QObject::tr("Error"), |
217 | QObject::tr("Undefined error occured.")); | 217 | QObject::tr("Undefined error occured.")); |
218 | break; | 218 | break; |
219 | case FileTransferLayer::Incomplete: | 219 | case FileTransferLayer::Incomplete: |
220 | QMessageBox::critical(this, | 220 | QMessageBox::critical(this, |
221 | QObject::tr("Error"), | 221 | QObject::tr("Error"), |
222 | QObject::tr("Incomplete transfer.")); | 222 | QObject::tr("Incomplete transfer.")); |
223 | break; | 223 | break; |
224 | case FileTransferLayer::Unknown: | 224 | case FileTransferLayer::Unknown: |
225 | default: | 225 | default: |
226 | QMessageBox::critical(this, | 226 | QMessageBox::critical(this, |
227 | QObject::tr("Error"), | 227 | QObject::tr("Error"), |
228 | QObject::tr("Unknown error occured.")); | 228 | QObject::tr("Unknown error occured.")); |
229 | break; | 229 | break; |
230 | } | 230 | } |
231 | 231 | ||
232 | m_autocleanup = 1; | 232 | m_autocleanup = 1; |
233 | } | 233 | } |
234 | 234 | ||
235 | void TransferDialog::slotSent() | 235 | void TransferDialog::slotSent() |
236 | { | 236 | { |