summaryrefslogtreecommitdiff
path: root/noncore/unsupported/mail2/composer.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/mail2/composer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/mail2/composer.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/noncore/unsupported/mail2/composer.cpp b/noncore/unsupported/mail2/composer.cpp
index 82ed117..7f65dba 100644
--- a/noncore/unsupported/mail2/composer.cpp
+++ b/noncore/unsupported/mail2/composer.cpp
@@ -1,93 +1,119 @@
1#include <qmultilineedit.h> 1#include <qmultilineedit.h>
2#include <qmessagebox.h> 2#include <qmessagebox.h>
3#include <qpopupmenu.h> 3#include <qpopupmenu.h>
4#include <qcombobox.h> 4#include <qcombobox.h>
5#include <qlineedit.h> 5#include <qlineedit.h>
6#include <qaction.h> 6#include <qaction.h>
7#include <qtimer.h> 7#include <qtimer.h>
8#include <qlabel.h> 8#include <qlabel.h>
9#include <qapplication.h>
9 10
10#include <qpe/resource.h> 11#include <qpe/resource.h>
11 12
12#include "addresspicker.h" 13#include "addresspicker.h"
13#include "listviewplus.h" 14#include "listviewplus.h"
14#include "smtphandler.h" 15#include "smtphandler.h"
15#include "attachdiag.h" 16#include "attachdiag.h"
16#include "composer.h" 17#include "composer.h"
17#include "rename.h" 18#include "rename.h"
18 19
19AttachViewItem::AttachViewItem(QListView *parent, Attachment &attachment) 20AttachViewItem::AttachViewItem(QListView *parent, Attachment &attachment)
20 : QListViewItem(parent), _attachment(attachment) 21 : QListViewItem(parent), _attachment(attachment)
21{ 22{
22 setPixmap(0, _attachment.docLnk()->pixmap().isNull() ? Resource::loadPixmap("UnknownDocument-14") : _attachment.docLnk()->pixmap()); 23 setPixmap(0, _attachment.docLnk()->pixmap().isNull() ? Resource::loadPixmap("UnknownDocument-14") : _attachment.docLnk()->pixmap());
23 setText(0, _attachment.newName().isEmpty() ? _attachment.fileName() : _attachment.newName()); 24 setText(0, _attachment.newName().isEmpty() ? _attachment.fileName() : _attachment.newName());
24 setText(1, _attachment.description()); 25 setText(1, _attachment.description());
25} 26}
26 27
27Composer::Composer(QWidget *parent, const char *name, WFlags fl) 28Composer::Composer(QWidget *parent, const char *name, WFlags fl)
28 : ComposerBase(parent, name, fl) 29 : ComposerBase(parent, name, fl), _inLoop(false)
29{ 30{
30 abort->setEnabled(false); 31 abort->setEnabled(false);
31 to->setFocus(); 32 to->setFocus();
32 33
33 connect(sendmail, SIGNAL(activated()), SLOT(slotSendMail())); 34 connect(sendmail, SIGNAL(activated()), SLOT(slotSendMail()));
34 connect(addressbook, SIGNAL(activated()), SLOT(slotOpenAddressPicker())); 35 connect(addressbook, SIGNAL(activated()), SLOT(slotOpenAddressPicker()));
35 connect(addattach, SIGNAL(activated()), SLOT(slotAddAttach())); 36 connect(addattach, SIGNAL(activated()), SLOT(slotAddAttach()));
36 connect(delattach, SIGNAL(activated()), SLOT(slotDelAttach())); 37 connect(delattach, SIGNAL(activated()), SLOT(slotDelAttach()));
37 38
38 connect(from, SIGNAL(activated(int)), SLOT(slotFromChanged(int))); 39 connect(from, SIGNAL(activated(int)), SLOT(slotFromChanged(int)));
39 40
40 connect(attachPopup, SIGNAL(activated(int)), SLOT(slotPopupHandler(int))); 41 connect(attachPopup, SIGNAL(activated(int)), SLOT(slotPopupHandler(int)));
41 42
42 QTimer::singleShot(0, this, SLOT(slotFillStuff())); 43 QTimer::singleShot(0, this, SLOT(slotFillStuff()));
43 QTimer::singleShot(0, this, SLOT(slotResizing())); 44 QTimer::singleShot(0, this, SLOT(slotResizing()));
44} 45}
45 46
47Composer::~Composer()
48{
49 hide();
50}
51
52void Composer::hide()
53{
54 QWidget::hide();
55
56 if (_inLoop) {
57 _inLoop = false;
58 qApp->exit_loop();
59 }
60}
61
62void Composer::exec()
63{
64 show();
65
66 if (!_inLoop) {
67 _inLoop = true;
68 qApp->enter_loop();
69 }
70}
71
46void Composer::setSendMail(SendMail &sendMail) 72void Composer::setSendMail(SendMail &sendMail)
47{ 73{
48 to->setText(sendMail.to()); 74 to->setText(sendMail.to());
49 cc->setText(sendMail.cc()); 75 cc->setText(sendMail.cc());
50 bcc->setText(sendMail.bcc()); 76 bcc->setText(sendMail.bcc());
51 subject->setText(sendMail.subject()); 77 subject->setText(sendMail.subject());
52 message->setText(sendMail.message()); 78 message->setText(sendMail.message());
53 _inReplyTo = sendMail.inReplyTo(); 79 _inReplyTo = sendMail.inReplyTo();
54 80
55 QValueList<Attachment> attachments = sendMail.attachments(); 81 QValueList<Attachment> attachments = sendMail.attachments();
56 QValueList<Attachment>::Iterator it; 82 QValueList<Attachment>::Iterator it;
57 for (it = attachments.begin(); it != attachments.end(); it++) { 83 for (it = attachments.begin(); it != attachments.end(); it++) {
58 (void) new AttachViewItem(attachView, *it); 84 (void) new AttachViewItem(attachView, *it);
59 if (attachView->isHidden()) attachView->show(); 85 if (attachView->isHidden()) attachView->show();
60 } 86 }
61} 87}
62 88
63void Composer::slotResizing() 89void Composer::slotResizing()
64{ 90{
65 from->setMaximumWidth(width() - fromBox->width()); 91 from->setMaximumWidth(width() - fromBox->width());
66 from->resize(width() - fromBox->width(), y()); 92 from->resize(width() - fromBox->width(), y());
67} 93}
68 94
69void Composer::slotPopupHandler(int itemid) 95void Composer::slotPopupHandler(int itemid)
70{ 96{
71 if (attachView->currentItem() == NULL) { 97 if (attachView->currentItem() == NULL) {
72 QMessageBox::information(this, tr("Error"), tr("Please select an entry first."), tr("Ok")); 98 QMessageBox::information(this, tr("Error"), tr("Please select an entry first."), tr("Ok"));
73 return; 99 return;
74 } 100 }
75 101
76 if (itemid == POPUP_ATTACH_RENAME) { 102 if (itemid == POPUP_ATTACH_RENAME) {
77 QString tmp = Rename::rename(attachView->currentItem()->text(0), this); 103 QString tmp = Rename::rename(attachView->currentItem()->text(0), this);
78 if (tmp != QString(0)) attachView->currentItem()->setText(0, tmp); 104 if (tmp != QString(0)) attachView->currentItem()->setText(0, tmp);
79 } else if (itemid == POPUP_ATTACH_DESC) { 105 } else if (itemid == POPUP_ATTACH_DESC) {
80 QString tmp = Rename::getText(tr("Set Description"), tr("<div align=center>Description"), this); 106 QString tmp = Rename::getText(tr("Set Description"), tr("<div align=center>Description"), this);
81 if (tmp != QString(0)) attachView->currentItem()->setText(1, tmp); 107 if (tmp != QString(0)) attachView->currentItem()->setText(1, tmp);
82 } else if (itemid == POPUP_ATTACH_REMOVE) { 108 } else if (itemid == POPUP_ATTACH_REMOVE) {
83 attachView->takeItem(attachView->currentItem()); 109 attachView->takeItem(attachView->currentItem());
84 } 110 }
85} 111}
86 112
87void Composer::slotSendMail() 113void Composer::slotSendMail()
88{ 114{
89 if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) { 115 if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) {
90 QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok")); 116 QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok"));
91 return; 117 return;
92 } 118 }
93 119