summaryrefslogtreecommitdiffabout
path: root/kmicromail/composemail.cpp
Unidiff
Diffstat (limited to 'kmicromail/composemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/composemail.cpp66
1 files changed, 33 insertions, 33 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp
index 946e97d..35ad367 100644
--- a/kmicromail/composemail.cpp
+++ b/kmicromail/composemail.cpp
@@ -43,88 +43,88 @@ ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool m
43{ 43{
44 mPickLineEdit = 0; 44 mPickLineEdit = 0;
45 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), 45 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)),
46 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); 46 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&)));
47 settings = s; 47 settings = s;
48 m_replyid = ""; 48 m_replyid = "";
49 if ( KOPrefs::instance()->mUseKapi) { 49 if ( KOPrefs::instance()->mUseKapi) {
50 KConfig config( locateLocal("config", "kabcrc") ); 50 KConfig config( locateLocal("config", "kabcrc") );
51 config.setGroup( "General" ); 51 config.setGroup( "General" );
52 QString whoami_uid = config.readEntry( "WhoAmI" ); 52 QString whoami_uid = config.readEntry( "WhoAmI" );
53 53
54 if ( whoami_uid.isEmpty() ) { 54 if ( whoami_uid.isEmpty() ) {
55 QMessageBox::information( 0, tr( "Hint" ), 55 QMessageBox::information( 0, i18n( "Hint" ),
56 tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 56 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
57 tr( "Ok" ) ); 57 i18n( "Ok" ) );
58 58
59 59
60 fillSettings(); 60 fillSettings();
61 } else 61 } else
62 ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); 62 ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid);
63 63
64 64
65#ifdef DESKTOP_VERSION 65#ifdef DESKTOP_VERSION
66 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); 66 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( );
67 QStringList mails = con.emails(); 67 QStringList mails = con.emails();
68 QString defmail = con.preferredEmail(); 68 QString defmail = con.preferredEmail();
69 if ( mails.count() == 0) 69 if ( mails.count() == 0)
70 QMessageBox::information( 0, tr( "Hint" ), 70 QMessageBox::information( 0, i18n( "Hint" ),
71 tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 71 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
72 tr( "Ok" ) ); 72 i18n( "Ok" ) );
73 if (defmail.length()!=0) { 73 if (defmail.length()!=0) {
74 fromBox->insertItem(defmail); 74 fromBox->insertItem(defmail);
75 } 75 }
76 QStringList::ConstIterator sit = mails.begin(); 76 QStringList::ConstIterator sit = mails.begin();
77 for (;sit!=mails.end();++sit) { 77 for (;sit!=mails.end();++sit) {
78 if ( (*sit)==defmail) 78 if ( (*sit)==defmail)
79 continue; 79 continue;
80 fromBox->insertItem((*sit)); 80 fromBox->insertItem((*sit));
81 } 81 }
82 senderNameEdit->setText(con.formattedName()); 82 senderNameEdit->setText(con.formattedName());
83#endif 83#endif
84 84
85 } else { 85 } else {
86 fillSettings(); 86 fillSettings();
87 } 87 }
88 checkBoxLater->setChecked( KOPrefs::instance()->mSendLater ); 88 checkBoxLater->setChecked( KOPrefs::instance()->mSendLater );
89 89
90 attList->addColumn( tr( "Name" ) ); 90 attList->addColumn( i18n( "Name" ) );
91 attList->addColumn( tr( "Size" ) ); 91 attList->addColumn( i18n( "Size" ) );
92 QList<Account> accounts = settings->getAccounts(); 92 QList<Account> accounts = settings->getAccounts();
93 93
94 if ( QApplication::desktop()->width() < 320 ) 94 if ( QApplication::desktop()->width() < 320 )
95 smtpAccountBox->setMaximumWidth( 80 ); 95 smtpAccountBox->setMaximumWidth( 80 );
96 Account *it; 96 Account *it;
97 for ( it = accounts.first(); it; it = accounts.next() ) { 97 for ( it = accounts.first(); it; it = accounts.next() ) {
98 if ( it->getType()==MAILLIB::A_SMTP ) { 98 if ( it->getType()==MAILLIB::A_SMTP ) {
99 SMTPaccount *smtp = static_cast<SMTPaccount *>(it); 99 SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
100 smtpAccountBox->insertItem( smtp->getAccountName() ); 100 smtpAccountBox->insertItem( smtp->getAccountName() );
101 smtpAccounts.append( smtp ); 101 smtpAccounts.append( smtp );
102 } 102 }
103 } 103 }
104 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); 104 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
105 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); 105 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
106 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); 106 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
107 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); 107 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
108 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); 108 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
109 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); 109 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) );
110 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); 110 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) );
111 mMail = 0; 111 mMail = 0;
112 warnAttach = true; 112 warnAttach = true;
113 if ( smtpAccounts.count() > 0 ) { 113 if ( smtpAccounts.count() > 0 ) {
114 fillValues( smtpAccountBox->currentItem() ); 114 fillValues( smtpAccountBox->currentItem() );
115 } else { 115 } else {
116 QMessageBox::information( 0, tr( "Problem" ), 116 QMessageBox::information( 0, i18n( "Problem" ),
117 tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ), 117 i18n( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ),
118 tr( "Ok" ) ); 118 i18n( "Ok" ) );
119 return; 119 return;
120 } 120 }
121 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); 121 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) );
122 message->setFont ( KOPrefs::instance()->mComposeFont ); 122 message->setFont ( KOPrefs::instance()->mComposeFont );
123 message->setWordWrap (QMultiLineEdit::WidgetWidth); 123 message->setWordWrap (QMultiLineEdit::WidgetWidth);
124#ifndef DESKTOP_VERSION 124#ifndef DESKTOP_VERSION
125 QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); 125 QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold );
126#endif 126#endif
127 127
128} 128}
129 129
130void ComposeMail::fillSettings() 130void ComposeMail::fillSettings()
@@ -163,33 +163,33 @@ void ComposeMail::saveAsDraft()
163 txt.append( sigMultiLine->text() ); 163 txt.append( sigMultiLine->text() );
164 } 164 }
165 mail->setMessage( txt ); 165 mail->setMessage( txt );
166 166
167 /* only use the default drafts folder name! */ 167 /* only use the default drafts folder name! */
168 Storemail wrapper(AbstractMail::draftFolder()); 168 Storemail wrapper(AbstractMail::draftFolder());
169 wrapper.storeMail(mail); 169 wrapper.storeMail(mail);
170 170
171 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 171 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
172 /* attachments we will ignore! */ 172 /* attachments we will ignore! */
173 if ( it != 0 ) { 173 if ( it != 0 ) {
174 if ( warnAttach ) 174 if ( warnAttach )
175 QMessageBox::warning(0,tr("Store message"), 175 QMessageBox::warning(0,i18n("Store message"),
176 tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); 176 i18n("<center>Attachments will not be stored in \"Draft\" folder</center>"));
177 warnAttach = false; 177 warnAttach = false;
178 } 178 }
179 setStatus( tr("Mail saved as draft!") ); 179 setStatus( i18n("Mail saved as draft!") );
180} 180}
181void ComposeMail::clearStatus() 181void ComposeMail::clearStatus()
182{ 182{
183 topLevelWidget()->setCaption( tr("Compose mail") ); 183 topLevelWidget()->setCaption( i18n("Compose mail") );
184} 184}
185void ComposeMail::setStatus( QString status ) 185void ComposeMail::setStatus( QString status )
186{ 186{
187 topLevelWidget()->setCaption( status ); 187 topLevelWidget()->setCaption( status );
188 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; 188 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ;
189} 189}
190void ComposeMail::pickAddress( ) 190void ComposeMail::pickAddress( )
191{ 191{
192 192
193 QLineEdit *line = mPickLineEdit; 193 QLineEdit *line = mPickLineEdit;
194 if ( line == 0 ) 194 if ( line == 0 )
195 return; 195 return;
@@ -219,27 +219,27 @@ void ComposeMail::pickAddress( )
219 // the result should now arrive through method insertAttendees 219 // the result should now arrive through method insertAttendees
220#endif 220#endif
221} 221}
222//the map includes name/email pairs, that comes from Ka/Pi 222//the map includes name/email pairs, that comes from Ka/Pi
223void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) 223void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList)
224{ 224{
225 //qDebug("ComposeMail::insertAttendees "); 225 //qDebug("ComposeMail::insertAttendees ");
226 raise(); 226 raise();
227 227
228 if ( mPickLineEdit == 0 ) { //whoami received 228 if ( mPickLineEdit == 0 ) { //whoami received
229 QString defmail = uidList[0]; 229 QString defmail = uidList[0];
230 if ( emailList.count() == 0 ) 230 if ( emailList.count() == 0 )
231 QMessageBox::information( 0, tr( "Hint" ), 231 QMessageBox::information( 0, i18n( "Hint" ),
232 tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 232 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
233 tr( "Ok" ) ); 233 i18n( "Ok" ) );
234 if (defmail.length()!=0) { 234 if (defmail.length()!=0) {
235 fromBox->insertItem(defmail); 235 fromBox->insertItem(defmail);
236 } 236 }
237 QStringList::ConstIterator sit = emailList.begin(); 237 QStringList::ConstIterator sit = emailList.begin();
238 int pref = 0; 238 int pref = 0;
239 for (;sit!=emailList.end();++sit) { 239 for (;sit!=emailList.end();++sit) {
240 if ( (*sit)==defmail) 240 if ( (*sit)==defmail)
241 continue; 241 continue;
242 fromBox->insertItem((*sit)); 242 fromBox->insertItem((*sit));
243 } 243 }
244 senderNameEdit->setText(nameList[0]); 244 senderNameEdit->setText(nameList[0]);
245 return; 245 return;
@@ -346,64 +346,64 @@ void ComposeMail::slotAdjustColumns()
346void ComposeMail::addAttachment() 346void ComposeMail::addAttachment()
347{ 347{
348 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); 348 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this );
349 if ( !lnk.isEmpty() ) { 349 if ( !lnk.isEmpty() ) {
350 Attachment *att = new Attachment( lnk ); 350 Attachment *att = new Attachment( lnk );
351 (void) new AttachViewItem( attList, att ); 351 (void) new AttachViewItem( attList, att );
352 } 352 }
353} 353}
354 354
355void ComposeMail::removeAttachment() 355void ComposeMail::removeAttachment()
356{ 356{
357 if ( !attList->currentItem() ) { 357 if ( !attList->currentItem() ) {
358 QMessageBox::information( this, tr( "Error" ), 358 QMessageBox::information( this, i18n( "Error" ),
359 tr( "<p>Please select a File.</p>" ), 359 i18n( "<p>Please select a File.</p>" ),
360 tr( "Ok" ) ); 360 i18n( "Ok" ) );
361 } else { 361 } else {
362 attList->takeItem( attList->currentItem() ); 362 attList->takeItem( attList->currentItem() );
363 } 363 }
364} 364}
365 365
366void ComposeMail::accept() 366void ComposeMail::accept()
367{ 367{
368 if ( smtpAccountBox->count() == 0 ) { 368 if ( smtpAccountBox->count() == 0 ) {
369 369
370 reject(); 370 reject();
371 return; 371 return;
372 } 372 }
373 373
374 if (! checkBoxLater->isChecked() ) { 374 if (! checkBoxLater->isChecked() ) {
375 int yesno = QMessageBox::warning(0,tr("Stop editing message"), 375 int yesno = QMessageBox::warning(0,i18n("Stop editing message"),
376 tr("Send this message?"), 376 i18n("Send this message?"),
377 tr("Yes"), 377 i18n("Yes"),
378 tr("Cancel")); 378 i18n("Cancel"));
379 379
380 if (yesno == 1) { 380 if (yesno == 1) {
381 return; 381 return;
382 } 382 }
383 } 383 }
384#if 0 384#if 0
385 odebug << "Sending Mail with " 385 odebug << "Sending Mail with "
386 << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; 386 << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl;
387#endif 387#endif
388 Opie::Core::OSmartPointer<Mail> mail=new Mail; 388 Opie::Core::OSmartPointer<Mail> mail=new Mail;
389 389
390 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); 390 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() );
391 mail->setMail(fromBox->currentText()); 391 mail->setMail(fromBox->currentText());
392 392
393 if ( !toLine->text().isEmpty() ) { 393 if ( !toLine->text().isEmpty() ) {
394 mail->setTo( toLine->text() ); 394 mail->setTo( toLine->text() );
395 } else { 395 } else {
396 QMessageBox::warning(0,tr("Sending mail"), 396 QMessageBox::warning(0,i18n("Sending mail"),
397 tr("No Receiver spezified" ) ); 397 i18n("No Receiver spezified" ) );
398 return; 398 return;
399 } 399 }
400 400
401 mail->setName(senderNameEdit->text()); 401 mail->setName(senderNameEdit->text());
402 mail->setCC( ccLine->text() ); 402 mail->setCC( ccLine->text() );
403 mail->setBCC( bccLine->text() ); 403 mail->setBCC( bccLine->text() );
404 mail->setReply( replyLine->text() ); 404 mail->setReply( replyLine->text() );
405 mail->setSubject( subjectLine->text() ); 405 mail->setSubject( subjectLine->text() );
406 if (!m_replyid.isEmpty()) { 406 if (!m_replyid.isEmpty()) {
407 QStringList ids; 407 QStringList ids;
408 ids.append(m_replyid); 408 ids.append(m_replyid);
409 mail->setInreply(ids); 409 mail->setInreply(ids);
@@ -426,34 +426,34 @@ void ComposeMail::accept()
426 else { 426 else {
427 setStatus( tr ("Error: Something went wrong. Nothing sent")); 427 setStatus( tr ("Error: Something went wrong. Nothing sent"));
428 return; 428 return;
429 } 429 }
430 430
431 431
432 QDialog::accept(); 432 QDialog::accept();
433} 433}
434 434
435void ComposeMail::reject() 435void ComposeMail::reject()
436{ 436{
437 //qDebug("ComposeMail::reject() "); 437 //qDebug("ComposeMail::reject() ");
438 int yesno = QMessageBox::warning(0,tr("Store message?"), 438 int yesno = QMessageBox::warning(0,i18n("Store message?"),
439 tr("Store message into drafts?\n"), 439 i18n("Store message into drafts?\n"),
440 tr("Yes"), 440 i18n("Yes"),
441 tr("No")); 441 i18n("No"));
442 442
443 //qDebug("button %d ", yesno); 443 //qDebug("button %d ", yesno);
444 if (yesno == 0) { 444 if (yesno == 0) {
445 if ( toLine->text().isEmpty() ) { 445 if ( toLine->text().isEmpty() ) {
446 QMessageBox::warning(0,tr("Sending mail"), 446 QMessageBox::warning(0,i18n("Sending mail"),
447 tr("No Receiver spezified" ) ); 447 i18n("No Receiver spezified" ) );
448 return; 448 return;
449 } 449 }
450 saveAsDraft(); 450 saveAsDraft();
451 } 451 }
452 if (yesno == 2) { 452 if (yesno == 2) {
453 qDebug("return "); 453 qDebug("return ");
454 return; 454 return;
455 } 455 }
456 QDialog::reject(); 456 QDialog::reject();
457} 457}
458 458
459ComposeMail::~ComposeMail() 459ComposeMail::~ComposeMail()