summaryrefslogtreecommitdiffabout
path: root/kmicromail/composemail.cpp
Unidiff
Diffstat (limited to 'kmicromail/composemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/composemail.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp
index 2c2e279..ca4f247 100644
--- a/kmicromail/composemail.cpp
+++ b/kmicromail/composemail.cpp
@@ -100,64 +100,64 @@ void ComposeMail::saveAsDraft()
100 mail->setTo( toLine->text() ); 100 mail->setTo( toLine->text() );
101 mail->setName(senderNameEdit->text()); 101 mail->setName(senderNameEdit->text());
102 mail->setCC( ccLine->text() ); 102 mail->setCC( ccLine->text() );
103 mail->setBCC( bccLine->text() ); 103 mail->setBCC( bccLine->text() );
104 mail->setReply( replyLine->text() ); 104 mail->setReply( replyLine->text() );
105 mail->setSubject( subjectLine->text() ); 105 mail->setSubject( subjectLine->text() );
106 if (!m_replyid.isEmpty()) { 106 if (!m_replyid.isEmpty()) {
107 QStringList ids; 107 QStringList ids;
108 ids.append(m_replyid); 108 ids.append(m_replyid);
109 mail->setInreply(ids); 109 mail->setInreply(ids);
110 } 110 }
111 QString txt = message->text(); 111 QString txt = message->text();
112 if ( !sigMultiLine->text().isEmpty() ) { 112 if ( !sigMultiLine->text().isEmpty() ) {
113 txt.append( "\n--\n" ); 113 txt.append( "\n--\n" );
114 txt.append( sigMultiLine->text() ); 114 txt.append( sigMultiLine->text() );
115 } 115 }
116 mail->setMessage( txt ); 116 mail->setMessage( txt );
117 117
118 /* only use the default drafts folder name! */ 118 /* only use the default drafts folder name! */
119 Storemail wrapper(AbstractMail::draftFolder()); 119 Storemail wrapper(AbstractMail::draftFolder());
120 wrapper.storeMail(mail); 120 wrapper.storeMail(mail);
121 121
122 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 122 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
123 /* attachments we will ignore! */ 123 /* attachments we will ignore! */
124 if ( it != NULL ) { 124 if ( it != 0 ) {
125 if ( warnAttach ) 125 if ( warnAttach )
126 QMessageBox::warning(0,tr("Store message"), 126 QMessageBox::warning(0,tr("Store message"),
127 tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); 127 tr("<center>Attachments will not be stored in \"Draft\" folder</center>"));
128 warnAttach = false; 128 warnAttach = false;
129 } 129 }
130 setStatus( tr("Mail saved as draft!") ); 130 setStatus( tr("Mail saved as draft!") );
131} 131}
132void ComposeMail::clearStatus() 132void ComposeMail::clearStatus()
133{ 133{
134 topLevelWidget()->setCaption( tr("Compose mail") ); 134 topLevelWidget()->setCaption( tr("Compose mail") );
135} 135}
136void ComposeMail::setStatus( QString status ) 136void ComposeMail::setStatus( QString status )
137{ 137{
138 topLevelWidget()->setCaption( status ); 138 topLevelWidget()->setCaption( status );
139 QTimer::singleShot ( 5000, this, SLOT( clearStatus() ) ) ; 139 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ;
140} 140}
141void ComposeMail::pickAddress( QLineEdit *line ) 141void ComposeMail::pickAddress( QLineEdit *line )
142{ 142{
143 //qDebug(" ComposeMail::pickAddress "); 143 //qDebug(" ComposeMail::pickAddress ");
144 QString names ;//= AddressPicker::getNames(); 144 QString names ;//= AddressPicker::getNames();
145 145
146 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 146 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
147 uint i=0; 147 uint i=0;
148 for (i=0; i < list.count(); i++) { 148 for (i=0; i < list.count(); i++) {
149 if ( !list[i].preferredEmail().isEmpty()) { 149 if ( !list[i].preferredEmail().isEmpty()) {
150 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; 150 names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">";
151 if ( i < list.count() -1 ) 151 if ( i < list.count() -1 )
152 names+= ","; 152 names+= ",";
153 } 153 }
154 } 154 }
155 155
156 156
157 if ( line->text().isEmpty() ) { 157 if ( line->text().isEmpty() ) {
158 line->setText( names ); 158 line->setText( names );
159 } else if ( !names.isEmpty() ) { 159 } else if ( !names.isEmpty() ) {
160 line->setText( line->text() + ", " + names ); 160 line->setText( line->text() + ", " + names );
161 } 161 }
162} 162}
163 163
@@ -279,55 +279,61 @@ void ComposeMail::accept()
279 mail->setTo( toLine->text() ); 279 mail->setTo( toLine->text() );
280 } else { 280 } else {
281 QMessageBox::warning(0,tr("Sending mail"), 281 QMessageBox::warning(0,tr("Sending mail"),
282 tr("No Receiver spezified" ) ); 282 tr("No Receiver spezified" ) );
283 return; 283 return;
284 } 284 }
285 285
286 mail->setName(senderNameEdit->text()); 286 mail->setName(senderNameEdit->text());
287 mail->setCC( ccLine->text() ); 287 mail->setCC( ccLine->text() );
288 mail->setBCC( bccLine->text() ); 288 mail->setBCC( bccLine->text() );
289 mail->setReply( replyLine->text() ); 289 mail->setReply( replyLine->text() );
290 mail->setSubject( subjectLine->text() ); 290 mail->setSubject( subjectLine->text() );
291 if (!m_replyid.isEmpty()) { 291 if (!m_replyid.isEmpty()) {
292 QStringList ids; 292 QStringList ids;
293 ids.append(m_replyid); 293 ids.append(m_replyid);
294 mail->setInreply(ids); 294 mail->setInreply(ids);
295 } 295 }
296 QString txt = message->text(); 296 QString txt = message->text();
297 if ( !sigMultiLine->text().isEmpty() ) { 297 if ( !sigMultiLine->text().isEmpty() ) {
298 txt.append( "\n--\n" ); 298 txt.append( "\n--\n" );
299 txt.append( sigMultiLine->text() ); 299 txt.append( sigMultiLine->text() );
300 } 300 }
301 mail->setMessage( txt ); 301 mail->setMessage( txt );
302 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 302 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
303 while ( it != NULL ) { 303 while ( it != 0 ) {
304 mail->addAttachment( it->getAttachment() ); 304 mail->addAttachment( it->getAttachment() );
305 it = (AttachViewItem *) it->nextSibling(); 305 it = (AttachViewItem *) it->nextSibling();
306 } 306 }
307 307
308 SMTPwrapper wrapper( smtp ); 308 SMTPwrapper wrapper( smtp );
309 wrapper.sendMail( mail,checkBoxLater->isChecked() ); 309 if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) )
310 setStatus( tr ("Mail sent"));
311 else {
312 setStatus( tr ("Error: Something went wrong. Nothing sent"));
313 return;
314 }
315
310 316
311 QDialog::accept(); 317 QDialog::accept();
312} 318}
313 319
314void ComposeMail::reject() 320void ComposeMail::reject()
315{ 321{
316 //qDebug("ComposeMail::reject() "); 322 //qDebug("ComposeMail::reject() ");
317 int yesno = QMessageBox::warning(0,tr("Stop editing message"), 323 int yesno = QMessageBox::warning(0,tr("Stop editing message"),
318 tr("Store message into drafts?"), 324 tr("Store message into drafts?"),
319 tr("Yes"), 325 tr("Yes"),
320 tr("No")); 326 tr("No"));
321 327
322 //qDebug("button %d ", yesno); 328 //qDebug("button %d ", yesno);
323 if (yesno == 0) { 329 if (yesno == 0) {
324 saveAsDraft(); 330 saveAsDraft();
325 } 331 }
326 if (yesno == 2) { 332 if (yesno == 2) {
327 qDebug("return "); 333 qDebug("return ");
328 return; 334 return;
329 } 335 }
330 QDialog::reject(); 336 QDialog::reject();
331} 337}
332 338
333ComposeMail::~ComposeMail() 339ComposeMail::~ComposeMail()