summaryrefslogtreecommitdiffabout
path: root/kmicromail/composemail.cpp
Unidiff
Diffstat (limited to 'kmicromail/composemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/composemail.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp
index 976e309..ed8a2ee 100644
--- a/kmicromail/composemail.cpp
+++ b/kmicromail/composemail.cpp
@@ -104,114 +104,123 @@ ComposeMail::ComposeMail( Settings *sett, QWidget *parent, const char *name, boo
104 attList->addColumn( i18n( "Size" ) ); 104 attList->addColumn( i18n( "Size" ) );
105 QList<Account> accounts = settings->getAccounts(); 105 QList<Account> accounts = settings->getAccounts();
106 106
107 if ( QApplication::desktop()->width() < 320 ) 107 if ( QApplication::desktop()->width() < 320 )
108 smtpAccountBox->setMaximumWidth( 80 ); 108 smtpAccountBox->setMaximumWidth( 80 );
109 Account *it; 109 Account *it;
110 for ( it = accounts.first(); it; it = accounts.next() ) { 110 for ( it = accounts.first(); it; it = accounts.next() ) {
111 if ( it->getType()==MAILLIB::A_SMTP ) { 111 if ( it->getType()==MAILLIB::A_SMTP ) {
112 SMTPaccount *smtp = static_cast<SMTPaccount *>(it); 112 SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
113 smtpAccountBox->insertItem( smtp->getAccountName() ); 113 smtpAccountBox->insertItem( smtp->getAccountName() );
114 smtpAccounts.append( smtp ); 114 smtpAccounts.append( smtp );
115 } 115 }
116 } 116 }
117 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); 117 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
118 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); 118 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
119 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); 119 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
120 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); 120 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
121 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); 121 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
122 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); 122 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) );
123 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); 123 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) );
124 mMail = 0; 124 mMail = 0;
125 warnAttach = true; 125 warnAttach = true;
126 QIconSet icon; 126 QIconSet icon;
127 //icon = SmallIcon("fileexport"); 127 //icon = SmallIcon("fileexport");
128 icon = SmallIcon("filesave"); 128 icon = SmallIcon("filesave");
129 SaveButton->setIconSet (icon ) ; 129 SaveButton->setIconSet (icon ) ;
130 if ( QApplication::desktop()->width() < 320 ) { 130 if ( QApplication::desktop()->width() < 320 ) {
131 SaveButton->setText ("") ; 131 SaveButton->setText ("") ;
132 SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ; 132 SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ;
133 } 133 }
134 else 134 else
135 SaveButton->setText (i18n("Save")); 135 SaveButton->setText (i18n("Save"));
136#ifndef DESKTOP_VERSION 136#ifndef DESKTOP_VERSION
137 QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); 137 QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold );
138 QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold ); 138 QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold );
139 QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold ); 139 QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold );
140#endif 140#endif
141 message->setFont ( KOPrefs::instance()->mComposeFont ); 141 message->setFont ( KOPrefs::instance()->mComposeFont );
142 message->setWordWrap (QMultiLineEdit::WidgetWidth); 142 message->setWordWrap (QMultiLineEdit::WidgetWidth);
143 if ( smtpAccounts.count() > 0 ) { 143 if ( smtpAccounts.count() > 0 ) {
144 fillValues( smtpAccountBox->currentItem() ); 144 fillValues( smtpAccountBox->currentItem() );
145 } else { 145 } else {
146 QMessageBox::information( 0, i18n( "Problem" ), 146 QMessageBox::information( 0, i18n( "Problem" ),
147 i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ), 147 i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ),
148 i18n( "Ok" ) ); 148 i18n( "Ok" ) );
149 return; 149 return;
150 } 150 }
151 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); 151 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) );
152 152 connect( SaveSigButton, SIGNAL( clicked() ), SLOT( saveSig()) );
153 if ( smtpAccountBox->count())
154 fillValues(0);
153 155
154} 156}
155 157
156void ComposeMail::fillSettings() 158void ComposeMail::fillSettings()
157{ 159{
158 if ( QApplication::desktop()->width() < 320 ) 160 if ( QApplication::desktop()->width() < 320 )
159 fromBox->setMaximumWidth( 100 ); 161 fromBox->setMaximumWidth( 100 );
160 QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); 162 QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail);
161 QStringList::ConstIterator sit = mailList.begin(); 163 QStringList::ConstIterator sit = mailList.begin();
162 int pref = 0; 164 int pref = 0;
163 for (;sit!=mailList.end();++sit) { 165 for (;sit!=mailList.end();++sit) {
164 fromBox->insertItem((*sit)); 166 fromBox->insertItem((*sit));
165 } 167 }
166 senderNameEdit->setText(KOPrefs::instance()->mName); 168 senderNameEdit->setText(KOPrefs::instance()->mName);
167} 169}
168 170void ComposeMail::saveSig()
169 171{
172 if ( smtpAccountBox->count()) {
173 int cur = smtpAccountBox->currentItem ();
174 SMTPaccount *smtp = smtpAccounts.at( cur );
175 if ( smtp )
176 smtp->setSignature( sigMultiLine->text());
177 }
178}
170void ComposeMail::saveAsDraft() 179void ComposeMail::saveAsDraft()
171{ 180{
172 181
173 Opie::Core::OSmartPointer<Mail> mail= new Mail(); 182 Opie::Core::OSmartPointer<Mail> mail= new Mail();
174 mail->setMail(fromBox->currentText()); 183 mail->setMail(fromBox->currentText());
175 mail->setTo( toLine->text() ); 184 mail->setTo( toLine->text() );
176 mail->setName(senderNameEdit->text()); 185 mail->setName(senderNameEdit->text());
177 mail->setCC( ccLine->text() ); 186 mail->setCC( ccLine->text() );
178 mail->setBCC( bccLine->text() ); 187 mail->setBCC( bccLine->text() );
179 mail->setReply( replyLine->text() ); 188 mail->setReply( replyLine->text() );
180 mail->setSubject( subjectLine->text() ); 189 mail->setSubject( subjectLine->text() );
181 if (!m_replyid.isEmpty()) { 190 if (!m_replyid.isEmpty()) {
182 QStringList ids; 191 QStringList ids;
183 ids.append(m_replyid); 192 ids.append(m_replyid);
184 mail->setInreply(ids); 193 mail->setInreply(ids);
185 } 194 }
186 QString txt = message->text(); 195 QString txt = message->text();
187 if ( !sigMultiLine->text().isEmpty() ) { 196 if ( !sigMultiLine->text().isEmpty() ) {
188 txt.append( "\n--\n" ); 197 txt.append( "\n--\n" );
189 txt.append( sigMultiLine->text() ); 198 txt.append( sigMultiLine->text() );
190 } 199 }
191 mail->setMessage( txt ); 200 mail->setMessage( txt );
192 mail->setCharset (mEncoding); 201 mail->setCharset (mEncoding);
193 /* only use the default drafts folder name! */ 202 /* only use the default drafts folder name! */
194 Storemail wrapper(AbstractMail::draftFolder()); 203 Storemail wrapper(AbstractMail::draftFolder());
195 wrapper.storeMail(mail); 204 wrapper.storeMail(mail);
196 205
197 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 206 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
198 /* attachments we will ignore! */ 207 /* attachments we will ignore! */
199 if ( it != 0 ) { 208 if ( it != 0 ) {
200 if ( warnAttach ) 209 if ( warnAttach )
201 QMessageBox::warning(0,i18n("Store message"), 210 QMessageBox::warning(0,i18n("Store message"),
202 i18n("<center>Attachments will not be stored in \"Draft\" folder</center>")); 211 i18n("<center>Attachments will not be stored in \"Draft\" folder</center>"));
203 warnAttach = false; 212 warnAttach = false;
204 } 213 }
205 setStatus( i18n("Mail saved as draft!") ); 214 setStatus( i18n("Mail saved as draft!") );
206} 215}
207void ComposeMail::clearStatus() 216void ComposeMail::clearStatus()
208{ 217{
209 topLevelWidget()->setCaption( i18n("Compose mail") ); 218 topLevelWidget()->setCaption( i18n("Compose mail") );
210} 219}
211void ComposeMail::setStatus( QString status ) 220void ComposeMail::setStatus( QString status )
212{ 221{
213 topLevelWidget()->setCaption( status ); 222 topLevelWidget()->setCaption( status );
214 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; 223 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ;
215} 224}
216void ComposeMail::pickAddress( ) 225void ComposeMail::pickAddress( )
217{ 226{
@@ -293,114 +302,116 @@ void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameLis
293 } 302 }
294} 303}
295 304
296void ComposeMail::setTo( const QString & to ) 305void ComposeMail::setTo( const QString & to )
297{ 306{
298 toLine->setText( to ); 307 toLine->setText( to );
299} 308}
300 309
301void ComposeMail::setSubject( const QString & subject ) 310void ComposeMail::setSubject( const QString & subject )
302{ 311{
303 subjectLine->setText( subject ); 312 subjectLine->setText( subject );
304} 313}
305 314
306void ComposeMail::setInReplyTo( const QString & messageId ) 315void ComposeMail::setInReplyTo( const QString & messageId )
307{ 316{
308 m_replyid = messageId; 317 m_replyid = messageId;
309} 318}
310 319
311void ComposeMail::setMessage( const QString & text ) 320void ComposeMail::setMessage( const QString & text )
312{ 321{
313 message->setText( text ); 322 message->setText( text );
314} 323}
315 324
316 325
317void ComposeMail::pickAddressTo() 326void ComposeMail::pickAddressTo()
318{ 327{
319 mPickLineEdit = toLine; 328 mPickLineEdit = toLine;
320 pickAddress( ); 329 pickAddress( );
321} 330}
322 331
323void ComposeMail::pickAddressCC() 332void ComposeMail::pickAddressCC()
324{ 333{
325 mPickLineEdit = ccLine; 334 mPickLineEdit = ccLine;
326 pickAddress( ); 335 pickAddress( );
327} 336}
328 337
329void ComposeMail::pickAddressBCC() 338void ComposeMail::pickAddressBCC()
330{ 339{
331 mPickLineEdit = bccLine; 340 mPickLineEdit = bccLine;
332 pickAddress( ); 341 pickAddress( );
333} 342}
334 343
335void ComposeMail::pickAddressReply() 344void ComposeMail::pickAddressReply()
336{ 345{
337 mPickLineEdit = replyLine; 346 mPickLineEdit = replyLine;
338 pickAddress( ); 347 pickAddress( );
339} 348}
340 349
341void ComposeMail::fillValues( int ) 350void ComposeMail::fillValues( int current )
342{ 351{
343#if 0 352#if 0
344 SMTPaccount *smtp = smtpAccounts.at( current ); 353 SMTPaccount *smtp = smtpAccounts.at( current );
345 ccLine->clear(); 354 ccLine->clear();
346 if ( smtp->getUseCC() ) { 355 if ( smtp->getUseCC() ) {
347 ccLine->setText( smtp->getCC() ); 356 ccLine->setText( smtp->getCC() );
348 } 357 }
349 bccLine->clear(); 358 bccLine->clear();
350 if ( smtp->getUseBCC() ) { 359 if ( smtp->getUseBCC() ) {
351 bccLine->setText( smtp->getBCC() ); 360 bccLine->setText( smtp->getBCC() );
352 } 361 }
353 replyLine->clear(); 362 replyLine->clear();
354 if ( smtp->getUseReply() ) { 363 if ( smtp->getUseReply() ) {
355 replyLine->setText( smtp->getReply() ); 364 replyLine->setText( smtp->getReply() );
356 } 365 }
357 sigMultiLine->setText( smtp->getSignature() );
358#endif 366#endif
367 SMTPaccount *smtp = smtpAccounts.at( current );
368 if ( smtp )
369 sigMultiLine->setText( smtp->getSignature() );
359} 370}
360 371
361void ComposeMail::slotAdjustColumns() 372void ComposeMail::slotAdjustColumns()
362{ 373{
363 int currPage = tabWidget->currentPageIndex(); 374 int currPage = tabWidget->currentPageIndex();
364 375
365 tabWidget->showPage( attachTab ); 376 tabWidget->showPage( attachTab );
366 attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); 377 attList->setColumnWidth( 0, attList->visibleWidth() - 80 );
367 attList->setColumnWidth( 1, 80 ); 378 attList->setColumnWidth( 1, 80 );
368 379
369 tabWidget->setCurrentPage( currPage ); 380 tabWidget->setCurrentPage( currPage );
370} 381}
371 382
372void ComposeMail::addAttachment() 383void ComposeMail::addAttachment()
373{ 384{
374 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); 385 QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this );
375 if ( !lnk.isEmpty() ) { 386 if ( !lnk.isEmpty() ) {
376 Attachment *att = new Attachment( lnk ); 387 Attachment *att = new Attachment( lnk );
377 (void) new AttachViewItem( attList, att ); 388 (void) new AttachViewItem( attList, att );
378 } 389 }
379} 390}
380 391
381void ComposeMail::removeAttachment() 392void ComposeMail::removeAttachment()
382{ 393{
383 if ( !attList->currentItem() ) { 394 if ( !attList->currentItem() ) {
384 QMessageBox::information( this, i18n( "Error" ), 395 QMessageBox::information( this, i18n( "Error" ),
385 i18n( "<p>Please select a File.</p>" ), 396 i18n( "<p>Please select a File.</p>" ),
386 i18n( "Ok" ) ); 397 i18n( "Ok" ) );
387 } else { 398 } else {
388 attList->takeItem( attList->currentItem() ); 399 attList->takeItem( attList->currentItem() );
389 } 400 }
390} 401}
391 402
392void ComposeMail::accept() 403void ComposeMail::accept()
393{ 404{
394 if ( smtpAccountBox->count() == 0 ) { 405 if ( smtpAccountBox->count() == 0 ) {
395 406
396 reject(); 407 reject();
397 return; 408 return;
398 } 409 }
399 410
400 if (! checkBoxLater->isChecked() ) { 411 if (! checkBoxLater->isChecked() ) {
401 int yesno = QMessageBox::warning(0,i18n("Stop editing message"), 412 int yesno = QMessageBox::warning(0,i18n("Stop editing message"),
402 i18n("Send this message?"), 413 i18n("Send this message?"),
403 i18n("Yes"), 414 i18n("Yes"),
404 i18n("Cancel")); 415 i18n("Cancel"));
405 416
406 if (yesno == 1) { 417 if (yesno == 1) {