Diffstat (limited to 'noncore/unsupported/mailit/writemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/mailit/writemail.cpp | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/noncore/unsupported/mailit/writemail.cpp b/noncore/unsupported/mailit/writemail.cpp index dcf0c6e..c75494e 100644 --- a/noncore/unsupported/mailit/writemail.cpp +++ b/noncore/unsupported/mailit/writemail.cpp | |||
@@ -13,26 +13,25 @@ | |||
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | #include <qwhatsthis.h> | 21 | #include <qwhatsthis.h> |
22 | #include "writemail.h" | 22 | #include "writemail.h" |
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | 24 | ||
25 | WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl ) | 25 | WriteMail::WriteMail( QWidget* parent, const char* name, WFlags fl ):QMainWindow( parent, name, fl ) |
26 | : QMainWindow( parent, name, fl ) | ||
27 | { | 26 | { |
28 | showingAddressList = FALSE; | 27 | showingAddressList = FALSE; |
29 | init(); | 28 | init(); |
30 | 29 | ||
31 | addAtt = new AddAtt(0, "Add Attachments"); | 30 | addAtt = new AddAtt(0, "Add Attachments"); |
32 | } | 31 | } |
33 | 32 | ||
34 | WriteMail::~WriteMail() | 33 | WriteMail::~WriteMail() |
35 | { | 34 | { |
36 | delete addAtt; | 35 | delete addAtt; |
37 | } | 36 | } |
38 | 37 | ||
@@ -250,46 +249,52 @@ void WriteMail::attachFile() | |||
250 | 249 | ||
251 | void WriteMail::reply(Email replyMail, bool replyAll) | 250 | void WriteMail::reply(Email replyMail, bool replyAll) |
252 | { | 251 | { |
253 | int pos; | 252 | int pos; |
254 | QString ccRecipients; | 253 | QString ccRecipients; |
255 | 254 | ||
256 | mail = replyMail; | 255 | mail = replyMail; |
257 | mail.files.clear(); | 256 | mail.files.clear(); |
258 | 257 | ||
259 | toInput->setText(mail.fromMail); | 258 | toInput->setText(mail.fromMail); |
260 | 259 | ||
261 | if (replyAll) | 260 | if (replyAll) |
262 | { | 261 | { |
263 | for (QStringList::Iterator it = mail.carbonCopies.begin();it != mail.carbonCopies.end(); ++it) | 262 | for (QStringList::Iterator it = mail.carbonCopies.begin();it != mail.carbonCopies.end(); ++it) |
264 | { | 263 | { |
265 | ccRecipients.append(*it); | 264 | ccRecipients.append(*it); |
266 | ccRecipients.append(";"); | 265 | ccRecipients.append(";"); |
267 | } | 266 | } |
268 | ccRecipients.truncate(ccRecipients.length()-1); //no ; at the end | 267 | ccRecipients.truncate(ccRecipients.length()-1); //no ; at the end |
269 | ccInput->setText(ccRecipients); | 268 | ccInput->setText(ccRecipients); |
270 | } | 269 | } |
271 | 270 | else ccInput->clear(); | |
272 | addRecipients(replyAll); | ||
273 | 271 | ||
274 | subjectInput->setText(tr("Re: ") + mail.subject); | 272 | subjectInput->setText(tr("Re: ") + mail.subject); |
275 | 273 | ||
274 | QString citation=mail.fromMail; | ||
275 | citation.append(tr(" wrote on ")); | ||
276 | citation.append(mail.date); | ||
277 | citation.append(":\n"); | ||
278 | |||
279 | |||
280 | //mail.body.insert(0,tr("On")); | ||
276 | pos = 0; | 281 | pos = 0; |
277 | mail.body.insert(pos, ">"); | 282 | mail.body.insert(pos, ">"); |
278 | while (pos != -1) { | 283 | while (pos != -1) { |
279 | pos = mail.body.find('\n', pos); | 284 | pos = mail.body.find('\n', pos); |
280 | if (pos != -1) | 285 | if (pos != -1) |
281 | mail.body.insert(++pos, ">>"); | 286 | mail.body.insert(++pos, ">>"); |
282 | } | 287 | } |
283 | 288 | mail.body.insert(0,citation); | |
284 | emailInput->setText(mail.body); | 289 | emailInput->setText(mail.body); |
285 | } | 290 | } |
286 | 291 | ||
287 | void WriteMail::forward(Email forwMail) | 292 | void WriteMail::forward(Email forwMail) |
288 | { | 293 | { |
289 | int pos=0; | 294 | int pos=0; |
290 | 295 | ||
291 | QString fwdBody=tr("======forwarded message from "); | 296 | QString fwdBody=tr("======forwarded message from "); |
292 | fwdBody.append(forwMail.fromMail); | 297 | fwdBody.append(forwMail.fromMail); |
293 | fwdBody.append(tr(" starts======\n\n")); | 298 | fwdBody.append(tr(" starts======\n\n")); |
294 | 299 | ||
295 | mail=forwMail; | 300 | mail=forwMail; |
@@ -299,41 +304,48 @@ void WriteMail::forward(Email forwMail) | |||
299 | 304 | ||
300 | fwdBody+=mail.body; | 305 | fwdBody+=mail.body; |
301 | fwdBody+=QString(tr("======end of forwarded message======\n\n")); | 306 | fwdBody+=QString(tr("======end of forwarded message======\n\n")); |
302 | 307 | ||
303 | emailInput->setText(fwdBody); | 308 | emailInput->setText(fwdBody); |
304 | } | 309 | } |
305 | 310 | ||
306 | bool WriteMail::getRecipients(bool ccField) | 311 | bool WriteMail::getRecipients(bool ccField) |
307 | { | 312 | { |
308 | QString str, temp; | 313 | QString str, temp; |
309 | int pos = 0; | 314 | int pos = 0; |
310 | 315 | ||
311 | mail.recipients.clear(); | 316 | if (ccField) |
312 | 317 | { | |
313 | ccField ? temp = ccInput->text() : temp=toInput->text() ; | 318 | mail.carbonCopies.clear(); |
319 | temp = ccInput->text(); | ||
320 | } | ||
321 | else | ||
322 | { | ||
323 | mail.recipients.clear(); | ||
324 | temp=toInput->text() ; | ||
325 | } | ||
314 | 326 | ||
315 | while ( (pos = temp.find(';')) != -1) { | 327 | while ( (pos = temp.find(';')) != -1) { |
316 | str = temp.left(pos).stripWhiteSpace(); | 328 | str = temp.left(pos).stripWhiteSpace(); |
317 | temp = temp.right(temp.length() - (pos + 1)); | 329 | temp = temp.right(temp.length() - (pos + 1)); |
318 | if ( str.find('@') == -1) | 330 | if ( str.find('@') == -1) |
319 | return false; | 331 | return false; |
320 | ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str); | 332 | ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str); |
321 | addressList->addContact(str, ""); | 333 | //addressList->addContact(str, ""); |
322 | } | 334 | } |
323 | temp = temp.stripWhiteSpace(); | 335 | temp = temp.stripWhiteSpace(); |
324 | if ( temp.find('@') == -1) | 336 | if ( temp.find('@') == -1) |
325 | return false; | 337 | return false; |
326 | ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp); | 338 | ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp); |
327 | addressList->addContact(temp, ""); | 339 | //addressList->addContact(temp, ""); |
328 | 340 | ||
329 | return TRUE; | 341 | return TRUE; |
330 | } | 342 | } |
331 | 343 | ||
332 | void WriteMail::addRecipients() | 344 | void WriteMail::addRecipients() |
333 | { | 345 | { |
334 | toInput->isVisible() ? addRecipients(false) : addRecipients(true); | 346 | toInput->isVisible() ? addRecipients(false) : addRecipients(true); |
335 | } | 347 | } |
336 | 348 | ||
337 | void WriteMail::addRecipients(bool ccField) | 349 | void WriteMail::addRecipients(bool ccField) |
338 | { | 350 | { |
339 | QString recipients = ""; | 351 | QString recipients = ""; |
@@ -374,16 +386,17 @@ void WriteMail::changeRecipients(int selection) | |||
374 | ccInput->show(); | 386 | ccInput->show(); |
375 | } | 387 | } |
376 | } | 388 | } |
377 | 389 | ||
378 | void WriteMail::setRecipient(const QString &recipient) | 390 | void WriteMail::setRecipient(const QString &recipient) |
379 | { | 391 | { |
380 | toInput->setText(recipient); | 392 | toInput->setText(recipient); |
381 | } | 393 | } |
382 | 394 | ||
383 | void WriteMail::newMail() | 395 | void WriteMail::newMail() |
384 | { | 396 | { |
385 | toInput->clear(); | 397 | toInput->clear(); |
398 | ccInput->clear(); | ||
386 | subjectInput->clear(); | 399 | subjectInput->clear(); |
387 | emailInput->clear(); | 400 | emailInput->clear(); |
388 | setAddressList(addressList); | 401 | setAddressList(addressList); |
389 | } | 402 | } |