summaryrefslogtreecommitdiffabout
path: root/kmicromail
Unidiff
Diffstat (limited to 'kmicromail') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/composemail.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp
index c504fdd..8eb6d27 100644
--- a/kmicromail/composemail.cpp
+++ b/kmicromail/composemail.cpp
@@ -21,194 +21,196 @@
21#include <qiconset.h> 21#include <qiconset.h>
22#include <qtimer.h> 22#include <qtimer.h>
23#include <qmessagebox.h> 23#include <qmessagebox.h>
24#include <qpushbutton.h> 24#include <qpushbutton.h>
25#include <qmultilineedit.h> 25#include <qmultilineedit.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qtabwidget.h> 27#include <qtabwidget.h>
28#include <qlistview.h> 28#include <qlistview.h>
29#include <kabc/addresseedialog.h> 29#include <kabc/addresseedialog.h>
30#include <kabc/stdaddressbook.h> 30#include <kabc/stdaddressbook.h>
31#include <kabc/addressee.h> 31#include <kabc/addressee.h>
32#ifdef DESKTOP_VERSION 32#ifdef DESKTOP_VERSION
33#include <kabc/addresseedialog.h> 33#include <kabc/addresseedialog.h>
34#else //DESKTOP_VERSION 34#else //DESKTOP_VERSION
35#include <libkdepim/externalapphandler.h> 35#include <libkdepim/externalapphandler.h>
36#endif //DESKTOP_VERSION 36#endif //DESKTOP_VERSION
37 37
38#include "koprefs.h" 38#include "koprefs.h"
39 39
40//using namespace Opie::Core; 40//using namespace Opie::Core;
41//using namespace Opie::Ui; 41//using namespace Opie::Ui;
42ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal ) 42ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal )
43 : ComposeMailUI( parent, name, modal ) 43 : ComposeMailUI( parent, name, modal )
44{ 44{
45 mPickLineEdit = 0; 45 mPickLineEdit = 0;
46 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), 46 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)),
47 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); 47 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&)));
48 settings = s; 48 settings = s;
49 m_replyid = ""; 49 m_replyid = "";
50 if ( KOPrefs::instance()->mUseKapi) { 50 if ( KOPrefs::instance()->mUseKapi) {
51 KConfig config( locateLocal("config", "kabcrc") ); 51 KConfig config( locateLocal("config", "kabcrc") );
52 config.setGroup( "General" ); 52 config.setGroup( "General" );
53 QString whoami_uid = config.readEntry( "WhoAmI" ); 53 QString whoami_uid = config.readEntry( "WhoAmI" );
54 54
55 if ( whoami_uid.isEmpty() ) { 55 if ( whoami_uid.isEmpty() ) {
56 QMessageBox::information( 0, i18n( "Hint" ), 56 QMessageBox::information( 0, i18n( "Hint" ),
57 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 57 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
58 i18n( "Ok" ) ); 58 i18n( "Ok" ) );
59 59
60 60
61 fillSettings(); 61 fillSettings();
62 } else 62 } else
63 ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); 63 ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid);
64 64
65 65
66#ifdef DESKTOP_VERSION 66#ifdef DESKTOP_VERSION
67 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); 67 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( );
68 QStringList mails = con.emails(); 68 QStringList mails = con.emails();
69 QString defmail = con.preferredEmail(); 69 QString defmail = con.preferredEmail();
70 if ( mails.count() == 0) 70 if ( mails.count() == 0)
71 QMessageBox::information( 0, i18n( "Hint" ), 71 QMessageBox::information( 0, i18n( "Hint" ),
72 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), 72 i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
73 i18n( "Ok" ) ); 73 i18n( "Ok" ) );
74 if (defmail.length()!=0) { 74 if (defmail.length()!=0) {
75 fromBox->insertItem(defmail); 75 fromBox->insertItem(defmail);
76 } 76 }
77 QStringList::ConstIterator sit = mails.begin(); 77 QStringList::ConstIterator sit = mails.begin();
78 for (;sit!=mails.end();++sit) { 78 for (;sit!=mails.end();++sit) {
79 if ( (*sit)==defmail) 79 if ( (*sit)==defmail)
80 continue; 80 continue;
81 fromBox->insertItem((*sit)); 81 fromBox->insertItem((*sit));
82 } 82 }
83 senderNameEdit->setText(con.formattedName()); 83 senderNameEdit->setText(con.formattedName());
84#endif 84#endif
85 85
86 } else { 86 } else {
87 fillSettings(); 87 fillSettings();
88 } 88 }
89 checkBoxLater->setChecked( KOPrefs::instance()->mSendLater ); 89 checkBoxLater->setChecked( KOPrefs::instance()->mSendLater );
90 90
91 attList->addColumn( i18n( "Name" ) ); 91 attList->addColumn( i18n( "Name" ) );
92 attList->addColumn( i18n( "Size" ) ); 92 attList->addColumn( i18n( "Size" ) );
93 QList<Account> accounts = settings->getAccounts(); 93 QList<Account> accounts = settings->getAccounts();
94 94
95 if ( QApplication::desktop()->width() < 320 ) 95 if ( QApplication::desktop()->width() < 320 )
96 smtpAccountBox->setMaximumWidth( 80 ); 96 smtpAccountBox->setMaximumWidth( 80 );
97 Account *it; 97 Account *it;
98 for ( it = accounts.first(); it; it = accounts.next() ) { 98 for ( it = accounts.first(); it; it = accounts.next() ) {
99 if ( it->getType()==MAILLIB::A_SMTP ) { 99 if ( it->getType()==MAILLIB::A_SMTP ) {
100 SMTPaccount *smtp = static_cast<SMTPaccount *>(it); 100 SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
101 smtpAccountBox->insertItem( smtp->getAccountName() ); 101 smtpAccountBox->insertItem( smtp->getAccountName() );
102 smtpAccounts.append( smtp ); 102 smtpAccounts.append( smtp );
103 } 103 }
104 } 104 }
105 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); 105 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
106 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); 106 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
107 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); 107 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
108 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); 108 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
109 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); 109 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
110 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); 110 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) );
111 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); 111 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) );
112 mMail = 0; 112 mMail = 0;
113 warnAttach = true; 113 warnAttach = true;
114 QIconSet icon; 114 QIconSet icon;
115 //icon = SmallIcon("fileexport"); 115 //icon = SmallIcon("fileexport");
116 icon = SmallIcon("filesave"); 116 icon = SmallIcon("filesave");
117 117 if ( QApplication::desktop()->width() < 320 )
118 SaveButton->setText ("") ; 118 SaveButton->setText ("") ;
119 else
120 SaveButton->setText (i18n("Save")) ;
119 SaveButton->setIconSet (icon ) ; 121 SaveButton->setIconSet (icon ) ;
120 SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ; 122 SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ;
121#ifndef DESKTOP_VERSION 123#ifndef DESKTOP_VERSION
122 QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); 124 QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold );
123 QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold ); 125 QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold );
124 QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold ); 126 QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold );
125#endif 127#endif
126 message->setFont ( KOPrefs::instance()->mComposeFont ); 128 message->setFont ( KOPrefs::instance()->mComposeFont );
127 message->setWordWrap (QMultiLineEdit::WidgetWidth); 129 message->setWordWrap (QMultiLineEdit::WidgetWidth);
128 if ( smtpAccounts.count() > 0 ) { 130 if ( smtpAccounts.count() > 0 ) {
129 fillValues( smtpAccountBox->currentItem() ); 131 fillValues( smtpAccountBox->currentItem() );
130 } else { 132 } else {
131 QMessageBox::information( 0, i18n( "Problem" ), 133 QMessageBox::information( 0, i18n( "Problem" ),
132 i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ), 134 i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ),
133 i18n( "Ok" ) ); 135 i18n( "Ok" ) );
134 return; 136 return;
135 } 137 }
136 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); 138 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) );
137 139
138 140
139} 141}
140 142
141void ComposeMail::fillSettings() 143void ComposeMail::fillSettings()
142{ 144{
143 if ( QApplication::desktop()->width() < 320 ) 145 if ( QApplication::desktop()->width() < 320 )
144 fromBox->setMaximumWidth( 100 ); 146 fromBox->setMaximumWidth( 100 );
145 QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); 147 QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail);
146 QStringList::ConstIterator sit = mailList.begin(); 148 QStringList::ConstIterator sit = mailList.begin();
147 int pref = 0; 149 int pref = 0;
148 for (;sit!=mailList.end();++sit) { 150 for (;sit!=mailList.end();++sit) {
149 fromBox->insertItem((*sit)); 151 fromBox->insertItem((*sit));
150 } 152 }
151 senderNameEdit->setText(KOPrefs::instance()->mName); 153 senderNameEdit->setText(KOPrefs::instance()->mName);
152} 154}
153 155
154 156
155void ComposeMail::saveAsDraft() 157void ComposeMail::saveAsDraft()
156{ 158{
157 159
158 Opie::Core::OSmartPointer<Mail> mail= new Mail(); 160 Opie::Core::OSmartPointer<Mail> mail= new Mail();
159 mail->setMail(fromBox->currentText()); 161 mail->setMail(fromBox->currentText());
160 mail->setTo( toLine->text() ); 162 mail->setTo( toLine->text() );
161 mail->setName(senderNameEdit->text()); 163 mail->setName(senderNameEdit->text());
162 mail->setCC( ccLine->text() ); 164 mail->setCC( ccLine->text() );
163 mail->setBCC( bccLine->text() ); 165 mail->setBCC( bccLine->text() );
164 mail->setReply( replyLine->text() ); 166 mail->setReply( replyLine->text() );
165 mail->setSubject( subjectLine->text() ); 167 mail->setSubject( subjectLine->text() );
166 if (!m_replyid.isEmpty()) { 168 if (!m_replyid.isEmpty()) {
167 QStringList ids; 169 QStringList ids;
168 ids.append(m_replyid); 170 ids.append(m_replyid);
169 mail->setInreply(ids); 171 mail->setInreply(ids);
170 } 172 }
171 QString txt = message->text(); 173 QString txt = message->text();
172 if ( !sigMultiLine->text().isEmpty() ) { 174 if ( !sigMultiLine->text().isEmpty() ) {
173 txt.append( "\n--\n" ); 175 txt.append( "\n--\n" );
174 txt.append( sigMultiLine->text() ); 176 txt.append( sigMultiLine->text() );
175 } 177 }
176 mail->setMessage( txt ); 178 mail->setMessage( txt );
177 179
178 /* only use the default drafts folder name! */ 180 /* only use the default drafts folder name! */
179 Storemail wrapper(AbstractMail::draftFolder()); 181 Storemail wrapper(AbstractMail::draftFolder());
180 wrapper.storeMail(mail); 182 wrapper.storeMail(mail);
181 183
182 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 184 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
183 /* attachments we will ignore! */ 185 /* attachments we will ignore! */
184 if ( it != 0 ) { 186 if ( it != 0 ) {
185 if ( warnAttach ) 187 if ( warnAttach )
186 QMessageBox::warning(0,i18n("Store message"), 188 QMessageBox::warning(0,i18n("Store message"),
187 i18n("<center>Attachments will not be stored in \"Draft\" folder</center>")); 189 i18n("<center>Attachments will not be stored in \"Draft\" folder</center>"));
188 warnAttach = false; 190 warnAttach = false;
189 } 191 }
190 setStatus( i18n("Mail saved as draft!") ); 192 setStatus( i18n("Mail saved as draft!") );
191} 193}
192void ComposeMail::clearStatus() 194void ComposeMail::clearStatus()
193{ 195{
194 topLevelWidget()->setCaption( i18n("Compose mail") ); 196 topLevelWidget()->setCaption( i18n("Compose mail") );
195} 197}
196void ComposeMail::setStatus( QString status ) 198void ComposeMail::setStatus( QString status )
197{ 199{
198 topLevelWidget()->setCaption( status ); 200 topLevelWidget()->setCaption( status );
199 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; 201 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ;
200} 202}
201void ComposeMail::pickAddress( ) 203void ComposeMail::pickAddress( )
202{ 204{
203 205
204 QLineEdit *line = mPickLineEdit; 206 QLineEdit *line = mPickLineEdit;
205 if ( line == 0 ) 207 if ( line == 0 )
206 return; 208 return;
207#ifdef DESKTOP_VERSION 209#ifdef DESKTOP_VERSION
208 //qDebug(" ComposeMail::pickAddress "); 210 //qDebug(" ComposeMail::pickAddress ");
209 QString names ;//= AddressPicker::getNames(); 211 QString names ;//= AddressPicker::getNames();
210 212
211 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 213 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
212 uint i=0; 214 uint i=0;
213 for (i=0; i < list.count(); i++) { 215 for (i=0; i < list.count(); i++) {
214 if ( !list[i].preferredEmail().isEmpty()) { 216 if ( !list[i].preferredEmail().isEmpty()) {