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 | |||
@@ -1,389 +1,402 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
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 | ||
39 | void WriteMail::setAddressList(AddressList *list) | 38 | void WriteMail::setAddressList(AddressList *list) |
40 | { | 39 | { |
41 | Contact *cPtr; | 40 | Contact *cPtr; |
42 | 41 | ||
43 | addressList = list; | 42 | addressList = list; |
44 | 43 | ||
45 | addressView->clear(); | 44 | addressView->clear(); |
46 | QList<Contact> *cListPtr = addressList->getContactList(); | 45 | QList<Contact> *cListPtr = addressList->getContactList(); |
47 | QListViewItem *item; | 46 | QListViewItem *item; |
48 | for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) { | 47 | for (cPtr = cListPtr->first(); cPtr != 0; cPtr = cListPtr->next() ) { |
49 | item = new QListViewItem(addressView, cPtr->name, cPtr->email); | 48 | item = new QListViewItem(addressView, cPtr->name, cPtr->email); |
50 | } | 49 | } |
51 | } | 50 | } |
52 | 51 | ||
53 | void WriteMail::init() | 52 | void WriteMail::init() |
54 | { | 53 | { |
55 | setToolBarsMovable(FALSE); | 54 | setToolBarsMovable(FALSE); |
56 | 55 | ||
57 | bar = new QToolBar(this); | 56 | bar = new QToolBar(this); |
58 | bar->setHorizontalStretchable( TRUE ); | 57 | bar->setHorizontalStretchable( TRUE ); |
59 | 58 | ||
60 | menu = new QMenuBar( bar ); | 59 | menu = new QMenuBar( bar ); |
61 | 60 | ||
62 | mailMenu = new QPopupMenu(menu); | 61 | mailMenu = new QPopupMenu(menu); |
63 | menu->insertItem( tr( "&Mail" ), mailMenu); | 62 | menu->insertItem( tr( "&Mail" ), mailMenu); |
64 | addMenu = new QPopupMenu(menu); | 63 | addMenu = new QPopupMenu(menu); |
65 | menu->insertItem( tr( "&Add" ), addMenu); | 64 | menu->insertItem( tr( "&Add" ), addMenu); |
66 | 65 | ||
67 | bar = new QToolBar(this); | 66 | bar = new QToolBar(this); |
68 | attachButton = new QAction(tr("Attachment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0); | 67 | attachButton = new QAction(tr("Attachment"), Resource::loadPixmap("mailit/attach"), QString::null, 0, this, 0); |
69 | attachButton->addTo(bar); | 68 | attachButton->addTo(bar); |
70 | attachButton->addTo(addMenu); | 69 | attachButton->addTo(addMenu); |
71 | connect( attachButton, SIGNAL( activated() ), this, SLOT( attachFile() ) ); | 70 | connect( attachButton, SIGNAL( activated() ), this, SLOT( attachFile() ) ); |
72 | attachButton->setWhatsThis(tr("Click here to attach files to your mail")); | 71 | attachButton->setWhatsThis(tr("Click here to attach files to your mail")); |
73 | 72 | ||
74 | confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); | 73 | confirmButton = new QAction(tr("Enque mail"), Resource::loadPixmap("OKButton"), QString::null, 0, this, 0); |
75 | confirmButton->addTo(bar); | 74 | confirmButton->addTo(bar); |
76 | confirmButton->addTo(mailMenu); | 75 | confirmButton->addTo(mailMenu); |
77 | connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); | 76 | connect( confirmButton, SIGNAL( activated() ), this, SLOT( accept() ) ); |
78 | confirmButton->setWhatsThis(tr("This button puts your mail in the send queue")); | 77 | confirmButton->setWhatsThis(tr("This button puts your mail in the send queue")); |
79 | 78 | ||
80 | newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); | 79 | newButton = new QAction(tr("New mail"), Resource::loadPixmap("new"), QString::null, 0, this, 0); |
81 | newButton->addTo(mailMenu); | 80 | newButton->addTo(mailMenu); |
82 | connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); | 81 | connect( newButton, SIGNAL( activated() ), this, SLOT( newMail() ) ); |
83 | newButton->setWhatsThis(tr("Click here to create a new mail")); | 82 | newButton->setWhatsThis(tr("Click here to create a new mail")); |
84 | 83 | ||
85 | widget = new QWidget(this, "widget"); | 84 | widget = new QWidget(this, "widget"); |
86 | grid = new QGridLayout( widget ); | 85 | grid = new QGridLayout( widget ); |
87 | 86 | ||
88 | recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); | 87 | recipientsBox = new QComboBox( FALSE, widget, "toLabel" ); |
89 | recipientsBox->insertItem( tr( "To:" ) ); | 88 | recipientsBox->insertItem( tr( "To:" ) ); |
90 | recipientsBox->insertItem( tr( "CC:" ) ); | 89 | recipientsBox->insertItem( tr( "CC:" ) ); |
91 | recipientsBox->setCurrentItem(0); | 90 | recipientsBox->setCurrentItem(0); |
92 | grid->addWidget( recipientsBox, 0, 0 ); | 91 | grid->addWidget( recipientsBox, 0, 0 ); |
93 | connect(recipientsBox,SIGNAL(activated(int)),this, SLOT(changeRecipients(int))); | 92 | connect(recipientsBox,SIGNAL(activated(int)),this, SLOT(changeRecipients(int))); |
94 | 93 | ||
95 | subjetLabel = new QLabel( widget, "subjetLabel" ); | 94 | subjetLabel = new QLabel( widget, "subjetLabel" ); |
96 | subjetLabel->setText( tr( "Subject:" ) ); | 95 | subjetLabel->setText( tr( "Subject:" ) ); |
97 | 96 | ||
98 | grid->addWidget( subjetLabel, 1, 0 ); | 97 | grid->addWidget( subjetLabel, 1, 0 ); |
99 | 98 | ||
100 | ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); | 99 | ToolButton13_2 = new QToolButton( widget, "ToolButton13_2" ); |
101 | ToolButton13_2->setText( tr( "..." ) ); | 100 | ToolButton13_2->setText( tr( "..." ) ); |
102 | grid->addWidget( ToolButton13_2, 1, 2 ); | 101 | grid->addWidget( ToolButton13_2, 1, 2 ); |
103 | 102 | ||
104 | subjectInput = new QLineEdit( widget, "subjectInput" ); | 103 | subjectInput = new QLineEdit( widget, "subjectInput" ); |
105 | grid->addWidget( subjectInput, 1, 1 ); | 104 | grid->addWidget( subjectInput, 1, 1 ); |
106 | QWhatsThis::add(subjectInput,QWidget::tr("The mail subject should be entered here")); | 105 | QWhatsThis::add(subjectInput,QWidget::tr("The mail subject should be entered here")); |
107 | 106 | ||
108 | toInput = new QLineEdit( widget, "toInput" ); | 107 | toInput = new QLineEdit( widget, "toInput" ); |
109 | grid->addWidget( toInput, 0, 1 ); | 108 | grid->addWidget( toInput, 0, 1 ); |
110 | QWhatsThis::add(recipientsBox,QWidget::tr("Recipients can be entered here")); | 109 | QWhatsThis::add(recipientsBox,QWidget::tr("Recipients can be entered here")); |
111 | 110 | ||
112 | ccInput = new QLineEdit( widget, "ccInput" ); | 111 | ccInput = new QLineEdit( widget, "ccInput" ); |
113 | ccInput->hide(); | 112 | ccInput->hide(); |
114 | grid->addWidget( ccInput, 0, 1 ); | 113 | grid->addWidget( ccInput, 0, 1 ); |
115 | QWhatsThis::add(ccInput,QWidget::tr("If you would like to send copies of your mail they can be entered here")); | 114 | QWhatsThis::add(ccInput,QWidget::tr("If you would like to send copies of your mail they can be entered here")); |
116 | 115 | ||
117 | addressButton = new QToolButton( widget, "addressButton" ); | 116 | addressButton = new QToolButton( widget, "addressButton" ); |
118 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); | 117 | addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); |
119 | addressButton->setToggleButton(TRUE); | 118 | addressButton->setToggleButton(TRUE); |
120 | grid->addWidget( addressButton, 0, 2 ); | 119 | grid->addWidget( addressButton, 0, 2 ); |
121 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); | 120 | connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); |
122 | QWhatsThis::add(addressButton,QWidget::tr("This button opens the address selector with all mail adresses from your OPIE addressbook")); | 121 | QWhatsThis::add(addressButton,QWidget::tr("This button opens the address selector with all mail adresses from your OPIE addressbook")); |
123 | 122 | ||
124 | emailInput = new QMultiLineEdit( widget, "emailInput" ); | 123 | emailInput = new QMultiLineEdit( widget, "emailInput" ); |
125 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); | 124 | grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); |
126 | QWhatsThis::add(emailInput,QWidget::tr("Enter your mail text here")); | 125 | QWhatsThis::add(emailInput,QWidget::tr("Enter your mail text here")); |
127 | 126 | ||
128 | addressView = new QListView( widget, "addressView"); | 127 | addressView = new QListView( widget, "addressView"); |
129 | addressView->addColumn("Name"); | 128 | addressView->addColumn("Name"); |
130 | addressView->addColumn("EMail"); | 129 | addressView->addColumn("EMail"); |
131 | addressView->setAllColumnsShowFocus(TRUE); | 130 | addressView->setAllColumnsShowFocus(TRUE); |
132 | addressView->setMultiSelection(TRUE); | 131 | addressView->setMultiSelection(TRUE); |
133 | addressView->hide(); | 132 | addressView->hide(); |
134 | grid->addMultiCellWidget( addressView, 3, 3, 0, 2); | 133 | grid->addMultiCellWidget( addressView, 3, 3, 0, 2); |
135 | QWhatsThis::add(recipientsBox,QWidget::tr("Choose the recipients from this list")); | 134 | QWhatsThis::add(recipientsBox,QWidget::tr("Choose the recipients from this list")); |
136 | 135 | ||
137 | okButton = new QToolButton(bar, "ok"); | 136 | okButton = new QToolButton(bar, "ok"); |
138 | okButton->setPixmap( Resource::loadPixmap("enter") ); | 137 | okButton->setPixmap( Resource::loadPixmap("enter") ); |
139 | okButton->hide(); | 138 | okButton->hide(); |
140 | connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); | 139 | connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); |
141 | QWhatsThis::add(okButton,QWidget::tr("Queue your mail by clicking here")); | 140 | QWhatsThis::add(okButton,QWidget::tr("Queue your mail by clicking here")); |
142 | 141 | ||
143 | setCentralWidget(widget); | 142 | setCentralWidget(widget); |
144 | } | 143 | } |
145 | 144 | ||
146 | void WriteMail::reject() | 145 | void WriteMail::reject() |
147 | { | 146 | { |
148 | emit cancelMail(); | 147 | emit cancelMail(); |
149 | } | 148 | } |
150 | 149 | ||
151 | void WriteMail::accept() | 150 | void WriteMail::accept() |
152 | { | 151 | { |
153 | QStringList attachedFiles, attachmentsType; | 152 | QStringList attachedFiles, attachmentsType; |
154 | int idCount = 0; | 153 | int idCount = 0; |
155 | 154 | ||
156 | if (toInput->text() == "") | 155 | if (toInput->text() == "") |
157 | { | 156 | { |
158 | QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n")); | 157 | QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n")); |
159 | return; | 158 | return; |
160 | } | 159 | } |
161 | 160 | ||
162 | if (! getRecipients(false) ) | 161 | if (! getRecipients(false) ) |
163 | { | 162 | { |
164 | QMessageBox::warning(this,tr("Incorrect recipient separator"), | 163 | QMessageBox::warning(this,tr("Incorrect recipient separator"), |
165 | tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); | 164 | tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); |
166 | return; | 165 | return; |
167 | } | 166 | } |
168 | 167 | ||
169 | if ((ccInput->text()!="") && (! getRecipients(true) )) | 168 | if ((ccInput->text()!="") && (! getRecipients(true) )) |
170 | { | 169 | { |
171 | QMessageBox::warning(this,tr("Incorrect carbon copy separator"), | 170 | QMessageBox::warning(this,tr("Incorrect carbon copy separator"), |
172 | tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); | 171 | tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); |
173 | return; | 172 | return; |
174 | } | 173 | } |
175 | 174 | ||
176 | mail.subject = subjectInput->text(); | 175 | mail.subject = subjectInput->text(); |
177 | mail.body = emailInput->text(); | 176 | mail.body = emailInput->text(); |
178 | mail.sent = false; | 177 | mail.sent = false; |
179 | mail.received = false; | 178 | mail.received = false; |
180 | 179 | ||
181 | mail.rawMail = "To: "; | 180 | mail.rawMail = "To: "; |
182 | 181 | ||
183 | for (QStringList::Iterator it = mail.recipients.begin(); | 182 | for (QStringList::Iterator it = mail.recipients.begin(); |
184 | it != mail.recipients.end(); ++it) { | 183 | it != mail.recipients.end(); ++it) { |
185 | 184 | ||
186 | mail.rawMail += (*it); | 185 | mail.rawMail += (*it); |
187 | mail.rawMail += ",\n"; | 186 | mail.rawMail += ",\n"; |
188 | } | 187 | } |
189 | 188 | ||
190 | mail.rawMail.truncate(mail.rawMail.length()-2); | 189 | mail.rawMail.truncate(mail.rawMail.length()-2); |
191 | 190 | ||
192 | mail.rawMail += "\nCC: "; | 191 | mail.rawMail += "\nCC: "; |
193 | 192 | ||
194 | for (QStringList::Iterator it = mail.carbonCopies.begin(); | 193 | for (QStringList::Iterator it = mail.carbonCopies.begin(); |
195 | it != mail.carbonCopies.end(); ++it) { | 194 | it != mail.carbonCopies.end(); ++it) { |
196 | 195 | ||
197 | mail.rawMail += (*it); | 196 | mail.rawMail += (*it); |
198 | mail.rawMail += ",\n"; | 197 | mail.rawMail += ",\n"; |
199 | } | 198 | } |
200 | 199 | ||
201 | mail.rawMail += mail.from; | 200 | mail.rawMail += mail.from; |
202 | mail.rawMail += "\nSubject: "; | 201 | mail.rawMail += "\nSubject: "; |
203 | mail.rawMail += mail.subject; | 202 | mail.rawMail += mail.subject; |
204 | mail.rawMail += "\n\n"; | 203 | mail.rawMail += "\n\n"; |
205 | 204 | ||
206 | attachedFiles = addAtt->returnattachedFiles(); | 205 | attachedFiles = addAtt->returnattachedFiles(); |
207 | attachmentsType = addAtt->returnFileTypes(); | 206 | attachmentsType = addAtt->returnFileTypes(); |
208 | 207 | ||
209 | QStringList::Iterator itType = attachmentsType.begin(); | 208 | QStringList::Iterator itType = attachmentsType.begin(); |
210 | 209 | ||
211 | Enclosure e; | 210 | Enclosure e; |
212 | for ( QStringList::Iterator it = attachedFiles.begin(); it != attachedFiles.end(); ++it ) { | 211 | for ( QStringList::Iterator it = attachedFiles.begin(); it != attachedFiles.end(); ++it ) { |
213 | e.id = idCount; | 212 | e.id = idCount; |
214 | e.originalName = (*it).latin1(); | 213 | e.originalName = (*it).latin1(); |
215 | e.contentType = (*itType).latin1(); | 214 | e.contentType = (*itType).latin1(); |
216 | e.contentAttribute = (*itType).latin1(); | 215 | e.contentAttribute = (*itType).latin1(); |
217 | e.saved = TRUE; | 216 | e.saved = TRUE; |
218 | mail.addEnclosure(&e); | 217 | mail.addEnclosure(&e); |
219 | 218 | ||
220 | itType++; | 219 | itType++; |
221 | idCount++; | 220 | idCount++; |
222 | } | 221 | } |
223 | mail.rawMail += mail.body; | 222 | mail.rawMail += mail.body; |
224 | mail.rawMail += "\n"; | 223 | mail.rawMail += "\n"; |
225 | mail.rawMail += ".\n"; | 224 | mail.rawMail += ".\n"; |
226 | emit sendMailRequested(mail); | 225 | emit sendMailRequested(mail); |
227 | addAtt->clear(); | 226 | addAtt->clear(); |
228 | } | 227 | } |
229 | 228 | ||
230 | void WriteMail::getAddress() | 229 | void WriteMail::getAddress() |
231 | { | 230 | { |
232 | showingAddressList = !showingAddressList; | 231 | showingAddressList = !showingAddressList; |
233 | 232 | ||
234 | if (showingAddressList) { | 233 | if (showingAddressList) { |
235 | emailInput->hide(); | 234 | emailInput->hide(); |
236 | addressView->show(); | 235 | addressView->show(); |
237 | okButton->show(); | 236 | okButton->show(); |
238 | 237 | ||
239 | } else { | 238 | } else { |
240 | addressView->hide(); | 239 | addressView->hide(); |
241 | okButton->hide(); | 240 | okButton->hide(); |
242 | emailInput->show(); | 241 | emailInput->show(); |
243 | } | 242 | } |
244 | } | 243 | } |
245 | 244 | ||
246 | void WriteMail::attachFile() | 245 | void WriteMail::attachFile() |
247 | { | 246 | { |
248 | addAtt->showMaximized(); | 247 | addAtt->showMaximized(); |
249 | } | 248 | } |
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; |
296 | toInput->setText(""); | 301 | toInput->setText(""); |
297 | ccInput->setText(""); | 302 | ccInput->setText(""); |
298 | subjectInput->setText(tr("FWD: ") + mail.subject); | 303 | subjectInput->setText(tr("FWD: ") + mail.subject); |
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 = ""; |
340 | 352 | ||
341 | mail.recipients.clear(); | 353 | mail.recipients.clear(); |
342 | 354 | ||
343 | QListViewItem *item = addressView->firstChild(); | 355 | QListViewItem *item = addressView->firstChild(); |
344 | while (item != NULL) { | 356 | while (item != NULL) { |
345 | if ( item->isSelected() ) { | 357 | if ( item->isSelected() ) { |
346 | if (recipients == "") { | 358 | if (recipients == "") { |
347 | recipients = item->text(1); | 359 | recipients = item->text(1); |
348 | } else { | 360 | } else { |
349 | recipients += "; " + item->text(1); | 361 | recipients += "; " + item->text(1); |
350 | } | 362 | } |
351 | } | 363 | } |
352 | item = item->nextSibling(); | 364 | item = item->nextSibling(); |
353 | } | 365 | } |
354 | 366 | ||
355 | ccField ? ccInput->setText(recipients):toInput->setText(recipients); | 367 | ccField ? ccInput->setText(recipients):toInput->setText(recipients); |
356 | 368 | ||
357 | addressView->hide(); | 369 | addressView->hide(); |
358 | okButton->hide(); | 370 | okButton->hide(); |
359 | emailInput->show(); | 371 | emailInput->show(); |
360 | addressButton->setOn(FALSE); | 372 | addressButton->setOn(FALSE); |
361 | showingAddressList = !showingAddressList; | 373 | showingAddressList = !showingAddressList; |
362 | } | 374 | } |
363 | 375 | ||
364 | void WriteMail::changeRecipients(int selection) | 376 | void WriteMail::changeRecipients(int selection) |
365 | { | 377 | { |
366 | if (selection==0) | 378 | if (selection==0) |
367 | { | 379 | { |
368 | toInput->show(); | 380 | toInput->show(); |
369 | ccInput->hide(); | 381 | ccInput->hide(); |
370 | } | 382 | } |
371 | else if (selection==1) | 383 | else if (selection==1) |
372 | { | 384 | { |
373 | toInput->hide(); | 385 | toInput->hide(); |
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 | } |