author | drw <drw> | 2004-02-23 17:41:08 (UTC) |
---|---|---|
committer | drw <drw> | 2004-02-23 17:41:08 (UTC) |
commit | 0259f547f4dea6e10df1e02ee78b343137de24ed (patch) (unidiff) | |
tree | c09a0a69c8dfe397238bf476a849875306072855 /noncore/apps/opie-console/transferdialog.cpp | |
parent | d1e639b1272a6ba18ebe3fc982148ce0cb5c8c84 (diff) | |
download | opie-0259f547f4dea6e10df1e02ee78b343137de24ed.zip opie-0259f547f4dea6e10df1e02ee78b343137de24ed.tar.gz opie-0259f547f4dea6e10df1e02ee78b343137de24ed.tar.bz2 |
Opie Console: libopie->libopie2
Diffstat (limited to 'noncore/apps/opie-console/transferdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/transferdialog.cpp | 416 |
1 files changed, 208 insertions, 208 deletions
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp index 55dd748..30e7caf 100644 --- a/noncore/apps/opie-console/transferdialog.cpp +++ b/noncore/apps/opie-console/transferdialog.cpp | |||
@@ -8,7 +8,7 @@ | |||
8 | #include <qradiobutton.h> | 8 | #include <qradiobutton.h> |
9 | #include <qbuttongroup.h> | 9 | #include <qbuttongroup.h> |
10 | 10 | ||
11 | #include <opie/ofiledialog.h> | 11 | #include <opie2/ofiledialog.h> |
12 | 12 | ||
13 | #include "metafactory.h" | 13 | #include "metafactory.h" |
14 | #include "mainwindow.h" | 14 | #include "mainwindow.h" |
@@ -19,75 +19,75 @@ TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const ch | |||
19 | : QDialog(parent, 0l, false), m_win(mainwindow) | 19 | : QDialog(parent, 0l, false), m_win(mainwindow) |
20 | { | 20 | { |
21 | m_lay = 0l; | 21 | m_lay = 0l; |
22 | m_recvlay = 0l; | 22 | m_recvlay = 0l; |
23 | QVBoxLayout *vbox, *vbox2; | 23 | QVBoxLayout *vbox, *vbox2; |
24 | QHBoxLayout *hbox, *hbox2, *hbox3; | 24 | QHBoxLayout *hbox, *hbox2, *hbox3; |
25 | QLabel *file, *mode, *progress, *status; | 25 | QLabel *file, *mode, *progress, *status; |
26 | QButtonGroup *group; | 26 | QButtonGroup *group; |
27 | QRadioButton *mode_send, *mode_receive; | 27 | QRadioButton *mode_send, *mode_receive; |
28 | 28 | ||
29 | m_autocleanup = 0; | 29 | m_autocleanup = 0; |
30 | m_running = true; | 30 | m_running = true; |
31 | 31 | ||
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() |
@@ -96,180 +96,180 @@ TransferDialog::~TransferDialog() | |||
96 | 96 | ||
97 | void TransferDialog::slotFilename() | 97 | void TransferDialog::slotFilename() |
98 | { | 98 | { |
99 | QString f; | 99 | QString f; |
100 | 100 | ||
101 | f = 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 | { |
237 | progressbar->setProgress(100); | 237 | progressbar->setProgress(100); |
238 | QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent.")); | 238 | QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent.")); |
239 | ok->setEnabled(true); | 239 | ok->setEnabled(true); |
240 | progressbar->setProgress(0); | 240 | progressbar->setProgress(0); |
241 | statusbar->setText(QObject::tr("Ready")); | 241 | statusbar->setText(QObject::tr("Ready")); |
242 | m_autocleanup = 1; | 242 | m_autocleanup = 1; |
243 | } | 243 | } |
244 | 244 | ||
245 | void TransferDialog::slotReceived(const QString& ) | 245 | void TransferDialog::slotReceived(const QString& ) |
246 | { | 246 | { |
247 | progressbar->setProgress(100); | 247 | progressbar->setProgress(100); |
248 | QMessageBox::information(this, QObject::tr("Received"), QObject::tr("File has been received.")); | 248 | QMessageBox::information(this, QObject::tr("Received"), QObject::tr("File has been received.")); |
249 | //QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file)); | 249 | //QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file)); |
250 | ok->setEnabled(true); | 250 | ok->setEnabled(true); |
251 | progressbar->setProgress(0); | 251 | progressbar->setProgress(0); |
252 | statusbar->setText(QObject::tr("Ready")); | 252 | statusbar->setText(QObject::tr("Ready")); |
253 | m_autocleanup = 1; | 253 | m_autocleanup = 1; |
254 | } | 254 | } |
255 | 255 | ||
256 | void TransferDialog::slotMode(int id) | 256 | void TransferDialog::slotMode(int id) |
257 | { | 257 | { |
258 | if(id == id_send) | 258 | if(id == id_send) |
259 | { | 259 | { |
260 | selector->setEnabled(true); | 260 | selector->setEnabled(true); |
261 | filename->setEnabled(true); | 261 | filename->setEnabled(true); |
262 | } | 262 | } |
263 | else | 263 | else |
264 | { | 264 | { |
265 | selector->setEnabled(false); | 265 | selector->setEnabled(false); |
266 | filename->setEnabled(false); | 266 | filename->setEnabled(false); |
267 | } | 267 | } |
268 | m_transfermode = id; | 268 | m_transfermode = id; |
269 | } | 269 | } |
270 | 270 | ||
271 | bool TransferDialog::isRunning() | 271 | bool TransferDialog::isRunning() |
272 | { | 272 | { |
273 | return m_running; | 273 | return m_running; |
274 | } | 274 | } |
275 | 275 | ||