summaryrefslogtreecommitdiff
path: root/noncore/net/mailit/writemail.cpp
Unidiff
Diffstat (limited to 'noncore/net/mailit/writemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mailit/writemail.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/noncore/net/mailit/writemail.cpp b/noncore/net/mailit/writemail.cpp
index 0336c83..dcf0c6e 100644
--- a/noncore/net/mailit/writemail.cpp
+++ b/noncore/net/mailit/writemail.cpp
@@ -102,74 +102,73 @@ void WriteMail::init()
102 grid->addWidget( ToolButton13_2, 1, 2 ); 102 grid->addWidget( ToolButton13_2, 1, 2 );
103 103
104 subjectInput = new QLineEdit( widget, "subjectInput" ); 104 subjectInput = new QLineEdit( widget, "subjectInput" );
105 grid->addWidget( subjectInput, 1, 1 ); 105 grid->addWidget( subjectInput, 1, 1 );
106 QWhatsThis::add(subjectInput,QWidget::tr("The mail subject should be entered here")); 106 QWhatsThis::add(subjectInput,QWidget::tr("The mail subject should be entered here"));
107 107
108 toInput = new QLineEdit( widget, "toInput" ); 108 toInput = new QLineEdit( widget, "toInput" );
109 grid->addWidget( toInput, 0, 1 ); 109 grid->addWidget( toInput, 0, 1 );
110 QWhatsThis::add(recipientsBox,QWidget::tr("Recipients can be entered here")); 110 QWhatsThis::add(recipientsBox,QWidget::tr("Recipients can be entered here"));
111 111
112 ccInput = new QLineEdit( widget, "ccInput" ); 112 ccInput = new QLineEdit( widget, "ccInput" );
113 ccInput->hide(); 113 ccInput->hide();
114 grid->addWidget( ccInput, 0, 1 ); 114 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")); 115 QWhatsThis::add(ccInput,QWidget::tr("If you would like to send copies of your mail they can be entered here"));
116 116
117 addressButton = new QToolButton( widget, "addressButton" ); 117 addressButton = new QToolButton( widget, "addressButton" );
118 addressButton->setPixmap( Resource::loadPixmap("AddressBook") ); 118 addressButton->setPixmap( Resource::loadPixmap("AddressBook") );
119 addressButton->setToggleButton(TRUE); 119 addressButton->setToggleButton(TRUE);
120 grid->addWidget( addressButton, 0, 2 ); 120 grid->addWidget( addressButton, 0, 2 );
121 connect(addressButton, SIGNAL(clicked()), this, SLOT(getAddress()) ); 121 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")); 122 QWhatsThis::add(addressButton,QWidget::tr("This button opens the address selector with all mail adresses from your OPIE addressbook"));
123 123
124 emailInput = new QMultiLineEdit( widget, "emailInput" ); 124 emailInput = new QMultiLineEdit( widget, "emailInput" );
125 grid->addMultiCellWidget( emailInput, 2, 2, 0, 2); 125 grid->addMultiCellWidget( emailInput, 2, 2, 0, 2);
126 QWhatsThis::add(recipientsBox,QWidget::tr("Enter your mail text here")); 126 QWhatsThis::add(emailInput,QWidget::tr("Enter your mail text here"));
127 127
128 addressView = new QListView( widget, "addressView"); 128 addressView = new QListView( widget, "addressView");
129 addressView->addColumn("Name"); 129 addressView->addColumn("Name");
130 addressView->addColumn("EMail"); 130 addressView->addColumn("EMail");
131 addressView->setAllColumnsShowFocus(TRUE); 131 addressView->setAllColumnsShowFocus(TRUE);
132 addressView->setMultiSelection(TRUE); 132 addressView->setMultiSelection(TRUE);
133 addressView->hide(); 133 addressView->hide();
134 grid->addMultiCellWidget( addressView, 3, 3, 0, 2); 134 grid->addMultiCellWidget( addressView, 3, 3, 0, 2);
135 QWhatsThis::add(recipientsBox,QWidget::tr("Chose the recipients from this list")); 135 QWhatsThis::add(recipientsBox,QWidget::tr("Choose the recipients from this list"));
136 136
137 okButton = new QToolButton(bar, "ok"); 137 okButton = new QToolButton(bar, "ok");
138 okButton->setPixmap( Resource::loadPixmap("enter") ); 138 okButton->setPixmap( Resource::loadPixmap("enter") );
139 okButton->hide(); 139 okButton->hide();
140 connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) ); 140 connect(okButton, SIGNAL(clicked()), this, SLOT(addRecipients()) );
141 QWhatsThis::add(okButton,QWidget::tr("Queue your mail by clicking here")); 141 QWhatsThis::add(okButton,QWidget::tr("Queue your mail by clicking here"));
142 142
143 setCentralWidget(widget); 143 setCentralWidget(widget);
144} 144}
145 145
146void WriteMail::reject() 146void WriteMail::reject()
147{ 147{
148 emit cancelMail(); 148 emit cancelMail();
149} 149}
150 150
151// need to insert date
152void WriteMail::accept() 151void WriteMail::accept()
153{ 152{
154 QStringList attachedFiles, attachmentsType; 153 QStringList attachedFiles, attachmentsType;
155 int idCount = 0; 154 int idCount = 0;
156 155
157 if (toInput->text() == "") 156 if (toInput->text() == "")
158 { 157 {
159 QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n")); 158 QMessageBox::warning(this,tr("No recipient"), tr("Send mail to whom?"), tr("OK\n"));
160 return; 159 return;
161 } 160 }
162 161
163 if (! getRecipients(false) ) 162 if (! getRecipients(false) )
164 { 163 {
165 QMessageBox::warning(this,tr("Incorrect recipient separator"), 164 QMessageBox::warning(this,tr("Incorrect recipient separator"),
166 tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); 165 tr("Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n"));
167 return; 166 return;
168 } 167 }
169 168
170 if ((ccInput->text()!="") && (! getRecipients(true) )) 169 if ((ccInput->text()!="") && (! getRecipients(true) ))
171 { 170 {
172 QMessageBox::warning(this,tr("Incorrect carbon copy separator"), 171 QMessageBox::warning(this,tr("Incorrect carbon copy separator"),
173 tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n")); 172 tr("CC Recipients must be separated by ;\nand be valid emailaddresses"), tr("OK\n"));
174 return; 173 return;
175 } 174 }
@@ -231,55 +230,66 @@ void WriteMail::accept()
231void WriteMail::getAddress() 230void WriteMail::getAddress()
232{ 231{
233 showingAddressList = !showingAddressList; 232 showingAddressList = !showingAddressList;
234 233
235 if (showingAddressList) { 234 if (showingAddressList) {
236 emailInput->hide(); 235 emailInput->hide();
237 addressView->show(); 236 addressView->show();
238 okButton->show(); 237 okButton->show();
239 238
240 } else { 239 } else {
241 addressView->hide(); 240 addressView->hide();
242 okButton->hide(); 241 okButton->hide();
243 emailInput->show(); 242 emailInput->show();
244 } 243 }
245} 244}
246 245
247void WriteMail::attachFile() 246void WriteMail::attachFile()
248{ 247{
249 addAtt->showMaximized(); 248 addAtt->showMaximized();
250} 249}
251 250
252void WriteMail::reply(Email replyMail, bool replyAll) 251void WriteMail::reply(Email replyMail, bool replyAll)
253{ 252{
254 int pos; 253 int pos;
254 QString ccRecipients;
255 255
256 mail = replyMail; 256 mail = replyMail;
257 mail.files.clear(); 257 mail.files.clear();
258 258
259 toInput->setText(mail.fromMail); 259 toInput->setText(mail.fromMail);
260 //replyAll ? ccInput->setText(mail.c)
261 260
261 if (replyAll)
262 {
263 for (QStringList::Iterator it = mail.carbonCopies.begin();it != mail.carbonCopies.end(); ++it)
264 {
265 ccRecipients.append(*it);
266 ccRecipients.append(";");
267 }
268 ccRecipients.truncate(ccRecipients.length()-1); //no ; at the end
269 ccInput->setText(ccRecipients);
270 }
271
262 addRecipients(replyAll); 272 addRecipients(replyAll);
263 273
264 subjectInput->setText(tr("Re: ") + mail.subject); 274 subjectInput->setText(tr("Re: ") + mail.subject);
265 275
266 pos = 0; 276 pos = 0;
267 mail.body.insert(pos, ">"); 277 mail.body.insert(pos, ">");
268 while (pos != -1) { 278 while (pos != -1) {
269 pos = mail.body.find('\n', pos); 279 pos = mail.body.find('\n', pos);
270 if (pos != -1) 280 if (pos != -1)
271 mail.body.insert(++pos, ">>"); 281 mail.body.insert(++pos, ">>");
272 } 282 }
273 283
274 emailInput->setText(mail.body); 284 emailInput->setText(mail.body);
275} 285}
276 286
277void WriteMail::forward(Email forwMail) 287void WriteMail::forward(Email forwMail)
278{ 288{
279 int pos=0; 289 int pos=0;
280 290
281 QString fwdBody=tr("======forwarded message from "); 291 QString fwdBody=tr("======forwarded message from ");
282 fwdBody.append(forwMail.fromMail); 292 fwdBody.append(forwMail.fromMail);
283 fwdBody.append(tr(" starts======\n\n")); 293 fwdBody.append(tr(" starts======\n\n"));
284 294
285 mail=forwMail; 295 mail=forwMail;
@@ -300,82 +310,80 @@ bool WriteMail::getRecipients(bool ccField)
300 310
301 mail.recipients.clear(); 311 mail.recipients.clear();
302 312
303 ccField ? temp = ccInput->text() : temp=toInput->text() ; 313 ccField ? temp = ccInput->text() : temp=toInput->text() ;
304 314
305 while ( (pos = temp.find(';')) != -1) { 315 while ( (pos = temp.find(';')) != -1) {
306 str = temp.left(pos).stripWhiteSpace(); 316 str = temp.left(pos).stripWhiteSpace();
307 temp = temp.right(temp.length() - (pos + 1)); 317 temp = temp.right(temp.length() - (pos + 1));
308 if ( str.find('@') == -1) 318 if ( str.find('@') == -1)
309 return false; 319 return false;
310 ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str); 320 ccField ? mail.carbonCopies.append(str) : mail.recipients.append(str);
311 addressList->addContact(str, ""); 321 addressList->addContact(str, "");
312 } 322 }
313 temp = temp.stripWhiteSpace(); 323 temp = temp.stripWhiteSpace();
314 if ( temp.find('@') == -1) 324 if ( temp.find('@') == -1)
315 return false; 325 return false;
316 ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp); 326 ccField ? mail.carbonCopies.append(temp) : mail.recipients.append(temp);
317 addressList->addContact(temp, ""); 327 addressList->addContact(temp, "");
318 328
319 return TRUE; 329 return TRUE;
320} 330}
321 331
322void WriteMail::addRecipients() 332void WriteMail::addRecipients()
323{ 333{
324 334 toInput->isVisible() ? addRecipients(false) : addRecipients(true);
325 addRecipients(false);
326 } 335 }
327 336
328void WriteMail::addRecipients(bool ccField) 337void WriteMail::addRecipients(bool ccField)
329{ 338{
330 QString recipients = ""; 339 QString recipients = "";
331 340
332 mail.recipients.clear(); 341 mail.recipients.clear();
333 342
334 QListViewItem *item = addressView->firstChild(); 343 QListViewItem *item = addressView->firstChild();
335 while (item != NULL) { 344 while (item != NULL) {
336 if ( item->isSelected() ) { 345 if ( item->isSelected() ) {
337 if (recipients == "") { 346 if (recipients == "") {
338 recipients = item->text(0); 347 recipients = item->text(1);
339 } else { 348 } else {
340 recipients += "; " + item->text(0); 349 recipients += "; " + item->text(1);
341 } 350 }
342 } 351 }
343 item = item->nextSibling(); 352 item = item->nextSibling();
344 } 353 }
345 354
346 ccField ? ccInput->setText(recipients):toInput->setText(recipients); 355 ccField ? ccInput->setText(recipients):toInput->setText(recipients);
347 356
348 addressView->hide(); 357 addressView->hide();
349 okButton->hide(); 358 okButton->hide();
350 emailInput->show(); 359 emailInput->show();
351 addressButton->setOn(FALSE); 360 addressButton->setOn(FALSE);
352 showingAddressList = !showingAddressList; 361 showingAddressList = !showingAddressList;
353} 362}
354 363
355void WriteMail::changeRecipients(int selection) 364void WriteMail::changeRecipients(int selection)
356{ 365{
357 if (selection==0) 366 if (selection==0)
358 { 367 {
359 toInput->show(); 368 toInput->show();
360 ccInput->hide(); 369 ccInput->hide();
361 } 370 }
362 else if (selection==1) 371 else if (selection==1)
363 { 372 {
364 toInput->hide(); 373 toInput->hide();
365 ccInput->show(); 374 ccInput->show();
366 } 375 }
367} 376}
368 377
369void WriteMail::setRecipient(const QString &recipient) 378void WriteMail::setRecipient(const QString &recipient)
370{ 379{
371 toInput->setText(recipient); 380 toInput->setText(recipient);
372} 381}
373 382
374void WriteMail::newMail() 383void WriteMail::newMail()
375{ 384{
376 toInput->clear(); 385 toInput->clear();
377 subjectInput->clear(); 386 subjectInput->clear();
378 emailInput->clear(); 387 emailInput->clear();
379 //to clear selected
380 setAddressList(addressList); 388 setAddressList(addressList);
381} 389}