-rw-r--r-- | kmicromail/composemail.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp index 35ad367..5f7a76f 100644 --- a/kmicromail/composemail.cpp +++ b/kmicromail/composemail.cpp | |||
@@ -1,382 +1,396 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | 2 | ||
3 | #include "composemail.h" | 3 | #include "composemail.h" |
4 | 4 | ||
5 | #include <libmailwrapper/smtpwrapper.h> | 5 | #include <libmailwrapper/smtpwrapper.h> |
6 | #include <libmailwrapper/storemail.h> | 6 | #include <libmailwrapper/storemail.h> |
7 | #include <libmailwrapper/abstractmail.h> | 7 | #include <libmailwrapper/abstractmail.h> |
8 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
9 | 9 | ||
10 | /* OPIE */ | 10 | /* OPIE */ |
11 | //#include <opie2/ofiledialog.h> | 11 | //#include <opie2/ofiledialog.h> |
12 | //#include <opie2/odebug.h> | 12 | //#include <opie2/odebug.h> |
13 | #include <kfiledialog.h> | 13 | #include <kfiledialog.h> |
14 | //#include <qpe/resource.h> | 14 | //#include <qpe/resource.h> |
15 | #include <qpe/global.h> | 15 | #include <qpe/global.h> |
16 | //#include <qpe/contact.h> | 16 | //#include <qpe/contact.h> |
17 | 17 | ||
18 | 18 | ||
19 | #include <qcombobox.h> | 19 | #include <qcombobox.h> |
20 | #include <qcheckbox.h> | 20 | #include <qcheckbox.h> |
21 | #include <qiconset.h> | ||
21 | #include <qtimer.h> | 22 | #include <qtimer.h> |
22 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
23 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
24 | #include <qmultilineedit.h> | 25 | #include <qmultilineedit.h> |
25 | #include <qlabel.h> | 26 | #include <qlabel.h> |
26 | #include <qtabwidget.h> | 27 | #include <qtabwidget.h> |
27 | #include <qlistview.h> | 28 | #include <qlistview.h> |
28 | #include <kabc/addresseedialog.h> | 29 | #include <kabc/addresseedialog.h> |
29 | #include <kabc/stdaddressbook.h> | 30 | #include <kabc/stdaddressbook.h> |
30 | #include <kabc/addressee.h> | 31 | #include <kabc/addressee.h> |
31 | #ifdef DESKTOP_VERSION | 32 | #ifdef DESKTOP_VERSION |
32 | #include <kabc/addresseedialog.h> | 33 | #include <kabc/addresseedialog.h> |
33 | #else //DESKTOP_VERSION | 34 | #else //DESKTOP_VERSION |
34 | #include <libkdepim/externalapphandler.h> | 35 | #include <libkdepim/externalapphandler.h> |
35 | #endif //DESKTOP_VERSION | 36 | #endif //DESKTOP_VERSION |
36 | 37 | ||
37 | #include "koprefs.h" | 38 | #include "koprefs.h" |
38 | 39 | ||
39 | //using namespace Opie::Core; | 40 | //using namespace Opie::Core; |
40 | //using namespace Opie::Ui; | 41 | //using namespace Opie::Ui; |
41 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal ) | 42 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal ) |
42 | : ComposeMailUI( parent, name, modal ) | 43 | : ComposeMailUI( parent, name, modal ) |
43 | { | 44 | { |
44 | mPickLineEdit = 0; | 45 | mPickLineEdit = 0; |
45 | 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&)), |
46 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 47 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
47 | settings = s; | 48 | settings = s; |
48 | m_replyid = ""; | 49 | m_replyid = ""; |
49 | if ( KOPrefs::instance()->mUseKapi) { | 50 | if ( KOPrefs::instance()->mUseKapi) { |
50 | KConfig config( locateLocal("config", "kabcrc") ); | 51 | KConfig config( locateLocal("config", "kabcrc") ); |
51 | config.setGroup( "General" ); | 52 | config.setGroup( "General" ); |
52 | QString whoami_uid = config.readEntry( "WhoAmI" ); | 53 | QString whoami_uid = config.readEntry( "WhoAmI" ); |
53 | 54 | ||
54 | if ( whoami_uid.isEmpty() ) { | 55 | if ( whoami_uid.isEmpty() ) { |
55 | QMessageBox::information( 0, i18n( "Hint" ), | 56 | QMessageBox::information( 0, i18n( "Hint" ), |
56 | 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" ), |
57 | i18n( "Ok" ) ); | 58 | i18n( "Ok" ) ); |
58 | 59 | ||
59 | 60 | ||
60 | fillSettings(); | 61 | fillSettings(); |
61 | } else | 62 | } else |
62 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); | 63 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); |
63 | 64 | ||
64 | 65 | ||
65 | #ifdef DESKTOP_VERSION | 66 | #ifdef DESKTOP_VERSION |
66 | KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); | 67 | KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); |
67 | QStringList mails = con.emails(); | 68 | QStringList mails = con.emails(); |
68 | QString defmail = con.preferredEmail(); | 69 | QString defmail = con.preferredEmail(); |
69 | if ( mails.count() == 0) | 70 | if ( mails.count() == 0) |
70 | QMessageBox::information( 0, i18n( "Hint" ), | 71 | QMessageBox::information( 0, i18n( "Hint" ), |
71 | 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" ), |
72 | i18n( "Ok" ) ); | 73 | i18n( "Ok" ) ); |
73 | if (defmail.length()!=0) { | 74 | if (defmail.length()!=0) { |
74 | fromBox->insertItem(defmail); | 75 | fromBox->insertItem(defmail); |
75 | } | 76 | } |
76 | QStringList::ConstIterator sit = mails.begin(); | 77 | QStringList::ConstIterator sit = mails.begin(); |
77 | for (;sit!=mails.end();++sit) { | 78 | for (;sit!=mails.end();++sit) { |
78 | if ( (*sit)==defmail) | 79 | if ( (*sit)==defmail) |
79 | continue; | 80 | continue; |
80 | fromBox->insertItem((*sit)); | 81 | fromBox->insertItem((*sit)); |
81 | } | 82 | } |
82 | senderNameEdit->setText(con.formattedName()); | 83 | senderNameEdit->setText(con.formattedName()); |
83 | #endif | 84 | #endif |
84 | 85 | ||
85 | } else { | 86 | } else { |
86 | fillSettings(); | 87 | fillSettings(); |
87 | } | 88 | } |
88 | checkBoxLater->setChecked( KOPrefs::instance()->mSendLater ); | 89 | checkBoxLater->setChecked( KOPrefs::instance()->mSendLater ); |
89 | 90 | ||
90 | attList->addColumn( i18n( "Name" ) ); | 91 | attList->addColumn( i18n( "Name" ) ); |
91 | attList->addColumn( i18n( "Size" ) ); | 92 | attList->addColumn( i18n( "Size" ) ); |
92 | QList<Account> accounts = settings->getAccounts(); | 93 | QList<Account> accounts = settings->getAccounts(); |
93 | 94 | ||
94 | if ( QApplication::desktop()->width() < 320 ) | 95 | if ( QApplication::desktop()->width() < 320 ) |
95 | smtpAccountBox->setMaximumWidth( 80 ); | 96 | smtpAccountBox->setMaximumWidth( 80 ); |
96 | Account *it; | 97 | Account *it; |
97 | for ( it = accounts.first(); it; it = accounts.next() ) { | 98 | for ( it = accounts.first(); it; it = accounts.next() ) { |
98 | if ( it->getType()==MAILLIB::A_SMTP ) { | 99 | if ( it->getType()==MAILLIB::A_SMTP ) { |
99 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); | 100 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); |
100 | smtpAccountBox->insertItem( smtp->getAccountName() ); | 101 | smtpAccountBox->insertItem( smtp->getAccountName() ); |
101 | smtpAccounts.append( smtp ); | 102 | smtpAccounts.append( smtp ); |
102 | } | 103 | } |
103 | } | 104 | } |
104 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); | 105 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); |
105 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); | 106 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); |
106 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); | 107 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); |
107 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); | 108 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); |
108 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); | 109 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); |
109 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); | 110 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); |
110 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); | 111 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); |
111 | mMail = 0; | 112 | mMail = 0; |
112 | warnAttach = true; | 113 | warnAttach = true; |
114 | QIconSet icon; | ||
115 | //icon = SmallIcon("fileexport"); | ||
116 | icon = SmallIcon("filesave"); | ||
117 | SaveButton->setIconSet (icon ) ; | ||
118 | if ( QApplication::desktop()->width() < 320 ) { | ||
119 | SaveButton->setText ("") ; | ||
120 | SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ; | ||
121 | } | ||
122 | else | ||
123 | SaveButton->setText (i18n("Save")); | ||
124 | #ifndef DESKTOP_VERSION | ||
125 | QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); | ||
126 | QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold ); | ||
127 | QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold ); | ||
128 | #endif | ||
129 | message->setFont ( KOPrefs::instance()->mComposeFont ); | ||
130 | message->setWordWrap (QMultiLineEdit::WidgetWidth); | ||
113 | if ( smtpAccounts.count() > 0 ) { | 131 | if ( smtpAccounts.count() > 0 ) { |
114 | fillValues( smtpAccountBox->currentItem() ); | 132 | fillValues( smtpAccountBox->currentItem() ); |
115 | } else { | 133 | } else { |
116 | QMessageBox::information( 0, i18n( "Problem" ), | 134 | QMessageBox::information( 0, i18n( "Problem" ), |
117 | i18n( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ), | 135 | i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ), |
118 | i18n( "Ok" ) ); | 136 | i18n( "Ok" ) ); |
119 | return; | 137 | return; |
120 | } | 138 | } |
121 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); | 139 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); |
122 | message->setFont ( KOPrefs::instance()->mComposeFont ); | 140 | |
123 | message->setWordWrap (QMultiLineEdit::WidgetWidth); | ||
124 | #ifndef DESKTOP_VERSION | ||
125 | QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); | ||
126 | #endif | ||
127 | 141 | ||
128 | } | 142 | } |
129 | 143 | ||
130 | void ComposeMail::fillSettings() | 144 | void ComposeMail::fillSettings() |
131 | { | 145 | { |
132 | if ( QApplication::desktop()->width() < 320 ) | 146 | if ( QApplication::desktop()->width() < 320 ) |
133 | fromBox->setMaximumWidth( 100 ); | 147 | fromBox->setMaximumWidth( 100 ); |
134 | QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); | 148 | QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); |
135 | QStringList::ConstIterator sit = mailList.begin(); | 149 | QStringList::ConstIterator sit = mailList.begin(); |
136 | int pref = 0; | 150 | int pref = 0; |
137 | for (;sit!=mailList.end();++sit) { | 151 | for (;sit!=mailList.end();++sit) { |
138 | fromBox->insertItem((*sit)); | 152 | fromBox->insertItem((*sit)); |
139 | } | 153 | } |
140 | senderNameEdit->setText(KOPrefs::instance()->mName); | 154 | senderNameEdit->setText(KOPrefs::instance()->mName); |
141 | } | 155 | } |
142 | 156 | ||
143 | 157 | ||
144 | void ComposeMail::saveAsDraft() | 158 | void ComposeMail::saveAsDraft() |
145 | { | 159 | { |
146 | 160 | ||
147 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); | 161 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); |
148 | mail->setMail(fromBox->currentText()); | 162 | mail->setMail(fromBox->currentText()); |
149 | mail->setTo( toLine->text() ); | 163 | mail->setTo( toLine->text() ); |
150 | mail->setName(senderNameEdit->text()); | 164 | mail->setName(senderNameEdit->text()); |
151 | mail->setCC( ccLine->text() ); | 165 | mail->setCC( ccLine->text() ); |
152 | mail->setBCC( bccLine->text() ); | 166 | mail->setBCC( bccLine->text() ); |
153 | mail->setReply( replyLine->text() ); | 167 | mail->setReply( replyLine->text() ); |
154 | mail->setSubject( subjectLine->text() ); | 168 | mail->setSubject( subjectLine->text() ); |
155 | if (!m_replyid.isEmpty()) { | 169 | if (!m_replyid.isEmpty()) { |
156 | QStringList ids; | 170 | QStringList ids; |
157 | ids.append(m_replyid); | 171 | ids.append(m_replyid); |
158 | mail->setInreply(ids); | 172 | mail->setInreply(ids); |
159 | } | 173 | } |
160 | QString txt = message->text(); | 174 | QString txt = message->text(); |
161 | if ( !sigMultiLine->text().isEmpty() ) { | 175 | if ( !sigMultiLine->text().isEmpty() ) { |
162 | txt.append( "\n--\n" ); | 176 | txt.append( "\n--\n" ); |
163 | txt.append( sigMultiLine->text() ); | 177 | txt.append( sigMultiLine->text() ); |
164 | } | 178 | } |
165 | mail->setMessage( txt ); | 179 | mail->setMessage( txt ); |
166 | 180 | ||
167 | /* only use the default drafts folder name! */ | 181 | /* only use the default drafts folder name! */ |
168 | Storemail wrapper(AbstractMail::draftFolder()); | 182 | Storemail wrapper(AbstractMail::draftFolder()); |
169 | wrapper.storeMail(mail); | 183 | wrapper.storeMail(mail); |
170 | 184 | ||
171 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 185 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
172 | /* attachments we will ignore! */ | 186 | /* attachments we will ignore! */ |
173 | if ( it != 0 ) { | 187 | if ( it != 0 ) { |
174 | if ( warnAttach ) | 188 | if ( warnAttach ) |
175 | QMessageBox::warning(0,i18n("Store message"), | 189 | QMessageBox::warning(0,i18n("Store message"), |
176 | i18n("<center>Attachments will not be stored in \"Draft\" folder</center>")); | 190 | i18n("<center>Attachments will not be stored in \"Draft\" folder</center>")); |
177 | warnAttach = false; | 191 | warnAttach = false; |
178 | } | 192 | } |
179 | setStatus( i18n("Mail saved as draft!") ); | 193 | setStatus( i18n("Mail saved as draft!") ); |
180 | } | 194 | } |
181 | void ComposeMail::clearStatus() | 195 | void ComposeMail::clearStatus() |
182 | { | 196 | { |
183 | topLevelWidget()->setCaption( i18n("Compose mail") ); | 197 | topLevelWidget()->setCaption( i18n("Compose mail") ); |
184 | } | 198 | } |
185 | void ComposeMail::setStatus( QString status ) | 199 | void ComposeMail::setStatus( QString status ) |
186 | { | 200 | { |
187 | topLevelWidget()->setCaption( status ); | 201 | topLevelWidget()->setCaption( status ); |
188 | QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; | 202 | QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; |
189 | } | 203 | } |
190 | void ComposeMail::pickAddress( ) | 204 | void ComposeMail::pickAddress( ) |
191 | { | 205 | { |
192 | 206 | ||
193 | QLineEdit *line = mPickLineEdit; | 207 | QLineEdit *line = mPickLineEdit; |
194 | if ( line == 0 ) | 208 | if ( line == 0 ) |
195 | return; | 209 | return; |
196 | #ifdef DESKTOP_VERSION | 210 | #ifdef DESKTOP_VERSION |
197 | //qDebug(" ComposeMail::pickAddress "); | 211 | //qDebug(" ComposeMail::pickAddress "); |
198 | QString names ;//= AddressPicker::getNames(); | 212 | QString names ;//= AddressPicker::getNames(); |
199 | 213 | ||
200 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 214 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
201 | uint i=0; | 215 | uint i=0; |
202 | for (i=0; i < list.count(); i++) { | 216 | for (i=0; i < list.count(); i++) { |
203 | if ( !list[i].preferredEmail().isEmpty()) { | 217 | if ( !list[i].preferredEmail().isEmpty()) { |
204 | if ( ! names.isEmpty() ) | 218 | if ( ! names.isEmpty() ) |
205 | names+= ","; | 219 | names+= ","; |
206 | names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; | 220 | names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; |
207 | 221 | ||
208 | } | 222 | } |
209 | } | 223 | } |
210 | 224 | ||
211 | 225 | ||
212 | if ( line->text().isEmpty() ) { | 226 | if ( line->text().isEmpty() ) { |
213 | line->setText( names ); | 227 | line->setText( names ); |
214 | } else if ( !names.isEmpty() ) { | 228 | } else if ( !names.isEmpty() ) { |
215 | line->setText( line->text() + ", " + names ); | 229 | line->setText( line->text() + ", " + names ); |
216 | } | 230 | } |
217 | #else | 231 | #else |
218 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); | 232 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/ompi", this->name() /* name is here the unique uid*/); |
219 | // the result should now arrive through method insertAttendees | 233 | // the result should now arrive through method insertAttendees |
220 | #endif | 234 | #endif |
221 | } | 235 | } |
222 | //the map includes name/email pairs, that comes from Ka/Pi | 236 | //the map includes name/email pairs, that comes from Ka/Pi |
223 | void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) | 237 | void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) |
224 | { | 238 | { |
225 | //qDebug("ComposeMail::insertAttendees "); | 239 | //qDebug("ComposeMail::insertAttendees "); |
226 | raise(); | 240 | raise(); |
227 | 241 | ||
228 | if ( mPickLineEdit == 0 ) { //whoami received | 242 | if ( mPickLineEdit == 0 ) { //whoami received |
229 | QString defmail = uidList[0]; | 243 | QString defmail = uidList[0]; |
230 | if ( emailList.count() == 0 ) | 244 | if ( emailList.count() == 0 ) |
231 | QMessageBox::information( 0, i18n( "Hint" ), | 245 | QMessageBox::information( 0, i18n( "Hint" ), |
232 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 246 | i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
233 | i18n( "Ok" ) ); | 247 | i18n( "Ok" ) ); |
234 | if (defmail.length()!=0) { | 248 | if (defmail.length()!=0) { |
235 | fromBox->insertItem(defmail); | 249 | fromBox->insertItem(defmail); |
236 | } | 250 | } |
237 | QStringList::ConstIterator sit = emailList.begin(); | 251 | QStringList::ConstIterator sit = emailList.begin(); |
238 | int pref = 0; | 252 | int pref = 0; |
239 | for (;sit!=emailList.end();++sit) { | 253 | for (;sit!=emailList.end();++sit) { |
240 | if ( (*sit)==defmail) | 254 | if ( (*sit)==defmail) |
241 | continue; | 255 | continue; |
242 | fromBox->insertItem((*sit)); | 256 | fromBox->insertItem((*sit)); |
243 | } | 257 | } |
244 | senderNameEdit->setText(nameList[0]); | 258 | senderNameEdit->setText(nameList[0]); |
245 | return; | 259 | return; |
246 | } | 260 | } |
247 | QString names ; | 261 | QString names ; |
248 | QLineEdit *line = mPickLineEdit; | 262 | QLineEdit *line = mPickLineEdit; |
249 | if (uid == this->name()) | 263 | if (uid == this->name()) |
250 | { | 264 | { |
251 | for ( int i = 0; i < nameList.count(); i++) | 265 | for ( int i = 0; i < nameList.count(); i++) |
252 | { | 266 | { |
253 | QString _name = nameList[i]; | 267 | QString _name = nameList[i]; |
254 | QString _email = emailList[i]; | 268 | QString _email = emailList[i]; |
255 | QString _uid = uidList[i]; | 269 | QString _uid = uidList[i]; |
256 | if ( ! _email.isEmpty() ) { | 270 | if ( ! _email.isEmpty() ) { |
257 | if ( ! names.isEmpty() ) | 271 | if ( ! names.isEmpty() ) |
258 | names+= ","; | 272 | names+= ","; |
259 | names+= "\""+_name +"\"<" +_email +">"; | 273 | names+= "\""+_name +"\"<" +_email +">"; |
260 | } | 274 | } |
261 | } | 275 | } |
262 | } | 276 | } |
263 | if ( line->text().isEmpty() ) { | 277 | if ( line->text().isEmpty() ) { |
264 | line->setText( names ); | 278 | line->setText( names ); |
265 | } else if ( !names.isEmpty() ) { | 279 | } else if ( !names.isEmpty() ) { |
266 | line->setText( line->text() + ", " + names ); | 280 | line->setText( line->text() + ", " + names ); |
267 | } | 281 | } |
268 | } | 282 | } |
269 | 283 | ||
270 | void ComposeMail::setTo( const QString & to ) | 284 | void ComposeMail::setTo( const QString & to ) |
271 | { | 285 | { |
272 | toLine->setText( to ); | 286 | toLine->setText( to ); |
273 | } | 287 | } |
274 | 288 | ||
275 | void ComposeMail::setSubject( const QString & subject ) | 289 | void ComposeMail::setSubject( const QString & subject ) |
276 | { | 290 | { |
277 | subjectLine->setText( subject ); | 291 | subjectLine->setText( subject ); |
278 | } | 292 | } |
279 | 293 | ||
280 | void ComposeMail::setInReplyTo( const QString & messageId ) | 294 | void ComposeMail::setInReplyTo( const QString & messageId ) |
281 | { | 295 | { |
282 | m_replyid = messageId; | 296 | m_replyid = messageId; |
283 | } | 297 | } |
284 | 298 | ||
285 | void ComposeMail::setMessage( const QString & text ) | 299 | void ComposeMail::setMessage( const QString & text ) |
286 | { | 300 | { |
287 | message->setText( text ); | 301 | message->setText( text ); |
288 | } | 302 | } |
289 | 303 | ||
290 | 304 | ||
291 | void ComposeMail::pickAddressTo() | 305 | void ComposeMail::pickAddressTo() |
292 | { | 306 | { |
293 | mPickLineEdit = toLine; | 307 | mPickLineEdit = toLine; |
294 | pickAddress( ); | 308 | pickAddress( ); |
295 | } | 309 | } |
296 | 310 | ||
297 | void ComposeMail::pickAddressCC() | 311 | void ComposeMail::pickAddressCC() |
298 | { | 312 | { |
299 | mPickLineEdit = ccLine; | 313 | mPickLineEdit = ccLine; |
300 | pickAddress( ); | 314 | pickAddress( ); |
301 | } | 315 | } |
302 | 316 | ||
303 | void ComposeMail::pickAddressBCC() | 317 | void ComposeMail::pickAddressBCC() |
304 | { | 318 | { |
305 | mPickLineEdit = bccLine; | 319 | mPickLineEdit = bccLine; |
306 | pickAddress( ); | 320 | pickAddress( ); |
307 | } | 321 | } |
308 | 322 | ||
309 | void ComposeMail::pickAddressReply() | 323 | void ComposeMail::pickAddressReply() |
310 | { | 324 | { |
311 | mPickLineEdit = replyLine; | 325 | mPickLineEdit = replyLine; |
312 | pickAddress( ); | 326 | pickAddress( ); |
313 | } | 327 | } |
314 | 328 | ||
315 | void ComposeMail::fillValues( int ) | 329 | void ComposeMail::fillValues( int ) |
316 | { | 330 | { |
317 | #if 0 | 331 | #if 0 |
318 | SMTPaccount *smtp = smtpAccounts.at( current ); | 332 | SMTPaccount *smtp = smtpAccounts.at( current ); |
319 | ccLine->clear(); | 333 | ccLine->clear(); |
320 | if ( smtp->getUseCC() ) { | 334 | if ( smtp->getUseCC() ) { |
321 | ccLine->setText( smtp->getCC() ); | 335 | ccLine->setText( smtp->getCC() ); |
322 | } | 336 | } |
323 | bccLine->clear(); | 337 | bccLine->clear(); |
324 | if ( smtp->getUseBCC() ) { | 338 | if ( smtp->getUseBCC() ) { |
325 | bccLine->setText( smtp->getBCC() ); | 339 | bccLine->setText( smtp->getBCC() ); |
326 | } | 340 | } |
327 | replyLine->clear(); | 341 | replyLine->clear(); |
328 | if ( smtp->getUseReply() ) { | 342 | if ( smtp->getUseReply() ) { |
329 | replyLine->setText( smtp->getReply() ); | 343 | replyLine->setText( smtp->getReply() ); |
330 | } | 344 | } |
331 | sigMultiLine->setText( smtp->getSignature() ); | 345 | sigMultiLine->setText( smtp->getSignature() ); |
332 | #endif | 346 | #endif |
333 | } | 347 | } |
334 | 348 | ||
335 | void ComposeMail::slotAdjustColumns() | 349 | void ComposeMail::slotAdjustColumns() |
336 | { | 350 | { |
337 | int currPage = tabWidget->currentPageIndex(); | 351 | int currPage = tabWidget->currentPageIndex(); |
338 | 352 | ||
339 | tabWidget->showPage( attachTab ); | 353 | tabWidget->showPage( attachTab ); |
340 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); | 354 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); |
341 | attList->setColumnWidth( 1, 80 ); | 355 | attList->setColumnWidth( 1, 80 ); |
342 | 356 | ||
343 | tabWidget->setCurrentPage( currPage ); | 357 | tabWidget->setCurrentPage( currPage ); |
344 | } | 358 | } |
345 | 359 | ||
346 | void ComposeMail::addAttachment() | 360 | void ComposeMail::addAttachment() |
347 | { | 361 | { |
348 | QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); | 362 | QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); |
349 | if ( !lnk.isEmpty() ) { | 363 | if ( !lnk.isEmpty() ) { |
350 | Attachment *att = new Attachment( lnk ); | 364 | Attachment *att = new Attachment( lnk ); |
351 | (void) new AttachViewItem( attList, att ); | 365 | (void) new AttachViewItem( attList, att ); |
352 | } | 366 | } |
353 | } | 367 | } |
354 | 368 | ||
355 | void ComposeMail::removeAttachment() | 369 | void ComposeMail::removeAttachment() |
356 | { | 370 | { |
357 | if ( !attList->currentItem() ) { | 371 | if ( !attList->currentItem() ) { |
358 | QMessageBox::information( this, i18n( "Error" ), | 372 | QMessageBox::information( this, i18n( "Error" ), |
359 | i18n( "<p>Please select a File.</p>" ), | 373 | i18n( "<p>Please select a File.</p>" ), |
360 | i18n( "Ok" ) ); | 374 | i18n( "Ok" ) ); |
361 | } else { | 375 | } else { |
362 | attList->takeItem( attList->currentItem() ); | 376 | attList->takeItem( attList->currentItem() ); |
363 | } | 377 | } |
364 | } | 378 | } |
365 | 379 | ||
366 | void ComposeMail::accept() | 380 | void ComposeMail::accept() |
367 | { | 381 | { |
368 | if ( smtpAccountBox->count() == 0 ) { | 382 | if ( smtpAccountBox->count() == 0 ) { |
369 | 383 | ||
370 | reject(); | 384 | reject(); |
371 | return; | 385 | return; |
372 | } | 386 | } |
373 | 387 | ||
374 | if (! checkBoxLater->isChecked() ) { | 388 | if (! checkBoxLater->isChecked() ) { |
375 | int yesno = QMessageBox::warning(0,i18n("Stop editing message"), | 389 | int yesno = QMessageBox::warning(0,i18n("Stop editing message"), |
376 | i18n("Send this message?"), | 390 | i18n("Send this message?"), |
377 | i18n("Yes"), | 391 | i18n("Yes"), |
378 | i18n("Cancel")); | 392 | i18n("Cancel")); |
379 | 393 | ||
380 | if (yesno == 1) { | 394 | if (yesno == 1) { |
381 | return; | 395 | return; |
382 | } | 396 | } |